1import{j as e}from"./vendor-react-Ci8XvypC.js";import{S as f,a as h}from"./SettingsShell-DEprddGX.js";import{bN as y,bO as N,bP as k,bQ as v,bR as w,G as S}from"./index-Hx-p8ka4.js";import{adminTabs as C,PlanPill as P,fmtDateTime as E,StatusPill as d,fmtDate as j}from"./AdminShared-BvRdp25b.js";import{c as I,L as A,b as g}from"./vendor-router-DC2shrY2.js";import{Q as L,b3 as $}from"./vendor-icons-CfgbQDMF.js";import"./index-CU3YYEgg.js";import"./vendor-react-dom-yPwZA2yX.js";import"./vendor-query-BWIl-I-M.js";function x(i){return i instanceof S?i.message:"Something went wrong. Try again."}function T(i){if(!i)return e.jsx(d,{kind:"idle",children:"no imports"});const t=i==="succeeded"?"ok":i==="failed"?"danger":"warn";return e.jsx(d,{kind:t,children:i})}function q(){const{leagueId:i}=I(),t=y(i),n=t.data;return e.jsxs(f,{eyebrow:"Master admin",title:(n==null?void 0:n.league.name)??"League",description:n?`Imported by ${n.league.ownerEmail??"unknown"}`:void 0,icon:e.jsx($,{size:18}),tabs:C,children:[e.jsxs(A,{to:"/admin/leagues",className:"adm-backlink",children:[e.jsx(L,{size:13})," All leagues"]}),t.isLoading?e.jsx("p",{className:"ui-empty",children:"Loading leagueâ¦"}):t.isError?e.jsx("p",{className:"ui-error",children:"Couldn't load this league. It may have been deleted."}):n?e.jsxs(e.Fragment,{children:[e.jsx(D,{d:n}),e.jsx(h,{title:"Seasons",description:"Imported provider seasons and the state of each one's last ingestion.",children:n.seasons.length===0?e.jsx("p",{className:"ui-empty",children:"No seasons imported."}):e.jsx("div",{className:"ui-table-scroll",children:e.jsxs("table",{className:"ui-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Season"}),e.jsx("th",{children:"Provider"}),e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Teams"}),e.jsx("th",{children:"Last import"})]})}),e.jsx("tbody",{children:n.seasons.map(s=>e.jsxs("tr",{children:[e.jsx("td",{className:"num",children:e.jsx("span",{className:"cell-main",children:s.season})}),e.jsx("td",{children:s.provider}),e.jsx("td",{children:s.name}),e.jsx("td",{className:"num",children:s.numTeams??"â"}),e.jsx("td",{children:T(s.lastJobStatus)})]},s.id))})]})})}),n.seasons.some(s=>s.provider==="cbs")&&e.jsx(B,{leagueId:n.league.id}),e.jsx(h,{title:"Members",description:"Invites and accepted accounts.",children:n.members.length===0?e.jsx("p",{className:"ui-empty",children:"No members beyond the importer."}):e.jsx("div",{className:"ui-table-scroll",children:e.jsxs("table",{className:"ui-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Member"}),e.jsx("th",{children:"Role"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Invited"}),e.jsx("th",{children:"Accepted"})]})}),e.jsx("tbody",{children:n.members.map(s=>e.jsx(R,{m:s},s.id))})]})})}),e.jsx(h,{title:"Franchise owners",description:"The league's permanent identities and who has claimed them.",children:n.owners.length===0?e.jsx("p",{className:"ui-empty",children:"No owners yet."}):e.jsx("div",{className:"ui-table-scroll",children:e.jsxs("table",{className:"ui-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Owner"}),e.jsx("th",{children:"Claimed by"}),e.jsx("th",{children:"Visibility"})]})}),e.jsx("tbody",{children:n.owners.map(s=>e.jsx(W,{o:s},s.id))})]})})}),e.jsx(F,{d:n})]}):null]})}function R({m:i}){const t=g();return e.jsxs("tr",{className:i.userId?"is-link":void 0,onClick:i.userId?()=>t(`/admin/users/${i.userId}`):void 0,children:[e.jsxs("td",{children:[e.jsx("span",{className:"cell-main",children:i.userEmail??i.invitedEmail}),i.userEmail&&i.userEmail!==i.invitedEmail&&e.jsxs("span",{className:"cell-sub",children:["invited as ",i.invitedEmail]})]}),e.jsx("td",{children:i.role}),e.jsx("td",{children:e.jsx(d,{kind:i.status==="accepted"?"ok":"warn",children:i.status})}),e.jsx("td",{children:j(i.createdAt)}),e.jsx("td",{children:j(i.acceptedAt)})]})}function W({o:i}){const t=g(),n=i.managerIds.length===1?i.managerIds[0]:null;return e.jsxs("tr",{className:n?"is-link":void 0,onClick:n?()=>t(`/admin/users/${n}`):void 0,children:[e.jsx("td",{children:e.jsx("span",{className:"cell-main",children:i.name})}),e.jsx("td",{children:i.managerEmails.length>0?i.managerEmails.join(" + "):"unclaimed"}),e.jsx("td",{children:i.hidden?e.jsx(d,{kind:"warn",children:"hidden"}):e.jsx(d,{kind:"idle",children:"visible"})})]})}function D({d:i}){var o,b;const t=N(i.league.id),n=k(i.league.id),s=i.league,a=s.plan==="elite"&&s.eliteSource==="stripe"&&!!s.stripeSubscriptionId?"Cancel the Stripe subscription first â an override on top of live billing would keep charging the payer.":void 0,l=async m=>{const u=m==="comp"?`Comp ${s.name} to Elite (no expiry, no charge)?`:`Drop ${s.name} to the Free plan? Elite surfaces lock immediately for every member.`;window.confirm(u)&&await t.mutateAsync({plan:m})},r=async m=>{const u={period_end:`Cancel ${s.name}'s subscription at period end? They keep Elite until it lapses; no further charges.`,immediate:`Cancel ${s.name}'s subscription NOW? Elite locks immediately and Stripe stops billing. (Refunds happen in the Stripe dashboard.)`,undo:`Undo the scheduled cancellation for ${s.name}? The subscription will renew normally.`};window.confirm(u[m])&&await n.mutateAsync(m)};return e.jsxs(h,{title:"Plan & billing",description:"The entitlement row is the truth for access; the Stripe panel is what the processor thinks.",children:[e.jsxs("dl",{className:"ui-kv",style:{marginBottom:14},children:[e.jsx("dt",{children:"Plan"}),e.jsx("dd",{children:e.jsx(P,{plan:s.plan,source:s.eliteSource,trialUntil:s.tri
1alUntil})}),s.eliteUntil&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Elite until"}),e.jsxs("dd",{children:[E(s.eliteUntil)," (incl. grace)"]})]}),e.jsx("dt",{children:"Payer"}),e.jsx("dd",{children:s.payerEmail??"â"}),s.stripeCustomerId&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Stripe customer"}),e.jsx("dd",{children:e.jsx("code",{children:s.stripeCustomerId})})]}),s.stripeSubscriptionId&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Subscription"}),e.jsxs("dd",{children:[e.jsx("code",{children:s.stripeSubscriptionId}),i.stripe&&e.jsxs(e.Fragment,{children:[" ",e.jsx(d,{kind:i.stripe.status==="active"||i.stripe.status==="trialing"?"ok":i.stripe.status==="past_due"?"warn":"danger",children:i.stripe.status}),i.stripe.cancelAtPeriodEnd&&e.jsxs(e.Fragment,{children:[" ",e.jsx(d,{kind:"warn",children:"cancels at period end"})]})]}),((o=i.stripe)==null?void 0:o.currentPeriodEnd)&&e.jsxs("span",{className:"cell-sub",children:["current period ends ",j(i.stripe.currentPeriodEnd)]})]})]})]}),s.stripeSubscriptionId&&e.jsxs("div",{className:"ui-actions",style:{marginBottom:10},children:[(b=i.stripe)!=null&&b.cancelAtPeriodEnd?e.jsx("button",{type:"button",className:"ui-btn",disabled:n.isPending,onClick:()=>r("undo"),children:n.isPending?"Workingâ¦":"Undo scheduled cancel"}):e.jsx("button",{type:"button",className:"ui-btn",disabled:n.isPending,onClick:()=>r("period_end"),children:n.isPending?"Workingâ¦":"Cancel at period end"}),e.jsx("button",{type:"button",className:"ui-btn ui-btn--ghost-danger",disabled:n.isPending,onClick:()=>r("immediate"),children:"Cancel now"})]}),e.jsxs("div",{className:"ui-actions",children:[s.eliteSource!=="comp"&&e.jsx("button",{type:"button",className:"ui-btn",disabled:!!a||t.isPending,title:a,onClick:()=>l("comp"),children:t.isPending?"Workingâ¦":"Comp to Elite"}),s.plan!=="free"&&e.jsx("button",{type:"button",className:"ui-btn ui-btn--ghost-danger",disabled:!!a||t.isPending,title:a,onClick:()=>l("free"),children:"Set to Free"})]}),a&&e.jsx("p",{className:"ui-note",children:a}),t.isError&&e.jsx("p",{className:"ui-error",children:x(t.error)}),n.isError&&e.jsx("p",{className:"ui-error",children:x(n.error)})]})}function F({d:i}){const t=g(),n=w(i.league.id),s=i.league,c=i.seasons.length,a=i.members.filter(r=>r.status==="accepted").length,l=async()=>{const r=[`Permanently delete ${s.name}?`,`${c} season${c===1?"":"s"} of history go with it`+(a>0?`, and ${a} member${a===1?"":"s"} lose${a===1?"s":""} access.`:"."),s.stripeSubscriptionId?"Its Stripe subscription is canceled first.":"","This can't be undone."].filter(Boolean).join(" ");window.confirm(r)&&(await n.mutateAsync(),t("/admin/leagues"))};return e.jsxs(h,{title:"Delete league",description:"Removes the league and its whole history for everyone, the same as the owner deleting it from settings.",children:[e.jsx("div",{className:"ui-actions",children:e.jsx("button",{type:"button",className:"ui-btn ui-btn--ghost-danger",disabled:n.isPending,onClick:l,children:n.isPending?"Deletingâ¦":"Delete league"})}),n.isError&&e.jsx("p",{className:"ui-error",children:x(n.error)})]})}const p=[["derived-player-points","Derived points"],["team-total","Team totals"],["optimal-lineup","Optimal lineup"],["lineup-efficiency","Efficiency"]];function B({leagueId:i}){const t=v(i),n=t.data;return e.jsx(h,{title:"CBS scoring readiness",description:"Weeks the scoring nucleus could compute per calculation, and the inputs still missing. Writes stay off until every input is verified.",children:t.isLoading?e.jsx("p",{className:"ui-empty",children:"Loading readinessâ¦"}):t.isError||!n?e.jsx("p",{className:"ui-error",children:"Couldn't load CBS readiness."}):n.seasons.length===0?e.jsx("p",{className:"ui-empty",children:"No CBS seasons."}):e.jsx("div",{className:"ui-table-scroll",children:e.jsxs("table",{className:"ui-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Season"}),e.jsx("th",{children:"Weeks"}),e.jsx("th",{children:"Provider points"}),p.map(([s,c])=>e.jsx("th",{children:c},s)),e.jsx("th",{children:"Top blockers"})]})}),e.jsx("tbody",{children:n.seasons.map(s=>{const c=new Map;for(const[l]of p)for(const r of s.calculations[l].blockers)c.set(r.reason,Math.max(c.get(r.reason)??0,r.weeks));const a=[...c].sort((l,r)=>r[1]-l[1]).slice(0,3);return e.jsxs("tr",{children:[e.jsx("td",{className:"num",children:e.jsx("span",{className:"cell-main",children:s.season})}),e.jsx("td",{className:"num",children:s.captured?s.weeks:e.jsx(d,{kind:"idle",children:"not captured"})}),e.jsx("td",{className:"num",children:s.captured?`${s.providerPointRows} / ${s.totalRosterRows} cells`:"â"}),p.map(([l])=>{const r=s.calculations[l],o=r.readyWeeks+r.blockedWeeks;return e.jsx("td",{className:"num",children:!s.captured||o===0?"â":r.blockedWeeks===0?e.jsxs(d,{kind:"ok",children:[r.readyWeeks,"/",o]}):e.jsxs(d,{kind:"warn",children:[r.readyWeeks,"/",o]})},l)}),e.jsx("td",{children:a.length===0?"â":a.map(([l,r])=>`${l} (${r})`).join("; ")})]},s.leagueSeasonId)})})]})})})}export{q as AdminLeagueDetail};
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.