@sportsdataverse/sdvplot 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/NOTICE.md +109 -0
- package/README.md +984 -2
- package/dist/_web-D7Aa5Rd8.d.ts +69 -0
- package/dist/aaf-GJ3SH34T.js +13 -0
- package/dist/aaf-HCYN5T6Y.js +37 -0
- package/dist/aaf-ZAE5KS2Y.js +13 -0
- package/dist/ahl-E66MDVCU.js +66 -0
- package/dist/ahl-NPQQWZEV.js +249 -0
- package/dist/ahl-QRDU73XX.js +309 -0
- package/dist/axis-CraWQRUJ.d.ts +49 -0
- package/dist/bins.d.ts +174 -0
- package/dist/bins.js +4 -0
- package/dist/bins.js.map +1 -0
- package/dist/cfb-F42SVS4X.js +5000 -0
- package/dist/cfb-P3SHEYRZ.js +692 -0
- package/dist/cfb-WXRZANLP.js +10226 -0
- package/dist/chartjs-surface.d.ts +42 -0
- package/dist/chartjs-surface.js +65 -0
- package/dist/chartjs-surface.js.map +1 -0
- package/dist/chartjs.d.ts +162 -0
- package/dist/chartjs.js +342 -0
- package/dist/chartjs.js.map +1 -0
- package/dist/chunk-4C3GX6QO.js +92 -0
- package/dist/chunk-4C3GX6QO.js.map +1 -0
- package/dist/chunk-57WFSI4Q.js +128 -0
- package/dist/chunk-57WFSI4Q.js.map +1 -0
- package/dist/chunk-7ULOCCFL.js +313 -0
- package/dist/chunk-7ULOCCFL.js.map +1 -0
- package/dist/chunk-AMXASQHT.js +120 -0
- package/dist/chunk-AMXASQHT.js.map +1 -0
- package/dist/chunk-B2MP37SR.js +175 -0
- package/dist/chunk-B2MP37SR.js.map +1 -0
- package/dist/chunk-C2CDY5OG.js +137 -0
- package/dist/chunk-C2CDY5OG.js.map +1 -0
- package/dist/chunk-DYMUVE6K.js +127 -0
- package/dist/chunk-DYMUVE6K.js.map +1 -0
- package/dist/chunk-E7G7VSLV.js +43 -0
- package/dist/chunk-E7G7VSLV.js.map +1 -0
- package/dist/chunk-H2C3FMMA.js +300 -0
- package/dist/chunk-H2C3FMMA.js.map +1 -0
- package/dist/chunk-J4P4HDBF.js +175 -0
- package/dist/chunk-J4P4HDBF.js.map +1 -0
- package/dist/chunk-J6R2LEJ7.js +58 -0
- package/dist/chunk-J6R2LEJ7.js.map +1 -0
- package/dist/chunk-M3XD2OSN.js +132 -0
- package/dist/chunk-M3XD2OSN.js.map +1 -0
- package/dist/chunk-OIILARXI.js +30 -0
- package/dist/chunk-OIILARXI.js.map +1 -0
- package/dist/chunk-RPVVJY74.js +170 -0
- package/dist/chunk-RPVVJY74.js.map +1 -0
- package/dist/chunk-UL5M6KDE.js +205 -0
- package/dist/chunk-UL5M6KDE.js.map +1 -0
- package/dist/chunk-WQT4IVLX.js +10 -0
- package/dist/chunk-WQT4IVLX.js.map +1 -0
- package/dist/chunk-ZAEQXFJM.js +556 -0
- package/dist/chunk-ZAEQXFJM.js.map +1 -0
- package/dist/cricket-KPCYG2HL.js +493 -0
- package/dist/cricket-NDXLE25B.js +116 -0
- package/dist/cricket-YUUF7P6M.js +160 -0
- package/dist/cytoscape.d.ts +188 -0
- package/dist/cytoscape.js +219 -0
- package/dist/cytoscape.js.map +1 -0
- package/dist/d3.d.ts +234 -0
- package/dist/d3.js +198 -0
- package/dist/d3.js.map +1 -0
- package/dist/deckgl.d.ts +232 -0
- package/dist/deckgl.js +197 -0
- package/dist/deckgl.js.map +1 -0
- package/dist/echarts.d.ts +121 -0
- package/dist/echarts.js +228 -0
- package/dist/echarts.js.map +1 -0
- package/dist/echl-3CR4RGFC.js +241 -0
- package/dist/echl-NPC32C23.js +107 -0
- package/dist/echl-PI33DGJC.js +64 -0
- package/dist/export.d.ts +130 -0
- package/dist/export.js +258 -0
- package/dist/export.js.map +1 -0
- package/dist/g2.d.ts +251 -0
- package/dist/g2.js +102 -0
- package/dist/g2.js.map +1 -0
- package/dist/headshots-B2J_LOO8.d.ts +40 -0
- package/dist/index.d.ts +183 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/interact.d.ts +567 -0
- package/dist/interact.js +809 -0
- package/dist/interact.js.map +1 -0
- package/dist/lightweight-charts.d.ts +217 -0
- package/dist/lightweight-charts.js +155 -0
- package/dist/lightweight-charts.js.map +1 -0
- package/dist/maplibre.d.ts +271 -0
- package/dist/maplibre.js +175 -0
- package/dist/maplibre.js.map +1 -0
- package/dist/marks-DH-tQIP-.d.ts +75 -0
- package/dist/mbb-3TRLVW3H.js +3619 -0
- package/dist/mbb-DQUHCHZP.js +5111 -0
- package/dist/mbb-PRAIO2P5.js +371 -0
- package/dist/milb-6IQ6NCEW.js +291 -0
- package/dist/milb-EYY5MD4T.js +1752 -0
- package/dist/milb-EYZ4SZLI.js +797 -0
- package/dist/mlb-4PBUJSVQ.js +35 -0
- package/dist/mlb-FHPY3GQJ.js +701 -0
- package/dist/mlb-REVGL3N2.js +665 -0
- package/dist/mui.d.ts +338 -0
- package/dist/mui.js +184 -0
- package/dist/mui.js.map +1 -0
- package/dist/nba-ATT775GS.js +485 -0
- package/dist/nba-LKM4UHVU.js +482 -0
- package/dist/nba-YX7PXM3R.js +35 -0
- package/dist/nbagl-3WGZCZ4S.js +37 -0
- package/dist/nbagl-LP4XJRAL.js +229 -0
- package/dist/nbagl-VTTOU7LN.js +499 -0
- package/dist/ncaa_baseball-UV75LNVR.js +2670 -0
- package/dist/ncaa_baseball-VD5J5C72.js +419 -0
- package/dist/ncaa_baseball-YRBS32D6.js +4592 -0
- package/dist/ncaa_mhockey-IMYHS7QS.js +1033 -0
- package/dist/ncaa_mhockey-TXTKWHE3.js +115 -0
- package/dist/ncaa_mhockey-U3MFW5VT.js +663 -0
- package/dist/ncaa_softball-6WR6KS64.js +420 -0
- package/dist/ncaa_softball-RZCTIE56.js +2654 -0
- package/dist/ncaa_softball-VOD4PVGY.js +4599 -0
- package/dist/ncaa_whockey-6XXGUTBK.js +607 -0
- package/dist/ncaa_whockey-AKKYKY67.js +53 -0
- package/dist/ncaa_whockey-KBEKXFBB.js +293 -0
- package/dist/nfl-BDB2HYAR.js +625 -0
- package/dist/nfl-EHYHDLJD.js +37 -0
- package/dist/nfl-VF4NJCHY.js +514 -0
- package/dist/nfl_gsis-UY64JO37.js +4 -0
- package/dist/nhl-6WPHME7H.js +511 -0
- package/dist/nhl-EMIJFZHY.js +884 -0
- package/dist/nhl-ISFUKRFU.js +37 -0
- package/dist/nivo.d.ts +193 -0
- package/dist/nivo.js +8 -0
- package/dist/nivo.js.map +1 -0
- package/dist/ohl-2FEM554G.js +113 -0
- package/dist/ohl-C5Q4W6JB.js +32 -0
- package/dist/ohl-TQ4J46VC.js +66 -0
- package/dist/perspective.d.ts +198 -0
- package/dist/perspective.js +171 -0
- package/dist/perspective.js.map +1 -0
- package/dist/phf-H7POU2KW.js +32 -0
- package/dist/phf-K5IFMZUM.js +13 -0
- package/dist/phf-TWJI3BOW.js +20 -0
- package/dist/placement-UWkqUzpa.d.ts +32 -0
- package/dist/plot.d.ts +451 -0
- package/dist/plot.js +712 -0
- package/dist/plot.js.map +1 -0
- package/dist/plotly.d.ts +129 -0
- package/dist/plotly.js +360 -0
- package/dist/plotly.js.map +1 -0
- package/dist/pwhl-OX3BO4JI.js +53 -0
- package/dist/pwhl-W44OC3C6.js +17 -0
- package/dist/pwhl-ZJGG3H7W.js +23 -0
- package/dist/qmjhl-5HISEHLL.js +35 -0
- package/dist/qmjhl-DA3UHKE5.js +125 -0
- package/dist/qmjhl-YG4BOQPF.js +614 -0
- package/dist/react.d.ts +377 -0
- package/dist/react.js +522 -0
- package/dist/react.js.map +1 -0
- package/dist/recharts.d.ts +162 -0
- package/dist/recharts.js +8 -0
- package/dist/recharts.js.map +1 -0
- package/dist/resolve-CQW-jzvr.d.ts +28 -0
- package/dist/selection-D4T3PkRt.d.ts +140 -0
- package/dist/shadcn.d.ts +83 -0
- package/dist/shadcn.js +88 -0
- package/dist/shadcn.js.map +1 -0
- package/dist/shots.d.ts +364 -0
- package/dist/shots.js +86 -0
- package/dist/shots.js.map +1 -0
- package/dist/soccer-7BH3ZLVL.js +7898 -0
- package/dist/soccer-MRU25OGE.js +2636 -0
- package/dist/soccer-PF4IPPVA.js +12342 -0
- package/dist/surface-TR7YFJW3.js +4 -0
- package/dist/surface-TR7YFJW3.js.map +1 -0
- package/dist/surfaces-MIG7HOFU.js +6 -0
- package/dist/surfaces-MIG7HOFU.js.map +1 -0
- package/dist/surfaces-W-odWLpT.d.ts +47 -0
- package/dist/svelte/HeadshotMark.svelte +25 -0
- package/dist/svelte/HeadshotMark.svelte.d.ts +10 -0
- package/dist/svelte/HeadshotMark.svelte.d.ts.map +1 -0
- package/dist/svelte/LogoMark.svelte +25 -0
- package/dist/svelte/LogoMark.svelte.d.ts +10 -0
- package/dist/svelte/LogoMark.svelte.d.ts.map +1 -0
- package/dist/svelte/Marks.svelte +25 -0
- package/dist/svelte/Marks.svelte.d.ts +10 -0
- package/dist/svelte/Marks.svelte.d.ts.map +1 -0
- package/dist/svelte/Surface.svelte +29 -0
- package/dist/svelte/Surface.svelte.d.ts +9 -0
- package/dist/svelte/Surface.svelte.d.ts.map +1 -0
- package/dist/svelte/SurfaceBackdrop.svelte +26 -0
- package/dist/svelte/SurfaceBackdrop.svelte.d.ts +11 -0
- package/dist/svelte/SurfaceBackdrop.svelte.d.ts.map +1 -0
- package/dist/svelte/index.d.ts +13 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +11 -0
- package/dist/svelte-core.d.ts +139 -0
- package/dist/svelte-core.js +123 -0
- package/dist/svelte-core.js.map +1 -0
- package/dist/tanstack.d.ts +240 -0
- package/dist/tanstack.js +110 -0
- package/dist/tanstack.js.map +1 -0
- package/dist/testing.d.ts +75 -0
- package/dist/testing.js +239 -0
- package/dist/testing.js.map +1 -0
- package/dist/three.d.ts +223 -0
- package/dist/three.js +50 -0
- package/dist/three.js.map +1 -0
- package/dist/tiers-BN4md-GB.d.ts +65 -0
- package/dist/types-C7n6gJF3.d.ts +62 -0
- package/dist/ufl-7VLZTLTT.js +143 -0
- package/dist/ufl-CCMBLPSW.js +100 -0
- package/dist/ufl-F2BJRXME.js +16 -0
- package/dist/unovis.d.ts +127 -0
- package/dist/unovis.js +108 -0
- package/dist/unovis.js.map +1 -0
- package/dist/uplot.d.ts +120 -0
- package/dist/uplot.js +110 -0
- package/dist/uplot.js.map +1 -0
- package/dist/usfl-4CR5RMZJ.js +32 -0
- package/dist/usfl-LD7HP2YK.js +14 -0
- package/dist/usfl-VU4YSJQD.js +19 -0
- package/dist/ushl-CPG2LB4L.js +73 -0
- package/dist/ushl-PQL6HJAD.js +88 -0
- package/dist/ushl-ZT2ATPHK.js +22 -0
- package/dist/vega.d.ts +85 -0
- package/dist/vega.js +362 -0
- package/dist/vega.js.map +1 -0
- package/dist/victory.d.ts +107 -0
- package/dist/victory.js +38 -0
- package/dist/victory.js.map +1 -0
- package/dist/wbb-3KHCDYTK.js +5087 -0
- package/dist/wbb-BMX53Q3Q.js +369 -0
- package/dist/wbb-QNRN2CJJ.js +3620 -0
- package/dist/whl-4ATYZWUB.js +97 -0
- package/dist/whl-RVFPL6MH.js +79 -0
- package/dist/whl-Y7ASKYMM.js +28 -0
- package/dist/wnba-FWX5SFVI.js +232 -0
- package/dist/wnba-GX6HZR4B.js +220 -0
- package/dist/wnba-NTMWIPP6.js +20 -0
- package/dist/xfl-43R2JMJK.js +30 -0
- package/dist/xfl-H3BXQPZZ.js +16 -0
- package/dist/xfl-XON7A7FI.js +69 -0
- package/package.json +366 -3
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import { InputError, warn, UnresolvedTeamError } from './chunk-E7G7VSLV.js';
|
|
2
|
+
|
|
3
|
+
// src/types.ts
|
|
4
|
+
var asTeamId = (s) => s;
|
|
5
|
+
var PRIORITY = [
|
|
6
|
+
"team_id",
|
|
7
|
+
"espn",
|
|
8
|
+
"espn_abbr",
|
|
9
|
+
"nhl",
|
|
10
|
+
"nflverse",
|
|
11
|
+
"mlbstats",
|
|
12
|
+
"nba_api",
|
|
13
|
+
"hockeytech",
|
|
14
|
+
"ncaa",
|
|
15
|
+
"pff",
|
|
16
|
+
"cricinfo",
|
|
17
|
+
"cfbd",
|
|
18
|
+
"bref",
|
|
19
|
+
"sportsipy",
|
|
20
|
+
"fangraphs",
|
|
21
|
+
"sdvplotr",
|
|
22
|
+
"name"
|
|
23
|
+
];
|
|
24
|
+
var EXPLICIT_ONLY = ["nhl_id"];
|
|
25
|
+
|
|
26
|
+
// src/data/index.ts
|
|
27
|
+
var LEAGUES = ["aaf", "ahl", "cfb", "cricket", "echl", "mbb", "milb", "mlb", "nba", "nbagl", "ncaa_baseball", "ncaa_mhockey", "ncaa_softball", "ncaa_whockey", "nfl", "nhl", "ohl", "phf", "pwhl", "qmjhl", "soccer", "ufl", "usfl", "ushl", "wbb", "whl", "wnba", "xfl"];
|
|
28
|
+
var INDEX_VERSION = "1c025b69f8cf";
|
|
29
|
+
var MANIFEST_LAST_MODIFIED = "2026-10-06";
|
|
30
|
+
var VARIANTS = ["alternate", "cap_on_dark", "cap_on_light", "cricinfo", "crop_64px", "dark", "default", "grayscale", "large", "logo2", "medium", "on_dark", "on_light", "primary_logo_black", "primary_logo_on_black_color", "primary_logo_on_primary_color", "primary_logo_on_secondary_color", "primary_logo_on_white_color", "primary_logo_white", "primary_on_dark", "primary_on_light", "scoreboard", "scoreboard_dark", "secondary_logo_black", "secondary_logo_on_black_color", "secondary_logo_on_primary_color", "secondary_logo_on_secondary_color", "secondary_logo_on_white_color", "secondary_logo_white", "sport_pictogram", "squared", "team_strip"];
|
|
31
|
+
var INDEX_FIRST_SEASON = 1871;
|
|
32
|
+
var INDEX_LAST_ALIAS_SEASON = 2027;
|
|
33
|
+
var LEAGUE_META = { "aaf": { "latestSeason": null, "firstSeason": null }, "ahl": { "latestSeason": null, "firstSeason": null }, "cfb": { "latestSeason": null, "firstSeason": null }, "cricket": { "latestSeason": null, "firstSeason": null }, "echl": { "latestSeason": null, "firstSeason": null }, "mbb": { "latestSeason": null, "firstSeason": null }, "milb": { "latestSeason": null, "firstSeason": null }, "mlb": { "latestSeason": 2026, "firstSeason": 1871 }, "nba": { "latestSeason": 2027, "firstSeason": 1947 }, "nbagl": { "latestSeason": null, "firstSeason": null }, "ncaa_baseball": { "latestSeason": null, "firstSeason": null }, "ncaa_mhockey": { "latestSeason": null, "firstSeason": null }, "ncaa_softball": { "latestSeason": null, "firstSeason": null }, "ncaa_whockey": { "latestSeason": null, "firstSeason": null }, "nfl": { "latestSeason": 2026, "firstSeason": 1920 }, "nhl": { "latestSeason": 1997, "firstSeason": null }, "ohl": { "latestSeason": null, "firstSeason": null }, "phf": { "latestSeason": null, "firstSeason": null }, "pwhl": { "latestSeason": null, "firstSeason": null }, "qmjhl": { "latestSeason": null, "firstSeason": null }, "soccer": { "latestSeason": null, "firstSeason": null }, "ufl": { "latestSeason": 2026, "firstSeason": 2024 }, "usfl": { "latestSeason": null, "firstSeason": null }, "ushl": { "latestSeason": null, "firstSeason": null }, "wbb": { "latestSeason": null, "firstSeason": null }, "whl": { "latestSeason": null, "firstSeason": null }, "wnba": { "latestSeason": 2026, "firstSeason": 1997 }, "xfl": { "latestSeason": 2023, "firstSeason": 2020 } };
|
|
34
|
+
var ARCHIVE_BASE = "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256";
|
|
35
|
+
function archiveUrl(sha256, ext) {
|
|
36
|
+
return `${ARCHIVE_BASE}/${sha256.slice(0, 2)}/${sha256}.${ext}`;
|
|
37
|
+
}
|
|
38
|
+
var loaders = {
|
|
39
|
+
"aaf": async () => {
|
|
40
|
+
const [t, a, m] = await Promise.all([import('./aaf-GJ3SH34T.js'), import('./aaf-HCYN5T6Y.js'), import('./aaf-ZAE5KS2Y.js')]);
|
|
41
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
42
|
+
},
|
|
43
|
+
"ahl": async () => {
|
|
44
|
+
const [t, a, m] = await Promise.all([import('./ahl-E66MDVCU.js'), import('./ahl-NPQQWZEV.js'), import('./ahl-QRDU73XX.js')]);
|
|
45
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
46
|
+
},
|
|
47
|
+
"cfb": async () => {
|
|
48
|
+
const [t, a, m] = await Promise.all([import('./cfb-P3SHEYRZ.js'), import('./cfb-WXRZANLP.js'), import('./cfb-F42SVS4X.js')]);
|
|
49
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
50
|
+
},
|
|
51
|
+
"cricket": async () => {
|
|
52
|
+
const [t, a, m] = await Promise.all([import('./cricket-NDXLE25B.js'), import('./cricket-KPCYG2HL.js'), import('./cricket-YUUF7P6M.js')]);
|
|
53
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
54
|
+
},
|
|
55
|
+
"echl": async () => {
|
|
56
|
+
const [t, a, m] = await Promise.all([import('./echl-PI33DGJC.js'), import('./echl-3CR4RGFC.js'), import('./echl-NPC32C23.js')]);
|
|
57
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
58
|
+
},
|
|
59
|
+
"mbb": async () => {
|
|
60
|
+
const [t, a, m] = await Promise.all([import('./mbb-PRAIO2P5.js'), import('./mbb-3TRLVW3H.js'), import('./mbb-DQUHCHZP.js')]);
|
|
61
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
62
|
+
},
|
|
63
|
+
"milb": async () => {
|
|
64
|
+
const [t, a, m] = await Promise.all([import('./milb-6IQ6NCEW.js'), import('./milb-EYY5MD4T.js'), import('./milb-EYZ4SZLI.js')]);
|
|
65
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
66
|
+
},
|
|
67
|
+
"mlb": async () => {
|
|
68
|
+
const [t, a, m] = await Promise.all([import('./mlb-4PBUJSVQ.js'), import('./mlb-FHPY3GQJ.js'), import('./mlb-REVGL3N2.js')]);
|
|
69
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
70
|
+
},
|
|
71
|
+
"nba": async () => {
|
|
72
|
+
const [t, a, m] = await Promise.all([import('./nba-YX7PXM3R.js'), import('./nba-LKM4UHVU.js'), import('./nba-ATT775GS.js')]);
|
|
73
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
74
|
+
},
|
|
75
|
+
"nbagl": async () => {
|
|
76
|
+
const [t, a, m] = await Promise.all([import('./nbagl-3WGZCZ4S.js'), import('./nbagl-LP4XJRAL.js'), import('./nbagl-VTTOU7LN.js')]);
|
|
77
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
78
|
+
},
|
|
79
|
+
"ncaa_baseball": async () => {
|
|
80
|
+
const [t, a, m] = await Promise.all([import('./ncaa_baseball-VD5J5C72.js'), import('./ncaa_baseball-UV75LNVR.js'), import('./ncaa_baseball-YRBS32D6.js')]);
|
|
81
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
82
|
+
},
|
|
83
|
+
"ncaa_mhockey": async () => {
|
|
84
|
+
const [t, a, m] = await Promise.all([import('./ncaa_mhockey-TXTKWHE3.js'), import('./ncaa_mhockey-U3MFW5VT.js'), import('./ncaa_mhockey-IMYHS7QS.js')]);
|
|
85
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
86
|
+
},
|
|
87
|
+
"ncaa_softball": async () => {
|
|
88
|
+
const [t, a, m] = await Promise.all([import('./ncaa_softball-6WR6KS64.js'), import('./ncaa_softball-RZCTIE56.js'), import('./ncaa_softball-VOD4PVGY.js')]);
|
|
89
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
90
|
+
},
|
|
91
|
+
"ncaa_whockey": async () => {
|
|
92
|
+
const [t, a, m] = await Promise.all([import('./ncaa_whockey-AKKYKY67.js'), import('./ncaa_whockey-KBEKXFBB.js'), import('./ncaa_whockey-6XXGUTBK.js')]);
|
|
93
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
94
|
+
},
|
|
95
|
+
"nfl": async () => {
|
|
96
|
+
const [t, a, m] = await Promise.all([import('./nfl-EHYHDLJD.js'), import('./nfl-VF4NJCHY.js'), import('./nfl-BDB2HYAR.js')]);
|
|
97
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
98
|
+
},
|
|
99
|
+
"nhl": async () => {
|
|
100
|
+
const [t, a, m] = await Promise.all([import('./nhl-ISFUKRFU.js'), import('./nhl-6WPHME7H.js'), import('./nhl-EMIJFZHY.js')]);
|
|
101
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
102
|
+
},
|
|
103
|
+
"ohl": async () => {
|
|
104
|
+
const [t, a, m] = await Promise.all([import('./ohl-C5Q4W6JB.js'), import('./ohl-2FEM554G.js'), import('./ohl-TQ4J46VC.js')]);
|
|
105
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
106
|
+
},
|
|
107
|
+
"phf": async () => {
|
|
108
|
+
const [t, a, m] = await Promise.all([import('./phf-K5IFMZUM.js'), import('./phf-H7POU2KW.js'), import('./phf-TWJI3BOW.js')]);
|
|
109
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
110
|
+
},
|
|
111
|
+
"pwhl": async () => {
|
|
112
|
+
const [t, a, m] = await Promise.all([import('./pwhl-W44OC3C6.js'), import('./pwhl-OX3BO4JI.js'), import('./pwhl-ZJGG3H7W.js')]);
|
|
113
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
114
|
+
},
|
|
115
|
+
"qmjhl": async () => {
|
|
116
|
+
const [t, a, m] = await Promise.all([import('./qmjhl-5HISEHLL.js'), import('./qmjhl-DA3UHKE5.js'), import('./qmjhl-YG4BOQPF.js')]);
|
|
117
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
118
|
+
},
|
|
119
|
+
"soccer": async () => {
|
|
120
|
+
const [t, a, m] = await Promise.all([import('./soccer-MRU25OGE.js'), import('./soccer-7BH3ZLVL.js'), import('./soccer-PF4IPPVA.js')]);
|
|
121
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
122
|
+
},
|
|
123
|
+
"ufl": async () => {
|
|
124
|
+
const [t, a, m] = await Promise.all([import('./ufl-F2BJRXME.js'), import('./ufl-CCMBLPSW.js'), import('./ufl-7VLZTLTT.js')]);
|
|
125
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
126
|
+
},
|
|
127
|
+
"usfl": async () => {
|
|
128
|
+
const [t, a, m] = await Promise.all([import('./usfl-LD7HP2YK.js'), import('./usfl-4CR5RMZJ.js'), import('./usfl-VU4YSJQD.js')]);
|
|
129
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
130
|
+
},
|
|
131
|
+
"ushl": async () => {
|
|
132
|
+
const [t, a, m] = await Promise.all([import('./ushl-ZT2ATPHK.js'), import('./ushl-CPG2LB4L.js'), import('./ushl-PQL6HJAD.js')]);
|
|
133
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
134
|
+
},
|
|
135
|
+
"wbb": async () => {
|
|
136
|
+
const [t, a, m] = await Promise.all([import('./wbb-BMX53Q3Q.js'), import('./wbb-QNRN2CJJ.js'), import('./wbb-3KHCDYTK.js')]);
|
|
137
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
138
|
+
},
|
|
139
|
+
"whl": async () => {
|
|
140
|
+
const [t, a, m] = await Promise.all([import('./whl-Y7ASKYMM.js'), import('./whl-4ATYZWUB.js'), import('./whl-RVFPL6MH.js')]);
|
|
141
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
142
|
+
},
|
|
143
|
+
"wnba": async () => {
|
|
144
|
+
const [t, a, m] = await Promise.all([import('./wnba-NTMWIPP6.js'), import('./wnba-GX6HZR4B.js'), import('./wnba-FWX5SFVI.js')]);
|
|
145
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
146
|
+
},
|
|
147
|
+
"xfl": async () => {
|
|
148
|
+
const [t, a, m] = await Promise.all([import('./xfl-H3BXQPZZ.js'), import('./xfl-XON7A7FI.js'), import('./xfl-43R2JMJK.js')]);
|
|
149
|
+
return { teams: t.teams, aliases: a.aliases, marks: m.marks.map((r) => ({ ...r, archive_url: archiveUrl(r.sha256, r.ext) })) };
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/index-data.ts
|
|
154
|
+
var loaded = /* @__PURE__ */ new Map();
|
|
155
|
+
var pending = /* @__PURE__ */ new Map();
|
|
156
|
+
function checkLeague(league) {
|
|
157
|
+
if (!LEAGUES.includes(league))
|
|
158
|
+
throw new InputError(`unknown league ${JSON.stringify(league)}; known leagues: ${LEAGUES.join(", ")}`);
|
|
159
|
+
}
|
|
160
|
+
async function loadLeague(league) {
|
|
161
|
+
checkLeague(league);
|
|
162
|
+
const hit = loaded.get(league);
|
|
163
|
+
if (hit) return hit;
|
|
164
|
+
let p = pending.get(league);
|
|
165
|
+
if (!p) {
|
|
166
|
+
p = loaders[league]().then(
|
|
167
|
+
(d) => {
|
|
168
|
+
loaded.set(league, d);
|
|
169
|
+
pending.delete(league);
|
|
170
|
+
return d;
|
|
171
|
+
},
|
|
172
|
+
(e) => {
|
|
173
|
+
pending.delete(league);
|
|
174
|
+
throw e;
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
pending.set(league, p);
|
|
178
|
+
}
|
|
179
|
+
return p;
|
|
180
|
+
}
|
|
181
|
+
async function preloadAll() {
|
|
182
|
+
await Promise.all([...LEAGUES.map(loadLeague), loadGsis()]);
|
|
183
|
+
}
|
|
184
|
+
function getLeagueSync(league) {
|
|
185
|
+
checkLeague(league);
|
|
186
|
+
const d = loaded.get(league);
|
|
187
|
+
if (!d)
|
|
188
|
+
throw new InputError(
|
|
189
|
+
`league ${league} is not loaded; await loadLeague("${league}") or preloadAll() before calling the *Sync variant`
|
|
190
|
+
);
|
|
191
|
+
return d;
|
|
192
|
+
}
|
|
193
|
+
function seasonBounds(league) {
|
|
194
|
+
const last = Math.max(INDEX_LAST_ALIAS_SEASON, (/* @__PURE__ */ new Date()).getFullYear() + 1);
|
|
195
|
+
const first = league ? LEAGUE_META[league].firstSeason ?? INDEX_FIRST_SEASON : INDEX_FIRST_SEASON;
|
|
196
|
+
return [first, last];
|
|
197
|
+
}
|
|
198
|
+
var latestSeason = (league) => LEAGUE_META[league].latestSeason;
|
|
199
|
+
|
|
200
|
+
// src/normalize.ts
|
|
201
|
+
var FLOAT_ID = /^-?\d+\.0+$/;
|
|
202
|
+
var PUNCT = { "\u2018": "'", "\u2019": "'", "\u2013": "-", "\u2014": "-" };
|
|
203
|
+
function normValue(value) {
|
|
204
|
+
if (value === null || value === void 0) return null;
|
|
205
|
+
if (typeof value === "boolean") return String(value);
|
|
206
|
+
if (typeof value === "bigint") return value.toString();
|
|
207
|
+
if (typeof value === "number") return Number.isNaN(value) ? null : String(value);
|
|
208
|
+
let s = String(value).trim();
|
|
209
|
+
if (!/^[\x00-\x7F]*$/.test(s))
|
|
210
|
+
s = s.replace(/[‘’–—]/g, (c) => PUNCT[c] ?? c).normalize("NFKD").replace(/\p{M}/gu, "");
|
|
211
|
+
s = s.toLowerCase().replace(/ß/g, "ss").replace(/ς/g, "\u03C3");
|
|
212
|
+
if (FLOAT_ID.test(s)) s = s.split(".")[0];
|
|
213
|
+
return s || null;
|
|
214
|
+
}
|
|
215
|
+
function checkSeason(year, league) {
|
|
216
|
+
const b = seasonBounds(league);
|
|
217
|
+
if (b && !(b[0] <= year && year <= b[1]))
|
|
218
|
+
throw new InputError(
|
|
219
|
+
`season ${year} is outside the seasons sdvplot knows${league ? ` for ${league}` : ""} (${b[0]} to ${b[1]}); pass a year such as 2020`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
var SPLIT = /^\s*(\d{4})\s*[-/]\s*(\d{2}|\d{4})\s*$/;
|
|
223
|
+
function normSeason(value, league) {
|
|
224
|
+
if (value === null || value === void 0) return null;
|
|
225
|
+
let year = null;
|
|
226
|
+
if (typeof value === "number") {
|
|
227
|
+
if (Number.isNaN(value)) return null;
|
|
228
|
+
if (Number.isInteger(value)) year = value;
|
|
229
|
+
} else if (/^\d+$/.test(value.trim())) year = Number.parseInt(value.trim(), 10);
|
|
230
|
+
if (year === null) {
|
|
231
|
+
const m = typeof value === "string" ? SPLIT.exec(value) : null;
|
|
232
|
+
const hint = m ? `; for a split season pass its ending year (${Number(m[1]) + 1} for '${String(value).trim()}')` : "";
|
|
233
|
+
throw new InputError(`season must be a year such as 2020, got ${JSON.stringify(value)}${hint}`);
|
|
234
|
+
}
|
|
235
|
+
checkSeason(year, league);
|
|
236
|
+
return year;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/headshots.ts
|
|
240
|
+
var ESPN_HEADSHOT_LEAGUES = {
|
|
241
|
+
nfl: "nfl",
|
|
242
|
+
nba: "nba",
|
|
243
|
+
wnba: "wnba",
|
|
244
|
+
mlb: "mlb",
|
|
245
|
+
nhl: "nhl",
|
|
246
|
+
cfb: "college-football",
|
|
247
|
+
mbb: "mens-college-basketball",
|
|
248
|
+
wbb: "womens-college-basketball"
|
|
249
|
+
};
|
|
250
|
+
var HEADSHOT_ASPECT = 600 / 436;
|
|
251
|
+
function nbaHeadshotUrl(id) {
|
|
252
|
+
return `https://cdn.nba.com/headshots/nba/latest/260x190/${id}.png`;
|
|
253
|
+
}
|
|
254
|
+
function wnbaHeadshotUrl(id) {
|
|
255
|
+
return `https://cdn.wnba.com/headshots/wnba/latest/260x190/${id}.png`;
|
|
256
|
+
}
|
|
257
|
+
function mlbHeadshotUrl(id) {
|
|
258
|
+
return `https://img.mlbstatic.com/mlb-photos/image/upload/d_people:generic:headshot:67:current.png/w_213,q_auto:best/v1/people/${id}/headshot/67/current.png`;
|
|
259
|
+
}
|
|
260
|
+
function nhlHeadshotUrl(id) {
|
|
261
|
+
return `https://assets.nhle.com/mugs/nhl/latest/${id}.png`;
|
|
262
|
+
}
|
|
263
|
+
function espn(id, league) {
|
|
264
|
+
if (!/^\d+$/.test(id)) return void 0;
|
|
265
|
+
return `https://a.espncdn.com/combiner/i?img=/i/headshots/${ESPN_HEADSHOT_LEAGUES[league]}/players/full/${id}.png`;
|
|
266
|
+
}
|
|
267
|
+
var gsis;
|
|
268
|
+
var gsisPending;
|
|
269
|
+
async function loadGsis() {
|
|
270
|
+
if (gsis) return;
|
|
271
|
+
gsisPending ??= import('./nfl_gsis-UY64JO37.js').then(
|
|
272
|
+
(m) => {
|
|
273
|
+
gsis = m.NFL_GSIS;
|
|
274
|
+
},
|
|
275
|
+
(e) => {
|
|
276
|
+
gsisPending = void 0;
|
|
277
|
+
throw e;
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
return gsisPending;
|
|
281
|
+
}
|
|
282
|
+
function headshotUrl(playerId, league, { idSystem = "espn" } = {}) {
|
|
283
|
+
if (idSystem === "espn" && !Object.hasOwn(ESPN_HEADSHOT_LEAGUES, league))
|
|
284
|
+
throw new InputError(
|
|
285
|
+
`no ESPN headshots for league ${JSON.stringify(league)}; supported: ${Object.keys(ESPN_HEADSHOT_LEAGUES).sort().join(", ")}`
|
|
286
|
+
);
|
|
287
|
+
if (idSystem !== "espn" && !(idSystem === "gsis" && league === "nfl"))
|
|
288
|
+
throw new InputError(
|
|
289
|
+
`idSystem must be 'espn' (any league) or 'gsis' (nfl), got ${JSON.stringify(idSystem)} for ${JSON.stringify(league)}`
|
|
290
|
+
);
|
|
291
|
+
if (idSystem === "gsis" && !gsis)
|
|
292
|
+
throw new InputError(
|
|
293
|
+
'the gsis map is not loaded; await loadGsis() (or preloadAll()) before headshotUrl(\u2026, { idSystem: "gsis" })'
|
|
294
|
+
);
|
|
295
|
+
const pid = normValue(playerId);
|
|
296
|
+
if (pid === null) return void 0;
|
|
297
|
+
if (idSystem === "espn") return espn(pid, league);
|
|
298
|
+
const key = String(playerId).trim();
|
|
299
|
+
const row = gsis && Object.hasOwn(gsis, key) ? gsis[key] : void 0;
|
|
300
|
+
if (!row) return void 0;
|
|
301
|
+
if (row.headshot) {
|
|
302
|
+
const t = row.headshot.replace("/f_auto,q_auto/", "/t_headshot_desktop/f_auto/");
|
|
303
|
+
return t.endsWith(".png") ? t : `${t}.png`;
|
|
304
|
+
}
|
|
305
|
+
return row.espn_id ? espn(row.espn_id, "nfl") : void 0;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// src/resolve.ts
|
|
309
|
+
var lookups = /* @__PURE__ */ new WeakMap();
|
|
310
|
+
function lookup(d) {
|
|
311
|
+
let l = lookups.get(d);
|
|
312
|
+
if (!l) {
|
|
313
|
+
l = /* @__PURE__ */ new Map();
|
|
314
|
+
for (const a of d.aliases) {
|
|
315
|
+
const k = normValue(a.value);
|
|
316
|
+
if (k === null) continue;
|
|
317
|
+
let sys = l.get(a.id_system);
|
|
318
|
+
if (!sys) {
|
|
319
|
+
sys = /* @__PURE__ */ new Map();
|
|
320
|
+
l.set(a.id_system, sys);
|
|
321
|
+
}
|
|
322
|
+
let c = sys.get(k);
|
|
323
|
+
if (!c) {
|
|
324
|
+
c = [];
|
|
325
|
+
sys.set(k, c);
|
|
326
|
+
}
|
|
327
|
+
c.push([a.team_id, a.valid_from, a.valid_to]);
|
|
328
|
+
}
|
|
329
|
+
lookups.set(d, l);
|
|
330
|
+
}
|
|
331
|
+
return l;
|
|
332
|
+
}
|
|
333
|
+
var covers = (lo, hi, s) => (lo === null || s >= lo) && (hi === null || s <= hi);
|
|
334
|
+
function systems(idSystem) {
|
|
335
|
+
if (idSystem !== "auto" && !PRIORITY.includes(idSystem) && !EXPLICIT_ONLY.includes(idSystem))
|
|
336
|
+
throw new InputError(
|
|
337
|
+
`unknown idSystem ${JSON.stringify(idSystem)}; use "auto" or one of ${[...PRIORITY, ...EXPLICIT_ONLY].join(", ")}`
|
|
338
|
+
);
|
|
339
|
+
return idSystem === "auto" ? PRIORITY : [idSystem];
|
|
340
|
+
}
|
|
341
|
+
function match(key, season, sys, table, latest) {
|
|
342
|
+
const whens = [];
|
|
343
|
+
for (const w of [season, latest]) if (w !== null && !whens.includes(w)) whens.push(w);
|
|
344
|
+
whens.push(null);
|
|
345
|
+
for (const when of whens)
|
|
346
|
+
for (const s of sys) {
|
|
347
|
+
let cands = table.get(s)?.get(key);
|
|
348
|
+
if (!cands?.length) continue;
|
|
349
|
+
if (when !== null) {
|
|
350
|
+
cands = cands.filter((c) => covers(c[1], c[2], when));
|
|
351
|
+
if (!cands.length) continue;
|
|
352
|
+
}
|
|
353
|
+
const ids = [...new Set(cands.map((c) => c[0]))];
|
|
354
|
+
return ids.length === 1 ? ids[0] : ids.sort();
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
function seasons(season, n, league) {
|
|
359
|
+
if (!Array.isArray(season)) return Array(n).fill(normSeason(season, league));
|
|
360
|
+
if (season.length !== n)
|
|
361
|
+
throw new InputError(`season has ${season.length} values but there are ${n} teams`);
|
|
362
|
+
return season.map((s) => normSeason(s, league));
|
|
363
|
+
}
|
|
364
|
+
function resolveIds(items, league, ss, idSystem, d) {
|
|
365
|
+
const sys = systems(idSystem);
|
|
366
|
+
for (const y of new Set(ss)) if (y !== null) checkSeason(y, league);
|
|
367
|
+
const table = lookup(d);
|
|
368
|
+
const latest = latestSeason(league);
|
|
369
|
+
let names;
|
|
370
|
+
const nameOf = (t) => {
|
|
371
|
+
names ??= new Map(d.teams.map((x) => [x.team_id, x.name ?? ""]));
|
|
372
|
+
return names.get(t) ?? "";
|
|
373
|
+
};
|
|
374
|
+
const out = [];
|
|
375
|
+
const unresolved = /* @__PURE__ */ new Map();
|
|
376
|
+
const memo = /* @__PURE__ */ new Map();
|
|
377
|
+
items.forEach((v, i) => {
|
|
378
|
+
const key = normValue(v);
|
|
379
|
+
if (key === null) {
|
|
380
|
+
out.push(void 0);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const mk = `${key}\0${ss[i]}`;
|
|
384
|
+
if (!memo.has(mk)) memo.set(mk, match(key, ss[i] ?? null, sys, table, latest));
|
|
385
|
+
const hit = memo.get(mk);
|
|
386
|
+
if (hit === null || Array.isArray(hit)) {
|
|
387
|
+
unresolved.set(
|
|
388
|
+
String(v),
|
|
389
|
+
hit === null ? "unknown" : `ambiguous: ${hit.map((t) => `${t} ${nameOf(t)}`.trim()).join(" or ")}`
|
|
390
|
+
);
|
|
391
|
+
out.push(void 0);
|
|
392
|
+
} else out.push(asTeamId(hit));
|
|
393
|
+
});
|
|
394
|
+
return { out, unresolved };
|
|
395
|
+
}
|
|
396
|
+
function report(unresolved, league, strict) {
|
|
397
|
+
const shown = [...unresolved].map(([v, why]) => `'${v}' (${why})`).join(", ");
|
|
398
|
+
let msg = `${unresolved.size} value(s) did not resolve to a ${league} team: ${shown}`;
|
|
399
|
+
if ([...unresolved.values()].some((w) => w.startsWith("ambiguous")))
|
|
400
|
+
msg += "; pass season for a code reused across eras, or idSystem for the id system of the values";
|
|
401
|
+
if (strict) throw new UnresolvedTeamError(msg);
|
|
402
|
+
warn(
|
|
403
|
+
`${league}:${[...unresolved.keys()].join(",")}`,
|
|
404
|
+
`${msg}. Use suggest() for candidates, or strict: true to throw.`
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
function resolveSync(values, league, opts = {}) {
|
|
408
|
+
const d = getLeagueSync(league);
|
|
409
|
+
const arr = Array.isArray(values);
|
|
410
|
+
const items = arr ? values : [values];
|
|
411
|
+
const { out, unresolved } = resolveIds(
|
|
412
|
+
items,
|
|
413
|
+
league,
|
|
414
|
+
seasons(opts.season, items.length, league),
|
|
415
|
+
opts.idSystem ?? "auto",
|
|
416
|
+
d
|
|
417
|
+
);
|
|
418
|
+
if (unresolved.size) report(unresolved, league, opts.strict ?? false);
|
|
419
|
+
return arr ? out : out[0];
|
|
420
|
+
}
|
|
421
|
+
async function resolve(values, league, opts = {}) {
|
|
422
|
+
await loadLeague(league);
|
|
423
|
+
return resolveSync(values, league, opts);
|
|
424
|
+
}
|
|
425
|
+
async function suggest(value, league, opts = {}) {
|
|
426
|
+
const n = opts.n ?? 5;
|
|
427
|
+
if (!Number.isInteger(n) || n < 1)
|
|
428
|
+
throw new InputError(
|
|
429
|
+
`n is the most candidates to return, an int of at least 1, got ${JSON.stringify(n)}`
|
|
430
|
+
);
|
|
431
|
+
const d = await loadLeague(league);
|
|
432
|
+
const key = normValue(value);
|
|
433
|
+
if (key === null) return [];
|
|
434
|
+
const merged = /* @__PURE__ */ new Map();
|
|
435
|
+
for (const sys of lookup(d).values())
|
|
436
|
+
for (const [k, cands] of sys) merged.set(k, [...merged.get(k) ?? [], ...cands.map((c) => c[0])]);
|
|
437
|
+
const names = new Map(d.teams.map((t) => [t.team_id, t.name ?? t.team_id]));
|
|
438
|
+
const scored = [...merged.keys()].map((k) => [k, ratio(k, key)]).filter(([, r]) => r >= 0.6).sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? 1 : a[0] > b[0] ? -1 : 0)).slice(0, n * 3);
|
|
439
|
+
const out = [];
|
|
440
|
+
for (const [k] of scored)
|
|
441
|
+
for (const tid of merged.get(k) ?? [])
|
|
442
|
+
if (!out.some(([t]) => t === tid)) out.push([asTeamId(tid), names.get(tid) ?? tid]);
|
|
443
|
+
return out.slice(0, n);
|
|
444
|
+
}
|
|
445
|
+
function ratio(a, b) {
|
|
446
|
+
const matches = (x, y) => {
|
|
447
|
+
if (!x || !y) return 0;
|
|
448
|
+
let bi = 0;
|
|
449
|
+
let bj = 0;
|
|
450
|
+
let best = 0;
|
|
451
|
+
let prev = Array(y.length + 1).fill(0);
|
|
452
|
+
for (let i = 1; i <= x.length; i++) {
|
|
453
|
+
const cur = Array(y.length + 1).fill(0);
|
|
454
|
+
for (let j = 1; j <= y.length; j++)
|
|
455
|
+
if (x[i - 1] === y[j - 1]) {
|
|
456
|
+
const v = (prev[j - 1] ?? 0) + 1;
|
|
457
|
+
cur[j] = v;
|
|
458
|
+
if (v > best) {
|
|
459
|
+
best = v;
|
|
460
|
+
bi = i;
|
|
461
|
+
bj = j;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
prev = cur;
|
|
465
|
+
}
|
|
466
|
+
if (!best) return 0;
|
|
467
|
+
return best + matches(x.slice(0, bi - best), y.slice(0, bj - best)) + matches(x.slice(bi), y.slice(bj));
|
|
468
|
+
};
|
|
469
|
+
return a.length + b.length === 0 ? 1 : 2 * matches(a, b) / (a.length + b.length);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// src/colors.ts
|
|
473
|
+
var COLUMNS = { primary: "color_primary", secondary: "color_secondary" };
|
|
474
|
+
function column(which) {
|
|
475
|
+
if (which !== "primary" && which !== "secondary")
|
|
476
|
+
throw new InputError(`which must be one of primary, secondary, got ${JSON.stringify(which)}`);
|
|
477
|
+
return COLUMNS[which];
|
|
478
|
+
}
|
|
479
|
+
function colorMap(league, col) {
|
|
480
|
+
const m = /* @__PURE__ */ new Map();
|
|
481
|
+
for (const t of getLeagueSync(league).teams) if (t[col]) m.set(t.team_id, t[col]);
|
|
482
|
+
return m;
|
|
483
|
+
}
|
|
484
|
+
async function palette(league, teams, opts = {}) {
|
|
485
|
+
const col = column(opts.which ?? "primary");
|
|
486
|
+
checkLeague(league);
|
|
487
|
+
await loadLeague(league);
|
|
488
|
+
const colors = colorMap(league, col);
|
|
489
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
490
|
+
if (teams == null) {
|
|
491
|
+
const rows = getLeagueSync(league).teams;
|
|
492
|
+
const counts = /* @__PURE__ */ new Map();
|
|
493
|
+
for (const t of rows) if (t.abbr) counts.set(t.abbr, (counts.get(t.abbr) ?? 0) + 1);
|
|
494
|
+
const shared = [...counts].filter(([, n]) => n > 1).map(([a]) => a);
|
|
495
|
+
if (shared.length)
|
|
496
|
+
warn(
|
|
497
|
+
`palette:shared:${league}`,
|
|
498
|
+
`abbreviations shared by several ${league} teams are keyed by team_id: ${shared.sort().join(", ")}`
|
|
499
|
+
);
|
|
500
|
+
for (const t of rows) {
|
|
501
|
+
const c = colors.get(t.team_id);
|
|
502
|
+
if (c === void 0) continue;
|
|
503
|
+
out[!t.abbr || shared.includes(t.abbr) ? t.team_id : t.abbr] = c;
|
|
504
|
+
}
|
|
505
|
+
return out;
|
|
506
|
+
}
|
|
507
|
+
const values = Array.isArray(teams) ? teams : [teams];
|
|
508
|
+
const slot = values.find((v) => v === "primary" || v === "secondary");
|
|
509
|
+
if (slot !== void 0)
|
|
510
|
+
throw new InputError(
|
|
511
|
+
`${JSON.stringify(slot)} is a color slot, not a team; pass it as an option: palette(league, teams, { which: "${slot}" })`
|
|
512
|
+
);
|
|
513
|
+
const ss = Array.isArray(opts.season) ? opts.season : Array(values.length).fill(opts.season);
|
|
514
|
+
if (ss.length !== values.length)
|
|
515
|
+
throw new InputError(`season has ${ss.length} values but there are ${values.length} teams`);
|
|
516
|
+
const seen = /* @__PURE__ */ new Set();
|
|
517
|
+
const vs = [];
|
|
518
|
+
const ys = [];
|
|
519
|
+
values.forEach((v, i) => {
|
|
520
|
+
if (v === null || v === void 0) return;
|
|
521
|
+
const k = `${typeof v}:${String(v)}\0${String(ss[i])}`;
|
|
522
|
+
if (seen.has(k)) return;
|
|
523
|
+
seen.add(k);
|
|
524
|
+
vs.push(v);
|
|
525
|
+
ys.push(ss[i]);
|
|
526
|
+
});
|
|
527
|
+
const ids = resolveSync(vs, league, { ...opts, season: ys });
|
|
528
|
+
vs.forEach((v, i) => {
|
|
529
|
+
const id = ids[i];
|
|
530
|
+
const c = id === void 0 ? void 0 : colors.get(id);
|
|
531
|
+
if (c !== void 0) out[String(v)] ??= c;
|
|
532
|
+
});
|
|
533
|
+
return out;
|
|
534
|
+
}
|
|
535
|
+
function teamColorsSync(league, teams, opts = {}) {
|
|
536
|
+
const col = column(opts.which ?? "primary");
|
|
537
|
+
checkLeague(league);
|
|
538
|
+
const colors = colorMap(league, col);
|
|
539
|
+
const ids = resolveSync(teams, league, opts);
|
|
540
|
+
const pick = (id) => id === void 0 ? void 0 : colors.get(id);
|
|
541
|
+
return Array.isArray(ids) ? ids.map(pick) : pick(ids);
|
|
542
|
+
}
|
|
543
|
+
function teamColorPairSync(league, team, opts = {}) {
|
|
544
|
+
checkLeague(league);
|
|
545
|
+
const id = resolveSync(team, league, opts);
|
|
546
|
+
const pick = (col) => id === void 0 ? void 0 : colorMap(league, col).get(id);
|
|
547
|
+
return { primary: pick("color_primary"), secondary: pick("color_secondary") };
|
|
548
|
+
}
|
|
549
|
+
async function teamColors(league, teams, opts = {}) {
|
|
550
|
+
await loadLeague(league);
|
|
551
|
+
return teamColorsSync(league, teams, opts);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export { ESPN_HEADSHOT_LEAGUES, EXPLICIT_ONLY, HEADSHOT_ASPECT, INDEX_VERSION, LEAGUES, MANIFEST_LAST_MODIFIED, PRIORITY, VARIANTS, archiveUrl, checkLeague, getLeagueSync, headshotUrl, latestSeason, loadGsis, loadLeague, mlbHeadshotUrl, nbaHeadshotUrl, nhlHeadshotUrl, normSeason, normValue, palette, preloadAll, resolve, resolveSync, seasonBounds, suggest, teamColorPairSync, teamColors, teamColorsSync, wnbaHeadshotUrl };
|
|
555
|
+
//# sourceMappingURL=chunk-ZAEQXFJM.js.map
|
|
556
|
+
//# sourceMappingURL=chunk-ZAEQXFJM.js.map
|