1"use strict";(globalThis.webpackChunkion_golf_ranking=globalThis.webpackChunkion_golf_ranking||[]).push([[77,658],{77(e,t,n){n.r(t),n.d(t,{default:()=>ae});var o=n(9950),r=n(5840),a=n(8392),i=n(6673),s=n(4279),l=n(2772),d=n(6506),c=n(4414);const h=["JUNIOR_BOYS","JUNIOR_GIRLS"];function u(e){let{selectedCategory:t,setSelectedCategory:n}=e;return(0,c.jsx)("div",{style:{display:"flex",marginBottom:8},children:null===h||void 0===h?void 0:h.map(e=>{let o={color:"black",backgroundColor:"transparent",border:"1px solid transparent"};return e===t&&(o={color:"#1b6dff",backgroundColor:"#e3edff",border:"1px solid #e3edff"}),(0,c.jsx)("div",{style:{margin:2,padding:6,paddingLeft:10,paddingRight:10,borderRadius:15,fontSize:11,fontWeight:"500",cursor:"pointer",...o},onClick:()=>n(e),children:e},e)})})}const x=e=>{let{onSearch:t}=e;const[n,a]=(0,o.useState)("");return(0,c.jsx)(r.S1,{value:n,onIonInput:e=>{console.log(e);const n=e.target.value;a(n),t(n)},placeholder:"Search tournaments...",className:"tournament-search",debounce:300})};var g=n(9246),m=n(8307);const p=e=>e?e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):"",j=e=>{var t,n,i;let{isOpen:s,onClose:l,onApply:d,initialFilters:h,selectedCategory:u,removeTours:x}=e;const[j,f]=(0,o.useState)([]),[v,y]=(0,o.useState)(""),[b,C]=(0,o.useState)({tour:(null===h||void 0===h?void 0:h.tour)||"",dateRange:{start:null,end:null},ageRange:{min:(null===h||void 0===h||null===(t=h.ageRange)||void 0===t?void 0:t.min)||9,max:(null===h||void 0===h||null===(n=h.ageRange)||void 0===n?void 0:n.max)||18}}),[S,k]=(0,o.useState)(!1),[w,A]=(0,o.useState)(!1),[T,_]=(0,o.useState)(!1),N=(0,o.useCallback)(async()=>{try{const{data:e}=await g.A.get("/plus-tournaments/tours",{params:{category:u}});console.log("Fetched tours:",e);const t=e.sort((e,t)=>e.tour_name.localeCompare(t.tour_name));f(t)}catch(e){console.error("Error fetching tours:",e)}},[u]);(0,o.useEffect)(()=>{N()},[u,N]),(0,o.useEffect)(()=>{var e,t,n,o;C({tour:(null===h||void 0===h?void 0:h.tour)||"",dateRange:{start:(null===h||void 0===h||null===(e=h.dateRange)||void 0===e?void 0:e.start)||null,end:(null===h||void 0===h||null===(t=h.dateRange)||void 0===t?void 0:t.end)||null},ageRange:{min:(null===h||void 0===h||null===(n=h.ageRange)||void 0===n?void 0:n.min)||9,max:(null===h||void 0===h||null===(o=h.ageRange)||void 0===o?void 0:o.max)||18}})},[h]);const I=e=>e?(0,m.GP)(new Date(e),"MMM dd, yyyy"):"",R=j.filter(e=>{if(!e||!e.tour_name)return!1;if(!v)return!0;const t=v.toLowerCase();return e.tour_name.toLowerCase().includes(t)||e.tour.toLowerCase().includes(t)});return(0,c.jsxs)(r.Sb,{isOpen:s,onDidDismiss:l,className:"filter-modal",children:[(0,c.jsx)(r.eU,{children:(0,c.jsxs)(r.ai,{children:[(0,c.jsx)(r.BC,{children:"Filter Tournaments"}),(0,c.jsx)(r.QW,{slot:"end",children:(0,c.jsx)(r.Jm,{onClick:l,children:(0,c.jsx)(r.iq,{icon:a.xfX,slot:"icon-only"})})})]})}),(0,c.jsxs)(r.W9,{children:[!x&&(0,c.jsxs)("div",{className:"filter-section",children:[(0,c.jsx)("div",{className:"filter-section-title",children:"Tour"}),(0,c.jsx)("div",{style:{padding:"0 16px"},children:(0,c.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[(0,c.jsx)(r.$w,{readonly:!0,placeholder:"Select Tour",value:p(null===(i=j.find(e=>(null===e||void 0===e?void 0:e.tour)===b.tour))||void 0===i?void 0:i.tour_name)||"",className:"date-input",onClick:()=>_(!0)}),b.tour&&(0,c.jsx)(r.Jm,{fill:"clear",size:"small",onClick:e=>{e.stopPropagation(),C(e=>({...e,tour:""}))},children:"Clear"})]})})]}),(0,c.jsxs)("div",{className:"filter-section",children:[(0,c.jsx)("div",{className:"filter-section-title",children:"When"}),(0,c.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flex:1},children:[(0,c.jsx)(r.$w,{readonly:!0,placeholder:"Start Date",value:I(b.dateRange.start),onClick:()=>k(!0),className:"date-input"}),(0,c.jsx)("span",{children:"to"}),(0,c.jsx)(r.$w,{readonly:!0,placeholder:"End Date",value:I(b.dateRange.end),onClick:()=>A(!0),className:"date-input"}),(0,c.jsx)(r.Jm,{fill:"clear",size:"small",onClick:()=>{C(e=>({...e,dateRange:{start:null,end:null}}))},children:"All"})]})]}),(0,c.jsxs)("div",{className:"filter-section",children:[(0,c.jsx)("div",{className:"filter-section-title",children:"Age Range"}),(0,c.jsx)("div",{style:{padding:"0 16px"},children:(0,c.jsxs)("div",{className:"age-range-inputs",children:[(0,c.jsx)(r.$w,{type:"number",placeholder:"Min Age",value:b.ageRange.min,min:9,max:18,className:"date-input",onIonChange:e=>{const t=parseInt(e.detail.value);t>=9&&t<=18&&C(e=>({...e,ageRange:{...e.ageRange,min:t}}))}}),(0,c.jsx)("span",{style:{padding:"0 8px"},children:"to"}),(0,c.jsx)(r.$w,{type:"number",placeholder:"Max Age",value:b.ageRange.max,min:9,max:18,className:"date-input",onIonChange:e=>{const t=parseInt(e.detail.value);t>=9&&t<=18&&C(e=>({...e,ageRange:{...e.ageRange,max:t}}))}})]})})]}),(0,c.jsx)(r.Sb,{isOpen:S,onDidDismiss:()=>
1k(!1),breakpoints:[0,.5],initialBreakpoint:.5,children:(0,c.jsx)(r.W9,{children:(0,c.jsx)(r.A9,{presentation:"date",max:(new Date).toISOString(),value:b.dateRange.start,onIonChange:e=>{C(t=>({...t,dateRange:{...t.dateRange,start:e.detail.value}})),k(!1)}})})}),(0,c.jsx)(r.Sb,{isOpen:w,onDidDismiss:()=>A(!1),breakpoints:[0,.5],initialBreakpoint:.5,children:(0,c.jsx)(r.W9,{children:(0,c.jsx)(r.A9,{presentation:"date",max:(new Date).toISOString(),min:b.dateRange.start,value:b.dateRange.end,onIonChange:e=>{C(t=>({...t,dateRange:{...t.dateRange,end:e.detail.value}})),A(!1)}})})}),(0,c.jsxs)(r.Sb,{isOpen:T,onDidDismiss:()=>_(!1),children:[(0,c.jsx)(r.eU,{children:(0,c.jsxs)(r.ai,{children:[(0,c.jsx)(r.BC,{children:"Select Tour"}),(0,c.jsx)(r.QW,{slot:"end",children:(0,c.jsx)(r.Jm,{onClick:()=>_(!1),children:"Close"})})]})}),(0,c.jsxs)(r.W9,{children:[(0,c.jsx)(r.S1,{value:v,onInput:e=>{console.log("Search value:",e.target.value),y(e.target.value||"")},placeholder:"Search tours...",debounce:300}),(0,c.jsx)(r.nf,{children:R.map(e=>{var t;return(0,c.jsx)(r.uz,{button:!0,onClick:()=>{C(t=>({...t,tour:(null===e||void 0===e?void 0:e.tour)||""})),_(!1)},children:(0,c.jsxs)(r.he,{children:[p(null===e||void 0===e?void 0:e.tour_name)||"Unknown Tour"," (",null===e||void 0===e||null===(t=e.tour)||void 0===t?void 0:t.toUpperCase(),")"]})},(null===e||void 0===e?void 0:e.tour)||Math.random())})})]})]}),(0,c.jsxs)("div",{className:"footer",children:[(0,c.jsx)(r.Jm,{fill:"clear",className:"clear-btn",onClick:()=>{const e={tour:"",dateRange:{start:null,end:null},ageRange:{min:9,max:18}};C(e),d(e),l()},children:"Clear all"}),(0,c.jsx)(r.Jm,{className:"apply-btn",onClick:()=>{d(b),l()},children:"Apply Filters"})]})]})]})},f=e=>e?e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):"",v=e=>{let{activeFilters:t,onRemove:n,tours:o,removeTours:i}=e;const s=[];if(t.tour&&!i){const e=o.find(e=>e.tour===t.tour);let n=e?e.tour_name:t.tour;n=f(n),s.push({id:"tour",label:`Tour: ${n}`})}if(t.dateRange.start||t.dateRange.end){const e=e=>e?(0,m.GP)(new Date(e),"MMM dd, yyyy"):"Any",n=`Date: ${e(t.dateRange.start)} - ${e(t.dateRange.end)}`;s.push({id:"dateRange",label:n})}return!t.ageRange||9===t.ageRange.min&&18===t.ageRange.max||s.push({id:"ageRange",label:`Age: ${t.ageRange.min}-${t.ageRange.max}`}),0===s.length?null:(0,c.jsx)("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",marginTop:"8px"},children:s.map(e=>(0,c.jsxs)(r.ZB,{onClick:()=>n(e.id),children:[(0,c.jsx)(r.he,{children:e.label}),(0,c.jsx)(r.iq,{icon:a.P0k})]},e.id))})};var y=n(8949),b=n(1644);const C={filterContainer:{display:"flex",alignItems:"center",gap:"12px"}},S=e=>{let{removeHeader:t=!1,removeTours:n=!1,activeTour:s}=e;const[l,d]=(0,o.useState)([]),[h,m]=(0,o.useState)(!0),[p,f]=(0,o.useState)(null),[S,k]=(0,o.useState)(1),[w,A]=(0,o.useState)(!0),[T,_]=(0,o.useState)("JUNIOR_BOYS"),N=Array.from({length:10},(e,t)=>t+9),[I]=(0,o.useState)(N),[R,D]=(0,o.useState)([]),[z,L]=(0,o.useState)(""),W=(0,i.W6)(),{userData:O}=(0,o.useContext)(y.c),[B,F]=(0,o.useState)(!1),[M,E]=(0,o.useState)(()=>{const e=localStorage.getItem("tournamentFilters");return e?JSON.parse(e):{tour:(null===s||void 0===s?void 0:s.tour)||"",dateRange:{start:null,end:null}}}),[U,$]=(0,o.useState)([]);(0,o.useEffect)(()=>{E({tour:(null===s||void 0===s?void 0:s.tour)||"",dateRange:{start:null,end:null}})},[s]);const H=(0,o.useCallback)(async e=>{try{var t,n;const{data:o}=await g.A.get("/plus-tournaments/list",{params:{category:T,page:e,tournament_name:z,tour:M.tour,start_date:M.dateRange.start,end_date:M.dateRange.end,min_age:(null===(t=M.ageRange)||void 0===t?void 0:t.min)||void 0,max_age:(null===(n=M.ageRange)||void 0===n?void 0:n.max)||void 0}});return Array.isArray(o.tournaments)&&0!==o.tournaments.length?o.tournaments:(A(!1),[])}catch(p){var o,r;return console.error("Error fetching tournaments:",p),f((null===(o=p.response)||void 0===o||null===(r=o.data)||void 0===r?void 0:r.message)||"Failed to fetch tournaments"),[]}},[T,z,M]);(0,o.useEffect)(()=>{if(!l)return;const e=l.filter(e=>{if(0===I.length)return!0;const t=e.min_age||9,n=e.max_age||18;return I.some(e=>e>=t&&e<=n)});D(e)}
1,[l,I]),(0,o.useEffect)(()=>{console.log(z),k(1),A(!0);(async()=>{m(!0),d([]);const e=await H(1);d(e),m(!1)})()},[z,T,M,H]),(0,o.useEffect)(()=>{(async()=>{try{const{data:e}=await g.A.get("/plus-tournaments/tours",{params:{category:T}});$(e)}catch(p){console.error("Error fetching tours:",p)}})()},[T,O]);const G=async e=>{const t=S+1,n=await H(t);n.length>0?(d(e=>[...e,...n]),k(t)):A(!1),e.target.complete()},J=e=>e?e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):"",P=e=>e.toUpperCase(),q=e=>{W.push(`${window.location.pathname}/${e}?category=${T}`)},Y=e=>e.min_age||e.max_age?e.min_age&&e.max_age?`Ages ${e.min_age}-${e.max_age}`:e.min_age?`Ages ${e.min_age}+`:e.max_age?`Under ${e.max_age}`:"":"";return(0,c.jsxs)(c.Fragment,{children:[t?null:(0,c.jsx)(r.eU,{children:(0,c.jsxs)(r.ai,{color:"white",children:[(0,c.jsx)(r.QW,{slot:"start",children:(0,c.jsx)(r.MC,{color:"dark",style:{color:"black"}})}),(0,c.jsx)(r.BC,{children:"Tours Tools"})]})}),(0,c.jsxs)(r.W9,{children:[(0,c.jsxs)("div",{className:"tournaments-container",children:[(0,c.jsxs)("div",{className:"tournaments-header",children:[(0,c.jsx)("h1",{className:"tournaments-title",children:(e=>{switch(e){case"JUNIOR_BOYS":return"Junior Boys Tournaments";case"JUNIOR_GIRLS":return"Junior Girls Tournaments";default:return"Golf Tournaments"}})(T)}),(0,c.jsx)(x,{onSearch:L}),(0,c.jsx)(v,{activeFilters:M,onRemove:e=>{const t={...M};"tour"===e?t.tour="":"dateRange"===e?t.dateRange={start:null,end:null}:"ageRange"===e&&(t.ageRange={min:9,max:18}),E(t),localStorage.setItem("tournamentFilters",JSON.stringify(t)),k(1),A(!0);(async()=>{m(!0);const e=await H(1);d(e),m(!1)})()},tours:U,removeTours:n}),(0,c.jsxs)("div",{style:C.filterContainer,children:[(0,c.jsx)(u,{selectedCategory:T,setSelectedCategory:_}),(0,c.jsxs)(r.Jm,{style:{"--border-radius":"20px","font-size":"12px","font-weight":"600",padding:"2px 12px",marginTop:-6},fill:"outline",onClick:()=>F(!0),children:[(0,c.jsx)(r.iq,{slot:"start",icon:a.PyO}),"Filters"]})]})]}),h?(0,c.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:(0,c.jsx)(r.w2,{})}):p?(0,c.jsx)("div",{style:{padding:"20px",textAlign:"center"},children:(0,c.jsx)(r.IO,{color:"danger",children:(0,c.jsxs)("p",{children:["Error loading tournaments: ",p]})})}):R&&0!==R.length?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{className:"desktop-view",children:(0,c.jsxs)("table",{className:"tournaments-table",children:[(0,c.jsx)("thead",{children:(0,c.jsxs)("tr",{children:[(0,c.jsx)("th",{children:"Date"}),(0,c.jsx)("th",{children:"Tournament"}),(0,c.jsx)("th",{children:"Age Range"}),(0,c.jsx)("th",{children:"Winner"}),(0,c.jsx)("th",{children:"Score"})]})}),(0,c.jsx)("tbody",{children:R.map(e=>{var t,n,o,r,a,i;return null!==e&&void 0!==e&&e.tournament_name&&null!==e&&void 0!==e&&e.start_date?(0,c.jsxs)("tr",{onClick:()=>q(e._id),style:{cursor:"pointer"},children:[(0,c.jsx)("td",{children:(0,b.z$)(e.start_date)}),(0,c.jsx)("td",{className:"tournament-name",children:P(e.tournament_name)}),(0,c.jsx)("td",{children:Y(e)}),(0,c.jsx)("td",{children:J((null===e||void 0===e||null===(t=e.firstPlaceWinner)||void 0===t||null===(n=t.k)||void 0===n||null===(o=n.split(" : "))||void 0===o?void 0:o[0])||"")}),(0,c.jsx)("td",{children:(null===e||void 0===e||null===(r=e.firstPlaceWinner)||void 0===r?void 0:r.v)>0?`+${null===e||void 0===e||null===(a=e.firstPlaceWinner)||void 0===a?void 0:a.v}`:null===e||void 0===e||null===(i=e.firstPlaceWinner)||void 0===i?void 0:i.v})]},e.id||Math.random()):null})})]})}),(0,c.jsx)("div",{className:"mobile-view",children:R.map(e=>{var t,n,o;return null!==e&&void 0!==e&&e.tournament_name&&null!==e&&void 0!==e&&e.start_date?(0,c.jsxs)("div",{className:"tournament-card",onClick:()=>q(e._id),children:[(0,c.jsxs)("div",{className:"tournament-header",children:[(0,c.jsx)("span",{className:"tournament-date",children:(0,b.z$)(e.end_date)}),(0,c.jsxs)("span",{className:"tournament-tour",children:[(0,c.jsx)(r.iq,{icon:a.NhD,style:{marginRight:4,marginBottom:-2}}),J((null===e||void 0===e||null===(t=e.firstPlaceWinner)||void 0===t||null===(n=t.k)||void 0===n||null===(o=n.split(" : "))||void 0===o?void 0:o[0])||"")]})]}),(0,c.jsx)("div",{className:"tournament-name",children:P(e.tournament_name)}),(0,c.jsx)("div",{className:"tournament-location",children:Y(e)})]},e.id||Math.random()):null})}),(0,c.jsx)(r.Ax,{onIonInfinite:G,disabled:!w,children:(0,c.jsx)(r.Hp,{loadingText:"Loading more tournaments...",loadingSpinner:"bubbles"})})]}):(0,c.jsx)("div",{style:{padding:"20px",textAlign:"center"},children:(0,c.jsx)(r.IO,{children:(0,c.jsx)("p",{children:"No tournaments found for the selected age range"})})})]}),(0,c.jsx)(j,{isOpen:B,onClose:()=>F(!1),onApply:e=>{E(e),localStorage.setItem("tournamentFilters",JSON.stringify(e))},initialFilters:M,selectedCategory:T,tours:U,removeTours:n})]})]})};var k=n(5374),w=n(6266),A=n(2658),T=n(4619);const _=e=>{let{isOpen:t,setIsOpen:n,tournament:a,playerId:i,category:s,navigateToLink:l}=e;const[d,h]=(0,o.useState)(null),[u,x]=(0,o.useState)(null),[m,p]=(0,o.useState)(!0),[j,f]=(0,o.useState)(null),[v,y]=(0,o.useState)(window.innerWidth);(0,o.useEffect)(()=>{const e=()=>y(window.innerWidth);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const b=v<=768?{"--width":"100%","--height":"100%","--border-radius":"0px"}:{"--width":"90%","--height":"90%","--max-width":"1200px","--border-radius":"10px"};function C(){n(!1),h(null),f(null)}(0,o.useEffect)(()=>{t&&(async()=>
1{if(i&&s)try{p(!0);const[e,t]=await Promise.all([g.A.get("/plus2/player",{params:{player_id:i,category:s}}),g.A.post("/plus-tournaments/player/scores",{tournamentId:a.link,player_id:i,category:s})]);if(!e.data)throw new Error("Failed to fetch player details");if(!t.data)throw new Error("Failed to fetch tournament scores");const n=e.data,o=t.data;h(n.player),x(o),f(null)}catch(e){console.error("Error fetching player data:",e),f(e.message)}finally{p(!1)}})()},[t,i,s,null===a||void 0===a?void 0:a._id,null===a||void 0===a?void 0:a.link]);const S=(()=>{if(null===a||void 0===a||!a.tournament_results||!i)return null;const e=a.tournament_results[i];if(null===e||void 0===e||!e.round_sequence)return null;const t=e.round_sequence.filter(e=>null!==e&&void 0!==e&&!isNaN(e));return 0===t.length?null:{series:[{name:`${(null===d||void 0===d?void 0:d.first_name)||""} ${(null===d||void 0===d?void 0:d.last_name)||""}`,data:t}],categories:t.map((e,t)=>`${t+1}`)}})(),k={chart:{type:"line",height:350,toolbar:{show:!1}},stroke:{width:3,curve:"smooth"},markers:{size:6},xaxis:{categories:(null===S||void 0===S?void 0:S.categories)||[],title:{text:"Tournament Hole"}},yaxis:{title:{text:"Score Relative to Par"},reversed:!0,labels:{formatter:function(e){return 0===e?"E":e>0?`+${e}`:e}}},title:{text:"Score Progression",align:"center",style:{fontSize:"16px",fontWeight:600}},colors:["#3B82F6"],tooltip:{y:{formatter:function(e){return 0===e?"Even":e>0?`+${e}`:e}}}};return(0,c.jsxs)(r.Sb,{isOpen:t,onDidDismiss:C,presentingElement:void 0,style:b,children:[(0,c.jsx)(r.eU,{children:(0,c.jsxs)(r.ai,{children:[(0,c.jsx)(r.BC,{children:"Player Details"}),(0,c.jsx)(r.QW,{slot:"end",children:(0,c.jsx)(r.Jm,{onClick:C,children:"Close"})})]})}),(0,c.jsx)(r.W9,{children:(0,c.jsx)(w.A,{children:(()=>{if(m)return(0,c.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:(0,c.jsx)(r.w2,{})});if(j)return(0,c.jsx)(r.b_,{children:(0,c.jsx)(r.I9,{children:(0,c.jsxs)("div",{style:{textAlign:"center",color:"var(--ion-color-danger)"},children:["Error loading player data: ",j]})})});let e=d,t=!0;if(console.log(e),!e){const[n=""]=(i||"").split(" : "),o=n.split(" "),r=(o[0]||"").charAt(0).toUpperCase()+(o[0]||"").slice(1),a=o.slice(1).join(" ").replace(/\(\d{4}\)/,"").trim()||"";e={first_name:r,last_name:a.charAt(0).toUpperCase()+a.slice(1),player_id:i,category:s},t=!1}return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(A.default,{tournament:u,player:e,showProfileLink:t,navigateToLink:l}),S&&(0,c.jsx)("div",{style:{marginTop:"20px"},children:(0,c.jsx)(T.A,{options:k,series:S.series,type:"line",height:380})})]})})()})})]})},N=e=>{var t,n;let{tournament:o,onPlayerClick:a,formatLocation:i,capitalizeFirst:s,formatPlayerName:l,formatPlayerLocation:h,formatScoreRelativeToPar:u}=e;if(!o.tournament_results)return null;if(null===(t=o.round_data)||void 0===t||!t.round1)return null;const x=Object.entries(o.tournament_results).map(e=>{var t;let[n,o]=e;const[r,a]=n.split(" : ");return{playerId:n,name:l(r),location:h(null===a||void 0===a?void 0:a.split(";")[0]),gradYear:null===(t=n.match(/\((\d{4})\)/))||void 0===t?void 0:t[1],...o}}).sort((e,t)=>e.place-t.place);return(0,c.jsxs)(d.k,{componentName:"JuniorTournaments",children:[(0,c.jsx)("div",{className:"course-info-section",children:(0,c.jsx)("div",{className:"course-cards",children:(0,c.jsxs)(r.I9,{children:[(0,c.jsx)("h2",{children:null===o||void 0===o||null===(n=o.tournament_name)||void 0===n?void 0:n.toUpperCase()}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Date:"}),(0,c.jsx)("span",{className:"value",children:(0,b.z$)(o.start_date,!0)})]}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Location:"}),(0,c.jsx)("span",{className:"value",children:i(o.location)})]}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Tour:"}),(0,c.jsx)("span",{className:"value",children:s(o.tour_name)})]})]})})}),(0,c.jsxs)("div",{className:"leaderboard-section",children:[(0,c.jsx)("h2",{children:"Leaderboard"}),(0,c.jsx)("div",{className:"leaderboard-table",children:(0,c.jsxs)("table",{children:[(0,c.jsx)("thead",{children:(0,c.jsxs)("tr",{children:[(0,c.jsx)("th",{children:"Pos"}),(0,c.jsx)("th",{children:"Player"}),(0,c.jsx)("th",{children:"Hometown"}),(0,c.jsx)("th",{children:"Class"}),(0,c.jsx)("th",{children:"Score"}),(0,c.jsx)("th",{children:"Total"})]})}),(0,c.jsx)("tbody",{children:x.map(e=>(0,c.jsxs)("tr",{onClick:()=>a(e.playerId),style:{cursor:"pointer"},className:"player-row",children:[(0,c.jsx)("td",{children:e.place}),(0,c.jsx)("td",{className:"player-name",children:e.name}),(0,c.jsx)("td",{children:e.location}),(0,c.jsx)("td",{children:e.gradYear||"-"}),(0,c.jsx)("td",{children:e.results_string}),(0,c.jsx)("td",{children:u(e.total_rel_par)})]},e.name))})]})})]})]})},I=e=>{var t,n,o,a;let{tournament:i,formatLocation:s,capitalizeFirst:l,capitalizeWords:d}=e;if(null===(t=i.round_data)||void 0===t||!t.round1)return null;const h=i.round_data.round1[Object.keys(i.round_data.round1)[0]];return console.log(h),console.log(i),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("h2",{children:"Information"}),(0,c.jsxs)("div",{className:"course-info-section",children:[(0,c.jsx)("div",{className:"course-cards",children:(0,c.jsx)(r.b_,{children:(0,c.jsxs)(r.I9,{children:[(0,c.jsx)("h3",{children:"Tourn
1ament Information"}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Date:"}),(0,c.jsx)("span",{className:"value",children:(0,b.z$)(null===i||void 0===i?void 0:i.start_date)})]}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Location:"}),(0,c.jsx)("span",{className:"value",children:s(null===i||void 0===i?void 0:i.location)})]}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Tour:"}),(0,c.jsx)("span",{className:"value",children:l(null===i||void 0===i?void 0:i.tour_name)})]})]})})}),(0,c.jsxs)("div",{className:"course-cards",children:[(0,c.jsx)(r.b_,{children:(0,c.jsxs)(r.I9,{children:[(0,c.jsx)("h3",{children:"Course Details"}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Course:"}),(0,c.jsx)("span",{className:"value",children:l(null===(n=i.course)||void 0===n?void 0:n.course1)})]}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Total Yardage:"}),(0,c.jsxs)("span",{className:"value",children:[null===h||void 0===h||null===(o=h.hole_yardages)||void 0===o?void 0:o.yt18," yards"]})]}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Par:"}),(0,c.jsx)("span",{className:"value",children:null===h||void 0===h||null===(a=h.hole_pars)||void 0===a?void 0:a.pt18})]})]})}),(0,c.jsx)(r.b_,{children:(0,c.jsxs)(r.I9,{children:[(0,c.jsx)("h3",{children:"Weather Conditions"}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Temperature:"}),(0,c.jsxs)("span",{className:"value",children:[Math.round(null===h||void 0===h?void 0:h.avg_temp),"\xb0F"]})]}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Wind:"}),(0,c.jsxs)("span",{className:"value",children:[null===h||void 0===h?void 0:h.wind," mph"]})]}),(0,c.jsxs)("div",{className:"info-row",children:[(0,c.jsx)("span",{className:"label",children:"Conditions:"}),(0,c.jsx)("span",{className:"value",children:d(null===h||void 0===h?void 0:h.conditions)})]})]})})]})]})]})},R=e=>{let{tournament:t,capitalizeFirst:n}=e;if(!t.all_rounds_data)return null;const{seriesData:o,categories:a}=(()=>{if(!t.tournament_results)return null;const e={};Object.entries(t.tournament_results).forEach(t=>{let[n,o]=t;const r=o.total_rel_par,a=n.split(" : ")[0];e[r]||(e[r]=[]),e[r].push(a)});const n=Object.values(t.tournament_results).map(e=>e.total_rel_par).sort((e,t)=>e-t),o=n.reduce((e,t)=>(e[t]=(e[t]||0)+1,e),{}),r=Math.min(...n),a=Math.max(...n),i=[],s=[];for(let t=r;t<=a;t++)s.push(t),i.push({y:o[t]||0,players:e[t]||[]});return{seriesData:i,categories:s}})()||{seriesData:[],categories:[]},i={chart:{type:"bar",height:350,toolbar:{show:!1}},annotations:{xaxis:[{x:0,borderColor:"#bbb",borderWidth:2,strokeDashArray:0,zIndex:0,opacity:.3,label:{text:"Even Par",position:"top",offsetY:-10,style:{background:"#fff",color:"#555",fontSize:"12px",fontWeight:400}}}]},plotOptions:{bar:{borderRadius:4,columnWidth:"60%",distributed:!0}},colors:["#1b6dff"],dataLabels:{enabled:!1},legend:{show:!1},xaxis:{categories:a,title:{text:"Score Relative to Par"},labels:{formatter:function(e){const t=e=>e>0?`+${e}`:e;return a.length>50?e%10===0?t(e):"":a.length>20?e%5===0?t(e):"":a.length>10?e%2===0?t(e):"":t(e)}}},yaxis:{title:{text:"Number of Players"},labels:{formatter:function(e){return Math.round(e)}},min:0,forceNiceScale:!0},title:{text:"Scoring Distribution",style:{fontSize:"16px",fontWeight:600}},tooltip:{enabled:!0,custom:function(e){let{dataPointIndex:t}=e;const r=a[t],i=o[t].players;return i&&0!==i.length?`\n <div style="padding: 8px; background: white; border-radius: 4px;">\n <div style="font-weight: 600; margin-bottom: 8px; color: #333;">\n Score: ${r}\n </div>\n <div style="color: #666;">\n ${i.map(e=>`<div style="padding: 2px 0;">${n(e)}</div>`).join("")}\n </div>\n </div>\n `:""},followCursor:!0,intersect:!0,shared:!1}},{series:s,labels:l}=(()=>
1{if(!t.tournament_results)return{series:[],labels:[]};const e={};Object.keys(t.tournament_results).forEach(t=>{const n=t.match(/\((\d{4})\)/);if(n){const t=n[1];e[t]=(e[t]||0)+1}});const n=Object.keys(e).sort();return{series:n.map(t=>e[t]),labels:n.map(e=>`Class of ${e}`)}})(),h={chart:{type:"donut"},labels:l,plotOptions:{pie:{donut:{size:"65%"}}},legend:{position:"bottom",horizontalAlign:"center"},title:{text:"Graduation Year Distribution",style:{fontSize:"16px",fontWeight:600}},colors:["#36D399","#3B82F6","#F87272","#FBBD23","#6B7280","#8B5CF6"],dataLabels:{enabled:!0,formatter:function(e,t){return t.w.config.series[t.seriesIndex]}},tooltip:{y:{formatter:function(e){return`${e} players`}}}},u=(()=>{if(!t.tournament_results)return null;const e=Object.entries(t.tournament_results).map(e=>{let[t,o]=e;const[r]=t.split(" : ");return{name:n(r),scores:o.round_sequence||[]}}).filter(e=>e.scores.length>0&&e.scores.every(e=>null!==e&&!isNaN(e)&&void 0!==e)).sort((e,t)=>e.scores[e.scores.length-1]-t.scores[t.scores.length-1]).slice(0,10);if(0===e.length)return null;const o=Math.max(...e.map(e=>e.scores.length)),r=Array.from({length:o},(e,t)=>`${t+1}`);return{series:e.map(e=>({name:e.name,data:e.scores})),categories:r}})(),x={chart:{type:"line",height:400,toolbar:{show:!1}},stroke:{width:2,curve:"smooth"},xaxis:{categories:(null===u||void 0===u?void 0:u.categories)||[],title:{text:"Tournament Hole"},labels:{formatter:function(e){const t=e=>e>0?`+${e}`:e;return a.length>50?e%10===0?t(e):"":a.length>20?e%5===0?t(e):"":a.length>10?e%2===0?t(e):"":t(e)},rotateAlways:!1,hideOverlappingLabels:!0,maxHeight:100,tickAmount:10},tickPlacement:"on"},yaxis:{title:{text:"Score Relative to Par"},reversed:!0,labels:{formatter:function(e){return e>0?`+${e}`:e}}},title:{text:"Score Progression (Top 10 Players)",style:{fontSize:"16px",fontWeight:600}},legend:{position:"bottom",horizontalAlign:"center"},markers:{size:3},tooltip:{shared:!0,intersect:!1,y:{formatter:function(e){return 0===e?"Even":e>0?`+${e}`:e}}}},g=e=>{let{courseData:t}=e;const n=Array.from({length:9},(e,t)=>t+1),o=Array.from({length:9},(e,t)=>t+10),r=()=>{var e,n,o,r;return{par:(null===t||void 0===t||null===(e=t.hole_pars)||void 0===e?void 0:e.pf9)||"",yards:(null===t||void 0===t||null===(n=t.hole_yardages)||void 0===n?void 0:n.yf9)||"",avgScore:(null===t||void 0===t||null===(o=t.avg_score_by_hole)||void 0===o||null===(r=o.sf9)||void 0===r?void 0:r.toFixed(1))||""}},a=()=>{var e,n,o,r;return{par:(null===t||void 0===t||null===(e=t.hole_pars)||void 0===e?void 0:e.pb9)||"",yards:(null===t||void 0===t||null===(n=t.hole_yardages)||void 0===n?void 0:n.yb9)||"",avgScore:(null===t||void 0===t||null===(o=t.avg_score_by_hole)||void 0===o||null===(r=o.sb9)||void 0===r?void 0:r.toFixed(1))||""}},i=()=>{var e,n,o,r;return{par:(null===t||void 0===t||null===(e=t.hole_pars)||void 0===e?void 0:e.pt18)||"",yards:(null===t||void 0===t||null===(n=t.hole_yardages)||void 0===n?void 0:n.yt18)||"",avgScore:(null===t||void 0===t||null===(o=t.avg_score_by_hole)||void 0===o||null===(r=o.st18)||void 0===r?void 0:r.toFixed(1))||""}};return(0,c.jsx)("div",{className:"scorecard-section",children:(0,c.jsx)("div",{style:{overflowX:"auto"},children:(0,c.jsxs)("table",{style:m.scorecard,children:[(0,c.jsx)("thead",{children:(0,c.jsxs)("tr",{children:[(0,c.jsx)("th",{children:"Hole"}),n.map(e=>(0,c.jsx)("th",{children:e},e)),(0,c.jsx)("th",{children:"OUT"}),o.map(e=>(0,c.jsx)("th",{children:e},e)),(0,c.jsx)("th",{children:"IN"}),(0,c.jsx)("th",{children:"TOT"})]})}),(0,c.jsxs)("tbody",{children:[(0,c.jsxs)("tr",{children:[(0,c.jsx)("td",{children:"Par"}),n.map(e=>{var n;return(0,c.jsx)("td",{children:null===t||void 0===t||null===(n=t.hole_pars)||void 0===n?void 0:n[`p${e}`]},e)}),(0,c.jsx)("td",{children:r().par}),o.map(e=>{var n;return(0,c.jsx)("td",{children:null===t||void 0===t||null===(n=t.hole_pars)||void 0===n?void 0:n[`p${e}`]},e)}),(0,c.jsx)("td",{children:a().par}),(0,c.jsx)("td",{children:i().par})]}),(0,c.jsxs)("tr",{children:[(0,c.jsx)("td",{children:"Yards"}),n.map(e=>{var n;return(0,c.jsx)("td",{children:null===t||void 0===t||null===(n=t.hole_yardages)||void 0===n?void 0:n[`y${e}`]},e)}),(0,c.jsx)("td",{children:r().yards}),o.map(e=>{var n;return(0,c.jsx)("td",{children:null===t||void 0===t||null===(n=t.hole_yardages)||void 0===n?void 0:n[`y${e}`]},e)}),(0,c.jsx)("td",{children:a().yards}),(0,c.jsx)("td",{children:i().yards})]}),(0,c.jsxs)("tr",{children:[(0,c.jsx)("td",{children:"Avg"}),n.map(e=>{var n,o;return(0,c.jsx)("td",{children:null===t||void 0===t||null===(n=t.avg_score_by_hole)||void 0===n||null===(o=n[`s${e}`])||void 0===o?void 0:o.toFixed(1)},e)}),(0,c.jsx)("td",{children:r().avgScore}),o.map(e=>{var n,o;return(0,c.jsx)("td",{children:null===t||void 0===t||null===(n=t.avg_score_by_hole)||void 0===n||null===(o=n[`s${e}`])||void 0===o?void 0:o.toFixed(1)},e)}),(0,c.jsx)("td",{children:a().avgScore}),(0,c.jsx)("td",{children:i().avgScore})]})]})]})})})},m={scorecard:{width:"100%",borderCollapse:"collapse",fontSize:"14px",textAlign:"center"}};return(0,c.jsx)(d.k,{componentName:"JuniorTournamentStatsTab",children:(0,c.jsxs)("div",{children:[(0,c.jsx)("h2",{children:"Tourn
1ament Stats"}),Object.entries(t.all_rounds_data).map(e=>{let[t,n]=e;const a=Array.from({length:18},(e,t)=>t+1),s=a.map(e=>{const t=n.avg_score_by_hole[`s${e}`],o=n.hole_pars[`p${e}`];return Number((t-o).toFixed(2))}),l={chart:{type:"bar",height:350,toolbar:{show:!1},annotations:{yaxis:[{y:0,strokeDashArray:0,borderColor:"#666",borderWidth:1,opacity:.3}]}},plotOptions:{bar:{borderRadius:4,colors:{ranges:[{from:-10,to:0,color:"#36D399"},{from:.01,to:10,color:"#F87272"}]},columnWidth:"60%"},annotations:{yaxis:[{y:0,strokeDashArray:0,borderColor:"#666",borderWidth:1,opacity:.3}]}},dataLabels:{enabled:!0,formatter:function(e){const t=Number(e.toFixed(2));return t>0?`+${t}`:t},style:{fontSize:"10px",fontWeight:600,colors:["#333"]},offsetY:-4},xaxis:{categories:a.map(e=>`${e}`),title:{text:"Holes"}},yaxis:{title:{text:"Strokes Relative to Par"},reversed:!0,labels:{formatter:function(e){return e>0?`+${null===e||void 0===e?void 0:e.toFixed(2)}`:null===e||void 0===e?void 0:e.toFixed(2)}},tickAmount:8},title:{text:"Average Scores Relative to Par",style:{fontSize:"16px",fontWeight:600}}};return(0,c.jsxs)("div",{children:[(0,c.jsx)(g,{courseData:n}),(0,c.jsx)("div",{className:"scoring-graph-section",children:(0,c.jsx)(r.b_,{style:{marginLeft:-10,marginRight:-10},children:(0,c.jsx)(r.I9,{children:(0,c.jsx)(T.A,{options:l,series:[{name:"Strokes Relative to Par",data:s}],type:"bar",height:350})})})}),(0,c.jsx)("div",{className:"scoring-graph-section",children:(0,c.jsx)(r.b_,{style:{marginLeft:-10,marginRight:-10},children:(0,c.jsx)(r.I9,{children:(0,c.jsx)(T.A,{options:i,series:[{name:"Players",data:o.map(e=>e.y),players:o.map(e=>e.players)}],type:"bar",height:350})})})})]},t)}),(0,c.jsx)("div",{className:"scoring-graph-section",children:(0,c.jsx)(r.b_,{style:{marginLeft:-10,marginRight:-10},children:(0,c.jsx)(r.I9,{children:(0,c.jsx)(T.A,{options:h,series:s,type:"donut",height:350})})})}),u&&(0,c.jsx)("div",{className:"scoring-graph-section",children:(0,c.jsx)(r.b_,{style:{marginLeft:-10,marginRight:-10},children:(0,c.jsx)(r.I9,{children:(0,c.jsx)(T.A,{options:x,series:u.series,type:"line",height:400})})})})]})})},D={fixedHeader:{position:"fixed",top:0,left:0,right:0,backgroundColor:"white",zIndex:1e3,borderBottom:"1px solid #e4e4e4"},headerContent:{padding:"12px 20px",display:"flex",alignItems:"center",gap:"12px"},backButton:{margin:0,"--padding-start":"8px","--padding-end":"8px"},title:{margin:0,fontSize:"18px",fontWeight:600,flex:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},z=e=>{var t,n;let{match:s,fromJuniorSection:l=!1}=e;const{userData:d}=(0,o.useContext)(y.c),[h,u]=(0,o.useState)(null),[x,m]=(0,o.useState)(!0),[p,j]=(0,o.useState)(null),[f,v]=(0,o.useState)(null),[b,C]=(0,o.useState)(!1),[S,A]=(0,o.useState)("Leaderboard"),T=(0,i.zy)(),z=new URLSearchParams(T.search).get("category")||"JUNIOR_BOYS",L=(0,i.W6)(),W=null===s||void 0===s||null===(t=s.params)||void 0===t?void 0:t.id;(0,o.useEffect)(()=>{null!==d&&void 0!==d&&d._id||(async()=>{if(!W)return j("Tournament ID is missing"),void m(!1);try{const e=await g.A.get(`/plus-tournaments/${W}`,{params:{category:z}});if(!e.data)throw new Error("No tournament data received");u(e.data)}catch(p){var e,t;console.error("Error fetching tournament details:",p),j((null===(e=p.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.message)||"Failed to load tournament details")}finally{m(!1)}})()},[W,z,null===d||void 0===d?void 0:d._id]);const O=e=>0===e?"E":e>0?`+${e}`:e,B=e=>e?e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):"",F=e=>["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"].includes(e.toUpperCase()),M=e=>e?e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):"",E=e=>{if(!e)return"TBA";return[...new Set([e.location1,e.location2])].filter(Boolean).map(e=>{if(!e)return"";return e.split(",").map(e=>e.trim()).map(e=>2===e.length&&F(e)?e.toUpperCase():M(e)).join(", ")}).join(", ")},U=e=>{if(!e)return"";return e.split(",").map(e=>e.trim()).map(e=>2===e.length&&F(e)?e.toUpperCase():M(e)).join(", ")},$=e=>e.split(" ").map(e=>M(e)).join(" "),H=e=>{v(e),C(!0)};return x?(0,c.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:(0,c.jsx)(r.w2,{})}):null!==d&&void 0!==d&&d._id?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{style:{...D.fixedHeader,top:l?50:0},children:(0,c.jsxs)("div",{style:D.headerContent,children:[(0,c.jsxs)(r.Jm,{fill:"clear",onClick:()=>L.push(l?`/junior/tournaments?category=${z}`:`/recruiting/tournaments?category=${z}`),style:D.backButton,children:[(0,c.jsx)(r.iq,{icon:a.fKZ,slot:"start"}),"Back"]}
1),(0,c.jsx)("h1",{style:D.title,children:"Tournament Details"})]})}),(0,c.jsxs)("div",{style:{padding:"40px 20px",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",maxWidth:"600px",margin:"100px auto"},children:[(0,c.jsx)(r.IO,{color:"danger",style:{fontSize:"20px",fontWeight:"500"},children:(0,c.jsx)("p",{children:"You must be logged in to view tournament details"})}),(0,c.jsx)(r.IO,{color:"medium",style:{fontSize:"16px"},children:(0,c.jsx)("p",{children:p})}),(0,c.jsx)(r.Jm,{fill:"solid",onClick:()=>L.push("/login"),style:{marginTop:"8px"},children:"Go to Login"})]})]}):h?(0,c.jsxs)(r.W9,{children:[(0,c.jsxs)("div",{style:{...D.fixedHeader,top:l?50:0},children:[(0,c.jsxs)("div",{style:D.headerContent,children:[(0,c.jsxs)(r.Jm,{fill:"clear",onClick:()=>L.push(l?`/junior/tournaments?category=${z}`:`/recruiting/tournaments?category=${z}`),style:D.backButton,children:[(0,c.jsx)(r.iq,{icon:a.fKZ,slot:"start"}),"Back"]}),(0,c.jsx)("h1",{style:D.title,children:null===h||void 0===h||null===(n=h.tournament_name)||void 0===n?void 0:n.toUpperCase()})]}),(0,c.jsx)(k.A,{buttons:[{name:"Leaderboard"},{name:"Tournament Stats"},{name:"Information"}],tabNameUpdated:A})]}),(0,c.jsx)("div",{style:{height:l?"130px":"80px"}}),(0,c.jsx)(w.A,{maxWidth:1e3,padding:0,children:(()=>{switch(S){case"Leaderboard":return(0,c.jsx)(N,{tournament:h,onPlayerClick:H,formatLocation:E,capitalizeFirst:M,capitalizeWords:B,formatPlayerName:$,formatPlayerLocation:U,formatScoreRelativeToPar:O});case"Information":return(0,c.jsx)(I,{tournament:h,formatLocation:E,capitalizeFirst:M,capitalizeWords:B});case"Tournament Stats":return(0,c.jsx)(R,{tournament:h,capitalizeWords:B,capitalizeFirst:M});default:return(0,c.jsx)("div",{children:S})}})()}),(0,c.jsx)(_,{isOpen:b,setIsOpen:C,tournament:h,playerId:f,category:z,navigateToLink:e=>{C(!1),setTimeout(()=>{L.push(`/junior/player/${e}||${z}`)},100)}})]}):(0,c.jsx)("div",{style:{padding:"20px",textAlign:"center"},children:(0,c.jsx)(r.IO,{children:(0,c.jsx)("p",{children:"Tournament not found"})})})};var L=n(3685),W=n(3149),O=n(9026);const B=e=>{let{titles:t,values:n,name:o,wholeNumber:r=!0,colors:a=null,trimMinMax:i=!1,min:s,max:l,fixed:d=2,height:h=240,color:u="#12784b"}=e;if(!n||!Array.isArray(n)||0===n.length)return(0,c.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:"No data available"});const x=n.map(e=>({...e,data:e.data.map(e=>null===e||void 0===e||isNaN(e)?0:e)})),g=t?t.map(e=>e||"Unknown"):[];let m={min:s,max:l};if(i){const e=x.reduce((e,t)=>[...e,...t.data],[]).filter(e=>!isNaN(e)&&null!==e&&void 0!==e);if(e.length>0){let t=Math.max(...e);m={min:.99*Math.min(...e),max:t}}}let p={series:x,options:{chart:{animations:{enabled:!1,animateGradually:{enabled:!1},dynamicAnimation:{enabled:!1}},height:250,type:"bar",toolbar:{show:!1}},...a?{colors:a}:{colors:[u,u]},plotOptions:{bar:{borderRadius:4,spaceBetween:20,dataLabels:{position:"top"}}},stroke:{width:6,colors:["transparent"]},dataLabels:{enabled:!1,formatter:function(e){return 0===e?"":e},offsetY:-20,style:{fontSize:"12px",colors:["#304758"]}},xaxis:{categories:g,position:"bottom",tickAmount:7,axisBorder:{show:!1},axisTicks:{show:!1},grid:{show:!1},crosshairs:{fill:{type:"gradient",gradient:{colorFrom:"#D8E3F0",colorTo:"#BED1E6",stops:[0,100],opacityFrom:.4,opacityTo:.5}}},tooltip:{enabled:!0}},grid:{show:!1},annotations:{yaxis:[{y:0,borderColor:"#999",strokeDashArray:0}]},yaxis:{axisBorder:{show:!1},axisTicks:{show:!1},labels:{show:!0,formatter:function(e,t){return(0,O.X)(e,r?0:null!==d&&void 0!==d?d:2)}},...m},title:{text:o||"Scores",floating:!0,offsetY:220,align:"center",style:{color:"#444"}}}};return(0,c.jsx)("div",{id:"chart",children:(0,c.jsx)(T.A,{options:p.options,series:p.series,type:"bar",height:h,style:{marginBottom:-10,marginTop:-30,marginLeft:-10,marginRight:0}})})},F={sectionTitle:{fontSize:24,fontWeight:"bold",color:"#001a3a",marginBottom:20,display:"flex",alignItems:"center",padding:"10px 0",borderBottom:"2px solid #e0e0e0"},sectionIcon:{fontSize:24,marginRight:12,color:"#001a3a"},chartCard:{backgroundColor:"#fff",borderRadius:12,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",border:"1px solid #e0e0e0",height:"100%",transition:"transform 0.2s ease, box-shadow 0.2s ease"},chartTitle:{display:"flex",alignItems:"center",fontSize:18,fontWeight:"600",color:"#001a3a",margin:0},chartIcon:{fontSize:20,marginRight:8,color:"#001a3a"},chartContent:{padding:"20px 16px",minHeight:200},chartSubtitle:{fontSize:14,color:"#666",marginTop:8}},M=e=>{let{title:t,icon:n,stats:o,generateChartColor:i,color:s}=e;if(!o)return null;console.log("Raw stats data received:",{grad_years:o.grad_years}),console.log("Complete stats object:",o),console.log("Available keys in stats:",Object.keys(o));const l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unknown";if(console.log(`Validating ${t}:`,e),!e||"object"!==typeof e)return console.log(`No ${t} data available - statsObj is:`,e),null;const n={};let o=0;return Object.keys(e).forEach(r=>{const a=e[r];null!==a&&void 0!==a&&!isNaN(a)&&a>0?(n[r]=a,o++):console.log(`Invalid value for ${t} key "${r}":`,a)}),console.log(`${t} validation: ${o} valid entries out of ${Object.keys(e).length} total`),console.log(`Sample ${t} data:`,Object.keys(e).slice(0,3)),console.log(`Validated ${t} data:`,n),n}(o.grad_years,"graduation years");return console.log("=== GRADUATION YEARS DEBUG ==="),console.log("Raw grad_years:",o.grad_years),console.log("Type of grad_years:",typeof o.grad_years),console.log("Is grad_years an object?","object"===typeof o.grad_years),console.log("Is grad_years null?",null===o.grad_years),console.log("Is grad_years undefined?",void 0===o.grad_years),console.log("Validated grad_years:",l),console.log("Validated grad_years keys:",l?Object.keys(l):"null"),console.log("Validated grad_years length:",l?Object.keys(l).length:0),console.log("=== END GRADUATION YEARS DEBUG ==="),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.ln,{children:(0,c.jsx)(r.hU,{size:"12",children:(0,c.jsxs)("h2",{style:F.sectionTitle,children:[(0,c.jsx)(r.iq,{icon:n,style:F.sectionIcon}),t]})})}),(0,c.jsx)(r.ln,{children:(0,c.jsx)(r.hU,{size:"12",children:(0,c.jsxs)(r.b_,{style:F.chartCard,children:[(0,c.jsx)(r.ME,{children:(0,c.jsxs)(r.tN,{style:F.chartTitle,children:[(0,c.jsx)(r.iq,{icon:a.ROU,style:F.chartIcon}),"Graduation Years"]})}),(0,c.jsx)(r.I9,{style:F.chartContent,children:l&&Object.keys(l).length>0?(0,c.jsx)(B,{titles:Object.keys(l),values:[{name:"Players",data:Object.values(l)}],name:" ",wholeNumber:!0,height:300,color:s}):(0,c.jsxs)("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:["No graduation year data available",(0,c.jsxs)("div",{style:{fontSize:"12px",marginTop:"5px"}
1,children:["Available data keys: ",Object.keys(o).join(", ")]})]})})]})})})]})},E=e=>{let{value:t,onChange:n}=e;const[i,s]=(0,o.useState)(!1),l=[{value:18,label:"Last 18 Months"},{value:12,label:"Last 12 Months"},{value:6,label:"Last 6 Months"},{value:1,label:"Last 1 Month"}];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"#f8f9fa",borderRadius:"8px",padding:"8px 12px",border:"1px solid #e9ecef",cursor:"pointer",transition:"all 0.2s ease",outline:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",minWidth:"140px"},onClick:()=>s(!0),id:"time-period-button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s(!0))},onMouseEnter:e=>{e.target.style.background="#f1f3f4",e.target.style.borderColor="#dee2e6"},onMouseLeave:e=>{e.target.style.background="#f8f9fa",e.target.style.borderColor="#e9ecef"},onFocus:e=>{e.target.style.outline="none"},onBlur:e=>{e.target.style.outline="none"},children:[(0,c.jsx)(r.iq,{icon:a.RXF,style:{fontSize:"16px",color:"#6c757d",marginRight:"8px"}}),(0,c.jsx)("span",{style:{fontSize:"14px",fontWeight:"500",color:"#495057",marginRight:"8px",flex:1,textAlign:"left"},children:(()=>{const e=l.find(e=>e.value===t);return e?e.label:"Last 18 Months"})()}),(0,c.jsx)(r.iq,{icon:a.SJM,style:{fontSize:"16px",color:"#6c757d",transition:"transform 0.2s ease",transform:i?"rotate(180deg)":"rotate(0deg)"}})]}),(0,c.jsx)(r.CF,{isOpen:i,onDidDismiss:()=>s(!1),trigger:"time-period-button",side:"bottom",alignment:"end",style:{"--width":"200px","--background":"white","--border-radius":"12px","--box-shadow":"0 10px 40px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1)","--backdrop-opacity":"0.4"},children:(0,c.jsxs)(r.W9,{style:{"--padding-top":"8px","--padding-bottom":"8px"},children:[(0,c.jsx)("div",{style:{padding:"12px 16px",borderBottom:"1px solid #f1f3f4",marginBottom:"8px"},children:(0,c.jsx)("span",{style:{fontSize:"16px",fontWeight:"600",color:"#1a1a1a"},children:"Select Time Period"})}),(0,c.jsx)(r.nf,{style:{"--padding-start":"0","--padding-end":"0","--border-radius":"12px"},children:l.map(e=>(0,c.jsx)(r.uz,{button:!0,onClick:()=>{n(e.value),s(!1)},style:{"--padding-start":"16px","--padding-end":"16px","--background":t===e.value?"#f8f9fa":"transparent","--color":t===e.value?"#1a1a1a":"#495057","--font-weight":t===e.value?"800":"400","--border-radius":"0","--min-height":"48px"},children:(0,c.jsx)(r.he,{style:{fontSize:"14px",lineHeight:"1.4",fontWeight:t===e.value?"800":"400"},children:e.label})},e.value))})]})})]})},U=e=>{const t=["#FF6B6B","#4ECDC4","#45B7D1","#96CEB4","#FFEAA7","#DDA0DD","#98D8C8","#F7DC6F","#BB8FCE","#85C1E9","#F8C471","#82E0AA","#F1948A","#85C1E9","#D7BDE2","#A9DFBF","#FAD7A0","#AED6F1","#D5A6BD","#A2D9CE"];return t[e%t.length]};function $(e){let{showHeader:t=!1,dashboardData:n,dashboardLoading:i,dashboardError:s,refreshDashboardData:l,lookbackMonths:d,setLookbackMonths:h}=e;const[u,x]=(0,o.useState)(!1),g=(0,o.useContext)(y.c),m=(null===g||void 0===g?void 0:g.userData)||null;return(0,o.useEffect)(()=>{const e=setTimeout(()=>{x(!0)},2e3);return()=>clearTimeout(e)},[]),"loading"===m?(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(r.W9,{children:(0,c.jsx)(L.A,{children:(0,c.jsxs)("div",{style:{marginTop:300},children:[u?(0,c.jsx)(r.KW,{src:"/assets/TUGRLogo.png",style:{width:200}}):null,(0,c.jsx)(L.A,{children:(0,c.jsx)(r.w2,{name:"dots"})})]})})})}):(0,c.jsxs)(c.Fragment,{children:[t?(0,c.jsx)(W.A,{}):null,(0,c.jsx)(r.W9,{children:(0,c.jsxs)(w.A,{padding:10,maxWidth:1300,children:[(0,c.jsxs)("div",{style:H.dashboardHeader,children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("h1",{style:H.dashboardTitle,children:"Dashboard"}),(0,c.jsx)("p",{style:H.dashboardSubtitle,children:"Tour analytics and performance insights"})]}),(0,c.jsx)("div",{style:H.headerActions,children:(0,c.jsx)(E,{value:d,onChange:h})})]}),i?(0,c.jsxs)("div",{style:H.loadingContainer,children:[(0,c.jsx)(r.w2,{name:"dots"}),(0,c.jsx)("p",{children:"Loading dashboard data..."})]}):s?(0,c.jsxs)("div",{style:H.errorContainer,children:[(0,c.jsx)("p",{style:H.errorText,children:s}),(0,c.jsx)(r.Jm,{onClick:l,children:"Retry"})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.lO,{style:H.metricsGrid,children:(0,c.jsxs)(r.ln,{children:[(0,c.jsx)(r.hU,{size:"12",sizeMd:"3",children:(0,c.jsx)(r.b_,{style:H.metricCard,children:(0,c.jsxs)(r.I9,{style:H.metricContent,children:[(0,c.jsxs)("div",{style:H.metricHeader,children:[(0,c.jsx)(r.iq,{icon:a.wx_,style:H.metricIcon}),(0,c.jsx)("span",{style:H.metricLabel,children:"Junior Boys"})]}),(0,c.jsx)("div",{style:H.metricValue,children:((null===n||void 0===n?void 0:n.numberOfJuniorBoys_last18mo)||0).toLocaleStr
1ing()}),(0,c.jsx)("div",{style:H.metricChange,children:(0,c.jsxs)("span",{style:H.changeLabel,children:["Last ",d," ",1===d?"month":"months"]})})]})})}),(0,c.jsx)(r.hU,{size:"12",sizeMd:"3",children:(0,c.jsx)(r.b_,{style:H.metricCard,children:(0,c.jsxs)(r.I9,{style:H.metricContent,children:[(0,c.jsxs)("div",{style:H.metricHeader,children:[(0,c.jsx)(r.iq,{icon:a.wx_,style:H.metricIcon}),(0,c.jsx)("span",{style:H.metricLabel,children:"Junior Girls"})]}),(0,c.jsx)("div",{style:H.metricValue,children:((null===n||void 0===n?void 0:n.numberOfJuniorGirls_last18mo)||0).toLocaleString()}),(0,c.jsx)("div",{style:H.metricChange,children:(0,c.jsxs)("span",{style:H.changeLabel,children:["Last ",d," ",1===d?"month":"months"]})})]})})}),(0,c.jsx)(r.hU,{size:"12",sizeMd:"3",children:(0,c.jsx)(r.b_,{style:H.metricCard,children:(0,c.jsxs)(r.I9,{style:H.metricContent,children:[(0,c.jsxs)("div",{style:H.metricHeader,children:[(0,c.jsx)(r.iq,{icon:a.wx_,style:H.metricIcon}),(0,c.jsx)("span",{style:H.metricLabel,children:"Total Players"})]}),(0,c.jsx)("div",{style:H.metricValue,children:(((null===n||void 0===n?void 0:n.numberOfJuniorBoys_last18mo)||0)+((null===n||void 0===n?void 0:n.numberOfJuniorGirls_last18mo)||0)).toLocaleString()}),(0,c.jsx)("div",{style:H.metricChange,children:(0,c.jsx)("span",{style:H.changeLabel,children:"Combined total"})})]})})}),(0,c.jsx)(r.hU,{size:"12",sizeMd:"3",children:(0,c.jsx)(r.b_,{style:H.metricCard,children:(0,c.jsxs)(r.I9,{style:H.metricContent,children:[(0,c.jsxs)("div",{style:H.metricHeader,children:[(0,c.jsx)(r.iq,{icon:a.UN$,style:H.metricIcon}),(0,c.jsx)("span",{style:H.metricLabel,children:"States"})]}),(0,c.jsx)("div",{style:H.metricValue,children:((e,t)=>{const o=Object.keys((null===n||void 0===n||null===(e=n.juniorBoysStats)||void 0===e?void 0:e.states)||{}),r=Object.keys((null===n||void 0===n||null===(t=n.juniorGirlsStats)||void 0===t?void 0:t.states)||{}),a=new Set([...o,...r]),i=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"];return Array.from(a).filter(e=>i.includes(e.toUpperCase().trim())).length})()}),(0,c.jsx)("div",{style:H.metricChange,children:(0,c.jsx)("span",{style:H.changeLabel,children:"Represented"})})]})})})]})}),(0,c.jsxs)(r.lO,{style:H.chartsGrid,children:[(null===n||void 0===n?void 0:n.juniorBoysStats)&&(0,c.jsx)(M,{title:"Junior Boys Analytics",icon:a.wx_,stats:n.juniorBoysStats,generateChartColor:U,color:"#00a0ff"}),(null===n||void 0===n?void 0:n.juniorGirlsStats)&&(0,c.jsx)(M,{title:"Junior Girls Analytics",icon:a.wx_,stats:n.juniorGirlsStats,generateChartColor:U,color:"#EC4899"})]})]})]})})]})}const H={background:{width:"100%",height:500,background:"linear-gradient(to bottom right, #f7f7f7 50%, #fff 50%)",position:"absolute",top:0,left:0,zIndex:-1,textAlign:"center"},title:{fontSize:60,color:"#001a3a",marginTop:130},paragraph:{color:"#2d4665"},video:{width:"50%",height:300,backgroundColor:"gray",borderRadius:20,marginTop:100},dashboardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:30,paddingBottom:20,borderBottom:"1px solid #e0e0e0",marginTop:30},dashboardTitle:{fontSize:32,fontWeight:"bold",color:"#001a3a",margin:0},dashboardSubtitle:{fontSize:16,color:"#666",margin:"5px 0 0 0"},headerActions:{display:"flex",gap:10},loadingContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:60,textAlign:"center"},errorContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:60,textAlign:"center"},errorText:{color:"#d000fa",marginBottom:20,fontSize:16},metricsGrid:{marginBottom:30},metricCard:{backgroundColor:"#fff",borderRadius:12,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",border:"1px solid #e0e0e0",height:"100%",transition:"transform 0.2s ease, box-shadow 0.2s ease"},metricContent:{padding:"20px 16px",textAlign:"center"},metricHeader:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:12},metricIcon:{fontSize:20,marginRight:8,color:"#001a3a"},metricLabel:{fontSize:14,fontWeight:"600",color:"#666",textTransform:"uppercase",letterSpacing:"0.5px"},metricValue:{fontSize:36,fontWeight:"bold",color:"#001a3a",marginBottom:8},metricChange:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:12},positiveChange:{color:"#56d362",marginRight:4},negativeChange:{color:"#d000fa",marginRight:4},changeLabel:{color:"#999",fontSize:11,marginLeft:4},chartsGrid:{marginBottom:30},sectionTitle:{fontSize:24,fontWeight:"bold",color:"#001a3a",marginBottom:20,display:"flex",alignItems:"center",padding:"10px 0",borderBottom:"2px s
1olid #e0e0e0"},sectionIcon:{fontSize:24,marginRight:12,color:"#001a3a"}};function G(e){let{showHeader:t=!1,dashboardData:n,dashboardLoading:i,dashboardError:s,refreshDashboardData:l,lookbackMonths:d,setLookbackMonths:h}=e;const[u,x]=(0,o.useState)(!1),g=(0,o.useContext)(y.c),m=(null===g||void 0===g?void 0:g.userData)||null;(0,o.useEffect)(()=>{const e=setTimeout(()=>{x(!0)},2e3);return()=>clearTimeout(e)},[]);const p=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unknown";if(!e||"object"!==typeof e)return console.log(`No ${t} data available`),null;const n={};return Object.keys(e).forEach(t=>{const o=e[t];null!==o&&void 0!==o&&!isNaN(o)&&o>0&&(n[t]=o)}),n};if("loading"===m)return(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(r.W9,{children:(0,c.jsx)(L.A,{children:(0,c.jsxs)("div",{style:{marginTop:300},children:[u?(0,c.jsx)(r.KW,{src:"/assets/TUGRLogo.png",style:{width:200}}):null,(0,c.jsx)(L.A,{children:(0,c.jsx)(r.w2,{name:"dots"})})]})})})});const j=n;return(0,c.jsxs)(c.Fragment,{children:[t?(0,c.jsx)(W.A,{}):null,(0,c.jsx)(r.W9,{children:(0,c.jsxs)(w.A,{padding:10,maxWidth:1300,children:[(0,c.jsxs)("div",{style:P.dashboardHeader,children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("h1",{style:P.dashboardTitle,children:"Scoring Analytics"}),(0,c.jsx)("p",{style:P.dashboardSubtitle,children:"Scoring performance and stroke average analysis"})]}),(0,c.jsx)("div",{style:P.headerActions,children:(0,c.jsx)(E,{value:d,onChange:h})})]}),i?(0,c.jsxs)("div",{style:P.loadingContainer,children:[(0,c.jsx)(r.w2,{name:"dots"}),(0,c.jsx)("p",{children:"Loading scoring analytics..."})]}):s?(0,c.jsxs)("div",{style:P.errorContainer,children:[(0,c.jsx)("p",{style:P.errorText,children:s}),(0,c.jsx)(r.Jm,{onClick:l,children:"Retry"})]}):(0,c.jsx)(c.Fragment,{children:(0,c.jsxs)(r.lO,{style:P.chartsGrid,children:[(null===j||void 0===j?void 0:j.juniorBoysStats)&&(0,c.jsx)(J,{title:"Junior Boys Scoring Analytics",icon:a.wx_,stats:j.juniorBoysStats,validateStats:p,color:"#00a0ff"}),(null===j||void 0===j?void 0:j.juniorGirlsStats)&&(0,c.jsx)(J,{title:"Junior Girls Scoring Analytics",icon:a.wx_,stats:j.juniorGirlsStats,validateStats:p,color:"#EC4899"})]})})]})})]})}const J=e=>{var t;let{title:n,icon:o,stats:i,validateStats:s,color:l}=e;if(!i)return null;const d=s(i.grad_years,"graduation years");return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.ln,{children:(0,c.jsx)(r.hU,{size:"12",children:(0,c.jsxs)("h2",{style:P.sectionTitle,children:[(0,c.jsx)(r.iq,{icon:o,style:P.sectionIcon}),n]})})}),(null===(t=i.stroke_averages)||void 0===t?void 0:t.by_grad_year)&&(0,c.jsx)(r.ln,{children:(0,c.jsx)(r.hU,{size:"12",children:(0,c.jsxs)(r.b_,{style:P.chartCard,children:[(0,c.jsxs)(r.ME,{children:[(0,c.jsxs)(r.tN,{style:P.chartTitle,children:[(0,c.jsx)(r.iq,{icon:a.ROU,style:P.chartIcon}),"Median Stroke Average by Graduation Year"]}),(0,c.jsx)("p",{style:P.chartSubtitle,children:"Median stroke average for each graduation class"})]}),(0,c.jsx)(r.I9,{style:P.chartContent,children:(0,c.jsx)(B,{titles:Object.keys(i.stroke_averages.by_grad_year),values:[{name:"Median",data:Object.values(i.stroke_averages.by_grad_year).map(e=>e.median)}],name:" ",wholeNumber:!1,height:300,min:60,fixed:1,color:l})})]})})}),(0,c.jsx)(r.ln,{children:(0,c.jsx)(r.hU,{size:"12",children:(0,c.jsxs)(r.b_,{style:P.chartCard,children:[(0,c.jsx)(r.ME,{children:(0,c.jsxs)(r.tN,{style:P.chartTitle,children:[(0,c.jsx)(r.iq,{icon:a.ROU,style:P.chartIcon}),"Graduation Years Distribution"]})}),(0,c.jsx)(r.I9,{style:P.chartContent,children:d&&Object.keys(d).length>0?(0,c.jsx)(B,{titles:Object.keys(d),values:[{name:"Players",data:Object.values(d)}],name:" ",wholeNumber:!0,height:300,color:l}):(0,c.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:"No graduation year data available"})})]})})})]})},P={background:{width:"100%",height:500,background:"linear-gradient(to bottom right, #f7f7f7 50%, #fff 50%)",position:"absolute",top:0,left:0,zIndex:-1,textAlign:"center"},title:{fontSize:60,color:"#001a3a",marginTop:130},paragraph:{color:"#2d4665"},video:{width:"50%",height:300,backgroundColor:"gray",borderRadius:20,marginTop:100},dashboardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:30,paddingBottom:20,borderBottom:"1px solid #e0e0e0",marginTop:30},dashboardTitle:{fontSize:32,fontWeight:"bold",color:"#001a3a",margin:0},dashboardSubtitle:{fontSize:16,color:"#666",margin:"5px 0 0 0"},headerActions:{display:"flex",gap:10},loadingContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:60,textAlign:"center"},errorContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:60,textAlign:"center"},errorText:{color:"#d000fa",marginBottom:20,fontSize:16},metricsGrid:{marginBottom:30},metricCard:{backgroundColor:"#fff",borderRadius:12,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",border:"1px solid #e0e0e0",height:"100%",transition:"transform 0.2s ease, box-shadow 0.2s ease"},metricContent:{padding:"20px 16px",textAlign:"center"},metricHeader:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:12},metricIcon:{fontSize:20,marginRight:8,color:"#001a3a"},metricLabel:{fontSize:14,fontWeight:"600",color:"#666",textTransform:"uppercase",letterSpacing:"0.5px"},metricValue:{fontSize:36,fontWeight:"bold",color:"#001a3a",marginBottom:8},metricChange:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:12},positiveChange:{color:"#56d362",marginRight:4},negativeChange:{color:"#d000fa",marginRight:4},changeLabel:{color:"#999",fontSize:11,marginLeft:4},chartsGrid:{marginBottom:30},sectionTitle:{fontSize:24,fontWeight:"bold",color:"#001a3a",marginBottom:20,display:"flex",alignItems:"center",padding:"10px 0",borderBottom:"2px s
1olid #e0e0e0"},sectionIcon:{fontSize:24,marginRight:12,color:"#001a3a"},chartCard:{backgroundColor:"#fff",borderRadius:12,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",border:"1px solid #e0e0e0",height:"100%",transition:"transform 0.2s ease, box-shadow 0.2s ease"},chartTitle:{display:"flex",alignItems:"center",fontSize:18,fontWeight:"600",color:"#001a3a",margin:0},chartIcon:{fontSize:20,marginRight:8,color:"#001a3a"},chartContent:{padding:"20px 16px",minHeight:200},chartSubtitle:{fontSize:14,color:"#666",marginTop:8},strokeAveragesGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:"20px",marginTop:"10px"},strokeAverageCard:{backgroundColor:"#f8f9fa",borderRadius:"8px",padding:"16px",border:"1px solid #e9ecef"},gradYearTitle:{fontSize:"18px",fontWeight:"600",color:"#001a3a",margin:"0 0 12px 0",textAlign:"center"},strokeStats:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},strokeStat:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0"},statLabel:{fontSize:"12px",color:"#666",fontWeight:"500"},statValue:{fontSize:"14px",color:"#001a3a",fontWeight:"600"}};var q=n(4386);const Y=e=>{let{titles:t,values:n,name:o,wholeNumber:r=!0,colors:a=null,height:i=240}
1=e,l=a?{colors:a}:{colors:[s.T.green,s.T.blue]};if(!n||!n[0]||!n[0].data||!t)return(0,c.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:"No data available"});const d=n.map(e=>({...e,data:e.data.map(e=>null===e||void 0===e||isNaN(e)?0:e)})),h=d[0].data.map((e,t)=>({value:e,index:t})).sort((e,t)=>t.value-e.value).slice(0,10);let u={series:d.map(e=>({...e,data:h.map(t=>e.data[t.index])})),options:{chart:{animations:{enabled:!1,animateGradually:{enabled:!1},dynamicAnimation:{enabled:!1}},height:i,type:"bar",toolbar:{show:!1}},...l,plotOptions:{bar:{borderRadius:4,horizontal:!0,dataLabels:{position:"right"}}},stroke:{width:6,colors:["transparent"]},dataLabels:{enabled:!1,formatter:function(e){return 0===e?"":(0,O.X)(e,r?0:2)},style:{fontSize:"12px",colors:["#304758"]},offsetX:10},xaxis:{categories:h.map(e=>t[e.index]||"Unknown"),position:"bottom",axisBorder:{show:!1},axisTicks:{show:!1},grid:{show:!1},labels:{formatter:function(e){return(0,O.X)(e,r?0:2)}}},yaxis:{axisBorder:{show:!1},axisTicks:{show:!1},labels:{show:!0,style:{fontSize:"12px",colors:"#304758"}}},grid:{show:!1},title:{text:o||"",floating:!0,offsetY:i-20,align:"center",style:{color:"#444"}}}};return(0,c.jsx)("div",{id:"chart",children:(0,c.jsx)(T.A,{options:u.options,series:u.series,type:"bar",height:i,style:{marginBottom:-30,marginTop:-30,marginLeft:-10,marginRight:0}})})};var V=n(7298),K=n(6268);const X=e=>{let{statesData:t,generateChartColor:n,color:o="blue"}=e;if(!t)return null;const r={AL:"01",AK:"02",AS:"60",AZ:"04",AR:"05",CA:"06",CO:"08",CT:"09",DE:"10",DC:"11",FL:"12",FM:"64",GA:"13",GU:"66",HI:"15",ID:"16",IL:"17",IN:"18",IA:"19",KS:"20",KY:"21",LA:"22",ME:"23",MH:"68",MD:"24",MA:"25",MI:"26",MN:"27",MS:"28",MO:"29",MT:"30",NE:"31",NV:"32",NH:"33",NJ:"34",NM:"35",NY:"36",NC:"37",ND:"38",MP:"69",OH:"39",OK:"40",OR:"41",PW:"70",PA:"42",PR:"72",RI:"44",SC:"45",SD:"46",TN:"47",TX:"48",UM:"74",UT:"49",VT:"50",VA:"51",VI:"78",WA:"53",WV:"54",WI:"55",WY:"56"},a=(e,t)=>{if(0===e)return"#f8f9fa";const n=e/t;return"pink"===o||"#EC4899"===o?n<=.1?"#fce4ec":n<=.2?"#f8bbd9":n<=.3?"#f48fb1":n<=.4?"#f06292":n<=.5?"#ec407a":n<=.6?"#e91e63":n<=.7?"#d81b60":n<=.8?"#c2185b":n<=.9?"#ad1457":"#880e4f":n<=.1?"#e3f2fd":n<=.2?"#bbdefb":n<=.3?"#90caf9":n<=.4?"#64b5f6":n<=.5?"#42a5f5":n<=.6?"#2196f3":n<=.7?"#1e88e5":n<=.8?"#1976d2":n<=.9?"#1565c0":"#0d47a1"},i=Object.values(t),s=Math.max(...i,1),l={};return Object.keys(t).forEach(e=>{const n=r[e];n&&(l[n]={count:t[e],color:a(t[e],s),abbreviation:e})}),(0,c.jsx)(V.ComposableMap,{projection:"geoAlbersUsa",style:{marginTop:-20,marginBottom:-20,maxWidth:"100%",width:"100%",height:"auto"},children:(0,c.jsx)(V.Geographies,{geography:"states.json",children:e=>{let{geographies:t}=e;return(0,c.jsxs)(c.Fragment,{children:[t.map(e=>{const t=l[e.id],n=t?t.color:"#f8f9fa";return(0,c.jsx)(V.Geography,{stroke:"#FFF",strokeWidth:.5,geography:e,fill:n,style:{default:{outline:"none"},hover:{outline:"none",fill:t?t.color:"#e9ecef",stroke:"#000",strokeWidth:1},pressed:{outline:"none"}}},e.rsmKey)}),t.map(e=>{const t=l[e.id];if(!t||0===t.count)return null;const n=(0,K.A)(e);return(0,c.jsx)(V.Marker,{coordinates:n,children:(0,c.jsx)("text",{y:"2",fontSize:"10",textAnchor:"middle",fill:t.count>.5*s?"#FFF":"#000",fontWeight:"bold",children:t.count})},`${e.rsmKey}-label`)})]})}})})};function Z(e){let{showHeader:t=!1,dashboardData:n,dashboardLoading:i,dashboardError:s,refreshDashboardData:l,lookbackMonths:d,setLookbackMonths:h}=e;const[u,x]=(0,o.useState)(!1),g=(0,o.useContext)(y.c),m=(null===g||void 0===g?void 0:g.userData)||null;(0,o.useEffect)(()=>{const e=setTimeout(()=>{x(!0)},2e3);return()=>clearTimeout(e)},[]);const p=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unknown";if(!e||"object"!==typeof e)return console.log(`No ${t} data available`),null;const n={};return Object.keys(e).forEach(t=>{const o=e[t];null!==o&&void 0!==o&&!isNaN(o)&&o>0&&(n[t]=o)}),n},j=e=>{if(!e||"object"!==typeof e)return console.log("No state data available"),null;const t=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"],n={};return Object.keys(e).forEach(o=>{const r=e[o],a=o.toUpperCase().trim();null!==r&&void 0!==r&&!isNaN(r)&&r>0&&t.includes(a)&&(n[a]=r)}),n},f=e=>{const t=["#FF6B6B","#4ECDC4","#45B7D1","#96CEB4","#FFEAA7","#DDA0DD","#98D8C8","#F7DC6F","#BB8FCE","#85C1E9","#F8C471","#82E0AA","#F1948A","#85C1E9","#D7BDE2","#A9DFBF","#FAD7A0","#AED6F1","#D5A6BD","#A2D9CE"];return t[e%t.length]};if("loading"===m)return(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(r.W9,{children:(0,c.jsx)(L.A,{children:(0,c.jsxs)("div",{style:{marginTop:300},children:[u?(0,c.jsx)(r.KW,{src:"/assets/TUGRLogo.png",style:{width:200}}):null,(0,c.jsx)(L.A,{children:(0,c.jsx)(r.w2,{name:"dots"})})]})})})});const v=n;return(0,c.jsxs)(c.Fragment,{children:[t?(0,c.jsx)(W.A,{}):null,(0,c.jsx)(r.W9,{children:(0,c.jsxs)(w.A,{padding:10,maxWidth:1300,children:[(0,c.jsxs)("div",{style:ee.dashboardHeader,children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("h1",{style:ee.dashboardTitle,children:"Hometowns"}),(0,c.jsx)("p",{style:ee.dashboardSubtitle,children:"Geographic distribution and hometown analytics"})]}),(0,c.jsx)("div",{style:ee.headerActions,children:(0,c.jsx)(E,{value:d,onChange:h})})]}),i?(0,c.jsxs)("div",{style:ee.loadingContainer,children:[(0,c.jsx)(r.w2,{name:"dots"}),(0,c.jsx)("p",{children:"Loading hometowns data..."})]}):s?(0,c.jsxs)("div",{style:ee.errorContainer,children:[(0,c.jsx)("p",{style:ee.errorText,children:s}),(0,c.jsx)(r.Jm,{onClick:l,children:"Retry"})]}):(0,c.jsx)(c.Fragment,{children:(0,c.jsxs)(r.lO,{style:ee.chartsGrid,children:[(null===v||void 0===v?void 0:v.juniorBoysStats)&&(0,c.jsx)(Q,{title:"Junior Boys Hometown Analytics",icon:a.wx_,stats:v.juniorBoysStats,validateStats:p,validateStateData:j,generateChartColor:f,color:"#00a0ff"}),(null===v||void 0===v?void 0:v.juniorGirlsStats)&&(0,c.jsx)(Q,{title:"Junior Girls Hometown Analytics",icon:a.wx_,stats:v.juniorGirlsStats,validateStats:p,validateStateData:j,generateChartColor:f,color:"#EC4899"})]})})]})})]})}const Q=e=>{let{title:t,icon:n,stats:o,validateStats:i,validateStateData:s,generateChartColor:l,color:d}=e;if(!o)return null;const h=s(o.states),u=i(o.h_towns,"hometowns");return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.ln,{children:(0,c.jsx)(r.hU,{size:"12",children:(0,c.jsxs)("h2",{style:ee.sectionTitle,children:[(0,c.jsx)(r.iq,{icon:n,style:ee.sectionIcon}),t]})})}),(0,c.jsx)(r.ln,{children:(0,c.jsx)(r.hU,{size:"12",children:(0,c.jsxs)(r.b_,{style:ee.chartCard,children:[(0,c.jsxs)(r.ME,{children:[(0,c.jsxs)(r.tN,{style:ee.chartTitle,children:[(0,c.jsx)(r.iq,{icon:a.UN$,style:ee.chartIcon}),"States Map"]}),(0,c.jsx)("p",{style:ee.chartSubtitle,children:"Numbers show the count of players from each state"})]}),(0,c.jsx)(r.I9,{style:ee.chartContent,children:h&&Object.keys(h).length>0?(0,c.jsx)(X,{statesData:h,generateChartColor:l,color:d}):(0,c.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:"No states data available"})})]})})}),(0,c.jsxs)(r.ln,{children:[(0,c.jsx)(r.hU,{size:"12",sizeLg:"6",children:(0,c.jsxs)(r.b_,{style:ee.chartCard,children:[(0,c.jsx)(r.ME,{children:(0,c.jsxs)(r.tN,{style:ee.chartTitle,children:[(0,c.jsx)(r.iq,{icon:a.UN$,style:ee.chartIcon}),"States Distribution"]})}),(0,c.jsx)(r.I9,{style:ee.chartContent,children:h&&Object.keys(h).length>0?(0,c.jsx)(q.A,{inputData:h,tileColors:Object.keys(h).map((e,t)=>l(t))}):(0,c.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:"No states data available"})})]})}),(0,c.jsx)(r.hU,{size:"12",sizeLg:"6",children:(0,c.jsxs)(r.b_,{style:ee.chartCard,children:[(0,c.jsx)(r.ME,{children:(0,c.jsxs)(r.tN,{style:ee.chartTitle,children:[(0,c.jsx)(r.iq,{icon:a.UN$,style:ee.chartIcon}),"Top Hometowns"]})}),(0,c.jsx)(r.I9,{style:ee.chartContent,children:u&&Object.keys(u).length>0?(0,c.jsx)(Y,{titles:Object.keys(u),values:[{name:"Players",data:Object.values(u)}],name:"",wholeNumber:!0,height:300,colors:[d]}):(0,c.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:"No hometowns data available"})})]})})]})]})},ee={background:{width:"100%",height:500,background:"linear-gradient(to bottom right, #f7f7f7 50%, #fff 50%)",position:"absolute",top:0,left:0,zIndex:-1,textAlign:"center"},title:{fontSize:60,color:"#001a3a",marginTop:130},paragraph:{color:"#2d4665"},video:{width:"50%",height:300,backgroundColor:"gray",borderRadius:20,marginTop:100},dashboardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:30,paddingBottom:20,borderBottom:"1px solid #e0e0e0",marginTop:30},dashboardTitle:{fontSize:32,fontWeight:"bold",color:"#001a3a",margin:0},dashboardSubtitle:{fontSize:16,color:"#666",margin:"5px 0 0 0"},headerActions:{display:"flex",gap:10},loadingContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:60,textAlign:"center"},errorContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:60,textAlign:"center"},errorText:{color:"#d000fa",marginBottom:20,fontSize:16},chartsGrid:{marginBottom:30},sectionTitle:{fontSize:24,fontWeight:"bold",color:"#001a3a",marginBottom:20,display:"flex",alignItems:"center",padding:"10px 0",borderBottom:"2px s
1olid #e0e0e0"},sectionIcon:{fontSize:24,marginRight:12,color:"#001a3a"},chartCard:{backgroundColor:"#fff",borderRadius:12,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",border:"1px solid #e0e0e0",height:"100%",transition:"transform 0.2s ease, box-shadow 0.2s ease"},chartTitle:{display:"flex",alignItems:"center",fontSize:18,fontWeight:"600",color:"#001a3a",margin:0},chartIcon:{fontSize:20,marginRight:8,color:"#001a3a"},chartContent:{padding:"20px 16px",minHeight:200},chartSubtitle:{fontSize:14,color:"#666",marginTop:8}};function te(e){var t,n,i;let{showHeader:s=!1,dashboardData:l,dashboardLoading:d,dashboardError:h,refreshDashboardData:u,lookbackMonths:x,setLookbackMonths:g}=e;const[m,p]=(0,o.useState)(!1),[j,f]=(0,o.useState)(null),[v,b]=(0,o.useState)(!1),[C,S]=(0,o.useState)("boys"),[k,A]=(0,o.useState)("name"),[T,_]=(0,o.useState)("asc"),N=(0,o.useContext)(y.c),I=(null===N||void 0===N?void 0:N.userData)||null;(0,o.useEffect)(()=>{const e=setTimeout(()=>{p(!0)},2e3);return()=>clearTimeout(e)},[]);const R="boys"===C?(null===l||void 0===l||null===(t=l.juniorBoysStats)||void 0===t?void 0:t.courses)||{}:(null===l||void 0===l||null===(n=l.juniorGirlsStats)||void 0===n?void 0:n.courses)||{},D=Object.entries(R).sort((e,t)=>{var n,o,r,a,i,s;const[,l]=e,[,d]=t;let c,h;switch(k){case"name":c=(null===(n=l.name)||void 0===n?void 0:n.toLowerCase())||"",h=(null===(o=d.name)||void 0===o?void 0:o.toLowerCase())||"";break;case"location":c=(null===(r=l.location)||void 0===r?void 0:r.toLowerCase())||"",h=(null===(a=d.location)||void 0===a?void 0:a.toLowerCase())||"";break;case"tournament_count":c=l.tournament_count||0,h=d.tournament_count||0;break;case"median":c=l.overall_median||0,h=d.overall_median||0;break;case"average":c=l.total_rounds>0?l.total_strokes/l.total_rounds:0,h=d.total_rounds>0?d.total_strokes/d.total_rounds:0;break;case"rounds":c=l.total_rounds||0,h=d.total_rounds||0;break;default:c=(null===(i=l.name)||void 0===i?void 0:i.toLowerCase())||"",h=(null===(s=d.name)||void 0===s?void 0:s.toLowerCase())||""}return"asc"===T?c>h?1:-1:c<h?1:-1}),z=e=>{k===e?_("asc"===T?"desc":"asc"):(A(e),_("asc"))},O=e=>k!==e?"\u2195":"asc"===T?"\u2191":"\u2193";console.log("Dashboard Data:",l),console.log("Selected Gender:",C),console.log("Junior Boys Stats:",null===l||void 0===l?void 0:l.juniorBoysStats),console.log("Junior Girls Stats:",null===l||void 0===l?void 0:l.juniorGirlsStats),console.log("Courses Data:",R),console.log("Courses Data Keys:",Object.keys(R)),console.log("Courses Data Length:",Object.keys(R).length);const F=()=>{b(!1),f(null)};return"loading"===I?(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(r.W9,{children:(0,c.jsx)(L.A,{children:(0,c.jsxs)("div",{style:{marginTop:300},children:[m?(0,c.jsx)(r.KW,{src:"/assets/TUGRLogo.png",style:{width:200}}):null,(0,c.jsx)(L.A,{children:(0,c.jsx)(r.w2,{name:"dots"})})]})})})}):(0,c.jsxs)(c.Fragment,{children:[s?(0,c.jsx)(W.A,{}):null,(0,c.jsx)(r.W9,{children:(0,c.jsxs)(w.A,{padding:10,maxWidth:1300,children:[(0,c.jsxs)("div",{style:ne.dashboardHeader,children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("h1",{style:ne.dashboardTitle,children:"Courses"}),(0,c.jsx)("p",{style:ne.dashboardSubtitle,children:"Course performance and stroke average analytics"})]}),(0,c.jsx)("div",{style:ne.headerActions,children:(0,c.jsx)(E,{value:x,onChange:g})})]}),d?(0,c.jsxs)("div",{style:ne.loadingContainer,children:[(0,c.jsx)(r.w2,{name:"dots"}),(0,c.jsx)("p",{children:"Loading courses data..."})]}):h?(0,c.jsxs)("div",{style:ne.errorContainer,children:[(0,c.jsx)("p",{style:ne.errorText,children:h}),(0,c.jsx)(r.Jm,{onClick:u,children:"Retry"})]}):(0,c.jsx)(c.Fragment,{children:(0,c.jsxs)(r.b_,{style:ne.tableCard,children:[(0,c.jsx)(r.ME,{children:(0,c.jsxs)(r.tN,{style:ne.tableTitle,children:[(0,c.jsx)(r.iq,{icon:a.$bO,style:ne.tableIcon}),"boys"===C?"Junior Boys":"Junior Girls"," Course Performance Overview"]})}),(0,c.jsxs)(r.I9,{style:ne.tableContent,children:[(0,c.jsx)("div",{style:ne.genderToggleContainer,children:(0,c.jsxs)("div",{style:ne.genderToggle,children:[(0,c.jsxs)(r.Jm,{fill:"boys"===C?"solid":"outline",size:"small",onClick:()=>S("boys"),style:"boys"===C?ne.activeToggle:ne.inactiveToggle,children:[(0,c.jsx)(r.iq,{slot:"start",icon:a.wx_}),"Junior Boys"]}),(0,c.jsxs)(r.Jm,{fill:"girls"===C?"solid":"outline",size:"small",onClick:()=>S("girls"),style:"girls"===C?ne.activeToggle:ne.inactiveToggle,children:[(0,c.jsx)(r.iq,{slot:"start",icon:a.wx_}),"Junior Girls"]})]})}),Object.keys(R).length>0?(0,c.jsx)("div",{style:ne.tableContainer,children:(0,c.jsxs)("table",{style:ne.table,children:[(0,c.jsx)("thead",{children:(0,c.jsxs)("tr",{style:ne.tableHeaderRow,children:[(0,c.jsxs)("th",{style:ne.tableHeader,onClick:()=>z("name"),children:["Course Name ",O("name")]}),(0,c.jsxs)("th",{style:ne.tableHeader,onClick:()=>z("location"),children:["Location ",O("location")]}),(0,c.jsxs)("th",{style:ne.tableHeader,onClick:()=>z("tournament_count"),children:["Tournaments ",O("tournament_count")]}),(0,c.jsxs)("th",{style:ne.tableHeader,onClick:()=>z("median"),children:["MedScore ",O("median")]}),(0,c.jsxs)("th",{style:ne.tableHeader,onClick:()=>z("average"),children:["Avg Score ",O("average")]})]})}),(0,c.jsx)("tbody",{children:D.map(e=>{var t;let[n,o]=e;return(0,c.jsxs)("tr",{style:ne.tableRow,onClick:()=>(e=>{f(e),b(!0)})(n),children:[(0,c.jsx)("td",{style:ne.tableCell,children:(0,c.jsx)("div",{style:ne.courseName,children:o.name})}),(0,c.jsx)("td",{style:ne.tableCell,children:(0,c.jsxs)("div",{style:ne.location,children:[(0,c.jsx)(r.iq,{icon:a.UN$,style:ne.locationIcon}),o.location]})}),(0,c.jsx)("td",{style:ne.tableCell,children:(0,c.jsx)(r.In,{color:"primary",style:ne.badge,children:o.tournament_count})}),(0,c.jsx)("td",{style:ne.tableCell,children:(0,c.jsx)("div",{style:ne.strokeValue,children:(null===(t=o.overall_median)||void 0===t?void 0:t.toFixed(1))||"N/A"})}),(0,c.jsx)("td",{style:ne.tableCell,children:(0,c.jsx)("div",{style:ne.strokeValue,children:o.total_rounds>0?(o.total_strokes/o.total_rounds).toFixed(1):"N/A"})})]},n)})})]})}):null]})]})})]})}),(0,c.jsxs)(r.Sb,{isOpen:v,onDidDismiss:F,style:ne.modal,children:[(0,c.jsx)(r.eU,{children:(0,c.jsxs)(r.ai,{children:[(0,c.jsxs)(r.BC,{children:[j&&(null===(i=R[j])||void 0===i?void 0:i.name)," - ","boys"===C?"Junior Boys":"Junior Girls"]}),(0,c.jsx)(r.Jm,{slot:"end",fill:"clear",onClick:F,children:(0,c.jsx)(r.iq,{icon:a.xfX})})]})}),(0,c.jsx)(r.W9,{children:j&&R[j]&&(0,c.jsx)("div",{style:ne.modalContent,children:(0,c.jsxs)(r.b_,{style:ne.modalCard,children:[(0,c.jsx)(r.ME,{children:(0,c.jsxs)(r.tN,{style:ne.modalCardTitle,children:[(0,c.jsx)(r.iq,{icon:a.IEp,style:ne.modalIcon}),"Median Stroke Average by Graduation Year"]})}),(0,c.jsx)(r.I9,{children:R[j].by_grad_year&&Object.keys(R[j].by_grad_year).length>0?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(B,{titles:Object.keys(R[j].by_grad_year),values:[{name:"Median",data:Object.values(R[j].by_grad_year).map(e=>e.median)}],name:" ",wholeNumber:!1,height:300,min:60,fixed:1,color:"#00a0ff"}),(0,c.jsx)("div",{style:ne.tableContainer,children:(0,c.jsxs)("table",{style:ne.gradYearTable,children:[(0,c.jsx)("thead",{children:(0,c.jsxs)("tr",{style:ne.tableHeaderRow,children:[(0,c.jsx)("th",{style:ne.tableHeader,children:"Graduation Year"}),(0,c.jsx)("th",{style:{...ne.tableHeader,textAlign:"right"},children:"Median"})]})}),(0,c.jsx)("tbody",{children:Object.entries(R[j].by_grad_year).map(e=>{var t;let[n,o]=e;return(0,c.jsxs)("tr",{style:ne.tableRow,children:[(0,c.jsxs)("td",{style:ne.gradYearCell,children:["Class of ",n]}),(0,c.jsx)("td",{style:ne.medianCell,children:null===(t=o.median)||void 0===t?void 0:t.toFixed(1)})]},n)})})]})})]}):(0,c.jsx)("div",{style:ne.noDataContainer,children:(0,c.jsx)("p",{children:"No graduation year data available for this course"})})})]})})})]})]})}const ne={background:{width:"100%",height:500,background:"linear-gradient(to bottom right, #f7f7f7 50%, #fff 50%)",position:"absolute",top:0,left:0,zIndex:-1,textAlign:"center"},title:{fontSize:60,color:"#001a3a",marginTop:130},paragraph:{color:"#2d4665"},video:{width:"50%",height:300,backgroundColor:"gray",borderRadius:20,marginTop:100},dashboardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:30,paddingBottom:20,borderBottom:"1px solid #e0e0e0",marginTop:30},dashboardTitle:{fontSize:32,fontWeight:"bold",color:"#001a3a",margin:0},dashboardSubtitle:{fontSize:16,color:"#666",margin:"5px 0 0 0"},headerActions:{display:"flex",gap:10},loadingContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:60,textAlign:"center"},errorContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:60,textAlign:"center"},errorText:{color:"#d000fa",marginBottom:20,fontSize:16},tableCard:{backgroundColor:"#fff",borderRadius:12,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",border:"1px solid #e0e0e0",marginBottom:30},tableTitle:{display:"flex",alignItems:"center",fontSize:20,fontWeight:"600",color:"#001a3a",margin:0},tableIcon:{fontSize:22,marginRight:10,color:"#001a3a"},tableContent:{padding:"20px 16px"},tableContainer:{overflowX:"auto"},table:{width:"100%",borderCollapse:"collapse",fontSize:14}
1,tableHeaderRow:{backgroundColor:"#f8f9fa",borderBottom:"2px solid #e9ecef"},tableHeader:{padding:"12px 16px",textAlign:"left",fontWeight:"600",color:"#495057",fontSize:13,textTransform:"uppercase",letterSpacing:"0.5px"},tableRow:{borderBottom:"1px solid #e9ecef",transition:"background-color 0.2s ease"},tableCell:{padding:"16px",verticalAlign:"middle"},gradYearCell:{padding:"16px",verticalAlign:"middle",fontWeight:"600",color:"#001a3a",fontSize:15},medianCell:{padding:"16px",verticalAlign:"middle",fontWeight:"600",color:"#001a3a",fontSize:15,textAlign:"right"},courseName:{fontWeight:"600",color:"#001a3a",fontSize:15},location:{display:"flex",alignItems:"center",color:"#666",fontSize:14},locationIcon:{fontSize:16,marginRight:6,color:"#666"},badge:{fontSize:12,fontWeight:"600"},strokeValue:{fontWeight:"600",color:"#001a3a",fontSize:15},roundsValue:{color:"#666",fontSize:14},noDataContainer:{textAlign:"center",padding:40,color:"#666"},modal:{"--width":"90%","--max-width":"800px","--height":"80%","--border-radius":"12px"},modalContent:{padding:20},modalCard:{backgroundColor:"#fff",borderRadius:12,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",border:"1px solid #e0e0e0"},modalCardTitle:{display:"flex",alignItems:"center",fontSize:18,fontWeight:"600",color:"#001a3a",margin:0},modalIcon:{fontSize:20,marginRight:8,color:"#001a3a"},gradYearTable:{width:"100%",borderCollapse:"collapse",fontSize:14,marginTop:20},genderToggleContainer:{marginTop:-20,display:"flex",marginBottom:20},genderToggle:{display:"flex",gap:10},activeToggle:{"--background":"#001a3a","--background-activated":"#001a3a","--color":"#fff","--color-activated":"#fff"},inactiveToggle:{"--background":"transparent","--background-activated":"transparent","--color":"#666","--color-activated":"#666"}};var oe=n(3522);const re={menuitem:{borderRadius:50,backgroundColor:"transparent"},activeMenuitem:{color:s.T.orangeDeep,fontWeight:"600"},menuicon:{fontSize:16,marginRight:14},activeMenuIcon:{color:s.T.orangeDeep},menulabel:{}},ae=()=>{const{userData:e}=(0,o.useContext)(y.c),[t,n]=(0,o.useState)(!1),[s,h]=(0,o.useState)([]),[u,x]=(0,o.useState)(null),[m,p]=(0,o.useState)(!0),[j,f]=(0,o.useState)(!1),[v,b]=(0,o.useState)(null),[C,k]=(0,o.useState)(!1),[w,A]=(0,o.useState)(null),[T,_]=(0,o.useState)(18),N=(0,i.zy)(),I=()=>{n(!t)},R=e=>N.pathname===e?{...re.menuitem,...re.activeMenuitem}:re.menuitem,D=e=>N.pathname===e?{...re.menuicon,...re.activeMenuIcon}:re.menuicon,L=(0,o.useCallback)(async()=>{try{const{data:n}=await g.A.get("/tour/user-authorized-tours",{params:{customerId:e._id}});console.log("Fetched tours:",n);const o=n.sort((e,t)=>e.tour_name.localeCompare(t.tour_name));h(o);const r=localStorage.getItem("activeTour");if(r)try{const e=JSON.parse(r),t=o.find(t=>t.tour===e.tour);if(t)return x(t),void p(!1)}catch(t){console.error("Error parsing stored active tour:",t)}x(o[0]),p(!1)}catch(t){console.error("Error fetching tours:",t),p(!1)}},[e]);(0,o.useEffect)(()=>{e&&e._id&&(console.log("Fetching tours for user:",e._id),L())},[e,L]),(0,o.useEffect)(()=>{u&&localStorage.setItem("activeTour",JSON.stringify(u))},[u]);const W=(0,o.useCallback)(async()=>{if(u&&u.tour&&e&&e._id){k(!0),A(null);try{const e=await g.A.get("/tour/dashboard",{params:{tour:u.tour,lookbackMonths:T}});b(e.data)}catch(o){var t,n;A((null===(t=o.response)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.message)||"Failed to load dashboard data")}finally{k(!1)}}},[u,e,T]);return(0,o.useEffect)(()=>{u&&u.tour&&e&&e._id&&W()},[u,e,T,W]),m||0!==s.length?(0,c.jsxs)(r.AO,{children:[(0,c.jsxs)(l.m,{children:[(0,c.jsx)("title",{children:"TUGR Tools for Tours"}),(0,c.jsx)("meta",{name:"description",content:"The best way to get data on your tournaments and players."}),(0,c.jsx)("link",{rel:"canonical",href:"https://tugr.org/tour"}),(0,c.jsx)("style",{children:"\n #tour-select-button:focus {\n outline: none !important;\n box-shadow: none !important;\n }\n #tour-select-button:active {\n outline: none !important;\n box-shadow: none !important;\n }\n #tour-select-button * {\n pointer-events: none;\n }\n "})]}),(0,c.jsxs)(d.k,{componentName:"Tours",children:[(0,c.jsxs)(r.HP,{contentId:"main-content",children:[(0,c.jsx)(r.oS,{className:"fixed-width-menu",contentId:"main-content",type:"overlay",side:"start",menuId:"first",isOpen:t,children:(0,c.jsxs)(r.W9,{children:[(0,c.jsx)(r.gf,{routerLink:"/",children:(0,c.jsx)("div",{style:{display:"flex"},children:(0,c.jsx)("div",{style:{margin:16,marginTop:20},children:(0,c.jsx)(r.KW,{src:"/assets/TUGRLogo_grey.png",style:{height:23}})})})}),(0,c.jsx)("div",{style:{display:"flex"},children:(0,c.jsx)("div",{style:{background:"linear-gradient(90deg,rgb(255, 140, 73),rgb(208, 0, 250) 114.68%)",borderRadius:20,margin:16,textAlign:"center",color:"white",fontSize:11,padding:4,fontWeight:"500",paddingLeft:10,paddingRight:10,marginTop:-10},children:"TUGR Tour Tools"})}),(0,c.jsx)(r.nf,{lines:"none",children:(0,c.jsxs)(r.cA,{autoHide:!1,children:[(0,c.jsxs)(r.uz,{button:!0,routerLink:"/tour",routerDirection:"none",onClick:I,style:R("/tour"),children:[(0,c.jsx)(r.iq,{slot:"start",icon:a.Ud0,style:D("/tour")}),(0,c.jsx)(r.he,{children:"Home"})]}
1),(0,c.jsxs)(r.uz,{button:!0,routerLink:"/tour/tournaments",routerDirection:"none",onClick:I,style:R("/tour/tournaments"),children:[(0,c.jsx)(r.iq,{slot:"start",icon:a.$bO,style:D("/tour/tournaments")}),(0,c.jsx)(r.he,{children:"Tournaments"})]}),(0,c.jsxs)(r.uz,{button:!0,routerLink:"/tour/scoring",routerDirection:"none",onClick:I,style:R("/tour/scoring"),children:[(0,c.jsx)(r.iq,{slot:"start",icon:a.MrY,style:D("/tour/scoring")}),(0,c.jsx)(r.he,{children:"Scoring"})]}),(0,c.jsxs)(r.uz,{button:!0,routerLink:"/tour/hometowns",routerDirection:"none",onClick:I,style:R("/tour/hometowns"),children:[(0,c.jsx)(r.iq,{slot:"start",icon:a.UN$,style:D("/tour/hometowns")}),(0,c.jsx)(r.he,{children:"Hometowns"})]}),(0,c.jsxs)(r.uz,{button:!0,routerLink:"/tour/courses",routerDirection:"none",onClick:I,style:R("/tour/courses"),children:[(0,c.jsx)(r.iq,{slot:"start",icon:a.ROU,style:D("/tour/courses")}),(0,c.jsx)(r.he,{children:"Courses"})]})]})})]})}),(0,c.jsxs)("div",{className:"ion-page",id:"main-content",children:[!N.pathname.startsWith("/recruiting/tournaments")&&(0,c.jsx)(r.eU,{children:(0,c.jsxs)(r.ai,{color:"white",children:[(0,c.jsx)(r.QW,{slot:"start",children:(0,c.jsx)(r.MC,{color:"dark",style:{color:"black"}})}),(0,c.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",paddingRight:"16px"},children:[(0,c.jsx)(r.BC,{children:u?(0,oe.C)(u.tour_name):"Tours Tools"}),s.length>1&&(0,c.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"#f8f9fa",borderRadius:"8px",padding:"8px 12px",border:"1px solid #e9ecef",cursor:"pointer",transition:"all 0.2s ease",outline:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onClick:()=>f(!0),id:"tour-select-button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),f(!0))},onMouseEnter:e=>{e.target.style.background="#f1f3f4",e.target.style.borderColor="#dee2e6"},onMouseLeave:e=>{e.target.style.background="#f8f9fa",e.target.style.borderColor="#e9ecef"},onFocus:e=>{e.target.style.outline="none"},onBlur:e=>{e.target.style.outline="none"},children:[(0,c.jsx)("span",{style:{fontSize:"14px",fontWeight:"500",color:"#495057",marginRight:"8px"},children:"Switch Tour"}),(0,c.jsx)(r.iq,{icon:a.SJM,style:{fontSize:"16px",color:"#6c757d",transition:"transform 0.2s ease",transform:j?"rotate(180deg)":"rotate(0deg)"}})]})]})]})}),(0,c.jsx)(r.W9,{children:(0,c.jsxs)(i.dO,{children:[(0,c.jsx)(i.qh,{exact:!0,path:"/tour",render:e=>(0,c.jsx)($,{...e,activeTour:u,dashboardData:v,dashboardLoading:C,dashboardError:w,refreshDashboardData:W,lookbackMonths:T,setLookbackMonths:_})}),(0,c.jsx)(i.qh,{exact:!0,path:"/tour/tournaments",render:e=>(0,c.jsx)(S,{...e,removeHeader:!0,activeTour:u,removeTours:!0})}),(0,c.jsx)(i.qh,{exact:!0,path:"/tour/scoring",render:e=>(0,c.jsx)(G,{...e,activeTour:u,dashboardData:v,dashboardLoading:C,dashboardError:w,refreshDashboardData:W,lookbackMonths:T,setLookbackMonths:_})}),(0,c.jsx)(i.qh,{exact:!0,path:"/tour/hometowns",render:e=>(0,c.jsx)(Z,{...e,activeTour:u,dashboardData:v,dashboardLoading:C,dashboardError:w,refreshDashboardData:W,lookbackMonths:T,setLookbackMonths:_})}),(0,c.jsx)(i.qh,{exact:!0,path:"/tour/courses",render:e=>(0,c.jsx)(te,{...e,activeTour:u,dashboardData:v,dashboardLoading:C,dashboardError:w,refreshDashboardData:W,lookbackMonths:T,setLookbackMonths:_})}),(0,c.jsx)(i.qh,{path:"/tour/tournaments/:id",render:e=>(0,c.jsx)(z,{...e,activeTour:u})})]})})]})]}),(0,c.jsx)(r.CF,{isOpen:j,onDidDismiss:()=>f(!1),trigger:"tour-select-button",side:"bottom",alignment:"end",style:{"--width":"280px","--background":"white","--border-radius":"12px","--box-shadow":"0 10px 40px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1)","--backdrop-opacity":"0.4"},children:(0,c.jsxs)(r.W9,{style:{"--padding-top":"8px","--padding-bottom":"8px"},children:[(0,c.jsx)("div",{style:{padding:"12px 16px",borderBottom:"1px solid #f1f3f4",marginBottom:"8px"},children:(0,c.jsx)("span",{style:{fontSize:"16px",fontWeight:"600",color:"#1a1a1a"},children:"Select Tour"})}),(0,c.jsx)(r.nf,{style:{"--padding-start":"0","--padding-end":"0","--border-radius":"12px"},children:s.map(e=>(0,c.jsx)(r.uz,{button:!0,onClick:()=>{(e=>{console.log(e);const t=s.find(t=>{var n;return(null===(n=t.tour_name)||void 0===n?void 0:n.toLowerCase())===e.toLowerCase()});console.log("Selected tour:",t),t?(x(t),console.log("Active tour updated to:",t.tour_name)):console.log("Tour not found in authorized tours")})(e.tour_name),f(!1)}
1,style:{"--padding-start":"16px","--padding-end":"16px","--background":(null===u||void 0===u?void 0:u.tour_name)===e.tour_name?"#f8f9fa":"transparent","--color":(null===u||void 0===u?void 0:u.tour_name)===e.tour_name?"#1a1a1a":"#495057","--font-weight":(null===u||void 0===u?void 0:u.tour_name)===e.tour_name?"800":"400","--border-radius":"0","--min-height":"48px"},children:(0,c.jsx)(r.he,{style:{fontSize:"14px",lineHeight:"1.4",fontWeight:(null===u||void 0===u?void 0:u.tour_name)===e.tour_name?"800":"400"},children:(0,oe.C)(e.tour_name)})},e._id))})]})})]})]}):(0,c.jsxs)(r.AO,{children:[(0,c.jsxs)(l.m,{children:[(0,c.jsx)("title",{children:"TUGR Tools for Tours"}),(0,c.jsx)("meta",{name:"description",content:"The best way to get data on your tournaments and players."}),(0,c.jsx)("link",{rel:"canonical",href:"https://tugr.org/tour"})]}),(0,c.jsx)(d.k,{componentName:"Tours",children:(0,c.jsx)(r.W9,{children:(0,c.jsx)($,{})})})]})}},2658(e,t,n){n.r(t),n.d(t,{default:()=>v});n(9950);var o=n(5840),r=n(4279),a=n(1644),i=n(3685),s=n(4414);function l(e){var t,n,l;let{t:d,lines:c,inputStyle:h={}}=e;return(0,s.jsxs)(o.uz,{lines:c,style:h,children:[(0,s.jsxs)(o.he,{class:"ion-text-wrap",style:{marginRight:2},children:[(0,s.jsx)("p",{style:{fontSize:12,marginTop:0,color:"grey"},children:null===d||void 0===d||null===(t=d.rounds)||void 0===t?void 0:t.map((e,t)=>0===t?d.rounds.length>1?(0,a.iu)(new Date((null===e||void 0===e?void 0:e.round_date)||(null===e||void 0===e?void 0:e.wd_date))):(0,a.c6)(new Date((null===e||void 0===e?void 0:e.round_date)||(null===e||void 0===e?void 0:e.wd_date))):t===d.rounds.length-1?" - "+(0,a.c6)(new Date((null===e||void 0===e?void 0:e.round_date)||(null===e||void 0===e?void 0:e.wd_date))):null)}),(0,s.jsx)("div",{children:null===d||void 0===d||null===(n=d.rounds)||void 0===n?void 0:n.map((e,t)=>{var n;return 0===t?(0,s.jsx)("div",{style:{display:"inline-block",fontSize:12,marginTop:0,paddingLeft:8,paddingRight:8,color:"white",backgroundColor:(0,a.LH)(null===e||void 0===e?void 0:e.tour),borderRadius:14},children:null===e||void 0===e||null===(n=e.tour)||void 0===n?void 0:n.toUpperCase()},t):null})})]}),(0,s.jsx)(o.he,{slot:"end",style:{marginRight:2,marginLeft:6},children:(0,s.jsxs)(i.A,{children:[(0,s.jsx)("span",{style:{minWidth:50,display:"block"}}),(0,s.jsx)("span",{style:{marginBottom:6,fontSize:24,color:(null===d||void 0===d?void 0:d.tournamentScore)<0?"red":0===(null===d||void 0===d?void 0:d.tournamentScore)?"green":"black",display:"block"},children:null!==d&&void 0!==d&&d.withdrawal?(0,s.jsx)("span",{style:{color:r.T.red},children:"WD"}):(0,s.jsxs)(s.Fragment,{children:[(null===d||void 0===d?void 0:d.tournamentScore)>0?"+":"",0===(null===d||void 0===d?void 0:d.tournamentScore)?"E":null===d||void 0===d?void 0:d.tournamentScore]})}),(0,s.jsx)("span",{style:{display:"block",fontSize:14},children:null===d||void 0===d||null===(l=d.rounds)||void 0===l?void 0:l.map((e,t)=>(t>0?"-":"")+(e.st18||(e.withdrawal?"WD":"")))})]})})]})}var d=n(8392);let c={height:20,width:20,justifyContent:"center",alignItems:"center",display:"flex",borderRadius:4},h={backgroundColor:r.T.blue50},u={backgroundColor:r.T.green25},x={backgroundColor:r.T.red25},g={backgroundColor:r.T.orange75};function m(e){let{score:t,par:n,name:o}=e,r={},a=t-n;return"sf9"===o||"sb9"===o||"st18"===o?r={fontWeight:"600"}:a<-1?r={...c,...h}:-1===a?r={...c,...u}:1===a?r={...c,...x}:a>1&&(r={...c,...g}),(0,s.jsx)("div",{style:r,children:t})}const p={display:"flex",alignItems:"center",marginRight:"10px"},j={width:12,height:12,borderRadius:4,marginRight:"5px"};function f(){let e=[{label:"Eagle or less",color:r.T.blue50},{label:"Birdie",color:r.T.green25},{label:"Bogey",color:r.T.red25},{label:"Double or more",color:r.T.orange75}];return(0,s.jsx)("div",{style:{marginTop:"10px",display:"flex",flexWrap:"wrap",marginLeft:4},children:e.map(e=>0===e.value?null:(0,s.jsxs)("div",{style:p,children:[(0,s.jsx)("div",{style:{...j,backgroundColor:e.color}}),(0,s.jsx)("span",{style:{fontSize:11,color:"grey"},children:e.label.toUpperCase()})]},`${e.label}-legend`))})}const v=e=>{var t,n,c;let{tournament:h,player:u,showProfileLink:x,navigateToLink:g,showNavigateToTournament:p,navigateToTournament:j}=e;console.log(h);const v=[1,2,3,4,5,6,7,8,9,"F9",10,11,12,13,14,15,16,17,18,"B9","TOT"],y=[1,2,3,4,5,6,7,8,9,"f9",10,11,12,13,14,15,16,17,18,"b9","t18"],b={overflowX:"auto",whiteSpace:"nowrap"},C={flexWrap:"nowrap"},S={flexWrap:"nowrap",fontWeight:"600"},k={flexWrap:"nowrap"},w={width:"auto",flex:"0 0 auto",display:"flex",justifyContent:"center",alignItems:"center",height:30,fontSize:12};if(!h)return null;let A=!1;return null===h||void 0===h||null===(t=h.rounds)||void 0===t||t.forEach((e,t)=>{var n;0===t&&("AJGA"===(null===e||void 0===e||null===(n=e.tour)||void 0===n?void 0:n.toUpperCase())&&(A=!0))}),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("br",{}),(0,s.jsx)("h3",{style:{margin:4,textAlign:"center"},children:null===h||void 0===h||null===(n=h.name)||void 0===n?void 0:n.toUpperCase()}),(0,s.jsxs)("h5",{style:{margin:4,color:r.T.green,textAlign:"center"},children:[null===u||void 0===u?void 0:u.first_name," ",null===u||void 0===u?void 0:u.last_name]}),x&&(0,s.jsx)("div",{style:{textAlign:"center",marginBottom:"10px"},children:(0,s.jsx)(o.Jm,{fill:"outline",color:"primary",onClick:()=>{g(u.player_id)},children:"View Full Profile"})}),(0,s.jsx)(l,{t:h,lines:"none",inputStyle:{marginRight:10}}),p&&(0,s.jsx)("div",{style:{textAlign:"center",marginBottom:10},children:(0,s.jsx)(o.Jm,{onClick:()=>j(h),children:"View Tournament"})}),A&&(0,s.jsx)("div",{style:{backgroundColor:r.T.green05,margin:20,borderRadius:12,border:`1px solid ${r.T.green25}
1`,boxShadow:"0 2px 8px rgba(18, 120, 75, 0.1)"},children:(0,s.jsx)(i.A,{children:(0,s.jsxs)("div",{style:{margin:24,textAlign:"center",maxWidth:400},children:[(0,s.jsx)(o.iq,{icon:d.Yv$,style:{fontSize:48,marginBottom:16,color:r.T.green}}),(0,s.jsx)("h3",{style:{fontSize:18,fontWeight:600,color:r.T.green,margin:"0 0 8px 0",lineHeight:1.3},children:"AJGA Tournament"}),(0,s.jsx)("p",{style:{fontSize:14,color:"#666",margin:0,lineHeight:1.4},children:"Hole-by-hole scoring is not available for AJGA tournaments. Only round totals are provided."})]})})}),!A&&(null===h||void 0===h||null===(c=h.rounds)||void 0===c?void 0:c.map((e,t)=>e.withdrawal?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("br",{}),(0,s.jsxs)("h6",{children:["Round ",t+1]}),(0,s.jsx)("div",{style:{backgroundColor:r.T.grey25,margin:20,borderRadius:10},children:(0,s.jsx)(i.A,{children:(0,s.jsx)("div",{style:{margin:20,fontSize:20,color:"grey"},children:(0,s.jsx)("h2",{children:"WD"})})})})]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("br",{}),(0,s.jsxs)("div",{style:{marginLeft:4},children:[(0,s.jsxs)("h6",{children:["Round ",null===e||void 0===e?void 0:e.round]}),(0,s.jsx)("p",{style:{marginTop:-10,fontSize:11,color:"grey",marginLeft:1},children:(0,a.c6)(new Date(null===e||void 0===e?void 0:e.round_date))})]}),(0,s.jsxs)(o.lO,{style:b,children:[(0,s.jsxs)(o.ln,{style:S,children:[(0,s.jsx)(o.hU,{style:{...w,aspectRatio:"1 / 1",width:55,borderBottom:"2px solid #d6d6d6",borderTop:"2px solid #d6d6d6",borderRight:"1px solid #d6d6d6",justifyContent:"left"},children:"HOLE"},"hole"),v.map((e,t)=>(0,s.jsx)(o.hU,{style:{...w,aspectRatio:"1 / 1",borderBottom:"2px solid #d6d6d6",borderTop:"2px solid #d6d6d6"},children:e},t))]}),(0,s.jsxs)(o.ln,{style:C,children:[(0,s.jsx)(o.hU,{style:{...w,aspectRatio:"1 / 1",width:55,borderRight:"1px solid #d6d6d6",justifyContent:"left"},children:"Par"},"par"),y.map((t,n)=>(0,s.jsx)(o.hU,{style:{...w,aspectRatio:"1 / 1"},children:e[`p${t}`]||""},n))]}),(0,s.jsxs)(o.ln,{style:k,children:[(0,s.jsx)(o.hU,{style:{...w,aspectRatio:"1 / 1",width:55,borderRight:"1px solid #d6d6d6",borderBottom:"1px solid #d6d6d6",justifyContent:"left",backgroundColor:r.T.grey25},children:"Score"},"score"),y.map((t,n)=>(0,s.jsx)(o.hU,{style:{...w,aspectRatio:"1 / 1",borderBottom:"1px solid #d6d6d6",backgroundColor:r.T.grey25},children:(0,s.jsx)(m,{score:e[`s${t}`]||"",par:e[`p${t}`],name:`s${t}`})},n))]})]}),(0,s.jsx)(f,{})]},(null===e||void 0===e?void 0:e.round)+"-round"))),(0,s.jsx)("br",{}),(0,s.jsx)("br",{}),(0,s.jsx)("br",{})]})}},3522(e,t,n){n.d(t,{C:()=>o});const o=e=>e?e.toLowerCase().includes("us kids golf foundation")?"U.S. Kids Golf Foundation":e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):""},4386(e,t,n){n.d(t,{A:()=>c});var o=n(9026),r=n(4619),a=n(3685),i=n(1644),s=n(4414);const l={display:"flex",alignItems:"center",marginRight:"10px",fontSize:13},d={width:7,height:7,borderRadius:"50%",marginRight:"5px"},c=e=>{let{inputData:t,tourFullnames:n,tileColors:c=null,player:h={_id:"test"}}=e,u=[];if(n&&(u=Object.keys(n)),!t)return null;const x={};if(Object.keys(t).forEach(e=>{const n=t[e];null!==n&&void 0!==n&&!isNaN(n)&&n>0&&(x[e]=n)}),0===Object.keys(x).length)return(0,s.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:"No data available"});const g=Object.keys(x).map((e,t)=>({name:null===e||void 0===e?void 0:e.toUpperCase(),value:x[e],fullName:u[t]||(null===e||void 0===e?void 0:e.toUpperCase()),color:c?c[t]:(0,i.LH)(e)})),m=g.map(e=>e.value),p={labels:g.map(e=>e.name),colors:g.map(e=>e.color),legend:{show:!1},dataLabels:{enabled:!0,style:{fontSize:"9px"}},tooltip:{y:{formatter:function(e){return(0,o.X)(e,1,"%")}}},plotOptions:{pie:{donut:{labels:{show:!1,name:{show:!0},value:{show:!0,formatter:function(e){return(0,o.X)(e,1,"%")}}}}}}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.A,{children:(0,s.jsx)(r.A,{options:p,series:m,type:"donut",width:230},(null===h||void 0===h?void 0:h._id)+"ApedChart")}),(0,s.jsx)("div",{style:{marginTop:"10px",display:"flex",flexWrap:"wrap"},children:null===g||void 0===g?void 0:g.map(e=>0===e.value?null:(0,s.jsxs)("div",{title:e.fullName,style:l,children:[(0,s.jsx)("div",{style:{...d,backgroundColor:e.color}}),(0,s.jsx)("span",{children:e.name})]},`${e.name}-legend`))})]})}},5374(e,t,n){n.d(t,{A:()=>i});n(9950);var o=n(4414);let r={height:40,backgroundColor:"white",paddingLeft:10,paddingRight:10,justifyContent:"center",alignItems:"center",display:"flex",cursor:"pointer",minWidth:"fit-content"};function a(e){let{name:t,isActive:n,index:a,handleClick:i}=e;return(0,o.jsx)("div",{style:{...r,borderBottom:"3px solid "+(n?"#439683":"transparent")},onClick:()=>{i(a)},children:t})}function i(e){let{buttons:t,tabNameUpdated:n,activeTab:r}=e;const i=r?t.findIndex(e=>e.name===r):0;function s(e){n(t[e].name)}return(0,o.jsx)("div",{style:{overflowX:"auto",backgroundColor:"white",boxShadow:"0px 4px 6px -2px rgba(0, 0, 0, 0.1)"},children:(0,o.jsx)("div",{style:{display:"flex",flexDirection:"row",maxWidth:"100%"},children:null===t||void 0===t?void 0:t.map((e,t)=>(0,o.jsx)(a,{name:e.name,index:t,isActive:t===i,handleClick:s},t))})})}},9026(e,t,n){n.d(t,{X:()=>r,s:()=>o});const o=e=>{if("number"===typeof e)return Number.isFinite(e)?e:null;if("string"===typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null},r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const r=o(e);return null===r?"":`${r.toFixed(t)}${n}`}}}]);
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.