fansunited-sdk-esm 1.1.2 → 1.1.5
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(n){if(a=n.indexOf(":"),r=Gr.trim(n.substr(0,a)).toLowerCase(),i=Gr.trim(n.substr(a+1)),r){if(t[r]&&Jo.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([i]):t[r]=t[r]?t[r]+", "+i:i}}),t}});var xi=h((Da,Oi)=>{"use strict";var _i=b();Oi.exports=_i.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function i(a){var s=a;return e&&(t.setAttribute("href",s),s=t.href),t.setAttribute("href",s),{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=i(window.location.href),function(s){var n=_i.isString(s)?i(s):s;return n.protocol===r.protocol&&n.host===r.host}}():function(){return function(){return!0}}()});var ge=h((Ua,Ai)=>{"use strict";function $r(o){this.message=o}$r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};$r.prototype.__CANCEL__=!0;Ai.exports=$r});var Hr=h((Ga,Bi)=>{"use strict";var Be=b(),zo=Mi(),Qo=Ii(),Zo=Vr(),ea=Ei(),ta=Ti(),ra=xi(),kr=Ur(),ia=we(),oa=ge();Bi.exports=function(e){return new Promise(function(r,i){var a=e.data,s=e.headers,n=e.responseType,p;function m(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}Be.isFormData(a)&&delete s["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",w=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.Authorization="Basic "+btoa(c+":"+w)}var fe=ea(e.baseURL,e.url);l.open(e.method.toUpperCase(),Zo(fe,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function oi(){if(!!l){var E="getAllResponseHeaders"in l?ta(l.getAllResponseHeaders()):null,j=!n||n==="text"||n==="json"?l.responseText:l.response,$={data:j,status:l.status,statusText:l.statusText,headers:E,config:e,request:l};zo(function(_r){r(_r),m()},function(_r){i(_r),m()},$),l=null}}if("onloadend"in l?l.onloadend=oi:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(oi)},l.onabort=function(){!l||(i(kr("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){i(kr("Network Error",e,null,l)),l=null},l.ontimeout=function(){var j=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",$=e.transitional||ia.transitional;e.timeoutErrorMessage&&(j=e.timeoutErrorMessage),i(kr(j,e,$.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",l)),l=null},Be.isStandardBrowserEnv()){var ai=(e.withCredentials||ra(fe))&&e.xsrfCookieName?Qo.read(e.xsrfCookieName):void 0;ai&&(s[e.xsrfHeaderName]=ai)}"setRequestHeader"in l&&Be.forEach(s,function(j,$){typeof a=="undefined"&&$.toLowerCase()==="content-type"?delete s[$]:l.setRequestHeader($,j)}),Be.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),n&&n!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(E){!l||(i(!E||E&&E.type?new oa("canceled"):E),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),a||(a=null),l.send(a)})}});var we=h(($a,Vi)=>{"use strict";var y=b(),Ni=fi(),aa=Dr(),sa={"Content-Type":"application/x-www-form-urlencoded"};function Li(o,e){!y.isUndefined(o)&&y.isUndefined(o["Content-Type"])&&(o["Content-Type"]=e)}function na(){var o;return typeof XMLHttpRequest!="undefined"?o=Hr():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(o=Hr()),o}function la(o,e,t){if(y.isString(o))try{return(e||JSON.parse)(o),y.trim(o)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(o)}var Ne={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:na(),transformRequest:[function(e,t){return Ni(t,"Accept"),Ni(t,"Content-Type"),y.isFormData(e)||y.isArrayBuffer(e)||y.isBuffer(e)||y.isStream(e)||y.isFile(e)||y.isBlob(e)?e:y.isArrayBufferView(e)?e.buffer:y.isURLSearchParams(e)?(Li(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):y.isObject(e)||t&&t["Content-Type"]==="application/json"?(Li(t,"application/json"),la(e)):e}],transformResponse:[function(e){var t=this.transitional||Ne.transitional,r=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,a=!r&&this.responseType==="json";if(a||i&&y.isString(e)&&e.length)try{return JSON.parse(e)}catch(s){if(a)throw s.name==="SyntaxError"?aa(s,this,"E_JSON_PARSE"):s}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, */*"}}};y.forEach(["delete","get","head"],function(e){Ne.headers[e]={}});y.forEach(["post","put","patch"],function(e){Ne.headers[e]=y.merge(sa)});Vi.exports=Ne});var Ui=h((ka,Di)=>{"use strict";var pa=b(),ca=we();Di.exports=function(e,t,r){var i=this||ca;return pa.forEach(r,function(s){e=s.call(i,e,t)}),e}});var qr=h((Ha,Gi)=>{"use strict";Gi.exports=function(e){return!!(e&&e.__CANCEL__)}});var Hi=h((qa,ki)=>{"use strict";var $i=b(),jr=Ui(),ma=qr(),ua=we(),da=ge();function Kr(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new da("canceled")}ki.exports=function(e){Kr(e),e.headers=e.headers||{},e.data=jr.call(e,e.data,e.headers,e.transformRequest),e.headers=$i.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),$i.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var t=e.adapter||ua.adapter;return t(e).then(function(i){return Kr(e),i.data=jr.call(e,i.data,i.headers,e.transformResponse),i},function(i){return ma(i)||(Kr(e),i&&i.response&&(i.response.data=jr.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var Xr=h((ja,qi)=>{"use strict";var R=b();qi.exports=function(e,t){t=t||{};var r={};function i(l,c){return R.isPlainObject(l)&&R.isPlainObject(c)?R.merge(l,c):R.isPlainObject(c)?R.merge({},c):R.isArray(c)?c.slice():c}function a(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(e[l],t[l])}function s(l){if(!R.isUndefined(t[l]))return i(void 0,t[l])}function n(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(void 0,t[l])}function p(l){if(l in t)return i(e[l],t[l]);if(l in e)return i(void 0,e[l])}var m={url:s,method:s,data:s,baseURL:n,transformRequest:n,transformResponse:n,paramsSerializer:n,timeout:n,timeoutMessage:n,withCredentials:n,adapter:n,responseType:n,xsrfCookieName:n,xsrfHeaderName:n,onUploadProgress:n,onDownloadProgress:n,decompress:n,maxContentLength:n,maxBodyLength:n,transport:n,httpAgent:n,httpsAgent:n,cancelToken:n,socketPath:n,responseEncoding:n,validateStatus:p};return R.forEach(Object.keys(e).concat(Object.keys(t)),function(c){var w=m[c]||a,fe=w(c);R.isUndefined(fe)&&w!==p||(r[c]=fe)}),r}});var Yr=h((Ka,ji)=>{ji.exports={version:"0.24.0"}});var Yi=h((Xa,Xi)=>{"use strict";var ha=Yr().version,Wr={};["object","boolean","number","function","string","symbol"].forEach(function(o,e){Wr[o]=function(r){return typeof r===o||"a"+(e<1?"n ":" ")+o}});var Ki={};Wr.transitional=function(e,t,r){function i(a,s){return"[Axios v"+ha+"] Transitional option '"+a+"'"+s+(r?". "+r:"")}return function(a,s,n){if(e===!1)throw new Error(i(s," has been removed"+(t?" in "+t:"")));return t&&!Ki[s]&&(Ki[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,s,n):!0}};function fa(o,e,t){if(typeof o!="object")throw new TypeError("options must be an object");for(var r=Object.keys(o),i=r.length;i-- >0;){var a=r[i],s=e[a];if(s){var n=o[a],p=n===void 0||s(n,a,o);if(p!==!0)throw new TypeError("option "+a+" must be "+p);continue}if(t!==!0)throw Error("Unknown option "+a)}}Xi.exports={assertOptions:fa,validators:Wr}});var eo=h((Ya,Zi)=>{"use strict";var Wi=b(),ya=Vr(),Ji=di(),zi=Hi(),Le=Xr(),Qi=Yi(),X=Qi.validators;function Me(o){this.defaults=o,this.interceptors={request:new Ji,response:new Ji}}Me.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Le(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&&Qi.assertOptions(t,{silentJSONParsing:X.transitional(X.boolean),forcedJSONParsing:X.transitional(X.boolean),clarifyTimeoutError:X.transitional(X.boolean)},!1);var r=[],i=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(e)===!1||(i=i&&w.synchronous,r.unshift(w.fulfilled,w.rejected))});var a=[];this.interceptors.response.forEach(function(w){a.push(w.fulfilled,w.rejected)});var s;if(!i){var n=[zi,void 0];for(Array.prototype.unshift.apply(n,r),n=n.concat(a),s=Promise.resolve(e);n.length;)s=s.then(n.shift(),n.shift());return s}for(var p=e;r.length;){var m=r.shift(),l=r.shift();try{p=m(p)}catch(c){l(c);break}}try{s=zi(p)}catch(c){return Promise.reject(c)}for(;a.length;)s=s.then(a.shift(),a.shift());return s};Me.prototype.getUri=function(e){return e=Le(this.defaults,e),ya(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Wi.forEach(["delete","get","head","options"],function(e){Me.prototype[e]=function(t,r){return this.request(Le(r||{},{method:e,url:t,data:(r||{}).data}))}});Wi.forEach(["post","put","patch"],function(e){Me.prototype[e]=function(t,r,i){return this.request(Le(i||{},{method:e,url:t,data:r}))}});Zi.exports=Me});var ro=h((Wa,to)=>{"use strict";var ga=ge();function Y(o){if(typeof o!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var t=this;this.promise.then(function(r){if(!!t._listeners){var i,a=t._listeners.length;for(i=0;i<a;i++)t._listeners[i](r);t._listeners=null}}),this.promise.then=function(r){var i,a=new Promise(function(s){t.subscribe(s),i=s}).then(r);return a.cancel=function(){t.unsubscribe(i)},a},o(function(i){t.reason||(t.reason=new ga(i),e(t.reason))})}Y.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Y.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Y.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};Y.source=function(){var e,t=new Y(function(i){e=i});return{token:t,cancel:e}};to.exports=Y});var oo=h((Ja,io)=>{"use strict";io.exports=function(e){return function(r){return e.apply(null,r)}}});var so=h((za,ao)=>{"use strict";ao.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var po=h((Qa,Jr)=>{"use strict";var no=b(),wa=xr(),Ve=eo(),Ma=Xr(),ba=we();function lo(o){var e=new Ve(o),t=wa(Ve.prototype.request,e);return no.extend(t,Ve.prototype,e),no.extend(t,e),t.create=function(i){return lo(Ma(o,i))},t}var C=lo(ba);C.Axios=Ve;C.Cancel=ge();C.CancelToken=ro();C.isCancel=qr();C.VERSION=Yr().version;C.all=function(e){return Promise.all(e)};C.spread=oo();C.isAxiosError=so();Jr.exports=C;Jr.exports.default=C});var W=h((Za,co)=>{co.exports=po()});var Qr=ye(W());var zr=o=>{let e=[],t=0;return o.forEach(r=>{e[t]?e[t].length<249?e[t].push(r):(t=t+1,e[t]=[r]):e[t]=[r]}),e},De=o=>{let e=[],t=200;for(;o.length>t-1;){let r=o.splice(0,t-1);e.push(r)}return e.push(o),e},T=(o,e)=>{let t="";return o==="prod"||o==="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 Ue=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[]};var Ge=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new Ue;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 $e=class{avatar=null;followingId=null;name=null;profileId=null};var ke=class{followingFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new $e;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var He=class{avatar=null;followerId=null;name=null;profileId=null};var qe=class{followersFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new He;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var be=class{profile_ids=[]};var Ia="/countries",S="/profile",mo="/profiles",je=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;constructor(e){let t=T(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}&lang=${e.lang}`,this.instanceAuth=Qr.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=Qr.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new Ge,this.followingRemapper=new ke,this.followersRemapper=new qe}getCountries=async()=>{try{return(await this.instance.get(`${Ia}${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching the countries:",e),e.response}};getProfile=async e=>{let t=`${S}${this.apiSignInUrl}`;if(e){t=`${mo}/${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.response}}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.response}};getProfiles=async e=>{try{let t=await this.instance.get(`${mo}${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.response}};getFollowers=async(e,t)=>{let r=`${S}/followers${this.apiSignInUrl}`;if(e&&!t){r=`${S}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}e&&t?r=`${S}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${S}/${t}/followers${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,i),i.response}};getFollowing=async(e,t)=>{let r=`${S}/following${this.apiSignInUrl}`;if(e&&!t){r=`${S}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}e&&t?r=`${S}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${S}/${t}/following${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,i),i.response}};follow=async e=>{let t=new be;t.profile_ids=e;try{let r=await this.instanceAuth.post(`${S}/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.response}};unfollow=async e=>{let t=new be;t.profile_ids=e;try{return await this.instanceAuth.delete(`${S}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(r){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),r.response}};updateProfile=async e=>{try{let t=this.profileRemapper.profileToRequest(e),r=await this.instanceAuth.patch(`${S}${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.response}}};var A={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var uo="FansUnited",ho={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},B=class{idSchema="";exparationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(ho)}clearData=()=>{this.setData(ho)};getEntityById=(e="",t="")=>this.getData().football.ids.find(r=>{let i=A[this.idSchema];return r&&`${r[i]}`===t&&r.resource===e});getEntity=(e,t,r)=>Array.isArray(e)?this.getData().football.ids.filter(i=>{let a=A[r];return i&&e.includes(`${i[a]}`)&&i.resource===t}):this.getData().football.ids.find(i=>{let a=A[r];return i&&`${i[a]}`===e&&i.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(r=>r&&`${r.id}`===t&&r.resource===e);checkForExistingIdObjs=(e,t)=>{let r=A[t],i={};return Object.keys(e).forEach(a=>{let s=e[a],p=this.getEntity(s,a,t).map(l=>l[r]),m=e[a].filter(l=>!p.includes(l));i[a]=s.map(l=>m.includes(l)?{id:l,exists:!1}:{id:l,exists:!0})}),i};getIdsByType=(e,t,r)=>{let i=A[r],a=A[t],s={};return Object.keys(e).forEach(n=>{let p=e[n],m=[];this.getData().football.ids.forEach(l=>{p.forEach((c,w)=>{c===l[a]&&n===l.resource&&(m[w]=l[i])})}),s[n]=m}),s};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(uo));setData=e=>{localStorage.setItem(uo,JSON.stringify(e))}};var fo=ye(W());var Ie={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Ke=class{instance=null;apiSignInUrl="";constructor(e){let t=T(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=fo.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Ie[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r.response}};getEntityByIdAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${Ie[e]}=${t}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,i),i.response}};getEntityIdsByIdsAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${Ie[e]}=${t.join(",")}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,i),i.response}};getEntitiesByIds=(e,t,r)=>{t.sort((s,n)=>s.localeCompare(n));let a=zr(t).map(s=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${Ie[e]}=${s.join(",")}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following ids:${s.join(",")}`,n),n.response}});return Promise.all(a).then(s=>{let n=[];return s.forEach(p=>{n.push(...p.data.data)}),n})};getEntitiesByIdObjs=async(e,t)=>{let r="";if(Object.keys(e).forEach(i=>{if(e[i].length>0){let a=e[i].filter((n,p,m)=>p===m.indexOf(n));zr(a).map(n=>{n.sort((p,m)=>p.localeCompare(m)),r+="&",r+=`${Ie[i]}=${n.join(",")}`})}}),r&&r.length>0)try{return(await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${r}`)).data.data}catch(i){throw console.warn("There was a problem with id mapping request",i),i.response}else return[]}};var Xe=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new B(e),this.https=new Ke(e)}getEntitiesByIds=async(e,t,r)=>{if(this.isBrowser)try{let i=this.localStorage.checkForExistingIdObjs(e,t),a=this.splitForRequestAndExisting(i),s=await this.https.getEntitiesByIdObjs(a.request,t);return this.localStorage.addIdMappings(s),this.localStorage.getIdsByType(e,t,r)}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}else try{let i=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(a=>{e[a]=i.filter(s=>s.resource===a).map(s=>s[A[r]])}),e}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}};getEntityById=async(e,t,r)=>{if(this.isBrowser){let i=this.localStorage.getEntity(e,t,r);if(i)return i;{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(i=>{t[i]=e[i].filter(a=>!a.exists).map(a=>a.id),r[i]=e[i].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(i){return console.warn(`There was a problem retrieving the requested entity: ${i}`),null}}};var Ye=o=>{switch(o){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 o}};var We=class{extractedObjIds={};traverse=(e,t)=>(t=Ye(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 i=e[r];r==="id"||r==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),this.extractedObjIds[t].push(i)):e[r]&&this.traverse(e[r],r)})}};var Je=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,r)=>(t=Ye(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 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 We().traverse(r,t);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new Je().traverse(r,t,s))}else return e}catch(i){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,i),[]}};getEntityIdsBySchemaId=async(e,t,r)=>{let i={};return i[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(i,this.idSchema,r):i}};var F=class{completed=!1;percentage;constructor(e){this.percentage=e}};var ze=class{teamFollowed=new F(10);teamFavourite=new F(15);playerFollowed=new F(10);playerFavourite=new F(10);competitionFollowed=new F(10);competitionFavourite=new F(5);addedBirthdate=new F(10);addedGender=new F(10);addedCountry=new F(10);addedAvatar=new F(10)};var Qe=class{totalPercentage;breakdown=new ze};var Fe=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 N=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 i=await this.https.getProfile();return this.localStorage.setOwnProfile(i),i}catch(i){throw console.warn("There was a problem retrieving your profile: ",i),i}}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 Fe(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 Fe(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 Qe,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(l=>l.type==="team"&&l.favourite)&&(t.breakdown.teamFavourite.completed=!0,r+=t.breakdown.teamFavourite.percentage),e.interests.find(l=>l.type==="team")&&(t.breakdown.teamFollowed.completed=!0,r+=t.breakdown.teamFollowed.percentage),e.interests.find(l=>l.type==="player"&&l.favourite)&&(t.breakdown.playerFavourite.completed=!0,r+=t.breakdown.playerFavourite.percentage),e.interests.find(l=>l.type==="player")&&(t.breakdown.playerFollowed.completed=!0,r+=t.breakdown.playerFollowed.percentage),e.interests.find(l=>l.type==="competition"&&l.favourite)&&(t.breakdown.competitionFavourite.completed=!0,r+=t.breakdown.competitionFavourite.percentage),e.interests.find(l=>l.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,r+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=r,t}};var Ze=class{id=null;name=null;assets=null};var et=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 tt=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 i=!0;return t.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?i&&=r.country.id===this[a]:a==="name"?i&&=r.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?i&&=this[a].some(s=>r.id===s):i&&=r[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),i})};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,i)=>this.sortOrder&&this.sortOrder==="desc"?i.name.localeCompare(r.name):r.name.localeCompare(i.name)):this.sortField==="countryId"?t=e.sort((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.country.id.localeCompare(r.country.id):r.country.id.localeCompare(i.country.id)):this.sortField==="scope"?e.forEach(r=>t[this.competitionIds.indexOf(r.id)]=r):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((r,i)=>i.id.localeCompare(r.id))),t}};var rt=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 tt(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.competitionIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");i.competition.length===0&&(t=!0),e.competitionIds=i.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],i=await this.getCompetitionById(r);return await this.idMapping.remapEntities(i,"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 it=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 ot=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 it(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");i.competition.length===0&&(t=!0),e.scope=i.competition}if(e.teamIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");i.team.length===0&&(t=!0),e.teamIds=i.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 Pe=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 J=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 Pe(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.playerIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");i.player.length===0&&(t=!0),e.playerIds=i.player}if(e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");i.competition.length===0&&(t=!0),e.scope=i.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}};getPlayersWithNativeIds=async e=>{let t=new Pe({playerIds:e}),r=await this.getPlayers(t);return r.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r,"player")};getPlayersMapWithNativeIds=async e=>{let t={},r=e.filter((a,s,n)=>s===n.indexOf(a));e.sort((a,s)=>a.localeCompare(s));let i=await this.getPlayersWithNativeIds(r);return r.forEach((a,s)=>t[a]=i[s]),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 Se=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 L=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}getMatchesIdMapping=async e=>{try{if(e){if(e=new Se(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}};getMatchesWithNativeIds=async e=>{let t=new Se({matchIds:e}),r=await this.getMatches(t);return r.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r,"match")};getMatchesMapWithNativeIds=async e=>{let t={},r=e.filter((a,s,n)=>s===n.indexOf(a));r.sort((a,s)=>a.localeCompare(s));let i=await this.getMatchesWithNativeIds(r);return r.forEach((a,s)=>t[a]=i[s]),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 at=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 st=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async e=>{try{if(e=new at(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 V=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 et(e,t,r),this.competitionsFacade=new rt(e,t,r),this.teamsFacade=new ot(t,r),this.playerFacade=new J(t,r),this.matchFacade=new L(t,r),this.searchFacade=new st(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 z=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={},i={};e.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],i[n.type]=[]),r[n.type].push(n.id),i[n.type].push(n)});let a=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",t),s=[];for(let[n,p]of Object.entries(i))p.forEach((m,l)=>{m.id=a[n][l],s.push(m)});return s}else return e;else return e};remapInterestToNative=async e=>{let t=this.idMapping.idSchema;if(t!=="native"){let r={},{id:i,type:a}=e;r[a]=[i];let s=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,"native");return e.id=s[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"),i=await this.remapInterestsToIdSchema(r);return t.forEach(a=>i.push(a)),i}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 i={};if(r.type==="team"){i.teamIds=[r.id];let a=await this.footballFacade.getTeams(i);r.model=a[0]}if(r.type==="player"){i.playerIds=[r.id];let a=await this.footballFacade.getPlayers(i);r.model=a[0]}if(r.type==="competition"){i.competitionIds=[r.id];let a=await this.footballFacade.getCompetitions(i);r.model=a[0]}r.model===void 0&&(r.model=null),t.push(r)}else t.push(r);return t}};var nt=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,i){this.localStorage=e,this.profileHttps=t,this.footballHttps=i,this.idMapping=r,this.footballFacade=new V(e,i,r),this.interestsService=new z(r,this.footballFacade),this.profileFacade=new N(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(i=>i.id!==t.id||i.type!==t.type||i.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 Ze,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 lt=class{profileHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballFacade=i,this.idMapping=r,this.interestsService=new z(r,i),this.profileFacade=new N(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 yo=ye(W());var pt=class{id="";alias="";countryCode="";assets=null;name=""};var f=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new pt;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 ct=class{id="";country=null;gender="";assets=null;type="";name=""};var I=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new ct;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 mt=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var ut=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var g=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new ut;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 dt=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new f,this.teamBasicRemapper=new g}fromResponse(e){try{let t=new mt;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 ht=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var ft=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var yt=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new ft;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 gt=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new f,this.competitionRemapper=new I,this.playerRemapper=new yt}fromResponse(e){try{let t=new ht;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 wt=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Mt=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Q=class{fromResponse(e){try{let t=new Mt;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 bt=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new g,this.competitionRemapper=new I,this.scoresRemapper=new Q}fromResponse(e){try{let t=new wt;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 It=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 Rt=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 Ft=class{fromResponse(e){try{let t=new Rt;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 Z=class{homeTeam={players:[]};awayTeam={players:[]}};var Pt=class{id="";name="";position="";shirtNumber;assets=null;type=""};var ee=class{fromResponse(e){try{let t=new Pt;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 St=class{playerRemapper=null;constructor(){this.playerRemapper=new ee}fromResponse(e){try{let t=new Z;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 vt=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Et=class{playerRemapper=null;constructor(){this.playerRemapper=new ee}fromResponse(e){try{let t=new vt;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 Ct=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new g,this.competitionsMapper=new I,this.lineupsMapper=new St,this.scoresMapper=new Q,this.statsMapper=new Ft,this.timelineMapper=new Et}fromResponse(e){try{let t=new It;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 Z,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var Tt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var _t=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new Tt;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 Ot=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var te=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new f,this.teamRemapper=new g}fromResponse(e){try{let t=new Ot;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 xt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var At=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new f,this.teamRemapper=new g,this.competitionRemapper=new I}fromResponse(e){try{let t=new xt;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 Bt=class{teams=null;players=null;competitions=null};var Nt=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new g,this.playerRemapper=new te,this.competitionremapper=new I}fromResponse(e){try{let t=new Bt;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 O=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=T(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}&client_id=${e.clientId}`,this.idSchema=e.idSchema,this.instance=yo.default.create({baseURL:t}),this.countryRemapper=new f,this.competitionBasicRemapper=new I,this.competitionFullRemapper=new dt,this.teamBasicRemapper=new g,this.teamFullRemapper=new gt,this.matchBasicRemapper=new bt,this.matchFullRemapper=new Ct,this.playerBasicRemapper=new te,this.playerFullRemapper=new At,this.topPlayerRemapper=new _t,this.searchRemapper=new Nt}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=[],i=De(e.competitionIds);for(let s of i)e.competitionIds=s,t=await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.competitionBasicRemapper.fromResponse(n)));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.response}};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.response}};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.response}};getTeams=async e=>{try{let t={};if(e&&e.teamIds&&e.teamIds.length>this.limitIds-1){let r=[],i=De(e.teamIds);for(let s of i)e.teamIds=s,t=await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.teamBasicRemapper.fromResponse(n)));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.response}};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.response}};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.response}};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.response}};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.response}};getPlayers=async e=>{try{let t={};if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let r=[],i=De(e.playerIds);for(let s of i)e.playerIds=s,t=await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.teamBasicRemapper.fromResponse(n)));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(i=>this.playerBasicRemapper.fromResponse(i))}catch(t){throw console.warn("There was a problem with getPlayers request",t),t.response}};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.response}};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.response}};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.response}};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.response}};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.response}};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.response}};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.response}}};var Lt=class{profileHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new je(e),this.footballHttps=new O(e),this.idMapping=new _(e),this.localStorage=new B(e),this.footballFacade=new V(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new N(this.localStorage,this.profileHttps),this.ownProfileBuilder=new nt(this.localStorage,this.profileHttps,this.idMapping,this.footballHttps),this.profileBuilder=new lt(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 Vt=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 Dt=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 Ut=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 Gt=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 Ee=class{getIdToken=null;logout=null};var oe=class{text=null;type=null};var $t=class{validation=null;message=new oe;getIdToken={validation:null,message:new oe};logout={validation:null,message:new oe}};var kt=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 Ee),r=new $t;if(e){let a=Object.keys(e).filter(s=>!t.includes(s));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 Ee).forEach(i=>{e[i]?t[i].validation="valid":t[i].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 Ce=class{validation;message};var Ht=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Ce,logout:new Ce};isValid=!1};var qt=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 jt=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Ht,r={apiKey:new Ut,environment:new Dt,idSchema:new Gt,clientId:new qt,lang:new Vt,authProvider:new kt};for(let[i,a]of Object.entries(t))i!=="isValid"&&(a=r[i].validate(e));return Object.keys(r).forEach(i=>{t[i]=r[i].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[r,i]of Object.entries(e))if(r!=="authProvider"){if(r!=="isValid"&&i.message.type==="error")return t=!1,t;if(r!=="isValid"&&i.message.type==="warning")return t=!0,t}return t}};var Kt=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new O(e),this.idMapping=new _(e),this.localStorage=new B(e),this.footballFacade=new V(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 ii=ye(W());var Xt=class{value=null;playerId=null;playerModel=null};var ae=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Xt;result=null};var Yt=class{value=!1;playerId=null};var D=class{matchId=null;market=null;prediction=null;constructor(e,t,r,i){this.matchId=e,this.market=t,this.prediction=new Yt,this.prediction.value=r,this.prediction.playerId=i}};var Wt=class{settledAt=null;resettledAt=null;status=null;outcome=null};var P=(d=>(d.FT_1X2="FT_1X2",d.HT_1X2="HT_1X2",d.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",d.DOUBLE_CHANCE="DOUBLE_CHANCE",d.HT_FT="HT_FT",d.PLAYER_SCORE="PLAYER_SCORE",d.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",d.PLAYER_RED_CARD="PLAYER_RED_CARD",d.RED_CARD_MATCH="RED_CARD_MATCH",d.PENALTY_MATCH="PENALTY_MATCH",d.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",d.CORNERS_MATCH="CORNERS_MATCH",d.CORRECT_SCORE="CORRECT_SCORE",d.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",d.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",d.OVER_GOALS_0_5="OVER_GOALS_0.5",d.OVER_GOALS_1_5="OVER_GOALS_1.5",d.OVER_GOALS_2_5="OVER_GOALS_2.5",d.OVER_GOALS_3_5="OVER_GOALS_3.5",d.OVER_GOALS_4_5="OVER_GOALS_4.5",d.OVER_GOALS_5_5="OVER_GOALS_5.5",d.OVER_GOALS_6_5="OVER_GOALS_6.5",d.OVER_CORNERS_6_5="OVER_CORNERS_6.5",d.OVER_CORNERS_7_5="OVER_CORNERS_7.5",d.OVER_CORNERS_8_5="OVER_CORNERS_8.5",d.OVER_CORNERS_9_5="OVER_CORNERS_9.5",d.OVER_CORNERS_10_5="OVER_CORNERS_10.5",d.OVER_CORNERS_11_5="OVER_CORNERS_11.5",d.OVER_CORNERS_12_5="OVER_CORNERS_12.5",d.OVER_CORNERS_13_5="OVER_CORNERS_13.5",d))(P||{}),go=["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"],wo=["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"],Zr=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var Jt=class{value=null};var U=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Jt,this.prediction.value=t}};var v=class{value=!1};var se=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new v,this.prediction.value=r}};var ne=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new v,this.prediction.value=r}};var zt=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,r){this.matchFacade=e,this.playerFacade=t,this.predictorService=r}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof D)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof se||e instanceof ne){let r=e.market.split("_");t.market=r[0]+"_"+r[1],t.prediction=e.prediction.value,t.target=r[2]}else if(e instanceof U){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=async e=>{e.length>1&&e.sort((n,p)=>n.match_id.localeCompare(p.match_id));let t=[],r=[];for(let n of e)t.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let i=await this.matchFacade.getMatchesWithNativeIds(t),a=[];r.sort((n,p)=>n.localeCompare(p)),r&&r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));let s=[];for(let n of e){let p=new ae;n.target?p.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):p.market=n.market,p.matchId=n.match_id,p.matchType=n.match_type,p.matchModel=i?i.shift():null,n.goals_home!==void 0&&n.goals_away!==void 0?p.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():p.prediction.value=n.prediction,p.prediction.playerId=n.player_id?n.player_id:null,p.prediction.playerId&&Object.keys(a).forEach(m=>{p.prediction.playerId===m&&(p.prediction.playerModel=a[m],p.prediction.playerId=a[m].id)}),p.result=this.remapResult(n.result),s.push(p)}return s};remapResult=e=>{let t=new Wt;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var le=class{goldenGoal=null};var Te=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new le;points=null;createdAt=null;updatedAt=null};var u=class{no=0;yes=0};var pe=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new u;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new u;penaltyMatch=new u;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new u;overOnePointFiveGoals=new u;overTwoPointFiveGoals=new u;overThreePointFiveGoals=new u;overFourPointFiveGoals=new u;overFivePointFiveGoals=new u;overSixPointFiveGoals=new u;overSixPointFiveCorners=new u;overSevenPointFiveCorners=new u;overEightPointFiveCorners=new u;overNinePointFiveCorners=new u;overTenPointFiveCorners=new u;overElevenPointFiveCorners=new u;overTwelvePointFiveCorners=new u;overThirteenPointFiveCorners=new u};var ei=(r=>(r.ONE="1",r.X="x",r.TWO="2",r))(ei||{}),ti=(r=>(r.ONE_X="1x",r.X_TWO="x2",r.ONE_TWO="12",r))(ti||{}),ri=(m=>(m.ONE_ONE="1/1",m.ONE_X="1/x",m.ONE_TWO="1/2",m.X_ONE="x/1",m.X_X="x/x",m.X_TWO="x/2",m.TWO_ONE="2/1",m.TWO_X="2/x",m.TWO_TWO="2/2",m))(ri||{});var Qt=class{value=null};var Zt=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Qt,this.prediction.value=t}};var er=class{value=null};var tr=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new er,this.prediction.value=t}};var ce=class{value=null};var rr=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ce,this.prediction.value=t}};var ir=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ce,this.prediction.value=t}};var or=class{value};var ar=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new or,this.prediction.value=t}};var sr=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new v,this.prediction.value=t}};var nr=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new v,this.prediction.value=t}};var lr=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new v,this.prediction.value=t}};var H=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var q=class{userId=null;points=null;results=[];tiebreaker=null};var pr=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(pr||{}),_e=["WON","LOST","PARTIALLY_WON","CANCELED"];var M=class{limit=null;startAfter=null;status=null;type=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null}constructFilterUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(pr).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(",")}`),this.type&&(e+="&",e+=`game_type=${this.type}`),e}};var cr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(cr||{});var x=class{limit=null;startAfter=null;status=null;type=null;gameIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null}constructFiltersUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&Object.values(cr).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),e}};var G=class{footballHttps=null;idMapping=null;matchFacade=null;constructor(e,t){this.footballHttps=new O(e),this.idMapping=t,this.matchFacade=new L(this.footballHttps,t)}remapMatchIdToNative=async e=>{let t=await this.idMapping.getEntityIdsBySchemaId(e,"match","native"),r=[];return t.match.forEach(i=>r.push(i)),r};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,i]of Object.entries(e))if(t.includes(r))for(let a of Object.keys(i)){let s={player:[a]},p=(await this.idMapping.idMappingFacade.getEntitiesByIds(s,"native",this.idMapping.idSchema)).player[0];i[p]=i[a],delete i[a]}return e};convertMarket=e=>{let t=Object.keys(new pe),r=Object.values(P);for(let i=0;i<r.length;i++)e===r[i]&&(e=t[i]);return e};convertMarketForResponseModel=(e,t)=>{let r=t.toString();return e+"_"+r};validateFixture=(e,t,r,i)=>{let a=Object.values(ei),s=Object.values(ri),n=Object.values(ti);if(t==="FT_1X2"){if(a.includes(r))return new rr(e,r)}else if(t==="HT_1X2"){if(a.includes(r))return new ir(e,r)}else if(t==="HT_FT"){if(s.includes(r))return new Zt(e,r)}else if(t==="DOUBLE_CHANCE"){if(n.includes(r))return new tr(e,r)}else if(t==="CORRECT_SCORE"){if(typeof r=="string"&&/\d+:\d+/.test(r))return new U(e,r)}else if(t==="CORNERS_MATCH"){if(typeof r=="number")return new ar(e,r)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof r=="boolean")return new sr(e,r)}else if(t==="RED_CARD_MATCH"){if(typeof r=="boolean")return new nr(e,r)}else if(t==="PENALTY_MATCH"){if(typeof r=="boolean")return new lr(e,r)}else if(Zr.includes(t)){if(i&&typeof r=="boolean")return new D(e,t,r,i)}else if(go.includes(t)){if(typeof r=="boolean")return new ne(e,t,r)}else if(wo.includes(t)&&typeof r=="boolean")return new se(e,t,r)};getMarketSummary=(e,t,r)=>{let i=this.convertMarket(t),a={};if(a.matchId=e.matchId,a.matchType=e.matchType,Object.keys(e.predictions).includes(i))a[i]=e.predictions[i];else throw new Error("You have passed invalid market");return Zr.includes(t)&&r?(a[i][r]||(a[i][r]=new u),a[i][r]):a};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};remapMatchIdsFixtures=async e=>{if(Array.isArray(e))if(e.length>0){let t=[];return e.forEach(r=>{r instanceof H?r.fixtures.forEach(i=>t.push(i.matchId)):r instanceof q&&r.results.forEach(i=>t.push(i.matchId))}),await this.refactorResponseArrModel(e,t)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t)=>{let r=[],i=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.forEach(a=>{a instanceof H?(a.fixtures.forEach(s=>{s.matchModel=i[s.matchId],s.matchId=s.matchModel.id}),r.push(a)):a instanceof q&&(a.results.forEach(s=>{s.matchModel=i[s.matchId],s.matchId=s.matchModel.id}),r.push(a))}),r};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(i=>t.push(i.matchId));let r=await this.matchFacade.getMatchesWithNativeIds(t);return e.fixtures.sort((i,a)=>i.matchId.localeCompare(a.matchId)),r.forEach((i,a)=>{e.fixtures[a].matchModel=i,this.idMapping.idSchema!=="native"&&(e.fixtures[a].matchId=i.id)}),e};getCurrentGameId=e=>{let t=new Date;if(e.length>1){let r=[];return e.forEach(a=>r.push(a.predictionsCutoff)),e.sort((a,s)=>{let[n,p]=[a.predictionsCutoff,s.predictionsCutoff].map(m=>Math.abs(new Date(m)-t));return n-p})[0].id}else return e[0].id};initGameTypePredictions=e=>{let t={type:e};return t=new M(t),t};initGameFilters=(e,t,r)=>{if(t&&r)return t.type=e,t.gameIds=r,t=new x(t),t;if(t&&!r)return t.type=e,t=new x(t),t;if(!t&&r){let i={type:e,gameIds:r};return i=new x(i),i}else{let i={type:e};return i=new x(i),i}}};var me=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new U(t.matchId,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var ue=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new O(e),this.matchFacade=new L(this.footballHttps,t),this.playerFacade=new J(this.footballHttps,t),this.predictorService=new G(e,t),this.fixturesRemapper=new zt(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesRequest(r)),e instanceof me&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{let t=[],r=[],i={},a=[];e.forEach(n=>{n.fixtures.forEach(p=>{t.push(p.match_id),p.player_id&&r.push(p.player_id)})});let s=await this.matchFacade.getMatchesMapWithNativeIds(t);return r.length>0&&(i=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.forEach(n=>{let p=new Te,m=[];p.id=n.id,p.gameInstanceId=n.game_instance_id,p.gameType=n.game_type,p.wager=n.wager,p.totalFixtures=n.total_fixtures,p.settledFixtures=n.settled_fixtures,p.userId=n.user_id,n.fixtures.forEach(l=>{let c=new ae;l.target?c.market=this.predictorService.convertMarketForResponseModel(l.market,l.target):c.market=l.market,c.matchId=s[l.match_id].id,c.matchType=l.match_type,c.matchModel=s[l.match_id],l.goals_home!==void 0&&l.goals_away!==void 0?c.prediction.value=l.goals_home.toString()+":"+l.goals_away.toString():c.prediction.value=l.prediction,c.prediction.playerId=l.player_id?l.player_id:null,c.prediction.playerId&&(c.prediction.playerModel=i[c.prediction.playerId],c.prediction.playerId=i[c.prediction.playerId].id),c.result=this.fixturesRemapper.remapResult(l.result),m.push(c)}),p.fixtures=m,p.status=n.status,n.tiebreaker?p.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:p.tiebreaker=null,p.points=n.points,p.createdAt=n.created_at,p.updatedAt=n.updated_at,a.push(p)}),a};remapResponseObjBody=async e=>{let t=new Te;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new pe;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE?e.BOTH_TEAMS_SCORE:new u,t.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:new u,t.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:new u,t.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:new u,t.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:new u,t.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:new u,t.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:new u,t.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:new u,t.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:new u,t.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:new u,t.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:new u,t.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:new u,t.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:new u,t.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:new u,t.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:new u,t.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:new u,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?e.RED_CARD_MATCH:new u,t.penaltyMatch=e.PENALTY_MATCH?e.PENALTY_MATCH:new u,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 mr=class{matchId=null;matchType=null;predictions=null};var ur=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new ue(e,t)}remapResponse=e=>{let t=new mr;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var dr=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null};var hr=class{matchId=null;matchModel=null;outcome=null};var fr=class{remapGamesListResponse=e=>{let t=new H;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new dr;return t.matchId=e.match_id,t.matchType=e.match_type,t};remapGameResults=e=>{let t=new q;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(r=>this.remapResults(r)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapResults=e=>{let t=new hr;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new le;return t.goldenGoal=e.golden_goal,t}};var de=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;constructor(e,t){let r=T(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new ue(e,t),this.matchSummaryRemapper=new ur(e,t),this.gamesRemapper=new fr,this.instanceAuth=ii.default.create({baseURL:r,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=ii.default.create({baseURL:r,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 await this.predictionRemapper.remapResponseObjBody(r.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async e=>{try{let t=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching predictions for match: ${e} `,t),t.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=e?await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instanceAuth.get(`/predictions${this.apiSignInUrl}`);return await this.predictionRemapper.remapResponseArrayBody(t.data.data)}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`)).data.data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t)=>{try{let r=t?await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFilterUrl()}`):await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}`);return await this.predictionRemapper.remapResponseArrayBody(r.data.data)}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFilterUrl()}`)).data.data}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getGames=async e=>{try{return(await this.instance.get(`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data.map(r=>this.gamesRemapper.remapGamesListResponse(r))}catch(t){throw console.warn("There was a problem fetching the games list",t),t.response}};getGameById=async e=>{try{let t=await this.instance.get(`/games/${e}${this.apiSignInUrl}`);return this.gamesRemapper.remapGamesListResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching the following game: ${e}`,t),t.response}};getGameResults=async(e,t)=>{try{return(t?await this.instance.get(`/games/${e}/results/${this.apiSignInUrl}${t.constructFiltersUrl()}`):await this.instance.get(`/games/${e}/results/${this.apiSignInUrl}`)).data.data.map(i=>this.gamesRemapper.remapGameResults(i))}catch(r){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,r),r.response}}};var yr=class{fullCoverageCompetitions=null;markets=null};var gr=class{remapConfig=e=>{let t=new yr;return t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t}};var wr=class{gameInstanceId=null;fixtures=null};var Mr=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,t,r,i){this.predictorHttps=t,this.idMapping=i,this.clientHttps=r,this.predictorConfigRemapper=new gr,this.predictorService=new G(e,i)}makeFootballPrediction=async(e,t,r,i)=>{let a=this.predictorService.validateFixture(e,t,r,i),s=new wr;if(a)if(this.idMapping.idSchema!=="native"){let n=a.matchId,p="",m=await this.predictorService.remapMatchIdToNative([n]);if(a.matchId=m[0],!a.matchId)throw new Error("Match id is invalid!");if(a instanceof D&&(p=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([p]),!a.prediction.playerId))throw new Error("Player id is invalid!");s.fixtures=[a];let l=await this.predictorHttps.makeFootballPrediction(s);return l.fixtures.map(c=>{c.prediction.playerId&&(c.prediction.playerId=p),c.matchId=n}),l}else return s.fixtures=[a],await this.predictorHttps.makeFootballPrediction(s);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 r=(await this.predictorService.remapMatchIdToNative([e]))[0],i=await this.predictorHttps.getMatchSummary(r);i.matchId=e;let a=i.predictions,s=await this.predictorService.remapPlayerIdToIdSchema(a);return i.predictions=s,i}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,t,r)=>{try{let i=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(i,t,r)}catch(i){return i.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 M(e)),await this.predictorHttps.getMyPredictions(e));getMyCurrentPredictions=async e=>{if(e)e.status=["ACTIVE"],e=new M(e);else{let t={status:["ACTIVE"]};e=new M(t)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status=_e,e=new M(e);else{let t={status:_e};e=new M(t)}return await this.getMyPredictions(e)};getUserPredictions=async(e,t)=>(t&&(t=new M(t)),await this.predictorHttps.getUserPredictions(e,t));getUserCurrentPredictions=async(e,t)=>{if(t)t.status=["ACTIVE"],t=new M(t);else{let r={status:["ACTIVE"]};t=new M(r)}return await this.getUserPredictions(e,t)};getUserPastPredictions=async(e,t)=>{if(t)t.status=_e,t=new M(t);else{let r={status:_e};t=new M(r)}return await this.getUserPredictions(e,t)}};var Mo=ye(W());var he=class{instance=null;apiSignInUrl="";constructor(e){let t=T(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=Mo.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getConfig=async()=>{try{return(await this.instance.get(`${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching configuration from Client API",e),e.response}}};var br=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new _(e),this.predictorHttps=new de(e,this.idMapping),this.clientHttps=new he(e),this.predictorFacade=new Mr(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,r,i)=>await this.predictorFacade.makeFootballPrediction(e,t,r,i);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,t,r)=>await this.predictorFacade.getMarketSummary(e,t,r);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 Ir=class{general=[];predictor=[];topX=[]};var Rr=class{enabled=!1;rewards=null};var Fr=class{general=null;topX=null;predictor=null};var Pr=class{points=null;tiers=null;badges=null};var Sr=class{remapLoyaltyResponse=e=>{let t=new Rr;return t.enabled=e.enabled,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Pr;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Fr;return t.general=e.general,t.topX=e.top_x,t.predictor=e.predictor,t};remapBadges=e=>{let t=new Ir;return t.general=e.general,t.predictor=e.predictor,t.topX=e.top_x,t}};var vr=class{https=null;loyaltyRemapper=null;constructor(e){this.https=e,this.loyaltyRemapper=new Sr}getConfig=async()=>{let e=await this.https.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)}};var Er=class{https=null;loyaltyFacade=null;constructor(e){this.https=new he(e),this.loyaltyFacade=new vr(this.https)}getConfig=async()=>await this.loyaltyFacade.getConfig()};var Cr=class{idMapping=null;predictorHttps=null;predictorService=null;constructor(e,t){this.idMapping=t,this.predictorHttps=new de(e,t),this.predictorService=new G(e,t)}getGames=async e=>{let t=this.predictorService.initGameFilters("TOP_X",e),r=await this.predictorHttps.getGames(t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async e=>{let t=await this.predictorHttps.getGameById(e);return await this.predictorService.remapMatchIdsFixtures(t)};getGameResults=async(e,t)=>{t&&(t=new x(t));let r=await this.predictorHttps.getGameResults(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async()=>{let e={status:"OPEN",type:"TOP_X"};e=new x(e);let t=await this.predictorHttps.getGames(e),r=this.predictorService.getCurrentGameId(t);return(await this.getGameResults(r))[0]};play=async e=>{let t=new me(e);if(this.idMapping.idSchema!=="native"){let i=[];t.fixtures.forEach(s=>i.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(i);t.fixtures.forEach(s=>s.matchId=a.shift())}let r=await this.predictorHttps.makeFootballPrediction(t);return r.fixtures.forEach(i=>{i.matchId=i.matchModel.id}),r};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),r=[];(await this.predictorHttps.getMyPredictionsNoRemap(t)).forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let a=this.predictorService.initGameFilters("TOP_X",e,r),s=await this.predictorHttps.getGames(a);return await this.predictorService.remapMatchIdsFixtures(s)};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X");return(await this.predictorHttps.getMyPredictions(t)).filter(a=>a.gameInstanceId===e)[0]};getUserGameEditions=async(e,t)=>{let r=this.predictorService.initGameTypePredictions("TOP_X"),i=[];(await this.predictorHttps.getUserPredictionsNoRemap(e,r)).forEach(p=>{p.game_instance_id&&i.push(p.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",t,i),n=await this.predictorHttps.getGames(s);return await this.predictorService.remapMatchIdsFixtures(n)};getUserGamePrediction=async(e,t)=>{let r=this.predictorService.initGameTypePredictions("TOP_X");return(await this.predictorHttps.getUserPredictions(e,r)).filter(s=>s.gameInstanceId===t)[0]}};var Tr=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new _(e),this.topXFacade=new Cr(e,this.idMapping)}getGames=async e=>await this.topXFacade.getGames(e);getGameById=async e=>await this.topXFacade.getGameById(e);getGameResults=async(e,t)=>await this.topXFacade.getGameResults(e,t);getCurrentGameResults=async()=>await this.topXFacade.getCurrentGameResults();play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async e=>await this.topXFacade.getMyGameEditions(e);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t)=>await this.topXFacade.getUserGameEditions(e,t);getUserGamePrediction=async(e,t)=>await this.topXFacade.getUserGamePrediction(e,t)};function qd(o){let t=new jt().validate(o);if(t.idSchema.validation==="missing"&&(console.warn(t.idSchema.message.text),o.idSchema="native"),t.environment.validation==="missing"&&(console.warn(t.environment.message.text),o.environment="prod"),t.lang.validation==="missing"&&(console.warn(t.lang.message.text),o.lang="en"),t.isValid)return{profile:new Lt(o),football:new Kt(o),predictor:new br(o),loyalty:new Er(o),topX:new Tr(o)};throw new Error("Configuration is not valid")}export{qd as FansUnitedSDK};
|
|
1
|
+
var _o=Object.create;var Dr=Object.defineProperty;var Oo=Object.getOwnPropertyDescriptor;var xo=Object.getOwnPropertyNames;var Ao=Object.getPrototypeOf,Bo=Object.prototype.hasOwnProperty;var No=o=>Dr(o,"__esModule",{value:!0});var h=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var Lo=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xo(e))!Bo.call(o,i)&&(t||i!=="default")&&Dr(o,i,{get:()=>e[i],enumerable:!(r=Oo(e,i))||r.enumerable});return o},be=(o,e)=>Lo(No(Dr(o!=null?_o(Ao(o)):{},"default",!e&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o);var $r=h((Ba,fi)=>{"use strict";fi.exports=function(e,t){return function(){for(var i=new Array(arguments.length),a=0;a<i.length;a++)i[a]=arguments[a];return e.apply(t,i)}}});var b=h((Na,Mi)=>{"use strict";var Go=$r(),K=Object.prototype.toString;function Hr(o){return K.call(o)==="[object Array]"}function kr(o){return typeof o=="undefined"}function Uo(o){return o!==null&&!kr(o)&&o.constructor!==null&&!kr(o.constructor)&&typeof o.constructor.isBuffer=="function"&&o.constructor.isBuffer(o)}function Vo(o){return K.call(o)==="[object ArrayBuffer]"}function Do(o){return typeof FormData!="undefined"&&o instanceof FormData}function $o(o){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(o):e=o&&o.buffer&&o.buffer instanceof ArrayBuffer,e}function Ho(o){return typeof o=="string"}function ko(o){return typeof o=="number"}function yi(o){return o!==null&&typeof o=="object"}function Le(o){if(K.call(o)!=="[object Object]")return!1;var e=Object.getPrototypeOf(o);return e===null||e===Object.prototype}function qo(o){return K.call(o)==="[object Date]"}function jo(o){return K.call(o)==="[object File]"}function Xo(o){return K.call(o)==="[object Blob]"}function gi(o){return K.call(o)==="[object Function]"}function Ko(o){return yi(o)&&gi(o.pipe)}function Yo(o){return typeof URLSearchParams!="undefined"&&o instanceof URLSearchParams}function Wo(o){return o.trim?o.trim():o.replace(/^\s+|\s+$/g,"")}function zo(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function qr(o,e){if(!(o===null||typeof o=="undefined"))if(typeof o!="object"&&(o=[o]),Hr(o))for(var t=0,r=o.length;t<r;t++)e.call(null,o[t],t,o);else for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&e.call(null,o[i],i,o)}function jr(){var o={};function e(i,a){Le(o[a])&&Le(i)?o[a]=jr(o[a],i):Le(i)?o[a]=jr({},i):Hr(i)?o[a]=i.slice():o[a]=i}for(var t=0,r=arguments.length;t<r;t++)qr(arguments[t],e);return o}function Qo(o,e,t){return qr(e,function(i,a){t&&typeof i=="function"?o[a]=Go(i,t):o[a]=i}),o}function Jo(o){return o.charCodeAt(0)===65279&&(o=o.slice(1)),o}Mi.exports={isArray:Hr,isArrayBuffer:Vo,isBuffer:Uo,isFormData:Do,isArrayBufferView:$o,isString:Ho,isNumber:ko,isObject:yi,isPlainObject:Le,isUndefined:kr,isDate:qo,isFile:jo,isBlob:Xo,isFunction:gi,isStream:Ko,isURLSearchParams:Yo,isStandardBrowserEnv:zo,forEach:qr,merge:jr,extend:Qo,trim:Wo,stripBOM:Jo}});var Xr=h((La,bi)=>{"use strict";var J=b();function wi(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}bi.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(J.isURLSearchParams(t))i=t.toString();else{var a=[];J.forEach(t,function(p,u){p===null||typeof p=="undefined"||(J.isArray(p)?u=u+"[]":p=[p],J.forEach(p,function(c){J.isDate(c)?c=c.toISOString():J.isObject(c)&&(c=JSON.stringify(c)),a.push(wi(u)+"="+wi(c))}))}),i=a.join("&")}if(i){var s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Ri=h((Ga,Ii)=>{"use strict";var Zo=b();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){Zo.forEach(this.handlers,function(r){r!==null&&e(r)})};Ii.exports=Ge});var Pi=h((Ua,Fi)=>{"use strict";var ea=b();Fi.exports=function(e,t){ea.forEach(e,function(i,a){a!==t&&a.toUpperCase()===t.toUpperCase()&&(e[t]=i,delete e[a])})}});var Kr=h((Va,vi)=>{"use strict";vi.exports=function(e,t,r,i,a){return e.config=t,r&&(e.code=r),e.request=i,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 Yr=h((Da,Si)=>{"use strict";var ta=Kr();Si.exports=function(e,t,r,i,a){var s=new Error(e);return ta(s,t,r,i,a)}});var Ei=h(($a,Ti)=>{"use strict";var ra=Yr();Ti.exports=function(e,t,r){var i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(ra("Request failed with status code "+r.status,r.config,null,r.request,r))}});var _i=h((Ha,Ci)=>{"use strict";var Ue=b();Ci.exports=Ue.isStandardBrowserEnv()?function(){return{write:function(t,r,i,a,s,n){var p=[];p.push(t+"="+encodeURIComponent(r)),Ue.isNumber(i)&&p.push("expires="+new Date(i).toGMTString()),Ue.isString(a)&&p.push("path="+a),Ue.isString(s)&&p.push("domain="+s),n===!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 xi=h((ka,Oi)=>{"use strict";Oi.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var Bi=h((qa,Ai)=>{"use strict";Ai.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}});var Li=h((ja,Ni)=>{"use strict";var ia=xi(),oa=Bi();Ni.exports=function(e,t){return e&&!ia(t)?oa(e,t):t}});var Ui=h((Xa,Gi)=>{"use strict";var Wr=b(),aa=["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"];Gi.exports=function(e){var t={},r,i,a;return e&&Wr.forEach(e.split(`
|
|
2
|
+
`),function(n){if(a=n.indexOf(":"),r=Wr.trim(n.substr(0,a)).toLowerCase(),i=Wr.trim(n.substr(a+1)),r){if(t[r]&&aa.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([i]):t[r]=t[r]?t[r]+", "+i:i}}),t}});var $i=h((Ka,Di)=>{"use strict";var Vi=b();Di.exports=Vi.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function i(a){var s=a;return e&&(t.setAttribute("href",s),s=t.href),t.setAttribute("href",s),{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=i(window.location.href),function(s){var n=Vi.isString(s)?i(s):s;return n.protocol===r.protocol&&n.host===r.host}}():function(){return function(){return!0}}()});var Ie=h((Ya,Hi)=>{"use strict";function zr(o){this.message=o}zr.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};zr.prototype.__CANCEL__=!0;Hi.exports=zr});var Jr=h((Wa,ki)=>{"use strict";var Ve=b(),sa=Ei(),na=_i(),la=Xr(),pa=Li(),ca=Ui(),ma=$i(),Qr=Yr(),ua=Re(),da=Ie();ki.exports=function(e){return new Promise(function(r,i){var a=e.data,s=e.headers,n=e.responseType,p;function u(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}Ve.isFormData(a)&&delete s["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.Authorization="Basic "+btoa(c+":"+f)}var N=pa(e.baseURL,e.url);l.open(e.method.toUpperCase(),la(N,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function di(){if(!!l){var C="getAllResponseHeaders"in l?ca(l.getAllResponseHeaders()):null,Q=!n||n==="text"||n==="json"?l.responseText:l.response,X={data:Q,status:l.status,statusText:l.statusText,headers:C,config:e,request:l};sa(function(Vr){r(Vr),u()},function(Vr){i(Vr),u()},X),l=null}}if("onloadend"in l?l.onloadend=di:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(di)},l.onabort=function(){!l||(i(Qr("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){i(Qr("Network Error",e,null,l)),l=null},l.ontimeout=function(){var Q=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",X=e.transitional||ua.transitional;e.timeoutErrorMessage&&(Q=e.timeoutErrorMessage),i(Qr(Q,e,X.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",l)),l=null},Ve.isStandardBrowserEnv()){var hi=(e.withCredentials||ma(N))&&e.xsrfCookieName?na.read(e.xsrfCookieName):void 0;hi&&(s[e.xsrfHeaderName]=hi)}"setRequestHeader"in l&&Ve.forEach(s,function(Q,X){typeof a=="undefined"&&X.toLowerCase()==="content-type"?delete s[X]:l.setRequestHeader(X,Q)}),Ve.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),n&&n!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(C){!l||(i(!C||C&&C.type?new da("canceled"):C),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),a||(a=null),l.send(a)})}});var Re=h((za,Xi)=>{"use strict";var g=b(),qi=Pi(),ha=Kr(),fa={"Content-Type":"application/x-www-form-urlencoded"};function ji(o,e){!g.isUndefined(o)&&g.isUndefined(o["Content-Type"])&&(o["Content-Type"]=e)}function ya(){var o;return typeof XMLHttpRequest!="undefined"?o=Jr():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(o=Jr()),o}function ga(o,e,t){if(g.isString(o))try{return(e||JSON.parse)(o),g.trim(o)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(o)}var De={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:ya(),transformRequest:[function(e,t){return qi(t,"Accept"),qi(t,"Content-Type"),g.isFormData(e)||g.isArrayBuffer(e)||g.isBuffer(e)||g.isStream(e)||g.isFile(e)||g.isBlob(e)?e:g.isArrayBufferView(e)?e.buffer:g.isURLSearchParams(e)?(ji(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):g.isObject(e)||t&&t["Content-Type"]==="application/json"?(ji(t,"application/json"),ga(e)):e}],transformResponse:[function(e){var t=this.transitional||De.transitional,r=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,a=!r&&this.responseType==="json";if(a||i&&g.isString(e)&&e.length)try{return JSON.parse(e)}catch(s){if(a)throw s.name==="SyntaxError"?ha(s,this,"E_JSON_PARSE"):s}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, */*"}}};g.forEach(["delete","get","head"],function(e){De.headers[e]={}});g.forEach(["post","put","patch"],function(e){De.headers[e]=g.merge(fa)});Xi.exports=De});var Yi=h((Qa,Ki)=>{"use strict";var Ma=b(),wa=Re();Ki.exports=function(e,t,r){var i=this||wa;return Ma.forEach(r,function(s){e=s.call(i,e,t)}),e}});var Zr=h((Ja,Wi)=>{"use strict";Wi.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ji=h((Za,Qi)=>{"use strict";var zi=b(),ei=Yi(),ba=Zr(),Ia=Re(),Ra=Ie();function ti(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Ra("canceled")}Qi.exports=function(e){ti(e),e.headers=e.headers||{},e.data=ei.call(e,e.data,e.headers,e.transformRequest),e.headers=zi.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),zi.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var t=e.adapter||Ia.adapter;return t(e).then(function(i){return ti(e),i.data=ei.call(e,i.data,i.headers,e.transformResponse),i},function(i){return ba(i)||(ti(e),i&&i.response&&(i.response.data=ei.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ri=h((es,Zi)=>{"use strict";var R=b();Zi.exports=function(e,t){t=t||{};var r={};function i(l,c){return R.isPlainObject(l)&&R.isPlainObject(c)?R.merge(l,c):R.isPlainObject(c)?R.merge({},c):R.isArray(c)?c.slice():c}function a(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(e[l],t[l])}function s(l){if(!R.isUndefined(t[l]))return i(void 0,t[l])}function n(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(void 0,t[l])}function p(l){if(l in t)return i(e[l],t[l]);if(l in e)return i(void 0,e[l])}var u={url:s,method:s,data:s,baseURL:n,transformRequest:n,transformResponse:n,paramsSerializer:n,timeout:n,timeoutMessage:n,withCredentials:n,adapter:n,responseType:n,xsrfCookieName:n,xsrfHeaderName:n,onUploadProgress:n,onDownloadProgress:n,decompress:n,maxContentLength:n,maxBodyLength:n,transport:n,httpAgent:n,httpsAgent:n,cancelToken:n,socketPath:n,responseEncoding:n,validateStatus:p};return R.forEach(Object.keys(e).concat(Object.keys(t)),function(c){var f=u[c]||a,N=f(c);R.isUndefined(N)&&f!==p||(r[c]=N)}),r}});var ii=h((ts,eo)=>{eo.exports={version:"0.24.0"}});var io=h((rs,ro)=>{"use strict";var Fa=ii().version,oi={};["object","boolean","number","function","string","symbol"].forEach(function(o,e){oi[o]=function(r){return typeof r===o||"a"+(e<1?"n ":" ")+o}});var to={};oi.transitional=function(e,t,r){function i(a,s){return"[Axios v"+Fa+"] Transitional option '"+a+"'"+s+(r?". "+r:"")}return function(a,s,n){if(e===!1)throw new Error(i(s," has been removed"+(t?" in "+t:"")));return t&&!to[s]&&(to[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,s,n):!0}};function Pa(o,e,t){if(typeof o!="object")throw new TypeError("options must be an object");for(var r=Object.keys(o),i=r.length;i-- >0;){var a=r[i],s=e[a];if(s){var n=o[a],p=n===void 0||s(n,a,o);if(p!==!0)throw new TypeError("option "+a+" must be "+p);continue}if(t!==!0)throw Error("Unknown option "+a)}}ro.exports={assertOptions:Pa,validators:oi}});var po=h((is,lo)=>{"use strict";var oo=b(),va=Xr(),ao=Ri(),so=Ji(),$e=ri(),no=io(),Z=no.validators;function Fe(o){this.defaults=o,this.interceptors={request:new ao,response:new ao}}Fe.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=$e(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&&no.assertOptions(t,{silentJSONParsing:Z.transitional(Z.boolean),forcedJSONParsing:Z.transitional(Z.boolean),clarifyTimeoutError:Z.transitional(Z.boolean)},!1);var r=[],i=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(e)===!1||(i=i&&f.synchronous,r.unshift(f.fulfilled,f.rejected))});var a=[];this.interceptors.response.forEach(function(f){a.push(f.fulfilled,f.rejected)});var s;if(!i){var n=[so,void 0];for(Array.prototype.unshift.apply(n,r),n=n.concat(a),s=Promise.resolve(e);n.length;)s=s.then(n.shift(),n.shift());return s}for(var p=e;r.length;){var u=r.shift(),l=r.shift();try{p=u(p)}catch(c){l(c);break}}try{s=so(p)}catch(c){return Promise.reject(c)}for(;a.length;)s=s.then(a.shift(),a.shift());return s};Fe.prototype.getUri=function(e){return e=$e(this.defaults,e),va(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};oo.forEach(["delete","get","head","options"],function(e){Fe.prototype[e]=function(t,r){return this.request($e(r||{},{method:e,url:t,data:(r||{}).data}))}});oo.forEach(["post","put","patch"],function(e){Fe.prototype[e]=function(t,r,i){return this.request($e(i||{},{method:e,url:t,data:r}))}});lo.exports=Fe});var mo=h((os,co)=>{"use strict";var Sa=Ie();function ee(o){if(typeof o!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var t=this;this.promise.then(function(r){if(!!t._listeners){var i,a=t._listeners.length;for(i=0;i<a;i++)t._listeners[i](r);t._listeners=null}}),this.promise.then=function(r){var i,a=new Promise(function(s){t.subscribe(s),i=s}).then(r);return a.cancel=function(){t.unsubscribe(i)},a},o(function(i){t.reason||(t.reason=new Sa(i),e(t.reason))})}ee.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};ee.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};ee.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};ee.source=function(){var e,t=new ee(function(i){e=i});return{token:t,cancel:e}};co.exports=ee});var ho=h((as,uo)=>{"use strict";uo.exports=function(e){return function(r){return e.apply(null,r)}}});var yo=h((ss,fo)=>{"use strict";fo.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var wo=h((ns,ai)=>{"use strict";var go=b(),Ta=$r(),He=po(),Ea=ri(),Ca=Re();function Mo(o){var e=new He(o),t=Ta(He.prototype.request,e);return go.extend(t,He.prototype,e),go.extend(t,e),t.create=function(i){return Mo(Ea(o,i))},t}var O=Mo(Ca);O.Axios=He;O.Cancel=Ie();O.CancelToken=mo();O.isCancel=Zr();O.VERSION=ii().version;O.all=function(e){return Promise.all(e)};O.spread=ho();O.isAxiosError=yo();ai.exports=O;ai.exports.default=O});var te=h((ls,bo)=>{bo.exports=wo()});var ni=be(te());var si=o=>{let e=250,t=[],r=0;return t[r]=[],o.forEach(i=>{t[r].length<=e?t[r].push(i):(r++,t[r]=[i])}),t},ke=o=>{let e=[],t=200;for(;o.length>t-1;){let r=o.splice(0,t-1);e.push(r)}return e.push(o),e},x=(o,e)=>{let t="";return o==="prod"||o==="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},U=o=>o.filter((t,r,i)=>r===i.indexOf(t));var qe=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[]};var je=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new qe;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}};var Xe=class{avatar=null;followingId=null;name=null;profileId=null};var Ke=class{followingFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new Xe;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var Ye=class{avatar=null;followerId=null;name=null;profileId=null};var We=class{followersFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new Ye;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 _a="/countries",S="/profile",Io="/profiles",ze=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;constructor(e){let t=x(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}&lang=${e.lang}`,this.instanceAuth=ni.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(r=>r,r=>{Promise.reject(r)}),this.instanceAuth.interceptors.response.use(r=>r,r=>{let i=r.config;if((r.response.status===403||r.response.status===401)&&!i._retry){i._retry=!0;let a=e.authProvider.getIdToken();return i.headers.Authorization=`Bearer ${a}`,this.instanceAuth(i)}return Promise.reject(r)}),this.instance=ni.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new je,this.followingRemapper=new Ke,this.followersRemapper=new We}getCountries=async()=>{try{return(await this.instance.get(`${_a}${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching the countries:",e),e.response}};getProfile=async e=>{let t=`${S}${this.apiSignInUrl}`;if(e){t=`${Io}/${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.response}}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 your profile from API:",r),r.response}};getProfiles=async e=>{try{let t=await this.instance.get(`${Io}${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.response}};getFollowers=async(e,t)=>{let r=`${S}/followers${this.apiSignInUrl}`;if(e&&!t){r=`${S}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}e&&t?r=`${S}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${S}/${t}/followers${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,i),i.response}};getFollowing=async(e,t)=>{let r=`${S}/following${this.apiSignInUrl}`;if(e&&!t){r=`${S}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}e&&t?r=`${S}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${S}/${t}/following${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,i),i.response}};follow=async e=>{let t=new Pe;t.profile_ids=e;try{let r=await this.instanceAuth.post(`${S}/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.response}};unfollow=async e=>{let t=new Pe;t.profile_ids=e;try{return await this.instanceAuth.delete(`${S}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(r){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),r.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${S}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var L={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var Ro="FansUnited",Fo={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},V=class{idSchema="";exparationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Fo)}clearData=()=>{this.setData(Fo)};getEntityById=(e="",t="")=>this.getData().football.ids.find(r=>{let i=L[this.idSchema];return r&&`${r[i]}`===t&&r.resource===e});getEntity=(e,t,r)=>Array.isArray(e)?this.getData().football.ids.filter(i=>{let a=L[r];return i&&e.includes(`${i[a]}`)&&i.resource===t}):this.getData().football.ids.find(i=>{let a=L[r];return i&&`${i[a]}`===e&&i.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(r=>r&&`${r.id}`===t&&r.resource===e);checkForExistingIdObjs=(e,t)=>{let r=L[t],i={};return Object.keys(e).forEach(a=>{let s=e[a],p=this.getEntity(s,a,t).map(l=>l[r]),u=e[a].filter(l=>!p.includes(l));i[a]=s.map(l=>u.includes(l)?{id:l,exists:!1}:{id:l,exists:!0})}),i};getIdsByType=(e,t,r)=>{let i=L[r],a=L[t],s={};return Object.keys(e).forEach(n=>{let p=e[n],u=[];this.getData().football.ids.forEach(l=>{p.forEach((c,f)=>{c===l[a]&&n===l.resource&&(u[f]=l[i])})}),s[n]=u}),s};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(Ro));setData=e=>{localStorage.setItem(Ro,JSON.stringify(e))}};var Po=be(te());var ve={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Qe=class{instance=null;apiSignInUrl="";constructor(e){let t=x(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=Po.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${ve[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r.response}};getEntityByIdAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ve[e]}=${t}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,i),i.response}};getEntityIdsByIdsAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ve[e]}=${t.join(",")}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,i),i.response}};getEntitiesByIds=(e,t,r)=>{t.sort((s,n)=>s.localeCompare(n));let a=si(t).map(s=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${ve[e]}=${s.join(",")}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following ids:${s.join(",")}`,n),n.response}});return Promise.all(a).then(s=>{let n=[];return s.forEach(p=>{n.push(...p.data.data)}),n})};getEntitiesByIdObjs=async(e,t)=>{let r=[],i={},a=[];Object.keys(e).forEach(u=>{r.push.apply(r,e[u])});let s=U(r),n=si(s);for(let u of n){let l="";if(Object.keys(e).forEach(c=>{i[c]=[];let f=u.filter(N=>e[c].includes(N));f&&f.length>0&&(i[c]=f)}),Object.keys(i).forEach(c=>{i[c].length>0&&(i[c].sort((f,N)=>f.localeCompare(N)),l+="&",l+=`${ve[c]}=${i[c].join(",")}`)}),l&&l.length>0)try{let c=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${l}`);a.push(c.data.data)}catch(c){throw console.warn("There was a problem with id mapping request",c),c.response}else a.push([])}return Array.prototype.concat.apply([],a)}};var Je=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new V(e),this.https=new Qe(e)}getEntitiesByIds=async(e,t,r)=>{if(this.isBrowser)try{let i=this.localStorage.checkForExistingIdObjs(e,t),a=this.splitForRequestAndExisting(i),s=await this.https.getEntitiesByIdObjs(a.request,t);return this.localStorage.addIdMappings(s),this.localStorage.getIdsByType(e,t,r)}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}else try{let i=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(a=>{e[a]=i.filter(s=>s.resource===a).map(s=>s[L[r]])}),e}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}};getEntityById=async(e,t,r)=>{if(this.isBrowser){let i=this.localStorage.getEntity(e,t,r);if(i)return i;{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(i=>{t[i]=e[i].filter(a=>!a.exists).map(a=>a.id),r[i]=e[i].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(i){return console.warn(`There was a problem retrieving the requested entity: ${i}`),null}}};var Ze=o=>{switch(o){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 o}};var et=class{extractedObjIds={};traverse=(e,t)=>(t=Ze(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 i=e[r];r==="id"||r==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),this.extractedObjIds[t].push(i)):e[r]&&this.traverse(e[r],r)})}};var tt=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,r)=>(t=Ze(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 T=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new Je(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 et().traverse(r,t);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new tt().traverse(r,t,s))}else return e}catch(i){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,i),[]}};getEntityIdsBySchemaId=async(e,t,r)=>{let i={};return i[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(i,this.idSchema,r):i}};var F=class{completed=!1;percentage;constructor(e){this.percentage=e}};var rt=class{teamFollowed=new F(10);teamFavourite=new F(15);playerFollowed=new F(10);playerFavourite=new F(10);competitionFollowed=new F(10);competitionFavourite=new F(5);addedBirthdate=new F(10);addedGender=new F(10);addedCountry=new F(10);addedAvatar=new F(10)};var it=class{totalPercentage;breakdown=new rt};var Te=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 D=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 i=await this.https.getProfile();return this.localStorage.setOwnProfile(i),i}catch(i){throw console.warn("There was a problem retrieving your profile: ",i),i}}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 Te(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 Te(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 it,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(l=>l.type==="team"&&l.favourite)&&(t.breakdown.teamFavourite.completed=!0,r+=t.breakdown.teamFavourite.percentage),e.interests.find(l=>l.type==="team")&&(t.breakdown.teamFollowed.completed=!0,r+=t.breakdown.teamFollowed.percentage),e.interests.find(l=>l.type==="player"&&l.favourite)&&(t.breakdown.playerFavourite.completed=!0,r+=t.breakdown.playerFavourite.percentage),e.interests.find(l=>l.type==="player")&&(t.breakdown.playerFollowed.completed=!0,r+=t.breakdown.playerFollowed.percentage),e.interests.find(l=>l.type==="competition"&&l.favourite)&&(t.breakdown.competitionFavourite.completed=!0,r+=t.breakdown.competitionFavourite.percentage),e.interests.find(l=>l.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,r+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=r,t}};var ot=class{id=null;name=null;assets=null};var at=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 st=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 i=!0;return t.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?i&&=r.country.id===this[a]:a==="name"?i&&=r.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?i&&=this[a].some(s=>r.id===s):i&&=r[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),i})};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,i)=>this.sortOrder&&this.sortOrder==="desc"?i.name.localeCompare(r.name):r.name.localeCompare(i.name)):this.sortField==="countryId"?t=e.sort((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.country.id.localeCompare(r.country.id):r.country.id.localeCompare(i.country.id)):this.sortField==="scope"?e.forEach(r=>t[this.competitionIds.indexOf(r.id)]=r):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((r,i)=>i.id.localeCompare(r.id))),t}};var nt=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 st(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.competitionIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");i.competition.length===0&&(t=!0),e.competitionIds=i.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],i=await this.getCompetitionById(r);return await this.idMapping.remapEntities(i,"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 lt=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 pt=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 lt(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");i.competition.length===0&&(t=!0),e.scope=i.competition}if(e.teamIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");i.team.length===0&&(t=!0),e.teamIds=i.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 Ee=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 $=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 Ee(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.playerIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");i.player.length===0&&(t=!0),e.playerIds=i.player}if(e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");i.competition.length===0&&(t=!0),e.scope=i.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}};getPlayersWithNativeIds=async e=>{let t=new Ee({playerIds:e}),r=await this.getPlayers(t);return r.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r,"player")};getPlayersMapWithNativeIds=async e=>{let t={},r=U(e);r.sort((a,s)=>a.localeCompare(s));let i=await this.getPlayersWithNativeIds(r);return r.forEach((a,s)=>t[a]=i[s]),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 Ce=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 H=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}getMatchesIdMapping=async e=>{try{if(e){if(e=new Ce(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}};getMatchesWithNativeIds=async e=>{let t=new Ce({matchIds:e}),r=await this.getMatches(t);return r.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r,"match")};getMatchesMapWithNativeIds=async e=>{let t={},r=U(e);r.sort((a,s)=>a.localeCompare(s));let i=await this.getMatchesWithNativeIds(r);return r.forEach((a,s)=>t[a]=i[s]),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 ct=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 mt=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async e=>{try{if(e=new ct(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 k=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 at(e,t,r),this.competitionsFacade=new nt(e,t,r),this.teamsFacade=new pt(t,r),this.playerFacade=new $(t,r),this.matchFacade=new H(t,r),this.searchFacade=new mt(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 re=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={},i={};e.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],i[n.type]=[]),r[n.type].push(n.id),i[n.type].push(n)});let a=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",t),s=[];for(let[n,p]of Object.entries(i))p.forEach((u,l)=>{u.id=a[n][l],s.push(u)});return s}else return e;else return e};remapInterestToNative=async e=>{let t=this.idMapping.idSchema;if(t!=="native"){let r={},{id:i,type:a}=e;r[a]=[i];let s=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,"native");return e.id=s[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"),i=await this.remapInterestsToIdSchema(r);return t.forEach(a=>i.push(a)),i}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 i={};if(r.type==="team"){i.teamIds=[r.id];let a=await this.footballFacade.getTeams(i);r.model=a[0]}if(r.type==="player"){i.playerIds=[r.id];let a=await this.footballFacade.getPlayers(i);r.model=a[0]}if(r.type==="competition"){i.competitionIds=[r.id];let a=await this.footballFacade.getCompetitions(i);r.model=a[0]}r.model===void 0&&(r.model=null),t.push(r)}else t.push(r);return t}};var ut=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,i){this.localStorage=e,this.profileHttps=t,this.footballHttps=i,this.idMapping=r,this.footballFacade=new k(e,i,r),this.interestsService=new re(r,this.footballFacade),this.profileFacade=new D(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;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch{this.isFetching=!1}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};extractUpdatedProps=(e,t)=>{let r={};return Object.keys(e).forEach(i=>{i==="gender"&&e[i]!==t[i]?r[i]=t[i]:i==="birthDate"?(t[i]===null||e[i]===null&&t[i]||e[i]!==t[i])&&(r.birth_date=t[i]):i==="country"?t[i]===null?r.country_id=t[i]:(e[i]===null&&t[i]||e[i].id!==t[i].id)&&(r.country_id=t[i].id):i==="interests"&&(e[i].length>0?e[i].filter(s=>!t[i].some(n=>s.id===n.id&&s.favourite===n.favourite&&s.type===n.type&&s.source===n.source)).length>0&&(r[i]=t[i]):r[i]=t[i])}),r};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(i=>i.id!==t.id||i.type!==t.type||i.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 ot,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.profileFacade.getOwn(),t=await this.getOwnProfile(),r=this.extractUpdatedProps(e,t),i=await this.profileHttps.updateProfile(r);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(i),delete i.interests,i}};var dt=class{profileHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballFacade=i,this.idMapping=r,this.interestsService=new re(r,i),this.profileFacade=new D(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 vo=be(te());var ht=class{id="";alias="";countryCode="";assets=null;name=""};var y=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new ht;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 ft=class{id="";country=null;gender="";assets=null;type="";name=""};var I=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new ft;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 yt=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var gt=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var M=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new gt;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 Mt=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new y,this.teamBasicRemapper=new M}fromResponse(e){try{let t=new yt;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 wt=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var bt=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var It=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new bt;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 Rt=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new y,this.competitionRemapper=new I,this.playerRemapper=new It}fromResponse(e){try{let t=new wt;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 Ft=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 ie=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 vt=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new M,this.competitionRemapper=new I,this.scoresRemapper=new ie}fromResponse(e){try{let t=new Ft;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 St=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 Tt=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 Et=class{fromResponse(e){try{let t=new Tt;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 oe=class{homeTeam={players:[]};awayTeam={players:[]}};var Ct=class{id="";name="";position="";shirtNumber;assets=null;type=""};var ae=class{fromResponse(e){try{let t=new Ct;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 _t=class{playerRemapper=null;constructor(){this.playerRemapper=new ae}fromResponse(e){try{let t=new oe;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 Ot=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var xt=class{playerRemapper=null;constructor(){this.playerRemapper=new ae}fromResponse(e){try{let t=new Ot;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 At=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new M,this.competitionsMapper=new I,this.lineupsMapper=new _t,this.scoresMapper=new ie,this.statsMapper=new Et,this.timelineMapper=new xt}fromResponse(e){try{let t=new St;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 oe,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 Nt=class{countryRemapper=null;constructor(){this.countryRemapper=new y}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 Lt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var se=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new y,this.teamRemapper=new M}fromResponse(e){try{let t=new Lt;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 Gt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var Ut=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new y,this.teamRemapper=new M,this.competitionRemapper=new I}fromResponse(e){try{let t=new Gt;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 Vt=class{teams=null;players=null;competitions=null};var Dt=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new M,this.playerRemapper=new se,this.competitionremapper=new I}fromResponse(e){try{let t=new Vt;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 A=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=x(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}&client_id=${e.clientId}`,this.idSchema=e.idSchema,this.instance=vo.default.create({baseURL:t}),this.countryRemapper=new y,this.competitionBasicRemapper=new I,this.competitionFullRemapper=new Mt,this.teamBasicRemapper=new M,this.teamFullRemapper=new Rt,this.matchBasicRemapper=new vt,this.matchFullRemapper=new At,this.playerBasicRemapper=new se,this.playerFullRemapper=new Ut,this.topPlayerRemapper=new Nt,this.searchRemapper=new Dt}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=[],i=ke(e.competitionIds);for(let s of i)e.competitionIds=s,t=await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.competitionBasicRemapper.fromResponse(n)));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.response}};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.response}};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.response}};getTeams=async e=>{try{let t={};if(e&&e.teamIds&&e.teamIds.length>this.limitIds-1){let r=[],i=ke(e.teamIds);for(let s of i)e.teamIds=s,t=await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.teamBasicRemapper.fromResponse(n)));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.response}};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.response}};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.response}};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.response}};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.response}};getPlayers=async e=>{try{let t={};if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let r=[],i=ke(e.playerIds);for(let s of i)e.playerIds=s,t=await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.teamBasicRemapper.fromResponse(n)));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(i=>this.playerBasicRemapper.fromResponse(i))}catch(t){throw console.warn("There was a problem with getPlayers request",t),t.response}};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.response}};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.response}};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.response}};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.response}};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.response}};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.response}};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.response}}};var $t=class{profileHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new ze(e),this.footballHttps=new A(e),this.idMapping=new T(e),this.localStorage=new V(e),this.footballFacade=new k(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new D(this.localStorage,this.profileHttps),this.ownProfileBuilder=new ut(this.localStorage,this.profileHttps,this.idMapping,this.footballHttps),this.profileBuilder=new dt(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 Ht=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 kt=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 qt=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 jt=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 Oe=class{getIdToken=null;logout=null};var pe=class{text=null;type=null};var Xt=class{validation=null;message=new pe;getIdToken={validation:null,message:new pe};logout={validation:null,message:new pe}};var Kt=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 Oe),r=new Xt;if(e){let a=Object.keys(e).filter(s=>!t.includes(s));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 Oe).forEach(i=>{e[i]?t[i].validation="valid":t[i].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 xe=class{validation;message};var Yt=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new xe,logout:new xe};isValid=!1};var Wt=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 zt=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Yt,r={apiKey:new qt,environment:new kt,idSchema:new jt,clientId:new Wt,lang:new Ht,authProvider:new Kt};for(let[i,a]of Object.entries(t))i!=="isValid"&&(a=r[i].validate(e));return Object.keys(r).forEach(i=>{t[i]=r[i].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[r,i]of Object.entries(e))if(r!=="authProvider"){if(r!=="isValid"&&i.message.type==="error")return t=!1,t;if(r!=="isValid"&&i.message.type==="warning")return t=!0,t}return t}};var Qt=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new A(e),this.idMapping=new T(e),this.localStorage=new V(e),this.footballFacade=new k(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 ui=be(te());var Jt=class{value=null;playerId=null;playerModel=null};var ce=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Jt;result=null};var Zt=class{value=!1;playerId=null};var _=class{matchId=null;market=null;prediction=null;constructor(e,t,r,i){this.matchId=e,this.market=t,this.prediction=new Zt,this.prediction.value=r,this.prediction.playerId=i}};var me=class{settledAt=null;resettledAt=null;status=null;outcome=null};var P=(d=>(d.FT_1X2="FT_1X2",d.HT_1X2="HT_1X2",d.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",d.DOUBLE_CHANCE="DOUBLE_CHANCE",d.HT_FT="HT_FT",d.PLAYER_SCORE="PLAYER_SCORE",d.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",d.PLAYER_RED_CARD="PLAYER_RED_CARD",d.RED_CARD_MATCH="RED_CARD_MATCH",d.PENALTY_MATCH="PENALTY_MATCH",d.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",d.CORNERS_MATCH="CORNERS_MATCH",d.CORRECT_SCORE="CORRECT_SCORE",d.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",d.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",d.OVER_GOALS_0_5="OVER_GOALS_0.5",d.OVER_GOALS_1_5="OVER_GOALS_1.5",d.OVER_GOALS_2_5="OVER_GOALS_2.5",d.OVER_GOALS_3_5="OVER_GOALS_3.5",d.OVER_GOALS_4_5="OVER_GOALS_4.5",d.OVER_GOALS_5_5="OVER_GOALS_5.5",d.OVER_GOALS_6_5="OVER_GOALS_6.5",d.OVER_CORNERS_6_5="OVER_CORNERS_6.5",d.OVER_CORNERS_7_5="OVER_CORNERS_7.5",d.OVER_CORNERS_8_5="OVER_CORNERS_8.5",d.OVER_CORNERS_9_5="OVER_CORNERS_9.5",d.OVER_CORNERS_10_5="OVER_CORNERS_10.5",d.OVER_CORNERS_11_5="OVER_CORNERS_11.5",d.OVER_CORNERS_12_5="OVER_CORNERS_12.5",d.OVER_CORNERS_13_5="OVER_CORNERS_13.5",d))(P||{}),So=["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"],li=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var er=class{value=null};var q=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new er,this.prediction.value=t}};var E=class{value=!1};var ue=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new E,this.prediction.value=r}};var de=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new E,this.prediction.value=r}};var tr=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,r){this.matchFacade=e,this.playerFacade=t,this.predictorService=r}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof _)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof ue||e instanceof de){let r=e.market.split("_");t.market=r[0]+"_"+r[1],t.prediction=e.prediction.value,t.target=Number(r[2])}else if(e instanceof q){t.market=e.market;let r=e.prediction.value.split(":");t.goals_home=Number(r[0]),t.goals_away=Number(r[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((n,p)=>n.match_id.localeCompare(p.match_id));let t=[],r=[];for(let n of e)t.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let i=await this.matchFacade.getMatchesMapWithNativeIds(t),a=[];r.sort((n,p)=>n.localeCompare(p)),r&&r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));let s=[];for(let n of e){let p=new ce;n.target?p.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):p.market=n.market,p.matchId=i[n.match_id].id,p.matchType=n.match_type,p.matchModel=i?i[n.match_id]:null,n.goals_home!==void 0&&n.goals_away!==void 0?p.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():p.prediction.value=n.prediction,p.prediction.playerId=n.player_id?n.player_id:null,p.prediction.playerId&&(p.prediction.playerModel=a[n.player_id],p.prediction.playerId=a[n.player_id].id),p.result=this.remapResult(n.result),s.push(p)}return s};remapResult=e=>{let t=new me;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var he=class{goldenGoal=null};var Ae=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new he;points=null;createdAt=null;updatedAt=null};var m=class{no=0;yes=0};var fe=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new m;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new m;penaltyMatch=new m;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new m;overOnePointFiveGoals=new m;overTwoPointFiveGoals=new m;overThreePointFiveGoals=new m;overFourPointFiveGoals=new m;overFivePointFiveGoals=new m;overSixPointFiveGoals=new m;overSixPointFiveCorners=new m;overSevenPointFiveCorners=new m;overEightPointFiveCorners=new m;overNinePointFiveCorners=new m;overTenPointFiveCorners=new m;overElevenPointFiveCorners=new m;overTwelvePointFiveCorners=new m;overThirteenPointFiveCorners=new m};var pi=(r=>(r.ONE="1",r.X="x",r.TWO="2",r))(pi||{}),ci=(r=>(r.ONE_X="1x",r.X_TWO="x2",r.ONE_TWO="12",r))(ci||{}),mi=(u=>(u.ONE_ONE="1/1",u.ONE_X="1/x",u.ONE_TWO="1/2",u.X_ONE="x/1",u.X_X="x/x",u.X_TWO="x/2",u.TWO_ONE="2/1",u.TWO_X="2/x",u.TWO_TWO="2/2",u))(mi||{});var rr=class{value=null};var ir=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new rr,this.prediction.value=t}};var or=class{value=null};var ar=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new or,this.prediction.value=t}};var ye=class{value=null};var sr=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ye,this.prediction.value=t}};var nr=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ye,this.prediction.value=t}};var lr=class{value};var pr=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new lr,this.prediction.value=t}};var cr=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new E,this.prediction.value=t}};var mr=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new E,this.prediction.value=t}};var ur=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new E,this.prediction.value=t}};var Y=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var W=class{userId=null;points=null;results=[];tiebreaker=null};var dr=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(dr||{}),Be=["WON","LOST","PARTIALLY_WON","CANCELED"];var w=class{limit=null;startAfter=null;status=null;type=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null}constructFilterUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(dr).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(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),e}};var Ne=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(Ne||{});var v=class{limit=null;startAfter=null;status=null;type=null;gameIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null}constructFiltersUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&Object.values(Ne).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),e}};var z=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var G=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var B=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new A(e),this.idMapping=t,this.matchFacade=new H(this.footballHttps,t),this.playerFacade=new $(this.footballHttps,t)}remapMatchIdToNative=async e=>{let t=await this.idMapping.getEntityIdsBySchemaId(e,"match","native"),r=[];return t.match.forEach(i=>r.push(i)),r};remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},r=U(e),a=(await this.idMapping.getEntityIdsBySchemaId(r,"player","native")).player;return r.forEach((s,n)=>t[s]=a[n]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[r,i]of Object.entries(e))if(t.includes(r))for(let a of Object.keys(i)){let s={player:[a]},p=(await this.idMapping.idMappingFacade.getEntitiesByIds(s,"native",this.idMapping.idSchema)).player[0];i[p]=i[a],delete i[a]}return e};convertMarket=e=>{let t=Object.keys(new fe),r=Object.values(P);for(let i=0;i<r.length;i++)e===r[i]&&(e=t[i]);return e};convertMarketForResponseModel=(e,t)=>{let r=t.toString();return e+"_"+r};validateFixture=(e,t,r,i)=>{let a=Object.values(pi),s=Object.values(mi),n=Object.values(ci);if(t==="FT_1X2"){if(a.includes(r))return new sr(e,r)}else if(t==="HT_1X2"){if(a.includes(r))return new nr(e,r)}else if(t==="HT_FT"){if(s.includes(r))return new ir(e,r)}else if(t==="DOUBLE_CHANCE"){if(n.includes(r))return new ar(e,r)}else if(t==="CORRECT_SCORE"){if(typeof r=="string"&&/\d+:\d+/.test(r))return new q(e,r)}else if(t==="CORNERS_MATCH"){if(typeof r=="number")return new pr(e,r)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof r=="boolean")return new cr(e,r)}else if(t==="RED_CARD_MATCH"){if(typeof r=="boolean")return new mr(e,r)}else if(t==="PENALTY_MATCH"){if(typeof r=="boolean")return new ur(e,r)}else if(li.includes(t)){if(i&&typeof r=="boolean")return new _(e,t,r,i)}else if(So.includes(t)){if(typeof r=="boolean")return new de(e,t,r)}else if(To.includes(t)&&typeof r=="boolean")return new ue(e,t,r)};getMarketSummary=(e,t,r)=>{let i=this.convertMarket(t),a={};if(a.matchId=e.matchId,a.matchType=e.matchType,Object.keys(e.predictions).includes(i))a[i]=e.predictions[i];else throw new Error("You have passed invalid market");return li.includes(t)&&r?(a[i][r]||(a[i][r]=new m),a[i][r]):a};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};remapMatchIdsFixtures=async e=>{if(Array.isArray(e))if(e.length>0){let t=[],r=[];return e.forEach(i=>{i instanceof z||i instanceof Y||i instanceof G?(i.fixtures.forEach(a=>t.push(a.matchId)),i instanceof G&&i.fixtures.forEach(a=>{a.prediction.playerId&&r.push(a.prediction.playerId)})):i instanceof W&&i.results.forEach(a=>t.push(a.matchId))}),await this.refactorResponseArrModel(e,t,r)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,r)=>{let i=[],a=await this.matchFacade.getMatchesMapWithNativeIds(t),s={};return r.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.forEach(n=>{n instanceof z||n instanceof Y||n instanceof G?(n.fixtures.forEach(p=>{p.matchModel=a[p.matchId],p.matchId=p.matchModel.id,n instanceof G&&p.prediction.playerId&&(p.prediction.playerModel=s[p.prediction.playerId],p.prediction.playerId=s[p.prediction.playerId].id)}),i.push(n)):n instanceof W&&(n.results.forEach(p=>{p.matchModel=a[p.matchId],p.matchId=p.matchModel.id}),i.push(n))}),i};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(i=>t.push(i.matchId));let r=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(i=>{i.matchModel=r[i.matchId],i.matchId=r[i.matchId].id}),e};getCurrentGameId=e=>{let t=new Date;if(e.length>1){let r=[];return e.forEach(a=>r.push(a.predictionsCutoff)),e.sort((a,s)=>{let[n,p]=[a.predictionsCutoff,s.predictionsCutoff].map(u=>Math.abs(new Date(u)-t));return n-p})[0].id}else return e[0].id};initGameTypePredictions=e=>{let t={type:e};return t=new w(t),t};initGameFilters=(e,t,r)=>{if(t&&r)return t.type=e,t.gameIds=r,t=new v(t),t;if(t&&!r)return t.type=e,t=new v(t),t;if(!t&&r){let i={type:e,gameIds:r};return i=new v(i),i}else{let i={type:e};return i=new v(i),i}};addPredictionProp=async(e,t)=>(t.forEach((r,i)=>{r.id===e[i].game_instance_id&&r.fixtures.forEach((a,s)=>{e[i].fixtures[s].goals_home!==void 0&&e[i].fixtures[s].goals_away!==void 0?a.prediction.value=e[i].fixtures[s].goals_home+":"+e[i].fixtures[s].goals_away:a.prediction.value=e[i].fixtures[s].prediction,e[i].fixtures[s].player_id?a.prediction.playerId=e[i].fixtures[s].player_id:e[i].fixtures[s].target&&(a.prediction.target=e[i].fixtures[s].target),a.prediction.result=this.remapResult(e[i].fixtures[s].result)})}),await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new me;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var ge=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new q(t.matchId,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var Me=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new A(e),this.matchFacade=new H(this.footballHttps,t),this.playerFacade=new $(this.footballHttps,t),this.predictorService=new B(e,t),this.fixturesRemapper=new tr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesRequest(r)),e instanceof ge&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{let t=[],r=[],i={},a=[];e.forEach(n=>{n.fixtures.forEach(p=>{t.push(p.match_id),p.player_id&&r.push(p.player_id)})});let s=await this.matchFacade.getMatchesMapWithNativeIds(t);return r.length>0&&(i=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.forEach(n=>{let p=new Ae,u=[];p.id=n.id,p.gameInstanceId=n.game_instance_id,p.gameType=n.game_type,p.wager=n.wager,p.totalFixtures=n.total_fixtures,p.settledFixtures=n.settled_fixtures,p.userId=n.user_id,n.fixtures.forEach(l=>{let c=new ce;l.target?c.market=this.predictorService.convertMarketForResponseModel(l.market,l.target):c.market=l.market,c.matchId=s[l.match_id].id,c.matchType=l.match_type,c.matchModel=s[l.match_id],l.goals_home!==void 0&&l.goals_away!==void 0?c.prediction.value=l.goals_home.toString()+":"+l.goals_away.toString():c.prediction.value=l.prediction,c.prediction.playerId=l.player_id?l.player_id:null,c.prediction.playerId&&(c.prediction.playerModel=i[c.prediction.playerId],c.prediction.playerId=i[c.prediction.playerId].id),c.result=this.fixturesRemapper.remapResult(l.result),u.push(c)}),p.fixtures=u,p.status=n.status,n.tiebreaker?p.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:p.tiebreaker=null,p.points=n.points,p.createdAt=n.created_at,p.updatedAt=n.updated_at,a.push(p)}),a};remapResponseObjBody=async e=>{let t=new Ae;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new fe;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE?e.BOTH_TEAMS_SCORE:new m,t.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:new m,t.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:new m,t.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:new m,t.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:new m,t.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:new m,t.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:new m,t.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:new m,t.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:new m,t.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:new m,t.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:new m,t.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:new m,t.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:new m,t.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:new m,t.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:new m,t.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:new m,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?e.RED_CARD_MATCH:new m,t.penaltyMatch=e.PENALTY_MATCH?e.PENALTY_MATCH:new m,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 hr=class{matchId=null;matchType=null;predictions=null};var fr=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new Me(e,t)}remapResponse=e=>{let t=new hr;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var yr=class{matchId=null;matchType=null;market=null;matchModel=null};var gr=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Mr=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new gr};var wr=class{value=null;result=null};var br=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null;prediction=new wr};var Ir=class{matchId=null;matchModel=null;outcome=null};var Rr=class{remapGamesListResponse=e=>{let t=new z;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new yr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapUserTopXEditionsResponse=e=>{let t=new Y;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapTopXFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new br;return t.matchId=e.match_id,t.matchType=e.match_type,t};remapUserMatchQuizEditionsResponse=e=>{let t=new G;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapMatchQuizFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new Mr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapGameResults=e=>{let t=new W;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(r=>this.remapResults(r)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapResults=e=>{let t=new Ir;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new he;return t.goldenGoal=e.golden_goal,t}};var j=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;constructor(e,t){let r=x(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new Me(e,t),this.matchSummaryRemapper=new fr(e,t),this.gamesRemapper=new Rr,this.instanceAuth=ui.default.create({baseURL:r,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=ui.default.create({baseURL:r,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 await this.predictionRemapper.remapResponseObjBody(r.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async e=>{try{let t=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching predictions for match: ${e} `,t),t.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=e?await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instanceAuth.get(`/predictions${this.apiSignInUrl}`);return await this.predictionRemapper.remapResponseArrayBody(t.data.data)}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`)).data.data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t)=>{try{let r=t?await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFilterUrl()}`):await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}`);return await this.predictionRemapper.remapResponseArrayBody(r.data.data)}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFilterUrl()}`)).data.data}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getGames=async e=>{try{return(await this.instance.get(`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data.map(r=>this.gamesRemapper.remapGamesListResponse(r))}catch(t){throw console.warn("There was a problem fetching the games list",t),t.response}};getGameById=async e=>{try{let t=await this.instance.get(`/games/${e}${this.apiSignInUrl}`);return this.gamesRemapper.remapGamesListResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching the following game: ${e}`,t),t.response}};getUserGameEditions=async e=>{try{return(await this.instance.get(`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data.map(r=>{if(r.type==="TOP_X")return this.gamesRemapper.remapUserTopXEditionsResponse(r);if(r.type==="MATCH_QUIZ")return this.gamesRemapper.remapUserMatchQuizEditionsResponse(r)})}catch(t){throw console.warn("There was a problem fetching the games list",t),t.response}};getGameResults=async(e,t)=>{try{return(t?await this.instance.get(`/games/${e}/results/${this.apiSignInUrl}${t.constructFiltersUrl()}`):await this.instance.get(`/games/${e}/results/${this.apiSignInUrl}`)).data.data.map(i=>this.gamesRemapper.remapGameResults(i))}catch(r){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,r),r.response}}};var Fr=class{fullCoverageCompetitions=null;markets=null};var Pr=class{remapConfig=e=>{let t=new Fr;return t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t}};var vr=class{gameInstanceId=null;fixtures=null};var Sr=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,t,r,i){this.predictorHttps=t,this.idMapping=i,this.clientHttps=r,this.predictorConfigRemapper=new Pr,this.predictorService=new B(e,i)}makeFootballPrediction=async(e,t,r,i)=>{let a=this.predictorService.validateFixture(e,t,r,i),s=new vr;if(a)if(this.idMapping.idSchema!=="native"){let n=a.matchId,p="",u=await this.predictorService.remapMatchIdToNative([n]);if(a.matchId=u[0],!a.matchId)throw new Error("Match id is invalid!");if(a instanceof _&&(p=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([p]),!a.prediction.playerId))throw new Error("Player id is invalid!");s.fixtures=[a];let l=await this.predictorHttps.makeFootballPrediction(s);return l.fixtures.map(c=>{c.prediction.playerId&&(c.prediction.playerId=p),c.matchId=n}),l}else return s.fixtures=[a],await this.predictorHttps.makeFootballPrediction(s);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 r=(await this.predictorService.remapMatchIdToNative([e]))[0],i=await this.predictorHttps.getMatchSummary(r);i.matchId=e;let a=i.predictions,s=await this.predictorService.remapPlayerIdToIdSchema(a);return i.predictions=s,i}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,t,r)=>{try{let i=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(i,t,r)}catch(i){return i.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 w(e)),await this.predictorHttps.getMyPredictions(e));getMyCurrentPredictions=async e=>{if(e)e.status=["ACTIVE"],e=new w(e);else{let t={status:["ACTIVE"]};e=new w(t)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status=Be,e=new w(e);else{let t={status:Be};e=new w(t)}return await this.getMyPredictions(e)};getUserPredictions=async(e,t)=>(t&&(t=new w(t)),await this.predictorHttps.getUserPredictions(e,t));getUserCurrentPredictions=async(e,t)=>{if(t)t.status=["ACTIVE"],t=new w(t);else{let r={status:["ACTIVE"]};t=new w(r)}return await this.getUserPredictions(e,t)};getUserPastPredictions=async(e,t)=>{if(t)t.status=Be,t=new w(t);else{let r={status:Be};t=new w(r)}return await this.getUserPredictions(e,t)}};var Eo=be(te());var we=class{instance=null;apiSignInUrl="";constructor(e){let t=x(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=Eo.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getConfig=async()=>{try{return(await this.instance.get(`${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching configuration from Client API",e),e.response}}};var Tr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new T(e),this.predictorHttps=new j(e,this.idMapping),this.clientHttps=new we(e),this.predictorFacade=new Sr(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,r,i)=>await this.predictorFacade.makeFootballPrediction(e,t,r,i);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,t,r)=>await this.predictorFacade.getMarketSummary(e,t,r);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 Er=class{general=[];predictor=[];topX=[]};var Cr=class{enabled=!1;rewards=null};var _r=class{general=null;topX=null;predictor=null};var Or=class{points=null;tiers=null;badges=null};var xr=class{remapLoyaltyResponse=e=>{let t=new Cr;return t.enabled=e.enabled,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Or;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new _r;return t.general=e.general,t.topX=e.top_x,t.predictor=e.predictor,t};remapBadges=e=>{let t=new Er;return t.general=e.general,t.predictor=e.predictor,t.topX=e.top_x,t}};var Ar=class{https=null;loyaltyRemapper=null;constructor(e){this.https=e,this.loyaltyRemapper=new xr}getConfig=async()=>{let e=await this.https.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)}};var Br=class{https=null;loyaltyFacade=null;constructor(e){this.https=new we(e),this.loyaltyFacade=new Ar(this.https)}getConfig=async()=>await this.loyaltyFacade.getConfig()};var Nr=class{idMapping=null;predictorHttps=null;predictorService=null;constructor(e,t){this.idMapping=t,this.predictorHttps=new j(e,t),this.predictorService=new B(e,t)}getGames=async e=>{let t=this.predictorService.initGameFilters("TOP_X",e),r=await this.predictorHttps.getGames(t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async e=>{let t=await this.predictorHttps.getGameById(e);return await this.predictorService.remapMatchIdsFixtures(t)};getGameResults=async(e,t)=>{t&&(t=new v(t));let r=await this.predictorHttps.getGameResults(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async()=>{let e={status:"OPEN",type:"TOP_X"};e=new v(e);let t=await this.predictorHttps.getGames(e),r=this.predictorService.getCurrentGameId(t);return(await this.getGameResults(r))[0]};play=async e=>{let t=new ge(e);if(this.idMapping.idSchema!=="native"){let i=[];t.fixtures.forEach(s=>i.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(i);t.fixtures.forEach(s=>s.matchId=a.shift())}let r=await this.predictorHttps.makeFootballPrediction(t);return r.fixtures.forEach(i=>{i.matchId=i.matchModel.id}),r};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),r=[],i=await this.predictorHttps.getMyPredictionsNoRemap(t);i.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let a=this.predictorService.initGameFilters("TOP_X",e,r),s=await this.predictorHttps.getUserGameEditions(a);return await this.predictorService.addPredictionProp(i,s)};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X");return(await this.predictorHttps.getMyPredictions(t)).filter(a=>a.gameInstanceId===e)[0]};getUserGameEditions=async(e,t)=>{let r=this.predictorService.initGameTypePredictions("TOP_X"),i=[],a=await this.predictorHttps.getUserPredictionsNoRemap(e,r);a.forEach(p=>{p.game_instance_id&&i.push(p.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",t,i),n=await this.predictorHttps.getUserGameEditions(s);return await this.predictorService.addPredictionProp(a,n)};getUserGamePrediction=async(e,t)=>{let r=this.predictorService.initGameTypePredictions("TOP_X");return(await this.predictorHttps.getUserPredictions(e,r)).filter(s=>s.gameInstanceId===t)[0]}};var Lr=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new T(e),this.topXFacade=new Nr(e,this.idMapping)}getGames=async e=>await this.topXFacade.getGames(e);getGameById=async e=>await this.topXFacade.getGameById(e);getGameResults=async(e,t)=>await this.topXFacade.getGameResults(e,t);getCurrentGameResults=async()=>await this.topXFacade.getCurrentGameResults();play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async e=>await this.topXFacade.getMyGameEditions(e);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t)=>await this.topXFacade.getUserGameEditions(e,t);getUserGamePrediction=async(e,t)=>await this.topXFacade.getUserGamePrediction(e,t)};var Gr=class{predictorHttps=null;predictorService=null;idMapping=null;constructor(e){this.idMapping=new T(e),this.predictorHttps=new j(e,this.idMapping),this.predictorService=new B(e,this.idMapping)}play=async e=>{let t=e.fixtures.map(r=>this.predictorService.validateFixture(r.matchId,r.market,r.prediction.value,r.prediction.playerId));if(t){if(this.idMapping.idSchema!=="native"){let r=[],i=[];t.forEach(n=>{r.push(n.matchId),n instanceof _&&i.push(n.prediction.playerId)});let a=await this.predictorService.remapMatchIdToNative(r),s={};i&&i.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(i)),t.forEach((n,p)=>{n.matchId=a[p],n instanceof _&&(n.prediction.playerId=s[n.prediction.playerId])})}}else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model");return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async e=>{let t=this.predictorService.initGameFilters("MATCH_QUIZ",e),r=await this.predictorHttps.getGames(t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async e=>{let t=await this.predictorHttps.getGameById(e);return await this.predictorService.remapMatchIdsFixtures(t)};getGameResults=async(e,t)=>{t&&(t=new v(t));let r=await this.predictorHttps.getGameResults(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async()=>{let e={status:"OPEN",type:"MATCH_QUIZ"};e=new v(e);let t=await this.predictorHttps.getGames(e),r=this.predictorService.getCurrentGameId(t);return(await this.getGameResults(r))[0]};getMyGameEditions=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),r=[],i=await this.predictorHttps.getMyPredictionsNoRemap(t);i.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let a=this.predictorService.initGameFilters("MATCH_QUIZ",e,r),s=await this.predictorHttps.getUserGameEditions(a);return await this.predictorService.addPredictionProp(i,s)};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ");return(await this.predictorHttps.getMyPredictions(t)).filter(a=>a.gameInstanceId===e)[0]};getUserGameEditions=async(e,t)=>{let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=[],a=await this.predictorHttps.getUserPredictionsNoRemap(e,r);a.forEach(p=>{p.game_instance_id&&i.push(p.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",t,i),n=await this.predictorHttps.getUserGameEditions(s);return await this.predictorService.addPredictionProp(a,n)};getUserGamePrediction=async(e,t)=>{let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ");return(await this.predictorHttps.getUserPredictions(e,r)).filter(s=>s.gameInstanceId===t)[0]}};var Ur=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new Gr(e)}play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async e=>await this.matchQuizFacade.getGames(e);getGameById=async e=>await this.matchQuizFacade.getGameById(e);getGameResults=async(e,t)=>await this.matchQuizFacade.getGameResults(e,t);getCurrentGameResults=async()=>await this.matchQuizFacade.getCurrentGameResults();getMyGameEditions=async e=>await this.matchQuizFacade.getMyGameEditions(e);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t)=>await this.matchQuizFacade.getUserGameEditions(e,t);getUserGamePrediction=async(e,t)=>await this.matchQuizFacade.getUserGamePrediction(e,t)};function Eh(o){let t=new zt().validate(o);if(t.idSchema.validation==="missing"&&(console.warn(t.idSchema.message.text),o.idSchema="native"),t.environment.validation==="missing"&&(console.warn(t.environment.message.text),o.environment="prod"),t.lang.validation==="missing"&&(console.warn(t.lang.message.text),o.lang="en"),t.isValid)return{profile:new $t(o),football:new Qt(o),predictor:new Tr(o),loyalty:new Br(o),topX:new Lr(o),matchQuiz:new Ur(o)};throw new Error("Configuration is not valid")}export{Eh as FansUnitedSDK};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|