PageSourceSearch

https://bowtiesports.com/assets/StatsManagement-uSPfFHCs.js

js bowtiesports.com collected 2026-10-07 02:29:20 UTC 29,198 bytes, 1 lines download raw bytes

1import{r as p,j as e}from"./react-vendor-DUhHROXo.js";import{_ as Y,J as k,aa as P,a5 as y,o as g,D as O,aN as I,q as E,s as G,t as B}from"./index-BLtzf0SR.js";import{s as v}from"./client-DTel1CZI.js";import{P as X}from"./PortalLayout-BUxGSFei.js";import{B as z}from"./badge-BsE4KYIf.js";import{I as n}from"./input-RFokm5kN.js";import{T}from"./textarea-Da4-oaTC.js";import{T as Z,a as $,b as F,c as q}from"./tabs-B9G-WuXr.js";import{S as w,a as C,b as S,c as L,d as u}from"./select-CMAo_7oa.js";import{u as _}from"./index-Cx0UdoxP.js";import{g as A,A as W}from"./teamConfig-D_oSiuQA.js";import{S as R}from"./square-pen-qopVEHIb.js";import{T as J}from"./trophy-Bmhl08mz.js";import{U as Q}from"./users-CIwSfVhi.js";import{P as M}from"./plus-Db1qFqHY.js";import{S as K}from"./save-vrPqs9Xk.js";import"./router-vendor-Dz9PdDzH.js";import"./AdminLayout-4AAuHeAU.js";import"./NavLink-CsyG-eHO.js";import"./scroll-area-BdyOmc9o.js";import"./index-BdQq_4o_.js";import"./collapsible-BAD8kbtc.js";import"./index-CMI-ZfmW.js";import"./arrow-left-CRb8P6iH.js";import"./globe-CQ83QW2m.js";import"./activity-CwFToTs3.js";import"./list-todo-BR3jv1RJ.js";import"./calendar-BDETTnfZ.js";import"./users-round-CCw5yxW7.js";import"./radio-BQgeDg5T.js";import"./clapperboard-BvstouST.js";import"./clipboard-list-CQJ-vJ2y.js";import"./image-arBWrt3y.js";import"./folder-open-CIWhCFhy.js";import"./pencil-C2cyk8cg.js";import"./message-square-BDdDilNB.js";import"./ticket-l9bl0kcm.js";import"./megaphone-DpQsxotQ.js";import"./package-DKB1lvtO.js";import"./circle-user-BeB3uaA1.js";import"./folder-kanban-B8jlMC6s.js";import"./settings-Baim_Eei.js";import"./briefcase-CdSp4ViD.js";import"./chart-line-ohAz7u_s.js";import"./HostOwnerLayout-PM2-LrXf.js";import"./layers-CvbkNa7J.js";import"./dollar-sign-D3lTBfQm.js";import"./index-O12prPmO.js";import"./chevron-up-B89bkR-F.js";const ee=["A+","A","A-","B+","B","B-","C+","C","C-","D+","D","D-","F"];function Xe(){const h=Y(),[s,d]=p.useState("2025"),[x,N]=p.useState("atl");p.useState(!1),p.useState(!1);const{data:m,isLoading:a}=k({queryKey:["admin-stats-standings",s],queryFn:async()=>{const{data:t,error:c}=await v.from("stats_standings").select("*").eq("season",s).order("wins",{ascending:!1});if(c)throw c;return t}}),{data:l,isLoading:f}=k({queryKey:["admin-stats-reports",s],queryFn:async()=>{const{data:t,error:c}=await v.from("stats_team_reports").select("*").eq("season",s).order("team_id");if(c)throw c;return t}}),{data:i,isLoading:b}=k({queryKey:["admin-stats-leaders",s],queryFn:async()=>{const{data:t,error:c}=await v.from("stats_leaders").select("*").eq("season",s).order("category");if(c)throw c;return t}}),o=A(x);m==null||m.find(t=>t.team_id===x);const r=l==null?void 0:l.find(t=>t.team_id===x);return e.jsx(X,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-display font-bold text-foreground flex items-center gap-2",children:[e.jsx(P,{className:"h-6 w-6 text-primary"}),"Stats & Standings Management"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage team standings, stats reports, D.O.L. commentary, and league leaders"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(w,{value:s,onValueChange:d,children:[e.jsx(C,{className:"w-32",children:e.jsx(S,{})}),e.jsxs(L,{children:[e.jsx(u,{value:"2025",children:"2025 Final"}),e.jsx(u,{value:"2026",children:"2026 Season"})]})]})})]}),l&&l.filter(t=>t.editorial_status==="pending_review").length>0&&e.jsxs("div",{className:"p-4 rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 flex items-center gap-3",children:[e.jsx(R,{className:"w-5 h-5 text-amber-600 shrink-0"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:[l.filter(t=>t.editorial_status==="pending_review").length," Host Editorial Edit(s) Pending Review"]}),e.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-300",children:"D.O.L. has submitted editorial changes. Review in the Team Reports tab."})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:"Standings Entries"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:(m==null?void 0:m.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"of 32 teams"})]}),e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:"Team Reports"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:(l==null?void 0:l.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l==null?void 0:l.filter(t=>t.is_published).length)||0," published"]})]}),e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:"Leader Categories"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:(i==null?void 0:i.length)||0})]}),e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:"Data Source"}),e.jsx("p",{className:"text-sm font-medium text-foreground mt-1",children:s==="2025"?"Static + DB":"Database Only"})]})]}),e.jsxs(Z,{defaultValue:"standings",className:"space-y-4",children:[e.jsxs($,{children:[e.jsxs(F,{value:"standings",children:[e.jsx(J,{className:"h-4 w-4 mr-1.5"}),"Standings"]}),e.jsxs(F,{value:"reports",children:[e.jsx(P,{className:"h-4 w-4 mr-1.5"}),"Team Reports"]}),e.jsxs(F,{value:"leaders",children:[e.jsx(Q,{className:"h-4 w-4 mr-1.5"}),"Leaders"]})]}),e.jsxs(q,{value:"standings",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(m==null?void 0:m.length)||0," standings entries for ",s]}),e.jsx(H,{season:s,onSaved:()=>h.invalidateQueries({queryKey:["admin-stats-standings"]})})]}),a?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(y,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):m&&m.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/30 text-left text-xs text-muted-foreground uppercase",children:[e.jsx("th",{className:"p-2",children:"Team"}),e.jsx("th",{className:"p-2",children:"W"}),e.jsx("th",{className:"p-2",children:"L"}),e.jsx("th",{className:"p-2",children:"T"}),e.jsx("th",{className:"p-2",children:"PF"}),e.jsx("th",{className:"p-2",children:"PA"}),e.jsx("th",{className:"p-2",children:"Diff"}),e.jsx("th",{className:"p-2",children:"Div Seed"}),e.jsx("th",{className:"p-2",children:"Playoff"}),e.jsx("th",{className:"p-2",children:"Actions"})]})}),e.jsx("tbody",{children:m.map(t=>{const c=A(t.team_id);return e.jsxs("tr",{className:"border-b border-border/10 hover:bg-muted/20",children:[e.jsxs("td",{className:"p-2 font-medium flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-bold shrink-0",style:{backgroundColor:(c==null?void 0:c.primary)||"#666"},children:(c==null?void 0:c.initials)||t.team_id.toUpperCase()}),(c==null?void 0:c.name)||t.team_id]}),e.jsx("td",{className:"p-2",children:t.wins}),e.jsx("td",{className:"p-2",children:t.losses}),e.jsx("td",{className:"p-2",children:t.ties}),e.jsx("td",{className:"p-2",children:t.points_for}),e.jsx("td",{className:"p-2",children:t.points_against}),e.jsx("td",{className:"p-2",children:e.jsxs("span",{className:t.point_diff>=0?"text-emerald-600":"text-red-500",children:[t.point_diff>=0?"+":"",t.point_diff]})}),e.jsx("td",{className:"p-2",children:t.division_seed||"-"}),e.jsx("td",{className:"p-2",children:e.jsx("span",{className:"text-xs",children:t.playoff_result||"N/A"})}),e.jsx("td",{className:"p-2",children:e.jsx(H,{season:s,existing:t,onSaved:()=>h.invalidateQueries({queryKey:["admin-stats-standings"]}),trigger:e.jsx(g,{variant:"ghost",size:"sm",children:e.jsx(R,{className:"h-3.5 w-3.5"})})})})]},t.id)})})]})}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(J,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsxs("p",{children:["No standings entries for ",s," season yet."]}),e.jsx("p",{className:"text-xs mt-1",children:"The public page currently uses static data files. Add entries here to manage via database."})]})]}),e.jsxs(q,{value:"reports",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(w,{value:x,onValueChange:N,children:[e.jsx(C,{className:"w-56",children:e.jsx(S,{})}),e.jsx(L,{children:W.map(t=>e.jsxs(u,{value:t.id,children:[t.initials," — ",t.name]},t.id))})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r?e.jsx(z,{variant:r.is_published?"default":"secondary",children:r.is_published?"Published":"Draft"}):e.jsx("span",{className:"text-xs",children:"No DB entry — using static data"})})]}),e.jsx(se,{season:s,teamId:x,existing:r,onSaved:()=>h.invalidateQueries({queryKey:["admin-stats-reports"]})})]}),f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(y,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Record"}),e.jsx("p",{className:"text-lg font-bold",children:r.compact_record||"
1N/A"})]}),e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"PPG"}),e.jsx("p",{className:"text-lg font-bold",children:r.compact_ppg||"N/A"})]}),e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"D.O.L. Grade"}),e.jsx("p",{className:"text-lg font-bold",children:r.dol_season_grade||"N/A"})]}),e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Published"}),e.jsx("p",{className:"text-lg font-bold",children:r.is_published?"✅":"❌"})]})]}),r.dol_season_summary&&e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-4",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase mb-2",children:"D.O.L.'s Season Summary"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.dol_season_summary})]}),r.compact_headline&&e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-4",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase mb-2",children:"Headline"}),e.jsx("p",{className:"text-sm italic",children:r.compact_headline})]})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsxs("p",{children:["No database report for ",(o==null?void 0:o.name)||x," (",s,")."]}),e.jsx("p",{className:"text-xs mt-1",children:'Click "Add / Edit Report" to create one.'})]}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase mb-2",children:["All Team Reports (",s,")"]}),l&&l.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/30 text-left text-xs text-muted-foreground uppercase",children:[e.jsx("th",{className:"p-2",children:"Team"}),e.jsx("th",{className:"p-2",children:"Record"}),e.jsx("th",{className:"p-2",children:"Grade"}),e.jsx("th",{className:"p-2",children:"Headline"}),e.jsx("th",{className:"p-2",children:"Published"})]})}),e.jsx("tbody",{children:l.map(t=>{const c=A(t.team_id);return e.jsxs("tr",{className:"border-b border-border/10 hover:bg-muted/20 cursor-pointer",onClick:()=>N(t.team_id),children:[e.jsx("td",{className:"p-2 font-medium",children:(c==null?void 0:c.name)||t.team_id}),e.jsx("td",{className:"p-2",children:t.compact_record||"-"}),e.jsx("td",{className:"p-2",children:t.dol_season_grade||"-"}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground truncate max-w-xs",children:t.compact_headline||"-"}),e.jsx("td",{className:"p-2",children:e.jsx(z,{variant:t.is_published?"default":"secondary",className:"text-xs",children:t.is_published?"Live":"Draft"})})]},t.id)})})]})}):e.jsxs("p",{className:"text-xs text-muted-foreground",children:["No reports in database for ",s,"."]})]})]}),e.jsxs(q,{value:"leaders",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(i==null?void 0:i.length)||0," leader categories for ",s]}),e.jsx(U,{season:s,onSaved:()=>h.invalidateQueries({queryKey:["admin-stats-leaders"]})})]}),b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(y,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):i&&i.length>0?e.jsx("div",{className:"grid md:grid-cols-2 gap-4",children:i.map(t=>e.jsxs("div",{className:"rounded-lg border border-border/30 bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm capitalize",children:t.category}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:t.subcategory})]}),e.jsx(U,{season:s,existing:t,onSaved:()=>h.invalidateQueries({queryKey:["admin-stats-leaders"]}),trigger:e.jsx(g,{variant:"ghost",size:"sm",children:e.jsx(R,{className:"h-3.5 w-3.5"})})})]}),e.jsx("div",{className:"space-y-1",children:(Array.isArray(t.leaders)?t.leaders:[]).map((c,j)=>e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j+1,". ",c.name," 
1(",c.team,") — ",c.stat]},j))})]},t.id))}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Q,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsxs("p",{children:["No leader entries for ",s,"."]}),e.jsx("p",{className:"text-xs mt-1",children:"The public page currently uses static data. Add leaders here to manage via database."})]})]})]})]})})}function H({season:h,existing:s,onSaved:d,trigger:x}){const[N,m]=p.useState(!1),[a,l]=p.useState({team_id:(s==null?void 0:s.team_id)||"atl",wins:(s==null?void 0:s.wins)||0,losses:(s==null?void 0:s.losses)||0,ties:(s==null?void 0:s.ties)||0,points_for:(s==null?void 0:s.points_for)||0,points_against:(s==null?void 0:s.points_against)||0,point_diff:(s==null?void 0:s.point_diff)||0,home_record:(s==null?void 0:s.home_record)||"",away_record:(s==null?void 0:s.away_record)||"",div_record:(s==null?void 0:s.div_record)||"",conf_record:(s==null?void 0:s.conf_record)||"",streak:(s==null?void 0:s.streak)||"",division_seed:(s==null?void 0:s.division_seed)||1,conference_seed:(s==null?void 0:s.conference_seed)||null,playoff_result:(s==null?void 0:s.playoff_result)||"",clinched:(s==null?void 0:s.clinched)||""}),[f,i]=p.useState(!1),b=async()=>{i(!0);try{const o={...a,season:h,point_diff:a.points_for-a.points_against};if(s!=null&&s.id){const{error:r}=await v.from("stats_standings").update(o).eq("id",s.id);if(r)throw r;_.success("Standing updated")}else{const{error:r}=await v.from("stats_standings").insert(o);if(r)throw r;_.success("Standing created")}d(),m(!1)}catch(o){_.error(o.message||"Failed to save")}finally{i(!1)}};return e.jsxs(O,{open:N,onOpenChange:m,children:[e.jsx(I,{asChild:!0,children:x||e.jsxs(g,{size:"sm",className:"gap-1.5",children:[e.jsx(M,{className:"h-4 w-4"})," Add Standing"]})}),e.jsxs(E,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(G,{children:e.jsxs(B,{children:[s?"Edit":"Add"," Standing (",h,")"]})}),e.jsxs("div",{className:"space-y-3",children:[!s&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Team"}),e.jsxs(w,{value:a.team_id,onValueChange:o=>l({...a,team_id:o}),children:[e.jsx(C,{children:e.jsx(S,{})}),e.jsx(L,{children:W.map(o=>e.jsxs(u,{value:o.id,children:[o.initials," — ",o.name]},o.id))})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Wins"}),e.jsx(n,{type:"number",value:a.wins,onChange:o=>l({...a,wins:parseInt(o.target.value)||0})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Losses"}),e.jsx(n,{type:"number",value:a.losses,onChange:o=>l({...a,losses:parseInt(o.target.value)||0})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Ties"}),e.jsx(n,{type:"number",value:a.ties,onChange:o=>l({...a,ties:parseInt(o.target.value)||0})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Points For"}),e.jsx(n,{type:"number",value:a.points_for,onChange:o=>l({...a,points_for:parseInt(o.target.value)||0})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Points Against"}),e.jsx(n,{type:"number",value:a.points_against,onChange:o=>l({...a,points_against:parseInt(o.target.value)||0})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Home Record"}),e.jsx(n,{value:a.home_record,onChange:o=>l({...a,home_record:o.target.value}),placeholder:"5-4"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Away Record"}),e.jsx(n,{value:a.away_record,onChange:o=>l({...a,away_record:o.target.value}),placeholder:"3-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Division Record"}),e.jsx(n,{value:a.div_record,onChange:o=>l({...a,div_record:o.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Conference Record"}),e.jsx(n,{value:a.conf_record,onChange:o=>l({...a,conf_record:o.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Streak"}),e.jsx(n,{value:a.streak,onChange:o=>l({...a,streak:o.target.value}),placeholder:"W3"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Div Seed"}),e.jsx(n,{type:"number",value:a.division_seed,onChange:o=>l({...a,division_seed:parseInt(o.target.value)||1})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Conf Seed"}),e.jsx(n,{type:"number",value:a.conference_seed||"",onChange:o=>l({...a,conference_seed:parseInt(o.target.value)||null})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Playoff Result"}
1),e.jsx(n,{value:a.playoff_result,onChange:o=>l({...a,playoff_result:o.target.value}),placeholder:"Wild Card Loss"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Clinched"}),e.jsxs(w,{value:a.clinched||"none",onValueChange:o=>l({...a,clinched:o==="none"?"":o}),children:[e.jsx(C,{children:e.jsx(S,{})}),e.jsxs(L,{children:[e.jsx(u,{value:"none",children:"None"}),e.jsx(u,{value:"division",children:"Division"}),e.jsx(u,{value:"wildcard",children:"Wild Card"}),e.jsx(u,{value:"bye",children:"Bye"})]})]})]}),e.jsxs(g,{onClick:b,disabled:f,className:"w-full gap-1.5",children:[f?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx(K,{className:"h-4 w-4"}),s?"Update":"Create"," Standing"]})]})]})]})}function se({season:h,teamId:s,existing:d,onSaved:x}){const[N,m]=p.useState(!1),[a,l]=p.useState({compact_record:(d==null?void 0:d.compact_record)||"",compact_ppg:(d==null?void 0:d.compact_ppg)||"",compact_papg:(d==null?void 0:d.compact_papg)||"",compact_rush_ypg:(d==null?void 0:d.compact_rush_ypg)||"",compact_pass_ypg:(d==null?void 0:d.compact_pass_ypg)||"",compact_sacks:(d==null?void 0:d.compact_sacks)||"",compact_ints:(d==null?void 0:d.compact_ints)||"",compact_fg_pct:(d==null?void 0:d.compact_fg_pct)||"",compact_top_off:(d==null?void 0:d.compact_top_off)||"",compact_top_def:(d==null?void 0:d.compact_top_def)||"",compact_headline:(d==null?void 0:d.compact_headline)||"",dol_season_grade:(d==null?void 0:d.dol_season_grade)||"C",dol_season_summary:(d==null?void 0:d.dol_season_summary)||"",dol_stat_of_note:(d==null?void 0:d.dol_stat_of_note)||"",dol_season_grade_rationale:(d==null?void 0:d.dol_season_grade_rationale)||"",is_published:(d==null?void 0:d.is_published)||!1}),[f,i]=p.useState(!1),b=async()=>{i(!0);try{const r={team_id:s,season:h,...a,compact_ppg:parseFloat(a.compact_ppg)||null,compact_papg:parseFloat(a.compact_papg)||null,compact_rush_ypg:parseFloat(a.compact_rush_ypg)||null,compact_pass_ypg:parseFloat(a.compact_pass_ypg)||null,compact_sacks:parseInt(a.compact_sacks)||null,compact_ints:parseInt(a.compact_ints)||null,compact_fg_pct:parseFloat(a.compact_fg_pct)||null};if(d!=null&&d.id){const{error:t}=await v.from("stats_team_reports").update(r).eq("id",d.id);if(t)throw t;_.success("Report updated")}else{const{error:t}=await v.from("stats_team_reports").insert(r);if(t)throw t;_.success("Report created")}x(),m(!1)}catch(r){_.error(r.message||"Failed to save")}finally{i(!1)}},o=A(s);return e.jsxs(O,{open:N,onOpenChange:m,children:[e.jsx(I,{asChild:!0,children:e.jsxs(g,{size:"sm",variant:"outline",className:"gap-1.5",children:[e.jsx(R,{className:"h-4 w-4"})," ",d?"Edit":"Add"," Report"]})}),e.jsxs(E,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsx(G,{children:e.jsxs(B,{children:[d?"Edit":"Create"," Report — ",(o==null?void 0:o.name)||s," (",h,")"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Record"}),e.jsx(n,{value:a.compact_record,onChange:r=>l({...a,compact_record:r.target.value}),placeholder:"8-9"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"PPG"}),e.jsx(n,{value:a.compact_ppg,onChange:r=>l({...a,compact_ppg:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"PAPG"}),e.jsx(n,{value:a.compact_papg,onChange:r=>l({...a,compact_papg:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Rush Yds/G"}),e.jsx(n,{value:a.compact_rush_ypg,onChange:r=>l({...a,compact_rush_ypg:r.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Pass Yds/G"}),e.jsx(n,{value:a.compact_pass_ypg,onChange:r=>l({...a,compact_pass_ypg:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Sacks"}),e.jsx(n,{value:a.compact_sacks,onChange:r=>l({...a,compact_sacks:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"INTs"}),e.jsx(n,{value:a.compact_ints,onChange:r=>l({...a,compact_ints:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"FG%"}),e.jsx(n,{value:a.compact_fg_pct,onChange:r=>l({...a,compact_fg_pct:r.target.value})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Top Offensive Production"}
1),e.jsx(n,{value:a.compact_top_off,onChange:r=>l({...a,compact_top_off:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Top Defensive Production"}),e.jsx(n,{value:a.compact_top_def,onChange:r=>l({...a,compact_top_def:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Headline"}),e.jsx(n,{value:a.compact_headline,onChange:r=>l({...a,compact_headline:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"D.O.L. Season Grade"}),e.jsxs(w,{value:a.dol_season_grade,onValueChange:r=>l({...a,dol_season_grade:r}),children:[e.jsx(C,{children:e.jsx(S,{})}),e.jsx(L,{children:ee.map(r=>e.jsx(u,{value:r,children:r},r))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"D.O.L.'s Stat of Note"}),e.jsx(T,{value:a.dol_stat_of_note,onChange:r=>l({...a,dol_stat_of_note:r.target.value}),rows:2})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"D.O.L.'s Season Grade Rationale"}),e.jsx(T,{value:a.dol_season_grade_rationale,onChange:r=>l({...a,dol_season_grade_rationale:r.target.value}),rows:3})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"D.O.L.'s Season Summary"}),e.jsx(T,{value:a.dol_season_summary,onChange:r=>l({...a,dol_season_summary:r.target.value}),rows:6})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:a.is_published,onChange:r=>l({...a,is_published:r.target.checked}),className:"rounded"}),e.jsx("label",{className:"text-sm",children:"Publish this report (visible to public)"})]}),e.jsxs(g,{onClick:b,disabled:f,className:"w-full gap-1.5",children:[f?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx(K,{className:"h-4 w-4"}),d?"Update":"Create"," Report"]})]})]})]})}function U({season:h,existing:s,onSaved:d,trigger:x}){const[N,m]=p.useState(!1),[a,l]=p.useState((s==null?void 0:s.category)||"passing"),[f,i]=p.useState((s==null?void 0:s.subcategory)||"yards"),[b,o]=p.useState(s!=null&&s.leaders?JSON.stringify(s.leaders,null,2):'[{"name":"","team":"","stat":"","note":""}]'),[r,t]=p.useState(!1),c=async()=>{t(!0);try{let j;try{j=JSON.parse(b)}catch{throw new Error("Invalid JSON in leaders field")}const V={season:h,category:a,subcategory:f,leaders:j};if(s!=null&&s.id){const{error:D}=await v.from("stats_leaders").update(V).eq("id",s.id);if(D)throw D;_.success("Leaders updated")}else{const{error:D}=await v.from("stats_leaders").insert(V);if(D)throw D;_.success("Leaders created")}d(),m(!1)}catch(j){_.error(j.message||"Failed to save")}finally{t(!1)}};return e.jsxs(O,{open:N,onOpenChange:m,children:[e.jsx(I,{asChild:!0,children:x||e.jsxs(g,{size:"sm",className:"gap-1.5",children:[e.jsx(M,{className:"h-4 w-4"})," Add Leaders"]})}),e.jsxs(E,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(G,{children:e.jsxs(B,{children:[s?"Edit":"Add"," Leaders (",h,")"]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Category"}),e.jsxs(w,{value:a,onValueChange:l,children:[e.jsx(C,{children:e.jsx(S,{})}),e.jsxs(L,{children:[e.jsx(u,{value:"passing",children:"Passing"}),e.jsx(u,{value:"rushing",children:"Rushing"}),e.jsx(u,{value:"receiving",children:"Receiving"}),e.jsx(u,{value:"defense",children:"Defense"}),e.jsx(u,{value:"specialTeams",children:"Special Teams"}),e.jsx(u,{value:"awards",children:"Awards"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Subcategory"}),e.jsx(n,{value:f,onChange:j=>i(j.target.value),placeholder:"yards, touchdowns, etc."})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Leaders (JSON Array)"}),e.jsx(T,{value:b,onChange:j=>o(j.target.value),rows:10,className:"font-mono text-xs",placeholder:'[{"name":"Player","team":"ATL","stat":"1,478 yds","note":"Best in NFL"}]'}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Each entry: ",'{ "name", "team", "stat", "note" (optional) }']})]}),e.jsxs(g,{onClick:c,disabled:r,className:"w-full gap-1.5",children:[r?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx(K,{className:"h-4 w-4"}),s?"Update":"Create"," Leaders"]})]})]})]})}export{Xe as default};

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.