Repository navigation
Expand file tree
/
Copy pathProfile.FIYvQsk3.js
More file actions
1 lines (1 loc) · 41.9 KB
/
Copy pathProfile.FIYvQsk3.js
File metadata and controls
1 lines (1 loc) · 41.9 KB
1
import{j as e}from"./jsx-runtime.CP-cH_KB.js";import{r as x,R as k}from"./index.D3MhXEDl.js";import{W as Z,e as We,b as Ae,l as Ke,T as Ve,I as qe,G as Je,p as Qe,a as P,$ as Ce,k as Pe,w as Ee,D as re,j as Ye,H as te,O as je,N as U,a2 as Ze,h as de,a3 as le,a4 as ae,u as Oe,a5 as Xe,M as oe,y as X,Y as et,a6 as _e,K as Fe,a7 as tt,E as nt,F as st,v as rt,Z as lt,d as at,c as Y,i as ee,g as ot,m as it,s as Me,V as Ie,C as Te,q as ct,R as dt,r as ut,a0 as pt,n as mt,t as xt,A as ft,a8 as Q,a9 as q,B as ht,a1 as vt,J as bt,aa as gt,ab as jt,ac as he}from"./portal.BhN3p41c.js";import{C as _t}from"./canvasjs.react.Creynk7O.js";import"./index.BHZy_G86.js";let wt="span";function yt(r,t){let o=x.useId(),m=We(),f=Ae(),{id:u=m||`headlessui-checkbox-${o}`,disabled:d=f||!1,autoFocus:l=!1,checked:a,defaultChecked:w,onChange:i,name:v,value:h,form:b,indeterminate:p=!1,...s}=r,n=Ke(w),[c,g]=Ve(a,i,n??!1),$=qe(),S=Je(),E=Qe(),[C,R]=x.useState(!1),B=P(()=>{R(!0),g?.(!c),E.nextFrame(()=>{R(!1)})}),M=P(N=>{if(je(N.currentTarget))return N.preventDefault();N.preventDefault(),B()}),H=P(N=>{N.key===U.Space?(N.preventDefault(),B()):N.key===U.Enter&&Ze(N.currentTarget)}),G=P(N=>N.preventDefault()),{isFocusVisible:F,focusProps:T}=Ce({autoFocus:l}),{isHovered:I,hoverProps:z}=Pe({isDisabled:d}),{pressed:A,pressProps:K}=Ee({disabled:d}),j=re({ref:t,id:u,role:"checkbox","aria-checked":p?"mixed":c?"true":"false","aria-labelledby":$,"aria-describedby":S,"aria-disabled":d?!0:void 0,indeterminate:p?"true":void 0,tabIndex:d?void 0:0,onKeyUp:d?void 0:H,onKeyPress:d?void 0:G,onClick:d?void 0:M},T,z,K),_=x.useMemo(()=>({checked:c,disabled:d,hover:I,focus:F,active:A,indeterminate:p,changing:C,autofocus:l}),[c,p,d,I,F,A,C,l]),y=x.useCallback(()=>{if(n!==void 0)return g?.(n)},[g,n]);return k.createElement(k.Fragment,null,v!=null&&k.createElement(Ye,{disabled:d,data:{[v]:h||"on"},overrides:{type:"checkbox",checked:c},form:b,onReset:y}),te({ourProps:j,theirProps:s,slot:_,defaultTag:wt,name:"Checkbox"}))}let Re=Z(yt);function Nt({defaultContainers:r=[],portals:t,mainTreeNode:o}={}){let m=de(o),f=P(()=>{var u,d;let l=[];for(let a of r)a!==null&&(a instanceof HTMLElement?l.push(a):"current"in a&&a.current instanceof HTMLElement&&l.push(a.current));if(t!=null&&t.current)for(let a of t.current)l.push(a);for(let a of(u=m?.querySelectorAll("html > *, body > *"))!=null?u:[])a!==document.body&&a!==document.head&&a instanceof HTMLElement&&a.id!=="headlessui-portal-root"&&(o&&(a.contains(o)||a.contains((d=o?.getRootNode())==null?void 0:d.host))||l.some(w=>a.contains(w))||l.push(a));return l});return{resolveContainers:f,contains:P(u=>f().some(d=>d.contains(u)))}}let Be=x.createContext(null);function De({children:r,node:t}){let[o,m]=x.useState(null),f=He(t??o);return k.createElement(Be.Provider,{value:f},r,f===null&&k.createElement(le,{features:ae.Hidden,ref:u=>{var d,l;if(u){for(let a of(l=(d=Oe(u))==null?void 0:d.querySelectorAll("html > *, body > *"))!=null?l:[])if(a!==document.body&&a!==document.head&&a instanceof HTMLElement&&a!=null&&a.contains(u)){m(a);break}}}}))}function He(r=null){var t;return(t=x.useContext(Be))!=null?t:r}var W=(r=>(r[r.Forwards=0]="Forwards",r[r.Backwards=1]="Backwards",r))(W||{});function Ge(){let r=x.useRef(0);return Xe(!0,"keydown",t=>{t.key==="Tab"&&(r.current=t.shiftKey?1:0)},!0),r}var kt=(r=>(r[r.Open=0]="Open",r[r.Closed=1]="Closed",r))(kt||{}),Ft=(r=>(r[r.TogglePopover=0]="TogglePopover",r[r.ClosePopover=1]="ClosePopover",r[r.SetButton=2]="SetButton",r[r.SetButtonId=3]="SetButtonId",r[r.SetPanel=4]="SetPanel",r[r.SetPanelId=5]="SetPanelId",r))(Ft||{});let $t={0:r=>({...r,popoverState:Y(r.popoverState,{0:1,1:0}),__demoMode:!1}),1(r){return r.popoverState===1?r:{...r,popoverState:1,__demoMode:!1}},2(r,t){return r.button===t.button?r:{...r,button:t.button}},3(r,t){return r.buttonId===t.buttonId?r:{...r,buttonId:t.buttonId}},4(r,t){return r.panel===t.panel?r:{...r,panel:t.panel}},5(r,t){return r.panelId===t.panelId?r:{...r,panelId:t.panelId}}},we=x.createContext(null);we.displayName="PopoverContext";function ue(r){let t=x.useContext(we);if(t===null){let o=new Error(`<${r} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,ue),o}return t}let pe=x.createContext(null);pe.displayName="PopoverAPIContext";function ye(r){let t=x.useContext(pe);if(t===null){let o=new Error(`<${r} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,ye),o}return t}let Ne=x.createContext(null);Ne.displayName="PopoverGroupContext";function Le(){return x.useContext(Ne)}let me=x.createContext(null);me.displayName="PopoverPanelContext";function St(){return x.useContext(me)}function Ct(r,t){return Y(t.type,$t,r,t)}let Pt="div";function Et(r,t){var o;let{__demoMode:m=!1,...f}=r,u=x.useRef(null),d=X(t,et(j=>{u.current=j})),l=x.useRef([]),a=x.useReducer(Ct,{__demoMode:m,popoverState:m?0:1,buttons:l,button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:x.createRef(),afterPanelSentinel:x.createRef(),afterButtonSentinel:x.createRef()}),[{popoverState:w,button:i,buttonId:v,panel:h,panelId:b,beforePanelSentinel:p,afterPanelSentinel:s,afterButtonSentinel:n},c]=a,g=de((o=u.current)!=null?o:i),$=x.useMemo(()=>{if(!i||!h)return!1;for(let O of document.querySelectorAll("body > *"))if(Number(O?.contains(i))^Number(O?.contains(h)))return!0;let j=_e(),_=j.indexOf(i),y=(_+j.length-1)%j.length,N=(_+1)%j.length,D=j[y],L=j[N];return!h.contains(D)&&!h.contains(L)},[i,h]),S=Fe(v),E=Fe(b),C=x.useMemo(()=>({buttonId:S,panelId:E,close:()=>c({type:1})}),[S,E,c]),R=Le(),B=R?.registerPopover,M=P(()=>{var j;return(j=R?.isFocusWithinPopoverGroup())!=null?j:g?.activeElement&&(i?.contains(g.activeElement)||h?.contains(g.activeElement))});x.useEffect(()=>B?.(C),[B,C]);let[H,G]=tt(),F=He(i),T=Nt({mainTreeNode:F,portals:H,defaultContainers:[i,h]});nt(g?.defaultView,"focus",j=>{var _,y,N,D,L,O;j.target!==window&&j.target instanceof HTMLElement&&w===0&&(M()||i&&h&&(T.contains(j.target)||(y=(_=p.current)==null?void 0:_.contains)!=null&&y.call(_,j.target)||(D=(N=s.current)==null?void 0:N.contains)!=null&&D.call(N,j.target)||(O=(L=n.current)==null?void 0:L.contains)!=null&&O.call(L,j.target)||c({type:1})))},!0),st(w===0,T.resolveContainers,(j,_)=>{c({type:1}),gt(_,jt.Loose)||(j.preventDefault(),i?.focus())});let I=P(j=>{c({type:1});let _=j?j instanceof HTMLElement?j:"current"in j&&j.current instanceof HTMLElement?j.current:i:i;_?.focus()}),z=x.useMemo(()=>({close:I,isPortalled:$}),[I,$]),A=x.useMemo(()=>({open:w===0,close:I}),[w,I]),K={ref:d};return k.createElement(De,{node:F},k.createElement(rt,null,k.createElement(me.Provider,{value:null},k.createElement(we.Provider,{value:a},k.createElement(pe.Provider,{value:z},k.createElement(lt,{value:I},k.createElement(at,{value:Y(w,{0:ee.Open,1:ee.Closed})},k.createElement(G,null,te({ourProps:K,theirProps:f,slot:A,defaultTag:Pt,name:"Popover"})))))))))}let Ot="button";function Mt(r,t){let o=x.useId(),{id:m=`headlessui-popover-button-${o}`,disabled:f=!1,autoFocus:u=!1,...d}=r,[l,a]=ue("Popover.Button"),{isPortalled:w}=ye("Popover.Button"),i=x.useRef(null),v=`headlessui-focus-sentinel-${x.useId()}`,h=Le(),b=h?.closeOthers,p=St()!==null;x.useEffect(()=>{if(!p)return a({type:3,buttonId:m}),()=>{a({type:3,buttonId:null})}},[p,m,a]);let[s]=x.useState(()=>Symbol()),n=X(i,t,ot(),p?null:_=>{if(_)l.buttons.current.push(s);else{let y=l.buttons.current.indexOf(s);y!==-1&&l.buttons.current.splice(y,1)}l.buttons.current.length>1&&console.warn("You are already using a <Popover.Button /> but only 1 <Popover.Button /> is supported."),_&&a({type:2,button:_})}),c=X(i,t),g=de(i),$=P(_=>{var y,N,D;if(p){if(l.popoverState===1)return;switch(_.key){case U.Space:case U.Enter:_.preventDefault(),(N=(y=_.target).click)==null||N.call(y),a({type:1}),(D=l.button)==null||D.focus();break}}else switch(_.key){case U.Space:case U.Enter:_.preventDefault(),_.stopPropagation(),l.popoverState===1&&b?.(l.buttonId),a({type:0});break;case U.Escape:if(l.popoverState!==0)return b?.(l.buttonId);if(!i.current||g!=null&&g.activeElement&&!i.current.contains(g.activeElement))return;_.preventDefault(),_.stopPropagation(),a({type:1});break}}),S=P(_=>{p||_.key===U.Space&&_.preventDefault()}),E=P(_=>{var y,N;je(_.currentTarget)||f||(p?(a({type:1}),(y=l.button)==null||y.focus()):(_.preventDefault(),_.stopPropagation(),l.popoverState===1&&b?.(l.buttonId),a({type:0}),(N=l.button)==null||N.focus()))}),C=P(_=>{_.preventDefault(),_.stopPropagation()}),{isFocusVisible:R,focusProps:B}=Ce({autoFocus:u}),{isHovered:M,hoverProps:H}=Pe({isDisabled:f}),{pressed:G,pressProps:F}=Ee({disabled:f}),T=l.popoverState===0,I=x.useMemo(()=>({open:T,active:G||T,disabled:f,hover:M,focus:R,autofocus:u}),[T,M,R,G,f,u]),z=it(r,i),A=p?re({ref:c,type:z,onKeyDown:$,onClick:E,disabled:f||void 0,autoFocus:u},B,H,F):re({ref:n,id:l.buttonId,type:z,"aria-expanded":l.popoverState===0,"aria-controls":l.panel?l.panelId:void 0,disabled:f||void 0,autoFocus:u,onKeyDown:$,onKeyUp:S,onClick:E,onMouseDown:C},B,H,F),K=Ge(),j=P(()=>{let _=l.panel;if(!_)return;function y(){Y(K.current,{[W.Forwards]:()=>Q(_,q.First),[W.Backwards]:()=>Q(_,q.Last)})===he.Error&&Q(_e().filter(N=>N.dataset.headlessuiFocusGuard!=="true"),Y(K.current,{[W.Forwards]:q.Next,[W.Backwards]:q.Previous}),{relativeTo:l.button})}y()});return k.createElement(k.Fragment,null,te({ourProps:A,theirProps:d,slot:I,defaultTag:Ot,name:"Popover.Button"}),T&&!p&&w&&k.createElement(le,{id:v,ref:l.afterButtonSentinel,features:ae.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:j}))}let It="div",Tt=oe.RenderStrategy|oe.Static;function ze(r,t){let o=x.useId(),{id:m=`headlessui-popover-backdrop-${o}`,transition:f=!1,...u}=r,[{popoverState:d},l]=ue("Popover.Backdrop"),a=x.useRef(null),w=X(t,a),i=Me(),[v,h]=Ie(f,a,i!==null?(i&ee.Open)===ee.Open:d===0),b=P(n=>{if(je(n.currentTarget))return n.preventDefault();l({type:1})}),p=x.useMemo(()=>({open:d===0}),[d]),s={ref:w,id:m,"aria-hidden":!0,onClick:b,...Te(h)};return te({ourProps:s,theirProps:u,slot:p,defaultTag:It,features:Tt,visible:v,name:"Popover.Backdrop"})}let Rt="div",Bt=oe.RenderStrategy|oe.Static;function Dt(r,t){let o=x.useId(),{id:m=`headlessui-popover-panel-${o}`,focus:f=!1,anchor:u,portal:d=!1,modal:l=!1,transition:a=!1,...w}=r,[i,v]=ue("Popover.Panel"),{close:h,isPortalled:b}=ye("Popover.Panel"),p=`headlessui-focus-sentinel-before-${o}`,s=`headlessui-focus-sentinel-after-${o}`,n=x.useRef(null),c=ct(u),[g,$]=dt(c),S=ut();c&&(d=!0);let E=X(n,t,c?g:null,j=>{v({type:4,panel:j})}),C=de(n),R=pt();mt(()=>(v({type:5,panelId:m}),()=>{v({type:5,panelId:null})}),[m,v]);let B=Me(),[M,H]=Ie(a,n,B!==null?(B&ee.Open)===ee.Open:i.popoverState===0);xt(M,i.button,()=>{v({type:1})});let G=i.__demoMode?!1:l&&M;ft(G,C);let F=P(j=>{var _;switch(j.key){case U.Escape:if(i.popoverState!==0||!n.current||C!=null&&C.activeElement&&!n.current.contains(C.activeElement))return;j.preventDefault(),j.stopPropagation(),v({type:1}),(_=i.button)==null||_.focus();break}});x.useEffect(()=>{var j;r.static||i.popoverState===1&&((j=r.unmount)==null||j)&&v({type:4,panel:null})},[i.popoverState,r.unmount,r.static,v]),x.useEffect(()=>{if(i.__demoMode||!f||i.popoverState!==0||!n.current)return;let j=C?.activeElement;n.current.contains(j)||Q(n.current,q.First)},[i.__demoMode,f,n.current,i.popoverState]);let T=x.useMemo(()=>({open:i.popoverState===0,close:h}),[i.popoverState,h]),I=re(c?S():{},{ref:E,id:m,onKeyDown:F,onBlur:f&&i.popoverState===0?j=>{var _,y,N,D,L;let O=j.relatedTarget;O&&n.current&&((_=n.current)!=null&&_.contains(O)||(v({type:1}),((N=(y=i.beforePanelSentinel.current)==null?void 0:y.contains)!=null&&N.call(y,O)||(L=(D=i.afterPanelSentinel.current)==null?void 0:D.contains)!=null&&L.call(D,O))&&O.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...w.style,...$,"--button-width":ht(i.button,!0).width},...Te(H)}),z=Ge(),A=P(()=>{let j=n.current;if(!j)return;function _(){Y(z.current,{[W.Forwards]:()=>{var y;Q(j,q.First)===he.Error&&((y=i.afterPanelSentinel.current)==null||y.focus())},[W.Backwards]:()=>{var y;(y=i.button)==null||y.focus({preventScroll:!0})}})}_()}),K=P(()=>{let j=n.current;if(!j)return;function _(){Y(z.current,{[W.Forwards]:()=>{var y;if(!i.button)return;let N=_e(),D=N.indexOf(i.button),L=N.slice(0,D+1),O=[...N.slice(D+1),...L];for(let xe of O.slice())if(xe.dataset.headlessuiFocusGuard==="true"||(y=i.panel)!=null&&y.contains(xe)){let ke=O.indexOf(xe);ke!==-1&&O.splice(ke,1)}Q(O,q.First,{sorted:!1})},[W.Backwards]:()=>{var y;Q(j,q.Previous)===he.Error&&((y=i.button)==null||y.focus())}})}_()});return k.createElement(vt,null,k.createElement(me.Provider,{value:m},k.createElement(pe.Provider,{value:{close:h,isPortalled:b}},k.createElement(bt,{enabled:d?r.static||M:!1},M&&b&&k.createElement(le,{id:p,ref:i.beforePanelSentinel,features:ae.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:A}),te({mergeRefs:R,ourProps:I,theirProps:w,slot:T,defaultTag:Rt,features:Bt,visible:M,name:"Popover.Panel"}),M&&b&&k.createElement(le,{id:s,ref:i.afterPanelSentinel,features:ae.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:K})))))}let Ht="div";function Gt(r,t){let o=x.useRef(null),m=X(o,t),[f,u]=x.useState([]),d=P(p=>{u(s=>{let n=s.indexOf(p);if(n!==-1){let c=s.slice();return c.splice(n,1),c}return s})}),l=P(p=>(u(s=>[...s,p]),()=>d(p))),a=P(()=>{var p;let s=Oe(o);if(!s)return!1;let n=s.activeElement;return(p=o.current)!=null&&p.contains(n)?!0:f.some(c=>{var g,$;return((g=s.getElementById(c.buttonId.current))==null?void 0:g.contains(n))||(($=s.getElementById(c.panelId.current))==null?void 0:$.contains(n))})}),w=P(p=>{for(let s of f)s.buttonId.current!==p&&s.close()}),i=x.useMemo(()=>({registerPopover:l,unregisterPopover:d,isFocusWithinPopoverGroup:a,closeOthers:w}),[l,d,a,w]),v=x.useMemo(()=>({}),[]),h=r,b={ref:m};return k.createElement(De,null,k.createElement(Ne.Provider,{value:i},te({ourProps:b,theirProps:h,slot:v,defaultTag:Ht,name:"Popover.Group"})))}let Lt=Z(Et),ie=Z(Mt),zt=Z(ze),Ut=Z(ze),ce=Z(Dt),Wt=Z(Gt),ve=Object.assign(Lt,{Button:ie,Backdrop:Ut,Overlay:zt,Panel:ce,Group:Wt});function At(){const[r,t]=x.useState(!0),[o,m]=x.useState(!1),f=o?"format":"round",u=r?"Δ":"rating";function d(){t(!1)}function l(){t(!0)}function a(){m(!0)}function w(){m(!1)}return e.jsxs("tr",{className:"text-[10pt] font-bold bg-gray",children:[e.jsx("td",{width:"56",className:"py-0.25 pl-[3px]",onMouseOver:a,onMouseOut:w,children:f}),e.jsx("td",{width:"56",className:"py-0.25 pl-[3px]",children:"table"}),e.jsx("td",{width:"416",className:"py-0.25 pl-[3px]",children:"opponent (rating)"}),e.jsx("td",{width:"88",className:"text-center",children:"result"}),e.jsx("td",{width:"68",className:"text-center",onMouseOver:d,onMouseOut:l,children:e.jsx("span",{children:u})})]})}function Kt(r){return e.jsxs("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg left-[-140px] top-[-2px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:["highest rating: ",r]})}function Vt(){return e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg left-[-185px] top-[-10px] w-max max-w-[180px] text-[12px] text-center absolute z-10",children:"this match gave this player their Nakamura number"})}function qt(r){const{match:t,row_idx:o,player_info:m}=r,f=["P","Q","S","F","L"],u=e.jsx("span",{children:t.round}),d=e.jsx("span",{className:"text-[8.5pt]",children:t.format}),l=t.own_elo.end-t.own_elo.start,a=e.jsx("span",{children:`${l>0?"+":""}${Math.round(l)}`}),w=e.jsx("span",{className:"font-bold",children:Math.round(t.own_elo.end)}),i=t.match_id===m.best_id&&t.own_elo.end>1500?"0px 0px 0px 1px #33DD33 inset":t.match_id==m.nakamura_match_id?"0px 0px 0px 1px #cccc33 inset":"",[v,h]=x.useState(!1),[b,p]=x.useState(!1);function s(){h(!0)}function n(){h(!1)}function c(){p(!0)}function g(){p(!1)}return e.jsxs("tr",{className:`text-[10pt] h-[19px] ${o%2===1?"bg-gray":""}`,children:[e.jsx("td",{width:"56",className:"py-0.25 pl-[3px]",onMouseOver:s,onMouseOut:n,children:v?d:u}),e.jsx("td",{width:"56",className:"py-0.25 pl-[3px]",children:f.includes(t.round)?"":t.table}),t.opp_data.opp?e.jsxs("td",{width:"416",className:"py-0.25 pl-[3px]",children:[e.jsx("a",{className:"hover:text-blink hover:underline",href:`/profile/${t.opp_data.id}`,children:t.opp_data.opp})," ",e.jsxs("span",{className:"text-[8pt]",children:["(",Math.round(t.opp_data.start),")"]})]}):e.jsx("td",{width:"416",className:"py-0.25 pl-[3px]",children:"[anonymous]"}),e.jsx("td",{width:"88",className:"text-center",children:t.opp_data.opp?e.jsx("a",{className:"hover:text-blink hover:underline",href:`/headtohead/${m.id}/${t.opp_data.id}`,children:t.result}):e.jsx(e.Fragment,{children:t.result})}),e.jsxs("td",{width:"68",className:"text-center tooltip-base relative",style:{boxShadow:i},onMouseOver:c,onMouseOut:g,children:[t.match_id===m.best_id&&t.own_elo.end>1500&&Kt(t.own_elo.end),!(t.match_id===m.best_id&&t.own_elo.end>1500)&&t.match_id==m.nakamura_match_id&&Vt(),b?w:a]})]})}function Jt(r){const{matches:t,eventInfo:o,player_info:m}=r,f=Math.round(t[0].own_elo.start),u=Math.round(t[t.length-1].own_elo.end),d=Math.round(t.map(v=>v.opp_data.start).reduce((v,h)=>v+h,0)/t.length),l=t.filter(v=>v.result.slice(0,3)=="Won").length,a=t.filter(v=>v.result.slice(0,4)=="Lost").length,w=t.filter(v=>v.result.slice(0,4)=="Draw"||v.result=="ID").length,i=`${l}-${a}`+(w>0?`-${w}`:"");return e.jsxs(e.Fragment,{children:[e.jsx("a",{id:o.code}),e.jsx("table",{width:"710",cellSpacing:"0",className:"border mb-[15px]",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsxs("td",{colSpan:3,className:"text-[15pt] whitespace-nowrap px-0.5 py-0.25",children:[e.jsx("a",{className:"hover:text-blink hover:underline",href:o.site,children:o.name}),e.jsxs("span",{className:"text-[12pt] pl-1",children:["(",o.format,")"]})]}),e.jsxs("td",{colSpan:2,className:"text-[11pt] text-center",children:["starting rating: ",f]})]}),e.jsx(At,{}),t.map((v,h)=>e.jsx(qt,{match:v,player_info:m,row_idx:h},v.match_id)),e.jsxs("tr",{className:`h-[22px] ${t.length%2===1?"bg-gray":""}`,children:[e.jsx("td",{width:"56",className:"text-[10pt] pl-[3px]",children:e.jsx("a",{className:"hover:text-blink hover:underline",href:"#top",children:"top"})}),e.jsx("td",{width:"56"}),e.jsx("td",{children:e.jsxs("span",{className:"flex justify-between items-baseline pl-[3px] pr-5 text-[10pt]",children:[e.jsxs("span",{children:["average opponent: ",d]}),e.jsxs("span",{children:["record: ",i]})]})}),e.jsxs("td",{colSpan:2,className:"text-[11pt] text-center",children:["new rating: ",u]})]})]})})]})}const ne=["pt","worlds","mocs"],Qt=["scg_open","scg_invi","scg_pc","scg_con"],Yt=["gp","mc_open","ss"],J={pt:"Pro Tour",gp:"Grand Prix",national:"Nationals",continental:"Continental",masters:"Masters",scg_open:"SCG Open",scg_invi:"SCG Invitational",worlds:"Worlds",scg_pc:"SCG Players Championship",scg_con:"SCG CON",lms_goq:"LMS Grand Open Qualifier",rc:"Regional Championship",ptq:"MagicCon PTQ",sls:"Secret Lair Showdown",mxp_open:"MXP Open",mc_open:"MagicCon Open",rc_side:"RC Side Event",dest_rcq:"Destinaton RCQ",mocs:"Magic Online Championship",ac:"Arena Championship",mpl:"Magic Pro League",ew:"Eternal Weekend",ss:"Spotlight Series"},be=["block","standard","extended","legacy","modern","pioneer","historic","alchemy","explorer","vintage"],ge=["draft","sealed","rochester"],$e={pro:"Pro Tours, Worlds, and MOCS are professional.",gp:"Grand Prix, MagicCon Opens, and Spotlight Series are GPs.",scg:"SCG Opens, Invis, and SCGCON events are SCG."};function Zt(r,t){return J[r]>J[t]?1:J[r]<J[t]?-1:0}function Ue(r){const{events:t,filter:o,onClose:m,onFilterUpdate:f}=r,[u,d]=x.useState([]);let l=t.map(s=>s.type);l=l.filter((s,n)=>l.indexOf(s)==n).sort(Zt),x.useEffect(()=>{d(o==="all"?l:o)},[]);let a={};a.all=l;const w=l.filter(s=>ne.includes(s)),i=l.filter(s=>Qt.includes(s)),v=l.filter(s=>Yt.includes(s));w.length>0&&(a.pro=w),v.length>0&&(a.gp=v),i.length>0&&(a.scg=i),a.none=[];function h(s){d(a[s])}function b(s){d(n=>n.includes(s)?n.filter(c=>c!==s):[...n,s])}function p(){f(u),m()}return e.jsxs("div",{className:"flex flex-row min-w-max bg-white z-10 p-1 text-[14px]",children:[e.jsxs("div",{className:"flex flex-col px-2 text-center border-r-[1px]",children:[e.jsx("span",{className:"grow-0",children:Object.keys(a).map(s=>e.jsxs("div",{className:`my-0.5 cursor-pointer border border-solid rounded py-0.5 tooltip-base ${u.length===a[s].length&&a[s].filter(n=>u.includes(n)).length===u.length?"bg-slate-200":""}`,onClick:()=>h(s),children:[Object.keys($e).includes(s)&&e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg ml-[-170px] mt-[-10px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:$e[s]}),s]},s))}),e.jsx("span",{className:"grow content-center",children:e.jsx("button",{className:"border border-solid rounded bg-slate-200 py-0.5 px-1",onClick:p,children:"submit"})})]}),e.jsx("div",{className:"flex flex-col flex-wrap px-0.5",children:l.map(s=>e.jsxs(Re,{checked:u.includes(s),onChange:()=>b(s),className:"p-0.5 cursor-pointer",children:[u.includes(s)?"☑":"☐"," ",J[s]]},s))})]})}function Xt(r){const{data:t,events:o,player_info:m}=r,[f,u]=x.useState(o),[d,l]=x.useState("all"),[a,w]=x.useState(!1);function i(b){if(b==="all")u([...o].reverse());else{const p=[...o].reverse().filter(s=>b.includes(s.type));u(p)}}function v(){u(b=>[...b].reverse()),w(b=>!b)}x.useEffect(()=>{i(d)},[o,t]);function h(b){l(b),i(b)}return e.jsx(e.Fragment,{children:t&&o&&e.jsxs(e.Fragment,{children:[Object.keys(t).length>=5&&e.jsxs(ve,{className:"w-full flex flex-row relative justify-end mb-2 overflow-y-visible items-baseline",children:[e.jsx(ie,{className:"min-w-[88px] bg-gray p-[3px] m-[1px] text-[14px] border border-nines rounded-sm cursor-pointer hover:bg-cookie focus:bg-cookie",children:"Filter tournaments"}),e.jsx(ce,{anchor:"bottom end",className:"shadow-bar !overflow-visible",children:({close:b})=>e.jsxs("span",{className:"flex flex-col bg-white",children:[e.jsx(Ue,{events:o,filter:d,onFilterUpdate:h,onClose:b}),e.jsx("span",{className:"text-[10pt] py-1 border-t border-dashed w-full text-center",children:e.jsxs("a",{onClick:v,className:"cursor-pointer",children:[a?"oldest":"newest"," first"]})})]})})]}),e.jsx("div",{className:`${Object.keys(t).length>=5?"":"mt-3"}`,children:f.map(b=>e.jsx(Jt,{matches:t[b.code],eventInfo:b,player_info:m},b.code))})]})})}const se={rc:"bg-[#CCFFDD]",national:"bg-[#CCFFDD]",continental:"bg-[#CCFFDD]",pt:"bg-[#E8E8FF]",scg_invi:"bg-[#FFD4FF]",scg_pc:"bg-[#FFD4FF]",worlds:"bg-[#FFFFDD]",mocs:"bg-[#FFFFDD]",ac:"bg-[#FFFFDD]"};function en(r){const{events:t,wins:o,onClose:m}=r;x.useEffect(()=>{function l(a){a.target.id==="tournament-dropdown-button"||(a.target.id=="tournament-link"?(window.location=a.target.href,m()):a.target.id!=="year"&&a.target.id!=="tournament-link"&&m())}return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[]);let f=t.map(l=>l.date.split("-")[0]);f=f.filter((l,a)=>f.indexOf(l)==a);const u=e.jsx("div",{className:"dropdown-content",children:e.jsx("ul",{className:"tournament-list",children:t.map(l=>e.jsxs("a",{className:`dropdown-tournament ${se[l.type]?se[l.type]:""}`,id:"tournament-link",href:`#${l.code}`,children:[l.name,o.includes(l.code)?" 🏆":""]},l.code))})}),d=e.jsx("div",{className:"dropdown-content",children:e.jsx("ul",{className:"year-list",children:f.map(l=>e.jsxs("li",{className:"dropdown-year",id:"year",children:[l,e.jsx("ul",{className:"year-events",children:t.map(a=>{if(a.date.split("-")[0]===l)return e.jsxs("a",{className:`dropdown-tournament ${se[a.type]?se[a.type]:""}`,id:"tournament-link",href:`#${a.code}`,children:[a.name,o.includes(a.code)?" 🏆":""]},a.code)})})]},l))})});return e.jsx(e.Fragment,{children:t.length>=20?d:u})}function tn(r){const{matches:t,filter:o,onClose:m,onFilterUpdate:f}=r,[u,d]=x.useState([]);let l=Object.keys(t).map(p=>t[p]).flat().map(p=>p.format);l=l.filter((p,s)=>l.indexOf(p)==s).sort(),x.useEffect(()=>{d(o==="all"?l:o)},[]);let a={};a.all=l;const w=l.filter(p=>be.includes(p)),i=l.filter(p=>ge.includes(p));w.length>0&&(a.constructed=w),i.length>0&&(a.limited=i),a.none=[];function v(p){d(a[p])}function h(p){d(s=>s.includes(p)?s.filter(n=>n!==p):[...s,p])}function b(){f(u),m()}return e.jsxs("div",{className:"flex flex-row min-w-max bg-white z-10 p-1 text-[14px]",children:[e.jsxs("div",{className:"flex flex-col px-2 text-center border-r-[1px]",children:[e.jsx("span",{className:"grow-0",children:Object.keys(a).map(p=>e.jsx("div",{className:`my-0.5 border border-solid rounded p-0.5 cursor-pointer ${u.length===a[p].length&&a[p].filter(s=>u.includes(s)).length===u.length?"bg-slate-200":""}`,onClick:()=>v(p),children:p},p))}),e.jsx("span",{className:"grow content-center",children:e.jsx("button",{className:"border border-solid rounded bg-slate-200 py-0.5 px-1",onClick:b,children:"submit"})})]}),e.jsx("div",{className:"flex flex-col flex-wrap px-0.5",children:l.map(p=>e.jsxs(Re,{checked:u.includes(p),onChange:()=>h(p),className:"p-0.5 cursor-pointer",children:[u.includes(p)?"☑":"☐"," ",p]},p))})]})}function V(r,t,o){return`${r}-${t}`+(o>0?`-${o}`:"")}function Se(r){return r?isNaN(parseInt(r))?r:`R${r}`:""}function nn(r){const{data:t}=r;let o={},m={};for(let s of t.events){const n=s.type;Object.keys(m).includes(n)||(m[n]=[0,0,0]);for(let c of t.matches[s.code]){Object.keys(o).includes(c.format)||(o[c.format]=[0,0,0]);const g=c.result.split(" ")[0];g==="Won"?(o[c.format][0]++,m[n][0]++):g==="Lost"?(o[c.format][1]++,m[n][1]++):g==="Draw"&&(o[c.format][2]++,m[n][2]++)}}let f=[0,0,0],u=[0,0,0],d=[0,0,0],l=[0,0,0];for(let s of ge)Object.keys(o).includes(s)&&(f[0]=f[0]+o[s][0],f[1]=f[1]+o[s][1],f[2]=f[2]+o[s][2]);for(let s of be)Object.keys(o).includes(s)&&(u[0]=u[0]+o[s][0],u[1]=u[1]+o[s][1],u[2]=u[2]+o[s][2]);for(let s of ne)Object.keys(m).includes(s)&&(d[0]=d[0]+m[s][0],d[1]=d[1]+m[s][1],d[2]=d[2]+m[s][2]);for(let s of Object.keys(J).filter(n=>!ne.includes(n)))Object.keys(m).includes(s)&&(l[0]=l[0]+m[s][0],l[1]=l[1]+m[s][1],l[2]=l[2]+m[s][2]);const a=Object.keys(o).filter(s=>ge.includes(s)).map(s=>e.jsxs(k.Fragment,{children:[e.jsx("div",{children:s}),e.jsx("div",{className:"text-center",children:V(...o[s])}),e.jsxs("div",{children:[(100*o[s][0]/(o[s][0]+o[s][1])).toFixed(2),"%"]})]},s)),w=Object.keys(o).filter(s=>be.includes(s)).map(s=>e.jsxs(k.Fragment,{children:[e.jsx("div",{children:s}),e.jsx("div",{className:"text-center",children:V(...o[s])}),e.jsxs("div",{children:[(100*o[s][0]/(o[s][0]+o[s][1])).toFixed(2),"%"]})]},s)),i=Object.keys(m).filter(s=>ne.includes(s)).map(s=>e.jsxs(k.Fragment,{children:[e.jsx("div",{children:J[s]}),e.jsx("div",{className:"text-center",children:V(...m[s])}),e.jsxs("div",{children:[(100*m[s][0]/(m[s][0]+m[s][1])).toFixed(2),"%"]})]},s)),v=Object.keys(m).filter(s=>!ne.includes(s)).map(s=>e.jsxs(k.Fragment,{children:[e.jsx("div",{children:J[s]}),e.jsx("div",{className:"text-center",children:V(...m[s])}),e.jsxs("div",{children:[(100*m[s][0]/(m[s][0]+m[s][1])).toFixed(2),"%"]})]},s)),h=t.info.best_event?Math.max(...t.matches[t.info.best_event].map(s=>s.own_elo.end)):1500,b=Object.keys(t.matches).find(s=>t.info.nakamura_match_id&&t.matches[s].map(n=>n.match_id).includes(t.info.nakamura_match_id)),p=b&&t.matches[b].find(s=>s.match_id==t.info.nakamura_match_id)?.round;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border border-solid flex flex-row items-start mx-auto min-w-[72%] max-w-[72%] text-[12px] justify-center",children:[e.jsxs("div",{className:"grid grid-cols-[auto_auto_1fr] border-r pl-0.5 pr-3 py-1 gap-x-2 gap-y-0 items-baseline my-auto",children:[f[0]+f[1]+f[2]>0&&e.jsxs(e.Fragment,{children:[a,e.jsx("div",{className:"font-bold py-1 pb-2",children:"all limited"}),e.jsx("div",{className:"text-center py-1 pb-2",children:V(...f)}),e.jsxs("div",{className:"py-1 pb-2",children:[(100*f[0]/(f[0]+f[1])).toFixed(2),"%"]})]}),u[0]+u[1]+u[2]>0&&e.jsxs(e.Fragment,{children:[w,e.jsx("div",{className:"font-bold pt-1",children:"all constructed"}),e.jsx("div",{className:"text-center pt-1",children:V(...u)}),e.jsxs("div",{className:"pt-1",children:[(100*u[0]/(u[0]+u[1])).toFixed(2),"%"]})]})]}),e.jsxs("div",{className:"grid grid-cols-[auto_auto_1fr] border-l pr-0.5 pl-3 py-1 gap-x-2 gap-y-0 items-baseline my-auto -ml-[1px]",children:[d[0]+d[1]+d[2]>0&&e.jsxs(e.Fragment,{children:[i,e.jsx("div",{className:"font-bold py-1 pb-2",children:"professional"}),e.jsx("div",{className:"text-center py-1 pb-2",children:V(...d)}),e.jsxs("div",{className:"py-1 pb-2",children:[(100*d[0]/(d[0]+d[1])).toFixed(2),"%"]})]}),l[0]+l[1]+l[2]>0&&e.jsxs(e.Fragment,{children:[v,e.jsx("div",{className:"font-bold pt-1",children:"others"}),e.jsx("div",{className:"text-center pt-1",children:V(...l)}),e.jsxs("div",{className:"pt-1",children:[(100*l[0]/(l[0]+l[1])).toFixed(2),"%"]})]})]})]}),e.jsx("div",{className:"border-b border-l border-r border-solid flex flex-row items-start mx-auto min-w-[72%] max-w-[72%] text-[12px] mb-3 justify-center",children:e.jsxs("div",{className:"p-1 grid grid-cols-[auto_2fr_auto] gap-x-4 my-auto",children:[h>1500&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Highest rating"}),e.jsx("div",{children:Math.round(h)}),e.jsxs("div",{children:["attained at"," ",e.jsxs("a",{className:"text-blink hover:underline",href:`#${t.info.best_event}`,children:[t.info.best_event," ",Se(t.info.best_round)]})]})]}),t.info.nakamura_number!==null&&t.info.nakamura_number>=0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsxs("span",{className:"tooltip-base",children:["Nakamura number",e.jsx("sup",{children:" ?"}),e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg ml-[-140px] mt-[-55px] w-max max-w-[180px] text-[12px] text-center absolute z-10",children:"length of the minimal chain of opponents needed to reach Shuhei Nakamura"})]})}),e.jsx("div",{className:"text-center",children:t.info.nakamura_number}),t.info.nakamura_number>0&&e.jsxs("div",{children:["first obtained at"," ",e.jsxs("a",{href:`#${b}`,className:"text-blink hover:underline",children:[b," ",Se(p)]})]}),t.info.last_name=="Nakamura"&&t.info.first_name=="Shuhei"&&e.jsx("div",{children:"(is Shuhei)"})]})]})})]})}function sn(r){return{year:r,n_events:0,wins:0,losses:0,draws:0,cuts_made:0,cut_events:0,top_8s:[],event_wins:[]}}const rn=r=>{const{data:t}=r,[o,m]=x.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-[72%] max-w-max mx-auto mt-3",children:[e.jsx("span",{onClick:()=>m(!0),className:`text-[11pt] cursor-pointer border-x border-t border-solid rounded-t border-collapse px-1 pt-0.5 pb-[1px] ${o?"bg-gray":""}`,children:"player card"})," ",e.jsx("span",{onClick:()=>m(!1),className:`text-[11pt] cursor-pointer border-x border-t border-solid rounded-t border-collapse px-1 pt-0.5 pb-[1px] ${o?"":"bg-gray"}`,children:"summary"})]}),o&&e.jsx(ln,{data:t}),!o&&e.jsx(nn,{data:t})]})},ln=r=>{const{data:t}=r,o=new Set(t.events.map(i=>i.type)).size,m=new Set(Object.keys(t.matches).map(i=>t.matches[i].map(v=>v.format)).flat()).size,[f,u]=x.useState("all"),[d,l]=x.useState("all");function a(i){u(i)}function w(i){l(i)}return e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_auto_1fr_1fr_1fr_1fr_1fr_1fr] min-w-[72%] mx-auto mb-3 text-[9pt] max-w-max border border-black border-solid text-center",children:[e.jsxs("div",{className:"col-span-9 text-[11pt] pb-1 text-right p-0.5",children:["filter stats by",e.jsxs(ve,{className:"relative inline justify-end mb-2 overflow-y-visible",children:[e.jsx(ie,{className:`px-1 ${f!="all"&&f.length!=o?"text-ruby":""}`,children:"tournaments ▽"}),e.jsx(ce,{anchor:"bottom end",className:"shadow-bar !overflow-visible",children:({close:i})=>e.jsx(Ue,{events:t.events,filter:f,onFilterUpdate:a,onClose:i})})]}),e.jsxs(ve,{className:"relative inline justify-end mb-2 overflow-y-visible",children:[e.jsx(ie,{className:`px-1 ${d!="all"&&d.length!=m?"text-ruby":""}`,children:"formats ▽"}),e.jsx(ce,{anchor:"bottom end",className:"shadow-bar",children:({close:i})=>e.jsx(tn,{matches:t.matches,filter:d,onFilterUpdate:w,onClose:i})})]})]}),e.jsx("div",{className:"font-bold bg-gray",children:"year"}),e.jsx("div",{className:"font-bold bg-gray",children:"events"}),e.jsx("div",{className:"font-bold bg-gray",children:"record"}),e.jsxs("div",{className:"tooltip-base font-bold bg-gray text-blink",children:["win%",e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg ml-[10px] mt-[-5px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:"ignores draws and IDs."})]}),e.jsxs("div",{className:"tooltip-base font-bold bg-gray text-blink",children:["day 2s",e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg ml-[10px] mt-[-5px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:"counts events with a match past the cut. if the player made day 2 and dropped between days, this is missed."})]}),e.jsx("div",{className:"font-bold bg-gray",children:"top 8s"}),e.jsx("div",{className:"font-bold bg-gray",children:"wins"}),e.jsxs("div",{className:"tooltip-base font-bold bg-gray text-blink",children:["avg elo",e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg ml-[10px] mt-[-5px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:"currently there is no filter-specific rating, so to avoid giving the wrong idea these columns are hidden when matches are filtered out."})]}),e.jsxs("div",{className:"tooltip-base font-bold bg-gray text-blink",children:["max elo",e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg ml-[10px] mt-[-5px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:"currently there is no filter-specific rating, so to avoid giving the wrong idea these columns are hidden when matches are filtered out."})]}),e.jsx(an,{data:t,filterEvents:f,filterFormats:d})]})},an=r=>{const{data:t,filterEvents:o,filterFormats:m}=r,f=t.events.filter(n=>o==="all"||o.includes(n.type));let u={},d={},l=[],a=[],w=[],i=[];for(let n of f){const c=t.matches[n.code].filter(g=>g.result!=="ID"&&(m=="all"||m.includes(g.format)));if(c.length>0){u[n.code]=c;const g=parseInt(n.date.split("-")[0]),$=c[c.length-1];let S=t.matches[n.code].map(E=>E.round);g in d?d[g].push(n.code):d[g]=[n.code],n.cut_before&&(l.push(n.code),n.code==="2019MC3"?S.includes("U1")&&a.push("2019MC3"):Math.max(...S.filter(E=>!!+E).map(E=>+E))>+n.cut_before&&a.push(n.code)),(S.includes("P")||S.includes("Q")||S.includes("S")||S.includes("U1")||S.includes("L1"))&&w.push(n.code),$.round==="F"&&$.result.slice(0,3)==="Won"&&i.push(n.code)}}let v=t.events.map(n=>parseInt(n.date.split("-")[0]));v=v.filter((n,c)=>v.indexOf(n)===c);let h=[];for(let n of v)if(n in d){const c=d[n].length;let g=0,$=0,S=0;for(let F of d[n])for(let T of u[F]){const I=T.result.split(" ")[0];I==="Won"?g++:I==="Lost"?$++:I==="Draw"&&S++}const E=l.filter(F=>d[n].includes(F)).length,C=a.filter(F=>d[n].includes(F)).length,R=w.filter(F=>d[n].includes(F)),B=i.filter(F=>d[n].includes(F)),M=Object.keys(u).filter(F=>d[n].includes(F)).map(F=>u[F]).flat().map(F=>F.own_elo.end);let H,G;Object.keys(u).length==t.events.length&&(H=M.reduce((F,T)=>F+T)/M.length,G=Math.round(Math.max(...M))),h.push({year:n,n_events:c,wins:g,losses:$,draws:S,cuts_made:C,cut_events:E,top_8s:R,event_wins:B,avg_elo:H,peak_elo:G})}else h.push(sn(n));const b=Object.keys(u).map(n=>u[n]).flat().map(n=>n.own_elo.end),p={year:0,n_events:h.map(n=>n.n_events).reduce((n,c)=>n+c),wins:h.map(n=>n.wins).reduce((n,c)=>n+c),losses:h.map(n=>n.losses).reduce((n,c)=>n+c),draws:h.map(n=>n.draws).reduce((n,c)=>n+c),cuts_made:h.map(n=>n.cuts_made).reduce((n,c)=>n+c),cut_events:h.map(n=>n.cut_events).reduce((n,c)=>n+c),top_8s:h.map(n=>n.top_8s).reduce((n,c)=>n.concat(c)),event_wins:h.map(n=>n.event_wins).reduce((n,c)=>n.concat(c)),avg_elo:Object.keys(u).length==t.events.length?b.reduce((n,c)=>n+c)/b.length:0,peak_elo:Math.max(...h.map(n=>n.peak_elo?n.peak_elo:0))},s=100*p.wins/(p.wins+p.losses);return e.jsxs(e.Fragment,{children:[h.map((n,c)=>{const g=n.wins+n.losses+n.draws,$=100*n.wins/(n.wins+n.losses),S=e.jsxs(e.Fragment,{children:[n.top_8s.length,e.jsx("span",{className:"tooltip-text bg-black text-white p-1 rounded-lg ml-[10px] mt-[-5px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:n.top_8s.map(C=>e.jsx("span",{className:"block",children:C},C))})]}),E=e.jsxs(e.Fragment,{children:[n.event_wins.length,e.jsx("span",{className:"tooltip-text bg-black text-white p-1 rounded-lg ml-[10px] mt-[-5px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:n.event_wins.map(C=>e.jsx("span",{className:"block",children:C},C))})]});return e.jsxs(k.Fragment,{children:[e.jsx("div",{className:c%2==1?"bg-gray":"",children:n.year}),e.jsx("div",{className:`${c%2==1?"bg-gray":""} ${n.n_events===0?"text-fade":""}`,children:n.n_events}),e.jsx("div",{className:`${c%2==1?"bg-gray":""} ${g===0?"text-fade":""}`,children:`${n.wins}-${n.losses}`+(n.draws>0?`-${n.draws}`:"")}),e.jsx("div",{className:c%2==1?"bg-gray":"",children:g>0?`${$.toFixed(2)}%`:""}),e.jsx("div",{className:c%2==1?"bg-gray":"",children:n.cut_events>0?`${n.cuts_made} / ${n.cut_events}`:""}),e.jsx("div",{className:`relative tooltip-base text-blink ${c%2==1?"bg-gray":""}`,children:n.top_8s.length>0?S:""}),e.jsx("div",{className:`relative tooltip-base text-blink ${c%2==1?"bg-gray":""}`,children:n.event_wins.length>0?E:""}),e.jsx("div",{className:c%2==1?"bg-gray":"",children:n.avg_elo?Math.round(n.avg_elo):"—"}),e.jsx("div",{className:c%2==1?"bg-gray":"",children:n.peak_elo?Math.round(n.peak_elo):"—"})]},n.year)}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:"totals"}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:p.n_events}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:`${p.wins}-${p.losses}`+(p.draws>0?`-${p.draws}`:"")}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:`${s.toFixed(2)}%`}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:`${p.cuts_made} / ${p.cut_events}`}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:p.top_8s.length}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:p.event_wins.length}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:p.avg_elo?Math.round(p.avg_elo):"—"}),e.jsx("div",{className:`font-bold py-0.5 ${h.length%2==1?"bg-gray":""}`,children:p.peak_elo?Math.round(p.peak_elo):"—"})]})};function fe(r){const{clickHandler:t,button_text:o,id:m}=r;return e.jsx("button",{className:"min-w-[88px] bg-gray p-[3px] m-[1px] text-[14px] border border-nines rounded-sm cursor-pointer hover:bg-cookie focus:bg-cookie",onClick:t,id:m,children:o})}const on=_t.CanvasJSChart;function cn(r){const{data:t}=r,[o,m]=x.useState(!1),[f,u]=x.useState(!1),[d,l]=x.useState(!1),[a,w]=x.useState();x.useEffect(()=>{t&&w({animationEnabled:!0,exportEnabled:!0,zoomEnabled:!0,axisX:{},axisY:{valueFormatString:"####"},data:[{yValueFormatString:"####",type:"spline",dataPoints:[{label:"start",y:1500},...Object.keys(t.matches).map(c=>{const g=t.matches[c][t.matches[c].length-1].own_elo.end;return{label:c,y:g}})]}]})},[t]);function i(){u(!1),m(c=>!c)}function v(){m(!1),u(c=>!c)}function h(){l(c=>!c)}function b(){l(!1)}const p=t.events.filter(c=>{const g=t.matches[c.code].slice(-1)[0];return g.round==="F"&&g.result.includes("Won")}).map(c=>c.code),s=(c,g,$)=>`${c}-${g}`+($>0?`-${$}`:""),n=(c,g,$)=>{if(c+g+$===0)return e.jsx(e.Fragment,{});const S=`${c}-${g}`+($>0?`-${$}`:"")+" ";return e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"text-[14pt]",children:"(all)"})," / ",S,e.jsxs("span",{className:"text-[14pt] tooltip-base",children:["(professional)",e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg ml-[10px] mt-[-5px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:"Pro Tours, Worlds, and MOCS are professional."})]})]})};return e.jsxs(e.Fragment,{children:[e.jsx("a",{id:"top"}),e.jsxs("div",{className:"flex flex-row items-end",children:[e.jsxs("div",{className:"flex flex-col grow leading-[1.2]",children:[e.jsxs("div",{className:"text-[22pt]",children:[t.info.last_name,t.info.first_name&&`, ${t.info.first_name}`]}),e.jsxs("div",{className:"text-[18pt]",children:["Current rating:"," ",e.jsxs("span",{className:"font-bold",children:[Math.round(t.info.current_rating)," "]}),t.info.current_rating>=1700&&e.jsxs("span",{className:"text-[14pt]",children:["(#",t.info.ranking+1,t.info.active_ranking==0||t.info.active_ranking?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"px-[5px]",children:"/"}),e.jsxs("span",{className:"tooltip-base",children:[`active #${t.info.active_ranking+1}`,e.jsx("span",{className:"tooltip-text font-normal bg-black text-white p-1 rounded-lg ml-[10px] mt-[-5px] w-max max-w-[150px] text-[12px] text-center absolute z-10",children:"active players have appeared since 7/1/19."})]})]}):null,")"]})]}),e.jsxs("div",{className:"text-[18pt]",children:["Record:"," ",s(t.info.record[0],t.info.record[1],t.info.record[2]),n(t.info.pro_record[0],t.info.pro_record[1],t.info.pro_record[2])]})]}),e.jsxs("div",{className:"flex flex-col grow-0 items-end justify-around",children:[t.events.length>=5&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(fe,{clickHandler:v,button_text:"Player card"})}),e.jsx("div",{children:e.jsx(fe,{clickHandler:i,button_text:o?"Hide graph":"Show graph"})})]}),t.events.length>=3&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"relative",children:[e.jsx(fe,{clickHandler:h,button_text:"Select tournament",id:"tournament-dropdown-button"}),d&&e.jsx(en,{events:t.events,wins:p,onClose:b})]})})]})]}),e.jsx("div",{children:f&&e.jsx(rn,{data:t})}),o&&a?e.jsx("div",{className:"w-full py-12",children:e.jsx(on,{options:a})}):null]})}const fn=r=>{const{playerid:t,info:o}=r,[m,f]=x.useState([]),[u,d]=x.useState({});return x.useEffect(()=>{const l=async w=>{const i=await fetch(`https://mtgeloproject.net/api/players/${w}/events`).then(v=>v.json());if(i.error)return console.log(i.error),null;f(i.data.sort((v,h)=>v.date.localeCompare(h.date)))},a=async w=>{const i=await fetch(`https://mtgeloproject.net/api/players/${w}/matches`).then(v=>v.json());if(i.error)return console.log(i.error),null;d(i)};l(t),a(t)},[]),e.jsx(e.Fragment,{children:m&&m.length&&u&&Object.keys(u).length&&o?e.jsxs(e.Fragment,{children:[e.jsx(cn,{data:{events:m,matches:u,info:o}}),e.jsx(Xt,{events:m,data:u,player_info:o})]}):e.jsx("p",{children:"Loading..."})})};export{fn as default};