PageSourceSearch

https://app.racedata.ai/_next/static/chunks/211-35a98c9bb4ff8120.js

js racedata.ai collected 2026-10-05 14:14:18 UTC 54,869 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[211],{82700:function(e,t,l){l.d(t,{$F:function(){return n},LN:function(){return r}});let n=[{label:"UTC -12:00",value:"utc-12"},{label:"UTC -11:00",value:"utc-11"},{label:"UTC -10:00",value:"utc-10"},{label:"UTC -9:00",value:"utc-9"},{label:"UTC -8:00",value:"utc-8"},{label:"UTC -7:00",value:"utc-7"},{label:"UTC -6:00",value:"utc-6"},{label:"UTC -5:00",value:"utc-5"},{label:"UTC -4:00",value:"utc-4"},{label:"UTC -3:00",value:"utc-3"},{label:"UTC -2:00",value:"utc-2"},{label:"UTC -1:00",value:"utc-1"},{label:"UTC +0:00 (GMT)",value:"utc+0"},{label:"UTC +1:00",value:"utc+1"},{label:"UTC +2:00",value:"utc+2"},{label:"UTC +3:00",value:"utc+3"},{label:"UTC +4:00",value:"utc+4"},{label:"UTC +5:00",value:"utc+5"},{label:"UTC +6:00",value:"utc+6"},{label:"UTC +7:00",value:"utc+7"},{label:"UTC +8:00",value:"utc+8"},{label:"UTC +9:00",value:"utc+9"},{label:"UTC +10:00",value:"utc+10"},{label:"UTC +11:00",value:"utc+11"},{label:"UTC +12:00",value:"utc+12"}],r={kmh:3.6,mph:2.23}},211:function(e,t,l){l.d(t,{S:function(){return _},m:function(){return h}});var n=l(57437),r=l(82248);l(83079);var i=(0,l(12119).$)("1fefba84690962f1a556f48059b198a96bb33dbf"),o=l(93448),a=l(21652),u=l.n(a),s=l(80605),d=l(43880),c=l(99376),m=l(2265),p=l(17200);let f=(0,m.createContext)(void 0),_=e=>{var t,l,a,_,h,v,g,b,x,z,M,S,y,F,C;let{children:L}=e,T=(0,m.useMemo)(()=>({scaleX:1,scaleZ:1,rotationDeg:0,offsetX:0,offsetZ:0}),[]),k=(0,c.useRouter)(),R=(0,c.useSearchParams)(),N=null==R?void 0:R.get("rl"),w=null==R?void 0:R.get("cl"),P=null==R?void 0:R.get("t"),I=null==R?void 0:R.get("mode"),{data:O,status:D}=(0,s.useSession)(),[A,q]=(0,m.useState)(),U=(0,d.G)(),W=null!==(S=null==O?void 0:null===(l=O.user)||void 0===l?void 0:null===(t=l.preferences)||void 0===t?void 0:t.speedUnit)&&void 0!==S?S:"kmh",[j,E]=(0,m.useState)(!!I&&"single"===I),[Z,X]=(0,m.useState)(),[G,B]=(0,m.useState)(!1),[V,H]=(0,m.useState)(!1),[$,J]=(0,m.useState)(!1),[Q,K]=(0,m.useState)(),[Y,ee]=(0,m.useState)(),[et,el]=(0,m.useState)(),[en,er]=(0,m.useState)(),[ei,eo]=(0,m.useState)(),[ea,eu]=(0,m.useState)(),[es,ed]=(0,m.useState)(),[ec,em]=(0,m.useState)(),[ep,ef]=(0,m.useState)({speedData:[],diffData:[],diffDataInMeters:[],throttleData:[],brakeData:[],rpmData:[],gearData:[],steeringData:[],fuelData:[],startRefTime:0,startCompTime:0,extremePoints:null}),[e_,eh]=(0,m.useState)(!1),[ev,eg]=(0,m.useState)(!1),[eb,ex]=(0,m.useState)(),[ez,eM]=(0,m.useState)(),[eS,ey]=(0,m.useState)(),[eF,eC]=(0,m.useState)(),[eL,eT]=(0,m.useState)(0),[ek,eR]=(0,m.useState)({}),[eN,ew]=(0,m.useState)({}),[eP,eI]=(0,m.useState)("position"),[eO,eD]=(0,m.useState)(null),[eA,eq]=(0,m.useState)(!0),[eU,eW]=(0,m.useState)(!0),[ej,eE]=(0,m.useState)(!0),[eZ,eX]=(0,m.useState)(0),[eG,eB]=(0,m.useState)(0),[eV,eH]=(0,m.useState)(null),[e$,eJ]=(0,m.useState)(null),eQ=(0,m.useMemo)(()=>{let e=null!=N?N:"single"===I?w:null;return e&&w?e===w:!!(e$&&eV&&e$._id===eV._id)},[N,w,I,e$,eV]),[eK,eY]=(0,m.useState)([]),[e0,e1]=(0,m.useState)([]),[e2,e3]=(0,m.useState)([]),[e9,e5]=(0,m.useState)([]),[e8,e4]=(0,m.useState)([]),[e6,e7]=(0,m.useState)(null),[te,tt]=(0,m.useState)(!1),[tl,tn]=(0,m.useState)(T),{data:tr,isValidating:ti}=(0,p.ZP)("loading"!==D&&N&&"null"!==N?U?["/api/v1/session/lap-telemetry?lapId=".concat(N),U]:["/api/v1/session/demo-lap-telemetry?lapId=".concat(N),null]:null,e=>{let[t,l]=e;return(0,o.bC)(t,l)},{revalidateOnFocus:!1}),{data:to,isValidating:ta}=(0,p.ZP)("loading"!==D&&w&&"null"!==w?U?["/api/v1/session/lap-telemetry?lapId=".concat(w),U]:["/api/v1/session/demo-lap-telemetry?lapId=".concat(w),null]:null,e=>{let[t,l]=e;return(0,o.bC)(t,l)},{revalidateOnFocus:!1}),tu=null==tr?void 0:null===(a=tr.data)||void 0===a?void 0:a.lapMeta,ts=null==to?void 0:null===(_=to.data)||void 0===_?void 0:_.lapMeta,td=null==tu?void 0:tu.trackId,tc=null==ts?void 0:ts.trackId,tm=null==tu?void 0:tu.gameId,tp=null==ts?void 0:ts.gameId,tf=!!tm&&!!tp&&(null==tm?void 0:null===(h=tm.toString)||void 0===h?void 0:h.call(tm))!==(null==tp?void 0:null===(v=tp.toString)||void 0===v?void 0:v.call(tp)),t_=e=>e&&"function"==typeof e.toString?e.toString():"string"==typeof e?e:null,th=t_(td),tv=t_(tc),tg=t_(tm),tb=t_(tp),tx=!!P&&(P===th||P===tv),tz=P&&!tx?P:null,{data:tM,error:tS}=(0,p.ZP)("loading"!==D&&tz?U?["/api/v1/track/combined-tracks/".concat(tz),U]:["/api/v1/track/combined-tracks/".concat(tz),void 0]:null,e=>{let[t,l]=e;return(0,o.bC)(t,l)},{revalidateOnFocus:!1,shouldRetryOnError:!1}),ty=t_(null!==(y=null==tM?void 0:null===(b=tM.data)||void 0===b?void 0:null===(g=b.canonical_track)||void 0===g?void 0:g._id)&&void 0!==y?y:null==tM?void 0:null===(x=tM.data)||void 0===x?void 0:x.canonical_track),tF=!tz||ty||tS?null!=ty?ty:tz&&null!==(F=null!=th?th:tv)&&void 0!==F?F:P:null,tC=Array.isArray(null==tM?void 0:null===(z=tM.data)||void 0===z?void 0:z.tracks)?tM.data.tracks:[],tL=tC.map(e=>{var t;return t_(null!==(t=null==e?void 0:e._id)&&void 0!==t?t:e)}
1).filter(Boolean),tT=tC.find(e=>{var t;return t_(null!==(t=null==e?void 0:e._id)&&void 0!==t?t:e)===tF}),tk=t_(null!==(C=null==tT?void 0:null===(M=tT.game)||void 0===M?void 0:M._id)&&void 0!==C?C:null==tT?void 0:tT.game),tR=tF===th,tN=tF===tv,tw=!!tk&&tk===tg,tP=!!tk&&tk===tb,tI=!!th&&tL.includes(th),tO=!!tv&&tL.includes(tv),tD=tf&&!!td&&!!tc&&(tR||!tN&&(tw||!tP&&tI&&!tO)),tA=tf&&td&&tc?tD?tc:td:null,{data:tq}=(0,p.ZP)("loading"!==D&&tF?U?["/api/v1/track/lines?trackId=".concat(tF),U]:["/api/v1/track/demo-lines?trackId=".concat(tF),null]:null,e=>{let[t,l]=e;return(0,o.bC)(t,l)},{revalidateOnFocus:!1}),{data:tU}=(0,p.ZP)("loading"!==D&&tF?U?["/api/v1/track/get?trackId=".concat(tF),U]:["/api/v1/track/demo-get?trackId=".concat(tF),null]:null,e=>{let[t,l]=e;return(0,o.bC)(t,l)},{revalidateOnFocus:!1});function tW(e,t){return e=>t(e)}let tj=tW("setRefLapTelemetry",ex),tE=tW("setCompLapTelemetry",eM),tZ=tW("setTrackDetails",ey),tX=tW("setSelectedSegment",eC),tG=tW("setStep",eT),tB=tW("setRefStep",eX),tV=tW("setCompStep",eB),tH=tW("setCurrentValueRef",eR),t$=tW("setCurrentValueComp",ew),tJ=tW("setRefFastestPoint",K),tQ=tW("setCompFastestPoint",ee),tK=tW("setRefSlowestPoint",el),tY=tW("setCompSlowestPoint",er),t0=tW("setCompPointWhenRefFastest",eo),t1=tW("setCompPointWhenRefSlowest",eu),t2=tW("setRefPointWhenCompFastest",ed),t3=tW("setRefPointWhenCompSlowest",em),t9=tW("setCompLap",eH),t5=tW("setRefLap",eJ),t8=tW("setChartData",ef),t4=tW("setIsGhostDriverActive",eq),t6=tW("setIsDriverFocused",eW),t7=tW("setCanChangeGhostMode",eE),le=tW("setAllowSingleLapAnalysis",E),lt=tW("setIsMap",X),ll=tW("setCanSeeMapView",H),ln=tW("setIsAutoplayActive",J),lr=tW("handleIsAdvancedZoomActive",B),li=tW("setIsChartHovering",tt),lo=tW("setIsPlaying",eh),la=(0,m.useMemo)(()=>({refLapTelemetry:eb,compLapTelemetry:ez,trackDetails:eS,selectedSegment:eF,step:eL,refStep:eZ,compStep:eG,brakeComparison:e6,currentValueRef:ek,currentValueComp:eN,refFastestPoint:Q,compFastestPoint:Y,refSlowestPoint:et,compSlowestPoint:en,isGhostDriverActive:eA,isDriverFocused:eU,compPointWhenRefFastest:ei,compPointWhenRefSlowest:ea,refPointWhenCompFastest:es,refPointWhenCompSlowest:ec,canChangeGhostMode:ej,refLapLinesData:tr,compLapLinesData:to,trackLinesData:tq,trackDetailsData:tU,isRefLapLoading:ti,isCompLapLoading:ta,isDataReady:ev,chartData:ep,isBaseRef:tD,isIRacingManualScaleAvailable:tf,crossGameManualScale:tl,setCrossGameManualScale:tn,resetCrossGameManualScale:()=>tn(T),setRefLapTelemetry:tj,setCompLapTelemetry:tE,setTrackDetails:tZ,setSelectedSegment:tX,setStep:tG,setRefStep:tB,setCompStep:tV,setCurrentValueRef:tH,setCurrentValueComp:t$,setRefFastestPoint:tJ,setCompFastestPoint:tQ,setRefSlowestPoint:tK,setCompSlowestPoint:tY,setIsGhostDriverActive:t4,setIsDriverFocused:t6,setCompPointWhenRefFastest:t0,setCompPointWhenRefSlowest:t1,setRefPointWhenCompFastest:t2,setRefPointWhenCompSlowest:t3,setCanChangeGhostMode:t7,compLap:eV,setCompLap:t9,refLap:e$,setRefLap:t5,setChartData:t8,allowSingleLapAnalysis:j,setAllowSingleLapAnalysis:le,isSingleLapAnalysis:eQ,isMap:Z,setIsMap:lt,canSeeMapView:V,setCanSeeMapView:ll,isAutoplayActive:$,setIsAutoplayActive:ln,isAdvancedZoomActive:G,handleIsAdvancedZoomActive:lr,isChartHovering:te,setIsChartHovering:li,isPlaying:e_,setIsPlaying:lo,lapsData:A,setLapsData:q,refBrakingZones:eK,compBrakingZones:e0,refThrottleZones:e2,compThrottleZones:e9,minimumSpeedPoints:e8,isCrossGameCompare:tf,analysisDomain:eP,setAnalysisDomain:eI,currentAnalysisTime:eO,setCurrentAnalysisTime:eD}),[eb,ez,eS,eF,eL,eZ,eG,ek,eN,Q,Y,et,en,eA,eU,ei,ea,es,ec,ej,tr,to,tq,tU,ti,ta,ev,ep,tD,tf,tl,T,eV,e$,j,eQ,Z,V,$,G,te,e_,A,eK,e0,e2,e3,e9,e5,e8,e4,tf,eP,eO]);return(0,m.useEffect)(()=>{eJ(null),(null==tU?void 0:tU.data)&&ey(tU.data)},[tU,ey]),(0,m.useEffect)(()=>{if(!tr||!to)return;if(401===tr.statusCode||401===to.statusCode){k.push("/dashboard/stints");return}let e=!1;return(async()=>{if(!tf)return(0,r.TK)({refLapLinesData:tr,compLapLinesData:to,isGhostDriverActive:eA});if(!tF||!tA||!N||!w)return eg(!1),null;let e=await i({accessToken:null!=U?U:void 0,isDemo:!U,refLapId:N,compLapId:w,baseTrackId:tF,srcTrackId:tA,isBaseRef:tD,isGhostDriverActive:eA,refLapMeta:"number"==typeof(null==e$?void 0:e$.lap_time)&&Number.isFinite(e$.lap_time)?{lap_time:e$.lap_time}:tu,compLapMeta:"number"==typeof(null==eV?void 0:eV.lap_time)&&Number.isFinite(eV.lap_time)?{lap_time:eV.lap_time}:ts,manualAlignment:tl});return e.data?e.data:(eg(!1),null)})().then(t=>{if(e||!t)return;let{filteredRefLap:l,filteredCompLap:n}=t;if(tf&&"1"===window.localStorage.getItem("rd_crossgame_debug")){var i,o,a,s,d,c,m,p,f,_,h,v,g,b;let e=e=>{var t,l,n,r,i,o,a,u,s,d,c,m,p,f,_;return{id:null!==(i=null!==(r=null==e?void 0:e._id)&&void 0!==r?r:null==e?void 0:e.id)&&void 0!==i?i:null,name:null!==(o=null==e?void 0:e.name)&&void 0!==o?o:null,slug:null!==(a=null==e?void 0:e.slug)&&void 0!==a?a:null,gameId:null!==(s=null!==(u=null==e?void 0:null===(t=e.game)||void 0===t?void 0:t._id)&&void 0!==u?u:null==e?void 0:e.gameId)&&void 0!==s?s:null,gameSlug:null!==(p=null!==(m=null!==(c=null!==(d=null==e?void 0:null===(l=e.game)||void 0===l?void 0:l.slug)&&void 0!==d?d:null==e?void 0:null===(n=e.game)||void 0===n?void 0:n.name)&&void 0!==c?c:null==e?void 0:e.gameSlug)&&void 0!==m?m:null==e?void 0:e.game_name)&&void 0!==p?p:null,leftCount:Array.isArray(null==e?void 0:e.left_line)?e.left_line.length:null,rightCount:Array.isArray(null==e?void 0:e.right_line)?e.right_line.length:null,scaleFactor:null!==(f=null==e?void 0:e.scale_factor)&&void 0!==f?f:null,distance:null!==(_=null==e?void 0:e.distance)&&void 0!==_?_:null,segmentCount:Array.isArray(null==e?void 0:e.segment_separators)?e.segment_separators.length:null}},t=e=>({side:e,lapId:"ref"===e?N:w,trackId:"ref"===e?th:tv,gameId:"ref"===e?tg:tb}),r=e=>{var t,l;return e?{n:e.car_position_normalized,cn:e.compare_normalized,x:e.car_coord_x,z:e.car_coord_z,lap_time:e.lap_time,q:e.compare_quality,extrapolated:null!==(t=e.__rd_compare_extrapolated)&&void 0!==t?t:null,extrapolatedSide:null!==(l=e.__rd_compare_extrapolated_side)&&void 0!==l?l:null}:null},u=e=>{let t=e.map(e=>null==e?void 0:e.car_coord_x).filter(e=>"number"==typeof e),l=e.map(e=>null==e?void 0:e.car_coord_z).filter(e=>"number"==typeof e);return{count:e.length,first:r(e[0]),mid:r(e[Math.floor(e.length/2)]),last:r(e[e.length-1]),bounds:t.length&&l.length?{minX:Math.min(...t),maxX:Math.max(...t),minZ:Math.min(...l),maxZ:Math.max(...l)}:null}},x={at:new Date().toISOString(),query:{requestedTrackId:P,analysisTrackId:tF,otherTrackId:tA,accesToken:U,combinedTrackLookupId:tz,comb
1inedCanonicalTrackId:ty},resolution:{requestedTrackMatchesLap:tx,analysisTrackMatchesRef:tR,analysisTrackMatchesComp:tN,analysisTrackGameId:tk,analysisTrackGameMatchesRef:tw,analysisTrackGameMatchesComp:tP,analysisTrackCombinedMatchesRef:tI,analysisTrackCombinedMatchesComp:tO},compare:{isBaseRef:tD,baseLap:t(tD?"ref":"comp"),srcLap:t(tD?"comp":"ref"),baseTrack:e(null==tq?void 0:tq.data),srcTrack:e({_id:tA}),trackDetails:e(null==tU?void 0:tU.data),scaleFactorAppliedInTrackView:!1},combinedTrack:{id:null!==(p=null==tM?void 0:null===(i=tM.data)||void 0===i?void 0:i._id)&&void 0!==p?p:null,name:null!==(f=null==tM?void 0:null===(o=tM.data)||void 0===o?void 0:o.name)&&void 0!==f?f:null,slug:null!==(_=null==tM?void 0:null===(a=tM.data)||void 0===a?void 0:a.slug)&&void 0!==_?_:null,canonicalTrack:null!==(h=null==tM?void 0:null===(s=tM.data)||void 0===s?void 0:s.canonical_track)&&void 0!==h?h:null,tracks:null!==(v=null==tM?void 0:null===(m=tM.data)||void 0===m?void 0:null===(c=m.tracks)||void 0===c?void 0:null===(d=c.map)||void 0===d?void 0:d.call(c,e=>{var t,l,n,r,i,o,a,u,s,d;return{id:null!==(r=null==e?void 0:e._id)&&void 0!==r?r:e,name:null!==(i=null==e?void 0:e.name)&&void 0!==i?i:null,slug:null!==(o=null==e?void 0:e.slug)&&void 0!==o?o:null,gameId:null!==(u=null!==(a=null==e?void 0:null===(t=e.game)||void 0===t?void 0:t._id)&&void 0!==a?a:null==e?void 0:e.game)&&void 0!==u?u:null,gameSlug:null!==(d=null!==(s=null==e?void 0:null===(l=e.game)||void 0===l?void 0:l.slug)&&void 0!==s?s:null==e?void 0:null===(n=e.game)||void 0===n?void 0:n.name)&&void 0!==d?d:null}}))&&void 0!==v?v:null},output:{ref:u(l),comp:u(n)},alignment:null!==(b=null!==(g=l.__rd_crossgame_alignment_debug)&&void 0!==g?g:n.__rd_crossgame_alignment_debug)&&void 0!==b?b:null};window.__rd_cross_compare_debug=x,console.info("[rd-cross-compare]",x)}let x=(0,r.tL)(l),z=(0,r.tL)(n);u()(eb,x)||ex(x),u()(ez,z)||eM(z),eg(!0)}),()=>{e=!0}},[tr,to,eA,k,tf,tD,tq,e$,eV,tu,ts,tl,P,tF,tz,ty,tx,tR,tN,tk,tw,tP,tI,tO,N,w,th,tv,tg,tb,tU,tM]),(0,m.useEffect)(()=>{if(!(!eb||!ez)){var e,t,l,n,i,o;let{refFiltered:a,compFiltered:u,refStep:s,compStep:d}=(0,r.rJ)(eb,ez,eF,tf),c=(null==eF?void 0:eF.start)===0&&(null==eF?void 0:eF.end)===1,m=(null==eS?void 0:eS.segment_separators)||[],p=eF?m.findIndex(e=>e.start===eF.start&&e.end===eF.end&&e.name===eF.name):-1,f=p>=0?(0,r.j$)(eb,m,e$,tf):null,_=p>=0?(0,r.j$)(ez,m,eV,tf):null,h=p>=0&&null!==(l=null==f?void 0:null===(e=f[p])||void 0===e?void 0:e.startTime)&&void 0!==l?l:null,v=p>=0&&null!==(n=null==_?void 0:null===(t=_[p])||void 0===t?void 0:t.startTime)&&void 0!==n?n:null,g=(0,r.mt)(a,u,W,j,c,!1,eS,tf,{refStartTime:h,compStartTime:v},eP);ef(g),"time"===eP?(eX(0),eB(0),eT(0)):(eX(s),eB(d),eT(Math.min(s,d)));let{extremePoints:b}=g;if(K(null==b?void 0:b.refFastest),el(null==b?void 0:b.refSlowest),ee(null==b?void 0:b.compFastest),er(null==b?void 0:b.compSlowest),eo(null==b?void 0:b.compPointWhenRefFastest),eu(null==b?void 0:b.compPointWhenRefSlowest),ed(null==b?void 0:b.refPointWhenCompFastest),em(null==b?void 0:b.refPointWhenCompSlowest),"time"===eP){let e=g.speedData[0];eD("number"==typeof(null==e?void 0:e.time)?e.time:0),eR(null!==(i=null==e?void 0:e.refOther)&&void 0!==i?i:null),ew(null!==(o=null==e?void 0:e.compOther)&&void 0!==o?o:null)}else eD(null)}},[eb,ez,eF,j,W,eS,tf,e$,eV,eP]),(0,m.useEffect)(()=>{if(ep.speedData.length>0&&ep.brakeData.length>0&&ep.throttleData.length>0&&ep.rpmData.length>0&&ep.gearData.length>0&&ep.steeringData.length>0&&ep.fuelData.length>0){let e=(0,o.I8)(ep.brakeData,"ref"),t=(0,o.I8)(ep.brakeData,"comp");eY(e),e1(t),e7((0,o.Jx)(ep.brakeData,ep.brakeData,"comp","ref"))}},[ep]),(0,n.jsx)(f.Provider,{value:la,children:L})},h=()=>{let e=(0,m.useContext)(f);if(void 0===e)throw Error("useLapAnalyze must be used within a LapAnalyzeProvider");return e}},43880:function(e,t,l){l.d(t,{G:function(){return o}});var n=l(2265),r=l(80605),i=l(3227);function o(){var e;let t=(0,n.useSyncExternalStore)(i.subscribeAccessToken,i.getAccessTokenSnapshot,()=>void 0),{data:l}=(0,r.useSession)();return null!=t?t:null==l?void 0:null===(e=l.user)||void 0===e?void 0:e.token}},43186:function(e,t,l){l.d(t,{M0:function(){return u},XB:function(){return a},mj:function(){return o}});let n=e=>"number"==typeof e&&Number.isFinite(e),r=e=>Math.atan2(Math.sin(e),Math.cos(e)),i=[Math.PI/3,Math.PI/8,Math.PI/16];function o(e){let t=function(e){let t=e.some(e=>n(e.heading)&&Math.abs(e.heading)>2*Math.PI+.01)?Math.PI/180:1,l=[];for(let r=0;r<e.length;r++){let i=e[r].heading;if(!n(i))continue;let o=function(e,t){var l;let n=e[t],r=null!==(l=e[t+1])&&void 0!==l?l:e[t-1];if(!n||!r)return null;let i=t+1<e.length?1:-1,o=(r.car_coord_x-n.car_coord_x)*i,a=(r.car_coord_z-n.car_coord_z)*i;return Number.isFinite(o)&&Number.isFinite(a)?.05>Math.hypot(o,a)?null:Math.atan2(a,o):null}(e,r);null!==o&&l.push({travel:o,heading:i*t})}if(l.length<40)return null;let o=e=>{let t=0,l=0;for(let n of e)t+=Math.sin(n),l+=Math.cos(n);
1return{offset:Math.atan2(t,l),consistency:Math.hypot(t,l)/e.length}},a=[1,-1].map(e=>{let t=l.map(t=>t.travel-t.heading*e);return{sign:e,differences:t,...o(t)}}).sort((e,t)=>t.consistency-e.consistency)[0];if(a.consistency<.6)return null;let u=a.offset;for(let e of i){let t=a.differences.filter(t=>Math.abs(r(t-u))<=e);if(t.length<40)break;u=o(t).offset}return{offset:u,scale:t*a.sign}}(e),l=t?function(e){let t=new Set,l=0,n=n=>{if(n-l+1<30)return;let r=0;for(let t=l;t<n;t++)r+=Math.hypot(e[t+1].car_coord_x-e[t].car_coord_x,e[t+1].car_coord_z-e[t].car_coord_z);if(!(r<20))for(let e=l;e<=n;e++)t.add(e)};for(let t=1;t<e.length;t++)e[t].heading!==e[t-1].heading&&(n(t-1),l=t);return n(e.length-1),t}(e):null;return e.map((e,i)=>{if(!t||!n(e.heading)||(null==l?void 0:l.has(i)))return{...e,map_heading:null};let o=r(e.heading*t.scale+t.offset);return{...e,map_heading:o}})}function a(e,t,l){if(!n(e)||!n(t)){let r=l<.5?e:t;return n(r)?r:null}let r=Math.atan2(Math.sin(t-e),Math.cos(t-e));return e+r*l}function u(e,t){if(!n(e))return null;let l=t({x:0,z:0}),r=t({x:Math.cos(e),z:Math.sin(e)}),i=r.x-l.x,o=r.z-l.z;return Number.isFinite(i)&&Number.isFinite(o)&&Math.hypot(i,o)>0?Math.atan2(o,i):null}},82248:function(e,t,l){l.d(t,{tL:function(){return k},g3:function(){return y},j$:function(){return P},Ek:function(){return R},u2:function(){return I},Qq:function(){return O},mt:function(){return Q},rJ:function(){return J},TK:function(){return D}});var n=l(82700);function r(e,t){return{x:e.x+t.x,z:e.z+t.z}}function i(e,t){return{x:e.x-t.x,z:e.z-t.z}}function o(e,t){return{x:e.x*t,z:e.z*t}}function a(e,t){return e.x*t.x+e.z*t.z}function u(e,t){return Math.hypot(e.x-t.x,e.z-t.z)}function s(e,t){let l=Math.cos(t),n=Math.sin(t);return{x:l*e.x-n*e.z,z:n*e.x+l*e.z}}function d(e,t){let l=s(e,t.rotationRad);return{x:l.x*t.scale+t.tx,z:l.z*t.scale+t.tz}}function c(e,t){return e.map(e=>d(e,t))}function m(e,t){return e.map(e=>{var l;let n=null!==(l=function(e,t){var l;if(t.length<2)return null!==(l=t[0])&&void 0!==l?l:null;let n=null,s=1/0;for(let l=0;l<t.length-1;l++){let{Q:d}=function(e,t,l){let n=i(l,t),u=Math.max(0,Math.min(1,a(i(e,t),n)/Math.max(1e-9,a(n,n))));return{Q:r(t,o(n,u)),t:u}}(e,t[l],t[l+1]),c=u(e,d);c<s&&(s=c,n=d)}return n}(e,t))&&void 0!==l?l:e;return{x:(e.x+n.x)/2,z:(e.z+n.z)/2}})}function p(e,t){let l=e.length,n=function(e,t){let l=e.length,n=Array(l).fill(0);for(let r=0;r<l;r++){let o=e[r],a=i(r+1<l?e[r+1]:t?e[0]:e[r],o);n[r]=Math.atan2(a.z,a.x)}return n}(e,t),r=Array(l).fill(0);for(let e=0;e<l;e++){let i=e-1>=0?e-1:t?l-1:0;r[e]=function(e){let t=e;for(;t<=-Math.PI;)t+=2*Math.PI;for(;t>Math.PI;)t-=2*Math.PI;return t}(n[e]-n[i])}return r}function f(e,t){let l=Math.min(e.length,t.length),n=Array(l).fill(0);for(let r=0;r<l;r++)n[r]=u(e[r],t[r]);return n}function _(e,t){let l=e.length,n=Array(l).fill(0);for(let r=0;r<l;r++){let i=r-1>=0?r-1:t?l-1:0;n[r]=e[r]-e[i]}return n}function h(e,t,l,n,r){let i=0;for(let o=0;o<r;o++){let a=(o-l+r)%r;i+=n*Math.abs(e[o]-t[a])}return i}function v(e,t,l,n,r){let i=0;for(let o=0;o<r;o++){let a=(o-l+r)%r;i+=e[o]*t[a]*n}return i}function g(e,t){let l=e.length;if(0===l)return[];let n=(t%l+l)%l;return 0===n?e.slice():e.slice(l-n).concat(e.slice(0,l-n))}function b(e,t,l){var n,a;if(t<=0)return[];if(0===e.length)return Array(t).fill({x:0,z:0});let s=function(e,t){let l=e.length,n=Array(l).fill(0);for(let t=1;t<l;t++)n[t]=n[t-1]+u(e[t-1],e[t]);return t&&l>1&&n.push(n[l-1]+u(e[l-1],e[0])),n}(e,l);if(l){let l=null!==(n=s[s.length-1])&&void 0!==n?n:0,a=[];for(let n=0;n<t;n++){let u=n*l/t;a.push(function(e,t,l,n){let a=e.length,u=(n%l+l)%l,s=0;for(;s+1<a&&t[s+1]<u;)s++;if(s+1<a){let l=s+1,n=(u-t[s])/Math.max(1e-9,t[l]-t[s]);return r(e[s],o(i(e[l],e[s]),n))}let d=t[a-1];return r(e[a-1],o(i(e[0],e[a-1]),(u-d)/Math.max(1e-9,l-d)))}(e,s,l,u))}return a}let d=null!==(a=s[e.length-1])&&void 0!==a?a:0,c=[];for(let l=0;l<t;l++){let n=l*d/(t-1);c.push(function(e,t,l){var n;let a=e.length;if(0===a)return{x:0,z:0};if(l<=0)return e[0];if(l>=(null!==(n=t[a-1])&&void 0!==n?n:0))return e[a-1];let u=0;for(;u+1<a&&t[u+1]<l;)u++;let s=u+1,d=(l-t[u])/Math.max(1e-9,t[s]-t[u]);return r(e[u],o(i(e[s],e[u]),d))}(e,s,n))}return c}function x(e,t){let l=Math.min(e.length,t.length);if(l<2)throw Error("Need at least 2 point correspondences");let n=e.slice(0,l),a=t.slice(0,l),u={x:0,z:0},d={x:0,z:0};for(let e=0;e<l;e++)u=r(u,n[e]),d=r(d,a[e]);u=o(u,1/l),d=o(d,1/l);let c=0,m=0,p=0,f=0,_=0;for(let e=0;e<l;e++){let t=i(n[e],u),l=i(a[e],d);c+=l.x*t.x,m+=l.x*t.z,p+=l.z*t.x,f+=l.z*t.z,_+=t.x*t.x+t.z*t.z}if(!(_>1e-9))return console.warn("[cross-game-compare] Degenerate src variance in solveSimilarityTransform2D; using translation-only fallback",{n:l,varSrc:_,muSrc:u,muDst:d}),{scale:1,rotationRad:0,tx:d.x-u.x,tz:d.z-u.z};let h=Math.atan2(p-m,c+f),v=(Math.cos(h)*(c+f)+Math.sin(h)*(p-m))/_,g=s(u,h),b=d.x-v*g.x,x=d.z-v*g.z;return{scale:v,rotationRad:h,tx:b,tz:x}}function z(e){return{x:e.car_coord_x,z:e.car_coord_z}}function M(e,t){let l=e.left_line.map(z),n=e.right_line.map(z);return{L:b(l,t,!1),R:b(n,t,!1),N:t}}var S=l(43186);function y(e,t){var l;return e?t&&"number"==typeof e.compare_normalized&&Number.isFinite(e.compare_normalized)?e.compare_normalized:null!==(l=e.car_position_normalized)&&void 0!==l?l:0:0}function F(e){return e?"number"==typeof e.lap_time&&Number.isFinite(e.lap_time)?e.lap_time:"number"==typeof e.time_covered&&Number.isFinite(e.time_covered)?e.time_covered:"number"==typeof e.timecovered&&Number.isFinite(e.timecovered)?e.timecovered:null:null}function C(e,t){var l,n;let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("number"==typeof(null==e?void 0:e.lap_time)&&e.lap_time>0)return e.lap_time;if(!t||0===t.length)return null;if(r){let e=null;for(let l of t){let t=null==l?void 0:l.lap_time;"number"==typeof t&&Number.isFinite(t)&&t>0&&(e=null===e?t:Math.max(e,t))}if(null!==e)return e}for(let e=t.length-1;e>=0;e--){let n=null===(l=t[e])||void 0===l?void 0:l.lap_time;if("number"==typeof n&&n>0)return n}for(let e=t.length-1;e>=0;e--){let l=null===(n=t[e])||void 0===n?void 0:n.best_lap_time;if("number"==typeof l&&l>0)return l}let i=F(t[t.length-1]);return null!==i&&i>0?i:null}function L(e){return"number"==typeof e&&Number.isFinite(e)}function T(e,t){if(!(null==e?void 0:e.length)||!L(t))return null;let l=null,n=null;for(let m of e){let e=F(m);if(L(e)){if(e>=t){var r,i,o,a,u,s,d,c;if(!l||null===n)return{...m};let p=e-n;if(!Number.isFinite(p)||1e-9>Math.abs(p))return{...m};let f=Math.max(0,Math.min(1,(t-n)/p)),_=f<.5?l:m,h=(e,t)=>L(e)&&L(t)?e+(t-e)*f:L(t)?t:L(e)?e:void 0;return{..._,lap_time:t,time_covered:h(l.time_covered,m.time_covered),car_position_normalized:h(l.car_position_normalized,m.car_position_normalized),compare_normalized:h(l.compare_normalized,m.compare_normalized),car_coord_x:null!==(r=h(l.car_coord_x,m.car_coord_x))&&void 0!==r?r:0,car_coord_y:null!==(i=h(l.car_coord_y,m.car_coord_y))&&void 0!==i?i:0,car_coord_z:null!==(o=h(l.car_coord_z,m.car_coord_z))&&void 0!==o?o:0,ground_speed:null!==(a=h(l.ground_speed,m.ground_speed))&&void 0!==a?a:0,throttle_pos:null!==(u=h(l.throttle_pos,m.throttle_pos))&&void 0!==u?u:_.throttle_pos,brake_pos:null!==(s=h(l.brake_pos,m.brake_pos))&&void 0!==s?s:_.brake_pos,rpm_pos:null!==(d=h(l.rpms,m.rpms))&&void 0!==d?d:_.rpms,steering_angle:null!==(c=h(l.steering_angle,m.steering_angle))&&void 0!==c?c:_.steering_angle,heading:_.heading,map_heading:(0,S.XB)(l.map_heading,m.map_heading,f),__rd_time_interpolated:!0}}l=m,n=e}}return l?{...l}:null}function k(e){for(let t=1;t<e.length;t++){let l=F(e[t]),n=F(e[t-1]);if(null!==l&&null!==n&&n-l>1e3){let n=t+1<e.length?F(e[t+1]):null,r=null!==n&&null!==l?n-l:50,i=[...e];for(let n=0;n<t;n++)i[n]={...e[n],lap_time:Math.max(0,l-(t-n)*r)};return i}}return e}function R(e,t){var l,n;if(!(null==e?void 0:e.length)||!t)return null;let r=null!==(l=t.car_position_normalized)&&void 0!==l?l:-1,i=0,o=e.length-1;for(;i<o;){let t=i+o>>1;(null!==(n=e[t].car_position_normalized)&&void 0!==n?n:0)<r?i=t+1:o=t}return i<e.length-1?e[i+1]:null}function N(e,t,l,n,r){var i;if(!r||!e)return null;let o=null!==(i=e.__rd_compare_extrapolated_side)&&void 0!==i?i:null,a=t<=.02,u=t>=.98;
1if(a&&"tail"===o)return"start_tail_extrapolated";if(u&&"head"===o)return"end_head_extrapolated";if(null!==n&&Number.isFinite(n)&&n>0&&null!==l&&Number.isFinite(l)){if(a&&l>.75*n)return"start_tail_time_frame";if(u&&l<.25*n)return"end_head_time_frame"}return null}function w(e,t,l,n,r,i){let o=N(e,t,l,r,i);if(!o)return null;let a=n.start<=.02,u=n.end>=.98;return a&&o.startsWith("start_")||u&&o.startsWith("end_")?o:null}function P(e,t,l,n){let r=C(l,e,n),i=(e,t,l)=>e+(t-e)*l,o=(e,t,l)=>N(e,t,l,r,n)||null,a=(null==e?void 0:e.length)?e.map((e,t)=>{let l=y(e,n),r=F(e),i=o(e,l,r);return{point:e,index:t,axis:l,time:r,reason:i}}).filter(e=>null!==e.time&&!e.reason):[],u=e=>{if(!a.length)return null;let t=a[0],l=a[a.length-1];if(e<=t.axis)return t.time;if(e>=l.axis)return l.time;for(let t=1;t<a.length;t++){let l=a[t-1],n=a[t],r=l.axis,o=n.axis;if(e<r||e>o)continue;let u=l.time,s=n.time;if(null===u||null===s)return null;if(o===r)return s;return i(u,s,(e-r)/(o-r))}return l.time},s=u(1),d=u(0),c=n&&null!==r&&null!==s&&Number.isFinite(r)&&Number.isFinite(s)&&Math.abs(r-s)>1e3?r-s:0,m=n&&null!==d&&Number.isFinite(d)?d+c:0,p=e=>null===e?null:n?e+c-m:e,f=(e,t,l)=>n&&t?0:n&&l&&null!==r&&Number.isFinite(r)?r:p(u(e));return t.map((l,i)=>{let o=function(e,t,l){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(!(null==e?void 0:e.length))return{time:null,count:0,first:null,last:null,ignoredEdgePointCount:0};let r=0,i=0,o=null,a=null;for(let u=e.length-1;u>=0;u--){let s=e[u],d=y(s,l);if(d>=t.start&&d<t.end){let e=F(s);if(w(s,d,e,t,n,l)){i++;continue}r++,a=null!=a?a:s,o=s}}return{time:a?F(a):null,count:r,first:o,last:a,ignoredEdgePointCount:i}}(e,l,n,r),a=i===t.length-1,u=f(l.start,0===i,!1),s=f(l.end,!1,a),d=null;return null!==s&&null!==u&&s>=u&&(d=s-u),{...l,startTime:u,duration:d,endTime:s,lapTotalTime:r,pointCount:o.count,firstPoint:o.first,lastPoint:o.last,ignoredEdgePointCount:o.ignoredEdgePointCount}})}function I(e,t){return t&&(null==e?void 0:e.length)?e.findIndex(e=>e.start===t.start&&e.end===t.end):-1}function O(e,t,l){var n,r,i,o;if(l<0)return null;let a=null==e?void 0:null===(r=e.segments)||void 0===r?void 0:null===(n=r.find(e=>e.segment_count===l+1))||void 0===n?void 0:n.segment_time,u=null==t?void 0:null===(o=t.segments)||void 0===o?void 0:null===(i=o.find(e=>e.segment_count===l+1))||void 0===i?void 0:i.segment_time;return"number"==typeof a&&"number"==typeof u?a-u:null}function D(e){var t,l,n;let{refLapLinesData:r,compLapLinesData:i,isGhostDriverActive:o,crossGame:a}=e;if(!r||!i)return{filteredRefLap:[],filteredCompLap:[]};let u=A(null==r?void 0:null===(t=r.data)||void 0===t?void 0:t.combinedTelemetry),s=A(null==i?void 0:null===(l=i.data)||void 0===l?void 0:l.combinedTelemetry);if(!u&&!s)return{filteredRefLap:[],filteredCompLap:[]};if(!u&&s)return{filteredRefLap:[],filteredCompLap:s};let b=!!(null==a?void 0:a.isCrossGameCompare);if(!b&&(u&&s&&u.length===s.length||!u||!s))return{filteredRefLap:u,filteredCompLap:s};let z=null===(n=null==a?void 0:a.interpolateIfNot2000)||void 0===n||n,y=b?q(u,z):es(u),F=b?q(s,z):es(s);return o&&!b?{filteredRefLap:y,filteredCompLap:F}:(null==a?void 0:a.isCrossGameCompare)&&a.baseTrackLines&&a.srcTrackLines?function(e){let{refLap:t,compLap:l,baseTrackLines:n,srcTrackLines:r,isBaseRef:i,refLapMeta:o,compLapMeta:a,manualAlignment:u}=e,s=Z(n)||Z(r),b=function(e,t,l){var n;let r=null!==(n=null==l?void 0:l.N)&&void 0!==n?n:2e3,i=M(e,r),o=M(t,r),{shifted:a,phase:u}=function(e,t,l){let n=function(e,t,l){var n,r,i,o,a,u;let s=null!==(n=null==l?void 0:l.N)&&void 0!==n?n:Math.min(e.L.length,e.R.length,t.L.length,t.R.length);if(s<2)throw Error("Need at least 2 points for phase shift");let d=null!==(r=null==l?void 0:l.wHeading)&&void 0!==r?r:1,c=null!==(i=null==l?void 0:l.wWidth)&&void 0!==i?i:.35,g=null!==(o=null==l?void 0:l.wDWidth)&&void 0!==o?o:.15,b=null!==(a=null==l?void 0:l.method)&&void 0!==a?a:"l1",x=null===(u=null==l?void 0:l.allowHeadingFlip)||void 0===u||u,z=m(e.L.slice(0,s),e.R.slice(0,s)),M=m(t.L.slice(0,s),t.R.slice(0,s)),S=p(z,!0),y=p(M,!0),F=f(e.L.slice(0,s),e.R.slice(0,s)),C=f(t.L.slice(0,s),t.R.slice(0,s)),L=_(F,!0),T=_(C,!0),k=e=>{let t=0,l="l1"===b?1/0:-1/0;for(let n=0;n<s;n++)if("l1"===b){let r=h(S,e,n,d,s)+h(F,C,n,c,s)+h(L,T,n,g,s);r<l&&(l=r,t=n)}else{let r=v(S,e,n,d,s)+v(F,C,n,c,s)+v(L,T,n,g,s);r>l&&(l=r,t=n)}return{bestShift:t,bestScore:l}},R=k(y);if(!x)return{shift:R.bestShift,N:s,method:b,usedHeadingFlip:!1,score:R.bestScore};let N=k(y.map(e=>-e)),w="l1"===b?N.bestScore<R.bestScore:N.bestScore>R.bestScore,P=w?N:R;return{shift:P.bestShift,N:s,method:b,usedHeadingFlip:w,score:P.bestScore}}({L:e.L,R:e.R},{L:t.L,R:t.R},{N:e.N,...null!=l?l:{}});return{shifted:{L:g(t.L,n.shift),R:g(t.R,n.shift),N:e.N}
1,phase:{shift:n.shift,score:n.score,usedHeadingFlip:n.usedHeadingFlip,method:n.method}}}(i,o,null==l?void 0:l.phaseOptions),s=x(a.L.concat(a.R),i.L.concat(i.R)),d={L:c(a.L,s),R:c(a.R,s),N:r};return{base:i,src:o,srcShifted:a,phase:u,T:s,srcInBase:d}}(n,r,{N:2e3,phaseOptions:{method:"l1"}}),z=(s?function(e){var t,l;let n=e.base.N,r=m(e.base.L,e.base.R),i=null,o=[];for(let a=0;a<n;a++){let u={L:g(e.src.L,a),R:g(e.src.R,a),N:n},s=m(u.L,u.R),c=x(s,r),p=s.map(e=>d(e,c)),f=function(e,t){let l=Math.min(e.length,t.length);if(l<2)return null;let n=0,r=0,i=0,o=0,a=0;for(let u=0;u<l;u++){let l=t[u],s=e[u];Number.isFinite(l.x)&&Number.isFinite(l.z)&&Number.isFinite(s.x)&&Number.isFinite(s.z)&&(n++,r+=l.x,i+=l.z,o+=s.x,a+=s.z)}if(n<2)return null;let u=r/n,s=i/n,d=o/n,c=a/n,m=0,p=0,f=0,_=0;for(let n=0;n<l;n++){let l=t[n],r=e[n];if(!Number.isFinite(l.x)||!Number.isFinite(l.z)||!Number.isFinite(r.x)||!Number.isFinite(r.z))continue;let i=l.x-u,o=l.z-s;m+=i*i,p+=o*o,f+=i*(r.x-d),_+=o*(r.z-c)}if(m<=0||p<=0)return null;let h=f/m,v=_/p;return!Number.isFinite(h)||!Number.isFinite(v)||h<=0||v<=0?null:Math.max(h,v)/Math.min(h,v)<1.35?null:{sx:h,sz:v,tx:d-h*u,tz:c-v*s}}(r,p),_=function(e,t){var l,n;let r=Math.min(e.length,t.length);if(r<2)return 1/0;let i=[];for(let l=0;l<r;l++){let n=e[l],r=t[l];Number.isFinite(n.x)&&Number.isFinite(n.z)&&Number.isFinite(r.x)&&Number.isFinite(r.z)&&i.push(Math.hypot(n.x-r.x,n.z-r.z))}if(i.length<2)return 1/0;i.sort((e,t)=>e-t);let o=null!==(l=i[Math.floor(.5*i.length)])&&void 0!==l?l:1/0,a=null!==(n=i[Math.floor(.9*i.length)])&&void 0!==n?n:o;return o+.35*a}(r,p.map(e=>f?{x:e.x*f.sx+f.tx,z:e.z*f.sz+f.tz}:e));o.push({shift:a,score:_,sx:null!==(t=null==f?void 0:f.sx)&&void 0!==t?t:null,sz:null!==(l=null==f?void 0:f.sz)&&void 0!==l?l:null}),(!i||_<i.score)&&(i={shift:a,score:_,T:c,correction:f,srcShifted:u})}if(!i)return{alignment:e,search:null};let a={L:c(i.srcShifted.L,i.T),R:c(i.srcShifted.R,i.T),N:n};return{alignment:{...e,srcShifted:i.srcShifted,phase:{...e.phase,shift:i.shift,score:i.score,method:"l1"},T:i.T,srcInBase:a},search:{initialShift:e.phase.shift,initialScore:e.phase.score,shift:i.shift,score:i.score,correction:i.correction,topCandidates:o.sort((e,t)=>e.score-t.score).slice(0,12)}}}(b):{alignment:b,search:null}).alignment,y=i?t:l,F=i?l:t,L=E(n),T=E(r),k=H(y,n,2e3,{skip:L}),R=H(F,r,2e3,{skip:T}),N=k.lap,w=R.lap,P=e=>E(e),I=P(n)||P(r),O=(e,t)=>m(e,t),D=(e,t)=>{if(!e.length||t.length<2)return null;let l=J(t);return[0,1,Math.floor(e.length/2),Math.max(0,e.length-2),e.length-1].map(t=>{let n=e[t];if(!n)return{index:t,q:null,u:null};let r=l.snap(U(n),{seg:null});return{index:t,q:Math.sqrt(r.distSq),u:r.normalized,seg:r.seg}})},A=O(z.base.L,z.base.R),q=O(z.srcShifted.L,z.srcShifted.R),j=O(z.base.L,z.base.R),X=O(z.src.L,z.src.R),G=I?x(q,A):null,B=null!=G?G:z.T,V=I&&!P(n)?q.map(e=>d(e,B)):A,$={L:z.srcShifted.L.map(e=>d(e,B)),R:z.srcShifted.R.map(e=>d(e,B))},J=e=>{let t=e.length-1,l=[],n=0;for(let r=0;r<t;r++){let t=e[r],i=e[r+1],o=Math.hypot(i.x-t.x,i.z-t.z);l.push({cumStart:n,segLen:o,ax:t.x,az:t.z,bx:i.x,bz:i.z}),n+=o}let r=n||1;function i(e,t,n,r,i,o,a){let u=i,s=o,d=a;for(let i=n;i<r;i++){let n=l[i],{t:r,distSq:o}=function(e,t,l,n,r,i){let o=r-l,a=i-n,u=o*o+a*a,s=0===u?0:((e-l)*o+(t-n)*a)/u,d=e-(l+(s=Math.max(0,Math.min(1,s)))*o),c=t-(n+s*a);return{t:s,distSq:d*d+c*c}}(e,t,n.ax,n.az,n.bx,n.bz);o<u&&(u=o,s=n.cumStart+r*n.segLen,d=i)}return{bestDistSq:u,bestLocation:s,bestSeg:d}}return{snap:function(e,l){let n=e.x,o=e.z,a=1/0,u=0,s=0;if(l&&"number"==typeof l.seg&&l.seg>=0&&l.seg<t){let e=l.seg,r=i(n,o,Math.max(0,e-24),Math.min(t,e+80+1),a,u,s);if(a=r.bestDistSq,u=r.bestLocation,s=r.bestSeg,a>25e4){let e=i(n,o,0,t,1/0,0,0);a=e.bestDistSq,u=e.bestLocation,s=e.bestSeg}}else{let e=i(n,o,0,t,1/0,0,0);a=e.bestDistSq,u=e.bestLocation,s=e.bestSeg}l&&(l.seg=s);let d=u/r;return{locationMeters:u,normalized:d=Math.max(0,Math.min(1,d)),distSq:a,seg:s}},trackLength:r}},Q=J(V),K=e=>{let t=e.map(e=>e.x).filter(e=>"number"==typeof e&&Number.isFinite(e)),l=e.map(e=>e.z).filter(e=>"number"==typeof e&&Number.isFinite(e));return t.length&&l.length?{minX:Math.min(...t),maxX:Math.max(...t),minZ:Math.min(...l),maxZ:Math.max(...l),width:Math.max(...t)-Math.min(...t),height:Math.max(...l)-Math.min(...l)}:null},Y=(e,t)=>
1{let l=e[t];return l?{x:l.x,z:l.z}:null},ee=e=>({count:e.length,first:Y(e,0),second:Y(e,1),mid:Y(e,Math.floor(e.length/2)),penultimate:Y(e,e.length-2),last:Y(e,e.length-1),bounds:K(e)}),et=e=>{var t,l,n,r;return e?{scale:null!==(t=e.scale)&&void 0!==t?t:null,rotationRad:null!==(l=e.rotationRad)&&void 0!==l?l:null,tx:null!==(n=e.tx)&&void 0!==n?n:null,tz:null!==(r=e.tz)&&void 0!==r?r:null}:null},el=s?((e,t)=>{let l=Math.min(e.length,t.length);if(l<2)return null;let n=0,r=0,i=0,o=0,a=0;for(let u=0;u<l;u++){let l=t[u],s=e[u];Number.isFinite(l.x)&&Number.isFinite(l.z)&&Number.isFinite(s.x)&&Number.isFinite(s.z)&&(n++,r+=l.x,i+=l.z,o+=s.x,a+=s.z)}if(n<2)return null;let u=r/n,s=i/n,d=o/n,c=a/n,m=0,p=0,f=0,_=0;for(let n=0;n<l;n++){let l=t[n],r=e[n];if(!Number.isFinite(l.x)||!Number.isFinite(l.z)||!Number.isFinite(r.x)||!Number.isFinite(r.z))continue;let i=l.x-u,o=l.z-s;m+=i*i,p+=o*o,f+=i*(r.x-d),_+=o*(r.z-c)}if(m<=0||p<=0)return null;let h=f/m,v=_/p;return!Number.isFinite(h)||!Number.isFinite(v)||h<=0||v<=0?null:Math.max(h,v)/Math.min(h,v)<1.35?null:{sx:h,sz:v,tx:d-h*u,tz:c-v*s}})(z.base.L.concat(z.base.R),$.L.concat($.R)):null,en=e=>el?{x:e.x*el.sx+el.tx,z:e.z*el.sz+el.tz}:e,er={L:$.L.map(en),R:$.R.map(en)},ei=e=>2e3!==e.length?e:e.map((e,t)=>({...e,car_position_normalized:5e-4*t})),eo=ei(N),ea=((e,t)=>{if(!Number.isFinite(e)||t<=0)return 0;let l=Math.trunc(e);return l>t/2&&(l-=t),l<-t/2&&(l+=t),l})(z.phase.shift,2e3),eu=C(i?a:o,w),es=ei(((e,t,l)=>{var n,r,i,o,a,u,s,d;let c=e.length;if(!c)return[];if(0===t)return e.slice();let m=Math.min(c,Math.abs(t)),p=e=>"number"==typeof e&&Number.isFinite(e),f=(e,t,l)=>e+(t-e)*l,_=e=>{let t=[];for(let r=1;r<e.length;r++){var l,n;let i=null===(l=e[r-1])||void 0===l?void 0:l.lap_time,o=null===(n=e[r])||void 0===n?void 0:n.lap_time;if("number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)){let e=Math.max(0,o-i);e>0&&t.push(e)}}return t.reduce((e,t)=>e+t,0)>0?t:null},h=(e,t,l)=>{var n,r;if(!e||0===e.length||l<=0)return l<=0?1:t/l;let i=e.reduce((e,t)=>e+Math.max(0,t),0);if(i<=0)return t/l;if(t<=0)return 0;if(t>=l)return 1;let o=Math.max(1,t/l*e.length),a=Math.floor(o),u=0;for(let t=0;t<Math.min(a,e.length);t++)u+=Math.max(0,null!==(n=e[t])&&void 0!==n?n:0);return a<e.length&&(u+=Math.max(0,null!==(r=e[a])&&void 0!==r?r:0)*(o-a)),Math.max(0,Math.min(1,u/i))},v=(e,t,l,n,r,i)=>{let o=l-t+1;if(!(o<=0)&&Number.isFinite(n)&&Number.isFinite(r)){if(1===o){e[t].lap_time=r;return}for(let l=0;l<o;l++){let a=h(i,l,o-1);e[t+l].lap_time=f(n,r,a)}}},g=(e,t)=>{let l=null==e?void 0:e.lap_time;return{...e,lap_time:p(l)?l+t:l}};if(t<0){let t=null!==(a=e[m])&&void 0!==a?a:e[0],n=p(null==t?void 0:t.lap_time)?t.lap_time:0,r=e.slice(m).map(e=>g(e,-n)),i=_(e.slice(0,Math.min(c,m+1))),d=null!==(s=null!==(u=r[r.length-1])&&void 0!==u?u:e[c-1])&&void 0!==s?s:t,f=Array(m).fill(0).map(()=>({...d,__rd_is_pad:!0,__rd_pad_profile_side:"tail",__rd_pad_time_profile:i})),h=r.concat(f),b=Math.max(0,r.length-1),x=p(null===(o=h[b])||void 0===o?void 0:o.lap_time)?h[b].lap_time:null;return null!==x&&null!==l&&Number.isFinite(l)&&v(h,b+1,h.length-1,x,l,i),h}let b=Math.max(0,c-m),x=p(null===(n=e[b])||void 0===n?void 0:n.lap_time)?e[b].lap_time:null,z=null!==l&&Number.isFinite(l)?l:p(null===(r=e[c-1])||void 0===r?void 0:r.lap_time)?e[c-1].lap_time:null,M=null!==x&&null!==z?Math.max(0,z-x):0,S=e.slice(0,Math.max(1,c-m)).map(e=>g(e,M)),y=_(e.slice(Math.max(0,c-m-1),c)),F=null!==(d=S[0])&&void 0!==d?d:e[0],C=Array(m).fill(0).map(()=>({...F,__rd_is_pad:!0,__rd_pad_profile_side:"head",__rd_pad_time_profile:y})).concat(S),L=p(null===(i=C[m])||void 0===i?void 0:i.lap_time)?C[m].lap_time:null;return null!==L&&v(C,0,m-1,0,L,y),C})(w,ea,eu)).map(e=>{let t=en(d(U(e),B));return W(e,t,e=>{var t,l;let n=d(e,{...B,tx:0,tz:0});return{x:n.x*(null!==(t=null==el?void 0:el.sx)&&void 0!==t?t:1),z:n.z*(null!==(l=null==el?void 0:el.sz)&&void 0!==l?l:1)}})}),ed=O(er.L,er.R),ec=s&&V.length>0&&ed.length>0?es.map((e,t)=>{let l=Math.min(t,V.length-1,ed.length-1),n=V[l],r=ed[l];return W(e,{x:e.car_coord_x+(n.x-r.x),z:e.car_coord_z+(n.z-r.z)})}):es,em=function(e,t,l){var n,r,i,o,a;let u=null!==(n=null==t?void 0:t.scaleX)&&void 0!==n?n:1,s=null!==(r=null==t?void 0:t.scaleZ)&&void 0!==r?r:1,d=null!==(i=null==t?void 0:t.rotationDeg)&&void 0!==i?i:0,c=null!==(o=null==t?void 0:t.offsetX)&&void 0!==o?o:0,m=null!==(a=null==t?void 0:t.offsetZ)&&void 0!==a?a:0;if(1===u&&1===s&&0===d&&0===c&&0===m||!l)return e;let p=d*Math.PI/180,f=Math.cos(p),_=Math.sin(p);return e.map(e=>({...e,map_heading:(0,S.M0)(e.map_heading,e=>({x:e.x*u*f-e.z*s*_,z:e.x*u*_+e.z*s*f})),car_coord_x:l.x+((e.car_coord_x-l.x)*u*f-(e.car_coord_z-l.z)*s*_)+c,car_coord_z:l.z+((e.car_coord_x-l.x)*u*_+(e.car_coord_z-l.z)*s*f)+m}))}(ec,u,function(e){let t=0,l=0,n=0;for(let r of e)Number.isFinite(r.car_coord_x)&&Number.isFinite(r.car_coord_z)&&(t+=r.car_coord_x,l+=r.car_coord_z,n++);return 0===n?null:{x:t/n,z:l/n}}(ec)),ep=function(e,t){var l,n,r,i,o,a,u;let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],d=arguments.length>3&&void 0!==arguments[3]&&arguments[3],c=(e,t,l)=>e+(t-e)*l,m=["ground_speed","throttle_pos","brake_pos","steering_angle","rpms","fuel"],p=(e,t)=>{if(t)for(let l of["lap_time","time_covered","timecovered"]){let n=null==t?void 0:t[l];
1"number"==typeof n&&Number.isFinite(n)&&(e[l]=n)}},f=e.filter(e=>!(null==e?void 0:e.__rd_is_pad)),_={seg:null},h=f.map(e=>{let l=U(e),n=Q.snap(l,d?_:void 0),r=n.normalized-t;if(s){for(;r<0;)r+=1;for(;r>=1;)r-=1}return{pt:e,u:r,distSq:n.distSq}}).filter(e=>e.u>=0&&e.u<1).sort((e,t)=>e.u-t.u),v=Array(2e3);if(h.length<2){let t=null!==(l=e[0])&&void 0!==l?l:{};for(let e=0;e<2e3;e++){let l=5e-4*e;v[e]={...t,car_position_normalized:l,compare_index:e,compare_normalized:l,compare_quality:null,__rd_compare_extrapolated:!0}}return v}let g=h[0],b=h[h.length-1],x=0;for(let t=0;t<2e3;t++){let l=5e-4*t;for(;x<h.length&&h[x].u<=l;)x++;if(x<=0){let r={...(null===(n=e[t])||void 0===n?void 0:n.__rd_is_pad)===!0?e[t]:g.pt,car_position_normalized:l,compare_index:t,compare_normalized:l,compare_quality:Math.sqrt(g.distSq),__rd_compare_extrapolated:!0,__rd_compare_extrapolated_side:"head"};p(r,e[t]),v[t]=r;continue}if(x>=h.length){let n={...(null===(r=e[t])||void 0===r?void 0:r.__rd_is_pad)===!0?e[t]:b.pt,car_position_normalized:l,compare_index:t,compare_normalized:l,compare_quality:Math.sqrt(b.distSq),__rd_compare_extrapolated:!0,__rd_compare_extrapolated_side:"tail"};p(n,e[t]),v[t]=n;continue}let s=h[x-1],d=h[x],f=d.u-s.u,_=0===f?0:(l-s.u)/f,z=null!==(i=s.pt.car_coord_x)&&void 0!==i?i:0,M=null!==(o=s.pt.car_coord_z)&&void 0!==o?o:0,y=null!==(a=d.pt.car_coord_x)&&void 0!==a?a:z,F=null!==(u=d.pt.car_coord_z)&&void 0!==u?u:M,C={...s.pt,index:t,car_coord_x:c(z,y,_),car_coord_z:c(M,F,_),heading:_<.5?s.pt.heading:d.pt.heading,map_heading:(0,S.XB)(s.pt.map_heading,d.pt.map_heading,_),car_position_normalized:l,compare_index:t,compare_normalized:l,compare_quality:c(Math.sqrt(s.distSq),Math.sqrt(d.distSq),_),__rd_compare_extrapolated:!1};for(let e of m){let t=s.pt[e],l=d.pt[e];"number"==typeof t&&"number"==typeof l&&(C[e]=c(t,l,_))}p(C,e[t]),v[t]=C}return v};{var ef,e_,eh,ev,eg,eb,ex,ez,eM,eS,ey,eF;let e=ep(eo,0,!1),t=ep(em,0,!1,null!==el),l=i?{filteredRefLap:e,filteredCompLap:t}:{filteredRefLap:t,filteredCompLap:e},n={isBaseRef:i,phase:z.phase,transforms:{alignmentT:et(z.T),realWorldRacingTransform:et(G),effectiveTransform:et(B),baseLapToTrack:et(k.T),srcLapToTrack:et(R.T)},centerlines:{base:ee(V),srcShifted:ee(q),srcInBaseLeft:ee($.L),srcInBaseRight:ee($.R)},snapper:{baseTrackLength:Q.trackLength},quality:{baseFirst:null!==(ex=null===(ef=e[0])||void 0===ef?void 0:ef.compare_quality)&&void 0!==ex?ex:null,baseMid:null!==(ez=null===(e_=e[Math.floor(1e3)])||void 0===e_?void 0:e_.compare_quality)&&void 0!==ez?ez:null,baseLast:null!==(eM=null===(eh=e[1999])||void 0===eh?void 0:eh.compare_quality)&&void 0!==eM?eM:null,srcFirst:null!==(eS=null===(ev=t[0])||void 0===ev?void 0:ev.compare_quality)&&void 0!==eS?eS:null,srcMid:null!==(ey=null===(eg=t[Math.floor(1e3)])||void 0===eg?void 0:eg.compare_quality)&&void 0!==ey?ey:null,srcLast:null!==(eF=null===(eb=t[1999])||void 0===eb?void 0:eb.compare_quality)&&void 0!==eF?eF:null,baseRawToOwnTrack:D(y,j),baseNormToOwnTrack:D(N,j),srcRawToOwnTrack:D(F,X),srcNormToOwnTrack:D(R.lap,X)}};return l.filteredRefLap.__rd_crossgame_alignment_debug=n,l.filteredCompLap.__rd_crossgame_alignment_debug=n,l}}({refLap:y,compLap:F,baseTrackLines:a.baseTrackLines,srcTrackLines:a.srcTrackLines,isBaseRef:!!a.isBaseRef,refLapMeta:a.refLapMeta,compLapMeta:a.compLapMeta,manualAlignment:a.manualAlignment}):function(e,t){var l,n;let r=e.map(e=>({normalized:e.car_position_normalized.toFixed(3)})),i=t.map(e=>({normalized:e.car_position_normalized.toFixed(3)})),o=(l=new Set(r.map(e=>e.normalized)),n=new Set(i.map(e=>e.normalized)),Math.min(l.size,n.size)===l.size?Array.from(n).filter(e=>l.has(e)):Array.from(l).filter(e=>n.has(e)));return{filteredRefLap:$(e,o),filteredCompLap:$(t,o)}}(y,F)}function A(e){return e&&(0,S.mj)(e).map((e,t)=>({...e,index:t}))}function q(e,t){return t&&Array.isArray(e)&&2e3!==e.length?es(e):e}function U(e){return{x:e.car_coord_x,z:e.car_coord_z}}function W(e,t,l){return{...e,car_coord_x:t.x,car_coord_z:t.z,...l?{map_heading:(0,S.M0)(e.map_heading,l)}:{}}}function j(e){var t,l,n,r,i,o;let a=null!==(o=null!==(i=null!==(r=null!==(n=null==e?void 0:null===(t=e.game)||void 0===t?void 0:t.slug)&&void 0!==n?n:null==e?void 0:null===(l=e.game)||void 0===l?void 0:l.name)&&void 0!==r?r:null==e?void 0:e.gameSlug)&&void 0!==i?i:null==e?void 0:e.game_name)&&void 0!==o?o:null;return"string"==typeof a?a.toLowerCase().replace(/[\s-]+/g,"_"):null}function E(e){let t=j(e);return"real_world_racing"===t||"realworldracing"===t||"real_racing"===t}function Z(e){let t=j(e);return"iracing"===t||"i_racing"===t}function X(e){return Math.max(0,Math.min(1,e))}function G(e){var t;return{x:e.car_coord_x,z:e.car_coord_z,n:X(null!==(t=e.car_position_normalized)&&void 0!==t?t:0)}}function B(e){var t;return{x:e.car_coord_x,z:e.car_coord_z,n:X(null!==(t=e.car_position_normalized)&&void 0!==t?t:0)}}function V(e,t){if(!e||0===e.length)return Array(t).fill({x:0,z:0});let l=e.map((e,t)=>({...e,_i:t})).sort((e,t)=>
1e.n===t.n?e._i-t._i:e.n-t.n),n=Array(t),r=0;for(let e=0;e<t;e++){let i=e/(t-1);for(;r+1<l.length&&l[r+1].n<i;)r++;let o=l[r],a=l[Math.min(r+1,l.length-1)];if(o.n===a.n){n[e]={x:o.x,z:o.z};continue}let u=(i-o.n)/(a.n-o.n);n[e]={x:o.x+(a.x-o.x)*u,z:o.z+(a.z-o.z)*u}}return n}function H(e,t,l,n){try{var r,i;if(null==n?void 0:n.skip)return{lap:e,T:null};let o=(null!==(r=t.left_line)&&void 0!==r?r:[]).map(B),a=(null!==(i=t.right_line)&&void 0!==i?i:[]).map(B);if(o.length<2||a.length<2||e.length<2)return{lap:e,T:null};let u=V(o,l),s=V(a,l),c=m(u,s),p=e.map(G),f=V(p,l),_=x(f,c);return{lap:e.map(e=>W(e,d(U(e),_),e=>d(e,{..._,tx:0,tz:0}))),T:_}}catch(t){return{lap:e,T:null}}}function $(e,t){let l=new Set;return e.filter(e=>{let n=e.car_position_normalized.toFixed(3);return!!t.includes(n)&&!l.has(n)&&(l.add(n),!0)})}function J(e,t,l){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!e||!t)return{refFiltered:[],compFiltered:[],refStep:0,compStep:0,refIgnoredEdgePointCount:0,compIgnoredEdgePointCount:0};let r=C(null,e,n),i=C(null,t,n),o=(e,t)=>{if(!l)return!0;let r=y(e,n);return!(r<l.start)&&!(r>=l.end)&&!w(e,r,F(e),l,t,n)},a=l?e.filter(e=>o(e,r)):e,u=l?t.filter(e=>o(e,i)):t,s=(e,t)=>l?e.reduce((e,r)=>{let i=y(r,n);return i<l.start||i>=l.end?e:w(r,i,F(r),l,t,n)?e+1:e},0):0,d=s(e,r),c=s(t,i);return{refFiltered:a,compFiltered:u,refStep:l?e.filter(e=>y(e,n)<=l.start).length:0,compStep:l?t.filter(e=>y(e,n)<=l.start).length:0,refIgnoredEdgePointCount:d,compIgnoredEdgePointCount:c}}function Q(e,t,l,n,r,i,o){var a,u,s,d,c,m,p,f,_,h,v,g,b,x,z,M,S,C,L;let k=arguments.length>7&&void 0!==arguments[7]&&arguments[7],R=arguments.length>8?arguments[8]:void 0,N=arguments.length>9&&void 0!==arguments[9]?arguments[9]:"position",w=y(e[0],k),P=y(t[0],k),I="number"==typeof(null==R?void 0:R.refStartTime)?R.refStartTime:w<=1e-9?0:null!==(c=null===(a=e[0])||void 0===a?void 0:a.lap_time)&&void 0!==c?c:0,O="number"==typeof(null==R?void 0:R.compStartTime)?R.compStartTime:P<=1e-9?0:null!==(m=null===(u=t[0])||void 0===u?void 0:u.lap_time)&&void 0!==m?m:0,D=k&&"number"!=typeof(null==R?void 0:R.refStartTime)&&"number"==typeof I&&1e-9>Math.abs(I)&&"number"==typeof(null==e?void 0:null===(s=e[0])||void 0===s?void 0:s.lap_time)&&Number.isFinite(e[0].lap_time)&&Math.abs(e[0].lap_time)>1e-6?e[0].lap_time:I,A=k&&"number"!=typeof(null==R?void 0:R.compStartTime)&&"number"==typeof O&&1e-9>Math.abs(O)&&"number"==typeof(null==t?void 0:null===(d=t[0])||void 0===d?void 0:d.lap_time)&&Number.isFinite(t[0].lap_time)&&Math.abs(t[0].lap_time)>1e-6?t[0].lap_time:O,q=[],U=[],W=[],j=[],E=[],Z=[],X=[],G=[],B=[];function V(e){if(!e||0===e.length)return{fastest:{},slowest:{}};let t=e.find(e=>void 0!==e.ground_speed&&null!==e.ground_speed&&e.ground_speed>0);if(!t)return{fastest:e[0],slowest:e[0]};let l=t,n=t;for(let t of e)void 0!==t.ground_speed&&null!==t.ground_speed&&!(t.ground_speed<=0)&&(t.ground_speed>l.ground_speed&&(l=t),t.ground_speed<n.ground_speed&&(n=t));return{fastest:l,slowest:n}}let H=V(e),$=V(t),J={refFastest:H.fastest,refSlowest:H.slowest,compFastest:$.fastest,compSlowest:$.slowest},Q=Math.max(e.length,t.length)-1,eu=ee(e[Q],t[Q],D,A),es=(eu.ref||0)-(eu.comp||0);if("time"===N){let n=F(e[e.length-1]),i=F(t[t.length-1]),a=null!==n?Math.max(0,n-D):0,u=null!==i?Math.max(0,i-A):0,s=r?Math.max(a,u):Math.min(a,u),d=Math.max(20,Math.ceil(s/2e3)),c=Math.max(1,Math.floor(s/d)+1),m="number"==typeof(null==o?void 0:o.distance)&&Number.isFinite(o.distance)&&o.distance>0;for(let n=0;n<c;n++){let r=Math.min(n*d,s),i=null!==(p=T(e,D+r))&&void 0!==p?p:e[Math.min(n,e.length-1)],a=null!==(f=T(t,A+r))&&void 0!==f?f:t[Math.min(n,t.length-1)],u=Y(i,a,l);u.time=r,q.push(u);let c=el(i,a);c.time=r,W.push(c);let _=en(i,a);_.time=r,j.push(_);let h=er(i,a);h.time=r,E.push(h);let v=ei(i,a);v.time=r,Z.push(v);let g=eo(i,a);g.time=r,X.push(g);let b=ea(i,a);if(b.time=r,G.push(b),m){let e=et(i,a,o.distance,k);e&&(e.time=r,U.push(e),B.push(e))}}if(s>0&&(c-1)*d<s){let n=null!==(_=T(e,D+s))&&void 0!==_?_:e[e.length-1],r=null!==(h=T(t,A+s))&&void 0!==h?h:t[t.length-1],i=Y(n,r,l);i.time=s,q.push(i);let a=el(n,r);a.time=s,W.push(a);let u=en(n,r);u.time=s,j.push(u);let d=er(n,r);d.time=s,E.push(d);let c=ei(n,r);c.time=s,Z.push(c);let p=eo(n,r);p.time=s,X.push(p);let f=ea(n,r);if(f.time=s,G.push(f),m){let e=et(n,r,o.distance,k);e&&(e.time=s,U.push(e),B.push(e))}}return{speedData:q,diffData:U,diffDataInMeters:B,throttleData:W,brakeData:j,rpmData:E,gearData:Z,steeringData:X,fuelData:G,startRefTime:D,startCompTime:A,timeDiff:es,extremePoints:{...J,compPointWhenRefFastest:K(J.refFastest,t,k),compPointWhenRefSlowest:K(J.refSlowe
1st,t,k),refPointWhenCompFastest:K(J.compFastest,e,k),refPointWhenCompSlowest:K(J.compSlowest,e,k)},focusZoneIndices:null}}let ed=Math.max(e.length,t.length);for(let n=0;n<ed;n++){let r=e[n],i=t[n];q.push(Y(r,i,l));let a=ee(r,i,D,A);U.push(a);let u=et(r,i,null!==(v=null==o?void 0:o.distance)&&void 0!==v?v:1,k);u&&B.push(u);let s=el(r,i);W.push(s);let d=en(r,i);j.push(d),E.push(er(r,i)),Z.push(ei(r,i)),X.push(eo(r,i)),G.push(ea(r,i)),s.brake_ref=null!==(g=d.ref)&&void 0!==g?g:0,s.brake_comp=null!==(b=d.comp)&&void 0!==b?b:0,s.throttle_ref=null!==(x=s.ref)&&void 0!==x?x:0,s.throttle_comp=null!==(z=s.comp)&&void 0!==z?z:0,d.brake_ref=null!==(M=d.ref)&&void 0!==M?M:0,d.brake_comp=null!==(S=d.comp)&&void 0!==S?S:0,d.throttle_ref=null!==(C=s.ref)&&void 0!==C?C:0,d.throttle_comp=null!==(L=s.comp)&&void 0!==L?L:0}let ec=r?null:function(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,n=e.length,r=e.map(t?e=>(e.ref||0)-(e.comp||0):e=>(e.comp||0)-(e.ref||0)),i=[];for(let e=1;e<n;e++)i.push(r[e]-r[e-1]);let o=-1/0,a=-1;for(let e=0;e<i.length;e++)i[e]>o&&(o=i[e],a=e);let u=a;for(;u>0&&i[u-1]>-l;)u--;let s=a;for(;s<i.length-1&&i[s+1]>-l;)s++;return{start:u,end:s+1}}(U,i);return{speedData:q,diffData:U,diffDataInMeters:B,throttleData:W,brakeData:j,rpmData:E,gearData:Z,steeringData:X,fuelData:G,startRefTime:D,startCompTime:A,timeDiff:es,extremePoints:{...J,compPointWhenRefFastest:K(J.refFastest,t,k),compPointWhenRefSlowest:K(J.refSlowest,t,k),refPointWhenCompFastest:K(J.compFastest,e,k),refPointWhenCompSlowest:K(J.compSlowest,e,k)},focusZoneIndices:ec}}function K(e,t){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.reduce((t,n)=>Math.abs(y(n,l)-y(e,l))<Math.abs(y(t,l)-y(e,l))?n:t,t[0])}function Y(e,t,l){return{ref:e&&Object.prototype.hasOwnProperty.call(e,"ground_speed")&&void 0!==e.ground_speed?(e.ground_speed||0)*n.LN[l]:null,comp:t&&Object.prototype.hasOwnProperty.call(t,"ground_speed")&&void 0!==t.ground_speed?(t.ground_speed||0)*n.LN[l]:null,refOther:e,compOther:t}}function ee(e,t,l,n){let r="number"==typeof(null==e?void 0:e.lap_time)&&Number.isFinite(e.lap_time),i="number"==typeof(null==t?void 0:t.lap_time)&&Number.isFinite(t.lap_time);return{ref:r?e.lap_time-l||0:null,comp:i?t.lap_time-n||0:null,refOther:e,compOther:t}}function et(e,t,l){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=(y(t,n)*(null!=l?l:1)).toFixed(1),i=(y(e,n)*(null!=l?l:1)).toFixed(1);return{ref:r?parseFloat(r):null,comp:i?parseFloat(i):null,refOther:e,compOther:t}}function el(e,t){return{ref:e&&Object.prototype.hasOwnProperty.call(e,"throttle_pos")&&void 0!==e.throttle_pos?100*(e.throttle_pos||0):null,comp:t&&Object.prototype.hasOwnProperty.call(t,"throttle_pos")&&void 0!==t.throttle_pos?100*(t.throttle_pos||0):null,refOther:e,compOther:t}}function en(e,t){return{ref:e&&Object.prototype.hasOwnProperty.call(e,"brake_pos")&&void 0!==e.brake_pos?100*(e.brake_pos||0):null,comp:t&&Object.prototype.hasOwnProperty.call(t,"brake_pos")&&void 0!==t.brake_pos?100*(t.brake_pos||0):null,refOther:e,compOther:t}}function er(e,t){return{ref:e&&Object.prototype.hasOwnProperty.call(e,"rpms")&&void 0!==e.rpms?e.rpms||0:null,comp:t&&Object.prototype.hasOwnProperty.call(t,"rpms")&&void 0!==t.rpms?t.rpms||0:null,refOther:e,compOther:t}}function ei(e,t){return{ref:e&&Object.prototype.hasOwnProperty.call(e,"gear")&&void 0!==e.gear?e.gear||0:null,comp:t&&Object.prototype.hasOwnProperty.call(t,"gear")&&void 0!==t.gear?t.gear||0:null,refOther:e,compOther:t}}function eo(e,t){return{ref:e&&Object.prototype.hasOwnProperty.call(e,"steering_angle")&&void 0!==e.steering_angle?e.steering_angle||0:null,comp:t&&Object.prototype.hasOwnProperty.call(t,"steering_angle")&&void 0!==t.steering_angle?t.steering_angle||0:null,refOther:e,compOther:t}}function ea(e,t){return{ref:e&&Object.prototype.hasOwnProperty.call(e,"fuel")&&void 0!==e.fuel?e.fuel||0:null,comp:t&&Object.prototype.hasOwnProperty.call(t,"fuel")&&void 0!==t.fuel?t.fuel||0:null,refOther:e,compOther:t}}function eu(e,t,l,n,r){return e===t?l:l+(n-l)*(r-e)/(t-e)}function es(e){let t=function(e){let t=[],l=0;for(let n=0;n<2e3;n++){let r=5e-4*n;if(r<e[0].car_position_normalized){t.push([0,1]);continue}if(r>e[e.length-1].car_position_normalized){t.push([e.length-2,e.length-1]);continue}for(;l<e.length-1&&e[l+1].car_position_normalized<=r;)l++;l<e.length-1?(e[l].car_position_normalized,e[l+1].car_position_normalized,t.push([l,l+1])):t.push([e.length-2,e.length-1])}return t}(e),l=[];
1if(0===e.length)return l;for(let n=0;n<2e3;n++){let r=5e-4*n,i=t[n][0],o=t[n][1],a=function(e,t,l){let n=l-e.car_position_normalized<t.car_position_normalized-l?e:t,r=e.car_position_normalized===t.car_position_normalized?0:(l-e.car_position_normalized)/(t.car_position_normalized-e.car_position_normalized);return{time_covered:eu(e.car_position_normalized,t.car_position_normalized,e.time_covered,t.time_covered,l),brake_pos:eu(e.car_position_normalized,t.car_position_normalized,e.brake_pos,t.brake_pos,l),rpm_pos:eu(e.car_position_normalized,t.car_position_normalized,e.rpm_pos,t.rpm_pos,l),gear:n.gear,ground_speed:eu(e.car_position_normalized,t.car_position_normalized,e.ground_speed,t.ground_speed,l),lap_time:eu(e.car_position_normalized,t.car_position_normalized,e.lap_time,t.lap_time,l),best_lap_time:n.best_lap_time,last_lap_time:n.last_lap_time,steering_angle:eu(e.car_position_normalized,t.car_position_normalized,e.steering_angle,t.steering_angle,l),throttle_pos:eu(e.car_position_normalized,t.car_position_normalized,e.throttle_pos,t.throttle_pos,l),car_coord_x:eu(e.car_position_normalized,t.car_position_normalized,e.car_coord_x,t.car_coord_x,l),car_coord_y:eu(e.car_position_normalized,t.car_position_normalized,e.car_coord_y,t.car_coord_y,l),car_coord_z:eu(e.car_position_normalized,t.car_position_normalized,e.car_coord_z,t.car_coord_z,l),session_lap_count:n.session_lap_count,car_position_normalized:l,abs_active:n.abs_active,tc_active:n.tc_active,fuel:eu(e.car_position_normalized,t.car_position_normalized,e.fuel,t.fuel,l),rpms:eu(e.car_position_normalized,t.car_position_normalized,e.rpms,t.rpms,l),heading:n.heading,map_heading:(0,S.XB)(e.map_heading,t.map_heading,r)}}(e[i],e[o],r);l.push(a)}return l}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.