@nukleus-sports/ui-patterns 0.5.0 → 0.6.0

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.cjs CHANGED
@@ -31,10 +31,12 @@ __export(team_exports, {
31
31
  TeamFactsContent: () => TeamFactsContent,
32
32
  TeamFactsWidget: () => TeamFactsWidget,
33
33
  TeamInfoCard: () => TeamInfoCard,
34
+ TeamScheduleTable: () => TeamScheduleTable,
34
35
  TeamSeasonScheduleSummaryPanel: () => TeamSeasonScheduleSummaryPanel,
35
36
  TeamSeasonStatsSummaryPanel: () => TeamSeasonStatsSummaryPanel,
36
37
  TeamSeasonStatsWidget: () => TeamSeasonStatsWidget,
37
38
  TeamStaffTable: () => TeamStaffTable,
39
+ TeamStatsTable: () => TeamStatsTable,
38
40
  VenuePhoto: () => VenuePhoto
39
41
  });
40
42
  module.exports = __toCommonJS(team_exports);
@@ -1619,6 +1621,681 @@ function RecentGamesWidget({
1619
1621
  }
1620
1622
  );
1621
1623
  }
1624
+
1625
+ // src/team/team-stats-table.tsx
1626
+ var import_react6 = require("react");
1627
+ var import_ui_web14 = require("@nukleus-sports/ui-web");
1628
+ var import_core9 = require("@nukleus-sports/core");
1629
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1630
+ function stripLeadingSlash(path) {
1631
+ return path.startsWith("/") ? path.slice(1) : path;
1632
+ }
1633
+ function isDefinedStatType(value) {
1634
+ return Boolean(value);
1635
+ }
1636
+ function getAvailableStatCategories(stats) {
1637
+ return Array.from(
1638
+ new Set(
1639
+ stats.flatMap(
1640
+ (stat) => (stat.stat_details?.stats ?? []).map((s) => s.stat_type).filter(isDefinedStatType)
1641
+ )
1642
+ )
1643
+ );
1644
+ }
1645
+ function deriveSelectedStatCategory(requested, available) {
1646
+ if (requested && available.includes(requested)) return requested;
1647
+ if (available.includes("offense")) return "offense";
1648
+ return available[0] ?? "offense";
1649
+ }
1650
+ function getStatsEmptyMessage(seasons, statsCount) {
1651
+ if (!seasons.selectedYear || seasons.selectedType === null) {
1652
+ return "Select a season to view stats.";
1653
+ }
1654
+ if (statsCount === 0) {
1655
+ const yearLabel = seasons.years.find((y) => y.value === seasons.selectedYear)?.label;
1656
+ const typeLabel = seasons.types.find((t) => t.value === seasons.selectedType)?.label;
1657
+ return `No stats available for ${yearLabel} - ${typeLabel}.`;
1658
+ }
1659
+ return "No stats found for this season";
1660
+ }
1661
+ function formatTeamStatDate(stat) {
1662
+ const dateStr = stat.stat_details?.game_details?.date;
1663
+ const date = dateStr ? new Date(dateStr) : null;
1664
+ if (!date || Number.isNaN(date.getTime())) {
1665
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: "--" });
1666
+ }
1667
+ const formatted = date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
1668
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-13.5 font-normal text-text-primary", children: formatted });
1669
+ }
1670
+ function getTeamStatResult(stat) {
1671
+ const gameDetails = stat.stat_details?.game_details;
1672
+ if (gameDetails?.home_team_score === void 0 || gameDetails?.away_team_score === void 0) {
1673
+ return "--";
1674
+ }
1675
+ const isHome = stat.team_id === gameDetails.home_team_id;
1676
+ const homeScore = gameDetails.home_team_score;
1677
+ const awayScore = gameDetails.away_team_score;
1678
+ let winLoss = "T";
1679
+ if (homeScore !== awayScore) {
1680
+ const teamWon = isHome ? homeScore > awayScore : awayScore > homeScore;
1681
+ winLoss = teamWon ? "W" : "L";
1682
+ }
1683
+ const teamScore = isHome ? homeScore : awayScore;
1684
+ const opponentScore = isHome ? awayScore : homeScore;
1685
+ const score = `${teamScore}-${opponentScore}${gameDetails.status_alt_details ? ` ${gameDetails.status_alt_details}` : ""}`;
1686
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
1687
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-baseline gap-1 leading-tight", children: [
1688
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: (0, import_ui_web14.cn)(colorClass, "body-text"), children: winLoss }),
1689
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: score })
1690
+ ] });
1691
+ }
1692
+ function StatOpponentCell({
1693
+ stat,
1694
+ resolveOpponentLogoUrl,
1695
+ defaultLogoUrl,
1696
+ showName
1697
+ }) {
1698
+ const [failedUrl, setFailedUrl] = (0, import_react6.useState)(null);
1699
+ const gameDetails = stat.stat_details?.game_details;
1700
+ const isHome = stat.team_id === gameDetails?.home_team_id;
1701
+ const opponentName = isHome ? gameDetails?.away_team_name : gameDetails?.home_team_name;
1702
+ const opponentLogoPath = isHome ? gameDetails?.away_team_logo : gameDetails?.home_team_logo;
1703
+ if (!opponentName) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: "--" });
1704
+ const prefix = isHome ? "vs" : "@";
1705
+ const resolved = opponentLogoPath ? resolveOpponentLogoUrl(stripLeadingSlash(opponentLogoPath)) : null;
1706
+ const logoSrc = resolved && resolved !== failedUrl ? resolved : defaultLogoUrl;
1707
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "h-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex items-center h-full", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex max-sm:gap-1 gap-2 items-center font-normal leading-tight text-12", children: [
1708
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: prefix }),
1709
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1710
+ "img",
1711
+ {
1712
+ src: logoSrc,
1713
+ alt: showName ? "" : opponentName,
1714
+ className: "max-sm:w-5 max-sm:h-5 w-4 h-4 rounded-full flex-shrink-0",
1715
+ onError: () => {
1716
+ if (resolved) setFailedUrl(resolved);
1717
+ }
1718
+ }
1719
+ ),
1720
+ showName && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentName })
1721
+ ] }) }) });
1722
+ }
1723
+ function buildStatsColumns({
1724
+ filteredStatTypes,
1725
+ selectedStatCategory,
1726
+ resolveOpponentLogoUrl,
1727
+ defaultLogoUrl,
1728
+ isSm,
1729
+ isSmallLaptop
1730
+ }) {
1731
+ return [
1732
+ {
1733
+ id: "game_date",
1734
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "w-[50px] shrink-0", children: "Date" }),
1735
+ cell: ({ row }) => formatTeamStatDate(row.original),
1736
+ meta: { cellSize: isSm ? "xs" : "xxs", headerClassName: "h-auto" }
1737
+ },
1738
+ {
1739
+ id: "opponent",
1740
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { children: isSm ? "Opponent" : "Opp" }),
1741
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1742
+ StatOpponentCell,
1743
+ {
1744
+ stat: row.original,
1745
+ resolveOpponentLogoUrl,
1746
+ defaultLogoUrl,
1747
+ showName: isSm
1748
+ }
1749
+ ),
1750
+ meta: {
1751
+ cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse",
1752
+ headerClassName: "h-auto"
1753
+ }
1754
+ },
1755
+ {
1756
+ id: "result",
1757
+ header: "Result",
1758
+ cell: ({ row }) => getTeamStatResult(row.original),
1759
+ meta: { cellSize: "xs", headerClassName: "h-auto", rowCellClassName: "!min-w-[70px]" }
1760
+ },
1761
+ ...filteredStatTypes.map((statType) => ({
1762
+ id: statType.name,
1763
+ header: statType.label || statType.name,
1764
+ cell: ({ row }) => {
1765
+ const value = row.original.stat_details?.stats?.find(
1766
+ (s) => s.stat_id === statType.id && s.stat_type === selectedStatCategory
1767
+ )?.stat_value;
1768
+ return value !== void 0 ? value : "--";
1769
+ },
1770
+ meta: {
1771
+ cellSize: "xxs",
1772
+ headerClassName: "h-auto py-0 !whitespace-normal !overflow-visible !text-clip !break-words !line-clamp-2"
1773
+ }
1774
+ }))
1775
+ ];
1776
+ }
1777
+ function StatsBody2({
1778
+ seasons,
1779
+ showsCategoryPicker,
1780
+ selectedStatCategory,
1781
+ availableStatCategories,
1782
+ onStatCategoryChange,
1783
+ isStatTypesError,
1784
+ hasVisibleStatTypes,
1785
+ columns,
1786
+ stats,
1787
+ statsLoading,
1788
+ isStatsError,
1789
+ isSm,
1790
+ isSmallLaptop,
1791
+ emptyMessage
1792
+ }) {
1793
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
1794
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2 min-[360px]:gap-3", children: [
1795
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
1796
+ showsCategoryPicker && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1797
+ import_ui_web14.Select,
1798
+ {
1799
+ value: selectedStatCategory,
1800
+ onValueChange: onStatCategoryChange,
1801
+ disabled: !seasons.selectedYear || seasons.selectedType === null,
1802
+ children: [
1803
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Stat category", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectValue, { placeholder: "Select stat category" }) }),
1804
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1805
+ import_ui_web14.SelectContent,
1806
+ {
1807
+ className: "bg-popover border-border z-50 [&_.checkbox]:!flex",
1808
+ classNameViewPort: "gap-2",
1809
+ children: availableStatCategories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectItem, { value: category, className: "capitalize min-h-8", children: category.charAt(0).toUpperCase() + category.slice(1) }, category))
1810
+ }
1811
+ )
1812
+ ]
1813
+ }
1814
+ )
1815
+ ] }),
1816
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-4 xl:flex-1 xl:min-h-0 xl:overflow-hidden", children: [
1817
+ isStatTypesError && !hasVisibleStatTypes && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-text-secondary text-13.5", children: "Couldn't load stat categories -- showing limited columns." }),
1818
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1819
+ import_ui_web14.BaseTable,
1820
+ {
1821
+ columns,
1822
+ data: stats,
1823
+ pageSize: stats.length || 10,
1824
+ hidePagination: true,
1825
+ stickyHeader: true,
1826
+ splitLayout: isSmallLaptop || !isSm,
1827
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
1828
+ loading: statsLoading,
1829
+ containerClassName: "border-0 rounded-none h-full",
1830
+ className: "border-none xl:h-full xl:min-h-0",
1831
+ numberOfColumns: 2,
1832
+ emptyMessage: isStatsError && stats.length === 0 ? "Couldn't load stats. Please try again." : emptyMessage
1833
+ }
1834
+ )
1835
+ ] })
1836
+ ] });
1837
+ }
1838
+ function TeamStatsTable({
1839
+ stats,
1840
+ statsLoading = false,
1841
+ isStatsError = false,
1842
+ statTypes,
1843
+ isStatTypesError = false,
1844
+ sportId,
1845
+ isTeamError = false,
1846
+ resolveOpponentLogoUrl,
1847
+ defaultLogoUrl,
1848
+ seasons,
1849
+ seasonsLoading = false,
1850
+ isSeasonsError = false,
1851
+ isSm,
1852
+ isSmallLaptop,
1853
+ className
1854
+ }) {
1855
+ const [requestedStatCategory, setRequestedStatCategory] = (0, import_react6.useState)(null);
1856
+ const availableStatCategories = getAvailableStatCategories(stats);
1857
+ const selectedStatCategory = deriveSelectedStatCategory(
1858
+ requestedStatCategory,
1859
+ availableStatCategories
1860
+ );
1861
+ if (isTeamError) {
1862
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
1863
+ }
1864
+ if (seasonsLoading || sportId === null) {
1865
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_ui_web14.CardContent, { className: "space-y-4 pt-6", children: [
1866
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-3 sm:flex-row justify-start", children: [
1867
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[68px] bg-form rounded-[5px]" }),
1868
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[142px] bg-form rounded-[5px]" }),
1869
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[102px] bg-form rounded-[5px]" })
1870
+ ] }),
1871
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-40 w-full bg-form !mt-3" })
1872
+ ] }) });
1873
+ }
1874
+ if (!seasons || seasons.years.length === 0) {
1875
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-none", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "pt-6", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("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." }) }) }) });
1876
+ }
1877
+ const visibleStatTypes = (0, import_core9.getVisibleTeamStatTypes)(statTypes, sportId);
1878
+ const filteredStatTypes = (0, import_core9.getOrderedTeamStatTypesForCategory)(
1879
+ visibleStatTypes,
1880
+ sportId,
1881
+ selectedStatCategory
1882
+ );
1883
+ const showsCategoryPicker = availableStatCategories.length > 0 && (0, import_core9.showsTeamStatCategoryPicker)(sportId);
1884
+ const columns = buildStatsColumns({
1885
+ filteredStatTypes,
1886
+ selectedStatCategory,
1887
+ resolveOpponentLogoUrl,
1888
+ defaultLogoUrl,
1889
+ isSm,
1890
+ isSmallLaptop
1891
+ });
1892
+ const emptyMessage = getStatsEmptyMessage(seasons, stats.length);
1893
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1894
+ import_ui_web14.Card,
1895
+ {
1896
+ className: (0, import_ui_web14.cn)(
1897
+ "border-none p-4 flex flex-col gap-3 xl:h-full xl:min-h-0 xl:flex-1 xl:overflow-hidden",
1898
+ className
1899
+ ),
1900
+ children: [
1901
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardTitle, { children: "Stats" }) }),
1902
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "space-y-0 p-0 flex flex-col gap-3 xl:flex-1 xl:min-h-0", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1903
+ StatsBody2,
1904
+ {
1905
+ seasons,
1906
+ showsCategoryPicker,
1907
+ selectedStatCategory,
1908
+ availableStatCategories,
1909
+ onStatCategoryChange: setRequestedStatCategory,
1910
+ isStatTypesError,
1911
+ hasVisibleStatTypes: visibleStatTypes.length > 0,
1912
+ columns,
1913
+ stats,
1914
+ statsLoading,
1915
+ isStatsError,
1916
+ isSm,
1917
+ isSmallLaptop,
1918
+ emptyMessage
1919
+ }
1920
+ ) })
1921
+ ]
1922
+ }
1923
+ );
1924
+ }
1925
+
1926
+ // src/team/team-schedule-table.tsx
1927
+ var import_ui_web15 = require("@nukleus-sports/ui-web");
1928
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1929
+ var SPECIAL_LOGO_LEAGUES = ["NFL", "NBA", "NHL", "MLB", "WNBA"];
1930
+ var COLLEGE_LEAGUE_IDS = [2, 6, 13];
1931
+ var COMPLETED_STATUS_ID = "3";
1932
+ var DATE_FORMAT2 = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" });
1933
+ function firstCompetition(game) {
1934
+ return game.game_details?.competitions?.[0];
1935
+ }
1936
+ function formatScore(score) {
1937
+ if (score?.displayValue) return score.displayValue;
1938
+ if (typeof score?.value === "number") return String(score.value);
1939
+ return "0";
1940
+ }
1941
+ function findCompetitor(competitors, teamEspnId) {
1942
+ if (!competitors || competitors.length !== 2 || !teamEspnId) return null;
1943
+ const [first, second] = competitors;
1944
+ if (!first || !second) return null;
1945
+ if (first.id === teamEspnId) return { own: first, other: second };
1946
+ if (second.id === teamEspnId) return { own: second, other: first };
1947
+ return null;
1948
+ }
1949
+ function findLeader(competitors, leaderType) {
1950
+ if (!competitors || competitors.length !== 2) return null;
1951
+ for (const competitor of competitors) {
1952
+ const leader = competitor?.leaders?.find((entry) => entry.name === leaderType);
1953
+ const top = leader?.leaders?.[0];
1954
+ if (top?.athlete) {
1955
+ return {
1956
+ displayName: top.athlete.displayName || "--",
1957
+ displayValue: top.displayValue || "--"
1958
+ };
1959
+ }
1960
+ }
1961
+ return null;
1962
+ }
1963
+ function showsFootballLeaders(leagueId) {
1964
+ return leagueId !== null && [1, 2, 13].includes(leagueId);
1965
+ }
1966
+ function showsBasketballLeaders(leagueId) {
1967
+ return leagueId !== null && [4, 5, 6].includes(leagueId);
1968
+ }
1969
+ function showsHockeyLeaders(leagueId) {
1970
+ return leagueId === 14;
1971
+ }
1972
+ function showsMlbLeaders(leagueId) {
1973
+ return leagueId === 7;
1974
+ }
1975
+ function leaderCell(leader, small = false) {
1976
+ if (!leader) return "--";
1977
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col leading-tight", children: [
1978
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: leader.displayName }),
1979
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1980
+ "span",
1981
+ {
1982
+ className: (0, import_ui_web15.cn)(
1983
+ small ? "text-text-secondary text-11" : "text-text-primary body-text",
1984
+ "truncate"
1985
+ ),
1986
+ children: leader.displayValue
1987
+ }
1988
+ )
1989
+ ] });
1990
+ }
1991
+ function formatScheduleDate(game) {
1992
+ if (!game.game_details) return "--";
1993
+ try {
1994
+ const { timeValid, date: rawDate } = game.game_details;
1995
+ const date = timeValid ? new Date(rawDate) : (() => {
1996
+ const [year, month, day] = rawDate.split("T")[0].split("-").map(Number);
1997
+ return new Date(year, month - 1, day);
1998
+ })();
1999
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text", children: DATE_FORMAT2.format(date) });
2000
+ } catch {
2001
+ return "--";
2002
+ }
2003
+ }
2004
+ function getScheduleResult(game, teamEspnId) {
2005
+ const competition = firstCompetition(game);
2006
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return null;
2007
+ const match = findCompetitor(competition.competitors, teamEspnId);
2008
+ if (!match) return null;
2009
+ const { own, other } = match;
2010
+ const ownValue = own.score?.value;
2011
+ const otherValue = other.score?.value;
2012
+ const scoresKnown = typeof ownValue === "number" && typeof otherValue === "number";
2013
+ const tied = scoresKnown && ownValue === otherValue;
2014
+ const winLoss = tied ? "T" : own.winner === true ? "W" : "L";
2015
+ const score = `${formatScore(own.score)}-${formatScore(other.score)}`;
2016
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
2017
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-baseline gap-1 leading-tight", children: [
2018
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: (0, import_ui_web15.cn)(colorClass, "body-text"), children: winLoss }),
2019
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text", children: score })
2020
+ ] });
2021
+ }
2022
+ function getScheduleRecord(game, teamEspnId) {
2023
+ const competition = firstCompetition(game);
2024
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return "--";
2025
+ return findCompetitor(competition.competitors, teamEspnId)?.own.record?.[0]?.displayValue || "--";
2026
+ }
2027
+ function getWinningGoalie(game) {
2028
+ const athlete = firstCompetition(game)?.featuredAthletes?.[0]?.athlete;
2029
+ if (!athlete?.lastName) return "--";
2030
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex flex-col leading-tight", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }) });
2031
+ }
2032
+ function getHockeyTopPlayer(game) {
2033
+ const competitors = firstCompetition(game)?.competitors;
2034
+ const competitor = competitors?.find((c) => c?.leaders?.[0]?.leaders?.length);
2035
+ const top = competitor?.leaders?.[0]?.leaders?.[0];
2036
+ if (!top?.athlete?.lastName) return "--";
2037
+ return leaderCell(
2038
+ { displayName: top.athlete.lastName, displayValue: top.displayValue || "--" },
2039
+ true
2040
+ );
2041
+ }
2042
+ function getMlbPitcher(game, pitcherType) {
2043
+ const pitcher = firstCompetition(game)?.featuredAthletes?.find((a) => a.name === pitcherType);
2044
+ const athlete = pitcher?.athlete;
2045
+ if (!athlete?.lastName) return "--";
2046
+ const stat = pitcherType === "savingPitcher" ? athlete.saves : athlete.record;
2047
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col leading-tight", children: [
2048
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }),
2049
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-secondary text-11 truncate", children: stat || "--" })
2050
+ ] });
2051
+ }
2052
+ function OpponentCell({
2053
+ game,
2054
+ teamEspnId,
2055
+ leagueId,
2056
+ leagueAbbreviation,
2057
+ resolveLogoUrl,
2058
+ defaultLogoUrl,
2059
+ showName
2060
+ }) {
2061
+ const match = findCompetitor(firstCompetition(game)?.competitors, teamEspnId);
2062
+ if (!match || leagueId === null || !leagueAbbreviation) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: "--" });
2063
+ const prefix = match.own.homeAway === "home" ? "vs" : "@";
2064
+ const opponentTeam = match.other.team;
2065
+ const isSpecialLeague = SPECIAL_LOGO_LEAGUES.includes(leagueAbbreviation);
2066
+ const identifier = isSpecialLeague ? opponentTeam.abbreviation : opponentTeam.id;
2067
+ const folder = COLLEGE_LEAGUE_IDS.includes(leagueId) ? "NCAA" : leagueAbbreviation;
2068
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1 sm:gap-2 h-full overflow-hidden", children: [
2069
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text shrink-0 sm:w-4", children: prefix }),
2070
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2071
+ "img",
2072
+ {
2073
+ src: resolveLogoUrl(folder, identifier),
2074
+ alt: showName ? "" : opponentTeam.displayName,
2075
+ loading: "lazy",
2076
+ className: "h-5 w-5 shrink-0 inline sm:h-6 sm:w-6 sm:mr-2",
2077
+ onError: (event) => {
2078
+ event.currentTarget.src = defaultLogoUrl;
2079
+ }
2080
+ }
2081
+ ),
2082
+ showName && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentTeam.displayName })
2083
+ ] });
2084
+ }
2085
+ function buildScheduleColumns({
2086
+ leagueId,
2087
+ leagueAbbreviation,
2088
+ teamEspnId,
2089
+ resolveLogoUrl,
2090
+ defaultLogoUrl,
2091
+ isSm,
2092
+ isSmallLaptop
2093
+ }) {
2094
+ const showsHockey = showsHockeyLeaders(leagueId);
2095
+ return [
2096
+ {
2097
+ id: "game_date",
2098
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-[50px] shrink-0", children: "Date" }),
2099
+ accessorFn: (row) => row.game_date,
2100
+ cell: ({ row }) => formatScheduleDate(row.original),
2101
+ meta: { cellSize: isSm ? "xs" : "xxs" }
2102
+ },
2103
+ {
2104
+ id: "opponent",
2105
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: isSm ? "Opponent" : "Opp" }),
2106
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2107
+ OpponentCell,
2108
+ {
2109
+ game: row.original,
2110
+ teamEspnId,
2111
+ leagueId,
2112
+ leagueAbbreviation,
2113
+ resolveLogoUrl,
2114
+ defaultLogoUrl,
2115
+ showName: isSm
2116
+ }
2117
+ ),
2118
+ meta: { cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse" }
2119
+ },
2120
+ {
2121
+ id: "result",
2122
+ header: "Result",
2123
+ cell: ({ row }) => getScheduleResult(row.original, teamEspnId) ?? "--",
2124
+ meta: { cellSize: "xs" }
2125
+ },
2126
+ {
2127
+ id: "record",
2128
+ header: showsHockey ? "W-L-OTL" : "W-L",
2129
+ cell: ({ row }) => getScheduleRecord(row.original, teamEspnId),
2130
+ meta: { cellSize: "xs" }
2131
+ },
2132
+ ...showsMlbLeaders(leagueId) ? [
2133
+ {
2134
+ id: "win",
2135
+ header: "Win",
2136
+ cell: ({ row }) => getMlbPitcher(row.original, "winningPitcher"),
2137
+ meta: { cellSize: "s" }
2138
+ },
2139
+ {
2140
+ id: "loss",
2141
+ header: "Loss",
2142
+ cell: ({ row }) => getMlbPitcher(row.original, "losingPitcher"),
2143
+ meta: { cellSize: "s" }
2144
+ },
2145
+ {
2146
+ id: "save",
2147
+ header: "Save",
2148
+ cell: ({ row }) => getMlbPitcher(row.original, "savingPitcher"),
2149
+ meta: { cellSize: "s" }
2150
+ }
2151
+ ] : [],
2152
+ ...showsBasketballLeaders(leagueId) ? [
2153
+ {
2154
+ id: "topPts",
2155
+ header: "Top Pts",
2156
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "points"), true),
2157
+ meta: { cellSize: "s" }
2158
+ },
2159
+ {
2160
+ id: "topReb",
2161
+ header: "Top Reb",
2162
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rebounds"), true),
2163
+ meta: { cellSize: "s" }
2164
+ },
2165
+ {
2166
+ id: "topAst",
2167
+ header: "Top Ast",
2168
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "assists"), true),
2169
+ meta: { cellSize: "s" }
2170
+ }
2171
+ ] : [],
2172
+ ...showsHockey ? [
2173
+ {
2174
+ id: "wGoalie",
2175
+ header: "W Goalie",
2176
+ cell: ({ row }) => getWinningGoalie(row.original),
2177
+ meta: { cellSize: "s" }
2178
+ },
2179
+ {
2180
+ id: "topPlayer",
2181
+ header: "Top Player",
2182
+ cell: ({ row }) => getHockeyTopPlayer(row.original),
2183
+ meta: { cellSize: "s" }
2184
+ }
2185
+ ] : [],
2186
+ ...showsFootballLeaders(leagueId) ? [
2187
+ {
2188
+ id: "topPass",
2189
+ header: "Top Pass",
2190
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "passingLeader")),
2191
+ meta: { cellSize: "l" }
2192
+ },
2193
+ {
2194
+ id: "topRush",
2195
+ header: "Top Rush",
2196
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rushingLeader")),
2197
+ meta: { cellSize: "l" }
2198
+ },
2199
+ {
2200
+ id: "topRec",
2201
+ header: "Top Rec",
2202
+ cell: ({ row }) => leaderCell(
2203
+ findLeader(firstCompetition(row.original)?.competitors, "receivingLeader")
2204
+ ),
2205
+ meta: { cellSize: "l" }
2206
+ }
2207
+ ] : []
2208
+ ];
2209
+ }
2210
+ function ScheduleBody({
2211
+ seasonsLoading,
2212
+ seasons,
2213
+ isSeasonsError,
2214
+ columns,
2215
+ games,
2216
+ gamesLoading,
2217
+ isGamesError,
2218
+ isSm,
2219
+ isSmallLaptop
2220
+ }) {
2221
+ if (seasonsLoading) {
2222
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex justify-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "text-sm text-text-primary", children: "Loading seasons..." }) });
2223
+ }
2224
+ if (!seasons || seasons.years.length === 0) {
2225
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "text-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-primary", children: isSeasonsError ? "Couldn't load seasons. Please try again." : "No seasons found" }) });
2226
+ }
2227
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col gap-3", children: [
2228
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
2229
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2230
+ import_ui_web15.BaseTable,
2231
+ {
2232
+ columns,
2233
+ data: games,
2234
+ pageSize: games.length || 10,
2235
+ splitLayout: isSmallLaptop || !isSm,
2236
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
2237
+ loading: gamesLoading,
2238
+ containerClassName: "border-0 rounded-none h-full",
2239
+ className: "h-full border-none",
2240
+ numberOfColumns: 2,
2241
+ emptyMessage: isGamesError ? "Couldn't load games. Please try again." : "No games found for this season"
2242
+ }
2243
+ ) })
2244
+ ] });
2245
+ }
2246
+ function TeamScheduleTable({
2247
+ games,
2248
+ gamesLoading = false,
2249
+ isGamesError = false,
2250
+ leagueId,
2251
+ leagueAbbreviation,
2252
+ isTeamError = false,
2253
+ teamEspnId,
2254
+ resolveLogoUrl,
2255
+ defaultLogoUrl,
2256
+ seasons,
2257
+ seasonsLoading = false,
2258
+ isSeasonsError = false,
2259
+ isSm,
2260
+ isSmallLaptop,
2261
+ className
2262
+ }) {
2263
+ const columns = buildScheduleColumns({
2264
+ leagueId,
2265
+ leagueAbbreviation,
2266
+ teamEspnId,
2267
+ resolveLogoUrl,
2268
+ defaultLogoUrl,
2269
+ isSm,
2270
+ isSmallLaptop
2271
+ });
2272
+ if (isTeamError) {
2273
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardContent, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
2274
+ }
2275
+ if (leagueId === null) {
2276
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_web15.CardContent, { className: "p-4 flex justify-center items-center gap-2", children: [
2277
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.IconLoader, {}),
2278
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-secondary", children: "Loading team information..." })
2279
+ ] }) });
2280
+ }
2281
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-none p-4 flex flex-col gap-3", className), children: [
2282
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardHeader, { className: "p-0 flex flex-row items-center justify-between space-y-0", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardTitle, { children: "Schedule" }) }),
2283
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardContent, { className: "space-y-0 p-0 flex flex-col gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2284
+ ScheduleBody,
2285
+ {
2286
+ seasonsLoading,
2287
+ seasons,
2288
+ isSeasonsError,
2289
+ columns,
2290
+ games,
2291
+ gamesLoading,
2292
+ isGamesError,
2293
+ isSm,
2294
+ isSmallLaptop
2295
+ }
2296
+ ) })
2297
+ ] });
2298
+ }
1622
2299
  // Annotate the CommonJS export names for ESM import in node:
1623
2300
  0 && (module.exports = {
1624
2301
  EmptyValue,
@@ -1632,10 +2309,12 @@ function RecentGamesWidget({
1632
2309
  TeamFactsContent,
1633
2310
  TeamFactsWidget,
1634
2311
  TeamInfoCard,
2312
+ TeamScheduleTable,
1635
2313
  TeamSeasonScheduleSummaryPanel,
1636
2314
  TeamSeasonStatsSummaryPanel,
1637
2315
  TeamSeasonStatsWidget,
1638
2316
  TeamStaffTable,
2317
+ TeamStatsTable,
1639
2318
  VenuePhoto
1640
2319
  });
1641
2320
  //# sourceMappingURL=team.cjs.map