fansunited-data-layer 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"matches.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/fansunited-sdk/odds/matches.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,kBAAkB,MAAM,0DAA0D,CAAC;AAC/F,OAAO,KAAK,EAAE,sBAAsB,EAA+B,MAAM,0BAA0B,CAAC;AACpG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,4DAA4D;IAC5D,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC;IACvC,mDAAmD;IACnD,SAAS,CAAC,EAAE,eAAe,GAAG,WAAW,CAAC;IAC1C,wCAAwC;IACxC,SAAS,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;CACtD;AA8ID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,iBAAiB,CACnC,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,wBAAwB,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAuBjC"}
1
+ {"version":3,"file":"matches.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/fansunited-sdk/odds/matches.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,kBAAkB,MAAM,0DAA0D,CAAC;AAC/F,OAAO,KAAK,EAAE,sBAAsB,EAA+B,MAAM,0BAA0B,CAAC;AACpG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,4DAA4D;IAC5D,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC;IACvC,mDAAmD;IACnD,SAAS,CAAC,EAAE,eAAe,GAAG,WAAW,CAAC;IAC1C,wCAAwC;IACxC,SAAS,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;CACtD;AA+ID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,iBAAiB,CACnC,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,wBAAwB,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAuBjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"odds.transformer.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/sportal365-sports/shared/odds.transformer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACR,2BAA2B,EAG9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAmC,MAAM,cAAc,CAAC;AAkFjF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,2BAA2B,EAAE,CAE/E"}
1
+ {"version":3,"file":"odds.transformer.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/sportal365-sports/shared/odds.transformer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACR,2BAA2B,EAG9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAmC,MAAM,cAAc,CAAC;AAmFjF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,2BAA2B,EAAE,CAE/E"}
package/client.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),B=require("./matches-B4GkQKDb.cjs");var at={exports:{}},$e={};var ya;function Ss(){if(ya)return $e;ya=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(i,s,r){var n=null;if(r!==void 0&&(n=""+r),s.key!==void 0&&(n=""+s.key),"key"in s){r={};for(var o in s)o!=="key"&&(r[o]=s[o])}else r=s;return s=r.ref,{$$typeof:e,type:i,key:n,ref:s!==void 0?s:null,props:r}}return $e.Fragment=t,$e.jsx=a,$e.jsxs=a,$e}var Ue={};var wa;function Cs(){return wa||(wa=1,process.env.NODE_ENV!=="production"&&(function(){function e(w){if(w==null)return null;if(typeof w=="function")return w.$$typeof===P?null:w.displayName||w.name||null;if(typeof w=="string")return w;switch(w){case T:return"Fragment";case O:return"Profiler";case I:return"StrictMode";case g:return"Suspense";case f:return"SuspenseList";case M:return"Activity"}if(typeof w=="object")switch(typeof w.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),w.$$typeof){case v:return"Portal";case G:return w.displayName||"Context";case C:return(w._context.displayName||"Context")+".Consumer";case A:var R=w.render;return w=w.displayName,w||(w=R.displayName||R.name||"",w=w!==""?"ForwardRef("+w+")":"ForwardRef"),w;case y:return R=w.displayName||null,R!==null?R:e(w.type)||"Memo";case b:R=w._payload,w=w._init;try{return e(w(R))}catch{}}return null}function t(w){return""+w}function a(w){try{t(w);var R=!1}catch{R=!0}if(R){R=console;var F=R.error,N=typeof Symbol=="function"&&Symbol.toStringTag&&w[Symbol.toStringTag]||w.constructor.name||"Object";return F.call(R,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",N),t(w)}}function i(w){if(w===T)return"<>";if(typeof w=="object"&&w!==null&&w.$$typeof===b)return"<...>";try{var R=e(w);return R?"<"+R+">":"<...>"}catch{return"<...>"}}function s(){var w=D.A;return w===null?null:w.getOwner()}function r(){return Error("react-stack-top-frame")}function n(w){if(U.call(w,"key")){var R=Object.getOwnPropertyDescriptor(w,"key").get;if(R&&R.isReactWarning)return!1}return w.key!==void 0}function o(w,R){function F(){re||(re=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",R))}F.isReactWarning=!0,Object.defineProperty(w,"key",{get:F,configurable:!0})}function l(){var w=e(this.type);return ie[w]||(ie[w]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),w=this.props.ref,w!==void 0?w:null}function c(w,R,F,N,ne,Ie){var $=F.ref;return w={$$typeof:_,type:w,key:R,props:F,_owner:N},($!==void 0?$:null)!==null?Object.defineProperty(w,"ref",{enumerable:!1,get:l}):Object.defineProperty(w,"ref",{enumerable:!1,value:null}),w._store={},Object.defineProperty(w._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(w,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(w,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.defineProperty(w,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ie}),Object.freeze&&(Object.freeze(w.props),Object.freeze(w)),w}function d(w,R,F,N,ne,Ie){var $=R.children;if($!==void 0)if(N)if(j($)){for(N=0;N<$.length;N++)p($[N]);Object.freeze&&Object.freeze($)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p($);if(U.call(R,"key")){$=e(w);var ee=Object.keys(R).filter(function(Ge){return Ge!=="key"});N=0<ee.length?"{key: someKey, "+ee.join(": ..., ")+": ...}":"{key: someKey}",Z[$+N]||(ee=0<ee.length?"{"+ee.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),B=require("./matches-DvC2VSyO.cjs");var at={exports:{}},$e={};var ya;function Ss(){if(ya)return $e;ya=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(i,s,r){var n=null;if(r!==void 0&&(n=""+r),s.key!==void 0&&(n=""+s.key),"key"in s){r={};for(var o in s)o!=="key"&&(r[o]=s[o])}else r=s;return s=r.ref,{$$typeof:e,type:i,key:n,ref:s!==void 0?s:null,props:r}}return $e.Fragment=t,$e.jsx=a,$e.jsxs=a,$e}var Ue={};var wa;function Cs(){return wa||(wa=1,process.env.NODE_ENV!=="production"&&(function(){function e(w){if(w==null)return null;if(typeof w=="function")return w.$$typeof===P?null:w.displayName||w.name||null;if(typeof w=="string")return w;switch(w){case T:return"Fragment";case O:return"Profiler";case I:return"StrictMode";case g:return"Suspense";case f:return"SuspenseList";case M:return"Activity"}if(typeof w=="object")switch(typeof w.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),w.$$typeof){case v:return"Portal";case G:return w.displayName||"Context";case C:return(w._context.displayName||"Context")+".Consumer";case A:var R=w.render;return w=w.displayName,w||(w=R.displayName||R.name||"",w=w!==""?"ForwardRef("+w+")":"ForwardRef"),w;case y:return R=w.displayName||null,R!==null?R:e(w.type)||"Memo";case b:R=w._payload,w=w._init;try{return e(w(R))}catch{}}return null}function t(w){return""+w}function a(w){try{t(w);var R=!1}catch{R=!0}if(R){R=console;var F=R.error,N=typeof Symbol=="function"&&Symbol.toStringTag&&w[Symbol.toStringTag]||w.constructor.name||"Object";return F.call(R,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",N),t(w)}}function i(w){if(w===T)return"<>";if(typeof w=="object"&&w!==null&&w.$$typeof===b)return"<...>";try{var R=e(w);return R?"<"+R+">":"<...>"}catch{return"<...>"}}function s(){var w=D.A;return w===null?null:w.getOwner()}function r(){return Error("react-stack-top-frame")}function n(w){if(U.call(w,"key")){var R=Object.getOwnPropertyDescriptor(w,"key").get;if(R&&R.isReactWarning)return!1}return w.key!==void 0}function o(w,R){function F(){re||(re=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",R))}F.isReactWarning=!0,Object.defineProperty(w,"key",{get:F,configurable:!0})}function l(){var w=e(this.type);return ie[w]||(ie[w]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),w=this.props.ref,w!==void 0?w:null}function c(w,R,F,N,ne,Ie){var $=F.ref;return w={$$typeof:_,type:w,key:R,props:F,_owner:N},($!==void 0?$:null)!==null?Object.defineProperty(w,"ref",{enumerable:!1,get:l}):Object.defineProperty(w,"ref",{enumerable:!1,value:null}),w._store={},Object.defineProperty(w._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(w,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(w,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.defineProperty(w,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ie}),Object.freeze&&(Object.freeze(w.props),Object.freeze(w)),w}function d(w,R,F,N,ne,Ie){var $=R.children;if($!==void 0)if(N)if(j($)){for(N=0;N<$.length;N++)p($[N]);Object.freeze&&Object.freeze($)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p($);if(U.call(R,"key")){$=e(w);var ee=Object.keys(R).filter(function(Ge){return Ge!=="key"});N=0<ee.length?"{key: someKey, "+ee.join(": ..., ")+": ...}":"{key: someKey}",Z[$+N]||(ee=0<ee.length?"{"+ee.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
package/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import Ds, { createContext as Xe, useContext as Je, useMemo as P, useCallback as v, useState as U, useEffect as ue, useRef as Ls } from "react";
3
- import { w as xs, A as Ns, n as Gs, z as ga, B as fa, C as ya, p as wa, r as $s, v as Us, q as Bs, D as Hs, F as Vs, m as Ws } from "./matches-CmJlbloT.js";
4
- import { E as fh } from "./matches-CmJlbloT.js";
3
+ import { w as xs, A as Ns, n as Gs, z as ga, B as fa, C as ya, p as wa, r as $s, v as Us, q as Bs, D as Hs, F as Vs, m as Ws } from "./matches-CB-dSXEA.js";
4
+ import { E as fh } from "./matches-CB-dSXEA.js";
5
5
  var nt = { exports: {} }, Be = {};
6
6
  var _a;
7
7
  function zs() {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./matches-B4GkQKDb.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 be(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 Le(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 Pe(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 Ne(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 be(t);case"player":return Le(t);case"coach":return Re(t);case"referee":return Pe(t);case"venue":return Ne(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 Pt(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=>Pt(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=Pt(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 Nt(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",P=Nt(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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 bo(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=bo(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 Lo(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 P.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",$=Nt(Ro);var Po=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 No=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;#L;#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:N,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??Po,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.#L=!!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=!!N,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";No(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.#P=r=>{o[r]=e[r]!==0?this.#T.now():0},this.#b=(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}}#P=()=>{};#b=()=>{};#$=()=>{};#g=()=>!1;#j(){let e=new ct(this.#a);this.#_=0,this.#S=e,this.#N=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.#_)}}#N=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.#L&&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.#N(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.#b(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.#L&&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.#N(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.#b(s,i));else return n&&this.#P(i),s&&(s.has="hit",this.#b(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.#L)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.#L)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.#M(O),s&&this.#P(O),p&&this.#b(p,O),S;let M=this.#H(e,O,C,T),I=M.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=N?"stale":"refresh",I&&N&&(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.#b(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.#P(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.#N(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}),b={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=>{b.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=b.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 b.set(t,a.data),dt(a,n)||ft(t,e,o),a.data}const r=await o();return b.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=b.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)&&(b.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);b.set(l,f),U?.isInitialized&&U.set(l,e,f),r.set(d,f)}}return r}function xo(t){b.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=b.get(n)??b.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=b.get(t)??b.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&&b.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)b.get(`entity:${r.related_id}`)||e.add(r.related_id);const i=n.country_id;i&&!b.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&&!b.get(`entity:${i}`)&&o.add(i);const r=s.related;if(r)for(const a of r)a.relationship==="COUNTRY"&&!b.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 bn(t,e){const o=ht(t,e);return parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")}function Ln(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 Pn(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 bt(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 Nn(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=Pn(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=bt(t,e,o,"scored"),p=Nn(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=bt(t,e,o,"conceded"),S=m.filter(g=>g.halfTimeGoalsAgainst>g.halfTimeGoalsFor).length,N=n.filter(g=>g.cornersFor!==null),M=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(M,N.length),avgCornersAgainst:et(I,N.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,N=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:N,homeGfPerMatch:M,awayGfPerMatch:I,homeGaPerMatch:g,awayGaPerMatch:F,homeGfGaPerMatch:Z,awayGfGaPerMatch:te}}function L(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:L(t,e,E.win,o),draw:L(t,e,E.draw,o),loss:L(t,e,E.loss,o),noWin:L(t,e,E.noWin,o),noDraw:L(t,e,E.noDraw,o),noDefeat:L(t,e,E.noDefeat,o),scored:L(t,e,E.scored,o),conceded:L(t,e,E.conceded,o),noGoalScored:L(t,e,E.noGoalScored,o),noGoalConceded:L(t,e,E.noGoalConceded,o),over25:L(t,e,E.over25,o),under25:L(t,e,E.under25,o),scoredTwice:L(t,e,E.scoredTwice,o),concededTwice:L(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 Lt(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=Lt(t,e),c=Lt(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.getFootballPlayerSeasonStatisticsByPlayerIds=h.getFootballPlayerSeasonStatisticsByPlayerIds;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=Ln;exports.calculateStreak=L;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=Lo;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=bn;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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./matches-DvC2VSyO.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 be(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 Le(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 Pe(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 Ne(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 be(t);case"player":return Le(t);case"coach":return Re(t);case"referee":return Pe(t);case"venue":return Ne(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 Pt(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=>Pt(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=Pt(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 Nt(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",P=Nt(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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 P.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 bo(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=bo(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 Lo(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 P.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",$=Nt(Ro);var Po=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 No=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;#L;#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:N,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??Po,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.#L=!!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=!!N,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";No(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.#P=r=>{o[r]=e[r]!==0?this.#T.now():0},this.#b=(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}}#P=()=>{};#b=()=>{};#$=()=>{};#g=()=>!1;#j(){let e=new ct(this.#a);this.#_=0,this.#S=e,this.#N=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.#_)}}#N=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.#L&&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.#N(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.#b(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.#L&&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.#N(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.#b(s,i));else return n&&this.#P(i),s&&(s.has="hit",this.#b(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.#L)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.#L)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.#M(O),s&&this.#P(O),p&&this.#b(p,O),S;let M=this.#H(e,O,C,T),I=M.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=N?"stale":"refresh",I&&N&&(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.#b(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.#P(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.#N(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}),b={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=>{b.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=b.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 b.set(t,a.data),dt(a,n)||ft(t,e,o),a.data}const r=await o();return b.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=b.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)&&(b.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);b.set(l,f),U?.isInitialized&&U.set(l,e,f),r.set(d,f)}}return r}function xo(t){b.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=b.get(n)??b.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=b.get(t)??b.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&&b.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)b.get(`entity:${r.related_id}`)||e.add(r.related_id);const i=n.country_id;i&&!b.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&&!b.get(`entity:${i}`)&&o.add(i);const r=s.related;if(r)for(const a of r)a.relationship==="COUNTRY"&&!b.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 bn(t,e){const o=ht(t,e);return parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")}function Ln(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 Pn(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 bt(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 Nn(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=Pn(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=bt(t,e,o,"scored"),p=Nn(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=bt(t,e,o,"conceded"),S=m.filter(g=>g.halfTimeGoalsAgainst>g.halfTimeGoalsFor).length,N=n.filter(g=>g.cornersFor!==null),M=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(M,N.length),avgCornersAgainst:et(I,N.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,N=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:N,homeGfPerMatch:M,awayGfPerMatch:I,homeGaPerMatch:g,awayGaPerMatch:F,homeGfGaPerMatch:Z,awayGfGaPerMatch:te}}function L(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:L(t,e,E.win,o),draw:L(t,e,E.draw,o),loss:L(t,e,E.loss,o),noWin:L(t,e,E.noWin,o),noDraw:L(t,e,E.noDraw,o),noDefeat:L(t,e,E.noDefeat,o),scored:L(t,e,E.scored,o),conceded:L(t,e,E.conceded,o),noGoalScored:L(t,e,E.noGoalScored,o),noGoalConceded:L(t,e,E.noGoalConceded,o),over25:L(t,e,E.over25,o),under25:L(t,e,E.under25,o),scoredTwice:L(t,e,E.scoredTwice,o),concededTwice:L(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 Lt(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=Lt(t,e),c=Lt(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.getFootballPlayerSeasonStatisticsByPlayerIds=h.getFootballPlayerSeasonStatisticsByPlayerIds;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=Ln;exports.calculateStreak=L;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=Lo;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=bn;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;
@@ -1,5 +1,5 @@
1
- import { t as b, g as E, f as Vt, c as ot, S as Kt, a as Pt, b as Xt, d as Jt, e as Zt, h as wt, i as st, j as te, k as ee } from "./matches-CmJlbloT.js";
2
- import { l as ts, m as es, n as ns, o as os, p as ss, q as is, r as rs, s as as, u as cs, v as ls, w as ds, x as us, y as fs, z as hs, A as ms, B as gs, C as ps, D as ys, E as Ts, F as _s, G as vs, H as Ss } from "./matches-CmJlbloT.js";
1
+ import { t as b, g as E, f as Vt, c as ot, S as Kt, a as Pt, b as Xt, d as Jt, e as Zt, h as wt, i as st, j as te, k as ee } from "./matches-CB-dSXEA.js";
2
+ import { l as ts, m as es, n as ns, o as os, p as ss, q as is, r as rs, s as as, u as cs, v as ls, w as ds, x as us, y as fs, z as hs, A as ms, B as gs, C as ps, D as ys, E as Ts, F as _s, G as vs, H as Ss } from "./matches-CB-dSXEA.js";
3
3
  import { useMemo as j } from "react";
4
4
  function ne(t) {
5
5
  return {
@@ -134,7 +134,8 @@ function B(e) {
134
134
  odds: e.odds,
135
135
  oddsOld: e.odds_old,
136
136
  movement: e.movement === "STABLE" ? "NONE" : e.movement,
137
- url: t
137
+ url: t,
138
+ providerSelectionId: e.provider_info?.selection_id
138
139
  };
139
140
  }
140
141
  function $(e) {
@@ -1566,7 +1567,8 @@ function be(e, t) {
1566
1567
  odds: v.odds,
1567
1568
  oddsOld: v.oddsOld,
1568
1569
  movement: I,
1569
- url: x
1570
+ url: x,
1571
+ providerSelectionId: v.providerInfo?.selectionId
1570
1572
  };
1571
1573
  })
1572
1574
  }))
@@ -0,0 +1 @@
1
+ "use strict";const A="__FANSUNITED_DATA_LAYER_CONFIG__";function $(e){globalThis[A]=e}function m(){const e=globalThis[A];if(!e)throw new Error("Data layer config not initialized. Call setConfig() in your root layout.");return e}function Y(){return globalThis[A]!==void 0}function P(e){const t=e.replace(/\/$/,"");function n(s){const{sportal365Sports:a}=s;if(!a)throw new Error("Sportal365 Sports API configuration is missing");const l=`${a.username}:${a.password}`;return`Basic ${btoa(l)}`}function o(s){return`${t}${s}`}return{async get(s){const a=s.config||m(),{sportal365Sports:l}=a;if(!l)throw new Error("Sportal365 Sports API configuration is missing");const d=new URL(o(s.path));if(s.params)for(const[_,g]of Object.entries(s.params))g!==void 0&&(Array.isArray(g)?g.length>0&&d.searchParams.set(_,g.join(",")):d.searchParams.set(_,g));const c=await fetch(d.toString(),{method:"GET",headers:{Authorization:n(a),"Content-Type":"application/json","X-Project":l.projectId,...s.headers},signal:l.timeout?AbortSignal.timeout(l.timeout):void 0,...s.next&&{next:s.next}});if(!c.ok)throw new Error(`Sportal365 API error: ${c.status} ${c.statusText}`);return c.json()}}}const V="https://football.api.sportal365.com",W="https://basketball.api.sportal365.com",K="https://tennis.api.sportal365.com",j="https://sports-statistics.api.sportal365.com",q="https://sports-search.api.sportal365.com",X="https://standing.api.sportal365.com",p=P(V);function R(e){if(e)return{id:e.id,name:e.name,slug:e.slug,position:e.position,gender:e.gender,assets:e.assets?{photo:e.assets.thumb?.url,photoTransparent:e.assets.thumb_transparent_background?.url}:void 0}}const z={GOAL:"GOAL",PENALTY_GOAL:"PENALTY_GOAL",OWN_GOAL:"OWN_GOAL",DISALLOWED_GOAL:"DISALLOWED_GOAL",PENALTY_SHOOTOUT_SCORED:"PENALTY_SHOOTOUT_SCORED",PENALTY_SHOOTOUT_MISSED:"PENALTY_SHOOTOUT_MISSED",YELLOW_CARD:"YELLOW_CARD",RED_CARD:"RED_CARD",YELLOW_RED_CARD:"YELLOW_RED_CARD",SUBSTITUTION:"SUBSTITUTION",KICKOFF:"KICKOFF",HALFTIME:"HALFTIME",START_SECOND_HALF:"START_SECOND_HALF",FINISHED:"FINISHED",INJURY_TIME:"INJURY_TIME",PENALTY_AWARDED:"PENALTY_AWARDED",PENALTY_MISSED:"PENALTY_MISSED",PENALTY_SAVED:"PENALTY_SAVED"};function C(e){const t=z[e.type_code];return t?{id:e.id,type:t,competitorPosition:e.team_position==="HOME"?"ONE":"TWO",minute:e.minute,injuryMinute:e.injury_minute,primaryPlayer:R(e.primary_player),secondaryPlayer:R(e.secondary_player),score:e.score?{competitorOne:String(e.score.home),competitorTwo:String(e.score.away)}:void 0}:(console.warn(`Unknown event type: ${e.type_code}`),null)}function r(e,t="sportal365"){if(e)return[{provider:t,id:e}]}function J(e,t){return e?e.find(o=>o.provider===t)?.id:void 0}function Q(e,t,n){const o=e??[],s=o.findIndex(a=>a.provider===t);if(s>=0){const a=[...o];return a[s]={provider:t,id:n},a}else return[...o,{provider:t,id:n}]}function Z(e){const t=e.urls?.find(n=>n.app_type==="desktop")?.url;return{id:e.id,name:e.name,code:e.code,value:e.value??void 0,odds:e.odds,oddsOld:e.odds_old,movement:e.movement==="STABLE"?"NONE":e.movement,url:t,providerSelectionId:e.provider_info?.selection_id}}function w(e){return{type:{id:e.type.id,code:e.type.code,name:e.type.name},period:{id:e.scope.id,type:e.scope.type,name:e.scope.name},selections:e.selections.map(Z)}}function ee(e){if(!e)return!0;const t=e.replace("#",""),n=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return(.2126*n+.7152*o+.0722*s)/255<.5}function te(e){const t=e.bookmaker.assets?.[0],n=e.bookmaker.branding||t,o=e.bookmaker.branding?.background_color||t?.background_color,s=e.bookmaker.branding?.text_color||(ee(o)?"#FFFFFF":"#000000");return{operator:{id:e.bookmaker.id,name:e.bookmaker.name,url:e.bookmaker.url,branding:n?{backgroundColor:o,textColor:s,logo:t?.logo}:void 0},type:e.type,markets:e.markets.map(w)}}function M(e){return e.map(te)}function oe(e){const t={finished_ap:"finished_after_penalties",finished_aet:"finished_after_extra_time",finished:"finished",not_started:"not_started",live:"live",interrupted:"interrupted",cancelled:"cancelled",postponed:"postponed",abandoned:"abandoned"};let n;return e.code&&t[e.code]?n=t[e.code]:n={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed",UNKNOWN:"not_started",ABANDONED:"abandoned"}[e.type]??"not_started",{code:n,name:e.name,shortName:e.short_name,type:e.type}}function L(e){return{id:e.id,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code,slug:e.slug,type:e.type==="national"?"national":"club",gender:e.gender,assets:e.assets?{logo:e.assets.logo?.url,homeKit:e.assets.home_kit?.url,awayKit:e.assets.away_kit?.url,squadImage:e.assets.squad_image?.url}:void 0,metadata:e.shirt_color?{shirtColors:[{type:"home",colorCode:e.shirt_color}]}:void 0,providerRef:r(e.uuid)}}function ne(e){return{kickoffTime:new Date(e.kickoff_time),currentMinute:e.minute?.regular_time,phaseStartedAt:e.phase_started_at?new Date(e.phase_started_at):void 0,finishedAt:e.finished_at?new Date(e.finished_at):void 0,firstHalfStartedAt:e.first_half_started_at?new Date(e.first_half_started_at):void 0,secondHalfStartedAt:e.second_half_started_at?new Date(e.second_half_started_at):void 0,extraTimeFirstHalfStartedAt:e.extra_time_first_half_started_at?new Date(e.extra_time_first_half_started_at):void 0,extraTimeSecondHalfStartedAt:e.extra_time_second_half_started_at?new Date(e.extra_time_second_half_started_at):void 0}}function se(e){if(!e)return;const t=o=>o?{competitorOne:String(o.home),competitorTwo:String(o.away)}:void 0,n=e.after_extra_time??e.regular_time;return{competitorOne:n?.home!=null?String(n.home):null,competitorTwo:n?.away!=null?String(n.away):null,breakdown:{total:t(e.total),halfTime:t(e.half_time),regularTime:t(e.regular_time),extraTime:t(e.extra_time),penaltyShootout:t(e.penalty_shootout),aggregate:t(e.aggregate)}}}function ae(e){if(e)return{id:e.id,name:e.name,slug:e.slug,assets:e.assets?.image?.url?{image:e.assets.image.url}:void 0,providerRef:r(e.uuid)}}function ie(e){if(e?.length)return e.map(t=>({id:t.id,name:t.name,slug:t.slug,role:t.role??"REFEREE",gender:t.gender}))}function re(e){if(!e.season?.tournament)return;const{tournament:t,...n}=e.season;return{id:t.id,name:t.name,slug:t.slug,type:t.type,region:t.region,country:t.country?{id:t.country.id,name:t.country.name,code:t.country.code??void 0,flag:t.country.assets?.flag?.url,providerRef:r(t.country.uuid)}:void 0,season:{id:n.id,name:n.name,status:n.status},stage:e.stage?{id:e.stage.id,name:e.stage.name,type:e.stage.type}:void 0,assets:t.assets?.logo?.url?{logo:t.assets.logo.url}:void 0,providerRef:r(t.uuid)}}function de(e){if(!e.winner?.match?.id)return;const t={"Regular Time":"REGULAR_TIME","Extra Time":"EXTRA_TIME",Penalties:"PENALTIES"};return{competitorId:e.winner.match.id,reason:e.winner.match.reason?.name?t[e.winner.match.reason.name]:void 0,aggregate:!!e.winner.aggregate}}function O(e){return{id:e.id,slug:e.slug,sport:"football",status:oe(e.status),timing:ne(e),competitorOne:L(e.home_team),competitorTwo:L(e.away_team),competition:re(e),round:e.round?{id:e.round.id??e.round.key,key:e.round.key,name:e.round.name,type:e.round.type??"REGULAR",providerRef:r(e.round.uuid)}:void 0,group:e.group?{id:e.group.id,name:e.group.name,providerRef:r(e.group.uuid)}:void 0,venue:ae(e.venue),officials:ie(e.referees),spectators:e.spectators??void 0,score:se(e.score),mainEvents:e.main_events?.map(C).filter(t=>t!==null),penaltyShootoutEvents:e.penalty_shootout_events?.map(C).filter(t=>t!==null),winner:de(e),coverage:e.coverage==="NOT_LIVE"?"UNKNOWN":e.coverage,lineupStatus:e.lineup_status==="UNCONFIRMED"?"EXPECTED":e.lineup_status,providerRef:r(e.uuid)}}function ce(e){const t=e.player;return{id:t.id,name:t.name,slug:t.slug,position:t.position,shirtNumber:e.shirt_number,positionX:e.position_x??void 0,positionY:e.position_y??void 0,country:t.country?{id:t.country.id,name:t.country.name,code:t.country.code,providerRef:r(t.country.uuid)}:void 0,birthdate:t.birthdate,profile:t.profile?{height:t.profile.height,weight:t.profile.weight}:void 0,assets:t.assets?{photo:t.assets.thumb?.url,photoTransparent:t.assets.thumb_transparent_background?.url}:void 0,events:e.events?.map(C).filter(n=>n!==null),providerRef:r(t.uuid)}}function D(e){const t=[],n=[];for(const o of e.players){const s=ce(o);o.type.category==="start"?t.push(s):o.type.category==="sub"&&n.push(s)}return{competitorId:e.team_id,formation:e.formation,coach:e.coach?{id:e.coach.id,name:e.coach.name,slug:e.coach.slug,country:e.coach.country?{id:e.coach.country.id,name:e.coach.country.name,code:e.coach.country.code,providerRef:r(e.coach.country.uuid)}:void 0,birthdate:e.coach.birthdate,providerRef:r(e.coach.uuid)}:void 0,starters:t,substitutes:n}}function ue(e){return{matchId:e.match_id,confirmed:e.status==="CONFIRMED",competitorOne:D(e.home_team),competitorTwo:D(e.away_team)}}function y(e,t,n,o){return t==null?null:{key:e,value:String(t),label:n,unit:o}}function k(e,t){const n=(t.shots_on??0)+(t.shots_off??0)+(t.shots_blocked??0),o=[y("possession",t.possession,"Possession","%"),y("shots_total",n,"Shots"),y("shots_on_target",t.shots_on,"Shots on Target"),y("shots_off_target",t.shots_off,"Shots off Target"),y("shots_blocked",t.shots_blocked,"Shots Blocked"),y("corners",t.corners,"Corner Kicks"),y("goal_kicks",t.goal_kicks,"Goal Kicks"),y("throw_ins",t.throw_in,"Throw Ins"),y("offsides",t.offside,"Offsides"),y("fouls",t.fouls_committed,"Fouls"),y("yellow_cards",t.yellow_cards,"Yellow Cards"),y("passes",t.pass,"Passes"),y("crosses",t.crosses,"Crosses")];return{competitorId:e,statistics:o.filter(s=>s!==null)}}function le(e){const t=e.find(o=>o.home_team),n=e.find(o=>!o.home_team);if(!t||!n)throw new Error("Missing competitor statistics");return{competitorOne:k(String(t.team.id),t.statistics),competitorTwo:k(String(n.team.id),n.statistics)}}function ge(e,t){return{matchId:e,operators:M(t)}}function N(e){if(e==null||e==="")return;const t=typeof e=="number"?e:parseInt(e,10);return isNaN(t)?void 0:t}function me(e){return{externalId:e.external_id,minute:N(e.elapsed),addedTime:N(e.elapsed_plus),text:e.auto_text,details:e.details,meta:{type:e.type,commentaryType:e.commentary_type,subtype1:e.subtype_1,subtype2:e.subtype_2,timestamp:e.incident_timestamp}}}async function pe(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/v2/matches/${e}`,params:{language_code:t?.languageCode??s?.languageCode??"en",odd_client:t?.oddClient,odd_type:t?.oddType,scope_type:t?.scopeType,odd_format:t?.oddFormat,market_types:t?.marketTypes,bookmaker_ids:t?.bookmakerIds,optional_data:t?.optionalData},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return O(a)}async function fe(e,t,n){const o=n||m(),{sportal365Sports:s}=o;return(await p.get({path:`/v2/matches/${e}/events`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o})).events.map(C).filter(l=>l!==null)}async function _e(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/v2/matches/${e}/lineups`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return ue(a)}async function ye(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/v2/matches/${e}`,params:{language_code:t?.languageCode??s?.languageCode??"en",odd_client:t?.oddClient??s?.oddClient,odd_type:t?.oddType,scope_type:t?.scopeType??"ALL",odd_format:t?.oddFormat??"DECIMAL",market_types:t?.marketTypes,bookmaker_ids:t?.bookmakerIds},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return ge(e,a.odds??[])}async function he(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/events/${e}/teamstats`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return le(a)}async function ve(e,t,n){const o=n||m(),{sportal365Sports:s}=o;return(await p.get({path:`/matches/${e}/commentary`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o})).map(me)}async function Se(e,t){const n=t||m(),{sportal365Sports:o}=n;return(await p.get({path:"/v2/matches",params:{language_code:e.languageCode??o?.languageCode??"en",limit:e.limit.toString(),offset:e.offset.toString(),tournament_ids:e.tournamentIds,season_ids:e.seasonIds,stage_ids:e.stageIds,group_ids:e.groupIds,round_ids:e.roundIds,round_filter:e.roundFilter,from_kickoff_time:e.fromKickoffTime,to_kickoff_time:e.toKickoffTime,team_ids:e.teamIds,team_ids_operator:e.teamIdsOperator,referee_id:e.refereeId,venue_id:e.venueId,player_id:e.playerId,status_types:e.statusTypes,status_codes:e.statusCodes,odd_client:e.oddClient??o?.oddClient,odd_type:e.oddType,scope_type:e.scopeType,odd_format:e.oddFormat,market_types:e.marketTypes,bookmaker_ids:e.bookmakerIds,sort_direction:e.sortDirection,optional_data:e.optionalData},headers:{"Accept-Language":e.languageCode??o?.languageCode??"en"},next:e.next,config:n})).matches.map(O)}async function Te(e,t){const n=t||m(),{sportal365Sports:o}=n;return(await p.get({path:"/v2/matches/livescore",params:{match_ids:e?.matchIds,date:e?.date,utc_offset:e?.utcOffset?.toString(),tournament_group:e?.tournamentGroup,status_types:e?.statusTypes,selection_filter:e?.selectionFilter,language_code:e?.languageCode??o?.languageCode??"en",odd_client:e?.oddClient??o?.oddClient,odd_type:e?.oddType,scope_type:e?.scopeType,odd_format:e?.oddFormat,market_types:e?.marketTypes,optional_data:e?.optionalData},headers:{"Accept-Language":e?.languageCode??o?.languageCode??"en"},next:e?.next,config:n})).matches.map(O)}function Ce(e){return{id:e.id,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code,slug:e.slug,type:e.type==="placeholder"||e.type==="club"?"club":"national",gender:e.gender,country:e.country?{id:e.country.id,name:e.country.name,code:e.country.code??void 0,flag:e.country.assets?.flag?.url,providerRef:r(e.country.uuid)}:void 0,venue:e.venue?{id:e.venue.id,name:e.venue.name,slug:e.venue.slug,city:e.venue.city?{id:e.venue.city.id,name:e.venue.city.name,country:e.venue.city.country?{id:e.venue.city.country.id,name:e.venue.city.country.name,code:e.venue.city.country.code??void 0,flag:e.venue.city.country.assets?.flag?.url,providerRef:r(e.venue.city.country.uuid)}:void 0,providerRef:r(e.venue.city.uuid??void 0)}:void 0,country:e.venue.country?{id:e.venue.country.id,name:e.venue.country.name,code:e.venue.country.code??void 0,flag:e.venue.country.assets?.flag?.url,providerRef:r(e.venue.country.uuid)}:void 0,profile:e.venue.profile?{latitude:e.venue.profile.lat,longitude:e.venue.profile.lng,capacity:e.venue.profile.capacity}:void 0,assets:e.venue.assets?.image?.url?{image:e.venue.assets.image.url}:void 0,providerRef:r(e.venue.uuid)}:void 0,coach:e.coach?{id:e.coach.id,name:e.coach.name,slug:e.coach.slug,country:{id:e.coach.country.id,name:e.coach.country.name,code:e.coach.country.code??void 0,flag:e.coach.country.assets?.flag?.url,providerRef:r(e.coach.country.uuid)},birthdate:e.coach.birthdate,providerRef:r(e.coach.uuid)}:void 0,founded:e.founded,assets:e.assets?{logo:e.assets.logo?.url,homeKit:e.assets.home_kit?.url,awayKit:e.assets.away_kit?.url,squadImage:e.assets.squad_image?.url}:void 0,metadata:{shirtColors:e.shirt_colors?.map(t=>({type:t.type,colorCode:t.color_code})),socials:e.social?{website:e.social.web,x:e.social.twitter_id,facebook:e.social.facebook_id,instagram:e.social.instagram_id,wikipedia:e.social.wikipedia_id}:void 0},activeSeasons:e.active_seasons?.map(t=>({id:t.id,name:t.name,slug:t.slug,active:t.status==="ACTIVE",providerRef:r(t.uuid)})),currentSeason:e.current_season?{id:e.current_season.id,name:e.current_season.name,slug:e.current_season.slug,active:e.current_season.status==="ACTIVE",providerRef:r(e.current_season.uuid)}:void 0,form:e.form&&e.form.length>0?{competitorId:e.id,results:e.form.map(t=>{const o=t.participants[0].id===e.uuid?t.participants[1]:t.participants[0],s=t.result[0]?.results.find(d=>d.position==="1")?.value,a=t.result[0]?.results.find(d=>d.position==="2")?.value,l=t.outcome==="win"?"W":t.outcome==="draw"?"D":"L";return{matchId:t.id,result:l,score:s&&a?`${s}-${a}`:void 0,opponent:{id:o.id,name:o.name,logo:o.display_asset?.url},date:new Date(t.start_time),competition:t.competition?{id:t.competition.id,name:t.competition.name}:void 0}}),formString:e.form.map(t=>t.outcome==="win"?"W":t.outcome==="draw"?"D":"L").join("")}:void 0,providerRef:r(e.uuid)}}function Ie(e){const t=e.player;return{id:t.id,name:t.name,slug:t.slug,position:t.position,shirtNumber:e.shirt_number,country:t.country?{id:t.country.id,name:t.country.name,code:t.country.code??void 0,flag:t.country.assets?.flag?.url,providerRef:r(t.country.uuid)}:void 0,gender:t.gender,birthdate:t.birthdate,profile:{height:t.profile?.height??void 0,weight:t.profile?.weight??void 0},assets:t.assets?{photo:t.assets.thumb?.url,photoTransparent:t.assets.thumb_transparent_background?.url}:void 0,status:e.status,contractType:e.contract_type,contractUntil:e.contract_until??void 0,joinedDate:e.start_date??void 0,providerRef:r(t.id)}}function Ae(e){return{id:e.id,name:e.name,slug:e.slug,country:e.country?{id:e.country.id,name:e.country.name,code:e.country.code??void 0,flag:e.country.assets?.flag?.url,providerRef:r(e.country.uuid)}:void 0,birthdate:e.birthdate,providerRef:r(e.uuid)}}function Oe(e){return{teamId:e.team.id,teamName:e.team.name,coach:e.coach?Ae(e.coach):void 0,players:e.players.map(Ie)}}function Ee(e){const t=parseInt(e,10);return isNaN(t)?void 0:t}function i(e,t){const n=e.find(o=>o.name===t);return n?Ee(n.value):void 0}function be(e,t){const n=e.statistics;return{playerId:e.player.id,seasonId:e.season.id,teamId:t,appearances:i(n,"played"),started:i(n,"started"),substituteIn:i(n,"substitute_in"),substituteOut:i(n,"substitute_out"),minutes:i(n,"minutes"),minutesSubstitute:i(n,"minutes_substitute"),goals:i(n,"goals"),goalsSubstitute:i(n,"goals_substitute"),penaltyGoals:i(n,"penalty_goals"),ownGoals:i(n,"own_goals"),assists:i(n,"assists"),shots:i(n,"shots"),shotsOnTarget:i(n,"shots_on_target"),yellowCards:i(n,"yellow_cards"),redCards:i(n,"red_cards"),foulsCommitted:i(n,"fouls_committed"),penaltiesCommitted:i(n,"penalties_committed"),penaltiesMissed:i(n,"penalties_missed"),cleansheets:i(n,"cleansheets"),saves:i(n,"saves"),conceded:i(n,"conceded"),caughtBall:i(n,"caught_ball"),penaltiesReceived:i(n,"penalties_received"),offsides:i(n,"offsides"),rawStatistics:n.map(o=>({name:o.name,value:o.value}))}}function Re(e){const t=e.statistics;return{playerId:e.player.id,seasonId:e.season.id,appearances:i(t,"played"),started:i(t,"started"),substituteIn:i(t,"substitute_in"),substituteOut:i(t,"substitute_out"),minutes:i(t,"minutes"),minutesSubstitute:i(t,"minutes_substitute"),goals:i(t,"goals"),goalsSubstitute:i(t,"goals_substitute"),penaltyGoals:i(t,"penalty_goals"),ownGoals:i(t,"own_goals"),assists:i(t,"assists"),shots:i(t,"shots"),shotsOnTarget:i(t,"shots_on_target"),yellowCards:i(t,"yellow_cards"),redCards:i(t,"red_cards"),foulsCommitted:i(t,"fouls_committed"),penaltiesCommitted:i(t,"penalties_committed"),penaltiesMissed:i(t,"penalties_missed"),cleansheets:i(t,"cleansheets"),saves:i(t,"saves"),conceded:i(t,"conceded"),caughtBall:i(t,"caught_ball"),penaltiesReceived:i(t,"penalties_received"),offsides:i(t,"offsides"),rawStatistics:t.map(n=>({name:n.name,value:n.value}))}}function u(e,t){if(!(e===void 0&&t===void 0))return(e??0)+(t??0)}function Le(e,t){return{playerId:e.playerId,seasonId:e.seasonId,appearances:u(e.appearances,t.appearances),started:u(e.started,t.started),substituteIn:u(e.substituteIn,t.substituteIn),substituteOut:u(e.substituteOut,t.substituteOut),minutes:u(e.minutes,t.minutes),minutesSubstitute:u(e.minutesSubstitute,t.minutesSubstitute),goals:u(e.goals,t.goals),goalsSubstitute:u(e.goalsSubstitute,t.goalsSubstitute),penaltyGoals:u(e.penaltyGoals,t.penaltyGoals),ownGoals:u(e.ownGoals,t.ownGoals),assists:u(e.assists,t.assists),shots:u(e.shots,t.shots),shotsOnTarget:u(e.shotsOnTarget,t.shotsOnTarget),yellowCards:u(e.yellowCards,t.yellowCards),redCards:u(e.redCards,t.redCards),foulsCommitted:u(e.foulsCommitted,t.foulsCommitted),penaltiesCommitted:u(e.penaltiesCommitted,t.penaltiesCommitted),penaltiesMissed:u(e.penaltiesMissed,t.penaltiesMissed),cleansheets:u(e.cleansheets,t.cleansheets),saves:u(e.saves,t.saves),conceded:u(e.conceded,t.conceded),caughtBall:u(e.caughtBall,t.caughtBall),penaltiesReceived:u(e.penaltiesReceived,t.penaltiesReceived),offsides:u(e.offsides,t.offsides),rawStatistics:[...e.rawStatistics??[],...t.rawStatistics??[]]}}async function x(e,t){const n=t||m(),{sportal365Sports:o}=n,{seasonIds:s,teamId:a,languageCode:l,next:d}=e,c=d??{revalidate:0},_={season_ids:s.join(","),team_id:a,language_code:l??o?.languageCode??"en"},g=await p.get({path:"/v2/statistics/players/season",params:_,headers:{"Accept-Language":l??o?.languageCode??"en"},next:c,config:n});if(!g.statistics)return console.error("[getFootballPlayerSeasonStatistics] Invalid API response - missing statistics array:",{teamId:a,seasonIds:s,response:g}),{};if(g.statistics.length===0)throw console.warn("[getFootballPlayerSeasonStatistics] API returned empty statistics array:",{teamId:a,seasonIds:s,hint:"This could be due to: wrong credentials, wrong project header, no data for this team/season, or API issue"}),new Error(`No player statistics found for team ${a} in seasons ${s.join(", ")}. This could be due to: wrong credentials, wrong X-Project header, or no data available for this team/season.`);const h={};for(const T of g.statistics){const S=T.player.id;h[S]=be(T,a)}return h}async function De(e,t){const n=t||m(),{sportal365Sports:o}=n,{playerIds:s,seasonIds:a,languageCode:l,next:d}=e,c=d??{revalidate:0},_={player_ids:s.join(","),season_ids:a.join(","),language_code:l??o?.languageCode??"en"},g=await p.get({path:"/v2/statistics/players/season",params:_,headers:{"Accept-Language":l??o?.languageCode??"en"},next:c,config:n});if(!g.statistics)return console.error("[getFootballPlayerSeasonStatisticsByPlayerIds] Invalid API response - missing statistics array:",{playerIds:s,seasonIds:a,response:g}),{};if(g.statistics.length===0)return{};const h={};for(const T of g.statistics){const S=T.player.id,f=Re(T);h[S]?h[S]=Le(h[S],f):h[S]=f}return h}async function ke(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/v2/teams/${e}`,params:{language_code:t?.languageCode??s?.languageCode??"en",optional_data:"form"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return Ce(a)}async function Ne(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=t?.seasonIds&&t.seasonIds.length>0?{revalidate:0}:t?.next,l=await p.get({path:`/v2/teams/${e}/squad`,params:{language_code:t?.languageCode??s?.languageCode??"en",memberStatus:t?.memberStatus??"ACTIVE"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:a,config:o}),d=Oe(l);if(t?.seasonIds&&t.seasonIds.length>0)try{const c=await x({seasonIds:t.seasonIds,teamId:e,languageCode:t.languageCode,next:t.next},o);for(const _ of d.players){const g=c[_.id];g&&(_.seasonStatistics=g)}}catch(c){console.error("[getFootballTeamSquad] Failed to fetch player statistics:",{error:c instanceof Error?c.message:String(c),stack:c instanceof Error?c.stack:void 0,teamId:e,seasonIds:t.seasonIds})}else console.warn("[getFootballTeamSquad] No seasonIds provided, skipping stats fetch");return d}function Fe(e){return{id:String(e.id),name:e.name,slug:e.slug,type:e.type,region:e.region,gender:e.gender,country:{id:String(e.country.id),name:e.country.name,flag:e.country.url_flag,providerRef:r(e.country.uuid)},seasons:e.seasons.map(t=>({id:String(t.id),name:t.name,slug:t.slug,active:t.active,providerRef:r(t.uuid)})),assets:e.url_logo?{logo:e.url_logo}:void 0,providerRef:r(e.uuid)}}function Pe(e){const t=e.rounds.map(n=>({id:n.id,name:n.name,key:n.key,type:n.type,status:n.status,startDate:n.start_date,endDate:n.end_date,providerRef:r(n.uuid)}));return{id:e.stage.id,name:e.stage.name,slug:e.stage.slug,shortName:e.stage.short_name??void 0,type:e.stage.type,status:e.stage.status,coverage:e.stage.coverage,order:e.stage.order_in_season,startDate:e.stage.start_date,endDate:e.stage.end_date,rounds:t,providerRef:r(e.stage.uuid)}}function Me(e){const{season:t,stages:n}=e,{tournament:o}=t,s={id:o.id,name:o.name,slug:o.slug,type:o.type,region:o.region,gender:o.gender,country:{id:o.country.id,name:o.country.name,code:o.country.code??void 0,flag:o.country.assets?.flag?.url,providerRef:r(o.country.uuid)},assets:o.assets?.logo?.url?{logo:o.assets.logo.url}:void 0,providerRef:r(o.uuid)};return{id:t.id,name:t.name,slug:t.slug,active:t.status==="ACTIVE",status:t.status==="ACTIVE"?"ACTIVE":"INACTIVE",competition:s,stages:n.map(Pe),providerRef:r(t.uuid)}}async function xe(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/tournaments/${e}`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return Fe(a)}async function Ue(e,t){const n=t||m(),{sportal365Sports:o}=n;if(!e?.seasonId&&!e?.competitionId)throw new Error("Either seasonId or competitionId must be provided");const s={language_code:e?.languageCode??o?.languageCode??"en"};e.seasonId?s.season_id=e.seasonId:e.competitionId&&(s.tournament_id=e.competitionId,e.status&&(s.status=e.status));const a=await p.get({path:"/v2/seasons/details",params:s,headers:{"Accept-Language":e?.languageCode??o?.languageCode??"en"},next:e?.next,config:n});return Me(a)}function E(e){return{championsleague:"championsLeague",europaleague:"europaLeague",conferenceleague:"conferenceLeague",relegation:"relegation",playoff:"playoff",promotion:"promotion"}[e.toLowerCase()]??e.toLowerCase().replace(/_/g,"")}function He(e){const t=e.toLowerCase();return t==="relegation"?"BOTTOM":t==="playoff"?"MIDDLE":"TOP"}function Be(e,t){if(!t||t.length===0)return;const n=t.map(s=>{const a=s.event,l=a.home_team.id===e,d=l?a.away_team:a.home_team,c=`${a.goal_home}-${a.goal_away}`;return{matchId:a.id.toString(),result:s.outcome,score:c,homeAway:l?"HOME":"AWAY",opponent:{id:d.id.toString(),name:d.name,logo:d.url_logo},date:new Date(a.start_time),competition:void 0}}),o=n.map(s=>s.result).join("");return{competitorId:e.toString(),results:n,formString:o}}function Ge(e){return{key:E(e.code),name:e.name,position:He(e.type)}}function $e(e){const t={played:e.played,won:e.wins,drawn:e.draws,lost:e.defeits,goalsFor:e.goals_for,goalsAgainst:e.goals_against,goalDifference:e.goals_for-e.goals_against,points:e.points},n=e.rules?.length>0?e.rules.map(s=>E(s.code)):void 0,o=Be(e.team.id,e.team.form??[]);return{rank:e.rank,competitor:{id:e.team.id.toString(),name:e.team.name,shortName:e.team.short_name??void 0,logo:e.team.url_logo,uuid:e.team.uuid},stats:t,form:o,rules:n}}function Ye(e){const t=e.map($e),n=new Map;for(const o of e)if(o.rules)for(const s of o.rules){const a=E(s.code);n.has(a)||n.set(a,Ge(s))}return{entries:t,metadata:{legend:Array.from(n.values())}}}async function Ve(e,t){const n=t||m(),{sportal365Sports:o}=n,s=e.expand?.join(","),a=await p.get({path:`/tournaments/seasons/stages/${e.stageId}/standing`,params:{expand:s,language_code:e.languageCode??o?.languageCode??"en"},headers:{"Accept-Language":e.languageCode??o?.languageCode??"en"},next:e.next,config:n});return!a||a.length===0?{entries:[],metadata:{legend:[]}}:Ye(a)}function U(e){return{id:e.id,name:e.name,code:e.country_code,assets:e.assets?.flag?{flag:e.assets.flag}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function We(e){return{id:e.id,name:e.name,type:e.type?.toUpperCase()||"LEAGUE",gender:e.gender?.toUpperCase(),country:e.country?U(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Ke(e){if(e.status){const a={notstarted:{code:"not_started",type:"NOT_STARTED",name:"Not Started"},live:{code:"live",type:"LIVE",name:"Live"},finished:{code:"finished",type:"FINISHED",name:"Finished"},postponed:{code:"postponed",type:"POSTPONED",name:"Postponed"},cancelled:{code:"cancelled",type:"CANCELLED",name:"Cancelled"},abandoned:{code:"abandoned",type:"ABANDONED",name:"Abandoned"}}[e.status.type];if(a)return a}let t="not_started",n="NOT_STARTED",o="Not Started";return e.finished_at?(t="finished",n="FINISHED",o="Finished"):e.started_at&&(t="live",n="LIVE",o="Live"),{code:t,name:o,type:n}}function je(e){return{kickoffTime:new Date(e.kickoff_at),currentMinute:e.minute??void 0,currentPeriod:void 0}}function F(e){return{id:e.id,name:e.name,shortName:e.short_name??void 0,fullName:e.full_name??void 0,threeLetterCode:e.code,type:e.national?"national":"club",gender:e.gender?.toUpperCase(),country:e.country?U(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function qe(e){if(!e)return;const t=o=>o?{competitorOne:o.home_goals!==null?String(o.home_goals):"0",competitorTwo:o.away_goals!==null?String(o.away_goals):"0"}:void 0,n=t(e.ft_score);if(n)return{competitorOne:n.competitorOne,competitorTwo:n.competitorTwo,breakdown:{total:n,halfTime:t(e.ht_score),regularTime:t(e.ft_score),extraTime:t(e.aet_score),penaltyShootout:t(e.pen_score)}}}function b(e){return{id:e.id,sport:e.sport??"football",status:Ke(e),timing:je(e),competitorOne:F(e.home_team),competitorTwo:F(e.away_team),score:qe(e.scores),competition:e.context?.competition?We(e.context.competition):void 0,lineupStatus:e.lineups_confirmed?"CONFIRMED":"NOT_AVAILABLE",updatedAt:e.updated_at?new Date(e.updated_at):void 0,isUndecided:e.undecided??void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Xe(e){return b(e.data)}function ze(e){return e.data.map(b)}function Je(e){return e.map(b)}async function H(e,t,n){const o=await e.loyalty.getTemplateMatches(t,n?.groupId,n?.disableCache);return Je(o)}async function Qe(e,t,n,o){return(await H(e,t,o)).filter(a=>a.competitorOne.id===n||a.competitorTwo.id===n)}async function Ze(e,t,n){const o=await e.loyalty.getTemplateById(t,n?.disableCache);return{id:o.id,name:o.name,description:o.description,type:o.type,fromDate:o.fromDate,toDate:o.toDate,markets:o.markets||[],teamIds:o.teamIds||[],matchIds:o.matchIds||[],groups:(o.groups||[]).map(a=>({groupId:a.groupId,label:a.label,flags:a.flags||[],filters:{fromDate:a.filters?.fromDate||"",toDate:a.filters?.toDate||"",matchIds:a.filters?.matchIds||[]}})),gameIds:o.gameIds||[],gameTypes:o.gameTypes||[],competitionIds:o.competitionIds||[],excludedProfileIds:o.excludedProfileIds||[],rules:o.rules||"",labels:o.labels||{},customFields:o.customFields||{},branding:o.branding?JSON.parse(JSON.stringify(o.branding)):{},brandingId:null,flags:o.flags||[],images:{main:o.images?.main||null,cover:o.images?.cover||null,mobile:o.images?.mobile||null},status:o.status,automaticallyChangeStatus:o.automaticallyChangeStatus||!1,createdAt:o.createdAt,updatedAt:o.updatedAt,related:o.related||[],adContent:o.adContent||""}}function we(e){return{"1x2":"1X2",12:"12",OVER_UNDER:"OVER_UNDER",DOUBLE_CHANCE:"DOUBLE_CHANCE",BOTH_TO_SCORE:"BOTH_TO_SCORE",DRAW_NO_BET:"DRAW_NO_BET",FIRST_TEAM_TO_SCORE:"FIRST_TEAM_TO_SCORE",CORRECT_SCORE:"CORRECT_SCORE",FIRST_HALF_GOALS:"FIRST_HALF_GOALS",FIRST_PLAYER_TO_SCORE:"FIRST_PLAYER_TO_SCORE",PLAYER_TO_SCORE_DURING_GAME:"PLAYER_TO_SCORE_DURING_GAME",PLAYER_TO_RECEIVE_CARD:"PLAYER_TO_RECEIVE_CARD",FIRST_HALF_AND_FINAL_RESULT:"FIRST_HALF_AND_FINAL_RESULT"}[e]||e.toUpperCase()}function et(e,t){const n=new Map;return e.forEach((o,s)=>{if(!o||o.length===0)return;const l=(t?o.filter(d=>d.bookmaker&&t.includes(d.bookmaker.id)):o).filter(d=>d.bookmaker&&d.markets&&d.markets.length>0).map(d=>{const c=d.bookmaker,_=c.assets?.[0],g=c.branding?.backgroundColor||_?.backgroundColor,h=c.branding?.textColor||(tt(g)?"#FFFFFF":"#000000"),T=_?.transparentBackgroundUrl||_?.logo,S=c.eventUrls?.find(f=>f.appType==="desktop")?.url||c.links?.find(f=>f.appType==="desktop")?.homepageUrl||c.url||"";return{operator:{id:c.id,name:c.name,url:S,branding:{backgroundColor:g,textColor:h,logo:T}},type:d.type,markets:d.markets.map(f=>({type:{id:f.type.id,code:f.type.code,name:f.type.name},period:{id:f.scope.id,type:f.scope.type,name:f.scope.name},selections:f.selections.map(v=>{const B=v.urls?.find(G=>G.appType==="desktop")?.url;let I="NONE";return v.movement==="UP"?I="UP":v.movement==="DOWN"&&(I="DOWN"),{id:v.id,name:v.name,code:v.code,value:v.value,odds:v.odds,oddsOld:v.oddsOld,movement:I,url:B,providerSelectionId:v.providerInfo?.selectionId}})}))}});n.set(s,l)}),n}function tt(e){if(!e)return!0;const t=e.replace("#",""),n=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return(.2126*n+.7152*o+.0722*s)/255<.5}async function ot(e,t,n){if(!t||t.length===0)return new Map;const o={oddType:n?.oddType||"ALL",scopeType:n?.scopeType||"ORDINARY_TIME",oddFormat:n?.oddFormat||"DECIMAL"};n?.marketTypes&&n.marketTypes.length>0&&(o.marketTypes=n.marketTypes.map(a=>we(a)));const s=await e.odds.getByMatchIds(t,o);return et(s,n?.bookmakerIds)}exports.SPORTAL365_BASKETBALL_DOMAIN=W;exports.SPORTAL365_SPORTS_SEARCH_DOMAIN=q;exports.SPORTAL365_STANDINGS_DOMAIN=X;exports.SPORTAL365_STATISTICS_DOMAIN=j;exports.SPORTAL365_TENNIS_DOMAIN=K;exports.addProviderRef=Q;exports.createHttpClient=P;exports.footballHttp=p;exports.getBatchMatchOdds=ot;exports.getConfig=m;exports.getFootballCompetition=xe;exports.getFootballLivescore=Te;exports.getFootballMatch=pe;exports.getFootballMatchCommentary=ve;exports.getFootballMatchEvents=fe;exports.getFootballMatchLineups=_e;exports.getFootballMatchOdds=ye;exports.getFootballMatchStatistics=he;exports.getFootballMatches=Se;exports.getFootballPlayerSeasonStatistics=x;exports.getFootballPlayerSeasonStatisticsByPlayerIds=De;exports.getFootballSeasonDetails=Ue;exports.getFootballStandings=Ve;exports.getFootballTeam=ke;exports.getFootballTeamSquad=Ne;exports.getLeaderboardMatches=H;exports.getLeaderboardTeamMatches=Qe;exports.getLeaderboardTemplate=Ze;exports.getProviderRefId=J;exports.isConfigured=Y;exports.setConfig=$;exports.toProviderRefArray=r;exports.transformMatch=Xe;exports.transformMatches=ze;exports.transformOdds=M;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "A TypeScript library for fetching and transforming sports data from multiple API providers. Returns clean, canonical types that are provider-agnostic.",
5
5
  "homepage": "https://fansunited.com/",
6
6
  "private": false,
7
- "version": "0.12.0",
7
+ "version": "0.12.1",
8
8
  "type": "module",
9
9
  "main": "./fansunited-data-layer.cjs",
10
10
  "module": "./fansunited-data-layer.js",
@@ -30,6 +30,7 @@ export interface FUSportsOddSelection {
30
30
  oddsOld?: string;
31
31
  movement?: "UP" | "DOWN" | "NONE";
32
32
  url?: string;
33
+ providerSelectionId?: string;
33
34
  }
34
35
  /**
35
36
  * Market period (e.g., full time, first half)
@@ -1 +1 @@
1
- {"version":3,"file":"odds.types.d.ts","sourceRoot":"","sources":["../../../src/lib/types/canonical/odds.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,+BAA+B,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;IAC3B,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,2BAA2B,EAAE,CAAC;CAC5C;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,GAAG,CAAC,MAAM,EAAE,2BAA2B,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"odds.types.d.ts","sourceRoot":"","sources":["../../../src/lib/types/canonical/odds.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,+BAA+B,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;IAC3B,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,2BAA2B,EAAE,CAAC;CAC5C;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,GAAG,CAAC,MAAM,EAAE,2BAA2B,EAAE,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- "use strict";const A="__FANSUNITED_DATA_LAYER_CONFIG__";function $(e){globalThis[A]=e}function m(){const e=globalThis[A];if(!e)throw new Error("Data layer config not initialized. Call setConfig() in your root layout.");return e}function Y(){return globalThis[A]!==void 0}function P(e){const t=e.replace(/\/$/,"");function n(s){const{sportal365Sports:a}=s;if(!a)throw new Error("Sportal365 Sports API configuration is missing");const l=`${a.username}:${a.password}`;return`Basic ${btoa(l)}`}function o(s){return`${t}${s}`}return{async get(s){const a=s.config||m(),{sportal365Sports:l}=a;if(!l)throw new Error("Sportal365 Sports API configuration is missing");const d=new URL(o(s.path));if(s.params)for(const[_,g]of Object.entries(s.params))g!==void 0&&(Array.isArray(g)?g.length>0&&d.searchParams.set(_,g.join(",")):d.searchParams.set(_,g));const c=await fetch(d.toString(),{method:"GET",headers:{Authorization:n(a),"Content-Type":"application/json","X-Project":l.projectId,...s.headers},signal:l.timeout?AbortSignal.timeout(l.timeout):void 0,...s.next&&{next:s.next}});if(!c.ok)throw new Error(`Sportal365 API error: ${c.status} ${c.statusText}`);return c.json()}}}const V="https://football.api.sportal365.com",W="https://basketball.api.sportal365.com",K="https://tennis.api.sportal365.com",j="https://sports-statistics.api.sportal365.com",q="https://sports-search.api.sportal365.com",X="https://standing.api.sportal365.com",p=P(V);function R(e){if(e)return{id:e.id,name:e.name,slug:e.slug,position:e.position,gender:e.gender,assets:e.assets?{photo:e.assets.thumb?.url,photoTransparent:e.assets.thumb_transparent_background?.url}:void 0}}const z={GOAL:"GOAL",PENALTY_GOAL:"PENALTY_GOAL",OWN_GOAL:"OWN_GOAL",DISALLOWED_GOAL:"DISALLOWED_GOAL",PENALTY_SHOOTOUT_SCORED:"PENALTY_SHOOTOUT_SCORED",PENALTY_SHOOTOUT_MISSED:"PENALTY_SHOOTOUT_MISSED",YELLOW_CARD:"YELLOW_CARD",RED_CARD:"RED_CARD",YELLOW_RED_CARD:"YELLOW_RED_CARD",SUBSTITUTION:"SUBSTITUTION",KICKOFF:"KICKOFF",HALFTIME:"HALFTIME",START_SECOND_HALF:"START_SECOND_HALF",FINISHED:"FINISHED",INJURY_TIME:"INJURY_TIME",PENALTY_AWARDED:"PENALTY_AWARDED",PENALTY_MISSED:"PENALTY_MISSED",PENALTY_SAVED:"PENALTY_SAVED"};function C(e){const t=z[e.type_code];return t?{id:e.id,type:t,competitorPosition:e.team_position==="HOME"?"ONE":"TWO",minute:e.minute,injuryMinute:e.injury_minute,primaryPlayer:R(e.primary_player),secondaryPlayer:R(e.secondary_player),score:e.score?{competitorOne:String(e.score.home),competitorTwo:String(e.score.away)}:void 0}:(console.warn(`Unknown event type: ${e.type_code}`),null)}function r(e,t="sportal365"){if(e)return[{provider:t,id:e}]}function J(e,t){return e?e.find(o=>o.provider===t)?.id:void 0}function Q(e,t,n){const o=e??[],s=o.findIndex(a=>a.provider===t);if(s>=0){const a=[...o];return a[s]={provider:t,id:n},a}else return[...o,{provider:t,id:n}]}function Z(e){const t=e.urls?.find(n=>n.app_type==="desktop")?.url;return{id:e.id,name:e.name,code:e.code,value:e.value??void 0,odds:e.odds,oddsOld:e.odds_old,movement:e.movement==="STABLE"?"NONE":e.movement,url:t}}function w(e){return{type:{id:e.type.id,code:e.type.code,name:e.type.name},period:{id:e.scope.id,type:e.scope.type,name:e.scope.name},selections:e.selections.map(Z)}}function ee(e){if(!e)return!0;const t=e.replace("#",""),n=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return(.2126*n+.7152*o+.0722*s)/255<.5}function te(e){const t=e.bookmaker.assets?.[0],n=e.bookmaker.branding||t,o=e.bookmaker.branding?.background_color||t?.background_color,s=e.bookmaker.branding?.text_color||(ee(o)?"#FFFFFF":"#000000");return{operator:{id:e.bookmaker.id,name:e.bookmaker.name,url:e.bookmaker.url,branding:n?{backgroundColor:o,textColor:s,logo:t?.logo}:void 0},type:e.type,markets:e.markets.map(w)}}function M(e){return e.map(te)}function oe(e){const t={finished_ap:"finished_after_penalties",finished_aet:"finished_after_extra_time",finished:"finished",not_started:"not_started",live:"live",interrupted:"interrupted",cancelled:"cancelled",postponed:"postponed",abandoned:"abandoned"};let n;return e.code&&t[e.code]?n=t[e.code]:n={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed",UNKNOWN:"not_started",ABANDONED:"abandoned"}[e.type]??"not_started",{code:n,name:e.name,shortName:e.short_name,type:e.type}}function L(e){return{id:e.id,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code,slug:e.slug,type:e.type==="national"?"national":"club",gender:e.gender,assets:e.assets?{logo:e.assets.logo?.url,homeKit:e.assets.home_kit?.url,awayKit:e.assets.away_kit?.url,squadImage:e.assets.squad_image?.url}:void 0,metadata:e.shirt_color?{shirtColors:[{type:"home",colorCode:e.shirt_color}]}:void 0,providerRef:r(e.uuid)}}function ne(e){return{kickoffTime:new Date(e.kickoff_time),currentMinute:e.minute?.regular_time,phaseStartedAt:e.phase_started_at?new Date(e.phase_started_at):void 0,finishedAt:e.finished_at?new Date(e.finished_at):void 0,firstHalfStartedAt:e.first_half_started_at?new Date(e.first_half_started_at):void 0,secondHalfStartedAt:e.second_half_started_at?new Date(e.second_half_started_at):void 0,extraTimeFirstHalfStartedAt:e.extra_time_first_half_started_at?new Date(e.extra_time_first_half_started_at):void 0,extraTimeSecondHalfStartedAt:e.extra_time_second_half_started_at?new Date(e.extra_time_second_half_started_at):void 0}}function se(e){if(!e)return;const t=o=>o?{competitorOne:String(o.home),competitorTwo:String(o.away)}:void 0,n=e.after_extra_time??e.regular_time;return{competitorOne:n?.home!=null?String(n.home):null,competitorTwo:n?.away!=null?String(n.away):null,breakdown:{total:t(e.total),halfTime:t(e.half_time),regularTime:t(e.regular_time),extraTime:t(e.extra_time),penaltyShootout:t(e.penalty_shootout),aggregate:t(e.aggregate)}}}function ae(e){if(e)return{id:e.id,name:e.name,slug:e.slug,assets:e.assets?.image?.url?{image:e.assets.image.url}:void 0,providerRef:r(e.uuid)}}function ie(e){if(e?.length)return e.map(t=>({id:t.id,name:t.name,slug:t.slug,role:t.role??"REFEREE",gender:t.gender}))}function re(e){if(!e.season?.tournament)return;const{tournament:t,...n}=e.season;return{id:t.id,name:t.name,slug:t.slug,type:t.type,region:t.region,country:t.country?{id:t.country.id,name:t.country.name,code:t.country.code??void 0,flag:t.country.assets?.flag?.url,providerRef:r(t.country.uuid)}:void 0,season:{id:n.id,name:n.name,status:n.status},stage:e.stage?{id:e.stage.id,name:e.stage.name,type:e.stage.type}:void 0,assets:t.assets?.logo?.url?{logo:t.assets.logo.url}:void 0,providerRef:r(t.uuid)}}function de(e){if(!e.winner?.match?.id)return;const t={"Regular Time":"REGULAR_TIME","Extra Time":"EXTRA_TIME",Penalties:"PENALTIES"};return{competitorId:e.winner.match.id,reason:e.winner.match.reason?.name?t[e.winner.match.reason.name]:void 0,aggregate:!!e.winner.aggregate}}function O(e){return{id:e.id,slug:e.slug,sport:"football",status:oe(e.status),timing:ne(e),competitorOne:L(e.home_team),competitorTwo:L(e.away_team),competition:re(e),round:e.round?{id:e.round.id??e.round.key,key:e.round.key,name:e.round.name,type:e.round.type??"REGULAR",providerRef:r(e.round.uuid)}:void 0,group:e.group?{id:e.group.id,name:e.group.name,providerRef:r(e.group.uuid)}:void 0,venue:ae(e.venue),officials:ie(e.referees),spectators:e.spectators??void 0,score:se(e.score),mainEvents:e.main_events?.map(C).filter(t=>t!==null),penaltyShootoutEvents:e.penalty_shootout_events?.map(C).filter(t=>t!==null),winner:de(e),coverage:e.coverage==="NOT_LIVE"?"UNKNOWN":e.coverage,lineupStatus:e.lineup_status==="UNCONFIRMED"?"EXPECTED":e.lineup_status,providerRef:r(e.uuid)}}function ce(e){const t=e.player;return{id:t.id,name:t.name,slug:t.slug,position:t.position,shirtNumber:e.shirt_number,positionX:e.position_x??void 0,positionY:e.position_y??void 0,country:t.country?{id:t.country.id,name:t.country.name,code:t.country.code,providerRef:r(t.country.uuid)}:void 0,birthdate:t.birthdate,profile:t.profile?{height:t.profile.height,weight:t.profile.weight}:void 0,assets:t.assets?{photo:t.assets.thumb?.url,photoTransparent:t.assets.thumb_transparent_background?.url}:void 0,events:e.events?.map(C).filter(n=>n!==null),providerRef:r(t.uuid)}}function D(e){const t=[],n=[];for(const o of e.players){const s=ce(o);o.type.category==="start"?t.push(s):o.type.category==="sub"&&n.push(s)}return{competitorId:e.team_id,formation:e.formation,coach:e.coach?{id:e.coach.id,name:e.coach.name,slug:e.coach.slug,country:e.coach.country?{id:e.coach.country.id,name:e.coach.country.name,code:e.coach.country.code,providerRef:r(e.coach.country.uuid)}:void 0,birthdate:e.coach.birthdate,providerRef:r(e.coach.uuid)}:void 0,starters:t,substitutes:n}}function ue(e){return{matchId:e.match_id,confirmed:e.status==="CONFIRMED",competitorOne:D(e.home_team),competitorTwo:D(e.away_team)}}function y(e,t,n,o){return t==null?null:{key:e,value:String(t),label:n,unit:o}}function k(e,t){const n=(t.shots_on??0)+(t.shots_off??0)+(t.shots_blocked??0),o=[y("possession",t.possession,"Possession","%"),y("shots_total",n,"Shots"),y("shots_on_target",t.shots_on,"Shots on Target"),y("shots_off_target",t.shots_off,"Shots off Target"),y("shots_blocked",t.shots_blocked,"Shots Blocked"),y("corners",t.corners,"Corner Kicks"),y("goal_kicks",t.goal_kicks,"Goal Kicks"),y("throw_ins",t.throw_in,"Throw Ins"),y("offsides",t.offside,"Offsides"),y("fouls",t.fouls_committed,"Fouls"),y("yellow_cards",t.yellow_cards,"Yellow Cards"),y("passes",t.pass,"Passes"),y("crosses",t.crosses,"Crosses")];return{competitorId:e,statistics:o.filter(s=>s!==null)}}function le(e){const t=e.find(o=>o.home_team),n=e.find(o=>!o.home_team);if(!t||!n)throw new Error("Missing competitor statistics");return{competitorOne:k(String(t.team.id),t.statistics),competitorTwo:k(String(n.team.id),n.statistics)}}function ge(e,t){return{matchId:e,operators:M(t)}}function N(e){if(e==null||e==="")return;const t=typeof e=="number"?e:parseInt(e,10);return isNaN(t)?void 0:t}function me(e){return{externalId:e.external_id,minute:N(e.elapsed),addedTime:N(e.elapsed_plus),text:e.auto_text,details:e.details,meta:{type:e.type,commentaryType:e.commentary_type,subtype1:e.subtype_1,subtype2:e.subtype_2,timestamp:e.incident_timestamp}}}async function pe(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/v2/matches/${e}`,params:{language_code:t?.languageCode??s?.languageCode??"en",odd_client:t?.oddClient,odd_type:t?.oddType,scope_type:t?.scopeType,odd_format:t?.oddFormat,market_types:t?.marketTypes,bookmaker_ids:t?.bookmakerIds,optional_data:t?.optionalData},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return O(a)}async function fe(e,t,n){const o=n||m(),{sportal365Sports:s}=o;return(await p.get({path:`/v2/matches/${e}/events`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o})).events.map(C).filter(l=>l!==null)}async function _e(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/v2/matches/${e}/lineups`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return ue(a)}async function ye(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/v2/matches/${e}`,params:{language_code:t?.languageCode??s?.languageCode??"en",odd_client:t?.oddClient??s?.oddClient,odd_type:t?.oddType,scope_type:t?.scopeType??"ALL",odd_format:t?.oddFormat??"DECIMAL",market_types:t?.marketTypes,bookmaker_ids:t?.bookmakerIds},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return ge(e,a.odds??[])}async function he(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/events/${e}/teamstats`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return le(a)}async function ve(e,t,n){const o=n||m(),{sportal365Sports:s}=o;return(await p.get({path:`/matches/${e}/commentary`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o})).map(me)}async function Se(e,t){const n=t||m(),{sportal365Sports:o}=n;return(await p.get({path:"/v2/matches",params:{language_code:e.languageCode??o?.languageCode??"en",limit:e.limit.toString(),offset:e.offset.toString(),tournament_ids:e.tournamentIds,season_ids:e.seasonIds,stage_ids:e.stageIds,group_ids:e.groupIds,round_ids:e.roundIds,round_filter:e.roundFilter,from_kickoff_time:e.fromKickoffTime,to_kickoff_time:e.toKickoffTime,team_ids:e.teamIds,team_ids_operator:e.teamIdsOperator,referee_id:e.refereeId,venue_id:e.venueId,player_id:e.playerId,status_types:e.statusTypes,status_codes:e.statusCodes,odd_client:e.oddClient??o?.oddClient,odd_type:e.oddType,scope_type:e.scopeType,odd_format:e.oddFormat,market_types:e.marketTypes,bookmaker_ids:e.bookmakerIds,sort_direction:e.sortDirection,optional_data:e.optionalData},headers:{"Accept-Language":e.languageCode??o?.languageCode??"en"},next:e.next,config:n})).matches.map(O)}async function Te(e,t){const n=t||m(),{sportal365Sports:o}=n;return(await p.get({path:"/v2/matches/livescore",params:{match_ids:e?.matchIds,date:e?.date,utc_offset:e?.utcOffset?.toString(),tournament_group:e?.tournamentGroup,status_types:e?.statusTypes,selection_filter:e?.selectionFilter,language_code:e?.languageCode??o?.languageCode??"en",odd_client:e?.oddClient??o?.oddClient,odd_type:e?.oddType,scope_type:e?.scopeType,odd_format:e?.oddFormat,market_types:e?.marketTypes,optional_data:e?.optionalData},headers:{"Accept-Language":e?.languageCode??o?.languageCode??"en"},next:e?.next,config:n})).matches.map(O)}function Ce(e){return{id:e.id,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code,slug:e.slug,type:e.type==="placeholder"||e.type==="club"?"club":"national",gender:e.gender,country:e.country?{id:e.country.id,name:e.country.name,code:e.country.code??void 0,flag:e.country.assets?.flag?.url,providerRef:r(e.country.uuid)}:void 0,venue:e.venue?{id:e.venue.id,name:e.venue.name,slug:e.venue.slug,city:e.venue.city?{id:e.venue.city.id,name:e.venue.city.name,country:e.venue.city.country?{id:e.venue.city.country.id,name:e.venue.city.country.name,code:e.venue.city.country.code??void 0,flag:e.venue.city.country.assets?.flag?.url,providerRef:r(e.venue.city.country.uuid)}:void 0,providerRef:r(e.venue.city.uuid??void 0)}:void 0,country:e.venue.country?{id:e.venue.country.id,name:e.venue.country.name,code:e.venue.country.code??void 0,flag:e.venue.country.assets?.flag?.url,providerRef:r(e.venue.country.uuid)}:void 0,profile:e.venue.profile?{latitude:e.venue.profile.lat,longitude:e.venue.profile.lng,capacity:e.venue.profile.capacity}:void 0,assets:e.venue.assets?.image?.url?{image:e.venue.assets.image.url}:void 0,providerRef:r(e.venue.uuid)}:void 0,coach:e.coach?{id:e.coach.id,name:e.coach.name,slug:e.coach.slug,country:{id:e.coach.country.id,name:e.coach.country.name,code:e.coach.country.code??void 0,flag:e.coach.country.assets?.flag?.url,providerRef:r(e.coach.country.uuid)},birthdate:e.coach.birthdate,providerRef:r(e.coach.uuid)}:void 0,founded:e.founded,assets:e.assets?{logo:e.assets.logo?.url,homeKit:e.assets.home_kit?.url,awayKit:e.assets.away_kit?.url,squadImage:e.assets.squad_image?.url}:void 0,metadata:{shirtColors:e.shirt_colors?.map(t=>({type:t.type,colorCode:t.color_code})),socials:e.social?{website:e.social.web,x:e.social.twitter_id,facebook:e.social.facebook_id,instagram:e.social.instagram_id,wikipedia:e.social.wikipedia_id}:void 0},activeSeasons:e.active_seasons?.map(t=>({id:t.id,name:t.name,slug:t.slug,active:t.status==="ACTIVE",providerRef:r(t.uuid)})),currentSeason:e.current_season?{id:e.current_season.id,name:e.current_season.name,slug:e.current_season.slug,active:e.current_season.status==="ACTIVE",providerRef:r(e.current_season.uuid)}:void 0,form:e.form&&e.form.length>0?{competitorId:e.id,results:e.form.map(t=>{const o=t.participants[0].id===e.uuid?t.participants[1]:t.participants[0],s=t.result[0]?.results.find(d=>d.position==="1")?.value,a=t.result[0]?.results.find(d=>d.position==="2")?.value,l=t.outcome==="win"?"W":t.outcome==="draw"?"D":"L";return{matchId:t.id,result:l,score:s&&a?`${s}-${a}`:void 0,opponent:{id:o.id,name:o.name,logo:o.display_asset?.url},date:new Date(t.start_time),competition:t.competition?{id:t.competition.id,name:t.competition.name}:void 0}}),formString:e.form.map(t=>t.outcome==="win"?"W":t.outcome==="draw"?"D":"L").join("")}:void 0,providerRef:r(e.uuid)}}function Ie(e){const t=e.player;return{id:t.id,name:t.name,slug:t.slug,position:t.position,shirtNumber:e.shirt_number,country:t.country?{id:t.country.id,name:t.country.name,code:t.country.code??void 0,flag:t.country.assets?.flag?.url,providerRef:r(t.country.uuid)}:void 0,gender:t.gender,birthdate:t.birthdate,profile:{height:t.profile?.height??void 0,weight:t.profile?.weight??void 0},assets:t.assets?{photo:t.assets.thumb?.url,photoTransparent:t.assets.thumb_transparent_background?.url}:void 0,status:e.status,contractType:e.contract_type,contractUntil:e.contract_until??void 0,joinedDate:e.start_date??void 0,providerRef:r(t.id)}}function Ae(e){return{id:e.id,name:e.name,slug:e.slug,country:e.country?{id:e.country.id,name:e.country.name,code:e.country.code??void 0,flag:e.country.assets?.flag?.url,providerRef:r(e.country.uuid)}:void 0,birthdate:e.birthdate,providerRef:r(e.uuid)}}function Oe(e){return{teamId:e.team.id,teamName:e.team.name,coach:e.coach?Ae(e.coach):void 0,players:e.players.map(Ie)}}function Ee(e){const t=parseInt(e,10);return isNaN(t)?void 0:t}function i(e,t){const n=e.find(o=>o.name===t);return n?Ee(n.value):void 0}function be(e,t){const n=e.statistics;return{playerId:e.player.id,seasonId:e.season.id,teamId:t,appearances:i(n,"played"),started:i(n,"started"),substituteIn:i(n,"substitute_in"),substituteOut:i(n,"substitute_out"),minutes:i(n,"minutes"),minutesSubstitute:i(n,"minutes_substitute"),goals:i(n,"goals"),goalsSubstitute:i(n,"goals_substitute"),penaltyGoals:i(n,"penalty_goals"),ownGoals:i(n,"own_goals"),assists:i(n,"assists"),shots:i(n,"shots"),shotsOnTarget:i(n,"shots_on_target"),yellowCards:i(n,"yellow_cards"),redCards:i(n,"red_cards"),foulsCommitted:i(n,"fouls_committed"),penaltiesCommitted:i(n,"penalties_committed"),penaltiesMissed:i(n,"penalties_missed"),cleansheets:i(n,"cleansheets"),saves:i(n,"saves"),conceded:i(n,"conceded"),caughtBall:i(n,"caught_ball"),penaltiesReceived:i(n,"penalties_received"),offsides:i(n,"offsides"),rawStatistics:n.map(o=>({name:o.name,value:o.value}))}}function Re(e){const t=e.statistics;return{playerId:e.player.id,seasonId:e.season.id,appearances:i(t,"played"),started:i(t,"started"),substituteIn:i(t,"substitute_in"),substituteOut:i(t,"substitute_out"),minutes:i(t,"minutes"),minutesSubstitute:i(t,"minutes_substitute"),goals:i(t,"goals"),goalsSubstitute:i(t,"goals_substitute"),penaltyGoals:i(t,"penalty_goals"),ownGoals:i(t,"own_goals"),assists:i(t,"assists"),shots:i(t,"shots"),shotsOnTarget:i(t,"shots_on_target"),yellowCards:i(t,"yellow_cards"),redCards:i(t,"red_cards"),foulsCommitted:i(t,"fouls_committed"),penaltiesCommitted:i(t,"penalties_committed"),penaltiesMissed:i(t,"penalties_missed"),cleansheets:i(t,"cleansheets"),saves:i(t,"saves"),conceded:i(t,"conceded"),caughtBall:i(t,"caught_ball"),penaltiesReceived:i(t,"penalties_received"),offsides:i(t,"offsides"),rawStatistics:t.map(n=>({name:n.name,value:n.value}))}}function u(e,t){if(!(e===void 0&&t===void 0))return(e??0)+(t??0)}function Le(e,t){return{playerId:e.playerId,seasonId:e.seasonId,appearances:u(e.appearances,t.appearances),started:u(e.started,t.started),substituteIn:u(e.substituteIn,t.substituteIn),substituteOut:u(e.substituteOut,t.substituteOut),minutes:u(e.minutes,t.minutes),minutesSubstitute:u(e.minutesSubstitute,t.minutesSubstitute),goals:u(e.goals,t.goals),goalsSubstitute:u(e.goalsSubstitute,t.goalsSubstitute),penaltyGoals:u(e.penaltyGoals,t.penaltyGoals),ownGoals:u(e.ownGoals,t.ownGoals),assists:u(e.assists,t.assists),shots:u(e.shots,t.shots),shotsOnTarget:u(e.shotsOnTarget,t.shotsOnTarget),yellowCards:u(e.yellowCards,t.yellowCards),redCards:u(e.redCards,t.redCards),foulsCommitted:u(e.foulsCommitted,t.foulsCommitted),penaltiesCommitted:u(e.penaltiesCommitted,t.penaltiesCommitted),penaltiesMissed:u(e.penaltiesMissed,t.penaltiesMissed),cleansheets:u(e.cleansheets,t.cleansheets),saves:u(e.saves,t.saves),conceded:u(e.conceded,t.conceded),caughtBall:u(e.caughtBall,t.caughtBall),penaltiesReceived:u(e.penaltiesReceived,t.penaltiesReceived),offsides:u(e.offsides,t.offsides),rawStatistics:[...e.rawStatistics??[],...t.rawStatistics??[]]}}async function x(e,t){const n=t||m(),{sportal365Sports:o}=n,{seasonIds:s,teamId:a,languageCode:l,next:d}=e,c=d??{revalidate:0},_={season_ids:s.join(","),team_id:a,language_code:l??o?.languageCode??"en"},g=await p.get({path:"/v2/statistics/players/season",params:_,headers:{"Accept-Language":l??o?.languageCode??"en"},next:c,config:n});if(!g.statistics)return console.error("[getFootballPlayerSeasonStatistics] Invalid API response - missing statistics array:",{teamId:a,seasonIds:s,response:g}),{};if(g.statistics.length===0)throw console.warn("[getFootballPlayerSeasonStatistics] API returned empty statistics array:",{teamId:a,seasonIds:s,hint:"This could be due to: wrong credentials, wrong project header, no data for this team/season, or API issue"}),new Error(`No player statistics found for team ${a} in seasons ${s.join(", ")}. This could be due to: wrong credentials, wrong X-Project header, or no data available for this team/season.`);const h={};for(const T of g.statistics){const S=T.player.id;h[S]=be(T,a)}return h}async function De(e,t){const n=t||m(),{sportal365Sports:o}=n,{playerIds:s,seasonIds:a,languageCode:l,next:d}=e,c=d??{revalidate:0},_={player_ids:s.join(","),season_ids:a.join(","),language_code:l??o?.languageCode??"en"},g=await p.get({path:"/v2/statistics/players/season",params:_,headers:{"Accept-Language":l??o?.languageCode??"en"},next:c,config:n});if(!g.statistics)return console.error("[getFootballPlayerSeasonStatisticsByPlayerIds] Invalid API response - missing statistics array:",{playerIds:s,seasonIds:a,response:g}),{};if(g.statistics.length===0)return{};const h={};for(const T of g.statistics){const S=T.player.id,f=Re(T);h[S]?h[S]=Le(h[S],f):h[S]=f}return h}async function ke(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/v2/teams/${e}`,params:{language_code:t?.languageCode??s?.languageCode??"en",optional_data:"form"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return Ce(a)}async function Ne(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=t?.seasonIds&&t.seasonIds.length>0?{revalidate:0}:t?.next,l=await p.get({path:`/v2/teams/${e}/squad`,params:{language_code:t?.languageCode??s?.languageCode??"en",memberStatus:t?.memberStatus??"ACTIVE"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:a,config:o}),d=Oe(l);if(t?.seasonIds&&t.seasonIds.length>0)try{const c=await x({seasonIds:t.seasonIds,teamId:e,languageCode:t.languageCode,next:t.next},o);for(const _ of d.players){const g=c[_.id];g&&(_.seasonStatistics=g)}}catch(c){console.error("[getFootballTeamSquad] Failed to fetch player statistics:",{error:c instanceof Error?c.message:String(c),stack:c instanceof Error?c.stack:void 0,teamId:e,seasonIds:t.seasonIds})}else console.warn("[getFootballTeamSquad] No seasonIds provided, skipping stats fetch");return d}function Fe(e){return{id:String(e.id),name:e.name,slug:e.slug,type:e.type,region:e.region,gender:e.gender,country:{id:String(e.country.id),name:e.country.name,flag:e.country.url_flag,providerRef:r(e.country.uuid)},seasons:e.seasons.map(t=>({id:String(t.id),name:t.name,slug:t.slug,active:t.active,providerRef:r(t.uuid)})),assets:e.url_logo?{logo:e.url_logo}:void 0,providerRef:r(e.uuid)}}function Pe(e){const t=e.rounds.map(n=>({id:n.id,name:n.name,key:n.key,type:n.type,status:n.status,startDate:n.start_date,endDate:n.end_date,providerRef:r(n.uuid)}));return{id:e.stage.id,name:e.stage.name,slug:e.stage.slug,shortName:e.stage.short_name??void 0,type:e.stage.type,status:e.stage.status,coverage:e.stage.coverage,order:e.stage.order_in_season,startDate:e.stage.start_date,endDate:e.stage.end_date,rounds:t,providerRef:r(e.stage.uuid)}}function Me(e){const{season:t,stages:n}=e,{tournament:o}=t,s={id:o.id,name:o.name,slug:o.slug,type:o.type,region:o.region,gender:o.gender,country:{id:o.country.id,name:o.country.name,code:o.country.code??void 0,flag:o.country.assets?.flag?.url,providerRef:r(o.country.uuid)},assets:o.assets?.logo?.url?{logo:o.assets.logo.url}:void 0,providerRef:r(o.uuid)};return{id:t.id,name:t.name,slug:t.slug,active:t.status==="ACTIVE",status:t.status==="ACTIVE"?"ACTIVE":"INACTIVE",competition:s,stages:n.map(Pe),providerRef:r(t.uuid)}}async function xe(e,t,n){const o=n||m(),{sportal365Sports:s}=o,a=await p.get({path:`/tournaments/${e}`,params:{language_code:t?.languageCode??s?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??s?.languageCode??"en"},next:t?.next,config:o});return Fe(a)}async function Ue(e,t){const n=t||m(),{sportal365Sports:o}=n;if(!e?.seasonId&&!e?.competitionId)throw new Error("Either seasonId or competitionId must be provided");const s={language_code:e?.languageCode??o?.languageCode??"en"};e.seasonId?s.season_id=e.seasonId:e.competitionId&&(s.tournament_id=e.competitionId,e.status&&(s.status=e.status));const a=await p.get({path:"/v2/seasons/details",params:s,headers:{"Accept-Language":e?.languageCode??o?.languageCode??"en"},next:e?.next,config:n});return Me(a)}function E(e){return{championsleague:"championsLeague",europaleague:"europaLeague",conferenceleague:"conferenceLeague",relegation:"relegation",playoff:"playoff",promotion:"promotion"}[e.toLowerCase()]??e.toLowerCase().replace(/_/g,"")}function He(e){const t=e.toLowerCase();return t==="relegation"?"BOTTOM":t==="playoff"?"MIDDLE":"TOP"}function Be(e,t){if(!t||t.length===0)return;const n=t.map(s=>{const a=s.event,l=a.home_team.id===e,d=l?a.away_team:a.home_team,c=`${a.goal_home}-${a.goal_away}`;return{matchId:a.id.toString(),result:s.outcome,score:c,homeAway:l?"HOME":"AWAY",opponent:{id:d.id.toString(),name:d.name,logo:d.url_logo},date:new Date(a.start_time),competition:void 0}}),o=n.map(s=>s.result).join("");return{competitorId:e.toString(),results:n,formString:o}}function Ge(e){return{key:E(e.code),name:e.name,position:He(e.type)}}function $e(e){const t={played:e.played,won:e.wins,drawn:e.draws,lost:e.defeits,goalsFor:e.goals_for,goalsAgainst:e.goals_against,goalDifference:e.goals_for-e.goals_against,points:e.points},n=e.rules?.length>0?e.rules.map(s=>E(s.code)):void 0,o=Be(e.team.id,e.team.form??[]);return{rank:e.rank,competitor:{id:e.team.id.toString(),name:e.team.name,shortName:e.team.short_name??void 0,logo:e.team.url_logo,uuid:e.team.uuid},stats:t,form:o,rules:n}}function Ye(e){const t=e.map($e),n=new Map;for(const o of e)if(o.rules)for(const s of o.rules){const a=E(s.code);n.has(a)||n.set(a,Ge(s))}return{entries:t,metadata:{legend:Array.from(n.values())}}}async function Ve(e,t){const n=t||m(),{sportal365Sports:o}=n,s=e.expand?.join(","),a=await p.get({path:`/tournaments/seasons/stages/${e.stageId}/standing`,params:{expand:s,language_code:e.languageCode??o?.languageCode??"en"},headers:{"Accept-Language":e.languageCode??o?.languageCode??"en"},next:e.next,config:n});return!a||a.length===0?{entries:[],metadata:{legend:[]}}:Ye(a)}function U(e){return{id:e.id,name:e.name,code:e.country_code,assets:e.assets?.flag?{flag:e.assets.flag}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function We(e){return{id:e.id,name:e.name,type:e.type?.toUpperCase()||"LEAGUE",gender:e.gender?.toUpperCase(),country:e.country?U(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Ke(e){if(e.status){const a={notstarted:{code:"not_started",type:"NOT_STARTED",name:"Not Started"},live:{code:"live",type:"LIVE",name:"Live"},finished:{code:"finished",type:"FINISHED",name:"Finished"},postponed:{code:"postponed",type:"POSTPONED",name:"Postponed"},cancelled:{code:"cancelled",type:"CANCELLED",name:"Cancelled"},abandoned:{code:"abandoned",type:"ABANDONED",name:"Abandoned"}}[e.status.type];if(a)return a}let t="not_started",n="NOT_STARTED",o="Not Started";return e.finished_at?(t="finished",n="FINISHED",o="Finished"):e.started_at&&(t="live",n="LIVE",o="Live"),{code:t,name:o,type:n}}function je(e){return{kickoffTime:new Date(e.kickoff_at),currentMinute:e.minute??void 0,currentPeriod:void 0}}function F(e){return{id:e.id,name:e.name,shortName:e.short_name??void 0,fullName:e.full_name??void 0,threeLetterCode:e.code,type:e.national?"national":"club",gender:e.gender?.toUpperCase(),country:e.country?U(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function qe(e){if(!e)return;const t=o=>o?{competitorOne:o.home_goals!==null?String(o.home_goals):"0",competitorTwo:o.away_goals!==null?String(o.away_goals):"0"}:void 0,n=t(e.ft_score);if(n)return{competitorOne:n.competitorOne,competitorTwo:n.competitorTwo,breakdown:{total:n,halfTime:t(e.ht_score),regularTime:t(e.ft_score),extraTime:t(e.aet_score),penaltyShootout:t(e.pen_score)}}}function b(e){return{id:e.id,sport:e.sport??"football",status:Ke(e),timing:je(e),competitorOne:F(e.home_team),competitorTwo:F(e.away_team),score:qe(e.scores),competition:e.context?.competition?We(e.context.competition):void 0,lineupStatus:e.lineups_confirmed?"CONFIRMED":"NOT_AVAILABLE",updatedAt:e.updated_at?new Date(e.updated_at):void 0,isUndecided:e.undecided??void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Xe(e){return b(e.data)}function ze(e){return e.data.map(b)}function Je(e){return e.map(b)}async function H(e,t,n){const o=await e.loyalty.getTemplateMatches(t,n?.groupId,n?.disableCache);return Je(o)}async function Qe(e,t,n,o){return(await H(e,t,o)).filter(a=>a.competitorOne.id===n||a.competitorTwo.id===n)}async function Ze(e,t,n){const o=await e.loyalty.getTemplateById(t,n?.disableCache);return{id:o.id,name:o.name,description:o.description,type:o.type,fromDate:o.fromDate,toDate:o.toDate,markets:o.markets||[],teamIds:o.teamIds||[],matchIds:o.matchIds||[],groups:(o.groups||[]).map(a=>({groupId:a.groupId,label:a.label,flags:a.flags||[],filters:{fromDate:a.filters?.fromDate||"",toDate:a.filters?.toDate||"",matchIds:a.filters?.matchIds||[]}})),gameIds:o.gameIds||[],gameTypes:o.gameTypes||[],competitionIds:o.competitionIds||[],excludedProfileIds:o.excludedProfileIds||[],rules:o.rules||"",labels:o.labels||{},customFields:o.customFields||{},branding:o.branding?JSON.parse(JSON.stringify(o.branding)):{},brandingId:null,flags:o.flags||[],images:{main:o.images?.main||null,cover:o.images?.cover||null,mobile:o.images?.mobile||null},status:o.status,automaticallyChangeStatus:o.automaticallyChangeStatus||!1,createdAt:o.createdAt,updatedAt:o.updatedAt,related:o.related||[],adContent:o.adContent||""}}function we(e){return{"1x2":"1X2",12:"12",OVER_UNDER:"OVER_UNDER",DOUBLE_CHANCE:"DOUBLE_CHANCE",BOTH_TO_SCORE:"BOTH_TO_SCORE",DRAW_NO_BET:"DRAW_NO_BET",FIRST_TEAM_TO_SCORE:"FIRST_TEAM_TO_SCORE",CORRECT_SCORE:"CORRECT_SCORE",FIRST_HALF_GOALS:"FIRST_HALF_GOALS",FIRST_PLAYER_TO_SCORE:"FIRST_PLAYER_TO_SCORE",PLAYER_TO_SCORE_DURING_GAME:"PLAYER_TO_SCORE_DURING_GAME",PLAYER_TO_RECEIVE_CARD:"PLAYER_TO_RECEIVE_CARD",FIRST_HALF_AND_FINAL_RESULT:"FIRST_HALF_AND_FINAL_RESULT"}[e]||e.toUpperCase()}function et(e,t){const n=new Map;return e.forEach((o,s)=>{if(!o||o.length===0)return;const l=(t?o.filter(d=>d.bookmaker&&t.includes(d.bookmaker.id)):o).filter(d=>d.bookmaker&&d.markets&&d.markets.length>0).map(d=>{const c=d.bookmaker,_=c.assets?.[0],g=c.branding?.backgroundColor||_?.backgroundColor,h=c.branding?.textColor||(tt(g)?"#FFFFFF":"#000000"),T=_?.transparentBackgroundUrl||_?.logo,S=c.eventUrls?.find(f=>f.appType==="desktop")?.url||c.links?.find(f=>f.appType==="desktop")?.homepageUrl||c.url||"";return{operator:{id:c.id,name:c.name,url:S,branding:{backgroundColor:g,textColor:h,logo:T}},type:d.type,markets:d.markets.map(f=>({type:{id:f.type.id,code:f.type.code,name:f.type.name},period:{id:f.scope.id,type:f.scope.type,name:f.scope.name},selections:f.selections.map(v=>{const B=v.urls?.find(G=>G.appType==="desktop")?.url;let I="NONE";return v.movement==="UP"?I="UP":v.movement==="DOWN"&&(I="DOWN"),{id:v.id,name:v.name,code:v.code,value:v.value,odds:v.odds,oddsOld:v.oddsOld,movement:I,url:B}})}))}});n.set(s,l)}),n}function tt(e){if(!e)return!0;const t=e.replace("#",""),n=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return(.2126*n+.7152*o+.0722*s)/255<.5}async function ot(e,t,n){if(!t||t.length===0)return new Map;const o={oddType:n?.oddType||"ALL",scopeType:n?.scopeType||"ORDINARY_TIME",oddFormat:n?.oddFormat||"DECIMAL"};n?.marketTypes&&n.marketTypes.length>0&&(o.marketTypes=n.marketTypes.map(a=>we(a)));const s=await e.odds.getByMatchIds(t,o);return et(s,n?.bookmakerIds)}exports.SPORTAL365_BASKETBALL_DOMAIN=W;exports.SPORTAL365_SPORTS_SEARCH_DOMAIN=q;exports.SPORTAL365_STANDINGS_DOMAIN=X;exports.SPORTAL365_STATISTICS_DOMAIN=j;exports.SPORTAL365_TENNIS_DOMAIN=K;exports.addProviderRef=Q;exports.createHttpClient=P;exports.footballHttp=p;exports.getBatchMatchOdds=ot;exports.getConfig=m;exports.getFootballCompetition=xe;exports.getFootballLivescore=Te;exports.getFootballMatch=pe;exports.getFootballMatchCommentary=ve;exports.getFootballMatchEvents=fe;exports.getFootballMatchLineups=_e;exports.getFootballMatchOdds=ye;exports.getFootballMatchStatistics=he;exports.getFootballMatches=Se;exports.getFootballPlayerSeasonStatistics=x;exports.getFootballPlayerSeasonStatisticsByPlayerIds=De;exports.getFootballSeasonDetails=Ue;exports.getFootballStandings=Ve;exports.getFootballTeam=ke;exports.getFootballTeamSquad=Ne;exports.getLeaderboardMatches=H;exports.getLeaderboardTeamMatches=Qe;exports.getLeaderboardTemplate=Ze;exports.getProviderRefId=J;exports.isConfigured=Y;exports.setConfig=$;exports.toProviderRefArray=r;exports.transformMatch=Xe;exports.transformMatches=ze;exports.transformOdds=M;