PageSourceSearch

https://app.coresportsai.com/_next/static/chunks/14550.48e24023f5c53e0b.js

js coresportsai.com collected 2026-10-09 23:00:44 UTC 16,673 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[14550],{14550:(e,t,a)=>{a.r(t),a.d(t,{default:()=>h});var l=a(95155),n=a(12115),r=a(52812),i=a(55345),s=a(59953),o=a(92792),c=a(98729);function d(e){let{points:t,zoneShares:a,tPct:r=0,className:i}=e,s=(0,n.useRef)(null),[d,h]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e=s.current;if(!e)return;let l=e.getContext("2d");if(!l)return;let n=e.clientWidth||300,i=e.clientHeight||450,d=window.devicePixelRatio||1;if(e.width=Math.max(1,Math.round(n*d)),e.height=Math.max(1,Math.round(i*d)),l.setTransform(d,0,0,d,0,0),l.clearRect(0,0,n,i),t&&t.length>=20){(0,o.rm)(l,0,0,n,i,t,{radius:.16,alpha:.92}),h(!1);return}if(a){let e=function(e,t){let a=1|Math.abs(Object.values(e).reduce((e,t,a)=>31337*e+Math.round(997*t)+7*a|0,1009*t|0)),l=()=>(a^=a<<13,a^=a>>>17,((a^=a<<5)>>>0)/0x100000000),n=()=>{let e=Math.max(1e-9,l()),t=l(),a=Math.sqrt(-2*Math.log(e));return[a*Math.cos(2*Math.PI*t),a*Math.sin(2*Math.PI*t)]},r=Math.max(...Object.values(e).filter(Number.isFinite),t,1),i=[];if(t>0){let e=t/r,a=Math.max(12,Math.round(120*e));for(let t=0;t<a;t++){let[t,a]=n();i.push({x:Math.max(0,Math.min(1,.5+.055*t)),y:Math.max(0,Math.min(1,.38+.065*a)),weight:e})}}for(let[t,a]of Object.entries(e)){let e=c.$u[t];if(!e||!(a>0))continue;let n=e.x+e.w/2,s=e.y+e.h/2,o=a/r,d=Math.max(8,Math.round(90*o)),h=n-.5,u=s-.38,x=Math.sqrt(h*h+u*u)||1,p=-u/x,m=h/x;for(let t=0;t<d;t++){let t=Math.sqrt(l()),a=.5+h*t,n=.38+u*t,r=(l()-.5)*Math.min(e.w,e.h)*t*1;i.push({x:Math.max(0,Math.min(1,a+p*r)),y:Math.max(0,Math.min(1,n+m*r)),weight:o*(.55+.45*t)})}}return i}(a,r);if(e.length){(0,o.rm)(l,0,0,n,i,e,{radius:.28,alpha:.9,clipPercentile:.95}),h(!0);return}}h(!1)},[t,a,r]),(0,l.jsx)("canvas",{ref:s,className:i,style:{width:"100%",height:"100%",display:"block",filter:d?"blur(8px)":void 0,transform:d?"scale(1.05)":void 0},role:"img","aria-label":"Court heatmap"})}function h(e){var t;let{matchStats:a,matchData:o,selectedPlayer:c,playerName:h,playerColor:u,matchId:x}=e,{isAdmin:p,onSave:m,getOverride:g,setOverride:f}=(0,r.L)(),[v,b]=(0,n.useState)(!1),[M,y]=(0,n.useState)([]),[j,F]=(0,n.useState)(!1),{coverageData:N,tPositionPct:w}=(0,n.useMemo)(()=>{var e,t,l,n,r,i,s,o,d,h,u,x;let p="player1"===c?"player_1":"player_2",m=null==a?void 0:a._v2Data,g=null==m||null==(l=m.players)||null==(t=l[p])||null==(e=t.movement_heatmap)?void 0:e.by_zone_percentage,f
1=parseFloat(null!=(x=null!=(u=null==m||null==(i=m.players)||null==(r=i[p])||null==(n=r.t_position_control)?void 0:n.percentage)?u:null==a||null==(o=a.tPositionControl)||null==(s=o.tPositionScores)?void 0:s["player1"===c?"player1":"player2"])?x:0)||0,v=e=>e>1?e:100*e;if(g){let e=[{zone:"Front Left",count:0,percentage:v(g.FL||0)},{zone:"Front Right",count:0,percentage:v(g.FR||0)},{zone:"Mid Left",count:0,percentage:v(g.ML||0)},{zone:"Mid Right",count:0,percentage:v(g.MR||0)},{zone:"Back Left",count:0,percentage:v(g.BL||0)},{zone:"Back Right",count:0,percentage:v(g.BR||0)}],t=e.reduce((e,t)=>e+t.percentage,0),a=t>105?100/t:1;return{tPositionPct:f,coverageData:e.map(e=>({...e,percentage:(e.percentage*a).toFixed(1)}))}}let b="player1"===c?"player1":"player2",M=null==a||null==(h=a.tPositionControl)||null==(d=h.courtCoverage)?void 0:d[b];return M?{tPositionPct:f,coverageData:[{zone:"Front Left",count:0,percentage:v(M.frontLeft||0).toFixed(1)},{zone:"Front Right",count:0,percentage:v(M.frontRight||0).toFixed(1)},{zone:"Mid Left",count:0,percentage:v(M.midLeft||0).toFixed(1)},{zone:"Mid Right",count:0,percentage:v(M.midRight||0).toFixed(1)},{zone:"Back Left",count:0,percentage:v(M.backLeft||0).toFixed(1)},{zone:"Back Right",count:0,percentage:v(M.backRight||0).toFixed(1)}]}:{tPositionPct:f,coverageData:[{zone:"Front Left",count:0,percentage:"0.0"},{zone:"Front Right",count:0,percentage:"0.0"},{zone:"Mid Left",count:0,percentage:"0.0"},{zone:"Mid Right",count:0,percentage:"0.0"},{zone:"Back Left",count:0,percentage:"0.0"},{zone:"Back Right",count:0,percentage:"0.0"}]}},[a,c]),z="matchAnalysis.adminOverrides.heatmap_coverage_".concat(c),k=g(z),R=(0,n.useMemo)(()=>{let e="player1"===c?"player_1":"player_2";try{return(0,s.B)(null!=o?o:a,e)}catch(e){return{points:[],salvaged:!1,shares:null}}},[o,a,c]),P=R.salvaged&&R.shares?N.map((e,t)=>({...e,percentage:[R.shares.FL,R.shares.FR,R.shares.ML,R.shares.MR,R.shares.BL,R.shares.BR][t].toFixed(1)})):null,C=(null==k?void 0:k.zones)?N.map((e,t)=>{var a;return{...e,percentage:(null!=(a=k.zones[t])?a:parseFloat(e.percentage)).toFixed(1)}}):null!=P?P:N,L=(null==k?void 0:k.t)!=null?k.t:R.salvaged&&R.shares?R.shares.T:w,B=async()=>{F(!0);try{var e;let t={zones:M.slice(0,6),t:null!=(e=M[6])?e:L};f(z,t),m&&await m({analysisUpdates:{[z]:t}}),b(!1)}finally{F(!1)}},_=(0,n.useMemo)(()=>{var e,t,a,l,n,r,i,s,o,c,d,h;let u=parseFloat((null==(e=C[0])?void 0:e.percentage)||"0")+parseFloat((null==(t=C[1])?void 0:t.percentage)||"0"),x=parseFloat((null==(a=C[2])?void 0:a.percentage)||"0")+parseFloat((null==(l=C[3])?void 0:l.percentage)||"0"),p=parseFloat((null==(n=C[4])?void 0:n.percentage)||"0")+parseFloat((null==(r=C[5])?void 0:r.percentage)||"0");return{frontPct:u,midPct:x,backPct:p,leftPct:parseFloat((null==(i=C[0])?void 0:i.percentage)||"0")+parseFloat((null==(s=C[2])?void 0:s.percentage)||"0")+parseFloat((null==(o=C[4])?void 0:o.percentage)||"0"),rightPct:parseFloat((null==(c=C[1])?void 0:c.percentage)||"0")+parseFloat((null==(d=C[3])?void 0:d.percentage)||"0")+parseFloat((null==(h=C[5])?void 0:h.percentage)||"0")}},[C]),S=(0,n.useMemo)(()=>(null==k?void 0:k.zones)?[]:R.points,[R,k]),I=(0,n.useMemo)(()=>{var e,t,a,l,n,r;return{FL:parseFloat((null==(e=C[0])?void 0:e.percentage)||"0"),FR:parseFloat((null==(t=C[1])?void 0:t.percentage)||"0"),ML:parseFloat((null==(a=C[2])?void 0:a.percentage)||"0"),MR:parseFloat((null==(l=C[3])?void 0:l.percentage)||"0"),BL:parseFloat((null==(n=C[4])?void 0:n.percentage)||"0"),BR:parseFloat((null==(r=C[5])?void 0:r.percentage)||"0")}},[C]);if(!C.some(e=>parseFloat(e.percentage)>0))return(0,l.jsxs)("div",{className:"text-center text-muted-foreground text-sm py-8",children:["No movement data available for ",h,"."]});let D="heatmap_coverage_".concat(c),E={zones:C.map(e=>parseFloat(e.percentage)||0),t:L},T=null!=(t=({"#000000":"#94A3B8","#FFFFFF":"#E2E8F0"})[u])?t:u;return(0,l.jsxs)("div",{className:"space-y-6",children:[p&&R.salvaged&&!(null==k?void 0:k.zones)&&(0,l.jsxs)("p",{className:"rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-xs text-amber-200",children:["Admin only: the court calibration partly failed, so this 
1shows only the ",R.points.length," positions that landed on the court. Set the zones by hand to override."]}),p&&(0,l.jsx)("div",{className:"flex justify-end",children:v?(0,l.jsxs)("div",{className:"w-full rounded-lg border border-primary/30 bg-muted/20 p-4",children:[(0,l.jsx)("div",{className:"space-y-2 mb-3",children:["Front Left","Front Right","Mid Left","Mid Right","Back Left","Back Right","T Position"].map((e,t)=>{var a,n;return(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-[10px] text-white/60 w-20 shrink-0",children:e}),(0,l.jsx)("input",{type:"range",min:0,max:100,step:.1,value:null!=(a=M[t])?a:0,onChange:e=>{var a;return a=Number(e.target.value),void y(e=>{let l=[...e];l[t]=Math.min(100,Math.max(0,a));let n=Math.max(0,100-l[t]),r=[0,1,2,3,4,5,6].filter(e=>e!==t),i=r.reduce((e,t)=>{var a;return e+(null!=(a=l[t])?a:0)},0);if(i>0){let e=0;r.slice(0,-1).forEach(t=>{var a;let r=Math.round((null!=(a=l[t])?a:0)/i*n*10)/10;l[t]=r,e+=r}),l[r[r.length-1]]=Math.round((n-e)*10)/10}else{let e=Math.round(n/r.length*10)/10;r.forEach(t=>{l[t]=e})}return l})},className:"flex-1 h-1.5 accent-primary cursor-pointer"}),(0,l.jsxs)("span",{className:"text-[11px] font-mono text-primary w-10 text-right",children:[(null!=(n=M[t])?n:0).toFixed(1),"%"]})]},t)})}),(0,l.jsxs)("div",{className:"flex items-center justify-between mt-1",children:[(0,l.jsxs)("span",{className:"text-[10px] text-white/40",children:["Total: ",(0,l.jsxs)("span",{className:.2>Math.abs(M.reduce((e,t)=>e+(null!=t?t:0),0)-100)?"text-green-400":"text-orange-400",children:[M.reduce((e,t)=>e+(null!=t?t:0),0).toFixed(1),"%"]})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("button",{onClick:B,disabled:j,className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-xs font-medium disabled:opacity-50",children:j?"Saving…":"Save"}),(0,l.jsx)("button",{onClick:()=>b(!1),className:"px-2.5 py-1 rounded-md bg-white/10 text-foreground text-xs hover:bg-white/15",children:"Cancel"})]})]})]}):(0,l.jsx)("button",{"data-export-skip":!0,onClick:()=>{let e=[...C.map(e=>parseFloat(e.percentage)),L],t=e.reduce((e,t)=>e+t,0),a=t>0?e.map(e=>Math.round(e/t*1e3)/10):e,l=a.slice(0,-1).reduce((e,t)=>e+t,0);a[6]=Math.round((100-l)*10)/10,y(a),b(!0)},className:"admin-edit-control inline-flex items-center gap-1 text-[11px] font-medium px-2.5 py-1 rounded-md bg-primary/10 hover:bg-primary/25 text-primary transition-all",children:"✎ Edit coverage"})}),(0,l.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,l.jsxs)("div",{className:"relative w-full aspect-[2/3] max-w-[300px] mx-auto bg-slate-950 rounded-lg overflow-hidden border-2 border-slate-500",children:[(0,l.jsx)(d,{points:S,zoneShares:I,tPct:L,className:"absolute inset-0"}),(0,l.jsxs)("div",{className:"absolute inset-0 pointer-events-none",children:[(0,l.jsx)("div",{className:"absolute top-0 left-0 right-0 h-1.5 bg-slate-400/60"}),(0,l.jsx)("div",{className:"absolute inset-0 grid grid-cols-2 grid-rows-3",children:Array.from({length:6}).map((e,t)=>(0,l.jsx)("div",{className:"border border-white/10"},t))})]}),(0,l.jsx)("div",{className:"absolute top-[50%] left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-cyan-500/30 border border-cyan-400/60 flex items-center justify-center z-20 pointer-events-none",children:(0,l.jsx)("span",{className:"text-[10px] font-bold text-cyan-400",children:"T"})}),(0,l.jsx)("div",{className:"absolute top-1 left-1/2 -translate-x-1/2 text-xs text-white font-medium z-10",children:"Front Wall"}),(0,l.jsx)("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 text-xs text-white/80 z-10",children:"Back"})]}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"bg-white/5 rounded-lg p-4",children:[(0,l.jsx)("h4",{className:"font-semibold mb-3 text-sm text-white",children:"Court Coverage"}),(0,l.jsxs)("div",{className:"space-y-2",children:[L>0&&(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,l.jsx)("span",{className:"text-cyan-300 font-medium",children:"T Position (center)"}),(0,l.jsx)("span",{className:"font-bold text-cyan-400",children:(0,l.jsxs)(i.Fo,{k:D,value:L,type:"number",min:0,max:100,hint:"% of court time on the T",toValue:e=>({...E,t:e}),children:[L.toFixed(1),"%"]})})]}),(0,l.jsx)("div",{className:"w-full bg-white/10 rounded-full h-1.5",children:(0,l.jsx)("div",{className:"h-1.5 rounded-full bg-cyan-400 transition-all",style:{width:"".concat(Math.min(L,100),"%")}})})]}),C.map((e,t)=>{let a;return(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,l.jsx)("span",{className:"text-white/70",children:e.zone}),(0,l.jsx)("span",{className:"font-bold",style:{color:T},children:(a="".concat(e.percentage,"%"),(0,l.jsx)(i.Fo,{k:D,value:E.zones[t],type:"number",min:0,max:100,hint:"% of court time in this zone",toValue:e=>({...E,zones:E.zones.map((a,l)=>l===t?e:a)}),children:a}))})]}),(0,l.jsx)("div",{className:"w-full bg-white/10 rounded-full h-1.5",children:(0,l.jsx)("div",{className:"h-1.5 rounded-full transition-all",style:{width:"".concat(Math.min(parseFloat(e.percentage),100),"%"),backgroundColor:T}})})]},e.zone)})]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,l.jsxs)("div",{className:"bg-white/5 rounded-lg p-3 text-center",children:[(0,l.jsx)("div",{className:"text-2xl font-bold",style:{color:T},children:(0,l.jsxs)("span",{"data-ov-skip":!0,children:[_.frontPct.toFixed(1),"%"]})}),(0,l.jsx)("div",{className:"text-xs text-white/60",children:"Front Court"})]}),(0,l.jsxs)("div",{className:"bg-white/5 rounded-lg p-3 text-center",children:[(0,l.jsx)("div",{className:"text-2xl font-bold",style:{color:T},children:(0,l.jsxs)("span",{"data-ov-skip":!0,children:[_.midPct.toFixed(1),"%"]})}),(0,l.jsx)("div",{className:"text-xs text-white/60",children:"Mid Court"})]}),(0,l.jsxs)("div",{className:"bg-white/5 rounded-lg p-3 text-center",children:[(0,l.jsx)("div",{className:"text-2xl font-bold",style:{color:T},children:(0,l.jsxs)("span",{"data-ov-skip":!0,children:[_.backPct.toFixed(1),"%"]})}),(0,l.jsx)("div",{className:"text-xs text-white/60",children:"Back Court"})]}),(0,l.jsxs)("div",{className:"bg-white/5 rounded-lg p-3 text-center border border-cyan-500/20",children:[(0,l.jsx)("div",{className:"text-2xl font-bold text-cyan-400",children:(0,l.jsxs)(i.Fo,{k:D,value:L,type:"number",min:0,max:100,hint:"% of court time on the T",toValue:e=>({...E,t:e}),children:[L.toFixed(1),"%"]})}),(0,l.jsx)("div",{className:"text-xs text-white/60",children:"T Position"})]})]})]})]})]})}},92792:(e,t,a)=>{a.d(t,{rm:()=>s,xd:()=>o});let l=[[0,[0,0,0]],[.12,[40,40,140]],[.32,[40,70,220]],[.5,[30,160,120]],[.66,[120,200,60]],[.8,[240,220,60]],[.92,[250,140,40]],[1,[240,40,40]]];function n(){let e=new Uint8ClampedArray(768);for(let t=0;t<256;t++){let a=t/255,n=l[0],r=l[l.length-1];for(let e=0;e<l.length-1;e++)if(a>=l[e][0]&&a<=l[e+1][0]){n=l[e],r=l[e+1];break}let i=r[0]-n[0]||1,s=(a-n[0])/i;for(let a=0;a<3;a++)e[3*t+a]=n[1][a]+(r[1][a]-n[1][a])*s}return e}let r=null;function i(e,t){if("undefined"==typeof document)return null;let a=document.createElement("canvas");return a.width=Math.max(1,Math.round(e)),a.height=Math.max(1,Math.round(t)),a}function s(e,t,a,l,s,o){var c,d,h,u;let x,p,m=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{};if(!o||0===o.length)return!1;if(o.length>2500){let e=o.length/2500,t=[];for(let a=0;a<2500;a++)t.push(o[Math.floor(a*e)]);o=t}let g=i(l,s),f=null==g?void 0:g.getContext("2d",{willReadFrequently:!0});if(!g||!f)return!1;let v=Math.max(6,(null!=(c=m.radius)?c:.17)*l),b=null!=(d=m.alpha)?d:.85,M=Math.PI*v*v,y=Math.max(.004,Math.min(.06,.45/(2*Math.max(1,o.length*M/Math.max(1,l*s)))));for(let e=0;e<4;e++){for(let e of(f.clearRect(0,0,g.width,g.height),f.globalCompositeOperation="lighter",o)){let t=e.x*l,a=e.y*s;if(!Number.isFinite(t)||!Number.isFinite(a))continue;let n=Math.max(0,Math.min(1,null!=(h=e.weight)?h:1));if(n<=0)continue;let r=f.createRadialGradient(t,a,0,t,a,v),i=y*n;r.addColorStop(0,"rgba(0,0,0,".concat(i,")")),r.addColorStop(1,"rgba(0,0,0,0)"),f.fillStyle=r,f.beginPath(),f.arc(t,a,v,0,2*Math.PI),f.fill()}f.globalCompositeOperation="source-over",p=(x=f.getImageData(0,0,g.width,g.height)).data;let e=0,t=0;for(let a=3;a<p.length;a+=4)p[a]>0&&t++,p[a]>=254&&e++;if(0===t)return!1;if(e/t<=.02||y<=.004)break;y=Math.max(.004,y/2.5)}let j=0,F=null!=(u=m.clipPercentile)?u:.99;if(F<1){let e=new Uint32Array(256),t=0;for(let a=3;a<p.length;a+=4)p[a]>0&&(e[p[a]]++,t++);if(0===t)return!1;let a=0;for(let l=0;l<256;l++)if((a+=e[l])>=t*F){j=l;break}}else for(let e=3;e<p.length;e+=4)p[e]>j&&(j=p[e]);if(j<=0)return!1;r||(r=n());let N=r;for(let e=0;e<p.length;e+=4){let t=p[e+3];if(0===t)continue;let a=Math.min(255,Math.round(t/j*255));p[e]=N[3*a],p[e+1]=N[3*a+1],p[e+2]=N[3*a+2],p[e+3]=Math.round(Math.min(255,a<26?5*a:255)*b)}return f.putImageData(x,0,0),e.drawImage(g,t,a,l,s),!0}function o(e,t,a,l,s,o,c){var d,h;let u=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},x=Object.entries(o).filter(e=>
1{let[t,a]=e;return c[t]&&Number.isFinite(a)&&a>0});if(!x.length)return!1;let p=i(l,s),m=null==p?void 0:p.getContext("2d",{willReadFrequently:!0});if(!p||!m)return!1;let g=null!=(d=u.alpha)?d:.9,f=null!=(h=u.smoothing)?h:2.2,v=Math.max(...x.map(e=>{let[,t]=e;return t})),b=x.map(e=>{let[t,a]=e,l=c[t];return{cx:(l.x+l.w/2)*p.width,cy:(l.y+l.h/2)*p.height,v:a/v}});r||(r=n());let M=r,y=m.createImageData(p.width,p.height),j=y.data;for(let e=0;e<p.height;e++)for(let t=0;t<p.width;t++){let a=0,l=0,n=-1;for(let r=0;r<b.length;r++){let i=t-b[r].cx,s=e-b[r].cy,o=i*i+s*s;if(o<1){n=r;break}let c=1/Math.pow(o,f/2);a+=c*b[r].v,l+=c}let r=n>=0?b[n].v:l>0?a/l:0,i=(e*p.width+t)*4,s=Math.max(0,Math.min(255,Math.round(255*r)));j[i]=M[3*s],j[i+1]=M[3*s+1],j[i+2]=M[3*s+2],j[i+3]=Math.round(Math.min(255,s<40?3.2*s:255)*g)}return m.putImageData(y,0,0),e.drawImage(p,t,a,l,s),!0}}}]);

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.