fansunited-data-layer 0.12.1 → 0.14.1

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.
Files changed (261) hide show
  1. package/api/fansunited/constants.js +5 -0
  2. package/api/fansunited/constants.js.map +1 -0
  3. package/api/fansunited/football/competition/index.js +21 -0
  4. package/api/fansunited/football/competition/index.js.map +1 -0
  5. package/api/fansunited/football/competition/transformer.js +41 -0
  6. package/api/fansunited/football/competition/transformer.js.map +1 -0
  7. package/api/fansunited/football/competitions/index.js +56 -0
  8. package/api/fansunited/football/competitions/index.js.map +1 -0
  9. package/api/fansunited/football/competitions/transformer.js +68 -0
  10. package/api/fansunited/football/competitions/transformer.js.map +1 -0
  11. package/api/fansunited/football/http.js +7 -0
  12. package/api/fansunited/football/http.js.map +1 -0
  13. package/api/fansunited/football/matches/index.js +132 -0
  14. package/api/fansunited/football/matches/index.js.map +1 -0
  15. package/api/fansunited/football/matches/transformer.js +148 -0
  16. package/api/fansunited/football/matches/transformer.js.map +1 -0
  17. package/api/fansunited/football/players/index.js +60 -0
  18. package/api/fansunited/football/players/index.js.map +1 -0
  19. package/api/fansunited/football/players/transformer.js +85 -0
  20. package/api/fansunited/football/players/transformer.js.map +1 -0
  21. package/api/fansunited/football/search/index.js +64 -0
  22. package/api/fansunited/football/search/index.js.map +1 -0
  23. package/api/fansunited/football/search/transformer.js +114 -0
  24. package/api/fansunited/football/search/transformer.js.map +1 -0
  25. package/api/fansunited/football/teams/index.js +66 -0
  26. package/api/fansunited/football/teams/index.js.map +1 -0
  27. package/api/fansunited/football/teams/transformer.js +53 -0
  28. package/api/fansunited/football/teams/transformer.js.map +1 -0
  29. package/api/fansunited/http.js +74 -0
  30. package/api/fansunited/http.js.map +1 -0
  31. package/api/fansunited/search/constants.js +5 -0
  32. package/api/fansunited/search/constants.js.map +1 -0
  33. package/api/fansunited/search/http.js +7 -0
  34. package/api/fansunited/search/http.js.map +1 -0
  35. package/api/fansunited/search/index.js +308 -0
  36. package/api/fansunited/search/index.js.map +1 -0
  37. package/api/fansunited/search/transformer.js +374 -0
  38. package/api/fansunited/search/transformer.js.map +1 -0
  39. package/api/fansunited-sdk/loyalty/matches.js +21 -0
  40. package/api/fansunited-sdk/loyalty/matches.js.map +1 -0
  41. package/api/fansunited-sdk/loyalty/template.js +52 -0
  42. package/api/fansunited-sdk/loyalty/template.js.map +1 -0
  43. package/api/fansunited-sdk/odds/matches.js +109 -0
  44. package/api/fansunited-sdk/odds/matches.js.map +1 -0
  45. package/api/sportal365-sports/basketball/games/index.js +32 -0
  46. package/api/sportal365-sports/basketball/games/index.js.map +1 -0
  47. package/api/sportal365-sports/basketball/games/transformers/game.js +137 -0
  48. package/api/sportal365-sports/basketball/games/transformers/game.js.map +1 -0
  49. package/api/sportal365-sports/basketball/http.js +7 -0
  50. package/api/sportal365-sports/basketball/http.js.map +1 -0
  51. package/api/sportal365-sports/constants.js +15 -0
  52. package/api/sportal365-sports/constants.js.map +1 -0
  53. package/api/sportal365-sports/football/competitions/index.js +52 -0
  54. package/api/sportal365-sports/football/competitions/index.js.map +1 -0
  55. package/api/sportal365-sports/football/competitions/utils.js +92 -0
  56. package/api/sportal365-sports/football/competitions/utils.js.map +1 -0
  57. package/api/sportal365-sports/football/http.js +7 -0
  58. package/api/sportal365-sports/football/http.js.map +1 -0
  59. package/api/sportal365-sports/football/index.d.ts +2 -2
  60. package/api/sportal365-sports/football/index.d.ts.map +1 -1
  61. package/api/sportal365-sports/football/matches/index.js +206 -0
  62. package/api/sportal365-sports/football/matches/index.js.map +1 -0
  63. package/api/sportal365-sports/football/matches/transformers/commentary.js +27 -0
  64. package/api/sportal365-sports/football/matches/transformers/commentary.js.map +1 -0
  65. package/api/sportal365-sports/football/matches/transformers/lineup.js +74 -0
  66. package/api/sportal365-sports/football/matches/transformers/lineup.js.map +1 -0
  67. package/api/sportal365-sports/football/matches/transformers/match-event.js +60 -0
  68. package/api/sportal365-sports/football/matches/transformers/match-event.js.map +1 -0
  69. package/api/sportal365-sports/football/matches/transformers/match.js +195 -0
  70. package/api/sportal365-sports/football/matches/transformers/match.js.map +1 -0
  71. package/api/sportal365-sports/football/matches/transformers/odds.js +11 -0
  72. package/api/sportal365-sports/football/matches/transformers/odds.js.map +1 -0
  73. package/api/sportal365-sports/football/matches/transformers/statistics.js +41 -0
  74. package/api/sportal365-sports/football/matches/transformers/statistics.js.map +1 -0
  75. package/api/sportal365-sports/football/search/index.js +42 -0
  76. package/api/sportal365-sports/football/search/index.js.map +1 -0
  77. package/api/sportal365-sports/football/search/search.transformer.js +166 -0
  78. package/api/sportal365-sports/football/search/search.transformer.js.map +1 -0
  79. package/api/sportal365-sports/football/standings/index.js +28 -0
  80. package/api/sportal365-sports/football/standings/index.js.map +1 -0
  81. package/api/sportal365-sports/football/standings/standing.transformer.js +107 -0
  82. package/api/sportal365-sports/football/standings/standing.transformer.js.map +1 -0
  83. package/api/sportal365-sports/football/statistics/index.d.ts +46 -1
  84. package/api/sportal365-sports/football/statistics/index.d.ts.map +1 -1
  85. package/api/sportal365-sports/football/statistics/index.js +154 -0
  86. package/api/sportal365-sports/football/statistics/index.js.map +1 -0
  87. package/api/sportal365-sports/football/statistics/player-career.transformer.d.ts +11 -0
  88. package/api/sportal365-sports/football/statistics/player-career.transformer.d.ts.map +1 -0
  89. package/api/sportal365-sports/football/statistics/player-career.transformer.js +77 -0
  90. package/api/sportal365-sports/football/statistics/player-career.transformer.js.map +1 -0
  91. package/api/sportal365-sports/football/statistics/player-career.types.d.ts +115 -0
  92. package/api/sportal365-sports/football/statistics/player-career.types.d.ts.map +1 -0
  93. package/api/sportal365-sports/football/statistics/player-recent.transformer.d.ts +11 -0
  94. package/api/sportal365-sports/football/statistics/player-recent.transformer.d.ts.map +1 -0
  95. package/api/sportal365-sports/football/statistics/player-recent.transformer.js +54 -0
  96. package/api/sportal365-sports/football/statistics/player-recent.transformer.js.map +1 -0
  97. package/api/sportal365-sports/football/statistics/player-recent.types.d.ts +31 -0
  98. package/api/sportal365-sports/football/statistics/player-recent.types.d.ts.map +1 -0
  99. package/api/sportal365-sports/football/statistics/player-season.transformer.js +147 -0
  100. package/api/sportal365-sports/football/statistics/player-season.transformer.js.map +1 -0
  101. package/api/sportal365-sports/football/teams/index.js +73 -0
  102. package/api/sportal365-sports/football/teams/index.js.map +1 -0
  103. package/api/sportal365-sports/football/teams/utils.js +196 -0
  104. package/api/sportal365-sports/football/teams/utils.js.map +1 -0
  105. package/api/sportal365-sports/http.js +58 -0
  106. package/api/sportal365-sports/http.js.map +1 -0
  107. package/api/sportal365-sports/index.d.ts +2 -2
  108. package/api/sportal365-sports/index.d.ts.map +1 -1
  109. package/api/sportal365-sports/search/http.js +7 -0
  110. package/api/sportal365-sports/search/http.js.map +1 -0
  111. package/api/sportal365-sports/search/index.js +61 -0
  112. package/api/sportal365-sports/search/index.js.map +1 -0
  113. package/api/sportal365-sports/search/search.transformer.js +254 -0
  114. package/api/sportal365-sports/search/search.transformer.js.map +1 -0
  115. package/api/sportal365-sports/shared/odds.transformer.js +65 -0
  116. package/api/sportal365-sports/shared/odds.transformer.js.map +1 -0
  117. package/api/sportal365-sports/shared/providerRef.helper.js +31 -0
  118. package/api/sportal365-sports/shared/providerRef.helper.js.map +1 -0
  119. package/api/sportal365-sports/standings/http.js +7 -0
  120. package/api/sportal365-sports/standings/http.js.map +1 -0
  121. package/api/sportal365-sports/standings/index.js +29 -0
  122. package/api/sportal365-sports/standings/index.js.map +1 -0
  123. package/api/sportal365-sports/standings/standing.transformer.js +185 -0
  124. package/api/sportal365-sports/standings/standing.transformer.js.map +1 -0
  125. package/api/sportal365-sports/statistics/http.js +7 -0
  126. package/api/sportal365-sports/statistics/http.js.map +1 -0
  127. package/api/sportal365-sports/statistics/index.js +25 -0
  128. package/api/sportal365-sports/statistics/index.js.map +1 -0
  129. package/api/sportal365-sports/statistics/team-stats.transformer.js +16 -0
  130. package/api/sportal365-sports/statistics/team-stats.transformer.js.map +1 -0
  131. package/api/sportal365-sports/tennis/http.js +7 -0
  132. package/api/sportal365-sports/tennis/http.js.map +1 -0
  133. package/api/sportal365-sports/tennis/matches/index.js +34 -0
  134. package/api/sportal365-sports/tennis/matches/index.js.map +1 -0
  135. package/api/sportal365-sports/tennis/matches/transformers/match.js +193 -0
  136. package/api/sportal365-sports/tennis/matches/transformers/match.js.map +1 -0
  137. package/cache/cache-manager.js +136 -0
  138. package/cache/cache-manager.js.map +1 -0
  139. package/cache/memory-store.js +29 -0
  140. package/cache/memory-store.js.map +1 -0
  141. package/client.js +38 -12337
  142. package/client.js.map +1 -0
  143. package/config/index.js +20 -0
  144. package/config/index.js.map +1 -0
  145. package/fansunited-data-layer.js +146 -3551
  146. package/fansunited-data-layer.js.map +1 -0
  147. package/helpers/competition.helpers.js +11 -0
  148. package/helpers/competition.helpers.js.map +1 -0
  149. package/helpers/player.helpers.js +165 -0
  150. package/helpers/player.helpers.js.map +1 -0
  151. package/helpers/player.hooks.js +34 -0
  152. package/helpers/player.hooks.js.map +1 -0
  153. package/helpers/team.helpers.js +216 -0
  154. package/helpers/team.helpers.js.map +1 -0
  155. package/index.d.ts +3 -3
  156. package/index.d.ts.map +1 -1
  157. package/package.json +6 -8
  158. package/providers/competition/hooks/useCompetitionStats.js +10 -0
  159. package/providers/competition/hooks/useCompetitionStats.js.map +1 -0
  160. package/providers/competition/hooks/useGoalDistribution.js +23 -0
  161. package/providers/competition/hooks/useGoalDistribution.js.map +1 -0
  162. package/providers/competition/hooks/useMatchHelpers.js +85 -0
  163. package/providers/competition/hooks/useMatchHelpers.js.map +1 -0
  164. package/providers/competition/hooks/useStandingsCalculations.js +89 -0
  165. package/providers/competition/hooks/useStandingsCalculations.js.map +1 -0
  166. package/providers/competition/hooks/useStandingsHelpers.js +61 -0
  167. package/providers/competition/hooks/useStandingsHelpers.js.map +1 -0
  168. package/providers/competition/hooks/useTeamPosition.js +15 -0
  169. package/providers/competition/hooks/useTeamPosition.js.map +1 -0
  170. package/providers/competition/hooks/useTeamResultsTable.js +86 -0
  171. package/providers/competition/hooks/useTeamResultsTable.js.map +1 -0
  172. package/providers/competition/utils/competitionStats.js +109 -0
  173. package/providers/competition/utils/competitionStats.js.map +1 -0
  174. package/providers/competition/utils/goalDistribution.js +64 -0
  175. package/providers/competition/utils/goalDistribution.js.map +1 -0
  176. package/providers/competition/utils/standingsCalculations.js +152 -0
  177. package/providers/competition/utils/standingsCalculations.js.map +1 -0
  178. package/providers/competition.context.js +14 -0
  179. package/providers/competition.context.js.map +1 -0
  180. package/providers/competition.provider.js +187 -0
  181. package/providers/competition.provider.js.map +1 -0
  182. package/providers/fansunited-config.context.js +6 -0
  183. package/providers/fansunited-config.context.js.map +1 -0
  184. package/providers/fansunited-config.hooks.js +20 -0
  185. package/providers/fansunited-config.hooks.js.map +1 -0
  186. package/providers/fansunited-config.provider.js +9 -0
  187. package/providers/fansunited-config.provider.js.map +1 -0
  188. package/providers/fansunited-sdk.hook.js +50 -0
  189. package/providers/fansunited-sdk.hook.js.map +1 -0
  190. package/providers/leaderboard/hooks/useMatchHelpers.js +30 -0
  191. package/providers/leaderboard/hooks/useMatchHelpers.js.map +1 -0
  192. package/providers/leaderboard/hooks/useTemplateHelpers.js +39 -0
  193. package/providers/leaderboard/hooks/useTemplateHelpers.js.map +1 -0
  194. package/providers/leaderboard.context.js +14 -0
  195. package/providers/leaderboard.context.js.map +1 -0
  196. package/providers/leaderboard.provider.js +98 -0
  197. package/providers/leaderboard.provider.js.map +1 -0
  198. package/providers/match/hooks/useBatchMatchOdds.js +72 -0
  199. package/providers/match/hooks/useBatchMatchOdds.js.map +1 -0
  200. package/providers/match/hooks/useEventHelpers.js +46 -0
  201. package/providers/match/hooks/useEventHelpers.js.map +1 -0
  202. package/providers/match/hooks/useHeadToHeadHelpers.js +52 -0
  203. package/providers/match/hooks/useHeadToHeadHelpers.js.map +1 -0
  204. package/providers/match/hooks/useLineupHelpers.js +53 -0
  205. package/providers/match/hooks/useLineupHelpers.js.map +1 -0
  206. package/providers/match/hooks/useMatchStandingsCalculations.js +332 -0
  207. package/providers/match/hooks/useMatchStandingsCalculations.js.map +1 -0
  208. package/providers/match/hooks/useMatchStatus.js +37 -0
  209. package/providers/match/hooks/useMatchStatus.js.map +1 -0
  210. package/providers/match/hooks/useOddsHelpers.js +54 -0
  211. package/providers/match/hooks/useOddsHelpers.js.map +1 -0
  212. package/providers/match/hooks/useScoreHelpers.js +34 -0
  213. package/providers/match/hooks/useScoreHelpers.js.map +1 -0
  214. package/providers/match/hooks/useStandingsHelpers.js +53 -0
  215. package/providers/match/hooks/useStandingsHelpers.js.map +1 -0
  216. package/providers/match/hooks/useStatisticsHelpers.js +40 -0
  217. package/providers/match/hooks/useStatisticsHelpers.js.map +1 -0
  218. package/providers/match/hooks/useTeamHelpers.js +38 -0
  219. package/providers/match/hooks/useTeamHelpers.js.map +1 -0
  220. package/providers/match/hooks/useTeamStatsHelpers.js +141 -0
  221. package/providers/match/hooks/useTeamStatsHelpers.js.map +1 -0
  222. package/providers/match.context.js +14 -0
  223. package/providers/match.context.js.map +1 -0
  224. package/providers/match.provider.js +176 -0
  225. package/providers/match.provider.js.map +1 -0
  226. package/providers/team/hooks/useFormStats.js +116 -0
  227. package/providers/team/hooks/useFormStats.js.map +1 -0
  228. package/providers/team/hooks/useMatchHelpers.js +46 -0
  229. package/providers/team/hooks/useMatchHelpers.js.map +1 -0
  230. package/providers/team/hooks/useSquadHelpers.js +67 -0
  231. package/providers/team/hooks/useSquadHelpers.js.map +1 -0
  232. package/providers/team.context.js +14 -0
  233. package/providers/team.context.js.map +1 -0
  234. package/providers/team.provider.js +98 -0
  235. package/providers/team.provider.js.map +1 -0
  236. package/types/canonical/index.d.ts +1 -1
  237. package/types/canonical/index.d.ts.map +1 -1
  238. package/types/canonical/statistics.types.d.ts +102 -0
  239. package/types/canonical/statistics.types.d.ts.map +1 -1
  240. package/utilities/stats/core/helpers.js +105 -0
  241. package/utilities/stats/core/helpers.js.map +1 -0
  242. package/utilities/stats/core/types.js +5 -0
  243. package/utilities/stats/core/types.js.map +1 -0
  244. package/utilities/stats/match/headToHead.js +83 -0
  245. package/utilities/stats/match/headToHead.js.map +1 -0
  246. package/utilities/stats/match/homeVsAway.js +140 -0
  247. package/utilities/stats/match/homeVsAway.js.map +1 -0
  248. package/utilities/stats/match/overUnder.js +91 -0
  249. package/utilities/stats/match/overUnder.js.map +1 -0
  250. package/utilities/stats/match/result.js +21 -0
  251. package/utilities/stats/match/result.js.map +1 -0
  252. package/utilities/stats/team/commonOpponents.js +77 -0
  253. package/utilities/stats/team/commonOpponents.js.map +1 -0
  254. package/utilities/stats/team/goalStats.js +50 -0
  255. package/utilities/stats/team/goalStats.js.map +1 -0
  256. package/utilities/stats/team/streaks.js +183 -0
  257. package/utilities/stats/team/streaks.js.map +1 -0
  258. package/client.cjs +0 -8
  259. package/fansunited-data-layer.cjs +0 -1
  260. package/matches-CB-dSXEA.js +0 -1633
  261. package/matches-DvC2VSyO.cjs +0 -1
@@ -1,1633 +0,0 @@
1
- const A = "__FANSUNITED_DATA_LAYER_CONFIG__";
2
- function Le(e) {
3
- globalThis[A] = e;
4
- }
5
- function g() {
6
- const e = globalThis[A];
7
- if (!e)
8
- throw new Error("Data layer config not initialized. Call setConfig() in your root layout.");
9
- return e;
10
- }
11
- function ke() {
12
- return globalThis[A] !== void 0;
13
- }
14
- function U(e) {
15
- const t = e.replace(/\/$/, "");
16
- function n(s) {
17
- const { sportal365Sports: a } = s;
18
- if (!a)
19
- throw new Error("Sportal365 Sports API configuration is missing");
20
- const l = `${a.username}:${a.password}`;
21
- return `Basic ${btoa(l)}`;
22
- }
23
- function o(s) {
24
- return `${t}${s}`;
25
- }
26
- return {
27
- async get(s) {
28
- const a = s.config || g(), { sportal365Sports: l } = a;
29
- if (!l)
30
- throw new Error("Sportal365 Sports API configuration is missing");
31
- const d = new URL(o(s.path));
32
- if (s.params)
33
- for (const [_, m] of Object.entries(s.params))
34
- m !== void 0 && (Array.isArray(m) ? m.length > 0 && d.searchParams.set(_, m.join(",")) : d.searchParams.set(_, m));
35
- const u = await fetch(d.toString(), {
36
- method: "GET",
37
- headers: {
38
- Authorization: n(a),
39
- "Content-Type": "application/json",
40
- "X-Project": l.projectId,
41
- // Merge custom headers (they can override defaults)
42
- ...s.headers
43
- },
44
- signal: l.timeout ? AbortSignal.timeout(l.timeout) : void 0,
45
- // Next.js cache options for ISR/on-demand revalidation
46
- ...s.next && { next: s.next }
47
- });
48
- if (!u.ok)
49
- throw new Error(`Sportal365 API error: ${u.status} ${u.statusText}`);
50
- return u.json();
51
- }
52
- };
53
- }
54
- const G = "https://football.api.sportal365.com", De = "https://basketball.api.sportal365.com", Ne = "https://tennis.api.sportal365.com", Fe = "https://sports-statistics.api.sportal365.com", Pe = "https://sports-search.api.sportal365.com", xe = "https://standing.api.sportal365.com", p = U(G);
55
- function R(e) {
56
- if (e)
57
- return {
58
- id: e.id,
59
- name: e.name,
60
- slug: e.slug,
61
- position: e.position,
62
- gender: e.gender,
63
- assets: e.assets ? {
64
- photo: e.assets.thumb?.url,
65
- photoTransparent: e.assets.thumb_transparent_background?.url
66
- } : void 0
67
- };
68
- }
69
- const H = {
70
- // Scoring events
71
- GOAL: "GOAL",
72
- PENALTY_GOAL: "PENALTY_GOAL",
73
- OWN_GOAL: "OWN_GOAL",
74
- DISALLOWED_GOAL: "DISALLOWED_GOAL",
75
- PENALTY_SHOOTOUT_SCORED: "PENALTY_SHOOTOUT_SCORED",
76
- PENALTY_SHOOTOUT_MISSED: "PENALTY_SHOOTOUT_MISSED",
77
- // Card events
78
- YELLOW_CARD: "YELLOW_CARD",
79
- RED_CARD: "RED_CARD",
80
- YELLOW_RED_CARD: "YELLOW_RED_CARD",
81
- // Substitution
82
- SUBSTITUTION: "SUBSTITUTION",
83
- // Match flow events
84
- KICKOFF: "KICKOFF",
85
- HALFTIME: "HALFTIME",
86
- START_SECOND_HALF: "START_SECOND_HALF",
87
- FINISHED: "FINISHED",
88
- INJURY_TIME: "INJURY_TIME",
89
- // Penalty events
90
- PENALTY_AWARDED: "PENALTY_AWARDED",
91
- PENALTY_MISSED: "PENALTY_MISSED",
92
- PENALTY_SAVED: "PENALTY_SAVED"
93
- };
94
- function S(e) {
95
- const t = H[e.type_code];
96
- return t ? {
97
- id: e.id,
98
- type: t,
99
- competitorPosition: e.team_position === "HOME" ? "ONE" : "TWO",
100
- minute: e.minute,
101
- injuryMinute: e.injury_minute,
102
- primaryPlayer: R(e.primary_player),
103
- secondaryPlayer: R(e.secondary_player),
104
- score: e.score ? { competitorOne: String(e.score.home), competitorTwo: String(e.score.away) } : void 0
105
- } : (console.warn(`Unknown event type: ${e.type_code}`), null);
106
- }
107
- function r(e, t = "sportal365") {
108
- if (e)
109
- return [
110
- {
111
- provider: t,
112
- id: e
113
- }
114
- ];
115
- }
116
- function Me(e, t) {
117
- return e ? e.find((o) => o.provider === t)?.id : void 0;
118
- }
119
- function Ue(e, t, n) {
120
- const o = e ?? [], s = o.findIndex((a) => a.provider === t);
121
- if (s >= 0) {
122
- const a = [...o];
123
- return a[s] = { provider: t, id: n }, a;
124
- } else
125
- return [...o, { provider: t, id: n }];
126
- }
127
- function B(e) {
128
- const t = e.urls?.find((n) => n.app_type === "desktop")?.url;
129
- return {
130
- id: e.id,
131
- name: e.name,
132
- code: e.code,
133
- value: e.value ?? void 0,
134
- odds: e.odds,
135
- oddsOld: e.odds_old,
136
- movement: e.movement === "STABLE" ? "NONE" : e.movement,
137
- url: t,
138
- providerSelectionId: e.provider_info?.selection_id
139
- };
140
- }
141
- function $(e) {
142
- return {
143
- type: {
144
- id: e.type.id,
145
- code: e.type.code,
146
- name: e.type.name
147
- },
148
- period: {
149
- id: e.scope.id,
150
- type: e.scope.type,
151
- name: e.scope.name
152
- },
153
- selections: e.selections.map(B)
154
- };
155
- }
156
- function Y(e) {
157
- if (!e) return !0;
158
- const t = e.replace("#", ""), n = parseInt(t.substring(0, 2), 16), o = parseInt(t.substring(2, 4), 16), s = parseInt(t.substring(4, 6), 16);
159
- return (0.2126 * n + 0.7152 * o + 0.0722 * s) / 255 < 0.5;
160
- }
161
- function V(e) {
162
- const t = e.bookmaker.assets?.[0], n = e.bookmaker.branding || t, o = e.bookmaker.branding?.background_color || t?.background_color, s = e.bookmaker.branding?.text_color || (Y(o) ? "#FFFFFF" : "#000000");
163
- return {
164
- operator: {
165
- id: e.bookmaker.id,
166
- name: e.bookmaker.name,
167
- url: e.bookmaker.url,
168
- branding: n ? {
169
- backgroundColor: o,
170
- textColor: s,
171
- logo: t?.logo
172
- } : void 0
173
- },
174
- type: e.type,
175
- markets: e.markets.map($)
176
- };
177
- }
178
- function W(e) {
179
- return e.map(V);
180
- }
181
- function j(e) {
182
- const t = {
183
- finished_ap: "finished_after_penalties",
184
- // finished after penalties
185
- finished_aet: "finished_after_extra_time",
186
- // finished after extra time
187
- finished: "finished",
188
- not_started: "not_started",
189
- live: "live",
190
- interrupted: "interrupted",
191
- cancelled: "cancelled",
192
- postponed: "postponed",
193
- abandoned: "abandoned"
194
- };
195
- let n;
196
- return e.code && t[e.code] ? n = t[e.code] : n = {
197
- FINISHED: "finished",
198
- NOT_STARTED: "not_started",
199
- LIVE: "live",
200
- INTERRUPTED: "interrupted",
201
- CANCELLED: "cancelled",
202
- POSTPONED: "postponed",
203
- UNKNOWN: "not_started",
204
- ABANDONED: "abandoned"
205
- }[e.type] ?? "not_started", {
206
- code: n,
207
- name: e.name,
208
- shortName: e.short_name,
209
- type: e.type
210
- };
211
- }
212
- function L(e) {
213
- return {
214
- id: e.id,
215
- name: e.name,
216
- shortName: e.short_name ?? void 0,
217
- threeLetterCode: e.three_letter_code,
218
- slug: e.slug,
219
- type: e.type === "national" ? "national" : "club",
220
- gender: e.gender,
221
- assets: e.assets ? {
222
- logo: e.assets.logo?.url,
223
- homeKit: e.assets.home_kit?.url,
224
- awayKit: e.assets.away_kit?.url,
225
- squadImage: e.assets.squad_image?.url
226
- } : void 0,
227
- metadata: e.shirt_color ? {
228
- shirtColors: [
229
- {
230
- type: "home",
231
- colorCode: e.shirt_color
232
- }
233
- ]
234
- } : void 0,
235
- providerRef: r(e.uuid)
236
- };
237
- }
238
- function K(e) {
239
- return {
240
- kickoffTime: new Date(e.kickoff_time),
241
- currentMinute: e.minute?.regular_time,
242
- phaseStartedAt: e.phase_started_at ? new Date(e.phase_started_at) : void 0,
243
- finishedAt: e.finished_at ? new Date(e.finished_at) : void 0,
244
- firstHalfStartedAt: e.first_half_started_at ? new Date(e.first_half_started_at) : void 0,
245
- secondHalfStartedAt: e.second_half_started_at ? new Date(e.second_half_started_at) : void 0,
246
- extraTimeFirstHalfStartedAt: e.extra_time_first_half_started_at ? new Date(e.extra_time_first_half_started_at) : void 0,
247
- extraTimeSecondHalfStartedAt: e.extra_time_second_half_started_at ? new Date(e.extra_time_second_half_started_at) : void 0
248
- };
249
- }
250
- function q(e) {
251
- if (!e) return;
252
- const t = (o) => o ? { competitorOne: String(o.home), competitorTwo: String(o.away) } : void 0, n = e.after_extra_time ?? e.regular_time;
253
- return {
254
- competitorOne: n?.home != null ? String(n.home) : null,
255
- competitorTwo: n?.away != null ? String(n.away) : null,
256
- breakdown: {
257
- total: t(e.total),
258
- halfTime: t(e.half_time),
259
- regularTime: t(e.regular_time),
260
- extraTime: t(e.extra_time),
261
- penaltyShootout: t(e.penalty_shootout),
262
- aggregate: t(e.aggregate)
263
- }
264
- };
265
- }
266
- function X(e) {
267
- if (e)
268
- return {
269
- id: e.id,
270
- name: e.name,
271
- slug: e.slug,
272
- assets: e.assets?.image?.url ? { image: e.assets.image.url } : void 0,
273
- providerRef: r(e.uuid)
274
- };
275
- }
276
- function z(e) {
277
- if (e?.length)
278
- return e.map((t) => ({
279
- id: t.id,
280
- name: t.name,
281
- slug: t.slug,
282
- role: t.role ?? "REFEREE",
283
- gender: t.gender
284
- }));
285
- }
286
- function J(e) {
287
- if (!e.season?.tournament) return;
288
- const { tournament: t, ...n } = e.season;
289
- return {
290
- id: t.id,
291
- name: t.name,
292
- slug: t.slug,
293
- type: t.type,
294
- region: t.region,
295
- country: t.country ? {
296
- id: t.country.id,
297
- name: t.country.name,
298
- code: t.country.code ?? void 0,
299
- flag: t.country.assets?.flag?.url,
300
- providerRef: r(t.country.uuid)
301
- } : void 0,
302
- season: {
303
- id: n.id,
304
- name: n.name,
305
- status: n.status
306
- },
307
- stage: e.stage ? {
308
- id: e.stage.id,
309
- name: e.stage.name,
310
- type: e.stage.type
311
- } : void 0,
312
- assets: t.assets?.logo?.url ? { logo: t.assets.logo.url } : void 0,
313
- providerRef: r(t.uuid)
314
- };
315
- }
316
- function Q(e) {
317
- if (!e.winner?.match?.id) return;
318
- const t = {
319
- "Regular Time": "REGULAR_TIME",
320
- "Extra Time": "EXTRA_TIME",
321
- Penalties: "PENALTIES"
322
- };
323
- return {
324
- competitorId: e.winner.match.id,
325
- reason: e.winner.match.reason?.name ? t[e.winner.match.reason.name] : void 0,
326
- aggregate: !!e.winner.aggregate
327
- };
328
- }
329
- function E(e) {
330
- return {
331
- id: e.id,
332
- slug: e.slug,
333
- sport: "football",
334
- status: j(e.status),
335
- timing: K(e),
336
- competitorOne: L(e.home_team),
337
- competitorTwo: L(e.away_team),
338
- competition: J(e),
339
- round: e.round ? {
340
- id: e.round.id ?? e.round.key,
341
- key: e.round.key,
342
- name: e.round.name,
343
- type: e.round.type ?? "REGULAR",
344
- providerRef: r(e.round.uuid)
345
- } : void 0,
346
- group: e.group ? {
347
- id: e.group.id,
348
- name: e.group.name,
349
- providerRef: r(e.group.uuid)
350
- } : void 0,
351
- venue: X(e.venue),
352
- officials: z(e.referees),
353
- spectators: e.spectators ?? void 0,
354
- score: q(e.score),
355
- mainEvents: e.main_events?.map(S).filter((t) => t !== null),
356
- penaltyShootoutEvents: e.penalty_shootout_events?.map(S).filter((t) => t !== null),
357
- winner: Q(e),
358
- coverage: e.coverage === "NOT_LIVE" ? "UNKNOWN" : e.coverage,
359
- lineupStatus: e.lineup_status === "UNCONFIRMED" ? "EXPECTED" : e.lineup_status,
360
- providerRef: r(e.uuid)
361
- };
362
- }
363
- function Z(e) {
364
- const t = e.player;
365
- return {
366
- id: t.id,
367
- name: t.name,
368
- slug: t.slug,
369
- position: t.position,
370
- shirtNumber: e.shirt_number,
371
- positionX: e.position_x ?? void 0,
372
- positionY: e.position_y ?? void 0,
373
- country: t.country ? {
374
- id: t.country.id,
375
- name: t.country.name,
376
- code: t.country.code,
377
- providerRef: r(t.country.uuid)
378
- } : void 0,
379
- birthdate: t.birthdate,
380
- profile: t.profile ? {
381
- height: t.profile.height,
382
- weight: t.profile.weight
383
- } : void 0,
384
- assets: t.assets ? {
385
- photo: t.assets.thumb?.url,
386
- photoTransparent: t.assets.thumb_transparent_background?.url
387
- } : void 0,
388
- events: e.events?.map(S).filter((n) => n !== null),
389
- providerRef: r(t.uuid)
390
- };
391
- }
392
- function k(e) {
393
- const t = [], n = [];
394
- for (const o of e.players) {
395
- const s = Z(o);
396
- o.type.category === "start" ? t.push(s) : o.type.category === "sub" && n.push(s);
397
- }
398
- return {
399
- competitorId: e.team_id,
400
- formation: e.formation,
401
- coach: e.coach ? {
402
- id: e.coach.id,
403
- name: e.coach.name,
404
- slug: e.coach.slug,
405
- country: e.coach.country ? {
406
- id: e.coach.country.id,
407
- name: e.coach.country.name,
408
- code: e.coach.country.code,
409
- providerRef: r(e.coach.country.uuid)
410
- } : void 0,
411
- birthdate: e.coach.birthdate,
412
- providerRef: r(e.coach.uuid)
413
- } : void 0,
414
- starters: t,
415
- substitutes: n
416
- };
417
- }
418
- function w(e) {
419
- return {
420
- matchId: e.match_id,
421
- confirmed: e.status === "CONFIRMED",
422
- competitorOne: k(e.home_team),
423
- competitorTwo: k(e.away_team)
424
- };
425
- }
426
- function y(e, t, n, o) {
427
- return t == null ? null : { key: e, value: String(t), label: n, unit: o };
428
- }
429
- function D(e, t) {
430
- const n = (t.shots_on ?? 0) + (t.shots_off ?? 0) + (t.shots_blocked ?? 0), o = [
431
- y("possession", t.possession, "Possession", "%"),
432
- y("shots_total", n, "Shots"),
433
- y("shots_on_target", t.shots_on, "Shots on Target"),
434
- y("shots_off_target", t.shots_off, "Shots off Target"),
435
- y("shots_blocked", t.shots_blocked, "Shots Blocked"),
436
- y("corners", t.corners, "Corner Kicks"),
437
- y("goal_kicks", t.goal_kicks, "Goal Kicks"),
438
- y("throw_ins", t.throw_in, "Throw Ins"),
439
- y("offsides", t.offside, "Offsides"),
440
- y("fouls", t.fouls_committed, "Fouls"),
441
- y("yellow_cards", t.yellow_cards, "Yellow Cards"),
442
- y("passes", t.pass, "Passes"),
443
- y("crosses", t.crosses, "Crosses")
444
- ];
445
- return {
446
- competitorId: e,
447
- statistics: o.filter((s) => s !== null)
448
- };
449
- }
450
- function ee(e) {
451
- const t = e.find((o) => o.home_team), n = e.find((o) => !o.home_team);
452
- if (!t || !n)
453
- throw new Error("Missing competitor statistics");
454
- return {
455
- competitorOne: D(String(t.team.id), t.statistics),
456
- competitorTwo: D(String(n.team.id), n.statistics)
457
- };
458
- }
459
- function te(e, t) {
460
- return {
461
- matchId: e,
462
- operators: W(t)
463
- };
464
- }
465
- function N(e) {
466
- if (e == null || e === "")
467
- return;
468
- const t = typeof e == "number" ? e : parseInt(e, 10);
469
- return isNaN(t) ? void 0 : t;
470
- }
471
- function oe(e) {
472
- return {
473
- externalId: e.external_id,
474
- minute: N(e.elapsed),
475
- addedTime: N(e.elapsed_plus),
476
- text: e.auto_text,
477
- details: e.details,
478
- meta: {
479
- type: e.type,
480
- commentaryType: e.commentary_type,
481
- subtype1: e.subtype_1,
482
- subtype2: e.subtype_2,
483
- timestamp: e.incident_timestamp
484
- }
485
- };
486
- }
487
- async function Ge(e, t, n) {
488
- const o = n || g(), { sportal365Sports: s } = o, a = await p.get({
489
- path: `/v2/matches/${e}`,
490
- params: {
491
- language_code: t?.languageCode ?? s?.languageCode ?? "en",
492
- odd_client: t?.oddClient,
493
- odd_type: t?.oddType,
494
- scope_type: t?.scopeType,
495
- odd_format: t?.oddFormat,
496
- market_types: t?.marketTypes,
497
- bookmaker_ids: t?.bookmakerIds,
498
- optional_data: t?.optionalData
499
- },
500
- headers: {
501
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
502
- },
503
- next: t?.next,
504
- config: o
505
- });
506
- return E(a);
507
- }
508
- async function He(e, t, n) {
509
- const o = n || g(), { sportal365Sports: s } = o;
510
- return (await p.get({
511
- path: `/v2/matches/${e}/events`,
512
- params: {
513
- language_code: t?.languageCode ?? s?.languageCode ?? "en"
514
- },
515
- headers: {
516
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
517
- },
518
- next: t?.next,
519
- config: o
520
- })).events.map(S).filter((l) => l !== null);
521
- }
522
- async function Be(e, t, n) {
523
- const o = n || g(), { sportal365Sports: s } = o, a = await p.get({
524
- path: `/v2/matches/${e}/lineups`,
525
- params: {
526
- language_code: t?.languageCode ?? s?.languageCode ?? "en"
527
- },
528
- headers: {
529
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
530
- },
531
- next: t?.next,
532
- config: o
533
- });
534
- return w(a);
535
- }
536
- async function $e(e, t, n) {
537
- const o = n || g(), { sportal365Sports: s } = o, a = await p.get({
538
- path: `/v2/matches/${e}`,
539
- params: {
540
- language_code: t?.languageCode ?? s?.languageCode ?? "en",
541
- odd_client: t?.oddClient ?? s?.oddClient,
542
- odd_type: t?.oddType,
543
- scope_type: t?.scopeType ?? "ALL",
544
- odd_format: t?.oddFormat ?? "DECIMAL",
545
- market_types: t?.marketTypes,
546
- bookmaker_ids: t?.bookmakerIds
547
- },
548
- headers: {
549
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
550
- },
551
- next: t?.next,
552
- config: o
553
- });
554
- return te(e, a.odds ?? []);
555
- }
556
- async function Ye(e, t, n) {
557
- const o = n || g(), { sportal365Sports: s } = o, a = await p.get({
558
- path: `/events/${e}/teamstats`,
559
- params: {
560
- language_code: t?.languageCode ?? s?.languageCode ?? "en"
561
- },
562
- headers: {
563
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
564
- },
565
- next: t?.next,
566
- config: o
567
- });
568
- return ee(a);
569
- }
570
- async function Ve(e, t, n) {
571
- const o = n || g(), { sportal365Sports: s } = o;
572
- return (await p.get({
573
- path: `/matches/${e}/commentary`,
574
- params: {
575
- language_code: t?.languageCode ?? s?.languageCode ?? "en"
576
- },
577
- headers: {
578
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
579
- },
580
- next: t?.next,
581
- config: o
582
- })).map(oe);
583
- }
584
- async function We(e, t) {
585
- const n = t || g(), { sportal365Sports: o } = n;
586
- return (await p.get({
587
- path: "/v2/matches",
588
- params: {
589
- language_code: e.languageCode ?? o?.languageCode ?? "en",
590
- limit: e.limit.toString(),
591
- offset: e.offset.toString(),
592
- // Competition filters
593
- tournament_ids: e.tournamentIds,
594
- season_ids: e.seasonIds,
595
- stage_ids: e.stageIds,
596
- group_ids: e.groupIds,
597
- round_ids: e.roundIds,
598
- round_filter: e.roundFilter,
599
- // Time filters
600
- from_kickoff_time: e.fromKickoffTime,
601
- to_kickoff_time: e.toKickoffTime,
602
- // Entity filters
603
- team_ids: e.teamIds,
604
- team_ids_operator: e.teamIdsOperator,
605
- referee_id: e.refereeId,
606
- venue_id: e.venueId,
607
- player_id: e.playerId,
608
- // Status filters
609
- status_types: e.statusTypes,
610
- status_codes: e.statusCodes,
611
- // Odds
612
- odd_client: e.oddClient ?? o?.oddClient,
613
- odd_type: e.oddType,
614
- scope_type: e.scopeType,
615
- odd_format: e.oddFormat,
616
- market_types: e.marketTypes,
617
- bookmaker_ids: e.bookmakerIds,
618
- // Sorting and optional data
619
- sort_direction: e.sortDirection,
620
- optional_data: e.optionalData
621
- },
622
- headers: {
623
- "Accept-Language": e.languageCode ?? o?.languageCode ?? "en"
624
- },
625
- next: e.next,
626
- config: n
627
- })).matches.map(E);
628
- }
629
- async function je(e, t) {
630
- const n = t || g(), { sportal365Sports: o } = n;
631
- return (await p.get({
632
- path: "/v2/matches/livescore",
633
- params: {
634
- // Match filters
635
- match_ids: e?.matchIds,
636
- date: e?.date,
637
- utc_offset: e?.utcOffset?.toString(),
638
- tournament_group: e?.tournamentGroup,
639
- status_types: e?.statusTypes,
640
- selection_filter: e?.selectionFilter,
641
- language_code: e?.languageCode ?? o?.languageCode ?? "en",
642
- // Odds parameters
643
- odd_client: e?.oddClient ?? o?.oddClient,
644
- odd_type: e?.oddType,
645
- scope_type: e?.scopeType,
646
- odd_format: e?.oddFormat,
647
- market_types: e?.marketTypes,
648
- // Optional data
649
- optional_data: e?.optionalData
650
- },
651
- headers: {
652
- "Accept-Language": e?.languageCode ?? o?.languageCode ?? "en"
653
- },
654
- next: e?.next,
655
- config: n
656
- })).matches.map(E);
657
- }
658
- function ne(e) {
659
- return {
660
- id: e.id,
661
- name: e.name,
662
- shortName: e.short_name ?? void 0,
663
- threeLetterCode: e.three_letter_code,
664
- slug: e.slug,
665
- type: e.type === "placeholder" || e.type === "club" ? "club" : "national",
666
- gender: e.gender,
667
- country: e.country ? {
668
- id: e.country.id,
669
- name: e.country.name,
670
- code: e.country.code ?? void 0,
671
- flag: e.country.assets?.flag?.url,
672
- providerRef: r(e.country.uuid)
673
- } : void 0,
674
- // Extended team profile data
675
- venue: e.venue ? {
676
- id: e.venue.id,
677
- name: e.venue.name,
678
- slug: e.venue.slug,
679
- city: e.venue.city ? {
680
- id: e.venue.city.id,
681
- name: e.venue.city.name,
682
- country: e.venue.city.country ? {
683
- id: e.venue.city.country.id,
684
- name: e.venue.city.country.name,
685
- code: e.venue.city.country.code ?? void 0,
686
- flag: e.venue.city.country.assets?.flag?.url,
687
- providerRef: r(e.venue.city.country.uuid)
688
- } : void 0,
689
- providerRef: r(e.venue.city.uuid ?? void 0)
690
- } : void 0,
691
- country: e.venue.country ? {
692
- id: e.venue.country.id,
693
- name: e.venue.country.name,
694
- code: e.venue.country.code ?? void 0,
695
- flag: e.venue.country.assets?.flag?.url,
696
- providerRef: r(e.venue.country.uuid)
697
- } : void 0,
698
- profile: e.venue.profile ? {
699
- latitude: e.venue.profile.lat,
700
- longitude: e.venue.profile.lng,
701
- capacity: e.venue.profile.capacity
702
- } : void 0,
703
- assets: e.venue.assets?.image?.url ? {
704
- image: e.venue.assets.image.url
705
- } : void 0,
706
- providerRef: r(e.venue.uuid)
707
- } : void 0,
708
- coach: e.coach ? {
709
- id: e.coach.id,
710
- name: e.coach.name,
711
- slug: e.coach.slug,
712
- country: {
713
- id: e.coach.country.id,
714
- name: e.coach.country.name,
715
- code: e.coach.country.code ?? void 0,
716
- flag: e.coach.country.assets?.flag?.url,
717
- providerRef: r(e.coach.country.uuid)
718
- },
719
- birthdate: e.coach.birthdate,
720
- providerRef: r(e.coach.uuid)
721
- } : void 0,
722
- founded: e.founded,
723
- // Assets
724
- assets: e.assets ? {
725
- logo: e.assets.logo?.url,
726
- homeKit: e.assets.home_kit?.url,
727
- awayKit: e.assets.away_kit?.url,
728
- squadImage: e.assets.squad_image?.url
729
- } : void 0,
730
- // Metadata
731
- metadata: {
732
- shirtColors: e.shirt_colors?.map((t) => ({
733
- type: t.type,
734
- colorCode: t.color_code
735
- })),
736
- socials: e.social ? {
737
- website: e.social.web,
738
- x: e.social.twitter_id,
739
- facebook: e.social.facebook_id,
740
- instagram: e.social.instagram_id,
741
- wikipedia: e.social.wikipedia_id
742
- } : void 0
743
- },
744
- // Seasons
745
- activeSeasons: e.active_seasons?.map((t) => ({
746
- id: t.id,
747
- name: t.name,
748
- slug: t.slug,
749
- active: t.status === "ACTIVE",
750
- providerRef: r(t.uuid)
751
- })),
752
- currentSeason: e.current_season ? {
753
- id: e.current_season.id,
754
- name: e.current_season.name,
755
- slug: e.current_season.slug,
756
- active: e.current_season.status === "ACTIVE",
757
- providerRef: r(e.current_season.uuid)
758
- } : void 0,
759
- // Form - map to FUSportsCompetitorForm
760
- form: e.form && e.form.length > 0 ? {
761
- competitorId: e.id,
762
- results: e.form.map((t) => {
763
- const o = t.participants[0].id === e.uuid ? t.participants[1] : t.participants[0], s = t.result[0]?.results.find((d) => d.position === "1")?.value, a = t.result[0]?.results.find((d) => d.position === "2")?.value, l = t.outcome === "win" ? "W" : t.outcome === "draw" ? "D" : "L";
764
- return {
765
- matchId: t.id,
766
- result: l,
767
- score: s && a ? `${s}-${a}` : void 0,
768
- opponent: {
769
- id: o.id,
770
- name: o.name,
771
- logo: o.display_asset?.url
772
- },
773
- date: new Date(t.start_time),
774
- competition: t.competition ? {
775
- id: t.competition.id,
776
- name: t.competition.name
777
- } : void 0
778
- };
779
- }),
780
- formString: e.form.map((t) => t.outcome === "win" ? "W" : t.outcome === "draw" ? "D" : "L").join("")
781
- } : void 0,
782
- providerRef: r(e.uuid)
783
- };
784
- }
785
- function se(e) {
786
- const t = e.player;
787
- return {
788
- id: t.id,
789
- name: t.name,
790
- slug: t.slug,
791
- position: t.position,
792
- shirtNumber: e.shirt_number,
793
- country: t.country ? {
794
- id: t.country.id,
795
- name: t.country.name,
796
- code: t.country.code ?? void 0,
797
- flag: t.country.assets?.flag?.url,
798
- providerRef: r(t.country.uuid)
799
- } : void 0,
800
- gender: t.gender,
801
- birthdate: t.birthdate,
802
- profile: {
803
- height: t.profile?.height ?? void 0,
804
- weight: t.profile?.weight ?? void 0
805
- },
806
- assets: t.assets ? {
807
- photo: t.assets.thumb?.url,
808
- photoTransparent: t.assets.thumb_transparent_background?.url
809
- } : void 0,
810
- status: e.status,
811
- contractType: e.contract_type,
812
- contractUntil: e.contract_until ?? void 0,
813
- joinedDate: e.start_date ?? void 0,
814
- providerRef: r(t.id)
815
- // Using player.id as provider reference
816
- };
817
- }
818
- function ae(e) {
819
- return {
820
- id: e.id,
821
- name: e.name,
822
- slug: e.slug,
823
- country: e.country ? {
824
- id: e.country.id,
825
- name: e.country.name,
826
- code: e.country.code ?? void 0,
827
- flag: e.country.assets?.flag?.url,
828
- providerRef: r(e.country.uuid)
829
- } : void 0,
830
- birthdate: e.birthdate,
831
- providerRef: r(e.uuid)
832
- };
833
- }
834
- function ie(e) {
835
- return {
836
- teamId: e.team.id,
837
- teamName: e.team.name,
838
- coach: e.coach ? ae(e.coach) : void 0,
839
- players: e.players.map(se)
840
- };
841
- }
842
- function re(e) {
843
- const t = parseInt(e, 10);
844
- return isNaN(t) ? void 0 : t;
845
- }
846
- function i(e, t) {
847
- const n = e.find((o) => o.name === t);
848
- return n ? re(n.value) : void 0;
849
- }
850
- function de(e, t) {
851
- const n = e.statistics;
852
- return {
853
- playerId: e.player.id,
854
- seasonId: e.season.id,
855
- teamId: t,
856
- // Core statistics
857
- appearances: i(n, "played"),
858
- started: i(n, "started"),
859
- substituteIn: i(n, "substitute_in"),
860
- substituteOut: i(n, "substitute_out"),
861
- minutes: i(n, "minutes"),
862
- minutesSubstitute: i(n, "minutes_substitute"),
863
- // Scoring
864
- goals: i(n, "goals"),
865
- goalsSubstitute: i(n, "goals_substitute"),
866
- penaltyGoals: i(n, "penalty_goals"),
867
- ownGoals: i(n, "own_goals"),
868
- assists: i(n, "assists"),
869
- // Shooting
870
- shots: i(n, "shots"),
871
- shotsOnTarget: i(n, "shots_on_target"),
872
- // Discipline
873
- yellowCards: i(n, "yellow_cards"),
874
- redCards: i(n, "red_cards"),
875
- foulsCommitted: i(n, "fouls_committed"),
876
- penaltiesCommitted: i(n, "penalties_committed"),
877
- // Penalties
878
- penaltiesMissed: i(n, "penalties_missed"),
879
- // Defensive
880
- cleansheets: i(n, "cleansheets"),
881
- // Goalkeeper-specific
882
- saves: i(n, "saves"),
883
- conceded: i(n, "conceded"),
884
- caughtBall: i(n, "caught_ball"),
885
- penaltiesReceived: i(n, "penalties_received"),
886
- // Other
887
- offsides: i(n, "offsides"),
888
- // Raw statistics array (for any additional stats not mapped above)
889
- rawStatistics: n.map((o) => ({
890
- name: o.name,
891
- value: o.value
892
- }))
893
- };
894
- }
895
- function ue(e) {
896
- const t = e.statistics;
897
- return {
898
- playerId: e.player.id,
899
- seasonId: e.season.id,
900
- // Core statistics
901
- appearances: i(t, "played"),
902
- started: i(t, "started"),
903
- substituteIn: i(t, "substitute_in"),
904
- substituteOut: i(t, "substitute_out"),
905
- minutes: i(t, "minutes"),
906
- minutesSubstitute: i(t, "minutes_substitute"),
907
- // Scoring
908
- goals: i(t, "goals"),
909
- goalsSubstitute: i(t, "goals_substitute"),
910
- penaltyGoals: i(t, "penalty_goals"),
911
- ownGoals: i(t, "own_goals"),
912
- assists: i(t, "assists"),
913
- // Shooting
914
- shots: i(t, "shots"),
915
- shotsOnTarget: i(t, "shots_on_target"),
916
- // Discipline
917
- yellowCards: i(t, "yellow_cards"),
918
- redCards: i(t, "red_cards"),
919
- foulsCommitted: i(t, "fouls_committed"),
920
- penaltiesCommitted: i(t, "penalties_committed"),
921
- // Penalties
922
- penaltiesMissed: i(t, "penalties_missed"),
923
- // Defensive
924
- cleansheets: i(t, "cleansheets"),
925
- // Goalkeeper-specific
926
- saves: i(t, "saves"),
927
- conceded: i(t, "conceded"),
928
- caughtBall: i(t, "caught_ball"),
929
- penaltiesReceived: i(t, "penalties_received"),
930
- // Other
931
- offsides: i(t, "offsides"),
932
- // Raw statistics array
933
- rawStatistics: t.map((n) => ({
934
- name: n.name,
935
- value: n.value
936
- }))
937
- };
938
- }
939
- function c(e, t) {
940
- if (!(e === void 0 && t === void 0))
941
- return (e ?? 0) + (t ?? 0);
942
- }
943
- function ce(e, t) {
944
- return {
945
- playerId: e.playerId,
946
- seasonId: e.seasonId,
947
- // Core statistics
948
- appearances: c(e.appearances, t.appearances),
949
- started: c(e.started, t.started),
950
- substituteIn: c(e.substituteIn, t.substituteIn),
951
- substituteOut: c(e.substituteOut, t.substituteOut),
952
- minutes: c(e.minutes, t.minutes),
953
- minutesSubstitute: c(e.minutesSubstitute, t.minutesSubstitute),
954
- // Scoring
955
- goals: c(e.goals, t.goals),
956
- goalsSubstitute: c(e.goalsSubstitute, t.goalsSubstitute),
957
- penaltyGoals: c(e.penaltyGoals, t.penaltyGoals),
958
- ownGoals: c(e.ownGoals, t.ownGoals),
959
- assists: c(e.assists, t.assists),
960
- // Shooting
961
- shots: c(e.shots, t.shots),
962
- shotsOnTarget: c(e.shotsOnTarget, t.shotsOnTarget),
963
- // Discipline
964
- yellowCards: c(e.yellowCards, t.yellowCards),
965
- redCards: c(e.redCards, t.redCards),
966
- foulsCommitted: c(e.foulsCommitted, t.foulsCommitted),
967
- penaltiesCommitted: c(e.penaltiesCommitted, t.penaltiesCommitted),
968
- // Penalties
969
- penaltiesMissed: c(e.penaltiesMissed, t.penaltiesMissed),
970
- // Defensive
971
- cleansheets: c(e.cleansheets, t.cleansheets),
972
- // Goalkeeper-specific
973
- saves: c(e.saves, t.saves),
974
- conceded: c(e.conceded, t.conceded),
975
- caughtBall: c(e.caughtBall, t.caughtBall),
976
- penaltiesReceived: c(e.penaltiesReceived, t.penaltiesReceived),
977
- // Other
978
- offsides: c(e.offsides, t.offsides),
979
- // Concatenate raw statistics from both entries
980
- rawStatistics: [...e.rawStatistics ?? [], ...t.rawStatistics ?? []]
981
- };
982
- }
983
- async function le(e, t) {
984
- const n = t || g(), { sportal365Sports: o } = n, { seasonIds: s, teamId: a, languageCode: l, next: d } = e, u = d ?? { revalidate: 0 }, _ = {
985
- season_ids: s.join(","),
986
- team_id: a,
987
- language_code: l ?? o?.languageCode ?? "en"
988
- }, m = await p.get({
989
- path: "/v2/statistics/players/season",
990
- params: _,
991
- headers: {
992
- "Accept-Language": l ?? o?.languageCode ?? "en"
993
- },
994
- next: u,
995
- config: n
996
- });
997
- if (!m.statistics)
998
- return console.error("[getFootballPlayerSeasonStatistics] Invalid API response - missing statistics array:", {
999
- teamId: a,
1000
- seasonIds: s,
1001
- response: m
1002
- }), {};
1003
- if (m.statistics.length === 0)
1004
- throw console.warn("[getFootballPlayerSeasonStatistics] API returned empty statistics array:", {
1005
- teamId: a,
1006
- seasonIds: s,
1007
- hint: "This could be due to: wrong credentials, wrong project header, no data for this team/season, or API issue"
1008
- }), new Error(
1009
- `No player statistics found for team ${a} in seasons ${s.join(", ")}. This could be due to: wrong credentials, wrong X-Project header, or no data available for this team/season.`
1010
- );
1011
- const h = {};
1012
- for (const C of m.statistics) {
1013
- const T = C.player.id;
1014
- h[T] = de(C, a);
1015
- }
1016
- return h;
1017
- }
1018
- async function Ke(e, t) {
1019
- const n = t || g(), { sportal365Sports: o } = n, { playerIds: s, seasonIds: a, languageCode: l, next: d } = e, u = d ?? { revalidate: 0 }, _ = {
1020
- player_ids: s.join(","),
1021
- season_ids: a.join(","),
1022
- language_code: l ?? o?.languageCode ?? "en"
1023
- }, m = await p.get({
1024
- path: "/v2/statistics/players/season",
1025
- params: _,
1026
- headers: {
1027
- "Accept-Language": l ?? o?.languageCode ?? "en"
1028
- },
1029
- next: u,
1030
- config: n
1031
- });
1032
- if (!m.statistics)
1033
- return console.error("[getFootballPlayerSeasonStatisticsByPlayerIds] Invalid API response - missing statistics array:", {
1034
- playerIds: s,
1035
- seasonIds: a,
1036
- response: m
1037
- }), {};
1038
- if (m.statistics.length === 0)
1039
- return {};
1040
- const h = {};
1041
- for (const C of m.statistics) {
1042
- const T = C.player.id, f = ue(C);
1043
- h[T] ? h[T] = ce(h[T], f) : h[T] = f;
1044
- }
1045
- return h;
1046
- }
1047
- async function qe(e, t, n) {
1048
- const o = n || g(), { sportal365Sports: s } = o, a = await p.get({
1049
- path: `/v2/teams/${e}`,
1050
- params: {
1051
- language_code: t?.languageCode ?? s?.languageCode ?? "en",
1052
- optional_data: "form"
1053
- },
1054
- headers: {
1055
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
1056
- },
1057
- next: t?.next,
1058
- config: o
1059
- });
1060
- return ne(a);
1061
- }
1062
- async function Xe(e, t, n) {
1063
- const o = n || g(), { sportal365Sports: s } = o, a = t?.seasonIds && t.seasonIds.length > 0 ? { revalidate: 0 } : t?.next, l = await p.get({
1064
- path: `/v2/teams/${e}/squad`,
1065
- params: {
1066
- language_code: t?.languageCode ?? s?.languageCode ?? "en",
1067
- memberStatus: t?.memberStatus ?? "ACTIVE"
1068
- },
1069
- headers: {
1070
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
1071
- },
1072
- next: a,
1073
- config: o
1074
- }), d = ie(l);
1075
- if (t?.seasonIds && t.seasonIds.length > 0)
1076
- try {
1077
- const u = await le(
1078
- {
1079
- seasonIds: t.seasonIds,
1080
- teamId: e,
1081
- languageCode: t.languageCode,
1082
- next: t.next
1083
- },
1084
- o
1085
- );
1086
- for (const _ of d.players) {
1087
- const m = u[_.id];
1088
- m && (_.seasonStatistics = m);
1089
- }
1090
- } catch (u) {
1091
- console.error("[getFootballTeamSquad] Failed to fetch player statistics:", {
1092
- error: u instanceof Error ? u.message : String(u),
1093
- stack: u instanceof Error ? u.stack : void 0,
1094
- teamId: e,
1095
- seasonIds: t.seasonIds
1096
- });
1097
- }
1098
- else
1099
- console.warn("[getFootballTeamSquad] No seasonIds provided, skipping stats fetch");
1100
- return d;
1101
- }
1102
- function me(e) {
1103
- return {
1104
- id: String(e.id),
1105
- name: e.name,
1106
- slug: e.slug,
1107
- type: e.type,
1108
- region: e.region,
1109
- gender: e.gender,
1110
- country: {
1111
- id: String(e.country.id),
1112
- name: e.country.name,
1113
- flag: e.country.url_flag,
1114
- providerRef: r(e.country.uuid)
1115
- },
1116
- seasons: e.seasons.map((t) => ({
1117
- id: String(t.id),
1118
- name: t.name,
1119
- slug: t.slug,
1120
- active: t.active,
1121
- providerRef: r(t.uuid)
1122
- })),
1123
- assets: e.url_logo ? {
1124
- logo: e.url_logo
1125
- } : void 0,
1126
- providerRef: r(e.uuid)
1127
- };
1128
- }
1129
- function ge(e) {
1130
- const t = e.rounds.map((n) => ({
1131
- id: n.id,
1132
- name: n.name,
1133
- key: n.key,
1134
- type: n.type,
1135
- status: n.status,
1136
- startDate: n.start_date,
1137
- endDate: n.end_date,
1138
- providerRef: r(n.uuid)
1139
- }));
1140
- return {
1141
- id: e.stage.id,
1142
- name: e.stage.name,
1143
- slug: e.stage.slug,
1144
- shortName: e.stage.short_name ?? void 0,
1145
- type: e.stage.type,
1146
- status: e.stage.status,
1147
- coverage: e.stage.coverage,
1148
- order: e.stage.order_in_season,
1149
- startDate: e.stage.start_date,
1150
- endDate: e.stage.end_date,
1151
- rounds: t,
1152
- providerRef: r(e.stage.uuid)
1153
- };
1154
- }
1155
- function pe(e) {
1156
- const { season: t, stages: n } = e, { tournament: o } = t, s = {
1157
- id: o.id,
1158
- name: o.name,
1159
- slug: o.slug,
1160
- type: o.type,
1161
- region: o.region,
1162
- gender: o.gender,
1163
- country: {
1164
- id: o.country.id,
1165
- name: o.country.name,
1166
- code: o.country.code ?? void 0,
1167
- flag: o.country.assets?.flag?.url,
1168
- providerRef: r(o.country.uuid)
1169
- },
1170
- assets: o.assets?.logo?.url ? {
1171
- logo: o.assets.logo.url
1172
- } : void 0,
1173
- providerRef: r(o.uuid)
1174
- };
1175
- return {
1176
- id: t.id,
1177
- name: t.name,
1178
- slug: t.slug,
1179
- active: t.status === "ACTIVE",
1180
- status: t.status === "ACTIVE" ? "ACTIVE" : "INACTIVE",
1181
- competition: s,
1182
- stages: n.map(ge),
1183
- providerRef: r(t.uuid)
1184
- };
1185
- }
1186
- async function ze(e, t, n) {
1187
- const o = n || g(), { sportal365Sports: s } = o, a = await p.get({
1188
- path: `/tournaments/${e}`,
1189
- params: {
1190
- language_code: t?.languageCode ?? s?.languageCode ?? "en"
1191
- },
1192
- headers: {
1193
- "Accept-Language": t?.languageCode ?? s?.languageCode ?? "en"
1194
- },
1195
- next: t?.next,
1196
- config: o
1197
- });
1198
- return me(a);
1199
- }
1200
- async function Je(e, t) {
1201
- const n = t || g(), { sportal365Sports: o } = n;
1202
- if (!e?.seasonId && !e?.competitionId)
1203
- throw new Error("Either seasonId or competitionId must be provided");
1204
- const s = {
1205
- language_code: e?.languageCode ?? o?.languageCode ?? "en"
1206
- };
1207
- e.seasonId ? s.season_id = e.seasonId : e.competitionId && (s.tournament_id = e.competitionId, e.status && (s.status = e.status));
1208
- const a = await p.get({
1209
- path: "/v2/seasons/details",
1210
- params: s,
1211
- headers: {
1212
- "Accept-Language": e?.languageCode ?? o?.languageCode ?? "en"
1213
- },
1214
- next: e?.next,
1215
- config: n
1216
- });
1217
- return pe(a);
1218
- }
1219
- function O(e) {
1220
- return {
1221
- championsleague: "championsLeague",
1222
- europaleague: "europaLeague",
1223
- conferenceleague: "conferenceLeague",
1224
- relegation: "relegation",
1225
- playoff: "playoff",
1226
- promotion: "promotion"
1227
- }[e.toLowerCase()] ?? e.toLowerCase().replace(/_/g, "");
1228
- }
1229
- function fe(e) {
1230
- const t = e.toLowerCase();
1231
- return t === "relegation" ? "BOTTOM" : t === "playoff" ? "MIDDLE" : "TOP";
1232
- }
1233
- function _e(e, t) {
1234
- if (!t || t.length === 0)
1235
- return;
1236
- const n = t.map((s) => {
1237
- const a = s.event, l = a.home_team.id === e, d = l ? a.away_team : a.home_team, u = `${a.goal_home}-${a.goal_away}`;
1238
- return {
1239
- matchId: a.id.toString(),
1240
- result: s.outcome,
1241
- score: u,
1242
- homeAway: l ? "HOME" : "AWAY",
1243
- opponent: {
1244
- id: d.id.toString(),
1245
- name: d.name,
1246
- logo: d.url_logo
1247
- },
1248
- date: new Date(a.start_time),
1249
- competition: void 0
1250
- // Football API doesn't include competition in form
1251
- };
1252
- }), o = n.map((s) => s.result).join("");
1253
- return {
1254
- competitorId: e.toString(),
1255
- results: n,
1256
- formString: o
1257
- };
1258
- }
1259
- function ye(e) {
1260
- return {
1261
- key: O(e.code),
1262
- name: e.name,
1263
- position: fe(e.type)
1264
- };
1265
- }
1266
- function he(e) {
1267
- const t = {
1268
- played: e.played,
1269
- won: e.wins,
1270
- drawn: e.draws,
1271
- lost: e.defeits,
1272
- goalsFor: e.goals_for,
1273
- goalsAgainst: e.goals_against,
1274
- goalDifference: e.goals_for - e.goals_against,
1275
- points: e.points
1276
- }, n = e.rules?.length > 0 ? e.rules.map((s) => O(s.code)) : void 0, o = _e(e.team.id, e.team.form ?? []);
1277
- return {
1278
- rank: e.rank,
1279
- competitor: {
1280
- id: e.team.id.toString(),
1281
- name: e.team.name,
1282
- shortName: e.team.short_name ?? void 0,
1283
- logo: e.team.url_logo,
1284
- uuid: e.team.uuid
1285
- },
1286
- stats: t,
1287
- form: o,
1288
- rules: n
1289
- };
1290
- }
1291
- function ve(e) {
1292
- const t = e.map(he), n = /* @__PURE__ */ new Map();
1293
- for (const o of e)
1294
- if (o.rules)
1295
- for (const s of o.rules) {
1296
- const a = O(s.code);
1297
- n.has(a) || n.set(a, ye(s));
1298
- }
1299
- return {
1300
- entries: t,
1301
- metadata: {
1302
- legend: Array.from(n.values())
1303
- }
1304
- };
1305
- }
1306
- async function Qe(e, t) {
1307
- const n = t || g(), { sportal365Sports: o } = n, s = e.expand?.join(","), a = await p.get({
1308
- path: `/tournaments/seasons/stages/${e.stageId}/standing`,
1309
- params: {
1310
- expand: s,
1311
- language_code: e.languageCode ?? o?.languageCode ?? "en"
1312
- },
1313
- headers: {
1314
- "Accept-Language": e.languageCode ?? o?.languageCode ?? "en"
1315
- },
1316
- next: e.next,
1317
- config: n
1318
- });
1319
- return !a || a.length === 0 ? { entries: [], metadata: { legend: [] } } : ve(a);
1320
- }
1321
- function P(e) {
1322
- return {
1323
- id: e.id,
1324
- name: e.name,
1325
- code: e.country_code,
1326
- assets: e.assets?.flag ? {
1327
- flag: e.assets.flag
1328
- } : void 0,
1329
- providerRef: [
1330
- {
1331
- provider: "fansunited",
1332
- id: e.id
1333
- }
1334
- ]
1335
- };
1336
- }
1337
- function Te(e) {
1338
- return {
1339
- id: e.id,
1340
- name: e.name,
1341
- type: e.type?.toUpperCase() || "LEAGUE",
1342
- gender: e.gender?.toUpperCase(),
1343
- country: e.country ? P(e.country) : void 0,
1344
- assets: e.assets?.logo ? {
1345
- logo: e.assets.logo
1346
- } : void 0,
1347
- providerRef: [
1348
- {
1349
- provider: "fansunited",
1350
- id: e.id
1351
- }
1352
- ]
1353
- };
1354
- }
1355
- function Ce(e) {
1356
- if (e.status) {
1357
- const a = {
1358
- notstarted: { code: "not_started", type: "NOT_STARTED", name: "Not Started" },
1359
- live: { code: "live", type: "LIVE", name: "Live" },
1360
- finished: { code: "finished", type: "FINISHED", name: "Finished" },
1361
- postponed: { code: "postponed", type: "POSTPONED", name: "Postponed" },
1362
- cancelled: { code: "cancelled", type: "CANCELLED", name: "Cancelled" },
1363
- abandoned: { code: "abandoned", type: "ABANDONED", name: "Abandoned" }
1364
- }[e.status.type];
1365
- if (a)
1366
- return a;
1367
- }
1368
- let t = "not_started", n = "NOT_STARTED", o = "Not Started";
1369
- return e.finished_at ? (t = "finished", n = "FINISHED", o = "Finished") : e.started_at && (t = "live", n = "LIVE", o = "Live"), {
1370
- code: t,
1371
- name: o,
1372
- type: n
1373
- };
1374
- }
1375
- function Se(e) {
1376
- return {
1377
- kickoffTime: new Date(e.kickoff_at),
1378
- currentMinute: e.minute ?? void 0,
1379
- currentPeriod: void 0
1380
- };
1381
- }
1382
- function F(e) {
1383
- return {
1384
- id: e.id,
1385
- name: e.name,
1386
- shortName: e.short_name ?? void 0,
1387
- fullName: e.full_name ?? void 0,
1388
- threeLetterCode: e.code,
1389
- type: e.national ? "national" : "club",
1390
- gender: e.gender?.toUpperCase(),
1391
- country: e.country ? P(e.country) : void 0,
1392
- assets: e.assets?.logo ? {
1393
- logo: e.assets.logo
1394
- } : void 0,
1395
- providerRef: [
1396
- {
1397
- provider: "fansunited",
1398
- id: e.id
1399
- }
1400
- ]
1401
- };
1402
- }
1403
- function Ie(e) {
1404
- if (!e) return;
1405
- const t = (o) => o ? {
1406
- competitorOne: o.home_goals !== null ? String(o.home_goals) : "0",
1407
- competitorTwo: o.away_goals !== null ? String(o.away_goals) : "0"
1408
- } : void 0, n = t(e.ft_score);
1409
- if (n)
1410
- return {
1411
- competitorOne: n.competitorOne,
1412
- competitorTwo: n.competitorTwo,
1413
- breakdown: {
1414
- total: n,
1415
- halfTime: t(e.ht_score),
1416
- regularTime: t(e.ft_score),
1417
- extraTime: t(e.aet_score),
1418
- penaltyShootout: t(e.pen_score)
1419
- }
1420
- };
1421
- }
1422
- function b(e) {
1423
- return {
1424
- id: e.id,
1425
- sport: e.sport ?? "football",
1426
- status: Ce(e),
1427
- timing: Se(e),
1428
- competitorOne: F(e.home_team),
1429
- competitorTwo: F(e.away_team),
1430
- score: Ie(e.scores),
1431
- competition: e.context?.competition ? Te(e.context.competition) : void 0,
1432
- lineupStatus: e.lineups_confirmed ? "CONFIRMED" : "NOT_AVAILABLE",
1433
- updatedAt: e.updated_at ? new Date(e.updated_at) : void 0,
1434
- isUndecided: e.undecided ?? void 0,
1435
- providerRef: [
1436
- {
1437
- provider: "fansunited",
1438
- id: e.id
1439
- }
1440
- ]
1441
- };
1442
- }
1443
- function Ze(e) {
1444
- return b(e.data);
1445
- }
1446
- function we(e) {
1447
- return e.data.map(b);
1448
- }
1449
- function Ae(e) {
1450
- return e.map(b);
1451
- }
1452
- async function Ee(e, t, n) {
1453
- const o = await e.loyalty.getTemplateMatches(
1454
- t,
1455
- n?.groupId,
1456
- n?.disableCache
1457
- );
1458
- return Ae(o);
1459
- }
1460
- async function et(e, t, n, o) {
1461
- return (await Ee(e, t, o)).filter((a) => a.competitorOne.id === n || a.competitorTwo.id === n);
1462
- }
1463
- async function tt(e, t, n) {
1464
- const o = await e.loyalty.getTemplateById(t, n?.disableCache);
1465
- return {
1466
- id: o.id,
1467
- name: o.name,
1468
- description: o.description,
1469
- type: o.type,
1470
- fromDate: o.fromDate,
1471
- toDate: o.toDate,
1472
- markets: o.markets || [],
1473
- teamIds: o.teamIds || [],
1474
- matchIds: o.matchIds || [],
1475
- groups: (o.groups || []).map((a) => ({
1476
- groupId: a.groupId,
1477
- label: a.label,
1478
- flags: a.flags || [],
1479
- filters: {
1480
- fromDate: a.filters?.fromDate || "",
1481
- toDate: a.filters?.toDate || "",
1482
- matchIds: a.filters?.matchIds || []
1483
- }
1484
- })),
1485
- gameIds: o.gameIds || [],
1486
- gameTypes: o.gameTypes || [],
1487
- competitionIds: o.competitionIds || [],
1488
- excludedProfileIds: o.excludedProfileIds || [],
1489
- rules: o.rules || "",
1490
- labels: o.labels || {},
1491
- customFields: o.customFields || {},
1492
- // Convert BrandingModel to plain object
1493
- branding: o.branding ? JSON.parse(JSON.stringify(o.branding)) : {},
1494
- brandingId: null,
1495
- // brandingId doesn't exist on TemplateByIdModel, using null
1496
- flags: o.flags || [],
1497
- images: {
1498
- main: o.images?.main || null,
1499
- cover: o.images?.cover || null,
1500
- mobile: o.images?.mobile || null
1501
- },
1502
- status: o.status,
1503
- automaticallyChangeStatus: o.automaticallyChangeStatus || !1,
1504
- createdAt: o.createdAt,
1505
- updatedAt: o.updatedAt,
1506
- related: o.related || [],
1507
- adContent: o.adContent || ""
1508
- };
1509
- }
1510
- function Oe(e) {
1511
- return {
1512
- "1x2": "1X2",
1513
- 12: "12",
1514
- OVER_UNDER: "OVER_UNDER",
1515
- DOUBLE_CHANCE: "DOUBLE_CHANCE",
1516
- BOTH_TO_SCORE: "BOTH_TO_SCORE",
1517
- DRAW_NO_BET: "DRAW_NO_BET",
1518
- FIRST_TEAM_TO_SCORE: "FIRST_TEAM_TO_SCORE",
1519
- CORRECT_SCORE: "CORRECT_SCORE",
1520
- FIRST_HALF_GOALS: "FIRST_HALF_GOALS",
1521
- FIRST_PLAYER_TO_SCORE: "FIRST_PLAYER_TO_SCORE",
1522
- PLAYER_TO_SCORE_DURING_GAME: "PLAYER_TO_SCORE_DURING_GAME",
1523
- PLAYER_TO_RECEIVE_CARD: "PLAYER_TO_RECEIVE_CARD",
1524
- FIRST_HALF_AND_FINAL_RESULT: "FIRST_HALF_AND_FINAL_RESULT"
1525
- }[e] || e.toUpperCase();
1526
- }
1527
- function be(e, t) {
1528
- const n = /* @__PURE__ */ new Map();
1529
- return e.forEach((o, s) => {
1530
- if (!o || o.length === 0)
1531
- return;
1532
- const l = (t ? o.filter((d) => d.bookmaker && t.includes(d.bookmaker.id)) : o).filter((d) => d.bookmaker && d.markets && d.markets.length > 0).map((d) => {
1533
- const u = d.bookmaker, _ = u.assets?.[0], m = u.branding?.backgroundColor || _?.backgroundColor, h = u.branding?.textColor || (Re(m) ? "#FFFFFF" : "#000000"), C = _?.transparentBackgroundUrl || _?.logo, T = u.eventUrls?.find((f) => f.appType === "desktop")?.url || u.links?.find((f) => f.appType === "desktop")?.homepageUrl || u.url || "";
1534
- return {
1535
- operator: {
1536
- id: u.id,
1537
- name: u.name,
1538
- url: T,
1539
- branding: {
1540
- backgroundColor: m,
1541
- textColor: h,
1542
- logo: C
1543
- }
1544
- },
1545
- type: d.type,
1546
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1547
- markets: d.markets.map((f) => ({
1548
- type: {
1549
- id: f.type.id,
1550
- code: f.type.code,
1551
- name: f.type.name
1552
- },
1553
- period: {
1554
- id: f.scope.id,
1555
- type: f.scope.type,
1556
- name: f.scope.name
1557
- },
1558
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1559
- selections: f.selections.map((v) => {
1560
- const x = v.urls?.find((M) => M.appType === "desktop")?.url;
1561
- let I = "NONE";
1562
- return v.movement === "UP" ? I = "UP" : v.movement === "DOWN" && (I = "DOWN"), {
1563
- id: v.id,
1564
- name: v.name,
1565
- code: v.code,
1566
- value: v.value,
1567
- odds: v.odds,
1568
- oddsOld: v.oddsOld,
1569
- movement: I,
1570
- url: x,
1571
- providerSelectionId: v.providerInfo?.selectionId
1572
- };
1573
- })
1574
- }))
1575
- };
1576
- });
1577
- n.set(s, l);
1578
- }), n;
1579
- }
1580
- function Re(e) {
1581
- if (!e) return !0;
1582
- const t = e.replace("#", ""), n = parseInt(t.substring(0, 2), 16), o = parseInt(t.substring(2, 4), 16), s = parseInt(t.substring(4, 6), 16);
1583
- return (0.2126 * n + 0.7152 * o + 0.0722 * s) / 255 < 0.5;
1584
- }
1585
- async function ot(e, t, n) {
1586
- if (!t || t.length === 0)
1587
- return /* @__PURE__ */ new Map();
1588
- const o = {
1589
- oddType: n?.oddType || "ALL",
1590
- scopeType: n?.scopeType || "ORDINARY_TIME",
1591
- oddFormat: n?.oddFormat || "DECIMAL"
1592
- };
1593
- n?.marketTypes && n.marketTypes.length > 0 && (o.marketTypes = n.marketTypes.map((a) => Oe(a)));
1594
- const s = await e.odds.getByMatchIds(t, o);
1595
- return be(s, n?.bookmakerIds);
1596
- }
1597
- export {
1598
- Qe as A,
1599
- qe as B,
1600
- Xe as C,
1601
- Ee as D,
1602
- et as E,
1603
- tt as F,
1604
- Me as G,
1605
- Le as H,
1606
- De as S,
1607
- W as a,
1608
- Ne as b,
1609
- U as c,
1610
- Pe as d,
1611
- xe as e,
1612
- p as f,
1613
- g,
1614
- Fe as h,
1615
- Ze as i,
1616
- we as j,
1617
- ke as k,
1618
- Ue as l,
1619
- ot as m,
1620
- ze as n,
1621
- je as o,
1622
- Ge as p,
1623
- Ve as q,
1624
- He as r,
1625
- Be as s,
1626
- r as t,
1627
- $e as u,
1628
- Ye as v,
1629
- We as w,
1630
- le as x,
1631
- Ke as y,
1632
- Je as z
1633
- };