PageSourceSearch

https://databallr.netlify.app/assets/RunCourt-DWLLAqhD.js

js databallr.netlify.app collected 2026-10-03 10:40:23 UTC 79,071 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/stage-aQVjsDok.js","assets/three.module-DQev7PIT.js","assets/rig-50zXqj1C.js","assets/sim-pXvfpYtz.js","assets/courtArt-DlPraTr5.js","assets/cityArt-B9vTRd04.js","assets/isoLook-CD6HoU32.js","assets/emotes-CKAVffNj.js","assets/index-BAz9GNw5.js","assets/index-BliKRkO6.css","assets/isoAudio-CxTfsJeM.js","assets/floorClock-D9il7TS0.js","assets/numbers-D7DKuouk.js","assets/isoInput-DRkc4nQw.js","assets/isoRender-DTAH5267.js"])))=>i.map(i=>d[i]);
2var Mn=Object.defineProperty;var wn=(s,t,i)=>t in s?Mn(s,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[t]=i;var x=(s,t,i)=>wn(s,typeof t!="symbol"?t+"":t,i);import{j as f,t as je,r as T,_ as Tn}from"./index-BAz9GNw5.js";import{h as xs,j as Nn,q as Sn,R as vs,e as On,c as An}from"./yoCareerRecSync-DSdRP-bI.js";import{I as Cn,p as Rn}from"./IsoScoreBug-Ddr2DarR.js";import{f as U,k as R,l as g,i as S,E as En,I as D,m as Q,F as Ae,g as Lt,y as bs,A as In,G as Me,z as Pn,H as _n,J as qs,t as at,K as zn,d as it,M as gs,N as Ln,O as Dn,P as Fn,j as Bn,n as ee,o as ks}from"./sim-pXvfpYtz.js";import{k as $n,I as Wn}from"./isoLook-CD6HoU32.js";import{d as js,e as Yn}from"./isoTeamLive-Bc5YddyP.js";import{t as Gn,v as Un,A as Hn,z as qn,B as Kn,C as Vn,D as Xn,q as Jn,m as Zn,G as Qn}from"./useIsoBracketRun-So1VaZ7D.js";import{u as ta,I as ea,i as sa,s as na}from"./isoControls-BP7MeWSE.js";import{I as aa,a as ia,b as ra,d as oa}from"./IsoBracketOutcome-BOvqI9ul.js";import{I as la}from"./isoRenderV2-BZGFtLa3.js";import{N as Ks}from"./numbers-D7DKuouk.js";import{i as ca}from"./isoApi-CAo-vWaU.js";import{a as ha,i as ua}from"./IsoV3-Bi989dcj.js";import{T as fa}from"./TournamentBanner-krhECk2K.js";import{u as da}from"./useBracketTournamentJoin-Qwuw-AS_.js";import{e as ma,f as pa}from"./isoHubRoutes-DiP5bu-D.js";import{c as ya}from"./isoBracketRun-CZp6j62Y.js";import{u as xa}from"./useIsoLook-BsdMlnIM.js";const va=[2,3,4,5],Ce=s=>s>=3?21:11,ba=s=>s<=3,we={size:5,target:Ce(5),speed:17,green:100,clock:14,capSeconds:720,tipoff:3},Ms=["windmill","spin","tomahawk","cradle"],ga=3.5,ka=.75,ja=44,Ma=7,ws=28,Vs=.7,Re=Vs/2,wa=.14,Ta=.035,Ts=4.5,Na=17,Sa=5,Oa=.4,Aa=.75,Ca=2,Ns=6,Ra=.6,Ea=.1,Ia=11.4,Xt=[25,31],xe=[7,23],ve=[43,23],Ss=[47.5,4],Pa=[17,7],_a=[33,7],Te={2:[Xt,ve],3:[Xt,xe,Ss],4:[Xt,xe,ve,_a],5:[Xt,xe,ve,Ss,Pa]},zt=s=>s===0?1:0,te=s=>[-s.fy,s.fx];function ht(s){let t=s.rng>>>0||2654435769;return t^=t<<13,t^=t>>>17,t^=t<<5,t>>>=0,s.rng=t,t/4294967296}const st=(s,t,i)=>t+ht(s)*(i-t);function V(s){return s.ball.state==="held"&&s.ball.owner>=0?s.ball.owner:-1}function za(s){const t=V(s);return t>=0?s.players[t]:null}const Tt=za;function mt(s,t){const i=s.cfg.size;return t<i?t+i:t-i}function yt(s,t){const i=s.players[t];let n=99;for(const a of s.players)a.team===i.team||a.fall||(n=Math.min(n,Math.hypot(a.x-i.x,a.y-i.y)));return n}function Ee(s,t,i){const n=s.players[t],a=s.players[i],e=a.x-n.x,r=a.y-n.y,l=e*e+r*r||1;let o=99;for(const h of s.players){if(h.team===n.team||h.fall)continue;const d=S(((h.x-n.x)*e+(h.y-n.y)*r)/l,.12,.92);o=Math.min(o,Math.hypot(h.x-(n.x+e*d),h.y-(n.y+r*d)))}return o}function ae(s,t,i=0,n=0){const a=s.players[t],e=Math.hypot(i,n);let r=-1,l=-1/0;for(let o=0;o<2&&r<0;o++){const h=o===0&&e>.35;if(!(o===0&&!h))for(let d=0;d<s.players.length;d++){const u=s.players[d];if(d===t||u.team!==a.team)continue;const m=u.x-a.x,p=u.y-a.y,c=Math.hypot(m,p)||1;let v;if(h){const b=(m*i+p*n)/(c*e);if(b<.3)continue;v=b*4-c*.02}else{const b=Math.min(yt(s,d),12),M=se(s,t,d),A=M?3:Ee(s,t,d);v=b-c*.1+(Q(u.x,u.y)?1:0)+(U(u.x,u.y)<8?1.5:0)+(M?3:0)-(A<3?(3-A)*2.5:0)}v>l&&(l=v,r=d)}}return r}function se(s,t,i){const n=s.players[t],a=s.players[i];if(!n||!a||t===i||a.team!==n.team||s.needClear||a.fall||a.z>.1||a.jumpT>=0||a.y<g.y+1)return!1;const e=U(a.x,a.y);if(e<8||e>20)return!1;const[r,l]=R(g.x-a.x,g.y-a.y);return a.vx*r+a.vy*l<10||yt(s,i)<4||Math.hypot(a.x-n.x,a.y-n.y)<10?!1:Ee(s,t,i)<6}function Ie(s,t,i){const n=s.players[t],a=s.players[i];return!n||!a||t===i||a.team!==n.team||s.needClear||a.fall||a.z>.1||a.jumpT>=0||a.y<g.y+1||U(a.x,a.y)>Na||yt(s,i)<Sa?!1:Math.hypot(a.x-n.x,a.y-n.y)>=6}function Pe(s,t,i=0,n=0){const a=s.players[t];
2if(!a)return-1;const e=Math.hypot(i,n);let r=-1,l=-1/0;for(let o=0;o<s.players.length;o++){if(!Ie(s,t,o))continue;const h=s.players[o],d=h.x-a.x,u=h.y-a.y,m=Math.hypot(d,u)||1;let p=Math.min(yt(s,o),10)*.5-U(h.x,h.y)*.25;const[c,v]=R(g.x-h.x,g.y-h.y);if(p+=S((h.vx*c+h.vy*v)/8,0,2),e>.35){const b=(d*i+u*n)/(m*e);if(b<.3)continue;p+=b*8}p>l&&(l=p,r=o)}return r}function Ne(s,t){const i=s.x+s.vx*t*.85,n=Math.max(s.y+s.vy*t*.85,g.y+1),a=i-g.x,e=n-g.y,r=Math.hypot(a,e)||1,l=S(r,1.6,7.5)/r;return[g.x+a*l,g.y+e*l]}function ct(s,t,i,n,a,e,r={}){if(!s)return;const l={k:"pop",text:t,team:i,x:n,y:a,z:e,size:r.size??1,life:r.life??.9};r.only!==void 0&&(l.only=r.only),s.push(l)}const G=(s,t,i,n,a)=>ct(s,i,n,t.x,t.y,t.z+9.6,a),F=(s,t,i=-1,n)=>{s&&s.push(n===void 0?{k:"sfx",name:t,team:i}:{k:"sfx",name:t,team:i,v:n})},Nt=(s,t)=>s==null?void 0:s.push({k:"shake",n:t});function La(s){return{team:s,x:25,y:30,vx:0,vy:0,fx:0,fy:-1,hand:1,inX:0,inY:0,move:null,moveCd:0,stumble:0,fall:!1,kind:"",reach:0,reachCd:0,whiff:!1,jumpT:-1,jumpDur:.62,jumpH:3,z:0,gather:null,sbT:0,fakeT:-9,leg:0,drib:0,shotPose:0,handVis:1,fake:0,fakeDur:.3,fakeAt:0,pend:null,buf:null,air:null}}const Os=()=>({fga:0,fgm:0,twos:0,fg3a:0,stl:0,blk:0,ank:0,tov:0,ast:0,poss:0}),Da=()=>({pts:0,ast:0,fgm:0,fga:0,stl:0,blk:0,fg3a:0,fg3m:0,tov:0});function _e(s,t={},i){const n={...we,...t},a=va.includes(n.size)?n.size:we.size;n.size=a,t.target===void 0&&(n.target=Ce(a));const e=[];for(let o=0;o<a*2;o++)e.push(La(o<a?0:1));const r={v:1,mode:"run",tick:0,time:0,score:[0,0],phase:"check",phaseT:0,needClear:!1,shotClock:0,possTeam:0,next:null,winner:-1,sudden:!1,rng:s>>>0||2654435769,netT:0,cfg:n,players:e,ball:{state:"held",owner:0,reserved:-1,looseT:0,x:25,y:30,z:3.6,vx:0,vy:0,vz:0,shot:null,pass:null,noPick:0,lastTouch:0},stats:[Os(),Os()],fire:[0,0],box:e.map(Da),feed:null,checks:[0,0]},l=i;return ze(r,l,void 0),r.stats[l].poss=1,r.phaseT=n.tipoff,r}function Fa(s){return JSON.parse(JSON.stringify(s))}function As(s,t,i){Object.assign(s,{x:t,y:i,vx:0,vy:0,move:null,moveCd:0,stumble:0,fall:!1,kind:"",reach:0,reachCd:0,whiff:!1,jumpT:-1,z:0,gather:null,sbT:0,fakeT:-9,hand:1,handVis:1,shotPose:0,inX:0,inY:0,fake:0,pend:null,buf:null,air:null});const[n,a]=R(g.x-t,g.y-i);s.fx=n,s.fy=a}function Ba(s,t){var i;return(((i=s.checks)==null?void 0:i[t])??0)%s.cfg.size}function Cs(s,t,i=!1){var l;const n=s.cfg.size,a=t<n?0:1,e=((l=s.checks)==null?void 0:l[a])??0,r=(i?e:Math.max(0,e-1))%n;return(t-a*n-r+n)%n}function ze(s,t,i){const n=s.cfg.size,a=Te[n],e=Ba(s,t),r=s.checks??(s.checks=[0,0]);r[t]++;for(let u=0;u<n;u++){const m=s.players[t*n+u],p=s.players[zt(t)*n+u],c=(u-e+n)%n,[v,b]=a[c];As(m,v,c===0?31.5:b);const[M,A]=R(g.x-m.x,g.y-m.y),E=c===0?4.3:4.2;As(p,m.x+M*E,m.y+A*E);const[N,w]=R(m.x-p.x,m.y-p.y);p.fx=N,p.fy=w}const l=s.players[t*n+e],o=s.ball;o.state="held",o.owner=t*n+e,o.shot=null,o.pass=null,o.noPick=0,o.lastTouch=t*n+e,o.reserved=-1,o.secure=Ae;const[h,d]=Lt(l);o.x=h,o.y=d,o.z=3.6,s.feed=null,s.oop=null,Zs(s,t),s.needClear=!1,s.shotClock=s.cfg.clock,s.phase="check",s.phaseT=.85,ct(i,"BALL",t,25,29.5,10,{size:.8,life:.85})}function Rs(s,t){s.phase="over",s.winner=t,s.next=null;for(const i of s.players)i.gather=null}function pt(s,t,i,n,a){if(t.fall||t.z>.3||t.gather||t.air)return!1;if(t.moveCd>0||t.move)return t.buf={m:i,side:n,until:s.time+.2},!1;t.fake>0&&(t.fake=0,t.fakeT=s.time),t.pend=null,t.buf=null;const[e,r]=te(t);let l,o,h,d;if(i==="cross"){const u=n||-t.hand;t.hand=u;const m=Math.max(0,t.inX*t.fx+t.inY*t.fy);[l,o]=R(e*u+t.fx*.6*m,r*u+t.fy*.6*m),h=.24,d=29,t.moveCd=.34}else i==="step"?(l=-t.fx,o=-t.fy,h=.22,d=25,t.sbT=.9,t.moveCd=.4):([l,o]=R(t.fx+.45*t.inX,t.fy+.45*t.inY),h=.34,d=27,t.moveCd=.48);return t.move={m:i,t:0,dur:h,dx:l,dy:o,spd:d,walled:!1},F(a,"squeak",t.team),i==="cross"&&$a(s,t,l,o,a),!0}function $a(s,t,i,n,a){for(const e of s.players){if(e.team===t.team||e.fall||Math.hypot(e.x-t.x,e.y-t.y)>7.5)continue;if(e.z<.5&&e.move&&e.move.m==="slide"&&e.move.dx*i+e.move.dy*n>.3){t.move.spd*=.55,G(a,e,"CUT OFF",e.team,{size:.85,life:.7});return}const r=e.vx*i+e.vy*n,l=!!e.move&&e.move.m==="slide"&&e.move.dx*i+e.move.dy*n<-.3;e.z<.5&&(e.reach>0||l)?(e.fall=!0,e.stumble=.8,e.kind="ankles",e.reach=0,e.move=null,G(a,e,"ANKLES!",t.team,{size:1.5,life:1.3}),Nt(a,11),F(a,"ooh"),s.stats[t.team].ank++):e.z<.5&&(r<-8||e.stumble>0&&e.kind==="reach")&&(e.stumble=Math.max(e.stumble,.22+.18*S((-r-8)/9,0,1)),e.kind="crossed",G(a,e,"CROSSED",t.team,{size:.95}))}}function Es(s,t,i,n){s.moveCd>0||s.move||s.fall||s.z>.3||s.stumble>0||(s.move={m:"slide",t:0,dur:.2,dx:t,dy:i,spd:29.5,walled:!1},s.moveCd=.4,F(n,"squeak",s.team))}function Is(s,t,i){if(t.jumpT>=0||t.fall||t.stumble>.2||t.z>.1)return;t.jumpT=0,t.jumpDur=.62,t.jumpH=3.4,t.move=null;const n=Tt(s);n&&n.team!==t.team&&!n.gather&&(n.fake>0||s.time-n.fakeT<.45)&&Math.hypot(n.x-t.x,n.y-t.y)<8&&G(i,t,"BIT ON IT",n.team,{size:.9})}function Wa(s,t){if(t.reachCd>0||t.fall||t.z>.3)return;t.reach=.2,t.reachCd=.85;const i=Tt(s);t.sq=i&&i.team!==t.team?0:void 0}function Ya(s,t,i){if(t.sq===void 0)return;const n=V(s),a=n>=0?s.players[n]:null;if(!a||a.team===t.team){t.sq=void 0;return}const e=zn({tick:s.tick,ball:{secure:s.ball.secure}},a,t,0),r=t.sq;if(t.reach>0&&(e>r||e===0&&r===0)){t.sq=e;return}if(t.sq=void 0,ht(s)<Math.max(e,r)){const[l,o]=Lt(a);a.gather=null,a.pend=null,a.fake=0,a.buf=null;const[h,d]=R(t.x-l+st(s,-1,1),t.y-o+st(s,-1,1));Object.assign(s.ball,{state:"loose",owner:-1,x:l,y:o,z:2.4,vx:h*11,vy:d*11,vz:3,noPick:.16,lastTouch:s.players.indexOf(t),reserved:-1,looseT:0}),G(i,a,"STRIPPED",t.team,{size:1.05}),F(i,"strip"),Nt(i,5),s.stats[t.team].stl++,s.stats[a.team].tov++,s.box[s.players.indexOf(t)].stl++,s.box[s.players.indexOf(a)].tov++}else Math.hypot(a.x-t.x,a.y-t.y)<6&&(t.whiff=!0)}function Le(s,t){const i=U(t.x,t.y),n=!!t.gather&&t.gather.layup,a=n?i<6?1.9:1.5:i<6?1.9:i<14?1.15:i<25.5?.9:Math.max(.2,.6-.06*(i-25.5)),[e,r]=R(g.x-t.x,g.y-t.y);let l=0;for(const h of s.players){if(h.team===t.team)continue;const d=Math.hypot(h.x-t.x,h.y-t.y);let u=S((7.5-d)/5,0,1);if(u<=0)continue;const[m,p]=R(h.x-t.x,h.y-t.y);u*=S(.35+.65*(e*m+r*p),0,1),h.z>.5&&(u=Math.min(1,u+.25)),(h.stumble>0||h.fall)&&(u*=.25),l=Math.max(l,u)}let o=.075*a*(1-.62*l)*(s.cfg.green/100);return t.sbT>0&&(o*=.9),t.gather&&!n&&t.gather.lat>10&&(o*=.85),En(s,t.team)&&(o*=Fn),{hw:o,c:l,dr:i}}function Xs(s,t,i,n,a=i){if(t.gather||t.air||t.z>.3||t.fall)return;if(s.needClear&&!Q(t.x,t.y)){G(n,t,"CLEAR IT FIRST",t.team,{size:.75,life:.8,only:t.team});return}if(t.move&&t.move.t/t.move.dur<.5){t.pend={pre:i,t0:s.time};return}t.move=null,t.fake=0,t.pend=null,t.buf=null;const e=U(t.x,t.y),[r,l]=R(g.x-t.x,g.y-t.y),o=t.vx*r+t.vy*l,h=Math.abs(-t.vx*l+t.vy*r),d=e<5||e<11&&o>7,u=d?.2:.18,m=d?.58:.6;t.gather={t:i,ground:u,jd:m,fill:(u+m/2)/it,lat:h,layup:d,jumped:!1,hid:a}}function Jt(s,t){t.gather&&!t.gather.jumped&&(t.gather=null,t.fakeT=s.time)}function Ps(s,t){t.gather||t.air||t.move||t.fake>0||t.z>.3||t.fall||(t.fake=t.fakeDur=.32,t.fakeAt=s.time)}function Ga(s,t){const i=t.gather;t.gather=null,t.fake=t.fakeDur=.26,t.fakeAt=s.time-(i?i.t:0)}const Ua=s=>S(1-.05*(s-Dn),.4,1);function Se(s,t,i,n,a){const e=s.players[t],r=e.gather;if(!r)return;const o=(i===void 0?r.t:S(i,r.t-gs,r.t+gs))/r.fill,h=Le(s,e),d=Math.abs(o-it),u=r.layup;let m,p;const c=Ua(h.dr);d<=h.hw?(m="GREEN",p=1):d<=h.hw*2.4?(m=o<it?"EARLY":"LATE",p=.4*(1-.55*h.c)*c+(u?.15:0)):(m=o<it?"WAY EARLY":"WAY LATE",p=.05*c+(u?.1:0));const v=Q(e.x,e.y)?3:2;v===3&&(p=Ln(e.x,e.y,m,p));const b=ht(s)<p;e.gather=null,e.shotPose=.5,e.move=null,e.air={layup:u}
2,r.jumped||(e.jumpT=0,e.jumpDur=.4,e.jumpH=1.2);const M=s.ball;Object.assign(M,{state:"shot",owner:-1,x:e.x+e.fx*.4,y:e.y+e.fy*.4,z:e.z+7.4,lastTouch:t}),M.shot={shooter:e.team,by:t,t:0,dur:.5+h.dr*.021,x0:M.x,y0:M.y,z0:M.z,make:b,pts:v,grade:m,apex:u?at+1.5+h.dr*.12:at+2.5+h.dr*.2,layup:u,rolled:!1,hid:r.hid},F(n,"release",e.team),s.stats[e.team].fga++,s.box[t].fga++,v===3&&(s.stats[e.team].fg3a=(s.stats[e.team].fg3a??0)+1,s.box[t].fg3a++),n==null||n.push({k:"flash",team:e.team,m:o,lo:it-h.hw,hi:it+h.hw,grade:m,by:t})}function Oe(s,t,i,n,a=!1){const e=s.players[t],r=s.players[i];if(e.fall||e.air)return;e.gather&&(e.gather=null),e.move=null,e.fake=0,e.pend=null,e.buf=null;const[l,o]=Lt(e),h=Math.hypot(r.x-l,r.y-o),d=a?Ie(s,t,i):se(s,t,i);if(a&&!d)return;let u,m,p;d?([m,p]=Ne(r,S(h/ws,.45,1.1)),u=S(Math.hypot(m-l,p-o)/ws,.45,1.1),a&&(u=S(Math.max(u,Math.hypot(m-r.x,p-r.y)/s.cfg.speed+.3),.55,1.6)),[m,p]=Ne(r,u)):(u=S(h/ja,.16,.8),m=S(r.x+r.vx*u*.85,1.5,48.5),p=S(r.y+r.vy*u*.85,1.2,44));const c=Math.hypot(m-l,p-o),v=s.ball;Object.assign(v,{state:"pass",owner:-1,x:l,y:o,z:e.z+4.4,vx:0,vy:0,vz:0,lastTouch:t,shot:null}),v.pass={from:t,to:i,t:0,dur:u,x0:l,y0:o,z0:v.z,x1:m,y1:p,z1:d?Ia:4.4,arc:d?3+c*.08:c>22?2.4+(c-22)*.12:.5,seen:[]},d&&(v.pass.lob={arrive:s.time+u-D},G(n,r,"OOP",r.team,{size:.9,life:u,only:r.team})),e.hand=Math.sign((m-e.x)*-e.fy+(p-e.y)*e.fx)||e.hand,F(n,"thump",e.team,.55)}function Js(s,t,i){var e;const n=(e=s.ball.pass)==null?void 0:e.lob,a=s.players[t];!n||n.jump!==void 0||a.jumpT>=0||a.fall||a.z>.1||(n.jump=s.time-i,a.jumpT=i,a.jumpDur=Vs,a.jumpH=3.6,a.move=null)}function Ha(s){const t=s.ball.state==="pass"?s.ball.pass:null,i=t==null?void 0:t.lob;if(!t||!i||i.jump!==void 0)return;const n=s.players[t.to];if(n.fall)return;const a=t.x1-n.x,e=t.y1-n.y,r=Math.hypot(a,e),l=r>.3?Math.min(1,r/1.5)/r:0;n.inX=a*l,n.inY=e*l,s.time>=i.arrive-Re+Ea&&(Js(s,t.to,0),i.jump!==void 0&&(i.auto=!0))}function qa(s,t){const i=s.ball,n=i.pass,a=n.lob,e=s.players[n.to],r=e.team;let l=0,o=-1;for(let v=0;v<s.players.length;v++){const b=s.players[v];if(b.team===r)continue;const M=Me(b,i);M>l&&(l=M,o=v)}if(o>=0&&ht(s)<.8*l){const v=s.players[o],[b,M]=R(i.x-v.x+st(s,-1,1),i.y-v.y+st(s,-1,1)+.01);Object.assign(i,{state:"loose",owner:-1,pass:null,vx:b*10,vy:M*10,vz:3,noPick:.2,lastTouch:o,reserved:-1,looseT:0}),G(t,v,"REJECTED",v.team,{size:1.15}),F(t,"swat"),Nt(t,6),s.stats[v.team].stl++,s.stats[r].tov++,s.box[o].stl++,s.box[n.from].tov++;return}const h=a.jump===void 0?1/0:a.jump+Re-a.arrive,d=Math.hypot(e.x-i.x,e.y-i.y);if(Math.abs(h)>wa||d>Ts||e.fall){const[v,b]=R(n.x1-n.x0,n.y1-n.y0);Object.assign(i,{state:"loose",owner:-1,pass:null,vx:v*4,vy:b*4,vz:-1,noPick:.35,reserved:-1,looseT:0}),G(t,e,h===1/0||d>Ts?"SAILED":"OFF HANDS",r,{size:.9});return}const u=!a.auto&&Math.abs(h)<=Ta;let m=0;for(const v of s.players){if(v.team===r||v.fall)continue;const b=Math.hypot(v.x-e.x,v.y-e.y);m=Math.max(m,S((Ns-b)/(Ns-Ca),0,1))}const{from:p,to:c}=n;ne(s,c,.35,t),s.feed={from:p,to:c,t:s.time},s.oop={by:c,style:u?Ms[Math.floor(ht(s)*Ms.length)]:"power",perfect:u,auto:!!a.auto,body:m,t:s.time},e.move=null,e.fake=0,e.pend=null,e.buf=null,e.gather={t:0,ground:0,jd:e.jumpDur,fill:1,lat:0,layup:!0,fin:"dunk",jumped:!0,hid:0},F(t,"thump",r,.6)}function _s(s,t,i){const n=s.players[t],a=s.oop;n.gather=null,n.shotPose=.5,n.move=null,n.air={layup:!0};const e=a.perfect?1:a.auto?Oa:Aa,r=ht(s)<e*(1-Ra*(a.body??0)),l=s.ball;Object.assign(l,{state:"shot",owner:-1,x:n.x+n.fx*.4,y:n.y+n.fy*.4,z:n.z+7.4,lastTouch:t}),l.shot={shooter:n.team,by:t,t:0,dur:a.perfect?.62:.3,x0:l.x,y0:l.y,z0:l.z,make:r,pts:2,grade:"GREEN",apex:at+.8,layup:!0,fin:"dunk",rolled:!0,hid:0},F(i,"release",n.team),s.stats[n.team].fga++,s.box[t].fga++}function Ka(s,t,i,n,a){var o,h,d;const e=s.players[t],r=s.ball.state==="held"&&s.ball.owner===t;if((s.ball.state==="pass"&&((o=s.ball.pass)==null?void 0:o.to)===t?s.ball.pass.lob:void 0)&&(i.t==="holdStart"||i.t==="jump"||i.t==="tap"||i.t==="swipe"&&Number.isFinite(i.sx)&&Number.isFinite(i.sy)&&i.sy<-Math.abs(i.sx)*1.1)){const u=i.t==="holdStart"&&typeof i.pre=="number"&&Number.isFinite(i.pre)?S(i.pre,0,.25):0;Js(s,t,u);return}if(!(r&&e.gather&&((h=s.oop)==null?void 0:h.by)===t))switch(i.t){case"holdStart":r&&Xs(s,e,S(i.pre??0,0,.25),n);break;case"holdEnd":{const u=e.gather,m=typeof i.held=="number"&&Number.isFinite(i.held)?i.held:void 0;u?u.jumped||m!==void 0&&m>=u.ground?Se(s,t,m,n):Ga(s,e):e.pend=null;break}case"fake":r&&Ps(s,e);break;case"pass":{const u=typeof i.to=="number"&&Number.isInteger(i.to)&&i.to!==t&&((d=s.players[i.to])==null?void 0:d.team)===e.team?i.to:-1,m=s.ball;if(!r&&m.state==="pass"&&m.pass&&m.pass.to===t){m.pass.next=u;break}if(!r)break;const p=u>=0?u:ae(s,t,e.inX,e.inY);p>=0&&Oe(s,t,p,n);break}case"oop":{if(!r)break;const u=typeof i.to=="number"&&Number.isInteger(i.to)&&Ie(s,t,i.to)?i.to:Pe(s,t,e.inX,e.inY);u>=0&&Oe(s,t,u,n,!0);break}case"swipe":{const u=S(i.sx,-1e4,1e4),m=S(i.sy,-1e4,1e4);
2if(r)if(e.pend=null,e.gather&&Jt(s,e),Math.abs(u)>Math.abs(m)*.9){const[p,c]=te(e);pt(s,e,"cross",Math.sign(p*u+c*m)||1,n)}else m>0?pt(s,e,"step",0,n):pt(s,e,"drive",0,n);else if(m<-Math.abs(u)*1.1)Is(s,e,n);else{const[p,c]=R(u,m);Es(e,p,c,n)}break}case"cross":if(r){e.pend=null,e.gather&&Jt(s,e);let u=i.side===1||i.side===-1?i.side:0;if(!u){const[m,p]=te(e),c=m*e.inX+p*e.inY;u=Math.abs(c)>.3?Math.sign(c):-e.hand}pt(s,e,"cross",u,n)}break;case"step":r&&(e.pend=null,e.gather&&Jt(s,e),pt(s,e,"step",0,n));break;case"drive":r&&(e.pend=null,e.gather&&Jt(s,e),pt(s,e,"drive",0,n));break;case"tap":r?Ps(s,e):Wa(s,e);break;case"jump":r||Is(s,e,n);break;case"slide":if(!r){let u=e.inX,m=e.inY;if(Math.hypot(u,m)<.2){const p=Tt(s);if(!p)break;const[c,v]=te(p),b=Math.sign((e.x-p.x)*c+(e.y-p.y)*v)||1;u=c*b,m=v*b}[u,m]=R(u,m),Es(e,u,m,n)}break}}function zs(s,t,i,n,a){var b,M,A,E,N;const e=s.players[t];if(e.moveCd=Math.max(0,e.moveCd-i),e.reachCd=Math.max(0,e.reachCd-i),e.sbT=Math.max(0,e.sbT-i),e.shotPose=Math.max(0,e.shotPose-i),e.reach>0&&(e.reach-=i,Ya(s,e,n),e.reach<=0&&e.whiff&&(e.whiff=!1,e.stumble=.25,e.kind="reach")),e.stumble>0&&(e.stumble-=i,e.stumble<=0&&(e.fall=!1,e.kind="")),e.handVis+=S(e.hand-e.handVis,-i*9,i*9),e.fake>0&&(e.fake-=i,e.fake<=0&&(e.fake=0,e.fakeT=s.time)),e.pend&&(!e.move||e.move.t/e.move.dur>=.5)){const w=e.pend;e.pend=null,e.move=null,Xs(s,e,w.pre+(s.time-w.t0),n,w.pre)}if(e.buf){if(s.time>e.buf.until||!(s.ball.state==="held"&&s.ball.owner===t))e.buf=null;else if(!e.move&&e.moveCd<=0){const w=e.buf;e.buf=null,pt(s,e,w.m,w.side,n)}}if(e.gather){const w=e.gather;w.t+=i,!w.jumped&&w.t>=w.ground&&(w.jumped=!0,e.jumpT=0,e.jumpDur=w.jd,e.jumpH=w.layup?2.8:2.3),((b=s.oop)==null?void 0:b.by)===t?w.t>=.06&&_s(s,t,n):w.t/w.fill>1.3&&Se(s,t,void 0,n)}const r=((M=s.oop)==null?void 0:M.by)===t&&s.ball.state==="shot"&&((A=s.ball.shot)==null?void 0:A.by)===t;if(e.jumpT>=0&&!r){e.jumpT+=i;const w=e.jumpT/e.jumpDur;w>=1?(e.jumpT=-1,e.z=0,e.gather&&(((E=s.oop)==null?void 0:E.by)===t?_s(s,t,n):Se(s,t,void 0,n)),e.air=null):e.z=4*e.jumpH*w*(1-w)}const l=Tt(s),o=s.ball;let h,d;l===e||!l&&o.state==="shot"&&((N=o.shot)==null?void 0:N.by)===t?(h=g.x-e.x,d=g.y-e.y):l?(h=l.x-e.x,d=l.y-e.y):o.state==="loose"||o.state==="pass"?(h=o.x-e.x,d=o.y-e.y):(h=g.x-e.x,d=g.y-e.y);const[u,m]=R(h,d),p=Math.min(1,i*14);[e.fx,e.fy]=R(e.fx+(u-e.fx)*p,e.fy+(m-e.fy)*p);let c=1;e.fall?c=0:e.stumble>0&&(c=.35),e.fake>0&&(c=Math.min(c,.35)),e.reach>0&&(c=Math.min(c,.7));const v=s.cfg.speed*(l===e?.96:1.05)*c;if(e.gather||e.air)Va(e);else if(e.move){const w=e.move;w.t+=i;const z=w.t/w.dur,rt=w.spd*(1-.45*z)*(e.stumble>0?.5:1),B=1-Math.exp(-i*30);e.vx+=(w.dx*rt-e.vx)*B,e.vy+=(w.dy*rt-e.vy)*B,z>=1&&(e.move=null)}else{let w=e.inX,z=e.inY;const rt=Math.hypot(w,z);rt>1&&(w/=rt,z/=rt);const B=e.z>.3?1.2:c<.5?7:12.5,xt=1-Math.exp(-i*B);e.vx+=(w*v-e.vx)*xt,e.vy+=(z*v-e.vy)*xt}e.x=S(e.x+e.vx*i,1,49),e.y=S(e.y+e.vy*i,.8,45),e.leg+=Math.hypot(e.vx,e.vy)*i*.75}function Va(s,t){var n;if(s.gather?s.gather.layup:!!((n=s.air)!=null&&n.layup)){const a=g.x-s.x,e=g.y+1.6-s.y,r=Math.hypot(a,e),l=r>.6?S(Math.hypot(s.vx,s.vy),7,13):0,o=1-Math.exp(-.008333333333333333*8);s.vx+=((r>.6?a/r*l:0)-s.vx)*o,s.vy+=((r>.6?e/r*l:0)-s.vy)*o}else{const a=Math.exp(-.008333333333333333*(s.z<.05&&s.jumpT<0?5:2.5));s.vx*=a,s.vy*=a}}function Ls(s,t){const i=s.players,n=Tt(s),a=2.4;for(let e=0;e<i.length;e++)for(let r=e+1;r<i.length;r++){const l=i[e],o=i[r];if(l.fall||o.fall||Math.abs(l.z-o.z)>2)continue;let h=o.x-l.x,d=o.y-l.y,u=Math.hypot(h,d);if(u>=a)continue;u<1e-4&&(h=0,d=1,u=1e-4);const m=h/u,p=d/u,c=a-u;if(n&&(n===l||n===o)&&l.team!==o.team&&n.move){const M=n===l?o:l;_n(n,M)&&(n.move.walled=!0,n.move.t=n.move.dur,n.vx*=.2,n.vy*=.2,G(t,M,"WALLED",M.team,{size:.8,life:.7}))}l.x-=m*c*.5,l.y-=p*c*.5,o.x+=m*c*.5,o.y+=p*c*.5;const v=l.vx*m+l.vy*p;v>0&&(l.vx-=v*m,l.vy-=v*p);const b=o.vx*m+o.vy*p;b<0&&(o.vx-=b*m,o.vy-=b*p)}}function Zs(s,t){s.possTeam=t;const i=s.stats[t];i.poss=(i.poss??0)+1}function ne(s,t,i,n){const a=s.players[t],e=s.ball;e.state="held",e.owner=t,e.shot=null,e.pass=null,e.reserved=-1,e.lastTouch=t,e.secure=i,a.gather=null,s.oop=null,a.team!==s.possTeam&&(Zs(s,a.team),s.feed=null,s.shotClock=s.cfg.clock,s.needClear=!Q(a.x,a.y),s.needClear&&G(n,a,"CLEAR IT",a.team,{size:.8,only:a.team}))}function Xa(s,t,i){const n=s.players[t].team!==s.possTeam||s.ball.lastTouch!==t;ne(s,t,Ae,i),n&&(s.shotClock=s.cfg.clock),s.feed=null}function Ja(s,t,i){const n=s.players[t],a=s.ball,[e,r]=R(a.x-n.x+st(s,-1.5,1.5),a.y-n.y+st(s,-1.5,1.5)+.01),l=st(s,12,17);Object.assign(a,{state:"loose",owner:-1,shot:null,vx:e*l,vy:r*l,vz:5,z:Math.max(a.z,8),noPick:.22,lastTouch:t,reserved:-1,looseT:0}),G(i,n,"SWATTED",n.team,{size:1.2}
2),F(i,"swat"),Nt(i,7),s.stats[n.team].blk++,s.box[t].blk++,qs(s,n.team===0?1:0,!1)}function Za(s,t){var e;const i=s.ball,n=i.shot;if(!n)return;const a=n.shooter;if(qs(s,a,n.make),n.make){s.score[a]+=n.pts,s.stats[a].fgm++,n.pts===3&&s.stats[a].twos++;const r=s.box[n.by];r.fgm++,n.pts===3&&r.fg3m++,r.pts+=n.pts;const l=s.feed;if(l&&l.to===n.by&&s.time-l.t<=ga&&(s.box[l.from].ast++,s.stats[a].ast++,G(t,s.players[l.from],"ASSIST",a,{size:.7,life:.9})),t==null||t.push({k:"score",team:a,pts:n.pts}),ct(t,"+"+n.pts,a,g.x,g.y,at+3.5,{size:1.45,life:1.1}),n.fin==="dunk"){s.stats[a].dnk=(s.stats[a].dnk??0)+1;const d=((e=s.oop)==null?void 0:e.by)===n.by?s.oop:null,u=!!(d!=null&&d.perfect);ct(t,u?d.style.toUpperCase():"ALLEY-OOP",a,g.x,g.y,at+7,{size:u?1.4:1.1,life:u?1.4:1.1}),F(t,"slam"),Nt(t,u?12:6)}else n.grade==="GREEN"&&ct(t,"SWISH",a,g.x,g.y,at+7,{size:.75,life:1});Object.assign(i,{state:"net",owner:-1,shot:null,x:g.x,y:g.y,z:at-.2,vx:0,vy:1.6,vz:-4}),s.netT=.7,F(t,"swish"),s.phase="dead",s.phaseT=1.15;const o=s.score[a]>=s.cfg.target||s.sudden,h=ba(s.cfg.size)?a:zt(a);s.next=o?{kind:"over",winner:a}:{kind:"check",team:h}}else{const r=st(s,.12*Math.PI,.88*Math.PI),l=st(s,5,10);Object.assign(i,{state:"loose",owner:-1,shot:null,x:g.x+Math.cos(r)*.9,y:g.y+Math.sin(r)*.9,z:at,vx:Math.cos(r)*l,vy:Math.sin(r)*l,vz:st(s,4,8),noPick:.12,reserved:-1,looseT:0}),ct(t,n.fin==="dunk"?"RIMMED OUT":n.grade==="GREEN"?"IN & OUT":"BOARD",-1,g.x,g.y,at+5,{size:.75}),F(t,"clank")}}function Qa(s,t,i){const n=s.ball,a=n.pass;a.t+=t;const e=s.players[a.to];if(!e.fall){const h=Math.max(0,a.dur-a.t),[d,u]=a.lob?Ne(e,h):[S(e.x+e.vx*h*.85,1.5,48.5),S(e.y+e.vy*h*.85,1.2,44)],m=Math.min(1,t*Ma);a.x1+=(d-a.x1)*m,a.y1+=(u-a.y1)*m}const r=Math.min(1,a.t/a.dur);n.x=a.x0+(a.x1-a.x0)*r,n.y=a.y0+(a.y1-a.y0)*r,n.z=a.z0+(a.z1-a.z0)*r+4*a.arc*r*(1-r);const l=s.players[a.from].team;if(r>.1&&!(a.lob&&r>.5))for(let h=0;h<s.players.length;h++){const d=s.players[h];if(d.team===l||d.fall||a.seen.includes(h))continue;const u=d.reach>0?3.1:1.9,m=Math.hypot(d.x-n.x,d.y-n.y);if(m>=u||n.z>8.4+d.z)continue;a.seen.push(h);const p=(d.reach>0?.42:.12)*S((u-m)/u*1.6,.25,1)*(d.stumble>0?.3:1);if(ht(s)<p){const c=s.players[a.from];ne(s,h,Ae,i),G(i,d,"PICKED OFF",d.team,{size:1.05}),F(i,"strip"),Nt(i,5),s.stats[d.team].stl++,s.stats[c.team].tov++,s.box[h].stl++,s.box[a.from].tov++;return}}if(a.lob){r>=1&&qa(s,i);return}const o=Math.hypot(e.x-n.x,e.y-n.y);if(r>.5&&o<1.8||r>=1){if(o<3.8&&!e.fall&&Math.abs(n.z-(e.z+4.2))<5){const{from:u,to:m,next:p}=a;if(ne(s,m,.35,i),s.feed={from:u,to:m,t:s.time},F(i,"thump",e.team,.5),p!==void 0){const c=p>=0&&p!==m?p:ae(s,m,e.inX,e.inY);c>=0&&Oe(s,m,c,i)}return}const h=(a.x1-a.x0)/a.dur*.55,d=(a.y1-a.y0)/a.dur*.55;Object.assign(n,{state:"loose",owner:-1,pass:null,vx:h,vy:d,vz:0,noPick:.05,reserved:-1,looseT:0})}}function be(s,t,i){const n=s.ball;if(n.noPick=Math.max(0,n.noPick-t),n.state==="held"&&n.owner>=0){const a=s.players[n.owner],[e,r]=Lt(a);if(a.gather||a.fake>0){const l=a.gather?S(a.gather.t/(a.gather.ground+.18),0,1):Math.sin(Math.PI*(1-a.fake/a.fakeDur))*.75,o=1-(1-l)*(1-l),h=a.x+a.fx*.35,d=a.y+a.fy*.35;n.x=e+(h-e)*o,n.y=r+(d-r)*o,n.z=a.z+3.2+3.9*o}else if(s.phase==="check")n.x=e,n.y=r,n.z=3.6;else{const l=Math.hypot(a.vx,a.vy),o=a.drib;a.drib+=t*(2+l*.1),Math.floor(a.drib)!==Math.floor(o)&&F(i,"thump",a.team),n.x=e,n.y=r;const h=Math.abs(a.handVis);n.z=h<.98?.35+2.6*h:.35+3*Math.abs(Math.sin(a.drib%1*Math.PI))}return}if(n.state==="pass"&&n.pass){Qa(s,t,i);return}if(n.state==="shot"&&n.shot){const a=n.shot;a.t+=t;const e=Math.min(1,a.t/a.dur),r=bs(a,a.t);if(n.x=r.x,n.y=r.y,n.z=r.z,!a.rolled){const l=a.t-In-(a.hid??0),o=bs(a,l);let h=0,d=-1,u=l<0;if(r.up)for(let p=0;p<s.players.length;p++){const c=s.players[p];if(c.team===a.shooter)continue;const v=Math.max(Me(c,r),l>=0?Me(c,o):0);v>h&&(h=v,d=p),(c.x-o.x)*(g.x-a.x0)+(c.y-o.y)*(g.y-a.y0)>0&&Math.hypot(c.x-o.x,c.y-o.y)<7&&(u=!0)}const m=a.bq??0;if(r.up&&e<1&&(h>=m||u))h>=m&&h>0&&(a.bq=h,a.bi=d);else if(m>0||!r.up||e>=1){a.rolled=!0;const p=Q(a.x0,a.y0)?1:ka;if(m>0&&a.bi!==void 0&&ht(s)<Pn*p*m){Ja(s,a.bi,i);return}}}e>=1&&Za(s,i);return}if(n.state==="loose"&&(n.looseT+=t),n.vz-=32*t,n.x+=n.vx*t,n.y+=n.vy*t,n.z+=n.vz*t,n.z<0&&(n.z=0,n.vz<-3?(n.vz*=-.55,n.vx*=.85,n.vy*=.85,n.state==="loose"&&F(i,"thump",-1,.5)):n.vz=0),n.z===0){const a=Math.max(0,1-1.6*t);n.vx*=a,n.vy*=a}if(n.x<.5&&(n.x=.5,n.vx=Math.abs(n.vx)*.6),n.x>49.5&&(n.x=49.5,n.vx=-Math.abs(n.vx)*.6),n.y<-1.5&&(n.y=-1.5,n.vy=Math.abs(n.vy)*.6),n.y>45.5&&(n.y=45.5,n.vy=-Math.abs(n.vy)*.6),n.state==="loose"&&n.noPick<=0&&s.phase==="live"){let a=-1,e=2.4;for(let r=0;r<s.players.length;r++){const l=s.players[r];if(l.fall)continue;const o=Math.hypot(l.x-n.x,l.y-n.y);o<e&&n.z<8+l.z&&(e=o,a=r)}a>=0?Xa(s,a,i):n.looseT>3&&ze(s,zt(s.possTeam),i)}}function ti(s,t){const i=t&&Number.isFinite(t.mx)?S(t.mx,-1,1):0,n=t&&Number.isFinite(t.my)?S(t.my,-1.6,1.6):0;s.inX=i,s.inY=n}function Qs(s,t,i,n){var l;const a=D,e=s.players.length;if(s.tick++,s.time+=a,s.netT=Math.max(0,s.netT-a),s.phase==="over")return;if(s.phase==="check"){s.phaseT-=a,be(s,a,i),s.phaseT<=0&&(s.phase="live");return}for(let o=0;o<e;o++)ti(s.players[o],t[o]);if(s.phase==="dead"){for(let o=0;o<e;o++)zs(s,o,a,i);if(Ls(s,i),be(s,a,i),s.phaseT-=a,s.phaseT<=0&&s.next){const o=s.next;s.next=null,o.kind==="over"?Rs(s,o.winner):ze(s,o.team,i)}return}if(!s.sudden&&s.time>=s.cfg.capSeconds){if(s.score[0]!==s.score[1]){Rs(s,s.score[0]>s.score[1]?0:1);return}s.sudden=!0,ct(i,"NEXT BUCKET WINS",-1,25,24,9,{size:1.1,life:1.6}),F(i,"whistle")}s.ball.secure&&(s.ball.secure=Math.max(0,s.ball.secure-a));for(let o=0;o<e;o++){const h=(l=t[o])==null?void 0:l.actions;if(h)for(const d of h)Ka(s,o,d,i)}Ha(s);for(let o=0;o<e;o++)zs(s,o,a,i);Ls(s,i),be(s,a,i);const r=Tt(s);s.phase==="live"&&(r&&s.needClear&&Q(r.x,r.y)&&(s.needClear=!1,G(i,r,"CLEARED",r.team,{size:.65,life:.6,only:r.team})),s.ball.state!=="shot"&&s.ball.state!=="net"&&(s.shotClock-=a,s.shotClock<=0&&(s.shotClock=0,r&&(r.gather=null),F(i,"whistle"),ct(i,"SHOT CLOCK",zt(s.possTeam),25,24,8,{size:1.1,life:1}),s.stats[s.possTeam].tov++,(r==null?void 0:r.team)===s.possTeam&&s.box[s.players.indexOf(r)].tov++,s.phase="dead",s.phaseT=.9,s.next={kind:"check",team:zt(s.possTeam)})))}class ge{constructor(t,i,n,a){x(this,"r");x(this,"recorder",{winner:null});this.size=i,this.myChar=a,this.r=new la(t,null,{court:n,shotWindow:(e,r)=>Le(e,r)}),this.dressTeams([],0,null)}get audio(){return this.r.audio}
2fit(t,i,n,a){this.r.fit(t,i,n,a)}draw(t,i,n,a,e){this.r.setFocus(e??null),this.r.draw(t,i,n,a)}setEmotes(t){this.r.setEmotes(t)}events(t,i){this.r.events(t,i)}dressTeams(t,i,n){var l;const a=[],e=[],r=[];for(let o=0;o<2;o++)for(let h=0;h<this.size;h++){const d=o*this.size+h,u=((l=t[o])==null?void 0:l[h])??null;a.push(d===n&&this.myChar?this.myChar:(u==null?void 0:u.char2d)??null);const m=o===i?0:1,p=u?$n(u):"0";e.push(p!=="0"?p:Ks[m][h]),r.push(u!=null&&u.cityJersey&&u.city?u.city.name:null)}this.r.setTeams(a,e,this.size,i,r),this.r.setDunkPacks([0,1].flatMap(o=>Array.from({length:this.size},(h,d)=>{var u,m;return((m=(u=t[o])==null?void 0:u[d])==null?void 0:m.dunks)??null})))}headOf(t,i){return this.r.head(t,i)?(i.y-=20,!0):!1}setNames(t){this.r.setNames(t)}reset(){this.r.reset()}dispose(){this.r.audio.close()}setCameraMode(){}setDrama(){}replaying(){return!1}replayFrame(){}stopReplay(){}playClip(){}}const ei=32e3,si=15e3;class ni{constructor(t){x(this,"state","off");x(this,"on",!1);x(this,"stream",null);x(this,"servers",null);x(this,"peers",new Map);x(this,"roomOn",!1);x(this,"peersOn",new Set);x(this,"retry",new Map);x(this,"liveKey","");x(this,"disposed",!1);this.opts=t}get teammates(){const{slot:t,size:i}=this.opts,n=t-t%i;return Array.from({length:i},(a,e)=>n+e).filter(a=>a!==t)}offers(t){return this.opts.slot<t}get starting(){return this.state==="starting"}async enable(){if(this.on||this.state==="starting"||this.disposed)return;this.set("starting");let t=null;try{t=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1}),this.servers??(this.servers=(await ca(`/teams/${this.opts.teamId}/voice-servers`,"POST",{})).iceServers)}catch(i){throw t==null||t.getTracks().forEach(n=>n.stop()),this.starting&&this.set("off"),new Error(ha(i))}if(this.disposed||!this.starting){t.getTracks().forEach(i=>i.stop());return}this.stream=t,this.on=!0,this.announce(),this.sync()}disable(){var i;const t=this.on||this.state==="starting";this.on=!1,(i=this.stream)==null||i.getTracks().forEach(n=>n.stop()),this.stream=null;for(const n of this.peers.keys())this.closePeer(n);for(const n of this.retry.values())clearTimeout(n);this.retry.clear(),t&&this.opts.send({type:"voice",on:!1}),this.set("off")}dispose(){this.disable(),this.disposed=!0}match(t){const i=t.voice??[];if(this.roomOn=!!i[this.opts.slot],this.peersOn=new Set(this.teammates.filter(n=>i[n])),this.on&&!this.roomOn){for(const n of this.peers.keys())this.closePeer(n);this.announce()}this.sync()}async receive(t,i,n){var a,e,r;if(!(!this.on||!this.stream||!this.teammates.includes(t)))try{if(n.kind==="offer"){if(this.offers(t))return;this.peersOn.add(t);const d=this.createPeer(t,i);if(await d.setRemoteDescription({type:"offer",sdp:n.sdp}),((a=this.peers.get(t))==null?void 0:a.pc)!==d)return;await this.flush(t,d);const u=await d.createAnswer();if(((e=this.peers.get(t))==null?void 0:e.pc)!==d)return;await d.setLocalDescription(u),this.signal(t,{kind:"answer",sdp:d.localDescription.sdp}),this.refresh();return}const l=this.peers.get(t);if(!l||i!==l.sid)return;const o=l.pc;if(n.kind==="answer"){if(!this.offers(t)||o.signalingState!=="have-local-offer")return;await o.setRemoteDescription({type:"answer",sdp:n.sdp}),((r=this.peers.get(t))==null?void 0:r.pc)===o&&await this.flush(t,o);return}const h={candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex};o.remoteDescription?await o.addIceCandidate(h).catch(()=>{}):l.pending.push(h)}catch{this.restart(t)}}announce(){this.opts.send({type:"voice",on:!0})}sync(){if(!this.on)return this.set(this.state==="starting"?"starting":"off");for(const t of this.teammates)this.roomOn&&this.peersOn.has(t)?!this.peers.has(t)&&!this.retry.has(t)&&this.offers(t)&&this.offer(t):this.closePeer(t);this.refresh()}refresh(){if(!this.on)return;const t=[...this.peers].filter(([,i])=>i.pc.connectionState==="connected").map(([i])=>i);if(t.length)return this.set("live",t);this.set(this.roomOn&&this.peersOn.size?"connecting":"waiting")}async offer(t){var a;const i=this.createPeer(t,crypto.randomUUID()),n=this.peers.get(t);n.watchdog=setTimeout(()=>{var e;((e=this.peers.get(t))==null?void 0:e.pc)===i&&i.connectionState!=="connected"&&this.restart(t)},si);try{const e=await i.createOffer();if(((a=this.peers.get(t))==null?void 0:a.pc)!==i)return;await i.setLocalDescription(e),this.signal(t,{kind:"offer",sdp:i.localDescription.sdp})}catch{this.restart(t)}}restart(t){this.closePeer(t),this.on&&(this.offers(t)&&!this.retry.has(t)&&this.retry.set(t,setTimeout(()=>{this.retry.delete(t),this.sync()},1500)),this.refresh())}createPeer(t,i){var l;const n=((l=this.peers.get(t))==null?void 0:l.audio)??null;this.closePeer(t);const a=new RTCPeerConnection({iceServers:this.servers??[],iceTransportPolicy:"relay"}),e={pc:a,sid:i,pending:[],audio:n,watchdog:void 0};this.peers.set(t,e);const r=this.stream;for(const o of r.getAudioTracks())a.addTrack(o,r);return a.onicecandidate=o=>{var h,d;((h=this.peers.get(t))==null?void 0:h.pc)!==a||!((d=o.candidate)!=null&&d.candidate)||this.signal(t,{kind:"ice",candidate:o.candidate.candidate,sdpMid:o.candidate.sdpMid,sdpMLineIndex:o.candidate.sdpMLineIndex})},a.ontrack=o=>{var h;((h=this.peers.get(t))==null?void 0:h.pc)===a&&this.play(e,o.streams[0]??new MediaStream([o.track]))},a.onconnectionstatechange=()=>{var h;if(((h=this.peers.get(t))==null?void 0:h.pc)!==a)return;const o=a.connectionState;if(o==="connected")clearTimeout(e.watchdog),this.limitBitrate(a);else if(o==="failed")return this.restart(t);this.refresh()},a}async flush(t,i){const n=this.peers.get(t);if(!n)return;const a=n.pending.splice(0);for(const e of a)await i.addIceCandidate(e).catch(()=>{})}signal(t,i){const n=this.peers.get(t);n&&this.opts.send({type:"rtc",to:t,sid:n.sid,signal:i})}play(t,i){this.disposed||(t.audio||(t.audio=new Audio,t.audio.autoplay=!0),t.audio.srcObject=i,t.audio.play().catch(()=>{}))}limitBitrate(t){var i,n;for(const a of t.getSenders()){if(((i=a.track)==null?void 0:i.kind)!=="audio")continue;const e=a.getParameters();(n=e.encodings)!=null&&n.length||(e.encodings=[{}]),e.encodings[0].maxBitrate=ei,a.setParameters(e).catch(()=>{})}}closePeer(t){const i=this.peers.get(t);if(!i)return;this.peers.delete(t),clearTimeout(i.watchdog);const n=i.pc;n.onicecandidate=n.ontrack=n.onconnectionstatechange=null,n.close(),i.audio&&(i.audio.srcObject=null)}set(t,i=[]){const n=`${t}:${i.join()}`;this.liveKey!==n&&(this.liveKey=n,this.state=t,this.opts.change(t,i))}}function ai({tournament:s,gameId:t,serverNowMs:i}){const n=da({tournamentId:s.id,activeMatchId:t,bracketRevision:`${t}:complete`});return f.jsxs(f.Fragment,{children:[n.pendingGames.length>0?f.jsx("div",{className:"i3-team-bracket",children:f.jsx(fa,{pendingGames:n.pendingGames,serverNowMs:i,onJoin:a=>void n.join(a),joiningSeriesId:n.joiningSeriesId,showBracketLink:!1,mobileDockOffset:!1})}):null,n.joinError?f.jsx("p",{className:"i3-note",children:n.joinError}):null]})}function ii({tournament:s,onLobby:t,children:i}){return f.jsxs("div",{className:"i3-row i3-result-row",children:[f.jsx(je,{className:"i3-btn",to:s.swiss?ma(s.id):pa(s.id
2),children:s.swiss?"Standings":"Bracket"}),i,f.jsx("button",{type:"button",className:"i3-btn ghost",onClick:t,children:"Lobby"})]})}const Zt=[g.x,g.y+2.2],Ds=()=>({think:.3,releaseAt:it,afterFake:-1,jumpAt:-1,seenG:null,fakeRolled:!1,jab:null,cut:-1,hold:0,spot:null,lob:-1});class ri{constructor(t,i={}){x(this,"skill");x(this,"react");x(this,"random");x(this,"minds",[]);x(this,"hist",[]);x(this,"lastPhase","");x(this,"lastOwner",-1);x(this,"mx",0);x(this,"my",0);this.size=t;const n=i.skill??[50,50];this.skill=[n[0]/100,n[1]/100];const a=i.react??[170,170];this.react=[a[0]/1e3,a[1]/1e3],this.random=i.random??Math.random;for(let e=0;e<t*2;e++)this.minds.push(Ds())}inputs(t,i=[]){const n=t.players.length,a=new Array(n);t.phase!==this.lastPhase&&t.phase==="check"&&this.reset(),this.lastPhase=t.phase,this.record(t);const e=V(t);if(e!==this.lastOwner){if(e>=0){const r=this.minds[e];r.hold=0,r.think=this.rnd(.12,.26)}this.lastOwner=e}for(let r=0;r<n;r++){if(i.includes(r))continue;if(t.phase!=="live"&&t.phase!=="dead"){a[r]={mx:0,my:0,actions:[]};continue}const l=[],o=t.players[r];this.mx=0,this.my=0,t.phase==="dead"?this.getBack(t,r):e===r?this.handle(t,r,l):e>=0&&t.players[e].team===o.team?this.offBall(t,r,e):e>=0?this.guard(t,r,e,l):this.scramble(t,r,l),a[r]={mx:this.mx,my:this.my,actions:l}}return a}reset(){for(let t=0;t<this.minds.length;t++)this.minds[t]=Ds();this.hist.length=0,this.lastOwner=-1}rnd(t,i){return t+this.random()*(i-t)}gauss(){let t=0,i=0;for(;!t;)t=this.random();for(;!i;)i=this.random();return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*i)}record(t){const i=t.players.map(n=>({x:n.x,y:n.y,vx:n.vx,vy:n.vy,hand:n.hand,gs:n.gather?Math.round((t.time-n.gather.t)*1e3)/1e3:n.fake>0?n.fakeAt:null,fakeT:n.fakeT}));for(this.hist.push({t:t.time,p:i});this.hist.length&&this.hist[0].t<t.time-.8;)this.hist.shift()}seen(t,i,n){var e;const a=t.time-this.react[n];for(let r=this.hist.length-1;r>=0;r--)if(this.hist[r].t<=a)return this.hist[r].p[i];return((e=this.hist[0])==null?void 0:e.p[i])??t.players[i]}arrive(t,i,n,a=1.5){i=S(i,1.5,48.5),n=S(n,1,43);const e=i-t.x,r=n-t.y,l=Math.hypot(e,r);if(l<.25){this.mx=0,this.my=0;return}const o=Math.min(1,l/a);this.mx=e/l*o,this.my=r/l*o}slot(t){return t%this.size}homeSpot(t,i){return this.minds[i].spot??Te[t.cfg.size][Cs(t,i)]}shoot(t,i,n){const a=this.skill[t.players[i].team],e=yt(t,i);this.minds[i].releaseAt=it+this.gauss()*(.045+.12*(1-a)+(e<4?.02:0)),n.push({t:"holdStart",pre:0})}bestLook(t,i){const n=t.players[i];let a=-1,e=-1/0;for(let r=0;r<t.players.length;r++){const l=t.players[r];if(r===i||l.team!==n.team||l.fall)continue;const o=Ee(t,i,r);if(o<2.2)continue;const h=Math.min(yt(t,r),14),d=U(l.x,l.y),u=Math.hypot(l.x-n.x,l.y-n.y);let m=h-u*.06+Math.min(o,6)*.25;d<7?m+=3:d>26.5?m-=3:Q(l.x,l.y)&&h>5&&(m+=1.5),t.needClear&&!Q(l.x,l.y)&&(m-=8),se(t,i,r)&&(m-=3),m>e&&(e=m,a=r)}return{to:a,v:e}}handle(t,i,n){const a=t.players[i],e=this.minds[i],r=this.skill[a.team];if(e.hold+=D,a.gather){Bn(a)>=e.releaseAt&&n.push({t:"holdEnd"});return}if(a.move||a.air)return;const l=this.nearestFoe(t,i),o=t.players[l],h=U(a.x,a.y),d=Math.hypot(o.x-a.x,o.y-a.y),u=yt(t,i);if(e.afterFake>0){if(t.time<e.afterFake)return;e.afterFake=-1,o.z>.4||o.stumble>0?n.push({t:"drive"}):this.random()<.5?this.shoot(t,i,n):n.push({t:"cross",side:this.random()<.5?-1:1});return}if(t.needClear&&!Q(a.x,a.y)){const b=this.bestLook(t,i);if(b.to>=0&&b.v>3&&e.hold>.25){n.push({t:"pass",to:b.to});return}const[M,A]=R(a.x-g.x,a.y-g.y+.001);let E=g.x+M*26.5,N=g.y+A*26.5;N<ee+1&&(E=a.x<25?1.6:48.4,N=S(a.y,3,ee)),this.arrive(a,E,N,.8);return}const m=o.stumble>0||o.fall||o.z>.8;if(t.shotClock<1.5||h<4.5){this.shoot(t,i,n);return}if(h<13&&this.crowd(t,i,6)>=2){const b=this.bestLook(t,i);if(b.to>=0&&b.v>2&&this.random()<(2+6*r)*D){n.push({t:"pass",to:b.to});return}}for(let b=0;b<t.players.length;b++)if(se(t,i,b)&&this.random()<(.2+.6*r)*D){n.push({t:"pass",to:b});return}if(e.think-=D,e.think<=0){if(e.think=this.rnd(.22,.45)*(1.3-r*.5),Q(a.x,a.y)&&u>5.5&&h<27&&this.random()<.45+.35*r){this.shoot(t,i,n);return}if((u>6.5||m&&d>3)&&h<26&&this.random()<.5+.3*r){this.shoot(t,i,n);return}const b=this.bestLook(t,i);if(b.to>
2=0){const M=b.v-Math.min(u,14),A=S(.15+M*.08+e.hold*.12,0,.85);if(M>-1&&this.random()<A){n.push({t:"pass",to:b.to});return}}if(d<5.8&&a.moveCd<=0){const M=-a.fy,A=a.fx,E=o.vx*M+o.vy*A,N=this.random();if(Math.abs(E)>4&&N<.4+.4*r)n.push({t:"cross",side:E>0?-1:1});else if(N<.3)e.jab={side:this.random()<.5?-1:1,until:t.time+this.rnd(.18,.3)};else if(h>21&&h<24&&N<.45)n.push({t:"step"});else if(m||N<.6)n.push({t:"drive"});else if(N<.72&&d<4.5){n.push({t:"fake"}),e.afterFake=t.time+this.rnd(.3,.4);return}}}if(e.jab){if(t.time<e.jab.until){this.mx=-a.fy*e.jab.side,this.my=a.fx*e.jab.side;return}const b=-e.jab.side;e.jab=null,n.push({t:"cross",side:b});return}if(Q(a.x,a.y)&&u>5.5&&h<27)return;if(m||u>5){this.arrive(a,Zt[0],Zt[1],1);return}const[p,c]=R(g.x-a.x,g.y-a.y),v=Math.sign(a.x-o.x)||1;this.arrive(a,a.x+p*4-c*v*3,a.y+c*4+p*v*3,2)}offBall(t,i,n){const a=t.players[i],e=this.minds[i],r=this.skill[a.team],l=t.players[n];if(e.cut>0){if(t.time<e.cut&&U(a.x,a.y)>3){this.arrive(a,Zt[0]+(a.x<25?-2:2),Zt[1]+1.5,1);return}e.cut=-1,e.spot=null}let[o,h]=this.homeSpot(t,i);if(Math.hypot(o-l.x,h-l.y)<9){const[m,p]=R(o-l.x+.01,h-l.y);o=l.x+m*11,h=l.y+p*11}if(t.needClear){const[m,p]=R(o-g.x,h-g.y+.001);o=g.x+m*26,h=Math.max(g.y+p*26,2)}const d=t.players[mt(t,i)],u=Math.hypot(d.x-a.x,d.y-a.y)>5.5&&d.fx*(l.x-d.x)+d.fy*(l.y-d.y)>0&&U(a.x,a.y)>14;if(!t.needClear&&u&&this.random()<(.35+.6*r)*D){e.cut=t.time+this.rnd(1.1,1.6);return}if(this.random()<.08*D){const m=[S(o+this.rnd(-6,6),2,48),S(h+this.rnd(-4,4),2,32)];e.spot=m}this.arrive(a,o,h,2)}guard(t,i,n,a){const e=t.players[i],r=this.minds[i],l=this.skill[e.team],o=mt(t,i),h=this.seen(t,o,e.team),d=this.seen(t,n,e.team),u=t.players[n];if(o===n){const p=U(h.x,h.y);let c=3.2+Math.max(0,p-24.5)*.6;t.needClear&&(c=Math.max(c,4.5));const v=h.x+h.vx*.1,b=h.y+h.vy*.1,[M,A]=R(g.x-v,g.y-b);if(this.arrive(e,v+M*c-A*h.hand*.65,b+A*c+M*h.hand*.65,1),!((t.ball.secure??0)>0)&&e.reachCd<=0&&e.stumble<=0&&!e.fall&&e.z<.2&&!u.gather){const[N,w]=Lt(u);if(Math.hypot(N-e.x,w-e.y)<3){let z=(.22+.6*l)*(Math.hypot(u.vx,u.vy)<3?2.2:1);u.move&&(z*=.25),this.random()<z*D&&a.push({t:"tap"})}}}else{const p=t.players[o],c=U(d.x,d.y),v=Math.hypot(h.x-d.x,h.y-d.y);let b=S(.18+v*.012,.18,.42);c<13&&v>8&&(b+=.2+.2*l);const[M,A]=R(g.x-h.x,g.y-h.y);let E=h.x+M*3+(d.x-h.x)*b,N=h.y+A*3+(d.y-h.y)*b;U(p.x,p.y)<10&&c>14&&(E=p.x+M*1.5,N=p.y+A*1.5),this.arrive(e,E,N,1.2)}const m=d;if(m.gs!=null&&r.seenG!==m.gs){r.seenG=m.gs,r.fakeRolled=!1;const p=Math.hypot(u.x-e.x,u.y-e.y),c=o===n?.35+.35*l:.06+.12*l;p<(o===n?6.5:5)&&this.random()<c&&(r.jumpAt=Math.max(t.time,m.gs+.6*it-.14+this.gauss()*.09*(1.3-l)))}r.jumpAt>0&&m.gs==null&&r.seenG!=null&&m.fakeT>=r.seenG&&!r.fakeRolled&&(r.fakeRolled=!0,this.random()<.6*l&&(r.jumpAt=-1)),r.jumpAt>0&&t.time>=r.jumpAt&&(r.jumpAt=-1,Math.hypot(u.x-e.x,u.y-e.y)<7&&a.push({t:"jump"}))}scramble(t,i,n){const a=t.players[i],e=t.ball,r=this.skill[a.team];if(e.state==="pass"&&e.pass){const l=e.pass,o=this.minds[i],h=l.lob;if(l.to===i){this.arrive(a,l.x1,l.y1,.6),h&&h.jump===void 0&&(o.lob!==h.arrive&&(o.lob=h.arrive,o.jumpAt=h.arrive-Re+this.gauss()*(.05+.1*(1-r))),o.jumpAt>0&&t.time>=o.jumpAt&&(o.jumpAt=-1,n.push({t:"jump"})));return}if(t.players[l.from].team===a.team){this.offBallIdle(t,i);return}if(h&&o.lob!==h.arrive){o.lob=h.arrive,o.jumpAt=-1;let c=!0;const v=Math.hypot(l.x1-a.x,l.y1-a.y);for(let b=0;b<t.players.length;b++){const M=t.players[b];b!==i&&M.team===a.team&&Math.hypot(l.x1-M.x,l.y1-M.y)<v&&(c=!1)}c&&v<7&&this.random()<.25+.35*r&&(o.jumpAt=h.arrive-.31+this.gauss()*(.05+.1*(1-r)))}h&&o.jumpAt>0&&t.time>=o.jumpAt&&(o.jumpAt=-1,n.push({t:"jump"})),Math.hypot(e.x-a.x,e.y-a.y)<4&&a.reachCd<=0&&this.random()<(3+8*r)*D&&n.push({t:"tap"});const m=t.players[l.to];mt(t,i)===l.to?this.arrive(a,m.x+(g.x-m.x)*.12,m.y+(g.y-m.y)*.12,1):this.arrive(a,a.x+(e.x-a.x)*.3,a.y+(e.y-a.y)*.3,1.5);return}if(e.state==="shot"&&e.shot){const l=t.players[mt(t,i)];if(e.shot.by===i)return;if(U(a.x,a.y)<12){const[d,u]=R(a.x-g.x,a.y-g.y+.001);this.arrive(a,g.x+d*5,g.y+Math.abs(u)*5+.5,1)}else{const[d,u]=R(g.x-l.x,g.y-l.y);this.arrive(a,l.x+d*2.2,l.y+u*2.2,1)}return}if(e.state==="loose"){let l=0;const o=Math.hypot(e.x-a.x,e.y-a.y);for(const h of t.players)h!==a&&h.team===a.team&&Math.hypot(e.x-h.x,e.y-h.y)<o&&l++;if(l<2)this.arrive(a,e.x+e.vx*.2,e.y+e.vy*.2,.5),e.z>6&&e.z<11&&o<2.5&&a.jumpT<0&&this.random()<3*D&&n.push({t:"jump"});else if(a.team===t.possTeam)this.offBallIdle(t,i);else{const h=t.players[mt(t,i)],[d,u]=R(g.x-h.x,g.y-h.y);this.arrive(a,h.x+d*3,h.y+u*3,1)}return}this.mx=this.my=0}offBallIdle(t,i){const[n,a]=this.homeSpot(t,i);this.arrive(t.players[i],n,a,2)}getBack(t,i){const n=t.players[i],a=t.cfg.size,e=t.next;if(!e||e.kind!=="check")return;const r=Te[t.cfg.size][Cs(t,i,!0)];if(n.team===e.team)this.arrive(n,r[0],r[1],3);else{const l=t.players[e.team*a+this.slot(i)],[o,h]=R(g.x-l.x,g.y-l.y);this.arrive(n,l.x+o*4,l.y+h*4,3)}}nearestFoe(t,i){const n=t.players[i];let a=mt(t,i),e=1/0;for(let r=0;r<t.players.length;r++){const l=t.players[r];if(l.team===n.team)continue;const o=Math.hypot(l.x-n.x,l.y-n.y);o<e&&(e=o,a=r)}return a}crowd(t,i,n){const a=t.players[i];let e=0;for(const r of t.players)r.team!==a.team&&!r.fall&&Math.hypot(r.x-a.x,r.y-a.y)<n&&e++;return e}}const Fs=24,oi=12;function H(s,t){let i=0;for(const n of s.players)t[i++]=n.x,t[i++]=n.y,t[i++]=n.z;t[i++]=s.ball.x,t[i++]=s.ball.y,t[i]=s.ball.z}function wt(s,t){let i=0;for(const n of s.players)n.x=t[i++],n.y=t[i++],n.z=t[i++];s.ball.x=t[i++],s.ball.y=t[i++],s.ball.z=t[i]}class li{constructor(t,i,n={}){x(this,"me",0);x(this,"active",0);x(this,"aim",-1);x(this,"oopAim",-1);x(this,"s");x(this,"brain");x(this,"acc",0);x(this,"prev");x(this,"cur");x(this,"out");x(this,"carry",[]);x(this,"manual",!1);x(this,"lastOwner",-1);x(this,"lastState","");this.size=t,this.onEvents=i;const a=Math.random()*4294967295>>>0||1;this.s=_e(a,{size:t},0),this.brain=new ri(t,{skill:[n.mates??55,n.skill??40],react:[150,n.react??200]});const e=(t*2+1)*3;this.prev=new Float64Array(e),this.cur=new Float64Array(e),this.out=new Float64Array(e),H(this.s,this.prev)}current(){return this.s}offense(){const t=this.s.ball;return t.state==="pass"&&t.pass?t.pass.to===this.active:V(this.s)===this.active}frame(t,i,n,a,e){var d;const r=this.s;this.acc+=t;for(const u of a)u==="switch"?this.grabNearest():u==="pass"&&V(r)===this.active&&this.aim>=0?this.carry.push({t:"pass",to:this.aim}):u==="oop"&&V(r)===this.active&&this.oopAim>=0?this.carry.push({t:"oop",to:this.oopAim}):u==="pass"&&r.ball.state==="pass"&&((d=r.ball.pass)==null?void 0:d.to)===this.active&&this.carry.push({t:"pass"});let l=this.carry.length?[...this.carry.splice(0),...n]:n,o=0;for(;this.acc>=D&&o<Fs;){H(r,this.prev),this.follow();const u=this.brain.inputs(r,[this.active]);u[this.active]={mx:i[0],my:i[1],actions:l},l=[];const m=[];Qs(r,u,m),m.length&&this.onEvents(m),this.acc-=D,o++}o>=Fs&&(this.acc=0),l.length&&this.carry.push(...l),this.follow();const h=V(r)===this.active;return this.aim=h?ae(r,this.active,i[0],i[1]):-1,this.oopAim=h?Pe(r,this.active,i[0],i[1]):-1,this.drawBlended(e),r}follow(){const t=this.s,i=t.ball,n=V(t),a=e=>t.players[e].team===this.me;if(i.state==="pass"&&i.pass&&a(i.pass.from))this.active=i.pass.to;else if(n>=0&&a(n))this.active=n,this.manual=!1;else if(n>=0){if(n!==this.lastOwner||!a(this.active)){this.manual=!1;const e=mt(t,n),r=t.players[n],l=t.players[e];
2this.active=Math.hypot(l.x-r.x,l.y-r.y)>oi?this.nearest(r.x,r.y):e}}else i.state==="loose"&&this.lastState!=="loose"&&!this.manual&&(this.active=this.nearest(i.x,i.y));this.lastOwner=n,this.lastState=i.state}grabNearest(){const t=this.s;if(V(t)===this.active)return;const i=this.nearest(t.ball.x,t.ball.y,this.active);i>=0&&(this.active=i,this.manual=!0)}nearest(t,i,n=-1){const a=this.s;let e=-1,r=1/0;for(let l=0;l<a.players.length;l++){const o=a.players[l];if(o.team!==this.me||l===n)continue;const h=Math.hypot(o.x-t,o.y-i);h<r&&(r=h,e=l)}return e}drawBlended(t){const i=this.s,n=this.acc/D,{prev:a,cur:e,out:r}=this;H(i,e);for(let l=0;l<e.length;l+=3){const o=Math.hypot(e[l]-a[l],e[l+1]-a[l+1])>=3;for(let h=0;h<3;h++){const d=e[l+h];r[l+h]=o?d:a[l+h]+(d-a[l+h])*n}}wt(i,r);try{t(i)}finally{wt(i,e)}}}const ke=[],Bs=24,ci=60,hi=4,ui=.12,fi=12,di=10,mi=4,Qt=.12,pi=1,yi=5,xi=.3,$s=s=>Math.round(s*100)/100;function Ws(s,t,i){const n=s.get(t);s.set(t,n?{mx:i.mx,my:i.my,actions:[...n.actions,...i.actions]}:i)}class vi{constructor(t,i,n){x(this,"me");x(this,"active");x(this,"aim",-1);x(this,"oopAim",-1);x(this,"n");x(this,"auth",null);x(this,"fresh",!1);x(this,"pred",null);x(this,"blank");x(this,"local",-1);x(this,"acc",0);x(this,"rtt",null);x(this,"live",!1);x(this,"firstStateAt",0);x(this,"lastResync",-1/0);x(this,"inputs");x(this,"held");x(this,"sentStick",[0,0]);x(this,"sentTick",-1/0);x(this,"delay",2);x(this,"carry",[]);x(this,"prev");x(this,"offset");x(this,"cur");x(this,"out");x(this,"shown",null);x(this,"clockOff",null);x(this,"lastWall",-1/0);x(this,"legacy",!1);x(this,"rejoined",!1);this.size=t,this.send=n,this.active=i,this.me=i<t?0:1,this.n=t*2,this.blank=_e(1,{size:t},0),this.inputs=Array.from({length:this.n},()=>new Map),this.held=Array.from({length:this.n},()=>[0,0]);const a=(this.n+1)*3;this.prev=new Float64Array(a),this.offset=new Float64Array(a),this.cur=new Float64Array(a),this.out=new Float64Array(a)}ready(){return this.auth!==null}current(){return this.pred??this.auth??this.blank}offense(){const t=this.current(),i=t.ball;return i.state==="pass"&&i.pass?i.pass.to===this.active:V(t)===this.active}setLive(t){t&&!this.live&&this.resync(),this.live=t,t||(this.carry.length=0)}rejoin(){this.rejoined=!0}resync(){this.clockOff=null,this.lastWall=-1/0,this.inputs[this.active].clear(),this.local=-1,this.pred=null,this.sentStick=[0,0],this.sentTick=-1/0}push(t,i){if(this.rejoined){this.rejoined=!1,this.auth=null,this.clockOff=null,this.lastWall=-1/0;for(const e of this.inputs)e.clear()}if(this.auth&&t.tick<this.auth.tick)return;this.legacy=i===void 0;const n=i??t.tick,a=performance.now();if(n>this.lastWall){const e=n-a*Qt;if(this.clockOff===null||this.lastWall===-1/0)this.clockOff=e;else{const r=this.clockOff-e;this.clockOff+=(e-this.clockOff)*(r<0?.5:.01)}this.lastWall=n}for(const e of this.inputs)for(const r of e.keys())r<t.tick&&e.delete(r);this.auth=t,this.fresh=!0,this.firstStateAt||(this.firstStateAt=a)}relay(t){const i=this.inputs[t.seat];!i||t.seat===this.active||this.auth&&t.tick<this.auth.tick||(Ws(i,t.tick,{mx:t.mx,my:t.my,actions:t.a??ke}),this.pred&&t.tick<this.local&&(this.fresh=!0))}pong(t){this.rtt=this.rtt===null?t:this.rtt*.8+t*.2;const i=Math.round(this.rtt*Qt*xi);this.delay=Math.max(pi,Math.min(yi,i))}netStats(){return{rtt:this.rtt,delay:this.delay,ahead:this.auth&&this.local>=0?this.local-this.auth.tick:null}}wallNow(){return performance.now()*Qt+this.clockOff+(this.rtt??0)/2*Qt}stepPred(t){const i=t.tick,n=new Array(this.n);for(let a=0;a<this.n;a++){const e=this.inputs[a].get(i);e?(this.held[a]=[e.mx,e.my],n[a]=e):n[a]={mx:this.held[a][0],my:this.held[a][1],actions:ke}}Qs(t,n)}reconcile(){const t=this.auth,i=new Float64Array(this.prev.length),n=this.pred!==null||this.shown!==null;this.pred?H(this.pred,i):this.shown&&i.set(this.shown),this.shown=null,this.local<t.tick&&(this.local=t.tick);const a=Fa(t);H(a,this.prev);for(let e=0;e<this.n;e++){const r=t.players[e];this.held[e]=[r.inX,r.inY]}for(;a.tick<this.local;)H(a,this.prev),this.stepPred(a);if(n){const e=new Float64Array(this.prev.length);H(a,e),this.retarget(i,e)}else this.offset.fill(0);this.pred=a}retarget(t,i){for(let n=0;n<=this.n;n++){const a=n*3,e=this.offset[a]+t[a]-i[a],r=this.offset[a+1]+t[a+1]-i[a+1],l=this.offset[a+2]+t[a+2]-i[a+2],o=Math.hypot(e,r,l)>(n===this.n?mi:di);this.offset[a]=o?0:e,this.offset[a+1]=o?0:r,this.offset[a+2]=o?0:l}}settle(t){const i=Math.exp(-t/ui);for(let n=0;n<=this.n;n++){const a=n*3,e=Math.hypot(this.offset[a],this.offset[a+1],this.offset[a+2]);if(!e)continue;const r=n===this.n?i:Math.max(i,1-fi*t/e);for(let l=a;l<a+3;l++)this.offset[l]=this.offset[l]*r}}drawAt(t,i,n){const{prev:a,cur:e,out:r,offset:l}=this;H(t,e);for(let o=0;o<e.length;o+=3){const h=Math.hypot(e[o]-a[o],e[o+1]-a[o+1])>=3;for(let d=0;d<3;d++){const u=e[o+d];r[o+d]=(h?u:a[o+d]+(u-a[o+d])*i)+l[o+d]}}wt(t,r);try{n(t)}finally{wt(t,e)}}still(t,i,n){const a=new Float64Array(this.prev.length);if(H(t,a),this.pred){const e=new Float64Array(this.prev.length);H(this.pred,e),this.retarget(e,a),this.pred=null}else this.shown&&this.retarget(this.shown,a);
2return this.settle(i),this.prev.set(a),this.shown=a,this.drawAt(t,1,n),t}passes(t){var a;const i=[],n=this.current();for(const e of t){if(e==="oop"&&V(n)===this.active&&this.oopAim>=0&&i.push({t:"oop",to:this.oopAim}),e!=="pass")continue;const r=n.ball;V(n)===this.active&&this.aim>=0?i.push({t:"pass",to:this.aim}):r.state==="pass"&&((a=r.pass)==null?void 0:a.to)===this.active&&i.push({t:"pass"})}return i}frame(t,i,n,a,e){const r=this.auth;if(!r)return e(this.blank),this.blank;if(!this.live||r.phase==="over")return this.local=-1,this.aim=-1,this.oopAim=-1,this.still(r,t,e);const l=performance.now();if(this.local<0){if(this.clockOff===null||this.rtt===null&&l-this.firstStateAt<400)return this.still(r,t,e);this.local=Math.max(r.tick,Math.round(this.wallNow())),this.acc=0,this.lastResync=l,this.fresh=!0}const o=this.wallNow()-(this.local+this.acc/D);let h=1;Math.abs(o)>ci&&l-this.lastResync>1e3?(this.local=Math.max(r.tick,Math.round(this.wallNow())),this.acc=0,this.lastResync=l,this.fresh=!0):h=1+Math.max(-.08,Math.min(.1,o*.01)),this.fresh&&(this.fresh=!1,this.reconcile());const d=this.pred,u=$s(i[0]),m=$s(i[1]),p=this.inputs[this.active];let c=[...this.carry.splice(0),...this.passes(a),...n];this.acc+=t*h;let v=0,b=!1;for(;this.acc>=D&&v<Bs;){const A=this.local+(this.legacy?0:this.delay);if(A>this.sentTick){const E=u!==this.sentStick[0]||m!==this.sentStick[1];if(c.length>0||!b&&(E&&A-this.sentTick>=2||A-this.sentTick>=hi)){const w={type:"input",tick:A,mx:u,my:m};c.length&&(w.a=c.slice(0,8)),this.send(w)&&(b=!0,this.sentStick=[u,m],this.sentTick=A,Ws(p,A,{mx:u,my:m,actions:w.a??ke}),c=c.slice(8))}}H(d,this.prev),this.stepPred(d),this.local++,this.acc-=D,v++}v>=Bs&&(this.acc=0),c.length&&this.carry.push(...c),this.settle(t);const M=V(d)===this.active;return this.aim=M?ae(d,this.active,u,m):-1,this.oopAim=M?Pe(d,this.active,u,m):-1,this.drawAt(d,Math.min(1,this.acc/D),e),d}}const Ys=1/(D*1e3),bi=8,gi=36,ki=60,ji=120,Mi=60,wi=.5;class Ti{constructor(t,i){x(this,"me",0);x(this,"active",-1);x(this,"aim",-1);x(this,"oopAim",-1);x(this,"blank");x(this,"snaps",[]);x(this,"queued",[]);x(this,"clockOff",null);x(this,"jitter",0);x(this,"gap",8);x(this,"at",-1);x(this,"drawn",null);x(this,"rejoined",!1);x(this,"pa");x(this,"pb");x(this,"out");x(this,"own");this.onEvents=i,this.blank=_e(1,{size:t},0);const n=(t*2+1)*3;this.pa=new Float64Array(n),this.pb=new Float64Array(n),this.out=new Float64Array(n),this.own=new Float64Array(n)}current(){return this.drawn??this.snaps.at(-1)??this.blank}offense(){return!1}get delay(){const t=2*this.gap+2*this.jitter;return Math.max(bi,Math.min(gi,Math.round(t)))}rejoin(){this.rejoined=!0}push(t,i){this.rejoined&&(this.rejoined=!1,this.snaps=[],this.queued=[],this.clockOff=null,this.at=-1);const n=this.snaps.at(-1);if(n&&t.tick<n.tick)return;if(i.length&&this.queued.push({tick:t.tick,ev:[...i]}),n&&t.tick===n.tick){this.snaps[this.snaps.length-1]=t;return}const a=t.tick-performance.now()*Ys;if(this.clockOff===null||this.clockOff-a>ki)this.clockOff=a;else{const e=this.clockOff-a;this.jitter+=(Math.max(0,e)-this.jitter)*.05,this.clockOff+=(a-this.clockOff)*(e<0?.5:.01)}n&&(this.gap+=(Math.min(30,t.tick-n.tick)-this.gap)*.1),this.snaps.push(t),this.snaps.length>256&&this.snaps.shift()}frame(t,i,n,a,e){const r=this.snaps;if(!r.length||this.clockOff===null)return e(this.blank),this.blank;const l=r[0].tick,o=r.at(-1).tick,h=performance.now()*Ys+this.clockOff-this.delay,d=h-this.at;for(this.at<0||Math.abs(d)>Mi?this.at=h:this.at+=t/D*(1+Math.max(-.1,Math.min(.1,d*.02))),this.at=Math.max(l,Math.min(o,this.at));r.length>2&&r[1].tick<=this.at;)r.shift();const u=r[0],m=r[1];let p=u;if(m&&this.at>u.tick){const c=(this.at-u.tick)/(m.tick-u.tick),{pa:v,pb:b,out:M,own:A}=this;H(u,v),H(m,b);const E=wi*Math.max(6,m.tick-u.tick);for(let N=0;N<v.length;N+=3){const w=Math.hypot(b[N]-v[N],b[N+1]-v[N+1])>E;for(let z=N;z<N+3;z++)M[z]=w?c<.5?v[z]:b[z]:v[z]+(b[z]-v[z])*c}p=c<.5?u:m,H(p,A),wt(p,M);try{e(p)}finally{wt(p,A)}}else e(u);if(this.drawn=p,this.queued.length){const c=[];for(;this.queued.length&&this.queued[0].tick<=this.at;){const v=this.queued.shift();v.tick>=this.at-ji&&c.push(...v.ev)}c.length&&this.onEvents(c)}return p}}const tn="iso3d:camera";function Ni(){try{return localStorage.getItem(tn)==="courtside"?"courtside":"broadcast"}catch{return"broadcast"}}function Si(s){let t=performance.now(),i=0,n,a=!1;const e=()=>{if(a)return;cancelAnimationFrame(i),clearTimeout(n);const r=performance.now(),l=Math.min(.1,(r-t)/1e3);t=r,s(l,r),i=requestAnimationFrame(e),n=setTimeout(e,60)};return e(),()=>{a=!0,cancelAnimationFrame(i),clearTimeout(n)}}const Gs={off:"Join team voice",starting:"Starting voice…",waiting:"In voice. Waiting for a teammate to join",connecting:"Connecting voice…",live:"Voice on. Tap to leave"};function lt({d:s,children:t}){return f.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:s?f.jsx("path",{d:s}):t})}function Oi(s,t,i){const n=(r,l)=>{const o=s[r];o&&o.textContent!==l&&(o.textContent=l)},a=1-i;Rn(s,{mine:t.score[i],theirs:t.score[a],poss:t.phase==="over"?null:t.possTeam===i?0:1,shotClock:t.shotClock,live:t.phase==="live",target:t.cfg.target,sudden:t.sudden,clearing:t.needClear&&t.phase==="live"});const e=t.phase==="check"&&t.score[0]===0&&t.score[1]===0&&t.phaseT>.9;n("tip",e?String(Math.ceil(t.phaseT)):"")}function Ai(s){const t=s.ball.shot;return s.ball.state==="shot"&&!!t&&s.phase==="live"&&(s.sudden||s.score[t.shooter]+t.pts>=s.cfg.target)}function Ci(s){return[[`${s.fgm}/${s.fga}`,"FG"],[s.twos,"Deep"],[s.ast,"Assists"],[s.stl,"Steals"],[s.blk,"Blocks"],[s.tov,"TO"]]}function Ri({shots:s}){if(!s.length)return null;const{x:t,y:i}=g;return f.jsxs("svg",{className:"i3-chart",viewBox:"-1 -1 52 40",role:"img","aria-label":"Your team's shot chart",children:[f.jsx("rect",{x:"0",y:"0",width:"50",height:"38",className:"bg"}),f.jsx("path",{className:"ln",d:`M3 0V${ee}A${ks} ${ks} 0 0 0 47 ${ee}V0M17 0V19H33V0M${t-6} 19A6 6 0 0 0 ${t+6} 19M0 0H50`}),f.jsx("circle",{cx:t,cy:i,r:"0.75",className:"rim"}),s.map((n,a)=>n.made?f.jsx("circle",{cx:n.x,cy:Math.min(n.y,37),r:"0.95",className:"make"},a):f.jsx("g",{className:"miss",transform:`translate(${n.x} ${Math.min(n.y,37)})`,children:f.jsx("path",{d:"M-.8 -.8L.8 .8M.8 -.8L-.8 .8"})},a)),f.jsx("title",{children:`${s.filter(n=>n.made).length} of ${s.length} made`})]})}function Us({box:s,size:t,team:i=0,names:n}){return f.jsxs("table",{className:"i3-run-box",children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{scope:"col",children:f.jsx("span",{className:"sr-only",children:"Player"})}),f.jsx("th",{scope:"col",children:"PTS"}),f.jsx("th",{scope:"col",children:"AST"}),f.jsx("th",{scope:"col",children:"FG"}),f.jsx("th",{scope:"col",children:"STL"}),f.jsx("th",{scope:"col",children:"BLK"})]})}),f.jsx("tbody",{children:s.slice(i*t,i*t+t).map((a,e)=>f.jsxs("tr",{children:[f.jsx("th",{scope:"row",children:(n==null?void 0:n[e])??`#${Ks[i][e]}`}),f.jsx("td",{children:a.pts}),f.jsx("td",{children:a.ast}),f.jsxs("td",{children:[a.fgm,"/",a.fga]}),f.jsx("td",{children:a.stl}),f.jsx("td",{children:a.blk})]},e))})]})}const Hs={cap:"Game clock expired",forfeit:"Forfeit",no_show:"The other team never showed",abandoned:"Game abandoned"};function Ei({size:s,onExit:t,onSize:i,teamId:n,watch:a=!1,after:e,flat:r}){var as,is,rs,os,ls;const l=T.useRef(null),o=T.useRef(null),h=T.useRef(null),d=T.useRef({}),u=y=>k=>{d.current[y]=k},m=T.useRef(null),p=T.useRef(null),[c,v]=T.useState(null),[b,M]=T.useState(!0),[A,E]=T.useState(!1),[N,w]=T.useState(""),[z,rt]=T.useState(0),B=T.useRef(null),[xt,en]=T.useState(0),ut=T.useRef(!1),Dt=T.useRef([]),Ft=T.useRef([]),J=T.useRef(null),[De,sn]=T.useState(0),[ie,nn]=T.useState(!1),[P,Fe]=T.useState(null),[re,oe]=T.useState(null),[St,Be]=T.useState(null),[an,Bt]=T.useState(!1),[$e,We]=T.useState(!1),$t=ta()==="touch",[vt,rn]=T.useState(Ni),nt=T.useRef(null),[ft,Ye]=T.useState("off"),[Wt,Yt]=T.useState(""),Gt=T.useRef(0),[on,ln]=T.useState(()=>Date.now()),Ge=!!n&&(!c||c.status==="waiting");T.useEffect(()=>{if(!Ge)return;const y=setInterval(()=>ln(Date.now()),250);return()=>clearInterval(y)},[Ge]);const dt=n?(c==null?void 0:c.slot)??null:null,Ue=!!n&&!!(c!=null&&c.chat)&&dt!==null&&!N&&!ie&&P===null,ot=Gn({enabled:Ue,seat:dt,me:dt??0,send:y=>{var k;return((k=p.current)==null?void 0:k.send({type:"chat",text:y}))??!1},count:s*2,mates:!0}),Ut=ot.bubbles,He=ot.hear,cn=Un({enabled:!!n&&!!(c!=null&&c.emotes)&&dt!==null&&!N&&!ie&&P===null,seat:dt,send:y=>{var k;return((k=p.current)==null?void 0:k.send({type:"emote",e:y}))??!1},bubbles:Ut,side:y=>dt!==null&&Math.floor(y/s)===Math.floor(dt/s)?"you":"them"}),{playing:qe,hear:Ke}=cn,Ot=(r==null?void 0:r.court)??null,Ve=(r==null?void 0:r.char)??null;T.useEffect(()=>{const y=l.current;let k=!1,L=()=>{},j=null,$=()=>{},q=null;const I=new ea(y,{offense:()=>{var C;return!!((C=m.current)!=null&&C.offense())},live:()=>ut.current,gesture:()=>{var C;return(C=B.current)==null?void 0:C.audio.unlock()}},!0),O=C=>{if(k)return C.dispose();q=C,B.current=C,en(X=>X+1),We(C.audio.muted);let W=0,qt=0;const fe=(X,Kt)=>C.headOf(X,Kt),de=()=>{const X=An(h.current,y,56);W=y.clientWidth||innerWidth,qt=X,C.fit(y.clientWidth||innerWidth,y.clientHeight||innerHeight,X,I.coarse)};de(),j=new ResizeObserver(de),j.observe(y),$=na(de);let me=1,cs="",pe="",Pt=null;L=Si((X,Kt)=>{var hs,us,fs,ds,ms,ps,ys;if(C.replaying()){C.replayFrame(X),(hs=Ut.current)==null||hs.clear();return}const K=m.current;if(!K)return;I.poll(Kt);const Mt=ut.current,gn=I.drain(),kn=[...I.drainPresses(),...Ft.current.splice(0)],jn=K.
2current(),ye=Ai(jn);C.setDrama(ye),me+=((ye?.38:1)-me)*Math.min(1,X*(ye?6:3));const _t=K.frame(X*me,I.stick(),Mt?gn:[],Mt?kn:[],Vt=>{C.setEmotes(qe(Kt)),C.draw(Vt,K.me,X,Mt?I.view(K.offense()):null,{idx:K.active,aim:K.aim})});(us=Ut.current)==null||us.place(X,fe,W,qt),Oi(d.current,_t,K.me),(fs=d.current.sw)==null||fs.toggleAttribute("hidden",!Mt||_t.possTeam===K.me),(ds=d.current.ps)==null||ds.toggleAttribute("hidden",!Mt||!K.offense()),(ms=d.current.oop)==null||ms.toggleAttribute("hidden",!Mt||!K.offense()),(ps=d.current.oop)==null||ps.toggleAttribute("data-open",K.oopAim>=0);const Z=_t.ball;if(Z.state==="shot"&&Z.shot){const Vt=`${Z.shot.by}|${Z.shot.x0.toFixed(1)}|${Z.shot.y0.toFixed(1)}`;Vt!==pe&&(pe=Vt,Pt=Z.shot.shooter===K.me?{x:Z.shot.x0,y:Z.shot.y0,made:!1}:null,Pt&&Dt.current.push(Pt))}else Z.state!=="net"&&(pe="");cs==="shot"&&Z.state==="net"&&Pt&&(Pt.made=!0),cs=Z.state,_t.phase==="over"&&((ys=J.current)==null||ys.call(J,_t))})},et=()=>{k||(I.dispose(),nn(!0))};return Ot?O(new ge(y,s,Ot,Ve)):Tn(async()=>{const{IsoStage:C}=await import("./stage-aQVjsDok.js");return{IsoStage:C}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(({IsoStage:C})=>{if(k)return;let W;try{W=new C(y,o.current,sa(),{size:s,shotWindow:(qt,fe)=>Le(qt,fe)})}catch{return et()}O(W)}).catch(et),()=>{k=!0,L(),j==null||j.disconnect(),$(),I.dispose(),q==null||q.dispose(),B.current=null}},[s,Ot,Ve,Ut,qe]);const hn=xa(),bt=n?c==null?void 0:c.teams:void 0,Xe=n?(c==null?void 0:c.slot)??null:null,Je=JSON.stringify([bt==null?void 0:bt.map((y,k)=>y.map((L,j)=>L.look??(Xe===k*s+j?hn:null)??null)),Xe]),Ze=JSON.stringify((bt==null?void 0:bt.flatMap(y=>y.map(k=>k.name)))??[]);T.useEffect(()=>{var y;(y=B.current)==null||y.setNames(JSON.parse(Ze))},[Ze,s,xt]),T.useEffect(()=>{const[y,k]=JSON.parse(Je);if(!y)return;const L=k!=null&&k>=s?1:0,j=B.current;j instanceof ge?j.dressTeams(y,L,k):j==null||j.dressTeams(y,L)},[Je,s,xt]),T.useEffect(()=>{var y;if((y=B.current)==null||y.setCameraMode(vt),!Ot)try{localStorage.setItem(tn,vt)}catch{}},[vt,xt,Ot]);const Qe=T.useCallback(y=>{var L;if(J.current=null,Fe(y),!n&&y.winner===(((L=m.current)==null?void 0:L.me)??0)){const j=xs();oe(Nn(s)),Sn(j).then(()=>{j<vs&&xs()>=vs&&oe(On)}).catch(()=>{})}const k=B.current;setTimeout(()=>{if(!k||k instanceof ge)return Bt(!0);const j=k.recorder.winner;if(!j)return Bt(!0);Be({label:"Game winner",tone:j.team===0?"you":"them"}),k.playClip(j,()=>{Be(null),Bt(!0)})},1100)},[n,s]);T.useEffect(()=>{var L;if((L=B.current)==null||L.reset(),Dt.current=[],Fe(null),oe(null),Bt(!1),J.current=Qe,n&&a){const j=new Ti(s,I=>{var O;return(O=B.current)==null?void 0:O.events(I,0)});m.current=j;let $=!1;const q=js({teamId:n,watch:!0,match:I=>{Gt.current=I.serverNow-Date.now(),v(I)},state:(I,O)=>j.push(I,O),relay:()=>{},rtc:()=>{},chat:()=>{},emote:()=>{},pong:()=>{},status:I=>{I&&!$&&j.rejoin(),$=I,M(I)},blocked:E,error:w});return p.current=q,()=>{q.close(),p.current=null,E(!1),J.current=null,m.current=null}}if(n){let j=null,$=!1,q=ua();const I=js({teamId:n,match:O=>{var C;Gt.current=O.serverNow-Date.now(),v(O),!j&&O.slot!==null&&(j=new vi(s,O.slot,W=>I.send(W)),m.current=j),!nt.current&&O.slot!==null&&(nt.current=new ni({teamId:n,slot:O.slot,size:O.size,send:W=>I.send(W),change:Ye})),(C=nt.current)==null||C.match(O),q&&nt.current&&O.voiceAvailable&&O.status!=="complete"&&(q=!1,nt.current.enable().catch(W=>Yt(W.message)));const et=O.status==="live"&&!O.paused;j==null||j.setLive(et),ut.current=et},state:(O,et,C)=>{var W;j&&(j.push(O,C),et.length&&((W=B.current)==null||W.events(et,j.me)))},relay:O=>j==null?void 0:j.relay(O),rtc:(O,et,C)=>{var W;return void((W=nt.current)==null?void 0:W.receive(O,et,C))},chat:He,emote:Ke,pong:O=>j==null?void 0:j.pong(O),status:O=>{O&&!$&&(j==null||j.rejoin()),$=O,M(O)},blocked:E,error:w});return p.current=I,()=>{var O;(O=nt.current)==null||O.dispose(),nt.current=null,Ye("off"),I.close(),p.current=null,E(!1),J.current=null,m.current=null,ut.current=!1}}const y=j=>{var $;return($=B.current)==null?void 0:$.events(j,0)},k=new li(s,y);return m.current=k,ut.current=!0,()=>{J.current=null,m.current=null,ut.current=!1}},[s,De,Qe,n,a,z,He,Ke]),T.useEffect(()=>{var k,L;if(!n||(c==null?void 0:c.status)!=="complete"||P)return;const y=(k=m.current)==null?void 0:k.current();y&&y.phase!=="over"&&((L=J.current)==null||L.call(J,y))},[n,c,P]),T.useEffect(()=>{if(!Wt)return;const y=setTimeout(()=>Yt(""),5e3);return()=>clearTimeout(y)},[Wt]),T.useEffect(()=>{ut.current=!a&&P===null&&m.current!==null&&(!n||(c==null?void 0:c.status)==="live"&&!c.paused)},[P,n,a,c]);const[le,ts]=T.useState(!1),[At,es]=T.useState(""),ss=async()=>
2{if(!le){ts(!0),es("");try{n&&await Yn(n),t()}catch{es("Could not leave the game. Reconnect or try Leave again.")}finally{ts(!1)}}},gt=y=>k=>{k.currentTarget.blur(),y()},un=()=>{var k;const y=(k=B.current)==null?void 0:k.audio;y&&(y.setMuted(!y.muted),We(y.muted))},fn=()=>{var y;return(y=B.current)==null?void 0:y.stopReplay()},dn=Hn(n?(c==null?void 0:c.slot)!=null&&c.status==="complete"?c.id:null:P&&re?`rec:${De}`:null,n?{won:!!c&&c.winner===(((as=m.current)==null?void 0:as.me)??0),rated:!!c&&c.ratingStatus!=="unranked"}:{unlocked:!0},"team"),Ct=qn({tournament:c==null?void 0:c.tournament,matchId:n,seated:!!n&&!a,won:(c==null?void 0:c.status)==="complete"?c.winner===(((is=m.current)==null?void 0:is.me)??0):null});if(N)return f.jsx("div",{className:"i3-court",children:f.jsx("section",{className:"i3-sheet",children:f.jsxs("div",{className:"i3-sheet-in",children:[f.jsx("div",{className:"i3-eyebrow",children:"Team game"}),f.jsx("h2",{className:"i3-h2",children:a?"Can't watch":N==="CONNECTION_REPLACED"?"Playing in another tab":N==="NOT_A_PARTICIPANT"?"You're not in this game":"That game is gone"}),a?f.jsx("p",{className:"i3-lede",children:N==="NOT_WATCHABLE"?"Only tournament games can be watched.":N==="WATCH_FULL"?"This game has as many spectators as it can take.":N==="CONNECTION_REPLACED"?"You're watching this game in another tab.":"That game is over or gone."}):null,f.jsxs("div",{className:"i3-row",children:[!a&&N==="CONNECTION_REPLACED"&&f.jsx("button",{type:"button",className:"i3-btn",onClick:()=>{w(""),rt(y=>y+1)},children:"Play here"}),f.jsx("button",{type:"button",className:"i3-btn",onClick:t,children:"Lobby"})]})]})})});if(ie)return f.jsx("div",{className:"i3-court",children:f.jsx("section",{className:"i3-sheet",children:f.jsxs("div",{className:"i3-sheet-in",children:[f.jsx("div",{className:"i3-eyebrow",children:"Rec run"}),f.jsx("h2",{className:"i3-h2",children:"3D is unavailable here"}),f.jsx("p",{className:"i3-lede",children:"This browser could not start WebGL."}),f.jsx("div",{className:"i3-row",children:f.jsx("button",{type:"button",className:"i3-btn",onClick:t,children:"Lobby"})})]})})});const Y=((rs=m.current)==null?void 0:rs.me)??0,kt=1-Y,_=!!n,Rt=_&&(c==null?void 0:c.status)==="complete"?c.winner:P==null?void 0:P.winner,Et=P!==null&&Rt===Y,mn=P!==null&&!St&&an,jt=`${s}v${s}`,It=y=>{var k;return((k=c==null?void 0:c.teams[y][0])==null?void 0:k.name)??(y===0?"Home":"Away")},ce=c?c.teams[Y]:null,ns=((os=c==null?void 0:c.ratingDeltas)==null?void 0:os[Y])??null,tt=(c==null?void 0:c.slot)??null,Ht=ns&&tt!==null?ns[tt%s]:null,he=_&&(!c||c.status==="waiting"),pn=c?c.connected.filter((y,k)=>!y&&!c.left[k]).length:0,ue=(c==null?void 0:c.startDeadline)!=null?Math.max(0,Math.ceil((c.startDeadline-(on+Gt.current))/1e3)):null,yn=c?b?pn===0?"Everyone is in. Tipping off…":ue===null?"The game tips when everyone is in.":ue>0?`Tips when everyone is in. Bots take empty seats in ${ue}s.`:"Bots are taking the empty seats…":"Reconnecting…":"Connecting to the game…",xn=_&&!!(c!=null&&c.voiceAvailable)&&tt!==null,vn=!!(c!=null&&c.voice)&&tt!==null&&c.voice.some((y,k)=>y&&k!==tt&&Math.floor(k/s)===Math.floor(tt/s)),bn=()=>{const y=nt.current;y&&(Yt(""),ft==="off"?y.enable().catch(k=>Yt(k.message)):y.disable())};return f.jsxs("div",{className:`i3-court${St?" is-replay":""}`,children:[f.jsx("canvas",{ref:l,className:"i3-canvas","aria-label":`${_?"Team":"Rec run"} ${jt} half-court game`}),f.jsx("div",{ref:ot.layerRef,className:"iso-say-layer",role:"log","aria-live":"polite"}),f.jsx("div",{ref:o,className:"i3-overlay","aria-hidden":"true"}),ot.open?f.jsx(Kn,{onSend:ot.say,onClose:()=>ot.setOpen(!1),placeholder:"Message your team"}):null,f.jsxs("div",{ref:h,className:"iso-chrome",children:[f.jsxs("div",{className:"iso-chrome-l i3-tools i3-tools-l",children:[f.jsx("button",{type:"button",className:"i3-icon","aria-label":a?"Stop watching":"Leave game",onClick:gt(_&&!P&&!a?ss:t),children:f.jsx(lt,{d:"M15 5l-7 7 7 7"})}),_&&!P&&(c==null?void 0:c.status)!=="complete"?f.jsx(Vn,{current:r?"2d":"3d",className:"i3-icon"}):null]}
2),f.jsx(Cn,{bind:u,names:a?[It(0),It(1)]:_?["Your team","Them"]:["You","CPU"],clock:we.clock,target:Ce(s),mid:Ct&&(c!=null&&c.tournament)?f.jsx(aa,{run:Ct,gameNo:c.tournament.gameNo}):null}),f.jsxs("div",{className:"iso-chrome-r i3-tools i3-tools-r",children:[!r&&f.jsx("button",{type:"button",className:"i3-icon","aria-label":vt==="broadcast"?"Courtside camera":"Broadcast camera","aria-pressed":vt==="courtside",onClick:gt(()=>rn(y=>y==="broadcast"?"courtside":"broadcast")),children:f.jsxs(lt,{children:[f.jsx("rect",{x:"3",y:"7",width:"13",height:"10"}),f.jsx("path",{d:vt==="broadcast"?"M16 10.5l5-3v9l-5-3":"M16 12l5-4v8z"})]})}),f.jsx("button",{type:"button",className:"i3-icon","aria-label":"Sound","aria-pressed":$e,onClick:gt(un),children:f.jsxs(lt,{children:[f.jsx("path",{d:"M4 9v6h4l5 4V5L8 9z"}),$e?f.jsx("path",{d:"M17 9l5 6M22 9l-5 6"}):f.jsx("path",{d:"M16.5 8.5a5 5 0 0 1 0 7M19 6a8.5 8.5 0 0 1 0 12"})]})}),Ue?f.jsx("button",{type:"button",className:"i3-icon","aria-label":"Team chat (Tab)",title:"Team chat (Tab)","aria-expanded":ot.open,onClick:gt(()=>ot.setOpen(!0)),children:f.jsx(Xn,{})}):null,xn?f.jsxs("button",{type:"button",className:"i3-icon iso-voice","data-state":ft,"aria-label":Gs[ft],title:Gs[ft],"aria-pressed":ft!=="off",onClick:gt(bn),children:[f.jsxs(lt,{children:[f.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),f.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"}),ft==="off"?f.jsx("path",{d:"M4 4l16 16"}):null]}),vn&&ft!=="live"?f.jsx("i",{className:"iso-voice-dot"}):null]}):null,Wt?f.jsx("p",{className:"iso-voice-note",role:"status",children:Wt}):null]})]}),f.jsx("div",{className:"i3-tip",ref:u("tip"),"aria-live":"polite"}),_&&!P&&(a||((c==null?void 0:c.watchers)??0)>0)?f.jsxs("div",{className:"iso-watching",role:"status",children:[f.jsxs(lt,{children:[f.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"}),f.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),f.jsx("span",{children:a?`Watching · ${(c==null?void 0:c.watchers)??1}`:`${c==null?void 0:c.watchers} watching`})]}):null,$t?f.jsxs("button",{type:"button",className:"i3-run-switch i3-run-ring",ref:u("sw"),hidden:!0,"aria-label":"Switch defender",onPointerDown:y=>{y.preventDefault(),Ft.current.push("switch")},children:[f.jsx(lt,{d:"M7 7h11l-3-3M17 17H6l3 3"}),"Switch"]}):null,$t?f.jsxs("button",{type:"button",className:"i3-run-switch",ref:u("ps"),hidden:!0,"aria-label":"Pass",onPointerDown:y=>{y.preventDefault(),Ft.current.push("pass")},children:[f.jsx(lt,{d:"M4 12h15M14 7l5 5-5 5"}),"Pass"]}):null,$t?f.jsxs("button",{type:"button",className:"i3-run-switch i3-run-ring i3-run-oop",ref:u("oop"),hidden:!0,"aria-label":"Alley-oop",onPointerDown:y=>{y.preventDefault(),Ft.current.push("oop")},children:[f.jsx(lt,{d:"M4 18C7 8 14 5 20 8M16 4l4 4-4 4"}),"Oop"]}):null,_&&c&&!P&&!he&&!$t?f.jsx("ol",{className:"i3-roster","aria-label":"Players",children:[Y,kt].map(y=>c.teams[y].map((k,L)=>{var q;const j=y*s+L,$=c.connected[j]&&!c.left[j];return f.jsxs("li",{"data-side":y===Y?"you":"them","data-here":$,children:[f.jsx("i",{"aria-hidden":"true"}),f.jsx("span",{children:j===tt?"You":k.name}),y===Y&&((q=c.voice)!=null&&q[j])?f.jsxs("svg",{className:"i3-roster-mic",viewBox:"0 0 24 24","aria-label":"In voice",children:[f.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),f.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]}):null,!$&&c.status==="live"?f.jsx("small",{children:"CPU"}):null]},k.id)}))}):null,_&&!he&&!P&&(!b||At||c!=null&&c.paused)?f.jsxs("div",{className:"i3-link i3-team-link",role:"status",children:[b&&(c!=null&&c.paused)?f.jsx("span",{children:c.restart?"Reconnecting… The server restarted. The game resumes when everyone is back.":"Everyone is back. Resuming…"}):null,b?null:f.jsxs(f.Fragment,{children:[f.jsx("span",{children:a?"Reconnecting…":"Reconnecting… A CPU covers your seat until you return."}),f.jsx("button",{type:"button",className:"i3-btn ghost",onClick:()=>{var y;return(y=p.current)==null?void 0:y.reconnect()},children:"Reconnect"})]}),At?f.jsx("p",{className:"i3-error",role:"alert",children:At}):null]}):null,he?f.jsx("section",{className:"i3-sheet",children:f.jsxs("div",{className:"i3-sheet-in",children:[f.jsxs("div",{className:"i3-eyebrow",children:[jt," · ",c!=null&&c.ranked?"Ranked":"Unranked"]}),f.jsx("h2",{className:"i3-h2",children:a?"Waiting for tip-off":"Waiting for players"}),f.jsx("p",{className:"i3-lede",children:yn}),A&&!c?f.jsx(Jn,{onRetry:()=>{var y;return(y=p.current)==null?void 0:y.reconnect()}}):null,At?f.jsx("p",{className:"i3-error",role:"alert",children:At}):null,c?f.jsx("ol",{className:"i3-wait","aria-label":"Players",children:[Y,kt].map(y=>c.teams[y].map((k,L)=>{const j=y*s+L,$=c.connected[j]&&!c.left[j];return f.jsxs("li",{"data-side":y===Y?"you":"them","data-here":$,children:[f.jsx("i",{"aria-hidden":"true"}),f.jsx("span",{children:j===tt?"You":k.name}),f.jsx("small",{children:$?"In":"Connecting…"})]},k.id)}))}):null,f.jsxs("div",{className:"i3-row",children:[a?f.jsx("button",{type:"button",className:"i3-btn ghost",onClick:t,children:"Back"}):f.jsx("button",{type:"button",className:"i3-btn ghost",onClick:ss,disabled:le,children:le?"Leaving…":"Leave"}),b?null:f.jsx("button",{type:"button",className:"i3-btn",onClick:()=>{var y;return(y=p.current)==null?void 0:y.reconnect()},children:"Reconnect"})]})]})}):null,St?f.jsxs("div",{className:"i3-replay","data-tone":St.tone,children:[f.jsx("span",{className:"i3-rec",children:"Replay"}),f.jsx("b",{children:St.label}),f.jsx("button",{type:"button",className:"i3-skip",onClick:gt(fn),children:"Skip"})]}):null,mn&&P?f.jsx("section",{className:"i3-sheet",children:f.jsxs("div",{className:`i3-sheet-in${_&&c?" wide":""}`,children:[f.jsxs("div",{className:"i3-eyebrow",children:[_?c!=null&&c.tournament&&!c.tournament.swiss?`${jt} · ${ya(c.tournament,Ct)}`:`Team ${jt}`:`Rec run · ${jt}`,_&&(c!=null&&c.reason)&&Hs[c.reason]?` · ${Hs[c.reason]}`:""]}),f.jsx("h2",{className:`i3-h2${Et&&!a?" win":""}`,children:_?Rt==null?"No result":a?Rt===-1?"No result":`${It(Rt)} wins`:Et?"Your team wins":"They win":Et?"You win":"CPU wins"}),f.jsxs("div",{className:"i3-final",children:[f.jsx("span",{className:Et?"win":"",children:P.score[Y]}),f.jsx("i",{}),f.jsx("span",{className:Et||Rt==null?"":"win",children:P.score[kt]})]}),re?f.jsxs("p",{className:"i3-note",children:[Wn[re].label," unlocked for"," ",f.jsx(je,{to:"/sixrings/iso/career",children:"YoCareer"}),"."]}):null,_&&c&&!a?f.jsx("p",{className:c.ranked&&Ht!==null?"i3-rating":"i3-note",children:c.ranked?Ht!==null?`${Ht>=0?"+":""}${Ht} ${jt} Elo`:"Saving your rating…":"Unranked game."}):null,Ct&&(c==null?void 0:c.status)==="complete"?f.jsx(ia,{run:Ct}):null,!a&&_&&(c!=null&&c.tournament)?f.jsx(ai,{tournament:c.tournament,gameId:c.id,serverNowMs:()=>Date.now()+Gt.current}):null,_&&c?f.jsx(ra,{sides:oa(c,Y,tt),rated:c.ratingStatus}):null,a?null:f.jsxs("div",{className:`i3-box${Dt.current.length?"":" solo"}`,children:[f.jsx("dl",{className:"i3-stats",children:Ci(P.stats[Y]).map(([y,k])=>f.jsxs("div",{children:[f.jsx("dt",{children:k}),f.jsx("dd",{children:y})]},k))}),f.jsx(Ri,{shots:Dt.current})]}),f.jsxs("div",{className:"i3-run-boxes",children:[f.jsxs("div",{children:[_&&c?f.jsx("div",{className:`i3-eyebrow${a?"":" iso-wide-only"}`,children:a?It(Y):"Your team"}):null,f.jsx(Us,{box:P.box,size:s,team:Y,names:ce==null?void 0:ce.map((y,k)=>Y*s+k===tt?"You":y.name)})]}),_&&c?f.jsxs("div",{className:a?void 0:"iso-wide-only",children:[f.jsx("div",{className:"i3-eyebrow",children:a?It(kt):"Opponents"}),f.jsx(Us,{box:P.box,size:s,team:kt,names:c.teams[kt].map(y=>y.name)})]}):null]}),f.jsx(Zn,{trigger:dn,surface:"team",returnTo:"/sixrings/iso/v3",btn:"i3-btn"}),f.jsx(Qn,{resultKey:n&&(c==null?void 0:c.slot)!=null&&c.status==="complete"?c.id:null,won:!!c&&c.winner===(((ls=m.current)==null?void 0:ls.me)??0),saved:(c==null?void 0:c.ratingStatus)==="saved",btn:"i3-btn"}),a?f.jsxs("div",{className:"i3-row i3-result-row",children:[c!=null&&c.tournament?f.jsx(je,{className:"i3-btn",to:`/sixrings/iso/bracket/${c.tournament.id}`,children:"Bracket"}):null,f.jsx("button",{type:"button",className:"i3-btn ghost",onClick:t,children:"Lobby"})]}):_&&(c!=null&&c.tournament)?f.jsx(ii,{tournament:c.tournament,onLobby:t}):_?e??f.jsx("div",{className:"i3-row i3-result-row",children:f.jsx("button",{type:"button",className:"i3-btn ghost",onClick:t,children:"Lobby"})}):f.jsxs("div",{className:"i3-row",children:[f.jsx("button",{type:"button",className:"i3-btn",onClick:()=>sn(y=>y+1),children:"Run it back"}),i&&s<5?f.jsxs("button",{type:"button",className:"i3-btn ghost",onClick:()=>i(s+1),children:["Try ",s+1,"v",s+1]}):null,f.jsx("button",{type:"button",className:"i3-btn ghost",onClick:t,children:"Lobby"})]})]})}):null]})}const Zi=Object.freeze(Object.defineProperty({__proto__:null,RunCourt:Ei},Symbol.toStringTag,{value:"Module"}));
2export{ai as I,Ei as R,va as a,ii as b,Zi as c};

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.