fansunited-data-layer 0.0.7 → 0.0.9

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 (51) hide show
  1. package/README.md +44 -0
  2. package/dist/api/sportal365-sports/football/competitions/competition.types.d.ts +148 -0
  3. package/dist/api/sportal365-sports/football/competitions/competition.types.d.ts.map +1 -0
  4. package/dist/api/sportal365-sports/football/competitions/index.d.ts +51 -0
  5. package/dist/api/sportal365-sports/football/competitions/index.d.ts.map +1 -0
  6. package/dist/api/sportal365-sports/football/competitions/utils.d.ts +14 -0
  7. package/dist/api/sportal365-sports/football/competitions/utils.d.ts.map +1 -0
  8. package/dist/api/sportal365-sports/football/index.d.ts +2 -0
  9. package/dist/api/sportal365-sports/football/index.d.ts.map +1 -1
  10. package/dist/api/sportal365-sports/football/matches/index.d.ts.map +1 -1
  11. package/dist/api/sportal365-sports/football/matches/types/commentary.types.d.ts +3 -0
  12. package/dist/api/sportal365-sports/football/matches/types/commentary.types.d.ts.map +1 -1
  13. package/dist/api/sportal365-sports/football/matches/types/option.types.d.ts +13 -0
  14. package/dist/api/sportal365-sports/football/matches/types/option.types.d.ts.map +1 -1
  15. package/dist/api/sportal365-sports/football/standings/http.d.ts.map +1 -1
  16. package/dist/api/sportal365-sports/football/standings/index.d.ts.map +1 -1
  17. package/dist/api/sportal365-sports/football/standings/standing.types.d.ts +3 -0
  18. package/dist/api/sportal365-sports/football/standings/standing.types.d.ts.map +1 -1
  19. package/dist/api/sportal365-sports/football/teams/index.d.ts.map +1 -1
  20. package/dist/api/sportal365-sports/football/teams/team.types.d.ts +3 -0
  21. package/dist/api/sportal365-sports/football/teams/team.types.d.ts.map +1 -1
  22. package/dist/api/sportal365-sports/http.d.ts +12 -0
  23. package/dist/api/sportal365-sports/http.d.ts.map +1 -1
  24. package/dist/api/sportal365-sports/index.d.ts +3 -2
  25. package/dist/api/sportal365-sports/index.d.ts.map +1 -1
  26. package/dist/client.cjs +6 -0
  27. package/dist/client.d.ts +20 -0
  28. package/dist/client.d.ts.map +1 -0
  29. package/dist/client.js +451 -0
  30. package/dist/fansunited-data-layer.cjs +1 -0
  31. package/dist/fansunited-data-layer.js +52 -1093
  32. package/dist/helpers/competition.helpers.d.ts +22 -0
  33. package/dist/helpers/competition.helpers.d.ts.map +1 -0
  34. package/dist/helpers/index.d.ts +6 -0
  35. package/dist/helpers/index.d.ts.map +1 -0
  36. package/dist/helpers/team.helpers.d.ts +45 -0
  37. package/dist/helpers/team.helpers.d.ts.map +1 -0
  38. package/dist/index-4gbkCyy3.cjs +1 -0
  39. package/dist/index-C8byrMrI.js +806 -0
  40. package/dist/index.d.ts +5 -4
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/providers/competition.provider.d.ts +1 -1
  43. package/dist/providers/competition.provider.d.ts.map +1 -1
  44. package/dist/providers/competition.types.d.ts +21 -3
  45. package/dist/providers/competition.types.d.ts.map +1 -1
  46. package/dist/types/canonical/base.types.d.ts +51 -0
  47. package/dist/types/canonical/base.types.d.ts.map +1 -1
  48. package/dist/types/canonical/index.d.ts +1 -1
  49. package/dist/types/canonical/index.d.ts.map +1 -1
  50. package/package.json +8 -3
  51. package/dist/fansunited-data-layer.umd.cjs +0 -6
@@ -1,1115 +1,74 @@
1
- "use client";
2
- import ge, { createContext as _e, useContext as ye, useState as ne, useEffect as Q, useCallback as y, useMemo as he } from "react";
3
- let z = null;
4
- function et(e) {
5
- z = e;
6
- }
7
- function T() {
8
- if (!z)
9
- throw new Error(
10
- "Data layer config not initialized. Call setConfig() in your root layout."
11
- );
12
- return z;
13
- }
14
- function tt() {
15
- return z !== null;
16
- }
17
- function Ee(e) {
18
- const t = e.replace(/\/$/, "");
19
- function n() {
20
- const { sportal365Sports: a } = T();
21
- if (!a)
22
- throw new Error("Sportal365 Sports API configuration is missing");
23
- const s = `${a.username}:${a.password}`;
24
- return `Basic ${btoa(s)}`;
25
- }
26
- function r(a) {
27
- return `${t}${a}`;
28
- }
29
- return {
30
- async get(a) {
31
- const { sportal365Sports: s } = T();
32
- if (!s)
33
- throw new Error("Sportal365 Sports API configuration is missing");
34
- const m = new URL(r(a.path));
35
- if (a.params)
36
- for (const [v, k] of Object.entries(a.params))
37
- k !== void 0 && (Array.isArray(k) ? k.length > 0 && m.searchParams.set(v, k.join(",")) : m.searchParams.set(v, k));
38
- const p = await fetch(m.toString(), {
39
- method: "GET",
40
- headers: {
41
- Authorization: n(),
42
- "Content-Type": "application/json",
43
- "X-Project": s.projectId
44
- },
45
- signal: s.timeout ? AbortSignal.timeout(s.timeout) : void 0
46
- });
47
- if (!p.ok)
48
- throw new Error(`Sportal365 API error: ${p.status} ${p.statusText}`);
49
- return p.json();
50
- }
51
- };
52
- }
53
- const Te = "https://football.api.sportal365.com", ve = "https://standing.api.sportal365.com", O = Ee(Te);
54
- function re(e) {
55
- if (e)
56
- return {
57
- id: e.id,
58
- name: e.name,
59
- slug: e.slug,
60
- position: e.position,
61
- gender: e.gender,
62
- assets: e.assets ? {
63
- photo: e.assets.thumb?.url,
64
- photoTransparent: e.assets.thumb_transparent_background?.url
65
- } : void 0
66
- };
67
- }
68
- const Se = {
69
- // Scoring events
70
- GOAL: "GOAL",
71
- PENALTY_GOAL: "PENALTY_GOAL",
72
- OWN_GOAL: "OWN_GOAL",
73
- DISALLOWED_GOAL: "DISALLOWED_GOAL",
74
- PENALTY_SHOOTOUT_SCORED: "PENALTY_SHOOTOUT_SCORED",
75
- PENALTY_SHOOTOUT_MISSED: "PENALTY_SHOOTOUT_MISSED",
76
- // Card events
77
- YELLOW_CARD: "YELLOW_CARD",
78
- RED_CARD: "RED_CARD",
79
- YELLOW_RED_CARD: "YELLOW_RED_CARD",
80
- // Substitution
81
- SUBSTITUTION: "SUBSTITUTION",
82
- // Match flow events
83
- KICKOFF: "KICKOFF",
84
- HALFTIME: "HALFTIME",
85
- START_SECOND_HALF: "START_SECOND_HALF",
86
- FINISHED: "FINISHED",
87
- INJURY_TIME: "INJURY_TIME",
88
- // Penalty events
89
- PENALTY_AWARDED: "PENALTY_AWARDED",
90
- PENALTY_MISSED: "PENALTY_MISSED",
91
- PENALTY_SAVED: "PENALTY_SAVED"
92
- };
93
- function J(e) {
94
- const t = Se[e.type_code];
95
- return t ? {
96
- id: e.id,
97
- type: t,
98
- competitorPosition: e.team_position === "HOME" ? "ONE" : "TWO",
99
- minute: e.minute,
100
- injuryMinute: e.injury_minute,
101
- primaryPlayer: re(e.primary_player),
102
- secondaryPlayer: re(e.secondary_player),
103
- score: e.score ? { competitorOne: String(e.score.home), competitorTwo: String(e.score.away) } : void 0
104
- } : (console.warn(`Unknown event type: ${e.type_code}`), null);
105
- }
106
- function ke(e) {
107
- return {
108
- code: {
109
- FINISHED: "finished",
110
- NOT_STARTED: "not_started",
111
- LIVE: "live",
112
- INTERRUPTED: "interrupted",
113
- CANCELLED: "cancelled",
114
- POSTPONED: "postponed",
115
- UNKNOWN: "not_started",
116
- ABANDONED: "abandoned"
117
- }[e.type] ?? "not_started",
118
- name: e.name,
119
- shortName: e.short_name,
120
- type: e.type
121
- };
122
- }
123
- function ae(e) {
124
- return {
125
- id: e.id,
126
- name: e.name,
127
- shortName: e.short_name ?? void 0,
128
- threeLetterCode: e.three_letter_code,
129
- slug: e.slug,
130
- type: e.type ?? "club",
131
- gender: e.gender,
132
- assets: e.assets ? {
133
- logo: e.assets.logo?.url,
134
- homeKit: e.assets.home_kit?.url,
135
- awayKit: e.assets.away_kit?.url,
136
- squadImage: e.assets.squad_image?.url
137
- } : void 0,
138
- metadata: e.shirt_color ? { shirtColor: e.shirt_color } : void 0
139
- };
140
- }
141
- function Ae(e) {
142
- return {
143
- kickoffTime: new Date(e.kickoff_time),
144
- currentMinute: e.minute?.regular_time,
145
- phaseStartedAt: e.phase_started_at ? new Date(e.phase_started_at) : void 0,
146
- finishedAt: e.finished_at ? new Date(e.finished_at) : void 0,
147
- firstHalfStartedAt: e.first_half_started_at ? new Date(e.first_half_started_at) : void 0,
148
- secondHalfStartedAt: e.second_half_started_at ? new Date(e.second_half_started_at) : void 0,
149
- extraTimeFirstHalfStartedAt: e.extra_time_first_half_started_at ? new Date(e.extra_time_first_half_started_at) : void 0,
150
- extraTimeSecondHalfStartedAt: e.extra_time_second_half_started_at ? new Date(e.extra_time_second_half_started_at) : void 0
151
- };
152
- }
153
- function Oe(e) {
154
- if (!e) return;
155
- const t = (r) => r ? { competitorOne: String(r.home), competitorTwo: String(r.away) } : void 0, n = e.total ?? e.regular_time;
156
- return {
157
- competitorOne: n?.home != null ? String(n.home) : null,
158
- competitorTwo: n?.away != null ? String(n.away) : null,
159
- breakdown: {
160
- total: t(e.total),
161
- halfTime: t(e.half_time),
162
- regularTime: t(e.regular_time),
163
- extraTime: t(e.extra_time),
164
- penaltyShootout: t(e.penalty_shootout),
165
- aggregate: t(e.aggregate)
166
- }
167
- };
168
- }
169
- function be(e) {
170
- if (e)
171
- return {
172
- id: e.id,
173
- name: e.name,
174
- slug: e.slug,
175
- assets: e.assets?.image?.url ? { image: e.assets.image.url } : void 0
176
- };
177
- }
178
- function Re(e) {
179
- if (e?.length)
180
- return e.map((t) => ({
181
- id: t.id,
182
- name: t.name,
183
- slug: t.slug,
184
- role: t.role ?? "REFEREE",
185
- gender: t.gender
186
- }));
187
- }
188
- function Ce(e) {
189
- if (!e.season?.tournament) return;
190
- const { tournament: t, ...n } = e.season;
1
+ import { g, f as l } from "./index-C8byrMrI.js";
2
+ import { k, a as b, h as F, b as v, c as M, d as D, e as S, j as _, l as C, m as x, i as E, s as L } from "./index-C8byrMrI.js";
3
+ function r(t) {
191
4
  return {
192
5
  id: t.id,
193
6
  name: t.name,
7
+ shortName: t.short_name ?? void 0,
8
+ threeLetterCode: t.three_letter_code,
194
9
  slug: t.slug,
195
- type: t.type,
196
- region: t.region,
10
+ type: t.type === "placeholder" ? "club" : t.type,
11
+ gender: t.gender,
197
12
  country: t.country ? {
198
13
  id: t.country.id,
199
14
  name: t.country.name,
200
15
  code: t.country.code ?? void 0,
201
16
  flag: t.country.assets?.flag?.url
202
17
  } : void 0,
203
- season: {
204
- id: n.id,
205
- name: n.name,
206
- status: n.status
207
- },
208
- stage: e.stage ? {
209
- id: e.stage.id,
210
- name: e.stage.name,
211
- type: e.stage.type
212
- } : void 0,
213
- assets: t.assets?.logo?.url ? { logo: t.assets.logo.url } : void 0
214
- };
215
- }
216
- function Ne(e) {
217
- if (!e.winner?.match?.id) return;
218
- const t = {
219
- "Regular Time": "REGULAR_TIME",
220
- "Extra Time": "EXTRA_TIME",
221
- Penalties: "PENALTIES"
222
- };
223
- return {
224
- competitorId: e.winner.match.id,
225
- reason: e.winner.match.reason?.name ? t[e.winner.match.reason.name] : void 0,
226
- aggregate: !!e.winner.aggregate
227
- };
228
- }
229
- function me(e) {
230
- return {
231
- id: e.id,
232
- slug: e.slug,
233
- status: ke(e.status),
234
- timing: Ae(e),
235
- competitorOne: ae(e.home_team),
236
- competitorTwo: ae(e.away_team),
237
- competition: Ce(e),
238
- round: e.round ? {
239
- id: e.round.id ?? e.round.key,
240
- key: e.round.key,
241
- name: e.round.name,
242
- type: e.round.type ?? "REGULAR"
243
- } : void 0,
244
- group: e.group ? {
245
- id: e.group.id,
246
- name: e.group.name
247
- } : void 0,
248
- venue: be(e.venue),
249
- officials: Re(e.referees),
250
- spectators: e.spectators ?? void 0,
251
- score: Oe(e.score),
252
- mainEvents: e.main_events?.map(J).filter((t) => t !== null),
253
- penaltyShootoutEvents: e.penalty_shootout_events?.map(J).filter((t) => t !== null),
254
- winner: Ne(e),
255
- coverage: e.coverage === "NOT_LIVE" ? "UNKNOWN" : e.coverage,
256
- lineupStatus: e.lineup_status === "UNCONFIRMED" ? "EXPECTED" : e.lineup_status
257
- };
258
- }
259
- function Le(e) {
260
- const t = e.player;
261
- return {
262
- id: t.id,
263
- name: t.name,
264
- slug: t.slug,
265
- position: t.position,
266
- shirtNumber: e.shirt_number,
267
- positionX: e.position_x ?? void 0,
268
- positionY: e.position_y ?? void 0,
269
- country: t.country ? {
270
- id: t.country.id,
271
- name: t.country.name,
272
- code: t.country.code
273
- } : void 0,
274
- birthdate: t.birthdate,
275
- profile: t.profile ? {
276
- height: t.profile.height,
277
- weight: t.profile.weight
278
- } : void 0,
279
- events: e.events?.map(J).filter((n) => n !== null)
280
- };
281
- }
282
- function se(e) {
283
- const t = [], n = [];
284
- for (const r of e.players) {
285
- const a = Le(r);
286
- r.type.category === "start" ? t.push(a) : r.type.category === "sub" && n.push(a);
287
- }
288
- return {
289
- competitorId: e.team_id,
290
- formation: e.formation,
291
- coach: e.coach ? {
292
- id: e.coach.id,
293
- name: e.coach.name,
294
- slug: e.coach.slug,
295
- country: e.coach.country ? {
296
- id: e.coach.country.id,
297
- name: e.coach.country.name,
298
- code: e.coach.country.code
299
- } : void 0,
300
- birthdate: e.coach.birthdate
301
- } : void 0,
302
- starters: t,
303
- substitutes: n
304
- };
305
- }
306
- function Pe(e) {
307
- return {
308
- matchId: e.match_id,
309
- confirmed: e.status === "CONFIRMED",
310
- competitorOne: se(e.home_team),
311
- competitorTwo: se(e.away_team)
312
- };
313
- }
314
- function h(e, t, n, r) {
315
- return t == null ? null : { key: e, value: String(t), label: n, unit: r };
316
- }
317
- function ie(e, t) {
318
- const n = (t.shots_on ?? 0) + (t.shots_off ?? 0) + (t.shots_blocked ?? 0), r = [
319
- h("possession", t.possession, "Possession", "%"),
320
- h("shots_total", n, "Shots"),
321
- h("shots_on_target", t.shots_on, "Shots on Target"),
322
- h("shots_off_target", t.shots_off, "Shots off Target"),
323
- h("shots_blocked", t.shots_blocked, "Shots Blocked"),
324
- h("corners", t.corners, "Corner Kicks"),
325
- h("goal_kicks", t.goal_kicks, "Goal Kicks"),
326
- h("throw_ins", t.throw_in, "Throw Ins"),
327
- h("offsides", t.offside, "Offsides"),
328
- h("fouls", t.fouls_committed, "Fouls"),
329
- h("yellow_cards", t.yellow_cards, "Yellow Cards"),
330
- h("passes", t.pass, "Passes"),
331
- h("crosses", t.crosses, "Crosses")
332
- ];
333
- return {
334
- competitorId: e,
335
- statistics: r.filter((a) => a !== null)
336
- };
337
- }
338
- function Ie(e) {
339
- const t = e.find((r) => r.home_team), n = e.find((r) => !r.home_team);
340
- if (!t || !n)
341
- throw new Error("Missing competitor statistics");
342
- return {
343
- competitorOne: ie(String(t.team.id), t.statistics),
344
- competitorTwo: ie(String(n.team.id), n.statistics)
345
- };
346
- }
347
- function De(e) {
348
- const t = e.urls?.find((n) => n.app_type === "desktop")?.url;
349
- return {
350
- id: e.id,
351
- name: e.name,
352
- code: e.code,
353
- value: e.value ?? void 0,
354
- odds: e.odds,
355
- oddsOld: e.odds_old,
356
- movement: e.movement === "STABLE" ? "NONE" : e.movement,
357
- url: t
358
- };
359
- }
360
- function xe(e) {
361
- return {
362
- type: {
363
- id: e.type.id,
364
- code: e.type.code,
365
- name: e.type.name
366
- },
367
- period: {
368
- id: e.scope.id,
369
- type: e.scope.type,
370
- name: e.scope.name
371
- },
372
- selections: e.selections.map(De)
373
- };
374
- }
375
- function Me(e) {
376
- return {
377
- operator: {
378
- id: e.bookmaker.id,
379
- name: e.bookmaker.name,
380
- url: e.bookmaker.url,
381
- branding: e.bookmaker.branding ? {
382
- backgroundColor: e.bookmaker.branding.background_color,
383
- textColor: e.bookmaker.branding.text_color,
384
- logo: e.bookmaker.assets?.[0]?.logo
385
- } : void 0
386
- },
387
- type: e.type,
388
- markets: e.markets.map(xe)
389
- };
390
- }
391
- function Fe(e, t) {
392
- return {
393
- matchId: e,
394
- operators: t.map(Me)
395
- };
396
- }
397
- function ce(e) {
398
- if (e == null || e === "")
399
- return;
400
- const t = typeof e == "number" ? e : parseInt(e, 10);
401
- return isNaN(t) ? void 0 : t;
402
- }
403
- function je(e) {
404
- return {
405
- externalId: e.external_id,
406
- minute: ce(e.elapsed),
407
- addedTime: ce(e.elapsed_plus),
408
- text: e.auto_text,
409
- details: e.details,
410
- meta: {
411
- type: e.type,
412
- commentaryType: e.commentary_type,
413
- subtype1: e.subtype_1,
414
- subtype2: e.subtype_2,
415
- timestamp: e.incident_timestamp
416
- }
417
- };
418
- }
419
- async function ot(e, t = {}) {
420
- const { sportal365Sports: n } = T(), r = await O.get({
421
- path: `/v2/matches/${e}`,
422
- params: {
423
- language_code: t.languageCode ?? n?.languageCode ?? "en",
424
- odd_client: t.oddClient,
425
- odd_type: t.oddType,
426
- scope_type: t.scopeType,
427
- odd_format: t.oddFormat,
428
- market_types: t.marketTypes,
429
- bookmaker_ids: t.bookmakerIds,
430
- optional_data: t.optionalData
431
- }
432
- });
433
- return me(r);
434
- }
435
- async function nt(e, t = {}) {
436
- const { sportal365Sports: n } = T();
437
- return (await O.get({
438
- path: `/v2/matches/${e}/events`,
439
- params: {
440
- language_code: t.languageCode ?? n?.languageCode ?? "en"
441
- }
442
- })).events.map(J).filter((a) => a !== null);
443
- }
444
- async function rt(e, t = {}) {
445
- const { sportal365Sports: n } = T(), r = await O.get({
446
- path: `/v2/matches/${e}/lineups`,
447
- params: {
448
- language_code: t.languageCode ?? n?.languageCode ?? "en"
449
- }
450
- });
451
- return Pe(r);
452
- }
453
- async function at(e, t = {}) {
454
- const { sportal365Sports: n } = T(), r = await O.get({
455
- path: `/v2/matches/${e}`,
456
- params: {
457
- language_code: t.languageCode ?? n?.languageCode ?? "en",
458
- odd_client: t.oddClient ?? n?.oddClient,
459
- odd_type: t.oddType,
460
- scope_type: t.scopeType ?? "ALL",
461
- odd_format: t.oddFormat ?? "DECIMAL",
462
- market_types: t.marketTypes,
463
- bookmaker_ids: t.bookmakerIds
464
- }
465
- });
466
- return Fe(e, r.odds ?? []);
467
- }
468
- async function st(e, t = {}) {
469
- const { sportal365Sports: n } = T(), r = await O.get({
470
- path: `/events/${e}/teamstats`,
471
- params: {
472
- language_code: t.languageCode ?? n?.languageCode ?? "en"
473
- }
474
- });
475
- return Ie(r);
476
- }
477
- async function it(e, t = {}) {
478
- const { sportal365Sports: n } = T();
479
- return (await O.get({
480
- path: `/matches/${e}/commentary`,
481
- params: {
482
- language_code: t.languageCode ?? n?.languageCode ?? "en"
483
- }
484
- })).map(je);
485
- }
486
- async function ct(e) {
487
- const { sportal365Sports: t } = T();
488
- return (await O.get({
489
- path: "/v2/matches",
490
- params: {
491
- language_code: e.languageCode ?? t?.languageCode ?? "en",
492
- limit: e.limit.toString(),
493
- offset: e.offset.toString(),
494
- // Competition filters
495
- tournament_ids: e.tournamentIds,
496
- season_ids: e.seasonIds,
497
- stage_ids: e.stageIds,
498
- group_ids: e.groupIds,
499
- round_ids: e.roundIds,
500
- round_filter: e.roundFilter,
501
- // Time filters
502
- from_kickoff_time: e.fromKickoffTime,
503
- to_kickoff_time: e.toKickoffTime,
504
- // Entity filters
505
- team_ids: e.teamIds,
506
- team_ids_operator: e.teamIdsOperator,
507
- referee_id: e.refereeId,
508
- venue_id: e.venueId,
509
- player_id: e.playerId,
510
- // Status filters
511
- status_types: e.statusTypes,
512
- status_codes: e.statusCodes,
513
- // Odds
514
- odd_client: e.oddClient ?? t?.oddClient,
515
- odd_type: e.oddType,
516
- scope_type: e.scopeType,
517
- odd_format: e.oddFormat,
518
- market_types: e.marketTypes,
519
- bookmaker_ids: e.bookmakerIds,
520
- // Sorting and optional data
521
- sort_direction: e.sortDirection,
522
- optional_data: e.optionalData
523
- }
524
- })).matches.map(me);
525
- }
526
- function Ye(e) {
527
- return {
528
- id: e.id,
529
- name: e.name,
530
- shortName: e.short_name ?? void 0,
531
- threeLetterCode: e.three_letter_code,
532
- slug: e.slug,
533
- type: e.type === "placeholder" ? "club" : e.type,
534
- gender: e.gender,
535
- country: e.country ? {
536
- id: e.country.id,
537
- name: e.country.name,
538
- code: e.country.code ?? void 0,
539
- flag: e.country.assets?.flag?.url
540
- } : void 0,
541
- assets: e.assets ? {
542
- logo: e.assets.logo?.url,
543
- homeKit: e.assets.home_kit?.url,
544
- awayKit: e.assets.away_kit?.url,
545
- squadImage: e.assets.squad_image?.url
18
+ assets: t.assets ? {
19
+ logo: t.assets.logo?.url,
20
+ homeKit: t.assets.home_kit?.url,
21
+ awayKit: t.assets.away_kit?.url,
22
+ squadImage: t.assets.squad_image?.url
546
23
  } : void 0
547
24
  };
548
25
  }
549
- async function ut(e, t = {}) {
550
- const { sportal365Sports: n } = T(), r = await O.get({
551
- path: `/v2/teams/${e}`,
26
+ async function m(t, o = {}) {
27
+ const { sportal365Sports: s } = g(), n = await l.get({
28
+ path: `/v2/teams/${t}`,
552
29
  params: {
553
- language_code: t.languageCode ?? n?.languageCode ?? "en",
30
+ language_code: o.languageCode ?? s?.languageCode ?? "en",
554
31
  optional_data: "form"
555
- }
556
- });
557
- return Ye(r);
558
- }
559
- const $e = ve.replace(/\/$/, "");
560
- function Ue() {
561
- const { sportal365Sports: e } = T();
562
- if (!e)
563
- throw new Error("Sportal365 Sports API configuration is missing");
564
- const t = `${e.username}:${e.password}`;
565
- return `Basic ${btoa(t)}`;
566
- }
567
- function We(e) {
568
- return `${$e}${e}`;
569
- }
570
- const Ge = {
571
- async get(e) {
572
- const { sportal365Sports: t } = T();
573
- if (!t)
574
- throw new Error("Sportal365 Sports API configuration is missing");
575
- const n = new URL(We(e.path));
576
- if (e.params)
577
- for (const [a, s] of Object.entries(e.params))
578
- s !== void 0 && (Array.isArray(s) ? s.length > 0 && n.searchParams.set(a, s.join(",")) : n.searchParams.set(a, s));
579
- const r = await fetch(n.toString(), {
580
- method: "GET",
581
- headers: {
582
- Authorization: Ue(),
583
- "Content-Type": "application/json",
584
- "X-Project": t.projectId
585
- // Standings API uses X-Project
586
- },
587
- signal: t.timeout ? AbortSignal.timeout(t.timeout) : void 0
588
- });
589
- if (!r.ok) {
590
- const a = await r.text();
591
- throw new Error(`Sportal365 Standings API error: ${r.status} ${r.statusText} - ${a}`);
592
- }
593
- return r.json();
594
- }
595
- };
596
- function He(e) {
597
- return {
598
- RANK: "rank",
599
- PLAYED: "played",
600
- WINS: "won",
601
- DRAWS: "drawn",
602
- LOSSES: "lost",
603
- GOALS_FOR: "goalsFor",
604
- GOALS_AGAINST: "goalsAgainst",
605
- GOAL_DIFFERENCE: "goalDifference",
606
- POINTS: "points"
607
- }[e] ?? e.toLowerCase();
608
- }
609
- function w(e) {
610
- return {
611
- CHAMPIONS_LEAGUE: "championsLeague",
612
- EUROPA_LEAGUE: "europaLeague",
613
- CONFERENCE_LEAGUE: "conferenceLeague",
614
- RELEGATION: "relegation",
615
- PLAYOFF: "playoff",
616
- PROMOTION: "promotion"
617
- }[e] ?? e.toLowerCase().replace(/_/g, "");
618
- }
619
- function Be(e) {
620
- switch (e) {
621
- case "win":
622
- return "W";
623
- case "loss":
624
- return "L";
625
- case "draw":
626
- return "D";
627
- }
628
- }
629
- function Ke(e, t) {
630
- if (!t || t.length === 0)
631
- return;
632
- const n = t.map((a) => {
633
- const s = a.participants.find((p) => p.id !== e) ?? a.participants[0], m = a.result?.[0]?.results?.map((p) => p.value).join("-") ?? void 0;
634
- return {
635
- matchId: a.id,
636
- result: Be(a.outcome),
637
- score: m,
638
- opponent: {
639
- id: s.id,
640
- name: s.name,
641
- logo: s.display_asset?.url ?? s.assets?.logo?.url
642
- },
643
- date: new Date(a.start_time),
644
- competition: a.competition ? {
645
- id: a.competition.id,
646
- name: a.competition.name
647
- } : void 0
648
- };
649
- }), r = n.map((a) => a.result).join("");
650
- return {
651
- competitorId: e,
652
- results: n,
653
- formString: r
654
- };
655
- }
656
- function Ve(e) {
657
- return {
658
- key: w(e.standing_api_rule_type),
659
- name: e.name,
660
- position: e.type
661
- };
662
- }
663
- function qe(e) {
664
- const t = {};
665
- let n = 0;
666
- for (const m of e.columns) {
667
- const p = He(m.type.code), v = parseInt(m.value, 10);
668
- m.type.code === "RANK" ? n = v : t[p] = isNaN(v) ? void 0 : v;
669
- }
670
- const r = e.rules?.length > 0 ? e.rules.map((m) => w(m.standing_api_rule_type)) : void 0, a = Ke(e.team.id, e.form), s = e.team.assets?.logo?.url;
671
- return {
672
- rank: n,
673
- competitor: {
674
- id: e.team.id,
675
- name: e.team.name,
676
- shortName: e.team.short_name ?? void 0,
677
- logo: s
678
32
  },
679
- stats: t,
680
- form: a,
681
- rules: r
682
- };
683
- }
684
- function ze(e) {
685
- const t = e.map(qe), n = /* @__PURE__ */ new Map();
686
- for (const r of e)
687
- if (r.rules)
688
- for (const a of r.rules) {
689
- const s = w(a.standing_api_rule_type);
690
- n.has(s) || n.set(s, Ve(a));
691
- }
692
- return {
693
- entries: t,
694
- metadata: {
695
- legend: Array.from(n.values())
696
- }
697
- };
698
- }
699
- async function lt(e) {
700
- const n = (await Ge.get({
701
- path: "/standings/football",
702
- params: {
703
- stage_id: e.stageId,
704
- coverage_type: e.coverageType ?? "ALL",
705
- optional_data: e.optionalData
706
- }
707
- })).data?.[0];
708
- if (!n?.standings?.length)
709
- return { entries: [], metadata: { legend: [] } };
710
- const r = n.standings[0];
711
- return r?.standing?.length ? ze(r.standing) : { entries: [], metadata: { legend: [] } };
712
- }
713
- var q = { exports: {} }, I = {};
714
- var ue;
715
- function Je() {
716
- if (ue) return I;
717
- ue = 1;
718
- var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
719
- function n(r, a, s) {
720
- var m = null;
721
- if (s !== void 0 && (m = "" + s), a.key !== void 0 && (m = "" + a.key), "key" in a) {
722
- s = {};
723
- for (var p in a)
724
- p !== "key" && (s[p] = a[p]);
725
- } else s = a;
726
- return a = s.ref, {
727
- $$typeof: e,
728
- type: r,
729
- key: m,
730
- ref: a !== void 0 ? a : null,
731
- props: s
732
- };
733
- }
734
- return I.Fragment = t, I.jsx = n, I.jsxs = n, I;
735
- }
736
- var D = {};
737
- var le;
738
- function Xe() {
739
- return le || (le = 1, process.env.NODE_ENV !== "production" && (function() {
740
- function e(o) {
741
- if (o == null) return null;
742
- if (typeof o == "function")
743
- return o.$$typeof === B ? null : o.displayName || o.name || null;
744
- if (typeof o == "string") return o;
745
- switch (o) {
746
- case R:
747
- return "Fragment";
748
- case j:
749
- return "Profiler";
750
- case F:
751
- return "StrictMode";
752
- case U:
753
- return "Suspense";
754
- case W:
755
- return "SuspenseList";
756
- case H:
757
- return "Activity";
758
- }
759
- if (typeof o == "object")
760
- switch (typeof o.tag == "number" && console.error(
761
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
762
- ), o.$$typeof) {
763
- case M:
764
- return "Portal";
765
- case $:
766
- return o.displayName || "Context";
767
- case Y:
768
- return (o._context.displayName || "Context") + ".Consumer";
769
- case A:
770
- var i = o.render;
771
- return o = o.displayName, o || (o = i.displayName || i.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
772
- case G:
773
- return i = o.displayName || null, i !== null ? i : e(o.type) || "Memo";
774
- case C:
775
- i = o._payload, o = o._init;
776
- try {
777
- return e(o(i));
778
- } catch {
779
- }
780
- }
781
- return null;
782
- }
783
- function t(o) {
784
- return "" + o;
785
- }
786
- function n(o) {
787
- try {
788
- t(o);
789
- var i = !1;
790
- } catch {
791
- i = !0;
792
- }
793
- if (i) {
794
- i = console;
795
- var l = i.error, g = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
796
- return l.call(
797
- i,
798
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
799
- g
800
- ), t(o);
801
- }
802
- }
803
- function r(o) {
804
- if (o === R) return "<>";
805
- if (typeof o == "object" && o !== null && o.$$typeof === C)
806
- return "<...>";
807
- try {
808
- var i = e(o);
809
- return i ? "<" + i + ">" : "<...>";
810
- } catch {
811
- return "<...>";
812
- }
813
- }
814
- function a() {
815
- var o = P.A;
816
- return o === null ? null : o.getOwner();
817
- }
818
- function s() {
819
- return Error("react-stack-top-frame");
820
- }
821
- function m(o) {
822
- if (c.call(o, "key")) {
823
- var i = Object.getOwnPropertyDescriptor(o, "key").get;
824
- if (i && i.isReactWarning) return !1;
825
- }
826
- return o.key !== void 0;
827
- }
828
- function p(o, i) {
829
- function l() {
830
- E || (E = !0, console.error(
831
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
832
- i
833
- ));
834
- }
835
- l.isReactWarning = !0, Object.defineProperty(o, "key", {
836
- get: l,
837
- configurable: !0
838
- });
839
- }
840
- function v() {
841
- var o = e(this.type);
842
- return K[o] || (K[o] = !0, console.error(
843
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
844
- )), o = this.props.ref, o !== void 0 ? o : null;
845
- }
846
- function k(o, i, l, g, V, X) {
847
- var _ = l.ref;
848
- return o = {
849
- $$typeof: L,
850
- type: o,
851
- key: i,
852
- props: l,
853
- _owner: g
854
- }, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(o, "ref", {
855
- enumerable: !1,
856
- get: v
857
- }) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
858
- configurable: !1,
859
- enumerable: !1,
860
- writable: !0,
861
- value: 0
862
- }), Object.defineProperty(o, "_debugInfo", {
863
- configurable: !1,
864
- enumerable: !1,
865
- writable: !0,
866
- value: null
867
- }), Object.defineProperty(o, "_debugStack", {
868
- configurable: !1,
869
- enumerable: !1,
870
- writable: !0,
871
- value: V
872
- }), Object.defineProperty(o, "_debugTask", {
873
- configurable: !1,
874
- enumerable: !1,
875
- writable: !0,
876
- value: X
877
- }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
878
- }
879
- function d(o, i, l, g, V, X) {
880
- var _ = i.children;
881
- if (_ !== void 0)
882
- if (g)
883
- if (u(_)) {
884
- for (g = 0; g < _.length; g++)
885
- x(_[g]);
886
- Object.freeze && Object.freeze(_);
887
- } else
888
- console.error(
889
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
890
- );
891
- else x(_);
892
- if (c.call(i, "key")) {
893
- _ = e(o);
894
- var N = Object.keys(i).filter(function(pe) {
895
- return pe !== "key";
896
- });
897
- g = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", oe[_ + g] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
898
- `A props object containing a "key" prop is being spread into JSX:
899
- let props = %s;
900
- <%s {...props} />
901
- React keys must be passed directly to JSX without using spread:
902
- let props = %s;
903
- <%s key={someKey} {...props} />`,
904
- g,
905
- _,
906
- N,
907
- _
908
- ), oe[_ + g] = !0);
909
- }
910
- if (_ = null, l !== void 0 && (n(l), _ = "" + l), m(i) && (n(i.key), _ = "" + i.key), "key" in i) {
911
- l = {};
912
- for (var Z in i)
913
- Z !== "key" && (l[Z] = i[Z]);
914
- } else l = i;
915
- return _ && p(
916
- l,
917
- typeof o == "function" ? o.displayName || o.name || "Unknown" : o
918
- ), k(
919
- o,
920
- _,
921
- l,
922
- a(),
923
- V,
924
- X
925
- );
926
- }
927
- function x(o) {
928
- S(o) ? o._store && (o._store.validated = 1) : typeof o == "object" && o !== null && o.$$typeof === C && (o._payload.status === "fulfilled" ? S(o._payload.value) && o._payload.value._store && (o._payload.value._store.validated = 1) : o._store && (o._store.validated = 1));
929
- }
930
- function S(o) {
931
- return typeof o == "object" && o !== null && o.$$typeof === L;
932
- }
933
- var b = ge, L = Symbol.for("react.transitional.element"), M = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), F = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), Y = Symbol.for("react.consumer"), $ = Symbol.for("react.context"), A = Symbol.for("react.forward_ref"), U = Symbol.for("react.suspense"), W = Symbol.for("react.suspense_list"), G = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), B = Symbol.for("react.client.reference"), P = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, c = Object.prototype.hasOwnProperty, u = Array.isArray, f = console.createTask ? console.createTask : function() {
934
- return null;
935
- };
936
- b = {
937
- react_stack_bottom_frame: function(o) {
938
- return o();
939
- }
940
- };
941
- var E, K = {}, ee = b.react_stack_bottom_frame.bind(
942
- b,
943
- s
944
- )(), te = f(r(s)), oe = {};
945
- D.Fragment = R, D.jsx = function(o, i, l) {
946
- var g = 1e4 > P.recentlyCreatedOwnerStacks++;
947
- return d(
948
- o,
949
- i,
950
- l,
951
- !1,
952
- g ? Error("react-stack-top-frame") : ee,
953
- g ? f(r(o)) : te
954
- );
955
- }, D.jsxs = function(o, i, l) {
956
- var g = 1e4 > P.recentlyCreatedOwnerStacks++;
957
- return d(
958
- o,
959
- i,
960
- l,
961
- !0,
962
- g ? Error("react-stack-top-frame") : ee,
963
- g ? f(r(o)) : te
964
- );
965
- };
966
- })()), D;
33
+ next: o.next
34
+ });
35
+ return r(n);
967
36
  }
968
- var de;
969
- function Ze() {
970
- return de || (de = 1, process.env.NODE_ENV === "production" ? q.exports = Je() : q.exports = Xe()), q.exports;
37
+ function f(t) {
38
+ return !t.seasons || t.seasons.length === 0 ? void 0 : t.seasons.find((s) => s.active) ?? t.seasons[0];
971
39
  }
972
- var Qe = Ze();
973
- const fe = _e(null);
974
- function dt() {
975
- const e = ye(fe);
976
- if (!e)
977
- throw new Error("useCompetition must be used within CompetitionProvider");
978
- return e;
40
+ function d(t, o) {
41
+ const s = /* @__PURE__ */ new Date(), n = o.filter((e) => {
42
+ const a = e.competitorOne.id === t || e.competitorTwo.id === t, i = e.status.type === "NOT_STARTED" || e.status.type === "LIVE", c = new Date(e.timing.kickoffTime) >= s || e.status.type === "LIVE";
43
+ return a && i && c;
44
+ });
45
+ return n.sort((e, a) => new Date(e.timing.kickoffTime).getTime() - new Date(a.timing.kickoffTime).getTime()), n[0];
979
46
  }
980
- function mt({
981
- competitionId: e,
982
- seasonId: t,
983
- stageId: n,
984
- matches: r,
985
- standings: a,
986
- previousSeasons: s,
987
- config: m,
988
- autoRefresh: p = !0,
989
- refreshInterval: v = 3e4,
990
- children: k
991
- }) {
992
- const [d, x] = ne(r), [S, b] = ne(a);
993
- Q(() => {
994
- x(r);
995
- }, [r]), Q(() => {
996
- b(a);
997
- }, [a]), Q(() => {
998
- if (!p || !d.some((f) => f.status.code === "live")) return;
999
- const u = setInterval(async () => {
1000
- console.log("[CompetitionProvider] Auto-refresh triggered for live matches");
1001
- }, v);
1002
- return () => clearInterval(u);
1003
- }, [p, v, d]);
1004
- const L = y((c) => d.find((u) => u.id === c), [d]), M = y(
1005
- (c) => d.filter((u) => u.competitorOne.id === c || u.competitorTwo.id === c),
1006
- [d]
1007
- ), R = y(
1008
- (c) => d.filter((u) => u.timing.kickoffTime.toISOString().startsWith(c)),
1009
- [d]
1010
- ), F = y(
1011
- (c) => d.filter((u) => u.round?.id === c),
1012
- [d]
1013
- ), j = y(() => d.filter((c) => c.status.code === "live"), [d]), Y = y(
1014
- (c) => {
1015
- const u = /* @__PURE__ */ new Date();
1016
- let f = d.filter((E) => E.status.code === "not_started" && E.timing.kickoffTime > u);
1017
- return c && (f = f.filter((E) => E.competitorOne.id === c || E.competitorTwo.id === c)), f.sort((E, K) => E.timing.kickoffTime.getTime() - K.timing.kickoffTime.getTime());
1018
- },
1019
- [d]
1020
- ), $ = y(
1021
- (c) => {
1022
- let u = d.filter((f) => f.status.code === "finished");
1023
- return c && (u = u.filter((f) => f.competitorOne.id === c || f.competitorTwo.id === c)), u.sort((f, E) => E.timing.kickoffTime.getTime() - f.timing.kickoffTime.getTime());
1024
- },
1025
- [d]
1026
- ), A = y(
1027
- (c) => S.find((u) => u.competitor.id === c),
1028
- [S]
1029
- ), U = y((c) => A(c)?.form?.formString, [A]), W = y((c) => A(c)?.stats, [A]), G = y(
1030
- (c) => [...S].sort((u, f) => u.rank - f.rank).slice(0, c),
1031
- [S]
1032
- ), C = y(
1033
- (c) => [...S].sort((u, f) => f.rank - u.rank).slice(0, c),
1034
- [S]
1035
- ), H = y(
1036
- (c) => s?.find((u) => u.id === c)?.matches,
1037
- [s]
1038
- ), B = y(
1039
- (c) => s?.find((u) => u.id === c)?.standings,
1040
- [s]
1041
- ), P = he(
1042
- () => ({
1043
- // Core identifiers
1044
- competitionId: e,
1045
- seasonId: t,
1046
- stageId: n,
1047
- // Core data
1048
- matches: d,
1049
- standings: S,
1050
- // Historical data
1051
- previousSeasons: s,
1052
- // Custom configuration
1053
- config: m,
1054
- // Match helpers
1055
- getMatch: L,
1056
- getMatchesByTeam: M,
1057
- getMatchesByDate: R,
1058
- getMatchesByRound: F,
1059
- getLiveMatches: j,
1060
- getUpcomingMatches: Y,
1061
- getFinishedMatches: $,
1062
- // Standings helpers
1063
- getTeamStanding: A,
1064
- getTeamForm: U,
1065
- getTeamStats: W,
1066
- getTopTeams: G,
1067
- getBottomTeams: C,
1068
- // Historical helpers
1069
- getSeasonMatches: H,
1070
- getSeasonStandings: B
1071
- }),
1072
- [
1073
- e,
1074
- t,
1075
- n,
1076
- d,
1077
- S,
1078
- s,
1079
- m,
1080
- L,
1081
- M,
1082
- R,
1083
- F,
1084
- j,
1085
- Y,
1086
- $,
1087
- A,
1088
- U,
1089
- W,
1090
- G,
1091
- C,
1092
- H,
1093
- B
1094
- ]
1095
- );
1096
- return /* @__PURE__ */ Qe.jsx(fe.Provider, { value: P, children: k });
47
+ function p(t, o) {
48
+ const s = /* @__PURE__ */ new Date(), n = o.filter((e) => {
49
+ const a = e.competitorOne.id === t || e.competitorTwo.id === t, i = e.status.type === "FINISHED", c = new Date(e.timing.kickoffTime) <= s;
50
+ return a && i && c;
51
+ });
52
+ return n.sort((e, a) => new Date(a.timing.kickoffTime).getTime() - new Date(e.timing.kickoffTime).getTime()), n[0];
1097
53
  }
1098
- const ft = "0.0.2";
54
+ const T = "0.0.2";
1099
55
  export {
1100
- mt as CompetitionProvider,
1101
- T as getConfig,
1102
- ot as getFootballMatch,
1103
- it as getFootballMatchCommentary,
1104
- nt as getFootballMatchEvents,
1105
- rt as getFootballMatchLineups,
1106
- at as getFootballMatchOdds,
1107
- st as getFootballMatchStatistics,
1108
- ct as getFootballMatches,
1109
- lt as getFootballStandings,
1110
- ut as getFootballTeam,
1111
- tt as isConfigured,
1112
- et as setConfig,
1113
- dt as useCompetition,
1114
- ft as version
56
+ f as getActiveSeason,
57
+ g as getConfig,
58
+ k as getFootballCompetition,
59
+ b as getFootballMatch,
60
+ F as getFootballMatchCommentary,
61
+ v as getFootballMatchEvents,
62
+ M as getFootballMatchLineups,
63
+ D as getFootballMatchOdds,
64
+ S as getFootballMatchStatistics,
65
+ _ as getFootballMatches,
66
+ C as getFootballSeasonDetails,
67
+ x as getFootballStandings,
68
+ m as getFootballTeam,
69
+ d as getTeamNextMatch,
70
+ p as getTeamPreviousMatch,
71
+ E as isConfigured,
72
+ L as setConfig,
73
+ T as version
1115
74
  };