@nukleus-sports/ui-patterns 0.5.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/team.js CHANGED
@@ -14,6 +14,15 @@ import {
14
14
  } from "@nukleus-sports/ui-web";
15
15
  import { formatTeamName, getTeamPlaceSummaries } from "@nukleus-sports/core";
16
16
  import { jsx, jsxs } from "react/jsx-runtime";
17
+ function PlaceValueCell({ place }) {
18
+ if (!place.name) {
19
+ return /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "No address available" });
20
+ }
21
+ return /* @__PURE__ */ jsxs("div", { className: "text-text-primary body-text", children: [
22
+ /* @__PURE__ */ jsx("p", { children: place.name }),
23
+ place.address ? /* @__PURE__ */ jsx("p", { children: place.address }) : /* @__PURE__ */ jsx("p", { children: "No address available" })
24
+ ] });
25
+ }
17
26
  var TAB_TRIGGER_CLASS = "flex-1 bg-card text-[13px] text-text-primary data-[state=active]:bg-card data-[state=active]:text-primary-color-nuk-text data-[state=active]:shadow-none border-b border-greys-grey-strokes-tables data-[state=active]:border-primary-color-nuk-ui-elem rounded-none px-0 pb-2 mb-[-1px] relative after:absolute after:left-0 after:-bottom-[1px] after:w-full after:h-[2px] after:content-[''] after:bg-transparent data-[state=active]:after:bg-primary-color-nuk-ui-elem";
18
27
  function TeamInfoCard({ team, resolveImageUrl, className }) {
19
28
  const teamDisplayName = formatTeamName(team.team, team.nickname) || "Team not found";
@@ -62,18 +71,12 @@ function TeamInfoCard({ team, resolveImageUrl, className }) {
62
71
  venueInfo.label,
63
72
  ":"
64
73
  ] }) }),
65
- /* @__PURE__ */ jsx("div", { className: "flex flex-col text-right", children: venueInfo.name ? /* @__PURE__ */ jsxs("div", { className: "text-text-primary body-text", children: [
66
- /* @__PURE__ */ jsx("p", { children: venueInfo.name }),
67
- venueInfo.address && /* @__PURE__ */ jsx("p", { children: venueInfo.address })
68
- ] }) : /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "No address available" }) }),
74
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col text-right", children: /* @__PURE__ */ jsx(PlaceValueCell, { place: venueInfo }) }),
69
75
  /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsxs("p", { className: "text-text-primary body-text", children: [
70
76
  facilityInfo.label,
71
77
  ":"
72
78
  ] }) }),
73
- /* @__PURE__ */ jsx("div", { className: "flex flex-col text-right", children: facilityInfo.name ? /* @__PURE__ */ jsxs("div", { className: "text-text-primary body-text", children: [
74
- /* @__PURE__ */ jsx("p", { children: facilityInfo.name }),
75
- facilityInfo.address && /* @__PURE__ */ jsx("p", { children: facilityInfo.address })
76
- ] }) : /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "No address available" }) }),
79
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col text-right", children: /* @__PURE__ */ jsx(PlaceValueCell, { place: facilityInfo }) }),
77
80
  /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "Website:" }) }),
78
81
  /* @__PURE__ */ jsx("div", { className: "flex flex-col text-right", children: team.officialWebsite ? /* @__PURE__ */ jsxs(
79
82
  "a",
@@ -298,10 +301,10 @@ function TeamStaffTable({
298
301
  splitLayout: isSplitLayout,
299
302
  numberOfColumns: 1,
300
303
  splitLayoutGridCols: isCompact ? "!grid-cols-[minmax(120px,120px)_1fr]" : isSplitLayout ? "sm:!grid-cols-[minmax(220px,220px)_1fr]" : "",
301
- containerClassName: cn2("border-0 rounded-none", effectiveVirtualized && "h-full"),
304
+ containerClassName: cn2("border-0 rounded-none xl:h-full", effectiveVirtualized && "h-full"),
302
305
  className: cn2(
303
- "border-none",
304
- effectiveVirtualized && "h-full min-h-0 w-full xl:flex-1 xl:overflow-hidden",
306
+ "border-none xl:flex-1 xl:min-h-0 xl:overflow-hidden",
307
+ effectiveVirtualized && "h-full min-h-0 w-full",
305
308
  className
306
309
  ),
307
310
  bottomContent: effectiveVirtualized && hasMore ? /* @__PURE__ */ jsx2("div", { ref: sentinelRef, className: "h-px w-full" }) : null,
@@ -1424,6 +1427,706 @@ function RecentGamesWidget({
1424
1427
  }
1425
1428
  );
1426
1429
  }
1430
+
1431
+ // src/team/team-stats-table.tsx
1432
+ import { useState as useState5 } from "react";
1433
+ import {
1434
+ BaseTable as BaseTable3,
1435
+ Card as Card7,
1436
+ CardContent as CardContent7,
1437
+ CardHeader as CardHeader6,
1438
+ CardTitle as CardTitle6,
1439
+ Select as Select2,
1440
+ SelectContent as SelectContent2,
1441
+ SelectItem as SelectItem2,
1442
+ SelectTrigger as SelectTrigger2,
1443
+ SelectValue as SelectValue2,
1444
+ Skeleton as Skeleton6,
1445
+ cn as cn13
1446
+ } from "@nukleus-sports/ui-web";
1447
+ import {
1448
+ getOrderedTeamStatTypesForCategory,
1449
+ getVisibleTeamStatTypes,
1450
+ showsTeamStatCategoryPicker
1451
+ } from "@nukleus-sports/core";
1452
+ import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
1453
+ function stripLeadingSlash(path) {
1454
+ return path.startsWith("/") ? path.slice(1) : path;
1455
+ }
1456
+ function isDefinedStatType(value) {
1457
+ return Boolean(value);
1458
+ }
1459
+ function getAvailableStatCategories(stats) {
1460
+ return Array.from(
1461
+ new Set(
1462
+ stats.flatMap(
1463
+ (stat) => (stat.stat_details?.stats ?? []).map((s) => s.stat_type).filter(isDefinedStatType)
1464
+ )
1465
+ )
1466
+ );
1467
+ }
1468
+ function deriveSelectedStatCategory(requested, available) {
1469
+ if (requested && available.includes(requested)) return requested;
1470
+ if (available.includes("offense")) return "offense";
1471
+ return available[0] ?? "offense";
1472
+ }
1473
+ function getStatsEmptyMessage(seasons, statsCount) {
1474
+ if (!seasons.selectedYear || seasons.selectedType === null) {
1475
+ return "Select a season to view stats.";
1476
+ }
1477
+ if (statsCount === 0) {
1478
+ const yearLabel = seasons.years.find((y) => y.value === seasons.selectedYear)?.label;
1479
+ const typeLabel = seasons.types.find((t) => t.value === seasons.selectedType)?.label;
1480
+ return `No stats available for ${yearLabel} - ${typeLabel}.`;
1481
+ }
1482
+ return "No stats found for this season";
1483
+ }
1484
+ function formatTeamStatDate(stat) {
1485
+ const dateStr = stat.stat_details?.game_details?.date;
1486
+ const date = dateStr ? new Date(dateStr) : null;
1487
+ if (!date || Number.isNaN(date.getTime())) {
1488
+ return /* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: "--" });
1489
+ }
1490
+ const formatted = date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
1491
+ return /* @__PURE__ */ jsx15("div", { className: "text-13.5 font-normal text-text-primary", children: formatted });
1492
+ }
1493
+ function getTeamStatResult(stat) {
1494
+ const gameDetails = stat.stat_details?.game_details;
1495
+ if (gameDetails?.home_team_score === void 0 || gameDetails?.away_team_score === void 0) {
1496
+ return "--";
1497
+ }
1498
+ const isHome = stat.team_id === gameDetails.home_team_id;
1499
+ const homeScore = gameDetails.home_team_score;
1500
+ const awayScore = gameDetails.away_team_score;
1501
+ let winLoss = "T";
1502
+ if (homeScore !== awayScore) {
1503
+ const teamWon = isHome ? homeScore > awayScore : awayScore > homeScore;
1504
+ winLoss = teamWon ? "W" : "L";
1505
+ }
1506
+ const teamScore = isHome ? homeScore : awayScore;
1507
+ const opponentScore = isHome ? awayScore : homeScore;
1508
+ const score = `${teamScore}-${opponentScore}${gameDetails.status_alt_details ? ` ${gameDetails.status_alt_details}` : ""}`;
1509
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
1510
+ return /* @__PURE__ */ jsxs15("div", { className: "flex items-baseline gap-1 leading-tight", children: [
1511
+ /* @__PURE__ */ jsx15("span", { className: cn13(colorClass, "body-text"), children: winLoss }),
1512
+ /* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: score })
1513
+ ] });
1514
+ }
1515
+ function StatOpponentCell({
1516
+ stat,
1517
+ resolveOpponentLogoUrl,
1518
+ defaultLogoUrl,
1519
+ showName
1520
+ }) {
1521
+ const [failedUrl, setFailedUrl] = useState5(null);
1522
+ const gameDetails = stat.stat_details?.game_details;
1523
+ const isHome = stat.team_id === gameDetails?.home_team_id;
1524
+ const opponentName = isHome ? gameDetails?.away_team_name : gameDetails?.home_team_name;
1525
+ const opponentLogoPath = isHome ? gameDetails?.away_team_logo : gameDetails?.home_team_logo;
1526
+ if (!opponentName) return /* @__PURE__ */ jsx15(Fragment4, { children: "--" });
1527
+ const prefix = isHome ? "vs" : "@";
1528
+ const resolved = opponentLogoPath ? resolveOpponentLogoUrl(stripLeadingSlash(opponentLogoPath)) : null;
1529
+ const logoSrc = resolved && resolved !== failedUrl ? resolved : defaultLogoUrl;
1530
+ return /* @__PURE__ */ jsx15("div", { className: "h-full overflow-hidden", children: /* @__PURE__ */ jsx15("div", { className: "flex items-center h-full", children: /* @__PURE__ */ jsxs15("div", { className: "flex max-sm:gap-1 gap-2 items-center font-normal leading-tight text-12", children: [
1531
+ /* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: prefix }),
1532
+ /* @__PURE__ */ jsx15(
1533
+ "img",
1534
+ {
1535
+ src: logoSrc,
1536
+ alt: showName ? "" : opponentName,
1537
+ className: "max-sm:w-5 max-sm:h-5 w-4 h-4 rounded-full flex-shrink-0",
1538
+ onError: () => {
1539
+ if (resolved) setFailedUrl(resolved);
1540
+ }
1541
+ }
1542
+ ),
1543
+ showName && /* @__PURE__ */ jsx15("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentName })
1544
+ ] }) }) });
1545
+ }
1546
+ function buildStatsColumns({
1547
+ filteredStatTypes,
1548
+ selectedStatCategory,
1549
+ resolveOpponentLogoUrl,
1550
+ defaultLogoUrl,
1551
+ isSm,
1552
+ isSmallLaptop
1553
+ }) {
1554
+ return [
1555
+ {
1556
+ id: "game_date",
1557
+ header: () => /* @__PURE__ */ jsx15("div", { className: "w-[50px] shrink-0", children: "Date" }),
1558
+ cell: ({ row }) => formatTeamStatDate(row.original),
1559
+ meta: { cellSize: isSm ? "xs" : "xxs", headerClassName: "h-auto" }
1560
+ },
1561
+ {
1562
+ id: "opponent",
1563
+ header: () => /* @__PURE__ */ jsx15("div", { children: isSm ? "Opponent" : "Opp" }),
1564
+ cell: ({ row }) => /* @__PURE__ */ jsx15(
1565
+ StatOpponentCell,
1566
+ {
1567
+ stat: row.original,
1568
+ resolveOpponentLogoUrl,
1569
+ defaultLogoUrl,
1570
+ showName: isSm
1571
+ }
1572
+ ),
1573
+ meta: {
1574
+ cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse",
1575
+ headerClassName: "h-auto"
1576
+ }
1577
+ },
1578
+ {
1579
+ id: "result",
1580
+ header: "Result",
1581
+ cell: ({ row }) => getTeamStatResult(row.original),
1582
+ meta: { cellSize: "xs", headerClassName: "h-auto", rowCellClassName: "!min-w-[70px]" }
1583
+ },
1584
+ ...filteredStatTypes.map((statType) => ({
1585
+ id: statType.name,
1586
+ header: statType.label || statType.name,
1587
+ cell: ({ row }) => {
1588
+ const value = row.original.stat_details?.stats?.find(
1589
+ (s) => s.stat_id === statType.id && s.stat_type === selectedStatCategory
1590
+ )?.stat_value;
1591
+ return value !== void 0 ? value : "--";
1592
+ },
1593
+ meta: {
1594
+ cellSize: "xxs",
1595
+ headerClassName: "h-auto py-0 !whitespace-normal !overflow-visible !text-clip !break-words !line-clamp-2"
1596
+ }
1597
+ }))
1598
+ ];
1599
+ }
1600
+ function StatsBody2({
1601
+ seasons,
1602
+ showsCategoryPicker,
1603
+ selectedStatCategory,
1604
+ availableStatCategories,
1605
+ onStatCategoryChange,
1606
+ isStatTypesError,
1607
+ hasVisibleStatTypes,
1608
+ columns,
1609
+ stats,
1610
+ statsLoading,
1611
+ isStatsError,
1612
+ isSm,
1613
+ isSmallLaptop,
1614
+ emptyMessage
1615
+ }) {
1616
+ return /* @__PURE__ */ jsxs15(Fragment4, { children: [
1617
+ /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 min-[360px]:gap-3", children: [
1618
+ /* @__PURE__ */ jsx15(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
1619
+ showsCategoryPicker && /* @__PURE__ */ jsxs15(
1620
+ Select2,
1621
+ {
1622
+ value: selectedStatCategory,
1623
+ onValueChange: onStatCategoryChange,
1624
+ disabled: !seasons.selectedYear || seasons.selectedType === null,
1625
+ children: [
1626
+ /* @__PURE__ */ jsx15(SelectTrigger2, { variant: "widget", size: "widget", "aria-label": "Stat category", children: /* @__PURE__ */ jsx15(SelectValue2, { placeholder: "Select stat category" }) }),
1627
+ /* @__PURE__ */ jsx15(
1628
+ SelectContent2,
1629
+ {
1630
+ className: "bg-popover border-border z-50 [&_.checkbox]:!flex",
1631
+ classNameViewPort: "gap-2",
1632
+ children: availableStatCategories.map((category) => /* @__PURE__ */ jsx15(SelectItem2, { value: category, className: "capitalize min-h-8", children: category.charAt(0).toUpperCase() + category.slice(1) }, category))
1633
+ }
1634
+ )
1635
+ ]
1636
+ }
1637
+ )
1638
+ ] }),
1639
+ /* @__PURE__ */ jsxs15("div", { className: "space-y-4 xl:flex-1 xl:min-h-0 xl:overflow-hidden", children: [
1640
+ isStatTypesError && !hasVisibleStatTypes && /* @__PURE__ */ jsx15("p", { className: "text-text-secondary text-13.5", children: "Couldn't load stat categories -- showing limited columns." }),
1641
+ /* @__PURE__ */ jsx15(
1642
+ BaseTable3,
1643
+ {
1644
+ columns,
1645
+ data: stats,
1646
+ pageSize: stats.length || 10,
1647
+ hidePagination: true,
1648
+ stickyHeader: true,
1649
+ splitLayout: isSmallLaptop || !isSm,
1650
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
1651
+ loading: statsLoading,
1652
+ containerClassName: "border-0 rounded-none h-full",
1653
+ className: "border-none xl:h-full xl:min-h-0",
1654
+ numberOfColumns: 2,
1655
+ emptyMessage: isStatsError && stats.length === 0 ? "Couldn't load stats. Please try again." : emptyMessage
1656
+ }
1657
+ )
1658
+ ] })
1659
+ ] });
1660
+ }
1661
+ function TeamStatsTable({
1662
+ stats,
1663
+ statsLoading = false,
1664
+ isStatsError = false,
1665
+ statTypes,
1666
+ isStatTypesError = false,
1667
+ sportId,
1668
+ isTeamError = false,
1669
+ resolveOpponentLogoUrl,
1670
+ defaultLogoUrl,
1671
+ seasons,
1672
+ seasonsLoading = false,
1673
+ isSeasonsError = false,
1674
+ isSm,
1675
+ isSmallLaptop,
1676
+ className
1677
+ }) {
1678
+ const [requestedStatCategory, setRequestedStatCategory] = useState5(null);
1679
+ const availableStatCategories = getAvailableStatCategories(stats);
1680
+ const selectedStatCategory = deriveSelectedStatCategory(
1681
+ requestedStatCategory,
1682
+ availableStatCategories
1683
+ );
1684
+ if (isTeamError) {
1685
+ return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-0", className), children: /* @__PURE__ */ jsx15(CardContent7, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ jsx15("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
1686
+ }
1687
+ if (seasonsLoading || sportId === null) {
1688
+ return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-0", className), children: /* @__PURE__ */ jsxs15(CardContent7, { className: "space-y-4 pt-6", children: [
1689
+ /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-3 sm:flex-row justify-start", children: [
1690
+ /* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[68px] bg-form rounded-[5px]" }),
1691
+ /* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[142px] bg-form rounded-[5px]" }),
1692
+ /* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[102px] bg-form rounded-[5px]" })
1693
+ ] }),
1694
+ /* @__PURE__ */ jsx15(Skeleton6, { className: "h-40 w-full bg-form !mt-3" })
1695
+ ] }) });
1696
+ }
1697
+ if (!seasons || seasons.years.length === 0) {
1698
+ return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-none", className), children: /* @__PURE__ */ jsx15(CardContent7, { className: "pt-6", children: /* @__PURE__ */ jsx15("div", { className: "text-center py-8", children: /* @__PURE__ */ jsx15("p", { className: "text-text-primary text-14.5 font-normal leading-normal", children: isSeasonsError ? "Couldn't load stats. Please try again." : "There are no stats for this team at this time." }) }) }) });
1699
+ }
1700
+ const visibleStatTypes = getVisibleTeamStatTypes(statTypes, sportId);
1701
+ const filteredStatTypes = getOrderedTeamStatTypesForCategory(
1702
+ visibleStatTypes,
1703
+ sportId,
1704
+ selectedStatCategory
1705
+ );
1706
+ const showsCategoryPicker = availableStatCategories.length > 0 && showsTeamStatCategoryPicker(sportId);
1707
+ const columns = buildStatsColumns({
1708
+ filteredStatTypes,
1709
+ selectedStatCategory,
1710
+ resolveOpponentLogoUrl,
1711
+ defaultLogoUrl,
1712
+ isSm,
1713
+ isSmallLaptop
1714
+ });
1715
+ const emptyMessage = getStatsEmptyMessage(seasons, stats.length);
1716
+ return /* @__PURE__ */ jsxs15(
1717
+ Card7,
1718
+ {
1719
+ className: cn13(
1720
+ "border-none p-4 flex flex-col gap-3 xl:h-full xl:min-h-0 xl:flex-1 xl:overflow-hidden",
1721
+ className
1722
+ ),
1723
+ children: [
1724
+ /* @__PURE__ */ jsx15(CardHeader6, { className: "p-0", children: /* @__PURE__ */ jsx15(CardTitle6, { children: "Stats" }) }),
1725
+ /* @__PURE__ */ jsx15(CardContent7, { className: "space-y-0 p-0 flex flex-col gap-3 xl:flex-1 xl:min-h-0", children: /* @__PURE__ */ jsx15(
1726
+ StatsBody2,
1727
+ {
1728
+ seasons,
1729
+ showsCategoryPicker,
1730
+ selectedStatCategory,
1731
+ availableStatCategories,
1732
+ onStatCategoryChange: setRequestedStatCategory,
1733
+ isStatTypesError,
1734
+ hasVisibleStatTypes: visibleStatTypes.length > 0,
1735
+ columns,
1736
+ stats,
1737
+ statsLoading,
1738
+ isStatsError,
1739
+ isSm,
1740
+ isSmallLaptop,
1741
+ emptyMessage
1742
+ }
1743
+ ) })
1744
+ ]
1745
+ }
1746
+ );
1747
+ }
1748
+
1749
+ // src/team/team-schedule-table.tsx
1750
+ import {
1751
+ BaseTable as BaseTable4,
1752
+ Card as Card8,
1753
+ CardContent as CardContent8,
1754
+ CardHeader as CardHeader7,
1755
+ CardTitle as CardTitle7,
1756
+ IconLoader as IconLoader3,
1757
+ cn as cn14
1758
+ } from "@nukleus-sports/ui-web";
1759
+ import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
1760
+ var SPECIAL_LOGO_LEAGUES = ["NFL", "NBA", "NHL", "MLB", "WNBA"];
1761
+ var COLLEGE_LEAGUE_IDS = [2, 6, 13];
1762
+ var COMPLETED_STATUS_ID = "3";
1763
+ var DATE_FORMAT2 = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" });
1764
+ function firstCompetition(game) {
1765
+ return game.game_details?.competitions?.[0];
1766
+ }
1767
+ function formatScore(score) {
1768
+ if (score?.displayValue) return score.displayValue;
1769
+ if (typeof score?.value === "number") return String(score.value);
1770
+ return "0";
1771
+ }
1772
+ function findCompetitor(competitors, teamEspnId) {
1773
+ if (!competitors || competitors.length !== 2 || !teamEspnId) return null;
1774
+ const [first, second] = competitors;
1775
+ if (!first || !second) return null;
1776
+ if (first.id === teamEspnId) return { own: first, other: second };
1777
+ if (second.id === teamEspnId) return { own: second, other: first };
1778
+ return null;
1779
+ }
1780
+ function findLeader(competitors, leaderType) {
1781
+ if (!competitors || competitors.length !== 2) return null;
1782
+ for (const competitor of competitors) {
1783
+ const leader = competitor?.leaders?.find((entry) => entry.name === leaderType);
1784
+ const top = leader?.leaders?.[0];
1785
+ if (top?.athlete) {
1786
+ return {
1787
+ displayName: top.athlete.displayName || "--",
1788
+ displayValue: top.displayValue || "--"
1789
+ };
1790
+ }
1791
+ }
1792
+ return null;
1793
+ }
1794
+ function showsFootballLeaders(leagueId) {
1795
+ return leagueId !== null && [1, 2, 13].includes(leagueId);
1796
+ }
1797
+ function showsBasketballLeaders(leagueId) {
1798
+ return leagueId !== null && [4, 5, 6].includes(leagueId);
1799
+ }
1800
+ function showsHockeyLeaders(leagueId) {
1801
+ return leagueId === 14;
1802
+ }
1803
+ function showsMlbLeaders(leagueId) {
1804
+ return leagueId === 7;
1805
+ }
1806
+ function leaderCell(leader, small = false) {
1807
+ if (!leader) return "--";
1808
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col leading-tight", children: [
1809
+ /* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: leader.displayName }),
1810
+ /* @__PURE__ */ jsx16(
1811
+ "span",
1812
+ {
1813
+ className: cn14(
1814
+ small ? "text-text-secondary text-11" : "text-text-primary body-text",
1815
+ "truncate"
1816
+ ),
1817
+ children: leader.displayValue
1818
+ }
1819
+ )
1820
+ ] });
1821
+ }
1822
+ function formatScheduleDate(game) {
1823
+ if (!game.game_details) return "--";
1824
+ try {
1825
+ const { timeValid, date: rawDate } = game.game_details;
1826
+ const date = timeValid ? new Date(rawDate) : (() => {
1827
+ const [year, month, day] = rawDate.split("T")[0].split("-").map(Number);
1828
+ return new Date(year, month - 1, day);
1829
+ })();
1830
+ return /* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text", children: DATE_FORMAT2.format(date) });
1831
+ } catch {
1832
+ return "--";
1833
+ }
1834
+ }
1835
+ function getScheduleResult(game, teamEspnId) {
1836
+ const competition = firstCompetition(game);
1837
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return null;
1838
+ const match = findCompetitor(competition.competitors, teamEspnId);
1839
+ if (!match) return null;
1840
+ const { own, other } = match;
1841
+ const ownValue = own.score?.value;
1842
+ const otherValue = other.score?.value;
1843
+ const scoresKnown = typeof ownValue === "number" && typeof otherValue === "number";
1844
+ const tied = scoresKnown && ownValue === otherValue;
1845
+ const winLoss = tied ? "T" : own.winner === true ? "W" : "L";
1846
+ const score = `${formatScore(own.score)}-${formatScore(other.score)}`;
1847
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
1848
+ return /* @__PURE__ */ jsxs16("div", { className: "flex items-baseline gap-1 leading-tight", children: [
1849
+ /* @__PURE__ */ jsx16("span", { className: cn14(colorClass, "body-text"), children: winLoss }),
1850
+ /* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text", children: score })
1851
+ ] });
1852
+ }
1853
+ function getScheduleRecord(game, teamEspnId) {
1854
+ const competition = firstCompetition(game);
1855
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return "--";
1856
+ return findCompetitor(competition.competitors, teamEspnId)?.own.record?.[0]?.displayValue || "--";
1857
+ }
1858
+ function getWinningGoalie(game) {
1859
+ const athlete = firstCompetition(game)?.featuredAthletes?.[0]?.athlete;
1860
+ if (!athlete?.lastName) return "--";
1861
+ return /* @__PURE__ */ jsx16("div", { className: "flex flex-col leading-tight", children: /* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }) });
1862
+ }
1863
+ function getHockeyTopPlayer(game) {
1864
+ const competitors = firstCompetition(game)?.competitors;
1865
+ const competitor = competitors?.find((c) => c?.leaders?.[0]?.leaders?.length);
1866
+ const top = competitor?.leaders?.[0]?.leaders?.[0];
1867
+ if (!top?.athlete?.lastName) return "--";
1868
+ return leaderCell(
1869
+ { displayName: top.athlete.lastName, displayValue: top.displayValue || "--" },
1870
+ true
1871
+ );
1872
+ }
1873
+ function getMlbPitcher(game, pitcherType) {
1874
+ const pitcher = firstCompetition(game)?.featuredAthletes?.find((a) => a.name === pitcherType);
1875
+ const athlete = pitcher?.athlete;
1876
+ if (!athlete?.lastName) return "--";
1877
+ const stat = pitcherType === "savingPitcher" ? athlete.saves : athlete.record;
1878
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col leading-tight", children: [
1879
+ /* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }),
1880
+ /* @__PURE__ */ jsx16("span", { className: "text-text-secondary text-11 truncate", children: stat || "--" })
1881
+ ] });
1882
+ }
1883
+ function OpponentCell({
1884
+ game,
1885
+ teamEspnId,
1886
+ leagueId,
1887
+ leagueAbbreviation,
1888
+ resolveLogoUrl,
1889
+ defaultLogoUrl,
1890
+ showName
1891
+ }) {
1892
+ const match = findCompetitor(firstCompetition(game)?.competitors, teamEspnId);
1893
+ if (!match || leagueId === null || !leagueAbbreviation) return /* @__PURE__ */ jsx16(Fragment5, { children: "--" });
1894
+ const prefix = match.own.homeAway === "home" ? "vs" : "@";
1895
+ const opponentTeam = match.other.team;
1896
+ const isSpecialLeague = SPECIAL_LOGO_LEAGUES.includes(leagueAbbreviation);
1897
+ const identifier = isSpecialLeague ? opponentTeam.abbreviation : opponentTeam.id;
1898
+ const folder = COLLEGE_LEAGUE_IDS.includes(leagueId) ? "NCAA" : leagueAbbreviation;
1899
+ return /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1 sm:gap-2 h-full overflow-hidden", children: [
1900
+ /* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text shrink-0 sm:w-4", children: prefix }),
1901
+ /* @__PURE__ */ jsx16(
1902
+ "img",
1903
+ {
1904
+ src: resolveLogoUrl(folder, identifier),
1905
+ alt: showName ? "" : opponentTeam.displayName,
1906
+ loading: "lazy",
1907
+ className: "h-5 w-5 shrink-0 inline sm:h-6 sm:w-6 sm:mr-2",
1908
+ onError: (event) => {
1909
+ event.currentTarget.src = defaultLogoUrl;
1910
+ }
1911
+ }
1912
+ ),
1913
+ showName && /* @__PURE__ */ jsx16("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentTeam.displayName })
1914
+ ] });
1915
+ }
1916
+ function buildScheduleColumns({
1917
+ leagueId,
1918
+ leagueAbbreviation,
1919
+ teamEspnId,
1920
+ resolveLogoUrl,
1921
+ defaultLogoUrl,
1922
+ isSm,
1923
+ isSmallLaptop
1924
+ }) {
1925
+ const showsHockey = showsHockeyLeaders(leagueId);
1926
+ return [
1927
+ {
1928
+ id: "game_date",
1929
+ header: () => /* @__PURE__ */ jsx16("div", { className: "w-[50px] shrink-0", children: "Date" }),
1930
+ accessorFn: (row) => row.game_date,
1931
+ cell: ({ row }) => formatScheduleDate(row.original),
1932
+ meta: { cellSize: isSm ? "xs" : "xxs" }
1933
+ },
1934
+ {
1935
+ id: "opponent",
1936
+ header: () => /* @__PURE__ */ jsx16("div", { children: isSm ? "Opponent" : "Opp" }),
1937
+ cell: ({ row }) => /* @__PURE__ */ jsx16(
1938
+ OpponentCell,
1939
+ {
1940
+ game: row.original,
1941
+ teamEspnId,
1942
+ leagueId,
1943
+ leagueAbbreviation,
1944
+ resolveLogoUrl,
1945
+ defaultLogoUrl,
1946
+ showName: isSm
1947
+ }
1948
+ ),
1949
+ meta: { cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse" }
1950
+ },
1951
+ {
1952
+ id: "result",
1953
+ header: "Result",
1954
+ cell: ({ row }) => getScheduleResult(row.original, teamEspnId) ?? "--",
1955
+ meta: { cellSize: "xs" }
1956
+ },
1957
+ {
1958
+ id: "record",
1959
+ header: showsHockey ? "W-L-OTL" : "W-L",
1960
+ cell: ({ row }) => getScheduleRecord(row.original, teamEspnId),
1961
+ meta: { cellSize: "xs" }
1962
+ },
1963
+ ...showsMlbLeaders(leagueId) ? [
1964
+ {
1965
+ id: "win",
1966
+ header: "Win",
1967
+ cell: ({ row }) => getMlbPitcher(row.original, "winningPitcher"),
1968
+ meta: { cellSize: "s" }
1969
+ },
1970
+ {
1971
+ id: "loss",
1972
+ header: "Loss",
1973
+ cell: ({ row }) => getMlbPitcher(row.original, "losingPitcher"),
1974
+ meta: { cellSize: "s" }
1975
+ },
1976
+ {
1977
+ id: "save",
1978
+ header: "Save",
1979
+ cell: ({ row }) => getMlbPitcher(row.original, "savingPitcher"),
1980
+ meta: { cellSize: "s" }
1981
+ }
1982
+ ] : [],
1983
+ ...showsBasketballLeaders(leagueId) ? [
1984
+ {
1985
+ id: "topPts",
1986
+ header: "Top Pts",
1987
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "points"), true),
1988
+ meta: { cellSize: "s" }
1989
+ },
1990
+ {
1991
+ id: "topReb",
1992
+ header: "Top Reb",
1993
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rebounds"), true),
1994
+ meta: { cellSize: "s" }
1995
+ },
1996
+ {
1997
+ id: "topAst",
1998
+ header: "Top Ast",
1999
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "assists"), true),
2000
+ meta: { cellSize: "s" }
2001
+ }
2002
+ ] : [],
2003
+ ...showsHockey ? [
2004
+ {
2005
+ id: "wGoalie",
2006
+ header: "W Goalie",
2007
+ cell: ({ row }) => getWinningGoalie(row.original),
2008
+ meta: { cellSize: "s" }
2009
+ },
2010
+ {
2011
+ id: "topPlayer",
2012
+ header: "Top Player",
2013
+ cell: ({ row }) => getHockeyTopPlayer(row.original),
2014
+ meta: { cellSize: "s" }
2015
+ }
2016
+ ] : [],
2017
+ ...showsFootballLeaders(leagueId) ? [
2018
+ {
2019
+ id: "topPass",
2020
+ header: "Top Pass",
2021
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "passingLeader")),
2022
+ meta: { cellSize: "l" }
2023
+ },
2024
+ {
2025
+ id: "topRush",
2026
+ header: "Top Rush",
2027
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rushingLeader")),
2028
+ meta: { cellSize: "l" }
2029
+ },
2030
+ {
2031
+ id: "topRec",
2032
+ header: "Top Rec",
2033
+ cell: ({ row }) => leaderCell(
2034
+ findLeader(firstCompetition(row.original)?.competitors, "receivingLeader")
2035
+ ),
2036
+ meta: { cellSize: "l" }
2037
+ }
2038
+ ] : []
2039
+ ];
2040
+ }
2041
+ function ScheduleBody({
2042
+ seasonsLoading,
2043
+ seasons,
2044
+ isSeasonsError,
2045
+ columns,
2046
+ games,
2047
+ gamesLoading,
2048
+ isGamesError,
2049
+ isSm,
2050
+ isSmallLaptop
2051
+ }) {
2052
+ if (seasonsLoading) {
2053
+ return /* @__PURE__ */ jsx16("div", { className: "flex justify-center py-8", children: /* @__PURE__ */ jsx16("div", { className: "text-sm text-text-primary", children: "Loading seasons..." }) });
2054
+ }
2055
+ if (!seasons || seasons.years.length === 0) {
2056
+ return /* @__PURE__ */ jsx16("div", { className: "text-center py-8", children: /* @__PURE__ */ jsx16("p", { className: "text-text-primary", children: isSeasonsError ? "Couldn't load seasons. Please try again." : "No seasons found" }) });
2057
+ }
2058
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-3", children: [
2059
+ /* @__PURE__ */ jsx16(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
2060
+ /* @__PURE__ */ jsx16("div", { children: /* @__PURE__ */ jsx16(
2061
+ BaseTable4,
2062
+ {
2063
+ columns,
2064
+ data: games,
2065
+ pageSize: games.length || 10,
2066
+ splitLayout: isSmallLaptop || !isSm,
2067
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
2068
+ loading: gamesLoading,
2069
+ containerClassName: "border-0 rounded-none h-full",
2070
+ className: "h-full border-none",
2071
+ numberOfColumns: 2,
2072
+ emptyMessage: isGamesError ? "Couldn't load games. Please try again." : "No games found for this season"
2073
+ }
2074
+ ) })
2075
+ ] });
2076
+ }
2077
+ function TeamScheduleTable({
2078
+ games,
2079
+ gamesLoading = false,
2080
+ isGamesError = false,
2081
+ leagueId,
2082
+ leagueAbbreviation,
2083
+ isTeamError = false,
2084
+ teamEspnId,
2085
+ resolveLogoUrl,
2086
+ defaultLogoUrl,
2087
+ seasons,
2088
+ seasonsLoading = false,
2089
+ isSeasonsError = false,
2090
+ isSm,
2091
+ isSmallLaptop,
2092
+ className
2093
+ }) {
2094
+ const columns = buildScheduleColumns({
2095
+ leagueId,
2096
+ leagueAbbreviation,
2097
+ teamEspnId,
2098
+ resolveLogoUrl,
2099
+ defaultLogoUrl,
2100
+ isSm,
2101
+ isSmallLaptop
2102
+ });
2103
+ if (isTeamError) {
2104
+ return /* @__PURE__ */ jsx16(Card8, { className: cn14("border-0", className), children: /* @__PURE__ */ jsx16(CardContent8, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ jsx16("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
2105
+ }
2106
+ if (leagueId === null) {
2107
+ return /* @__PURE__ */ jsx16(Card8, { className: cn14("border-0", className), children: /* @__PURE__ */ jsxs16(CardContent8, { className: "p-4 flex justify-center items-center gap-2", children: [
2108
+ /* @__PURE__ */ jsx16(IconLoader3, {}),
2109
+ /* @__PURE__ */ jsx16("p", { className: "text-text-secondary", children: "Loading team information..." })
2110
+ ] }) });
2111
+ }
2112
+ return /* @__PURE__ */ jsxs16(Card8, { className: cn14("border-none p-4 flex flex-col gap-3", className), children: [
2113
+ /* @__PURE__ */ jsx16(CardHeader7, { className: "p-0 flex flex-row items-center justify-between space-y-0", children: /* @__PURE__ */ jsx16(CardTitle7, { children: "Schedule" }) }),
2114
+ /* @__PURE__ */ jsx16(CardContent8, { className: "space-y-0 p-0 flex flex-col gap-3", children: /* @__PURE__ */ jsx16(
2115
+ ScheduleBody,
2116
+ {
2117
+ seasonsLoading,
2118
+ seasons,
2119
+ isSeasonsError,
2120
+ columns,
2121
+ games,
2122
+ gamesLoading,
2123
+ isGamesError,
2124
+ isSm,
2125
+ isSmallLaptop
2126
+ }
2127
+ ) })
2128
+ ] });
2129
+ }
1427
2130
  export {
1428
2131
  EmptyValue,
1429
2132
  FactField,
@@ -1436,10 +2139,12 @@ export {
1436
2139
  TeamFactsContent,
1437
2140
  TeamFactsWidget,
1438
2141
  TeamInfoCard,
2142
+ TeamScheduleTable,
1439
2143
  TeamSeasonScheduleSummaryPanel,
1440
2144
  TeamSeasonStatsSummaryPanel,
1441
2145
  TeamSeasonStatsWidget,
1442
2146
  TeamStaffTable,
2147
+ TeamStatsTable,
1443
2148
  VenuePhoto
1444
2149
  };
1445
2150
  //# sourceMappingURL=team.js.map