fansunited-data-layer 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/api/fansunited/index.d.ts +2 -0
  2. package/api/fansunited/index.d.ts.map +1 -1
  3. package/api/fansunited/search/__tests__/index.test.d.ts +2 -0
  4. package/api/fansunited/search/__tests__/index.test.d.ts.map +1 -0
  5. package/api/fansunited/search/__tests__/transformer.test.d.ts +2 -0
  6. package/api/fansunited/search/__tests__/transformer.test.d.ts.map +1 -0
  7. package/api/fansunited/search/constants.d.ts +2 -0
  8. package/api/fansunited/search/constants.d.ts.map +1 -0
  9. package/api/fansunited/search/http.d.ts +5 -0
  10. package/api/fansunited/search/http.d.ts.map +1 -0
  11. package/api/fansunited/search/index.d.ts +50 -0
  12. package/api/fansunited/search/index.d.ts.map +1 -0
  13. package/api/fansunited/search/raw-types.d.ts +93 -0
  14. package/api/fansunited/search/raw-types.d.ts.map +1 -0
  15. package/api/fansunited/search/transformer.d.ts +66 -0
  16. package/api/fansunited/search/transformer.d.ts.map +1 -0
  17. package/api/fansunited/search/types.d.ts +136 -0
  18. package/api/fansunited/search/types.d.ts.map +1 -0
  19. package/cache/__tests__/cache-manager.test.d.ts +2 -0
  20. package/cache/__tests__/cache-manager.test.d.ts.map +1 -0
  21. package/cache/__tests__/cleanup.test.d.ts +2 -0
  22. package/cache/__tests__/cleanup.test.d.ts.map +1 -0
  23. package/cache/__tests__/memory-store.test.d.ts +2 -0
  24. package/cache/__tests__/memory-store.test.d.ts.map +1 -0
  25. package/cache/__tests__/sqlite-store.test.d.ts +2 -0
  26. package/cache/__tests__/sqlite-store.test.d.ts.map +1 -0
  27. package/cache/cache-manager.d.ts +42 -0
  28. package/cache/cache-manager.d.ts.map +1 -0
  29. package/cache/cleanup.d.ts +7 -0
  30. package/cache/cleanup.d.ts.map +1 -0
  31. package/cache/index.d.ts +13 -0
  32. package/cache/index.d.ts.map +1 -0
  33. package/cache/memory-store.d.ts +12 -0
  34. package/cache/memory-store.d.ts.map +1 -0
  35. package/cache/sqlite-store.d.ts +19 -0
  36. package/cache/sqlite-store.d.ts.map +1 -0
  37. package/cache/types.d.ts +15 -0
  38. package/cache/types.d.ts.map +1 -0
  39. package/client.js +2 -2
  40. package/config/types.d.ts +2 -0
  41. package/config/types.d.ts.map +1 -1
  42. package/fansunited-data-layer.cjs +1 -1
  43. package/fansunited-data-layer.js +2600 -1462
  44. package/index.d.ts +5 -3
  45. package/index.d.ts.map +1 -1
  46. package/{matches-CIte0UPI.js → matches-dKvggZia.js} +21 -21
  47. package/package.json +11 -3
  48. package/types/canonical/base.types.d.ts +28 -2
  49. package/types/canonical/base.types.d.ts.map +1 -1
  50. package/types/canonical/index.d.ts +1 -1
  51. package/types/canonical/index.d.ts.map +1 -1
@@ -1,197 +1,197 @@
1
- import { t as v, g as A, f as ae, c as b, S as re, a as ee, b as ce, d as le, e as de, h as ue, i as me, j as fe } from "./matches-CIte0UPI.js";
2
- import { k as Ho, l as Uo, m as bo, n as ko, o as Bo, p as $o, q as xo, r as Wo, s as Yo, u as Qo, v as qo, w as Vo, x as jo, y as Ko, z as zo, A as Xo, B as Jo, C as Zo, D as wo, E as en, F as tn, G as on } from "./matches-CIte0UPI.js";
3
- import { useMemo as G } from "react";
4
- function pe(e) {
1
+ import { t as L, g as b, f as Qt, c as ot, S as Vt, a as It, b as Kt, d as Xt, e as Jt, h as Zt, i as wt, j as te, k as ee } from "./matches-dKvggZia.js";
2
+ import { l as Xo, m as Jo, n as Zo, o as wo, p as ts, q as es, r as ns, s as os, u as ss, v as is, w as rs, x as as, y as cs, z as ls, A as ds, B as us, C as fs, D as hs, E as ms, F as gs, G as ps } from "./matches-dKvggZia.js";
3
+ import { useMemo as j } from "react";
4
+ function ne(t) {
5
5
  return {
6
6
  entityType: "tournament",
7
- id: e.id.toString(),
8
- name: e.name,
9
- slug: e.slug,
10
- gender: e.gender,
11
- type: e.type,
12
- region: e.region,
7
+ id: t.id.toString(),
8
+ name: t.name,
9
+ slug: t.slug,
10
+ gender: t.gender,
11
+ type: t.type,
12
+ region: t.region,
13
13
  country: {
14
- id: e.country.id.toString(),
15
- name: e.country.name,
14
+ id: t.country.id.toString(),
15
+ name: t.country.name,
16
16
  code: void 0,
17
- flag: e.country.url_flag ?? void 0,
18
- providerRef: v(e.country.uuid)
17
+ flag: t.country.url_flag ?? void 0,
18
+ providerRef: L(t.country.uuid)
19
19
  },
20
- assets: e.url_logo ? {
21
- logo: e.url_logo
20
+ assets: t.url_logo ? {
21
+ logo: t.url_logo
22
22
  } : void 0,
23
- providerRef: v(e.uuid)
23
+ providerRef: L(t.uuid)
24
24
  };
25
25
  }
26
- function ge(e) {
26
+ function oe(t) {
27
27
  return {
28
28
  entityType: "player",
29
- id: e.id.toString(),
30
- name: e.name,
31
- slug: e.slug,
32
- position: e.position,
33
- gender: e.gender,
34
- birthdate: e.birthdate,
29
+ id: t.id.toString(),
30
+ name: t.name,
31
+ slug: t.slug,
32
+ position: t.position,
33
+ gender: t.gender,
34
+ birthdate: t.birthdate,
35
35
  country: {
36
- id: e.country.id.toString(),
37
- name: e.country.name,
36
+ id: t.country.id.toString(),
37
+ name: t.country.name,
38
38
  code: void 0,
39
- flag: e.country.url_flag ?? void 0,
40
- providerRef: v(e.country.uuid)
39
+ flag: t.country.url_flag ?? void 0,
40
+ providerRef: L(t.country.uuid)
41
41
  },
42
- assets: e.url_thumb ? {
43
- photo: e.url_thumb
42
+ assets: t.url_thumb ? {
43
+ photo: t.url_thumb
44
44
  } : void 0,
45
- providerRef: v(e.uuid)
45
+ providerRef: L(t.uuid)
46
46
  };
47
47
  }
48
- function ye(e) {
48
+ function se(t) {
49
49
  return {
50
50
  entityType: "team",
51
- id: e.id.toString(),
52
- name: e.name,
53
- slug: e.slug,
54
- shortName: e.short_name ?? void 0,
55
- threeLetterCode: e.three_letter_code ?? void 0,
56
- type: e.type === "national" ? "national" : "club",
57
- gender: e.gender,
51
+ id: t.id.toString(),
52
+ name: t.name,
53
+ slug: t.slug,
54
+ shortName: t.short_name ?? void 0,
55
+ threeLetterCode: t.three_letter_code ?? void 0,
56
+ type: t.type === "national" ? "national" : "club",
57
+ gender: t.gender,
58
58
  country: {
59
- id: e.country.id.toString(),
60
- name: e.country.name,
59
+ id: t.country.id.toString(),
60
+ name: t.country.name,
61
61
  code: void 0,
62
- flag: e.country.url_flag ?? void 0,
63
- providerRef: v(e.country.uuid)
62
+ flag: t.country.url_flag ?? void 0,
63
+ providerRef: L(t.country.uuid)
64
64
  },
65
- assets: e.url_logo ? {
66
- logo: e.url_logo
65
+ assets: t.url_logo ? {
66
+ logo: t.url_logo
67
67
  } : void 0,
68
- providerRef: v(e.uuid)
68
+ providerRef: L(t.uuid)
69
69
  };
70
70
  }
71
- function he(e) {
71
+ function ie(t) {
72
72
  return {
73
73
  entityType: "president",
74
- id: e.id.toString(),
75
- name: e.name,
76
- slug: e.slug,
77
- birthdate: e.birthdate ?? void 0,
74
+ id: t.id.toString(),
75
+ name: t.name,
76
+ slug: t.slug,
77
+ birthdate: t.birthdate ?? void 0,
78
78
  country: {
79
- id: e.country.id.toString(),
80
- name: e.country.name,
79
+ id: t.country.id.toString(),
80
+ name: t.country.name,
81
81
  code: void 0,
82
- flag: e.country.url_flag ?? void 0,
83
- providerRef: v(e.country.uuid)
82
+ flag: t.country.url_flag ?? void 0,
83
+ providerRef: L(t.country.uuid)
84
84
  },
85
- assets: e.url_thumb ? {
86
- photo: e.url_thumb
85
+ assets: t.url_thumb ? {
86
+ photo: t.url_thumb
87
87
  } : void 0,
88
- providerRef: v(e.uuid)
88
+ providerRef: L(t.uuid)
89
89
  };
90
90
  }
91
- function Te(e) {
91
+ function re(t) {
92
92
  return {
93
93
  entityType: "venue",
94
- id: e.id.toString(),
95
- name: e.name,
96
- slug: e.slug,
94
+ id: t.id.toString(),
95
+ name: t.name,
96
+ slug: t.slug,
97
97
  city: {
98
- id: e.city.id.toString(),
99
- name: e.city.name,
98
+ id: t.city.id.toString(),
99
+ name: t.city.name,
100
100
  country: {
101
- id: e.city.country.id.toString(),
102
- name: e.city.country.name,
101
+ id: t.city.country.id.toString(),
102
+ name: t.city.country.name,
103
103
  code: void 0,
104
- flag: e.city.country.url_flag ?? void 0,
105
- providerRef: v(e.city.country.uuid)
104
+ flag: t.city.country.url_flag ?? void 0,
105
+ providerRef: L(t.city.country.uuid)
106
106
  },
107
- providerRef: v(e.city.uuid)
107
+ providerRef: L(t.city.uuid)
108
108
  },
109
109
  country: {
110
- id: e.country.id.toString(),
111
- name: e.country.name,
110
+ id: t.country.id.toString(),
111
+ name: t.country.name,
112
112
  code: void 0,
113
- flag: e.country.url_flag ?? void 0,
114
- providerRef: v(e.country.uuid)
113
+ flag: t.country.url_flag ?? void 0,
114
+ providerRef: L(t.country.uuid)
115
115
  },
116
116
  profile: {
117
- latitude: e.profile.lat,
118
- longitude: e.profile.lng,
119
- capacity: e.profile.capacity
117
+ latitude: t.profile.lat,
118
+ longitude: t.profile.lng,
119
+ capacity: t.profile.capacity
120
120
  },
121
- assets: e.url_thumb ? {
122
- image: e.url_thumb
121
+ assets: t.url_thumb ? {
122
+ image: t.url_thumb
123
123
  } : void 0,
124
- providerRef: v(e.uuid)
124
+ providerRef: L(t.uuid)
125
125
  };
126
126
  }
127
- function _e(e) {
127
+ function ae(t) {
128
128
  return {
129
129
  entityType: "coach",
130
- id: e.id.toString(),
131
- name: e.name,
132
- slug: e.slug,
133
- birthdate: e.birthdate ?? void 0,
130
+ id: t.id.toString(),
131
+ name: t.name,
132
+ slug: t.slug,
133
+ birthdate: t.birthdate ?? void 0,
134
134
  country: {
135
- id: e.country.id.toString(),
136
- name: e.country.name,
135
+ id: t.country.id.toString(),
136
+ name: t.country.name,
137
137
  code: void 0,
138
- flag: e.country.url_flag ?? void 0,
139
- providerRef: v(e.country.uuid)
138
+ flag: t.country.url_flag ?? void 0,
139
+ providerRef: L(t.country.uuid)
140
140
  },
141
- assets: e.url_thumb ? {
142
- photo: e.url_thumb
141
+ assets: t.url_thumb ? {
142
+ photo: t.url_thumb
143
143
  } : void 0,
144
- providerRef: v(e.uuid)
144
+ providerRef: L(t.uuid)
145
145
  };
146
146
  }
147
- function ve(e) {
148
- switch (e.entity_type) {
147
+ function ce(t) {
148
+ switch (t.entity_type) {
149
149
  case "tournament":
150
- return pe(e);
150
+ return ne(t);
151
151
  case "player":
152
- return ge(e);
152
+ return oe(t);
153
153
  case "team":
154
- return ye(e);
154
+ return se(t);
155
155
  case "president":
156
- return he(e);
156
+ return ie(t);
157
157
  case "venue":
158
- return Te(e);
158
+ return re(t);
159
159
  case "coach":
160
- return _e(e);
160
+ return ae(t);
161
161
  default:
162
- throw new Error(`Unknown entity type: ${e.entity_type}`);
162
+ throw new Error(`Unknown entity type: ${t.entity_type}`);
163
163
  }
164
164
  }
165
- async function kt(e, t) {
166
- if (!e.query || e.query.trim() === "")
165
+ async function zn(t, e) {
166
+ if (!t.query || t.query.trim() === "")
167
167
  return {
168
168
  results: [],
169
- query: e.query || ""
169
+ query: t.query || ""
170
170
  };
171
- const o = t || A(), { sportal365Sports: n } = o, s = e.entityTypes && e.entityTypes.length > 0 ? e.entityTypes : ["tournament", "player", "team", "president", "venue", "coach"], i = await ae.get({
171
+ const n = e || b(), { sportal365Sports: o } = n, s = t.entityTypes && t.entityTypes.length > 0 ? t.entityTypes : ["tournament", "player", "team", "president", "venue", "coach"], i = await Qt.get({
172
172
  path: "/search",
173
173
  params: {
174
- query: e.query.trim(),
174
+ query: t.query.trim(),
175
175
  entity_type: s.join(","),
176
- language_code: e.languageCode ?? n?.languageCode ?? "en"
176
+ language_code: t.languageCode ?? o?.languageCode ?? "en"
177
177
  },
178
178
  headers: {
179
- "Accept-Language": e.languageCode ?? n?.languageCode ?? "en"
179
+ "Accept-Language": t.languageCode ?? o?.languageCode ?? "en"
180
180
  },
181
- next: e.next,
182
- config: o
181
+ next: t.next,
182
+ config: n
183
183
  });
184
184
  return !i || i.length === 0 ? {
185
185
  results: [],
186
- query: e.query
186
+ query: t.query
187
187
  } : {
188
- results: i.map(ve),
189
- query: e.query
188
+ results: i.map(ce),
189
+ query: t.query
190
190
  };
191
191
  }
192
- const Ae = b(re);
193
- function Se(e) {
194
- const t = {
192
+ const le = ot(Vt);
193
+ function de(t) {
194
+ const e = {
195
195
  FINISHED: "finished",
196
196
  NOT_STARTED: "not_started",
197
197
  LIVE: "live",
@@ -199,606 +199,606 @@ function Se(e) {
199
199
  CANCELLED: "cancelled",
200
200
  POSTPONED: "postponed",
201
201
  UNKNOWN: "not_started"
202
- }, o = e.type.toUpperCase();
202
+ }, n = t.type.toUpperCase();
203
203
  return {
204
- code: t[o] ?? "not_started",
205
- name: e.name,
206
- shortName: e.short_name,
207
- type: o
204
+ code: e[n] ?? "not_started",
205
+ name: t.name,
206
+ shortName: t.short_name,
207
+ type: n
208
208
  };
209
209
  }
210
- function X(e) {
210
+ function Ot(t) {
211
211
  return {
212
- id: e.id,
213
- name: e.name,
214
- threeLetterCode: e.three_letter_code,
215
- slug: e.slug,
216
- type: e.type === "national" ? "national" : "club",
217
- gender: e.gender
212
+ id: t.id,
213
+ name: t.name,
214
+ threeLetterCode: t.three_letter_code,
215
+ slug: t.slug,
216
+ type: t.type === "national" ? "national" : "club",
217
+ gender: t.gender
218
218
  };
219
219
  }
220
- function Ce(e) {
220
+ function ue(t) {
221
221
  return {
222
- kickoffTime: new Date(e.game_time),
223
- currentMinute: e.minute
222
+ kickoffTime: new Date(t.game_time),
223
+ currentMinute: t.minute
224
224
  };
225
225
  }
226
- function Oe(e) {
227
- if (!e.season?.competition) return;
228
- const t = e.season.competition;
226
+ function fe(t) {
227
+ if (!t.season?.competition) return;
228
+ const e = t.season.competition;
229
229
  return {
230
- id: t.id,
231
- name: t.name,
232
- slug: t.slug,
230
+ id: e.id,
231
+ name: e.name,
232
+ slug: e.slug,
233
233
  type: "LEAGUE",
234
- gender: t.gender,
235
- region: t.region,
236
- country: t.country ? {
237
- id: t.country.id,
238
- name: t.country.name
234
+ gender: e.gender,
235
+ region: e.region,
236
+ country: e.country ? {
237
+ id: e.country.id,
238
+ name: e.country.name
239
239
  } : void 0,
240
240
  season: {
241
- id: e.season.id,
242
- name: e.season.name,
243
- status: e.season.status
241
+ id: t.season.id,
242
+ name: t.season.name,
243
+ status: t.season.status
244
244
  },
245
- stage: e.stage ? {
246
- id: e.stage.id,
247
- name: e.stage.name,
248
- type: e.stage.type
245
+ stage: t.stage ? {
246
+ id: t.stage.id,
247
+ name: t.stage.name,
248
+ type: t.stage.type
249
249
  } : void 0
250
250
  };
251
251
  }
252
- function Le(e) {
253
- if (e)
252
+ function he(t) {
253
+ if (t)
254
254
  return {
255
- id: e.id,
256
- name: e.name,
257
- slug: e.slug
255
+ id: t.id,
256
+ name: t.name,
257
+ slug: t.slug
258
258
  };
259
259
  }
260
- function Ee(e) {
261
- if (!e || e.length === 0) return;
262
- const t = e.filter((i) => i.result_type.category === "single_period");
263
- if (t.length === 0) return;
264
- let o = 0, n = 0;
260
+ function me(t) {
261
+ if (!t || t.length === 0) return;
262
+ const e = t.filter((i) => i.result_type.category === "single_period");
263
+ if (e.length === 0) return;
264
+ let n = 0, o = 0;
265
265
  const s = [];
266
- for (const i of t)
267
- o += i.home, n += i.away, s.push({
266
+ for (const i of e)
267
+ n += i.home, o += i.away, s.push({
268
268
  competitorOne: String(i.home),
269
269
  competitorTwo: String(i.away)
270
270
  });
271
271
  return {
272
- competitorOne: String(o),
273
- competitorTwo: String(n),
272
+ competitorOne: String(n),
273
+ competitorTwo: String(o),
274
274
  breakdown: {
275
275
  total: {
276
- competitorOne: String(o),
277
- competitorTwo: String(n)
276
+ competitorOne: String(n),
277
+ competitorTwo: String(o)
278
278
  },
279
279
  periods: s
280
280
  }
281
281
  };
282
282
  }
283
- function Fe(e) {
284
- if (e.winner)
283
+ function ge(t) {
284
+ if (t.winner)
285
285
  return {
286
- competitorId: e.winner.id
286
+ competitorId: t.winner.id
287
287
  };
288
288
  }
289
- function Ne(e) {
289
+ function pe(t) {
290
290
  return {
291
- id: e.id,
292
- slug: e.slug,
293
- status: Se(e.status),
294
- timing: Ce(e),
295
- competitorOne: X(e.home_team),
296
- competitorTwo: X(e.away_team),
297
- competition: Oe(e),
298
- round: e.round ? {
299
- id: e.round.id,
300
- key: e.round.uuid,
301
- name: e.round.name,
291
+ id: t.id,
292
+ slug: t.slug,
293
+ status: de(t.status),
294
+ timing: ue(t),
295
+ competitorOne: Ot(t.home_team),
296
+ competitorTwo: Ot(t.away_team),
297
+ competition: fe(t),
298
+ round: t.round ? {
299
+ id: t.round.id,
300
+ key: t.round.uuid,
301
+ name: t.round.name,
302
302
  type: "REGULAR",
303
- providerRef: v(e.round.uuid)
303
+ providerRef: L(t.round.uuid)
304
304
  } : void 0,
305
- venue: Le(e.arena),
306
- score: Ee(e.score),
307
- winner: Fe(e),
308
- odds: e.odds ? ee(e.odds) : void 0,
309
- coverage: e.coverage === "NOT_LIVE" ? "UNKNOWN" : e.coverage,
305
+ venue: he(t.arena),
306
+ score: me(t.score),
307
+ winner: ge(t),
308
+ odds: t.odds ? It(t.odds) : void 0,
309
+ coverage: t.coverage === "NOT_LIVE" ? "UNKNOWN" : t.coverage,
310
310
  providerRef: [
311
311
  {
312
312
  provider: "sportal365-basketball",
313
- id: e.id
313
+ id: t.id
314
314
  }
315
315
  ]
316
316
  };
317
317
  }
318
- async function Bt(e, t) {
319
- const o = t || A(), { sportal365Sports: n } = o;
320
- return (await Ae.get({
318
+ async function Yn(t, e) {
319
+ const n = e || b(), { sportal365Sports: o } = n;
320
+ return (await le.get({
321
321
  path: "/games",
322
322
  params: {
323
323
  offset: "0",
324
324
  limit: "1000",
325
- competition_list: e?.competitionList,
326
- status_type: e?.statusTypes,
327
- from_game_time: e?.fromGameTime,
328
- to_game_time: e?.toGameTime,
329
- odd_client: e?.oddClient ?? n?.oddClient,
330
- odd_type: e?.oddType,
331
- market_types: e?.marketTypes,
332
- language_code: e?.languageCode ?? n?.languageCode ?? "en"
325
+ competition_list: t?.competitionList,
326
+ status_type: t?.statusTypes,
327
+ from_game_time: t?.fromGameTime,
328
+ to_game_time: t?.toGameTime,
329
+ odd_client: t?.oddClient ?? o?.oddClient,
330
+ odd_type: t?.oddType,
331
+ market_types: t?.marketTypes,
332
+ language_code: t?.languageCode ?? o?.languageCode ?? "en"
333
333
  },
334
334
  headers: {
335
- "Accept-Language": e?.languageCode ?? n?.languageCode ?? "en"
335
+ "Accept-Language": t?.languageCode ?? o?.languageCode ?? "en"
336
336
  },
337
- next: e?.next,
338
- config: o
339
- })).games.map(Ne);
337
+ next: t?.next,
338
+ config: n
339
+ })).games.map(pe);
340
340
  }
341
- const Pe = b(ce);
342
- function Ie(e) {
343
- const t = {
341
+ const ye = ot(Kt);
342
+ function Te(t) {
343
+ const e = {
344
344
  FINISHED: "finished",
345
345
  NOT_STARTED: "not_started",
346
346
  LIVE: "live",
347
347
  INTERRUPTED: "interrupted",
348
348
  CANCELLED: "cancelled",
349
349
  POSTPONED: "postponed"
350
- }, o = e.type.toUpperCase();
350
+ }, n = t.type.toUpperCase();
351
351
  return {
352
- code: t[o] ?? "not_started",
353
- name: e.name,
354
- shortName: e.short_name,
355
- type: o
352
+ code: e[n] ?? "not_started",
353
+ name: t.name,
354
+ shortName: t.short_name,
355
+ type: n
356
356
  };
357
357
  }
358
- function J(e) {
359
- if (e.type === "PLAYER")
358
+ function Et(t) {
359
+ if (t.type === "PLAYER")
360
360
  return {
361
- id: e.id,
362
- name: e.name,
363
- shortName: e.short_name,
364
- threeLetterCode: e.three_letter_code,
361
+ id: t.id,
362
+ name: t.name,
363
+ shortName: t.short_name,
364
+ threeLetterCode: t.three_letter_code,
365
365
  type: "player",
366
- country: e.details?.[0]?.country ? {
367
- id: e.details[0].country.id,
368
- name: e.details[0].country.name
366
+ country: t.details?.[0]?.country ? {
367
+ id: t.details[0].country.id,
368
+ name: t.details[0].country.name
369
369
  } : void 0,
370
- gender: e.details?.[0]?.gender
370
+ gender: t.details?.[0]?.gender
371
371
  };
372
- if (e.type === "TEAM_DOUBLE" && e.details && e.details.length === 2) {
373
- const t = {
374
- id: e.details[0].id,
375
- name: e.details[0].name,
376
- shortName: e.details[0].short_name,
377
- threeLetterCode: e.details[0].three_letter_code,
372
+ if (t.type === "TEAM_DOUBLE" && t.details && t.details.length === 2) {
373
+ const e = {
374
+ id: t.details[0].id,
375
+ name: t.details[0].name,
376
+ shortName: t.details[0].short_name,
377
+ threeLetterCode: t.details[0].three_letter_code,
378
378
  type: "player",
379
- country: e.details[0].country ? {
380
- id: e.details[0].country.id,
381
- name: e.details[0].country.name
379
+ country: t.details[0].country ? {
380
+ id: t.details[0].country.id,
381
+ name: t.details[0].country.name
382
382
  } : void 0,
383
- gender: e.details[0].gender
384
- }, o = {
385
- id: e.details[1].id,
386
- name: e.details[1].name,
387
- shortName: e.details[1].short_name,
388
- threeLetterCode: e.details[1].three_letter_code,
383
+ gender: t.details[0].gender
384
+ }, n = {
385
+ id: t.details[1].id,
386
+ name: t.details[1].name,
387
+ shortName: t.details[1].short_name,
388
+ threeLetterCode: t.details[1].three_letter_code,
389
389
  type: "player",
390
- country: e.details[1].country ? {
391
- id: e.details[1].country.id,
392
- name: e.details[1].country.name
390
+ country: t.details[1].country ? {
391
+ id: t.details[1].country.id,
392
+ name: t.details[1].country.name
393
393
  } : void 0,
394
- gender: e.details[1].gender
394
+ gender: t.details[1].gender
395
395
  };
396
396
  return {
397
- id: e.id,
398
- name: e.name,
399
- shortName: e.short_name,
400
- threeLetterCode: e.three_letter_code,
397
+ id: t.id,
398
+ name: t.name,
399
+ shortName: t.short_name,
400
+ threeLetterCode: t.three_letter_code,
401
401
  type: "pair",
402
- players: [t, o]
402
+ players: [e, n]
403
403
  };
404
404
  } else
405
405
  return {
406
- id: e.id,
407
- name: e.name,
408
- shortName: e.short_name,
409
- threeLetterCode: e.three_letter_code,
406
+ id: t.id,
407
+ name: t.name,
408
+ shortName: t.short_name,
409
+ threeLetterCode: t.three_letter_code,
410
410
  type: "national",
411
- country: e.details?.[0]?.country ? {
412
- id: e.details[0].country.id,
413
- name: e.details[0].country.name
411
+ country: t.details?.[0]?.country ? {
412
+ id: t.details[0].country.id,
413
+ name: t.details[0].country.name
414
414
  } : void 0,
415
- gender: e.details?.[0]?.gender
415
+ gender: t.details?.[0]?.gender
416
416
  };
417
417
  }
418
- function Re(e) {
418
+ function _e(t) {
419
419
  return {
420
- kickoffTime: new Date(e.scheduled_start_time),
421
- phaseStartedAt: e.started_at ? new Date(e.started_at) : void 0,
422
- finishedAt: e.finished_at ? new Date(e.finished_at) : void 0
420
+ kickoffTime: new Date(t.scheduled_start_time),
421
+ phaseStartedAt: t.started_at ? new Date(t.started_at) : void 0,
422
+ finishedAt: t.finished_at ? new Date(t.finished_at) : void 0
423
423
  };
424
424
  }
425
- function Me(e) {
426
- if (!e.tournament) return;
427
- const t = e.tournament;
425
+ function ve(t) {
426
+ if (!t.tournament) return;
427
+ const e = t.tournament;
428
428
  return {
429
- id: t.competition?.id ?? t.id,
430
- name: t.competition?.name ?? t.name,
431
- slug: t.competition?.slug ?? t.slug,
429
+ id: e.competition?.id ?? e.id,
430
+ name: e.competition?.name ?? e.name,
431
+ slug: e.competition?.slug ?? e.slug,
432
432
  type: "TOURNAMENT",
433
- gender: t.gender,
433
+ gender: e.gender,
434
434
  region: "INTERNATIONAL",
435
- country: t.country ? {
436
- id: t.country.id,
437
- name: t.country.name
435
+ country: e.country ? {
436
+ id: e.country.id,
437
+ name: e.country.name
438
438
  } : void 0
439
439
  };
440
440
  }
441
- function Ge(e) {
442
- if (!e.results || e.results.length === 0) return;
443
- const t = e.results.filter((c) => /^set\d+$/i.test(c.type.code));
444
- if (t.length === 0) return;
445
- const o = [];
446
- for (const c of t) {
447
- const d = c.values.find((l) => l.position === "1"), u = c.values.find((l) => l.position === "2");
448
- !d || !u || d.value == null || u.value == null || o.push({
441
+ function Se(t) {
442
+ if (!t.results || t.results.length === 0) return;
443
+ const e = t.results.filter((c) => /^set\d+$/i.test(c.type.code));
444
+ if (e.length === 0) return;
445
+ const n = [];
446
+ for (const c of e) {
447
+ const d = c.values.find((l) => l.position === "1"), f = c.values.find((l) => l.position === "2");
448
+ !d || !f || d.value == null || f.value == null || n.push({
449
449
  competitorOne: d.value,
450
- competitorTwo: u.value
450
+ competitorTwo: f.value
451
451
  });
452
452
  }
453
- if (o.length === 0) return;
454
- const n = e.results.find((c) => c.type.code === "setswon"), s = n?.values.find((c) => c.position === "1"), i = n?.values.find((c) => c.position === "2");
455
- let a, r;
456
- return s?.value != null && i?.value != null ? (a = parseInt(s.value), r = parseInt(i.value)) : (a = o.filter((c) => parseInt(c.competitorOne) > parseInt(c.competitorTwo)).length, r = o.filter((c) => parseInt(c.competitorTwo) > parseInt(c.competitorOne)).length), {
457
- competitorOne: String(a),
458
- competitorTwo: String(r),
453
+ if (n.length === 0) return;
454
+ const o = t.results.find((c) => c.type.code === "setswon"), s = o?.values.find((c) => c.position === "1"), i = o?.values.find((c) => c.position === "2");
455
+ let r, a;
456
+ return s?.value != null && i?.value != null ? (r = parseInt(s.value), a = parseInt(i.value)) : (r = n.filter((c) => parseInt(c.competitorOne) > parseInt(c.competitorTwo)).length, a = n.filter((c) => parseInt(c.competitorTwo) > parseInt(c.competitorOne)).length), {
457
+ competitorOne: String(r),
458
+ competitorTwo: String(a),
459
459
  breakdown: {
460
460
  total: {
461
- competitorOne: String(a),
462
- competitorTwo: String(r)
461
+ competitorOne: String(r),
462
+ competitorTwo: String(a)
463
463
  },
464
- periods: o
464
+ periods: n
465
465
  }
466
466
  };
467
467
  }
468
- function De(e) {
469
- const t = e.participants.find((o) => o.winner === "YES");
470
- if (t)
468
+ function Ae(t) {
469
+ const e = t.participants.find((n) => n.winner === "YES");
470
+ if (e)
471
471
  return {
472
- competitorId: t.id
472
+ competitorId: e.id
473
473
  };
474
474
  }
475
- function He(e) {
476
- const t = e.participants.sort((o, n) => o.position - n.position);
475
+ function Ce(t) {
476
+ const e = t.participants.sort((n, o) => n.position - o.position);
477
477
  return {
478
- id: e.id,
479
- slug: e.slug,
480
- status: Ie(e.status),
481
- timing: Re(e),
482
- competitorOne: J(t[0]),
483
- competitorTwo: J(t[1]),
484
- competition: Me(e),
485
- round: e.round ? {
486
- id: e.round.id,
487
- key: e.round.uuid,
488
- name: e.round.name,
478
+ id: t.id,
479
+ slug: t.slug,
480
+ status: Te(t.status),
481
+ timing: _e(t),
482
+ competitorOne: Et(e[0]),
483
+ competitorTwo: Et(e[1]),
484
+ competition: ve(t),
485
+ round: t.round ? {
486
+ id: t.round.id,
487
+ key: t.round.uuid,
488
+ name: t.round.name,
489
489
  type: "REGULAR",
490
- providerRef: v(e.round.uuid)
490
+ providerRef: L(t.round.uuid)
491
491
  } : void 0,
492
- score: Ge(e),
493
- winner: De(e),
494
- odds: e.odds ? ee(e.odds) : void 0,
495
- coverage: e.coverage?.type === "NOT_LIVE" ? "UNKNOWN" : e.coverage?.type,
492
+ score: Se(t),
493
+ winner: Ae(t),
494
+ odds: t.odds ? It(t.odds) : void 0,
495
+ coverage: t.coverage?.type === "NOT_LIVE" ? "UNKNOWN" : t.coverage?.type,
496
496
  metadata: {
497
- matchType: e.type,
498
- bestOfSets: e.best_of_sets,
499
- surface: e.tournament?.surface,
500
- indoorOutdoor: e.tournament?.indoor_outdoor
497
+ matchType: t.type,
498
+ bestOfSets: t.best_of_sets,
499
+ surface: t.tournament?.surface,
500
+ indoorOutdoor: t.tournament?.indoor_outdoor
501
501
  },
502
502
  providerRef: [
503
503
  {
504
504
  provider: "sportal365-tennis",
505
- id: e.id
505
+ id: t.id
506
506
  }
507
507
  ]
508
508
  };
509
509
  }
510
- async function $t(e, t) {
511
- const o = t || A(), { sportal365Sports: n } = o;
512
- return (await Pe.get({
510
+ async function jn(t, e) {
511
+ const n = e || b(), { sportal365Sports: o } = n;
512
+ return (await ye.get({
513
513
  path: "/matches/livescore",
514
514
  params: {
515
- date: e?.date,
516
- utc_offset: e?.utcOffset?.toString(),
515
+ date: t?.date,
516
+ utc_offset: t?.utcOffset?.toString(),
517
517
  offset: "0",
518
518
  limit: "1000",
519
- type: e?.type,
520
- gender: e?.gender,
521
- status_type: e?.statusType,
522
- competition_list: e?.competitionList,
523
- odd_client: e?.oddClient ?? n?.oddClient,
524
- odd_type: e?.oddType,
525
- market_types: e?.marketTypes,
526
- language_code: e?.languageCode ?? n?.languageCode ?? "en"
519
+ type: t?.type,
520
+ gender: t?.gender,
521
+ status_type: t?.statusType,
522
+ competition_list: t?.competitionList,
523
+ odd_client: t?.oddClient ?? o?.oddClient,
524
+ odd_type: t?.oddType,
525
+ market_types: t?.marketTypes,
526
+ language_code: t?.languageCode ?? o?.languageCode ?? "en"
527
527
  },
528
528
  headers: {
529
- "Accept-Language": e?.languageCode ?? n?.languageCode ?? "en"
529
+ "Accept-Language": t?.languageCode ?? o?.languageCode ?? "en"
530
530
  },
531
- next: e?.next,
532
- config: o
533
- })).matches.map(He);
531
+ next: t?.next,
532
+ config: n
533
+ })).matches.map(Ce);
534
534
  }
535
- const Ue = b(le);
536
- function E(e) {
535
+ const Oe = ot(Xt);
536
+ function D(t) {
537
537
  return {
538
- language: e.language,
539
- name: e.name,
540
- shortName: e.short_name ?? void 0,
541
- threeLetterCode: e.three_letter_code ?? void 0
538
+ language: t.language,
539
+ name: t.name,
540
+ shortName: t.short_name ?? void 0,
541
+ threeLetterCode: t.three_letter_code ?? void 0
542
542
  };
543
543
  }
544
- function F(e) {
545
- if (!(!e || !e.url))
544
+ function U(t) {
545
+ if (!(!t || !t.url))
546
546
  return {
547
- url: e.url
547
+ url: t.url
548
548
  };
549
549
  }
550
- function M(e) {
551
- if (e)
550
+ function z(t) {
551
+ if (t)
552
552
  return {
553
- id: e.id,
554
- legacyId: e.legacy_id ?? void 0,
555
- name: e.name,
556
- shortName: e.short_name ?? void 0,
557
- threeLetterCode: e.three_letter_code ?? void 0,
558
- translations: e.translations.map(E),
559
- displayAsset: F(e.display_asset),
560
- slug: e.slug,
561
- providerRef: e.id
553
+ id: t.id,
554
+ legacyId: t.legacy_id ?? void 0,
555
+ name: t.name,
556
+ shortName: t.short_name ?? void 0,
557
+ threeLetterCode: t.three_letter_code ?? void 0,
558
+ translations: t.translations.map(D),
559
+ displayAsset: U(t.display_asset),
560
+ slug: t.slug,
561
+ providerRef: t.id
562
562
  };
563
563
  }
564
- function V(e) {
564
+ function yt(t) {
565
565
  return {
566
566
  entityType: "team",
567
- id: e.id,
568
- legacyId: e.legacy_id ?? void 0,
569
- name: e.name,
570
- shortName: e.short_name ?? void 0,
571
- threeLetterCode: e.three_letter_code ?? void 0,
572
- translations: e.translations.map(E),
573
- displayAsset: F(e.display_asset),
574
- slug: e.slug,
575
- tagScore: e.tag_score ?? void 0,
576
- sport: e.sport,
577
- country: M(e.country),
578
- gender: e.gender,
579
- competitionIds: e.competition_ids,
580
- type: e.type,
581
- national: e.national,
582
- undecided: e.undecided,
583
- providerRef: e.id
567
+ id: t.id,
568
+ legacyId: t.legacy_id ?? void 0,
569
+ name: t.name,
570
+ shortName: t.short_name ?? void 0,
571
+ threeLetterCode: t.three_letter_code ?? void 0,
572
+ translations: t.translations.map(D),
573
+ displayAsset: U(t.display_asset),
574
+ slug: t.slug,
575
+ tagScore: t.tag_score ?? void 0,
576
+ sport: t.sport,
577
+ country: z(t.country),
578
+ gender: t.gender,
579
+ competitionIds: t.competition_ids,
580
+ type: t.type,
581
+ national: t.national,
582
+ undecided: t.undecided,
583
+ providerRef: t.id
584
584
  };
585
585
  }
586
- function te(e) {
586
+ function Pt(t) {
587
587
  return {
588
588
  entityType: "city",
589
- id: e.id,
590
- legacyId: e.legacy_id ?? void 0,
591
- name: e.name,
592
- shortName: e.short_name ?? void 0,
593
- threeLetterCode: e.three_letter_code ?? void 0,
594
- translations: e.translations.map(E),
595
- displayAsset: F(e.display_asset),
596
- slug: e.slug,
597
- tagScore: e.tag_score ?? void 0,
598
- sport: e.sport,
599
- country: M(e.country),
600
- providerRef: e.id
589
+ id: t.id,
590
+ legacyId: t.legacy_id ?? void 0,
591
+ name: t.name,
592
+ shortName: t.short_name ?? void 0,
593
+ threeLetterCode: t.three_letter_code ?? void 0,
594
+ translations: t.translations.map(D),
595
+ displayAsset: U(t.display_asset),
596
+ slug: t.slug,
597
+ tagScore: t.tag_score ?? void 0,
598
+ sport: t.sport,
599
+ country: z(t.country),
600
+ providerRef: t.id
601
601
  };
602
602
  }
603
- function be(e) {
603
+ function Ee(t) {
604
604
  return {
605
605
  entityType: "horse",
606
- id: e.id,
607
- legacyId: e.legacy_id ?? void 0,
608
- name: e.name,
609
- shortName: e.short_name ?? void 0,
610
- threeLetterCode: e.three_letter_code ?? void 0,
611
- translations: e.translations.map(E),
612
- displayAsset: F(e.display_asset),
613
- slug: e.slug,
614
- tagScore: e.tag_score ?? void 0,
615
- sport: e.sport,
616
- country: M(e.country),
617
- gender: e.gender,
618
- providerRef: e.id
606
+ id: t.id,
607
+ legacyId: t.legacy_id ?? void 0,
608
+ name: t.name,
609
+ shortName: t.short_name ?? void 0,
610
+ threeLetterCode: t.three_letter_code ?? void 0,
611
+ translations: t.translations.map(D),
612
+ displayAsset: U(t.display_asset),
613
+ slug: t.slug,
614
+ tagScore: t.tag_score ?? void 0,
615
+ sport: t.sport,
616
+ country: z(t.country),
617
+ gender: t.gender,
618
+ providerRef: t.id
619
619
  };
620
620
  }
621
- function ke(e) {
621
+ function Fe(t) {
622
622
  return {
623
623
  entityType: "player",
624
- id: e.id,
625
- legacyId: e.legacy_id ?? void 0,
626
- name: e.name,
627
- shortName: e.short_name ?? void 0,
628
- threeLetterCode: e.three_letter_code ?? void 0,
629
- translations: e.translations.map(E),
630
- displayAsset: F(e.display_asset),
631
- slug: e.slug,
632
- tagScore: e.tag_score ?? void 0,
633
- sport: e.sport,
634
- country: M(e.country),
635
- gender: e.gender,
636
- birthdate: e.birthdate ?? void 0,
637
- position: e.position ?? void 0,
638
- providerRef: e.id
624
+ id: t.id,
625
+ legacyId: t.legacy_id ?? void 0,
626
+ name: t.name,
627
+ shortName: t.short_name ?? void 0,
628
+ threeLetterCode: t.three_letter_code ?? void 0,
629
+ translations: t.translations.map(D),
630
+ displayAsset: U(t.display_asset),
631
+ slug: t.slug,
632
+ tagScore: t.tag_score ?? void 0,
633
+ sport: t.sport,
634
+ country: z(t.country),
635
+ gender: t.gender,
636
+ birthdate: t.birthdate ?? void 0,
637
+ position: t.position ?? void 0,
638
+ providerRef: t.id
639
639
  };
640
640
  }
641
- function Be(e) {
641
+ function Le(t) {
642
642
  return {
643
643
  entityType: "coach",
644
- id: e.id,
645
- legacyId: e.legacy_id ?? void 0,
646
- name: e.name,
647
- shortName: e.short_name ?? void 0,
648
- threeLetterCode: e.three_letter_code ?? void 0,
649
- translations: e.translations.map(E),
650
- displayAsset: F(e.display_asset),
651
- slug: e.slug,
652
- tagScore: e.tag_score ?? void 0,
653
- sport: e.sport,
654
- country: M(e.country),
655
- gender: e.gender,
656
- birthdate: e.birthdate ?? void 0,
657
- providerRef: e.id
644
+ id: t.id,
645
+ legacyId: t.legacy_id ?? void 0,
646
+ name: t.name,
647
+ shortName: t.short_name ?? void 0,
648
+ threeLetterCode: t.three_letter_code ?? void 0,
649
+ translations: t.translations.map(D),
650
+ displayAsset: U(t.display_asset),
651
+ slug: t.slug,
652
+ tagScore: t.tag_score ?? void 0,
653
+ sport: t.sport,
654
+ country: z(t.country),
655
+ gender: t.gender,
656
+ birthdate: t.birthdate ?? void 0,
657
+ providerRef: t.id
658
658
  };
659
659
  }
660
- function $e(e) {
660
+ function be(t) {
661
661
  return {
662
662
  entityType: "referee",
663
- id: e.id,
664
- legacyId: e.legacy_id ?? void 0,
665
- name: e.name,
666
- shortName: e.short_name ?? void 0,
667
- threeLetterCode: e.three_letter_code ?? void 0,
668
- translations: e.translations.map(E),
669
- displayAsset: F(e.display_asset),
670
- slug: e.slug,
671
- tagScore: e.tag_score ?? void 0,
672
- sport: e.sport,
673
- country: M(e.country),
674
- gender: e.gender,
675
- birthdate: e.birthdate ?? void 0,
676
- providerRef: e.id
663
+ id: t.id,
664
+ legacyId: t.legacy_id ?? void 0,
665
+ name: t.name,
666
+ shortName: t.short_name ?? void 0,
667
+ threeLetterCode: t.three_letter_code ?? void 0,
668
+ translations: t.translations.map(D),
669
+ displayAsset: U(t.display_asset),
670
+ slug: t.slug,
671
+ tagScore: t.tag_score ?? void 0,
672
+ sport: t.sport,
673
+ country: z(t.country),
674
+ gender: t.gender,
675
+ birthdate: t.birthdate ?? void 0,
676
+ providerRef: t.id
677
677
  };
678
678
  }
679
- function xe(e) {
679
+ function Ne(t) {
680
680
  return {
681
681
  entityType: "venue",
682
- id: e.id,
683
- legacyId: e.legacy_id ?? void 0,
684
- name: e.name,
685
- shortName: e.short_name ?? void 0,
686
- threeLetterCode: e.three_letter_code ?? void 0,
687
- translations: e.translations.map(E),
688
- displayAsset: F(e.display_asset),
689
- slug: e.slug,
690
- tagScore: e.tag_score ?? void 0,
691
- sport: e.sport,
692
- country: M(e.country),
693
- city: e.city ? te(e.city) : void 0,
694
- providerRef: e.id
682
+ id: t.id,
683
+ legacyId: t.legacy_id ?? void 0,
684
+ name: t.name,
685
+ shortName: t.short_name ?? void 0,
686
+ threeLetterCode: t.three_letter_code ?? void 0,
687
+ translations: t.translations.map(D),
688
+ displayAsset: U(t.display_asset),
689
+ slug: t.slug,
690
+ tagScore: t.tag_score ?? void 0,
691
+ sport: t.sport,
692
+ country: z(t.country),
693
+ city: t.city ? Pt(t.city) : void 0,
694
+ providerRef: t.id
695
695
  };
696
696
  }
697
- function We(e) {
697
+ function Re(t) {
698
698
  return {
699
- entityType: e.entity_type,
700
- id: e.id,
701
- legacyId: e.legacy_id ?? void 0,
702
- name: e.name,
703
- shortName: e.short_name ?? void 0,
704
- threeLetterCode: e.three_letter_code ?? void 0,
705
- translations: e.translations.map(E),
706
- displayAsset: F(e.display_asset),
707
- slug: e.slug,
708
- tagScore: e.tag_score ?? void 0,
709
- sport: e.sport,
710
- country: M(e.country),
711
- gender: e.gender,
712
- type: e.type ?? void 0,
713
- region: e.region ?? void 0,
714
- providerRef: e.id
699
+ entityType: t.entity_type,
700
+ id: t.id,
701
+ legacyId: t.legacy_id ?? void 0,
702
+ name: t.name,
703
+ shortName: t.short_name ?? void 0,
704
+ threeLetterCode: t.three_letter_code ?? void 0,
705
+ translations: t.translations.map(D),
706
+ displayAsset: U(t.display_asset),
707
+ slug: t.slug,
708
+ tagScore: t.tag_score ?? void 0,
709
+ sport: t.sport,
710
+ country: z(t.country),
711
+ gender: t.gender,
712
+ type: t.type ?? void 0,
713
+ region: t.region ?? void 0,
714
+ providerRef: t.id
715
715
  };
716
716
  }
717
- function Ye(e) {
717
+ function Ie(t) {
718
718
  return {
719
719
  entityType: "match",
720
- id: e.id,
721
- legacyId: e.legacy_id ?? void 0,
722
- name: e.name,
723
- shortName: e.short_name ?? void 0,
724
- threeLetterCode: e.three_letter_code ?? void 0,
725
- translations: e.translations.map(E),
726
- displayAsset: F(e.display_asset),
727
- slug: e.slug,
728
- tagScore: e.tag_score ?? void 0,
729
- sport: e.sport,
730
- competitionId: e.competition_id ?? void 0,
731
- startTime: e.start_time ?? void 0,
732
- homeTeam: e.home_team ? V(e.home_team) : void 0,
733
- awayTeam: e.away_team ? V(e.away_team) : void 0,
734
- providerRef: e.id
720
+ id: t.id,
721
+ legacyId: t.legacy_id ?? void 0,
722
+ name: t.name,
723
+ shortName: t.short_name ?? void 0,
724
+ threeLetterCode: t.three_letter_code ?? void 0,
725
+ translations: t.translations.map(D),
726
+ displayAsset: U(t.display_asset),
727
+ slug: t.slug,
728
+ tagScore: t.tag_score ?? void 0,
729
+ sport: t.sport,
730
+ competitionId: t.competition_id ?? void 0,
731
+ startTime: t.start_time ?? void 0,
732
+ homeTeam: t.home_team ? yt(t.home_team) : void 0,
733
+ awayTeam: t.away_team ? yt(t.away_team) : void 0,
734
+ providerRef: t.id
735
735
  };
736
736
  }
737
- function Qe(e) {
737
+ function Pe(t) {
738
738
  return {
739
739
  entityType: "country",
740
- id: e.id,
741
- legacyId: e.legacy_id ?? void 0,
742
- name: e.name,
743
- shortName: e.short_name ?? void 0,
744
- threeLetterCode: e.three_letter_code ?? void 0,
745
- translations: e.translations.map(E),
746
- displayAsset: F(e.display_asset),
747
- slug: e.slug,
748
- tagScore: e.tag_score ?? void 0,
749
- sport: e.sport,
750
- providerRef: e.id
740
+ id: t.id,
741
+ legacyId: t.legacy_id ?? void 0,
742
+ name: t.name,
743
+ shortName: t.short_name ?? void 0,
744
+ threeLetterCode: t.three_letter_code ?? void 0,
745
+ translations: t.translations.map(D),
746
+ displayAsset: U(t.display_asset),
747
+ slug: t.slug,
748
+ tagScore: t.tag_score ?? void 0,
749
+ sport: t.sport,
750
+ providerRef: t.id
751
751
  };
752
752
  }
753
- function qe(e) {
754
- switch (e.entity_type) {
753
+ function Me(t) {
754
+ switch (t.entity_type) {
755
755
  case "team":
756
- return V(e);
756
+ return yt(t);
757
757
  case "city":
758
- return te(e);
758
+ return Pt(t);
759
759
  case "horse":
760
- return be(e);
760
+ return Ee(t);
761
761
  case "player":
762
- return ke(e);
762
+ return Fe(t);
763
763
  case "coach":
764
- return Be(e);
764
+ return Le(t);
765
765
  case "referee":
766
- return $e(e);
766
+ return be(t);
767
767
  case "venue":
768
- return xe(e);
768
+ return Ne(t);
769
769
  case "tournament":
770
770
  case "competition":
771
- return We(e);
771
+ return Re(t);
772
772
  case "match":
773
- return Ye(e);
773
+ return Ie(t);
774
774
  case "country":
775
- return Qe(e);
775
+ return Pe(t);
776
776
  default: {
777
- const t = e;
778
- throw new Error(`Unknown entity type: ${t.entity_type}`);
777
+ const e = t;
778
+ throw new Error(`Unknown entity type: ${e.entity_type}`);
779
779
  }
780
780
  }
781
781
  }
782
- async function xt(e = {}, t) {
783
- const o = t ?? A(), n = {};
784
- e.name && (n.name = e.name), e.entityTypes && e.entityTypes.length > 0 && (n.entity_type = e.entityTypes.join(",")), e.sports && e.sports.length > 0 && (n.sport = e.sports.join(",")), e.eventStartTime && (n.event_start_time = e.eventStartTime), e.ids && e.ids.length > 0 && (n.ids = e.ids.join(",")), e.competitionIds && e.competitionIds.length > 0 && (n.competition_ids = e.competitionIds.join(",")), e.domain && (n.domain = e.domain), e.inputLanguage && (n.input_language = e.inputLanguage), e.translationLanguage && (n.translation_language = e.translationLanguage), e.limit !== void 0 && (n.limit = e.limit.toString()), e.offset !== void 0 && (n.offset = e.offset.toString());
785
- const s = await Ue.get({
782
+ async function qn(t = {}, e) {
783
+ const n = e ?? b(), o = {};
784
+ t.name && (o.name = t.name), t.entityTypes && t.entityTypes.length > 0 && (o.entity_type = t.entityTypes.join(",")), t.sports && t.sports.length > 0 && (o.sport = t.sports.join(",")), t.eventStartTime && (o.event_start_time = t.eventStartTime), t.ids && t.ids.length > 0 && (o.ids = t.ids.join(",")), t.competitionIds && t.competitionIds.length > 0 && (o.competition_ids = t.competitionIds.join(",")), t.domain && (o.domain = t.domain), t.inputLanguage && (o.input_language = t.inputLanguage), t.translationLanguage && (o.translation_language = t.translationLanguage), t.limit !== void 0 && (o.limit = t.limit.toString()), t.offset !== void 0 && (o.offset = t.offset.toString());
785
+ const s = await Oe.get({
786
786
  path: "/suggest",
787
- params: n,
788
- next: e.next,
789
- config: o
787
+ params: o,
788
+ next: t.next,
789
+ config: n
790
790
  });
791
791
  return !s.results || s.results.length === 0 ? {
792
792
  results: [],
793
- query: e.name
793
+ query: t.name
794
794
  } : {
795
- results: s.results.map(qe),
796
- query: e.name
795
+ results: s.results.map(Me),
796
+ query: t.name
797
797
  };
798
798
  }
799
- const Ve = b(de);
800
- function je(e) {
801
- const t = {
799
+ const Ge = ot(Jt);
800
+ function De(t) {
801
+ const e = {
802
802
  RANK: null,
803
803
  // rank is a top-level field, not a stat
804
804
  PLAYED: "played",
@@ -809,9 +809,9 @@ function je(e) {
809
809
  GOALS_AGAINST: "goalsAgainst",
810
810
  POINTS: "points"
811
811
  };
812
- return e in t ? t[e] : e.toLowerCase().replace(/_/g, "");
812
+ return t in e ? e[t] : t.toLowerCase().replace(/_/g, "");
813
813
  }
814
- function oe(e) {
814
+ function Mt(t) {
815
815
  return {
816
816
  CHAMPIONS_LEAGUE: "championsLeague",
817
817
  CHAMPIONS_LEAGUE_QUAL: "championsLeagueQual",
@@ -852,28 +852,28 @@ function oe(e) {
852
852
  AFC_CHAMPIONS_LEAGUE_QUAL: "afcChampionsLeagueQual",
853
853
  PLAYOFF_TO_AFC_CHAMPIONS_LEAGUE_QUAL: "playoffAfcChampionsLeagueQual",
854
854
  WORLD_CUP: "worldCup"
855
- }[e] ?? e.toLowerCase().replace(/_/g, "");
855
+ }[t] ?? t.toLowerCase().replace(/_/g, "");
856
856
  }
857
- function Ke(e) {
858
- return e === "RELEGATION" || e === "RELEGATION_PLAYOFF" ? "BOTTOM" : e.includes("PLAYOFF") ? "MIDDLE" : "TOP";
857
+ function Ue(t) {
858
+ return t === "RELEGATION" || t === "RELEGATION_PLAYOFF" ? "BOTTOM" : t.includes("PLAYOFF") ? "MIDDLE" : "TOP";
859
859
  }
860
- function ze(e, t) {
861
- if (!t || t.length === 0) return;
862
- const o = {
860
+ function xe(t, e) {
861
+ if (!e || e.length === 0) return;
862
+ const n = {
863
863
  win: "W",
864
864
  loss: "L",
865
865
  draw: "D"
866
- }, n = t.map((s) => {
867
- const i = s.participants.find((m) => m.id === e), a = s.participants.find((m) => m.id !== e), r = i?.position === "1", c = s.result.find((m) => m.type === "display"), d = c?.results.find((m) => m.position === "1")?.value, u = c?.results.find((m) => m.position === "2")?.value, l = d && u ? `${d}-${u}` : void 0;
866
+ }, o = e.map((s) => {
867
+ const i = s.participants.find((u) => u.id === t), r = s.participants.find((u) => u.id !== t), a = i?.position === "1", c = s.result.find((u) => u.type === "display"), d = c?.results.find((u) => u.position === "1")?.value, f = c?.results.find((u) => u.position === "2")?.value, l = d && f ? `${d}-${f}` : void 0;
868
868
  return {
869
869
  matchId: s.id,
870
- result: o[s.outcome] ?? "L",
870
+ result: n[s.outcome] ?? "L",
871
871
  score: l,
872
- homeAway: r ? "HOME" : "AWAY",
872
+ homeAway: a ? "HOME" : "AWAY",
873
873
  opponent: {
874
- id: a?.id ?? "",
875
- name: a?.name ?? "",
876
- logo: a?.display_asset?.url
874
+ id: r?.id ?? "",
875
+ name: r?.name ?? "",
876
+ logo: r?.display_asset?.url
877
877
  },
878
878
  date: new Date(s.start_time),
879
879
  competition: s.competition ? {
@@ -883,163 +883,163 @@ function ze(e, t) {
883
883
  };
884
884
  });
885
885
  return {
886
- competitorId: e,
887
- results: n,
888
- formString: n.map((s) => s.result).join("")
886
+ competitorId: t,
887
+ results: o,
888
+ formString: o.map((s) => s.result).join("")
889
889
  };
890
890
  }
891
- function Xe(e) {
892
- const t = {};
893
- for (const o of e) {
894
- const n = je(o.type.code);
895
- n && (t[n] = Number(o.value));
891
+ function He(t) {
892
+ const e = {};
893
+ for (const n of t) {
894
+ const o = De(n.type.code);
895
+ o && (e[o] = Number(n.value));
896
896
  }
897
- return t.goalsFor != null && t.goalsAgainst != null && t.goalDifference == null && (t.goalDifference = t.goalsFor - t.goalsAgainst), t;
897
+ return e.goalsFor != null && e.goalsAgainst != null && e.goalDifference == null && (e.goalDifference = e.goalsFor - e.goalsAgainst), e;
898
898
  }
899
- function Je(e) {
900
- const t = e.find((o) => o.type.code === "RANK");
901
- return t ? Number(t.value) : 0;
899
+ function ke(t) {
900
+ const e = t.find((n) => n.type.code === "RANK");
901
+ return e ? Number(e.value) : 0;
902
902
  }
903
- function Ze(e) {
904
- const t = e.rules?.length > 0 ? e.rules.map((o) => oe(o.standing_api_rule_type)) : void 0;
903
+ function $e(t) {
904
+ const e = t.rules?.length > 0 ? t.rules.map((n) => Mt(n.standing_api_rule_type)) : void 0;
905
905
  return {
906
- rank: Je(e.columns),
906
+ rank: ke(t.columns),
907
907
  competitor: {
908
- id: e.team.id,
909
- name: e.team.name,
910
- shortName: e.team.short_name ?? void 0,
908
+ id: t.team.id,
909
+ name: t.team.name,
910
+ shortName: t.team.short_name ?? void 0,
911
911
  logo: void 0
912
912
  // Standings API doesn't include logo in team object
913
913
  },
914
- stats: Xe(e.columns),
915
- form: ze(e.team.id, e.form ?? []),
916
- rules: t
917
- };
918
- }
919
- function we(e) {
920
- const t = /* @__PURE__ */ new Map();
921
- for (const o of e)
922
- if (o.rules)
923
- for (const n of o.rules) {
924
- const s = oe(n.standing_api_rule_type);
925
- t.has(s) || t.set(s, {
914
+ stats: He(t.columns),
915
+ form: xe(t.team.id, t.form ?? []),
916
+ rules: e
917
+ };
918
+ }
919
+ function Be(t) {
920
+ const e = /* @__PURE__ */ new Map();
921
+ for (const n of t)
922
+ if (n.rules)
923
+ for (const o of n.rules) {
924
+ const s = Mt(o.standing_api_rule_type);
925
+ e.has(s) || e.set(s, {
926
926
  key: s,
927
- name: n.name,
928
- position: Ke(n.type)
927
+ name: o.name,
928
+ position: Ue(o.type)
929
929
  });
930
930
  }
931
- return Array.from(t.values());
931
+ return Array.from(e.values());
932
932
  }
933
- function et(e) {
934
- const t = e.standing.map(Ze), o = we(e.standing);
933
+ function We(t) {
934
+ const e = t.standing.map($e), n = Be(t.standing);
935
935
  return {
936
- entries: t,
937
- metadata: { legend: o }
936
+ entries: e,
937
+ metadata: { legend: n }
938
938
  };
939
939
  }
940
- function tt(e) {
941
- return e.standings.map((t) => ({
940
+ function ze(t) {
941
+ return t.standings.map((e) => ({
942
942
  stage: {
943
- id: e.stage.id,
944
- name: e.stage.name
943
+ id: t.stage.id,
944
+ name: t.stage.name
945
945
  },
946
946
  group: {
947
- id: t.group.id,
948
- name: t.group.name,
949
- type: t.group.type
947
+ id: e.group.id,
948
+ name: e.group.name,
949
+ type: e.group.type
950
950
  },
951
- coverageType: t.type,
952
- rankingType: t.ranking_type,
953
- standings: et(t)
951
+ coverageType: e.type,
952
+ rankingType: e.ranking_type,
953
+ standings: We(e)
954
954
  }));
955
955
  }
956
- function ot(e) {
957
- return !e?.data || e.data.length === 0 ? [] : e.data.flatMap(tt);
958
- }
959
- async function Wt(e, t) {
960
- const o = t || A(), { sportal365Sports: n } = o, s = {
961
- season_id: e.seasonId,
962
- stage_id: e.stageId,
963
- group_id: e.groupId,
964
- coverage_type: e.coverageType,
965
- home_away: e.homeAway,
966
- optional_data: e.includeForm ? "form" : void 0,
967
- row_limit: e.rowLimit?.toString(),
968
- row_offset: e.rowOffset?.toString(),
969
- translation_language: e.languageCode ?? n?.languageCode ?? "en"
970
- }, i = await Ve.get({
971
- path: `/standings/${e.sport}`,
956
+ function Ye(t) {
957
+ return !t?.data || t.data.length === 0 ? [] : t.data.flatMap(ze);
958
+ }
959
+ async function Qn(t, e) {
960
+ const n = e || b(), { sportal365Sports: o } = n, s = {
961
+ season_id: t.seasonId,
962
+ stage_id: t.stageId,
963
+ group_id: t.groupId,
964
+ coverage_type: t.coverageType,
965
+ home_away: t.homeAway,
966
+ optional_data: t.includeForm ? "form" : void 0,
967
+ row_limit: t.rowLimit?.toString(),
968
+ row_offset: t.rowOffset?.toString(),
969
+ translation_language: t.languageCode ?? o?.languageCode ?? "en"
970
+ }, i = await Ge.get({
971
+ path: `/standings/${t.sport}`,
972
972
  params: s,
973
- next: e.next,
974
- config: o
973
+ next: t.next,
974
+ config: n
975
975
  });
976
- return ot(i);
977
- }
978
- const nt = b(ue);
979
- function st(e, t) {
980
- return {
981
- teamId: e.id,
982
- teamName: e.name,
983
- seasonId: t,
984
- statistics: e.statistics.map((o) => ({
985
- key: o.id,
986
- value: o.value,
987
- label: o.name
976
+ return Ye(i);
977
+ }
978
+ const je = ot(Zt);
979
+ function qe(t, e) {
980
+ return {
981
+ teamId: t.id,
982
+ teamName: t.name,
983
+ seasonId: e,
984
+ statistics: t.statistics.map((n) => ({
985
+ key: n.id,
986
+ value: n.value,
987
+ label: n.name
988
988
  }))
989
989
  };
990
990
  }
991
- async function Yt(e, t) {
992
- const o = t || A(), n = e.next ?? { revalidate: 600 }, s = await nt.get({
991
+ async function Vn(t, e) {
992
+ const n = e || b(), o = t.next ?? { revalidate: 600 }, s = await je.get({
993
993
  path: "/statistics/aggregate",
994
994
  params: {
995
- participant_ids: e.teamId,
996
- season_ids: e.seasonId,
995
+ participant_ids: t.teamId,
996
+ season_ids: t.seasonId,
997
997
  participant_type: "TEAM"
998
998
  },
999
- next: n,
1000
- config: o
999
+ next: o,
1000
+ config: n
1001
1001
  });
1002
1002
  if (!s.data || s.data.length === 0)
1003
- throw new Error(`No statistics found for team ${e.teamId} in season ${e.seasonId}`);
1004
- return st(s.data[0], e.seasonId);
1003
+ throw new Error(`No statistics found for team ${t.teamId} in season ${t.seasonId}`);
1004
+ return qe(s.data[0], t.seasonId);
1005
1005
  }
1006
- function it(e) {
1007
- const t = e.replace(/\/$/, "");
1008
- function o(n) {
1009
- return `${t}${n}`;
1006
+ function Gt(t) {
1007
+ const e = t.replace(/\/$/, "");
1008
+ function n(o) {
1009
+ return `${e}${o}`;
1010
1010
  }
1011
1011
  return {
1012
- async get(n) {
1013
- const s = n.config || A(), { fansUnited: i } = s;
1012
+ async get(o) {
1013
+ const s = o.config || b(), { fansUnited: i } = s;
1014
1014
  if (!i)
1015
1015
  throw new Error(
1016
1016
  "Fans United configuration is missing. Add 'fansUnited' with 'apiKey' and 'clientId' to your config."
1017
1017
  );
1018
1018
  if (!i.apiKey || !i.clientId)
1019
1019
  throw new Error("Fans United configuration requires both 'apiKey' and 'clientId'");
1020
- const a = new URL(o(n.path));
1021
- if (a.searchParams.set("key", i.apiKey), a.searchParams.set("client_id", i.clientId), n.params)
1022
- for (const [u, l] of Object.entries(n.params))
1023
- l !== void 0 && (Array.isArray(l) ? l.length > 0 && a.searchParams.set(u, l.join(",")) : a.searchParams.set(u, l));
1024
- const r = 3e4, c = new URL(a.toString());
1020
+ const r = new URL(n(o.path));
1021
+ if (r.searchParams.set("key", i.apiKey), r.searchParams.set("client_id", i.clientId), o.params)
1022
+ for (const [f, l] of Object.entries(o.params))
1023
+ l !== void 0 && (Array.isArray(l) ? l.length > 0 && r.searchParams.set(f, l.join(",")) : r.searchParams.set(f, l));
1024
+ const a = 3e4, c = new URL(r.toString());
1025
1025
  c.searchParams.delete("key"), c.searchParams.delete("client_id"), console.log("🔗 FansUnited API URL:", c.toString());
1026
- const d = await fetch(a.toString(), {
1026
+ const d = await fetch(r.toString(), {
1027
1027
  method: "GET",
1028
1028
  headers: {
1029
1029
  Accept: "application/json",
1030
1030
  "Content-Type": "application/json",
1031
1031
  // Merge custom headers (they can override defaults)
1032
- ...n.headers
1032
+ ...o.headers
1033
1033
  },
1034
- signal: AbortSignal.timeout(r),
1034
+ signal: AbortSignal.timeout(a),
1035
1035
  // Next.js cache options for ISR/on-demand revalidation
1036
- ...n.next && { next: n.next }
1036
+ ...o.next && { next: o.next }
1037
1037
  });
1038
1038
  if (!d.ok) {
1039
- let u = `Fans United API error: ${d.status} ${d.statusText}`;
1039
+ let f = `Fans United API error: ${d.status} ${d.statusText}`;
1040
1040
  try {
1041
1041
  const l = await d.text();
1042
- l && (u += ` - ${l}`);
1042
+ l && (f += ` - ${l}`);
1043
1043
  } catch (l) {
1044
1044
  console.error("[Fans United HTTP] Failed to read error response body:", {
1045
1045
  error: l instanceof Error ? l.message : String(l),
@@ -1047,435 +1047,435 @@ function it(e) {
1047
1047
  statusText: d.statusText
1048
1048
  });
1049
1049
  }
1050
- throw new Error(u);
1050
+ throw new Error(f);
1051
1051
  }
1052
1052
  return d.json();
1053
1053
  }
1054
1054
  };
1055
1055
  }
1056
- const at = "https://football.fansunitedapi.com", R = it(at);
1057
- function rt(e) {
1056
+ const Qe = "https://football.fansunitedapi.com", $ = Gt(Qe);
1057
+ function Ve(t) {
1058
1058
  return {
1059
- id: String(e.id),
1060
- name: e.name,
1061
- active: e.active,
1059
+ id: String(t.id),
1060
+ name: t.name,
1061
+ active: t.active,
1062
1062
  providerRef: [
1063
1063
  {
1064
1064
  provider: "fansunited",
1065
- id: String(e.id)
1065
+ id: String(t.id)
1066
1066
  }
1067
1067
  ]
1068
1068
  };
1069
1069
  }
1070
- function ct(e) {
1071
- const t = {
1072
- id: String(e.id),
1073
- name: e.name,
1074
- shortName: e.short_name,
1075
- slug: e.slug,
1076
- type: e.type || "LEAGUE",
1077
- region: e.region,
1078
- gender: e.gender,
1070
+ function Ke(t) {
1071
+ const e = {
1072
+ id: String(t.id),
1073
+ name: t.name,
1074
+ shortName: t.short_name,
1075
+ slug: t.slug,
1076
+ type: t.type || "LEAGUE",
1077
+ region: t.region,
1078
+ gender: t.gender,
1079
1079
  providerRef: [
1080
1080
  {
1081
1081
  provider: "fansunited",
1082
- id: String(e.id)
1082
+ id: String(t.id)
1083
1083
  }
1084
1084
  ]
1085
1085
  };
1086
- return e.country && (t.country = {
1087
- id: String(e.country.id),
1088
- name: e.country.name,
1089
- code: e.country.code,
1090
- flag: e.country.assets?.flag,
1086
+ return t.country && (e.country = {
1087
+ id: String(t.country.id),
1088
+ name: t.country.name,
1089
+ code: t.country.code,
1090
+ flag: t.country.assets?.flag,
1091
1091
  providerRef: [
1092
1092
  {
1093
1093
  provider: "fansunited",
1094
- id: String(e.country.id)
1094
+ id: String(t.country.id)
1095
1095
  }
1096
1096
  ]
1097
- }), e.assets?.logo && (t.assets = {
1098
- logo: e.assets.logo
1099
- }), e.seasons && e.seasons.length > 0 && (t.seasons = e.seasons.map(rt)), e.current_season && (t.season = {
1100
- id: String(e.current_season.id),
1101
- name: e.current_season.name,
1102
- status: e.current_season.active ? "ACTIVE" : "INACTIVE"
1103
- }), t;
1104
- }
1105
- function lt(e) {
1106
- return e.map(ct);
1107
- }
1108
- async function Qt(e, t) {
1109
- const o = {};
1110
- e?.lang ? o.lang = e.lang : o.lang = "EN", e?.sortField && (o.sort_field = e.sortField), e?.sortOrder && (o.sort_order = e.sortOrder), e?.page !== void 0 && (o.page = String(e.page)), e?.perPage !== void 0 && (o.per_page = String(e.perPage)), e?.countryId !== void 0 && (o.country_id = String(e.countryId)), e?.active !== void 0 && (o.active = e.active ? "1" : "0");
1111
- const n = await R.get({
1097
+ }), t.assets?.logo && (e.assets = {
1098
+ logo: t.assets.logo
1099
+ }), t.seasons && t.seasons.length > 0 && (e.seasons = t.seasons.map(Ve)), t.current_season && (e.season = {
1100
+ id: String(t.current_season.id),
1101
+ name: t.current_season.name,
1102
+ status: t.current_season.active ? "ACTIVE" : "INACTIVE"
1103
+ }), e;
1104
+ }
1105
+ function Xe(t) {
1106
+ return t.map(Ke);
1107
+ }
1108
+ async function Kn(t, e) {
1109
+ const n = {};
1110
+ t?.lang ? n.lang = t.lang : n.lang = "EN", t?.sortField && (n.sort_field = t.sortField), t?.sortOrder && (n.sort_order = t.sortOrder), t?.page !== void 0 && (n.page = String(t.page)), t?.perPage !== void 0 && (n.per_page = String(t.perPage)), t?.countryId !== void 0 && (n.country_id = String(t.countryId)), t?.active !== void 0 && (n.active = t.active ? "1" : "0");
1111
+ const o = await $.get({
1112
1112
  path: "/v1/competitions",
1113
- params: o,
1114
- config: t,
1115
- next: e?.next
1116
- }), s = n.data.map((d) => d.id), i = new Set(s);
1113
+ params: n,
1114
+ config: e,
1115
+ next: t?.next
1116
+ }), s = o.data.map((d) => d.id), i = new Set(s);
1117
1117
  s.length !== i.size && console.warn("⚠️ API returned duplicate competitions!");
1118
- const a = lt(n.data), r = /* @__PURE__ */ new Set(), c = a.filter((d) => r.has(d.id) ? !1 : (r.add(d.id), !0));
1119
- return a.length !== c.length && console.warn(`Removed ${a.length - c.length} duplicate competitions`), c;
1118
+ const r = Xe(o.data), a = /* @__PURE__ */ new Set(), c = r.filter((d) => a.has(d.id) ? !1 : (a.add(d.id), !0));
1119
+ return r.length !== c.length && console.warn(`Removed ${r.length - c.length} duplicate competitions`), c;
1120
1120
  }
1121
- function dt(e) {
1121
+ function Je(t) {
1122
1122
  return {
1123
- id: e.id,
1124
- name: e.name,
1125
- code: e.country_code,
1126
- assets: e.assets?.flag ? {
1127
- flag: e.assets.flag
1123
+ id: t.id,
1124
+ name: t.name,
1125
+ code: t.country_code,
1126
+ assets: t.assets?.flag ? {
1127
+ flag: t.assets.flag
1128
1128
  } : void 0,
1129
1129
  providerRef: [
1130
1130
  {
1131
1131
  provider: "fansunited",
1132
- id: e.id
1132
+ id: t.id
1133
1133
  }
1134
1134
  ]
1135
1135
  };
1136
1136
  }
1137
- function ut(e) {
1137
+ function Ze(t) {
1138
1138
  return {
1139
- id: e.id,
1140
- name: e.name,
1141
- type: e.type?.toUpperCase() || "LEAGUE",
1142
- gender: e.gender?.toUpperCase(),
1143
- country: e.country ? dt(e.country) : void 0,
1144
- assets: e.assets?.logo ? {
1145
- logo: e.assets.logo
1139
+ id: t.id,
1140
+ name: t.name,
1141
+ type: t.type?.toUpperCase() || "LEAGUE",
1142
+ gender: t.gender?.toUpperCase(),
1143
+ country: t.country ? Je(t.country) : void 0,
1144
+ assets: t.assets?.logo ? {
1145
+ logo: t.assets.logo
1146
1146
  } : void 0,
1147
1147
  providerRef: [
1148
1148
  {
1149
1149
  provider: "fansunited",
1150
- id: e.id
1150
+ id: t.id
1151
1151
  }
1152
1152
  ]
1153
1153
  };
1154
1154
  }
1155
- function mt(e) {
1156
- return ut(e.data);
1155
+ function we(t) {
1156
+ return Ze(t.data);
1157
1157
  }
1158
- async function qt(e, t, o) {
1159
- const n = o || A(), s = {};
1160
- t?.lang && (s.lang = t.lang);
1161
- const i = await R.get({
1162
- path: `/v1/competitions/${e}`,
1158
+ async function Xn(t, e, n) {
1159
+ const o = n || b(), s = {};
1160
+ e?.lang && (s.lang = e.lang);
1161
+ const i = await $.get({
1162
+ path: `/v1/competitions/${t}`,
1163
1163
  params: s,
1164
- next: t?.next,
1165
- config: n
1164
+ next: e?.next,
1165
+ config: o
1166
1166
  });
1167
- return mt(i);
1167
+ return we(i);
1168
1168
  }
1169
- function ft(e) {
1169
+ function tn(t) {
1170
1170
  return {
1171
- id: e.id,
1172
- name: e.name,
1173
- code: e.country_code,
1174
- flag: e.assets?.flag,
1171
+ id: t.id,
1172
+ name: t.name,
1173
+ code: t.country_code,
1174
+ flag: t.assets?.flag,
1175
1175
  providerRef: [
1176
1176
  {
1177
1177
  provider: "fansunited",
1178
- id: e.id
1178
+ id: t.id
1179
1179
  }
1180
1180
  ]
1181
1181
  };
1182
1182
  }
1183
- function ne(e) {
1183
+ function Dt(t) {
1184
1184
  return {
1185
- id: e.id,
1186
- name: e.name,
1187
- shortName: e.short_name || void 0,
1188
- threeLetterCode: e.code,
1189
- type: e.national ? "national" : "club",
1190
- gender: e.gender ? e.gender.toUpperCase() : void 0,
1191
- country: e.country ? ft(e.country) : void 0,
1192
- assets: e.assets?.logo ? {
1193
- logo: e.assets.logo
1185
+ id: t.id,
1186
+ name: t.name,
1187
+ shortName: t.short_name || void 0,
1188
+ threeLetterCode: t.code,
1189
+ type: t.national ? "national" : "club",
1190
+ gender: t.gender ? t.gender.toUpperCase() : void 0,
1191
+ country: t.country ? tn(t.country) : void 0,
1192
+ assets: t.assets?.logo ? {
1193
+ logo: t.assets.logo
1194
1194
  } : void 0,
1195
- metadata: e.colors ? {
1196
- shirtColors: e.colors.primary ? [
1195
+ metadata: t.colors ? {
1196
+ shirtColors: t.colors.primary ? [
1197
1197
  {
1198
1198
  type: "home",
1199
- colorCode: e.colors.primary
1199
+ colorCode: t.colors.primary
1200
1200
  }
1201
1201
  ] : void 0
1202
1202
  } : void 0,
1203
1203
  providerRef: [
1204
1204
  {
1205
1205
  provider: "fansunited",
1206
- id: e.id
1206
+ id: t.id
1207
1207
  }
1208
1208
  ]
1209
1209
  };
1210
1210
  }
1211
- function pt(e) {
1212
- return ne(e.data);
1211
+ function en(t) {
1212
+ return Dt(t.data);
1213
1213
  }
1214
- function gt(e) {
1215
- return e.data.map(ne);
1214
+ function nn(t) {
1215
+ return t.data.map(Dt);
1216
1216
  }
1217
- async function Vt(e, t, o) {
1218
- const n = o || A(), s = {};
1219
- t?.lang && (s.lang = t.lang);
1220
- const i = await R.get({
1221
- path: `/v1/teams/${e}`,
1217
+ async function Jn(t, e, n) {
1218
+ const o = n || b(), s = {};
1219
+ e?.lang && (s.lang = e.lang);
1220
+ const i = await $.get({
1221
+ path: `/v1/teams/${t}`,
1222
1222
  params: s,
1223
- next: t?.next,
1224
- config: n
1223
+ next: e?.next,
1224
+ config: o
1225
1225
  });
1226
- return pt(i);
1226
+ return en(i);
1227
1227
  }
1228
- async function jt(e, t) {
1229
- const o = t || A(), n = {};
1230
- e?.lang && (n.lang = e.lang), e?.teamIds && (n.team_ids = e.teamIds), e?.countryId && (n.country_id = e.countryId), e?.name && (n.name = e.name), e?.scope && (n.scope = e.scope), e?.national !== void 0 && (n.national = String(e.national)), e?.gender && (n.gender = e.gender), e?.limit !== void 0 && (n.limit = String(e.limit)), e?.page !== void 0 && (n.page = String(e.page)), e?.sortField && (n.sort_field = e.sortField), e?.sortOrder && (n.sort_order = e.sortOrder);
1231
- const s = await R.get({
1228
+ async function Zn(t, e) {
1229
+ const n = e || b(), o = {};
1230
+ t?.lang && (o.lang = t.lang), t?.teamIds && (o.team_ids = t.teamIds), t?.countryId && (o.country_id = t.countryId), t?.name && (o.name = t.name), t?.scope && (o.scope = t.scope), t?.national !== void 0 && (o.national = String(t.national)), t?.gender && (o.gender = t.gender), t?.limit !== void 0 && (o.limit = String(t.limit)), t?.page !== void 0 && (o.page = String(t.page)), t?.sortField && (o.sort_field = t.sortField), t?.sortOrder && (o.sort_order = t.sortOrder);
1231
+ const s = await $.get({
1232
1232
  path: "/v1/teams",
1233
- params: n,
1234
- next: e?.next,
1235
- config: o
1233
+ params: o,
1234
+ next: t?.next,
1235
+ config: n
1236
1236
  });
1237
- return gt(s);
1237
+ return nn(s);
1238
1238
  }
1239
- function j(e) {
1239
+ function vt(t) {
1240
1240
  return {
1241
- id: e.id,
1242
- name: e.name,
1243
- code: e.country_code,
1244
- flag: e.assets?.flag,
1241
+ id: t.id,
1242
+ name: t.name,
1243
+ code: t.country_code,
1244
+ flag: t.assets?.flag,
1245
1245
  providerRef: [
1246
1246
  {
1247
1247
  provider: "fansunited",
1248
- id: e.id
1248
+ id: t.id
1249
1249
  }
1250
1250
  ]
1251
1251
  };
1252
1252
  }
1253
- function yt(e) {
1253
+ function on(t) {
1254
1254
  return {
1255
- id: e.id,
1256
- name: e.name,
1257
- shortName: e.short_name ?? void 0,
1258
- fullName: e.full_name ?? void 0,
1259
- threeLetterCode: e.code,
1260
- type: e.national ? "national" : "club",
1261
- gender: e.gender?.toUpperCase(),
1262
- country: e.country ? j(e.country) : void 0,
1263
- assets: e.assets?.logo ? {
1264
- logo: e.assets.logo
1255
+ id: t.id,
1256
+ name: t.name,
1257
+ shortName: t.short_name ?? void 0,
1258
+ fullName: t.full_name ?? void 0,
1259
+ threeLetterCode: t.code,
1260
+ type: t.national ? "national" : "club",
1261
+ gender: t.gender?.toUpperCase(),
1262
+ country: t.country ? vt(t.country) : void 0,
1263
+ assets: t.assets?.logo ? {
1264
+ logo: t.assets.logo
1265
1265
  } : void 0,
1266
1266
  providerRef: [
1267
1267
  {
1268
1268
  provider: "fansunited",
1269
- id: e.id
1269
+ id: t.id
1270
1270
  }
1271
1271
  ]
1272
1272
  };
1273
1273
  }
1274
- function ht(e) {
1274
+ function sn(t) {
1275
1275
  return {
1276
- id: e.id,
1277
- name: e.name,
1278
- type: e.type?.toUpperCase() || "LEAGUE",
1279
- gender: e.gender?.toUpperCase(),
1280
- country: e.country ? j(e.country) : void 0,
1281
- assets: e.assets?.logo ? {
1282
- logo: e.assets.logo
1276
+ id: t.id,
1277
+ name: t.name,
1278
+ type: t.type?.toUpperCase() || "LEAGUE",
1279
+ gender: t.gender?.toUpperCase(),
1280
+ country: t.country ? vt(t.country) : void 0,
1281
+ assets: t.assets?.logo ? {
1282
+ logo: t.assets.logo
1283
1283
  } : void 0,
1284
1284
  providerRef: [
1285
1285
  {
1286
1286
  provider: "fansunited",
1287
- id: e.id
1287
+ id: t.id
1288
1288
  }
1289
1289
  ]
1290
1290
  };
1291
1291
  }
1292
- function se(e) {
1292
+ function Ut(t) {
1293
1293
  return {
1294
1294
  type: "player",
1295
- id: e.id,
1296
- name: e.name,
1297
- position: e.position,
1298
- birthdate: e.birth_date,
1299
- country: e.country ? j(e.country) : void 0,
1300
- assets: e.assets?.headshot ? {
1301
- photo: e.assets.headshot
1295
+ id: t.id,
1296
+ name: t.name,
1297
+ position: t.position,
1298
+ birthdate: t.birth_date,
1299
+ country: t.country ? vt(t.country) : void 0,
1300
+ assets: t.assets?.headshot ? {
1301
+ photo: t.assets.headshot
1302
1302
  } : void 0,
1303
- teams: e.teams?.map(yt),
1304
- competitions: e.competitions?.map(ht),
1303
+ teams: t.teams?.map(on),
1304
+ competitions: t.competitions?.map(sn),
1305
1305
  providerRef: [
1306
1306
  {
1307
1307
  provider: "fansunited",
1308
- id: e.id
1308
+ id: t.id
1309
1309
  }
1310
1310
  ]
1311
1311
  };
1312
1312
  }
1313
- function Tt(e) {
1314
- return se(e.data);
1313
+ function rn(t) {
1314
+ return Ut(t.data);
1315
1315
  }
1316
- function _t(e) {
1317
- return e.data.map(se);
1316
+ function an(t) {
1317
+ return t.data.map(Ut);
1318
1318
  }
1319
- async function Kt(e, t, o) {
1320
- const n = o || A(), s = {};
1321
- t?.lang && (s.lang = t.lang);
1322
- const i = await R.get({
1323
- path: `/v1/players/${e}`,
1319
+ async function wn(t, e, n) {
1320
+ const o = n || b(), s = {};
1321
+ e?.lang && (s.lang = e.lang);
1322
+ const i = await $.get({
1323
+ path: `/v1/players/${t}`,
1324
1324
  params: s,
1325
- next: t?.next,
1326
- config: n
1327
- });
1328
- return Tt(i);
1329
- }
1330
- async function zt(e, t) {
1331
- const o = t || A(), n = {};
1332
- e?.lang && (n.lang = e.lang), e?.playerIds && (n.player_ids = e.playerIds), e?.countryId && (n.country_id = e.countryId), e?.name && (n.name = e.name), e?.scope && (n.scope = e.scope), e?.limit !== void 0 && (n.limit = String(e.limit)), e?.page !== void 0 && (n.page = String(e.page)), e?.sortField && (n.sort_field = e.sortField), e?.sortOrder && (n.sort_order = e.sortOrder);
1333
- const s = await R.get({
1334
- path: "/v1/players",
1335
- params: n,
1336
1325
  next: e?.next,
1337
1326
  config: o
1338
1327
  });
1339
- return _t(s);
1328
+ return rn(i);
1340
1329
  }
1341
- async function Xt(e, t, o) {
1342
- const n = o || A(), s = {};
1343
- t?.lang && (s.lang = t.lang);
1344
- const i = await R.get({
1345
- path: `/v1/matches/${e}`,
1346
- params: s,
1330
+ async function to(t, e) {
1331
+ const n = e || b(), o = {};
1332
+ t?.lang && (o.lang = t.lang), t?.playerIds && (o.player_ids = t.playerIds), t?.countryId && (o.country_id = t.countryId), t?.name && (o.name = t.name), t?.scope && (o.scope = t.scope), t?.limit !== void 0 && (o.limit = String(t.limit)), t?.page !== void 0 && (o.page = String(t.page)), t?.sortField && (o.sort_field = t.sortField), t?.sortOrder && (o.sort_order = t.sortOrder);
1333
+ const s = await $.get({
1334
+ path: "/v1/players",
1335
+ params: o,
1347
1336
  next: t?.next,
1348
1337
  config: n
1349
1338
  });
1350
- return me(i);
1339
+ return an(s);
1351
1340
  }
1352
- async function Jt(e, t) {
1353
- const o = t || A(), n = {};
1354
- e?.lang && (n.lang = e.lang), e?.competitions && (n.competitions = e.competitions), e?.countries && (n.countries = e.countries), e?.fromDate && (n.from_date = e.fromDate), e?.toDate && (n.to_date = e.toDate), e?.matches && (n.matches = e.matches), e?.teams && (n.teams = e.teams), e?.status && (n.status = e.status), e?.limit !== void 0 && (n.limit = String(e.limit)), e?.page !== void 0 && (n.page = String(e.page)), e?.sortField && (n.sort_field = e.sortField), e?.sortOrder && (n.sort_order = e.sortOrder), e?.showDeleted !== void 0 && (n.show_deleted = e.showDeleted ? "true" : "false");
1355
- const s = await R.get({
1356
- path: "/v1/matches",
1357
- params: n,
1341
+ async function eo(t, e, n) {
1342
+ const o = n || b(), s = {};
1343
+ e?.lang && (s.lang = e.lang);
1344
+ const i = await $.get({
1345
+ path: `/v1/matches/${t}`,
1346
+ params: s,
1358
1347
  next: e?.next,
1359
1348
  config: o
1360
1349
  });
1361
- return fe(s);
1350
+ return wt(i);
1362
1351
  }
1363
- function K(e) {
1352
+ async function no(t, e) {
1353
+ const n = e || b(), o = {};
1354
+ t?.lang && (o.lang = t.lang), t?.competitions && (o.competitions = t.competitions), t?.countries && (o.countries = t.countries), t?.fromDate && (o.from_date = t.fromDate), t?.toDate && (o.to_date = t.toDate), t?.matches && (o.matches = t.matches), t?.teams && (o.teams = t.teams), t?.status && (o.status = t.status), t?.limit !== void 0 && (o.limit = String(t.limit)), t?.page !== void 0 && (o.page = String(t.page)), t?.sortField && (o.sort_field = t.sortField), t?.sortOrder && (o.sort_order = t.sortOrder), t?.showDeleted !== void 0 && (o.show_deleted = t.showDeleted ? "true" : "false");
1355
+ const s = await $.get({
1356
+ path: "/v1/matches",
1357
+ params: o,
1358
+ next: t?.next,
1359
+ config: n
1360
+ });
1361
+ return te(s);
1362
+ }
1363
+ function St(t) {
1364
1364
  return {
1365
- id: e.id,
1366
- name: e.name,
1367
- code: e.country_code,
1368
- flag: e.assets?.flag || void 0,
1365
+ id: t.id,
1366
+ name: t.name,
1367
+ code: t.country_code,
1368
+ flag: t.assets?.flag || void 0,
1369
1369
  providerRef: [
1370
1370
  {
1371
1371
  provider: "fansunited",
1372
- id: e.id
1372
+ id: t.id
1373
1373
  }
1374
1374
  ]
1375
1375
  };
1376
1376
  }
1377
- function vt(e) {
1377
+ function cn(t) {
1378
1378
  return {
1379
- id: e.id,
1380
- name: e.name,
1381
- shortName: e.short_name || void 0,
1382
- type: e.type || "LEAGUE",
1383
- region: e.region,
1384
- gender: e.gender?.toUpperCase(),
1385
- country: e.country ? K(e.country) : void 0,
1386
- assets: e.assets?.logo ? {
1387
- logo: e.assets.logo
1379
+ id: t.id,
1380
+ name: t.name,
1381
+ shortName: t.short_name || void 0,
1382
+ type: t.type || "LEAGUE",
1383
+ region: t.region,
1384
+ gender: t.gender?.toUpperCase(),
1385
+ country: t.country ? St(t.country) : void 0,
1386
+ assets: t.assets?.logo ? {
1387
+ logo: t.assets.logo
1388
1388
  } : void 0,
1389
1389
  providerRef: [
1390
1390
  {
1391
1391
  provider: "fansunited",
1392
- id: e.id
1392
+ id: t.id
1393
1393
  }
1394
1394
  ]
1395
1395
  };
1396
1396
  }
1397
- function At(e) {
1397
+ function ln(t) {
1398
1398
  return {
1399
1399
  type: "player",
1400
- id: e.id,
1401
- name: e.name,
1402
- position: e.position || void 0,
1403
- gender: e.gender?.toUpperCase(),
1404
- birthdate: e.birth_date || void 0,
1405
- country: e.country ? K(e.country) : void 0,
1406
- assets: e.assets?.headshot ? {
1407
- photo: e.assets.headshot
1400
+ id: t.id,
1401
+ name: t.name,
1402
+ position: t.position || void 0,
1403
+ gender: t.gender?.toUpperCase(),
1404
+ birthdate: t.birth_date || void 0,
1405
+ country: t.country ? St(t.country) : void 0,
1406
+ assets: t.assets?.headshot ? {
1407
+ photo: t.assets.headshot
1408
1408
  } : void 0,
1409
1409
  providerRef: [
1410
1410
  {
1411
1411
  provider: "fansunited",
1412
- id: e.id
1412
+ id: t.id
1413
1413
  }
1414
1414
  ]
1415
1415
  };
1416
1416
  }
1417
- function St(e) {
1417
+ function dn(t) {
1418
1418
  return {
1419
- type: e.national ? "national" : "club",
1420
- id: e.id,
1421
- name: e.name,
1422
- shortName: e.short_name || void 0,
1423
- threeLetterCode: e.code || void 0,
1424
- gender: e.gender?.toUpperCase(),
1425
- country: e.country ? K(e.country) : void 0,
1426
- assets: e.assets?.logo ? {
1427
- logo: e.assets.logo
1419
+ type: t.national ? "national" : "club",
1420
+ id: t.id,
1421
+ name: t.name,
1422
+ shortName: t.short_name || void 0,
1423
+ threeLetterCode: t.code || void 0,
1424
+ gender: t.gender?.toUpperCase(),
1425
+ country: t.country ? St(t.country) : void 0,
1426
+ assets: t.assets?.logo ? {
1427
+ logo: t.assets.logo
1428
1428
  } : void 0,
1429
1429
  providerRef: [
1430
1430
  {
1431
1431
  provider: "fansunited",
1432
- id: e.id
1432
+ id: t.id
1433
1433
  }
1434
1434
  ]
1435
1435
  };
1436
1436
  }
1437
- function q(e) {
1438
- switch (e.entity_type) {
1437
+ function gt(t) {
1438
+ switch (t.entity_type) {
1439
1439
  case "competition": {
1440
- const t = vt(e);
1440
+ const e = cn(t);
1441
1441
  return {
1442
1442
  source: "FOOTBALL",
1443
1443
  entityType: "competition",
1444
- entityId: e.id,
1445
- entityData: t
1444
+ entityId: t.id,
1445
+ entityData: e
1446
1446
  };
1447
1447
  }
1448
1448
  case "player": {
1449
- const t = At(e);
1449
+ const e = ln(t);
1450
1450
  return {
1451
1451
  source: "FOOTBALL",
1452
1452
  entityType: "player",
1453
- entityId: e.id,
1454
- entityData: t
1453
+ entityId: t.id,
1454
+ entityData: e
1455
1455
  };
1456
1456
  }
1457
1457
  case "team": {
1458
- const t = St(e);
1458
+ const e = dn(t);
1459
1459
  return {
1460
1460
  source: "FOOTBALL",
1461
1461
  entityType: "team",
1462
- entityId: e.id,
1463
- entityData: t
1462
+ entityId: t.id,
1463
+ entityData: e
1464
1464
  };
1465
1465
  }
1466
1466
  case "venue":
1467
1467
  case "coach":
1468
1468
  return null;
1469
1469
  default:
1470
- throw new Error(`Unknown entity type: ${e.entity_type}`);
1470
+ throw new Error(`Unknown entity type: ${t.entity_type}`);
1471
1471
  }
1472
1472
  }
1473
- async function Zt(e, t) {
1474
- if (!e.query || e.query.trim() === "")
1473
+ async function oo(t, e) {
1474
+ if (!t.query || t.query.trim() === "")
1475
1475
  return [];
1476
- const o = t || A(), n = {
1477
- q: e.query.trim()
1478
- }, i = (e.entityTypes && e.entityTypes.length > 0 ? e.entityTypes : ["competition", "team", "player"]).map((c) => {
1476
+ const n = e || b(), o = {
1477
+ q: t.query.trim()
1478
+ }, i = (t.entityTypes && t.entityTypes.length > 0 ? t.entityTypes : ["competition", "team", "player"]).map((c) => {
1479
1479
  switch (c) {
1480
1480
  case "team":
1481
1481
  return "teams";
@@ -1487,170 +1487,1296 @@ async function Zt(e, t) {
1487
1487
  return c;
1488
1488
  }
1489
1489
  });
1490
- n.entities = i.join(","), e.lang && (n.lang = e.lang), e.limit && (n.limit = String(e.limit));
1491
- const a = await R.get({
1490
+ o.entities = i.join(","), t.lang && (o.lang = t.lang), t.limit && (o.limit = String(t.limit));
1491
+ const r = await $.get({
1492
1492
  path: "/v1/search",
1493
- params: n,
1494
- next: e.next,
1495
- config: o
1496
- }), r = [];
1497
- return a.data && (a.data.competitions && a.data.competitions.forEach((c) => {
1498
- const d = q({ ...c, entity_type: "competition" });
1499
- d && r.push(d);
1500
- }), a.data.teams && a.data.teams.forEach((c) => {
1501
- const d = q({ ...c, entity_type: "team" });
1502
- d && r.push(d);
1503
- }), a.data.players && a.data.players.forEach((c) => {
1504
- const d = q({ ...c, entity_type: "player" });
1505
- d && r.push(d);
1506
- })), r;
1507
- }
1508
- function wt(e) {
1509
- return !e.seasons || e.seasons.length === 0 ? void 0 : e.seasons.find((o) => o.active) ?? e.seasons[0];
1510
- }
1511
- function eo(e, t) {
1512
- const o = /* @__PURE__ */ new Date(), n = t.filter((s) => {
1513
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, a = s.status.type === "NOT_STARTED", r = new Date(s.timing.kickoffTime) >= o;
1514
- return i && a && r;
1493
+ params: o,
1494
+ next: t.next,
1495
+ config: n
1496
+ }), a = [];
1497
+ return r.data && (r.data.competitions && r.data.competitions.forEach((c) => {
1498
+ const d = gt({ ...c, entity_type: "competition" });
1499
+ d && a.push(d);
1500
+ }), r.data.teams && r.data.teams.forEach((c) => {
1501
+ const d = gt({ ...c, entity_type: "team" });
1502
+ d && a.push(d);
1503
+ }), r.data.players && r.data.players.forEach((c) => {
1504
+ const d = gt({ ...c, entity_type: "player" });
1505
+ d && a.push(d);
1506
+ })), a;
1507
+ }
1508
+ const un = "https://search.fansunitedapi.com", B = Gt(un);
1509
+ var fn = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, xt = /* @__PURE__ */ new Set(), Tt = typeof process == "object" && process ? process : {}, Ht = (t, e, n, o) => {
1510
+ typeof Tt.emitWarning == "function" ? Tt.emitWarning(t, e, n, o) : console.error(`[${n}] ${e}: ${t}`);
1511
+ }, ut = globalThis.AbortController, Ft = globalThis.AbortSignal;
1512
+ if (typeof ut > "u") {
1513
+ Ft = class {
1514
+ onabort;
1515
+ _onabort = [];
1516
+ reason;
1517
+ aborted = !1;
1518
+ addEventListener(n, o) {
1519
+ this._onabort.push(o);
1520
+ }
1521
+ }, ut = class {
1522
+ constructor() {
1523
+ e();
1524
+ }
1525
+ signal = new Ft();
1526
+ abort(n) {
1527
+ if (!this.signal.aborted) {
1528
+ this.signal.reason = n, this.signal.aborted = !0;
1529
+ for (let o of this.signal._onabort) o(n);
1530
+ this.signal.onabort?.(n);
1531
+ }
1532
+ }
1533
+ };
1534
+ let t = Tt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", e = () => {
1535
+ t && (t = !1, Ht("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", e));
1536
+ };
1537
+ }
1538
+ var hn = (t) => !xt.has(t), W = (t) => t && t === Math.floor(t) && t > 0 && isFinite(t), kt = (t) => W(t) ? t <= Math.pow(2, 8) ? Uint8Array : t <= Math.pow(2, 16) ? Uint16Array : t <= Math.pow(2, 32) ? Uint32Array : t <= Number.MAX_SAFE_INTEGER ? dt : null : null, dt = class extends Array {
1539
+ constructor(t) {
1540
+ super(t), this.fill(0);
1541
+ }
1542
+ }, mn = class et {
1543
+ heap;
1544
+ length;
1545
+ static #a = !1;
1546
+ static create(e) {
1547
+ let n = kt(e);
1548
+ if (!n) return [];
1549
+ et.#a = !0;
1550
+ let o = new et(e, n);
1551
+ return et.#a = !1, o;
1552
+ }
1553
+ constructor(e, n) {
1554
+ if (!et.#a) throw new TypeError("instantiate Stack using Stack.create(n)");
1555
+ this.heap = new n(e), this.length = 0;
1556
+ }
1557
+ push(e) {
1558
+ this.heap[this.length++] = e;
1559
+ }
1560
+ pop() {
1561
+ return this.heap[--this.length];
1562
+ }
1563
+ }, gn = class $t {
1564
+ #a;
1565
+ #u;
1566
+ #p;
1567
+ #N;
1568
+ #y;
1569
+ #M;
1570
+ #G;
1571
+ #T;
1572
+ get perf() {
1573
+ return this.#T;
1574
+ }
1575
+ ttl;
1576
+ ttlResolution;
1577
+ ttlAutopurge;
1578
+ updateAgeOnGet;
1579
+ updateAgeOnHas;
1580
+ allowStale;
1581
+ noDisposeOnSet;
1582
+ noUpdateTTL;
1583
+ maxEntrySize;
1584
+ sizeCalculation;
1585
+ noDeleteOnFetchRejection;
1586
+ noDeleteOnStaleGet;
1587
+ allowStaleOnFetchAbort;
1588
+ allowStaleOnFetchRejection;
1589
+ ignoreFetchAbort;
1590
+ #s;
1591
+ #_;
1592
+ #o;
1593
+ #n;
1594
+ #t;
1595
+ #l;
1596
+ #f;
1597
+ #c;
1598
+ #i;
1599
+ #v;
1600
+ #r;
1601
+ #S;
1602
+ #A;
1603
+ #h;
1604
+ #m;
1605
+ #C;
1606
+ #b;
1607
+ #d;
1608
+ #D;
1609
+ static unsafeExposeInternals(e) {
1610
+ return { starts: e.#A, ttls: e.#h, autopurgeTimers: e.#m, sizes: e.#S, keyMap: e.#o, keyList: e.#n, valList: e.#t, next: e.#l, prev: e.#f, get head() {
1611
+ return e.#c;
1612
+ }, get tail() {
1613
+ return e.#i;
1614
+ }, free: e.#v, isBackgroundFetch: (n) => e.#e(n), backgroundFetch: (n, o, s, i) => e.#H(n, o, s, i), moveToTail: (n) => e.#P(n), indexes: (n) => e.#O(n), rindexes: (n) => e.#E(n), isStale: (n) => e.#g(n) };
1615
+ }
1616
+ get max() {
1617
+ return this.#a;
1618
+ }
1619
+ get maxSize() {
1620
+ return this.#u;
1621
+ }
1622
+ get calculatedSize() {
1623
+ return this.#_;
1624
+ }
1625
+ get size() {
1626
+ return this.#s;
1627
+ }
1628
+ get fetchMethod() {
1629
+ return this.#M;
1630
+ }
1631
+ get memoMethod() {
1632
+ return this.#G;
1633
+ }
1634
+ get dispose() {
1635
+ return this.#p;
1636
+ }
1637
+ get onInsert() {
1638
+ return this.#N;
1639
+ }
1640
+ get disposeAfter() {
1641
+ return this.#y;
1642
+ }
1643
+ constructor(e) {
1644
+ let { max: n = 0, ttl: o, ttlResolution: s = 1, ttlAutopurge: i, updateAgeOnGet: r, updateAgeOnHas: a, allowStale: c, dispose: d, onInsert: f, disposeAfter: l, noDisposeOnSet: u, noUpdateTTL: h, maxSize: p = 0, maxEntrySize: y = 0, sizeCalculation: S, fetchMethod: g, memoMethod: T, noDeleteOnFetchRejection: A, noDeleteOnStaleGet: C, allowStaleOnFetchRejection: v, allowStaleOnFetchAbort: R, ignoreFetchAbort: P, perf: M } = e;
1645
+ if (M !== void 0 && typeof M?.now != "function") throw new TypeError("perf option must have a now() method if specified");
1646
+ if (this.#T = M ?? fn, n !== 0 && !W(n)) throw new TypeError("max option must be a nonnegative integer");
1647
+ let m = n ? kt(n) : Array;
1648
+ if (!m) throw new Error("invalid max value: " + n);
1649
+ if (this.#a = n, this.#u = p, this.maxEntrySize = y || this.#u, this.sizeCalculation = S, this.sizeCalculation) {
1650
+ if (!this.#u && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
1651
+ if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
1652
+ }
1653
+ if (T !== void 0 && typeof T != "function") throw new TypeError("memoMethod must be a function if defined");
1654
+ if (this.#G = T, g !== void 0 && typeof g != "function") throw new TypeError("fetchMethod must be a function if specified");
1655
+ if (this.#M = g, this.#b = !!g, this.#o = /* @__PURE__ */ new Map(), this.#n = new Array(n).fill(void 0), this.#t = new Array(n).fill(void 0), this.#l = new m(n), this.#f = new m(n), this.#c = 0, this.#i = 0, this.#v = mn.create(n), this.#s = 0, this.#_ = 0, typeof d == "function" && (this.#p = d), typeof f == "function" && (this.#N = f), typeof l == "function" ? (this.#y = l, this.#r = []) : (this.#y = void 0, this.#r = void 0), this.#C = !!this.#p, this.#D = !!this.#N, this.#d = !!this.#y, this.noDisposeOnSet = !!u, this.noUpdateTTL = !!h, this.noDeleteOnFetchRejection = !!A, this.allowStaleOnFetchRejection = !!v, this.allowStaleOnFetchAbort = !!R, this.ignoreFetchAbort = !!P, this.maxEntrySize !== 0) {
1656
+ if (this.#u !== 0 && !W(this.#u)) throw new TypeError("maxSize must be a positive integer if specified");
1657
+ if (!W(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
1658
+ this.#j();
1659
+ }
1660
+ if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!C, this.updateAgeOnGet = !!r, this.updateAgeOnHas = !!a, this.ttlResolution = W(s) || s === 0 ? s : 1, this.ttlAutopurge = !!i, this.ttl = o || 0, this.ttl) {
1661
+ if (!W(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
1662
+ this.#k();
1663
+ }
1664
+ if (this.#a === 0 && this.ttl === 0 && this.#u === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
1665
+ if (!this.ttlAutopurge && !this.#a && !this.#u) {
1666
+ let O = "LRU_CACHE_UNBOUNDED";
1667
+ hn(O) && (xt.add(O), Ht("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", O, $t));
1668
+ }
1669
+ }
1670
+ getRemainingTTL(e) {
1671
+ return this.#o.has(e) ? 1 / 0 : 0;
1672
+ }
1673
+ #k() {
1674
+ let e = new dt(this.#a), n = new dt(this.#a);
1675
+ this.#h = e, this.#A = n;
1676
+ let o = this.ttlAutopurge ? new Array(this.#a) : void 0;
1677
+ this.#m = o, this.#$ = (r, a, c = this.#T.now()) => {
1678
+ if (n[r] = a !== 0 ? c : 0, e[r] = a, o?.[r] && (clearTimeout(o[r]), o[r] = void 0), a !== 0 && o) {
1679
+ let d = setTimeout(() => {
1680
+ this.#g(r) && this.#F(this.#n[r], "expire");
1681
+ }, a + 1);
1682
+ d.unref && d.unref(), o[r] = d;
1683
+ }
1684
+ }, this.#R = (r) => {
1685
+ n[r] = e[r] !== 0 ? this.#T.now() : 0;
1686
+ }, this.#L = (r, a) => {
1687
+ if (e[a]) {
1688
+ let c = e[a], d = n[a];
1689
+ if (!c || !d) return;
1690
+ r.ttl = c, r.start = d, r.now = s || i();
1691
+ let f = r.now - d;
1692
+ r.remainingTTL = c - f;
1693
+ }
1694
+ };
1695
+ let s = 0, i = () => {
1696
+ let r = this.#T.now();
1697
+ if (this.ttlResolution > 0) {
1698
+ s = r;
1699
+ let a = setTimeout(() => s = 0, this.ttlResolution);
1700
+ a.unref && a.unref();
1701
+ }
1702
+ return r;
1703
+ };
1704
+ this.getRemainingTTL = (r) => {
1705
+ let a = this.#o.get(r);
1706
+ if (a === void 0) return 0;
1707
+ let c = e[a], d = n[a];
1708
+ if (!c || !d) return 1 / 0;
1709
+ let f = (s || i()) - d;
1710
+ return c - f;
1711
+ }, this.#g = (r) => {
1712
+ let a = n[r], c = e[r];
1713
+ return !!c && !!a && (s || i()) - a > c;
1714
+ };
1715
+ }
1716
+ #R = () => {
1717
+ };
1718
+ #L = () => {
1719
+ };
1720
+ #$ = () => {
1721
+ };
1722
+ #g = () => !1;
1723
+ #j() {
1724
+ let e = new dt(this.#a);
1725
+ this.#_ = 0, this.#S = e, this.#I = (n) => {
1726
+ this.#_ -= e[n], e[n] = 0;
1727
+ }, this.#B = (n, o, s, i) => {
1728
+ if (this.#e(o)) return 0;
1729
+ if (!W(s)) if (i) {
1730
+ if (typeof i != "function") throw new TypeError("sizeCalculation must be a function");
1731
+ if (s = i(o, n), !W(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
1732
+ } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
1733
+ return s;
1734
+ }, this.#U = (n, o, s) => {
1735
+ if (e[n] = o, this.#u) {
1736
+ let i = this.#u - e[n];
1737
+ for (; this.#_ > i; ) this.#x(!0);
1738
+ }
1739
+ this.#_ += e[n], s && (s.entrySize = o, s.totalCalculatedSize = this.#_);
1740
+ };
1741
+ }
1742
+ #I = (e) => {
1743
+ };
1744
+ #U = (e, n, o) => {
1745
+ };
1746
+ #B = (e, n, o, s) => {
1747
+ if (o || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
1748
+ return 0;
1749
+ };
1750
+ *#O({ allowStale: e = this.allowStale } = {}) {
1751
+ if (this.#s) for (let n = this.#i; !(!this.#W(n) || ((e || !this.#g(n)) && (yield n), n === this.#c)); ) n = this.#f[n];
1752
+ }
1753
+ *#E({ allowStale: e = this.allowStale } = {}) {
1754
+ if (this.#s) for (let n = this.#c; !(!this.#W(n) || ((e || !this.#g(n)) && (yield n), n === this.#i)); ) n = this.#l[n];
1755
+ }
1756
+ #W(e) {
1757
+ return e !== void 0 && this.#o.get(this.#n[e]) === e;
1758
+ }
1759
+ *entries() {
1760
+ for (let e of this.#O()) this.#t[e] !== void 0 && this.#n[e] !== void 0 && !this.#e(this.#t[e]) && (yield [this.#n[e], this.#t[e]]);
1761
+ }
1762
+ *rentries() {
1763
+ for (let e of this.#E()) this.#t[e] !== void 0 && this.#n[e] !== void 0 && !this.#e(this.#t[e]) && (yield [this.#n[e], this.#t[e]]);
1764
+ }
1765
+ *keys() {
1766
+ for (let e of this.#O()) {
1767
+ let n = this.#n[e];
1768
+ n !== void 0 && !this.#e(this.#t[e]) && (yield n);
1769
+ }
1770
+ }
1771
+ *rkeys() {
1772
+ for (let e of this.#E()) {
1773
+ let n = this.#n[e];
1774
+ n !== void 0 && !this.#e(this.#t[e]) && (yield n);
1775
+ }
1776
+ }
1777
+ *values() {
1778
+ for (let e of this.#O()) this.#t[e] !== void 0 && !this.#e(this.#t[e]) && (yield this.#t[e]);
1779
+ }
1780
+ *rvalues() {
1781
+ for (let e of this.#E()) this.#t[e] !== void 0 && !this.#e(this.#t[e]) && (yield this.#t[e]);
1782
+ }
1783
+ [Symbol.iterator]() {
1784
+ return this.entries();
1785
+ }
1786
+ [Symbol.toStringTag] = "LRUCache";
1787
+ find(e, n = {}) {
1788
+ for (let o of this.#O()) {
1789
+ let s = this.#t[o], i = this.#e(s) ? s.__staleWhileFetching : s;
1790
+ if (i !== void 0 && e(i, this.#n[o], this)) return this.get(this.#n[o], n);
1791
+ }
1792
+ }
1793
+ forEach(e, n = this) {
1794
+ for (let o of this.#O()) {
1795
+ let s = this.#t[o], i = this.#e(s) ? s.__staleWhileFetching : s;
1796
+ i !== void 0 && e.call(n, i, this.#n[o], this);
1797
+ }
1798
+ }
1799
+ rforEach(e, n = this) {
1800
+ for (let o of this.#E()) {
1801
+ let s = this.#t[o], i = this.#e(s) ? s.__staleWhileFetching : s;
1802
+ i !== void 0 && e.call(n, i, this.#n[o], this);
1803
+ }
1804
+ }
1805
+ purgeStale() {
1806
+ let e = !1;
1807
+ for (let n of this.#E({ allowStale: !0 })) this.#g(n) && (this.#F(this.#n[n], "expire"), e = !0);
1808
+ return e;
1809
+ }
1810
+ info(e) {
1811
+ let n = this.#o.get(e);
1812
+ if (n === void 0) return;
1813
+ let o = this.#t[n], s = this.#e(o) ? o.__staleWhileFetching : o;
1814
+ if (s === void 0) return;
1815
+ let i = { value: s };
1816
+ if (this.#h && this.#A) {
1817
+ let r = this.#h[n], a = this.#A[n];
1818
+ if (r && a) {
1819
+ let c = r - (this.#T.now() - a);
1820
+ i.ttl = c, i.start = Date.now();
1821
+ }
1822
+ }
1823
+ return this.#S && (i.size = this.#S[n]), i;
1824
+ }
1825
+ dump() {
1826
+ let e = [];
1827
+ for (let n of this.#O({ allowStale: !0 })) {
1828
+ let o = this.#n[n], s = this.#t[n], i = this.#e(s) ? s.__staleWhileFetching : s;
1829
+ if (i === void 0 || o === void 0) continue;
1830
+ let r = { value: i };
1831
+ if (this.#h && this.#A) {
1832
+ r.ttl = this.#h[n];
1833
+ let a = this.#T.now() - this.#A[n];
1834
+ r.start = Math.floor(Date.now() - a);
1835
+ }
1836
+ this.#S && (r.size = this.#S[n]), e.unshift([o, r]);
1837
+ }
1838
+ return e;
1839
+ }
1840
+ load(e) {
1841
+ this.clear();
1842
+ for (let [n, o] of e) {
1843
+ if (o.start) {
1844
+ let s = Date.now() - o.start;
1845
+ o.start = this.#T.now() - s;
1846
+ }
1847
+ this.set(n, o.value, o);
1848
+ }
1849
+ }
1850
+ set(e, n, o = {}) {
1851
+ if (n === void 0) return this.delete(e), this;
1852
+ let { ttl: s = this.ttl, start: i, noDisposeOnSet: r = this.noDisposeOnSet, sizeCalculation: a = this.sizeCalculation, status: c } = o, { noUpdateTTL: d = this.noUpdateTTL } = o, f = this.#B(e, n, o.size || 0, a);
1853
+ if (this.maxEntrySize && f > this.maxEntrySize) return c && (c.set = "miss", c.maxEntrySizeExceeded = !0), this.#F(e, "set"), this;
1854
+ let l = this.#s === 0 ? void 0 : this.#o.get(e);
1855
+ if (l === void 0) l = this.#s === 0 ? this.#i : this.#v.length !== 0 ? this.#v.pop() : this.#s === this.#a ? this.#x(!1) : this.#s, this.#n[l] = e, this.#t[l] = n, this.#o.set(e, l), this.#l[this.#i] = l, this.#f[l] = this.#i, this.#i = l, this.#s++, this.#U(l, f, c), c && (c.set = "add"), d = !1, this.#D && this.#N?.(n, e, "add");
1856
+ else {
1857
+ this.#P(l);
1858
+ let u = this.#t[l];
1859
+ if (n !== u) {
1860
+ if (this.#b && this.#e(u)) {
1861
+ u.__abortController.abort(new Error("replaced"));
1862
+ let { __staleWhileFetching: h } = u;
1863
+ h !== void 0 && !r && (this.#C && this.#p?.(h, e, "set"), this.#d && this.#r?.push([h, e, "set"]));
1864
+ } else r || (this.#C && this.#p?.(u, e, "set"), this.#d && this.#r?.push([u, e, "set"]));
1865
+ if (this.#I(l), this.#U(l, f, c), this.#t[l] = n, c) {
1866
+ c.set = "replace";
1867
+ let h = u && this.#e(u) ? u.__staleWhileFetching : u;
1868
+ h !== void 0 && (c.oldValue = h);
1869
+ }
1870
+ } else c && (c.set = "update");
1871
+ this.#D && this.onInsert?.(n, e, n === u ? "update" : "replace");
1872
+ }
1873
+ if (s !== 0 && !this.#h && this.#k(), this.#h && (d || this.#$(l, s, i), c && this.#L(c, l)), !r && this.#d && this.#r) {
1874
+ let u = this.#r, h;
1875
+ for (; h = u?.shift(); ) this.#y?.(...h);
1876
+ }
1877
+ return this;
1878
+ }
1879
+ pop() {
1880
+ try {
1881
+ for (; this.#s; ) {
1882
+ let e = this.#t[this.#c];
1883
+ if (this.#x(!0), this.#e(e)) {
1884
+ if (e.__staleWhileFetching) return e.__staleWhileFetching;
1885
+ } else if (e !== void 0) return e;
1886
+ }
1887
+ } finally {
1888
+ if (this.#d && this.#r) {
1889
+ let e = this.#r, n;
1890
+ for (; n = e?.shift(); ) this.#y?.(...n);
1891
+ }
1892
+ }
1893
+ }
1894
+ #x(e) {
1895
+ let n = this.#c, o = this.#n[n], s = this.#t[n];
1896
+ return this.#b && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#C || this.#d) && (this.#C && this.#p?.(s, o, "evict"), this.#d && this.#r?.push([s, o, "evict"])), this.#I(n), this.#m?.[n] && (clearTimeout(this.#m[n]), this.#m[n] = void 0), e && (this.#n[n] = void 0, this.#t[n] = void 0, this.#v.push(n)), this.#s === 1 ? (this.#c = this.#i = 0, this.#v.length = 0) : this.#c = this.#l[n], this.#o.delete(o), this.#s--, n;
1897
+ }
1898
+ has(e, n = {}) {
1899
+ let { updateAgeOnHas: o = this.updateAgeOnHas, status: s } = n, i = this.#o.get(e);
1900
+ if (i !== void 0) {
1901
+ let r = this.#t[i];
1902
+ if (this.#e(r) && r.__staleWhileFetching === void 0) return !1;
1903
+ if (this.#g(i)) s && (s.has = "stale", this.#L(s, i));
1904
+ else return o && this.#R(i), s && (s.has = "hit", this.#L(s, i)), !0;
1905
+ } else s && (s.has = "miss");
1906
+ return !1;
1907
+ }
1908
+ peek(e, n = {}) {
1909
+ let { allowStale: o = this.allowStale } = n, s = this.#o.get(e);
1910
+ if (s === void 0 || !o && this.#g(s)) return;
1911
+ let i = this.#t[s];
1912
+ return this.#e(i) ? i.__staleWhileFetching : i;
1913
+ }
1914
+ #H(e, n, o, s) {
1915
+ let i = n === void 0 ? void 0 : this.#t[n];
1916
+ if (this.#e(i)) return i;
1917
+ let r = new ut(), { signal: a } = o;
1918
+ a?.addEventListener("abort", () => r.abort(a.reason), { signal: r.signal });
1919
+ let c = { signal: r.signal, options: o, context: s }, d = (y, S = !1) => {
1920
+ let { aborted: g } = r.signal, T = o.ignoreFetchAbort && y !== void 0, A = o.ignoreFetchAbort || !!(o.allowStaleOnFetchAbort && y !== void 0);
1921
+ if (o.status && (g && !S ? (o.status.fetchAborted = !0, o.status.fetchError = r.signal.reason, T && (o.status.fetchAbortIgnored = !0)) : o.status.fetchResolved = !0), g && !T && !S) return l(r.signal.reason, A);
1922
+ let C = h, v = this.#t[n];
1923
+ return (v === h || T && S && v === void 0) && (y === void 0 ? C.__staleWhileFetching !== void 0 ? this.#t[n] = C.__staleWhileFetching : this.#F(e, "fetch") : (o.status && (o.status.fetchUpdated = !0), this.set(e, y, c.options))), y;
1924
+ }, f = (y) => (o.status && (o.status.fetchRejected = !0, o.status.fetchError = y), l(y, !1)), l = (y, S) => {
1925
+ let { aborted: g } = r.signal, T = g && o.allowStaleOnFetchAbort, A = T || o.allowStaleOnFetchRejection, C = A || o.noDeleteOnFetchRejection, v = h;
1926
+ if (this.#t[n] === h && (!C || !S && v.__staleWhileFetching === void 0 ? this.#F(e, "fetch") : T || (this.#t[n] = v.__staleWhileFetching)), A) return o.status && v.__staleWhileFetching !== void 0 && (o.status.returnedStale = !0), v.__staleWhileFetching;
1927
+ if (v.__returned === v) throw y;
1928
+ }, u = (y, S) => {
1929
+ let g = this.#M?.(e, i, c);
1930
+ g && g instanceof Promise && g.then((T) => y(T === void 0 ? void 0 : T), S), r.signal.addEventListener("abort", () => {
1931
+ (!o.ignoreFetchAbort || o.allowStaleOnFetchAbort) && (y(void 0), o.allowStaleOnFetchAbort && (y = (T) => d(T, !0)));
1932
+ });
1933
+ };
1934
+ o.status && (o.status.fetchDispatched = !0);
1935
+ let h = new Promise(u).then(d, f), p = Object.assign(h, { __abortController: r, __staleWhileFetching: i, __returned: void 0 });
1936
+ return n === void 0 ? (this.set(e, p, { ...c.options, status: void 0 }), n = this.#o.get(e)) : this.#t[n] = p, p;
1937
+ }
1938
+ #e(e) {
1939
+ if (!this.#b) return !1;
1940
+ let n = e;
1941
+ return !!n && n instanceof Promise && n.hasOwnProperty("__staleWhileFetching") && n.__abortController instanceof ut;
1942
+ }
1943
+ async fetch(e, n = {}) {
1944
+ let { allowStale: o = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, ttl: r = this.ttl, noDisposeOnSet: a = this.noDisposeOnSet, size: c = 0, sizeCalculation: d = this.sizeCalculation, noUpdateTTL: f = this.noUpdateTTL, noDeleteOnFetchRejection: l = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: u = this.allowStaleOnFetchRejection, ignoreFetchAbort: h = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: y, forceRefresh: S = !1, status: g, signal: T } = n;
1945
+ if (!this.#b) return g && (g.fetch = "get"), this.get(e, { allowStale: o, updateAgeOnGet: s, noDeleteOnStaleGet: i, status: g });
1946
+ let A = { allowStale: o, updateAgeOnGet: s, noDeleteOnStaleGet: i, ttl: r, noDisposeOnSet: a, size: c, sizeCalculation: d, noUpdateTTL: f, noDeleteOnFetchRejection: l, allowStaleOnFetchRejection: u, allowStaleOnFetchAbort: p, ignoreFetchAbort: h, status: g, signal: T }, C = this.#o.get(e);
1947
+ if (C === void 0) {
1948
+ g && (g.fetch = "miss");
1949
+ let v = this.#H(e, C, A, y);
1950
+ return v.__returned = v;
1951
+ } else {
1952
+ let v = this.#t[C];
1953
+ if (this.#e(v)) {
1954
+ let m = o && v.__staleWhileFetching !== void 0;
1955
+ return g && (g.fetch = "inflight", m && (g.returnedStale = !0)), m ? v.__staleWhileFetching : v.__returned = v;
1956
+ }
1957
+ let R = this.#g(C);
1958
+ if (!S && !R) return g && (g.fetch = "hit"), this.#P(C), s && this.#R(C), g && this.#L(g, C), v;
1959
+ let P = this.#H(e, C, A, y), M = P.__staleWhileFetching !== void 0 && o;
1960
+ return g && (g.fetch = R ? "stale" : "refresh", M && R && (g.returnedStale = !0)), M ? P.__staleWhileFetching : P.__returned = P;
1961
+ }
1962
+ }
1963
+ async forceFetch(e, n = {}) {
1964
+ let o = await this.fetch(e, n);
1965
+ if (o === void 0) throw new Error("fetch() returned undefined");
1966
+ return o;
1967
+ }
1968
+ memo(e, n = {}) {
1969
+ let o = this.#G;
1970
+ if (!o) throw new Error("no memoMethod provided to constructor");
1971
+ let { context: s, forceRefresh: i, ...r } = n, a = this.get(e, r);
1972
+ if (!i && a !== void 0) return a;
1973
+ let c = o(e, a, { options: r, context: s });
1974
+ return this.set(e, c, r), c;
1975
+ }
1976
+ get(e, n = {}) {
1977
+ let { allowStale: o = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, status: r } = n, a = this.#o.get(e);
1978
+ if (a !== void 0) {
1979
+ let c = this.#t[a], d = this.#e(c);
1980
+ return r && this.#L(r, a), this.#g(a) ? (r && (r.get = "stale"), d ? (r && o && c.__staleWhileFetching !== void 0 && (r.returnedStale = !0), o ? c.__staleWhileFetching : void 0) : (i || this.#F(e, "expire"), r && o && (r.returnedStale = !0), o ? c : void 0)) : (r && (r.get = "hit"), d ? c.__staleWhileFetching : (this.#P(a), s && this.#R(a), c));
1981
+ } else r && (r.get = "miss");
1982
+ }
1983
+ #z(e, n) {
1984
+ this.#f[n] = e, this.#l[e] = n;
1985
+ }
1986
+ #P(e) {
1987
+ e !== this.#i && (e === this.#c ? this.#c = this.#l[e] : this.#z(this.#f[e], this.#l[e]), this.#z(this.#i, e), this.#i = e);
1988
+ }
1989
+ delete(e) {
1990
+ return this.#F(e, "delete");
1991
+ }
1992
+ #F(e, n) {
1993
+ let o = !1;
1994
+ if (this.#s !== 0) {
1995
+ let s = this.#o.get(e);
1996
+ if (s !== void 0) if (this.#m?.[s] && (clearTimeout(this.#m?.[s]), this.#m[s] = void 0), o = !0, this.#s === 1) this.#Y(n);
1997
+ else {
1998
+ this.#I(s);
1999
+ let i = this.#t[s];
2000
+ if (this.#e(i) ? i.__abortController.abort(new Error("deleted")) : (this.#C || this.#d) && (this.#C && this.#p?.(i, e, n), this.#d && this.#r?.push([i, e, n])), this.#o.delete(e), this.#n[s] = void 0, this.#t[s] = void 0, s === this.#i) this.#i = this.#f[s];
2001
+ else if (s === this.#c) this.#c = this.#l[s];
2002
+ else {
2003
+ let r = this.#f[s];
2004
+ this.#l[r] = this.#l[s];
2005
+ let a = this.#l[s];
2006
+ this.#f[a] = this.#f[s];
2007
+ }
2008
+ this.#s--, this.#v.push(s);
2009
+ }
2010
+ }
2011
+ if (this.#d && this.#r?.length) {
2012
+ let s = this.#r, i;
2013
+ for (; i = s?.shift(); ) this.#y?.(...i);
2014
+ }
2015
+ return o;
2016
+ }
2017
+ clear() {
2018
+ return this.#Y("delete");
2019
+ }
2020
+ #Y(e) {
2021
+ for (let n of this.#E({ allowStale: !0 })) {
2022
+ let o = this.#t[n];
2023
+ if (this.#e(o)) o.__abortController.abort(new Error("deleted"));
2024
+ else {
2025
+ let s = this.#n[n];
2026
+ this.#C && this.#p?.(o, s, e), this.#d && this.#r?.push([o, s, e]);
2027
+ }
2028
+ }
2029
+ if (this.#o.clear(), this.#t.fill(void 0), this.#n.fill(void 0), this.#h && this.#A) {
2030
+ this.#h.fill(0), this.#A.fill(0);
2031
+ for (let n of this.#m ?? []) n !== void 0 && clearTimeout(n);
2032
+ this.#m?.fill(void 0);
2033
+ }
2034
+ if (this.#S && this.#S.fill(0), this.#c = 0, this.#i = 0, this.#v.length = 0, this.#_ = 0, this.#s = 0, this.#d && this.#r) {
2035
+ let n = this.#r, o;
2036
+ for (; o = n?.shift(); ) this.#y?.(...o);
2037
+ }
2038
+ }
2039
+ };
2040
+ const pn = 50 * 1024 * 1024, tt = new gn({
2041
+ maxSize: pn,
2042
+ sizeCalculation: (t) => JSON.stringify(t.data).length
2043
+ }), F = {
2044
+ get(t) {
2045
+ return tt.get(t);
2046
+ },
2047
+ set(t, e) {
2048
+ tt.set(t, { data: e, storedAt: Date.now() });
2049
+ },
2050
+ delete(t) {
2051
+ tt.delete(t);
2052
+ },
2053
+ clear() {
2054
+ tt.clear();
2055
+ },
2056
+ get size() {
2057
+ return tt.size;
2058
+ }
2059
+ };
2060
+ let G = null;
2061
+ function so(t) {
2062
+ G = t;
2063
+ }
2064
+ const yn = {
2065
+ competitions: { staleTTL: 24 * 3600, maxTTL: 72 * 3600 },
2066
+ teams: { staleTTL: 24 * 3600, maxTTL: 48 * 3600 },
2067
+ athletes: { staleTTL: 24 * 3600, maxTTL: 48 * 3600 },
2068
+ venues: { staleTTL: 72 * 3600, maxTTL: 168 * 3600 },
2069
+ countries: { staleTTL: 96 * 3600, maxTTL: 168 * 3600 },
2070
+ coaches: { staleTTL: 24 * 3600, maxTTL: 48 * 3600 },
2071
+ search: { staleTTL: 300, maxTTL: 1800 }
2072
+ }, pt = /* @__PURE__ */ new Set();
2073
+ function Bt(t) {
2074
+ const e = yn[t];
2075
+ if (!e)
2076
+ throw new Error(`Unknown entity type: ${t}`);
2077
+ return e;
2078
+ }
2079
+ function ft(t, e) {
2080
+ return Date.now() - t.storedAt < e * 1e3;
2081
+ }
2082
+ function ht(t, e) {
2083
+ return Date.now() - t.storedAt >= e * 1e3;
2084
+ }
2085
+ function mt(t, e, n) {
2086
+ pt.has(t) || (pt.add(t), n().then((o) => {
2087
+ F.set(t, o), G?.isInitialized && G.set(t, e, o);
2088
+ }).catch((o) => {
2089
+ console.error(`[cache] Background refresh failed for ${t}:`, o);
2090
+ }).finally(() => {
2091
+ pt.delete(t);
2092
+ }));
2093
+ }
2094
+ async function q(t, e, n) {
2095
+ const { staleTTL: o, maxTTL: s } = Bt(e), i = F.get(t);
2096
+ if (i) {
2097
+ if (ft(i, o))
2098
+ return i.data;
2099
+ if (!ht(i, s))
2100
+ return mt(t, e, n), i.data;
2101
+ }
2102
+ if (G?.isInitialized) {
2103
+ const a = G.get(t);
2104
+ if (a && !ht(a, s))
2105
+ return F.set(t, a.data), ft(a, o) || mt(t, e, n), a.data;
2106
+ }
2107
+ const r = await n();
2108
+ return F.set(t, r), G?.isInitialized && G.set(t, e, r), r;
2109
+ }
2110
+ async function Tn(t, e, n, o) {
2111
+ const { staleTTL: s, maxTTL: i } = Bt(e), r = /* @__PURE__ */ new Map(), a = [];
2112
+ for (const c of t) {
2113
+ const d = o(c);
2114
+ let f = !1;
2115
+ const l = F.get(d);
2116
+ if (l && !ht(l, i) && (r.set(c, l.data), ft(l, s) || mt(d, e, async () => {
2117
+ const h = (await n([c])).get(c);
2118
+ if (!h) throw new Error(`Batch fetcher did not return ID: ${c}`);
2119
+ return h;
2120
+ }), f = !0), !f && G?.isInitialized) {
2121
+ const u = G.get(d);
2122
+ u && !ht(u, i) && (F.set(d, u.data), r.set(c, u.data), ft(u, s) || mt(d, e, async () => {
2123
+ const p = (await n([c])).get(c);
2124
+ if (!p) throw new Error(`Batch fetcher did not return ID: ${c}`);
2125
+ return p;
2126
+ }), f = !0);
2127
+ }
2128
+ f || a.push(c);
2129
+ }
2130
+ if (a.length > 0) {
2131
+ const c = await n(a);
2132
+ for (const [d, f] of c) {
2133
+ const l = o(d);
2134
+ F.set(l, f), G?.isInitialized && G.set(l, e, f), r.set(d, f);
2135
+ }
2136
+ }
2137
+ return r;
2138
+ }
2139
+ function io(t) {
2140
+ F.delete(t);
2141
+ }
2142
+ function x(t, e, n, o) {
2143
+ const s = e.toUpperCase(), i = t.find((r) => r.language.toUpperCase() === s);
2144
+ if (i)
2145
+ return {
2146
+ name: i.name,
2147
+ shortName: i.short_name ?? o ?? void 0
2148
+ };
2149
+ if (s !== "EN") {
2150
+ const r = t.find((a) => a.language.toUpperCase() === "EN");
2151
+ if (r)
2152
+ return {
2153
+ name: r.name,
2154
+ shortName: r.short_name ?? o ?? void 0
2155
+ };
2156
+ }
2157
+ return {
2158
+ name: n,
2159
+ shortName: o ?? void 0
2160
+ };
2161
+ }
2162
+ function Q(t) {
2163
+ const e = {};
2164
+ for (const n of t)
2165
+ e[n.key.toLowerCase()] = n.value;
2166
+ return e;
2167
+ }
2168
+ function K(t) {
2169
+ if (!t) return;
2170
+ const e = {};
2171
+ return t.primary_color && (e.primaryColor = t.primary_color), t.secondary_color && (e.secondaryColor = t.secondary_color), t.text_color && (e.textColor = t.text_color), t.background_color && (e.backgroundColor = t.background_color), t.background_gradient_from_color && (e.backgroundGradientFromColor = t.background_gradient_from_color), t.background_gradient_to_color && (e.backgroundGradientToColor = t.background_gradient_to_color), t.background_image && (e.backgroundImage = t.background_image), Object.keys(e).length > 0 ? e : void 0;
2172
+ }
2173
+ function X(t) {
2174
+ return t.map((e) => ({ provider: e.provider, id: e.id }));
2175
+ }
2176
+ function _n(t, e) {
2177
+ return t.filter((n) => n.relationship === e).map((n) => n.related_id);
2178
+ }
2179
+ function H(t, e, n) {
2180
+ const o = t || _n(e, "COUNTRY")[0];
2181
+ if (!o) return;
2182
+ const s = F.get(o) ?? F.get(`entity:${o}`);
2183
+ if (s?.data) {
2184
+ const i = s.data;
2185
+ return st(i, n);
2186
+ }
2187
+ return { id: o, name: o };
2188
+ }
2189
+ function st(t, e) {
2190
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []);
2191
+ return {
2192
+ id: t.id,
2193
+ name: n,
2194
+ ...t.country_code ? { code: t.country_code } : {},
2195
+ ...s.flag ? { flag: s.flag } : {},
2196
+ ...o ? { shortName: o } : {}
2197
+ };
2198
+ }
2199
+ function At(t, e) {
2200
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.branding), r = H(null, t.related ?? [], e);
2201
+ return {
2202
+ id: t.id,
2203
+ name: n,
2204
+ sport: t.sport,
2205
+ ...o ? { shortName: o } : {},
2206
+ ...t.format ? { type: t.format } : {},
2207
+ ...r ? { country: r } : {},
2208
+ ...s.logo ? { assets: { logo: s.logo } } : {},
2209
+ ...i ? { metadata: { branding: i } } : {}
2210
+ };
2211
+ }
2212
+ function nt(t, e) {
2213
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.metadata?.branding), r = H(t.country_id, t.related ?? [], e);
2214
+ return {
2215
+ id: t.id,
2216
+ name: n,
2217
+ sport: t.sport,
2218
+ ...o ? { shortName: o } : {},
2219
+ ...t.three_letter_code ? { threeLetterCode: t.three_letter_code } : {},
2220
+ ...t.full_name ? { fullName: t.full_name } : {},
2221
+ ...t.nickname ? { nickname: t.nickname } : {},
2222
+ ...t.gender ? { gender: t.gender } : {},
2223
+ ...r ? { country: r } : {},
2224
+ ...s.logo ? { assets: { logo: s.logo } } : {},
2225
+ ...i ? { metadata: { branding: i } } : {}
2226
+ };
2227
+ }
2228
+ function Wt(t, e) {
2229
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.metadata?.branding), r = H(t.country_id, t.related ?? [], e);
2230
+ return {
2231
+ id: t.id,
2232
+ name: n,
2233
+ sport: t.sport,
2234
+ type: "player",
2235
+ ...o ? { shortName: o } : {},
2236
+ ...t.position ? { position: t.position } : {},
2237
+ ...t.birth_date ? { birthdate: t.birth_date } : {},
2238
+ ...t.shirt_number != null ? { shirtNumber: t.shirt_number } : {},
2239
+ ...t.gender ? { gender: t.gender } : {},
2240
+ ...r ? { country: r } : {},
2241
+ ...s.logo || s.headshot ? { assets: { ...s.logo ? { logo: s.logo } : {}, ...s.headshot ? { photo: s.headshot } : {} } } : {},
2242
+ ...i ? { metadata: { branding: i } } : {}
2243
+ };
2244
+ }
2245
+ function zt(t, e) {
2246
+ const { name: n } = x(t.translations ?? [], e, t.name, t.short_name), o = H(t.country_id, t.related ?? [], e), s = t.capacity != null || t.latitude != null || t.longitude != null;
2247
+ return {
2248
+ id: t.id,
2249
+ name: n,
2250
+ sport: t.sport,
2251
+ ...o ? { country: o } : {},
2252
+ ...s ? {
2253
+ profile: {
2254
+ ...t.capacity != null ? { capacity: t.capacity } : {},
2255
+ ...t.latitude != null ? { latitude: t.latitude } : {},
2256
+ ...t.longitude != null ? { longitude: t.longitude } : {}
2257
+ }
2258
+ } : {}
2259
+ };
2260
+ }
2261
+ function vn(t, e) {
2262
+ const { name: n } = x(t.translations ?? [], e, t.name, t.short_name), o = H(t.country_id, t.related ?? [], e);
2263
+ return {
2264
+ id: t.id,
2265
+ name: n,
2266
+ sport: t.sport,
2267
+ ...t.birth_date ? { birthdate: t.birth_date } : {},
2268
+ ...o ? { country: o } : {}
2269
+ };
2270
+ }
2271
+ function Sn(t, e, n) {
2272
+ const o = F.get(t) ?? F.get(`entity:${t}`);
2273
+ if (!o?.data) return;
2274
+ const s = o.data;
2275
+ switch (e) {
2276
+ case "COMPETITION":
2277
+ return At(s, n);
2278
+ case "TEAM":
2279
+ return nt(s, n);
2280
+ case "ATHLETE":
2281
+ return Wt(s, n);
2282
+ case "COUNTRY":
2283
+ return st(s, n);
2284
+ default:
2285
+ return;
2286
+ }
2287
+ }
2288
+ function it(t, e) {
2289
+ if (!t || t.length === 0) return;
2290
+ const n = {};
2291
+ for (const o of t) {
2292
+ const s = Sn(o.related_id, o.relationship, e);
2293
+ if (s)
2294
+ switch (o.relationship) {
2295
+ case "COMPETITION":
2296
+ (n.competitions ??= []).push(s);
2297
+ break;
2298
+ case "TEAM":
2299
+ (n.teams ??= []).push(s);
2300
+ break;
2301
+ case "ATHLETE":
2302
+ (n.athletes ??= []).push(s);
2303
+ break;
2304
+ case "COUNTRY":
2305
+ (n.countries ??= []).push(s);
2306
+ break;
2307
+ }
2308
+ }
2309
+ return Object.keys(n).length > 0 ? n : void 0;
2310
+ }
2311
+ function An(t, e) {
2312
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.branding), r = H(null, t.related ?? [], e), a = it(t.related ?? [], e);
2313
+ return {
2314
+ id: t.id,
2315
+ name: n,
2316
+ sport: t.sport,
2317
+ ...o ? { shortName: o } : {},
2318
+ ...t.format ? { type: t.format } : {},
2319
+ ...t.gender ? { gender: t.gender } : {},
2320
+ ...r ? { country: r } : {},
2321
+ ...s.logo ? { assets: { logo: s.logo } } : {},
2322
+ ...i ? { metadata: { branding: i } } : {},
2323
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2324
+ ...a ? { related: a } : {}
2325
+ };
2326
+ }
2327
+ function Lt(t, e) {
2328
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.metadata?.branding), r = H(t.country_id, t.related ?? [], e), a = it(t.related ?? [], e);
2329
+ return {
2330
+ id: t.id,
2331
+ name: n,
2332
+ sport: t.sport,
2333
+ ...o ? { shortName: o } : {},
2334
+ ...t.three_letter_code ? { threeLetterCode: t.three_letter_code } : {},
2335
+ ...t.full_name ? { fullName: t.full_name } : {},
2336
+ ...t.nickname ? { nickname: t.nickname } : {},
2337
+ ...t.gender ? { gender: t.gender } : {},
2338
+ ...r ? { country: r } : {},
2339
+ ...s.logo ? { assets: { logo: s.logo } } : {},
2340
+ ...i ? { metadata: { branding: i } } : {},
2341
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2342
+ ...a ? { related: a } : {}
2343
+ };
2344
+ }
2345
+ function Cn(t, e) {
2346
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.metadata?.branding), r = H(t.country_id, t.related ?? [], e), a = it(t.related ?? [], e);
2347
+ return {
2348
+ id: t.id,
2349
+ name: n,
2350
+ sport: t.sport,
2351
+ type: "player",
2352
+ ...o ? { shortName: o } : {},
2353
+ ...t.position ? { position: t.position } : {},
2354
+ ...t.birth_date ? { birthdate: t.birth_date } : {},
2355
+ ...t.shirt_number != null ? { shirtNumber: t.shirt_number } : {},
2356
+ ...t.gender ? { gender: t.gender } : {},
2357
+ ...r ? { country: r } : {},
2358
+ ...s.logo || s.headshot ? { assets: { ...s.logo ? { logo: s.logo } : {}, ...s.headshot ? { photo: s.headshot } : {} } } : {},
2359
+ ...i ? { metadata: { branding: i } } : {},
2360
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2361
+ ...a ? { related: a } : {}
2362
+ };
2363
+ }
2364
+ function On(t, e) {
2365
+ return {
2366
+ ...st(t, e),
2367
+ sport: t.sport,
2368
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {}
2369
+ };
2370
+ }
2371
+ function En(t, e) {
2372
+ const { name: n } = x(t.translations ?? [], e, t.name, t.short_name), o = H(t.country_id, t.related ?? [], e), s = it(t.related ?? [], e), i = t.capacity != null || t.latitude != null || t.longitude != null;
2373
+ return {
2374
+ id: t.id,
2375
+ name: n,
2376
+ sport: t.sport,
2377
+ ...o ? { country: o } : {},
2378
+ ...i ? {
2379
+ profile: {
2380
+ ...t.capacity != null ? { capacity: t.capacity } : {},
2381
+ ...t.latitude != null ? { latitude: t.latitude } : {},
2382
+ ...t.longitude != null ? { longitude: t.longitude } : {}
2383
+ }
2384
+ } : {},
2385
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2386
+ ...s ? { related: s } : {}
2387
+ };
2388
+ }
2389
+ function Fn(t, e) {
2390
+ const { name: n } = x(t.translations ?? [], e, t.name, t.short_name), o = H(t.country_id, t.related ?? [], e), s = it(t.related ?? [], e);
2391
+ return {
2392
+ id: t.id,
2393
+ name: n,
2394
+ sport: t.sport,
2395
+ ...t.birth_date ? { birthdate: t.birth_date } : {},
2396
+ ...o ? { country: o } : {},
2397
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2398
+ ...s ? { related: s } : {}
2399
+ };
2400
+ }
2401
+ function Yt(t, e) {
2402
+ const n = t.content_type?.toUpperCase?.(), o = t.type?.toUpperCase?.(), s = t.entityType?.toLowerCase?.();
2403
+ return n === "COMPETITION" || s === "competition" ? { ...An(t, e), entityType: "competition" } : s === "country" || t.country_code !== void 0 ? { ...On(t, e), entityType: "country" } : s === "venue" || t.capacity !== void 0 && !s ? { ...En(t, e), entityType: "venue" } : s === "coach" || o === "COACH" ? { ...Fn(t, e), entityType: "coach" } : s === "athlete" || o === "PLAYER" || t.position !== void 0 || t.shirt_number !== void 0 ? { ...Cn(t, e), entityType: "athlete" } : s === "team" || o === "TEAM" || t.three_letter_code !== void 0 ? { ...Lt(t, e), entityType: "team" } : { ...Lt(t, e), entityType: "team" };
2404
+ }
2405
+ function Ln(t, e) {
2406
+ const n = t.content_type?.toUpperCase?.(), o = t.type?.toUpperCase?.(), s = t.entityType?.toLowerCase?.();
2407
+ return n === "COMPETITION" || s === "competition" ? { ...At(t, e), entityType: "competition" } : s === "country" || t.country_code !== void 0 ? { ...st(t, e), entityType: "country" } : s === "venue" || t.capacity !== void 0 && !s ? { ...zt(t, e), entityType: "venue" } : s === "coach" || o === "COACH" ? { ...vn(t, e), entityType: "coach" } : s === "athlete" || o === "PLAYER" || t.position !== void 0 || t.shirt_number !== void 0 ? { ...Wt(t, e), entityType: "athlete" } : s === "team" || o === "TEAM" || t.three_letter_code !== void 0 ? { ...nt(t, e), entityType: "team" } : { ...nt(t, e), entityType: "team" };
2408
+ }
2409
+ function J(t) {
2410
+ const e = Object.entries(t).filter(([, o]) => o !== void 0).sort(([o], [s]) => o.localeCompare(s)).map(([o, s]) => `${o}=${Array.isArray(s) ? s.join(",") : s}`).join("&");
2411
+ let n = 0;
2412
+ for (let o = 0; o < e.length; o++)
2413
+ n = (n << 5) - n + e.charCodeAt(o) | 0;
2414
+ return n.toString(36);
2415
+ }
2416
+ function V(t) {
2417
+ for (const e of t)
2418
+ e.id && F.set(`entity:${e.id}`, e);
2419
+ }
2420
+ function Y(t) {
2421
+ if (t?.lang) return t.lang;
2422
+ if (ee()) {
2423
+ const e = b();
2424
+ if (e.fansUnited && "lang" in e.fansUnited && e.fansUnited.lang)
2425
+ return e.fansUnited.lang;
2426
+ }
2427
+ return "EN";
2428
+ }
2429
+ function bt(t) {
2430
+ const e = /* @__PURE__ */ new Set();
2431
+ for (const n of t) {
2432
+ const o = n, s = o.related;
2433
+ if (s)
2434
+ for (const r of s)
2435
+ F.get(`entity:${r.related_id}`) || e.add(r.related_id);
2436
+ const i = o.country_id;
2437
+ i && !F.get(`entity:${i}`) && e.add(i);
2438
+ }
2439
+ return e;
2440
+ }
2441
+ async function _t(t, e) {
2442
+ if (t.size === 0) return [];
2443
+ const n = await B.get({
2444
+ path: "/v1/entities/search",
2445
+ params: { ids: Array.from(t) },
2446
+ next: e?.next,
2447
+ config: e?.config
1515
2448
  });
1516
- return n.sort((s, i) => new Date(s.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()), n[0];
2449
+ return V(n.data), n.data;
2450
+ }
2451
+ async function jt(t, e) {
2452
+ const n = bt(t);
2453
+ if (n.size !== 0)
2454
+ try {
2455
+ const o = await _t(n, e), s = bt(o);
2456
+ s.size > 0 && await _t(s, e);
2457
+ } catch {
2458
+ }
1517
2459
  }
1518
- function to(e, t) {
1519
- const o = /* @__PURE__ */ new Date(), n = t.filter((s) => {
1520
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, a = s.status.type === "FINISHED", r = new Date(s.timing.kickoffTime) <= o;
1521
- return i && a && r;
2460
+ async function rt(t, e) {
2461
+ const n = /* @__PURE__ */ new Set();
2462
+ for (const o of t) {
2463
+ const s = o, i = s.country_id;
2464
+ i && !F.get(`entity:${i}`) && n.add(i);
2465
+ const r = s.related;
2466
+ if (r)
2467
+ for (const a of r)
2468
+ a.relationship === "COUNTRY" && !F.get(`entity:${a.related_id}`) && n.add(a.related_id);
2469
+ }
2470
+ if (n.size !== 0)
2471
+ try {
2472
+ await _t(n, e);
2473
+ } catch {
2474
+ }
2475
+ }
2476
+ async function ro(t = {}, e) {
2477
+ const n = Y(t), o = {
2478
+ query: t.query,
2479
+ content_type: t.contentType,
2480
+ ids: t.ids,
2481
+ limit: t.limit?.toString(),
2482
+ page: t.page?.toString(),
2483
+ mode: t.mode,
2484
+ sport: t.sport,
2485
+ relationship: t.relationship,
2486
+ value: t.value
2487
+ }, s = `search:entities:${J(o)}`, i = await q(
2488
+ s,
2489
+ "search",
2490
+ () => B.get({
2491
+ path: "/v1/entities/search",
2492
+ params: o,
2493
+ next: t.next || e?.next,
2494
+ config: t.config
2495
+ })
2496
+ );
2497
+ return V(i.data), await rt(i.data, { next: t.next || e?.next, config: t.config }), { data: i.data.map(
2498
+ (a) => Ln(a, n)
2499
+ ), pagination: i.meta.pagination };
2500
+ }
2501
+ async function ao(t, e) {
2502
+ const n = Y(e), o = `entity:${t}`, s = await q(o, "search", async () => {
2503
+ const i = await B.get({
2504
+ path: "/v1/entities/search",
2505
+ params: { ids: [t] },
2506
+ next: e?.next,
2507
+ config: e?.config
2508
+ });
2509
+ if (!i.data || i.data.length === 0)
2510
+ throw new Error(`Entity not found: ${t}`);
2511
+ return i.data[0];
1522
2512
  });
1523
- return n.sort((s, i) => new Date(i.timing.kickoffTime).getTime() - new Date(s.timing.kickoffTime).getTime()), n[0];
2513
+ return await jt([s], { next: e?.next, config: e?.config }), Yt(s, n);
1524
2514
  }
1525
- function oo(e, t) {
1526
- const o = /* @__PURE__ */ new Date();
1527
- return t.filter((s) => {
1528
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, a = s.status.type === "NOT_STARTED" || s.status.type === "LIVE", r = new Date(s.timing.kickoffTime) >= o || s.status.type === "LIVE";
1529
- return i && a && r;
2515
+ async function co(t, e) {
2516
+ if (t.length === 0) return [];
2517
+ const n = Y(e), o = await Tn(
2518
+ t,
2519
+ "search",
2520
+ async (i) => {
2521
+ const r = await B.get({
2522
+ path: "/v1/entities/search",
2523
+ params: { ids: i },
2524
+ next: e?.next,
2525
+ config: e?.config
2526
+ }), a = /* @__PURE__ */ new Map();
2527
+ for (const c of r.data)
2528
+ a.set(c.id, c);
2529
+ return a;
2530
+ },
2531
+ (i) => `entity:${i}`
2532
+ ), s = t.map((i) => o.get(i)).filter((i) => i !== void 0);
2533
+ return await jt(s, { next: e?.next, config: e?.config }), s.map((i) => Yt(i, n));
2534
+ }
2535
+ async function lo(t = {}) {
2536
+ const e = Y(t), n = {
2537
+ content_type: "competition",
2538
+ query: t.query,
2539
+ limit: t.limit?.toString(),
2540
+ page: t.page?.toString(),
2541
+ sport: t.sport
2542
+ }, o = `competitions:${J(n)}`, s = await q(
2543
+ o,
2544
+ "competitions",
2545
+ () => B.get({
2546
+ path: "/v1/entities/search",
2547
+ params: n,
2548
+ next: t.next,
2549
+ config: t.config
2550
+ })
2551
+ );
2552
+ return V(s.data), await rt(s.data, { next: t.next, config: t.config }), { data: s.data.map((r) => At(r, e)), pagination: s.meta.pagination };
2553
+ }
2554
+ async function uo(t, e = {}) {
2555
+ const n = Y(e), o = {
2556
+ content_type: "team",
2557
+ relationship: "COUNTRY",
2558
+ value: t,
2559
+ query: e.query,
2560
+ limit: e.limit?.toString(),
2561
+ page: e.page?.toString(),
2562
+ sport: e.sport
2563
+ }, s = `teams:country:${t}:${J(o)}`, i = await q(
2564
+ s,
2565
+ "teams",
2566
+ () => B.get({
2567
+ path: "/v1/entities/search",
2568
+ params: o,
2569
+ next: e.next,
2570
+ config: e.config
2571
+ })
2572
+ );
2573
+ return V(i.data), await rt(i.data, { next: e.next, config: e.config }), { data: i.data.map((a) => nt(a, n)), pagination: i.meta.pagination };
2574
+ }
2575
+ async function fo(t, e = {}) {
2576
+ const n = Y(e), o = {
2577
+ content_type: "team",
2578
+ relationship: "COMPETITION",
2579
+ value: t,
2580
+ query: e.query,
2581
+ limit: e.limit?.toString(),
2582
+ page: e.page?.toString(),
2583
+ sport: e.sport
2584
+ }, s = `teams:competition:${t}:${J(o)}`, i = await q(
2585
+ s,
2586
+ "teams",
2587
+ () => B.get({
2588
+ path: "/v1/entities/search",
2589
+ params: o,
2590
+ next: e.next,
2591
+ config: e.config
2592
+ })
2593
+ );
2594
+ return V(i.data), await rt(i.data, { next: e.next, config: e.config }), { data: i.data.map((a) => nt(a, n)), pagination: i.meta.pagination };
2595
+ }
2596
+ async function ho(t = {}) {
2597
+ const e = Y(t), n = {
2598
+ content_type: "country",
2599
+ query: t.query,
2600
+ limit: t.limit?.toString(),
2601
+ page: t.page?.toString(),
2602
+ sport: t.sport
2603
+ }, o = `countries:${J(n)}`, s = await q(
2604
+ o,
2605
+ "countries",
2606
+ () => B.get({
2607
+ path: "/v1/entities/search",
2608
+ params: n,
2609
+ next: t.next,
2610
+ config: t.config
2611
+ })
2612
+ );
2613
+ return V(s.data), { data: s.data.map((r) => st(r, e)), pagination: s.meta.pagination };
2614
+ }
2615
+ async function mo(t = {}) {
2616
+ const e = Y(t), n = {
2617
+ content_type: "venue",
2618
+ query: t.query,
2619
+ limit: t.limit?.toString(),
2620
+ page: t.page?.toString(),
2621
+ sport: t.sport
2622
+ }, o = `venues:${J(n)}`, s = await q(
2623
+ o,
2624
+ "venues",
2625
+ () => B.get({
2626
+ path: "/v1/entities/search",
2627
+ params: n,
2628
+ next: t.next,
2629
+ config: t.config
2630
+ })
2631
+ );
2632
+ return V(s.data), await rt(s.data, { next: t.next, config: t.config }), { data: s.data.map((r) => zt(r, e)), pagination: s.meta.pagination };
2633
+ }
2634
+ function go(t) {
2635
+ return !t.seasons || t.seasons.length === 0 ? void 0 : t.seasons.find((n) => n.active) ?? t.seasons[0];
2636
+ }
2637
+ function po(t, e) {
2638
+ const n = /* @__PURE__ */ new Date(), o = e.filter((s) => {
2639
+ const i = s.competitorOne.id === t || s.competitorTwo.id === t, r = s.status.type === "NOT_STARTED", a = new Date(s.timing.kickoffTime) >= n;
2640
+ return i && r && a;
2641
+ });
2642
+ return o.sort((s, i) => new Date(s.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()), o[0];
2643
+ }
2644
+ function yo(t, e) {
2645
+ const n = /* @__PURE__ */ new Date(), o = e.filter((s) => {
2646
+ const i = s.competitorOne.id === t || s.competitorTwo.id === t, r = s.status.type === "FINISHED", a = new Date(s.timing.kickoffTime) <= n;
2647
+ return i && r && a;
2648
+ });
2649
+ return o.sort((s, i) => new Date(i.timing.kickoffTime).getTime() - new Date(s.timing.kickoffTime).getTime()), o[0];
2650
+ }
2651
+ function To(t, e) {
2652
+ const n = /* @__PURE__ */ new Date();
2653
+ return e.filter((s) => {
2654
+ const i = s.competitorOne.id === t || s.competitorTwo.id === t, r = s.status.type === "NOT_STARTED" || s.status.type === "LIVE", a = new Date(s.timing.kickoffTime) >= n || s.status.type === "LIVE";
2655
+ return i && r && a;
1530
2656
  }).sort(
1531
2657
  (s, i) => new Date(s.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()
1532
2658
  );
1533
2659
  }
1534
- function no(e, t) {
1535
- const o = /* @__PURE__ */ new Date();
1536
- return t.filter((s) => {
1537
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, a = s.status.type === "FINISHED", r = new Date(s.timing.kickoffTime) <= o;
1538
- return i && a && r;
2660
+ function _o(t, e) {
2661
+ const n = /* @__PURE__ */ new Date();
2662
+ return e.filter((s) => {
2663
+ const i = s.competitorOne.id === t || s.competitorTwo.id === t, r = s.status.type === "FINISHED", a = new Date(s.timing.kickoffTime) <= n;
2664
+ return i && r && a;
1539
2665
  }).sort(
1540
2666
  (s, i) => new Date(i.timing.kickoffTime).getTime() - new Date(s.timing.kickoffTime).getTime()
1541
2667
  );
1542
2668
  }
1543
- function so(e, t, o) {
1544
- const n = o.filter((a) => a.status.type === "FINISHED"), s = o.filter(
1545
- (a) => a.status.type === "NOT_STARTED" || a.status.type === "POSTPONED"
1546
- ), i = t.entries.map((a) => {
1547
- const r = a.competitor.id, c = n.filter(
1548
- (m) => m.competitorOne.id === e && m.competitorTwo.id === r || m.competitorOne.id === r && m.competitorTwo.id === e
2669
+ function vo(t, e, n) {
2670
+ const o = n.filter((r) => r.status.type === "FINISHED"), s = n.filter(
2671
+ (r) => r.status.type === "NOT_STARTED" || r.status.type === "POSTPONED"
2672
+ ), i = e.entries.map((r) => {
2673
+ const a = r.competitor.id, c = o.filter(
2674
+ (u) => u.competitorOne.id === t && u.competitorTwo.id === a || u.competitorOne.id === a && u.competitorTwo.id === t
1549
2675
  ), d = s.filter(
1550
- (m) => m.competitorOne.id === e && m.competitorTwo.id === r || m.competitorOne.id === r && m.competitorTwo.id === e
2676
+ (u) => u.competitorOne.id === t && u.competitorTwo.id === a || u.competitorOne.id === a && u.competitorTwo.id === t
1551
2677
  );
1552
- let u, l;
1553
- return c.forEach((m) => {
1554
- const p = m.competitorOne.id === e, g = parseInt(m.score?.competitorOne ?? "0"), h = parseInt(m.score?.competitorTwo ?? "0"), N = p ? g : h, S = p ? h : g;
1555
- let O;
1556
- N > S ? O = "W" : N === S ? O = "D" : O = "L";
1557
- const P = {
1558
- result: O,
1559
- score: `${g} - ${h}`,
1560
- date: m.timing.kickoffTime,
1561
- matchId: m.id,
2678
+ let f, l;
2679
+ return c.forEach((u) => {
2680
+ const h = u.competitorOne.id === t, p = parseInt(u.score?.competitorOne ?? "0"), y = parseInt(u.score?.competitorTwo ?? "0"), S = h ? p : y, g = h ? y : p;
2681
+ let T;
2682
+ S > g ? T = "W" : S === g ? T = "D" : T = "L";
2683
+ const A = {
2684
+ result: T,
2685
+ score: `${p} - ${y}`,
2686
+ date: u.timing.kickoffTime,
2687
+ matchId: u.id,
1562
2688
  isUpcoming: !1
1563
2689
  };
1564
- p ? u = P : l = P;
1565
- }), d.forEach((m) => {
1566
- const p = m.competitorOne.id === e;
1567
- p && !u ? u = {
1568
- date: m.timing.kickoffTime,
1569
- matchId: m.id,
2690
+ h ? f = A : l = A;
2691
+ }), d.forEach((u) => {
2692
+ const h = u.competitorOne.id === t;
2693
+ h && !f ? f = {
2694
+ date: u.timing.kickoffTime,
2695
+ matchId: u.id,
1570
2696
  isUpcoming: !0
1571
- } : !p && !l && (l = {
1572
- date: m.timing.kickoffTime,
1573
- matchId: m.id,
2697
+ } : !h && !l && (l = {
2698
+ date: u.timing.kickoffTime,
2699
+ matchId: u.id,
1574
2700
  isUpcoming: !0
1575
2701
  });
1576
2702
  }), {
1577
- rank: a.rank,
1578
- teamId: a.competitor.id,
1579
- teamName: a.competitor.name,
1580
- teamShortName: a.competitor.shortName,
1581
- teamLogo: a.competitor.logo,
1582
- gamesPlayed: a.stats.played ?? 0,
1583
- points: a.stats.points ?? 0,
1584
- homeResult: u,
2703
+ rank: r.rank,
2704
+ teamId: r.competitor.id,
2705
+ teamName: r.competitor.name,
2706
+ teamShortName: r.competitor.shortName,
2707
+ teamLogo: r.competitor.logo,
2708
+ gamesPlayed: r.stats.played ?? 0,
2709
+ points: r.stats.points ?? 0,
2710
+ homeResult: f,
1585
2711
  awayResult: l
1586
2712
  };
1587
2713
  });
1588
2714
  return {
1589
- teamId: e,
2715
+ teamId: t,
1590
2716
  rows: i
1591
2717
  };
1592
2718
  }
1593
- function io(e, t = 10) {
1594
- return e.players.filter((o) => (o.seasonStatistics?.goals ?? 0) > 0).sort((o, n) => {
1595
- const s = o.seasonStatistics?.goals ?? 0, i = n.seasonStatistics?.goals ?? 0;
2719
+ function So(t, e = 10) {
2720
+ return t.players.filter((n) => (n.seasonStatistics?.goals ?? 0) > 0).sort((n, o) => {
2721
+ const s = n.seasonStatistics?.goals ?? 0, i = o.seasonStatistics?.goals ?? 0;
1596
2722
  if (i !== s)
1597
2723
  return i - s;
1598
- const a = o.seasonStatistics?.assists ?? 0;
1599
- return (n.seasonStatistics?.assists ?? 0) - a;
1600
- }).slice(0, t);
2724
+ const r = n.seasonStatistics?.assists ?? 0;
2725
+ return (o.seasonStatistics?.assists ?? 0) - r;
2726
+ }).slice(0, e);
1601
2727
  }
1602
- function ao(e, t = 10) {
1603
- return e.players.filter((o) => (o.seasonStatistics?.assists ?? 0) > 0).sort((o, n) => {
1604
- const s = o.seasonStatistics?.assists ?? 0, i = n.seasonStatistics?.assists ?? 0;
2728
+ function Ao(t, e = 10) {
2729
+ return t.players.filter((n) => (n.seasonStatistics?.assists ?? 0) > 0).sort((n, o) => {
2730
+ const s = n.seasonStatistics?.assists ?? 0, i = o.seasonStatistics?.assists ?? 0;
1605
2731
  if (i !== s)
1606
2732
  return i - s;
1607
- const a = o.seasonStatistics?.goals ?? 0;
1608
- return (n.seasonStatistics?.goals ?? 0) - a;
1609
- }).slice(0, t);
2733
+ const r = n.seasonStatistics?.goals ?? 0;
2734
+ return (o.seasonStatistics?.goals ?? 0) - r;
2735
+ }).slice(0, e);
1610
2736
  }
1611
- function ro(e, t = 10) {
1612
- return e.players.filter((o) => (o.seasonStatistics?.appearances ?? 0) > 0).sort((o, n) => {
1613
- const s = o.seasonStatistics?.appearances ?? 0, i = n.seasonStatistics?.appearances ?? 0;
2737
+ function Co(t, e = 10) {
2738
+ return t.players.filter((n) => (n.seasonStatistics?.appearances ?? 0) > 0).sort((n, o) => {
2739
+ const s = n.seasonStatistics?.appearances ?? 0, i = o.seasonStatistics?.appearances ?? 0;
1614
2740
  if (i !== s)
1615
2741
  return i - s;
1616
- const a = o.seasonStatistics?.minutes ?? 0;
1617
- return (n.seasonStatistics?.minutes ?? 0) - a;
1618
- }).slice(0, t);
2742
+ const r = n.seasonStatistics?.minutes ?? 0;
2743
+ return (o.seasonStatistics?.minutes ?? 0) - r;
2744
+ }).slice(0, e);
1619
2745
  }
1620
- function co(e, t = 10) {
1621
- return e.players.filter((o) => (o.seasonStatistics?.minutes ?? 0) > 0).sort((o, n) => {
1622
- const s = o.seasonStatistics?.minutes ?? 0, i = n.seasonStatistics?.minutes ?? 0;
2746
+ function Oo(t, e = 10) {
2747
+ return t.players.filter((n) => (n.seasonStatistics?.minutes ?? 0) > 0).sort((n, o) => {
2748
+ const s = n.seasonStatistics?.minutes ?? 0, i = o.seasonStatistics?.minutes ?? 0;
1623
2749
  if (i !== s)
1624
2750
  return i - s;
1625
- const a = o.seasonStatistics?.appearances ?? 0;
1626
- return (n.seasonStatistics?.appearances ?? 0) - a;
1627
- }).slice(0, t);
2751
+ const r = n.seasonStatistics?.appearances ?? 0;
2752
+ return (o.seasonStatistics?.appearances ?? 0) - r;
2753
+ }).slice(0, e);
1628
2754
  }
1629
- function lo(e, t = 10) {
1630
- return e.players.filter((o) => (o.seasonStatistics?.cleansheets ?? 0) > 0).sort((o, n) => {
1631
- const s = o.seasonStatistics?.cleansheets ?? 0, i = n.seasonStatistics?.cleansheets ?? 0;
2755
+ function Eo(t, e = 10) {
2756
+ return t.players.filter((n) => (n.seasonStatistics?.cleansheets ?? 0) > 0).sort((n, o) => {
2757
+ const s = n.seasonStatistics?.cleansheets ?? 0, i = o.seasonStatistics?.cleansheets ?? 0;
1632
2758
  if (i !== s)
1633
2759
  return i - s;
1634
- const a = o.seasonStatistics?.appearances ?? 0;
1635
- return (n.seasonStatistics?.appearances ?? 0) - a;
1636
- }).slice(0, t);
1637
- }
1638
- function uo(e, t = 10) {
1639
- return e.players.filter((o) => {
1640
- const n = o.seasonStatistics?.yellowCards ?? 0, s = o.seasonStatistics?.redCards ?? 0;
1641
- return n + s > 0;
1642
- }).sort((o, n) => {
1643
- const s = o.seasonStatistics?.yellowCards ?? 0, i = o.seasonStatistics?.redCards ?? 0, a = n.seasonStatistics?.yellowCards ?? 0, r = n.seasonStatistics?.redCards ?? 0, c = s + i * 3, d = a + r * 3;
1644
- return d !== c ? d - c : r !== i ? r - i : a - s;
1645
- }).slice(0, t);
1646
- }
1647
- function H(e) {
1648
- const t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
1649
- return e.forEach((n) => {
1650
- !n.mainEvents || n.mainEvents.length === 0 || n.mainEvents.forEach((s) => {
2760
+ const r = n.seasonStatistics?.appearances ?? 0;
2761
+ return (o.seasonStatistics?.appearances ?? 0) - r;
2762
+ }).slice(0, e);
2763
+ }
2764
+ function Fo(t, e = 10) {
2765
+ return t.players.filter((n) => {
2766
+ const o = n.seasonStatistics?.yellowCards ?? 0, s = n.seasonStatistics?.redCards ?? 0;
2767
+ return o + s > 0;
2768
+ }).sort((n, o) => {
2769
+ const s = n.seasonStatistics?.yellowCards ?? 0, i = n.seasonStatistics?.redCards ?? 0, r = o.seasonStatistics?.yellowCards ?? 0, a = o.seasonStatistics?.redCards ?? 0, c = s + i * 3, d = r + a * 3;
2770
+ return d !== c ? d - c : a !== i ? a - i : r - s;
2771
+ }).slice(0, e);
2772
+ }
2773
+ function Z(t) {
2774
+ const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
2775
+ return t.forEach((o) => {
2776
+ !o.mainEvents || o.mainEvents.length === 0 || o.mainEvents.forEach((s) => {
1651
2777
  if (s.primaryPlayer) {
1652
2778
  const i = s.primaryPlayer.id;
1653
- t.has(i) || t.set(i, {
2779
+ e.has(i) || e.set(i, {
1654
2780
  playerId: s.primaryPlayer.id,
1655
2781
  seasonId: "",
1656
2782
  // Not applicable for match aggregation
@@ -1662,12 +2788,12 @@ function H(e) {
1662
2788
  redCards: 0,
1663
2789
  appearances: 0
1664
2790
  });
1665
- const a = t.get(i);
1666
- o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(n.id), (s.type === "GOAL" || s.type === "PENALTY_GOAL") && (a.goals = (a.goals ?? 0) + 1), s.type === "YELLOW_CARD" && (a.yellowCards = (a.yellowCards ?? 0) + 1), (s.type === "RED_CARD" || s.type === "YELLOW_RED_CARD") && (a.redCards = (a.redCards ?? 0) + 1);
2791
+ const r = e.get(i);
2792
+ n.has(i) || n.set(i, /* @__PURE__ */ new Set()), n.get(i).add(o.id), (s.type === "GOAL" || s.type === "PENALTY_GOAL") && (r.goals = (r.goals ?? 0) + 1), s.type === "YELLOW_CARD" && (r.yellowCards = (r.yellowCards ?? 0) + 1), (s.type === "RED_CARD" || s.type === "YELLOW_RED_CARD") && (r.redCards = (r.redCards ?? 0) + 1);
1667
2793
  }
1668
2794
  if (s.secondaryPlayer && (s.type === "GOAL" || s.type === "PENALTY_GOAL")) {
1669
2795
  const i = s.secondaryPlayer.id;
1670
- t.has(i) || t.set(i, {
2796
+ e.has(i) || e.set(i, {
1671
2797
  playerId: s.secondaryPlayer.id,
1672
2798
  seasonId: "",
1673
2799
  // Not applicable for match aggregation
@@ -1679,205 +2805,205 @@ function H(e) {
1679
2805
  redCards: 0,
1680
2806
  appearances: 0
1681
2807
  });
1682
- const a = t.get(i);
1683
- a.assists = (a.assists ?? 0) + 1, o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(n.id);
2808
+ const r = e.get(i);
2809
+ r.assists = (r.assists ?? 0) + 1, n.has(i) || n.set(i, /* @__PURE__ */ new Set()), n.get(i).add(o.id);
1684
2810
  }
1685
2811
  });
1686
- }), o.forEach((n, s) => {
1687
- const i = t.get(s);
1688
- i && i.appearances !== void 0 && (i.appearances = n.size);
1689
- }), t;
1690
- }
1691
- function k(e) {
1692
- return Array.from(e.values()).map((t) => ({
1693
- ...t,
1694
- totalCards: (t.yellowCards ?? 0) + (t.redCards ?? 0)
2812
+ }), n.forEach((o, s) => {
2813
+ const i = e.get(s);
2814
+ i && i.appearances !== void 0 && (i.appearances = o.size);
2815
+ }), e;
2816
+ }
2817
+ function at(t) {
2818
+ return Array.from(t.values()).map((e) => ({
2819
+ ...e,
2820
+ totalCards: (e.yellowCards ?? 0) + (e.redCards ?? 0)
1695
2821
  }));
1696
2822
  }
1697
- function Ct(e, t = 10) {
1698
- const o = H(e);
1699
- return k(o).filter((s) => (s.goals ?? 0) > 0).sort((s, i) => {
1700
- const a = s.goals ?? 0, r = i.goals ?? 0;
1701
- if (r !== a)
1702
- return r - a;
2823
+ function bn(t, e = 10) {
2824
+ const n = Z(t);
2825
+ return at(n).filter((s) => (s.goals ?? 0) > 0).sort((s, i) => {
2826
+ const r = s.goals ?? 0, a = i.goals ?? 0;
2827
+ if (a !== r)
2828
+ return a - r;
1703
2829
  const c = s.assists ?? 0;
1704
2830
  return (i.assists ?? 0) - c;
1705
- }).slice(0, t);
1706
- }
1707
- function Ot(e, t = 10) {
1708
- const o = H(e);
1709
- return k(o).filter((s) => (s.assists ?? 0) > 0).sort((s, i) => {
1710
- const a = s.assists ?? 0, r = i.assists ?? 0;
1711
- if (r !== a)
1712
- return r - a;
2831
+ }).slice(0, e);
2832
+ }
2833
+ function Nn(t, e = 10) {
2834
+ const n = Z(t);
2835
+ return at(n).filter((s) => (s.assists ?? 0) > 0).sort((s, i) => {
2836
+ const r = s.assists ?? 0, a = i.assists ?? 0;
2837
+ if (a !== r)
2838
+ return a - r;
1713
2839
  const c = s.goals ?? 0;
1714
2840
  return (i.goals ?? 0) - c;
1715
- }).slice(0, t);
1716
- }
1717
- function Lt(e, t = 10) {
1718
- const o = H(e);
1719
- return k(o).filter((s) => (s.totalCards ?? 0) > 0).sort((s, i) => {
1720
- const a = (s.yellowCards ?? 0) + (s.redCards ?? 0) * 3, r = (i.yellowCards ?? 0) + (i.redCards ?? 0) * 3;
1721
- if (r !== a)
1722
- return r - a;
2841
+ }).slice(0, e);
2842
+ }
2843
+ function Rn(t, e = 10) {
2844
+ const n = Z(t);
2845
+ return at(n).filter((s) => (s.totalCards ?? 0) > 0).sort((s, i) => {
2846
+ const r = (s.yellowCards ?? 0) + (s.redCards ?? 0) * 3, a = (i.yellowCards ?? 0) + (i.redCards ?? 0) * 3;
2847
+ if (a !== r)
2848
+ return a - r;
1723
2849
  const c = s.redCards ?? 0, d = i.redCards ?? 0;
1724
2850
  if (d !== c)
1725
2851
  return d - c;
1726
- const u = s.yellowCards ?? 0;
1727
- return (i.yellowCards ?? 0) - u;
1728
- }).slice(0, t);
1729
- }
1730
- function Et(e, t = 10) {
1731
- const o = H(e);
1732
- return k(o).filter((s) => (s.goals ?? 0) + (s.assists ?? 0) > 0).sort((s, i) => {
1733
- const a = (s.goals ?? 0) + (s.assists ?? 0), r = (i.goals ?? 0) + (i.assists ?? 0);
1734
- if (r !== a)
1735
- return r - a;
2852
+ const f = s.yellowCards ?? 0;
2853
+ return (i.yellowCards ?? 0) - f;
2854
+ }).slice(0, e);
2855
+ }
2856
+ function In(t, e = 10) {
2857
+ const n = Z(t);
2858
+ return at(n).filter((s) => (s.goals ?? 0) + (s.assists ?? 0) > 0).sort((s, i) => {
2859
+ const r = (s.goals ?? 0) + (s.assists ?? 0), a = (i.goals ?? 0) + (i.assists ?? 0);
2860
+ if (a !== r)
2861
+ return a - r;
1736
2862
  const c = s.goals ?? 0, d = i.goals ?? 0;
1737
2863
  if (d !== c)
1738
2864
  return d - c;
1739
- const u = s.assists ?? 0;
1740
- return (i.assists ?? 0) - u;
1741
- }).slice(0, t);
1742
- }
1743
- function Ft(e) {
1744
- const t = H(e);
1745
- return k(t).sort((n, s) => {
1746
- const i = n.appearances ?? 0, a = s.appearances ?? 0;
1747
- if (a !== i)
1748
- return a - i;
1749
- const r = (n.goals ?? 0) + (n.assists ?? 0);
1750
- return (s.goals ?? 0) + (s.assists ?? 0) - r;
2865
+ const f = s.assists ?? 0;
2866
+ return (i.assists ?? 0) - f;
2867
+ }).slice(0, e);
2868
+ }
2869
+ function Pn(t) {
2870
+ const e = Z(t);
2871
+ return at(e).sort((o, s) => {
2872
+ const i = o.appearances ?? 0, r = s.appearances ?? 0;
2873
+ if (r !== i)
2874
+ return r - i;
2875
+ const a = (o.goals ?? 0) + (o.assists ?? 0);
2876
+ return (s.goals ?? 0) + (s.assists ?? 0) - a;
1751
2877
  });
1752
2878
  }
1753
- function mo(e, t = 10) {
1754
- return G(() => Ct(e, t), [e, t]);
2879
+ function Lo(t, e = 10) {
2880
+ return j(() => bn(t, e), [t, e]);
1755
2881
  }
1756
- function fo(e, t = 10) {
1757
- return G(() => Ot(e, t), [e, t]);
2882
+ function bo(t, e = 10) {
2883
+ return j(() => Nn(t, e), [t, e]);
1758
2884
  }
1759
- function po(e, t = 10) {
1760
- return G(() => Lt(e, t), [e, t]);
2885
+ function No(t, e = 10) {
2886
+ return j(() => Rn(t, e), [t, e]);
1761
2887
  }
1762
- function go(e, t = 10) {
1763
- return G(() => Et(e, t), [e, t]);
2888
+ function Ro(t, e = 10) {
2889
+ return j(() => In(t, e), [t, e]);
1764
2890
  }
1765
- function yo(e) {
1766
- return G(() => Ft(e), [e]);
2891
+ function Io(t) {
2892
+ return j(() => Pn(t), [t]);
1767
2893
  }
1768
- function Nt(e) {
1769
- return G(() => H(e), [e]);
2894
+ function Mn(t) {
2895
+ return j(() => Z(t), [t]);
1770
2896
  }
1771
- function ho(e, t) {
1772
- const o = Nt(e);
1773
- return G(() => o.get(t), [o, t]);
2897
+ function Po(t, e) {
2898
+ const n = Mn(t);
2899
+ return j(() => n.get(e), [n, e]);
1774
2900
  }
1775
- const Pt = ["GOAL", "PENALTY_GOAL", "OWN_GOAL"];
1776
- function L(e, t) {
1777
- return t > 0 ? e / t * 100 : 0;
2901
+ const Gn = ["GOAL", "PENALTY_GOAL", "OWN_GOAL"];
2902
+ function I(t, e) {
2903
+ return e > 0 ? t / e * 100 : 0;
1778
2904
  }
1779
- function Y(e, t) {
1780
- return t > 0 ? e / t : 0;
2905
+ function ct(t, e) {
2906
+ return e > 0 ? t / e : 0;
1781
2907
  }
1782
- function To(e, t = !1, o = 2) {
1783
- return t ? `${Math.round(e)}%` : Number.isInteger(e) ? e.toString() : e.toFixed(o);
2908
+ function Mo(t, e = !1, n = 2) {
2909
+ return e ? `${Math.round(t)}%` : Number.isInteger(t) ? t.toString() : t.toFixed(n);
1784
2910
  }
1785
- function _o(e, t) {
1786
- const o = typeof e == "string" ? parseFloat(e) : e;
1787
- if (isNaN(o) || t === 0) return "0";
1788
- const n = (o / t).toFixed(1);
1789
- return `${o} (${n} avg)`;
2911
+ function Go(t, e) {
2912
+ const n = typeof t == "string" ? parseFloat(t) : t;
2913
+ if (isNaN(n) || e === 0) return "0";
2914
+ const o = (n / e).toFixed(1);
2915
+ return `${n} (${o} avg)`;
1790
2916
  }
1791
- function vo(e, t) {
1792
- const o = typeof e == "string" ? parseFloat(e) : e;
1793
- return isNaN(o) || t === 0 ? "0.0" : (o / t).toFixed(1);
2917
+ function Do(t, e) {
2918
+ const n = typeof t == "string" ? parseFloat(t) : t;
2919
+ return isNaN(n) || e === 0 ? "0.0" : (n / e).toFixed(1);
1794
2920
  }
1795
- function Ao(e) {
1796
- const t = parseFloat(e);
1797
- return isNaN(t) ? "0%" : `${Math.round(t)}%`;
2921
+ function Uo(t) {
2922
+ const e = parseFloat(t);
2923
+ return isNaN(e) ? "0%" : `${Math.round(e)}%`;
1798
2924
  }
1799
- function It(e, t, o) {
1800
- if (e.status?.type !== "FINISHED" || !e.score) return null;
1801
- const n = parseInt(e.score.competitorOne || "0"), s = parseInt(e.score.competitorTwo || "0"), i = o ? n : s, a = o ? s : n;
1802
- let r = null, c = null;
1803
- const d = e.score.breakdown?.halfTime;
2925
+ function Dn(t, e, n) {
2926
+ if (t.status?.type !== "FINISHED" || !t.score) return null;
2927
+ const o = parseInt(t.score.competitorOne || "0"), s = parseInt(t.score.competitorTwo || "0"), i = n ? o : s, r = n ? s : o;
2928
+ let a = null, c = null;
2929
+ const d = t.score.breakdown?.halfTime;
1804
2930
  if (d) {
1805
- const p = parseInt(d.competitorOne || "0"), g = parseInt(d.competitorTwo || "0");
1806
- r = o ? p : g, c = o ? g : p;
2931
+ const h = parseInt(d.competitorOne || "0"), p = parseInt(d.competitorTwo || "0");
2932
+ a = n ? h : p, c = n ? p : h;
1807
2933
  }
1808
- const u = e.statistics;
1809
- let l = null, m = null;
1810
- if (u) {
1811
- const p = u.find?.((g) => g.type === "CORNERS");
1812
- p && (l = o ? p.competitorOne : p.competitorTwo, m = o ? p.competitorTwo : p.competitorOne);
2934
+ const f = t.statistics;
2935
+ let l = null, u = null;
2936
+ if (f) {
2937
+ const h = f.find?.((p) => p.type === "CORNERS");
2938
+ h && (l = n ? h.competitorOne : h.competitorTwo, u = n ? h.competitorTwo : h.competitorOne);
1813
2939
  }
1814
2940
  return {
1815
2941
  goalsFor: i,
1816
- goalsAgainst: a,
1817
- halfTimeGoalsFor: r,
2942
+ goalsAgainst: r,
2943
+ halfTimeGoalsFor: a,
1818
2944
  halfTimeGoalsAgainst: c,
1819
2945
  cornersFor: l,
1820
- cornersAgainst: m,
1821
- isWin: i > a,
1822
- isDraw: i === a,
1823
- isLoss: i < a
2946
+ cornersAgainst: u,
2947
+ isWin: i > r,
2948
+ isDraw: i === r,
2949
+ isLoss: i < r
1824
2950
  };
1825
2951
  }
1826
- function z(e, t) {
1827
- return e.competitorOne.id === t;
2952
+ function Ct(t, e) {
2953
+ return t.competitorOne.id === e;
1828
2954
  }
1829
- function Rt(e, t) {
1830
- return e.competitorTwo.id === t;
2955
+ function Un(t, e) {
2956
+ return t.competitorTwo.id === e;
1831
2957
  }
1832
- function So(e, t) {
1833
- return z(e, t) || Rt(e, t);
2958
+ function xo(t, e) {
2959
+ return Ct(t, e) || Un(t, e);
1834
2960
  }
1835
- function Co(e) {
1836
- return e.status?.type === "FINISHED";
2961
+ function Ho(t) {
2962
+ return t.status?.type === "FINISHED";
1837
2963
  }
1838
- function Oo(e, t) {
1839
- const o = z(e, t);
1840
- return parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0");
2964
+ function ko(t, e) {
2965
+ const n = Ct(t, e);
2966
+ return parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0");
1841
2967
  }
1842
- function Lo(e, t) {
1843
- const o = z(e, t);
1844
- return parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
2968
+ function $o(t, e) {
2969
+ const n = Ct(t, e);
2970
+ return parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0");
1845
2971
  }
1846
- function Eo(e, t, o) {
1847
- const n = e.filter((u) => {
1848
- if (u.status?.type !== "FINISHED" || !u.score) return !1;
1849
- const l = u.competitorOne.id === t || u.competitorTwo.id === t, m = u.competitorOne.id === o || u.competitorTwo.id === o;
1850
- return l && m;
2972
+ function Bo(t, e, n) {
2973
+ const o = t.filter((f) => {
2974
+ if (f.status?.type !== "FINISHED" || !f.score) return !1;
2975
+ const l = f.competitorOne.id === e || f.competitorTwo.id === e, u = f.competitorOne.id === n || f.competitorTwo.id === n;
2976
+ return l && u;
1851
2977
  });
1852
- let s = 0, i = 0, a = 0, r = 0, c = 0;
1853
- n.forEach((u) => {
1854
- const l = parseInt(u.score?.competitorOne || "0"), m = parseInt(u.score?.competitorTwo || "0"), p = u.competitorOne.id === t, g = p ? l : m, h = p ? m : l;
1855
- r += g, c += h, g > h ? s++ : h > g ? i++ : a++;
2978
+ let s = 0, i = 0, r = 0, a = 0, c = 0;
2979
+ o.forEach((f) => {
2980
+ const l = parseInt(f.score?.competitorOne || "0"), u = parseInt(f.score?.competitorTwo || "0"), h = f.competitorOne.id === e, p = h ? l : u, y = h ? u : l;
2981
+ a += p, c += y, p > y ? s++ : y > p ? i++ : r++;
1856
2982
  });
1857
- const d = n.length;
2983
+ const d = o.length;
1858
2984
  return {
1859
2985
  totalMatches: d,
1860
2986
  homeTeamWins: s,
1861
2987
  awayTeamWins: i,
1862
- draws: a,
1863
- homeTeamGoals: r,
2988
+ draws: r,
2989
+ homeTeamGoals: a,
1864
2990
  awayTeamGoals: c,
1865
2991
  homeTeamWinPercentage: d > 0 ? s / d * 100 : 0,
1866
2992
  awayTeamWinPercentage: d > 0 ? i / d * 100 : 0,
1867
- drawPercentage: d > 0 ? a / d * 100 : 0,
1868
- homeTeamAvgGoals: d > 0 ? r / d : 0,
2993
+ drawPercentage: d > 0 ? r / d * 100 : 0,
2994
+ homeTeamAvgGoals: d > 0 ? a / d : 0,
1869
2995
  awayTeamAvgGoals: d > 0 ? c / d : 0
1870
2996
  };
1871
2997
  }
1872
- function Fo(e, t, o, n = 5) {
1873
- return e.filter((i) => {
2998
+ function Wo(t, e, n, o = 5) {
2999
+ return t.filter((i) => {
1874
3000
  if (i.status?.type !== "FINISHED" || !i.score) return !1;
1875
- const a = i.competitorOne.id === t || i.competitorTwo.id === t, r = i.competitorOne.id === o || i.competitorTwo.id === o;
1876
- return a && r;
1877
- }).sort((i, a) => new Date(a.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()).slice(0, n).map((i) => {
1878
- const a = parseInt(i.score?.competitorOne || "0"), r = parseInt(i.score?.competitorTwo || "0"), c = i.competitorOne.id === t, d = c ? a : r, u = c ? r : a;
3001
+ const r = i.competitorOne.id === e || i.competitorTwo.id === e, a = i.competitorOne.id === n || i.competitorTwo.id === n;
3002
+ return r && a;
3003
+ }).sort((i, r) => new Date(r.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()).slice(0, o).map((i) => {
3004
+ const r = parseInt(i.score?.competitorOne || "0"), a = parseInt(i.score?.competitorTwo || "0"), c = i.competitorOne.id === e, d = c ? r : a, f = c ? a : r;
1879
3005
  let l;
1880
- return d > u ? l = "home" : u > d ? l = "away" : l = "draw", {
3006
+ return d > f ? l = "home" : f > d ? l = "away" : l = "draw", {
1881
3007
  id: i.id,
1882
3008
  date: new Date(i.timing.kickoffTime).toLocaleDateString("en-GB", {
1883
3009
  day: "numeric",
@@ -1888,52 +3014,52 @@ function Fo(e, t, o, n = 5) {
1888
3014
  awayTeamName: i.competitorTwo.name,
1889
3015
  homeTeamLogo: i.competitorOne.assets?.logo,
1890
3016
  awayTeamLogo: i.competitorTwo.assets?.logo,
1891
- homeScore: a,
1892
- awayScore: r,
3017
+ homeScore: r,
3018
+ awayScore: a,
1893
3019
  venue: i.venue?.name,
1894
3020
  winner: l
1895
3021
  };
1896
3022
  });
1897
3023
  }
1898
- function Mt(e, t, o) {
1899
- return e.filter((n) => {
1900
- const s = n.competitorOne.id === t, i = n.competitorTwo.id === t;
1901
- return !s && !i ? !1 : o === "home" ? s : i;
1902
- }).map((n) => {
1903
- const s = n.competitorOne.id === t;
1904
- return It(n, t, s);
1905
- }).filter((n) => n !== null);
3024
+ function xn(t, e, n) {
3025
+ return t.filter((o) => {
3026
+ const s = o.competitorOne.id === e, i = o.competitorTwo.id === e;
3027
+ return !s && !i ? !1 : n === "home" ? s : i;
3028
+ }).map((o) => {
3029
+ const s = o.competitorOne.id === e;
3030
+ return Dn(o, e, s);
3031
+ }).filter((o) => o !== null);
1906
3032
  }
1907
- function Z(e, t, o, n) {
3033
+ function Nt(t, e, n, o) {
1908
3034
  let s = 0;
1909
- for (const i of e) {
1910
- const a = i.competitorOne.id === t, r = i.competitorTwo.id === t;
1911
- if (!a && !r || o === "home" && !a || o === "away" && !r || i.status?.type !== "FINISHED") continue;
3035
+ for (const i of t) {
3036
+ const r = i.competitorOne.id === e, a = i.competitorTwo.id === e;
3037
+ if (!r && !a || n === "home" && !r || n === "away" && !a || i.status?.type !== "FINISHED") continue;
1912
3038
  const c = i.mainEvents;
1913
3039
  if (!c || !Array.isArray(c)) continue;
1914
- const d = c.filter((g) => g.type && Pt.includes(g.type)).sort((g, h) => {
1915
- const N = g.minute ?? 0, S = h.minute ?? 0;
1916
- return N !== S ? N - S : (g.injuryMinute ?? 0) - (h.injuryMinute ?? 0);
3040
+ const d = c.filter((p) => p.type && Gn.includes(p.type)).sort((p, y) => {
3041
+ const S = p.minute ?? 0, g = y.minute ?? 0;
3042
+ return S !== g ? S - g : (p.injuryMinute ?? 0) - (y.injuryMinute ?? 0);
1917
3043
  });
1918
3044
  if (d.length === 0) continue;
1919
- const u = d[0], l = a ? "ONE" : "TWO", m = u.type === "OWN_GOAL";
1920
- let p;
1921
- m ? p = u.competitorPosition !== l : p = u.competitorPosition === l, (n === "scored" && p || n === "conceded" && !p) && s++;
3045
+ const f = d[0], l = r ? "ONE" : "TWO", u = f.type === "OWN_GOAL";
3046
+ let h;
3047
+ u ? h = f.competitorPosition !== l : h = f.competitorPosition === l, (o === "scored" && h || o === "conceded" && !h) && s++;
1922
3048
  }
1923
3049
  return s;
1924
3050
  }
1925
- function Gt(e, t, o) {
1926
- let n = 0;
1927
- for (const s of e) {
1928
- const i = s.competitorOne.id === t, a = s.competitorTwo.id === t;
1929
- if (!i && !a || o === "home" && !i || o === "away" && !a || s.status?.type !== "FINISHED") continue;
1930
- const r = s.mainEvents;
1931
- r && Array.isArray(r) && n++;
3051
+ function Hn(t, e, n) {
3052
+ let o = 0;
3053
+ for (const s of t) {
3054
+ const i = s.competitorOne.id === e, r = s.competitorTwo.id === e;
3055
+ if (!i && !r || n === "home" && !i || n === "away" && !r || s.status?.type !== "FINISHED") continue;
3056
+ const a = s.mainEvents;
3057
+ a && Array.isArray(a) && o++;
1932
3058
  }
1933
- return n;
3059
+ return o;
1934
3060
  }
1935
- function No(e, t, o) {
1936
- const n = Mt(e, t, o), s = n.length;
3061
+ function zo(t, e, n) {
3062
+ const o = xn(t, e, n), s = o.length;
1937
3063
  if (s === 0)
1938
3064
  return {
1939
3065
  played: 0,
@@ -1954,411 +3080,423 @@ function No(e, t, o) {
1954
3080
  avgCornersFor: 0,
1955
3081
  avgCornersAgainst: 0
1956
3082
  };
1957
- const i = n.reduce((f, _) => f + _.goalsFor, 0), a = n.reduce((f, _) => f + _.goalsAgainst, 0), r = n.filter((f) => f.goalsAgainst === 0).length, c = n.filter((f) => f.isWin && f.goalsAgainst === 0).length, d = n.filter((f) => f.goalsFor > 0).length, u = n.filter((f) => f.goalsFor === 0).length, l = n.filter((f) => f.isLoss && f.goalsFor === 0).length, m = n.filter((f) => f.goalsAgainst > 0).length, p = n.filter((f) => f.halfTimeGoalsFor !== null), g = p.length, h = p.filter((f) => {
1958
- const _ = f.halfTimeGoalsFor, U = f.goalsFor - _;
1959
- return _ > 0 && U > 0;
1960
- }).length, N = Z(e, t, o, "scored"), S = Gt(e, t, o), O = p.filter((f) => f.halfTimeGoalsFor > f.halfTimeGoalsAgainst).length, P = p.filter((f) => {
1961
- const _ = f.halfTimeGoalsAgainst, U = f.goalsAgainst - _;
1962
- return _ > 0 && U > 0;
1963
- }).length, B = Z(e, t, o, "conceded"), $ = p.filter((f) => f.halfTimeGoalsAgainst > f.halfTimeGoalsFor).length, D = n.filter((f) => f.cornersFor !== null), x = D.reduce((f, _) => f + (_.cornersFor || 0), 0), W = D.reduce((f, _) => f + (_.cornersAgainst || 0), 0);
3083
+ const i = o.reduce((m, O) => m + O.goalsFor, 0), r = o.reduce((m, O) => m + O.goalsAgainst, 0), a = o.filter((m) => m.goalsAgainst === 0).length, c = o.filter((m) => m.isWin && m.goalsAgainst === 0).length, d = o.filter((m) => m.goalsFor > 0).length, f = o.filter((m) => m.goalsFor === 0).length, l = o.filter((m) => m.isLoss && m.goalsFor === 0).length, u = o.filter((m) => m.goalsAgainst > 0).length, h = o.filter((m) => m.halfTimeGoalsFor !== null), p = h.length, y = h.filter((m) => {
3084
+ const O = m.halfTimeGoalsFor, w = m.goalsFor - O;
3085
+ return O > 0 && w > 0;
3086
+ }).length, S = Nt(t, e, n, "scored"), g = Hn(t, e, n), T = h.filter((m) => m.halfTimeGoalsFor > m.halfTimeGoalsAgainst).length, A = h.filter((m) => {
3087
+ const O = m.halfTimeGoalsAgainst, w = m.goalsAgainst - O;
3088
+ return O > 0 && w > 0;
3089
+ }).length, C = Nt(t, e, n, "conceded"), v = h.filter((m) => m.halfTimeGoalsAgainst > m.halfTimeGoalsFor).length, R = o.filter((m) => m.cornersFor !== null), P = R.reduce((m, O) => m + (O.cornersFor || 0), 0), M = R.reduce((m, O) => m + (O.cornersAgainst || 0), 0);
1964
3090
  return {
1965
3091
  played: s,
1966
- goalsForPerMatch: Y(i, s),
1967
- cleanSheets: L(r, s),
1968
- wonToNil: L(c, s),
1969
- scoringRate: L(d, s),
1970
- scoredInBothHalves: L(h, g),
1971
- scoredFirst: L(N, S),
1972
- leadingAtHalfTime: L(O, g),
1973
- goalsAgainstPerMatch: Y(a, s),
1974
- failedToScore: L(u, s),
1975
- lostToNil: L(l, s),
1976
- concedingRate: L(m, s),
1977
- concededInBothHalves: L(P, g),
1978
- concededFirst: L(B, S),
1979
- losingAtHalfTime: L($, g),
1980
- avgCornersFor: Y(x, D.length),
1981
- avgCornersAgainst: Y(W, D.length)
1982
- };
1983
- }
1984
- function Dt(e, t) {
1985
- return e.filter((o) => o.status?.type !== "FINISHED" ? !1 : o.competitorOne.id === t || o.competitorTwo.id === t).map((o) => {
1986
- const n = o.competitorOne.id === t, s = parseInt(o.score?.competitorOne || "0"), i = parseInt(o.score?.competitorTwo || "0"), a = s + i, r = o.periods;
3092
+ goalsForPerMatch: ct(i, s),
3093
+ cleanSheets: I(a, s),
3094
+ wonToNil: I(c, s),
3095
+ scoringRate: I(d, s),
3096
+ scoredInBothHalves: I(y, p),
3097
+ scoredFirst: I(S, g),
3098
+ leadingAtHalfTime: I(T, p),
3099
+ goalsAgainstPerMatch: ct(r, s),
3100
+ failedToScore: I(f, s),
3101
+ lostToNil: I(l, s),
3102
+ concedingRate: I(u, s),
3103
+ concededInBothHalves: I(A, p),
3104
+ concededFirst: I(C, g),
3105
+ losingAtHalfTime: I(v, p),
3106
+ avgCornersFor: ct(P, R.length),
3107
+ avgCornersAgainst: ct(M, R.length)
3108
+ };
3109
+ }
3110
+ function kn(t, e) {
3111
+ return t.filter((n) => n.status?.type !== "FINISHED" ? !1 : n.competitorOne.id === e || n.competitorTwo.id === e).map((n) => {
3112
+ const o = n.competitorOne.id === e, s = parseInt(n.score?.competitorOne || "0"), i = parseInt(n.score?.competitorTwo || "0"), r = s + i, a = n.periods;
1987
3113
  let c = null;
1988
- if (r && Array.isArray(r)) {
1989
- const d = r.find(
1990
- (u) => u.type === "FIRST_HALF" || u.type === "1ST_HALF"
3114
+ if (a && Array.isArray(a)) {
3115
+ const d = a.find(
3116
+ (f) => f.type === "FIRST_HALF" || f.type === "1ST_HALF"
1991
3117
  );
1992
3118
  if (d?.score) {
1993
- const u = parseInt(d.score.competitorOne || "0"), l = parseInt(d.score.competitorTwo || "0");
1994
- c = u + l;
3119
+ const f = parseInt(d.score.competitorOne || "0"), l = parseInt(d.score.competitorTwo || "0");
3120
+ c = f + l;
1995
3121
  }
1996
3122
  }
1997
- return { totalGoals: a, halfTimeGoals: c, isHome: n };
3123
+ return { totalGoals: r, halfTimeGoals: c, isHome: o };
1998
3124
  });
1999
3125
  }
2000
- function y(e, t) {
2001
- return e.length === 0 ? 0 : e.filter((n) => n > t).length / e.length * 100;
3126
+ function _(t, e) {
3127
+ return t.length === 0 ? 0 : t.filter((o) => o > e).length / t.length * 100;
2002
3128
  }
2003
- function Po(e, t) {
2004
- const o = Dt(e, t), n = o.filter((l) => l.isHome), s = o.filter((l) => !l.isHome), i = o.map((l) => l.totalGoals), a = n.map((l) => l.totalGoals), r = s.map((l) => l.totalGoals), c = o.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals), d = n.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals), u = s.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals);
3129
+ function Yo(t, e) {
3130
+ const n = kn(t, e), o = n.filter((l) => l.isHome), s = n.filter((l) => !l.isHome), i = n.map((l) => l.totalGoals), r = o.map((l) => l.totalGoals), a = s.map((l) => l.totalGoals), c = n.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals), d = o.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals), f = s.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals);
2005
3131
  return {
2006
3132
  over05: {
2007
- home: y(a, 0.5),
2008
- total: y(i, 0.5),
2009
- away: y(r, 0.5)
3133
+ home: _(r, 0.5),
3134
+ total: _(i, 0.5),
3135
+ away: _(a, 0.5)
2010
3136
  },
2011
3137
  over15: {
2012
- home: y(a, 1.5),
2013
- total: y(i, 1.5),
2014
- away: y(r, 1.5)
3138
+ home: _(r, 1.5),
3139
+ total: _(i, 1.5),
3140
+ away: _(a, 1.5)
2015
3141
  },
2016
3142
  over25: {
2017
- home: y(a, 2.5),
2018
- total: y(i, 2.5),
2019
- away: y(r, 2.5)
3143
+ home: _(r, 2.5),
3144
+ total: _(i, 2.5),
3145
+ away: _(a, 2.5)
2020
3146
  },
2021
3147
  over35: {
2022
- home: y(a, 3.5),
2023
- total: y(i, 3.5),
2024
- away: y(r, 3.5)
3148
+ home: _(r, 3.5),
3149
+ total: _(i, 3.5),
3150
+ away: _(a, 3.5)
2025
3151
  },
2026
3152
  over45: {
2027
- home: y(a, 4.5),
2028
- total: y(i, 4.5),
2029
- away: y(r, 4.5)
3153
+ home: _(r, 4.5),
3154
+ total: _(i, 4.5),
3155
+ away: _(a, 4.5)
2030
3156
  },
2031
3157
  over55: {
2032
- home: y(a, 5.5),
2033
- total: y(i, 5.5),
2034
- away: y(r, 5.5)
3158
+ home: _(r, 5.5),
3159
+ total: _(i, 5.5),
3160
+ away: _(a, 5.5)
2035
3161
  },
2036
3162
  over05HT: {
2037
- home: y(d, 0.5),
2038
- total: y(c, 0.5),
2039
- away: y(u, 0.5)
3163
+ home: _(d, 0.5),
3164
+ total: _(c, 0.5),
3165
+ away: _(f, 0.5)
2040
3166
  },
2041
3167
  over15HT: {
2042
- home: y(d, 1.5),
2043
- total: y(c, 1.5),
2044
- away: y(u, 1.5)
3168
+ home: _(d, 1.5),
3169
+ total: _(c, 1.5),
3170
+ away: _(f, 1.5)
2045
3171
  },
2046
3172
  over25HT: {
2047
- home: y(d, 2.5),
2048
- total: y(c, 2.5),
2049
- away: y(u, 2.5)
3173
+ home: _(d, 2.5),
3174
+ total: _(c, 2.5),
3175
+ away: _(f, 2.5)
2050
3176
  }
2051
3177
  };
2052
3178
  }
2053
- function Ht(e, t) {
2054
- const o = e.competitorOne.id === t, n = e.competitorTwo.id === t;
2055
- if (!o && !n || !e.score) return null;
2056
- const s = parseInt(o ? e.score.competitorOne || "0" : e.score.competitorTwo || "0"), i = parseInt(o ? e.score.competitorTwo || "0" : e.score.competitorOne || "0");
2057
- let a;
2058
- return s > i ? a = "W" : s < i ? a = "L" : a = "D", {
2059
- result: { score: `${s}:${i}`, result: a, isHome: o },
2060
- isHome: o
3179
+ function $n(t, e) {
3180
+ const n = t.competitorOne.id === e, o = t.competitorTwo.id === e;
3181
+ if (!n && !o || !t.score) return null;
3182
+ const s = parseInt(n ? t.score.competitorOne || "0" : t.score.competitorTwo || "0"), i = parseInt(n ? t.score.competitorTwo || "0" : t.score.competitorOne || "0");
3183
+ let r;
3184
+ return s > i ? r = "W" : s < i ? r = "L" : r = "D", {
3185
+ result: { score: `${s}:${i}`, result: r, isHome: n },
3186
+ isHome: n
2061
3187
  };
2062
3188
  }
2063
- function Io(e, t, o, n, s, i) {
2064
- const a = t?.entries.find((I) => I.competitor.id === e), r = o?.entries.find((I) => I.competitor.id === e), c = n?.entries.find((I) => I.competitor.id === e), d = s?.entries.find((I) => I.competitor.id === e), u = i?.entries.find((I) => I.competitor.id === e);
2065
- if (!a) return null;
2066
- const l = r?.stats?.goalsFor ?? 0, m = c?.stats?.goalsFor ?? 0, p = a?.stats?.goalsFor ?? 0, g = d?.stats?.goalsAgainst ?? 0, h = u?.stats?.goalsAgainst ?? 0, N = a?.stats?.goalsAgainst ?? 0, S = r?.stats?.played ?? 0, O = c?.stats?.played ?? 0, P = a?.stats?.played ?? 0, B = P > 0 ? p / P : 0, $ = P > 0 ? N / P : 0, D = B + $, x = S > 0 ? l / S : 0, W = O > 0 ? m / O : 0, f = S > 0 ? g / S : 0, _ = O > 0 ? h / O : 0, U = x + f, ie = W + _;
3189
+ function jo(t, e, n, o, s, i) {
3190
+ const r = e?.entries.find((k) => k.competitor.id === t), a = n?.entries.find((k) => k.competitor.id === t), c = o?.entries.find((k) => k.competitor.id === t), d = s?.entries.find((k) => k.competitor.id === t), f = i?.entries.find((k) => k.competitor.id === t);
3191
+ if (!r) return null;
3192
+ const l = a?.stats?.goalsFor ?? 0, u = c?.stats?.goalsFor ?? 0, h = r?.stats?.goalsFor ?? 0, p = d?.stats?.goalsAgainst ?? 0, y = f?.stats?.goalsAgainst ?? 0, S = r?.stats?.goalsAgainst ?? 0, g = a?.stats?.played ?? 0, T = c?.stats?.played ?? 0, A = r?.stats?.played ?? 0, C = A > 0 ? h / A : 0, v = A > 0 ? S / A : 0, R = C + v, P = g > 0 ? l / g : 0, M = T > 0 ? u / T : 0, m = g > 0 ? p / g : 0, O = T > 0 ? y / T : 0, w = P + m, qt = M + O;
2067
3193
  return {
2068
3194
  homeGoals: l,
2069
- totalGoals: p,
2070
- awayGoals: m,
2071
- homeGamesPlayed: S,
2072
- awayGamesPlayed: O,
2073
- totalGamesPlayed: P,
2074
- homeGoalsConceded: g,
2075
- totalGoalsConceded: N,
2076
- awayGoalsConceded: h,
2077
- gfPerMatch: B,
2078
- gaPerMatch: $,
2079
- gfGaPerMatch: D,
2080
- homeGfPerMatch: x,
2081
- awayGfPerMatch: W,
2082
- homeGaPerMatch: f,
2083
- awayGaPerMatch: _,
2084
- homeGfGaPerMatch: U,
2085
- awayGfGaPerMatch: ie
2086
- };
2087
- }
2088
- function C(e, t, o, n) {
2089
- const s = e.filter((a) => {
2090
- const r = a.competitorOne.id === t, c = a.competitorTwo.id === t;
2091
- return !(!r && !c || a.status?.type !== "FINISHED" || n === "home" && !r || n === "away" && !c);
2092
- }).sort((a, r) => new Date(r.timing.kickoffTime).getTime() - new Date(a.timing.kickoffTime).getTime());
3195
+ totalGoals: h,
3196
+ awayGoals: u,
3197
+ homeGamesPlayed: g,
3198
+ awayGamesPlayed: T,
3199
+ totalGamesPlayed: A,
3200
+ homeGoalsConceded: p,
3201
+ totalGoalsConceded: S,
3202
+ awayGoalsConceded: y,
3203
+ gfPerMatch: C,
3204
+ gaPerMatch: v,
3205
+ gfGaPerMatch: R,
3206
+ homeGfPerMatch: P,
3207
+ awayGfPerMatch: M,
3208
+ homeGaPerMatch: m,
3209
+ awayGaPerMatch: O,
3210
+ homeGfGaPerMatch: w,
3211
+ awayGfGaPerMatch: qt
3212
+ };
3213
+ }
3214
+ function N(t, e, n, o) {
3215
+ const s = t.filter((r) => {
3216
+ const a = r.competitorOne.id === e, c = r.competitorTwo.id === e;
3217
+ return !(!a && !c || r.status?.type !== "FINISHED" || o === "home" && !a || o === "away" && !c);
3218
+ }).sort((r, a) => new Date(a.timing.kickoffTime).getTime() - new Date(r.timing.kickoffTime).getTime());
2093
3219
  if (s.length === 0) return null;
2094
3220
  let i = 0;
2095
- for (const a of s) {
2096
- const r = a.competitorOne.id === t;
2097
- if (o(a, t, r))
3221
+ for (const r of s) {
3222
+ const a = r.competitorOne.id === e;
3223
+ if (n(r, e, a))
2098
3224
  i++;
2099
3225
  else
2100
3226
  break;
2101
3227
  }
2102
3228
  return i > 0 ? i : null;
2103
3229
  }
2104
- const T = {
2105
- win: (e, t, o) => {
2106
- const n = parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0"), s = parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
2107
- return n > s;
3230
+ const E = {
3231
+ win: (t, e, n) => {
3232
+ const o = parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0"), s = parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0");
3233
+ return o > s;
2108
3234
  },
2109
- draw: (e) => e.score?.competitorOne === e.score?.competitorTwo,
2110
- loss: (e, t, o) => {
2111
- const n = parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0"), s = parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
2112
- return n < s;
3235
+ draw: (t) => t.score?.competitorOne === t.score?.competitorTwo,
3236
+ loss: (t, e, n) => {
3237
+ const o = parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0"), s = parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0");
3238
+ return o < s;
2113
3239
  },
2114
- noWin: (e, t, o) => !T.win(e, t, o),
2115
- noDraw: (e) => !T.draw(e),
2116
- noDefeat: (e, t, o) => !T.loss(e, t, o),
2117
- scored: (e, t, o) => parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0") >= 1,
2118
- conceded: (e, t, o) => parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0") >= 1,
2119
- noGoalScored: (e, t, o) => !T.scored(e, t, o),
2120
- noGoalConceded: (e, t, o) => !T.conceded(e, t, o),
2121
- over25: (e) => parseInt(e.score?.competitorOne || "0") + parseInt(e.score?.competitorTwo || "0") > 2,
2122
- under25: (e) => parseInt(e.score?.competitorOne || "0") + parseInt(e.score?.competitorTwo || "0") < 3,
2123
- scoredTwice: (e, t, o) => parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0") >= 2,
2124
- concededTwice: (e, t, o) => parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0") >= 2
3240
+ noWin: (t, e, n) => !E.win(t, e, n),
3241
+ noDraw: (t) => !E.draw(t),
3242
+ noDefeat: (t, e, n) => !E.loss(t, e, n),
3243
+ scored: (t, e, n) => parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0") >= 1,
3244
+ conceded: (t, e, n) => parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0") >= 1,
3245
+ noGoalScored: (t, e, n) => !E.scored(t, e, n),
3246
+ noGoalConceded: (t, e, n) => !E.conceded(t, e, n),
3247
+ over25: (t) => parseInt(t.score?.competitorOne || "0") + parseInt(t.score?.competitorTwo || "0") > 2,
3248
+ under25: (t) => parseInt(t.score?.competitorOne || "0") + parseInt(t.score?.competitorTwo || "0") < 3,
3249
+ scoredTwice: (t, e, n) => parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0") >= 2,
3250
+ concededTwice: (t, e, n) => parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0") >= 2
2125
3251
  };
2126
- function Q(e, t, o) {
2127
- return {
2128
- win: C(e, t, T.win, o),
2129
- draw: C(e, t, T.draw, o),
2130
- loss: C(e, t, T.loss, o),
2131
- noWin: C(e, t, T.noWin, o),
2132
- noDraw: C(e, t, T.noDraw, o),
2133
- noDefeat: C(e, t, T.noDefeat, o),
2134
- scored: C(e, t, T.scored, o),
2135
- conceded: C(e, t, T.conceded, o),
2136
- noGoalScored: C(e, t, T.noGoalScored, o),
2137
- noGoalConceded: C(e, t, T.noGoalConceded, o),
2138
- over25: C(e, t, T.over25, o),
2139
- under25: C(e, t, T.under25, o),
2140
- scoredTwice: C(e, t, T.scoredTwice, o),
2141
- concededTwice: C(e, t, T.concededTwice, o)
2142
- };
2143
- }
2144
- function Ro(e, t, o) {
2145
- const n = Q(e, t, "home"), s = Q(e, t), i = Q(e, o, "away"), a = Q(e, o);
3252
+ function lt(t, e, n) {
3253
+ return {
3254
+ win: N(t, e, E.win, n),
3255
+ draw: N(t, e, E.draw, n),
3256
+ loss: N(t, e, E.loss, n),
3257
+ noWin: N(t, e, E.noWin, n),
3258
+ noDraw: N(t, e, E.noDraw, n),
3259
+ noDefeat: N(t, e, E.noDefeat, n),
3260
+ scored: N(t, e, E.scored, n),
3261
+ conceded: N(t, e, E.conceded, n),
3262
+ noGoalScored: N(t, e, E.noGoalScored, n),
3263
+ noGoalConceded: N(t, e, E.noGoalConceded, n),
3264
+ over25: N(t, e, E.over25, n),
3265
+ under25: N(t, e, E.under25, n),
3266
+ scoredTwice: N(t, e, E.scoredTwice, n),
3267
+ concededTwice: N(t, e, E.concededTwice, n)
3268
+ };
3269
+ }
3270
+ function qo(t, e, n) {
3271
+ const o = lt(t, e, "home"), s = lt(t, e), i = lt(t, n, "away"), r = lt(t, n);
2146
3272
  return [
2147
3273
  {
2148
3274
  label: "Consecutive wins",
2149
- homeTeam: { home: n.win, total: s.win },
2150
- awayTeam: { total: a.win, home: i.win },
3275
+ homeTeam: { home: o.win, total: s.win },
3276
+ awayTeam: { total: r.win, home: i.win },
2151
3277
  colorType: "neutral"
2152
3278
  },
2153
3279
  {
2154
3280
  label: "Consecutive draws",
2155
- homeTeam: { home: n.draw, total: s.draw },
2156
- awayTeam: { total: a.draw, home: i.draw },
3281
+ homeTeam: { home: o.draw, total: s.draw },
3282
+ awayTeam: { total: r.draw, home: i.draw },
2157
3283
  colorType: "neutral"
2158
3284
  },
2159
3285
  {
2160
3286
  label: "Consecutive defeats",
2161
- homeTeam: { home: n.loss, total: s.loss },
2162
- awayTeam: { total: a.loss, home: i.loss },
3287
+ homeTeam: { home: o.loss, total: s.loss },
3288
+ awayTeam: { total: r.loss, home: i.loss },
2163
3289
  colorType: "neutral"
2164
3290
  },
2165
3291
  {
2166
3292
  label: "No win",
2167
- homeTeam: { home: n.noWin, total: s.noWin },
2168
- awayTeam: { total: a.noWin, home: i.noWin },
3293
+ homeTeam: { home: o.noWin, total: s.noWin },
3294
+ awayTeam: { total: r.noWin, home: i.noWin },
2169
3295
  colorType: "negative"
2170
3296
  },
2171
3297
  {
2172
3298
  label: "No draw",
2173
- homeTeam: { home: n.noDraw, total: s.noDraw },
2174
- awayTeam: { total: a.noDraw, home: i.noDraw },
3299
+ homeTeam: { home: o.noDraw, total: s.noDraw },
3300
+ awayTeam: { total: r.noDraw, home: i.noDraw },
2175
3301
  colorType: "neutral"
2176
3302
  },
2177
3303
  {
2178
3304
  label: "No defeat",
2179
- homeTeam: { home: n.noDefeat, total: s.noDefeat },
2180
- awayTeam: { total: a.noDefeat, home: i.noDefeat },
3305
+ homeTeam: { home: o.noDefeat, total: s.noDefeat },
3306
+ awayTeam: { total: r.noDefeat, home: i.noDefeat },
2181
3307
  colorType: "positive"
2182
3308
  },
2183
3309
  {
2184
3310
  label: "Scored at least once",
2185
- homeTeam: { home: n.scored, total: s.scored },
2186
- awayTeam: { total: a.scored, home: i.scored },
3311
+ homeTeam: { home: o.scored, total: s.scored },
3312
+ awayTeam: { total: r.scored, home: i.scored },
2187
3313
  colorType: "positive"
2188
3314
  },
2189
3315
  {
2190
3316
  label: "Conceded at least once",
2191
- homeTeam: { home: n.conceded, total: s.conceded },
2192
- awayTeam: { total: a.conceded, home: i.conceded },
3317
+ homeTeam: { home: o.conceded, total: s.conceded },
3318
+ awayTeam: { total: r.conceded, home: i.conceded },
2193
3319
  colorType: "negative"
2194
3320
  },
2195
3321
  {
2196
3322
  label: "No goal scored",
2197
- homeTeam: { home: n.noGoalScored, total: s.noGoalScored },
2198
- awayTeam: { total: a.noGoalScored, home: i.noGoalScored },
3323
+ homeTeam: { home: o.noGoalScored, total: s.noGoalScored },
3324
+ awayTeam: { total: r.noGoalScored, home: i.noGoalScored },
2199
3325
  colorType: "neutral"
2200
3326
  },
2201
3327
  {
2202
3328
  label: "No goal conceded",
2203
- homeTeam: { home: n.noGoalConceded, total: s.noGoalConceded },
2204
- awayTeam: { total: a.noGoalConceded, home: i.noGoalConceded },
3329
+ homeTeam: { home: o.noGoalConceded, total: s.noGoalConceded },
3330
+ awayTeam: { total: r.noGoalConceded, home: i.noGoalConceded },
2205
3331
  colorType: "neutral"
2206
3332
  },
2207
3333
  {
2208
3334
  label: "GS + GC over 2.5",
2209
- homeTeam: { home: n.over25, total: s.over25 },
2210
- awayTeam: { total: a.over25, home: i.over25 },
3335
+ homeTeam: { home: o.over25, total: s.over25 },
3336
+ awayTeam: { total: r.over25, home: i.over25 },
2211
3337
  colorType: "neutral"
2212
3338
  },
2213
3339
  {
2214
3340
  label: "GS + GC under 2.5",
2215
- homeTeam: { home: n.under25, total: s.under25 },
2216
- awayTeam: { total: a.under25, home: i.under25 },
3341
+ homeTeam: { home: o.under25, total: s.under25 },
3342
+ awayTeam: { total: r.under25, home: i.under25 },
2217
3343
  colorType: "neutral"
2218
3344
  },
2219
3345
  {
2220
3346
  label: "Scored at least twice",
2221
- homeTeam: { home: n.scoredTwice, total: s.scoredTwice },
2222
- awayTeam: { total: a.scoredTwice, home: i.scoredTwice },
3347
+ homeTeam: { home: o.scoredTwice, total: s.scoredTwice },
3348
+ awayTeam: { total: r.scoredTwice, home: i.scoredTwice },
2223
3349
  colorType: "positive"
2224
3350
  },
2225
3351
  {
2226
3352
  label: "Conceded at least twice",
2227
- homeTeam: { home: n.concededTwice, total: s.concededTwice },
2228
- awayTeam: { total: a.concededTwice, home: i.concededTwice },
3353
+ homeTeam: { home: o.concededTwice, total: s.concededTwice },
3354
+ awayTeam: { total: r.concededTwice, home: i.concededTwice },
2229
3355
  colorType: "negative"
2230
3356
  }
2231
3357
  ];
2232
3358
  }
2233
- function w(e, t) {
2234
- const o = /* @__PURE__ */ new Map();
2235
- return e.forEach((n) => {
2236
- if (n.status?.type !== "FINISHED") return;
2237
- const s = Ht(n, t);
3359
+ function Rt(t, e) {
3360
+ const n = /* @__PURE__ */ new Map();
3361
+ return t.forEach((o) => {
3362
+ if (o.status?.type !== "FINISHED") return;
3363
+ const s = $n(o, e);
2238
3364
  if (!s) return;
2239
- const i = s.isHome ? n.competitorTwo.id : n.competitorOne.id, a = s.isHome ? n.competitorTwo : n.competitorOne, r = o.get(i) || {
3365
+ const i = s.isHome ? o.competitorTwo.id : o.competitorOne.id, r = s.isHome ? o.competitorTwo : o.competitorOne, a = n.get(i) || {
2240
3366
  opponentId: i,
2241
- opponentName: a.name,
2242
- opponentLogo: a.assets?.logo
3367
+ opponentName: r.name,
3368
+ opponentLogo: r.assets?.logo
2243
3369
  };
2244
- s.isHome ? r.homeResult = s.result : r.awayResult = s.result, o.set(i, r);
2245
- }), o;
3370
+ s.isHome ? a.homeResult = s.result : a.awayResult = s.result, n.set(i, a);
3371
+ }), n;
2246
3372
  }
2247
- function Mo(e, t, o, n, s, i, a) {
2248
- const r = w(e, t), c = w(e, o), d = /* @__PURE__ */ new Set([
2249
- ...r.keys(),
3373
+ function Qo(t, e, n, o, s, i, r) {
3374
+ const a = Rt(t, e), c = Rt(t, n), d = /* @__PURE__ */ new Set([
3375
+ ...a.keys(),
2250
3376
  ...c.keys(),
2251
- t,
3377
+ e,
2252
3378
  // Include home team as row for away team results
2253
- o
3379
+ n
2254
3380
  // Include away team as row for home team results
2255
- ]), u = [];
3381
+ ]), f = [];
2256
3382
  return d.forEach((l) => {
2257
- const m = r.get(l), p = c.get(l);
2258
- if (!m && !p && l !== t && l !== o)
3383
+ const u = a.get(l), h = c.get(l);
3384
+ if (!u && !h && l !== e && l !== n)
2259
3385
  return;
2260
- let g, h;
2261
- l === t ? (g = n, h = i) : l === o ? (g = s, h = a) : (g = m?.opponentName || p?.opponentName || "", h = m?.opponentLogo || p?.opponentLogo), u.push({
3386
+ let p, y;
3387
+ l === e ? (p = o, y = i) : l === n ? (p = s, y = r) : (p = u?.opponentName || h?.opponentName || "", y = u?.opponentLogo || h?.opponentLogo), f.push({
2262
3388
  opponentId: l,
2263
- opponentName: g,
2264
- opponentLogo: h,
2265
- homeTeamHome: m?.homeResult,
2266
- homeTeamAway: m?.awayResult,
2267
- awayTeamHome: p?.homeResult,
2268
- awayTeamAway: p?.awayResult,
2269
- isHomeTeamRow: l === t,
2270
- isAwayTeamRow: l === o
3389
+ opponentName: p,
3390
+ opponentLogo: y,
3391
+ homeTeamHome: u?.homeResult,
3392
+ homeTeamAway: u?.awayResult,
3393
+ awayTeamHome: h?.homeResult,
3394
+ awayTeamAway: h?.awayResult,
3395
+ isHomeTeamRow: l === e,
3396
+ isAwayTeamRow: l === n
2271
3397
  });
2272
- }), u.sort((l, m) => l.isHomeTeamRow ? -1 : m.isHomeTeamRow ? 1 : l.isAwayTeamRow ? -1 : m.isAwayTeamRow ? 1 : l.opponentName.localeCompare(m.opponentName));
3398
+ }), f.sort((l, u) => l.isHomeTeamRow ? -1 : u.isHomeTeamRow ? 1 : l.isAwayTeamRow ? -1 : u.isAwayTeamRow ? 1 : l.opponentName.localeCompare(u.opponentName));
2273
3399
  }
2274
3400
  export {
2275
- Pt as GOAL_EVENT_TYPES,
2276
- Ho as addProviderRef,
2277
- H as aggregatePlayerStatisticsFromMatches,
2278
- It as analyzeMatch,
2279
- Y as calcAverage,
2280
- L as calcPercentage,
2281
- Eo as calculateH2HStats,
2282
- C as calculateStreak,
2283
- vo as formatAsAverage,
2284
- Ao as formatPossessionPercentage,
2285
- To as formatStatValue,
2286
- _o as formatWithAverage,
2287
- wt as getActiveSeason,
2288
- Ft as getAllPlayerStatisticsFromMatches,
2289
- Bt as getBasketballLivescore,
2290
- Uo as getBatchMatchOdds,
2291
- A as getConfig,
2292
- qt as getFansUnitedFootballCompetition,
2293
- Qt as getFansUnitedFootballCompetitions,
2294
- Xt as getFansUnitedFootballMatch,
2295
- Jt as getFansUnitedFootballMatches,
2296
- Kt as getFansUnitedFootballPlayer,
2297
- zt as getFansUnitedFootballPlayers,
2298
- Zt as getFansUnitedFootballSearch,
2299
- Vt as getFansUnitedFootballTeam,
2300
- jt as getFansUnitedFootballTeams,
2301
- bo as getFootballCompetition,
2302
- ko as getFootballLivescore,
2303
- Bo as getFootballMatch,
2304
- $o as getFootballMatchCommentary,
2305
- xo as getFootballMatchEvents,
2306
- Wo as getFootballMatchLineups,
2307
- Yo as getFootballMatchOdds,
2308
- Qo as getFootballMatchStatistics,
2309
- qo as getFootballMatches,
2310
- Vo as getFootballPlayerSeasonStatistics,
2311
- jo as getFootballSeasonDetails,
2312
- Ko as getFootballStandings,
2313
- zo as getFootballTeam,
2314
- Xo as getFootballTeamSquad,
2315
- Jo as getLeaderboardMatches,
2316
- Zo as getLeaderboardTeamMatches,
2317
- wo as getLeaderboardTemplate,
2318
- Ht as getMatchResult,
2319
- Lt as getMostCardedPlayersFromMatches,
2320
- Lo as getOpponentScore,
2321
- en as getProviderRefId,
2322
- Fo as getRecentH2HMeetings,
2323
- Wt as getSportal365Standings,
2324
- no as getTeamFinishedMatches,
2325
- Io as getTeamGoalStats,
2326
- No as getTeamHomeAwayStats,
2327
- uo as getTeamMostDecorated,
2328
- eo as getTeamNextMatch,
2329
- Po as getTeamOverUnderStats,
2330
- to as getTeamPreviousMatch,
2331
- so as getTeamResultsTable,
2332
- Oo as getTeamScore,
2333
- Yt as getTeamSeasonStatistics,
2334
- Q as getTeamStreaks,
2335
- Ro as getTeamStreaksComparison,
2336
- ro as getTeamTopAppearances,
2337
- ao as getTeamTopAssisters,
2338
- lo as getTeamTopCleanSheets,
2339
- co as getTeamTopMinutesPlayed,
2340
- io as getTeamTopScorers,
2341
- oo as getTeamUpcomingMatches,
2342
- Mo as getTeamsCommonOpponents,
2343
- $t as getTennisLivescore,
2344
- Ot as getTopAssistersFromMatches,
2345
- Et as getTopGoalContributorsFromMatches,
2346
- Ct as getTopScorersFromMatches,
2347
- tn as isConfigured,
2348
- Co as isMatchFinished,
2349
- Rt as isTeamAway,
2350
- z as isTeamHome,
2351
- So as isTeamInMatch,
2352
- xt as search,
2353
- kt as searchFootball,
2354
- on as setConfig,
2355
- T as streakFilters,
2356
- v as toProviderRefArray,
2357
- yo as useAllPlayerStatisticsFromMatches,
2358
- po as useMostCardedPlayersFromMatches,
2359
- ho as usePlayerStatistics,
2360
- Nt as usePlayerStatisticsMap,
2361
- fo as useTopAssistersFromMatches,
2362
- go as useTopGoalContributorsFromMatches,
2363
- mo as useTopScorersFromMatches
3401
+ Gn as GOAL_EVENT_TYPES,
3402
+ Xo as addProviderRef,
3403
+ Z as aggregatePlayerStatisticsFromMatches,
3404
+ Dn as analyzeMatch,
3405
+ q as cached,
3406
+ Tn as cachedBatch,
3407
+ ct as calcAverage,
3408
+ I as calcPercentage,
3409
+ Bo as calculateH2HStats,
3410
+ N as calculateStreak,
3411
+ Do as formatAsAverage,
3412
+ Uo as formatPossessionPercentage,
3413
+ Mo as formatStatValue,
3414
+ Go as formatWithAverage,
3415
+ go as getActiveSeason,
3416
+ Pn as getAllPlayerStatisticsFromMatches,
3417
+ Yn as getBasketballLivescore,
3418
+ Jo as getBatchMatchOdds,
3419
+ b as getConfig,
3420
+ lo as getFansUnitedCompetitions,
3421
+ ho as getFansUnitedCountries,
3422
+ co as getFansUnitedEntitiesByIds,
3423
+ ao as getFansUnitedEntityById,
3424
+ Xn as getFansUnitedFootballCompetition,
3425
+ Kn as getFansUnitedFootballCompetitions,
3426
+ eo as getFansUnitedFootballMatch,
3427
+ no as getFansUnitedFootballMatches,
3428
+ wn as getFansUnitedFootballPlayer,
3429
+ to as getFansUnitedFootballPlayers,
3430
+ oo as getFansUnitedFootballSearch,
3431
+ Jn as getFansUnitedFootballTeam,
3432
+ Zn as getFansUnitedFootballTeams,
3433
+ ro as getFansUnitedSearchEntities,
3434
+ fo as getFansUnitedTeamsByCompetition,
3435
+ uo as getFansUnitedTeamsByCountry,
3436
+ mo as getFansUnitedVenues,
3437
+ Zo as getFootballCompetition,
3438
+ wo as getFootballLivescore,
3439
+ ts as getFootballMatch,
3440
+ es as getFootballMatchCommentary,
3441
+ ns as getFootballMatchEvents,
3442
+ os as getFootballMatchLineups,
3443
+ ss as getFootballMatchOdds,
3444
+ is as getFootballMatchStatistics,
3445
+ rs as getFootballMatches,
3446
+ as as getFootballPlayerSeasonStatistics,
3447
+ cs as getFootballSeasonDetails,
3448
+ ls as getFootballStandings,
3449
+ ds as getFootballTeam,
3450
+ us as getFootballTeamSquad,
3451
+ fs as getLeaderboardMatches,
3452
+ hs as getLeaderboardTeamMatches,
3453
+ ms as getLeaderboardTemplate,
3454
+ $n as getMatchResult,
3455
+ Rn as getMostCardedPlayersFromMatches,
3456
+ $o as getOpponentScore,
3457
+ gs as getProviderRefId,
3458
+ Wo as getRecentH2HMeetings,
3459
+ Qn as getSportal365Standings,
3460
+ _o as getTeamFinishedMatches,
3461
+ jo as getTeamGoalStats,
3462
+ zo as getTeamHomeAwayStats,
3463
+ Fo as getTeamMostDecorated,
3464
+ po as getTeamNextMatch,
3465
+ Yo as getTeamOverUnderStats,
3466
+ yo as getTeamPreviousMatch,
3467
+ vo as getTeamResultsTable,
3468
+ ko as getTeamScore,
3469
+ Vn as getTeamSeasonStatistics,
3470
+ lt as getTeamStreaks,
3471
+ qo as getTeamStreaksComparison,
3472
+ Co as getTeamTopAppearances,
3473
+ Ao as getTeamTopAssisters,
3474
+ Eo as getTeamTopCleanSheets,
3475
+ Oo as getTeamTopMinutesPlayed,
3476
+ So as getTeamTopScorers,
3477
+ To as getTeamUpcomingMatches,
3478
+ Qo as getTeamsCommonOpponents,
3479
+ jn as getTennisLivescore,
3480
+ Nn as getTopAssistersFromMatches,
3481
+ In as getTopGoalContributorsFromMatches,
3482
+ bn as getTopScorersFromMatches,
3483
+ so as initL2,
3484
+ io as invalidate,
3485
+ ee as isConfigured,
3486
+ Ho as isMatchFinished,
3487
+ Un as isTeamAway,
3488
+ Ct as isTeamHome,
3489
+ xo as isTeamInMatch,
3490
+ qn as search,
3491
+ zn as searchFootball,
3492
+ ps as setConfig,
3493
+ E as streakFilters,
3494
+ L as toProviderRefArray,
3495
+ Io as useAllPlayerStatisticsFromMatches,
3496
+ No as useMostCardedPlayersFromMatches,
3497
+ Po as usePlayerStatistics,
3498
+ Mn as usePlayerStatisticsMap,
3499
+ bo as useTopAssistersFromMatches,
3500
+ Ro as useTopGoalContributorsFromMatches,
3501
+ Lo as useTopScorersFromMatches
2364
3502
  };