fansunited-data-layer 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fansunited-data-layer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as C, g as F, f as te, c as X, S as oe, a as
|
|
2
|
-
import { e as Qt, h as Xt, i as Zt, j as wt, k as eo, l as to, m as oo, n as
|
|
1
|
+
import { t as C, g as F, f as te, c as X, S as oe, a as ne, b as se, d as ie } from "./matches-CBFdPkPa.js";
|
|
2
|
+
import { e as Qt, h as Xt, i as Zt, j as wt, k as eo, l as to, m as oo, n as no, o as so, p as io, q as ro, r as ao, s as co, u as lo, v as uo, w as mo, x as fo, y as go, z as po, A as yo, B as ho } from "./matches-CBFdPkPa.js";
|
|
3
3
|
import { useMemo as P } from "react";
|
|
4
4
|
function re(e) {
|
|
5
5
|
return {
|
|
@@ -162,21 +162,21 @@ function me(e) {
|
|
|
162
162
|
throw new Error(`Unknown entity type: ${e.entity_type}`);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
async function
|
|
165
|
+
async function st(e, t) {
|
|
166
166
|
if (!e.query || e.query.trim() === "")
|
|
167
167
|
return {
|
|
168
168
|
results: [],
|
|
169
169
|
query: e.query || ""
|
|
170
170
|
};
|
|
171
|
-
const o = t || F(), { sportal365Sports:
|
|
171
|
+
const o = t || F(), { sportal365Sports: s } = o, n = e.entityTypes && e.entityTypes.length > 0 ? e.entityTypes : ["tournament", "player", "team", "president", "venue", "coach"], i = await te.get({
|
|
172
172
|
path: "/search",
|
|
173
173
|
params: {
|
|
174
174
|
query: e.query.trim(),
|
|
175
|
-
entity_type:
|
|
176
|
-
language_code: e.languageCode ??
|
|
175
|
+
entity_type: n.join(","),
|
|
176
|
+
language_code: e.languageCode ?? s?.languageCode ?? "en"
|
|
177
177
|
},
|
|
178
178
|
headers: {
|
|
179
|
-
"Accept-Language": e.languageCode ??
|
|
179
|
+
"Accept-Language": e.languageCode ?? s?.languageCode ?? "en"
|
|
180
180
|
},
|
|
181
181
|
next: e.next,
|
|
182
182
|
config: o
|
|
@@ -204,7 +204,7 @@ function G(e) {
|
|
|
204
204
|
url: e.url
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function N(e) {
|
|
208
208
|
if (e)
|
|
209
209
|
return {
|
|
210
210
|
id: e.id,
|
|
@@ -231,7 +231,7 @@ function V(e) {
|
|
|
231
231
|
slug: e.slug,
|
|
232
232
|
tagScore: e.tag_score ?? void 0,
|
|
233
233
|
sport: e.sport,
|
|
234
|
-
country:
|
|
234
|
+
country: N(e.country),
|
|
235
235
|
gender: e.gender,
|
|
236
236
|
competitionIds: e.competition_ids,
|
|
237
237
|
type: e.type,
|
|
@@ -253,7 +253,7 @@ function Z(e) {
|
|
|
253
253
|
slug: e.slug,
|
|
254
254
|
tagScore: e.tag_score ?? void 0,
|
|
255
255
|
sport: e.sport,
|
|
256
|
-
country:
|
|
256
|
+
country: N(e.country),
|
|
257
257
|
providerRef: e.id
|
|
258
258
|
};
|
|
259
259
|
}
|
|
@@ -270,7 +270,7 @@ function ge(e) {
|
|
|
270
270
|
slug: e.slug,
|
|
271
271
|
tagScore: e.tag_score ?? void 0,
|
|
272
272
|
sport: e.sport,
|
|
273
|
-
country:
|
|
273
|
+
country: N(e.country),
|
|
274
274
|
gender: e.gender,
|
|
275
275
|
providerRef: e.id
|
|
276
276
|
};
|
|
@@ -288,7 +288,7 @@ function pe(e) {
|
|
|
288
288
|
slug: e.slug,
|
|
289
289
|
tagScore: e.tag_score ?? void 0,
|
|
290
290
|
sport: e.sport,
|
|
291
|
-
country:
|
|
291
|
+
country: N(e.country),
|
|
292
292
|
gender: e.gender,
|
|
293
293
|
birthdate: e.birthdate ?? void 0,
|
|
294
294
|
position: e.position ?? void 0,
|
|
@@ -308,7 +308,7 @@ function ye(e) {
|
|
|
308
308
|
slug: e.slug,
|
|
309
309
|
tagScore: e.tag_score ?? void 0,
|
|
310
310
|
sport: e.sport,
|
|
311
|
-
country:
|
|
311
|
+
country: N(e.country),
|
|
312
312
|
gender: e.gender,
|
|
313
313
|
birthdate: e.birthdate ?? void 0,
|
|
314
314
|
providerRef: e.id
|
|
@@ -327,7 +327,7 @@ function he(e) {
|
|
|
327
327
|
slug: e.slug,
|
|
328
328
|
tagScore: e.tag_score ?? void 0,
|
|
329
329
|
sport: e.sport,
|
|
330
|
-
country:
|
|
330
|
+
country: N(e.country),
|
|
331
331
|
gender: e.gender,
|
|
332
332
|
birthdate: e.birthdate ?? void 0,
|
|
333
333
|
providerRef: e.id
|
|
@@ -346,7 +346,7 @@ function Te(e) {
|
|
|
346
346
|
slug: e.slug,
|
|
347
347
|
tagScore: e.tag_score ?? void 0,
|
|
348
348
|
sport: e.sport,
|
|
349
|
-
country:
|
|
349
|
+
country: N(e.country),
|
|
350
350
|
city: e.city ? Z(e.city) : void 0,
|
|
351
351
|
providerRef: e.id
|
|
352
352
|
};
|
|
@@ -364,7 +364,7 @@ function ve(e) {
|
|
|
364
364
|
slug: e.slug,
|
|
365
365
|
tagScore: e.tag_score ?? void 0,
|
|
366
366
|
sport: e.sport,
|
|
367
|
-
country:
|
|
367
|
+
country: N(e.country),
|
|
368
368
|
gender: e.gender,
|
|
369
369
|
type: e.type ?? void 0,
|
|
370
370
|
region: e.region ?? void 0,
|
|
@@ -437,23 +437,23 @@ function Ce(e) {
|
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
async function it(e = {}, t) {
|
|
440
|
-
const o = t ?? F(),
|
|
441
|
-
e.name && (
|
|
442
|
-
const
|
|
440
|
+
const o = t ?? F(), s = {};
|
|
441
|
+
e.name && (s.name = e.name), e.entityTypes && e.entityTypes.length > 0 && (s.entity_type = e.entityTypes.join(",")), e.sports && e.sports.length > 0 && (s.sport = e.sports.join(",")), e.eventStartTime && (s.event_start_time = e.eventStartTime), e.ids && e.ids.length > 0 && (s.ids = e.ids.join(",")), e.competitionIds && e.competitionIds.length > 0 && (s.competition_ids = e.competitionIds.join(",")), e.domain && (s.domain = e.domain), e.inputLanguage && (s.input_language = e.inputLanguage), e.translationLanguage && (s.translation_language = e.translationLanguage), e.limit !== void 0 && (s.limit = e.limit.toString()), e.offset !== void 0 && (s.offset = e.offset.toString());
|
|
442
|
+
const n = await fe.get({
|
|
443
443
|
path: "/suggest",
|
|
444
|
-
params:
|
|
444
|
+
params: s,
|
|
445
445
|
next: e.next,
|
|
446
446
|
config: o
|
|
447
447
|
});
|
|
448
|
-
return !
|
|
448
|
+
return !n.results || n.results.length === 0 ? {
|
|
449
449
|
results: [],
|
|
450
450
|
query: e.name
|
|
451
451
|
} : {
|
|
452
|
-
results:
|
|
452
|
+
results: n.results.map(Ce),
|
|
453
453
|
query: e.name
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
|
-
const Ae = X(
|
|
456
|
+
const Ae = X(ne);
|
|
457
457
|
function Oe(e, t) {
|
|
458
458
|
return {
|
|
459
459
|
teamId: e.id,
|
|
@@ -467,37 +467,37 @@ function Oe(e, t) {
|
|
|
467
467
|
};
|
|
468
468
|
}
|
|
469
469
|
async function rt(e, t) {
|
|
470
|
-
const o = t || F(),
|
|
470
|
+
const o = t || F(), s = e.next ?? { revalidate: 600 }, n = await Ae.get({
|
|
471
471
|
path: "/statistics/aggregate",
|
|
472
472
|
params: {
|
|
473
473
|
participant_ids: e.teamId,
|
|
474
474
|
season_ids: e.seasonId,
|
|
475
475
|
participant_type: "TEAM"
|
|
476
476
|
},
|
|
477
|
-
next:
|
|
477
|
+
next: s,
|
|
478
478
|
config: o
|
|
479
479
|
});
|
|
480
|
-
if (!
|
|
480
|
+
if (!n.data || n.data.length === 0)
|
|
481
481
|
throw new Error(`No statistics found for team ${e.teamId} in season ${e.seasonId}`);
|
|
482
|
-
return Oe(
|
|
482
|
+
return Oe(n.data[0], e.seasonId);
|
|
483
483
|
}
|
|
484
484
|
function Fe(e) {
|
|
485
485
|
const t = e.replace(/\/$/, "");
|
|
486
|
-
function o(
|
|
487
|
-
return `${t}${
|
|
486
|
+
function o(s) {
|
|
487
|
+
return `${t}${s}`;
|
|
488
488
|
}
|
|
489
489
|
return {
|
|
490
|
-
async get(
|
|
491
|
-
const
|
|
490
|
+
async get(s) {
|
|
491
|
+
const n = s.config || F(), { fansUnited: i } = n;
|
|
492
492
|
if (!i)
|
|
493
493
|
throw new Error(
|
|
494
494
|
"Fans United configuration is missing. Add 'fansUnited' with 'apiKey' and 'clientId' to your config."
|
|
495
495
|
);
|
|
496
496
|
if (!i.apiKey || !i.clientId)
|
|
497
497
|
throw new Error("Fans United configuration requires both 'apiKey' and 'clientId'");
|
|
498
|
-
const r = new URL(o(
|
|
499
|
-
if (r.searchParams.set("key", i.apiKey), r.searchParams.set("client_id", i.clientId),
|
|
500
|
-
for (const [u, c] of Object.entries(
|
|
498
|
+
const r = new URL(o(s.path));
|
|
499
|
+
if (r.searchParams.set("key", i.apiKey), r.searchParams.set("client_id", i.clientId), s.params)
|
|
500
|
+
for (const [u, c] of Object.entries(s.params))
|
|
501
501
|
c !== void 0 && (Array.isArray(c) ? c.length > 0 && r.searchParams.set(u, c.join(",")) : r.searchParams.set(u, c));
|
|
502
502
|
const a = 3e4, d = new URL(r.toString());
|
|
503
503
|
d.searchParams.delete("key"), d.searchParams.delete("client_id"), console.log("🔗 FansUnited API URL:", d.toString());
|
|
@@ -507,11 +507,11 @@ function Fe(e) {
|
|
|
507
507
|
Accept: "application/json",
|
|
508
508
|
"Content-Type": "application/json",
|
|
509
509
|
// Merge custom headers (they can override defaults)
|
|
510
|
-
...
|
|
510
|
+
...s.headers
|
|
511
511
|
},
|
|
512
512
|
signal: AbortSignal.timeout(a),
|
|
513
513
|
// Next.js cache options for ISR/on-demand revalidation
|
|
514
|
-
...
|
|
514
|
+
...s.next && { next: s.next }
|
|
515
515
|
});
|
|
516
516
|
if (!l.ok) {
|
|
517
517
|
let u = `Fans United API error: ${l.status} ${l.statusText}`;
|
|
@@ -585,22 +585,18 @@ function De(e) {
|
|
|
585
585
|
}
|
|
586
586
|
async function at(e, t) {
|
|
587
587
|
const o = {};
|
|
588
|
-
e?.lang ? o.lang = e.lang : o.lang = "EN",
|
|
589
|
-
const
|
|
588
|
+
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");
|
|
589
|
+
const s = await I.get({
|
|
590
590
|
path: "/v1/competitions",
|
|
591
591
|
params: o,
|
|
592
592
|
config: t,
|
|
593
593
|
next: e?.next
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
const
|
|
597
|
-
console.log("Unique raw competition IDs:", i.size), s.length !== i.size && console.warn("⚠️ API returned duplicate competitions!");
|
|
598
|
-
const r = De(n.data);
|
|
599
|
-
console.log("Transformed (first 3 items):", JSON.stringify(r.slice(0, 3), null, 2));
|
|
600
|
-
const a = /* @__PURE__ */ new Set(), d = r.filter((l) => a.has(l.id) ? !1 : (a.add(l.id), !0));
|
|
594
|
+
}), n = s.data.map((l) => l.id), i = new Set(n);
|
|
595
|
+
n.length !== i.size && console.warn("⚠️ API returned duplicate competitions!");
|
|
596
|
+
const r = De(s.data), a = /* @__PURE__ */ new Set(), d = r.filter((l) => a.has(l.id) ? !1 : (a.add(l.id), !0));
|
|
601
597
|
return r.length !== d.length && console.warn(`Removed ${r.length - d.length} duplicate competitions`), d;
|
|
602
598
|
}
|
|
603
|
-
function
|
|
599
|
+
function Ee(e) {
|
|
604
600
|
return {
|
|
605
601
|
id: e.id,
|
|
606
602
|
name: e.name,
|
|
@@ -616,13 +612,13 @@ function Ne(e) {
|
|
|
616
612
|
]
|
|
617
613
|
};
|
|
618
614
|
}
|
|
619
|
-
function
|
|
615
|
+
function Ne(e) {
|
|
620
616
|
return {
|
|
621
617
|
id: e.id,
|
|
622
618
|
name: e.name,
|
|
623
619
|
type: e.type?.toUpperCase() || "LEAGUE",
|
|
624
620
|
gender: e.gender?.toUpperCase(),
|
|
625
|
-
country: e.country ?
|
|
621
|
+
country: e.country ? Ee(e.country) : void 0,
|
|
626
622
|
assets: e.assets?.logo ? {
|
|
627
623
|
logo: e.assets.logo
|
|
628
624
|
} : void 0,
|
|
@@ -635,16 +631,16 @@ function Ee(e) {
|
|
|
635
631
|
};
|
|
636
632
|
}
|
|
637
633
|
function Ie(e) {
|
|
638
|
-
return
|
|
634
|
+
return Ne(e.data);
|
|
639
635
|
}
|
|
640
636
|
async function ct(e, t, o) {
|
|
641
|
-
const
|
|
642
|
-
t?.lang && (
|
|
637
|
+
const s = o || F(), n = {};
|
|
638
|
+
t?.lang && (n.lang = t.lang);
|
|
643
639
|
const i = await I.get({
|
|
644
640
|
path: `/v1/competitions/${e}`,
|
|
645
|
-
params:
|
|
641
|
+
params: n,
|
|
646
642
|
next: t?.next,
|
|
647
|
-
config:
|
|
643
|
+
config: s
|
|
648
644
|
});
|
|
649
645
|
return Ie(i);
|
|
650
646
|
}
|
|
@@ -694,13 +690,13 @@ function be(e) {
|
|
|
694
690
|
return Le(e.data);
|
|
695
691
|
}
|
|
696
692
|
async function lt(e, t, o) {
|
|
697
|
-
const
|
|
698
|
-
t?.lang && (
|
|
693
|
+
const s = o || F(), n = {};
|
|
694
|
+
t?.lang && (n.lang = t.lang);
|
|
699
695
|
const i = await I.get({
|
|
700
696
|
path: `/v1/teams/${e}`,
|
|
701
|
-
params:
|
|
697
|
+
params: n,
|
|
702
698
|
next: t?.next,
|
|
703
|
-
config:
|
|
699
|
+
config: s
|
|
704
700
|
});
|
|
705
701
|
return be(i);
|
|
706
702
|
}
|
|
@@ -785,48 +781,48 @@ function Ue(e) {
|
|
|
785
781
|
return e.data.map(w);
|
|
786
782
|
}
|
|
787
783
|
async function dt(e, t, o) {
|
|
788
|
-
const
|
|
789
|
-
t?.lang && (
|
|
784
|
+
const s = o || F(), n = {};
|
|
785
|
+
t?.lang && (n.lang = t.lang);
|
|
790
786
|
const i = await I.get({
|
|
791
787
|
path: `/v1/players/${e}`,
|
|
792
|
-
params:
|
|
788
|
+
params: n,
|
|
793
789
|
next: t?.next,
|
|
794
|
-
config:
|
|
790
|
+
config: s
|
|
795
791
|
});
|
|
796
792
|
return Be(i);
|
|
797
793
|
}
|
|
798
794
|
async function ut(e, t) {
|
|
799
|
-
const o = t || F(),
|
|
800
|
-
e?.lang && (
|
|
801
|
-
const
|
|
795
|
+
const o = t || F(), s = {};
|
|
796
|
+
e?.lang && (s.lang = e.lang), e?.playerIds && (s.player_ids = e.playerIds), e?.countryId && (s.country_id = e.countryId), e?.name && (s.name = e.name), e?.scope && (s.scope = e.scope), e?.limit !== void 0 && (s.limit = String(e.limit)), e?.page !== void 0 && (s.page = String(e.page)), e?.sortField && (s.sort_field = e.sortField), e?.sortOrder && (s.sort_order = e.sortOrder);
|
|
797
|
+
const n = await I.get({
|
|
802
798
|
path: "/v1/players",
|
|
803
|
-
params:
|
|
799
|
+
params: s,
|
|
804
800
|
next: e?.next,
|
|
805
801
|
config: o
|
|
806
802
|
});
|
|
807
|
-
return Ue(
|
|
803
|
+
return Ue(n);
|
|
808
804
|
}
|
|
809
805
|
async function mt(e, t, o) {
|
|
810
|
-
const
|
|
811
|
-
t?.lang && (
|
|
806
|
+
const s = o || F(), n = {};
|
|
807
|
+
t?.lang && (n.lang = t.lang);
|
|
812
808
|
const i = await I.get({
|
|
813
809
|
path: `/v1/matches/${e}`,
|
|
814
|
-
params:
|
|
810
|
+
params: n,
|
|
815
811
|
next: t?.next,
|
|
816
|
-
config:
|
|
812
|
+
config: s
|
|
817
813
|
});
|
|
818
|
-
return
|
|
814
|
+
return se(i);
|
|
819
815
|
}
|
|
820
816
|
async function ft(e, t) {
|
|
821
|
-
const o = t || F(),
|
|
822
|
-
e?.lang && (
|
|
823
|
-
const
|
|
817
|
+
const o = t || F(), s = {};
|
|
818
|
+
e?.lang && (s.lang = e.lang), e?.competitions && (s.competitions = e.competitions), e?.countries && (s.countries = e.countries), e?.fromDate && (s.from_date = e.fromDate), e?.toDate && (s.to_date = e.toDate), e?.matches && (s.matches = e.matches), e?.teams && (s.teams = e.teams), e?.status && (s.status = e.status), e?.limit !== void 0 && (s.limit = String(e.limit)), e?.page !== void 0 && (s.page = String(e.page)), e?.sortField && (s.sort_field = e.sortField), e?.sortOrder && (s.sort_order = e.sortOrder), e?.showDeleted !== void 0 && (s.show_deleted = e.showDeleted ? "true" : "false");
|
|
819
|
+
const n = await I.get({
|
|
824
820
|
path: "/v1/matches",
|
|
825
|
-
params:
|
|
821
|
+
params: s,
|
|
826
822
|
next: e?.next,
|
|
827
823
|
config: o
|
|
828
824
|
});
|
|
829
|
-
return ie(
|
|
825
|
+
return ie(n);
|
|
830
826
|
}
|
|
831
827
|
function z(e) {
|
|
832
828
|
return {
|
|
@@ -941,7 +937,7 @@ function j(e) {
|
|
|
941
937
|
async function gt(e, t) {
|
|
942
938
|
if (!e.query || e.query.trim() === "")
|
|
943
939
|
return [];
|
|
944
|
-
const o = t || F(),
|
|
940
|
+
const o = t || F(), s = {
|
|
945
941
|
q: e.query.trim()
|
|
946
942
|
}, i = (e.entityTypes && e.entityTypes.length > 0 ? e.entityTypes : ["competition", "team", "player"]).map((d) => {
|
|
947
943
|
switch (d) {
|
|
@@ -955,10 +951,10 @@ async function gt(e, t) {
|
|
|
955
951
|
return d;
|
|
956
952
|
}
|
|
957
953
|
});
|
|
958
|
-
|
|
954
|
+
s.entities = i.join(","), e.lang && (s.lang = e.lang), e.limit && (s.limit = String(e.limit));
|
|
959
955
|
const r = await I.get({
|
|
960
956
|
path: "/v1/search",
|
|
961
|
-
params:
|
|
957
|
+
params: s,
|
|
962
958
|
next: e.next,
|
|
963
959
|
config: o
|
|
964
960
|
}), a = [];
|
|
@@ -977,44 +973,44 @@ function pt(e) {
|
|
|
977
973
|
return !e.seasons || e.seasons.length === 0 ? void 0 : e.seasons.find((o) => o.active) ?? e.seasons[0];
|
|
978
974
|
}
|
|
979
975
|
function yt(e, t) {
|
|
980
|
-
const o = /* @__PURE__ */ new Date(),
|
|
981
|
-
const i =
|
|
976
|
+
const o = /* @__PURE__ */ new Date(), s = t.filter((n) => {
|
|
977
|
+
const i = n.competitorOne.id === e || n.competitorTwo.id === e, r = n.status.type === "NOT_STARTED", a = new Date(n.timing.kickoffTime) >= o;
|
|
982
978
|
return i && r && a;
|
|
983
979
|
});
|
|
984
|
-
return
|
|
980
|
+
return s.sort((n, i) => new Date(n.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()), s[0];
|
|
985
981
|
}
|
|
986
982
|
function ht(e, t) {
|
|
987
|
-
const o = /* @__PURE__ */ new Date(),
|
|
988
|
-
const i =
|
|
983
|
+
const o = /* @__PURE__ */ new Date(), s = t.filter((n) => {
|
|
984
|
+
const i = n.competitorOne.id === e || n.competitorTwo.id === e, r = n.status.type === "FINISHED", a = new Date(n.timing.kickoffTime) <= o;
|
|
989
985
|
return i && r && a;
|
|
990
986
|
});
|
|
991
|
-
return
|
|
987
|
+
return s.sort((n, i) => new Date(i.timing.kickoffTime).getTime() - new Date(n.timing.kickoffTime).getTime()), s[0];
|
|
992
988
|
}
|
|
993
989
|
function Tt(e, t) {
|
|
994
990
|
const o = /* @__PURE__ */ new Date();
|
|
995
|
-
return t.filter((
|
|
996
|
-
const i =
|
|
991
|
+
return t.filter((n) => {
|
|
992
|
+
const i = n.competitorOne.id === e || n.competitorTwo.id === e, r = n.status.type === "NOT_STARTED" || n.status.type === "LIVE", a = new Date(n.timing.kickoffTime) >= o || n.status.type === "LIVE";
|
|
997
993
|
return i && r && a;
|
|
998
994
|
}).sort(
|
|
999
|
-
(
|
|
995
|
+
(n, i) => new Date(n.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()
|
|
1000
996
|
);
|
|
1001
997
|
}
|
|
1002
998
|
function vt(e, t) {
|
|
1003
999
|
const o = /* @__PURE__ */ new Date();
|
|
1004
|
-
return t.filter((
|
|
1005
|
-
const i =
|
|
1000
|
+
return t.filter((n) => {
|
|
1001
|
+
const i = n.competitorOne.id === e || n.competitorTwo.id === e, r = n.status.type === "FINISHED", a = new Date(n.timing.kickoffTime) <= o;
|
|
1006
1002
|
return i && r && a;
|
|
1007
1003
|
}).sort(
|
|
1008
|
-
(
|
|
1004
|
+
(n, i) => new Date(i.timing.kickoffTime).getTime() - new Date(n.timing.kickoffTime).getTime()
|
|
1009
1005
|
);
|
|
1010
1006
|
}
|
|
1011
1007
|
function St(e, t, o) {
|
|
1012
|
-
const
|
|
1008
|
+
const s = o.filter((r) => r.status.type === "FINISHED"), n = o.filter(
|
|
1013
1009
|
(r) => r.status.type === "NOT_STARTED" || r.status.type === "POSTPONED"
|
|
1014
1010
|
), i = t.entries.map((r) => {
|
|
1015
|
-
const a = r.competitor.id, d =
|
|
1011
|
+
const a = r.competitor.id, d = s.filter(
|
|
1016
1012
|
(m) => m.competitorOne.id === e && m.competitorTwo.id === a || m.competitorOne.id === a && m.competitorTwo.id === e
|
|
1017
|
-
), l =
|
|
1013
|
+
), l = n.filter(
|
|
1018
1014
|
(m) => m.competitorOne.id === e && m.competitorTwo.id === a || m.competitorOne.id === a && m.competitorTwo.id === e
|
|
1019
1015
|
);
|
|
1020
1016
|
let u, c;
|
|
@@ -1059,67 +1055,67 @@ function St(e, t, o) {
|
|
|
1059
1055
|
};
|
|
1060
1056
|
}
|
|
1061
1057
|
function _t(e, t = 10) {
|
|
1062
|
-
return e.players.filter((o) => (o.seasonStatistics?.goals ?? 0) > 0).sort((o,
|
|
1063
|
-
const
|
|
1064
|
-
if (i !==
|
|
1065
|
-
return i -
|
|
1058
|
+
return e.players.filter((o) => (o.seasonStatistics?.goals ?? 0) > 0).sort((o, s) => {
|
|
1059
|
+
const n = o.seasonStatistics?.goals ?? 0, i = s.seasonStatistics?.goals ?? 0;
|
|
1060
|
+
if (i !== n)
|
|
1061
|
+
return i - n;
|
|
1066
1062
|
const r = o.seasonStatistics?.assists ?? 0;
|
|
1067
|
-
return (
|
|
1063
|
+
return (s.seasonStatistics?.assists ?? 0) - r;
|
|
1068
1064
|
}).slice(0, t);
|
|
1069
1065
|
}
|
|
1070
1066
|
function Ct(e, t = 10) {
|
|
1071
|
-
return e.players.filter((o) => (o.seasonStatistics?.assists ?? 0) > 0).sort((o,
|
|
1072
|
-
const
|
|
1073
|
-
if (i !==
|
|
1074
|
-
return i -
|
|
1067
|
+
return e.players.filter((o) => (o.seasonStatistics?.assists ?? 0) > 0).sort((o, s) => {
|
|
1068
|
+
const n = o.seasonStatistics?.assists ?? 0, i = s.seasonStatistics?.assists ?? 0;
|
|
1069
|
+
if (i !== n)
|
|
1070
|
+
return i - n;
|
|
1075
1071
|
const r = o.seasonStatistics?.goals ?? 0;
|
|
1076
|
-
return (
|
|
1072
|
+
return (s.seasonStatistics?.goals ?? 0) - r;
|
|
1077
1073
|
}).slice(0, t);
|
|
1078
1074
|
}
|
|
1079
1075
|
function At(e, t = 10) {
|
|
1080
|
-
return e.players.filter((o) => (o.seasonStatistics?.appearances ?? 0) > 0).sort((o,
|
|
1081
|
-
const
|
|
1082
|
-
if (i !==
|
|
1083
|
-
return i -
|
|
1076
|
+
return e.players.filter((o) => (o.seasonStatistics?.appearances ?? 0) > 0).sort((o, s) => {
|
|
1077
|
+
const n = o.seasonStatistics?.appearances ?? 0, i = s.seasonStatistics?.appearances ?? 0;
|
|
1078
|
+
if (i !== n)
|
|
1079
|
+
return i - n;
|
|
1084
1080
|
const r = o.seasonStatistics?.minutes ?? 0;
|
|
1085
|
-
return (
|
|
1081
|
+
return (s.seasonStatistics?.minutes ?? 0) - r;
|
|
1086
1082
|
}).slice(0, t);
|
|
1087
1083
|
}
|
|
1088
1084
|
function Ot(e, t = 10) {
|
|
1089
|
-
return e.players.filter((o) => (o.seasonStatistics?.minutes ?? 0) > 0).sort((o,
|
|
1090
|
-
const
|
|
1091
|
-
if (i !==
|
|
1092
|
-
return i -
|
|
1085
|
+
return e.players.filter((o) => (o.seasonStatistics?.minutes ?? 0) > 0).sort((o, s) => {
|
|
1086
|
+
const n = o.seasonStatistics?.minutes ?? 0, i = s.seasonStatistics?.minutes ?? 0;
|
|
1087
|
+
if (i !== n)
|
|
1088
|
+
return i - n;
|
|
1093
1089
|
const r = o.seasonStatistics?.appearances ?? 0;
|
|
1094
|
-
return (
|
|
1090
|
+
return (s.seasonStatistics?.appearances ?? 0) - r;
|
|
1095
1091
|
}).slice(0, t);
|
|
1096
1092
|
}
|
|
1097
1093
|
function Ft(e, t = 10) {
|
|
1098
|
-
return e.players.filter((o) => (o.seasonStatistics?.cleansheets ?? 0) > 0).sort((o,
|
|
1099
|
-
const
|
|
1100
|
-
if (i !==
|
|
1101
|
-
return i -
|
|
1094
|
+
return e.players.filter((o) => (o.seasonStatistics?.cleansheets ?? 0) > 0).sort((o, s) => {
|
|
1095
|
+
const n = o.seasonStatistics?.cleansheets ?? 0, i = s.seasonStatistics?.cleansheets ?? 0;
|
|
1096
|
+
if (i !== n)
|
|
1097
|
+
return i - n;
|
|
1102
1098
|
const r = o.seasonStatistics?.appearances ?? 0;
|
|
1103
|
-
return (
|
|
1099
|
+
return (s.seasonStatistics?.appearances ?? 0) - r;
|
|
1104
1100
|
}).slice(0, t);
|
|
1105
1101
|
}
|
|
1106
1102
|
function Mt(e, t = 10) {
|
|
1107
1103
|
return e.players.filter((o) => {
|
|
1108
|
-
const
|
|
1109
|
-
return
|
|
1110
|
-
}).sort((o,
|
|
1111
|
-
const
|
|
1112
|
-
return l !== d ? l - d : a !== i ? a - i : r -
|
|
1104
|
+
const s = o.seasonStatistics?.yellowCards ?? 0, n = o.seasonStatistics?.redCards ?? 0;
|
|
1105
|
+
return s + n > 0;
|
|
1106
|
+
}).sort((o, s) => {
|
|
1107
|
+
const n = o.seasonStatistics?.yellowCards ?? 0, i = o.seasonStatistics?.redCards ?? 0, r = s.seasonStatistics?.yellowCards ?? 0, a = s.seasonStatistics?.redCards ?? 0, d = n + i * 3, l = r + a * 3;
|
|
1108
|
+
return l !== d ? l - d : a !== i ? a - i : r - n;
|
|
1113
1109
|
}).slice(0, t);
|
|
1114
1110
|
}
|
|
1115
1111
|
function b(e) {
|
|
1116
1112
|
const t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
1117
|
-
return e.forEach((
|
|
1118
|
-
!
|
|
1119
|
-
if (
|
|
1120
|
-
const i =
|
|
1113
|
+
return e.forEach((s) => {
|
|
1114
|
+
!s.mainEvents || s.mainEvents.length === 0 || s.mainEvents.forEach((n) => {
|
|
1115
|
+
if (n.primaryPlayer) {
|
|
1116
|
+
const i = n.primaryPlayer.id;
|
|
1121
1117
|
t.has(i) || t.set(i, {
|
|
1122
|
-
playerId:
|
|
1118
|
+
playerId: n.primaryPlayer.id,
|
|
1123
1119
|
seasonId: "",
|
|
1124
1120
|
// Not applicable for match aggregation
|
|
1125
1121
|
teamId: "",
|
|
@@ -1131,12 +1127,12 @@ function b(e) {
|
|
|
1131
1127
|
appearances: 0
|
|
1132
1128
|
});
|
|
1133
1129
|
const r = t.get(i);
|
|
1134
|
-
o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(
|
|
1130
|
+
o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(s.id), (n.type === "GOAL" || n.type === "PENALTY_GOAL") && (r.goals = (r.goals ?? 0) + 1), n.type === "YELLOW_CARD" && (r.yellowCards = (r.yellowCards ?? 0) + 1), (n.type === "RED_CARD" || n.type === "YELLOW_RED_CARD") && (r.redCards = (r.redCards ?? 0) + 1);
|
|
1135
1131
|
}
|
|
1136
|
-
if (
|
|
1137
|
-
const i =
|
|
1132
|
+
if (n.secondaryPlayer && (n.type === "GOAL" || n.type === "PENALTY_GOAL")) {
|
|
1133
|
+
const i = n.secondaryPlayer.id;
|
|
1138
1134
|
t.has(i) || t.set(i, {
|
|
1139
|
-
playerId:
|
|
1135
|
+
playerId: n.secondaryPlayer.id,
|
|
1140
1136
|
seasonId: "",
|
|
1141
1137
|
// Not applicable for match aggregation
|
|
1142
1138
|
teamId: "",
|
|
@@ -1148,12 +1144,12 @@ function b(e) {
|
|
|
1148
1144
|
appearances: 0
|
|
1149
1145
|
});
|
|
1150
1146
|
const r = t.get(i);
|
|
1151
|
-
r.assists = (r.assists ?? 0) + 1, o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(
|
|
1147
|
+
r.assists = (r.assists ?? 0) + 1, o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(s.id);
|
|
1152
1148
|
}
|
|
1153
1149
|
});
|
|
1154
|
-
}), o.forEach((
|
|
1155
|
-
const i = t.get(
|
|
1156
|
-
i && i.appearances !== void 0 && (i.appearances =
|
|
1150
|
+
}), o.forEach((s, n) => {
|
|
1151
|
+
const i = t.get(n);
|
|
1152
|
+
i && i.appearances !== void 0 && (i.appearances = s.size);
|
|
1157
1153
|
}), t;
|
|
1158
1154
|
}
|
|
1159
1155
|
function k(e) {
|
|
@@ -1164,58 +1160,58 @@ function k(e) {
|
|
|
1164
1160
|
}
|
|
1165
1161
|
function qe(e, t = 10) {
|
|
1166
1162
|
const o = b(e);
|
|
1167
|
-
return k(o).filter((
|
|
1168
|
-
const r =
|
|
1163
|
+
return k(o).filter((n) => (n.goals ?? 0) > 0).sort((n, i) => {
|
|
1164
|
+
const r = n.goals ?? 0, a = i.goals ?? 0;
|
|
1169
1165
|
if (a !== r)
|
|
1170
1166
|
return a - r;
|
|
1171
|
-
const d =
|
|
1167
|
+
const d = n.assists ?? 0;
|
|
1172
1168
|
return (i.assists ?? 0) - d;
|
|
1173
1169
|
}).slice(0, t);
|
|
1174
1170
|
}
|
|
1175
1171
|
function je(e, t = 10) {
|
|
1176
1172
|
const o = b(e);
|
|
1177
|
-
return k(o).filter((
|
|
1178
|
-
const r =
|
|
1173
|
+
return k(o).filter((n) => (n.assists ?? 0) > 0).sort((n, i) => {
|
|
1174
|
+
const r = n.assists ?? 0, a = i.assists ?? 0;
|
|
1179
1175
|
if (a !== r)
|
|
1180
1176
|
return a - r;
|
|
1181
|
-
const d =
|
|
1177
|
+
const d = n.goals ?? 0;
|
|
1182
1178
|
return (i.goals ?? 0) - d;
|
|
1183
1179
|
}).slice(0, t);
|
|
1184
1180
|
}
|
|
1185
1181
|
function Ve(e, t = 10) {
|
|
1186
1182
|
const o = b(e);
|
|
1187
|
-
return k(o).filter((
|
|
1188
|
-
const r = (
|
|
1183
|
+
return k(o).filter((n) => (n.totalCards ?? 0) > 0).sort((n, i) => {
|
|
1184
|
+
const r = (n.yellowCards ?? 0) + (n.redCards ?? 0) * 3, a = (i.yellowCards ?? 0) + (i.redCards ?? 0) * 3;
|
|
1189
1185
|
if (a !== r)
|
|
1190
1186
|
return a - r;
|
|
1191
|
-
const d =
|
|
1187
|
+
const d = n.redCards ?? 0, l = i.redCards ?? 0;
|
|
1192
1188
|
if (l !== d)
|
|
1193
1189
|
return l - d;
|
|
1194
|
-
const u =
|
|
1190
|
+
const u = n.yellowCards ?? 0;
|
|
1195
1191
|
return (i.yellowCards ?? 0) - u;
|
|
1196
1192
|
}).slice(0, t);
|
|
1197
1193
|
}
|
|
1198
1194
|
function Ye(e, t = 10) {
|
|
1199
1195
|
const o = b(e);
|
|
1200
|
-
return k(o).filter((
|
|
1201
|
-
const r = (
|
|
1196
|
+
return k(o).filter((n) => (n.goals ?? 0) + (n.assists ?? 0) > 0).sort((n, i) => {
|
|
1197
|
+
const r = (n.goals ?? 0) + (n.assists ?? 0), a = (i.goals ?? 0) + (i.assists ?? 0);
|
|
1202
1198
|
if (a !== r)
|
|
1203
1199
|
return a - r;
|
|
1204
|
-
const d =
|
|
1200
|
+
const d = n.goals ?? 0, l = i.goals ?? 0;
|
|
1205
1201
|
if (l !== d)
|
|
1206
1202
|
return l - d;
|
|
1207
|
-
const u =
|
|
1203
|
+
const u = n.assists ?? 0;
|
|
1208
1204
|
return (i.assists ?? 0) - u;
|
|
1209
1205
|
}).slice(0, t);
|
|
1210
1206
|
}
|
|
1211
1207
|
function ze(e) {
|
|
1212
1208
|
const t = b(e);
|
|
1213
|
-
return k(t).sort((
|
|
1214
|
-
const i =
|
|
1209
|
+
return k(t).sort((s, n) => {
|
|
1210
|
+
const i = s.appearances ?? 0, r = n.appearances ?? 0;
|
|
1215
1211
|
if (r !== i)
|
|
1216
1212
|
return r - i;
|
|
1217
|
-
const a = (
|
|
1218
|
-
return (
|
|
1213
|
+
const a = (s.goals ?? 0) + (s.assists ?? 0);
|
|
1214
|
+
return (n.goals ?? 0) + (n.assists ?? 0) - a;
|
|
1219
1215
|
});
|
|
1220
1216
|
}
|
|
1221
1217
|
function Gt(e, t = 10) {
|
|
@@ -1227,10 +1223,10 @@ function Rt(e, t = 10) {
|
|
|
1227
1223
|
function Dt(e, t = 10) {
|
|
1228
1224
|
return P(() => Ve(e, t), [e, t]);
|
|
1229
1225
|
}
|
|
1230
|
-
function
|
|
1226
|
+
function Et(e, t = 10) {
|
|
1231
1227
|
return P(() => Ye(e, t), [e, t]);
|
|
1232
1228
|
}
|
|
1233
|
-
function
|
|
1229
|
+
function Nt(e) {
|
|
1234
1230
|
return P(() => ze(e), [e]);
|
|
1235
1231
|
}
|
|
1236
1232
|
function Ke(e) {
|
|
@@ -1253,8 +1249,8 @@ function Pt(e, t = !1, o = 2) {
|
|
|
1253
1249
|
function Lt(e, t) {
|
|
1254
1250
|
const o = typeof e == "string" ? parseFloat(e) : e;
|
|
1255
1251
|
if (isNaN(o) || t === 0) return "0";
|
|
1256
|
-
const
|
|
1257
|
-
return `${o} (${
|
|
1252
|
+
const s = (o / t).toFixed(1);
|
|
1253
|
+
return `${o} (${s} avg)`;
|
|
1258
1254
|
}
|
|
1259
1255
|
function bt(e, t) {
|
|
1260
1256
|
const o = typeof e == "string" ? parseFloat(e) : e;
|
|
@@ -1266,7 +1262,7 @@ function Ht(e) {
|
|
|
1266
1262
|
}
|
|
1267
1263
|
function Qe(e, t, o) {
|
|
1268
1264
|
if (e.status?.type !== "FINISHED" || !e.score) return null;
|
|
1269
|
-
const
|
|
1265
|
+
const s = parseInt(e.score.competitorOne || "0"), n = parseInt(e.score.competitorTwo || "0"), i = o ? s : n, r = o ? n : s;
|
|
1270
1266
|
let a = null, d = null;
|
|
1271
1267
|
const l = e.score.breakdown?.halfTime;
|
|
1272
1268
|
if (l) {
|
|
@@ -1312,37 +1308,37 @@ function $t(e, t) {
|
|
|
1312
1308
|
return parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
|
|
1313
1309
|
}
|
|
1314
1310
|
function xt(e, t, o) {
|
|
1315
|
-
const
|
|
1311
|
+
const s = e.filter((u) => {
|
|
1316
1312
|
if (u.status?.type !== "FINISHED" || !u.score) return !1;
|
|
1317
1313
|
const c = u.competitorOne.id === t || u.competitorTwo.id === t, m = u.competitorOne.id === o || u.competitorTwo.id === o;
|
|
1318
1314
|
return c && m;
|
|
1319
1315
|
});
|
|
1320
|
-
let
|
|
1321
|
-
|
|
1316
|
+
let n = 0, i = 0, r = 0, a = 0, d = 0;
|
|
1317
|
+
s.forEach((u) => {
|
|
1322
1318
|
const c = parseInt(u.score?.competitorOne || "0"), m = parseInt(u.score?.competitorTwo || "0"), g = u.competitorOne.id === t, p = g ? c : m, h = g ? m : c;
|
|
1323
|
-
a += p, d += h, p > h ?
|
|
1319
|
+
a += p, d += h, p > h ? n++ : h > p ? i++ : r++;
|
|
1324
1320
|
});
|
|
1325
|
-
const l =
|
|
1321
|
+
const l = s.length;
|
|
1326
1322
|
return {
|
|
1327
1323
|
totalMatches: l,
|
|
1328
|
-
homeTeamWins:
|
|
1324
|
+
homeTeamWins: n,
|
|
1329
1325
|
awayTeamWins: i,
|
|
1330
1326
|
draws: r,
|
|
1331
1327
|
homeTeamGoals: a,
|
|
1332
1328
|
awayTeamGoals: d,
|
|
1333
|
-
homeTeamWinPercentage: l > 0 ?
|
|
1329
|
+
homeTeamWinPercentage: l > 0 ? n / l * 100 : 0,
|
|
1334
1330
|
awayTeamWinPercentage: l > 0 ? i / l * 100 : 0,
|
|
1335
1331
|
drawPercentage: l > 0 ? r / l * 100 : 0,
|
|
1336
1332
|
homeTeamAvgGoals: l > 0 ? a / l : 0,
|
|
1337
1333
|
awayTeamAvgGoals: l > 0 ? d / l : 0
|
|
1338
1334
|
};
|
|
1339
1335
|
}
|
|
1340
|
-
function Wt(e, t, o,
|
|
1336
|
+
function Wt(e, t, o, s = 5) {
|
|
1341
1337
|
return e.filter((i) => {
|
|
1342
1338
|
if (i.status?.type !== "FINISHED" || !i.score) return !1;
|
|
1343
1339
|
const r = i.competitorOne.id === t || i.competitorTwo.id === t, a = i.competitorOne.id === o || i.competitorTwo.id === o;
|
|
1344
1340
|
return r && a;
|
|
1345
|
-
}).sort((i, r) => new Date(r.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()).slice(0,
|
|
1341
|
+
}).sort((i, r) => new Date(r.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()).slice(0, s).map((i) => {
|
|
1346
1342
|
const r = parseInt(i.score?.competitorOne || "0"), a = parseInt(i.score?.competitorTwo || "0"), d = i.competitorOne.id === t, l = d ? r : a, u = d ? a : r;
|
|
1347
1343
|
let c;
|
|
1348
1344
|
return l > u ? c = "home" : u > l ? c = "away" : c = "draw", {
|
|
@@ -1364,16 +1360,16 @@ function Wt(e, t, o, n = 5) {
|
|
|
1364
1360
|
});
|
|
1365
1361
|
}
|
|
1366
1362
|
function Ze(e, t, o) {
|
|
1367
|
-
return e.filter((
|
|
1368
|
-
const
|
|
1369
|
-
return !
|
|
1370
|
-
}).map((
|
|
1371
|
-
const
|
|
1372
|
-
return Qe(
|
|
1373
|
-
}).filter((
|
|
1374
|
-
}
|
|
1375
|
-
function J(e, t, o,
|
|
1376
|
-
let
|
|
1363
|
+
return e.filter((s) => {
|
|
1364
|
+
const n = s.competitorOne.id === t, i = s.competitorTwo.id === t;
|
|
1365
|
+
return !n && !i ? !1 : o === "home" ? n : i;
|
|
1366
|
+
}).map((s) => {
|
|
1367
|
+
const n = s.competitorOne.id === t;
|
|
1368
|
+
return Qe(s, t, n);
|
|
1369
|
+
}).filter((s) => s !== null);
|
|
1370
|
+
}
|
|
1371
|
+
function J(e, t, o, s) {
|
|
1372
|
+
let n = 0;
|
|
1377
1373
|
for (const i of e) {
|
|
1378
1374
|
const r = i.competitorOne.id === t, a = i.competitorTwo.id === t;
|
|
1379
1375
|
if (!r && !a || o === "home" && !r || o === "away" && !a || i.status?.type !== "FINISHED") continue;
|
|
@@ -1386,23 +1382,23 @@ function J(e, t, o, n) {
|
|
|
1386
1382
|
if (l.length === 0) continue;
|
|
1387
1383
|
const u = l[0], c = r ? "ONE" : "TWO", m = u.type === "OWN_GOAL";
|
|
1388
1384
|
let g;
|
|
1389
|
-
m ? g = u.competitorPosition !== c : g = u.competitorPosition === c, (
|
|
1385
|
+
m ? g = u.competitorPosition !== c : g = u.competitorPosition === c, (s === "scored" && g || s === "conceded" && !g) && n++;
|
|
1390
1386
|
}
|
|
1391
|
-
return
|
|
1387
|
+
return n;
|
|
1392
1388
|
}
|
|
1393
1389
|
function we(e, t, o) {
|
|
1394
|
-
let
|
|
1395
|
-
for (const
|
|
1396
|
-
const i =
|
|
1397
|
-
if (!i && !r || o === "home" && !i || o === "away" && !r ||
|
|
1398
|
-
const a =
|
|
1399
|
-
a && Array.isArray(a) &&
|
|
1390
|
+
let s = 0;
|
|
1391
|
+
for (const n of e) {
|
|
1392
|
+
const i = n.competitorOne.id === t, r = n.competitorTwo.id === t;
|
|
1393
|
+
if (!i && !r || o === "home" && !i || o === "away" && !r || n.status?.type !== "FINISHED") continue;
|
|
1394
|
+
const a = n.mainEvents;
|
|
1395
|
+
a && Array.isArray(a) && s++;
|
|
1400
1396
|
}
|
|
1401
|
-
return
|
|
1397
|
+
return s;
|
|
1402
1398
|
}
|
|
1403
1399
|
function qt(e, t, o) {
|
|
1404
|
-
const
|
|
1405
|
-
if (
|
|
1400
|
+
const s = Ze(e, t, o), n = s.length;
|
|
1401
|
+
if (n === 0)
|
|
1406
1402
|
return {
|
|
1407
1403
|
played: 0,
|
|
1408
1404
|
goalsForPerMatch: 0,
|
|
@@ -1422,26 +1418,26 @@ function qt(e, t, o) {
|
|
|
1422
1418
|
avgCornersFor: 0,
|
|
1423
1419
|
avgCornersAgainst: 0
|
|
1424
1420
|
};
|
|
1425
|
-
const i =
|
|
1421
|
+
const i = s.reduce((f, v) => f + v.goalsFor, 0), r = s.reduce((f, v) => f + v.goalsAgainst, 0), a = s.filter((f) => f.goalsAgainst === 0).length, d = s.filter((f) => f.isWin && f.goalsAgainst === 0).length, l = s.filter((f) => f.goalsFor > 0).length, u = s.filter((f) => f.goalsFor === 0).length, c = s.filter((f) => f.isLoss && f.goalsFor === 0).length, m = s.filter((f) => f.goalsAgainst > 0).length, g = s.filter((f) => f.halfTimeGoalsFor !== null), p = g.length, h = g.filter((f) => {
|
|
1426
1422
|
const v = f.halfTimeGoalsFor, H = f.goalsFor - v;
|
|
1427
1423
|
return v > 0 && H > 0;
|
|
1428
1424
|
}).length, R = J(e, t, o, "scored"), S = we(e, t, o), A = g.filter((f) => f.halfTimeGoalsFor > f.halfTimeGoalsAgainst).length, D = g.filter((f) => {
|
|
1429
1425
|
const v = f.halfTimeGoalsAgainst, H = f.goalsAgainst - v;
|
|
1430
1426
|
return v > 0 && H > 0;
|
|
1431
|
-
}).length, B = J(e, t, o, "conceded"), U = g.filter((f) => f.halfTimeGoalsAgainst > f.halfTimeGoalsFor).length, L =
|
|
1427
|
+
}).length, B = J(e, t, o, "conceded"), U = g.filter((f) => f.halfTimeGoalsAgainst > f.halfTimeGoalsFor).length, L = s.filter((f) => f.cornersFor !== null), $ = L.reduce((f, v) => f + (v.cornersFor || 0), 0), x = L.reduce((f, v) => f + (v.cornersAgainst || 0), 0);
|
|
1432
1428
|
return {
|
|
1433
|
-
played:
|
|
1434
|
-
goalsForPerMatch: W(i,
|
|
1435
|
-
cleanSheets: O(a,
|
|
1436
|
-
wonToNil: O(d,
|
|
1437
|
-
scoringRate: O(l,
|
|
1429
|
+
played: n,
|
|
1430
|
+
goalsForPerMatch: W(i, n),
|
|
1431
|
+
cleanSheets: O(a, n),
|
|
1432
|
+
wonToNil: O(d, n),
|
|
1433
|
+
scoringRate: O(l, n),
|
|
1438
1434
|
scoredInBothHalves: O(h, p),
|
|
1439
1435
|
scoredFirst: O(R, S),
|
|
1440
1436
|
leadingAtHalfTime: O(A, p),
|
|
1441
|
-
goalsAgainstPerMatch: W(r,
|
|
1442
|
-
failedToScore: O(u,
|
|
1443
|
-
lostToNil: O(c,
|
|
1444
|
-
concedingRate: O(m,
|
|
1437
|
+
goalsAgainstPerMatch: W(r, n),
|
|
1438
|
+
failedToScore: O(u, n),
|
|
1439
|
+
lostToNil: O(c, n),
|
|
1440
|
+
concedingRate: O(m, n),
|
|
1445
1441
|
concededInBothHalves: O(D, p),
|
|
1446
1442
|
concededFirst: O(B, S),
|
|
1447
1443
|
losingAtHalfTime: O(U, p),
|
|
@@ -1451,7 +1447,7 @@ function qt(e, t, o) {
|
|
|
1451
1447
|
}
|
|
1452
1448
|
function et(e, t) {
|
|
1453
1449
|
return e.filter((o) => o.status?.type !== "FINISHED" ? !1 : o.competitorOne.id === t || o.competitorTwo.id === t).map((o) => {
|
|
1454
|
-
const
|
|
1450
|
+
const s = o.competitorOne.id === t, n = parseInt(o.score?.competitorOne || "0"), i = parseInt(o.score?.competitorTwo || "0"), r = n + i, a = o.periods;
|
|
1455
1451
|
let d = null;
|
|
1456
1452
|
if (a && Array.isArray(a)) {
|
|
1457
1453
|
const l = a.find(
|
|
@@ -1462,14 +1458,14 @@ function et(e, t) {
|
|
|
1462
1458
|
d = u + c;
|
|
1463
1459
|
}
|
|
1464
1460
|
}
|
|
1465
|
-
return { totalGoals: r, halfTimeGoals: d, isHome:
|
|
1461
|
+
return { totalGoals: r, halfTimeGoals: d, isHome: s };
|
|
1466
1462
|
});
|
|
1467
1463
|
}
|
|
1468
1464
|
function y(e, t) {
|
|
1469
|
-
return e.length === 0 ? 0 : e.filter((
|
|
1465
|
+
return e.length === 0 ? 0 : e.filter((s) => s > t).length / e.length * 100;
|
|
1470
1466
|
}
|
|
1471
1467
|
function jt(e, t) {
|
|
1472
|
-
const o = et(e, t),
|
|
1468
|
+
const o = et(e, t), s = o.filter((c) => c.isHome), n = o.filter((c) => !c.isHome), i = o.map((c) => c.totalGoals), r = s.map((c) => c.totalGoals), a = n.map((c) => c.totalGoals), d = o.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals), l = s.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals), u = n.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals);
|
|
1473
1469
|
return {
|
|
1474
1470
|
over05: {
|
|
1475
1471
|
home: y(r, 0.5),
|
|
@@ -1519,17 +1515,17 @@ function jt(e, t) {
|
|
|
1519
1515
|
};
|
|
1520
1516
|
}
|
|
1521
1517
|
function tt(e, t) {
|
|
1522
|
-
const o = e.competitorOne.id === t,
|
|
1523
|
-
if (!o && !
|
|
1524
|
-
const
|
|
1518
|
+
const o = e.competitorOne.id === t, s = e.competitorTwo.id === t;
|
|
1519
|
+
if (!o && !s || !e.score) return null;
|
|
1520
|
+
const n = parseInt(o ? e.score.competitorOne || "0" : e.score.competitorTwo || "0"), i = parseInt(o ? e.score.competitorTwo || "0" : e.score.competitorOne || "0");
|
|
1525
1521
|
let r;
|
|
1526
|
-
return
|
|
1527
|
-
result: { score: `${
|
|
1522
|
+
return n > i ? r = "W" : n < i ? r = "L" : r = "D", {
|
|
1523
|
+
result: { score: `${n}:${i}`, result: r, isHome: o },
|
|
1528
1524
|
isHome: o
|
|
1529
1525
|
};
|
|
1530
1526
|
}
|
|
1531
|
-
function Vt(e, t, o,
|
|
1532
|
-
const r = t?.entries.find((
|
|
1527
|
+
function Vt(e, t, o, s, n, i) {
|
|
1528
|
+
const r = t?.entries.find((E) => E.competitor.id === e), a = o?.entries.find((E) => E.competitor.id === e), d = s?.entries.find((E) => E.competitor.id === e), l = n?.entries.find((E) => E.competitor.id === e), u = i?.entries.find((E) => E.competitor.id === e);
|
|
1533
1529
|
if (!r) return null;
|
|
1534
1530
|
const c = a?.stats?.goalsFor ?? 0, m = d?.stats?.goalsFor ?? 0, g = r?.stats?.goalsFor ?? 0, p = l?.stats?.goalsAgainst ?? 0, h = u?.stats?.goalsAgainst ?? 0, R = r?.stats?.goalsAgainst ?? 0, S = a?.stats?.played ?? 0, A = d?.stats?.played ?? 0, D = r?.stats?.played ?? 0, B = D > 0 ? g / D : 0, U = D > 0 ? R / D : 0, L = B + U, $ = S > 0 ? c / S : 0, x = A > 0 ? m / A : 0, f = S > 0 ? p / S : 0, v = A > 0 ? h / A : 0, H = $ + f, ee = x + v;
|
|
1535
1531
|
return {
|
|
@@ -1553,14 +1549,14 @@ function Vt(e, t, o, n, s, i) {
|
|
|
1553
1549
|
awayGfGaPerMatch: ee
|
|
1554
1550
|
};
|
|
1555
1551
|
}
|
|
1556
|
-
function _(e, t, o,
|
|
1557
|
-
const
|
|
1552
|
+
function _(e, t, o, s) {
|
|
1553
|
+
const n = e.filter((r) => {
|
|
1558
1554
|
const a = r.competitorOne.id === t, d = r.competitorTwo.id === t;
|
|
1559
|
-
return !(!a && !d || r.status?.type !== "FINISHED" ||
|
|
1555
|
+
return !(!a && !d || r.status?.type !== "FINISHED" || s === "home" && !a || s === "away" && !d);
|
|
1560
1556
|
}).sort((r, a) => new Date(a.timing.kickoffTime).getTime() - new Date(r.timing.kickoffTime).getTime());
|
|
1561
|
-
if (
|
|
1557
|
+
if (n.length === 0) return null;
|
|
1562
1558
|
let i = 0;
|
|
1563
|
-
for (const r of
|
|
1559
|
+
for (const r of n) {
|
|
1564
1560
|
const a = r.competitorOne.id === t;
|
|
1565
1561
|
if (o(r, t, a))
|
|
1566
1562
|
i++;
|
|
@@ -1571,13 +1567,13 @@ function _(e, t, o, n) {
|
|
|
1571
1567
|
}
|
|
1572
1568
|
const T = {
|
|
1573
1569
|
win: (e, t, o) => {
|
|
1574
|
-
const
|
|
1575
|
-
return
|
|
1570
|
+
const s = parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0"), n = parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
|
|
1571
|
+
return s > n;
|
|
1576
1572
|
},
|
|
1577
1573
|
draw: (e) => e.score?.competitorOne === e.score?.competitorTwo,
|
|
1578
1574
|
loss: (e, t, o) => {
|
|
1579
|
-
const
|
|
1580
|
-
return
|
|
1575
|
+
const s = parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0"), n = parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
|
|
1576
|
+
return s < n;
|
|
1581
1577
|
},
|
|
1582
1578
|
noWin: (e, t, o) => !T.win(e, t, o),
|
|
1583
1579
|
noDraw: (e) => !T.draw(e),
|
|
@@ -1610,89 +1606,89 @@ function q(e, t, o) {
|
|
|
1610
1606
|
};
|
|
1611
1607
|
}
|
|
1612
1608
|
function Yt(e, t, o) {
|
|
1613
|
-
const
|
|
1609
|
+
const s = q(e, t, "home"), n = q(e, t), i = q(e, o, "away"), r = q(e, o);
|
|
1614
1610
|
return [
|
|
1615
1611
|
{
|
|
1616
1612
|
label: "Consecutive wins",
|
|
1617
|
-
homeTeam: { home:
|
|
1613
|
+
homeTeam: { home: s.win, total: n.win },
|
|
1618
1614
|
awayTeam: { total: r.win, home: i.win },
|
|
1619
1615
|
colorType: "neutral"
|
|
1620
1616
|
},
|
|
1621
1617
|
{
|
|
1622
1618
|
label: "Consecutive draws",
|
|
1623
|
-
homeTeam: { home:
|
|
1619
|
+
homeTeam: { home: s.draw, total: n.draw },
|
|
1624
1620
|
awayTeam: { total: r.draw, home: i.draw },
|
|
1625
1621
|
colorType: "neutral"
|
|
1626
1622
|
},
|
|
1627
1623
|
{
|
|
1628
1624
|
label: "Consecutive defeats",
|
|
1629
|
-
homeTeam: { home:
|
|
1625
|
+
homeTeam: { home: s.loss, total: n.loss },
|
|
1630
1626
|
awayTeam: { total: r.loss, home: i.loss },
|
|
1631
1627
|
colorType: "neutral"
|
|
1632
1628
|
},
|
|
1633
1629
|
{
|
|
1634
1630
|
label: "No win",
|
|
1635
|
-
homeTeam: { home:
|
|
1631
|
+
homeTeam: { home: s.noWin, total: n.noWin },
|
|
1636
1632
|
awayTeam: { total: r.noWin, home: i.noWin },
|
|
1637
1633
|
colorType: "negative"
|
|
1638
1634
|
},
|
|
1639
1635
|
{
|
|
1640
1636
|
label: "No draw",
|
|
1641
|
-
homeTeam: { home:
|
|
1637
|
+
homeTeam: { home: s.noDraw, total: n.noDraw },
|
|
1642
1638
|
awayTeam: { total: r.noDraw, home: i.noDraw },
|
|
1643
1639
|
colorType: "neutral"
|
|
1644
1640
|
},
|
|
1645
1641
|
{
|
|
1646
1642
|
label: "No defeat",
|
|
1647
|
-
homeTeam: { home:
|
|
1643
|
+
homeTeam: { home: s.noDefeat, total: n.noDefeat },
|
|
1648
1644
|
awayTeam: { total: r.noDefeat, home: i.noDefeat },
|
|
1649
1645
|
colorType: "positive"
|
|
1650
1646
|
},
|
|
1651
1647
|
{
|
|
1652
1648
|
label: "Scored at least once",
|
|
1653
|
-
homeTeam: { home:
|
|
1649
|
+
homeTeam: { home: s.scored, total: n.scored },
|
|
1654
1650
|
awayTeam: { total: r.scored, home: i.scored },
|
|
1655
1651
|
colorType: "positive"
|
|
1656
1652
|
},
|
|
1657
1653
|
{
|
|
1658
1654
|
label: "Conceded at least once",
|
|
1659
|
-
homeTeam: { home:
|
|
1655
|
+
homeTeam: { home: s.conceded, total: n.conceded },
|
|
1660
1656
|
awayTeam: { total: r.conceded, home: i.conceded },
|
|
1661
1657
|
colorType: "negative"
|
|
1662
1658
|
},
|
|
1663
1659
|
{
|
|
1664
1660
|
label: "No goal scored",
|
|
1665
|
-
homeTeam: { home:
|
|
1661
|
+
homeTeam: { home: s.noGoalScored, total: n.noGoalScored },
|
|
1666
1662
|
awayTeam: { total: r.noGoalScored, home: i.noGoalScored },
|
|
1667
1663
|
colorType: "neutral"
|
|
1668
1664
|
},
|
|
1669
1665
|
{
|
|
1670
1666
|
label: "No goal conceded",
|
|
1671
|
-
homeTeam: { home:
|
|
1667
|
+
homeTeam: { home: s.noGoalConceded, total: n.noGoalConceded },
|
|
1672
1668
|
awayTeam: { total: r.noGoalConceded, home: i.noGoalConceded },
|
|
1673
1669
|
colorType: "neutral"
|
|
1674
1670
|
},
|
|
1675
1671
|
{
|
|
1676
1672
|
label: "GS + GC over 2.5",
|
|
1677
|
-
homeTeam: { home:
|
|
1673
|
+
homeTeam: { home: s.over25, total: n.over25 },
|
|
1678
1674
|
awayTeam: { total: r.over25, home: i.over25 },
|
|
1679
1675
|
colorType: "neutral"
|
|
1680
1676
|
},
|
|
1681
1677
|
{
|
|
1682
1678
|
label: "GS + GC under 2.5",
|
|
1683
|
-
homeTeam: { home:
|
|
1679
|
+
homeTeam: { home: s.under25, total: n.under25 },
|
|
1684
1680
|
awayTeam: { total: r.under25, home: i.under25 },
|
|
1685
1681
|
colorType: "neutral"
|
|
1686
1682
|
},
|
|
1687
1683
|
{
|
|
1688
1684
|
label: "Scored at least twice",
|
|
1689
|
-
homeTeam: { home:
|
|
1685
|
+
homeTeam: { home: s.scoredTwice, total: n.scoredTwice },
|
|
1690
1686
|
awayTeam: { total: r.scoredTwice, home: i.scoredTwice },
|
|
1691
1687
|
colorType: "positive"
|
|
1692
1688
|
},
|
|
1693
1689
|
{
|
|
1694
1690
|
label: "Conceded at least twice",
|
|
1695
|
-
homeTeam: { home:
|
|
1691
|
+
homeTeam: { home: s.concededTwice, total: n.concededTwice },
|
|
1696
1692
|
awayTeam: { total: r.concededTwice, home: i.concededTwice },
|
|
1697
1693
|
colorType: "negative"
|
|
1698
1694
|
}
|
|
@@ -1700,19 +1696,19 @@ function Yt(e, t, o) {
|
|
|
1700
1696
|
}
|
|
1701
1697
|
function Q(e, t) {
|
|
1702
1698
|
const o = /* @__PURE__ */ new Map();
|
|
1703
|
-
return e.forEach((
|
|
1704
|
-
if (
|
|
1705
|
-
const
|
|
1706
|
-
if (!
|
|
1707
|
-
const i =
|
|
1699
|
+
return e.forEach((s) => {
|
|
1700
|
+
if (s.status?.type !== "FINISHED") return;
|
|
1701
|
+
const n = tt(s, t);
|
|
1702
|
+
if (!n) return;
|
|
1703
|
+
const i = n.isHome ? s.competitorTwo.id : s.competitorOne.id, r = n.isHome ? s.competitorTwo : s.competitorOne, a = o.get(i) || {
|
|
1708
1704
|
opponentId: i,
|
|
1709
1705
|
opponentName: r.name,
|
|
1710
1706
|
opponentLogo: r.assets?.logo
|
|
1711
1707
|
};
|
|
1712
|
-
|
|
1708
|
+
n.isHome ? a.homeResult = n.result : a.awayResult = n.result, o.set(i, a);
|
|
1713
1709
|
}), o;
|
|
1714
1710
|
}
|
|
1715
|
-
function zt(e, t, o,
|
|
1711
|
+
function zt(e, t, o, s, n, i, r) {
|
|
1716
1712
|
const a = Q(e, t), d = Q(e, o), l = /* @__PURE__ */ new Set([
|
|
1717
1713
|
...a.keys(),
|
|
1718
1714
|
...d.keys(),
|
|
@@ -1726,7 +1722,7 @@ function zt(e, t, o, n, s, i, r) {
|
|
|
1726
1722
|
if (!m && !g && c !== t && c !== o)
|
|
1727
1723
|
return;
|
|
1728
1724
|
let p, h;
|
|
1729
|
-
c === t ? (p =
|
|
1725
|
+
c === t ? (p = s, h = i) : c === o ? (p = n, h = r) : (p = m?.opponentName || g?.opponentName || "", h = m?.opponentLogo || g?.opponentLogo), u.push({
|
|
1730
1726
|
opponentId: c,
|
|
1731
1727
|
opponentName: p,
|
|
1732
1728
|
opponentLogo: h,
|
|
@@ -1769,8 +1765,8 @@ export {
|
|
|
1769
1765
|
eo as getFootballMatchCommentary,
|
|
1770
1766
|
to as getFootballMatchEvents,
|
|
1771
1767
|
oo as getFootballMatchLineups,
|
|
1772
|
-
|
|
1773
|
-
|
|
1768
|
+
no as getFootballMatchOdds,
|
|
1769
|
+
so as getFootballMatchStatistics,
|
|
1774
1770
|
io as getFootballMatches,
|
|
1775
1771
|
ro as getFootballPlayerSeasonStatistics,
|
|
1776
1772
|
ao as getFootballSeasonDetails,
|
|
@@ -1813,15 +1809,15 @@ export {
|
|
|
1813
1809
|
K as isTeamHome,
|
|
1814
1810
|
kt as isTeamInMatch,
|
|
1815
1811
|
it as search,
|
|
1816
|
-
|
|
1812
|
+
st as searchFootball,
|
|
1817
1813
|
ho as setConfig,
|
|
1818
1814
|
T as streakFilters,
|
|
1819
1815
|
C as toProviderRefArray,
|
|
1820
|
-
|
|
1816
|
+
Nt as useAllPlayerStatisticsFromMatches,
|
|
1821
1817
|
Dt as useMostCardedPlayersFromMatches,
|
|
1822
1818
|
It as usePlayerStatistics,
|
|
1823
1819
|
Ke as usePlayerStatisticsMap,
|
|
1824
1820
|
Rt as useTopAssistersFromMatches,
|
|
1825
|
-
|
|
1821
|
+
Et as useTopGoalContributorsFromMatches,
|
|
1826
1822
|
Gt as useTopScorersFromMatches
|
|
1827
1823
|
};
|