fansunited-sdk-esm 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/index.js.map +3 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),function(l){if(a=l.indexOf(":"),r=Pr.trim(l.substr(0,a)).toLowerCase(),o=Pr.trim(l.substr(a+1)),r){if(t[r]&&Lo.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([o]):t[r]=t[r]?t[r]+", "+o:o}}),t}});var fi=d((Fa,hi)=>{"use strict";var di=w();hi.exports=di.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function o(a){var n=a;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=o(window.location.href),function(n){var l=di.isString(n)?o(n):n;return l.protocol===r.protocol&&l.host===r.host}}():function(){return function(){return!0}}()});var ne=d((Pa,yi)=>{"use strict";function Sr(i){this.message=i}Sr.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Sr.prototype.__CANCEL__=!0;yi.exports=Sr});var Cr=d((Sa,gi)=>{"use strict";var ge=w(),No=ri(),Vo=oi(),Do=Ir(),Uo=ci(),$o=ui(),qo=fi(),vr=Fr(),ko=se(),Ho=ne();gi.exports=function(e){return new Promise(function(r,o){var a=e.data,n=e.headers,l=e.responseType,p;function c(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}ge.isFormData(a)&&delete n["Content-Type"];var s=new XMLHttpRequest;if(e.auth){var u=e.auth.username||"",g=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";n.Authorization="Basic "+btoa(u+":"+g)}var oe=Uo(e.baseURL,e.url);s.open(e.method.toUpperCase(),Do(oe,e.params,e.paramsSerializer),!0),s.timeout=e.timeout;function qr(){if(!!s){var S="getAllResponseHeaders"in s?$o(s.getAllResponseHeaders()):null,V=!l||l==="text"||l==="json"?s.responseText:s.response,B={data:V,status:s.status,statusText:s.statusText,headers:S,config:e,request:s};No(function(hr){r(hr),c()},function(hr){o(hr),c()},B),s=null}}if("onloadend"in s?s.onloadend=qr:s.onreadystatechange=function(){!s||s.readyState!==4||s.status===0&&!(s.responseURL&&s.responseURL.indexOf("file:")===0)||setTimeout(qr)},s.onabort=function(){!s||(o(vr("Request aborted",e,"ECONNABORTED",s)),s=null)},s.onerror=function(){o(vr("Network Error",e,null,s)),s=null},s.ontimeout=function(){var V=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",B=e.transitional||ko.transitional;e.timeoutErrorMessage&&(V=e.timeoutErrorMessage),o(vr(V,e,B.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",s)),s=null},ge.isStandardBrowserEnv()){var kr=(e.withCredentials||qo(oe))&&e.xsrfCookieName?Vo.read(e.xsrfCookieName):void 0;kr&&(n[e.xsrfHeaderName]=kr)}"setRequestHeader"in s&&ge.forEach(n,function(V,B){typeof a=="undefined"&&B.toLowerCase()==="content-type"?delete n[B]:s.setRequestHeader(B,V)}),ge.isUndefined(e.withCredentials)||(s.withCredentials=!!e.withCredentials),l&&l!=="json"&&(s.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&s.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&s.upload&&s.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(S){!s||(o(!S||S&&S.type?new Ho("canceled"):S),s.abort(),s=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),a||(a=null),s.send(a)})}});var se=d((va,bi)=>{"use strict";var f=w(),wi=Qr(),Go=Rr(),jo={"Content-Type":"application/x-www-form-urlencoded"};function Mi(i,e){!f.isUndefined(i)&&f.isUndefined(i["Content-Type"])&&(i["Content-Type"]=e)}function Ko(){var i;return typeof XMLHttpRequest!="undefined"?i=Cr():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(i=Cr()),i}function Xo(i,e,t){if(f.isString(i))try{return(e||JSON.parse)(i),f.trim(i)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(i)}var we={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Ko(),transformRequest:[function(e,t){return wi(t,"Accept"),wi(t,"Content-Type"),f.isFormData(e)||f.isArrayBuffer(e)||f.isBuffer(e)||f.isStream(e)||f.isFile(e)||f.isBlob(e)?e:f.isArrayBufferView(e)?e.buffer:f.isURLSearchParams(e)?(Mi(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):f.isObject(e)||t&&t["Content-Type"]==="application/json"?(Mi(t,"application/json"),Xo(e)):e}],transformResponse:[function(e){var t=this.transitional||we.transitional,r=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,a=!r&&this.responseType==="json";if(a||o&&f.isString(e)&&e.length)try{return JSON.parse(e)}catch(n){if(a)throw n.name==="SyntaxError"?Go(n,this,"E_JSON_PARSE"):n}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};f.forEach(["delete","get","head"],function(e){we.headers[e]={}});f.forEach(["post","put","patch"],function(e){we.headers[e]=f.merge(jo)});bi.exports=we});var Ri=d((Ca,Ii)=>{"use strict";var Yo=w(),Wo=se();Ii.exports=function(e,t,r){var o=this||Wo;return Yo.forEach(r,function(n){e=n.call(o,e,t)}),e}});var Er=d((Ea,Fi)=>{"use strict";Fi.exports=function(e){return!!(e&&e.__CANCEL__)}});var vi=d((Ta,Si)=>{"use strict";var Pi=w(),Tr=Ri(),Jo=Er(),zo=se(),Qo=ne();function _r(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new Qo("canceled")}Si.exports=function(e){_r(e),e.headers=e.headers||{},e.data=Tr.call(e,e.data,e.headers,e.transformRequest),e.headers=Pi.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Pi.forEach(["delete","get","head","post","put","patch","common"],function(o){delete e.headers[o]});var t=e.adapter||zo.adapter;return t(e).then(function(o){return _r(e),o.data=Tr.call(e,o.data,o.headers,e.transformResponse),o},function(o){return Jo(o)||(_r(e),o&&o.response&&(o.response.data=Tr.call(e,o.response.data,o.response.headers,e.transformResponse))),Promise.reject(o)})}});var Or=d((_a,Ci)=>{"use strict";var b=w();Ci.exports=function(e,t){t=t||{};var r={};function o(s,u){return b.isPlainObject(s)&&b.isPlainObject(u)?b.merge(s,u):b.isPlainObject(u)?b.merge({},u):b.isArray(u)?u.slice():u}function a(s){if(b.isUndefined(t[s])){if(!b.isUndefined(e[s]))return o(void 0,e[s])}else return o(e[s],t[s])}function n(s){if(!b.isUndefined(t[s]))return o(void 0,t[s])}function l(s){if(b.isUndefined(t[s])){if(!b.isUndefined(e[s]))return o(void 0,e[s])}else return o(void 0,t[s])}function p(s){if(s in t)return o(e[s],t[s]);if(s in e)return o(void 0,e[s])}var c={url:n,method:n,data:n,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:p};return b.forEach(Object.keys(e).concat(Object.keys(t)),function(u){var g=c[u]||a,oe=g(u);b.isUndefined(oe)&&g!==p||(r[u]=oe)}),r}});var xr=d((Oa,Ei)=>{Ei.exports={version:"0.24.0"}});var Oi=d((xa,_i)=>{"use strict";var Zo=xr().version,Ar={};["object","boolean","number","function","string","symbol"].forEach(function(i,e){Ar[i]=function(r){return typeof r===i||"a"+(e<1?"n ":" ")+i}});var Ti={};Ar.transitional=function(e,t,r){function o(a,n){return"[Axios v"+Zo+"] Transitional option '"+a+"'"+n+(r?". "+r:"")}return function(a,n,l){if(e===!1)throw new Error(o(n," has been removed"+(t?" in "+t:"")));return t&&!Ti[n]&&(Ti[n]=!0,console.warn(o(n," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,n,l):!0}};function ea(i,e,t){if(typeof i!="object")throw new TypeError("options must be an object");for(var r=Object.keys(i),o=r.length;o-- >0;){var a=r[o],n=e[a];if(n){var l=i[a],p=l===void 0||n(l,a,i);if(p!==!0)throw new TypeError("option "+a+" must be "+p);continue}if(t!==!0)throw Error("Unknown option "+a)}}_i.exports={assertOptions:ea,validators:Ar}});var Vi=d((Aa,Ni)=>{"use strict";var xi=w(),ta=Ir(),Ai=Jr(),Bi=vi(),Me=Or(),Li=Oi(),U=Li.validators;function le(i){this.defaults=i,this.interceptors={request:new Ai,response:new Ai}}le.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Me(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&Li.assertOptions(t,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1);var r=[],o=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(e)===!1||(o=o&&g.synchronous,r.unshift(g.fulfilled,g.rejected))});var a=[];this.interceptors.response.forEach(function(g){a.push(g.fulfilled,g.rejected)});var n;if(!o){var l=[Bi,void 0];for(Array.prototype.unshift.apply(l,r),l=l.concat(a),n=Promise.resolve(e);l.length;)n=n.then(l.shift(),l.shift());return n}for(var p=e;r.length;){var c=r.shift(),s=r.shift();try{p=c(p)}catch(u){s(u);break}}try{n=Bi(p)}catch(u){return Promise.reject(u)}for(;a.length;)n=n.then(a.shift(),a.shift());return n};le.prototype.getUri=function(e){return e=Me(this.defaults,e),ta(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};xi.forEach(["delete","get","head","options"],function(e){le.prototype[e]=function(t,r){return this.request(Me(r||{},{method:e,url:t,data:(r||{}).data}))}});xi.forEach(["post","put","patch"],function(e){le.prototype[e]=function(t,r,o){return this.request(Me(o||{},{method:e,url:t,data:r}))}});Ni.exports=le});var Ui=d((Ba,Di)=>{"use strict";var ra=ne();function $(i){if(typeof i!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(o){e=o});var t=this;this.promise.then(function(r){if(!!t._listeners){var o,a=t._listeners.length;for(o=0;o<a;o++)t._listeners[o](r);t._listeners=null}}),this.promise.then=function(r){var o,a=new Promise(function(n){t.subscribe(n),o=n}).then(r);return a.cancel=function(){t.unsubscribe(o)},a},i(function(o){t.reason||(t.reason=new ra(o),e(t.reason))})}$.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};$.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};$.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};$.source=function(){var e,t=new $(function(o){e=o});return{token:t,cancel:e}};Di.exports=$});var qi=d((La,$i)=>{"use strict";$i.exports=function(e){return function(r){return e.apply(null,r)}}});var Hi=d((Na,ki)=>{"use strict";ki.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Ki=d((Va,Br)=>{"use strict";var Gi=w(),ia=yr(),be=Vi(),oa=Or(),aa=se();function ji(i){var e=new be(i),t=ia(be.prototype.request,e);return Gi.extend(t,be.prototype,e),Gi.extend(t,e),t.create=function(o){return ji(oa(i,o))},t}var v=ji(aa);v.Axios=be;v.Cancel=ne();v.CancelToken=Ui();v.isCancel=Er();v.VERSION=xr().version;v.all=function(e){return Promise.all(e)};v.spread=qi();v.isAxiosError=Hi();Br.exports=v;Br.exports.default=v});var q=d((Da,Xi)=>{Xi.exports=Ki()});var Yi=ae(q());var Lr=i=>{let e=[],t=0;return i.forEach(r=>{e[t]?e[t].length<249?e[t].push(r):(t=t+1,e[t]=[r]):e[t]=[r]}),e},Ie=i=>{let e=[],t=200;for(;i.length>t-1;){let r=i.splice(0,t-1);e.push(r)}return e.push(i),e},C=(i,e)=>{let t="";return i==="prod"||i==="sandbox"?t={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1"}[e]:t={profile:"http://localhost:8010",football:"http://locahost:8080",idMapping:"http://localhost:8030",predictor:"http://localhost:8040",client:"http://localhost:8080"}[e],t};var Re=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[]};var Fe=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new Re;return t.avatar=e.avatar,t.birthDate=e.birth_date,t.country=e.country,t.gender=e.gender,t.id=e.id,t.interests=e.interests,t.name=e.name,t};profileToRequest=e=>({country_id:e.country?e.country.id:null,gender:e.gender,birth_date:e.birthDate,interests:e.interests,name:e.name})};var Pe=class{avatar=null;followingId=null;name=null;profileId=null};var Se=class{followingFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new Pe;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var ve=class{avatar=null;followerId=null;name=null;profileId=null};var Ce=class{followersFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new ve;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var pe=class{profile_ids=[]};var N=class{limit=0;startAfter=null;constructor(e){this.limit=e.limit?e.limit:20,this.startAfter=e.startAfter?e.startAfter:null}constructFilterUrl=()=>{let e="";return this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.startAfter&&(e=e+"&",e=e+`start_after=${this.startAfter}`),e}};var na="/countries",R="/profile",Wi="/profiles",Ee=class{instance=null;apiSignInUrl="";profileRemapper=null;followingRemapper=null;followersRemapper=null;constructor(e){let t=C(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}&lang=${e.lang}`,this.instance=Yi.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.profileRemapper=new Fe,this.followingRemapper=new Se,this.followersRemapper=new Ce}getCountries=async()=>{try{return(await this.instance.get(`${na}${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching the countries:",e),e}};getProfile=async e=>{let t=`${R}${this.apiSignInUrl}`;e&&(t=`${Wi}/${e}${this.apiSignInUrl}`);try{let r=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r}};getProfiles=async e=>{try{let t=await this.instance.get(`${Wi}${this.apiSignInUrl}&profile_ids=${e.join(",")}`);return this.profileRemapper.profilesFromResponse(t.data.data)}catch(t){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,t),t}};getFollowers=async(e,t)=>{let r=`${R}/followers${this.apiSignInUrl}`;e&&!t?(e=new N(e),r=`${R}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`):e&&t?(e=new N(e),r=`${R}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`):!e&&t&&(r=`${R}/${t}/followers${this.apiSignInUrl}`);try{let o=await this.instance.get(r);return this.followersRemapper.followersFromResponse(o.data.data)}catch(o){throw console.warn("There was a problem fetching the followers for profile",o),o}};getFollowing=async(e,t)=>{let r=`${R}/following${this.apiSignInUrl}`;e&&!t?(e=new N(e),r=`${R}/following${this.apiSignInUrl}${e.constructFilterUrl()}`):e&&t?(e=new N(e),r=`${R}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`):!e&&t&&(r=`${R}/${t}/following${this.apiSignInUrl}`);try{let o=await this.instance.get(r);return this.followingRemapper.followingFromResponse(o.data.data)}catch(o){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o}};follow=async e=>{let t=new pe;t.profile_ids=e;try{let r=await this.instance.post(`${R}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followingFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,r),r}};unfollow=async e=>{let t=new pe;t.profile_ids=e;try{return await this.instance.delete(`${R}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(r){return console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),!1}};updateProfile=async e=>{try{let t=this.profileRemapper.profileToRequest(e),r=await this.instance.patch(`${R}${this.apiSignInUrl}`,t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t}}};var E={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var Ji="FansUnited",zi={football:{ids:[],countries:[],competitions:[]},profile:{others:[],own:{},countries:[],expireAt:0}},T=class{idSchema="";exparationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(zi)}clearData=()=>{this.setData(zi)};getEntityById=(e="",t="")=>this.getData().football.ids.find(r=>{let o=E[this.idSchema];return r&&`${r[o]}`===t&&r.resource===e});getEntity=(e,t,r)=>Array.isArray(e)?this.getData().football.ids.filter(o=>{let a=E[r];return o&&e.includes(`${o[a]}`)&&o.resource===t}):this.getData().football.ids.find(o=>{let a=E[r];return o&&`${o[a]}`===e&&o.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(r=>r&&`${r.id}`===t&&r.resource===e);checkForExistingIdObjs=(e,t)=>{let r=E[t],o={};return Object.keys(e).forEach(a=>{let n=e[a],p=this.getEntity(n,a,t).map(s=>s[r]),c=e[a].filter(s=>!p.includes(s));o[a]=n.map(s=>c.includes(s)?{id:s,exists:!1}:{id:s,exists:!0})}),o};getIdsByType=(e,t,r)=>{let o=E[r],a=E[t],n={};return Object.keys(e).forEach(l=>{let p=e[l],c=[];this.getData().football.ids.forEach(s=>{p.forEach((u,g)=>{u===s[a]&&l===s.resource&&(c[g]=s[o])})}),n[l]=c}),n};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),r=t.football.ids;r=[...r,...e],t.football.ids=r,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.own=e,t.profile.expireAt=Math.floor(Date.now()/1e3)+this.exparationTimeout,this.setData(t)};addProfiles=e=>{let t=this.getData(),r=e.map(a=>`${a.id}`),o=t.profile.others.filter(a=>!r.includes(`${a.id}`));o.push(...e),t.profile.others=o,this.setData(t)};addProfile=e=>{let t=this.getData(),r=t.profile.others.filter(o=>`${o.id}`!=`${e.id}`);r.push(e),t.profile.others=r,this.setData(t)};getOwnProfile=()=>this.getData().profile.own;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getProfilesByIds=e=>this.getData().profile.others.filter(o=>e.includes(`${o.id}`));getProfileById=e=>this.getData().profile.others.find(o=>`${o.id}`==`${e}`);getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData();t.football.competitions.push(...e),this.setData(t)};getExparationProfile=()=>this.getData().profile.expireAt;getData=()=>JSON.parse(localStorage.getItem(Ji));setData=e=>{localStorage.setItem(Ji,JSON.stringify(e))}};var Qi=ae(q());var ce={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Te=class{instance=null;apiSignInUrl="";constructor(e){let t=C(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=Qi.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${ce[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r}};getEntityByIdAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ce[e]}=${t}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,o),o}};getEntityIdsByIdsAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ce[e]}=${t.join(",")}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,o),o}};getEntitiesByIds=(e,t,r)=>{t.sort((n,l)=>n.localeCompare(l));let a=Lr(t).map(n=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ce[e]}=${n.join(",")}`)}catch(l){throw console.warn(`There was a problem with id mapping request for the following ids:${n.join(",")}`,l),l}});return Promise.all(a).then(n=>{let l=[];return n.forEach(p=>{l.push(...p.data.data)}),l})};getEntitiesByIdObjs=(e,t)=>{let r=[];return Object.keys(e).forEach(o=>{let n=Lr(e[o]).map(l=>{l.sort((p,c)=>p.localeCompare(c));try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}&${ce[o]}=${l.join(",")}`)}catch(p){throw console.warn(`There was a problem with id mapping request for the following ids:${l.join(",")}`,p),p}});r=[...r,...n]}),Promise.all(r).then(o=>{let a=[];return o.forEach(n=>{a.push(...n.data.data)}),a})}};var _e=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new T(e),this.https=new Te(e)}getEntitiesByIds=async(e,t,r)=>{if(this.isBrowser)try{let o=this.localStorage.checkForExistingIdObjs(e,t),a=this.splitForRequestAndExisting(o),n=await this.https.getEntitiesByIdObjs(a.request,t);return this.localStorage.addIdMappings(n),this.localStorage.getIdsByType(e,t,r)}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}else try{let o=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(a=>{e[a]=o.filter(n=>n.resource===a).map(n=>n[E[r]])}),e}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}};getEntityById=async(e,t,r)=>{if(this.isBrowser){let o=this.localStorage.getEntity(e,t,r);if(o)return o;{let a=await this.requestEntity(e,t,r);return this.localStorage.addIdMappings(a),a}}else return await this.requestEntity(e,t,r)};splitForRequestAndExisting=e=>{let t={},r={};return Object.keys(e).forEach(o=>{t[o]=e[o].filter(a=>!a.exists).map(a=>a.id),r[o]=e[o].filter(a=>a.exists).map(a=>a.id)}),{existing:r,request:t}};requestEntity=async(e,t,r)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,r)}catch(o){return console.warn(`There was a problem retrieving the requested entity: ${o}`),null}}};var Oe=i=>{switch(i){case"competitions":return"competition";case"players":case"relatedPlayer":case"squad":return"player";case"teams":case"participants":case"homeTeam":case"awayTeam":case"timeline":case"teamId":return"team";default:return i}};var xe=class{extractedObjIds={};traverse=(e,t)=>(t=Oe(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(r=>{this.traverseObjExtract(r,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{let o=e[r];r==="id"||r==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),this.extractedObjIds[t].push(o)):e[r]&&this.traverse(e[r],r)})}};var Ae=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,r)=>(t=Oe(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(r),this.remappedIdsObj=r),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(r=>{this.traverseObjReplace(r,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{r==="id"||r==="teamId"?(e[r]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[r]&&this.traverse(e[r],r,this.remappedIdsObj)})}};var _=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new _e(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let r=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let a=new xe().traverse(r,t);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(n=>new Ae().traverse(r,t,n))}else return e}catch(o){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,o),[]}};getEntityIdsBySchemaId=async(e,t,r)=>{let o={};return o[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(o,this.idSchema,r):o}};var I=class{completed=!1;percentage;constructor(e){this.percentage=e}};var Be=class{teamFollowed=new I(10);teamFavourite=new I(15);playerFollowed=new I(10);playerFavourite=new I(10);competitionFollowed=new I(10);competitionFavourite=new I(5);addedBirthdate=new I(10);addedGender=new I(10);addedCountry=new I(10);addedAvatar=new I(10)};var Le=class{totalPercentage;breakdown=new Be};var O=class{isBrowser=!1;localStorage={};https=null;constructor(e,t){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.https=t}getOwn=async()=>{if(this.isBrowser){let e=Math.floor(Date.now()/1e3),t=this.localStorage.getExparationProfile(),r=null;if(t>e&&(r=this.localStorage.getOwnProfile()),r)return r;try{let o=await this.https.getProfile();return this.localStorage.setOwnProfile(o),o}catch(o){throw console.warn("There was a problem retrieving your profile: ",o),o}}else try{return await this.https.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async e=>{if(this.isBrowser){let t=this.localStorage.getProfilesByIds(e);if(t&&t.length===e.length)return t.filter(r=>delete r.interests),t;try{let r=await this.https.getProfiles(e);return this.localStorage.addProfiles(r),r.filter(o=>delete o.interests),r}catch(r){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,r),r}}else try{let t=await this.https.getProfiles(e);return t.filter(r=>delete r.interests),t}catch(t){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,t),t}};getById=async e=>{if(this.isBrowser){let t=this.localStorage.getProfileById(e);if(t)return t;try{let r=await this.https.getProfile(e);return this.localStorage.addProfile(r),r}catch(r){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,r),r}}else try{return await this.https.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async()=>{if(this.isBrowser){let e=this.localStorage.getProfileCountries();if(e&&e.length>0)return e;try{let t=await this.https.getCountries();return this.localStorage.setProfileCountries(t),t}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}}else try{return await this.https.getCountries()}catch(e){throw console.warn("There was a problem retrieving profile countries: ",e),e}};getFollowers=async(e,t)=>{try{return await this.https.getFollowers(e,t)}catch(r){throw console.warn("There was a problem retrieving your followers: ",r),r}};getFollowing=async(e,t)=>{try{return await this.https.getFollowing(e,t)}catch(r){throw console.warn("There was a problem retrieving your following profiles: ",r),r}};follow=async e=>{try{return await this.https.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.https.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new Le,r=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,r+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,r+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,r+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,r+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(s=>s.type==="team"&&s.favourite)&&(t.breakdown.teamFavourite.completed=!0,r+=t.breakdown.teamFavourite.percentage),e.interests.find(s=>s.type==="team")&&(t.breakdown.teamFollowed.completed=!0,r+=t.breakdown.teamFollowed.percentage),e.interests.find(s=>s.type==="player"&&s.favourite)&&(t.breakdown.playerFavourite.completed=!0,r+=t.breakdown.playerFavourite.percentage),e.interests.find(s=>s.type==="player")&&(t.breakdown.playerFollowed.completed=!0,r+=t.breakdown.playerFollowed.percentage),e.interests.find(s=>s.type==="competition"&&s.favourite)&&(t.breakdown.competitionFavourite.completed=!0,r+=t.breakdown.competitionFavourite.percentage),e.interests.find(s=>s.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,r+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=r,t}};var Ne=class{id=null;name=null;assets=null};var Ve=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCountriesWithIdMapping=async()=>{try{let e=await this.getCountries();return this.idMapping.remapEntities(e,"country")}catch(e){throw console.warn("There was a problem browsing countries as football entities",e),e}};getCountries=async()=>{if(this.isBrowser){let e=this.localStorage.getFootballCountries();if(e&&e.length>0)return e;try{let t=await this.https.getCountries();return this.localStorage.setFootballCountries(t),t}catch(t){throw console.warn("There was a problem retrieving countries as football entities",t),t}}else return this.https.getCountries()}};var De=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(r=>{let o=!0;return t.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?o&&=r.country.id===this[a]:a==="name"?o&&=r.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?o&&=this[a].some(n=>r.id===n):o&&=r[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),o})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((r,o)=>this.sortOrder&&this.sortOrder==="desc"?o.name.localeCompare(r.name):r.name.localeCompare(o.name)):this.sortField==="countryId"?t=e.sort((r,o)=>this.sortOrder&&this.sortOrder==="desc"?o.country.id.localeCompare(r.country.id):r.country.id.localeCompare(o.country.id)):this.sortField==="scope"?e.forEach(r=>t[this.competitionIds.indexOf(r.id)]=r):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((r,o)=>o.id.localeCompare(r.id))),t}};var Ue=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCompetitionsIdMapping=async e=>{try{let t=!1;if(e){if(e=new De(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");o.country.length===0&&(t=!0),e.countryId=o.country[0]}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");o.competition.length===0&&(t=!0),e.competitionIds=o.competition}if(t)return[]}let r=await this.getCompetitions(e);return await this.idMapping.remapEntities(r,"competition")}catch(t){throw console.warn("There was a problem browsing all of the competitions",t),t}};getCompetitions=async e=>{if(this.isBrowser){let t=this.localStorage.getCompetitions(e);if(t&&t.length>0)return t;try{let r=await this.https.getCompetitions(e);return this.localStorage.setCompetitions(r),this.localStorage.getCompetitions(e)}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}}else return this.https.getCompetitions(e)};getCompetitionByIdIdMapping=async e=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],o=await this.getCompetitionById(r);return await this.idMapping.remapEntities(o,"competition")}catch(t){throw console.warn(`There was a problem browsing the following competition:${e}`,t),t}};getCompetitionById=async e=>{try{return await this.https.getCompetitionById(e)}catch(t){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,t),t}};getTopCompetitionsIdMapping=async()=>{try{let e=await this.getTopCompetitions();return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async()=>{try{return await this.https.getTopCompetitions()}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var $e=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(e){this.name=e.name?e.name:null,this.countryId=e.countryId?`${e.countryId}`:null,this.national=e.national?e.national:!1,this.gender=e.gender?e.gender:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.scope=e.scope?e.scope:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.teamIds=e.teamIds?e.teamIds:null}constructFilterUrl=()=>{let e="";return this.name&&(e=e+"&",e=e+`name=${this.name}`),this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.national&&(e=e+"&",e=e+`national=${this.national}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.teamIds&&(e=e+"&",e=e+`team_ids=${this.teamIds.join(",")}`),e}};var qe=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getTeamsIdMapping=async e=>{try{let t=!1;if(e){if(e=new $e(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");o.country.length===0&&(t=!0),e.countryId=o.country[0]}if(e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");o.competition.length===0&&(t=!0),e.scope=o.competition}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");o.team.length===0&&(t=!0),e.teamIds=o.team}}if(t)return[];let r=await this.getTeams(e);return await this.idMapping.remapEntities(r,"team")}catch(t){throw console.warn("There was a problem browsing all teams",t),t}};getTeams=async e=>{try{return await this.https.getTeams(e)}catch(t){throw console.warn("There was a problem retrieving all teams",t),t}};getTeamByIdIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getTeamById(e);return await this.idMapping.remapEntities(r,"team")}catch(t){throw console.warn(`There was a problem browsing the following team:${e}`,t),t}};getTeamById=async e=>{try{return await this.https.getTeamById(e)}catch(t){throw console.warn(`There was a problem retrieving the following team: ${e}`,t),t}};getTopTeamsIdMapping=async()=>{try{let e=await this.getTopTeams();return await this.idMapping.remapEntities(e,"team")}catch(e){throw console.warn("There was a problem browsing the top teams",e),e}};getTopTeams=async()=>{try{return await this.https.getTopTeams()}catch(e){throw console.warn("There was a problem retrieving the top teams",e),e}};getNextMatchForTeamIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getNextMatchForTeam(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,t),t}};getNextMatchForTeam=async e=>{try{return await this.https.getNextMatchForTeam(e)}catch(t){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,t),t}};getPrevMatchForTeamIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getPrevMatchForTeam(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,t),t}};getPrevMatchForTeam=async e=>{try{return await this.https.getPrevMatchForTeam(e)}catch(t){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,t),t}}};var ke=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var He=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getPlayersIdMapping=async e=>{try{let t=!1;if(e){if(e=new ke(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");o.country.length===0&&(t=!0),e.countryId=o.country[0]}if(e.playerIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");o.player.length===0&&(t=!0),e.playerIds=o.player}if(e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");o.competition.length===0&&(t=!0),e.scope=o.competition}if(t)return[]}let r=await this.getPlayers(e);return await this.idMapping.remapEntities(r,"player")}catch(t){throw console.warn("There was a problem browsing the players",t),t}};getPlayers=async e=>{try{return await this.https.getPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the players",t),t}};getPlayerIdMapping=async e=>{try{let t=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),r=await this.getPlayerById(t.player[0]);return await this.idMapping.remapEntities(r,"player")}catch(t){throw console.warn(`There was a problem browsing the following player:${e}`,t),t}};getPlayerById=async e=>{try{return await this.https.getPlayerById(e)}catch(t){throw console.warn(`There was a problem retrieving the following player: ${e}`,t),t}};getTopPlayersIdMapping=async()=>{try{let e=await this.getTopPlayers();return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async()=>{try{return await this.https.getTopPlayers()}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getNextMatchForPlayer(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the next match for player:${e}`,t),t}};getNextMatchForPlayer=async e=>{try{return await this.https.getNextMatchForPlayer(e)}catch(t){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,t),t}};getPrevMatchForPlayerIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the previous match for player:${e}`,t),t}};getPrevMatchForPlayer=async e=>{try{return await this.https.getPrevMatchForPlayer(e)}catch(t){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,t),t}}};var Ge=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryIds=e.countryIds?e.countryIds:null,this.competitionIds=e.competitionIds?e.competitionIds:null,this.matchIds=e.matchIds?e.matchIds:null,this.status=e.status?e.status:null,this.teamIds=e.teamIds?e.teamIds:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&(e=e+"&",e=e+`teams=${this.teamIds.join(",")}`),this.fromDate&&(e=e+"&",e=e+`from_date=${this.fromDate}`),this.toDate&&(e=e+"&",e=e+`to_date=${this.toDate}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var je=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}getMatchesIdMapping=async e=>{try{if(e){if(e=new Ge(e),e.countryIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=r.country}if(e.competitionIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=r.competition}if(e.matchIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=r.match}if(e.teamIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=r.team}}let t=await this.getMatches(e);return await this.idMapping.remapEntities(t,"match")}catch(t){throw console.warn("There was a problem browsing the matches",t),t}};getMatches=async e=>{try{return await this.https.getMatches(e)}catch(t){throw console.warn("There was a problem retrieving the matches",t),t}};getMatchIdMapping=async e=>{try{let t=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),r=await this.getMatchById(t.match[0]);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the following match: ${e}`,t),t}};getMatchById=async e=>{try{return await this.https.getMatchById(e)}catch(t){throw console.warn(`There was a problem retrieving the following match: ${e}`,t),t}}};var Ke=class{entities=null;query=null;scope=null;constructor(e){this.entities=e.entities?e.entities:null,this.query=e.query?e.query:null,this.scope=e.scope?e.scope:null}constructFilterUrl=()=>{let e="";return this.entities&&(e=e+"&",e=e+`entities=${this.entities.join(",")}`),this.query&&(e=e+"&",e=e+`q=${this.query}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),e}};var Xe=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async e=>{try{if(e=new Ke(e),e.scope){let r=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=r.competition}let t=await this.search(e);if(t.teams&&t.teams.length>0){let r=await this.idMapping.remapEntities(t.teams,"team");t.teams=r}if(t.players&&t.players.length>0){let r=await this.idMapping.remapEntities(t.players,"player");t.players=r}if(t.competitions&&t.competitions.length>0){let r=await this.idMapping.remapEntities(t.competitions,"competition");t.competitions=r}return t}catch(t){throw console.warn("There was a problem with browsing the search result",t),t}};search=async e=>{try{return await this.https.search(e)}catch(t){throw console.warn("There was a problem retrieving the search response",t),t}}};var x=class{isBrowser=!1;localStorage={};https=null;idMapping=null;countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t,this.countriesFacade=new Ve(e,t,r),this.competitionsFacade=new Ue(e,t,r),this.teamsFacade=new qe(t,r),this.playerFacade=new He(t,r),this.matchFacade=new je(t,r),this.searchFacade=new Xe(t,r)}getCountries=async()=>this.countriesFacade.getCountriesWithIdMapping();getCompetitions=async e=>this.competitionsFacade.getCompetitionsIdMapping(e);getCompetitionById=async e=>this.competitionsFacade.getCompetitionByIdIdMapping(e);getTopCompetitions=async()=>this.competitionsFacade.getTopCompetitionsIdMapping();getTeams=async e=>this.teamsFacade.getTeamsIdMapping(e);getTeamById=async e=>this.teamsFacade.getTeamByIdIdMapping(e);getTopTeams=async()=>this.teamsFacade.getTopTeamsIdMapping();getNextMatchForTeam=async e=>this.teamsFacade.getNextMatchForTeamIdMapping(e);getPrevMatchForTeam=async e=>this.teamsFacade.getPrevMatchForTeamIdMapping(e);getPlayers=async e=>this.playerFacade.getPlayersIdMapping(e);getPlayerById=async e=>this.playerFacade.getPlayerIdMapping(e);getTopPlayers=async()=>this.playerFacade.getTopPlayersIdMapping();getNextMatchForPlayer=async e=>this.playerFacade.getNextMatchForPlayerIdMapping(e);getPrevMatchForPlayer=async e=>this.playerFacade.getPrevMatchForPlayerIdMapping(e);getMatches=async e=>this.matchFacade.getMatchesIdMapping(e);getMatchById=async e=>this.matchFacade.getMatchIdMapping(e);search=async e=>this.searchFacade.searchIdMapping(e)};var k=class{idMapping=null;footballFacade=null;constructor(e,t){this.idMapping=e,this.footballFacade=t}remapInterestsToIdSchema=async e=>{let t=this.idMapping.idSchema;if(t!=="native")if(e.length>0){let r={},o={};e.forEach(l=>{r.hasOwnProperty(l.type)||(r[l.type]=[],o[l.type]=[]),r[l.type].push(l.id),o[l.type].push(l)});let a=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",t),n=[];for(let[l,p]of Object.entries(o))p.forEach((c,s)=>{c.id=a[l][s],n.push(c)});return n}else return e;else return e};remapInterestToNative=async e=>{let t=this.idMapping.idSchema;if(t!=="native"){let r={},{id:o,type:a}=e;r[a]=[o];let n=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,"native");return e.id=n[a][0],e}return e};inquiryCustomInterests=async e=>{let t=[];if(e&&e.length>0&&(t=e.filter(r=>r.source==="custom")),t&&t.length>0){let r=e.filter(a=>a.source!=="custom"),o=await this.remapInterestsToIdSchema(r);return t.forEach(a=>o.push(a)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0)for(let r of e)if(r.source!=="custom"&&r.source==="football"){let o={};if(r.type==="team"){o.teamIds=[r.id];let a=await this.footballFacade.getTeams(o);r.model=a[0]}if(r.type==="player"){o.playerIds=[r.id];let a=await this.footballFacade.getPlayers(o);r.model=a[0]}if(r.type==="competition"){o.competitionIds=[r.id];let a=await this.footballFacade.getCompetitions(o);r.model=a[0]}r.model===void 0&&(r.model=null),t.push(r)}else t.push(r);return t}};var Ye=class{profileHttps=null;footballHttps=null;localStorage=null;idMapping=null;profileFacade=null;footballFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,r,o){this.localStorage=e,this.profileHttps=t,this.footballHttps=o,this.idMapping=r,this.footballFacade=new x(e,o,r),this.interestsService=new k(r,this.footballFacade),this.profileFacade=new O(e,t)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;let t=await this.profileFacade.getOwn();return this.setOwnProfile(t),this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>await this.profileFacade.follow(e);unfollow=async e=>await this.profileFacade.unfollow(e);addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e;let r=this.ownProfile.interests.filter(o=>o.id!==t.id||o.type!==t.type||o.source!==t.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==t.id||r.type!==t.type||r.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new Ne,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.getOwnProfile(),t=await this.profileHttps.updateProfile(e);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(t),delete t.interests,t}};var We=class{profileHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,r,o){this.localStorage=e,this.profileHttps=t,this.footballFacade=o,this.idMapping=r,this.interestsService=new k(r,o),this.profileFacade=new O(e,t)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)}};var Zi=ae(q());var Je=class{id="";alias="";countryCode="";assets=null;name=""};var h=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new Je;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var ze=class{id="";country=null;gender="";assets=null;type="";name=""};var M=class{countryRemapper=null;constructor(){this.countryRemapper=new h}fromResponse(e){try{let t=new ze;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Qe=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Ze=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var y=class{countryRemapper=null;constructor(){this.countryRemapper=new h}fromResponse(e){try{let t=new Ze;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var et=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new h,this.teamBasicRemapper=new y}fromResponse(e){try{let t=new Qe;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(r=>this.teamBasicRemapper.fromResponse(r)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var tt=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var rt=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var it=class{countryRemapper=null;constructor(){this.countryRemapper=new h}fromResponse(e){try{let t=new rt;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var ot=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new h,this.competitionRemapper=new M,this.playerRemapper=new it}fromResponse(e){try{let t=new tt;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t.squad=e.squad?e.squad.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var at=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var nt=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var H=class{fromResponse(e){try{let t=new nt;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var st=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new y,this.competitionRemapper=new M,this.scoresRemapper=new H}fromResponse(e){try{let t=new at;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var lt=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var pt=class{corners=null;crosses=null;offside=null;shotsOn=null;throwIn=null;redCards=null;shotsOff=null;goalKicks=null;possession=null;treatments=null;yellowCards=null;shotsBlocked=null;substitutions=null;counterAttacks=null;foulsCommitted=null};var ct=class{fromResponse(e){try{let t=new pt;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var G=class{homeTeam={players:[]};awayTeam={players:[]}};var mt=class{id="";name="";position="";shirtNumber;assets=null;type=""};var j=class{fromResponse(e){try{let t=new mt;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var ut=class{playerRemapper=null;constructor(){this.playerRemapper=new j}fromResponse(e){try{let t=new G;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var dt=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var ht=class{playerRemapper=null;constructor(){this.playerRemapper=new j}fromResponse(e){try{let t=new dt;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var ft=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new y,this.competitionsMapper=new M,this.lineupsMapper=new ut,this.scoresMapper=new H,this.statsMapper=new ct,this.timelineMapper=new ht}fromResponse(e){try{let t=new lt;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(r=>this.timelineMapper.fromResponse(r)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new G,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var yt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var gt=class{countryRemapper=null;constructor(){this.countryRemapper=new h}fromResponse(e){try{let t=new yt;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var wt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var K=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new h,this.teamRemapper=new y}fromResponse(e){try{let t=new wt;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var Mt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var bt=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new h,this.teamRemapper=new y,this.competitionRemapper=new M}fromResponse(e){try{let t=new Mt;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var It=class{teams=null;players=null;competitions=null};var Rt=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new y,this.playerRemapper=new K,this.competitionremapper=new M}fromResponse(e){try{let t=new It;return t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.players=e.players?e.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.competitions=e.competitions?e.competitions.map(r=>this.competitionremapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var X=class{instance=null;apiSignInUrl="";idSchema="";limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;constructor(e){let t=C(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}&client_id=${e.clientId}`,this.idSchema=e.idSchema,this.instance=Zi.default.create({baseURL:t}),this.countryRemapper=new h,this.competitionBasicRemapper=new M,this.competitionFullRemapper=new et,this.teamBasicRemapper=new y,this.teamFullRemapper=new ot,this.matchBasicRemapper=new st,this.matchFullRemapper=new ft,this.playerBasicRemapper=new K,this.playerFullRemapper=new bt,this.topPlayerRemapper=new gt,this.searchRemapper=new Rt}getCountries=async()=>{try{let e=await this.instance.get(`/countries${this.apiSignInUrl}`);return this.countryRemapper.countriesFromResponse(e.data.data)}catch(e){throw console.warn("There was a problem with the football countries request",e),e}};getCompetitions=async e=>{try{let t={};if(e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let r=[],o=Ie(e.competitionIds);for(let n of o)e.competitionIds=n,t=await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(l=>this.competitionBasicRemapper.fromResponse(l)));return Array.prototype.concat.apply([],r)}else return t=e?await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/competitions${this.apiSignInUrl}`),t.data.data.map(r=>this.competitionBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getCompetitions request",t),t}};getCompetitionById=async e=>{try{let t=await this.instance.get(`/competitions/${e}${this.apiSignInUrl}`);return this.competitionFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getCompetitionById request",t),t}};getTopCompetitions=async()=>{try{return(await this.instance.get(`/competitions/top${this.apiSignInUrl}`)).data.data.map(t=>this.competitionBasicRemapper.fromResponse(t))}catch(e){throw console.warn("There was a problem with getTopCompetitions request",e),e}};getTeams=async e=>{try{let t={};if(e&&e.teamIds&&e.teamIds.length>this.limitIds-1){let r=[],o=Ie(e.teamIds);for(let n of o)e.teamIds=n,t=await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)));return Array.prototype.concat.apply([],r)}else return t=e?await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/teams${this.apiSignInUrl}`),t.data.data.map(r=>this.teamBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getTeams request",t),t}};getTeamById=async e=>{try{let t=await this.instance.get(`/teams/${e}${this.apiSignInUrl}`);return this.teamFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getTeamById request",t),t}};getTopTeams=async()=>{try{let e=await this.instance.get(`/teams/top${this.apiSignInUrl}`);return e.data.data?e.data.data.map(t=>this.teamBasicRemapper.fromResponse(t)):[]}catch(e){throw console.warn("There was a problem with getTopTeams request",e),e}};getNextMatchForTeam=async e=>{try{let t=await this.instance.get(`/teams/${e}/next-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getNextMatchForTeam request",t),t}};getPrevMatchForTeam=async e=>{try{let t=await this.instance.get(`/teams/${e}/previous-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPrevMatchForTeam request",t),t}};getPlayers=async e=>{try{let t={};if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let r=[],o=Ie(e.playerIds);for(let n of o)e.playerIds=n,t=await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)));return Array.prototype.concat.apply([],r)}else return(e?await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/players${this.apiSignInUrl}`)).data.data.map(o=>this.playerBasicRemapper.fromResponse(o))}catch(t){throw console.warn("There was a problem with getPlayers request",t),t}};getPlayerById=async e=>{try{let t=await this.instance.get(`/players/${e}${this.apiSignInUrl}`);return this.playerFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPlayerById request",t),t}};getTopPlayers=async()=>{try{return(await this.instance.get(`/players/top${this.apiSignInUrl}`)).data.data.map(t=>this.topPlayerRemapper.fromResponse(t))}catch(e){throw console.warn("There was a problem with getTopPlayers request",e),e}};getNextMatchForPlayer=async e=>{try{let t=await this.instance.get(`/players/${e}/next-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getNextMatchForPlayer request",t),t}};getPrevMatchForPlayer=async e=>{try{let t=await this.instance.get(`/players/${e}/previous-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPrevMatchForPlayer request",t),t}};getMatchById=async e=>{try{let t=await this.instance.get(`/matches/${e}${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getMatchById request",t),t}};getMatches=async e=>{try{return(e?await this.instance.get(`/matches${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/matches${this.apiSignInUrl}`)).data.data.map(r=>this.matchBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getMatches request",t),t}};search=async e=>{try{let t=await this.instance.get(`/search${this.apiSignInUrl}${e.constructFilterUrl()}`);return this.searchRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with search request",t),t}}};var Ft=class{profileHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Ee(e),this.footballHttps=new X(e),this.idMapping=new _(e),this.localStorage=new T(e),this.footballFacade=new x(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new O(this.localStorage,this.profileHttps),this.ownProfileBuilder=new Ye(this.localStorage,this.profileHttps,this.idMapping,this.footballHttps),this.profileBuilder=new We(this.localStorage,this.profileHttps,this.idMapping,this.footballFacade)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async()=>await this.profileFacade.getCountries();getByIds=async e=>await this.profileFacade.getByIds(e)};var Pt=class{validate=e=>{let t=this.validateField(e.lang),r=this.generateMessage(t);return{validation:t,message:r}};validateField=e=>{let t=["bg","ro","en"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: EN"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: EN"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var St=class{validate(e){let t=this.validateField(e.environment),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["dev","sandbox","prod"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var vt=class{validate(e){let t=this.validateField(e.apiKey),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use this SDK"),e==="valid"&&(r=null),{text:t,type:r}}};var Ct=class{validate(e){let t=this.validateField(e.idSchema),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var ue=class{getIdToken=null;logout=null};var J=class{text=null;type=null};var Et=class{validation=null;message=new J;getIdToken={validation:null,message:new J};logout={validation:null,message:new J}};var Tt=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new ue),r=new Et;if(e){let a=Object.keys(e).filter(n=>!t.includes(n));a.length>0?(r.validation="invalid",r.message.type="warning",r.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):r.validation="valid"}else r.validation="missing",r.message.type="error",r.message.text="The field authProvider must be provided to use this SDK";return r};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new ue).forEach(o=>{e[o]?t[o].validation="valid":t[o].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let r=e[t];r.validation==="missing"&&(r.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,r.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var de=class{validation;message};var _t=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new de,logout:new de};isValid=!1};var Ot=class{validate(e){let t=this.validateField(e.clientId),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="The field clientId must be provided to use this SDK"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var xt=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new _t,r={apiKey:new vt,environment:new St,idSchema:new Ct,clientId:new Ot,lang:new Pt,authProvider:new Tt};for(let[o,a]of Object.entries(t))o!=="isValid"&&(a=r[o].validate(e));return Object.keys(r).forEach(o=>{t[o]=r[o].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[r,o]of Object.entries(e))if(r!=="authProvider"){if(r!=="isValid"&&o.message.type==="error")return t=!1,t;if(r!=="isValid"&&o.message.type==="warning")return t=!0,t}return t}};var At=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new X(e),this.idMapping=new _(e),this.localStorage=new T(e),this.footballFacade=new x(this.localStorage,this.https,this.idMapping)}getCountries=async()=>await this.footballFacade.getCountries();getCompetitions=async e=>await this.footballFacade.getCompetitions(e);getCompetitionById=async e=>await this.footballFacade.getCompetitionById(e);getTopCompetitions=async()=>await this.footballFacade.getTopCompetitions();getTeams=async e=>await this.footballFacade.getTeams(e);getTeamById=async e=>await this.footballFacade.getTeamById(e);getTopTeams=async()=>await this.footballFacade.getTopTeams();getNextMatchForTeam=async e=>await this.footballFacade.getNextMatchForTeam(e);getPrevMatchForTeam=async e=>await this.footballFacade.getPrevMatchForTeam(e);getPlayers=async e=>await this.footballFacade.getPlayers(e);getPlayerById=async e=>await this.footballFacade.getPlayerById(e);getTopPlayers=async()=>await this.footballFacade.getTopPlayers();getNextMatchForPlayer=async e=>await this.footballFacade.getNextMatchForPlayer(e);getPrevMatchForPlayer=async e=>await this.footballFacade.getPrevMatchForPlayer(e);getMatches=async e=>await this.footballFacade.getMatches(e);getMatchById=async e=>await this.footballFacade.getMatchById(e);search=async e=>await this.footballFacade.search(e)};var Vr=ae(q());var Bt=class{matchId=null;matchType=null;result=null;market=null;prediction;target;playerId;goalsHome;goalsAway};var Lt=class{value=!1;playerId=null};var A=class{matchId=null;market=null;prediction=null;constructor(e,t,r,o){this.matchId=e,this.market=t,this.prediction=new Lt,this.prediction.value=r,this.prediction.playerId=o}};var Nt=class{settledAt=null;resettledAt=null;status=null;outcome=null};var F=(m=>(m.FT_1X2="FT_1X2",m.HT_1X2="HT_1X2",m.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",m.DOUBLE_CHANCE="DOUBLE_CHANCE",m.HT_FT="HT_FT",m.PLAYER_SCORE="PLAYER_SCORE",m.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",m.PLAYER_RED_CARD="PLAYER_RED_CARD",m.RED_CARD_MATCH="RED_CARD_MATCH",m.PENALTY_MATCH="PENALTY_MATCH",m.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",m.CORNERS_MATCH="CORNERS_MATCH",m.CORRECT_SCORE="CORRECT_SCORE",m.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",m.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",m.OVER_GOALS_0_5="OVER_GOALS_0.5",m.OVER_GOALS_1_5="OVER_GOALS_1.5",m.OVER_GOALS_2_5="OVER_GOALS_2.5",m.OVER_GOALS_3_5="OVER_GOALS_3.5",m.OVER_GOALS_4_5="OVER_GOALS_4.5",m.OVER_GOALS_5_5="OVER_GOALS_5.5",m.OVER_GOALS_6_5="OVER_GOALS_6.5",m.OVER_CORNERS_6_5="OVER_CORNERS_6.5",m.OVER_CORNERS_7_5="OVER_CORNERS_7.5",m.OVER_CORNERS_8_5="OVER_CORNERS_8.5",m.OVER_CORNERS_9_5="OVER_CORNERS_9.5",m.OVER_CORNERS_10_5="OVER_CORNERS_10.5",m.OVER_CORNERS_11_5="OVER_CORNERS_11.5",m.OVER_CORNERS_12_5="OVER_CORNERS_12.5",m.OVER_CORNERS_13_5="OVER_CORNERS_13.5",m))(F||{}),eo=["OVER_GOALS_0.5","OVER_GOALS_1.5","OVER_GOALS_2.5","OVER_GOALS_3.5","OVER_GOALS_4.5","OVER_GOALS_5.5","OVER_GOALS_6.5"],to=["OVER_CORNERS_6.5","OVER_CORNERS_7.5","OVER_CORNERS_8.5","OVER_CORNERS_9.5","OVER_CORNERS_10.5","OVER_CORNERS_11.5","OVER_CORNERS_12.5","OVER_CORNERS_13.5"],ro=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var Vt=class{value=null};var z=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Vt,this.prediction.value=t}};var P=class{value=!1};var Q=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new P,this.prediction.value=r}};var Z=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new P,this.prediction.value=r}};var Dt=class{remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof A)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof Q||e instanceof Z){let r=e.market.split("_");t.market=r[0]+"_"+r[1],t.prediction=e.prediction.value,t.target=r[2]}else if(e instanceof z){t.market=e.market;let r=e.prediction.value.split(":");t.goals_home=r[0],t.goals_away=r[1]}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=e=>{let t=new Bt;return t.matchId=e.match_id,t.matchType=e.match_type,t.result=this.remapResult(e.result),t.market=e.market,e.prediction!==void 0&&(t.prediction=e.prediction),e.target&&(t.target=e.target),e.player_id&&(t.playerId=e.player_id),e.goals_home&&(t.goalsHome=e.goals_home),e.goals_away&&(t.goalsAway=e.goals_away),t};remapResult=e=>{let t=new Nt;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var Ut=class{id=null;gameInstanceId=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=null;status=null;tiebreaker=null;points=null;createdAt=null;updatedAt=null};var ee=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore={};doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch={};penaltyMatch={};playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals={};overOnePointFiveGoals={};overTwoPointFiveGoals={};overThreePointFiveGoals={};overFourPointFiveGoals={};overFivePointFiveGoals={};overSixPointFiveGoals={};overSixPointFiveCorners={};overSevenPointFiveCorners={};overEightPointFiveCorners={};overNinePointFiveCorners={};overTenPointFiveCorners={};overElevenPointFiveCorners={};overTwelvePointFiveCorners={};overThirteenPointFiveCorners={}};var te=class{fixturesRemapper=null;constructor(){this.fixturesRemapper=new Dt}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesRequest(r)),t};remapResponseBody=e=>{let t=new Ut;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesResponse(r)),t.status=e.status,t.tiebreaker=e.tiebreaker,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new ee;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:{},t.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:{},t.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:{},t.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:{},t.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:{},t.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:{},t.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:{},t.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:{},t.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:{},t.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:{},t.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:{},t.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:{},t.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:{},t.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:{},t.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:{},t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var $t=class{matchId=null;matchType=null;predictions=null};var qt=class{remapPredictions=null;constructor(){this.remapPredictions=new te}remapResponse=e=>{let t=new $t;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var kt=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;constructor(e){let t=C(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new te,this.matchSummaryRemapper=new qt,this.instanceAuth=Vr.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=Vr.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),r=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return this.predictionRemapper.remapResponseBody(r.data)}catch(t){return console.warn("There was a problem making POST request: ",t),t.message}};getMatchSummary=async e=>{try{let t=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(t.data)}catch(t){return console.warn(`There was a problem fetching predictions for match: ${e} `,t),t.message}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){return console.warn(`There was a problem deleting your prediction: ${e}`,t),!1}};getMyPredictions=async e=>{try{return(e?await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instanceAuth.get(`/predictions${this.apiSignInUrl}`)).data.data.map(r=>this.predictionRemapper.remapResponseBody(r))}catch(t){return console.warn("There was a problem fetching own predictions",t),t.message}}};var Ht=class{fullCoverageCompetitions=null;markets=null};var Gt=class{remapConfig=e=>{let t=new Ht;return t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t}};var Dr=(r=>(r.ONE="1",r.X="x",r.TWO="2",r))(Dr||{}),Ur=(r=>(r.ONE_X="1x",r.X_TWO="x2",r.ONE_TWO="12",r))(Ur||{}),$r=(c=>(c.ONE_ONE="1/1",c.ONE_X="1/x",c.ONE_TWO="1/2",c.X_ONE="x/1",c.X_X="x/x",c.X_TWO="x/2",c.TWO_ONE="2/1",c.TWO_X="2/x",c.TWO_TWO="2/2",c))($r||{});var jt=class{value=null};var Kt=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new jt,this.prediction.value=t}};var Xt=class{value=null};var Yt=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Xt,this.prediction.value=t}};var re=class{value=null};var Wt=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new re,this.prediction.value=t}};var Jt=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new re,this.prediction.value=t}};var zt=class{value};var Qt=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new zt,this.prediction.value=t}};var Zt=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new P,this.prediction.value=t}};var er=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new P,this.prediction.value=t}};var tr=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new P,this.prediction.value=t}};var rr=class{idMapping=null;constructor(e){this.idMapping=e}remapMatchIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"match","native")).match[0];remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[r,o]of Object.entries(e))if(t.includes(r))for(let a of Object.keys(o)){let n={player:[a]},p=(await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",this.idMapping.idSchema)).player[0];o[p]=o[a],delete o[a]}return e};convertMarket=e=>{let t=Object.keys(new ee),r=Object.values(F);for(let o=0;o<r.length;o++)e===r[o]&&(e=t[o]);return e};validateFixture=(e,t,r,o)=>{let a=Object.values(Dr),n=Object.values($r),l=Object.values(Ur);if(t==="FT_1X2"){if(a.includes(r))return new Wt(e,r)}else if(t==="HT_1X2"){if(a.includes(r))return new Jt(e,r)}else if(t==="HT_FT"){if(n.includes(r))return new Kt(e,r)}else if(t==="DOUBLE_CHANCE"){if(l.includes(r))return new Yt(e,r)}else if(t==="CORRECT_SCORE"){if(typeof r=="string"&&/\d+:\d+/.test(r))return new z(e,r)}else if(t==="CORNERS_MATCH"){if(typeof r=="number")return new Qt(e,r)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof r=="boolean")return new Zt(e,r)}else if(t==="RED_CARD_MATCH"){if(typeof r=="boolean")return new er(e,r)}else if(t==="PENALTY_MATCH"){if(typeof r=="boolean")return new tr(e,r)}else if(ro.includes(t)){if(o&&typeof r=="boolean")return new A(e,t,r,o)}else if(eo.includes(t)){if(typeof r=="boolean")return new Z(e,t,r)}else if(to.includes(t)&&typeof r=="boolean")return new Q(e,t,r)};getMarketSummary=(e,t)=>{let r=this.convertMarket(t),o={};if(o.matchId=e.matchId,o.matchType=e.matchType,Object.keys(e.predictions).includes(r))o[r]=e.predictions[r];else throw new Error("You have passed invalid market");return o};remapCompetitionsFromConfig=async e=>{let t={competition:e.fullCoverageCompetitions},r=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=r.competition,e};remapMyPredictions=async e=>{if(e&&e.length>0){for(let t of e){let o={match:[t.fixtures[0].matchId]},a=await this.idMapping.idMappingFacade.getEntitiesByIds(o,"native",this.idMapping.idSchema);t.fixtures[0].matchId=a.match[0]}return e}else return e}};var ir=class{gameInstanceId=null;fixtures=null};var or=class{limit=null;startAfter=null;status=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null}constructFilterUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&(e+="&",e+=`status=${this.status}`),e}};var ar=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,t,r){this.predictorHttps=e,this.idMapping=r,this.clientHttps=t,this.predictorConfigRemapper=new Gt,this.predictorService=new rr(r)}makeFootballPrediction=async(e,t,r,o)=>{let a=this.predictorService.validateFixture(e,t,r,o),n=new ir;if(a)if(this.idMapping.idSchema!=="native"){let l=a.matchId,p="";if(a.matchId=await this.predictorService.remapMatchIdToNative([l]),!a.matchId)throw new Error("Match id is invalid!");if(a instanceof A&&(p=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([p]),!a.prediction.playerId))throw new Error("Player id is invalid!");n.fixtures=[a];let c=await this.predictorHttps.makeFootballPrediction(n);return c.fixtures.map(s=>{s.playerId&&(s.playerId=p),s.matchId=l}),c}else return n.fixtures=[a],await this.predictorHttps.makeFootballPrediction(n);else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model")};getMatchSummary=async e=>{if(this.idMapping.idSchema!=="native"){let t=await this.predictorService.remapMatchIdToNative([e]),r=await this.predictorHttps.getMatchSummary(t);r.matchId=e;let o=r.predictions,a=await this.predictorService.remapPlayerIdToIdSchema(o);return r.predictions=a,r}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,t)=>{try{let r=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(r,t)}catch(r){return r.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig(),t=await this.predictorConfigRemapper.remapConfig(e.predictor);return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{if(e&&(e=new or(e)),this.idMapping.idSchema!=="native"){let t=await this.predictorHttps.getMyPredictions(e);return await this.predictorService.remapMyPredictions(t)}return await this.predictorHttps.getMyPredictions(e)};getUserPastPredictions=()=>{};getUserCurrentPredictions=()=>{}};var io=ae(q());var ie=class{instance=null;apiSignInUrl="";constructor(e){let t=C(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=io.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getConfig=async()=>{try{return(await this.instance.get(`${this.apiSignInUrl}`)).data.data}catch(e){return console.warn("There was a problem fetching configuration from Client API",e),e.message}}};var nr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.predictorHttps=new kt(e),this.clientHttps=new ie(e),this.idMapping=new _(e),this.predictorFacade=new ar(this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,r,o)=>await this.predictorFacade.makeFootballPrediction(e,t,r,o);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,t)=>await this.predictorFacade.getMarketSummary(e,t);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getUserPastPredictions=()=>{};getUserCurrentPredictions=()=>{}};var sr=class{general=[];predictor=[];topX=[]};var lr=class{enabled=!1;rewards=null};var pr=class{general=null;topX=null;predictor=null};var cr=class{points=null;tiers=null;badges=null};var mr=class{remapLoyaltyResponse=e=>{let t=new lr;return t.enabled=e.enabled,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new cr;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new pr;return t.general=e.general,t.topX=e.top_x,t.predictor=e.predictor,t};remapBadges=e=>{let t=new sr;return t.general=e.general,t.predictor=e.predictor,t.topX=e.top_x,t}};var ur=class{https=null;loyaltyRemapper=null;constructor(e){this.https=e,this.loyaltyRemapper=new mr}getConfig=async()=>{let e=await this.https.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)}};var dr=class{https=null;loyaltyFacade=null;constructor(e){this.https=new ie(e),this.loyaltyFacade=new ur(this.https)}getConfig=async()=>await this.loyaltyFacade.getConfig()};function _u(i){let t=new xt().validate(i);if(t.idSchema.validation==="missing"&&(console.warn(t.idSchema.message.text),i.idSchema="native"),t.environment.validation==="missing"&&(console.warn(t.environment.message.text),i.environment="prod"),t.lang.validation==="missing"&&(console.warn(t.lang.message.text),i.lang="en"),t.isValid)return{profile:new Ft(i),football:new At(i),predictor:new nr(i),loyalty:new dr(i)};throw new Error("Configuration is not valid")}export{_u as FansUnitedSDK};
|
|
1
|
+
var so=Object.create;var wr=Object.defineProperty;var lo=Object.getOwnPropertyDescriptor;var po=Object.getOwnPropertyNames;var co=Object.getPrototypeOf,mo=Object.prototype.hasOwnProperty;var uo=i=>wr(i,"__esModule",{value:!0});var d=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var ho=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of po(e))!mo.call(i,o)&&(t||o!=="default")&&wr(i,o,{get:()=>e[o],enumerable:!(r=lo(e,o))||r.enumerable});return i},ae=(i,e)=>ho(uo(wr(i!=null?so(co(i)):{},"default",!e&&i&&i.__esModule?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var br=d((ua,Kr)=>{"use strict";Kr.exports=function(e,t){return function(){for(var o=new Array(arguments.length),a=0;a<o.length;a++)o[a]=arguments[a];return e.apply(t,o)}}});var w=d((da,Wr)=>{"use strict";var fo=br(),N=Object.prototype.toString;function Mr(i){return N.call(i)==="[object Array]"}function Rr(i){return typeof i=="undefined"}function yo(i){return i!==null&&!Rr(i)&&i.constructor!==null&&!Rr(i.constructor)&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function go(i){return N.call(i)==="[object ArrayBuffer]"}function wo(i){return typeof FormData!="undefined"&&i instanceof FormData}function bo(i){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(i):e=i&&i.buffer&&i.buffer instanceof ArrayBuffer,e}function Mo(i){return typeof i=="string"}function Ro(i){return typeof i=="number"}function Yr(i){return i!==null&&typeof i=="object"}function ye(i){if(N.call(i)!=="[object Object]")return!1;var e=Object.getPrototypeOf(i);return e===null||e===Object.prototype}function Io(i){return N.call(i)==="[object Date]"}function Fo(i){return N.call(i)==="[object File]"}function Po(i){return N.call(i)==="[object Blob]"}function Xr(i){return N.call(i)==="[object Function]"}function So(i){return Yr(i)&&Xr(i.pipe)}function vo(i){return typeof URLSearchParams!="undefined"&&i instanceof URLSearchParams}function Co(i){return i.trim?i.trim():i.replace(/^\s+|\s+$/g,"")}function Eo(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Ir(i,e){if(!(i===null||typeof i=="undefined"))if(typeof i!="object"&&(i=[i]),Mr(i))for(var t=0,r=i.length;t<r;t++)e.call(null,i[t],t,i);else for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&e.call(null,i[o],o,i)}function Fr(){var i={};function e(o,a){ye(i[a])&&ye(o)?i[a]=Fr(i[a],o):ye(o)?i[a]=Fr({},o):Mr(o)?i[a]=o.slice():i[a]=o}for(var t=0,r=arguments.length;t<r;t++)Ir(arguments[t],e);return i}function To(i,e,t){return Ir(e,function(o,a){t&&typeof o=="function"?i[a]=fo(o,t):i[a]=o}),i}function _o(i){return i.charCodeAt(0)===65279&&(i=i.slice(1)),i}Wr.exports={isArray:Mr,isArrayBuffer:go,isBuffer:yo,isFormData:wo,isArrayBufferView:bo,isString:Mo,isNumber:Ro,isObject:Yr,isPlainObject:ye,isUndefined:Rr,isDate:Io,isFile:Fo,isBlob:Po,isFunction:Xr,isStream:So,isURLSearchParams:vo,isStandardBrowserEnv:Eo,forEach:Ir,merge:Fr,extend:To,trim:Co,stripBOM:_o}});var Pr=d((ha,zr)=>{"use strict";var U=w();function Jr(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}zr.exports=function(e,t,r){if(!t)return e;var o;if(r)o=r(t);else if(U.isURLSearchParams(t))o=t.toString();else{var a=[];U.forEach(t,function(p,c){p===null||typeof p=="undefined"||(U.isArray(p)?c=c+"[]":p=[p],U.forEach(p,function(u){U.isDate(u)?u=u.toISOString():U.isObject(u)&&(u=JSON.stringify(u)),a.push(Jr(c)+"="+Jr(u))}))}),o=a.join("&")}if(o){var n=e.indexOf("#");n!==-1&&(e=e.slice(0,n)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}});var Zr=d((fa,Qr)=>{"use strict";var Oo=w();function ge(){this.handlers=[]}ge.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1};ge.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};ge.prototype.forEach=function(e){Oo.forEach(this.handlers,function(r){r!==null&&e(r)})};Qr.exports=ge});var ti=d((ya,ei)=>{"use strict";var xo=w();ei.exports=function(e,t){xo.forEach(e,function(o,a){a!==t&&a.toUpperCase()===t.toUpperCase()&&(e[t]=o,delete e[a])})}});var Sr=d((ga,ri)=>{"use strict";ri.exports=function(e,t,r,o,a){return e.config=t,r&&(e.code=r),e.request=o,e.response=a,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var vr=d((wa,ii)=>{"use strict";var Ao=Sr();ii.exports=function(e,t,r,o,a){var n=new Error(e);return Ao(n,t,r,o,a)}});var ai=d((ba,oi)=>{"use strict";var Bo=vr();oi.exports=function(e,t,r){var o=r.config.validateStatus;!r.status||!o||o(r.status)?e(r):t(Bo("Request failed with status code "+r.status,r.config,null,r.request,r))}});var si=d((Ma,ni)=>{"use strict";var we=w();ni.exports=we.isStandardBrowserEnv()?function(){return{write:function(t,r,o,a,n,l){var p=[];p.push(t+"="+encodeURIComponent(r)),we.isNumber(o)&&p.push("expires="+new Date(o).toGMTString()),we.isString(a)&&p.push("path="+a),we.isString(n)&&p.push("domain="+n),l===!0&&p.push("secure"),document.cookie=p.join("; ")},read:function(t){var r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var pi=d((Ra,li)=>{"use strict";li.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var mi=d((Ia,ci)=>{"use strict";ci.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}});var di=d((Fa,ui)=>{"use strict";var Lo=pi(),No=mi();ui.exports=function(e,t){return e&&!Lo(t)?No(e,t):t}});var fi=d((Pa,hi)=>{"use strict";var Cr=w(),Vo=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];hi.exports=function(e){var t={},r,o,a;return e&&Cr.forEach(e.split(`
|
|
2
|
+
`),function(l){if(a=l.indexOf(":"),r=Cr.trim(l.substr(0,a)).toLowerCase(),o=Cr.trim(l.substr(a+1)),r){if(t[r]&&Vo.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([o]):t[r]=t[r]?t[r]+", "+o:o}}),t}});var wi=d((Sa,gi)=>{"use strict";var yi=w();gi.exports=yi.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function o(a){var n=a;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=o(window.location.href),function(n){var l=yi.isString(n)?o(n):n;return l.protocol===r.protocol&&l.host===r.host}}():function(){return function(){return!0}}()});var ne=d((va,bi)=>{"use strict";function Er(i){this.message=i}Er.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Er.prototype.__CANCEL__=!0;bi.exports=Er});var _r=d((Ca,Mi)=>{"use strict";var be=w(),Uo=ai(),Do=si(),$o=Pr(),qo=di(),ko=fi(),Ho=wi(),Tr=vr(),Go=se(),jo=ne();Mi.exports=function(e){return new Promise(function(r,o){var a=e.data,n=e.headers,l=e.responseType,p;function c(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}be.isFormData(a)&&delete n["Content-Type"];var s=new XMLHttpRequest;if(e.auth){var u=e.auth.username||"",g=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";n.Authorization="Basic "+btoa(u+":"+g)}var oe=qo(e.baseURL,e.url);s.open(e.method.toUpperCase(),$o(oe,e.params,e.paramsSerializer),!0),s.timeout=e.timeout;function Gr(){if(!!s){var v="getAllResponseHeaders"in s?ko(s.getAllResponseHeaders()):null,V=!l||l==="text"||l==="json"?s.responseText:s.response,L={data:V,status:s.status,statusText:s.statusText,headers:v,config:e,request:s};Uo(function(gr){r(gr),c()},function(gr){o(gr),c()},L),s=null}}if("onloadend"in s?s.onloadend=Gr:s.onreadystatechange=function(){!s||s.readyState!==4||s.status===0&&!(s.responseURL&&s.responseURL.indexOf("file:")===0)||setTimeout(Gr)},s.onabort=function(){!s||(o(Tr("Request aborted",e,"ECONNABORTED",s)),s=null)},s.onerror=function(){o(Tr("Network Error",e,null,s)),s=null},s.ontimeout=function(){var V=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",L=e.transitional||Go.transitional;e.timeoutErrorMessage&&(V=e.timeoutErrorMessage),o(Tr(V,e,L.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",s)),s=null},be.isStandardBrowserEnv()){var jr=(e.withCredentials||Ho(oe))&&e.xsrfCookieName?Do.read(e.xsrfCookieName):void 0;jr&&(n[e.xsrfHeaderName]=jr)}"setRequestHeader"in s&&be.forEach(n,function(V,L){typeof a=="undefined"&&L.toLowerCase()==="content-type"?delete n[L]:s.setRequestHeader(L,V)}),be.isUndefined(e.withCredentials)||(s.withCredentials=!!e.withCredentials),l&&l!=="json"&&(s.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&s.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&s.upload&&s.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(v){!s||(o(!v||v&&v.type?new jo("canceled"):v),s.abort(),s=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),a||(a=null),s.send(a)})}});var se=d((Ea,Fi)=>{"use strict";var f=w(),Ri=ti(),Ko=Sr(),Yo={"Content-Type":"application/x-www-form-urlencoded"};function Ii(i,e){!f.isUndefined(i)&&f.isUndefined(i["Content-Type"])&&(i["Content-Type"]=e)}function Xo(){var i;return typeof XMLHttpRequest!="undefined"?i=_r():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(i=_r()),i}function Wo(i,e,t){if(f.isString(i))try{return(e||JSON.parse)(i),f.trim(i)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(i)}var Me={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Xo(),transformRequest:[function(e,t){return Ri(t,"Accept"),Ri(t,"Content-Type"),f.isFormData(e)||f.isArrayBuffer(e)||f.isBuffer(e)||f.isStream(e)||f.isFile(e)||f.isBlob(e)?e:f.isArrayBufferView(e)?e.buffer:f.isURLSearchParams(e)?(Ii(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):f.isObject(e)||t&&t["Content-Type"]==="application/json"?(Ii(t,"application/json"),Wo(e)):e}],transformResponse:[function(e){var t=this.transitional||Me.transitional,r=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,a=!r&&this.responseType==="json";if(a||o&&f.isString(e)&&e.length)try{return JSON.parse(e)}catch(n){if(a)throw n.name==="SyntaxError"?Ko(n,this,"E_JSON_PARSE"):n}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};f.forEach(["delete","get","head"],function(e){Me.headers[e]={}});f.forEach(["post","put","patch"],function(e){Me.headers[e]=f.merge(Yo)});Fi.exports=Me});var Si=d((Ta,Pi)=>{"use strict";var Jo=w(),zo=se();Pi.exports=function(e,t,r){var o=this||zo;return Jo.forEach(r,function(n){e=n.call(o,e,t)}),e}});var Or=d((_a,vi)=>{"use strict";vi.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ti=d((Oa,Ei)=>{"use strict";var Ci=w(),xr=Si(),Qo=Or(),Zo=se(),ea=ne();function Ar(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new ea("canceled")}Ei.exports=function(e){Ar(e),e.headers=e.headers||{},e.data=xr.call(e,e.data,e.headers,e.transformRequest),e.headers=Ci.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ci.forEach(["delete","get","head","post","put","patch","common"],function(o){delete e.headers[o]});var t=e.adapter||Zo.adapter;return t(e).then(function(o){return Ar(e),o.data=xr.call(e,o.data,o.headers,e.transformResponse),o},function(o){return Qo(o)||(Ar(e),o&&o.response&&(o.response.data=xr.call(e,o.response.data,o.response.headers,e.transformResponse))),Promise.reject(o)})}});var Br=d((xa,_i)=>{"use strict";var M=w();_i.exports=function(e,t){t=t||{};var r={};function o(s,u){return M.isPlainObject(s)&&M.isPlainObject(u)?M.merge(s,u):M.isPlainObject(u)?M.merge({},u):M.isArray(u)?u.slice():u}function a(s){if(M.isUndefined(t[s])){if(!M.isUndefined(e[s]))return o(void 0,e[s])}else return o(e[s],t[s])}function n(s){if(!M.isUndefined(t[s]))return o(void 0,t[s])}function l(s){if(M.isUndefined(t[s])){if(!M.isUndefined(e[s]))return o(void 0,e[s])}else return o(void 0,t[s])}function p(s){if(s in t)return o(e[s],t[s]);if(s in e)return o(void 0,e[s])}var c={url:n,method:n,data:n,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:p};return M.forEach(Object.keys(e).concat(Object.keys(t)),function(u){var g=c[u]||a,oe=g(u);M.isUndefined(oe)&&g!==p||(r[u]=oe)}),r}});var Lr=d((Aa,Oi)=>{Oi.exports={version:"0.24.0"}});var Bi=d((Ba,Ai)=>{"use strict";var ta=Lr().version,Nr={};["object","boolean","number","function","string","symbol"].forEach(function(i,e){Nr[i]=function(r){return typeof r===i||"a"+(e<1?"n ":" ")+i}});var xi={};Nr.transitional=function(e,t,r){function o(a,n){return"[Axios v"+ta+"] Transitional option '"+a+"'"+n+(r?". "+r:"")}return function(a,n,l){if(e===!1)throw new Error(o(n," has been removed"+(t?" in "+t:"")));return t&&!xi[n]&&(xi[n]=!0,console.warn(o(n," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,n,l):!0}};function ra(i,e,t){if(typeof i!="object")throw new TypeError("options must be an object");for(var r=Object.keys(i),o=r.length;o-- >0;){var a=r[o],n=e[a];if(n){var l=i[a],p=l===void 0||n(l,a,i);if(p!==!0)throw new TypeError("option "+a+" must be "+p);continue}if(t!==!0)throw Error("Unknown option "+a)}}Ai.exports={assertOptions:ra,validators:Nr}});var $i=d((La,Di)=>{"use strict";var Li=w(),ia=Pr(),Ni=Zr(),Vi=Ti(),Re=Br(),Ui=Bi(),D=Ui.validators;function le(i){this.defaults=i,this.interceptors={request:new Ni,response:new Ni}}le.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Re(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&Ui.assertOptions(t,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1);var r=[],o=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(e)===!1||(o=o&&g.synchronous,r.unshift(g.fulfilled,g.rejected))});var a=[];this.interceptors.response.forEach(function(g){a.push(g.fulfilled,g.rejected)});var n;if(!o){var l=[Vi,void 0];for(Array.prototype.unshift.apply(l,r),l=l.concat(a),n=Promise.resolve(e);l.length;)n=n.then(l.shift(),l.shift());return n}for(var p=e;r.length;){var c=r.shift(),s=r.shift();try{p=c(p)}catch(u){s(u);break}}try{n=Vi(p)}catch(u){return Promise.reject(u)}for(;a.length;)n=n.then(a.shift(),a.shift());return n};le.prototype.getUri=function(e){return e=Re(this.defaults,e),ia(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Li.forEach(["delete","get","head","options"],function(e){le.prototype[e]=function(t,r){return this.request(Re(r||{},{method:e,url:t,data:(r||{}).data}))}});Li.forEach(["post","put","patch"],function(e){le.prototype[e]=function(t,r,o){return this.request(Re(o||{},{method:e,url:t,data:r}))}});Di.exports=le});var ki=d((Na,qi)=>{"use strict";var oa=ne();function $(i){if(typeof i!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(o){e=o});var t=this;this.promise.then(function(r){if(!!t._listeners){var o,a=t._listeners.length;for(o=0;o<a;o++)t._listeners[o](r);t._listeners=null}}),this.promise.then=function(r){var o,a=new Promise(function(n){t.subscribe(n),o=n}).then(r);return a.cancel=function(){t.unsubscribe(o)},a},i(function(o){t.reason||(t.reason=new oa(o),e(t.reason))})}$.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};$.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};$.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};$.source=function(){var e,t=new $(function(o){e=o});return{token:t,cancel:e}};qi.exports=$});var Gi=d((Va,Hi)=>{"use strict";Hi.exports=function(e){return function(r){return e.apply(null,r)}}});var Ki=d((Ua,ji)=>{"use strict";ji.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Wi=d((Da,Vr)=>{"use strict";var Yi=w(),aa=br(),Ie=$i(),na=Br(),sa=se();function Xi(i){var e=new Ie(i),t=aa(Ie.prototype.request,e);return Yi.extend(t,Ie.prototype,e),Yi.extend(t,e),t.create=function(o){return Xi(na(i,o))},t}var C=Xi(sa);C.Axios=Ie;C.Cancel=ne();C.CancelToken=ki();C.isCancel=Or();C.VERSION=Lr().version;C.all=function(e){return Promise.all(e)};C.spread=Gi();C.isAxiosError=Ki();Vr.exports=C;Vr.exports.default=C});var q=d(($a,Ji)=>{Ji.exports=Wi()});var Dr=ae(q());var Ur=i=>{let e=[],t=0;return i.forEach(r=>{e[t]?e[t].length<249?e[t].push(r):(t=t+1,e[t]=[r]):e[t]=[r]}),e},Fe=i=>{let e=[],t=200;for(;i.length>t-1;){let r=i.splice(0,t-1);e.push(r)}return e.push(i),e},E=(i,e)=>{let t="";return i==="prod"||i==="sandbox"?t={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1"}[e]:t={profile:"http://localhost:8010",football:"http://locahost:8080",idMapping:"http://localhost:8030",predictor:"http://localhost:8040",client:"http://localhost:8080"}[e],t};var Pe=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[]};var Se=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new Pe;return t.avatar=e.avatar,t.birthDate=e.birth_date,t.country=e.country,t.gender=e.gender,t.id=e.id,t.interests=e.interests,t.name=e.name,t};profileToRequest=e=>({country_id:e.country?e.country.id:null,gender:e.gender,birth_date:e.birthDate,interests:e.interests,name:e.name})};var ve=class{avatar=null;followingId=null;name=null;profileId=null};var Ce=class{followingFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new ve;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var Ee=class{avatar=null;followerId=null;name=null;profileId=null};var Te=class{followersFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new Ee;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var pe=class{profile_ids=[]};var la="/countries",F="/profile",zi="/profiles",_e=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;constructor(e){let t=E(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}&lang=${e.lang}`,this.instanceAuth=Dr.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=Dr.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new Se,this.followingRemapper=new Ce,this.followersRemapper=new Te}getCountries=async()=>{try{return(await this.instance.get(`${la}${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching the countries:",e),e}};getProfile=async e=>{let t=`${F}${this.apiSignInUrl}`;if(e){t=`${zi}/${e}${this.apiSignInUrl}`;try{let r=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r}}else try{let r=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r}};getProfiles=async e=>{try{let t=await this.instance.get(`${zi}${this.apiSignInUrl}&profile_ids=${e.join(",")}`);return this.profileRemapper.profilesFromResponse(t.data.data)}catch(t){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,t),t}};getFollowers=async(e,t)=>{let r=`${F}/followers${this.apiSignInUrl}`;if(e&&!t){r=`${F}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(o.data.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o}}else if(!e&&!t)try{let o=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(o.data.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o}e&&t?r=`${F}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${F}/${t}/followers${this.apiSignInUrl}`);try{let o=await this.instance.get(r);return this.followersRemapper.followersFromResponse(o.data.data)}catch(o){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,o),o}};getFollowing=async(e,t)=>{let r=`${F}/following${this.apiSignInUrl}`;if(e&&!t){r=`${F}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(o.data.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o}}else if(!e&&!t)try{let o=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(o.data.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o}e&&t?r=`${F}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${F}/${t}/following${this.apiSignInUrl}`);try{let o=await this.instance.get(r);return this.followingRemapper.followingFromResponse(o.data.data)}catch(o){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o}};follow=async e=>{let t=new pe;t.profile_ids=e;try{let r=await this.instanceAuth.post(`${F}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followingFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,r),r}};unfollow=async e=>{let t=new pe;t.profile_ids=e;try{return await this.instanceAuth.delete(`${F}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(r){return console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),!1}};updateProfile=async e=>{try{let t=this.profileRemapper.profileToRequest(e),r=await this.instanceAuth.patch(`${F}${this.apiSignInUrl}`,t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t}}};var T={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var Qi="FansUnited",Zi={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},_=class{idSchema="";exparationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Zi)}clearData=()=>{this.setData(Zi)};getEntityById=(e="",t="")=>this.getData().football.ids.find(r=>{let o=T[this.idSchema];return r&&`${r[o]}`===t&&r.resource===e});getEntity=(e,t,r)=>Array.isArray(e)?this.getData().football.ids.filter(o=>{let a=T[r];return o&&e.includes(`${o[a]}`)&&o.resource===t}):this.getData().football.ids.find(o=>{let a=T[r];return o&&`${o[a]}`===e&&o.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(r=>r&&`${r.id}`===t&&r.resource===e);checkForExistingIdObjs=(e,t)=>{let r=T[t],o={};return Object.keys(e).forEach(a=>{let n=e[a],p=this.getEntity(n,a,t).map(s=>s[r]),c=e[a].filter(s=>!p.includes(s));o[a]=n.map(s=>c.includes(s)?{id:s,exists:!1}:{id:s,exists:!0})}),o};getIdsByType=(e,t,r)=>{let o=T[r],a=T[t],n={};return Object.keys(e).forEach(l=>{let p=e[l],c=[];this.getData().football.ids.forEach(s=>{p.forEach((u,g)=>{u===s[a]&&l===s.resource&&(c[g]=s[o])})}),n[l]=c}),n};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),r=t.football.ids;r=[...r,...e],t.football.ids=r,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.own=e,t.profile.expireAt=Math.floor(Date.now()/1e3)+this.exparationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.own;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData();t.football.competitions.push(...e),this.setData(t)};getExparationProfile=()=>this.getData().profile.expireAt;getData=()=>JSON.parse(localStorage.getItem(Qi));setData=e=>{localStorage.setItem(Qi,JSON.stringify(e))}};var eo=ae(q());var ce={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Oe=class{instance=null;apiSignInUrl="";constructor(e){let t=E(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=eo.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${ce[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r}};getEntityByIdAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ce[e]}=${t}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,o),o}};getEntityIdsByIdsAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ce[e]}=${t.join(",")}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,o),o}};getEntitiesByIds=(e,t,r)=>{t.sort((n,l)=>n.localeCompare(l));let a=Ur(t).map(n=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ce[e]}=${n.join(",")}`)}catch(l){throw console.warn(`There was a problem with id mapping request for the following ids:${n.join(",")}`,l),l}});return Promise.all(a).then(n=>{let l=[];return n.forEach(p=>{l.push(...p.data.data)}),l})};getEntitiesByIdObjs=(e,t)=>{let r=[];return Object.keys(e).forEach(o=>{let n=Ur(e[o]).map(l=>{l.sort((p,c)=>p.localeCompare(c));try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}&${ce[o]}=${l.join(",")}`)}catch(p){throw console.warn(`There was a problem with id mapping request for the following ids:${l.join(",")}`,p),p}});r=[...r,...n]}),Promise.all(r).then(o=>{let a=[];return o.forEach(n=>{a.push(...n.data.data)}),a})}};var xe=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new _(e),this.https=new Oe(e)}getEntitiesByIds=async(e,t,r)=>{if(this.isBrowser)try{let o=this.localStorage.checkForExistingIdObjs(e,t),a=this.splitForRequestAndExisting(o),n=await this.https.getEntitiesByIdObjs(a.request,t);return this.localStorage.addIdMappings(n),this.localStorage.getIdsByType(e,t,r)}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}else try{let o=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(a=>{e[a]=o.filter(n=>n.resource===a).map(n=>n[T[r]])}),e}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}};getEntityById=async(e,t,r)=>{if(this.isBrowser){let o=this.localStorage.getEntity(e,t,r);if(o)return o;{let a=await this.requestEntity(e,t,r);return this.localStorage.addIdMappings(a),a}}else return await this.requestEntity(e,t,r)};splitForRequestAndExisting=e=>{let t={},r={};return Object.keys(e).forEach(o=>{t[o]=e[o].filter(a=>!a.exists).map(a=>a.id),r[o]=e[o].filter(a=>a.exists).map(a=>a.id)}),{existing:r,request:t}};requestEntity=async(e,t,r)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,r)}catch(o){return console.warn(`There was a problem retrieving the requested entity: ${o}`),null}}};var Ae=i=>{switch(i){case"competitions":return"competition";case"players":case"relatedPlayer":case"squad":return"player";case"teams":case"participants":case"homeTeam":case"awayTeam":case"timeline":case"teamId":return"team";default:return i}};var Be=class{extractedObjIds={};traverse=(e,t)=>(t=Ae(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(r=>{this.traverseObjExtract(r,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{let o=e[r];r==="id"||r==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),this.extractedObjIds[t].push(o)):e[r]&&this.traverse(e[r],r)})}};var Le=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,r)=>(t=Ae(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(r),this.remappedIdsObj=r),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(r=>{this.traverseObjReplace(r,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{r==="id"||r==="teamId"?(e[r]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[r]&&this.traverse(e[r],r,this.remappedIdsObj)})}};var O=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new xe(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let r=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let a=new Be().traverse(r,t);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(n=>new Le().traverse(r,t,n))}else return e}catch(o){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,o),[]}};getEntityIdsBySchemaId=async(e,t,r)=>{let o={};return o[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(o,this.idSchema,r):o}};var R=class{completed=!1;percentage;constructor(e){this.percentage=e}};var Ve=class{teamFollowed=new R(10);teamFavourite=new R(15);playerFollowed=new R(10);playerFavourite=new R(10);competitionFollowed=new R(10);competitionFavourite=new R(5);addedBirthdate=new R(10);addedGender=new R(10);addedCountry=new R(10);addedAvatar=new R(10)};var Ue=class{totalPercentage;breakdown=new Ve};var me=class{limit=0;startAfter=null;constructor(e){this.limit=e.limit?e.limit:20,this.startAfter=e.startAfter?e.startAfter:null}constructFilterUrl=()=>{let e="";return this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.startAfter&&(e=e+"&",e=e+`start_after=${this.startAfter}`),e}};var x=class{isBrowser=!1;localStorage={};https=null;constructor(e,t){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.https=t}getOwn=async()=>{if(this.isBrowser){let e=Math.floor(Date.now()/1e3),t=this.localStorage.getExparationProfile(),r=null;if(t>e&&(r=this.localStorage.getOwnProfile()),r)return r;try{let o=await this.https.getProfile();return this.localStorage.setOwnProfile(o),o}catch(o){throw console.warn("There was a problem retrieving your profile: ",o),o}}else try{return await this.https.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async e=>{try{return await this.https.getProfiles(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,t),t}};getById=async e=>{try{return await this.https.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async()=>{if(this.isBrowser){let e=this.localStorage.getProfileCountries();if(e&&e.length>0)return e;try{let t=await this.https.getCountries();return this.localStorage.setProfileCountries(t),t}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}}else try{return await this.https.getCountries()}catch(e){throw console.warn("There was a problem retrieving profile countries: ",e),e}};getFollowers=async(e,t)=>{try{return e&&(e=new me(e)),await this.https.getFollowers(e,t)}catch(r){throw console.warn("There was a problem retrieving your followers: ",r),r}};getFollowing=async(e,t)=>{try{return e&&(e=new me(e)),await this.https.getFollowing(e,t)}catch(r){throw console.warn("There was a problem retrieving your following profiles: ",r),r}};follow=async e=>{try{return await this.https.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.https.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new Ue,r=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,r+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,r+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,r+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,r+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(s=>s.type==="team"&&s.favourite)&&(t.breakdown.teamFavourite.completed=!0,r+=t.breakdown.teamFavourite.percentage),e.interests.find(s=>s.type==="team")&&(t.breakdown.teamFollowed.completed=!0,r+=t.breakdown.teamFollowed.percentage),e.interests.find(s=>s.type==="player"&&s.favourite)&&(t.breakdown.playerFavourite.completed=!0,r+=t.breakdown.playerFavourite.percentage),e.interests.find(s=>s.type==="player")&&(t.breakdown.playerFollowed.completed=!0,r+=t.breakdown.playerFollowed.percentage),e.interests.find(s=>s.type==="competition"&&s.favourite)&&(t.breakdown.competitionFavourite.completed=!0,r+=t.breakdown.competitionFavourite.percentage),e.interests.find(s=>s.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,r+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=r,t}};var De=class{id=null;name=null;assets=null};var $e=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCountriesWithIdMapping=async()=>{try{let e=await this.getCountries();return this.idMapping.remapEntities(e,"country")}catch(e){throw console.warn("There was a problem browsing countries as football entities",e),e}};getCountries=async()=>{if(this.isBrowser){let e=this.localStorage.getFootballCountries();if(e&&e.length>0)return e;try{let t=await this.https.getCountries();return this.localStorage.setFootballCountries(t),t}catch(t){throw console.warn("There was a problem retrieving countries as football entities",t),t}}else return this.https.getCountries()}};var qe=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(r=>{let o=!0;return t.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?o&&=r.country.id===this[a]:a==="name"?o&&=r.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?o&&=this[a].some(n=>r.id===n):o&&=r[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),o})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((r,o)=>this.sortOrder&&this.sortOrder==="desc"?o.name.localeCompare(r.name):r.name.localeCompare(o.name)):this.sortField==="countryId"?t=e.sort((r,o)=>this.sortOrder&&this.sortOrder==="desc"?o.country.id.localeCompare(r.country.id):r.country.id.localeCompare(o.country.id)):this.sortField==="scope"?e.forEach(r=>t[this.competitionIds.indexOf(r.id)]=r):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((r,o)=>o.id.localeCompare(r.id))),t}};var ke=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCompetitionsIdMapping=async e=>{try{let t=!1;if(e){if(e=new qe(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");o.country.length===0&&(t=!0),e.countryId=o.country[0]}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");o.competition.length===0&&(t=!0),e.competitionIds=o.competition}if(t)return[]}let r=await this.getCompetitions(e);return await this.idMapping.remapEntities(r,"competition")}catch(t){throw console.warn("There was a problem browsing all of the competitions",t),t}};getCompetitions=async e=>{if(this.isBrowser){let t=this.localStorage.getCompetitions(e);if(t&&t.length>0)return t;try{let r=await this.https.getCompetitions(e);return this.localStorage.setCompetitions(r),this.localStorage.getCompetitions(e)}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}}else return this.https.getCompetitions(e)};getCompetitionByIdIdMapping=async e=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],o=await this.getCompetitionById(r);return await this.idMapping.remapEntities(o,"competition")}catch(t){throw console.warn(`There was a problem browsing the following competition:${e}`,t),t}};getCompetitionById=async e=>{try{return await this.https.getCompetitionById(e)}catch(t){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,t),t}};getTopCompetitionsIdMapping=async()=>{try{let e=await this.getTopCompetitions();return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async()=>{try{return await this.https.getTopCompetitions()}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var He=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(e){this.name=e.name?e.name:null,this.countryId=e.countryId?`${e.countryId}`:null,this.national=e.national?e.national:!1,this.gender=e.gender?e.gender:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.scope=e.scope?e.scope:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.teamIds=e.teamIds?e.teamIds:null}constructFilterUrl=()=>{let e="";return this.name&&(e=e+"&",e=e+`name=${this.name}`),this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.national&&(e=e+"&",e=e+`national=${this.national}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.teamIds&&(e=e+"&",e=e+`team_ids=${this.teamIds.join(",")}`),e}};var Ge=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getTeamsIdMapping=async e=>{try{let t=!1;if(e){if(e=new He(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");o.country.length===0&&(t=!0),e.countryId=o.country[0]}if(e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");o.competition.length===0&&(t=!0),e.scope=o.competition}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");o.team.length===0&&(t=!0),e.teamIds=o.team}}if(t)return[];let r=await this.getTeams(e);return await this.idMapping.remapEntities(r,"team")}catch(t){throw console.warn("There was a problem browsing all teams",t),t}};getTeams=async e=>{try{return await this.https.getTeams(e)}catch(t){throw console.warn("There was a problem retrieving all teams",t),t}};getTeamByIdIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getTeamById(e);return await this.idMapping.remapEntities(r,"team")}catch(t){throw console.warn(`There was a problem browsing the following team:${e}`,t),t}};getTeamById=async e=>{try{return await this.https.getTeamById(e)}catch(t){throw console.warn(`There was a problem retrieving the following team: ${e}`,t),t}};getTopTeamsIdMapping=async()=>{try{let e=await this.getTopTeams();return await this.idMapping.remapEntities(e,"team")}catch(e){throw console.warn("There was a problem browsing the top teams",e),e}};getTopTeams=async()=>{try{return await this.https.getTopTeams()}catch(e){throw console.warn("There was a problem retrieving the top teams",e),e}};getNextMatchForTeamIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getNextMatchForTeam(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,t),t}};getNextMatchForTeam=async e=>{try{return await this.https.getNextMatchForTeam(e)}catch(t){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,t),t}};getPrevMatchForTeamIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getPrevMatchForTeam(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,t),t}};getPrevMatchForTeam=async e=>{try{return await this.https.getPrevMatchForTeam(e)}catch(t){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,t),t}}};var je=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var Ke=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getPlayersIdMapping=async e=>{try{let t=!1;if(e){if(e=new je(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");o.country.length===0&&(t=!0),e.countryId=o.country[0]}if(e.playerIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");o.player.length===0&&(t=!0),e.playerIds=o.player}if(e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");o.competition.length===0&&(t=!0),e.scope=o.competition}if(t)return[]}let r=await this.getPlayers(e);return await this.idMapping.remapEntities(r,"player")}catch(t){throw console.warn("There was a problem browsing the players",t),t}};getPlayers=async e=>{try{return await this.https.getPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the players",t),t}};getPlayerIdMapping=async e=>{try{let t=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),r=await this.getPlayerById(t.player[0]);return await this.idMapping.remapEntities(r,"player")}catch(t){throw console.warn(`There was a problem browsing the following player:${e}`,t),t}};getPlayerById=async e=>{try{return await this.https.getPlayerById(e)}catch(t){throw console.warn(`There was a problem retrieving the following player: ${e}`,t),t}};getTopPlayersIdMapping=async()=>{try{let e=await this.getTopPlayers();return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async()=>{try{return await this.https.getTopPlayers()}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getNextMatchForPlayer(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the next match for player:${e}`,t),t}};getNextMatchForPlayer=async e=>{try{return await this.https.getNextMatchForPlayer(e)}catch(t){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,t),t}};getPrevMatchForPlayerIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the previous match for player:${e}`,t),t}};getPrevMatchForPlayer=async e=>{try{return await this.https.getPrevMatchForPlayer(e)}catch(t){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,t),t}}};var Ye=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryIds=e.countryIds?e.countryIds:null,this.competitionIds=e.competitionIds?e.competitionIds:null,this.matchIds=e.matchIds?e.matchIds:null,this.status=e.status?e.status:null,this.teamIds=e.teamIds?e.teamIds:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&(e=e+"&",e=e+`teams=${this.teamIds.join(",")}`),this.fromDate&&(e=e+"&",e=e+`from_date=${this.fromDate}`),this.toDate&&(e=e+"&",e=e+`to_date=${this.toDate}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var Xe=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}getMatchesIdMapping=async e=>{try{if(e){if(e=new Ye(e),e.countryIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=r.country}if(e.competitionIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=r.competition}if(e.matchIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=r.match}if(e.teamIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=r.team}}let t=await this.getMatches(e);return await this.idMapping.remapEntities(t,"match")}catch(t){throw console.warn("There was a problem browsing the matches",t),t}};getMatches=async e=>{try{return await this.https.getMatches(e)}catch(t){throw console.warn("There was a problem retrieving the matches",t),t}};getMatchIdMapping=async e=>{try{let t=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),r=await this.getMatchById(t.match[0]);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the following match: ${e}`,t),t}};getMatchById=async e=>{try{return await this.https.getMatchById(e)}catch(t){throw console.warn(`There was a problem retrieving the following match: ${e}`,t),t}}};var We=class{entities=null;query=null;scope=null;constructor(e){this.entities=e.entities?e.entities:null,this.query=e.query?e.query:null,this.scope=e.scope?e.scope:null}constructFilterUrl=()=>{let e="";return this.entities&&(e=e+"&",e=e+`entities=${this.entities.join(",")}`),this.query&&(e=e+"&",e=e+`q=${this.query}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),e}};var Je=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async e=>{try{if(e=new We(e),e.scope){let r=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=r.competition}let t=await this.search(e);if(t.teams&&t.teams.length>0){let r=await this.idMapping.remapEntities(t.teams,"team");t.teams=r}if(t.players&&t.players.length>0){let r=await this.idMapping.remapEntities(t.players,"player");t.players=r}if(t.competitions&&t.competitions.length>0){let r=await this.idMapping.remapEntities(t.competitions,"competition");t.competitions=r}return t}catch(t){throw console.warn("There was a problem with browsing the search result",t),t}};search=async e=>{try{return await this.https.search(e)}catch(t){throw console.warn("There was a problem retrieving the search response",t),t}}};var A=class{isBrowser=!1;localStorage={};https=null;idMapping=null;countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t,this.countriesFacade=new $e(e,t,r),this.competitionsFacade=new ke(e,t,r),this.teamsFacade=new Ge(t,r),this.playerFacade=new Ke(t,r),this.matchFacade=new Xe(t,r),this.searchFacade=new Je(t,r)}getCountries=async()=>this.countriesFacade.getCountriesWithIdMapping();getCompetitions=async e=>this.competitionsFacade.getCompetitionsIdMapping(e);getCompetitionById=async e=>this.competitionsFacade.getCompetitionByIdIdMapping(e);getTopCompetitions=async()=>this.competitionsFacade.getTopCompetitionsIdMapping();getTeams=async e=>this.teamsFacade.getTeamsIdMapping(e);getTeamById=async e=>this.teamsFacade.getTeamByIdIdMapping(e);getTopTeams=async()=>this.teamsFacade.getTopTeamsIdMapping();getNextMatchForTeam=async e=>this.teamsFacade.getNextMatchForTeamIdMapping(e);getPrevMatchForTeam=async e=>this.teamsFacade.getPrevMatchForTeamIdMapping(e);getPlayers=async e=>this.playerFacade.getPlayersIdMapping(e);getPlayerById=async e=>this.playerFacade.getPlayerIdMapping(e);getTopPlayers=async()=>this.playerFacade.getTopPlayersIdMapping();getNextMatchForPlayer=async e=>this.playerFacade.getNextMatchForPlayerIdMapping(e);getPrevMatchForPlayer=async e=>this.playerFacade.getPrevMatchForPlayerIdMapping(e);getMatches=async e=>this.matchFacade.getMatchesIdMapping(e);getMatchById=async e=>this.matchFacade.getMatchIdMapping(e);search=async e=>this.searchFacade.searchIdMapping(e)};var k=class{idMapping=null;footballFacade=null;constructor(e,t){this.idMapping=e,this.footballFacade=t}remapInterestsToIdSchema=async e=>{let t=this.idMapping.idSchema;if(t!=="native")if(e.length>0){let r={},o={};e.forEach(l=>{r.hasOwnProperty(l.type)||(r[l.type]=[],o[l.type]=[]),r[l.type].push(l.id),o[l.type].push(l)});let a=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",t),n=[];for(let[l,p]of Object.entries(o))p.forEach((c,s)=>{c.id=a[l][s],n.push(c)});return n}else return e;else return e};remapInterestToNative=async e=>{let t=this.idMapping.idSchema;if(t!=="native"){let r={},{id:o,type:a}=e;r[a]=[o];let n=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,"native");return e.id=n[a][0],e}return e};inquiryCustomInterests=async e=>{let t=[];if(e&&e.length>0&&(t=e.filter(r=>r.source==="custom")),t&&t.length>0){let r=e.filter(a=>a.source!=="custom"),o=await this.remapInterestsToIdSchema(r);return t.forEach(a=>o.push(a)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0)for(let r of e)if(r.source!=="custom"&&r.source==="football"){let o={};if(r.type==="team"){o.teamIds=[r.id];let a=await this.footballFacade.getTeams(o);r.model=a[0]}if(r.type==="player"){o.playerIds=[r.id];let a=await this.footballFacade.getPlayers(o);r.model=a[0]}if(r.type==="competition"){o.competitionIds=[r.id];let a=await this.footballFacade.getCompetitions(o);r.model=a[0]}r.model===void 0&&(r.model=null),t.push(r)}else t.push(r);return t}};var ze=class{profileHttps=null;footballHttps=null;localStorage=null;idMapping=null;profileFacade=null;footballFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,r,o){this.localStorage=e,this.profileHttps=t,this.footballHttps=o,this.idMapping=r,this.footballFacade=new A(e,o,r),this.interestsService=new k(r,this.footballFacade),this.profileFacade=new x(e,t)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;let t=await this.profileFacade.getOwn();return this.setOwnProfile(t),this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>await this.profileFacade.follow(e);unfollow=async e=>await this.profileFacade.unfollow(e);addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e;let r=this.ownProfile.interests.filter(o=>o.id!==t.id||o.type!==t.type||o.source!==t.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==t.id||r.type!==t.type||r.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new De,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.getOwnProfile(),t=await this.profileHttps.updateProfile(e);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(t),delete t.interests,t}};var Qe=class{profileHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,r,o){this.localStorage=e,this.profileHttps=t,this.footballFacade=o,this.idMapping=r,this.interestsService=new k(r,o),this.profileFacade=new x(e,t)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)}};var to=ae(q());var Ze=class{id="";alias="";countryCode="";assets=null;name=""};var h=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new Ze;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var et=class{id="";country=null;gender="";assets=null;type="";name=""};var b=class{countryRemapper=null;constructor(){this.countryRemapper=new h}fromResponse(e){try{let t=new et;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var tt=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var rt=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var y=class{countryRemapper=null;constructor(){this.countryRemapper=new h}fromResponse(e){try{let t=new rt;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var it=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new h,this.teamBasicRemapper=new y}fromResponse(e){try{let t=new tt;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(r=>this.teamBasicRemapper.fromResponse(r)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var ot=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var at=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var nt=class{countryRemapper=null;constructor(){this.countryRemapper=new h}fromResponse(e){try{let t=new at;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var st=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new h,this.competitionRemapper=new b,this.playerRemapper=new nt}fromResponse(e){try{let t=new ot;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t.squad=e.squad?e.squad.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var lt=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var pt=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var H=class{fromResponse(e){try{let t=new pt;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var ct=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new y,this.competitionRemapper=new b,this.scoresRemapper=new H}fromResponse(e){try{let t=new lt;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var mt=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var ut=class{corners=null;crosses=null;offside=null;shotsOn=null;throwIn=null;redCards=null;shotsOff=null;goalKicks=null;possession=null;treatments=null;yellowCards=null;shotsBlocked=null;substitutions=null;counterAttacks=null;foulsCommitted=null};var dt=class{fromResponse(e){try{let t=new ut;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var G=class{homeTeam={players:[]};awayTeam={players:[]}};var ht=class{id="";name="";position="";shirtNumber;assets=null;type=""};var j=class{fromResponse(e){try{let t=new ht;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var ft=class{playerRemapper=null;constructor(){this.playerRemapper=new j}fromResponse(e){try{let t=new G;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var yt=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var gt=class{playerRemapper=null;constructor(){this.playerRemapper=new j}fromResponse(e){try{let t=new yt;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var wt=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new y,this.competitionsMapper=new b,this.lineupsMapper=new ft,this.scoresMapper=new H,this.statsMapper=new dt,this.timelineMapper=new gt}fromResponse(e){try{let t=new mt;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(r=>this.timelineMapper.fromResponse(r)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new G,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var bt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Mt=class{countryRemapper=null;constructor(){this.countryRemapper=new h}fromResponse(e){try{let t=new bt;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var Rt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var K=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new h,this.teamRemapper=new y}fromResponse(e){try{let t=new Rt;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var It=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var Ft=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new h,this.teamRemapper=new y,this.competitionRemapper=new b}fromResponse(e){try{let t=new It;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var Pt=class{teams=null;players=null;competitions=null};var St=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new y,this.playerRemapper=new K,this.competitionremapper=new b}fromResponse(e){try{let t=new Pt;return t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.players=e.players?e.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.competitions=e.competitions?e.competitions.map(r=>this.competitionremapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var Y=class{instance=null;apiSignInUrl="";idSchema="";limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;constructor(e){let t=E(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}&client_id=${e.clientId}`,this.idSchema=e.idSchema,this.instance=to.default.create({baseURL:t}),this.countryRemapper=new h,this.competitionBasicRemapper=new b,this.competitionFullRemapper=new it,this.teamBasicRemapper=new y,this.teamFullRemapper=new st,this.matchBasicRemapper=new ct,this.matchFullRemapper=new wt,this.playerBasicRemapper=new K,this.playerFullRemapper=new Ft,this.topPlayerRemapper=new Mt,this.searchRemapper=new St}getCountries=async()=>{try{let e=await this.instance.get(`/countries${this.apiSignInUrl}`);return this.countryRemapper.countriesFromResponse(e.data.data)}catch(e){throw console.warn("There was a problem with the football countries request",e),e}};getCompetitions=async e=>{try{let t={};if(e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let r=[],o=Fe(e.competitionIds);for(let n of o)e.competitionIds=n,t=await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(l=>this.competitionBasicRemapper.fromResponse(l)));return Array.prototype.concat.apply([],r)}else return t=e?await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/competitions${this.apiSignInUrl}`),t.data.data.map(r=>this.competitionBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getCompetitions request",t),t}};getCompetitionById=async e=>{try{let t=await this.instance.get(`/competitions/${e}${this.apiSignInUrl}`);return this.competitionFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getCompetitionById request",t),t}};getTopCompetitions=async()=>{try{return(await this.instance.get(`/competitions/top${this.apiSignInUrl}`)).data.data.map(t=>this.competitionBasicRemapper.fromResponse(t))}catch(e){throw console.warn("There was a problem with getTopCompetitions request",e),e}};getTeams=async e=>{try{let t={};if(e&&e.teamIds&&e.teamIds.length>this.limitIds-1){let r=[],o=Fe(e.teamIds);for(let n of o)e.teamIds=n,t=await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)));return Array.prototype.concat.apply([],r)}else return t=e?await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/teams${this.apiSignInUrl}`),t.data.data.map(r=>this.teamBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getTeams request",t),t}};getTeamById=async e=>{try{let t=await this.instance.get(`/teams/${e}${this.apiSignInUrl}`);return this.teamFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getTeamById request",t),t}};getTopTeams=async()=>{try{let e=await this.instance.get(`/teams/top${this.apiSignInUrl}`);return e.data.data?e.data.data.map(t=>this.teamBasicRemapper.fromResponse(t)):[]}catch(e){throw console.warn("There was a problem with getTopTeams request",e),e}};getNextMatchForTeam=async e=>{try{let t=await this.instance.get(`/teams/${e}/next-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getNextMatchForTeam request",t),t}};getPrevMatchForTeam=async e=>{try{let t=await this.instance.get(`/teams/${e}/previous-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPrevMatchForTeam request",t),t}};getPlayers=async e=>{try{let t={};if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let r=[],o=Fe(e.playerIds);for(let n of o)e.playerIds=n,t=await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)));return Array.prototype.concat.apply([],r)}else return(e?await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/players${this.apiSignInUrl}`)).data.data.map(o=>this.playerBasicRemapper.fromResponse(o))}catch(t){throw console.warn("There was a problem with getPlayers request",t),t}};getPlayerById=async e=>{try{let t=await this.instance.get(`/players/${e}${this.apiSignInUrl}`);return this.playerFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPlayerById request",t),t}};getTopPlayers=async()=>{try{return(await this.instance.get(`/players/top${this.apiSignInUrl}`)).data.data.map(t=>this.topPlayerRemapper.fromResponse(t))}catch(e){throw console.warn("There was a problem with getTopPlayers request",e),e}};getNextMatchForPlayer=async e=>{try{let t=await this.instance.get(`/players/${e}/next-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getNextMatchForPlayer request",t),t}};getPrevMatchForPlayer=async e=>{try{let t=await this.instance.get(`/players/${e}/previous-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPrevMatchForPlayer request",t),t}};getMatchById=async e=>{try{let t=await this.instance.get(`/matches/${e}${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getMatchById request",t),t}};getMatches=async e=>{try{return(e?await this.instance.get(`/matches${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/matches${this.apiSignInUrl}`)).data.data.map(r=>this.matchBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getMatches request",t),t}};search=async e=>{try{let t=await this.instance.get(`/search${this.apiSignInUrl}${e.constructFilterUrl()}`);return this.searchRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with search request",t),t}}};var vt=class{profileHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new _e(e),this.footballHttps=new Y(e),this.idMapping=new O(e),this.localStorage=new _(e),this.footballFacade=new A(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new x(this.localStorage,this.profileHttps),this.ownProfileBuilder=new ze(this.localStorage,this.profileHttps,this.idMapping,this.footballHttps),this.profileBuilder=new Qe(this.localStorage,this.profileHttps,this.idMapping,this.footballFacade)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async()=>await this.profileFacade.getCountries();getByIds=async e=>await this.profileFacade.getByIds(e)};var Ct=class{validate=e=>{let t=this.validateField(e.lang),r=this.generateMessage(t);return{validation:t,message:r}};validateField=e=>{let t=["bg","ro","en"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: EN"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: EN"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Et=class{validate(e){let t=this.validateField(e.environment),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["dev","sandbox","prod"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Tt=class{validate(e){let t=this.validateField(e.apiKey),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use this SDK"),e==="valid"&&(r=null),{text:t,type:r}}};var _t=class{validate(e){let t=this.validateField(e.idSchema),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var de=class{getIdToken=null;logout=null};var J=class{text=null;type=null};var Ot=class{validation=null;message=new J;getIdToken={validation:null,message:new J};logout={validation:null,message:new J}};var xt=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new de),r=new Ot;if(e){let a=Object.keys(e).filter(n=>!t.includes(n));a.length>0?(r.validation="invalid",r.message.type="warning",r.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):r.validation="valid"}else r.validation="missing",r.message.type="error",r.message.text="The field authProvider must be provided to use this SDK";return r};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new de).forEach(o=>{e[o]?t[o].validation="valid":t[o].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let r=e[t];r.validation==="missing"&&(r.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,r.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var he=class{validation;message};var At=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new he,logout:new he};isValid=!1};var Bt=class{validate(e){let t=this.validateField(e.clientId),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="The field clientId must be provided to use this SDK"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Lt=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new At,r={apiKey:new Tt,environment:new Et,idSchema:new _t,clientId:new Bt,lang:new Ct,authProvider:new xt};for(let[o,a]of Object.entries(t))o!=="isValid"&&(a=r[o].validate(e));return Object.keys(r).forEach(o=>{t[o]=r[o].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[r,o]of Object.entries(e))if(r!=="authProvider"){if(r!=="isValid"&&o.message.type==="error")return t=!1,t;if(r!=="isValid"&&o.message.type==="warning")return t=!0,t}return t}};var Nt=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new Y(e),this.idMapping=new O(e),this.localStorage=new _(e),this.footballFacade=new A(this.localStorage,this.https,this.idMapping)}getCountries=async()=>await this.footballFacade.getCountries();getCompetitions=async e=>await this.footballFacade.getCompetitions(e);getCompetitionById=async e=>await this.footballFacade.getCompetitionById(e);getTopCompetitions=async()=>await this.footballFacade.getTopCompetitions();getTeams=async e=>await this.footballFacade.getTeams(e);getTeamById=async e=>await this.footballFacade.getTeamById(e);getTopTeams=async()=>await this.footballFacade.getTopTeams();getNextMatchForTeam=async e=>await this.footballFacade.getNextMatchForTeam(e);getPrevMatchForTeam=async e=>await this.footballFacade.getPrevMatchForTeam(e);getPlayers=async e=>await this.footballFacade.getPlayers(e);getPlayerById=async e=>await this.footballFacade.getPlayerById(e);getTopPlayers=async()=>await this.footballFacade.getTopPlayers();getNextMatchForPlayer=async e=>await this.footballFacade.getNextMatchForPlayer(e);getPrevMatchForPlayer=async e=>await this.footballFacade.getPrevMatchForPlayer(e);getMatches=async e=>await this.footballFacade.getMatches(e);getMatchById=async e=>await this.footballFacade.getMatchById(e);search=async e=>await this.footballFacade.search(e)};var $r=ae(q());var Vt=class{matchId=null;matchType=null;result=null;market=null;prediction;target;playerId;goalsHome;goalsAway};var Ut=class{value=!1;playerId=null};var B=class{matchId=null;market=null;prediction=null;constructor(e,t,r,o){this.matchId=e,this.market=t,this.prediction=new Ut,this.prediction.value=r,this.prediction.playerId=o}};var Dt=class{settledAt=null;resettledAt=null;status=null;outcome=null};var P=(m=>(m.FT_1X2="FT_1X2",m.HT_1X2="HT_1X2",m.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",m.DOUBLE_CHANCE="DOUBLE_CHANCE",m.HT_FT="HT_FT",m.PLAYER_SCORE="PLAYER_SCORE",m.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",m.PLAYER_RED_CARD="PLAYER_RED_CARD",m.RED_CARD_MATCH="RED_CARD_MATCH",m.PENALTY_MATCH="PENALTY_MATCH",m.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",m.CORNERS_MATCH="CORNERS_MATCH",m.CORRECT_SCORE="CORRECT_SCORE",m.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",m.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",m.OVER_GOALS_0_5="OVER_GOALS_0.5",m.OVER_GOALS_1_5="OVER_GOALS_1.5",m.OVER_GOALS_2_5="OVER_GOALS_2.5",m.OVER_GOALS_3_5="OVER_GOALS_3.5",m.OVER_GOALS_4_5="OVER_GOALS_4.5",m.OVER_GOALS_5_5="OVER_GOALS_5.5",m.OVER_GOALS_6_5="OVER_GOALS_6.5",m.OVER_CORNERS_6_5="OVER_CORNERS_6.5",m.OVER_CORNERS_7_5="OVER_CORNERS_7.5",m.OVER_CORNERS_8_5="OVER_CORNERS_8.5",m.OVER_CORNERS_9_5="OVER_CORNERS_9.5",m.OVER_CORNERS_10_5="OVER_CORNERS_10.5",m.OVER_CORNERS_11_5="OVER_CORNERS_11.5",m.OVER_CORNERS_12_5="OVER_CORNERS_12.5",m.OVER_CORNERS_13_5="OVER_CORNERS_13.5",m))(P||{}),ro=["OVER_GOALS_0.5","OVER_GOALS_1.5","OVER_GOALS_2.5","OVER_GOALS_3.5","OVER_GOALS_4.5","OVER_GOALS_5.5","OVER_GOALS_6.5"],io=["OVER_CORNERS_6.5","OVER_CORNERS_7.5","OVER_CORNERS_8.5","OVER_CORNERS_9.5","OVER_CORNERS_10.5","OVER_CORNERS_11.5","OVER_CORNERS_12.5","OVER_CORNERS_13.5"],oo=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var $t=class{value=null};var z=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new $t,this.prediction.value=t}};var S=class{value=!1};var Q=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new S,this.prediction.value=r}};var Z=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new S,this.prediction.value=r}};var qt=class{remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof B)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof Q||e instanceof Z){let r=e.market.split("_");t.market=r[0]+"_"+r[1],t.prediction=e.prediction.value,t.target=r[2]}else if(e instanceof z){t.market=e.market;let r=e.prediction.value.split(":");t.goals_home=r[0],t.goals_away=r[1]}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=e=>{let t=new Vt;return t.matchId=e.match_id,t.matchType=e.match_type,t.result=this.remapResult(e.result),t.market=e.market,e.prediction!==void 0&&(t.prediction=e.prediction),e.target!==void 0&&(t.target=e.target),e.player_id!==void 0&&(t.playerId=e.player_id),e.goals_home!==void 0&&(t.goalsHome=e.goals_home),e.goals_away!==void 0&&(t.goalsAway=e.goals_away),t};remapResult=e=>{let t=new Dt;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var kt=class{id=null;gameInstanceId=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=null;status=null;tiebreaker=null;points=null;createdAt=null;updatedAt=null};var ee=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore={};doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch={};penaltyMatch={};playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals={};overOnePointFiveGoals={};overTwoPointFiveGoals={};overThreePointFiveGoals={};overFourPointFiveGoals={};overFivePointFiveGoals={};overSixPointFiveGoals={};overSixPointFiveCorners={};overSevenPointFiveCorners={};overEightPointFiveCorners={};overNinePointFiveCorners={};overTenPointFiveCorners={};overElevenPointFiveCorners={};overTwelvePointFiveCorners={};overThirteenPointFiveCorners={}};var te=class{fixturesRemapper=null;constructor(){this.fixturesRemapper=new qt}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesRequest(r)),t};remapResponseBody=e=>{let t=new kt;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesResponse(r)),t.status=e.status,t.tiebreaker=e.tiebreaker,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new ee;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:{},t.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:{},t.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:{},t.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:{},t.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:{},t.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:{},t.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:{},t.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:{},t.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:{},t.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:{},t.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:{},t.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:{},t.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:{},t.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:{},t.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:{},t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var Ht=class{matchId=null;matchType=null;predictions=null};var Gt=class{remapPredictions=null;constructor(){this.remapPredictions=new te}remapResponse=e=>{let t=new Ht;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var jt=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;constructor(e){let t=E(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new te,this.matchSummaryRemapper=new Gt,this.instanceAuth=$r.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=$r.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),r=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return this.predictionRemapper.remapResponseBody(r.data)}catch(t){return console.warn("There was a problem making POST request: ",t),t.message}};getMatchSummary=async e=>{try{let t=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(t.data)}catch(t){return console.warn(`There was a problem fetching predictions for match: ${e} `,t),t.message}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){return console.warn(`There was a problem deleting your prediction: ${e}`,t),!1}};getMyPredictions=async e=>{try{return(e?await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instanceAuth.get(`/predictions${this.apiSignInUrl}`)).data.data.map(r=>this.predictionRemapper.remapResponseBody(r))}catch(t){return console.warn("There was a problem fetching own predictions",t),t.message}};getUserPredictions=async(e,t)=>{try{return(t?await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFilterUrl()}`):await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}`)).data.data.map(o=>this.predictionRemapper.remapResponseBody(o))}catch(r){return console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.message}}};var Kt=class{fullCoverageCompetitions=null;markets=null};var Yt=class{remapConfig=e=>{let t=new Kt;return t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t}};var qr=(r=>(r.ONE="1",r.X="x",r.TWO="2",r))(qr||{}),kr=(r=>(r.ONE_X="1x",r.X_TWO="x2",r.ONE_TWO="12",r))(kr||{}),Hr=(c=>(c.ONE_ONE="1/1",c.ONE_X="1/x",c.ONE_TWO="1/2",c.X_ONE="x/1",c.X_X="x/x",c.X_TWO="x/2",c.TWO_ONE="2/1",c.TWO_X="2/x",c.TWO_TWO="2/2",c))(Hr||{});var Xt=class{value=null};var Wt=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Xt,this.prediction.value=t}};var Jt=class{value=null};var zt=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Jt,this.prediction.value=t}};var re=class{value=null};var Qt=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new re,this.prediction.value=t}};var Zt=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new re,this.prediction.value=t}};var er=class{value};var tr=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new er,this.prediction.value=t}};var rr=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new S,this.prediction.value=t}};var ir=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new S,this.prediction.value=t}};var or=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new S,this.prediction.value=t}};var ar=class{idMapping=null;constructor(e){this.idMapping=e}remapMatchIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"match","native")).match[0];remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[r,o]of Object.entries(e))if(t.includes(r))for(let a of Object.keys(o)){let n={player:[a]},p=(await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",this.idMapping.idSchema)).player[0];o[p]=o[a],delete o[a]}return e};convertMarket=e=>{let t=Object.keys(new ee),r=Object.values(P);for(let o=0;o<r.length;o++)e===r[o]&&(e=t[o]);return e};validateFixture=(e,t,r,o)=>{let a=Object.values(qr),n=Object.values(Hr),l=Object.values(kr);if(t==="FT_1X2"){if(a.includes(r))return new Qt(e,r)}else if(t==="HT_1X2"){if(a.includes(r))return new Zt(e,r)}else if(t==="HT_FT"){if(n.includes(r))return new Wt(e,r)}else if(t==="DOUBLE_CHANCE"){if(l.includes(r))return new zt(e,r)}else if(t==="CORRECT_SCORE"){if(typeof r=="string"&&/\d+:\d+/.test(r))return new z(e,r)}else if(t==="CORNERS_MATCH"){if(typeof r=="number")return new tr(e,r)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof r=="boolean")return new rr(e,r)}else if(t==="RED_CARD_MATCH"){if(typeof r=="boolean")return new ir(e,r)}else if(t==="PENALTY_MATCH"){if(typeof r=="boolean")return new or(e,r)}else if(oo.includes(t)){if(o&&typeof r=="boolean")return new B(e,t,r,o)}else if(ro.includes(t)){if(typeof r=="boolean")return new Z(e,t,r)}else if(io.includes(t)&&typeof r=="boolean")return new Q(e,t,r)};getMarketSummary=(e,t)=>{let r=this.convertMarket(t),o={};if(o.matchId=e.matchId,o.matchType=e.matchType,Object.keys(e.predictions).includes(r))o[r]=e.predictions[r];else throw new Error("You have passed invalid market");return o};remapCompetitionsFromConfig=async e=>{let t={competition:e.fullCoverageCompetitions},r=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=r.competition,e};remapPredictions=async e=>{if(this.idMapping.idSchema!=="native")if(e&&e.length>0){for(let t of e)for(let r of t.fixtures){let a={match:[r.matchId]};r.playerId&&(a.player=[r.playerId]);let n=await this.idMapping.idMappingFacade.getEntitiesByIds(a,"native",this.idMapping.idSchema);r.matchId=n.match[0],n.player&&(r.playerId=n.player[0])}return e}else return e;else return e}};var nr=class{gameInstanceId=null;fixtures=null};var sr=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(sr||{}),fe=["WON","LOST","PARTIALLY_WON","CANCELED"];var I=class{limit=null;startAfter=null;status=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null}constructFilterUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(sr).some(r=>this.status.includes(r))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),e}};var lr=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,t,r){this.predictorHttps=e,this.idMapping=r,this.clientHttps=t,this.predictorConfigRemapper=new Yt,this.predictorService=new ar(r)}makeFootballPrediction=async(e,t,r,o)=>{let a=this.predictorService.validateFixture(e,t,r,o),n=new nr;if(a)if(this.idMapping.idSchema!=="native"){let l=a.matchId,p="";if(a.matchId=await this.predictorService.remapMatchIdToNative([l]),!a.matchId)throw new Error("Match id is invalid!");if(a instanceof B&&(p=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([p]),!a.prediction.playerId))throw new Error("Player id is invalid!");n.fixtures=[a];let c=await this.predictorHttps.makeFootballPrediction(n);return c.fixtures.map(s=>{s.playerId&&(s.playerId=p),s.matchId=l}),c}else return n.fixtures=[a],await this.predictorHttps.makeFootballPrediction(n);else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model")};getMatchSummary=async e=>{if(this.idMapping.idSchema!=="native"){let t=await this.predictorService.remapMatchIdToNative([e]),r=await this.predictorHttps.getMatchSummary(t);r.matchId=e;let o=r.predictions,a=await this.predictorService.remapPlayerIdToIdSchema(o);return r.predictions=a,r}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,t)=>{try{let r=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(r,t)}catch(r){return r.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig(),t=await this.predictorConfigRemapper.remapConfig(e.predictor);return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{e&&(e=new I(e));let t=await this.predictorHttps.getMyPredictions(e);return await this.predictorService.remapPredictions(t)};getMyCurrentPredictions=async e=>{if(e)e.status=["ACTIVE"],e=new I(e);else{let t={status:["ACTIVE"]};e=new I(t)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status=fe,e=new I(e);else{let t={status:fe};e=new I(t)}return await this.getMyPredictions(e)};getUserPredictions=async(e,t)=>{t&&(t=new I(t));let r=await this.predictorHttps.getUserPredictions(e,t);return await this.predictorService.remapPredictions(r)};getUserCurrentPredictions=async(e,t)=>{if(t)t.status=["ACTIVE"],t=new I(t);else{let r={status:["ACTIVE"]};t=new I(r)}return await this.getUserPredictions(e,t)};getUserPastPredictions=async(e,t)=>{if(t)t.status=fe,t=new I(t);else{let r={status:fe};t=new I(r)}return await this.getUserPredictions(e,t)}};var ao=ae(q());var ie=class{instance=null;apiSignInUrl="";constructor(e){let t=E(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=ao.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getConfig=async()=>{try{return(await this.instance.get(`${this.apiSignInUrl}`)).data.data}catch(e){return console.warn("There was a problem fetching configuration from Client API",e),e.message}}};var pr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.predictorHttps=new jt(e),this.clientHttps=new ie(e),this.idMapping=new O(e),this.predictorFacade=new lr(this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,r,o)=>await this.predictorFacade.makeFootballPrediction(e,t,r,o);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,t)=>await this.predictorFacade.getMarketSummary(e,t);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getUserPredictions=async(e,t)=>await this.predictorFacade.getUserPredictions(e,t);getUserCurrentPredictions=async(e,t)=>await this.predictorFacade.getUserCurrentPredictions(e,t);getUserPastPredictions=async(e,t)=>await this.predictorFacade.getUserPastPredictions(e,t)};var cr=class{general=[];predictor=[];topX=[]};var mr=class{enabled=!1;rewards=null};var ur=class{general=null;topX=null;predictor=null};var dr=class{points=null;tiers=null;badges=null};var hr=class{remapLoyaltyResponse=e=>{let t=new mr;return t.enabled=e.enabled,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new dr;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new ur;return t.general=e.general,t.topX=e.top_x,t.predictor=e.predictor,t};remapBadges=e=>{let t=new cr;return t.general=e.general,t.predictor=e.predictor,t.topX=e.top_x,t}};var fr=class{https=null;loyaltyRemapper=null;constructor(e){this.https=e,this.loyaltyRemapper=new hr}getConfig=async()=>{let e=await this.https.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)}};var yr=class{https=null;loyaltyFacade=null;constructor(e){this.https=new ie(e),this.loyaltyFacade=new fr(this.https)}getConfig=async()=>await this.loyaltyFacade.getConfig()};function Vu(i){let t=new Lt().validate(i);if(t.idSchema.validation==="missing"&&(console.warn(t.idSchema.message.text),i.idSchema="native"),t.environment.validation==="missing"&&(console.warn(t.environment.message.text),i.environment="prod"),t.lang.validation==="missing"&&(console.warn(t.lang.message.text),i.lang="en"),t.isValid)return{profile:new vt(i),football:new Nt(i),predictor:new pr(i),loyalty:new yr(i)};throw new Error("Configuration is not valid")}export{Vu as FansUnitedSDK};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|