fansunited-data-layer 0.10.0 → 0.11.2
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/api/fansunited/football/index.d.ts +1 -1
- package/api/fansunited/football/index.d.ts.map +1 -1
- package/api/fansunited/football/matches/index.d.ts +36 -0
- package/api/fansunited/football/matches/index.d.ts.map +1 -1
- package/api/fansunited/football/matches/transformer.d.ts.map +1 -1
- package/api/fansunited/football/matches/types.d.ts +1 -0
- package/api/fansunited/football/matches/types.d.ts.map +1 -1
- package/api/fansunited/index.d.ts +1 -1
- package/api/fansunited/index.d.ts.map +1 -1
- package/api/sportal365-sports/basketball/games/transformers/game.d.ts.map +1 -1
- package/api/sportal365-sports/football/matches/transformers/match.d.ts.map +1 -1
- package/api/sportal365-sports/football/standings/standing.transformer.d.ts.map +1 -1
- package/api/sportal365-sports/tennis/matches/transformers/match.d.ts.map +1 -1
- package/client.cjs +1 -1
- package/client.js +2 -2
- package/fansunited-data-layer.cjs +1 -1
- package/fansunited-data-layer.js +446 -396
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/{matches-dKvggZia.js → matches-DpXELQ3n.js} +4 -1
- package/matches-tjnMum3M.cjs +1 -0
- package/package.json +1 -1
- package/types/canonical/match.types.d.ts +1 -0
- package/types/canonical/match.types.d.ts.map +1 -1
- package/types/canonical/standing.types.d.ts +1 -0
- package/types/canonical/standing.types.d.ts.map +1 -1
- package/matches-D5jlWsqr.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./matches-D5jlWsqr.cjs"),j=require("react");function ee(t){return{entityType:"tournament",id:t.id.toString(),name:t.name,slug:t.slug,gender:t.gender,type:t.type,region:t.region,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_logo?{logo:t.url_logo}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function oe(t){return{entityType:"player",id:t.id.toString(),name:t.name,slug:t.slug,position:t.position,gender:t.gender,birthdate:t.birthdate,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ne(t){return{entityType:"team",id:t.id.toString(),name:t.name,slug:t.slug,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,type:t.type==="national"?"national":"club",gender:t.gender,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_logo?{logo:t.url_logo}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function se(t){return{entityType:"president",id:t.id.toString(),name:t.name,slug:t.slug,birthdate:t.birthdate??void 0,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ie(t){return{entityType:"venue",id:t.id.toString(),name:t.name,slug:t.slug,city:{id:t.city.id.toString(),name:t.city.name,country:{id:t.city.country.id.toString(),name:t.city.country.name,code:void 0,flag:t.city.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.city.country.uuid)},providerRef:h.toProviderRefArray(t.city.uuid)},country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},profile:{latitude:t.profile.lat,longitude:t.profile.lng,capacity:t.profile.capacity},assets:t.url_thumb?{image:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function re(t){return{entityType:"coach",id:t.id.toString(),name:t.name,slug:t.slug,birthdate:t.birthdate??void 0,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ae(t){switch(t.entity_type){case"tournament":return ee(t);case"player":return oe(t);case"team":return ne(t);case"president":return se(t);case"venue":return ie(t);case"coach":return re(t);default:throw new Error(`Unknown entity type: ${t.entity_type}`)}}async function ce(t,e){if(!t.query||t.query.trim()==="")return{results:[],query:t.query||""};const o=e||h.getConfig(),{sportal365Sports:n}=o,s=t.entityTypes&&t.entityTypes.length>0?t.entityTypes:["tournament","player","team","president","venue","coach"],i=await h.footballHttp.get({path:"/search",params:{query:t.query.trim(),entity_type:s.join(","),language_code:t.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t.languageCode??n?.languageCode??"en"},next:t.next,config:o});return!i||i.length===0?{results:[],query:t.query}:{results:i.map(ae),query:t.query}}const le=h.createHttpClient(h.SPORTAL365_BASKETBALL_DOMAIN);function de(t){const e={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed",UNKNOWN:"not_started"},o=t.type.toUpperCase();return{code:e[o]??"not_started",name:t.name,shortName:t.short_name,type:o}}function At(t){return{id:t.id,name:t.name,threeLetterCode:t.three_letter_code,slug:t.slug,type:t.type==="national"?"national":"club",gender:t.gender}}function ue(t){return{kickoffTime:new Date(t.game_time),currentMinute:t.minute}}function fe(t){if(!t.season?.competition)return;const e=t.season.competition;return{id:e.id,name:e.name,slug:e.slug,type:"LEAGUE",gender:e.gender,region:e.region,country:e.country?{id:e.country.id,name:e.country.name}:void 0,season:{id:t.season.id,name:t.season.name,status:t.season.status},stage:t.stage?{id:t.stage.id,name:t.stage.name,type:t.stage.type}:void 0}}function he(t){if(t)return{id:t.id,name:t.name,slug:t.slug}}function me(t){if(!t||t.length===0)return;const e=t.filter(i=>i.result_type.category==="single_period");if(e.length===0)return;let o=0,n=0;const s=[];for(const i of e)o+=i.home,n+=i.away,s.push({competitorOne:String(i.home),competitorTwo:String(i.away)});return{competitorOne:String(o),competitorTwo:String(n),breakdown:{total:{competitorOne:String(o),competitorTwo:String(n)},periods:s}}}function ge(t){if(t.winner)return{competitorId:t.winner.id}}function pe(t){return{id:t.id,slug:t.slug,status:de(t.status),timing:ue(t),competitorOne:At(t.home_team),competitorTwo:At(t.away_team),competition:fe(t),round:t.round?{id:t.round.id,key:t.round.uuid,name:t.round.name,type:"REGULAR",providerRef:h.toProviderRefArray(t.round.uuid)}:void 0,venue:he(t.arena),score:me(t.score),winner:ge(t),odds:t.odds?h.transformOdds(t.odds):void 0,coverage:t.coverage==="NOT_LIVE"?"UNKNOWN":t.coverage,providerRef:[{provider:"sportal365-basketball",id:t.id}]}}async function ye(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o;return(await le.get({path:"/games",params:{offset:"0",limit:"1000",competition_list:t?.competitionList,status_type:t?.statusTypes,from_game_time:t?.fromGameTime,to_game_time:t?.toGameTime,odd_client:t?.oddClient??n?.oddClient,odd_type:t?.oddType,market_types:t?.marketTypes,language_code:t?.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??n?.languageCode??"en"},next:t?.next,config:o})).games.map(pe)}const Te=h.createHttpClient(h.SPORTAL365_TENNIS_DOMAIN);function _e(t){const e={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed"},o=t.type.toUpperCase();return{code:e[o]??"not_started",name:t.name,shortName:t.short_name,type:o}}function Ct(t){if(t.type==="PLAYER")return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"player",country:t.details?.[0]?.country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details?.[0]?.gender};if(t.type==="TEAM_DOUBLE"&&t.details&&t.details.length===2){const e={id:t.details[0].id,name:t.details[0].name,shortName:t.details[0].short_name,threeLetterCode:t.details[0].three_letter_code,type:"player",country:t.details[0].country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details[0].gender},o={id:t.details[1].id,name:t.details[1].name,shortName:t.details[1].short_name,threeLetterCode:t.details[1].three_letter_code,type:"player",country:t.details[1].country?{id:t.details[1].country.id,name:t.details[1].country.name}:void 0,gender:t.details[1].gender};return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"pair",players:[e,o]}}else return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"national",country:t.details?.[0]?.country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details?.[0]?.gender}}function ve(t){return{kickoffTime:new Date(t.scheduled_start_time),phaseStartedAt:t.started_at?new Date(t.started_at):void 0,finishedAt:t.finished_at?new Date(t.finished_at):void 0}}function Se(t){if(!t.tournament)return;const e=t.tournament;return{id:e.competition?.id??e.id,name:e.competition?.name??e.name,slug:e.competition?.slug??e.slug,type:"TOURNAMENT",gender:e.gender,region:"INTERNATIONAL",country:e.country?{id:e.country.id,name:e.country.name}:void 0}}function Ae(t){if(!t.results||t.results.length===0)return;const e=t.results.filter(c=>/^set\d+$/i.test(c.type.code));if(e.length===0)return;const o=[];for(const c of e){const d=c.values.find(l=>l.position==="1"),f=c.values.find(l=>l.position==="2");!d||!f||d.value==null||f.value==null||o.push({competitorOne:d.value,competitorTwo:f.value})}if(o.length===0)return;const n=t.results.find(c=>c.type.code==="setswon"),s=n?.values.find(c=>c.position==="1"),i=n?.values.find(c=>c.position==="2");let r,a;return s?.value!=null&&i?.value!=null?(r=parseInt(s.value),a=parseInt(i.value)):(r=o.filter(c=>parseInt(c.competitorOne)>parseInt(c.competitorTwo)).length,a=o.filter(c=>parseInt(c.competitorTwo)>parseInt(c.competitorOne)).length),{competitorOne:String(r),competitorTwo:String(a),breakdown:{total:{competitorOne:String(r),competitorTwo:String(a)},periods:o}}}function Ce(t){const e=t.participants.find(o=>o.winner==="YES");if(e)return{competitorId:e.id}}function Oe(t){const e=t.participants.sort((o,n)=>o.position-n.position);return{id:t.id,slug:t.slug,status:_e(t.status),timing:ve(t),competitorOne:Ct(e[0]),competitorTwo:Ct(e[1]),competition:Se(t),round:t.round?{id:t.round.id,key:t.round.uuid,name:t.round.name,type:"REGULAR",providerRef:h.toProviderRefArray(t.round.uuid)}:void 0,score:Ae(t),winner:Ce(t),odds:t.odds?h.transformOdds(t.odds):void 0,coverage:t.coverage?.type==="NOT_LIVE"?"UNKNOWN":t.coverage?.type,metadata:{matchType:t.type,bestOfSets:t.best_of_sets,surface:t.tournament?.surface,indoorOutdoor:t.tournament?.indoor_outdoor},providerRef:[{provider:"sportal365-tennis",id:t.id}]}}async function Fe(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o;return(await Te.get({path:"/matches/livescore",params:{date:t?.date,utc_offset:t?.utcOffset?.toString(),offset:"0",limit:"1000",type:t?.type,gender:t?.gender,status_type:t?.statusType,competition_list:t?.competitionList,odd_client:t?.oddClient??n?.oddClient,odd_type:t?.oddType,market_types:t?.marketTypes,language_code:t?.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??n?.languageCode??"en"},next:t?.next,config:o})).matches.map(Oe)}const Ee=h.createHttpClient(h.SPORTAL365_SPORTS_SEARCH_DOMAIN);function U(t){return{language:t.language,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0}}function G(t){if(!(!t||!t.url))return{url:t.url}}function W(t){if(t)return{id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,providerRef:t.id}}function pt(t){return{entityType:"team",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,competitionIds:t.competition_ids,type:t.type,national:t.national,undecided:t.undecided,providerRef:t.id}}function Rt(t){return{entityType:"city",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),providerRef:t.id}}function Le(t){return{entityType:"horse",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,providerRef:t.id}}function be(t){return{entityType:"player",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,position:t.position??void 0,providerRef:t.id}}function Re(t){return{entityType:"coach",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,providerRef:t.id}}function Ne(t){return{entityType:"referee",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,providerRef:t.id}}function Pe(t){return{entityType:"venue",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),city:t.city?Rt(t.city):void 0,providerRef:t.id}}function Ie(t){return{entityType:t.entity_type,id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,type:t.type??void 0,region:t.region??void 0,providerRef:t.id}}function Me(t){return{entityType:"match",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,competitionId:t.competition_id??void 0,startTime:t.start_time??void 0,homeTeam:t.home_team?pt(t.home_team):void 0,awayTeam:t.away_team?pt(t.away_team):void 0,providerRef:t.id}}function Ue(t){return{entityType:"country",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(U),displayAsset:G(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,providerRef:t.id}}function Ge(t){switch(t.entity_type){case"team":return pt(t);case"city":return Rt(t);case"horse":return Le(t);case"player":return be(t);case"coach":return Re(t);case"referee":return Ne(t);case"venue":return Pe(t);case"tournament":case"competition":return Ie(t);case"match":return Me(t);case"country":return Ue(t);default:{const e=t;throw new Error(`Unknown entity type: ${e.entity_type}`)}}}async function De(t={},e){const o=e??h.getConfig(),n={};t.name&&(n.name=t.name),t.entityTypes&&t.entityTypes.length>0&&(n.entity_type=t.entityTypes.join(",")),t.sports&&t.sports.length>0&&(n.sport=t.sports.join(",")),t.eventStartTime&&(n.event_start_time=t.eventStartTime),t.ids&&t.ids.length>0&&(n.ids=t.ids.join(",")),t.competitionIds&&t.competitionIds.length>0&&(n.competition_ids=t.competitionIds.join(",")),t.domain&&(n.domain=t.domain),t.inputLanguage&&(n.input_language=t.inputLanguage),t.translationLanguage&&(n.translation_language=t.translationLanguage),t.limit!==void 0&&(n.limit=t.limit.toString()),t.offset!==void 0&&(n.offset=t.offset.toString());const s=await Ee.get({path:"/suggest",params:n,next:t.next,config:o});return!s.results||s.results.length===0?{results:[],query:t.name}:{results:s.results.map(Ge),query:t.name}}const xe=h.createHttpClient(h.SPORTAL365_STANDINGS_DOMAIN);function He(t){const e={RANK:null,PLAYED:"played",WINS:"won",DRAWS:"drawn",LOSSES:"lost",GOALS_FOR:"goalsFor",GOALS_AGAINST:"goalsAgainst",POINTS:"points"};return t in e?e[t]:t.toLowerCase().replace(/_/g,"")}function Nt(t){return{CHAMPIONS_LEAGUE:"championsLeague",CHAMPIONS_LEAGUE_QUAL:"championsLeagueQual",CHAMPIONS_LEAGUE_8:"championsLeague8",CHAMPIONS_LEAGUE_PLAYOFF_16:"championsLeaguePlayoff16",PLAYOFF_TO_CHAMPIONS_LEAGUE:"playoffChampionsLeague",PLAYOFF_TO_CHAMPIONS_LEAGUE_QUAL:"playoffChampionsLeagueQual",UEFA_CUP:"europaLeague",UEFA_QUAL:"europaLeagueQual",UEFA_QUAL_PLAYOFF:"europaLeagueQualPlayoff",PLAYOFF_TO_UEFA_QUAL:"playoffEuropaLeagueQual",EUROPA_LEAGUE_8:"europaLeague8",EUROPA_LEAGUE_PLAYOFF_16:"europaLeaguePlayoff16",EUROPA_CONFERENCE_LEAGUE_PLAYOFF:"europaConferenceLeaguePlayoff",EUROPA_CONFERENCE_LEAGUE_QUALIFICATION:"europaConferenceLeagueQual",CONFERENCE_LEAGUE_8:"conferenceLeague8",CONFERENCE_LEAGUE_PLAYOFF_16:"conferenceLeaguePlayoff16",RELEGATION:"relegation",RELEGATION_PLAYOFF:"relegationPlayoff",PROMOTION:"promotion",PROMOTION_PLAYOFF:"promotionPlayoff",QUALIFICATION_TO_NEXT_STAGE:"qualificationNextStage",POSSIBLE_QUALIFICATION_TO_NEXT_STAGE:"possibleQualificationNextStage",CHAMPIONSHIP_PLAYOFF:"championshipPlayoff",OVERALL_CHAMPIONSHIP_PLAYOFF:"overallChampionshipPlayoff",CONFERENCE_CHAMPIONSHIP_PLAYOFF:"conferenceChampionshipPlayoff",POSSIBLE_CONFERENCE_CHAMPIONSHIP_PLAYOFF:"possibleConferenceChampionshipPlayoff",DIVISION_CHAMPIONSHIP_PLAYOFF:"divisionChampionshipPlayoff",COPA_LIBERTADORES:"copaLibertadores",PLAYOFF_TO_COPA_LIBERTADORES:"playoffCopaLibertadores",PLAYOFF_TO_COPA_LIBERTADORES_QUAL:"playoffCopaLibertadoresQual",PLAYOFF_TO_COPA_SUDAMERICANA:"playoffCopaSudamericana",PLAYOFF_TO_CONCACAF_CHAMPIONS_LEAGUE:"playoffConcacafChampionsLeague",CAF_CHAMPIONS_QUAL:"cafChampionsQual",CAF_CONFEGERATION_CUP_QUAL:"cafConfederationCupQual",CFU_CLUB_CHAMPIONSHIP:"cfuClubChampionship",AFC_CHAMPIONS_LEAGUE:"afcChampionsLeague",AFC_CHAMPIONS_LEAGUE_QUAL:"afcChampionsLeagueQual",PLAYOFF_TO_AFC_CHAMPIONS_LEAGUE_QUAL:"playoffAfcChampionsLeagueQual",WORLD_CUP:"worldCup"}[t]??t.toLowerCase().replace(/_/g,"")}function ke(t){return t==="RELEGATION"||t==="RELEGATION_PLAYOFF"?"BOTTOM":t.includes("PLAYOFF")?"MIDDLE":"TOP"}function $e(t,e){if(!e||e.length===0)return;const o={win:"W",loss:"L",draw:"D"},n=e.map(s=>{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;return{matchId:s.id,result:o[s.outcome]??"L",score:l,homeAway:a?"HOME":"AWAY",opponent:{id:r?.id??"",name:r?.name??"",logo:r?.display_asset?.url},date:new Date(s.start_time),competition:s.competition?{id:s.competition.id,name:s.competition.name}:void 0}});return{competitorId:t,results:n,formString:n.map(s=>s.result).join("")}}function Be(t){const e={};for(const o of t){const n=He(o.type.code);n&&(e[n]=Number(o.value))}return e.goalsFor!=null&&e.goalsAgainst!=null&&e.goalDifference==null&&(e.goalDifference=e.goalsFor-e.goalsAgainst),e}function We(t){const e=t.find(o=>o.type.code==="RANK");return e?Number(e.value):0}function ze(t){const e=t.rules?.length>0?t.rules.map(o=>Nt(o.standing_api_rule_type)):void 0;return{rank:We(t.columns),competitor:{id:t.team.id,name:t.team.name,shortName:t.team.short_name??void 0,logo:void 0},stats:Be(t.columns),form:$e(t.team.id,t.form??[]),rules:e}}function Ye(t){const e=new Map;for(const o of t)if(o.rules)for(const n of o.rules){const s=Nt(n.standing_api_rule_type);e.has(s)||e.set(s,{key:s,name:n.name,position:ke(n.type)})}return Array.from(e.values())}function je(t){const e=t.standing.map(ze),o=Ye(t.standing);return{entries:e,metadata:{legend:o}}}function qe(t){return t.standings.map(e=>({stage:{id:t.stage.id,name:t.stage.name},group:{id:e.group.id,name:e.group.name,type:e.group.type},coverageType:e.type,rankingType:e.ranking_type,standings:je(e)}))}function Ve(t){return!t?.data||t.data.length===0?[]:t.data.flatMap(qe)}async function Qe(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o,s={season_id:t.seasonId,stage_id:t.stageId,group_id:t.groupId,coverage_type:t.coverageType,home_away:t.homeAway,optional_data:t.includeForm?"form":void 0,row_limit:t.rowLimit?.toString(),row_offset:t.rowOffset?.toString(),translation_language:t.languageCode??n?.languageCode??"en"},i=await xe.get({path:`/standings/${t.sport}`,params:s,next:t.next,config:o});return Ve(i)}const Ke=h.createHttpClient(h.SPORTAL365_STATISTICS_DOMAIN);function Xe(t,e){return{teamId:t.id,teamName:t.name,seasonId:e,statistics:t.statistics.map(o=>({key:o.id,value:o.value,label:o.name}))}}async function Je(t,e){const o=e||h.getConfig(),n=t.next??{revalidate:600},s=await Ke.get({path:"/statistics/aggregate",params:{participant_ids:t.teamId,season_ids:t.seasonId,participant_type:"TEAM"},next:n,config:o});if(!s.data||s.data.length===0)throw new Error(`No statistics found for team ${t.teamId} in season ${t.seasonId}`);return Xe(s.data[0],t.seasonId)}function Pt(t){const e=t.replace(/\/$/,"");function o(n){return`${e}${n}`}return{async get(n){const s=n.config||h.getConfig(),{fansUnited:i}=s;if(!i)throw new Error("Fans United configuration is missing. Add 'fansUnited' with 'apiKey' and 'clientId' to your config.");if(!i.apiKey||!i.clientId)throw new Error("Fans United configuration requires both 'apiKey' and 'clientId'");const r=new URL(o(n.path));if(r.searchParams.set("key",i.apiKey),r.searchParams.set("client_id",i.clientId),n.params)for(const[f,l]of Object.entries(n.params))l!==void 0&&(Array.isArray(l)?l.length>0&&r.searchParams.set(f,l.join(",")):r.searchParams.set(f,l));const a=3e4,c=new URL(r.toString());c.searchParams.delete("key"),c.searchParams.delete("client_id"),console.log("🔗 FansUnited API URL:",c.toString());const d=await fetch(r.toString(),{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...n.headers},signal:AbortSignal.timeout(a),...n.next&&{next:n.next}});if(!d.ok){let f=`Fans United API error: ${d.status} ${d.statusText}`;try{const l=await d.text();l&&(f+=` - ${l}`)}catch(l){console.error("[Fans United HTTP] Failed to read error response body:",{error:l instanceof Error?l.message:String(l),status:d.status,statusText:d.statusText})}throw new Error(f)}return d.json()}}}const Ze="https://football.fansunitedapi.com",k=Pt(Ze);function we(t){return{id:String(t.id),name:t.name,active:t.active,providerRef:[{provider:"fansunited",id:String(t.id)}]}}function to(t){const e={id:String(t.id),name:t.name,shortName:t.short_name,slug:t.slug,type:t.type||"LEAGUE",region:t.region,gender:t.gender,providerRef:[{provider:"fansunited",id:String(t.id)}]};return t.country&&(e.country={id:String(t.country.id),name:t.country.name,code:t.country.code,flag:t.country.assets?.flag,providerRef:[{provider:"fansunited",id:String(t.country.id)}]}),t.assets?.logo&&(e.assets={logo:t.assets.logo}),t.seasons&&t.seasons.length>0&&(e.seasons=t.seasons.map(we)),t.current_season&&(e.season={id:String(t.current_season.id),name:t.current_season.name,status:t.current_season.active?"ACTIVE":"INACTIVE"}),e}function eo(t){return t.map(to)}async function oo(t,e){const o={};t?.lang?o.lang=t.lang:o.lang="EN",t?.sortField&&(o.sort_field=t.sortField),t?.sortOrder&&(o.sort_order=t.sortOrder),t?.page!==void 0&&(o.page=String(t.page)),t?.perPage!==void 0&&(o.per_page=String(t.perPage)),t?.countryId!==void 0&&(o.country_id=String(t.countryId)),t?.active!==void 0&&(o.active=t.active?"1":"0");const n=await k.get({path:"/v1/competitions",params:o,config:e,next:t?.next}),s=n.data.map(d=>d.id),i=new Set(s);s.length!==i.size&&console.warn("⚠️ API returned duplicate competitions!");const r=eo(n.data),a=new Set,c=r.filter(d=>a.has(d.id)?!1:(a.add(d.id),!0));return r.length!==c.length&&console.warn(`Removed ${r.length-c.length} duplicate competitions`),c}function no(t){return{id:t.id,name:t.name,code:t.country_code,assets:t.assets?.flag?{flag:t.assets.flag}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function so(t){return{id:t.id,name:t.name,type:t.type?.toUpperCase()||"LEAGUE",gender:t.gender?.toUpperCase(),country:t.country?no(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function io(t){return so(t.data)}async function ro(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await k.get({path:`/v1/competitions/${t}`,params:s,next:e?.next,config:n});return io(i)}function ao(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag,providerRef:[{provider:"fansunited",id:t.id}]}}function It(t){return{id:t.id,name:t.name,shortName:t.short_name||void 0,threeLetterCode:t.code,type:t.national?"national":"club",gender:t.gender?t.gender.toUpperCase():void 0,country:t.country?ao(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,metadata:t.colors?{shirtColors:t.colors.primary?[{type:"home",colorCode:t.colors.primary}]:void 0}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function co(t){return It(t.data)}function lo(t){return t.data.map(It)}async function uo(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await k.get({path:`/v1/teams/${t}`,params:s,next:e?.next,config:n});return co(i)}async function fo(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.teamIds&&(n.team_ids=t.teamIds),t?.countryId&&(n.country_id=t.countryId),t?.name&&(n.name=t.name),t?.scope&&(n.scope=t.scope),t?.national!==void 0&&(n.national=String(t.national)),t?.gender&&(n.gender=t.gender),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder);const s=await k.get({path:"/v1/teams",params:n,next:t?.next,config:o});return lo(s)}function _t(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag,providerRef:[{provider:"fansunited",id:t.id}]}}function ho(t){return{id:t.id,name:t.name,shortName:t.short_name??void 0,fullName:t.full_name??void 0,threeLetterCode:t.code,type:t.national?"national":"club",gender:t.gender?.toUpperCase(),country:t.country?_t(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function mo(t){return{id:t.id,name:t.name,type:t.type?.toUpperCase()||"LEAGUE",gender:t.gender?.toUpperCase(),country:t.country?_t(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Mt(t){return{type:"player",id:t.id,name:t.name,position:t.position,birthdate:t.birth_date,country:t.country?_t(t.country):void 0,assets:t.assets?.headshot?{photo:t.assets.headshot}:void 0,teams:t.teams?.map(ho),competitions:t.competitions?.map(mo),providerRef:[{provider:"fansunited",id:t.id}]}}function go(t){return Mt(t.data)}function po(t){return t.data.map(Mt)}async function yo(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await k.get({path:`/v1/players/${t}`,params:s,next:e?.next,config:n});return go(i)}async function To(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.playerIds&&(n.player_ids=t.playerIds),t?.countryId&&(n.country_id=t.countryId),t?.name&&(n.name=t.name),t?.scope&&(n.scope=t.scope),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder);const s=await k.get({path:"/v1/players",params:n,next:t?.next,config:o});return po(s)}async function _o(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await k.get({path:`/v1/matches/${t}`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function vo(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.competitions&&(n.competitions=t.competitions),t?.countries&&(n.countries=t.countries),t?.fromDate&&(n.from_date=t.fromDate),t?.toDate&&(n.to_date=t.toDate),t?.matches&&(n.matches=t.matches),t?.teams&&(n.teams=t.teams),t?.status&&(n.status=t.status),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder),t?.showDeleted!==void 0&&(n.show_deleted=t.showDeleted?"true":"false");const s=await k.get({path:"/v1/matches",params:n,next:t?.next,config:o});return h.transformMatches(s)}function vt(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag||void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function So(t){return{id:t.id,name:t.name,shortName:t.short_name||void 0,type:t.type||"LEAGUE",region:t.region,gender:t.gender?.toUpperCase(),country:t.country?vt(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Ao(t){return{type:"player",id:t.id,name:t.name,position:t.position||void 0,gender:t.gender?.toUpperCase(),birthdate:t.birth_date||void 0,country:t.country?vt(t.country):void 0,assets:t.assets?.headshot?{photo:t.assets.headshot}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Co(t){return{type:t.national?"national":"club",id:t.id,name:t.name,shortName:t.short_name||void 0,threeLetterCode:t.code||void 0,gender:t.gender?.toUpperCase(),country:t.country?vt(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function mt(t){switch(t.entity_type){case"competition":{const e=So(t);return{source:"FOOTBALL",entityType:"competition",entityId:t.id,entityData:e}}case"player":{const e=Ao(t);return{source:"FOOTBALL",entityType:"player",entityId:t.id,entityData:e}}case"team":{const e=Co(t);return{source:"FOOTBALL",entityType:"team",entityId:t.id,entityData:e}}case"venue":case"coach":return null;default:throw new Error(`Unknown entity type: ${t.entity_type}`)}}async function Oo(t,e){if(!t.query||t.query.trim()==="")return[];const o=e||h.getConfig(),n={q:t.query.trim()},i=(t.entityTypes&&t.entityTypes.length>0?t.entityTypes:["competition","team","player"]).map(c=>{switch(c){case"team":return"teams";case"player":return"players";case"competition":return"competitions";default:return c}});n.entities=i.join(","),t.lang&&(n.lang=t.lang),t.limit&&(n.limit=String(t.limit));const r=await k.get({path:"/v1/search",params:n,next:t.next,config:o}),a=[];return r.data&&(r.data.competitions&&r.data.competitions.forEach(c=>{const d=mt({...c,entity_type:"competition"});d&&a.push(d)}),r.data.teams&&r.data.teams.forEach(c=>{const d=mt({...c,entity_type:"team"});d&&a.push(d)}),r.data.players&&r.data.players.forEach(c=>{const d=mt({...c,entity_type:"player"});d&&a.push(d)})),a}const Fo="https://search.fansunitedapi.com",$=Pt(Fo);var Eo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ut=new Set,yt=typeof process=="object"&&process?process:{},Gt=(t,e,o,n)=>{typeof yt.emitWarning=="function"?yt.emitWarning(t,e,o,n):console.error(`[${o}] ${e}: ${t}`)},lt=globalThis.AbortController,Ot=globalThis.AbortSignal;if(typeof lt>"u"){Ot=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(o,n){this._onabort.push(n)}},lt=class{constructor(){e()}signal=new Ot;abort(o){if(!this.signal.aborted){this.signal.reason=o,this.signal.aborted=!0;for(let n of this.signal._onabort)n(o);this.signal.onabort?.(o)}}};let t=yt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,Gt("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))}}var Lo=t=>!Ut.has(t),B=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Dt=t=>B(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ct:null:null,ct=class extends Array{constructor(t){super(t),this.fill(0)}},bo=class tt{heap;length;static#a=!1;static create(e){let o=Dt(e);if(!o)return[];tt.#a=!0;let n=new tt(e,o);return tt.#a=!1,n}constructor(e,o){if(!tt.#a)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new o(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Ro=class xt{#a;#u;#p;#R;#y;#M;#U;#T;get perf(){return this.#T}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#s;#_;#n;#o;#t;#l;#f;#c;#i;#v;#r;#S;#A;#h;#m;#C;#b;#d;#G;static unsafeExposeInternals(e){return{starts:e.#A,ttls:e.#h,autopurgeTimers:e.#m,sizes:e.#S,keyMap:e.#n,keyList:e.#o,valList:e.#t,next:e.#l,prev:e.#f,get head(){return e.#c},get tail(){return e.#i},free:e.#v,isBackgroundFetch:o=>e.#e(o),backgroundFetch:(o,n,s,i)=>e.#H(o,n,s,i),moveToTail:o=>e.#I(o),indexes:o=>e.#O(o),rindexes:o=>e.#F(o),isStale:o=>e.#g(o)}}get max(){return this.#a}get maxSize(){return this.#u}get calculatedSize(){return this.#_}get size(){return this.#s}get fetchMethod(){return this.#M}get memoMethod(){return this.#U}get dispose(){return this.#p}get onInsert(){return this.#R}get disposeAfter(){return this.#y}constructor(e){let{max:o=0,ttl:n,ttlResolution:s=1,ttlAutopurge:i,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:c,dispose:d,onInsert:f,disposeAfter:l,noDisposeOnSet:u,noUpdateTTL:m,maxSize:y=0,maxEntrySize:T=0,sizeCalculation:A,fetchMethod:p,memoMethod:_,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:N,ignoreFetchAbort:P,perf:I}=e;if(I!==void 0&&typeof I?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#T=I??Eo,o!==0&&!B(o))throw new TypeError("max option must be a nonnegative integer");let g=o?Dt(o):Array;if(!g)throw new Error("invalid max value: "+o);if(this.#a=o,this.#u=y,this.maxEntrySize=T||this.#u,this.sizeCalculation=A,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(_!==void 0&&typeof _!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#U=_,p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#M=p,this.#b=!!p,this.#n=new Map,this.#o=new Array(o).fill(void 0),this.#t=new Array(o).fill(void 0),this.#l=new g(o),this.#f=new g(o),this.#c=0,this.#i=0,this.#v=bo.create(o),this.#s=0,this.#_=0,typeof d=="function"&&(this.#p=d),typeof f=="function"&&(this.#R=f),typeof l=="function"?(this.#y=l,this.#r=[]):(this.#y=void 0,this.#r=void 0),this.#C=!!this.#p,this.#G=!!this.#R,this.#d=!!this.#y,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!N,this.ignoreFetchAbort=!!P,this.maxEntrySize!==0){if(this.#u!==0&&!B(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!B(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#j()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=B(s)||s===0?s:1,this.ttlAutopurge=!!i,this.ttl=n||0,this.ttl){if(!B(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#a===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#a&&!this.#u){let F="LRU_CACHE_UNBOUNDED";Lo(F)&&(Ut.add(F),Gt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",F,xt))}}getRemainingTTL(e){return this.#n.has(e)?1/0:0}#k(){let e=new ct(this.#a),o=new ct(this.#a);this.#h=e,this.#A=o;let n=this.ttlAutopurge?new Array(this.#a):void 0;this.#m=n,this.#$=(r,a,c=this.#T.now())=>{if(o[r]=a!==0?c:0,e[r]=a,n?.[r]&&(clearTimeout(n[r]),n[r]=void 0),a!==0&&n){let d=setTimeout(()=>{this.#g(r)&&this.#E(this.#o[r],"expire")},a+1);d.unref&&d.unref(),n[r]=d}},this.#N=r=>{o[r]=e[r]!==0?this.#T.now():0},this.#L=(r,a)=>{if(e[a]){let c=e[a],d=o[a];if(!c||!d)return;r.ttl=c,r.start=d,r.now=s||i();let f=r.now-d;r.remainingTTL=c-f}};let s=0,i=()=>{let r=this.#T.now();if(this.ttlResolution>0){s=r;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref()}return r};this.getRemainingTTL=r=>{let a=this.#n.get(r);if(a===void 0)return 0;let c=e[a],d=o[a];if(!c||!d)return 1/0;let f=(s||i())-d;return c-f},this.#g=r=>{let a=o[r],c=e[r];return!!c&&!!a&&(s||i())-a>c}}#N=()=>{};#L=()=>{};#$=()=>{};#g=()=>!1;#j(){let e=new ct(this.#a);this.#_=0,this.#S=e,this.#P=o=>{this.#_-=e[o],e[o]=0},this.#B=(o,n,s,i)=>{if(this.#e(n))return 0;if(!B(s))if(i){if(typeof i!="function")throw new TypeError("sizeCalculation must be a function");if(s=i(n,o),!B(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#D=(o,n,s)=>{if(e[o]=n,this.#u){let i=this.#u-e[o];for(;this.#_>i;)this.#x(!0)}this.#_+=e[o],s&&(s.entrySize=n,s.totalCalculatedSize=this.#_)}}#P=e=>{};#D=(e,o,n)=>{};#B=(e,o,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:e=this.allowStale}={}){if(this.#s)for(let o=this.#i;!(!this.#W(o)||((e||!this.#g(o))&&(yield o),o===this.#c));)o=this.#f[o]}*#F({allowStale:e=this.allowStale}={}){if(this.#s)for(let o=this.#c;!(!this.#W(o)||((e||!this.#g(o))&&(yield o),o===this.#i));)o=this.#l[o]}#W(e){return e!==void 0&&this.#n.get(this.#o[e])===e}*entries(){for(let e of this.#O())this.#t[e]!==void 0&&this.#o[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#o[e],this.#t[e]])}*rentries(){for(let e of this.#F())this.#t[e]!==void 0&&this.#o[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#o[e],this.#t[e]])}*keys(){for(let e of this.#O()){let o=this.#o[e];o!==void 0&&!this.#e(this.#t[e])&&(yield o)}}*rkeys(){for(let e of this.#F()){let o=this.#o[e];o!==void 0&&!this.#e(this.#t[e])&&(yield o)}}*values(){for(let e of this.#O())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}*rvalues(){for(let e of this.#F())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,o={}){for(let n of this.#O()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;if(i!==void 0&&e(i,this.#o[n],this))return this.get(this.#o[n],o)}}forEach(e,o=this){for(let n of this.#O()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;i!==void 0&&e.call(o,i,this.#o[n],this)}}rforEach(e,o=this){for(let n of this.#F()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;i!==void 0&&e.call(o,i,this.#o[n],this)}}purgeStale(){let e=!1;for(let o of this.#F({allowStale:!0}))this.#g(o)&&(this.#E(this.#o[o],"expire"),e=!0);return e}info(e){let o=this.#n.get(e);if(o===void 0)return;let n=this.#t[o],s=this.#e(n)?n.__staleWhileFetching:n;if(s===void 0)return;let i={value:s};if(this.#h&&this.#A){let r=this.#h[o],a=this.#A[o];if(r&&a){let c=r-(this.#T.now()-a);i.ttl=c,i.start=Date.now()}}return this.#S&&(i.size=this.#S[o]),i}dump(){let e=[];for(let o of this.#O({allowStale:!0})){let n=this.#o[o],s=this.#t[o],i=this.#e(s)?s.__staleWhileFetching:s;if(i===void 0||n===void 0)continue;let r={value:i};if(this.#h&&this.#A){r.ttl=this.#h[o];let a=this.#T.now()-this.#A[o];r.start=Math.floor(Date.now()-a)}this.#S&&(r.size=this.#S[o]),e.unshift([n,r])}return e}load(e){this.clear();for(let[o,n]of e){if(n.start){let s=Date.now()-n.start;n.start=this.#T.now()-s}this.set(o,n.value,n)}}set(e,o,n={}){if(o===void 0)return this.delete(e),this;let{ttl:s=this.ttl,start:i,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=n,{noUpdateTTL:d=this.noUpdateTTL}=n,f=this.#B(e,o,n.size||0,a);if(this.maxEntrySize&&f>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#E(e,"set"),this;let l=this.#s===0?void 0:this.#n.get(e);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.#o[l]=e,this.#t[l]=o,this.#n.set(e,l),this.#l[this.#i]=l,this.#f[l]=this.#i,this.#i=l,this.#s++,this.#D(l,f,c),c&&(c.set="add"),d=!1,this.#G&&this.#R?.(o,e,"add");else{this.#I(l);let u=this.#t[l];if(o!==u){if(this.#b&&this.#e(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=u;m!==void 0&&!r&&(this.#C&&this.#p?.(m,e,"set"),this.#d&&this.#r?.push([m,e,"set"]))}else r||(this.#C&&this.#p?.(u,e,"set"),this.#d&&this.#r?.push([u,e,"set"]));if(this.#P(l),this.#D(l,f,c),this.#t[l]=o,c){c.set="replace";let m=u&&this.#e(u)?u.__staleWhileFetching:u;m!==void 0&&(c.oldValue=m)}}else c&&(c.set="update");this.#G&&this.onInsert?.(o,e,o===u?"update":"replace")}if(s!==0&&!this.#h&&this.#k(),this.#h&&(d||this.#$(l,s,i),c&&this.#L(c,l)),!r&&this.#d&&this.#r){let u=this.#r,m;for(;m=u?.shift();)this.#y?.(...m)}return this}pop(){try{for(;this.#s;){let e=this.#t[this.#c];if(this.#x(!0),this.#e(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#d&&this.#r){let e=this.#r,o;for(;o=e?.shift();)this.#y?.(...o)}}}#x(e){let o=this.#c,n=this.#o[o],s=this.#t[o];return this.#b&&this.#e(s)?s.__abortController.abort(new Error("evicted")):(this.#C||this.#d)&&(this.#C&&this.#p?.(s,n,"evict"),this.#d&&this.#r?.push([s,n,"evict"])),this.#P(o),this.#m?.[o]&&(clearTimeout(this.#m[o]),this.#m[o]=void 0),e&&(this.#o[o]=void 0,this.#t[o]=void 0,this.#v.push(o)),this.#s===1?(this.#c=this.#i=0,this.#v.length=0):this.#c=this.#l[o],this.#n.delete(n),this.#s--,o}has(e,o={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=o,i=this.#n.get(e);if(i!==void 0){let r=this.#t[i];if(this.#e(r)&&r.__staleWhileFetching===void 0)return!1;if(this.#g(i))s&&(s.has="stale",this.#L(s,i));else return n&&this.#N(i),s&&(s.has="hit",this.#L(s,i)),!0}else s&&(s.has="miss");return!1}peek(e,o={}){let{allowStale:n=this.allowStale}=o,s=this.#n.get(e);if(s===void 0||!n&&this.#g(s))return;let i=this.#t[s];return this.#e(i)?i.__staleWhileFetching:i}#H(e,o,n,s){let i=o===void 0?void 0:this.#t[o];if(this.#e(i))return i;let r=new lt,{signal:a}=n;a?.addEventListener("abort",()=>r.abort(a.reason),{signal:r.signal});let c={signal:r.signal,options:n,context:s},d=(T,A=!1)=>{let{aborted:p}=r.signal,_=n.ignoreFetchAbort&&T!==void 0,C=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&T!==void 0);if(n.status&&(p&&!A?(n.status.fetchAborted=!0,n.status.fetchError=r.signal.reason,_&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),p&&!_&&!A)return l(r.signal.reason,C);let O=m,S=this.#t[o];return(S===m||_&&A&&S===void 0)&&(T===void 0?O.__staleWhileFetching!==void 0?this.#t[o]=O.__staleWhileFetching:this.#E(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,T,c.options))),T},f=T=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=T),l(T,!1)),l=(T,A)=>{let{aborted:p}=r.signal,_=p&&n.allowStaleOnFetchAbort,C=_||n.allowStaleOnFetchRejection,O=C||n.noDeleteOnFetchRejection,S=m;if(this.#t[o]===m&&(!O||!A&&S.__staleWhileFetching===void 0?this.#E(e,"fetch"):_||(this.#t[o]=S.__staleWhileFetching)),C)return n.status&&S.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw T},u=(T,A)=>{let p=this.#M?.(e,i,c);p&&p instanceof Promise&&p.then(_=>T(_===void 0?void 0:_),A),r.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(T(void 0),n.allowStaleOnFetchAbort&&(T=_=>d(_,!0)))})};n.status&&(n.status.fetchDispatched=!0);let m=new Promise(u).then(d,f),y=Object.assign(m,{__abortController:r,__staleWhileFetching:i,__returned:void 0});return o===void 0?(this.set(e,y,{...c.options,status:void 0}),o=this.#n.get(e)):this.#t[o]=y,y}#e(e){if(!this.#b)return!1;let o=e;return!!o&&o instanceof Promise&&o.hasOwnProperty("__staleWhileFetching")&&o.__abortController instanceof lt}async fetch(e,o={}){let{allowStale:n=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:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:y=this.allowStaleOnFetchAbort,context:T,forceRefresh:A=!1,status:p,signal:_}=o;if(!this.#b)return p&&(p.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:i,status:p});let C={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:i,ttl:r,noDisposeOnSet:a,size:c,sizeCalculation:d,noUpdateTTL:f,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:y,ignoreFetchAbort:m,status:p,signal:_},O=this.#n.get(e);if(O===void 0){p&&(p.fetch="miss");let S=this.#H(e,O,C,T);return S.__returned=S}else{let S=this.#t[O];if(this.#e(S)){let g=n&&S.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",g&&(p.returnedStale=!0)),g?S.__staleWhileFetching:S.__returned=S}let N=this.#g(O);if(!A&&!N)return p&&(p.fetch="hit"),this.#I(O),s&&this.#N(O),p&&this.#L(p,O),S;let P=this.#H(e,O,C,T),I=P.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=N?"stale":"refresh",I&&N&&(p.returnedStale=!0)),I?P.__staleWhileFetching:P.__returned=P}}async forceFetch(e,o={}){let n=await this.fetch(e,o);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,o={}){let n=this.#U;if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:i,...r}=o,a=this.get(e,r);if(!i&&a!==void 0)return a;let c=n(e,a,{options:r,context:s});return this.set(e,c,r),c}get(e,o={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:r}=o,a=this.#n.get(e);if(a!==void 0){let c=this.#t[a],d=this.#e(c);return r&&this.#L(r,a),this.#g(a)?(r&&(r.get="stale"),d?(r&&n&&c.__staleWhileFetching!==void 0&&(r.returnedStale=!0),n?c.__staleWhileFetching:void 0):(i||this.#E(e,"expire"),r&&n&&(r.returnedStale=!0),n?c:void 0)):(r&&(r.get="hit"),d?c.__staleWhileFetching:(this.#I(a),s&&this.#N(a),c))}else r&&(r.get="miss")}#z(e,o){this.#f[o]=e,this.#l[e]=o}#I(e){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)}delete(e){return this.#E(e,"delete")}#E(e,o){let n=!1;if(this.#s!==0){let s=this.#n.get(e);if(s!==void 0)if(this.#m?.[s]&&(clearTimeout(this.#m?.[s]),this.#m[s]=void 0),n=!0,this.#s===1)this.#Y(o);else{this.#P(s);let i=this.#t[s];if(this.#e(i)?i.__abortController.abort(new Error("deleted")):(this.#C||this.#d)&&(this.#C&&this.#p?.(i,e,o),this.#d&&this.#r?.push([i,e,o])),this.#n.delete(e),this.#o[s]=void 0,this.#t[s]=void 0,s===this.#i)this.#i=this.#f[s];else if(s===this.#c)this.#c=this.#l[s];else{let r=this.#f[s];this.#l[r]=this.#l[s];let a=this.#l[s];this.#f[a]=this.#f[s]}this.#s--,this.#v.push(s)}}if(this.#d&&this.#r?.length){let s=this.#r,i;for(;i=s?.shift();)this.#y?.(...i)}return n}clear(){return this.#Y("delete")}#Y(e){for(let o of this.#F({allowStale:!0})){let n=this.#t[o];if(this.#e(n))n.__abortController.abort(new Error("deleted"));else{let s=this.#o[o];this.#C&&this.#p?.(n,s,e),this.#d&&this.#r?.push([n,s,e])}}if(this.#n.clear(),this.#t.fill(void 0),this.#o.fill(void 0),this.#h&&this.#A){this.#h.fill(0),this.#A.fill(0);for(let o of this.#m??[])o!==void 0&&clearTimeout(o);this.#m?.fill(void 0)}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){let o=this.#r,n;for(;n=o?.shift();)this.#y?.(...n)}}};const No=50*1024*1024,w=new Ro({maxSize:No,sizeCalculation:t=>JSON.stringify(t.data).length}),L={get(t){return w.get(t)},set(t,e){w.set(t,{data:e,storedAt:Date.now()})},delete(t){w.delete(t)},clear(){w.clear()},get size(){return w.size}};let M=null;function Po(t){M=t}const Io={competitions:{staleTTL:24*3600,maxTTL:72*3600},teams:{staleTTL:24*3600,maxTTL:48*3600},athletes:{staleTTL:24*3600,maxTTL:48*3600},venues:{staleTTL:72*3600,maxTTL:168*3600},countries:{staleTTL:96*3600,maxTTL:168*3600},coaches:{staleTTL:24*3600,maxTTL:48*3600},search:{staleTTL:300,maxTTL:1800}},gt=new Set;function Ht(t){const e=Io[t];if(!e)throw new Error(`Unknown entity type: ${t}`);return e}function dt(t,e){return Date.now()-t.storedAt<e*1e3}function ut(t,e){return Date.now()-t.storedAt>=e*1e3}function ft(t,e,o){gt.has(t)||(gt.add(t),o().then(n=>{L.set(t,n),M?.isInitialized&&M.set(t,e,n)}).catch(n=>{console.error(`[cache] Background refresh failed for ${t}:`,n)}).finally(()=>{gt.delete(t)}))}async function z(t,e,o){const{staleTTL:n,maxTTL:s}=Ht(e),i=L.get(t);if(i){if(dt(i,n))return i.data;if(!ut(i,s))return ft(t,e,o),i.data}if(M?.isInitialized){const a=M.get(t);if(a&&!ut(a,s))return L.set(t,a.data),dt(a,n)||ft(t,e,o),a.data}const r=await o();return L.set(t,r),M?.isInitialized&&M.set(t,e,r),r}async function kt(t,e,o,n){const{staleTTL:s,maxTTL:i}=Ht(e),r=new Map,a=[];for(const c of t){const d=n(c);let f=!1;const l=L.get(d);if(l&&!ut(l,i)&&(r.set(c,l.data),dt(l,s)||ft(d,e,async()=>{const m=(await o([c])).get(c);if(!m)throw new Error(`Batch fetcher did not return ID: ${c}`);return m}),f=!0),!f&&M?.isInitialized){const u=M.get(d);u&&!ut(u,i)&&(L.set(d,u.data),r.set(c,u.data),dt(u,s)||ft(d,e,async()=>{const y=(await o([c])).get(c);if(!y)throw new Error(`Batch fetcher did not return ID: ${c}`);return y}),f=!0)}f||a.push(c)}if(a.length>0){const c=await o(a);for(const[d,f]of c){const l=n(d);L.set(l,f),M?.isInitialized&&M.set(l,e,f),r.set(d,f)}}return r}function Mo(t){L.delete(t)}function D(t,e,o,n){const s=e.toUpperCase(),i=t.find(r=>r.language.toUpperCase()===s);if(i)return{name:i.name,shortName:i.short_name??n??void 0};if(s!=="EN"){const r=t.find(a=>a.language.toUpperCase()==="EN");if(r)return{name:r.name,shortName:r.short_name??n??void 0}}return{name:o,shortName:n??void 0}}function q(t){const e={};for(const o of t)e[o.key.toLowerCase()]=o.value;return e}function K(t){if(!t)return;const e={};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}function X(t){return t.map(e=>({provider:e.provider,id:e.id}))}function Uo(t,e){return t.filter(o=>o.relationship===e).map(o=>o.related_id)}function x(t,e,o){const n=t||Uo(e,"COUNTRY")[0];if(!n)return;const s=L.get(n)??L.get(`entity:${n}`);if(s?.data){const i=s.data;return st(i,o)}return{id:n,name:n}}function st(t,e){const{name:o,shortName:n}=D(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]);return{id:t.id,name:o,...t.country_code?{code:t.country_code}:{},...s.flag?{flag:s.flag}:{},...n?{shortName:n}:{}}}function St(t,e){const{name:o,shortName:n}=D(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.branding),r=x(null,t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.format?{type:t.format}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{}}}function nt(t,e){const{name:o,shortName:n}=D(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.metadata?.branding),r=x(t.country_id,t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.three_letter_code?{threeLetterCode:t.three_letter_code}:{},...t.full_name?{fullName:t.full_name}:{},...t.nickname?{nickname:t.nickname}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{}}}function $t(t,e){const{name:o,shortName:n}=D(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.metadata?.branding),r=x(t.country_id,t.related??[],e);return{id:t.id,name:o,sport:t.sport,type:"player",...n?{shortName:n}:{},...t.position?{position:t.position}:{},...t.birth_date?{birthdate:t.birth_date}:{},...t.shirt_number!=null?{shirtNumber:t.shirt_number}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo||s.headshot?{assets:{...s.logo?{logo:s.logo}:{},...s.headshot?{photo:s.headshot}:{}}}:{},...i?{metadata:{branding:i}}:{}}}function Bt(t,e){const{name:o}=D(t.translations??[],e,t.name,t.short_name),n=x(t.country_id,t.related??[],e),s=t.capacity!=null||t.latitude!=null||t.longitude!=null;return{id:t.id,name:o,sport:t.sport,...n?{country:n}:{},...s?{profile:{...t.capacity!=null?{capacity:t.capacity}:{},...t.latitude!=null?{latitude:t.latitude}:{},...t.longitude!=null?{longitude:t.longitude}:{}}}:{}}}function Go(t,e){const{name:o}=D(t.translations??[],e,t.name,t.short_name),n=x(t.country_id,t.related??[],e);return{id:t.id,name:o,sport:t.sport,...t.birth_date?{birthdate:t.birth_date}:{},...n?{country:n}:{}}}function Do(t,e,o){const n=L.get(t)??L.get(`entity:${t}`);if(!n?.data)return;const s=n.data;switch(e){case"COMPETITION":return St(s,o);case"TEAM":return nt(s,o);case"ATHLETE":return $t(s,o);case"COUNTRY":return st(s,o);default:return}}function it(t,e){if(!t||t.length===0)return;const o={};for(const n of t){const s=Do(n.related_id,n.relationship,e);if(s)switch(n.relationship){case"COMPETITION":(o.competitions??=[]).push(s);break;case"TEAM":(o.teams??=[]).push(s);break;case"ATHLETE":(o.athletes??=[]).push(s);break;case"COUNTRY":(o.countries??=[]).push(s);break}}return Object.keys(o).length>0?o:void 0}function xo(t,e){const{name:o,shortName:n}=D(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.branding),r=x(null,t.related??[],e),a=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.format?{type:t.format}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function Ft(t,e){const{name:o,shortName:n}=D(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.metadata?.branding),r=x(t.country_id,t.related??[],e),a=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.three_letter_code?{threeLetterCode:t.three_letter_code}:{},...t.full_name?{fullName:t.full_name}:{},...t.nickname?{nickname:t.nickname}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function Ho(t,e){const{name:o,shortName:n}=D(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.metadata?.branding),r=x(t.country_id,t.related??[],e),a=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,type:"player",...n?{shortName:n}:{},...t.position?{position:t.position}:{},...t.birth_date?{birthdate:t.birth_date}:{},...t.shirt_number!=null?{shirtNumber:t.shirt_number}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo||s.headshot?{assets:{...s.logo?{logo:s.logo}:{},...s.headshot?{photo:s.headshot}:{}}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function ko(t,e){return{...st(t,e),sport:t.sport,...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{}}}function $o(t,e){const{name:o}=D(t.translations??[],e,t.name,t.short_name),n=x(t.country_id,t.related??[],e),s=it(t.related??[],e),i=t.capacity!=null||t.latitude!=null||t.longitude!=null;return{id:t.id,name:o,sport:t.sport,...n?{country:n}:{},...i?{profile:{...t.capacity!=null?{capacity:t.capacity}:{},...t.latitude!=null?{latitude:t.latitude}:{},...t.longitude!=null?{longitude:t.longitude}:{}}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...s?{related:s}:{}}}function Bo(t,e){const{name:o}=D(t.translations??[],e,t.name,t.short_name),n=x(t.country_id,t.related??[],e),s=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,...t.birth_date?{birthdate:t.birth_date}:{},...n?{country:n}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...s?{related:s}:{}}}function Wt(t,e){const o=t.content_type?.toUpperCase?.(),n=t.type?.toUpperCase?.(),s=t.entityType?.toLowerCase?.();return o==="COMPETITION"||s==="competition"?{...xo(t,e),entityType:"competition"}:s==="country"||t.country_code!==void 0?{...ko(t,e),entityType:"country"}:s==="venue"||t.capacity!==void 0&&!s?{...$o(t,e),entityType:"venue"}:s==="coach"||n==="COACH"?{...Bo(t,e),entityType:"coach"}:s==="athlete"||n==="PLAYER"||t.position!==void 0||t.shirt_number!==void 0?{...Ho(t,e),entityType:"athlete"}:s==="team"||n==="TEAM"||t.three_letter_code!==void 0?{...Ft(t,e),entityType:"team"}:{...Ft(t,e),entityType:"team"}}function Wo(t,e){const o=t.content_type?.toUpperCase?.(),n=t.type?.toUpperCase?.(),s=t.entityType?.toLowerCase?.();return o==="COMPETITION"||s==="competition"?{...St(t,e),entityType:"competition"}:s==="country"||t.country_code!==void 0?{...st(t,e),entityType:"country"}:s==="venue"||t.capacity!==void 0&&!s?{...Bt(t,e),entityType:"venue"}:s==="coach"||n==="COACH"?{...Go(t,e),entityType:"coach"}:s==="athlete"||n==="PLAYER"||t.position!==void 0||t.shirt_number!==void 0?{...$t(t,e),entityType:"athlete"}:s==="team"||n==="TEAM"||t.three_letter_code!==void 0?{...nt(t,e),entityType:"team"}:{...nt(t,e),entityType:"team"}}function J(t){const e=Object.entries(t).filter(([,n])=>n!==void 0).sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}=${Array.isArray(s)?s.join(","):s}`).join("&");let o=0;for(let n=0;n<e.length;n++)o=(o<<5)-o+e.charCodeAt(n)|0;return o.toString(36)}function V(t){for(const e of t)e.id&&L.set(`entity:${e.id}`,e)}function Y(t){if(t?.lang)return t.lang;if(h.isConfigured()){const e=h.getConfig();if(e.fansUnited&&"lang"in e.fansUnited&&e.fansUnited.lang)return e.fansUnited.lang}return"EN"}function Et(t){const e=new Set;for(const o of t){const n=o,s=n.related;if(s)for(const r of s)L.get(`entity:${r.related_id}`)||e.add(r.related_id);const i=n.country_id;i&&!L.get(`entity:${i}`)&&e.add(i)}return e}async function Tt(t,e){if(t.size===0)return[];const o=await $.get({path:"/v1/entities/search",params:{ids:Array.from(t)},next:e?.next,config:e?.config});return V(o.data),o.data}async function zt(t,e){const o=Et(t);if(o.size!==0)try{const n=await Tt(o,e),s=Et(n);s.size>0&&await Tt(s,e)}catch{}}async function rt(t,e){const o=new Set;for(const n of t){const s=n,i=s.country_id;i&&!L.get(`entity:${i}`)&&o.add(i);const r=s.related;if(r)for(const a of r)a.relationship==="COUNTRY"&&!L.get(`entity:${a.related_id}`)&&o.add(a.related_id)}if(o.size!==0)try{await Tt(o,e)}catch{}}async function zo(t={},e){const o=Y(t),n={query:t.query,content_type:t.contentType,ids:t.ids,limit:t.limit?.toString(),page:t.page?.toString(),mode:t.mode,sport:t.sport,relationship:t.relationship,value:t.value},s=`search:entities:${J(n)}`,i=await z(s,"search",()=>$.get({path:"/v1/entities/search",params:n,next:t.next||e?.next,config:t.config}));return V(i.data),await rt(i.data,{next:t.next||e?.next,config:t.config}),{data:i.data.map(a=>Wo(a,o)),pagination:i.meta.pagination}}async function Yo(t,e){const o=Y(e),n=`entity:${t}`,s=await z(n,"search",async()=>{const i=await $.get({path:"/v1/entities/search",params:{ids:[t]},next:e?.next,config:e?.config});if(!i.data||i.data.length===0)throw new Error(`Entity not found: ${t}`);return i.data[0]});return await zt([s],{next:e?.next,config:e?.config}),Wt(s,o)}async function jo(t,e){if(t.length===0)return[];const o=Y(e),n=await kt(t,"search",async i=>{const r=await $.get({path:"/v1/entities/search",params:{ids:i},next:e?.next,config:e?.config}),a=new Map;for(const c of r.data)a.set(c.id,c);return a},i=>`entity:${i}`),s=t.map(i=>n.get(i)).filter(i=>i!==void 0);return await zt(s,{next:e?.next,config:e?.config}),s.map(i=>Wt(i,o))}async function qo(t={}){const e=Y(t),o={content_type:"competition",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`competitions:${J(o)}`,s=await z(n,"competitions",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),await rt(s.data,{next:t.next,config:t.config}),{data:s.data.map(r=>St(r,e)),pagination:s.meta.pagination}}async function Vo(t,e={}){const o=Y(e),n={content_type:"team",relationship:"COUNTRY",value:t,query:e.query,limit:e.limit?.toString(),page:e.page?.toString(),sport:e.sport},s=`teams:country:${t}:${J(n)}`,i=await z(s,"teams",()=>$.get({path:"/v1/entities/search",params:n,next:e.next,config:e.config}));return V(i.data),await rt(i.data,{next:e.next,config:e.config}),{data:i.data.map(a=>nt(a,o)),pagination:i.meta.pagination}}async function Qo(t,e={}){const o=Y(e),n={content_type:"team",relationship:"COMPETITION",value:t,query:e.query,limit:e.limit?.toString(),page:e.page?.toString(),sport:e.sport},s=`teams:competition:${t}:${J(n)}`,i=await z(s,"teams",()=>$.get({path:"/v1/entities/search",params:n,next:e.next,config:e.config}));return V(i.data),await rt(i.data,{next:e.next,config:e.config}),{data:i.data.map(a=>nt(a,o)),pagination:i.meta.pagination}}async function Ko(t={}){const e=Y(t),o={content_type:"country",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`countries:${J(o)}`,s=await z(n,"countries",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),{data:s.data.map(r=>st(r,e)),pagination:s.meta.pagination}}async function Xo(t={}){const e=Y(t),o={content_type:"venue",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`venues:${J(o)}`,s=await z(n,"venues",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),await rt(s.data,{next:t.next,config:t.config}),{data:s.data.map(r=>Bt(r,e)),pagination:s.meta.pagination}}function Jo(t){return!t.seasons||t.seasons.length===0?void 0:t.seasons.find(o=>o.active)??t.seasons[0]}function Zo(t,e){const o=new Date,n=e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="NOT_STARTED",a=new Date(s.timing.kickoffTime)>=o;return i&&r&&a});return n.sort((s,i)=>new Date(s.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()),n[0]}function wo(t,e){const o=new Date,n=e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="FINISHED",a=new Date(s.timing.kickoffTime)<=o;return i&&r&&a});return n.sort((s,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(s.timing.kickoffTime).getTime()),n[0]}function tn(t,e){const o=new Date;return e.filter(s=>{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)>=o||s.status.type==="LIVE";return i&&r&&a}).sort((s,i)=>new Date(s.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime())}function en(t,e){const o=new Date;return e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="FINISHED",a=new Date(s.timing.kickoffTime)<=o;return i&&r&&a}).sort((s,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(s.timing.kickoffTime).getTime())}function on(t,e,o){const n=o.filter(r=>r.status.type==="FINISHED"),s=o.filter(r=>r.status.type==="NOT_STARTED"||r.status.type==="POSTPONED"),i=e.entries.map(r=>{const a=r.competitor.id,c=n.filter(u=>u.competitorOne.id===t&&u.competitorTwo.id===a||u.competitorOne.id===a&&u.competitorTwo.id===t),d=s.filter(u=>u.competitorOne.id===t&&u.competitorTwo.id===a||u.competitorOne.id===a&&u.competitorTwo.id===t);let f,l;return c.forEach(u=>{const m=u.competitorOne.id===t,y=parseInt(u.score?.competitorOne??"0"),T=parseInt(u.score?.competitorTwo??"0"),A=m?y:T,p=m?T:y;let _;A>p?_="W":A===p?_="D":_="L";const C={result:_,score:`${y} - ${T}`,date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!1};m?f=C:l=C}),d.forEach(u=>{const m=u.competitorOne.id===t;m&&!f?f={date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!0}:!m&&!l&&(l={date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!0})}),{rank:r.rank,teamId:r.competitor.id,teamName:r.competitor.name,teamShortName:r.competitor.shortName,teamLogo:r.competitor.logo,gamesPlayed:r.stats.played??0,points:r.stats.points??0,homeResult:f,awayResult:l}});return{teamId:t,rows:i}}function nn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.goals??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.goals??0,i=n.seasonStatistics?.goals??0;if(i!==s)return i-s;const r=o.seasonStatistics?.assists??0;return(n.seasonStatistics?.assists??0)-r}).slice(0,e)}function sn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.assists??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.assists??0,i=n.seasonStatistics?.assists??0;if(i!==s)return i-s;const r=o.seasonStatistics?.goals??0;return(n.seasonStatistics?.goals??0)-r}).slice(0,e)}function rn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.appearances??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.appearances??0,i=n.seasonStatistics?.appearances??0;if(i!==s)return i-s;const r=o.seasonStatistics?.minutes??0;return(n.seasonStatistics?.minutes??0)-r}).slice(0,e)}function an(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.minutes??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.minutes??0,i=n.seasonStatistics?.minutes??0;if(i!==s)return i-s;const r=o.seasonStatistics?.appearances??0;return(n.seasonStatistics?.appearances??0)-r}).slice(0,e)}function cn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.cleansheets??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.cleansheets??0,i=n.seasonStatistics?.cleansheets??0;if(i!==s)return i-s;const r=o.seasonStatistics?.appearances??0;return(n.seasonStatistics?.appearances??0)-r}).slice(0,e)}function ln(t,e=10){return t.players.filter(o=>{const n=o.seasonStatistics?.yellowCards??0,s=o.seasonStatistics?.redCards??0;return n+s>0}).sort((o,n)=>{const s=o.seasonStatistics?.yellowCards??0,i=o.seasonStatistics?.redCards??0,r=n.seasonStatistics?.yellowCards??0,a=n.seasonStatistics?.redCards??0,c=s+i*3,d=r+a*3;return d!==c?d-c:a!==i?a-i:r-s}).slice(0,e)}function Q(t){const e=new Map,o=new Map;return t.forEach(n=>{!n.mainEvents||n.mainEvents.length===0||n.mainEvents.forEach(s=>{if(s.primaryPlayer){const i=s.primaryPlayer.id;e.has(i)||e.set(i,{playerId:s.primaryPlayer.id,seasonId:"",teamId:"",goals:0,assists:0,yellowCards:0,redCards:0,appearances:0});const r=e.get(i);o.has(i)||o.set(i,new Set),o.get(i).add(n.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)}if(s.secondaryPlayer&&(s.type==="GOAL"||s.type==="PENALTY_GOAL")){const i=s.secondaryPlayer.id;e.has(i)||e.set(i,{playerId:s.secondaryPlayer.id,seasonId:"",teamId:"",goals:0,assists:0,yellowCards:0,redCards:0,appearances:0});const r=e.get(i);r.assists=(r.assists??0)+1,o.has(i)||o.set(i,new Set),o.get(i).add(n.id)}})}),o.forEach((n,s)=>{const i=e.get(s);i&&i.appearances!==void 0&&(i.appearances=n.size)}),e}function at(t){return Array.from(t.values()).map(e=>({...e,totalCards:(e.yellowCards??0)+(e.redCards??0)}))}function Yt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.goals??0)>0).sort((s,i)=>{const r=s.goals??0,a=i.goals??0;if(a!==r)return a-r;const c=s.assists??0;return(i.assists??0)-c}).slice(0,e)}function jt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.assists??0)>0).sort((s,i)=>{const r=s.assists??0,a=i.assists??0;if(a!==r)return a-r;const c=s.goals??0;return(i.goals??0)-c}).slice(0,e)}function qt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.totalCards??0)>0).sort((s,i)=>{const r=(s.yellowCards??0)+(s.redCards??0)*3,a=(i.yellowCards??0)+(i.redCards??0)*3;if(a!==r)return a-r;const c=s.redCards??0,d=i.redCards??0;if(d!==c)return d-c;const f=s.yellowCards??0;return(i.yellowCards??0)-f}).slice(0,e)}function Vt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.goals??0)+(s.assists??0)>0).sort((s,i)=>{const r=(s.goals??0)+(s.assists??0),a=(i.goals??0)+(i.assists??0);if(a!==r)return a-r;const c=s.goals??0,d=i.goals??0;if(d!==c)return d-c;const f=s.assists??0;return(i.assists??0)-f}).slice(0,e)}function Qt(t){const e=Q(t);return at(e).sort((n,s)=>{const i=n.appearances??0,r=s.appearances??0;if(r!==i)return r-i;const a=(n.goals??0)+(n.assists??0);return(s.goals??0)+(s.assists??0)-a})}function dn(t,e=10){return j.useMemo(()=>Yt(t,e),[t,e])}function un(t,e=10){return j.useMemo(()=>jt(t,e),[t,e])}function fn(t,e=10){return j.useMemo(()=>qt(t,e),[t,e])}function hn(t,e=10){return j.useMemo(()=>Vt(t,e),[t,e])}function mn(t){return j.useMemo(()=>Qt(t),[t])}function Kt(t){return j.useMemo(()=>Q(t),[t])}function gn(t,e){const o=Kt(t);return j.useMemo(()=>o.get(e),[o,e])}const Xt=["GOAL","PENALTY_GOAL","OWN_GOAL"];function R(t,e){return e>0?t/e*100:0}function et(t,e){return e>0?t/e:0}function pn(t,e=!1,o=2){return e?`${Math.round(t)}%`:Number.isInteger(t)?t.toString():t.toFixed(o)}function yn(t,e){const o=typeof t=="string"?parseFloat(t):t;if(isNaN(o)||e===0)return"0";const n=(o/e).toFixed(1);return`${o} (${n} avg)`}function Tn(t,e){const o=typeof t=="string"?parseFloat(t):t;return isNaN(o)||e===0?"0.0":(o/e).toFixed(1)}function _n(t){const e=parseFloat(t);return isNaN(e)?"0%":`${Math.round(e)}%`}function Jt(t,e,o){if(t.status?.type!=="FINISHED"||!t.score)return null;const n=parseInt(t.score.competitorOne||"0"),s=parseInt(t.score.competitorTwo||"0"),i=o?n:s,r=o?s:n;let a=null,c=null;const d=t.score.breakdown?.halfTime;if(d){const m=parseInt(d.competitorOne||"0"),y=parseInt(d.competitorTwo||"0");a=o?m:y,c=o?y:m}const f=t.statistics;let l=null,u=null;if(f){const m=f.find?.(y=>y.type==="CORNERS");m&&(l=o?m.competitorOne:m.competitorTwo,u=o?m.competitorTwo:m.competitorOne)}return{goalsFor:i,goalsAgainst:r,halfTimeGoalsFor:a,halfTimeGoalsAgainst:c,cornersFor:l,cornersAgainst:u,isWin:i>r,isDraw:i===r,isLoss:i<r}}function ht(t,e){return t.competitorOne.id===e}function Zt(t,e){return t.competitorTwo.id===e}function vn(t,e){return ht(t,e)||Zt(t,e)}function Sn(t){return t.status?.type==="FINISHED"}function An(t,e){const o=ht(t,e);return parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")}function Cn(t,e){const o=ht(t,e);return parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")}function On(t,e,o){const n=t.filter(f=>{if(f.status?.type!=="FINISHED"||!f.score)return!1;const l=f.competitorOne.id===e||f.competitorTwo.id===e,u=f.competitorOne.id===o||f.competitorTwo.id===o;return l&&u});let s=0,i=0,r=0,a=0,c=0;n.forEach(f=>{const l=parseInt(f.score?.competitorOne||"0"),u=parseInt(f.score?.competitorTwo||"0"),m=f.competitorOne.id===e,y=m?l:u,T=m?u:l;a+=y,c+=T,y>T?s++:T>y?i++:r++});const d=n.length;return{totalMatches:d,homeTeamWins:s,awayTeamWins:i,draws:r,homeTeamGoals:a,awayTeamGoals:c,homeTeamWinPercentage:d>0?s/d*100:0,awayTeamWinPercentage:d>0?i/d*100:0,drawPercentage:d>0?r/d*100:0,homeTeamAvgGoals:d>0?a/d:0,awayTeamAvgGoals:d>0?c/d:0}}function Fn(t,e,o,n=5){return t.filter(i=>{if(i.status?.type!=="FINISHED"||!i.score)return!1;const r=i.competitorOne.id===e||i.competitorTwo.id===e,a=i.competitorOne.id===o||i.competitorTwo.id===o;return r&&a}).sort((i,r)=>new Date(r.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()).slice(0,n).map(i=>{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;let l;return d>f?l="home":f>d?l="away":l="draw",{id:i.id,date:new Date(i.timing.kickoffTime).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),homeTeamName:i.competitorOne.name,awayTeamName:i.competitorTwo.name,homeTeamLogo:i.competitorOne.assets?.logo,awayTeamLogo:i.competitorTwo.assets?.logo,homeScore:r,awayScore:a,venue:i.venue?.name,winner:l}})}function En(t,e,o){return t.filter(n=>{const s=n.competitorOne.id===e,i=n.competitorTwo.id===e;return!s&&!i?!1:o==="home"?s:i}).map(n=>{const s=n.competitorOne.id===e;return Jt(n,e,s)}).filter(n=>n!==null)}function Lt(t,e,o,n){let s=0;for(const i of t){const r=i.competitorOne.id===e,a=i.competitorTwo.id===e;if(!r&&!a||o==="home"&&!r||o==="away"&&!a||i.status?.type!=="FINISHED")continue;const c=i.mainEvents;if(!c||!Array.isArray(c))continue;const d=c.filter(y=>y.type&&Xt.includes(y.type)).sort((y,T)=>{const A=y.minute??0,p=T.minute??0;return A!==p?A-p:(y.injuryMinute??0)-(T.injuryMinute??0)});if(d.length===0)continue;const f=d[0],l=r?"ONE":"TWO",u=f.type==="OWN_GOAL";let m;u?m=f.competitorPosition!==l:m=f.competitorPosition===l,(n==="scored"&&m||n==="conceded"&&!m)&&s++}return s}function Ln(t,e,o){let n=0;for(const s of t){const i=s.competitorOne.id===e,r=s.competitorTwo.id===e;if(!i&&!r||o==="home"&&!i||o==="away"&&!r||s.status?.type!=="FINISHED")continue;const a=s.mainEvents;a&&Array.isArray(a)&&n++}return n}function bn(t,e,o){const n=En(t,e,o),s=n.length;if(s===0)return{played:0,goalsForPerMatch:0,cleanSheets:0,wonToNil:0,scoringRate:0,scoredInBothHalves:0,scoredFirst:0,leadingAtHalfTime:0,goalsAgainstPerMatch:0,failedToScore:0,lostToNil:0,concedingRate:0,concededInBothHalves:0,concededFirst:0,losingAtHalfTime:0,avgCornersFor:0,avgCornersAgainst:0};const i=n.reduce((g,F)=>g+F.goalsFor,0),r=n.reduce((g,F)=>g+F.goalsAgainst,0),a=n.filter(g=>g.goalsAgainst===0).length,c=n.filter(g=>g.isWin&&g.goalsAgainst===0).length,d=n.filter(g=>g.goalsFor>0).length,f=n.filter(g=>g.goalsFor===0).length,l=n.filter(g=>g.isLoss&&g.goalsFor===0).length,u=n.filter(g=>g.goalsAgainst>0).length,m=n.filter(g=>g.halfTimeGoalsFor!==null),y=m.length,T=m.filter(g=>{const F=g.halfTimeGoalsFor,Z=g.goalsFor-F;return F>0&&Z>0}).length,A=Lt(t,e,o,"scored"),p=Ln(t,e,o),_=m.filter(g=>g.halfTimeGoalsFor>g.halfTimeGoalsAgainst).length,C=m.filter(g=>{const F=g.halfTimeGoalsAgainst,Z=g.goalsAgainst-F;return F>0&&Z>0}).length,O=Lt(t,e,o,"conceded"),S=m.filter(g=>g.halfTimeGoalsAgainst>g.halfTimeGoalsFor).length,N=n.filter(g=>g.cornersFor!==null),P=N.reduce((g,F)=>g+(F.cornersFor||0),0),I=N.reduce((g,F)=>g+(F.cornersAgainst||0),0);return{played:s,goalsForPerMatch:et(i,s),cleanSheets:R(a,s),wonToNil:R(c,s),scoringRate:R(d,s),scoredInBothHalves:R(T,y),scoredFirst:R(A,p),leadingAtHalfTime:R(_,y),goalsAgainstPerMatch:et(r,s),failedToScore:R(f,s),lostToNil:R(l,s),concedingRate:R(u,s),concededInBothHalves:R(C,y),concededFirst:R(O,p),losingAtHalfTime:R(S,y),avgCornersFor:et(P,N.length),avgCornersAgainst:et(I,N.length)}}function Rn(t,e){return t.filter(o=>o.status?.type!=="FINISHED"?!1:o.competitorOne.id===e||o.competitorTwo.id===e).map(o=>{const n=o.competitorOne.id===e,s=parseInt(o.score?.competitorOne||"0"),i=parseInt(o.score?.competitorTwo||"0"),r=s+i,a=o.periods;let c=null;if(a&&Array.isArray(a)){const d=a.find(f=>f.type==="FIRST_HALF"||f.type==="1ST_HALF");if(d?.score){const f=parseInt(d.score.competitorOne||"0"),l=parseInt(d.score.competitorTwo||"0");c=f+l}}return{totalGoals:r,halfTimeGoals:c,isHome:n}})}function v(t,e){return t.length===0?0:t.filter(n=>n>e).length/t.length*100}function Nn(t,e){const o=Rn(t,e),n=o.filter(l=>l.isHome),s=o.filter(l=>!l.isHome),i=o.map(l=>l.totalGoals),r=n.map(l=>l.totalGoals),a=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),f=s.filter(l=>l.halfTimeGoals!==null).map(l=>l.halfTimeGoals);return{over05:{home:v(r,.5),total:v(i,.5),away:v(a,.5)},over15:{home:v(r,1.5),total:v(i,1.5),away:v(a,1.5)},over25:{home:v(r,2.5),total:v(i,2.5),away:v(a,2.5)},over35:{home:v(r,3.5),total:v(i,3.5),away:v(a,3.5)},over45:{home:v(r,4.5),total:v(i,4.5),away:v(a,4.5)},over55:{home:v(r,5.5),total:v(i,5.5),away:v(a,5.5)},over05HT:{home:v(d,.5),total:v(c,.5),away:v(f,.5)},over15HT:{home:v(d,1.5),total:v(c,1.5),away:v(f,1.5)},over25HT:{home:v(d,2.5),total:v(c,2.5),away:v(f,2.5)}}}function wt(t,e){const o=t.competitorOne.id===e,n=t.competitorTwo.id===e;if(!o&&!n||!t.score)return null;const s=parseInt(o?t.score.competitorOne||"0":t.score.competitorTwo||"0"),i=parseInt(o?t.score.competitorTwo||"0":t.score.competitorOne||"0");let r;return s>i?r="W":s<i?r="L":r="D",{result:{score:`${s}:${i}`,result:r,isHome:o},isHome:o}}function Pn(t,e,o,n,s,i){const r=e?.entries.find(H=>H.competitor.id===t),a=o?.entries.find(H=>H.competitor.id===t),c=n?.entries.find(H=>H.competitor.id===t),d=s?.entries.find(H=>H.competitor.id===t),f=i?.entries.find(H=>H.competitor.id===t);if(!r)return null;const l=a?.stats?.goalsFor??0,u=c?.stats?.goalsFor??0,m=r?.stats?.goalsFor??0,y=d?.stats?.goalsAgainst??0,T=f?.stats?.goalsAgainst??0,A=r?.stats?.goalsAgainst??0,p=a?.stats?.played??0,_=c?.stats?.played??0,C=r?.stats?.played??0,O=C>0?m/C:0,S=C>0?A/C:0,N=O+S,P=p>0?l/p:0,I=_>0?u/_:0,g=p>0?y/p:0,F=_>0?T/_:0,Z=P+g,te=I+F;return{homeGoals:l,totalGoals:m,awayGoals:u,homeGamesPlayed:p,awayGamesPlayed:_,totalGamesPlayed:C,homeGoalsConceded:y,totalGoalsConceded:A,awayGoalsConceded:T,gfPerMatch:O,gaPerMatch:S,gfGaPerMatch:N,homeGfPerMatch:P,awayGfPerMatch:I,homeGaPerMatch:g,awayGaPerMatch:F,homeGfGaPerMatch:Z,awayGfGaPerMatch:te}}function b(t,e,o,n){const s=t.filter(r=>{const a=r.competitorOne.id===e,c=r.competitorTwo.id===e;return!(!a&&!c||r.status?.type!=="FINISHED"||n==="home"&&!a||n==="away"&&!c)}).sort((r,a)=>new Date(a.timing.kickoffTime).getTime()-new Date(r.timing.kickoffTime).getTime());if(s.length===0)return null;let i=0;for(const r of s){const a=r.competitorOne.id===e;if(o(r,e,a))i++;else break}return i>0?i:null}const E={win:(t,e,o)=>{const n=parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0"),s=parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0");return n>s},draw:t=>t.score?.competitorOne===t.score?.competitorTwo,loss:(t,e,o)=>{const n=parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0"),s=parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0");return n<s},noWin:(t,e,o)=>!E.win(t,e,o),noDraw:t=>!E.draw(t),noDefeat:(t,e,o)=>!E.loss(t,e,o),scored:(t,e,o)=>parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")>=1,conceded:(t,e,o)=>parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")>=1,noGoalScored:(t,e,o)=>!E.scored(t,e,o),noGoalConceded:(t,e,o)=>!E.conceded(t,e,o),over25:t=>parseInt(t.score?.competitorOne||"0")+parseInt(t.score?.competitorTwo||"0")>2,under25:t=>parseInt(t.score?.competitorOne||"0")+parseInt(t.score?.competitorTwo||"0")<3,scoredTwice:(t,e,o)=>parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")>=2,concededTwice:(t,e,o)=>parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")>=2};function ot(t,e,o){return{win:b(t,e,E.win,o),draw:b(t,e,E.draw,o),loss:b(t,e,E.loss,o),noWin:b(t,e,E.noWin,o),noDraw:b(t,e,E.noDraw,o),noDefeat:b(t,e,E.noDefeat,o),scored:b(t,e,E.scored,o),conceded:b(t,e,E.conceded,o),noGoalScored:b(t,e,E.noGoalScored,o),noGoalConceded:b(t,e,E.noGoalConceded,o),over25:b(t,e,E.over25,o),under25:b(t,e,E.under25,o),scoredTwice:b(t,e,E.scoredTwice,o),concededTwice:b(t,e,E.concededTwice,o)}}function In(t,e,o){const n=ot(t,e,"home"),s=ot(t,e),i=ot(t,o,"away"),r=ot(t,o);return[{label:"Consecutive wins",homeTeam:{home:n.win,total:s.win},awayTeam:{total:r.win,home:i.win},colorType:"neutral"},{label:"Consecutive draws",homeTeam:{home:n.draw,total:s.draw},awayTeam:{total:r.draw,home:i.draw},colorType:"neutral"},{label:"Consecutive defeats",homeTeam:{home:n.loss,total:s.loss},awayTeam:{total:r.loss,home:i.loss},colorType:"neutral"},{label:"No win",homeTeam:{home:n.noWin,total:s.noWin},awayTeam:{total:r.noWin,home:i.noWin},colorType:"negative"},{label:"No draw",homeTeam:{home:n.noDraw,total:s.noDraw},awayTeam:{total:r.noDraw,home:i.noDraw},colorType:"neutral"},{label:"No defeat",homeTeam:{home:n.noDefeat,total:s.noDefeat},awayTeam:{total:r.noDefeat,home:i.noDefeat},colorType:"positive"},{label:"Scored at least once",homeTeam:{home:n.scored,total:s.scored},awayTeam:{total:r.scored,home:i.scored},colorType:"positive"},{label:"Conceded at least once",homeTeam:{home:n.conceded,total:s.conceded},awayTeam:{total:r.conceded,home:i.conceded},colorType:"negative"},{label:"No goal scored",homeTeam:{home:n.noGoalScored,total:s.noGoalScored},awayTeam:{total:r.noGoalScored,home:i.noGoalScored},colorType:"neutral"},{label:"No goal conceded",homeTeam:{home:n.noGoalConceded,total:s.noGoalConceded},awayTeam:{total:r.noGoalConceded,home:i.noGoalConceded},colorType:"neutral"},{label:"GS + GC over 2.5",homeTeam:{home:n.over25,total:s.over25},awayTeam:{total:r.over25,home:i.over25},colorType:"neutral"},{label:"GS + GC under 2.5",homeTeam:{home:n.under25,total:s.under25},awayTeam:{total:r.under25,home:i.under25},colorType:"neutral"},{label:"Scored at least twice",homeTeam:{home:n.scoredTwice,total:s.scoredTwice},awayTeam:{total:r.scoredTwice,home:i.scoredTwice},colorType:"positive"},{label:"Conceded at least twice",homeTeam:{home:n.concededTwice,total:s.concededTwice},awayTeam:{total:r.concededTwice,home:i.concededTwice},colorType:"negative"}]}function bt(t,e){const o=new Map;return t.forEach(n=>{if(n.status?.type!=="FINISHED")return;const s=wt(n,e);if(!s)return;const i=s.isHome?n.competitorTwo.id:n.competitorOne.id,r=s.isHome?n.competitorTwo:n.competitorOne,a=o.get(i)||{opponentId:i,opponentName:r.name,opponentLogo:r.assets?.logo};s.isHome?a.homeResult=s.result:a.awayResult=s.result,o.set(i,a)}),o}function Mn(t,e,o,n,s,i,r){const a=bt(t,e),c=bt(t,o),d=new Set([...a.keys(),...c.keys(),e,o]),f=[];return d.forEach(l=>{const u=a.get(l),m=c.get(l);if(!u&&!m&&l!==e&&l!==o)return;let y,T;l===e?(y=n,T=i):l===o?(y=s,T=r):(y=u?.opponentName||m?.opponentName||"",T=u?.opponentLogo||m?.opponentLogo),f.push({opponentId:l,opponentName:y,opponentLogo:T,homeTeamHome:u?.homeResult,homeTeamAway:u?.awayResult,awayTeamHome:m?.homeResult,awayTeamAway:m?.awayResult,isHomeTeamRow:l===e,isAwayTeamRow:l===o})}),f.sort((l,u)=>l.isHomeTeamRow?-1:u.isHomeTeamRow?1:l.isAwayTeamRow?-1:u.isAwayTeamRow?1:l.opponentName.localeCompare(u.opponentName))}exports.addProviderRef=h.addProviderRef;exports.getBatchMatchOdds=h.getBatchMatchOdds;exports.getConfig=h.getConfig;exports.getFootballCompetition=h.getFootballCompetition;exports.getFootballLivescore=h.getFootballLivescore;exports.getFootballMatch=h.getFootballMatch;exports.getFootballMatchCommentary=h.getFootballMatchCommentary;exports.getFootballMatchEvents=h.getFootballMatchEvents;exports.getFootballMatchLineups=h.getFootballMatchLineups;exports.getFootballMatchOdds=h.getFootballMatchOdds;exports.getFootballMatchStatistics=h.getFootballMatchStatistics;exports.getFootballMatches=h.getFootballMatches;exports.getFootballPlayerSeasonStatistics=h.getFootballPlayerSeasonStatistics;exports.getFootballSeasonDetails=h.getFootballSeasonDetails;exports.getFootballStandings=h.getFootballStandings;exports.getFootballTeam=h.getFootballTeam;exports.getFootballTeamSquad=h.getFootballTeamSquad;exports.getLeaderboardMatches=h.getLeaderboardMatches;exports.getLeaderboardTeamMatches=h.getLeaderboardTeamMatches;exports.getLeaderboardTemplate=h.getLeaderboardTemplate;exports.getProviderRefId=h.getProviderRefId;exports.isConfigured=h.isConfigured;exports.setConfig=h.setConfig;exports.toProviderRefArray=h.toProviderRefArray;exports.GOAL_EVENT_TYPES=Xt;exports.aggregatePlayerStatisticsFromMatches=Q;exports.analyzeMatch=Jt;exports.cached=z;exports.cachedBatch=kt;exports.calcAverage=et;exports.calcPercentage=R;exports.calculateH2HStats=On;exports.calculateStreak=b;exports.formatAsAverage=Tn;exports.formatPossessionPercentage=_n;exports.formatStatValue=pn;exports.formatWithAverage=yn;exports.getActiveSeason=Jo;exports.getAllPlayerStatisticsFromMatches=Qt;exports.getBasketballLivescore=ye;exports.getFansUnitedCompetitions=qo;exports.getFansUnitedCountries=Ko;exports.getFansUnitedEntitiesByIds=jo;exports.getFansUnitedEntityById=Yo;exports.getFansUnitedFootballCompetition=ro;exports.getFansUnitedFootballCompetitions=oo;exports.getFansUnitedFootballMatch=_o;exports.getFansUnitedFootballMatches=vo;exports.getFansUnitedFootballPlayer=yo;exports.getFansUnitedFootballPlayers=To;exports.getFansUnitedFootballSearch=Oo;exports.getFansUnitedFootballTeam=uo;exports.getFansUnitedFootballTeams=fo;exports.getFansUnitedSearchEntities=zo;exports.getFansUnitedTeamsByCompetition=Qo;exports.getFansUnitedTeamsByCountry=Vo;exports.getFansUnitedVenues=Xo;exports.getMatchResult=wt;exports.getMostCardedPlayersFromMatches=qt;exports.getOpponentScore=Cn;exports.getRecentH2HMeetings=Fn;exports.getSportal365Standings=Qe;exports.getTeamFinishedMatches=en;exports.getTeamGoalStats=Pn;exports.getTeamHomeAwayStats=bn;exports.getTeamMostDecorated=ln;exports.getTeamNextMatch=Zo;exports.getTeamOverUnderStats=Nn;exports.getTeamPreviousMatch=wo;exports.getTeamResultsTable=on;exports.getTeamScore=An;exports.getTeamSeasonStatistics=Je;exports.getTeamStreaks=ot;exports.getTeamStreaksComparison=In;exports.getTeamTopAppearances=rn;exports.getTeamTopAssisters=sn;exports.getTeamTopCleanSheets=cn;exports.getTeamTopMinutesPlayed=an;exports.getTeamTopScorers=nn;exports.getTeamUpcomingMatches=tn;exports.getTeamsCommonOpponents=Mn;exports.getTennisLivescore=Fe;exports.getTopAssistersFromMatches=jt;exports.getTopGoalContributorsFromMatches=Vt;exports.getTopScorersFromMatches=Yt;exports.initL2=Po;exports.invalidate=Mo;exports.isMatchFinished=Sn;exports.isTeamAway=Zt;exports.isTeamHome=ht;exports.isTeamInMatch=vn;exports.search=De;exports.searchFootball=ce;exports.streakFilters=E;exports.useAllPlayerStatisticsFromMatches=mn;exports.useMostCardedPlayersFromMatches=fn;exports.usePlayerStatistics=gn;exports.usePlayerStatisticsMap=Kt;exports.useTopAssistersFromMatches=un;exports.useTopGoalContributorsFromMatches=hn;exports.useTopScorersFromMatches=dn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./matches-tjnMum3M.cjs"),j=require("react");function ee(t){return{entityType:"tournament",id:t.id.toString(),name:t.name,slug:t.slug,gender:t.gender,type:t.type,region:t.region,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_logo?{logo:t.url_logo}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function oe(t){return{entityType:"player",id:t.id.toString(),name:t.name,slug:t.slug,position:t.position,gender:t.gender,birthdate:t.birthdate,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ne(t){return{entityType:"team",id:t.id.toString(),name:t.name,slug:t.slug,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,type:t.type==="national"?"national":"club",gender:t.gender,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_logo?{logo:t.url_logo}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function se(t){return{entityType:"president",id:t.id.toString(),name:t.name,slug:t.slug,birthdate:t.birthdate??void 0,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ie(t){return{entityType:"venue",id:t.id.toString(),name:t.name,slug:t.slug,city:{id:t.city.id.toString(),name:t.city.name,country:{id:t.city.country.id.toString(),name:t.city.country.name,code:void 0,flag:t.city.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.city.country.uuid)},providerRef:h.toProviderRefArray(t.city.uuid)},country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},profile:{latitude:t.profile.lat,longitude:t.profile.lng,capacity:t.profile.capacity},assets:t.url_thumb?{image:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function re(t){return{entityType:"coach",id:t.id.toString(),name:t.name,slug:t.slug,birthdate:t.birthdate??void 0,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ae(t){switch(t.entity_type){case"tournament":return ee(t);case"player":return oe(t);case"team":return ne(t);case"president":return se(t);case"venue":return ie(t);case"coach":return re(t);default:throw new Error(`Unknown entity type: ${t.entity_type}`)}}async function ce(t,e){if(!t.query||t.query.trim()==="")return{results:[],query:t.query||""};const o=e||h.getConfig(),{sportal365Sports:n}=o,s=t.entityTypes&&t.entityTypes.length>0?t.entityTypes:["tournament","player","team","president","venue","coach"],i=await h.footballHttp.get({path:"/search",params:{query:t.query.trim(),entity_type:s.join(","),language_code:t.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t.languageCode??n?.languageCode??"en"},next:t.next,config:o});return!i||i.length===0?{results:[],query:t.query}:{results:i.map(ae),query:t.query}}const le=h.createHttpClient(h.SPORTAL365_BASKETBALL_DOMAIN);function de(t){const e={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed",UNKNOWN:"not_started"},o=t.type.toUpperCase();return{code:e[o]??"not_started",name:t.name,shortName:t.short_name,type:o}}function At(t){return{id:t.id,name:t.name,threeLetterCode:t.three_letter_code,slug:t.slug,type:t.type==="national"?"national":"club",gender:t.gender}}function ue(t){return{kickoffTime:new Date(t.game_time),currentMinute:t.minute}}function fe(t){if(!t.season?.competition)return;const e=t.season.competition;return{id:e.id,name:e.name,slug:e.slug,type:"LEAGUE",gender:e.gender,region:e.region,country:e.country?{id:e.country.id,name:e.country.name}:void 0,season:{id:t.season.id,name:t.season.name,status:t.season.status},stage:t.stage?{id:t.stage.id,name:t.stage.name,type:t.stage.type}:void 0}}function he(t){if(t)return{id:t.id,name:t.name,slug:t.slug}}function me(t){if(!t||t.length===0)return;const e=t.filter(i=>i.result_type.category==="single_period");if(e.length===0)return;let o=0,n=0;const s=[];for(const i of e)o+=i.home,n+=i.away,s.push({competitorOne:String(i.home),competitorTwo:String(i.away)});return{competitorOne:String(o),competitorTwo:String(n),breakdown:{total:{competitorOne:String(o),competitorTwo:String(n)},periods:s}}}function ge(t){if(t.winner)return{competitorId:t.winner.id}}function pe(t){return{id:t.id,slug:t.slug,sport:"basketball",status:de(t.status),timing:ue(t),competitorOne:At(t.home_team),competitorTwo:At(t.away_team),competition:fe(t),round:t.round?{id:t.round.id,key:t.round.uuid,name:t.round.name,type:"REGULAR",providerRef:h.toProviderRefArray(t.round.uuid)}:void 0,venue:he(t.arena),score:me(t.score),winner:ge(t),odds:t.odds?h.transformOdds(t.odds):void 0,coverage:t.coverage==="NOT_LIVE"?"UNKNOWN":t.coverage,providerRef:[{provider:"sportal365-basketball",id:t.id}]}}async function ye(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o;return(await le.get({path:"/games",params:{offset:"0",limit:"1000",competition_list:t?.competitionList,status_type:t?.statusTypes,from_game_time:t?.fromGameTime,to_game_time:t?.toGameTime,odd_client:t?.oddClient??n?.oddClient,odd_type:t?.oddType,market_types:t?.marketTypes,language_code:t?.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??n?.languageCode??"en"},next:t?.next,config:o})).games.map(pe)}const Te=h.createHttpClient(h.SPORTAL365_TENNIS_DOMAIN);function _e(t){const e={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed"},o=t.type.toUpperCase();return{code:e[o]??"not_started",name:t.name,shortName:t.short_name,type:o}}function Ct(t){if(t.type==="PLAYER")return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"player",country:t.details?.[0]?.country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details?.[0]?.gender};if(t.type==="TEAM_DOUBLE"&&t.details&&t.details.length===2){const e={id:t.details[0].id,name:t.details[0].name,shortName:t.details[0].short_name,threeLetterCode:t.details[0].three_letter_code,type:"player",country:t.details[0].country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details[0].gender},o={id:t.details[1].id,name:t.details[1].name,shortName:t.details[1].short_name,threeLetterCode:t.details[1].three_letter_code,type:"player",country:t.details[1].country?{id:t.details[1].country.id,name:t.details[1].country.name}:void 0,gender:t.details[1].gender};return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"pair",players:[e,o]}}else return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"national",country:t.details?.[0]?.country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details?.[0]?.gender}}function ve(t){return{kickoffTime:new Date(t.scheduled_start_time),phaseStartedAt:t.started_at?new Date(t.started_at):void 0,finishedAt:t.finished_at?new Date(t.finished_at):void 0}}function Se(t){if(!t.tournament)return;const e=t.tournament;return{id:e.competition?.id??e.id,name:e.competition?.name??e.name,slug:e.competition?.slug??e.slug,type:"TOURNAMENT",gender:e.gender,region:"INTERNATIONAL",country:e.country?{id:e.country.id,name:e.country.name}:void 0}}function Ae(t){if(!t.results||t.results.length===0)return;const e=t.results.filter(c=>/^set\d+$/i.test(c.type.code));if(e.length===0)return;const o=[];for(const c of e){const d=c.values.find(l=>l.position==="1"),f=c.values.find(l=>l.position==="2");!d||!f||d.value==null||f.value==null||o.push({competitorOne:d.value,competitorTwo:f.value})}if(o.length===0)return;const n=t.results.find(c=>c.type.code==="setswon"),s=n?.values.find(c=>c.position==="1"),i=n?.values.find(c=>c.position==="2");let r,a;return s?.value!=null&&i?.value!=null?(r=parseInt(s.value),a=parseInt(i.value)):(r=o.filter(c=>parseInt(c.competitorOne)>parseInt(c.competitorTwo)).length,a=o.filter(c=>parseInt(c.competitorTwo)>parseInt(c.competitorOne)).length),{competitorOne:String(r),competitorTwo:String(a),breakdown:{total:{competitorOne:String(r),competitorTwo:String(a)},periods:o}}}function Ce(t){const e=t.participants.find(o=>o.winner==="YES");if(e)return{competitorId:e.id}}function Oe(t){const e=t.participants.sort((o,n)=>o.position-n.position);return{id:t.id,slug:t.slug,sport:"tennis",status:_e(t.status),timing:ve(t),competitorOne:Ct(e[0]),competitorTwo:Ct(e[1]),competition:Se(t),round:t.round?{id:t.round.id,key:t.round.uuid,name:t.round.name,type:"REGULAR",providerRef:h.toProviderRefArray(t.round.uuid)}:void 0,score:Ae(t),winner:Ce(t),odds:t.odds?h.transformOdds(t.odds):void 0,coverage:t.coverage?.type==="NOT_LIVE"?"UNKNOWN":t.coverage?.type,metadata:{matchType:t.type,bestOfSets:t.best_of_sets,surface:t.tournament?.surface,indoorOutdoor:t.tournament?.indoor_outdoor},providerRef:[{provider:"sportal365-tennis",id:t.id}]}}async function Fe(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o;return(await Te.get({path:"/matches/livescore",params:{date:t?.date,utc_offset:t?.utcOffset?.toString(),offset:"0",limit:"1000",type:t?.type,gender:t?.gender,status_type:t?.statusType,competition_list:t?.competitionList,odd_client:t?.oddClient??n?.oddClient,odd_type:t?.oddType,market_types:t?.marketTypes,language_code:t?.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??n?.languageCode??"en"},next:t?.next,config:o})).matches.map(Oe)}const Ee=h.createHttpClient(h.SPORTAL365_SPORTS_SEARCH_DOMAIN);function G(t){return{language:t.language,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0}}function D(t){if(!(!t||!t.url))return{url:t.url}}function W(t){if(t)return{id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,providerRef:t.id}}function pt(t){return{entityType:"team",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,competitionIds:t.competition_ids,type:t.type,national:t.national,undecided:t.undecided,providerRef:t.id}}function Rt(t){return{entityType:"city",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),providerRef:t.id}}function Le(t){return{entityType:"horse",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,providerRef:t.id}}function be(t){return{entityType:"player",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,position:t.position??void 0,providerRef:t.id}}function Re(t){return{entityType:"coach",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,providerRef:t.id}}function Ne(t){return{entityType:"referee",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,providerRef:t.id}}function Pe(t){return{entityType:"venue",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),city:t.city?Rt(t.city):void 0,providerRef:t.id}}function Me(t){return{entityType:t.entity_type,id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,type:t.type??void 0,region:t.region??void 0,providerRef:t.id}}function Ie(t){return{entityType:"match",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,competitionId:t.competition_id??void 0,startTime:t.start_time??void 0,homeTeam:t.home_team?pt(t.home_team):void 0,awayTeam:t.away_team?pt(t.away_team):void 0,providerRef:t.id}}function Ue(t){return{entityType:"country",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,providerRef:t.id}}function Ge(t){switch(t.entity_type){case"team":return pt(t);case"city":return Rt(t);case"horse":return Le(t);case"player":return be(t);case"coach":return Re(t);case"referee":return Ne(t);case"venue":return Pe(t);case"tournament":case"competition":return Me(t);case"match":return Ie(t);case"country":return Ue(t);default:{const e=t;throw new Error(`Unknown entity type: ${e.entity_type}`)}}}async function De(t={},e){const o=e??h.getConfig(),n={};t.name&&(n.name=t.name),t.entityTypes&&t.entityTypes.length>0&&(n.entity_type=t.entityTypes.join(",")),t.sports&&t.sports.length>0&&(n.sport=t.sports.join(",")),t.eventStartTime&&(n.event_start_time=t.eventStartTime),t.ids&&t.ids.length>0&&(n.ids=t.ids.join(",")),t.competitionIds&&t.competitionIds.length>0&&(n.competition_ids=t.competitionIds.join(",")),t.domain&&(n.domain=t.domain),t.inputLanguage&&(n.input_language=t.inputLanguage),t.translationLanguage&&(n.translation_language=t.translationLanguage),t.limit!==void 0&&(n.limit=t.limit.toString()),t.offset!==void 0&&(n.offset=t.offset.toString());const s=await Ee.get({path:"/suggest",params:n,next:t.next,config:o});return!s.results||s.results.length===0?{results:[],query:t.name}:{results:s.results.map(Ge),query:t.name}}const xe=h.createHttpClient(h.SPORTAL365_STANDINGS_DOMAIN);function He(t){const e={RANK:null,PLAYED:"played",WINS:"won",DRAWS:"drawn",LOSSES:"lost",GOALS_FOR:"goalsFor",GOALS_AGAINST:"goalsAgainst",POINTS:"points"};return t in e?e[t]:t.toLowerCase().replace(/_/g,"")}function Nt(t){return{CHAMPIONS_LEAGUE:"championsLeague",CHAMPIONS_LEAGUE_QUAL:"championsLeagueQual",CHAMPIONS_LEAGUE_8:"championsLeague8",CHAMPIONS_LEAGUE_PLAYOFF_16:"championsLeaguePlayoff16",PLAYOFF_TO_CHAMPIONS_LEAGUE:"playoffChampionsLeague",PLAYOFF_TO_CHAMPIONS_LEAGUE_QUAL:"playoffChampionsLeagueQual",UEFA_CUP:"europaLeague",UEFA_QUAL:"europaLeagueQual",UEFA_QUAL_PLAYOFF:"europaLeagueQualPlayoff",PLAYOFF_TO_UEFA_QUAL:"playoffEuropaLeagueQual",EUROPA_LEAGUE_8:"europaLeague8",EUROPA_LEAGUE_PLAYOFF_16:"europaLeaguePlayoff16",EUROPA_CONFERENCE_LEAGUE_PLAYOFF:"europaConferenceLeaguePlayoff",EUROPA_CONFERENCE_LEAGUE_QUALIFICATION:"europaConferenceLeagueQual",CONFERENCE_LEAGUE_8:"conferenceLeague8",CONFERENCE_LEAGUE_PLAYOFF_16:"conferenceLeaguePlayoff16",RELEGATION:"relegation",RELEGATION_PLAYOFF:"relegationPlayoff",PROMOTION:"promotion",PROMOTION_PLAYOFF:"promotionPlayoff",QUALIFICATION_TO_NEXT_STAGE:"qualificationNextStage",POSSIBLE_QUALIFICATION_TO_NEXT_STAGE:"possibleQualificationNextStage",CHAMPIONSHIP_PLAYOFF:"championshipPlayoff",OVERALL_CHAMPIONSHIP_PLAYOFF:"overallChampionshipPlayoff",CONFERENCE_CHAMPIONSHIP_PLAYOFF:"conferenceChampionshipPlayoff",POSSIBLE_CONFERENCE_CHAMPIONSHIP_PLAYOFF:"possibleConferenceChampionshipPlayoff",DIVISION_CHAMPIONSHIP_PLAYOFF:"divisionChampionshipPlayoff",COPA_LIBERTADORES:"copaLibertadores",PLAYOFF_TO_COPA_LIBERTADORES:"playoffCopaLibertadores",PLAYOFF_TO_COPA_LIBERTADORES_QUAL:"playoffCopaLibertadoresQual",PLAYOFF_TO_COPA_SUDAMERICANA:"playoffCopaSudamericana",PLAYOFF_TO_CONCACAF_CHAMPIONS_LEAGUE:"playoffConcacafChampionsLeague",CAF_CHAMPIONS_QUAL:"cafChampionsQual",CAF_CONFEGERATION_CUP_QUAL:"cafConfederationCupQual",CFU_CLUB_CHAMPIONSHIP:"cfuClubChampionship",AFC_CHAMPIONS_LEAGUE:"afcChampionsLeague",AFC_CHAMPIONS_LEAGUE_QUAL:"afcChampionsLeagueQual",PLAYOFF_TO_AFC_CHAMPIONS_LEAGUE_QUAL:"playoffAfcChampionsLeagueQual",WORLD_CUP:"worldCup"}[t]??t.toLowerCase().replace(/_/g,"")}function ke(t){return t==="RELEGATION"||t==="RELEGATION_PLAYOFF"?"BOTTOM":t.includes("PLAYOFF")?"MIDDLE":"TOP"}function $e(t,e){if(!e||e.length===0)return;const o={win:"W",loss:"L",draw:"D"},n=e.map(s=>{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;return{matchId:s.id,result:o[s.outcome]??"L",score:l,homeAway:a?"HOME":"AWAY",opponent:{id:r?.id??"",name:r?.name??"",logo:r?.display_asset?.url},date:new Date(s.start_time),competition:s.competition?{id:s.competition.id,name:s.competition.name}:void 0}});return{competitorId:t,results:n,formString:n.map(s=>s.result).join("")}}function Be(t){const e={};for(const o of t){const n=He(o.type.code);n&&(e[n]=Number(o.value))}return e.goalsFor!=null&&e.goalsAgainst!=null&&e.goalDifference==null&&(e.goalDifference=e.goalsFor-e.goalsAgainst),e}function We(t){const e=t.find(o=>o.type.code==="RANK");return e?Number(e.value):0}function ze(t){const e=t.rules?.length>0?t.rules.map(o=>Nt(o.standing_api_rule_type)):void 0;return{rank:We(t.columns),competitor:{id:t.team.id,name:t.team.name,shortName:t.team.short_name??void 0,logo:void 0},stats:Be(t.columns),form:$e(t.team.id,t.form??[]),rules:e}}function Ye(t){const e=new Map;for(const o of t)if(o.rules)for(const n of o.rules){const s=Nt(n.standing_api_rule_type);e.has(s)||e.set(s,{key:s,name:n.name,position:ke(n.type)})}return Array.from(e.values())}function je(t){const e=t.standing.map(ze),o=Ye(t.standing);return{entries:e,metadata:{legend:o}}}function qe(t){return t.standings.map(e=>({stage:{id:t.stage.id,name:t.stage.name},group:{id:e.group.id,name:e.group.name,type:e.group.type},coverageType:e.type,rankingType:e.ranking_type,standings:je(e)}))}function Ve(t){return!t?.data||t.data.length===0?[]:t.data.flatMap(qe)}async function Qe(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o,s={season_id:t.seasonId,stage_id:t.stageId,group_id:t.groupId,coverage_type:t.coverageType,home_away:t.homeAway,optional_data:t.includeForm?"form":void 0,row_limit:t.rowLimit?.toString(),row_offset:t.rowOffset?.toString(),translation_language:t.languageCode??n?.languageCode??"en"},i=await xe.get({path:`/standings/${t.sport}`,params:s,next:t.next,config:o});return Ve(i)}const Ke=h.createHttpClient(h.SPORTAL365_STATISTICS_DOMAIN);function Xe(t,e){return{teamId:t.id,teamName:t.name,seasonId:e,statistics:t.statistics.map(o=>({key:o.id,value:o.value,label:o.name}))}}async function Je(t,e){const o=e||h.getConfig(),n=t.next??{revalidate:600},s=await Ke.get({path:"/statistics/aggregate",params:{participant_ids:t.teamId,season_ids:t.seasonId,participant_type:"TEAM"},next:n,config:o});if(!s.data||s.data.length===0)throw new Error(`No statistics found for team ${t.teamId} in season ${t.seasonId}`);return Xe(s.data[0],t.seasonId)}function Pt(t){const e=t.replace(/\/$/,"");function o(n){return`${e}${n}`}return{async get(n){const s=n.config||h.getConfig(),{fansUnited:i}=s;if(!i)throw new Error("Fans United configuration is missing. Add 'fansUnited' with 'apiKey' and 'clientId' to your config.");if(!i.apiKey||!i.clientId)throw new Error("Fans United configuration requires both 'apiKey' and 'clientId'");const r=new URL(o(n.path));if(r.searchParams.set("key",i.apiKey),r.searchParams.set("client_id",i.clientId),n.params)for(const[f,l]of Object.entries(n.params))l!==void 0&&(Array.isArray(l)?l.length>0&&r.searchParams.set(f,l.join(",")):r.searchParams.set(f,l));const a=3e4,c=new URL(r.toString());c.searchParams.delete("key"),c.searchParams.delete("client_id"),console.log("🔗 FansUnited API URL:",c.toString());const d=await fetch(r.toString(),{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...n.headers},signal:AbortSignal.timeout(a),...n.next&&{next:n.next}});if(!d.ok){let f=`Fans United API error: ${d.status} ${d.statusText}`;try{const l=await d.text();l&&(f+=` - ${l}`)}catch(l){console.error("[Fans United HTTP] Failed to read error response body:",{error:l instanceof Error?l.message:String(l),status:d.status,statusText:d.statusText})}throw new Error(f)}return d.json()}}}const Ze="https://football.fansunitedapi.com",N=Pt(Ze);function we(t){return{id:String(t.id),name:t.name,active:t.active,providerRef:[{provider:"fansunited",id:String(t.id)}]}}function to(t){const e={id:String(t.id),name:t.name,shortName:t.short_name,slug:t.slug,type:t.type||"LEAGUE",region:t.region,gender:t.gender,providerRef:[{provider:"fansunited",id:String(t.id)}]};return t.country&&(e.country={id:String(t.country.id),name:t.country.name,code:t.country.code,flag:t.country.assets?.flag,providerRef:[{provider:"fansunited",id:String(t.country.id)}]}),t.assets?.logo&&(e.assets={logo:t.assets.logo}),t.seasons&&t.seasons.length>0&&(e.seasons=t.seasons.map(we)),t.current_season&&(e.season={id:String(t.current_season.id),name:t.current_season.name,status:t.current_season.active?"ACTIVE":"INACTIVE"}),e}function eo(t){return t.map(to)}async function oo(t,e){const o={};t?.lang?o.lang=t.lang:o.lang="EN",t?.sortField&&(o.sort_field=t.sortField),t?.sortOrder&&(o.sort_order=t.sortOrder),t?.page!==void 0&&(o.page=String(t.page)),t?.perPage!==void 0&&(o.per_page=String(t.perPage)),t?.countryId!==void 0&&(o.country_id=String(t.countryId)),t?.active!==void 0&&(o.active=t.active?"1":"0");const n=await N.get({path:"/v1/competitions",params:o,config:e,next:t?.next}),s=n.data.map(d=>d.id),i=new Set(s);s.length!==i.size&&console.warn("⚠️ API returned duplicate competitions!");const r=eo(n.data),a=new Set,c=r.filter(d=>a.has(d.id)?!1:(a.add(d.id),!0));return r.length!==c.length&&console.warn(`Removed ${r.length-c.length} duplicate competitions`),c}function no(t){return{id:t.id,name:t.name,code:t.country_code,assets:t.assets?.flag?{flag:t.assets.flag}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function so(t){return{id:t.id,name:t.name,type:t.type?.toUpperCase()||"LEAGUE",gender:t.gender?.toUpperCase(),country:t.country?no(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function io(t){return so(t.data)}async function ro(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/competitions/${t}`,params:s,next:e?.next,config:n});return io(i)}function ao(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag,providerRef:[{provider:"fansunited",id:t.id}]}}function Mt(t){return{id:t.id,name:t.name,shortName:t.short_name||void 0,threeLetterCode:t.code,type:t.national?"national":"club",gender:t.gender?t.gender.toUpperCase():void 0,country:t.country?ao(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,metadata:t.colors?{shirtColors:t.colors.primary?[{type:"home",colorCode:t.colors.primary}]:void 0}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function co(t){return Mt(t.data)}function lo(t){return t.data.map(Mt)}async function uo(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/teams/${t}`,params:s,next:e?.next,config:n});return co(i)}async function fo(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.teamIds&&(n.team_ids=t.teamIds),t?.countryId&&(n.country_id=t.countryId),t?.name&&(n.name=t.name),t?.scope&&(n.scope=t.scope),t?.national!==void 0&&(n.national=String(t.national)),t?.gender&&(n.gender=t.gender),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder);const s=await N.get({path:"/v1/teams",params:n,next:t?.next,config:o});return lo(s)}function _t(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag,providerRef:[{provider:"fansunited",id:t.id}]}}function ho(t){return{id:t.id,name:t.name,shortName:t.short_name??void 0,fullName:t.full_name??void 0,threeLetterCode:t.code,type:t.national?"national":"club",gender:t.gender?.toUpperCase(),country:t.country?_t(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function mo(t){return{id:t.id,name:t.name,type:t.type?.toUpperCase()||"LEAGUE",gender:t.gender?.toUpperCase(),country:t.country?_t(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function It(t){return{type:"player",id:t.id,name:t.name,position:t.position,birthdate:t.birth_date,country:t.country?_t(t.country):void 0,assets:t.assets?.headshot?{photo:t.assets.headshot}:void 0,teams:t.teams?.map(ho),competitions:t.competitions?.map(mo),providerRef:[{provider:"fansunited",id:t.id}]}}function go(t){return It(t.data)}function po(t){return t.data.map(It)}async function yo(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/players/${t}`,params:s,next:e?.next,config:n});return go(i)}async function To(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.playerIds&&(n.player_ids=t.playerIds),t?.countryId&&(n.country_id=t.countryId),t?.name&&(n.name=t.name),t?.scope&&(n.scope=t.scope),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder);const s=await N.get({path:"/v1/players",params:n,next:t?.next,config:o});return po(s)}async function _o(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/matches/${t}`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function vo(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.competitions&&(n.competitions=t.competitions),t?.countries&&(n.countries=t.countries),t?.fromDate&&(n.from_date=t.fromDate),t?.toDate&&(n.to_date=t.toDate),t?.matches&&(n.matches=t.matches),t?.teams&&(n.teams=t.teams),t?.status&&(n.status=t.status),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder),t?.showDeleted!==void 0&&(n.show_deleted=t.showDeleted?"true":"false");const s=await N.get({path:"/v1/matches",params:n,next:t?.next,config:o});return h.transformMatches(s)}async function So(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/teams/${t}/next-match`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function Ao(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/teams/${t}/previous-match`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function Co(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/players/${t}/next-match`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function Oo(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/players/${t}/previous-match`,params:s,next:e?.next,config:n});return h.transformMatch(i)}function vt(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag||void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Fo(t){return{id:t.id,name:t.name,shortName:t.short_name||void 0,type:t.type||"LEAGUE",region:t.region,gender:t.gender?.toUpperCase(),country:t.country?vt(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Eo(t){return{type:"player",id:t.id,name:t.name,position:t.position||void 0,gender:t.gender?.toUpperCase(),birthdate:t.birth_date||void 0,country:t.country?vt(t.country):void 0,assets:t.assets?.headshot?{photo:t.assets.headshot}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Lo(t){return{type:t.national?"national":"club",id:t.id,name:t.name,shortName:t.short_name||void 0,threeLetterCode:t.code||void 0,gender:t.gender?.toUpperCase(),country:t.country?vt(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function mt(t){switch(t.entity_type){case"competition":{const e=Fo(t);return{source:"FOOTBALL",entityType:"competition",entityId:t.id,entityData:e}}case"player":{const e=Eo(t);return{source:"FOOTBALL",entityType:"player",entityId:t.id,entityData:e}}case"team":{const e=Lo(t);return{source:"FOOTBALL",entityType:"team",entityId:t.id,entityData:e}}case"venue":case"coach":return null;default:throw new Error(`Unknown entity type: ${t.entity_type}`)}}async function bo(t,e){if(!t.query||t.query.trim()==="")return[];const o=e||h.getConfig(),n={q:t.query.trim()},i=(t.entityTypes&&t.entityTypes.length>0?t.entityTypes:["competition","team","player"]).map(c=>{switch(c){case"team":return"teams";case"player":return"players";case"competition":return"competitions";default:return c}});n.entities=i.join(","),t.lang&&(n.lang=t.lang),t.limit&&(n.limit=String(t.limit));const r=await N.get({path:"/v1/search",params:n,next:t.next,config:o}),a=[];return r.data&&(r.data.competitions&&r.data.competitions.forEach(c=>{const d=mt({...c,entity_type:"competition"});d&&a.push(d)}),r.data.teams&&r.data.teams.forEach(c=>{const d=mt({...c,entity_type:"team"});d&&a.push(d)}),r.data.players&&r.data.players.forEach(c=>{const d=mt({...c,entity_type:"player"});d&&a.push(d)})),a}const Ro="https://search.fansunitedapi.com",$=Pt(Ro);var No=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ut=new Set,yt=typeof process=="object"&&process?process:{},Gt=(t,e,o,n)=>{typeof yt.emitWarning=="function"?yt.emitWarning(t,e,o,n):console.error(`[${o}] ${e}: ${t}`)},lt=globalThis.AbortController,Ot=globalThis.AbortSignal;if(typeof lt>"u"){Ot=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(o,n){this._onabort.push(n)}},lt=class{constructor(){e()}signal=new Ot;abort(o){if(!this.signal.aborted){this.signal.reason=o,this.signal.aborted=!0;for(let n of this.signal._onabort)n(o);this.signal.onabort?.(o)}}};let t=yt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,Gt("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))}}var Po=t=>!Ut.has(t),B=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Dt=t=>B(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ct:null:null,ct=class extends Array{constructor(t){super(t),this.fill(0)}},Mo=class tt{heap;length;static#a=!1;static create(e){let o=Dt(e);if(!o)return[];tt.#a=!0;let n=new tt(e,o);return tt.#a=!1,n}constructor(e,o){if(!tt.#a)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new o(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Io=class xt{#a;#u;#p;#R;#y;#I;#U;#T;get perf(){return this.#T}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#s;#_;#n;#o;#t;#l;#f;#c;#i;#v;#r;#S;#A;#h;#m;#C;#b;#d;#G;static unsafeExposeInternals(e){return{starts:e.#A,ttls:e.#h,autopurgeTimers:e.#m,sizes:e.#S,keyMap:e.#n,keyList:e.#o,valList:e.#t,next:e.#l,prev:e.#f,get head(){return e.#c},get tail(){return e.#i},free:e.#v,isBackgroundFetch:o=>e.#e(o),backgroundFetch:(o,n,s,i)=>e.#H(o,n,s,i),moveToTail:o=>e.#M(o),indexes:o=>e.#O(o),rindexes:o=>e.#F(o),isStale:o=>e.#g(o)}}get max(){return this.#a}get maxSize(){return this.#u}get calculatedSize(){return this.#_}get size(){return this.#s}get fetchMethod(){return this.#I}get memoMethod(){return this.#U}get dispose(){return this.#p}get onInsert(){return this.#R}get disposeAfter(){return this.#y}constructor(e){let{max:o=0,ttl:n,ttlResolution:s=1,ttlAutopurge:i,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:c,dispose:d,onInsert:f,disposeAfter:l,noDisposeOnSet:u,noUpdateTTL:m,maxSize:y=0,maxEntrySize:T=0,sizeCalculation:A,fetchMethod:p,memoMethod:_,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:P,ignoreFetchAbort:M,perf:I}=e;if(I!==void 0&&typeof I?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#T=I??No,o!==0&&!B(o))throw new TypeError("max option must be a nonnegative integer");let g=o?Dt(o):Array;if(!g)throw new Error("invalid max value: "+o);if(this.#a=o,this.#u=y,this.maxEntrySize=T||this.#u,this.sizeCalculation=A,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(_!==void 0&&typeof _!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#U=_,p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#I=p,this.#b=!!p,this.#n=new Map,this.#o=new Array(o).fill(void 0),this.#t=new Array(o).fill(void 0),this.#l=new g(o),this.#f=new g(o),this.#c=0,this.#i=0,this.#v=Mo.create(o),this.#s=0,this.#_=0,typeof d=="function"&&(this.#p=d),typeof f=="function"&&(this.#R=f),typeof l=="function"?(this.#y=l,this.#r=[]):(this.#y=void 0,this.#r=void 0),this.#C=!!this.#p,this.#G=!!this.#R,this.#d=!!this.#y,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#u!==0&&!B(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!B(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#j()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=B(s)||s===0?s:1,this.ttlAutopurge=!!i,this.ttl=n||0,this.ttl){if(!B(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#a===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#a&&!this.#u){let F="LRU_CACHE_UNBOUNDED";Po(F)&&(Ut.add(F),Gt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",F,xt))}}getRemainingTTL(e){return this.#n.has(e)?1/0:0}#k(){let e=new ct(this.#a),o=new ct(this.#a);this.#h=e,this.#A=o;let n=this.ttlAutopurge?new Array(this.#a):void 0;this.#m=n,this.#$=(r,a,c=this.#T.now())=>{if(o[r]=a!==0?c:0,e[r]=a,n?.[r]&&(clearTimeout(n[r]),n[r]=void 0),a!==0&&n){let d=setTimeout(()=>{this.#g(r)&&this.#E(this.#o[r],"expire")},a+1);d.unref&&d.unref(),n[r]=d}},this.#N=r=>{o[r]=e[r]!==0?this.#T.now():0},this.#L=(r,a)=>{if(e[a]){let c=e[a],d=o[a];if(!c||!d)return;r.ttl=c,r.start=d,r.now=s||i();let f=r.now-d;r.remainingTTL=c-f}};let s=0,i=()=>{let r=this.#T.now();if(this.ttlResolution>0){s=r;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref()}return r};this.getRemainingTTL=r=>{let a=this.#n.get(r);if(a===void 0)return 0;let c=e[a],d=o[a];if(!c||!d)return 1/0;let f=(s||i())-d;return c-f},this.#g=r=>{let a=o[r],c=e[r];return!!c&&!!a&&(s||i())-a>c}}#N=()=>{};#L=()=>{};#$=()=>{};#g=()=>!1;#j(){let e=new ct(this.#a);this.#_=0,this.#S=e,this.#P=o=>{this.#_-=e[o],e[o]=0},this.#B=(o,n,s,i)=>{if(this.#e(n))return 0;if(!B(s))if(i){if(typeof i!="function")throw new TypeError("sizeCalculation must be a function");if(s=i(n,o),!B(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#D=(o,n,s)=>{if(e[o]=n,this.#u){let i=this.#u-e[o];for(;this.#_>i;)this.#x(!0)}this.#_+=e[o],s&&(s.entrySize=n,s.totalCalculatedSize=this.#_)}}#P=e=>{};#D=(e,o,n)=>{};#B=(e,o,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:e=this.allowStale}={}){if(this.#s)for(let o=this.#i;!(!this.#W(o)||((e||!this.#g(o))&&(yield o),o===this.#c));)o=this.#f[o]}*#F({allowStale:e=this.allowStale}={}){if(this.#s)for(let o=this.#c;!(!this.#W(o)||((e||!this.#g(o))&&(yield o),o===this.#i));)o=this.#l[o]}#W(e){return e!==void 0&&this.#n.get(this.#o[e])===e}*entries(){for(let e of this.#O())this.#t[e]!==void 0&&this.#o[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#o[e],this.#t[e]])}*rentries(){for(let e of this.#F())this.#t[e]!==void 0&&this.#o[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#o[e],this.#t[e]])}*keys(){for(let e of this.#O()){let o=this.#o[e];o!==void 0&&!this.#e(this.#t[e])&&(yield o)}}*rkeys(){for(let e of this.#F()){let o=this.#o[e];o!==void 0&&!this.#e(this.#t[e])&&(yield o)}}*values(){for(let e of this.#O())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}*rvalues(){for(let e of this.#F())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,o={}){for(let n of this.#O()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;if(i!==void 0&&e(i,this.#o[n],this))return this.get(this.#o[n],o)}}forEach(e,o=this){for(let n of this.#O()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;i!==void 0&&e.call(o,i,this.#o[n],this)}}rforEach(e,o=this){for(let n of this.#F()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;i!==void 0&&e.call(o,i,this.#o[n],this)}}purgeStale(){let e=!1;for(let o of this.#F({allowStale:!0}))this.#g(o)&&(this.#E(this.#o[o],"expire"),e=!0);return e}info(e){let o=this.#n.get(e);if(o===void 0)return;let n=this.#t[o],s=this.#e(n)?n.__staleWhileFetching:n;if(s===void 0)return;let i={value:s};if(this.#h&&this.#A){let r=this.#h[o],a=this.#A[o];if(r&&a){let c=r-(this.#T.now()-a);i.ttl=c,i.start=Date.now()}}return this.#S&&(i.size=this.#S[o]),i}dump(){let e=[];for(let o of this.#O({allowStale:!0})){let n=this.#o[o],s=this.#t[o],i=this.#e(s)?s.__staleWhileFetching:s;if(i===void 0||n===void 0)continue;let r={value:i};if(this.#h&&this.#A){r.ttl=this.#h[o];let a=this.#T.now()-this.#A[o];r.start=Math.floor(Date.now()-a)}this.#S&&(r.size=this.#S[o]),e.unshift([n,r])}return e}load(e){this.clear();for(let[o,n]of e){if(n.start){let s=Date.now()-n.start;n.start=this.#T.now()-s}this.set(o,n.value,n)}}set(e,o,n={}){if(o===void 0)return this.delete(e),this;let{ttl:s=this.ttl,start:i,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=n,{noUpdateTTL:d=this.noUpdateTTL}=n,f=this.#B(e,o,n.size||0,a);if(this.maxEntrySize&&f>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#E(e,"set"),this;let l=this.#s===0?void 0:this.#n.get(e);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.#o[l]=e,this.#t[l]=o,this.#n.set(e,l),this.#l[this.#i]=l,this.#f[l]=this.#i,this.#i=l,this.#s++,this.#D(l,f,c),c&&(c.set="add"),d=!1,this.#G&&this.#R?.(o,e,"add");else{this.#M(l);let u=this.#t[l];if(o!==u){if(this.#b&&this.#e(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=u;m!==void 0&&!r&&(this.#C&&this.#p?.(m,e,"set"),this.#d&&this.#r?.push([m,e,"set"]))}else r||(this.#C&&this.#p?.(u,e,"set"),this.#d&&this.#r?.push([u,e,"set"]));if(this.#P(l),this.#D(l,f,c),this.#t[l]=o,c){c.set="replace";let m=u&&this.#e(u)?u.__staleWhileFetching:u;m!==void 0&&(c.oldValue=m)}}else c&&(c.set="update");this.#G&&this.onInsert?.(o,e,o===u?"update":"replace")}if(s!==0&&!this.#h&&this.#k(),this.#h&&(d||this.#$(l,s,i),c&&this.#L(c,l)),!r&&this.#d&&this.#r){let u=this.#r,m;for(;m=u?.shift();)this.#y?.(...m)}return this}pop(){try{for(;this.#s;){let e=this.#t[this.#c];if(this.#x(!0),this.#e(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#d&&this.#r){let e=this.#r,o;for(;o=e?.shift();)this.#y?.(...o)}}}#x(e){let o=this.#c,n=this.#o[o],s=this.#t[o];return this.#b&&this.#e(s)?s.__abortController.abort(new Error("evicted")):(this.#C||this.#d)&&(this.#C&&this.#p?.(s,n,"evict"),this.#d&&this.#r?.push([s,n,"evict"])),this.#P(o),this.#m?.[o]&&(clearTimeout(this.#m[o]),this.#m[o]=void 0),e&&(this.#o[o]=void 0,this.#t[o]=void 0,this.#v.push(o)),this.#s===1?(this.#c=this.#i=0,this.#v.length=0):this.#c=this.#l[o],this.#n.delete(n),this.#s--,o}has(e,o={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=o,i=this.#n.get(e);if(i!==void 0){let r=this.#t[i];if(this.#e(r)&&r.__staleWhileFetching===void 0)return!1;if(this.#g(i))s&&(s.has="stale",this.#L(s,i));else return n&&this.#N(i),s&&(s.has="hit",this.#L(s,i)),!0}else s&&(s.has="miss");return!1}peek(e,o={}){let{allowStale:n=this.allowStale}=o,s=this.#n.get(e);if(s===void 0||!n&&this.#g(s))return;let i=this.#t[s];return this.#e(i)?i.__staleWhileFetching:i}#H(e,o,n,s){let i=o===void 0?void 0:this.#t[o];if(this.#e(i))return i;let r=new lt,{signal:a}=n;a?.addEventListener("abort",()=>r.abort(a.reason),{signal:r.signal});let c={signal:r.signal,options:n,context:s},d=(T,A=!1)=>{let{aborted:p}=r.signal,_=n.ignoreFetchAbort&&T!==void 0,C=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&T!==void 0);if(n.status&&(p&&!A?(n.status.fetchAborted=!0,n.status.fetchError=r.signal.reason,_&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),p&&!_&&!A)return l(r.signal.reason,C);let O=m,S=this.#t[o];return(S===m||_&&A&&S===void 0)&&(T===void 0?O.__staleWhileFetching!==void 0?this.#t[o]=O.__staleWhileFetching:this.#E(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,T,c.options))),T},f=T=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=T),l(T,!1)),l=(T,A)=>{let{aborted:p}=r.signal,_=p&&n.allowStaleOnFetchAbort,C=_||n.allowStaleOnFetchRejection,O=C||n.noDeleteOnFetchRejection,S=m;if(this.#t[o]===m&&(!O||!A&&S.__staleWhileFetching===void 0?this.#E(e,"fetch"):_||(this.#t[o]=S.__staleWhileFetching)),C)return n.status&&S.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw T},u=(T,A)=>{let p=this.#I?.(e,i,c);p&&p instanceof Promise&&p.then(_=>T(_===void 0?void 0:_),A),r.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(T(void 0),n.allowStaleOnFetchAbort&&(T=_=>d(_,!0)))})};n.status&&(n.status.fetchDispatched=!0);let m=new Promise(u).then(d,f),y=Object.assign(m,{__abortController:r,__staleWhileFetching:i,__returned:void 0});return o===void 0?(this.set(e,y,{...c.options,status:void 0}),o=this.#n.get(e)):this.#t[o]=y,y}#e(e){if(!this.#b)return!1;let o=e;return!!o&&o instanceof Promise&&o.hasOwnProperty("__staleWhileFetching")&&o.__abortController instanceof lt}async fetch(e,o={}){let{allowStale:n=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:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:y=this.allowStaleOnFetchAbort,context:T,forceRefresh:A=!1,status:p,signal:_}=o;if(!this.#b)return p&&(p.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:i,status:p});let C={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:i,ttl:r,noDisposeOnSet:a,size:c,sizeCalculation:d,noUpdateTTL:f,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:y,ignoreFetchAbort:m,status:p,signal:_},O=this.#n.get(e);if(O===void 0){p&&(p.fetch="miss");let S=this.#H(e,O,C,T);return S.__returned=S}else{let S=this.#t[O];if(this.#e(S)){let g=n&&S.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",g&&(p.returnedStale=!0)),g?S.__staleWhileFetching:S.__returned=S}let P=this.#g(O);if(!A&&!P)return p&&(p.fetch="hit"),this.#M(O),s&&this.#N(O),p&&this.#L(p,O),S;let M=this.#H(e,O,C,T),I=M.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=P?"stale":"refresh",I&&P&&(p.returnedStale=!0)),I?M.__staleWhileFetching:M.__returned=M}}async forceFetch(e,o={}){let n=await this.fetch(e,o);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,o={}){let n=this.#U;if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:i,...r}=o,a=this.get(e,r);if(!i&&a!==void 0)return a;let c=n(e,a,{options:r,context:s});return this.set(e,c,r),c}get(e,o={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:r}=o,a=this.#n.get(e);if(a!==void 0){let c=this.#t[a],d=this.#e(c);return r&&this.#L(r,a),this.#g(a)?(r&&(r.get="stale"),d?(r&&n&&c.__staleWhileFetching!==void 0&&(r.returnedStale=!0),n?c.__staleWhileFetching:void 0):(i||this.#E(e,"expire"),r&&n&&(r.returnedStale=!0),n?c:void 0)):(r&&(r.get="hit"),d?c.__staleWhileFetching:(this.#M(a),s&&this.#N(a),c))}else r&&(r.get="miss")}#z(e,o){this.#f[o]=e,this.#l[e]=o}#M(e){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)}delete(e){return this.#E(e,"delete")}#E(e,o){let n=!1;if(this.#s!==0){let s=this.#n.get(e);if(s!==void 0)if(this.#m?.[s]&&(clearTimeout(this.#m?.[s]),this.#m[s]=void 0),n=!0,this.#s===1)this.#Y(o);else{this.#P(s);let i=this.#t[s];if(this.#e(i)?i.__abortController.abort(new Error("deleted")):(this.#C||this.#d)&&(this.#C&&this.#p?.(i,e,o),this.#d&&this.#r?.push([i,e,o])),this.#n.delete(e),this.#o[s]=void 0,this.#t[s]=void 0,s===this.#i)this.#i=this.#f[s];else if(s===this.#c)this.#c=this.#l[s];else{let r=this.#f[s];this.#l[r]=this.#l[s];let a=this.#l[s];this.#f[a]=this.#f[s]}this.#s--,this.#v.push(s)}}if(this.#d&&this.#r?.length){let s=this.#r,i;for(;i=s?.shift();)this.#y?.(...i)}return n}clear(){return this.#Y("delete")}#Y(e){for(let o of this.#F({allowStale:!0})){let n=this.#t[o];if(this.#e(n))n.__abortController.abort(new Error("deleted"));else{let s=this.#o[o];this.#C&&this.#p?.(n,s,e),this.#d&&this.#r?.push([n,s,e])}}if(this.#n.clear(),this.#t.fill(void 0),this.#o.fill(void 0),this.#h&&this.#A){this.#h.fill(0),this.#A.fill(0);for(let o of this.#m??[])o!==void 0&&clearTimeout(o);this.#m?.fill(void 0)}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){let o=this.#r,n;for(;n=o?.shift();)this.#y?.(...n)}}};const Uo=50*1024*1024,w=new Io({maxSize:Uo,sizeCalculation:t=>JSON.stringify(t.data).length}),L={get(t){return w.get(t)},set(t,e){w.set(t,{data:e,storedAt:Date.now()})},delete(t){w.delete(t)},clear(){w.clear()},get size(){return w.size}};let U=null;function Go(t){U=t}const Do={competitions:{staleTTL:24*3600,maxTTL:72*3600},teams:{staleTTL:24*3600,maxTTL:48*3600},athletes:{staleTTL:24*3600,maxTTL:48*3600},venues:{staleTTL:72*3600,maxTTL:168*3600},countries:{staleTTL:96*3600,maxTTL:168*3600},coaches:{staleTTL:24*3600,maxTTL:48*3600},search:{staleTTL:300,maxTTL:1800}},gt=new Set;function Ht(t){const e=Do[t];if(!e)throw new Error(`Unknown entity type: ${t}`);return e}function dt(t,e){return Date.now()-t.storedAt<e*1e3}function ut(t,e){return Date.now()-t.storedAt>=e*1e3}function ft(t,e,o){gt.has(t)||(gt.add(t),o().then(n=>{L.set(t,n),U?.isInitialized&&U.set(t,e,n)}).catch(n=>{console.error(`[cache] Background refresh failed for ${t}:`,n)}).finally(()=>{gt.delete(t)}))}async function z(t,e,o){const{staleTTL:n,maxTTL:s}=Ht(e),i=L.get(t);if(i){if(dt(i,n))return i.data;if(!ut(i,s))return ft(t,e,o),i.data}if(U?.isInitialized){const a=U.get(t);if(a&&!ut(a,s))return L.set(t,a.data),dt(a,n)||ft(t,e,o),a.data}const r=await o();return L.set(t,r),U?.isInitialized&&U.set(t,e,r),r}async function kt(t,e,o,n){const{staleTTL:s,maxTTL:i}=Ht(e),r=new Map,a=[];for(const c of t){const d=n(c);let f=!1;const l=L.get(d);if(l&&!ut(l,i)&&(r.set(c,l.data),dt(l,s)||ft(d,e,async()=>{const m=(await o([c])).get(c);if(!m)throw new Error(`Batch fetcher did not return ID: ${c}`);return m}),f=!0),!f&&U?.isInitialized){const u=U.get(d);u&&!ut(u,i)&&(L.set(d,u.data),r.set(c,u.data),dt(u,s)||ft(d,e,async()=>{const y=(await o([c])).get(c);if(!y)throw new Error(`Batch fetcher did not return ID: ${c}`);return y}),f=!0)}f||a.push(c)}if(a.length>0){const c=await o(a);for(const[d,f]of c){const l=n(d);L.set(l,f),U?.isInitialized&&U.set(l,e,f),r.set(d,f)}}return r}function xo(t){L.delete(t)}function x(t,e,o,n){const s=e.toUpperCase(),i=t.find(r=>r.language.toUpperCase()===s);if(i)return{name:i.name,shortName:i.short_name??n??void 0};if(s!=="EN"){const r=t.find(a=>a.language.toUpperCase()==="EN");if(r)return{name:r.name,shortName:r.short_name??n??void 0}}return{name:o,shortName:n??void 0}}function q(t){const e={};for(const o of t)e[o.key.toLowerCase()]=o.value;return e}function K(t){if(!t)return;const e={};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}function X(t){return t.map(e=>({provider:e.provider,id:e.id}))}function Ho(t,e){return t.filter(o=>o.relationship===e).map(o=>o.related_id)}function H(t,e,o){const n=t||Ho(e,"COUNTRY")[0];if(!n)return;const s=L.get(n)??L.get(`entity:${n}`);if(s?.data){const i=s.data;return st(i,o)}return{id:n,name:n}}function st(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]);return{id:t.id,name:o,...t.country_code?{code:t.country_code}:{},...s.flag?{flag:s.flag}:{},...n?{shortName:n}:{}}}function St(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.branding),r=H(null,t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.format?{type:t.format}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{}}}function nt(t,e){const{name:o,shortName:n}=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);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.three_letter_code?{threeLetterCode:t.three_letter_code}:{},...t.full_name?{fullName:t.full_name}:{},...t.nickname?{nickname:t.nickname}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{}}}function $t(t,e){const{name:o,shortName:n}=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);return{id:t.id,name:o,sport:t.sport,type:"player",...n?{shortName:n}:{},...t.position?{position:t.position}:{},...t.birth_date?{birthdate:t.birth_date}:{},...t.shirt_number!=null?{shirtNumber:t.shirt_number}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo||s.headshot?{assets:{...s.logo?{logo:s.logo}:{},...s.headshot?{photo:s.headshot}:{}}}:{},...i?{metadata:{branding:i}}:{}}}function Bt(t,e){const{name:o}=x(t.translations??[],e,t.name,t.short_name),n=H(t.country_id,t.related??[],e),s=t.capacity!=null||t.latitude!=null||t.longitude!=null;return{id:t.id,name:o,sport:t.sport,...n?{country:n}:{},...s?{profile:{...t.capacity!=null?{capacity:t.capacity}:{},...t.latitude!=null?{latitude:t.latitude}:{},...t.longitude!=null?{longitude:t.longitude}:{}}}:{}}}function ko(t,e){const{name:o}=x(t.translations??[],e,t.name,t.short_name),n=H(t.country_id,t.related??[],e);return{id:t.id,name:o,sport:t.sport,...t.birth_date?{birthdate:t.birth_date}:{},...n?{country:n}:{}}}function $o(t,e,o){const n=L.get(t)??L.get(`entity:${t}`);if(!n?.data)return;const s=n.data;switch(e){case"COMPETITION":return St(s,o);case"TEAM":return nt(s,o);case"ATHLETE":return $t(s,o);case"COUNTRY":return st(s,o);default:return}}function it(t,e){if(!t||t.length===0)return;const o={};for(const n of t){const s=$o(n.related_id,n.relationship,e);if(s)switch(n.relationship){case"COMPETITION":(o.competitions??=[]).push(s);break;case"TEAM":(o.teams??=[]).push(s);break;case"ATHLETE":(o.athletes??=[]).push(s);break;case"COUNTRY":(o.countries??=[]).push(s);break}}return Object.keys(o).length>0?o:void 0}function Bo(t,e){const{name:o,shortName:n}=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);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.format?{type:t.format}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function Ft(t,e){const{name:o,shortName:n}=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);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.three_letter_code?{threeLetterCode:t.three_letter_code}:{},...t.full_name?{fullName:t.full_name}:{},...t.nickname?{nickname:t.nickname}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function Wo(t,e){const{name:o,shortName:n}=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);return{id:t.id,name:o,sport:t.sport,type:"player",...n?{shortName:n}:{},...t.position?{position:t.position}:{},...t.birth_date?{birthdate:t.birth_date}:{},...t.shirt_number!=null?{shirtNumber:t.shirt_number}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo||s.headshot?{assets:{...s.logo?{logo:s.logo}:{},...s.headshot?{photo:s.headshot}:{}}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function zo(t,e){return{...st(t,e),sport:t.sport,...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{}}}function Yo(t,e){const{name:o}=x(t.translations??[],e,t.name,t.short_name),n=H(t.country_id,t.related??[],e),s=it(t.related??[],e),i=t.capacity!=null||t.latitude!=null||t.longitude!=null;return{id:t.id,name:o,sport:t.sport,...n?{country:n}:{},...i?{profile:{...t.capacity!=null?{capacity:t.capacity}:{},...t.latitude!=null?{latitude:t.latitude}:{},...t.longitude!=null?{longitude:t.longitude}:{}}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...s?{related:s}:{}}}function jo(t,e){const{name:o}=x(t.translations??[],e,t.name,t.short_name),n=H(t.country_id,t.related??[],e),s=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,...t.birth_date?{birthdate:t.birth_date}:{},...n?{country:n}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...s?{related:s}:{}}}function Wt(t,e){const o=t.content_type?.toUpperCase?.(),n=t.type?.toUpperCase?.(),s=t.entityType?.toLowerCase?.();return o==="COMPETITION"||s==="competition"?{...Bo(t,e),entityType:"competition"}:s==="country"||t.country_code!==void 0?{...zo(t,e),entityType:"country"}:s==="venue"||t.capacity!==void 0&&!s?{...Yo(t,e),entityType:"venue"}:s==="coach"||n==="COACH"?{...jo(t,e),entityType:"coach"}:s==="athlete"||n==="PLAYER"||t.position!==void 0||t.shirt_number!==void 0?{...Wo(t,e),entityType:"athlete"}:s==="team"||n==="TEAM"||t.three_letter_code!==void 0?{...Ft(t,e),entityType:"team"}:{...Ft(t,e),entityType:"team"}}function qo(t,e){const o=t.content_type?.toUpperCase?.(),n=t.type?.toUpperCase?.(),s=t.entityType?.toLowerCase?.();return o==="COMPETITION"||s==="competition"?{...St(t,e),entityType:"competition"}:s==="country"||t.country_code!==void 0?{...st(t,e),entityType:"country"}:s==="venue"||t.capacity!==void 0&&!s?{...Bt(t,e),entityType:"venue"}:s==="coach"||n==="COACH"?{...ko(t,e),entityType:"coach"}:s==="athlete"||n==="PLAYER"||t.position!==void 0||t.shirt_number!==void 0?{...$t(t,e),entityType:"athlete"}:s==="team"||n==="TEAM"||t.three_letter_code!==void 0?{...nt(t,e),entityType:"team"}:{...nt(t,e),entityType:"team"}}function J(t){const e=Object.entries(t).filter(([,n])=>n!==void 0).sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}=${Array.isArray(s)?s.join(","):s}`).join("&");let o=0;for(let n=0;n<e.length;n++)o=(o<<5)-o+e.charCodeAt(n)|0;return o.toString(36)}function V(t){for(const e of t)e.id&&L.set(`entity:${e.id}`,e)}function Y(t){if(t?.lang)return t.lang;if(h.isConfigured()){const e=h.getConfig();if(e.fansUnited&&"lang"in e.fansUnited&&e.fansUnited.lang)return e.fansUnited.lang}return"EN"}function Et(t){const e=new Set;for(const o of t){const n=o,s=n.related;if(s)for(const r of s)L.get(`entity:${r.related_id}`)||e.add(r.related_id);const i=n.country_id;i&&!L.get(`entity:${i}`)&&e.add(i)}return e}async function Tt(t,e){if(t.size===0)return[];const o=await $.get({path:"/v1/entities/search",params:{ids:Array.from(t)},next:e?.next,config:e?.config});return V(o.data),o.data}async function zt(t,e){const o=Et(t);if(o.size!==0)try{const n=await Tt(o,e),s=Et(n);s.size>0&&await Tt(s,e)}catch{}}async function rt(t,e){const o=new Set;for(const n of t){const s=n,i=s.country_id;i&&!L.get(`entity:${i}`)&&o.add(i);const r=s.related;if(r)for(const a of r)a.relationship==="COUNTRY"&&!L.get(`entity:${a.related_id}`)&&o.add(a.related_id)}if(o.size!==0)try{await Tt(o,e)}catch{}}async function Vo(t={},e){const o=Y(t),n={query:t.query,content_type:t.contentType,ids:t.ids,limit:t.limit?.toString(),page:t.page?.toString(),mode:t.mode,sport:t.sport,relationship:t.relationship,value:t.value},s=`search:entities:${J(n)}`,i=await z(s,"search",()=>$.get({path:"/v1/entities/search",params:n,next:t.next||e?.next,config:t.config}));return V(i.data),await rt(i.data,{next:t.next||e?.next,config:t.config}),{data:i.data.map(a=>qo(a,o)),pagination:i.meta.pagination}}async function Qo(t,e){const o=Y(e),n=`entity:${t}`,s=await z(n,"search",async()=>{const i=await $.get({path:"/v1/entities/search",params:{ids:[t]},next:e?.next,config:e?.config});if(!i.data||i.data.length===0)throw new Error(`Entity not found: ${t}`);return i.data[0]});return await zt([s],{next:e?.next,config:e?.config}),Wt(s,o)}async function Ko(t,e){if(t.length===0)return[];const o=Y(e),n=await kt(t,"search",async i=>{const r=await $.get({path:"/v1/entities/search",params:{ids:i},next:e?.next,config:e?.config}),a=new Map;for(const c of r.data)a.set(c.id,c);return a},i=>`entity:${i}`),s=t.map(i=>n.get(i)).filter(i=>i!==void 0);return await zt(s,{next:e?.next,config:e?.config}),s.map(i=>Wt(i,o))}async function Xo(t={}){const e=Y(t),o={content_type:"competition",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`competitions:${J(o)}`,s=await z(n,"competitions",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),await rt(s.data,{next:t.next,config:t.config}),{data:s.data.map(r=>St(r,e)),pagination:s.meta.pagination}}async function Jo(t,e={}){const o=Y(e),n={content_type:"team",relationship:"COUNTRY",value:t,query:e.query,limit:e.limit?.toString(),page:e.page?.toString(),sport:e.sport},s=`teams:country:${t}:${J(n)}`,i=await z(s,"teams",()=>$.get({path:"/v1/entities/search",params:n,next:e.next,config:e.config}));return V(i.data),await rt(i.data,{next:e.next,config:e.config}),{data:i.data.map(a=>nt(a,o)),pagination:i.meta.pagination}}async function Zo(t,e={}){const o=Y(e),n={content_type:"team",relationship:"COMPETITION",value:t,query:e.query,limit:e.limit?.toString(),page:e.page?.toString(),sport:e.sport},s=`teams:competition:${t}:${J(n)}`,i=await z(s,"teams",()=>$.get({path:"/v1/entities/search",params:n,next:e.next,config:e.config}));return V(i.data),await rt(i.data,{next:e.next,config:e.config}),{data:i.data.map(a=>nt(a,o)),pagination:i.meta.pagination}}async function wo(t={}){const e=Y(t),o={content_type:"country",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`countries:${J(o)}`,s=await z(n,"countries",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),{data:s.data.map(r=>st(r,e)),pagination:s.meta.pagination}}async function tn(t={}){const e=Y(t),o={content_type:"venue",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`venues:${J(o)}`,s=await z(n,"venues",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),await rt(s.data,{next:t.next,config:t.config}),{data:s.data.map(r=>Bt(r,e)),pagination:s.meta.pagination}}function en(t){return!t.seasons||t.seasons.length===0?void 0:t.seasons.find(o=>o.active)??t.seasons[0]}function on(t,e){const o=new Date,n=e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="NOT_STARTED",a=new Date(s.timing.kickoffTime)>=o;return i&&r&&a});return n.sort((s,i)=>new Date(s.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()),n[0]}function nn(t,e){const o=new Date,n=e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="FINISHED",a=new Date(s.timing.kickoffTime)<=o;return i&&r&&a});return n.sort((s,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(s.timing.kickoffTime).getTime()),n[0]}function sn(t,e){const o=new Date;return e.filter(s=>{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)>=o||s.status.type==="LIVE";return i&&r&&a}).sort((s,i)=>new Date(s.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime())}function rn(t,e){const o=new Date;return e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="FINISHED",a=new Date(s.timing.kickoffTime)<=o;return i&&r&&a}).sort((s,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(s.timing.kickoffTime).getTime())}function an(t,e,o){const n=o.filter(r=>r.status.type==="FINISHED"),s=o.filter(r=>r.status.type==="NOT_STARTED"||r.status.type==="POSTPONED"),i=e.entries.map(r=>{const a=r.competitor.id,c=n.filter(u=>u.competitorOne.id===t&&u.competitorTwo.id===a||u.competitorOne.id===a&&u.competitorTwo.id===t),d=s.filter(u=>u.competitorOne.id===t&&u.competitorTwo.id===a||u.competitorOne.id===a&&u.competitorTwo.id===t);let f,l;return c.forEach(u=>{const m=u.competitorOne.id===t,y=parseInt(u.score?.competitorOne??"0"),T=parseInt(u.score?.competitorTwo??"0"),A=m?y:T,p=m?T:y;let _;A>p?_="W":A===p?_="D":_="L";const C={result:_,score:`${y} - ${T}`,date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!1};m?f=C:l=C}),d.forEach(u=>{const m=u.competitorOne.id===t;m&&!f?f={date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!0}:!m&&!l&&(l={date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!0})}),{rank:r.rank,teamId:r.competitor.id,teamName:r.competitor.name,teamShortName:r.competitor.shortName,teamLogo:r.competitor.logo,gamesPlayed:r.stats.played??0,points:r.stats.points??0,homeResult:f,awayResult:l}});return{teamId:t,rows:i}}function cn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.goals??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.goals??0,i=n.seasonStatistics?.goals??0;if(i!==s)return i-s;const r=o.seasonStatistics?.assists??0;return(n.seasonStatistics?.assists??0)-r}).slice(0,e)}function ln(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.assists??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.assists??0,i=n.seasonStatistics?.assists??0;if(i!==s)return i-s;const r=o.seasonStatistics?.goals??0;return(n.seasonStatistics?.goals??0)-r}).slice(0,e)}function dn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.appearances??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.appearances??0,i=n.seasonStatistics?.appearances??0;if(i!==s)return i-s;const r=o.seasonStatistics?.minutes??0;return(n.seasonStatistics?.minutes??0)-r}).slice(0,e)}function un(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.minutes??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.minutes??0,i=n.seasonStatistics?.minutes??0;if(i!==s)return i-s;const r=o.seasonStatistics?.appearances??0;return(n.seasonStatistics?.appearances??0)-r}).slice(0,e)}function fn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.cleansheets??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.cleansheets??0,i=n.seasonStatistics?.cleansheets??0;if(i!==s)return i-s;const r=o.seasonStatistics?.appearances??0;return(n.seasonStatistics?.appearances??0)-r}).slice(0,e)}function hn(t,e=10){return t.players.filter(o=>{const n=o.seasonStatistics?.yellowCards??0,s=o.seasonStatistics?.redCards??0;return n+s>0}).sort((o,n)=>{const s=o.seasonStatistics?.yellowCards??0,i=o.seasonStatistics?.redCards??0,r=n.seasonStatistics?.yellowCards??0,a=n.seasonStatistics?.redCards??0,c=s+i*3,d=r+a*3;return d!==c?d-c:a!==i?a-i:r-s}).slice(0,e)}function Q(t){const e=new Map,o=new Map;return t.forEach(n=>{!n.mainEvents||n.mainEvents.length===0||n.mainEvents.forEach(s=>{if(s.primaryPlayer){const i=s.primaryPlayer.id;e.has(i)||e.set(i,{playerId:s.primaryPlayer.id,seasonId:"",teamId:"",goals:0,assists:0,yellowCards:0,redCards:0,appearances:0});const r=e.get(i);o.has(i)||o.set(i,new Set),o.get(i).add(n.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)}if(s.secondaryPlayer&&(s.type==="GOAL"||s.type==="PENALTY_GOAL")){const i=s.secondaryPlayer.id;e.has(i)||e.set(i,{playerId:s.secondaryPlayer.id,seasonId:"",teamId:"",goals:0,assists:0,yellowCards:0,redCards:0,appearances:0});const r=e.get(i);r.assists=(r.assists??0)+1,o.has(i)||o.set(i,new Set),o.get(i).add(n.id)}})}),o.forEach((n,s)=>{const i=e.get(s);i&&i.appearances!==void 0&&(i.appearances=n.size)}),e}function at(t){return Array.from(t.values()).map(e=>({...e,totalCards:(e.yellowCards??0)+(e.redCards??0)}))}function Yt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.goals??0)>0).sort((s,i)=>{const r=s.goals??0,a=i.goals??0;if(a!==r)return a-r;const c=s.assists??0;return(i.assists??0)-c}).slice(0,e)}function jt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.assists??0)>0).sort((s,i)=>{const r=s.assists??0,a=i.assists??0;if(a!==r)return a-r;const c=s.goals??0;return(i.goals??0)-c}).slice(0,e)}function qt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.totalCards??0)>0).sort((s,i)=>{const r=(s.yellowCards??0)+(s.redCards??0)*3,a=(i.yellowCards??0)+(i.redCards??0)*3;if(a!==r)return a-r;const c=s.redCards??0,d=i.redCards??0;if(d!==c)return d-c;const f=s.yellowCards??0;return(i.yellowCards??0)-f}).slice(0,e)}function Vt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.goals??0)+(s.assists??0)>0).sort((s,i)=>{const r=(s.goals??0)+(s.assists??0),a=(i.goals??0)+(i.assists??0);if(a!==r)return a-r;const c=s.goals??0,d=i.goals??0;if(d!==c)return d-c;const f=s.assists??0;return(i.assists??0)-f}).slice(0,e)}function Qt(t){const e=Q(t);return at(e).sort((n,s)=>{const i=n.appearances??0,r=s.appearances??0;if(r!==i)return r-i;const a=(n.goals??0)+(n.assists??0);return(s.goals??0)+(s.assists??0)-a})}function mn(t,e=10){return j.useMemo(()=>Yt(t,e),[t,e])}function gn(t,e=10){return j.useMemo(()=>jt(t,e),[t,e])}function pn(t,e=10){return j.useMemo(()=>qt(t,e),[t,e])}function yn(t,e=10){return j.useMemo(()=>Vt(t,e),[t,e])}function Tn(t){return j.useMemo(()=>Qt(t),[t])}function Kt(t){return j.useMemo(()=>Q(t),[t])}function _n(t,e){const o=Kt(t);return j.useMemo(()=>o.get(e),[o,e])}const Xt=["GOAL","PENALTY_GOAL","OWN_GOAL"];function R(t,e){return e>0?t/e*100:0}function et(t,e){return e>0?t/e:0}function vn(t,e=!1,o=2){return e?`${Math.round(t)}%`:Number.isInteger(t)?t.toString():t.toFixed(o)}function Sn(t,e){const o=typeof t=="string"?parseFloat(t):t;if(isNaN(o)||e===0)return"0";const n=(o/e).toFixed(1);return`${o} (${n} avg)`}function An(t,e){const o=typeof t=="string"?parseFloat(t):t;return isNaN(o)||e===0?"0.0":(o/e).toFixed(1)}function Cn(t){const e=parseFloat(t);return isNaN(e)?"0%":`${Math.round(e)}%`}function Jt(t,e,o){if(t.status?.type!=="FINISHED"||!t.score)return null;const n=parseInt(t.score.competitorOne||"0"),s=parseInt(t.score.competitorTwo||"0"),i=o?n:s,r=o?s:n;let a=null,c=null;const d=t.score.breakdown?.halfTime;if(d){const m=parseInt(d.competitorOne||"0"),y=parseInt(d.competitorTwo||"0");a=o?m:y,c=o?y:m}const f=t.statistics;let l=null,u=null;if(f){const m=f.find?.(y=>y.type==="CORNERS");m&&(l=o?m.competitorOne:m.competitorTwo,u=o?m.competitorTwo:m.competitorOne)}return{goalsFor:i,goalsAgainst:r,halfTimeGoalsFor:a,halfTimeGoalsAgainst:c,cornersFor:l,cornersAgainst:u,isWin:i>r,isDraw:i===r,isLoss:i<r}}function ht(t,e){return t.competitorOne.id===e}function Zt(t,e){return t.competitorTwo.id===e}function On(t,e){return ht(t,e)||Zt(t,e)}function Fn(t){return t.status?.type==="FINISHED"}function En(t,e){const o=ht(t,e);return parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")}function Ln(t,e){const o=ht(t,e);return parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")}function bn(t,e,o){const n=t.filter(f=>{if(f.status?.type!=="FINISHED"||!f.score)return!1;const l=f.competitorOne.id===e||f.competitorTwo.id===e,u=f.competitorOne.id===o||f.competitorTwo.id===o;return l&&u});let s=0,i=0,r=0,a=0,c=0;n.forEach(f=>{const l=parseInt(f.score?.competitorOne||"0"),u=parseInt(f.score?.competitorTwo||"0"),m=f.competitorOne.id===e,y=m?l:u,T=m?u:l;a+=y,c+=T,y>T?s++:T>y?i++:r++});const d=n.length;return{totalMatches:d,homeTeamWins:s,awayTeamWins:i,draws:r,homeTeamGoals:a,awayTeamGoals:c,homeTeamWinPercentage:d>0?s/d*100:0,awayTeamWinPercentage:d>0?i/d*100:0,drawPercentage:d>0?r/d*100:0,homeTeamAvgGoals:d>0?a/d:0,awayTeamAvgGoals:d>0?c/d:0}}function Rn(t,e,o,n=5){return t.filter(i=>{if(i.status?.type!=="FINISHED"||!i.score)return!1;const r=i.competitorOne.id===e||i.competitorTwo.id===e,a=i.competitorOne.id===o||i.competitorTwo.id===o;return r&&a}).sort((i,r)=>new Date(r.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()).slice(0,n).map(i=>{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;let l;return d>f?l="home":f>d?l="away":l="draw",{id:i.id,date:new Date(i.timing.kickoffTime).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),homeTeamName:i.competitorOne.name,awayTeamName:i.competitorTwo.name,homeTeamLogo:i.competitorOne.assets?.logo,awayTeamLogo:i.competitorTwo.assets?.logo,homeScore:r,awayScore:a,venue:i.venue?.name,winner:l}})}function Nn(t,e,o){return t.filter(n=>{const s=n.competitorOne.id===e,i=n.competitorTwo.id===e;return!s&&!i?!1:o==="home"?s:i}).map(n=>{const s=n.competitorOne.id===e;return Jt(n,e,s)}).filter(n=>n!==null)}function Lt(t,e,o,n){let s=0;for(const i of t){const r=i.competitorOne.id===e,a=i.competitorTwo.id===e;if(!r&&!a||o==="home"&&!r||o==="away"&&!a||i.status?.type!=="FINISHED")continue;const c=i.mainEvents;if(!c||!Array.isArray(c))continue;const d=c.filter(y=>y.type&&Xt.includes(y.type)).sort((y,T)=>{const A=y.minute??0,p=T.minute??0;return A!==p?A-p:(y.injuryMinute??0)-(T.injuryMinute??0)});if(d.length===0)continue;const f=d[0],l=r?"ONE":"TWO",u=f.type==="OWN_GOAL";let m;u?m=f.competitorPosition!==l:m=f.competitorPosition===l,(n==="scored"&&m||n==="conceded"&&!m)&&s++}return s}function Pn(t,e,o){let n=0;for(const s of t){const i=s.competitorOne.id===e,r=s.competitorTwo.id===e;if(!i&&!r||o==="home"&&!i||o==="away"&&!r||s.status?.type!=="FINISHED")continue;const a=s.mainEvents;a&&Array.isArray(a)&&n++}return n}function Mn(t,e,o){const n=Nn(t,e,o),s=n.length;if(s===0)return{played:0,goalsForPerMatch:0,cleanSheets:0,wonToNil:0,scoringRate:0,scoredInBothHalves:0,scoredFirst:0,leadingAtHalfTime:0,goalsAgainstPerMatch:0,failedToScore:0,lostToNil:0,concedingRate:0,concededInBothHalves:0,concededFirst:0,losingAtHalfTime:0,avgCornersFor:0,avgCornersAgainst:0};const i=n.reduce((g,F)=>g+F.goalsFor,0),r=n.reduce((g,F)=>g+F.goalsAgainst,0),a=n.filter(g=>g.goalsAgainst===0).length,c=n.filter(g=>g.isWin&&g.goalsAgainst===0).length,d=n.filter(g=>g.goalsFor>0).length,f=n.filter(g=>g.goalsFor===0).length,l=n.filter(g=>g.isLoss&&g.goalsFor===0).length,u=n.filter(g=>g.goalsAgainst>0).length,m=n.filter(g=>g.halfTimeGoalsFor!==null),y=m.length,T=m.filter(g=>{const F=g.halfTimeGoalsFor,Z=g.goalsFor-F;return F>0&&Z>0}).length,A=Lt(t,e,o,"scored"),p=Pn(t,e,o),_=m.filter(g=>g.halfTimeGoalsFor>g.halfTimeGoalsAgainst).length,C=m.filter(g=>{const F=g.halfTimeGoalsAgainst,Z=g.goalsAgainst-F;return F>0&&Z>0}).length,O=Lt(t,e,o,"conceded"),S=m.filter(g=>g.halfTimeGoalsAgainst>g.halfTimeGoalsFor).length,P=n.filter(g=>g.cornersFor!==null),M=P.reduce((g,F)=>g+(F.cornersFor||0),0),I=P.reduce((g,F)=>g+(F.cornersAgainst||0),0);return{played:s,goalsForPerMatch:et(i,s),cleanSheets:R(a,s),wonToNil:R(c,s),scoringRate:R(d,s),scoredInBothHalves:R(T,y),scoredFirst:R(A,p),leadingAtHalfTime:R(_,y),goalsAgainstPerMatch:et(r,s),failedToScore:R(f,s),lostToNil:R(l,s),concedingRate:R(u,s),concededInBothHalves:R(C,y),concededFirst:R(O,p),losingAtHalfTime:R(S,y),avgCornersFor:et(M,P.length),avgCornersAgainst:et(I,P.length)}}function In(t,e){return t.filter(o=>o.status?.type!=="FINISHED"?!1:o.competitorOne.id===e||o.competitorTwo.id===e).map(o=>{const n=o.competitorOne.id===e,s=parseInt(o.score?.competitorOne||"0"),i=parseInt(o.score?.competitorTwo||"0"),r=s+i,a=o.periods;let c=null;if(a&&Array.isArray(a)){const d=a.find(f=>f.type==="FIRST_HALF"||f.type==="1ST_HALF");if(d?.score){const f=parseInt(d.score.competitorOne||"0"),l=parseInt(d.score.competitorTwo||"0");c=f+l}}return{totalGoals:r,halfTimeGoals:c,isHome:n}})}function v(t,e){return t.length===0?0:t.filter(n=>n>e).length/t.length*100}function Un(t,e){const o=In(t,e),n=o.filter(l=>l.isHome),s=o.filter(l=>!l.isHome),i=o.map(l=>l.totalGoals),r=n.map(l=>l.totalGoals),a=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),f=s.filter(l=>l.halfTimeGoals!==null).map(l=>l.halfTimeGoals);return{over05:{home:v(r,.5),total:v(i,.5),away:v(a,.5)},over15:{home:v(r,1.5),total:v(i,1.5),away:v(a,1.5)},over25:{home:v(r,2.5),total:v(i,2.5),away:v(a,2.5)},over35:{home:v(r,3.5),total:v(i,3.5),away:v(a,3.5)},over45:{home:v(r,4.5),total:v(i,4.5),away:v(a,4.5)},over55:{home:v(r,5.5),total:v(i,5.5),away:v(a,5.5)},over05HT:{home:v(d,.5),total:v(c,.5),away:v(f,.5)},over15HT:{home:v(d,1.5),total:v(c,1.5),away:v(f,1.5)},over25HT:{home:v(d,2.5),total:v(c,2.5),away:v(f,2.5)}}}function wt(t,e){const o=t.competitorOne.id===e,n=t.competitorTwo.id===e;if(!o&&!n||!t.score)return null;const s=parseInt(o?t.score.competitorOne||"0":t.score.competitorTwo||"0"),i=parseInt(o?t.score.competitorTwo||"0":t.score.competitorOne||"0");let r;return s>i?r="W":s<i?r="L":r="D",{result:{score:`${s}:${i}`,result:r,isHome:o},isHome:o}}function Gn(t,e,o,n,s,i){const r=e?.entries.find(k=>k.competitor.id===t),a=o?.entries.find(k=>k.competitor.id===t),c=n?.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);if(!r)return null;const l=a?.stats?.goalsFor??0,u=c?.stats?.goalsFor??0,m=r?.stats?.goalsFor??0,y=d?.stats?.goalsAgainst??0,T=f?.stats?.goalsAgainst??0,A=r?.stats?.goalsAgainst??0,p=a?.stats?.played??0,_=c?.stats?.played??0,C=r?.stats?.played??0,O=C>0?m/C:0,S=C>0?A/C:0,P=O+S,M=p>0?l/p:0,I=_>0?u/_:0,g=p>0?y/p:0,F=_>0?T/_:0,Z=M+g,te=I+F;return{homeGoals:l,totalGoals:m,awayGoals:u,homeGamesPlayed:p,awayGamesPlayed:_,totalGamesPlayed:C,homeGoalsConceded:y,totalGoalsConceded:A,awayGoalsConceded:T,gfPerMatch:O,gaPerMatch:S,gfGaPerMatch:P,homeGfPerMatch:M,awayGfPerMatch:I,homeGaPerMatch:g,awayGaPerMatch:F,homeGfGaPerMatch:Z,awayGfGaPerMatch:te}}function b(t,e,o,n){const s=t.filter(r=>{const a=r.competitorOne.id===e,c=r.competitorTwo.id===e;return!(!a&&!c||r.status?.type!=="FINISHED"||n==="home"&&!a||n==="away"&&!c)}).sort((r,a)=>new Date(a.timing.kickoffTime).getTime()-new Date(r.timing.kickoffTime).getTime());if(s.length===0)return null;let i=0;for(const r of s){const a=r.competitorOne.id===e;if(o(r,e,a))i++;else break}return i>0?i:null}const E={win:(t,e,o)=>{const n=parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0"),s=parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0");return n>s},draw:t=>t.score?.competitorOne===t.score?.competitorTwo,loss:(t,e,o)=>{const n=parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0"),s=parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0");return n<s},noWin:(t,e,o)=>!E.win(t,e,o),noDraw:t=>!E.draw(t),noDefeat:(t,e,o)=>!E.loss(t,e,o),scored:(t,e,o)=>parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")>=1,conceded:(t,e,o)=>parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")>=1,noGoalScored:(t,e,o)=>!E.scored(t,e,o),noGoalConceded:(t,e,o)=>!E.conceded(t,e,o),over25:t=>parseInt(t.score?.competitorOne||"0")+parseInt(t.score?.competitorTwo||"0")>2,under25:t=>parseInt(t.score?.competitorOne||"0")+parseInt(t.score?.competitorTwo||"0")<3,scoredTwice:(t,e,o)=>parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")>=2,concededTwice:(t,e,o)=>parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")>=2};function ot(t,e,o){return{win:b(t,e,E.win,o),draw:b(t,e,E.draw,o),loss:b(t,e,E.loss,o),noWin:b(t,e,E.noWin,o),noDraw:b(t,e,E.noDraw,o),noDefeat:b(t,e,E.noDefeat,o),scored:b(t,e,E.scored,o),conceded:b(t,e,E.conceded,o),noGoalScored:b(t,e,E.noGoalScored,o),noGoalConceded:b(t,e,E.noGoalConceded,o),over25:b(t,e,E.over25,o),under25:b(t,e,E.under25,o),scoredTwice:b(t,e,E.scoredTwice,o),concededTwice:b(t,e,E.concededTwice,o)}}function Dn(t,e,o){const n=ot(t,e,"home"),s=ot(t,e),i=ot(t,o,"away"),r=ot(t,o);return[{label:"Consecutive wins",homeTeam:{home:n.win,total:s.win},awayTeam:{total:r.win,home:i.win},colorType:"neutral"},{label:"Consecutive draws",homeTeam:{home:n.draw,total:s.draw},awayTeam:{total:r.draw,home:i.draw},colorType:"neutral"},{label:"Consecutive defeats",homeTeam:{home:n.loss,total:s.loss},awayTeam:{total:r.loss,home:i.loss},colorType:"neutral"},{label:"No win",homeTeam:{home:n.noWin,total:s.noWin},awayTeam:{total:r.noWin,home:i.noWin},colorType:"negative"},{label:"No draw",homeTeam:{home:n.noDraw,total:s.noDraw},awayTeam:{total:r.noDraw,home:i.noDraw},colorType:"neutral"},{label:"No defeat",homeTeam:{home:n.noDefeat,total:s.noDefeat},awayTeam:{total:r.noDefeat,home:i.noDefeat},colorType:"positive"},{label:"Scored at least once",homeTeam:{home:n.scored,total:s.scored},awayTeam:{total:r.scored,home:i.scored},colorType:"positive"},{label:"Conceded at least once",homeTeam:{home:n.conceded,total:s.conceded},awayTeam:{total:r.conceded,home:i.conceded},colorType:"negative"},{label:"No goal scored",homeTeam:{home:n.noGoalScored,total:s.noGoalScored},awayTeam:{total:r.noGoalScored,home:i.noGoalScored},colorType:"neutral"},{label:"No goal conceded",homeTeam:{home:n.noGoalConceded,total:s.noGoalConceded},awayTeam:{total:r.noGoalConceded,home:i.noGoalConceded},colorType:"neutral"},{label:"GS + GC over 2.5",homeTeam:{home:n.over25,total:s.over25},awayTeam:{total:r.over25,home:i.over25},colorType:"neutral"},{label:"GS + GC under 2.5",homeTeam:{home:n.under25,total:s.under25},awayTeam:{total:r.under25,home:i.under25},colorType:"neutral"},{label:"Scored at least twice",homeTeam:{home:n.scoredTwice,total:s.scoredTwice},awayTeam:{total:r.scoredTwice,home:i.scoredTwice},colorType:"positive"},{label:"Conceded at least twice",homeTeam:{home:n.concededTwice,total:s.concededTwice},awayTeam:{total:r.concededTwice,home:i.concededTwice},colorType:"negative"}]}function bt(t,e){const o=new Map;return t.forEach(n=>{if(n.status?.type!=="FINISHED")return;const s=wt(n,e);if(!s)return;const i=s.isHome?n.competitorTwo.id:n.competitorOne.id,r=s.isHome?n.competitorTwo:n.competitorOne,a=o.get(i)||{opponentId:i,opponentName:r.name,opponentLogo:r.assets?.logo};s.isHome?a.homeResult=s.result:a.awayResult=s.result,o.set(i,a)}),o}function xn(t,e,o,n,s,i,r){const a=bt(t,e),c=bt(t,o),d=new Set([...a.keys(),...c.keys(),e,o]),f=[];return d.forEach(l=>{const u=a.get(l),m=c.get(l);if(!u&&!m&&l!==e&&l!==o)return;let y,T;l===e?(y=n,T=i):l===o?(y=s,T=r):(y=u?.opponentName||m?.opponentName||"",T=u?.opponentLogo||m?.opponentLogo),f.push({opponentId:l,opponentName:y,opponentLogo:T,homeTeamHome:u?.homeResult,homeTeamAway:u?.awayResult,awayTeamHome:m?.homeResult,awayTeamAway:m?.awayResult,isHomeTeamRow:l===e,isAwayTeamRow:l===o})}),f.sort((l,u)=>l.isHomeTeamRow?-1:u.isHomeTeamRow?1:l.isAwayTeamRow?-1:u.isAwayTeamRow?1:l.opponentName.localeCompare(u.opponentName))}exports.addProviderRef=h.addProviderRef;exports.getBatchMatchOdds=h.getBatchMatchOdds;exports.getConfig=h.getConfig;exports.getFootballCompetition=h.getFootballCompetition;exports.getFootballLivescore=h.getFootballLivescore;exports.getFootballMatch=h.getFootballMatch;exports.getFootballMatchCommentary=h.getFootballMatchCommentary;exports.getFootballMatchEvents=h.getFootballMatchEvents;exports.getFootballMatchLineups=h.getFootballMatchLineups;exports.getFootballMatchOdds=h.getFootballMatchOdds;exports.getFootballMatchStatistics=h.getFootballMatchStatistics;exports.getFootballMatches=h.getFootballMatches;exports.getFootballPlayerSeasonStatistics=h.getFootballPlayerSeasonStatistics;exports.getFootballSeasonDetails=h.getFootballSeasonDetails;exports.getFootballStandings=h.getFootballStandings;exports.getFootballTeam=h.getFootballTeam;exports.getFootballTeamSquad=h.getFootballTeamSquad;exports.getLeaderboardMatches=h.getLeaderboardMatches;exports.getLeaderboardTeamMatches=h.getLeaderboardTeamMatches;exports.getLeaderboardTemplate=h.getLeaderboardTemplate;exports.getProviderRefId=h.getProviderRefId;exports.isConfigured=h.isConfigured;exports.setConfig=h.setConfig;exports.toProviderRefArray=h.toProviderRefArray;exports.GOAL_EVENT_TYPES=Xt;exports.aggregatePlayerStatisticsFromMatches=Q;exports.analyzeMatch=Jt;exports.cached=z;exports.cachedBatch=kt;exports.calcAverage=et;exports.calcPercentage=R;exports.calculateH2HStats=bn;exports.calculateStreak=b;exports.formatAsAverage=An;exports.formatPossessionPercentage=Cn;exports.formatStatValue=vn;exports.formatWithAverage=Sn;exports.getActiveSeason=en;exports.getAllPlayerStatisticsFromMatches=Qt;exports.getBasketballLivescore=ye;exports.getFansUnitedCompetitions=Xo;exports.getFansUnitedCountries=wo;exports.getFansUnitedEntitiesByIds=Ko;exports.getFansUnitedEntityById=Qo;exports.getFansUnitedFootballCompetition=ro;exports.getFansUnitedFootballCompetitions=oo;exports.getFansUnitedFootballMatch=_o;exports.getFansUnitedFootballMatches=vo;exports.getFansUnitedFootballPlayer=yo;exports.getFansUnitedFootballPlayerNextMatch=Co;exports.getFansUnitedFootballPlayerPreviousMatch=Oo;exports.getFansUnitedFootballPlayers=To;exports.getFansUnitedFootballSearch=bo;exports.getFansUnitedFootballTeam=uo;exports.getFansUnitedFootballTeamNextMatch=So;exports.getFansUnitedFootballTeamPreviousMatch=Ao;exports.getFansUnitedFootballTeams=fo;exports.getFansUnitedSearchEntities=Vo;exports.getFansUnitedTeamsByCompetition=Zo;exports.getFansUnitedTeamsByCountry=Jo;exports.getFansUnitedVenues=tn;exports.getMatchResult=wt;exports.getMostCardedPlayersFromMatches=qt;exports.getOpponentScore=Ln;exports.getRecentH2HMeetings=Rn;exports.getSportal365Standings=Qe;exports.getTeamFinishedMatches=rn;exports.getTeamGoalStats=Gn;exports.getTeamHomeAwayStats=Mn;exports.getTeamMostDecorated=hn;exports.getTeamNextMatch=on;exports.getTeamOverUnderStats=Un;exports.getTeamPreviousMatch=nn;exports.getTeamResultsTable=an;exports.getTeamScore=En;exports.getTeamSeasonStatistics=Je;exports.getTeamStreaks=ot;exports.getTeamStreaksComparison=Dn;exports.getTeamTopAppearances=dn;exports.getTeamTopAssisters=ln;exports.getTeamTopCleanSheets=fn;exports.getTeamTopMinutesPlayed=un;exports.getTeamTopScorers=cn;exports.getTeamUpcomingMatches=sn;exports.getTeamsCommonOpponents=xn;exports.getTennisLivescore=Fe;exports.getTopAssistersFromMatches=jt;exports.getTopGoalContributorsFromMatches=Vt;exports.getTopScorersFromMatches=Yt;exports.initL2=Go;exports.invalidate=xo;exports.isMatchFinished=Fn;exports.isTeamAway=Zt;exports.isTeamHome=ht;exports.isTeamInMatch=On;exports.search=De;exports.searchFootball=ce;exports.streakFilters=E;exports.useAllPlayerStatisticsFromMatches=Tn;exports.useMostCardedPlayersFromMatches=pn;exports.usePlayerStatistics=_n;exports.usePlayerStatisticsMap=Kt;exports.useTopAssistersFromMatches=gn;exports.useTopGoalContributorsFromMatches=yn;exports.useTopScorersFromMatches=mn;
|