fansunited-sdk-esm 1.57.0 → 1.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.js.map +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var Qs=Object.create;var ts=Object.defineProperty;var Xs=Object.getOwnPropertyDescriptor;var Ys=Object.getOwnPropertyNames;var Js=Object.getPrototypeOf,Zs=Object.prototype.hasOwnProperty;var tn=(o,t,e)=>t in o?ts(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var Go=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var en=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ys(t))!Zs.call(o,r)&&r!==e&&ts(o,r,{get:()=>t[r],enumerable:!(i=Xs(t,r))||i.enumerable});return o};var rn=(o,t,e)=>(e=o!=null?Qs(Js(o)):{},en(t||!o||!o.__esModule?ts(e,"default",{value:o,enumerable:!0}):e,o));var ii=(o,t,e)=>(tn(o,typeof t!="symbol"?t+"":t,e),e);var Fs=Go((fl,jo)=>{var nn=function(){"use strict";function o(c,d){return d!=null&&c instanceof d}var t;try{t=Map}catch{t=function(){}}var e;try{e=Set}catch{e=function(){}}var i;try{i=Promise}catch{i=function(){}}function r(c,d,m,y,h){typeof d=="object"&&(m=d.depth,y=d.prototype,h=d.includeNonEnumerable,d=d.circular);var vt=[],Ot=[],Lt=typeof Buffer<"u";typeof d>"u"&&(d=!0),typeof m>"u"&&(m=1/0);function k(f,ct){if(f===null)return null;if(ct===0)return f;var v,Ze;if(typeof f!="object")return f;if(o(f,t))v=new t;else if(o(f,e))v=new e;else if(o(f,i))v=new i(function(ti,g){f.then(function(ei){ti(k(ei,ct-1))},function(ei){g(k(ei,ct-1))})});else if(r.__isArray(f))v=[];else if(r.__isRegExp(f))v=new RegExp(f.source,l(f)),f.lastIndex&&(v.lastIndex=f.lastIndex);else if(r.__isDate(f))v=new Date(f.getTime());else{if(Lt&&Buffer.isBuffer(f))return Buffer.allocUnsafe?v=Buffer.allocUnsafe(f.length):v=new Buffer(f.length),f.copy(v),v;o(f,Error)?v=Object.create(f):typeof y>"u"?(Ze=Object.getPrototypeOf(f),v=Object.create(Ze)):(v=Object.create(y),Ze=y)}if(d){var hs=vt.indexOf(f);if(hs!=-1)return Ot[hs];vt.push(f),Ot.push(v)}o(f,t)&&f.forEach(function(ti,g){var ei=k(g,ct-1),zs=k(ti,ct-1);v.set(ei,zs)}),o(f,e)&&f.forEach(function(ti){var g=k(ti,ct-1);v.add(g)});for(var Q in f){var Zo;Ze&&(Zo=Object.getOwnPropertyDescriptor(Ze,Q)),!(Zo&&Zo.set==null)&&(v[Q]=k(f[Q],ct-1))}if(Object.getOwnPropertySymbols)for(var gs=Object.getOwnPropertySymbols(f),Q=0;Q<gs.length;Q++){var Ho=gs[Q],Ne=Object.getOwnPropertyDescriptor(f,Ho);Ne&&!Ne.enumerable&&!h||(v[Ho]=k(f[Ho],ct-1),Ne.enumerable||Object.defineProperty(v,Ho,{enumerable:!1}))}if(h)for(var fs=Object.getOwnPropertyNames(f),Q=0;Q<fs.length;Q++){var ko=fs[Q],Ne=Object.getOwnPropertyDescriptor(f,ko);Ne&&Ne.enumerable||(v[ko]=k(f[ko],ct-1),Object.defineProperty(v,ko,{enumerable:!1}))}return v}return k(c,m)}r.clonePrototype=function(d){if(d===null)return null;var m=function(){};return m.prototype=d,new m};function a(c){return Object.prototype.toString.call(c)}r.__objToStr=a;function s(c){return typeof c=="object"&&a(c)==="[object Date]"}r.__isDate=s;function p(c){return typeof c=="object"&&a(c)==="[object Array]"}r.__isArray=p;function n(c){return typeof c=="object"&&a(c)==="[object RegExp]"}r.__isRegExp=n;function l(c){var d="";return c.global&&(d+="g"),c.ignoreCase&&(d+="i"),c.multiline&&(d+="m"),d}return r.__getRegExpFlags=l,r}();typeof jo=="object"&&jo.exports&&(jo.exports=nn)});var Ns=Go((yl,ls)=>{"use strict";var Ge=typeof Reflect=="object"?Reflect:null,Es=Ge&&typeof Ge.apply=="function"?Ge.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)},qo;Ge&&typeof Ge.ownKeys=="function"?qo=Ge.ownKeys:Object.getOwnPropertySymbols?qo=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:qo=function(t){return Object.getOwnPropertyNames(t)};function ln(o){console&&console.warn&&console.warn(o)}var Ss=Number.isNaN||function(t){return t!==t};function P(){P.init.call(this)}ls.exports=P;ls.exports.once=mn;P.EventEmitter=P;P.prototype._events=void 0;P.prototype._eventsCount=0;P.prototype._maxListeners=void 0;var Rs=10;function zo(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(P,"defaultMaxListeners",{enumerable:!0,get:function(){return Rs},set:function(o){if(typeof o!="number"||o<0||Ss(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");Rs=o}});P.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};P.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Ss(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function Cs(o){return o._maxListeners===void 0?P.defaultMaxListeners:o._maxListeners}P.prototype.getMaxListeners=function(){return Cs(this)};P.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var r=t==="error",a=this._events;if(a!==void 0)r=r&&a.error===void 0;else if(!r)return!1;if(r){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var p=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw p.context=s,p}var n=a[t];if(n===void 0)return!1;if(typeof n=="function")Es(n,this,e);else for(var l=n.length,c=Ds(n,l),i=0;i<l;++i)Es(c[i],this,e);return!0};function As(o,t,e,i){var r,a,s;if(zo(e),a=o._events,a===void 0?(a=o._events=Object.create(null),o._eventsCount=0):(a.newListener!==void 0&&(o.emit("newListener",t,e.listener?e.listener:e),a=o._events),s=a[t]),s===void 0)s=a[t]=e,++o._eventsCount;else if(typeof s=="function"?s=a[t]=i?[e,s]:[s,e]:i?s.unshift(e):s.push(e),r=Cs(o),r>0&&s.length>r&&!s.warned){s.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=o,p.type=t,p.count=s.length,ln(p)}return o}P.prototype.addListener=function(t,e){return As(this,t,e,!1)};P.prototype.on=P.prototype.addListener;P.prototype.prependListener=function(t,e){return As(this,t,e,!0)};function pn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Os(o,t,e){var i={fired:!1,wrapFn:void 0,target:o,type:t,listener:e},r=pn.bind(i);return r.listener=e,i.wrapFn=r,r}P.prototype.once=function(t,e){return zo(e),this.on(t,Os(this,t,e)),this};P.prototype.prependOnceListener=function(t,e){return zo(e),this.prependListener(t,Os(this,t,e)),this};P.prototype.removeListener=function(t,e){var i,r,a,s,p;if(zo(e),r=this._events,r===void 0)return this;if(i=r[t],i===void 0)return this;if(i===e||i.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if(typeof i!="function"){for(a=-1,s=i.length-1;s>=0;s--)if(i[s]===e||i[s].listener===e){p=i[s].listener,a=s;break}if(a<0)return this;a===0?i.shift():cn(i,a),i.length===1&&(r[t]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",t,p||e)}return this};P.prototype.off=P.prototype.removeListener;P.prototype.removeAllListeners=function(t){var e,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[t]),this;if(arguments.length===0){var a=Object.keys(i),s;for(r=0;r<a.length;++r)s=a[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=i[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this};function Ls(o,t,e){var i=o._events;if(i===void 0)return[];var r=i[t];return r===void 0?[]:typeof r=="function"?e?[r.listener||r]:[r]:e?dn(r):Ds(r,r.length)}P.prototype.listeners=function(t){return Ls(this,t,!0)};P.prototype.rawListeners=function(t){return Ls(this,t,!1)};P.listenerCount=function(o,t){return typeof o.listenerCount=="function"?o.listenerCount(t):xs.call(o,t)};P.prototype.listenerCount=xs;function xs(o){var t=this._events;if(t!==void 0){var e=t[o];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}P.prototype.eventNames=function(){return this._eventsCount>0?qo(this._events):[]};function Ds(o,t){for(var e=new Array(t),i=0;i<t;++i)e[i]=o[i];return e}function cn(o,t){for(;t+1<o.length;t++)o[t]=o[t+1];o.pop()}function dn(o){for(var t=new Array(o.length),e=0;e<t.length;++e)t[e]=o[e].listener||o[e];return t}function mn(o,t){return new Promise(function(e,i){function r(s){o.removeListener(t,a),i(s)}function a(){typeof o.removeListener=="function"&&o.removeListener("error",r),e([].slice.call(arguments))}Bs(o,t,a,{once:!0}),t!=="error"&&un(o,r,{once:!0})})}function un(o,t,e){typeof o.on=="function"&&Bs(o,"error",t,e)}function Bs(o,t,e,i){if(typeof o.on=="function")i.once?o.once(t,e):o.on(t,e);else if(typeof o.addEventListener=="function")o.addEventListener(t,function r(a){i.once&&o.removeEventListener(t,r),e(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof o)}});var ks=Go((Us,Hs)=>{(function(){var o,t,e,i=[].splice,r=function(s,p){if(!(s instanceof p))throw new Error("Bound instance method accessed before binding")},a=[].indexOf;e=Fs(),o=Ns().EventEmitter,Hs.exports=t=function(){class s extends o{constructor(n={}){super(),this.get=this.get.bind(this),this.mget=this.mget.bind(this),this.set=this.set.bind(this),this.mset=this.mset.bind(this),this.del=this.del.bind(this),this.take=this.take.bind(this),this.ttl=this.ttl.bind(this),this.getTtl=this.getTtl.bind(this),this.keys=this.keys.bind(this),this.has=this.has.bind(this),this.getStats=this.getStats.bind(this),this.flushAll=this.flushAll.bind(this),this.flushStats=this.flushStats.bind(this),this.close=this.close.bind(this),this._checkData=this._checkData.bind(this),this._check=this._check.bind(this),this._isInvalidKey=this._isInvalidKey.bind(this),this._wrap=this._wrap.bind(this),this._getValLength=this._getValLength.bind(this),this._error=this._error.bind(this),this._initErrors=this._initErrors.bind(this),this.options=n,this._initErrors(),this.data={},this.options=Object.assign({forceString:!1,objectValueSize:80,promiseValueSize:80,arrayValueSize:40,stdTTL:0,checkperiod:600,useClones:!0,deleteOnExpire:!0,enableLegacyCallbacks:!1,maxKeys:-1},this.options),this.options.enableLegacyCallbacks&&(console.warn("WARNING! node-cache legacy callback support will drop in v6.x"),["get","mget","set","del","ttl","getTtl","keys","has"].forEach(l=>{var c;c=this[l],this[l]=function(...d){var m,y,h,vt;if(h=d,[...d]=h,[m]=i.call(d,-1),typeof m=="function")try{vt=c(...d),m(null,vt)}catch(Ot){y=Ot,m(y)}else return c(...d,m)}})),this.stats={hits:0,misses:0,keys:0,ksize:0,vsize:0},this.validKeyTypes=["string","number"],this._checkData()}get(n){var l,c;if(r(this,s),(c=this._isInvalidKey(n))!=null)throw c;if(this.data[n]!=null&&this._check(n,this.data[n]))return this.stats.hits++,l=this._unwrap(this.data[n]),l;this.stats.misses++}mget(n){var l,c,d,m,y,h;if(r(this,s),!Array.isArray(n))throw l=this._error("EKEYSTYPE"),l;for(h={},d=0,y=n.length;d<y;d++){if(m=n[d],(c=this._isInvalidKey(m))!=null)throw c;this.data[m]!=null&&this._check(m,this.data[m])?(this.stats.hits++,h[m]=this._unwrap(this.data[m])):this.stats.misses++}return h}set(n,l,c){var d,m,y;if(r(this,s),this.options.maxKeys>-1&&this.stats.keys>=this.options.maxKeys)throw d=this._error("ECACHEFULL"),d;if(this.options.forceString&&!typeof l==="string"&&(l=JSON.stringify(l)),c==null&&(c=this.options.stdTTL),(m=this._isInvalidKey(n))!=null)throw m;return y=!1,this.data[n]&&(y=!0,this.stats.vsize-=this._getValLength(this._unwrap(this.data[n],!1))),this.data[n]=this._wrap(l,c),this.stats.vsize+=this._getValLength(l),y||(this.stats.ksize+=this._getKeyLength(n),this.stats.keys++),this.emit("set",n,l),!0}mset(n){var l,c,d,m,y,h,vt,Ot,Lt,k;if(r(this,s),this.options.maxKeys>-1&&this.stats.keys+n.length>=this.options.maxKeys)throw l=this._error("ECACHEFULL"),l;for(d=0,vt=n.length;d<vt;d++){if(h=n[d],{key:y,val:k,ttl:Lt}=h,Lt&&typeof Lt!="number")throw l=this._error("ETTLTYPE"),l;if((c=this._isInvalidKey(y))!=null)throw c}for(m=0,Ot=n.length;m<Ot;m++)h=n[m],{key:y,val:k,ttl:Lt}=h,this.set(y,k,Lt);return!0}del(n){var l,c,d,m,y,h;for(r(this,s),Array.isArray(n)||(n=[n]),l=0,d=0,y=n.length;d<y;d++){if(m=n[d],(c=this._isInvalidKey(m))!=null)throw c;this.data[m]!=null&&(this.stats.vsize-=this._getValLength(this._unwrap(this.data[m],!1)),this.stats.ksize-=this._getKeyLength(m),this.stats.keys--,l++,h=this.data[m],delete this.data[m],this.emit("del",m,h.v))}return l}take(n){var l;return r(this,s),l=this.get(n),l!=null&&this.del(n),l}ttl(n,l){var c;if(r(this,s),l||(l=this.options.stdTTL),!n)return!1;if((c=this._isInvalidKey(n))!=null)throw c;return this.data[n]!=null&&this._check(n,this.data[n])?(l>=0?this.data[n]=this._wrap(this.data[n].v,l,!1):this.del(n),!0):!1}getTtl(n){var l,c;if(r(this,s),!!n){if((c=this._isInvalidKey(n))!=null)throw c;if(this.data[n]!=null&&this._check(n,this.data[n]))return l=this.data[n].t,l}}keys(){var n;return r(this,s),n=Object.keys(this.data),n}has(n){var l;return r(this,s),l=this.data[n]!=null&&this._check(n,this.data[n]),l}getStats(){return r(this,s),this.stats}flushAll(n=!0){r(this,s),this.data={},this.stats={hits:0,misses:0,keys:0,ksize:0,vsize:0},this._killCheckPeriod(),this._checkData(n),this.emit("flush")}flushStats(){r(this,s),this.stats={hits:0,misses:0,keys:0,ksize:0,vsize:0},this.emit("flush_stats")}close(){r(this,s),this._killCheckPeriod()}_checkData(n=!0){var l,c,d;r(this,s),c=this.data;for(l in c)d=c[l],this._check(l,d);n&&this.options.checkperiod>0&&(this.checkTimeout=setTimeout(this._checkData,this.options.checkperiod*1e3,n),this.checkTimeout!=null&&this.checkTimeout.unref!=null&&this.checkTimeout.unref())}_killCheckPeriod(){if(this.checkTimeout!=null)return clearTimeout(this.checkTimeout)}_check(n,l){var c;return r(this,s),c=!0,l.t!==0&&l.t<Date.now()&&(this.options.deleteOnExpire&&(c=!1,this.del(n)),this.emit("expired",n,this._unwrap(l))),c}_isInvalidKey(n){var l;if(r(this,s),l=typeof n,a.call(this.validKeyTypes,l)<0)return this._error("EKEYTYPE",{type:typeof n})}_wrap(n,l,c=!0){var d,m,y,h;return r(this,s),this.options.useClones||(c=!1),m=Date.now(),d=0,h=1e3,l===0?d=0:l?d=m+l*h:this.options.stdTTL===0?d=this.options.stdTTL:d=m+this.options.stdTTL*h,y={t:d,v:c?e(n):n}}_unwrap(n,l=!0){return this.options.useClones||(l=!1),n.v!=null?l?e(n.v):n.v:null}_getKeyLength(n){return n.toString().length}_getValLength(n){return r(this,s),typeof n=="string"?n.length:this.options.forceString?JSON.stringify(n).length:Array.isArray(n)?this.options.arrayValueSize*n.length:typeof n=="number"?8:typeof n?.then=="function"?this.options.promiseValueSize:typeof Buffer<"u"&&Buffer!==null&&Buffer.isBuffer(n)?n.length:n!=null&&typeof n=="object"?this.options.objectValueSize*Object.keys(n).length:typeof n=="boolean"?8:0}_error(n,l={}){var c;return r(this,s),c=new Error,c.name=n,c.errorcode=n,c.message=this.ERRORS[n]!=null?this.ERRORS[n](l):"-",c.data=l,c}_initErrors(){var n,l,c;r(this,s),this.ERRORS={},c=this._ERRORS;for(l in c)n=c[l],this.ERRORS[l]=this.createErrorMessage(n)}createErrorMessage(n){return function(l){return n.replace("__key",l.type)}}}return s.prototype._ERRORS={ENOTFOUND:"Key `__key` not found",ECACHEFULL:"Cache max keys amount exceeded",EKEYTYPE:"The key argument has to be of type `string` or `number`. Found: `__key`",EKEYSTYPE:"The keys argument has to be an array.",ETTLTYPE:"The ttl argument has to be a number."},s}.call(this)}).call(Us)});var $s=Go((Gs,Vs)=>{(function(){var o;o=Vs.exports=ks(),o.version="5.1.2"}).call(Gs)});var es=o=>{let t=200,e=[],i=0;return e[i]=[],o.forEach(r=>{e[i].length<=t-1?e[i].push(r):(i++,e[i]=[r])}),e},xt=(o,t)=>{let e=[];for(;o.length>t;){let i=o.splice(0,t);e.push(i)}return e.push(o),e},R=(o,t)=>{let e="",i={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",loyalty:"https://loyalty.fansunitedapi.com/v1",miniGames:"https://mini-games.fansunitedapi.com/v1",discussions:"https://discussions.fansunitedapi.com/v1",privateLeagues:"https://private-leagues.fansunitedapi.com/v1"},r={profile:"https://profile.watg.fansunitedapi.com/v1",football:"https://football.watg.fansunitedapi.com/v1",idMapping:"https://id-mapping.watg.fansunitedapi.com/v1",predictor:"https://prediction.watg.fansunitedapi.com/v1",client:"https://client.watg.fansunitedapi.com/v1",loyalty:"https://loyalty.watg.fansunitedapi.com/v1",miniGames:"https://mini-games.watg.fansunitedapi.com/v1",discussions:"https://discussions.watg.fansunitedapi.com/v1",privateLeagues:"https://private-leagues.watg.fansunitedapi.com/v1"},a={profile:"http://localhost:8010/v1",football:"http://localhost:8080/v1",idMapping:"http://localhost:8030/v1",predictor:"http://localhost:8040/v1",client:"http://localhost:8070/v1",loyalty:"http://localhost:8060/v1",miniGames:"http://localhost:9040/v1",discussions:"http://localhost:9020/v1",privateLeagues:"http://localhost:9010/v1"},s={profile:"https://profile.fansunitedstagingapi.com/v1",football:"https://football.fansunitedstagingapi.com/v1",idMapping:"https://id-mapping.fansunitedstagingapi.com/v1",predictor:"https://prediction.fansunitedstagingapi.com/v1",client:"https://client.fansunitedstagingapi.com/v1",loyalty:"https://loyalty.fansunitedstagingapi.com/v1",miniGames:"https://mini-games.fansunitedstagingapi.com/v1",discussions:"https://discussions.fansunitedstagingapi.com/v1",privateLeagues:"https://private-leagues.fansunitedstagingapi.com/v1"};return o==="prod"?e=i[t]:o==="dev"?e=a[t]:o==="watg"?e=r[t]:e=s[t],e},_t=o=>o.filter((e,i,r)=>i===r.indexOf(e)),I=o=>o||!1,M=()=>`&disable_cache=${Date.now()}`,Vo=o=>JSON.parse(JSON.stringify(o.sort((t,e)=>t.localeCompare(e))));var ri=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var ai=class{profilesFromResponse=t=>t?t.map(e=>this.fullProfileFromResponse(e)):null;fullProfileFromResponse=t=>{let e=new ri;return e.id=t.id,e.name=t.name,e.nickname=t.nickname,e.avatar=t.avatar,e.gender=t.gender,e.country=t.country,e.birthDate=t.birth_date,e.interests=t.interests?t.interests:[],e.followingCount=t.following_count,e.followersCount=t.followers_count,e}};var dt=class{nextPageStartsAfter=null;itemsPerPage=null};var G=class{pagination=new dt};var E=class{meta=new G;data=[]};var oi=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var si=class{followResponse=t=>t.map(e=>this.remapResponse(e));followingFromResponse=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapResponse(i)),e};remapResponse=t=>{let e=new oi;return e.avatar=t.avatar,e.followingId=t.following_id,e.name=t.name,e.profileId=t.profile_id,e.nickname=t.nickname,e}};var ni=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var li=class{followersFromResponse=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapResponse(i)),e};remapResponse=t=>{let e=new ni;return e.avatar=t.avatar,e.followerId=t.follower_id,e.name=t.name,e.profileId=t.profile_id,e}};var Ue=class{profile_ids=[]};function is(o){this.message=o}is.prototype=new Error,is.prototype.name="InvalidCharacterError";var bs=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(o){var t=String(o).replace(/=+$/,"");if(t.length%4==1)throw new is("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,i,r=0,a=0,s="";i=t.charAt(a++);~i&&(e=r%4?64*e+i:i,r++%4)?s+=String.fromCharCode(255&e>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function an(o){var t=o.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(bs(e).replace(/(.)/g,function(i,r){var a=r.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a}))}(t)}catch{return bs(t)}}function $o(o){this.message=o}function on(o,t){if(typeof o!="string")throw new $o("Invalid token specified");var e=(t=t||{}).header===!0?0:1;try{return JSON.parse(an(o.split(".")[e]))}catch(i){throw new $o("Invalid token specified: "+i.message)}}$o.prototype=new Error,$o.prototype.name="InvalidTokenError";var Ms=on;var A={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id",api_football:"api_football_id"},rs={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},as=["matchId","matchType","market","prediction"],ws=new Map().set("FT_1X2","fullTimeOneXTwo").set("HT_1X2","halfTimeOneXTwo").set("BOTH_TEAMS_SCORE","bothTeamsScore").set("DOUBLE_CHANCE","doubleChance").set("HT_FT","halfTimeFullTime").set("PLAYER_SCORE","playerScore").set("PLAYER_YELLOW_CARD","playerYellowCard").set("PLAYER_RED_CARD","playerRedCard").set("RED_CARD_MATCH","redCardMatch").set("PENALTY_MATCH","penaltyMatch").set("PLAYER_SCORE_FIRST_GOAL","playerScoreFirstGoal").set("CORNERS_MATCH","cornersMatch").set("CORRECT_SCORE","correctScore").set("CORRECT_SCORE_ADVANCED","correctScoreAdvanced").set("CORRECT_SCORE_HT","correctScoreHalfTime").set("PLAYER_SCORE_HATTRICK","playerScoreHattrick").set("PLAYER_SCORE_TWICE","playerScoreTwice").set("OVER_GOALS_0_5","overZeroPointFiveGoals").set("OVER_GOALS_1_5","overOnePointFiveGoals").set("OVER_GOALS_2_5","overTwoPointFiveGoals").set("OVER_GOALS_3_5","overThreePointFiveGoals").set("OVER_GOALS_4_5","overFourPointFiveGoals").set("OVER_GOALS_5_5","overFivePointFiveGoals").set("OVER_GOALS_6_5","overSixPointFiveGoals").set("OVER_CORNERS_6_5","overSixPointFiveCorners").set("OVER_CORNERS_7_5","overSevenPointFiveCorners").set("OVER_CORNERS_8_5","overEightPointFiveCorners").set("OVER_CORNERS_9_5","overNinePointFiveCorners").set("OVER_CORNERS_10_5","overTenPointFiveCorners").set("OVER_CORNERS_11_5","overElevenPointFiveCorners").set("OVER_CORNERS_12_5","overTwelvePointFiveCorners").set("OVER_CORNERS_13_5","overThirteenPointFiveCorners");var os={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
2
2
|
${rs.PREDICTOR_USER_RELATED_OPERATION}`,UNEXPECTED_TYPE_PROP:`Unexpected provided property 'type'. You can NOT use this property for this method. For more information visit our documentation:
|
|
3
|
-
${rs.PREDICTOR_USER_RELATED_OPERATION}`},Is=(o,t)=>`The prediction '${o}' is invalid for market '${t}'. Please check again have you passed appropriate prediction model. For more information please visit our documentation: https://docs.fansunitedmedia.com/sdks/js/match.quiz#gamerelatedoperations`,Wo=o=>`The market '${o}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Ps=o=>`The market '${o}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Ts=o=>`The field/s '${o.length>1?o.join(", "):o[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,vs=(o,t)=>`The following field/s is/are missing from ${o}: '${t.length>1?t.join(", "):t[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,_s=(o,t)=>`The field ${o} has incorrect type. The correct type is ${t}`;var Ft=class{data={error:{code:0,status:"",message:""}};status=0;statusText="";headers=null;constructor(t,e){this.data.error.code=e.code,this.data.error.status=e.status,this.data.error.message=e.message,this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}errorMessage=()=>this.data.error.message};var u=class{error={code:0,status:"",message:""};constructor(t,e,i){this.error.code=t,this.error.status=e,this.error.message=i}};var _=class{baseUrl=null;apiSignInUrl=null;jwtToken=null;idSchema=null;retryRequest=!1;headers=null;authHeaders=null;errorHandlingMode=null;constructor(t,e){this.baseUrl=e,this.apiSignInUrl=`?key=${t.apiKey}&client_id=${t.clientId}`,this.jwtToken=t.authProvider.getIdToken(),this.errorHandlingMode=t.errorHandlingMode,this.idSchema=t.idSchema,this.headers={"Content-Type":"application/json"},this.authHeaders={"Content-Type":"application/json",Authorization:`Bearer ${t.authProvider.getIdToken()}`}}fetchWithoutAuth=async(t,e)=>{let i=await fetch(this.baseUrl+t,{headers:this.headers}),r=await i.json();if(!i.ok){let a=this.transformFetchException(i,r);throw console.warn(e,a),a}return r};fetchWithAuth=async(t,e,i,r)=>{this.validateJWTToken();let a=null,s=null;if(i&&r?a=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders,body:JSON.stringify(r)}):i&&!r?a=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders}):a=await fetch(this.baseUrl+t,{headers:this.authHeaders}),i!=="DELETE"&&(s=await a.json()),!a.ok){(a.status===401||a.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuth(t,e,i,r)),this.retryRequest=!1;let p=this.transformFetchException(a,s||await a.json());throw console.warn(e,p),p}return this.retryRequest=!1,s};fetchWithAuthNewBaseURL=async(t,e,i,r,a)=>{this.validateJWTToken();let s=null,p=null;if(r&&a?s=await fetch(t+e,{method:r,headers:this.authHeaders,body:JSON.stringify(a)}):r&&!a?s=await fetch(t+e,{method:r,headers:this.authHeaders}):s=await fetch(t+e,{headers:this.authHeaders}),r!=="DELETE"&&(p=await s.json()),!s.ok){(s.status===401||s.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuthNewBaseURL(t,e,i,r,a)),this.retryRequest=!1;let n=this.transformFetchException(s,p||await s.json());throw console.warn(i,n),n}return this.retryRequest=!1,p};transformFetchException=(t,e)=>{if(!e&&t.status===401){if(this.errorHandlingMode==="standard")return new u(401,"unauthorized","Invalid JWT token is provided");let s={code:401,status:"unauthorized",message:"Invalid JWT token is provided"};return new Ft(t,s)}let{code:i,status:r,message:a}=e.error;return this.errorHandlingMode==="standard"?new u(i,r,a):new Ft(t,e.error)};validateJWTToken=()=>{let t=null;try{t=Ms(this.jwtToken)}catch(i){if(this.errorHandlingMode==="default"){let r={status:401,statusText:i.message,headers:{}},a={code:401,status:"invalid_token",message:"Invalid JWT token is provided"};throw new Ft(r,a)}else if(this.errorHandlingMode==="standard")throw new u(401,"invalid_token","Invalid JWT token is provided")}if(Date.now()>t.exp*1e3){if(this.errorHandlingMode==="default"){let i={status:401,statusText:"",headers:{}},r={code:401,status:"invalid_token",message:"The provided JWT token is expired"};throw new Ft(i,r)}else if(this.errorHandlingMode==="standard")throw new u(401,"invalid_token","The provided JWT token is expired")}}};var sn="/countries",U="/profile",Ko="/profiles",Dt=class extends _{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(t){super(t,R(t.environment,"profile")),this.lang=t.lang,this.profileRemapper=new ai,this.followingRemapper=new si,this.followersRemapper=new li}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${sn}${this.apiSignInUrl}${e}`,r=Date.now(),a="There was a problem fetching profile countries";return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,a)).data};getProfile=async t=>{let e=`${U}${this.apiSignInUrl}`,i="";if(t){e=`${Ko}/${t}${this.apiSignInUrl}`,i=`There was a problem fetching the following profile: ${t}`;let r=await this.fetchWithoutAuth(e,i);return this.profileRemapper.fullProfileFromResponse(r.data)}else{i="There was a problem fetching your profile from API";let r=await this.fetchWithAuth(e,i);return this.profileRemapper.fullProfileFromResponse(r.data)}};getProfiles=async(t,e,i)=>{let r=Date.now(),a=`There was a problem fetching the following profiles: ${t.join(",")}`;if(t&&t.length){if(t.length>this.limitIds){let c=[],d=xt(t,this.limitIds);for(let m of d){let y=`${Ko}${this.apiSignInUrl}&profile_ids=${m.join(",")}`;a=`There was a problem fetching the following profiles: ${m.join(",")}`,i&&(y+=`&disable_cache=${r}`);let h=await this.fetchWithoutAuth(y,a);c.push(...this.profileRemapper.profilesFromResponse(h.data))}return c}let n=`${Ko}${this.apiSignInUrl}&profile_ids=${t.join(",")}`;i&&(n+=`&disable_cache=${r}`);let l=await this.fetchWithoutAuth(n,a);return this.profileRemapper.profilesFromResponse(l.data)}let s=`${Ko}${this.apiSignInUrl}&search=${e}`;i&&(s+=`&disable_cache=${r}`);let p=await this.fetchWithoutAuth(s,a);return this.profileRemapper.profilesFromResponse(p.data)};getFollowers=async(t,e)=>{let i=`${U}/followers${this.apiSignInUrl}`,r="There was a problem fetching the followers for own profile";if(t&&!e){i=`${U}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`;let s=await this.fetchWithAuth(i,r);return this.followersRemapper.followersFromResponse(s)}else if(!t&&!e){let s=await this.fetchWithAuth(i,r);return this.followersRemapper.followersFromResponse(s)}t&&e?i=`${U}/${e}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${U}/${e}/followers${this.apiSignInUrl}`),r=`There was a problem fetching the followers for profile: ${e}`;let a=await this.fetchWithoutAuth(i,r);return this.followersRemapper.followersFromResponse(a)};getFollowing=async(t,e)=>{let i=`${U}/following${this.apiSignInUrl}`,r="There was a problem fetching the followers of own profile";if(t&&!e){i=`${U}/following${this.apiSignInUrl}${t.constructFilterUrl()}`;let s=await this.fetchWithAuth(i,r);return this.followingRemapper.followingFromResponse(s)}else if(!t&&!e){let s=await this.fetchWithAuth(i,r);return this.followingRemapper.followingFromResponse(s)}t&&e?i=`${U}/${e}/following${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${U}/${e}/following${this.apiSignInUrl}`),r=`There was a problem fetching the followers of the following profile: ${e}`;let a=await this.fetchWithoutAuth(i,r);return this.followingRemapper.followingFromResponse(a)};follow=async t=>{let e=new Ue;e.profile_ids=t;let i=U+`/follow${this.apiSignInUrl}`,r=`There was a problem with following profiles: ${t.join(",")}`,a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.followingRemapper.followResponse(s.data)};unfollow=async t=>{let e=new Ue;e.profile_ids=t;let i=U+`/follow${this.apiSignInUrl}`,r=`There was a problem with unfollowing profiles: ${t.join(",")}`,a="DELETE";return await this.fetchWithAuth(i,r,a,e),!0};getBadges=async t=>{let e=`${U}/badges${this.apiSignInUrl}`,i="There was a problem with fetching own badges";return t?(e=`${U}/${t}/badges${this.apiSignInUrl}`,i="There was a problem with fetching the badges",(await this.fetchWithoutAuth(e,i)).data):(await this.fetchWithAuth(e,i)).data};updateProfile=async t=>{let e=U+this.apiSignInUrl,i="There was a problem updating the own profile",r="PATCH",a=await this.fetchWithAuth(e,i,r,t);return this.profileRemapper.fullProfileFromResponse(a.data)}};var x=(a=>(a.NATIVE="native",a.ENETPULSE="enetpulse",a.SPORTRADAR="sportradar",a.SPORTAL_365="sportal365",a.API_FOOTBALL="api_football",a))(x||{});var pi={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},ci=class extends _{constructor(t){super(t,R(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${pi[t]}=${e}`,r=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(i,r)};getEntityByIdAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${pi[t]}=${e}`,a=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(r,a)};getEntityIdsByIdsAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${pi[t]}=${e.join(",")}`,a=`There was a problem with id mapping request for the following ids: ${e.join(",")}`;return await this.fetchWithoutAuth(r,a)};getEntitiesByIds=async(t,e,i)=>{e.sort((s,p)=>s.localeCompare(p));let r=es(e),a=[];for(let s of r){let p=`/football${this.apiSignInUrl}&input_provider=${i}&${pi[t]}=${s.join(",")}`,n=`There was a problem with id mapping request for the following ids :${s.join(",")}`,l=await this.fetchWithoutAuth(p,n);a=[...a,...l.data]}return a};getEntitiesByIdObjs=async(t,e)=>{let i=[],r={},a=[];Object.keys(t).forEach(l=>{i.push.apply(i,t[l])});let s=_t(i),p=es(s);for(let l of p){let c="";if(Object.keys(t).forEach(d=>{r[d]=[];let m=l.filter(y=>t[d].includes(y));m&&m.length>0&&(r[d]=m)}),Object.keys(r).forEach(d=>{r[d].length>0&&(r[d].sort((m,y)=>m.localeCompare(y)),c+="&",c+=`${pi[d]}=${r[d].join(",")}`)}),c&&c.length>0){let d=`/football${this.apiSignInUrl}&input_provider=${e||"native"}${c}`,m="There was a problem with id mapping request",y=await this.fetchWithoutAuth(d,m);a.push(y.data)}else a.push([])}return Array.prototype.concat.apply([],a)};getTopEntities=async()=>{let t=`/football/top${this.apiSignInUrl}`,e="There was a problem with top id mappings request";return(await this.fetchWithoutAuth(t,e)).data}};var ss="FansUnited",ns={football:{ids:[],countries:[],competitions:[],expirations:{ids:0}},profile:{info:{},statistics:{},badges:null,countries:[],expirations:{profile:0,statistics:0,badges:0}},client:{features:{},expirations:{features:0}}},He=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t}static getInstance(t){return He.instance||(He.instance=new He(t)),He.instance}clearData=()=>{this.setData(ns)};getEntityById=(t="",e="")=>this.getData().football.ids.find(i=>{let r=A[this.idSchema];return i&&`${i[r]}`===e&&i.resource===t});getEntity=(t,e,i)=>Array.isArray(t)?this.getData().football.ids.filter(r=>{let a=A[i];return r&&t.includes(`${r[a]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let a=A[i];return r&&`${r[a]}`===t&&r.resource===e});getEntityByNativeId=(t="",e="")=>this.getData().football.ids.find(i=>i&&`${i.id}`===e&&i.resource===t);checkForExistingIdObjs=(t,e)=>{let i=A[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),l=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=A[i],a=A[e],s={};return Object.keys(t).forEach(p=>{let n=t[p],l=[];this.getData().football.ids.forEach(c=>{n.forEach((d,m)=>{d===c[a]&&p===c.resource&&(l[m]=c[r])})}),s[p]=l}),s};addIdMapping=t=>{let e=this.getData();e.football.ids.push(t),this.setData(e)};addIdMappings=t=>{let e=this.getData(),i=e.football.ids;i=[...i,...t],e.football.ids=i,this.setData(e)};addTopIdMappings=t=>{let e=this.getData();if(e.football.ids.length){let i=JSON.parse(JSON.stringify(e.football.ids));i=i.filter(r=>r.resource!=="match"),t=t.filter(r=>r.resource==="match"),i=[...i,...t],e.football.ids=i}else e.football.ids=t;e.football.expirations.ids=Math.floor(Date.now()/1e3)+this.expirationFootballIdsTimeout,this.setData(e)};setOwnProfile=t=>{let e=this.getData();e.profile.info=t,e.profile.expirations.profile=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(e)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=t=>{let e=this.getData();e.profile.countries=t,this.setData(e)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=t=>{let e=this.getData();e.profile.statistics=t,e.profile.expirations.statistics=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(e)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=t=>{let e=this.getData();e.profile.badges=t,e.profile.expirations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(e)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=t=>{let e=this.getData();e.football.countries=t,this.setData(e)};getCompetitions=t=>{let e=this.getData();return t?t.competitionSearchFilter(e.football.competitions):e.football.competitions};setCompetitions=t=>{let e=this.getData(),i=[...e.football.competitions];i.push(...t),e.football.competitions=this.makeCompetitionsUnique(i),this.setData(e)};getCompetitionsLength=()=>{let{football:t}=this.getData();return t.competitions.length};getClientFeatures=()=>this.getData().client.features;setClientFeatures=t=>{let e=this.getData(),i=JSON.parse(JSON.stringify(t));e.client.expirations.features=Math.floor(Date.now()/1e3)+this.expirationClientFeaturesTimeout,e.client.features=i,this.setData(e)};deleteClientFeatures=()=>{let t=this.getData(),e=JSON.parse(JSON.stringify(t));e.client={features:{},expirations:{features:0}},this.setData(e)};getExpiration=(t,e)=>{this.initialNewSchema(t,"expirations");let i=this.getData();switch(e){case"profile":return i.profile.expirations.profile;case"statistics":return i.profile.expirations.statistics;case"badges":return i.profile.expirations.badges;case"features":return i.client.expirations.features;case"ids":return i.football.expirations.ids}};makeCompetitionsUnique=t=>{let e=new Set;return t.filter(i=>{let r=!e.has(i.id);return e.add(i.id),r})};getData=()=>(localStorage.getItem(ss)||this.setData(ns),JSON.parse(localStorage.getItem(ss)));setData=t=>{localStorage.setItem(ss,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(ns)}},ke=He;ii(ke,"instance");var Ws=rn($s());var b=class{profileTTL=600;clientTTL=14400;profileBadgesTTL=3600;idMappingsExpiration=0;idSchema="";constructor(t){}static getInstance(t){return b.instance||(b.instance=new b(t),b.nodeCache.options.useClones=!1),b.instance}clearData=()=>b.nodeCache.flushAll();getEntityById=(t,e)=>{let i=b.nodeCache.get("ids");return i?i.find(r=>{let a=A[this.idSchema];return r&&`${r[a]}`===e&&r.resource===t}):null};getEntity=(t,e,i)=>{let r=b.nodeCache.get("ids");return r?Array.isArray(t)?[]:null:Array.isArray(t)?r.filter(a=>{let s=A[i];return a&&t.includes(`${a[s]}`)&&a.resource===e}):r.find(a=>{let s=A[i];return a&&`${a[s]}`===t&&a.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=A[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),l=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=A[i],a=A[e],s=b.nodeCache.get("ids"),p={};return s?(Object.keys(t).forEach(n=>{let l=t[n],c=[];s.forEach(d=>{l.forEach((m,y)=>{m===d[a]&&n===d.resource&&(c[y]=d[r])})}),p[n]=c}),p):null};addIdMapping=t=>{let e=b.nodeCache.get("ids");e.push(t),b.nodeCache.set("ids",e)};addIdMappings=t=>{let e=b.nodeCache.get("ids");e=[...e,...t],b.nodeCache.set("ids",e)};addTopIdMappings=t=>{let e=b.nodeCache.get("ids"),i=604800;if(e){let r=JSON.parse(JSON.stringify(e));r=r.filter(a=>a.resource!=="match"),t=t.filter(a=>a.resource==="match"),r=[...r,...t],b.nodeCache.set("ids",r)}else b.nodeCache.set("ids",t);this.idMappingsExpiration=Math.floor(Date.now()/1e3)+i};setOwnProfile=t=>b.nodeCache.set("profile",t,this.profileTTL);getOwnProfile=()=>b.nodeCache.get("profile");getProfileCountries=()=>b.nodeCache.get("profile_countries");setProfileCountries=t=>b.nodeCache.set("profile_countries",t);getProfileStats=()=>b.nodeCache.get("profile_stats");setProfileStats=t=>b.nodeCache.set("profile_stats",t,this.profileTTL);getProfileBadges=()=>b.nodeCache.get("profile_badges");setProfileBadges=t=>{b.nodeCache.set("profile_badges",t,this.profileBadgesTTL)};getFootballCountries=()=>b.nodeCache.get("football_countries");setFootballCountries=t=>b.nodeCache.set("football_countries",t);getCompetitions=t=>{let e=b.nodeCache.get("football_competitions");return e?t?t.competitionSearchFilter(e):e:null};setCompetitions=t=>b.nodeCache.set("football_competitions",t);getCompetitionsLength=()=>{let t=b.nodeCache.get("football_competitions");return t?t.length:0};getClientFeatures=()=>b.nodeCache.get("client");setClientFeatures=t=>b.nodeCache.set("client",t,this.clientTTL);deleteClientFeatures=()=>b.nodeCache.del("client");getExpiration=(t,e)=>{let i=this.getKeyFromExpirationType(e);return i==="ids"?this.idMappingsExpiration:b.nodeCache.getTtl(i)};getKeyFromExpirationType=t=>{switch(t){case"profile":return"profile";case"statistics":return"profile_stats";case"badges":return"profile_badges";case"features":return"client";case"ids":return"ids"}}},Bt=b;ii(Bt,"instance"),ii(Bt,"nodeCache",new Ws.default);var V=class{createLocalCacheInstance=t=>typeof window>"u"?Bt.getInstance(t):ke.getInstance(t)};var di=class{localCache=null;https=null;constructor(t){this.localCache=new V().createLocalCacheInstance(t.idSchema),this.https=new ci(t)}getEntitiesByIds=async(t,e,i)=>{await this.setTopIdMappings();try{let r=this.localCache.checkForExistingIdObjs(t,e),a=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(a.request,e);return this.localCache.addIdMappings(s),this.localCache.getIdsByType(t,e,i)}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}};getEntityById=async(t,e,i)=>{let r=this.localCache.getEntity(t,e,i);if(r)return r;let a=await this.requestEntity(t,e,i);return this.localCache.addIdMappings(a),a};splitForRequestAndExisting=t=>{let e={},i={};return Object.keys(t).forEach(r=>{e[r]=t[r].filter(a=>!a.exists).map(a=>a.id),i[r]=t[r].filter(a=>a.exists).map(a=>a.id)}),{existing:i,request:e}};requestEntity=async(t,e,i)=>{try{return t=Array.isArray(t)?t:[t],await this.https.getEntitiesByIds(e,t,i)}catch(r){return console.warn(`There was a problem retrieving the requested entity: ${r}`),null}};setTopIdMappings=async()=>{let t=Math.floor(Date.now()/1e3);if(this.localCache.getExpiration("football","ids")>t)return Promise.resolve();let i=await this.https.getTopEntities();this.localCache.addTopIdMappings(i)}};var Qo=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 mi=class{extractedObjIds={};traverse=(t,e)=>(e=Qo(e),Array.isArray(t)?this.traverseArrExtract(t,e):t&&typeof t=="object"&&this.traverseObjExtract(t,e),this.extractedObjIds);traverseArrExtract=(t,e)=>{t&&t.length>0&&t.forEach(i=>{this.traverseObjExtract(i,e)})};traverseObjExtract=(t,e)=>{t&&Object.keys(t).length>0&&Object.keys(t).forEach(i=>{let r=t[i];i==="id"||i==="teamId"?(this.extractedObjIds.hasOwnProperty(e)||(this.extractedObjIds[e]=[]),r&&this.extractedObjIds[e].push(r)):t[i]&&this.traverse(t[i],i)})}};var ui=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=Qo(e),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(i),this.remappedIdsObj=i),Array.isArray(t)?this.traverseArrReplace(t,e):t&&typeof t=="object"&&this.traverseObjReplace(t,e),t);initReplaceObjIdsIndex=t=>{this.replaceObjIdsIndex={},Object.keys(t).forEach(e=>{this.replaceObjIdsIndex[e]=0})};traverseArrReplace=(t,e)=>{t&&t.length>0&&t.forEach(i=>{this.traverseObjReplace(i,e)})};traverseObjReplace=(t,e)=>{t&&Object.keys(t).length>0&&Object.keys(t).forEach(i=>{i==="id"||i==="teamId"?t[i]&&(t[i]=this.remappedIdsObj[e][this.replaceObjIdsIndex[e]],this.replaceObjIdsIndex[e]=this.replaceObjIdsIndex[e]+1):t[i]&&this.traverse(t[i],i,this.remappedIdsObj)})}};var F=class{idSchema="";idMappingFacade=null;constructor(t){this.idSchema=t.idSchema,this.idMappingFacade=new di(t)}getEntityIdBySchemaId=(t,e)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(t,e)=>{let i=JSON.parse(JSON.stringify(t));try{if(this.idSchema!=="native"){let a=new mi().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new ui().traverse(i,e,s))}else return t}catch(r){return console.warn(`There was a problem remapping entity: ${e} with inner entity `,r),[]}};getEntityIdsBySchemaId=async(t,e,i)=>{let r={};return r[e]=t,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(r,this.idSchema,i):r}};var H=class{completed=!1;percentage;constructor(t){this.percentage=t}};var hi=class{teamFollowed=new H(10);teamFavourite=new H(15);playerFollowed=new H(10);playerFavourite=new H(10);competitionFollowed=new H(10);competitionFavourite=new H(5);addedBirthdate=new H(10);addedGender=new H(10);addedCountry=new H(10);addedAvatar=new H(10)};var gi=class{totalPercentage;breakdown=new hi};var Ve=class{limit=0;startAfter=null;constructor(t){this.limit=t.limit?t.limit:20,this.startAfter=t.startAfter?t.startAfter:null}constructFilterUrl=()=>{let t="";return this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.startAfter&&(t=t+"&",t=t+`start_after=${this.startAfter}`),t}};var J=class{localCache;profileHttps=null;activityHttps=null;constructor(t,e,i){this.localCache=t,this.profileHttps=e,this.activityHttps=i}getOwn=async()=>{let t=this.getLocalStorageData("profile");if(t)return JSON.parse(JSON.stringify(t));try{let e=await this.profileHttps.getProfile();return this.localCache.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let t=await this.profileHttps.getProfile();return this.localCache.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}};getByIds=async(t,e,i)=>{if(t&&t.length>0&&e||!t&&t.length===0&&!e)throw new u(400,"invalid_method_call","The method 'getByIds' from Profile namespace is not called correctly. You need to provide 'profileIds' OR 'search' parameters to the method, but you can't use both of them or neither of them.");try{return await this.profileHttps.getProfiles(t,e,i)}catch(r){throw console.warn(`There was a problem retrieving the selected profiles: ${t.join(",")} `,r),r}};getById=async t=>{try{return await this.profileHttps.getProfile(t)}catch(e){throw console.warn(`There was a problem retrieving the selected profile: ${t} `,e),e}};getCountries=async t=>{t=t||!1;let e=this.localCache.getProfileCountries();if(e&&e.length>0)return e;try{let i=await this.profileHttps.getCountries(t);return this.localCache.setProfileCountries(i),i}catch(i){throw console.warn("There was a problem retrieving profile countries: ",i),i}};getFollowers=async(t,e)=>{try{t&&(t=new Ve(t));let i=await this.profileHttps.getFollowers(t,e),r=i.data.map(a=>a.followerId);if(r.length){let a=await this.getByIds(r),s=i.data.map(p=>(a.forEach(n=>{p.followerId===n.id&&(p.name=n.name,p.nickname=n.nickname,p.avatar=n.avatar)}),p));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your followers: ",i),i}};getFollowing=async(t,e)=>{try{t&&(t=new Ve(t));let i=await this.profileHttps.getFollowing(t,e),r=i.data.map(a=>a.followingId);if(r.length){let a=await this.getByIds(r),s=i.data.map(p=>(a.forEach(n=>{p.followingId===n.id&&(p.name=n.name,p.nickname=n.nickname,p.avatar=n.avatar)}),p));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your following profiles: ",i),i}};follow=async t=>{try{return await this.profileHttps.follow(t)}catch(e){throw console.warn(`There was a problem following profiles: ${t.join(",")} `,e),e}};unfollow=async t=>{try{return await this.profileHttps.unfollow(t)}catch(e){throw console.warn(`There was a problem unfollowing profiles: ${t.join(",")} `,e),e}};showFullnessProfile=t=>{let e=new gi,i=0;return t.avatar&&(e.breakdown.addedAvatar.completed=!0,i+=e.breakdown.addedAvatar.percentage),t.birthDate&&(e.breakdown.addedBirthdate.completed=!0,i+=e.breakdown.addedBirthdate.percentage),t.country&&(e.breakdown.addedCountry.completed=!0,i+=e.breakdown.addedCountry.percentage),t.gender&&(e.breakdown.addedGender.completed=!0,i+=e.breakdown.addedGender.percentage),t.interests&&t.interests.length>0&&(t.interests.find(c=>c.type==="team"&&c.favourite)&&(e.breakdown.teamFavourite.completed=!0,i+=e.breakdown.teamFavourite.percentage),t.interests.find(c=>c.type==="team")&&(e.breakdown.teamFollowed.completed=!0,i+=e.breakdown.teamFollowed.percentage),t.interests.find(c=>c.type==="player"&&c.favourite)&&(e.breakdown.playerFavourite.completed=!0,i+=e.breakdown.playerFavourite.percentage),t.interests.find(c=>c.type==="player")&&(e.breakdown.playerFollowed.completed=!0,i+=e.breakdown.playerFollowed.percentage),t.interests.find(c=>c.type==="competition"&&c.favourite)&&(e.breakdown.competitionFavourite.completed=!0,i+=e.breakdown.competitionFavourite.percentage),t.interests.find(c=>c.type==="competition")&&(e.breakdown.competitionFollowed.completed=!0,i+=e.breakdown.competitionFollowed.percentage)),e.totalPercentage=i,e};getStats=async()=>{let t=["predictionsMade","predictions","tiers","badges"],e=this.getLocalStorageData("statistics"),i=e?t.every(r=>Object.keys(e).includes(r)):!1;if(e&&Object.keys(e).length&&i)return JSON.parse(JSON.stringify(e));try{let r=await this.activityHttps.getStats();return this.localCache.setProfileStats(r),r}catch(r){throw console.warn("There was a problem retrieving own profile statistics: ",r),r}};getBadges=async()=>{let t=this.getLocalStorageData("badges");if(t)return t;try{let e=await this.profileHttps.getBadges();return this.localCache.setProfileBadges(e),e}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=t=>{let e=Math.floor(Date.now()/1e3),i=this.localCache.getExpiration("profile",t);switch(t){case"profile":if(i>e)return this.localCache.getOwnProfile();case"statistics":if(i>e)return this.localCache.getProfileStats();case"badges":if(i>e)return this.localCache.getProfileBadges();default:return null}}};var fi=class{id=null;name=null;assets=null};var yi=class{extractUpdatedProps=(t,e)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(t).forEach(a=>{if(i.includes(a)&&t[a]!==e[a])r[a]=e[a];else if(a==="birthDate")(e[a]===null||t[a]===null&&e[a]||t[a]!==e[a])&&(r.birth_date=e[a]);else if(a==="country")e[a]===null?r.country_id=e[a]:(t[a]===null&&e[a]||t[a].id!==e[a].id)&&(r.country_id=e[a].id);else if(a==="interests"){let s=t[a],p=e[a];p.length&&this.isNewInterest(s,p)?r[a]=this.updateInterests(s,p):(!p.length&&s.length||s.length!==p.length&&!this.isNewInterest(s,p))&&(r[a]=p)}}),r};updateInterests=(t,e)=>{if(t.length===e.length){let[i,r]=this.extractSameAndNewInterests(t,e);return[...r,...i]}else return e};isNewInterest=(t,e)=>{let i=!1,[r]=this.extractSameAndNewInterests(t,e);return r.length&&(i=!0),i};extractSameAndNewInterests=(t,e)=>{let i=e.filter(a=>t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite));return[e.filter(a=>!t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite)),i]};isAvatarValidURL=t=>{try{return new URL(t),!0}catch{return!1}}};var w=class extends Error{code=0;status=null;message=null;constructor(t,e,i){super(),this.code=t,this.status=e,this.message=i}errorMessage=()=>this.message};var bi=class{idsRemapper=null;profileHttps=null;profileService=null;localCache=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;errorHandlingMode=null;constructor(t,e,i,r,a){this.idsRemapper=t,this.localCache=e,this.profileHttps=i,this.errorHandlingMode=a,this.profileService=new yi,this.profileFacade=new J(e,i,r)}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 t=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<t){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let e=await this.profileFacade.getOwn();this.setOwnProfile(e)}catch(e){throw this.isFetching=!1,e}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=t=>new Promise(e=>{setTimeout(e,t)});setOwnProfile=t=>{this.ownProfile=t};getInfo=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return delete e.interests,e};showInterests=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.remapInterests(e.interests)};showFullInterests=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.showFullInterests(e.interests)};getFollowers=async t=>await this.profileFacade.getFollowers(t);getFollowing=async t=>await this.profileFacade.getFollowing(t);follow=async t=>{let e=await this.profileFacade.follow(t),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),e};unfollow=async t=>{let e=await this.profileFacade.unfollow(t),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),e};getStats=async()=>{let t=await this.profileFacade.getStats();return await this.idsRemapper.remapProfileStats(t)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e;let r=this.ownProfile.interests.filter(a=>a.id!==i.id||a.type!==i.type||a.source!==i.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(i),this};addInterest=t=>(this.promises.push(this.addInterestPromise(t)),this);removeInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;return t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==i.id||r.type!==i.type||r.source!==i.source),this};removeInterest=t=>(this.promises.push(this.removeInterestPromise(t)),this);setBirthdatePromise=async t=>(this.modified=!0,await this.getOwnProfile(),t?this.ownProfile.birthDate=t:this.ownProfile.birthDate=null,this);setBirthdate=t=>(this.promises.push(this.setBirthdatePromise(t)),this);setGenderPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t==="male"||t==="female"?this.ownProfile.gender=t:this.ownProfile.gender="unspecified",this);setGender=t=>(this.promises.push(this.setGenderPromise(t)),this);setNicknamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=t,this);setNickname=t=>(this.promises.push(this.setNicknamePromise(t)),this);setNamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=t,this);setName=t=>(this.promises.push(this.setNamePromise(t)),this);setCountryPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t&&!this.ownProfile.country?(this.ownProfile.country=new fi,this.ownProfile.country.id=t):t&&this.ownProfile.country?this.ownProfile.country.id=t:this.ownProfile.country=null,this);setCountry=t=>(this.promises.push(this.setCountryPromise(t)),this);showFullnessProfile=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return this.profileFacade.showFullnessProfile(e)};setAvatarPromise=async t=>{if(this.modified=!0,await this.getOwnProfile(),this.profileService.isAvatarValidURL(t))this.ownProfile.avatar=t;else{if(this.errorHandlingMode==="default")throw new w(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.errorHandlingMode==="standard")throw new u(400,"invalid_avatar","Invalid URL syntax for avatar image.")}return this};setAvatar=t=>(this.promises.push(this.setAvatarPromise(t)),this);update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let t=await this.profileFacade.getOwn(),e=await this.getOwnProfile(),i=this.profileService.extractUpdatedProps(t,e);if(this.modified=!1,this.expireAt=0,Object.keys(i).length){let a=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(a));return this.setOwnProfile(s),this.localCache.setOwnProfile(s),delete a.interests,a}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r}};var Mi=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(t,e,i,r){this.idsRemapper=t,this.profileHttps=i,this.activityHttps=r,this.profileFacade=new J(e,i,r)}setId=t=>(this.profileId=t,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let t=await this.getProfile();return delete t.interests,t};showInterests=async()=>{let t=await this.getProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.remapInterests(e.interests)};showFullInterests=async()=>{let t=await this.getProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.showFullInterests(e.interests)};getFollowers=async t=>await this.profileFacade.getFollowers(t,this.profileId);getFollowing=async t=>await this.profileFacade.getFollowing(t,this.profileId);showFullnessProfile=async()=>{let t=await this.getProfile();return this.profileFacade.showFullnessProfile(t)};getStats=async t=>{let e=await this.activityHttps.getStats(this.profileId,t);return await this.idsRemapper.remapProfileStats(e)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var wi=class{localCache=null;https=null;idMapping=null;constructor(t,e,i){this.localCache=t,this.idMapping=i,this.https=e}getCountriesWithIdMapping=async t=>{try{let e=await this.getCountries(t);return this.idMapping.remapEntities(e,"country")}catch(e){throw console.warn("There was a problem browsing countries as football entities",e),e}};getCountries=async t=>{t=t||!1;let e=this.localCache.getFootballCountries();if(e&&e.length>0)return e;try{let i=await this.https.getCountries(t);return this.localCache.setFootballCountries(i),i}catch(i){throw console.warn("There was a problem retrieving countries as football entities",i),i}}};var $e=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(t){this.countryId=t.countryId?`${t.countryId}`:null,this.name=t.name?t.name:null,this.gender=t.gender?t.gender:null,this.type=t.type?t.type:null,this.sortField=t.sortField?`${t.sortField}`:null,this.sortOrder=t.sortOrder?`${t.sortOrder}`:null,this.competitionIds=t.competitionIds?t.competitionIds:null}constructFilterUrl=()=>{let t="";return this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.gender&&(t=t+"&",t=t+`gender=${this.gender}`),this.type&&(t=t+"&",t=t+`type=${this.type}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.competitionIds&&(t=t+"&",t=t+`competition_ids=${this.competitionIds.join(",")}`),t};competitionSearchFilter=t=>{try{let e=this.filter(t);return this.sortField||this.sortOrder?this.sort(e):e}catch(e){return console.warn("There was a problem filtering the local competitions",e),[]}};filter=t=>{let e=this.entitiesToSearchWith();return t.filter(i=>{let r=!0;return e.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?r&&=i.country.id===this[a]:a==="name"?r&&=i.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?r&&=this[a].some(s=>i.id===s):r&&=i[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),r})};entitiesToSearchWith=()=>{let t=[];return this.countryId&&t.push("countryId"),this.name&&t.push("name"),this.gender&&t.push("gender"),this.type&&t.push("type"),this.sortField&&t.push("sortField"),this.sortOrder&&t.push("sortOrder"),this.competitionIds&&t.push("competitionIds"),t};sort=t=>{let e=[];return this.sortField==="name"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.name.localeCompare(i.name):i.name.localeCompare(r.name)):this.sortField==="country"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.country.name.localeCompare(i.country.name):i.country.name.localeCompare(r.country.name)):this.sortField==="scope"?t.forEach(i=>e[this.competitionIds.indexOf(i.id)]=i):!this.sortField&&this.sortOrder==="desc"&&(e=t.sort((i,r)=>r.id.localeCompare(i.id))),e}};var Ii=class{localStorage=null;https=null;idMapping=null;constructor(t,e,i){this.localStorage=t,this.idMapping=i,this.https=e}getCompetitionsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new $e(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");a.competition.length===0&&(i=!0),t.competitionIds=a.competition}if(i)return[]}let r=await this.getCompetitions(t,e);return await this.idMapping.remapEntities(r,"competition")}catch(i){throw console.warn("There was a problem browsing all of the competitions",i),i}};getCompetitionsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new $e({competitionIds:t,limit:i}),a=await this.getCompetitions(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=Vo(t),p=await this.idMapping.remapEntities(a,"competition");return s.forEach((n,l)=>e.set(n,p[l])),e};getCompetitions=async(t,e)=>{let i=null;if(e=e||!1,!this.localStorage.getCompetitionsLength()){try{i=await this.https.getCompetitions()}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}this.localStorage.setCompetitions(i)}return this.localStorage.getCompetitions(t)};getCompetitionByIdIdMapping=async(t,e)=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([t],"competition","native")).competition[0],a=await this.getCompetitionById(r,e);return await this.idMapping.remapEntities(a,"competition")}catch(i){throw console.warn(`There was a problem browsing the following competition:${t}`,i),i}};getCompetitionById=async(t,e)=>{try{return e=e||!1,await this.https.getCompetitionById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the competition with the following id: ${t}`,i),i}};getTopCompetitionsIdMapping=async t=>{try{let e=await this.getTopCompetitions(t);return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async t=>{try{return t=t||!1,await this.https.getTopCompetitions(t)}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var We=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(t){this.name=t.name?t.name:null,this.countryId=t.countryId?`${t.countryId}`:null,this.national=t.national?t.national:!1,this.gender=t.gender?t.gender:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.scope=t.scope?t.scope:null,this.sortField=t.sortField?`${t.sortField}`:null,this.sortOrder=t.sortOrder?`${t.sortOrder}`:null,this.teamIds=t.teamIds?t.teamIds:null}constructFilterUrl=()=>{let t="";return this.name&&(t=t+"&",t=t+`name=${this.name}`),this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.national&&(t=t+"&",t=t+`national=${this.national}`),this.gender&&(t=t+"&",t=t+`gender=${this.gender}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.scope&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),this.teamIds&&(t=t+"&",t=t+`team_ids=${this.teamIds.join(",")}`),t}};var Pi=class{reason="";words=[]};var Nt=class{enabled=!1;moderateLinks=!1;linksWhitelist=[];moderatorProfileId="";dictionary=new Pi};var Ti=class{enabled=!1;clientId=null;automaticModeration=new Nt};var vi=class{general=[];predictor=[];topX=[];matchQuiz=[]};var mt=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var _i=class{id;label;assets={mainImageUrl:""};enabled;requirements=new mt};var Ut=class extends mt{postPoints=null;postsCount=null;reactionsCount=null;totalDiscussionPoints=null};var Fi=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Ut};var Ei=class{id;weight;multiplier;conditions};var Ri=class{value=[new Ei]};var Ht=class{points=null;tiers=null;badges=null};var Si=class{enabled=!1;clientId=null;conditions={list:null};actions=new Ri;rewards=new Ht};var Ci=class{general=null;predictor=null;activity=null;topX=null;matchQuiz=null;discussionPost=null};var kt=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var Gt=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Ai=class{competitions=[];teams=[];markets=[]};var Vt=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new Ai;userDataConfig=null};var Oi=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var Li=class{remapPredictorConfig=t=>{let e=new Vt;return e.enabled=t.enabled,e.clientId=t.client_id,e.fullCoverageCompetitions=t.full_coverage_competitions,e.markets=t.markets,e.successRateScopes=t.success_rate_scopes,e.userDataConfig=t.user_data_config?this.remapUserDataConfig(t.user_data_config):null,e};remapTopXConfig=t=>{let e=new Gt;return e.enabled=t.enabled,e.clientId=t.client_id,e.minFixtures=t.min_fixtures,e.maxFixtures=t.max_fixtures,e.competitionsWhitelist=t.competitions_whitelist,e};remapMatchQuizConfig=t=>{let e=new kt;return e.enabled=t.enabled,e.clientId=t.client_id,e.defaultMarkets=t.default_markets,e.competitionsWhitelist=t.competitions_whitelist,e};remapLoyaltyConfig=t=>{let e=new Si;return e.enabled=t.enabled,e.clientId=t.client_id,e.conditions.list=t.conditions.list,e.actions.value=t.actions.value,e.rewards=this.remapRewards(t.rewards),e};remapDiscussionsConfig=t=>{let e=new Ti;return e.enabled=t.enabled,e.clientId=t.client_id,e.automaticModeration=t.automatic_moderation?this.remapAutomaticModeration(t.automatic_moderation):null,e};remapAutomaticModeration=t=>{let e=new Nt;return e.enabled=t.enabled,e.moderateLinks=t.moderate_links,e.linksWhitelist=t.links_whitelist,e.moderatorProfileId=t.moderator_profile_id,e.dictionary=t.dictionary,e};remapRewards=t=>{let e=new Ht;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new Ci;return e.general=t.general,e.discussionPost=t.discussion_post,e.predictor=t.predictor,e.activity=t.activity,e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapBadges=t=>{let e=new vi;return e.general=this.remapGeneralBadgeValues(t.general),e.predictor=this.remapBadgeValues(t.predictor),e.topX=this.remapBadgeValues(t.top_x),e.matchQuiz=this.remapBadgeValues(t.match_quiz),e};remapBadgeValues=t=>t.map(e=>{let i=new _i;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapRequirements(e.requirements),i});remapRequirements=t=>{let e=new mt;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e};remapUserDataConfig=t=>{let e=new Oi;return e.storeIp=t.store_ip,e.storeDeviceId=t.store_device_id,e.storeAgent=t.store_agent,e};remapGeneralBadgeValues=t=>t.map(e=>{let i=new Fi;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapGeneralRequirements(e.requirements),i});remapGeneralRequirements=t=>{let e=new Ut;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e.postPoints=t.post_points,e.postsCount=t.posts_count,e.reactionsCount=t.reactions_count,e.totalDiscussionPoints=t.total_discussion_points,e}};var B=class extends _{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(t){super(t,R(t.environment,"client")),this.clientId=t.clientId,this.localStorage=new V().createLocalCacheInstance(t.idSchema),this.featureConfigRemapper=new Li}getConfig=async t=>{let e=this.getCachedFeatures();if(!e){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0],a=i+r,s="There was a problem fetching client features from Client API";e=(await this.fetchWithoutAuth(a,s)).data,this.localStorage.setClientFeatures(e)}switch(t){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(e.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(e.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(e.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(e.loyalty);case"discussions":return this.featureConfigRemapper.remapDiscussionsConfig(e.discussions)}};getCachedFeatures=()=>{let t=this.getLocalStorageData();if(!(!t||!Object.keys(t).length))return t.predictor.client_id&&t.predictor.client_id!==this.clientId?(this.localStorage.deleteClientFeatures(),null):t};getLocalStorageData=()=>{let t=Math.floor(Date.now()/1e3);return this.localStorage.getExpiration("client","features")>t?this.localStorage.getClientFeatures():null}};var ut=class{clientHttps=null;constructor(t){this.clientHttps=new B(t)}setAvailableMarketsForMatch=async t=>{let{fullCoverageCompetitions:e,markets:i}=await this.clientHttps.getConfig("predictor");if(Array.isArray(t))return t.map(r=>this.setAvailableMarkets(r,e,i));if(typeof t=="object"&&Object.keys(t).length)return this.setAvailableMarkets(t,e,i)};setAvailableMarkets=(t,e,i)=>{let r=t.context.competition?.id;return r&&this.isMatchInCoverageCompetition(r,e)?(t.availableMarkets=i.all,t):(t.availableMarkets=i.main,t)};isMatchInCoverageCompetition=(t,e)=>{let i=!1;return e.includes(t)&&(i=!0),i}};var Di=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new ut(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new We(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(t.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");a.team.length===0&&(i=!0),t.teamIds=a.team}}if(i)return[];let r=await this.getTeams(t,e);return r.data=await this.idMapping.remapEntities(r.data,"team"),r}catch(i){throw console.warn("There was a problem browsing all teams",i),i}};getTeamsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new We({teamIds:t,limit:i}),{data:a}=await this.getTeams(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=Vo(t),p=await this.idMapping.remapEntities(a,"team");return s.forEach((n,l)=>e.set(n,p[l])),e};getTeams=async(t,e)=>{try{return e=e||!1,await this.https.getTeams(t,e)}catch(i){throw console.warn("There was a problem retrieving all teams",i),i}};getTeamByIdIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getTeamById(t,e);return await this.idMapping.remapEntities(r,"team")}catch(i){throw console.warn(`There was a problem browsing the following team:${t}`,i),i}};getTeamById=async(t,e)=>{try{return e=e||!1,await this.https.getTeamById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following team: ${t}`,i),i}};getTopTeamsIdMapping=async t=>{try{let e=await this.getTopTeams(t);return await this.idMapping.remapEntities(e,"team")}catch(e){throw console.warn("There was a problem browsing the top teams",e),e}};getTopTeams=async t=>{try{return t=t||!1,await this.https.getTopTeams(t)}catch(e){throw console.warn("There was a problem retrieving the top teams",e),e}};getNextMatchForTeamIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getNextMatchForTeam(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for the following team:${t}`,i),i}};getNextMatchForTeam=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForTeam(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for the following team: ${t}`,i),i}};getPrevMatchForTeamIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getPrevMatchForTeam(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for the following team:${t}`,i),i}};getPrevMatchForTeam=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForTeam(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for the following team: ${t}`,i),i}}};var Ke=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(t){this.countryId=t.countryId?t.countryId:null,this.scope=t.scope?t.scope:null,this.name=t.name?t.name:null,this.playerIds=t.playerIds?t.playerIds:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.sortField=t.sortField?t.sortField:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFilterUrl=()=>{let t="";return this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.scope&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.playerIds&&(t=t+"&",t=t+`player_ids=${this.playerIds.join(",")}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),t}};var ht=class{https=null;footballService=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new ut(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new Ke(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([t.countryId],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.playerIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.playerIds,"player","native");a.player.length===0&&(i=!0),t.playerIds=a.player}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(i)return[]}let r=await this.getPlayers(t,e);return r.data=await this.idMapping.remapEntities(r.data,"player"),r}catch(i){throw console.warn("There was a problem browsing the players",i),i}};getPlayersWithNativeIds=async t=>{let e=t.length,i=new Ke({playerIds:t,limit:e}),r=await this.getPlayers(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async t=>{let e={},i=_t(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getPlayersWithNativeIds(i);return i.forEach((a,s)=>e[a]=r[s]),e};getPlayers=async(t,e)=>{try{return e=e||!1,await this.https.getPlayers(t,e)}catch(i){throw console.warn("There was a problem retrieving the players",i),i}};getPlayerIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"player","native"),r=await this.getPlayerById(i.player[0],e);return await this.idMapping.remapEntities(r,"player")}catch(i){throw console.warn(`There was a problem browsing the following player:${t}`,i),i}};getPlayerById=async(t,e)=>{try{return e=e||!1,await this.https.getPlayerById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following player: ${t}`,i),i}};getTopPlayersIdMapping=async t=>{try{let e=await this.getTopPlayers(t);return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async t=>{try{return t=t||!1,await this.https.getTopPlayers(t)}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getNextMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for player:${t}`,i),i}};getNextMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for player: ${t}`,i),i}};getPrevMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for player:${t}`,i),i}};getPrevMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for player: ${t}`,i),i}}};var $t=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(t){this.countryIds=t.countryIds?t.countryIds:null,this.competitionIds=t.competitionIds?t.competitionIds:null,this.matchIds=t.matchIds?t.matchIds:null,this.status=t.status?t.status:null,this.teamIds=t.teamIds?t.teamIds:null,this.fromDate=t.fromDate?t.fromDate:null,this.toDate=t.toDate?t.toDate:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.sortField=t.sortField?t.sortField:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFilterUrl=()=>{let t="";return this.countryIds&&(t=t+"&",t=t+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(t=t+"&",t=t+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(t=t+"&",t=t+`matches=${this.matchIds.join(",")}`),this.status&&(t=t+"&",t=t+`status=${this.status}`),this.teamIds&&(t=t+"&",t=t+`teams=${this.teamIds.join(",")}`),this.fromDate&&(t=t+"&",t=t+`from_date=${this.fromDate}`),this.toDate&&(t=t+"&",t=t+`to_date=${this.toDate}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),t}};var gt=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new ut(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new $t(t),t.countryIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.countryIds,"country","native");t.countryIds=r.country}if(t.competitionIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");t.competitionIds=r.competition}if(t.matchIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.matchIds,"match","native");t.matchIds=r.match}if(t.teamIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");t.teamIds=r.team}}let i=await this.getMatches(t,e);return i.data=await this.footballService.setAvailableMarketsForMatch([...i.data]),i.data=await this.idMapping.remapEntities(i.data,"match"),i}catch(i){throw console.warn("There was a problem browsing the matches",i),i}};getMatchesWithNativeIds=async t=>{let e=t.length,i=new $t({matchIds:t,limit:e}),r=await this.getMatches(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async t=>{let e={},i=_t(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let a=new $t({matchIds:i,limit:i.length}),s=await this.getMatches(a),p=i.filter(n=>{if(s.data.every(l=>l.id!==n))return n});i=i.filter(n=>{if(!p.includes(n))return n})}return i.forEach((a,s)=>e[a]=r[s]),e};getMatches=async(t,e)=>{try{return e=e||!1,await this.https.getMatches(t,e)}catch(i){throw console.warn("There was a problem retrieving the matches",i),i}};getMatchIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"match","native"),r=await this.getMatchById(i.match[0],e),a=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(a,"match")}catch(i){throw console.warn(`There was a problem browsing the following match: ${t}`,i),i}};getMatchById=async(t,e)=>{try{return e=e||!1,await this.https.getMatchById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following match: ${t}`,i),i}}};var Bi=class{entities=null;query=null;scope=null;constructor(t){this.entities=t.entities?t.entities:null,this.query=t.query?t.query:null,this.scope=t.scope?t.scope:null}constructFilterUrl=()=>{let t="";return this.entities&&(t=t+"&",t=t+`entities=${this.entities.join(",")}`),this.query&&(t=t+"&",t=t+`q=${this.query}`),this.scope&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),t}};var Ni=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new Bi(t),t.scope){let r=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");t.scope=r.competition}let i=await this.search(t,e);if(i.teams&&i.teams.length>0){let r=await this.idMapping.remapEntities(i.teams,"team");i.teams=r}if(i.players&&i.players.length>0){let r=await this.idMapping.remapEntities(i.players,"player");i.players=r}if(i.competitions&&i.competitions.length>0){let r=await this.idMapping.remapEntities(i.competitions,"competition");i.competitions=r}return i}catch(i){throw console.warn("There was a problem with browsing the search result",i),i}};search=async(t,e)=>{try{return await this.https.search(t,e)}catch(i){throw console.warn("There was a problem retrieving the search response",i),i}}};var Wt=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new wi(e,i,r),this.competitionsFacade=new Ii(e,i,r),this.teamsFacade=new Di(t,i,r),this.playerFacade=new ht(t,i,r),this.matchFacade=new gt(t,i,r),this.searchFacade=new Ni(i,r)}getCountries=async t=>this.countriesFacade.getCountriesWithIdMapping(t);getCompetitions=async(t,e)=>this.competitionsFacade.getCompetitionsIdMapping(t,e);getCompetitionById=async(t,e)=>this.competitionsFacade.getCompetitionByIdIdMapping(t,e);getTopCompetitions=async t=>this.competitionsFacade.getTopCompetitionsIdMapping(t);getCompetitionsMapWithNativeIds=async t=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(t);getTeams=async(t,e)=>this.teamsFacade.getTeamsIdMapping(t,e);getTeamById=async(t,e)=>this.teamsFacade.getTeamByIdIdMapping(t,e);getTopTeams=async t=>this.teamsFacade.getTopTeamsIdMapping(t);getNextMatchForTeam=async(t,e)=>this.teamsFacade.getNextMatchForTeamIdMapping(t,e);getPrevMatchForTeam=async(t,e)=>this.teamsFacade.getPrevMatchForTeamIdMapping(t,e);getTeamsMapWithNativeIds=async t=>await this.teamsFacade.getTeamsMapWithNativeIds(t);getPlayers=async(t,e)=>this.playerFacade.getPlayersIdMapping(t,e);getPlayerById=async(t,e)=>this.playerFacade.getPlayerIdMapping(t,e);getTopPlayers=async t=>this.playerFacade.getTopPlayersIdMapping(t);getNextMatchForPlayer=async(t,e)=>this.playerFacade.getNextMatchForPlayerIdMapping(t,e);getPrevMatchForPlayer=async(t,e)=>this.playerFacade.getPrevMatchForPlayerIdMapping(t,e);getPlayersMapWithNativeIds=async t=>this.playerFacade.getPlayersMapWithNativeIds(t);getMatches=async(t,e)=>this.matchFacade.getMatchesIdMapping(t,e);getMatchById=async(t,e)=>this.matchFacade.getMatchIdMapping(t,e);search=async(t,e)=>this.searchFacade.searchIdMapping(t,e)};var Ui=class{id="";alias="";countryCode="";assets=null;name=""};var S=class{countriesFromResponse=t=>{if(t)return t.map(e=>this.countryFromResponse(e))};countryFromResponse=t=>{try{if(t){let e=new Ui;return e.id=t.id,e.alias=t.alias,e.assets=t.assets,e.countryCode=t.country_code,e.name=t.name,e}}catch(e){throw e}return null}};var Hi=class{id="";country=null;gender="";assets=null;type="";name=""};var N=class{countryRemapper=null;constructor(){this.countryRemapper=new S}fromResponse(t){try{let e=new Hi;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.type=t.type,e.name=t.name,e}catch(e){throw console.warn("There was a problem remapping the competition response",e),e}}};var ki=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Gi=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName="";isDeleted=!1};var O=class{countryRemapper=null;constructor(){this.countryRemapper=new S}fromResponse(t){try{let e=new Gi;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.code=t.code,e.national=t.national,e.fullName=t.full_name,e.shortName=t.short_name,e.name=t.name,e.isDeleted=t.is_deleted,e}catch(e){throw console.warn("There was a problem remapping teams response",e),e}}};var Vi=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new S,this.teamBasicRemapper=new O}fromResponse(t){try{let e=new ki;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.type=t.type,e.name=t.name,e.participants=t.participants.map(i=>this.teamBasicRemapper.fromResponse(i)),e}catch(e){throw console.warn("There was a problem remapping the competition response",e),e}}};var $i=class{primary=null;secondary=null;tertiary=null};var Wi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new $i;squad=[]};var Ki=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var ji=class{countryRemapper=null;constructor(){this.countryRemapper=new S}fromResponse(t){try{let e=new Ki;return e.id=t.id,e.startDate=t.start_date,e.endDate=t.end_date,e.shirtNumber=t.shirt_number,e.loan=t.loan,e.position=t.position,e.country=this.countryRemapper.countryFromResponse(t.country),e.name=t.name,e.assets=t.assets,e.birthDate=t.birth_date,e}catch(e){throw console.warn("There was a problem remapping the player from squad",e),e}}};var qi=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new S,this.competitionRemapper=new N,this.playerRemapper=new ji}fromResponse(t){try{let e=new Wi;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.code=t.code,e.national=t.national,e.fullName=t.full_name,e.shortName=t.short_name,e.name=t.name,e.isDeleted=t.is_deleted,e.competitions=t.competitions?t.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],e.colors=t.colors?t.colors:e.colors,e.squad=t.squad?t.squad.map(i=>this.playerRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping team response",e),e}}};var zi=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;isDeleted=!1;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Qi=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Kt=class{fromResponse(t){try{let e=new Qi;return e.ftScore=this.statEntityFromResponse(t.ft_score),e.htScore=this.statEntityFromResponse(t.ht_score),e.aetScore=this.statEntityFromResponse(t.aet_score),e.aggScore=this.statEntityFromResponse(t.agg_score),e.penScore=this.statEntityFromResponse(t.pen_score),e}catch(e){throw console.warn("There was a problem remapping the scores",e),e}}statEntityFromResponse=t=>({homeGoals:t.home_goals,awayGoals:t.away_goals})};var Xi=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new O,this.competitionRemapper=new N,this.scoresRemapper=new Kt}fromResponse(t){try{let e=new zi;return e.id=t.id,e.kickoffAt=t.kickoff_at,e.finishedAt=t.finished_at,e.updatedAt=t.updated_at,e.isDeleted=t.is_deleted,e.homeTeam=this.teamRemapper.fromResponse(t.home_team),e.awayTeam=this.teamRemapper.fromResponse(t.away_team),e.lineupsConfirmed=t.lineups_confirmed,e.startedAt=t.started_at,e.minute=t.minute,e.scores=this.scoresRemapper.fromResponse(t.scores),e.context={competition:t.context.competition?this.competitionRemapper.fromResponse(t.context.competition):null},e.status={type:t.status.type,subType:t.status.sub_type},e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var $=class{type=null;subType=null};var Yi=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;isDeleted=!1;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status=new $;lineups=null};var Ji=class{corners=null;cornersFirstHalf=null;cornersSecondHalf=null;cornersExtraTime=null;crosses=null;crossesFirstHalf=null;crossesSecondHalf=null;crossesExtraTime=null;offside=null;offsideFirstHalf=null;offsideSecondHalf=null;offsideExtraTime=null;shotsOn=null;shotsOnFirstHalf=null;shotsOnSecondHalf=null;shotsOnExtraTime=null;throwIn=null;throwInFirstHalf=null;throwInSecondHalf=null;throwInExtraTime=null;redCards=null;redCardsFirstHalf=null;redCardsSecondHalf=null;redCardsExtraTime=null;shotsOff=null;shotsOffFirstHalf=null;shotsOffSecondHalf=null;shotsOffExtraTime=null;goalKicks=null;goalKicksFirstHalf=null;goalKicksSecondHalf=null;goalKicksExtraTime=null;possession=null;possessionFirstHalf=null;possessionSecondHalf=null;possessionExtraTime=null;treatments=null;treatmentsFirstHalf=null;treatmentsSecondHalf=null;treatmentsExtraTime=null;yellowCards=null;yellowCardsFirstHalf=null;yellowCardsSecondHalf=null;yellowCardsExtraTime=null;shotsBlocked=null;shotsBlockedFirstHalf=null;shotsBlockedSecondHalf=null;shotsBlockedExtraTime=null;substitutions=null;substitutionsFirstHalf=null;substitutionsSecondHalf=null;substitutionsExtraTime=null;counterAttacks=null;counterAttacksFirstHalf=null;counterAttacksSecondHalf=null;counterAttacksExtraTime=null;foulsCommitted=null;foulsCommittedFirstHalf=null;foulsCommittedSecondHalf=null;foulsCommittedExtraTime=null};var Zi=class{fromResponse(t){try{let e=new Ji;return e.corners=this.statEntityFromResponse(t.corners),e.cornersFirstHalf=this.statEntityFromResponse(t.corners_1h),e.cornersSecondHalf=this.statEntityFromResponse(t.corners_2h),e.cornersExtraTime=this.statEntityFromResponse(t.corners_et),e.crosses=this.statEntityFromResponse(t.crosses),e.crossesFirstHalf=this.statEntityFromResponse(t.crosses_1h),e.crossesSecondHalf=this.statEntityFromResponse(t.crosses_2h),e.crossesExtraTime=this.statEntityFromResponse(t.crosses_et),e.offside=this.statEntityFromResponse(t.offside),e.offsideFirstHalf=this.statEntityFromResponse(t.offside_1h),e.offsideSecondHalf=this.statEntityFromResponse(t.offside_2h),e.offsideExtraTime=this.statEntityFromResponse(t.offside_et),e.shotsOn=this.statEntityFromResponse(t.shots_on),e.shotsOnFirstHalf=this.statEntityFromResponse(t.shots_on_1h),e.shotsOnSecondHalf=this.statEntityFromResponse(t.shots_on_2h),e.shotsOnExtraTime=this.statEntityFromResponse(t.shots_on_et),e.throwIn=this.statEntityFromResponse(t.throw_in),e.throwInFirstHalf=this.statEntityFromResponse(t.throw_in_1h),e.throwInSecondHalf=this.statEntityFromResponse(t.throw_in_2h),e.throwInExtraTime=this.statEntityFromResponse(t.throw_in_et),e.redCards=this.statEntityFromResponse(t.red_cards),e.redCardsFirstHalf=this.statEntityFromResponse(t.red_cards_1h),e.redCardsSecondHalf=this.statEntityFromResponse(t.red_cards_2h),e.redCardsExtraTime=this.statEntityFromResponse(t.red_cards_et),e.shotsOff=this.statEntityFromResponse(t.shots_off),e.shotsOffFirstHalf=this.statEntityFromResponse(t.shots_off_1h),e.shotsOffSecondHalf=this.statEntityFromResponse(t.shots_off_2h),e.shotsOffExtraTime=this.statEntityFromResponse(t.shots_off_et),e.goalKicks=this.statEntityFromResponse(t.goal_kicks),e.goalKicksFirstHalf=this.statEntityFromResponse(t.goal_kicks_1h),e.goalKicksSecondHalf=this.statEntityFromResponse(t.goal_kicks_2h),e.goalKicksExtraTime=this.statEntityFromResponse(t.goal_kicks_et),e.possession=this.statEntityFromResponse(t.possession),e.possessionFirstHalf=this.statEntityFromResponse(t.possession_1h),e.possessionSecondHalf=this.statEntityFromResponse(t.possession_2h),e.possessionExtraTime=this.statEntityFromResponse(t.possession_et),e.treatments=this.statEntityFromResponse(t.treatments),e.treatmentsFirstHalf=this.statEntityFromResponse(t.treatments_1h),e.treatmentsSecondHalf=this.statEntityFromResponse(t.treatments_2h),e.treatmentsExtraTime=this.statEntityFromResponse(t.treatments_et),e.yellowCards=this.statEntityFromResponse(t.yellow_cards),e.yellowCardsFirstHalf=this.statEntityFromResponse(t.yellow_cards_1h),e.yellowCardsSecondHalf=this.statEntityFromResponse(t.yellow_cards_2h),e.yellowCardsExtraTime=this.statEntityFromResponse(t.yellow_cards_et),e.shotsBlocked=this.statEntityFromResponse(t.shots_blocked),e.shotsBlockedFirstHalf=this.statEntityFromResponse(t.shots_blocked_1h),e.shotsBlockedSecondHalf=this.statEntityFromResponse(t.shots_blocked_2h),e.shotsBlockedExtraTime=this.statEntityFromResponse(t.shots_blocked_et),e.substitutions=this.statEntityFromResponse(t.substitutions),e.substitutionsFirstHalf=this.statEntityFromResponse(t.substitutions_1h),e.substitutionsSecondHalf=this.statEntityFromResponse(t.substitutions_2h),e.substitutionsExtraTime=this.statEntityFromResponse(t.substitutions_et),e.counterAttacks=this.statEntityFromResponse(t.counter_attacks),e.counterAttacksFirstHalf=this.statEntityFromResponse(t.counter_attacks_1h),e.counterAttacksSecondHalf=this.statEntityFromResponse(t.counter_attacks_2h),e.counterAttacksExtraTime=this.statEntityFromResponse(t.counter_attacks_et),e.foulsCommitted=this.statEntityFromResponse(t.fouls_committed),e.foulsCommittedFirstHalf=this.statEntityFromResponse(t.fouls_committed_1h),e.foulsCommittedSecondHalf=this.statEntityFromResponse(t.fouls_committed_2h),e.foulsCommittedExtraTime=this.statEntityFromResponse(t.fouls_committed_et),e}catch(e){throw console.warn("There was a problem remapping the stats",e),e}}statEntityFromResponse=t=>({homeTeam:t?t.home_team:null,awayTeam:t?t.away_team:null})};var jt=class{homeTeam={players:[]};awayTeam={players:[]}};var tr=class{id="";name="";position="";shirtNumber;assets=null;type=""};var qt=class{fromResponse(t){try{let e=new tr;return e.id=t.id,e.name=t.name,e.position=t.position,e.shirtNumber=t.shirt_number,e.assets=t.assets,e.type=t.type,e}catch(e){throw console.warn("There was a problem remapping the player from timeline",e),e}}};var er=class{playerRemapper=null;constructor(){this.playerRemapper=new qt}fromResponse(t){try{let e=new jt;return e.homeTeam.players=t.home_team&&t.home_team.players?t.home_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],e.awayTeam.players=t.away_team&&t.away_team.players?t.away_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping the lineups",e),e}}};var ir=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var rr=class{playerRemapper=null;constructor(){this.playerRemapper=new qt}fromResponse(t){try{let e=new ir;return e.minute=t.minute,e.type=t.type,e.teamId=t.team_id,e.player=this.playerRemapper.fromResponse(t.player),e.relatedPlayer=t.related_player?this.playerRemapper.fromResponse(t.related_player):null,e.updatedAt=t.updated_at,e}catch(e){throw console.warn("There was a problem remapping timeline",e),e}}};var ar=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new O,this.competitionsMapper=new N,this.lineupsMapper=new er,this.scoresMapper=new Kt,this.statsMapper=new Zi,this.timelineMapper=new rr}fromResponse(t){try{let e=new Yi;return e.id=t.id,e.kickoffAt=t.kickoff_at,e.finishedAt=t.finished_at,e.updatedAt=t.updated_at,e.isDeleted=t.is_deleted,e.homeTeam=t.home_team?this.teamMapper.fromResponse(t.home_team):null,e.awayTeam=t.away_team?this.teamMapper.fromResponse(t.away_team):null,e.lineupsConfirmed=t.lineups_confirmed,e.startedAt=t.started_at,e.minute=t.minute,e.scores=this.scoresMapper.fromResponse(t.scores),e.stats=this.statsMapper.fromResponse(t.stats),e.context={competition:this.competitionsMapper.fromResponse(t.context.competition)},e.timeline=t.timeline?t.timeline.map(i=>this.timelineMapper.fromResponse(i)):[],e.status={type:t.status.type,subType:t.status.sub_type},e.lineups=t.lineups?this.lineupsMapper.fromResponse(t.lineups):new jt,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var or=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var sr=class{countryRemapper=null;constructor(){this.countryRemapper=new S}fromResponse(t){try{let e=new or;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.position=t.position,e}catch(e){throw console.warn("There was a problem remapping top player response",e),e}}};var nr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var zt=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new S,this.teamRemapper=new O}fromResponse(t){try{let e=new nr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.position=t.position,e.isDeleted=t.is_deleted,e}catch(e){throw console.warn("There was a problem remapping players response",e),e}}};var lr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var pr=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new S,this.teamRemapper=new O,this.competitionRemapper=new N}fromResponse(t){try{let e=new lr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.position=t.position,e.isDeleted=t.is_deleted,e.competitions=t.competitions?t.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping player response",e),e}}};var cr=class{teams=null;players=null;competitions=null};var dr=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new O,this.playerRemapper=new zt,this.competitionremapper=new N}fromResponse(t){try{let e=new cr;return e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.players=t.players?t.players.map(i=>this.playerRemapper.fromResponse(i)):[],e.competitions=t.competitions?t.competitions.map(i=>this.competitionremapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping search response",e),e}}};var ft=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var W=class{pagination=new ft};var Qt=class{meta=new W;data=[]};var mr=class{remapMetaProp=t=>{let e=new W;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e}};var Z=class extends _{limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(t){super(t,R(t.environment,"football")),this.apiSignInUrl=t.lang!=="en"?this.apiSignInUrl+`&lang=${t.lang}`:this.apiSignInUrl,this.countryRemapper=new S,this.competitionBasicRemapper=new N,this.competitionFullRemapper=new Vi,this.teamBasicRemapper=new O,this.teamFullRemapper=new qi,this.matchBasicRemapper=new Xi,this.matchFullRemapper=new ar,this.playerBasicRemapper=new zt,this.playerFullRemapper=new pr,this.topPlayerRemapper=new sr,this.searchRemapper=new dr,this.footballMetaRemapper=new mr}getCountries=async t=>{let e="There was a problem with the football countries request",i=`/countries${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let a=await this.fetchWithoutAuth(i,e);return this.countryRemapper.countriesFromResponse(a.data)};getCompetitions=async(t,e)=>{let i=Date.now(),r="There was a problem with football competitions request";if(e=e||!1,t&&t.competitionIds&&t.competitionIds.length>this.limitIds-1){let a=[],s=xt(t.competitionIds,this.limitIds);for(let n of s){t.competitionIds=n;let l=`/competitions${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);a.push(c.data.map(d=>this.competitionBasicRemapper.fromResponse(d)))}return Array.prototype.concat.apply([],a)}else{let a=`/competitions${this.apiSignInUrl}`;return t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(a,r)).data.map(p=>this.competitionBasicRemapper.fromResponse(p))}};getCompetitionById=async(t,e)=>{let i=`/competitions/${t}${this.apiSignInUrl}`,r="There was a problem with football competition by ID request",a=Date.now();e&&(i+=`&disable_cache=${a}`);let s=await this.fetchWithoutAuth(i,r);return this.competitionFullRemapper.fromResponse(s.data)};getTopCompetitions=async t=>{let e="There was a problem with top football competitions request",i=`/competitions/top${this.apiSignInUrl}`,r=Date.now();return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,e)).data.map(s=>this.competitionBasicRemapper.fromResponse(s))};getTeams=async(t,e)=>{let i=Date.now(),r="There was a problem with football teams request";if(t&&t.teamIds&&t.teamIds.length>this.limitIds){let a=[],s=xt(t.teamIds,this.limitIds);for(let n of s){t.teamIds=n;let l=`/teams${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);a.push(c.data.map(d=>this.teamBasicRemapper.fromResponse(d)))}return Array.prototype.concat.apply([],a)}else{let a=new Qt,s=`/teams${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(p.meta),a.data=p.data.map(n=>this.teamBasicRemapper.fromResponse(n)),a}};getTeamById=async(t,e)=>{let i="There was a problem with football team by ID request",r=`/teams/${t}${this.apiSignInUrl}`,a=Date.now();e&&(r+=`disable_cache=${a}`);let s=await this.fetchWithoutAuth(r,i);return this.teamFullRemapper.fromResponse(s.data)};getTopTeams=async t=>{let e=`/teams/top${this.apiSignInUrl}`,i="There was a problem with top football teams request",r=Date.now();t&&(e+=`$disable_cache=${r}`);let a=await this.fetchWithoutAuth(e,i);return a.data?a.data.map(s=>this.teamBasicRemapper.fromResponse(s)):[]};getNextMatchForTeam=async(t,e)=>{let i=`/teams/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for team request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForTeam=async(t,e)=>{let i=`/teams/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for team request";e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPlayers=async(t,e)=>{let i=Date.now(),r="There was a problem with football players request";if(t&&t.playerIds&&t.playerIds.length>this.limitIds-1){let a=[],s=xt(t.playerIds,this.limitIds);for(let n of s){t.playerIds=n;let l=`/players${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);a.push(c.data.map(d=>this.teamBasicRemapper.fromResponse(d)))}return Array.prototype.concat.apply([],a)}else{let a=new Qt,s=`/players${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(p.meta),a.data=p.data.map(n=>this.playerBasicRemapper.fromResponse(n)),a}};getPlayerById=async(t,e)=>{let i=`/players/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with football player by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.playerFullRemapper.fromResponse(s.data)};getTopPlayers=async t=>{let e=`/players/top${this.apiSignInUrl}`,i=Date.now(),r="There was a problem with top football players request";return t&&(e+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(e,r)).data.map(s=>this.topPlayerRemapper.fromResponse(s))};getNextMatchForPlayer=async(t,e)=>{let i=`/players/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForPlayer=async(t,e)=>{let i=`/players/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatchById=async(t,e)=>{let i=`/matches/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with match by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatches=async(t,e)=>{let i=new Qt,r="There was a problem with football matches request";if(t&&t.matchIds&&t.matchIds.length>this.limitIds-1){let a=[],s=xt(t.matchIds,this.limitIds);for(let n of s){t.matchIds=n;let l=`/matches${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=M());let c=await this.fetchWithoutAuth(l,r);i.meta=this.footballMetaRemapper.remapMetaProp(c.meta),a.push(c.data.map(d=>this.matchBasicRemapper.fromResponse(d)))}let p=Array.prototype.concat.apply([],a);return i.data=p,i}else{let a=`/matches${this.apiSignInUrl}`;t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=M());let s=await this.fetchWithoutAuth(a,r);return i.meta=this.footballMetaRemapper.remapMetaProp(s.meta),i.data=s.data.map(p=>this.matchBasicRemapper.fromResponse(p)),i}};search=async(t,e)=>{let i=`/search${this.apiSignInUrl}${t.constructFilterUrl()}`,r=Date.now(),a="There was a problem with football search request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.searchRemapper.fromResponse(s.data)}};var K=(g=>(g.FT_1X2="FT_1X2",g.HT_1X2="HT_1X2",g.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",g.DOUBLE_CHANCE="DOUBLE_CHANCE",g.HT_FT="HT_FT",g.PLAYER_SCORE="PLAYER_SCORE",g.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",g.PLAYER_RED_CARD="PLAYER_RED_CARD",g.RED_CARD_MATCH="RED_CARD_MATCH",g.PENALTY_MATCH="PENALTY_MATCH",g.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",g.CORNERS_MATCH="CORNERS_MATCH",g.CORRECT_SCORE="CORRECT_SCORE",g.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",g.CORRECT_SCORE_HT="CORRECT_SCORE_HT",g.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",g.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",g.OVER_GOALS_0_5="OVER_GOALS_0_5",g.OVER_GOALS_1_5="OVER_GOALS_1_5",g.OVER_GOALS_2_5="OVER_GOALS_2_5",g.OVER_GOALS_3_5="OVER_GOALS_3_5",g.OVER_GOALS_4_5="OVER_GOALS_4_5",g.OVER_GOALS_5_5="OVER_GOALS_5_5",g.OVER_GOALS_6_5="OVER_GOALS_6_5",g.OVER_CORNERS_6_5="OVER_CORNERS_6_5",g.OVER_CORNERS_7_5="OVER_CORNERS_7_5",g.OVER_CORNERS_8_5="OVER_CORNERS_8_5",g.OVER_CORNERS_9_5="OVER_CORNERS_9_5",g.OVER_CORNERS_10_5="OVER_CORNERS_10_5",g.OVER_CORNERS_11_5="OVER_CORNERS_11_5",g.OVER_CORNERS_12_5="OVER_CORNERS_12_5",g.OVER_CORNERS_13_5="OVER_CORNERS_13_5",g))(K||{}),Ks=["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"],js=["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"],tt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],qs=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],je="PLAYER_SCORE_FIRST_GOAL";var ur=class{id="";achievedAt=""};var Xt=class{totalPoints=null;postPoints=null;postsMade=null;reactionPoints=null;reactionCount=null};var qe=class{participations=0;points=0};var Et=class{footballCompetitions=[];footballTeams=[]};var Yt=class{predictionsMade=0;correct=0;points=0;breakdown=new Et};var Jt=class{single=new Yt;topX=new qe;matchQuiz=new qe};var hr=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var gr=class{profileId;tier;points;predictionsMade;successRates=new hr;predictions=new Jt;tiers=[];badges=[];discussions=new Xt};var fr=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var yr=class{successRatePercent;model=null};var Zt=class{content=null;tags=[];campaign=null};var te=class{id=null;profileId=null;property=null;value=null;action=null;context=new Zt;points=0};var br=class{meta=new W;data=[new te]};var Mr=class{remapSingleResponse=t=>{let e=new te;return e.id=t.id,e.profileId=t.profile_id,e.property=t.property,e.value=t.value,e.action=t.action,e.context.content=t.context.content,e.context.tags=t.context.tags,e.context.campaign=t.context.campaign,e.points=t.points,e};remapActivitiesResponse=t=>{let e=new br;return e.meta.pagination.currentPage=t.meta.pagination.current_page,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.meta.pagination.numberOfPages=t.meta.pagination.number_of_pages,e.meta.pagination.totalItems=t.meta.pagination.total_items,e.data=t.data.map(i=>this.remapSingleResponse(i)),e};remapStatsResponse=t=>{let e=new gr;return e.profileId=t.profile_id,e.tier=t.tier,e.points=t.points,e.predictionsMade=t.predictions_made,e.successRates.overallPercent=t.success_rates.overall_percent,e.successRates.byFootballCompetition=this.constructNewRecord(t.success_rates.by_competition),e.successRates.byFootballTeam=this.constructNewRecord(t.success_rates.by_team),e.successRates.byFootballMarket=this.constructNewRecord(t.success_rates.by_market),e.predictions=t.predictions?this.remapPredictionsStats(t.predictions):null,e.tiers=t.tiers?this.remapAchievementsStats(t.tiers):null,e.badges=t.badges?this.remapAchievementsStats(t.badges):null,e.discussions=t.discussions?this.remapDiscussionStats(t.discussions):null,e};constructNewRecord=t=>{let e;if(Object.entries(t).length)Object.entries(t).forEach(([i,r])=>{e={...e,[i]:this.remapSuccessRatePercent(r)},K[i]&&delete e[i].model});else return t;return e};remapSuccessRatePercent=t=>{let e=new yr;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new Jt;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new Yt;return e.predictionsMade=t.predictions_made,e.correct=t.correct,e.points=t.points,e.breakdown=this.remapBreakdownSinglePredictionsStats(t.breakdown),e};remapBreakdownSinglePredictionsStats=t=>{if(t&&Object.keys(t).length){let e=new Et,i=[],r=[];return Object.keys(t).forEach(a=>{let s=new fr;s.entityId=a,s.entityType=t[a].entity_type,s.entitySource=t[a].entity_source,s.predictionsMade=t[a].predictions_made,s.correct=t[a].correct,s.points=t[a].points,s.entityType==="competition"?i.push(s):s.entityType==="team"&&r.push(s)}),e.footballCompetitions=i,e.footballTeams=r,e}return new Et};remapAchievementsStats=t=>t.map(e=>{let i=new ur;return i.id=e.id,i.achievedAt=e.achieved_at,i});remapDiscussionStats=t=>{let e=new Xt;return e.totalPoints=t.total_points,e.postPoints=t.post_points,e.postsMade=t.posts_made,e.reactionPoints=t.reaction_points,e.reactionCount=t.reaction_count,e}};var ee=class extends _{activityRemapper=null;constructor(t){super(t,R(t.environment,"loyalty")),this.activityRemapper=new Mr}createActivity=async t=>{let e=`/activities${this.apiSignInUrl}`,i="There was a problem with creating activity",r="POST",a=await this.fetchWithAuth(e,i,r,t);return this.activityRemapper.remapSingleResponse(a)};deleteActivity=async t=>{let e=`/activities/${t}${this.apiSignInUrl}`,i=`There was a problem deleting the following activity: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getOwnActivities=async(t,e)=>{let i=`/activities${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with fetching own activities";t&&(i+=`${t.constructFilterUrl()}`),e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithAuth(i,a);return this.activityRemapper.remapActivitiesResponse(s)};getActivitiesForUser=async(t,e,i)=>{let r=`/users/${t}/activities${this.apiSignInUrl}`,a=Date.now(),s=`There was a problem with fetching activities for user: ${t}`;e&&(r+=`${e.constructFilterUrl()}`),i&&(r+=`disable_cache=${a}`);let p=await this.fetchWithoutAuth(r,s);return this.activityRemapper.remapActivitiesResponse(p)};getStats=async(t,e)=>{let i="",r="",a=null;return t?(i+=I(e)?`/users/${t}/statistics${this.apiSignInUrl}${M()}`:`/users/${t}/statistics${this.apiSignInUrl}`,r=`There was a problem fetching statistics for profile: ${t}`,a=await this.fetchWithoutAuth(i,r)):(i+=`/statistics${this.apiSignInUrl}`,r="There was a problem fetching profile`s statistics",a=await this.fetchWithAuth(i,r)),this.activityRemapper.remapStatsResponse(a.data)}};var wr=class{id="";source="";type="";favourite=!1};var Ir=class extends wr{model=null};var Pr=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(t,e,i){this.idMapping=i,this.idSchema=t.idSchema,this.footballFacade=e}remapProfileStats=async t=>{if(!t.predictions)return t;let{successRates:e,predictions:i}=t,r={competition:this.getIdsKeys(e.byFootballCompetition,i.single.breakdown.footballCompetitions),team:this.getIdsKeys(e.byFootballTeam,i.single.breakdown.footballTeams)};if(Object.values(r.competition).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballCompetition)),s=await this.getEntitiesMap(r.competition,"competition"),p=await this.setSuccessRatesModels(a,s);t.successRates.byFootballCompetition=p,i.single.breakdown.footballCompetitions=this.reconstructBreakdown(i.single.breakdown.footballCompetitions,s)}if(Object.values(r.team).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballTeam)),s=await this.getEntitiesMap(r.team,"team"),p=await this.setSuccessRatesModels(a,s);t.successRates.byFootballTeam=p,i.single.breakdown.footballTeams=this.reconstructBreakdown(i.single.breakdown.footballTeams,s)}return t};setSuccessRatesModels=async(t,e)=>{let i;return this.reconstructRecords(t,i,e)};getEntitiesMap=async(t,e)=>{switch(e){case"competition":return await this.footballFacade.getCompetitionsMapWithNativeIds(t);case"team":return await this.footballFacade.getTeamsMapWithNativeIds(t)}};reconstructRecords=(t,e,i)=>t&&Object.keys(t).length?(Object.keys(t).forEach(r=>{let a=i.get(r);e={...e,[a.id]:t[r]},e[a.id].model=a}),e):t;reconstructBreakdown=(t,e)=>t.length?t.map(i=>{let r=e.get(i.entityId);return i.entityId=r.id,i.model=r,i}):t;getIdsKeys=(t,e)=>{let i=Object.keys(t);if(e.length){let r=e.map(a=>a.entityId);return Array.from(new Set([...i,...r]))}return i};remapInterestsToIdSchema=async t=>{if(this.idSchema!==this.native)if(t&&t.length>0){let e={},i={},r=t.filter(n=>n.source.toLocaleUpperCase()==="FOOTBALL"),a=t.filter(n=>n.source.toLocaleUpperCase()!=="FOOTBALL");r.forEach(n=>{e.hasOwnProperty(n.type)||(e[n.type]=[],i[n.type]=[]),e[n.type].push(n.id),i[n.type].push(n)});let s=await this.remapIdsObj(e,this.native,this.idSchema),p=[];for(let[n,l]of Object.entries(i))l.forEach((c,d)=>{c.id=s[n][d],p.push(c)});return p.concat(a)}else return t;return t};remapInterestToNative=async t=>{if(this.idSchema!==this.native&&t.source.toLocaleUpperCase()==="FOOTBALL"){let e={},{id:i,type:r}=t;e[r]=[i];let a=await this.remapIdsObj(e,this.idSchema,this.native);return t.id=a[r][0],t}return t};inquiryCustomInterests=(t,e)=>{let i=[];return t&&t.length>0&&(i=t.filter(r=>r.source.toLocaleUpperCase()==="CUSTOM"),e)?i.map(r=>{let a=new Ir;return a.id=r.id,a.type=r.type,a.source=r.source,a.favourite=r.favourite,a}):i};remapInterests=async t=>{let i=this.inquiryCustomInterests(t,!1);if(i&&i.length>0){let r=t.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),a=await this.remapInterestsToIdSchema(r);return i.forEach(s=>a.push(s)),a}return await this.remapInterestsToIdSchema(t)};showFullInterests=async t=>{let e=[];if(t&&t.length>0){let r=this.inquiryCustomInterests(t,!0);e.push(r);let a=t.filter(c=>c.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:p,playersMap:n}=await this.getInterestsEntitiesMap(a),l=a.map(c=>{let d=null;if(c.source.toLocaleUpperCase()==="FOOTBALL"){if(c.type==="competition")return d=s.get(c.id),d&&(c.id=d.id),c.model=d,c;if(c.type==="team")return d=p.get(c.id),d&&(c.id=d.id),c.model=d,c;if(c.type==="player")return n?(c.model=n[c.id],c.id=n[c.id].id):c.model=d,c}else return c.model=d,c});return e.push(l),e.flat()}return e};getInterestsEntitiesMap=async t=>{let e=[],i=[],r=[],a=new Map,s=new Map,p=null;return t.forEach(n=>{n.type==="competition"&&n.source.toLocaleUpperCase()==="FOOTBALL"?e.push(n.id):n.type==="team"&&n.source.toLocaleUpperCase()==="FOOTBALL"?i.push(n.id):n.type==="player"&&n.source.toLocaleUpperCase()==="FOOTBALL"&&r.push(n.id)}),e.length&&(a=await this.footballFacade.getCompetitionsMapWithNativeIds(e)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(p=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:a,teamsMap:s,playersMap:p}};remapIdsObj=async(t,e,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(t,e,i)};var Tr=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new F(t),this.profileOperations=new Pr(t,e,this.idMapping)}remapProfileStats=async t=>await this.profileOperations.remapProfileStats(t);remapInterestToNative=async t=>await this.profileOperations.remapInterestToNative(t);remapInterests=async t=>await this.profileOperations.remapInterests(t);showFullInterests=async t=>await this.profileOperations.showFullInterests(t)};var C=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localCache=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(t){this.profileHttps=new Dt(t),this.activityHttps=new ee(t),this.footballHttps=new Z(t),this.idMapping=new F(t),this.localCache=new V().createLocalCacheInstance(t.idSchema),this.footballFacade=new Wt(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new J(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new Tr(t,this.footballFacade),this.ownProfileBuilder=new bi(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps,t.errorHandlingMode),this.profileBuilder=new Mi(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=t=>this.profileBuilder.setId(t);getCountries=async t=>await this.profileFacade.getCountries(t);getByIds=async(t,e,i)=>await this.profileFacade.getByIds(t,e,i)};var Xo=(h=>(h.EN="en",h.BG="bg",h.RO="ro",h.EL="el",h.SK="sk",h.PT="pt",h.SR="sr",h.HU="hu",h.SV="sv",h.ES="es",h.FR="fr",h.NL="nl",h.DE="de",h.IT="it",h))(Xo||{});var vr=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(Xo),i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no lang is passed the default one will be set which is: en"),t==="invalid"&&(e="This lang value is not supported, the default one will be set which is: en"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var _r=class{validate(t){let e=this.validateField(t.environment),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=["dev","staging","prod","watg"],i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no environment is passed the default one will be set which is: prod"),t==="invalid"&&(e="This environment value is not supported, the default one will be set which is: prod"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Fr=class{validate(t){let e=this.validateField(t.apiKey),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=null;return t!=null&&t.length>0?e="valid":e="missing",e};generateMessage=t=>{let e=null,i="error";return t==="missing"&&(e="The field apiKey with valid value must be provided to use Fans United JS SDK"),t==="valid"&&(i=null),{text:e,type:i}}};var Er=class{validate(t){let e=this.validateField(t.idSchema),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=Object.values(x),i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no idSchema is passed the default one will be set which is: native"),t==="invalid"&&(e="This idSchema value is not supported, the default one will be set which is: native"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var St=class{getIdToken=null;logout=null};var re=class{text=null;type=null};var Rr=class{validation=null;message=new re;getIdToken={validation:null,message:new re};logout={validation:null,message:new re}};var Sr=class{validate(t){let e=this.validateAuthProvider(t.authProvider);return e.validation!=="missing"&&(e=this.validateAuthProviderConfigFields(t.authProvider,e),e=this.generateAuthProviderConfigMessages(e),e=this.checkAuthProviderConfigMessagesForErrors(e)),e}validateAuthProvider=t=>{let e=Object.keys(new St),i=new Rr;if(t){let a=Object.keys(t).filter(s=>!e.includes(s));a.length>0?(i.validation="invalid",i.message.type="warning",i.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):i.validation="valid"}else i.validation="missing",i.message.type="error",i.message.text="The field authProvider must be provided to use this SDK";return i};validateAuthProviderConfigFields=(t,e)=>(Object.keys(new St).forEach(r=>{t[r]?e[r].validation="valid":e[r].validation="missing"}),e);generateAuthProviderConfigMessages=t=>(Object.keys(t).filter(e=>e!=="validation"&&e!=="message").forEach(e=>{let i=t[e];i.validation==="missing"&&(i.message.text=`${"The following property is missing from the authProvider object:"} ${e}`,i.message.type="error")}),t);checkAuthProviderConfigMessagesForErrors=t=>(Object.keys(t).filter(e=>e!=="validation"&&e!=="message").forEach(e=>{t[e].validation==="missing"&&t.validation==="valid"&&(t.validation="invalid",t.message.type="error",t.message.text="The field authProvider has missing properties")}),t)};var Qe=class{validation;message};var Cr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Qe,logout:new Qe};isValid=!1};var Ar=class{validate(t){let e=this.validateField(t.clientId),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=null;return t!=null&&t.length>0?e="valid":e="missing",e};generateMessage=t=>{let e=null,i="error";return t==="missing"&&(e="The field clientId must be provided to use Fans United JS SDK"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Or=class{validate=t=>{let e=this.validateField(t.errorHandlingMode),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=["default","standard"],i=null;return t?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no errorHandlingMode is passed the default one will be set which is: default"),t==="invalid"&&(e="This errorHandlingMode value is not supported, the default one will be set which is: default"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Lr=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new Cr,i={apiKey:new Fr,environment:new _r,idSchema:new Er,clientId:new Ar,lang:new vr,errorHandlingMode:new Or,authProvider:new Sr};for(let[r,a]of Object.entries(e))r!=="isValid"&&(a=i[r].validate(t));return Object.keys(i).forEach(r=>{e[r]=i[r].validate(t)}),e};containsErrorMessage=t=>{let e=!0;for(let[i,r]of Object.entries(t))if(i!=="authProvider"){if(i!=="isValid"&&r.message.type==="error")return e=!1,e;if(i!=="isValid"&&r.message.type==="warning")return e=!0,e}else if(r.message.type==="error")return e=!1,e;return e}};var et=class{https=null;idMapping=null;localCache=null;footballFacade=null;constructor(t){this.https=new Z(t),this.idMapping=new F(t),this.localCache=new V().createLocalCacheInstance(t.idSchema),this.footballFacade=new Wt(t,this.localCache,this.https,this.idMapping)}getCountries=async t=>await this.footballFacade.getCountries(t);getCompetitions=async(t,e)=>await this.footballFacade.getCompetitions(t,e);getCompetitionById=async(t,e)=>await this.footballFacade.getCompetitionById(t,e);getTopCompetitions=async t=>await this.footballFacade.getTopCompetitions(t);getTeams=async(t,e)=>await this.footballFacade.getTeams(t,e);getTeamById=async(t,e)=>await this.footballFacade.getTeamById(t,e);getTopTeams=async t=>await this.footballFacade.getTopTeams(t);getNextMatchForTeam=async(t,e)=>await this.footballFacade.getNextMatchForTeam(t,e);getPrevMatchForTeam=async(t,e)=>await this.footballFacade.getPrevMatchForTeam(t,e);getPlayers=async(t,e)=>await this.footballFacade.getPlayers(t,e);getPlayerById=async(t,e)=>await this.footballFacade.getPlayerById(t,e);getTopPlayers=async t=>await this.footballFacade.getTopPlayers(t);getNextMatchForPlayer=async(t,e)=>await this.footballFacade.getNextMatchForPlayer(t,e);getPrevMatchForPlayer=async(t,e)=>await this.footballFacade.getPrevMatchForPlayer(t,e);getMatches=async(t,e)=>await this.footballFacade.getMatches(t,e);getMatchById=async(t,e)=>await this.footballFacade.getMatchById(t,e);search=async(t,e)=>await this.footballFacade.search(t,e)};var xr=class{value=null;playerId=null;playerModel=null};var ae=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new xr;result=null};var Dr=class{value=!1;playerId=null};var j=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i,r){this.matchId=t,this.market=e,this.prediction=new Dr,this.prediction.value=i,this.prediction.playerId=r}};var oe=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var Br=class{value=null};var yt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new Br,this.prediction.value=i}};var q=class{value=!1};var se=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new q,this.prediction.value=i}};var ne=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new q,this.prediction.value=i}};var Nr=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e,i){this.matchFacade=t,this.playerFacade=e,this.predictorService=i}remapFixturesRequest=t=>{let e={};if(e.match_id=t.matchId,e.match_type="FOOTBALL",t instanceof j)e.market=t.market,e.prediction=t.prediction.value,e.player_id=t.prediction.playerId;else if(t instanceof se||t instanceof ne)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof yt){e.market=t.market;let i=t.prediction.value.split(":");e.goals_home=Number(i[0]),e.goals_away=Number(i[1])}else e.market=t.market,e.prediction=t.prediction.value;return e};remapFixturesResponse=async t=>{let e="OWN_GOAL",i=[],r=[],a=null,s=[];t.length>1&&t.sort((n,l)=>n.match_id.localeCompare(l.match_id));for(let n of t)i.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let p=await this.matchFacade.getMatchesMapWithNativeIds(i);r.sort((n,l)=>n.localeCompare(l)),r&&r.length>0&&!r.includes(e)&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of t){let l=new ae;n.target?l.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):l.market=n.market,l.matchId=p[n.match_id].id,l.matchType=n.match_type,l.matchModel=p?p[n.match_id]:null,delete l.matchModel.availableMarkets,n.goals_home!==void 0&&n.goals_away!==void 0?l.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():l.prediction.value=n.prediction,l.prediction.playerId=n.player_id?n.player_id:null,l.prediction.playerId&&l.prediction.playerId!==e&&(l.prediction.playerModel=a[n.player_id],l.prediction.playerId=a[n.player_id].id),l.result=this.remapResult(n.result),s.push(l)}return s};remapResult=t=>{let e=new oe;return e.settledAt=t.settled_at,e.resettledAt=t.resettled_at,e.status=t.status,e.outcome=t.outcome,e.points=t.points,e}};var it=class{goldenGoal=null};var Xe=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new it;points=null;createdAt=null;updatedAt=null};var T=class{no=0;yes=0};var Ur=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new T;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new T;penaltyMatch=new T;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new T;overOnePointFiveGoals=new T;overTwoPointFiveGoals=new T;overThreePointFiveGoals=new T;overFourPointFiveGoals=new T;overFivePointFiveGoals=new T;overSixPointFiveGoals=new T;overSixPointFiveCorners=new T;overSevenPointFiveCorners=new T;overEightPointFiveCorners=new T;overNinePointFiveCorners=new T;overTenPointFiveCorners=new T;overElevenPointFiveCorners=new T;overTwelvePointFiveCorners=new T;overThirteenPointFiveCorners=new T};var rt=class{timeTiebreaker=!1};var bt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new rt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null;predictionTiebreaker=new it};var Ct=class{userId=null;points=null;results=[];tiebreaker=null};var Yo=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(Yo||{}),ps=["WON","LOST","PARTIALLY_WON","CANCELED"];var D=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;gameIds=null;constructor(t){this.limit=t.limit?t.limit:null,this.startAfter=t.startAfter?t.startAfter:null,this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.matchIds=t.matchIds?t.matchIds:null,this.gameIds=t.gameIds?t.gameIds:null}constructFiltersUrl=()=>{let t="",e=!1;return this.status&&(e=Object.values(Yo).some(i=>this.status.includes(i))),this.limit&&(t+="&",t+=`limit=${this.limit}`),this.startAfter&&(t+="&",t+=`start_after=${this.startAfter}`),this.status&&e&&(t+="&",t+=`status=${this.status.join(",")}`),this.type&&(t+="&",t+=`game_types=${this.type}`),this.matchIds&&(t+="&",t+=`match_ids=${this.matchIds.join(",")}`),this.gameIds&&(t+="&",t+=`game_ids=${this.gameIds.join(",")}`),t}};var L=class{limit;startAfter;constructor(t){this.limit=t&&t.limit?t.limit:null,this.startAfter=t&&t.startAfter?t.startAfter:null}constructMainFiltersUrl(){let t="";return this.limit&&(t+="&",t+=`limit=${this.limit}`),this.startAfter&&(t+="&",t+=`start_after=${this.startAfter}`),t}};var Hr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(Hr||{});var z=class extends L{status=null;type=null;gameIds=null;sortOrder=null;constructor(t){super(t),this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.gameIds=t.gameIds?t.gameIds:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.status&&Object.values(Hr).includes(this.status)&&(t+="&",t+=`status=${this.status}`),this.type&&(t+="&",t+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(t+="&",t+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(t+="&",t+=`sort_order=${this.sortOrder}`),t}};var at=class{main=null;cover=null;mobile=null};var lt=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new rt;participantsCount=0;related=null;excludedProfileIds=null;rules=null;labels=null;customFields=null;flags=null;images=new at;createdAt=null;updatedAt=null};var pt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new rt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var le=class extends lt{adContent=null};var ot=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(t,e){this.footballHttps=new Z(t),this.idMapping=e,this.matchFacade=new gt(t,this.footballHttps,e),this.playerFacade=new ht(t,this.footballHttps,e),this.profileNamespace=new C(t)}remapMatchIdToNative=async t=>(await this.idMapping.getEntityIdsBySchemaId(t,"match","native")).match;remapPlayerIdToNative=async t=>(await this.idMapping.getEntityIdsBySchemaId(t,"player","native")).player[0];remapPlayerIdMapToNative=async t=>{let e={},i=_t(t),a=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,p)=>e[s]=a[p]),e};remapPlayerIdToIdSchema=async t=>{let e=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[a,s]of Object.entries(t))if(e.includes(a))for(let p of Object.keys(s))p!=="NOBODY"&&p!=="OWN_GOAL"&&i.push(p);if(!i.length)return t;let r=await this.playerFacade.getPlayersMapWithNativeIds(i);for(let[a,s]of Object.entries(t))if(e.includes(a))for(let p of Object.keys(s))p!=="NOBODY"&&p!=="OWN_GOAL"&&(s[r[p].id]=s[p],s[r[p].id].model=r[p],this.idMapping.idSchema!=="native"&&delete s[p]);return t};convertMarketForResponseModel=(t,e)=>{let i=e.toString();return t+"_"+i};getMarketSummary=async(t,e,i)=>{let r=ws.get(e),a={};if(a.matchId=t.matchId,a.matchType=t.matchType,Object.keys(t.predictions).includes(r))a[r]=t.predictions[r];else throw new Error("You have passed invalid market");if(tt.includes(e)&&i){let p="";if(i!=="OWN_GOAL"&&i!=="NOBODY"&&(p=(await this.idMapping.idMappingFacade.getEntitiesByIds({player:[i]},this.idMapping.idSchema,"native")).player[0]),p&&a[r][p]){let n=await this.playerFacade.getPlayersMapWithNativeIds([p]);return a[r][p].model=n[p],a[r][p]}else return p?(a[r][p]=new T,a[r][p]):a[r][i]}else if(tt.includes(e)&&!i){let p=Object.keys(a[r]).filter(l=>l!=="NOBODY"&&l!=="OWN_GOAL"),n=p.length?await this.playerFacade.getPlayersMapWithNativeIds(p):{};Object.keys(n).length&&Object.keys(a[r]).forEach(l=>{l!=="NOBODY"&&l!=="OWN_GOAL"&&(a[r][n[l].id]=a[r][l],a[r][n[l].id].model=n[l],this.idMapping.idSchema!=="native"&&delete a[r][l])})}return a};remapCompetitionsFromConfig=async t=>{if(t instanceof Vt){let e={competition:t.fullCoverageCompetitions},i={competition:t.successRateScopes.competitions},r={team:t.successRateScopes.teams},a=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return t.fullCoverageCompetitions=a.competition,t.successRateScopes.competitions=s.competition,t.successRateScopes.teams=p.team,t}if(t instanceof Gt||t instanceof kt){let e={competition:t.competitionsWhitelist},i=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema);return t.competitionsWhitelist=i.competition,t}};remapMatchIdsFixtures=async t=>{if(Array.isArray(t.data))if(t.data.length>0){let e=[],i=[];return t.data.forEach(r=>{r instanceof lt||r instanceof bt||r instanceof pt||r instanceof le?(r.fixtures.forEach(a=>e.push(a.matchId)),r instanceof pt&&r.fixtures.forEach(a=>{a.prediction.playerId&&a.prediction.playerId!=="OWN_GOAL"&&i.push(a.prediction.playerId)})):r instanceof Ct&&r.results.forEach(a=>e.push(a.matchId))}),await this.refactorResponseArrModel(t,e,i)}else return t;else return await this.refactorResponseObjModel(t)};refactorResponseArrModel=async(t,e,i)=>{let r=[],a=await this.matchFacade.getMatchesMapWithNativeIds(e),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),t.data.forEach(p=>{p instanceof lt||p instanceof bt||p instanceof pt?(p.fixtures.forEach(n=>{this.handleMatchModel(a,n),p instanceof pt&&n.prediction.playerId&&n.prediction.playerId!=="OWN_GOAL"&&(n.prediction.playerModel=s[n.prediction.playerId],n.prediction.playerId=s[n.prediction.playerId].id)}),r.push(p)):p instanceof Ct&&(p.results.forEach(n=>{n.matchModel=a[n.matchId],delete n.matchModel.availableMarkets,n.matchId=n.matchModel.id}),r.push(p))}),t.data=r,t};refactorResponseObjModel=async t=>{let e=[];t.fixtures.forEach(r=>e.push(r.matchId));let i=await this.matchFacade.getMatchesMapWithNativeIds(e);return t.fixtures.forEach(r=>this.handleMatchModel(i,r)),t};getCurrentGameId=t=>{let e=new Date;if(t.data.length>1){let i=[];return t.data.forEach(a=>i.push(a.predictionsCutoff)),t.data.sort((a,s)=>{let[p,n]=[a.predictionsCutoff,s.predictionsCutoff].map(l=>Math.abs(new Date(l)-e));return p-n})[0].id}else return t.data[0].id};initGameTypePredictions=(t,e)=>{let i={type:t,limit:null,startAfter:null};return e&&(i={...i,limit:e.limit,startAfter:e.startAfter}),i=new D(i),i};initGameFilters=(t,e,i)=>{if(e&&i)return e.type=t,e.gameIds=i,e=new z(e),e;if(e&&!i)return e.type=t,e=new z(e),e;if(!e&&i){let r={type:t,gameIds:i};return r=new z(r),r}else{let r={type:t};return r=new z(r),r}};addPredictionProp=async(t,e)=>(e.data.forEach(i=>{t.data.forEach(r=>{i.id===r.game_instance_id&&(i.predictionId=r.id,i.outcome=r.status,i.fixtures.forEach((a,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?a.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:a.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?a.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(a.prediction.target=r.fixtures[s].target),a.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof bt&&(r.tiebreaker?i.predictionTiebreaker.goldenGoal=r.tiebreaker.golden_goal:i.predictionTiebreaker=r.tiebreaker))})}),e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(e));remapResult=t=>{let e=new oe;return e.settledAt=t.settled_at,e.resettledAt=t.resettled_at,e.status=t.status,e.outcome=t.outcome,e.points=t.points,e};areIdsExceeded=t=>t.length>10;initPredictionsFilters=(t,e,i)=>{switch(e){case"user":t&&(t=new D(t));break;case"current":if(t)this.deleteUnexpectedProperties(t),t.status=["ACTIVE"],t=new D(t);else{let r={status:["ACTIVE"]};t=new D(r)}break;case"past":if(t)this.deleteUnexpectedProperties(t),t.status=ps,t=new D(t);else{let r={status:ps};t=new D(r)}break;case"matches":if(t)this.deleteUnexpectedProperties(t),t.matchIds=i,t=new D(t);else{let r={matchIds:i};t=new D(r)}break}return t};completeGameMarketResults=async(t,e)=>{switch(e){case"MATCH_QUIZ":let i={},r=t.results[0].matchId,a=t.results.map(l=>tt.includes(l.market)&&!l.result.includes("OWN_GOAL")?[...l.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return a.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(a)),t.results=t.results.map(l=>{if(l.matchModel=s[l.matchId]?s[l.matchId]:null,l.playerModels&&Object.keys(i).length&&l.result.forEach(d=>{let m=i[d];l.playerModels.push(m)}),this.idMapping.idSchema!=="native"&&(this.remapMatchIdForResultsMarkets(s,l),l.playerModels&&Object.keys(i).length)){let c=l.result;l.result=c.map(d=>i[d].id)}return l}),t;case"TOP_X":let p=t.results.map(l=>l.matchId),n=await this.matchFacade.getMatchesMapWithNativeIds(p);if(t.results=t.results.map(l=>(l.matchModel=n[l.matchId]?n[l.matchId]:null,this.idMapping.idSchema!=="native"&&this.remapMatchIdForResultsMarkets(n,l),l)),t.tieBreakers.goldenGoals.length){let l=t.tieBreakers.goldenGoals.map(d=>d.playerId),c=await this.playerFacade.getPlayersMapWithNativeIds(l);t.tieBreakers.goldenGoals=t.tieBreakers.goldenGoals.map(d=>(d.matchModel=n[d.matchId],d.playerModel=c[d.playerId],this.idMapping.idSchema!=="native"&&(d.matchId=n[d.matchId].id,d.playerId=c[d.playerId].id),d))}return t}};completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};handleMatchModel=(t,e)=>{t[e.matchId]?(e.matchModel=t[e.matchId],delete e.matchModel.availableMarkets,e.matchId=e.matchModel.id):(e.matchModel=null,this.idMapping.idSchema!=="native"&&this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[A[this.idMapping.idSchema]]}))};remapMatchIdForResultsMarkets=(t,e)=>{t[e.matchId]?e.matchId=t[e.matchId].id:this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[A[this.idMapping.idSchema]]})};deleteUnexpectedProperties=t=>(t.status&&(console.warn(os.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(os.UNEXPECTED_TYPE_PROP),delete t.type),t)};var pe=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new yt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var ce=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new Z(t),this.matchFacade=new gt(t,this.footballHttps,e),this.playerFacade=new ht(t,this.footballHttps,e),this.predictorService=new ot(t,e),this.fixturesRemapper=new Nr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=t=>{let e={};return e.game_instance_id=t.gameInstanceId,e.fixtures=t.fixtures.map(i=>this.fixturesRemapper.remapFixturesRequest(i)),t instanceof pe&&t.tiebreaker&&(e.tiebreaker={},e.tiebreaker.golden_goal=t.tiebreaker.goldenGoal?t.tiebreaker.goldenGoal:null),e};remapResponseArrayBody=async t=>{if(t.length){let e="OWN_GOAL",i=[],r=[],a={},s=[];t.forEach(n=>{n.fixtures.forEach(l=>{i.push(l.match_id),l.player_id&&l.player_id!==e&&r.push(l.player_id)})});let p=await this.matchFacade.getMatchesMapWithNativeIds(i);return r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r)),t.forEach(n=>{let l=new Xe,c=[];l.id=n.id,l.gameInstanceId=n.game_instance_id,l.gameType=n.game_type,l.wager=n.wager,l.totalFixtures=n.total_fixtures,l.settledFixtures=n.settled_fixtures,l.userId=n.user_id,n.fixtures.forEach(d=>{let m=new ae;d.target?m.market=this.predictorService.convertMarketForResponseModel(d.market,d.target):m.market=d.market,m.matchId=p[d.match_id].id,m.matchType=d.match_type,m.matchModel=p[d.match_id],delete m.matchModel.availableMarkets,d.goals_home!==void 0&&d.goals_away!==void 0?m.prediction.value=d.goals_home.toString()+":"+d.goals_away.toString():m.prediction.value=d.prediction,m.prediction.playerId=d.player_id?d.player_id:null,m.prediction.playerId&&m.prediction.playerId!==e&&(m.prediction.playerModel=a[m.prediction.playerId],m.prediction.playerId=a[m.prediction.playerId].id),m.result=this.fixturesRemapper.remapResult(d.result),c.push(m)}),l.fixtures=c,l.status=n.status,n.tiebreaker?l.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:l.tiebreaker=null,l.points=n.points,l.createdAt=n.created_at,l.updatedAt=n.updated_at,s.push(l)}),s}return t};remapResponseObjBody=async t=>{let e=new Xe;return e.id=t.id,e.gameInstanceId=t.game_instance_id,e.gameType=t.game_type,e.wager=t.wager,e.totalFixtures=t.total_fixtures,e.settledFixtures=t.settled_fixtures,e.userId=t.user_id,e.fixtures=await this.fixturesRemapper.remapFixturesResponse(t.fixtures),e.status=t.status,t.tiebreaker?e.tiebreaker.goldenGoal=t.tiebreaker.golden_goal:e.tiebreaker=null,e.points=t.points,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapPredictionModel=t=>{let e=new Ur;return e.fullTimeOneXTwo=t.FT_1X2,e.halfTimeOneXTwo=t.HT_1X2,e.bothTeamsScore=t.BOTH_TEAMS_SCORE,e.overZeroPointFiveGoals=t.OVER_GOALS_0_5,e.overOnePointFiveGoals=t.OVER_GOALS_1_5,e.overTwoPointFiveGoals=t.OVER_GOALS_2_5,e.overThreePointFiveGoals=t.OVER_GOALS_3_5,e.overFourPointFiveGoals=t.OVER_GOALS_4_5,e.overFivePointFiveGoals=t.OVER_GOALS_5_5,e.overSixPointFiveGoals=t.OVER_GOALS_6_5,e.overSixPointFiveCorners=t.OVER_CORNERS_6_5,e.overSevenPointFiveCorners=t.OVER_CORNERS_7_5,e.overEightPointFiveCorners=t.OVER_CORNERS_8_5,e.overNinePointFiveCorners=t.OVER_CORNERS_9_5,e.overTenPointFiveCorners=t.OVER_CORNERS_10_5,e.overElevenPointFiveCorners=t.OVER_CORNERS_11_5,e.overTwelvePointFiveCorners=t.OVER_CORNERS_12_5,e.overThirteenPointFiveCorners=t.OVER_CORNERS_13_5,e.doubleChance=t.DOUBLE_CHANCE,e.halfTimeFullTime=t.HT_FT,e.playerScore=t.PLAYER_SCORE,e.playerYellowCard=t.PLAYER_YELLOW_CARD,e.playerRedCard=t.PLAYER_RED_CARD,e.redCardMatch=t.RED_CARD_MATCH,e.penaltyMatch=t.PENALTY_MATCH,e.playerScoreFirstGoal=t.PLAYER_SCORE_FIRST_GOAL,e.cornersMatch=t.CORNERS_MATCH,e.correctScore=t.CORRECT_SCORE,e.correctScoreHalfTime=t.CORRECT_SCORE_HT,e.correctScoreAdvanced=t.CORRECT_SCORE_ADVANCED,e.playerScoreHattrick=t.PLAYER_SCORE_HATTRICK,e.playerScoreTwice=t.PLAYER_SCORE_TWICE,e}};var kr=class{matchId=null;matchType=null;predictions=null};var Gr=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new ce(t,e)}remapResponse=t=>{let e=new kr;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var Vr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new $};var $r=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Wr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new $;prediction=new $r};var Kr=class{value=null;result=null};var jr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new $;prediction=new Kr};var qr=class{matchId=null;matchModel=null;outcome=null};var zr=class{gameId=null;results=null;tieBreakers=null};var de=class{entityId=null;entityType=null};var Qr=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var Xr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Yr=class{remapPaginatedGames=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapGamesListResponse(i)),e};remapGamesListResponse=t=>{let e=new lt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.scheduleOpenAt=t.schedule_open_at,e.predictionsCutoff=t.predictions_cutoff,e.fixtures=t.fixtures.map(i=>this.remapFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.labels=t.labels,e.customFields=t.custom_fields,e.flags=t.flags,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapGameByIdResponse=t=>{let e=new le;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.scheduleOpenAt=t.schedule_open_at,e.predictionsCutoff=t.predictions_cutoff,e.fixtures=t.fixtures.map(i=>this.remapFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.adContent=t.ad_content,e.labels=t.labels,e.customFields=t.custom_fields,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapFixturesResponse=t=>{let e=new Vr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedUserTopXEditions=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapUserTopXEditionsResponse(i)),e};remapUserTopXEditionsResponse=t=>{let e=new bt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.predictionsCutoff=t.predictions_cutoff,e.scheduleOpenAt=t.schedule_open_at,e.fixtures=t.fixtures.map(i=>this.remapTopXFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapTopXFixturesResponse=t=>{let e=new jr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedUserMathQuizEditions=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapUserMatchQuizEditionsResponse(i)),e};remapUserMatchQuizEditionsResponse=t=>{let e=new pt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.predictionsCutoff=t.predictions_cutoff,e.scheduleOpenAt=t.schedule_open_at,e.fixtures=t.fixtures.map(i=>this.remapMatchQuizFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMatchQuizFixturesResponse=t=>{let e=new Wr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedGameResults=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapGameResults(i)),e};remapGameResults=t=>{let e=new Ct;return e.userId=t.user_id,e.points=t.points?t.points:0,e.results=t.results.map(i=>this.remapResults(i)),e.tiebreaker=t.tiebreaker?this.remapTiebreaker(t.tiebreaker):null,e};remapGameMarketsResults=t=>{let e=new zr;return e.gameId=t.game_id,e.results=this.remapMarketsResults(t.results),e.tieBreakers=t.tie_breakers?this.remapTieBreakers(t.tie_breakers):null,e};remapContestWinners=t=>{let e=new Qr;return e.contestId=t.contest_id,e.contestType=t.contest_type,e.description=t.description,e.userList=t.user_list?t.user_list.map(i=>this.remapUserListWinners(i)):null,e};remapUserListWinners=t=>{let e=new Xr;return e.position=t.position,e.profileId=t.profile_id,e.note=t.note,e.tags=t.tags,e};remapTieBreakers=t=>{let e={goldenGoals:[]};return e.goldenGoals=t.golden_goals.map(i=>({minute:i.minute,matchId:i.match_id,matchModel:null,playerId:i.player_id,playerModel:null,goalType:i.goal_type})),e};remapMarketsResults=t=>{let e=[];return t.forEach(i=>{let r={matchId:i.match_id,market:i.market,result:this.remapMarketResult(i.market,i.result),matchModel:null,playerModels:[],matchStatus:this.remapMarketsResultsMatchStatus(i.match_status)};e.push(this.deleteUnusefulField(r))}),e};remapMarketsResultsMatchStatus=t=>{let e=new $;return t&&(e.type=t.type,e.subType=t.sub_type),e};remapMarketResult=(t,e)=>{if(qs.includes(t))return e[0];if(tt.includes(t))return e;if(e[0]==="true")return!0;if(e[0]==="false")return!1};deleteUnusefulField=t=>((!tt.includes(t.market)||this.isPlayerMarketWithNoResult(t.market,t.result))&&delete t.playerModels,t);isPlayerMarketWithNoResult=(t,e)=>tt.includes(t)&&e.length===0;remapResults=t=>{let e=new qr;return e.matchId=t.match_id,e.outcome=t.outcome,e};remapTiebreaker=t=>{let e=new it;return e.goldenGoal=t.golden_goal,e};remapTimeTiebreaker=t=>{let e=new rt;return e.timeTiebreaker=t,e};remapRelated=t=>t.map(e=>{let i=new de;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Jr=class{remapMetaData=t=>{let e=new G;return e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.itemsPerPage=t.pagination.items_per_page,e}};var st=class extends _{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(t,e){super(t,R(t.environment,"predictor")),this.predictionRemapper=new ce(t,e),this.matchSummaryRemapper=new Gr(t,e),this.gamesRemapper=new Yr,this.metaRemapper=new Jr}makeFootballPrediction=async t=>{let e=`/predictions${this.apiSignInUrl}`,i="There was a problem making POST request",r="POST",a=await this.fetchWithAuth(e,i,r,this.predictionRemapper.remapRequestBody(t));return await this.predictionRemapper.remapResponseObjBody(a)};getMatchSummary=async(t,e)=>{let i=I(e)?`/predictions/summary/${t}${this.apiSignInUrl}${M()}`:`/predictions/summary/${t}${this.apiSignInUrl}`,r=`There was a problem fetching predictions for match: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.matchSummaryRemapper.remapResponse(a)};deleteFootballPrediction=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem deleting your prediction: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getMyPredictions=async t=>{let e=new E,i=`/predictions${this.apiSignInUrl}`,r="There was a problem fetching own predictions";t&&(i+=`${t.constructFiltersUrl()}`);let a=await this.fetchWithAuth(i,r);return e.meta=this.metaRemapper.remapMetaData(a.meta),e.data=await this.predictionRemapper.remapResponseArrayBody(a.data),e};getMyPredictionsNoRemap=async t=>{let e=`/predictions${this.apiSignInUrl}${t.constructFiltersUrl()}`,i="There was a problem fetching own predictions";return await this.fetchWithAuth(e,i)};getUserPredictions=async(t,e,i)=>{let r=new E,a=I(e)?`/predictions/users/${t}${this.apiSignInUrl}${M()}`:`/predictions/users/${t}${this.apiSignInUrl}`,s=`There was a problem fetching predictions for user: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(a,s);return r.meta=this.metaRemapper.remapMetaData(p.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(p.data),r};getUserPredictionsNoRemap=async(t,e)=>{let i=`/predictions/users/${t}${this.apiSignInUrl}${e.constructFiltersUrl()}`,r=`There was a problem fetching predictions for user: ${t}`;return await this.fetchWithoutAuth(i,r)};getGames=async(t,e)=>{let i=I(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${M()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,r="There was a problem fetching the games list",a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapPaginatedGames(a)};getGameById=async(t,e)=>{let i=I(e)?`/games/${t}${this.apiSignInUrl}${M()}`:`/games/${t}${this.apiSignInUrl}`,r=`There was a problem fetching the following game: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameByIdResponse(a)};getGamePredictions=async(t,e,i)=>{let r=new E,a=I(e)?`/games/${t}/predictions${this.apiSignInUrl}${M()}`:`/games/${t}/predictions${this.apiSignInUrl}`,s=`There was a problem fetching the predictions for game: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(a,s);return r.meta=this.metaRemapper.remapMetaData(p.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(p.data),r};getUserGameEditions=async(t,e)=>{let i=null,r=I(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${M()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,a="There was a problem fetching the games list",s=await this.fetchWithoutAuth(r,a);return s.data.forEach(p=>{p.type==="TOP_X"?i=this.gamesRemapper.remapPaginatedUserTopXEditions(s):p.type==="MATCH_QUIZ"&&(i=this.gamesRemapper.remapPaginatedUserMathQuizEditions(s))}),i};getGameResults=async(t,e,i)=>{let r=I(e)?`/games/${t}/results/${this.apiSignInUrl}${M()}`:`/games/${t}/results/${this.apiSignInUrl}`,a=`There was a problem fetching the results for the following game: ${t}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return this.gamesRemapper.remapPaginatedGameResults(s)};getMarketResultsForGame=async(t,e)=>{let i=`/games/${t}/correct-results/${this.apiSignInUrl}`,r=`There was a problem fetching the markets correct results for the following game: ${t}`;I(e)&&(i+=`${M()}`);let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(a.data)};getContestWinners=async(t,e)=>{let i=`/winners/${this.apiSignInUrl}&contest_id=${t}`,r=`There was a problem fetching winners for the following game: ${t}`;e&&(i+=M());let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapContestWinners(a)};getPredictionById=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem fetching info for the following prediction: ${t}`,r=await this.fetchWithoutAuth(e,i);return(await this.predictionRemapper.remapResponseArrayBody([r.data]))[0]};getPredictionsByIds=async t=>{let e=`/predictions/by-ids${this.apiSignInUrl}&prediction_ids=${t.join(",")}`,i="There was a problem fetching predictions",r=await this.fetchWithoutAuth(e,i);return await this.predictionRemapper.remapResponseArrayBody(r.data)}};var me=class{gameInstanceId=null;fixtures=null};var cs=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(cs||{}),ds=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(ds||{}),ms=(l=>(l.ONE_ONE="1/1",l.ONE_X="1/x",l.ONE_TWO="1/2",l.X_ONE="x/1",l.X_X="x/x",l.X_TWO="x/2",l.TWO_ONE="2/1",l.TWO_X="2/x",l.TWO_TWO="2/2",l))(ms||{});var Zr=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new q,this.prediction.value=e}};var ta=class{value};var ea=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new ta,this.prediction.value=e}};var ia=class{value=null};var ra=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new ia,this.prediction.value=e}};var aa=class{value=null};var oa=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new aa,this.prediction.value=i}};var sa=class{value=null};var na=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new sa,this.prediction.value=e}};var la=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new q,this.prediction.value=e}};var pa=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new q,this.prediction.value=e}};var Mt=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new me);switch(t){case"MATCH_QUIZ":i.forEach(n=>{r.includes(n)||this.throwInvalidParamException([n])});break;case"TOP_X":let s=e;s.fixtures.forEach(n=>this.validateMarketTopX(n.market));let p="tiebreaker";i.includes(p)&&s.tiebreaker&&this.validateTiebreaker(s.tiebreaker),i.forEach(n=>{n!=="tiebreaker"&&!r.includes(n)&&this.throwInvalidParamException([n])});break}let a=r.filter(s=>!i.includes(s));return a.length&&this.throwMissingFieldsException("game prediction body",a),e.fixtures.forEach(s=>{this.validateFixtureFields(s)}),e};validateFixture=(t,e,i,r)=>{this.validateMarket(e);let a=Object.values(cs),s=Object.values(ms),p=Object.values(ds);if(e==="FT_1X2"||e==="HT_1X2"){if(a.includes(i))return new oa(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new na(t,i)}else if(e==="DOUBLE_CHANCE"){if(p.includes(i))return new ra(t,i)}else if(e==="CORRECT_SCORE"||e==="CORRECT_SCORE_ADVANCED"||e==="CORRECT_SCORE_HT"){if(typeof i=="string"&&/\d+:\d+/.test(i))return new yt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new ea(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new Zr(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new pa(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new la(t,i)}else if(tt.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===je&&this.isPredictionBoolean(i)){let l=r&&r===n?n:r;return new j(t,e,i,l)}if(r&&this.isPredictionBoolean(i))return new j(t,e,i,r)}else if(Ks.includes(e)){if(this.isPredictionBoolean(i))return new ne(t,e,i)}else if(js.includes(e)&&this.isPredictionBoolean(i))return new se(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{as.includes(r)||this.throwInvalidParamException([r])});let i=as.filter(r=>{if(r!=="matchType"&&!e.includes(r))return r});i.length&&this.throwMissingFieldsException("fixtures",i),this.validatePredictionKey(t.market,t.prediction)};validateTiebreaker=t=>{let e=Object.keys(t);(!e.length||typeof t!="object")&&this.throwInvalidType("tiebreaker","object");let i=Object.keys(new it)[0];e.forEach(r=>{i!==r&&this.throwInvalidParamException([r])}),e.includes(i)||this.throwMissingFieldsException("tiebreaker",[i]),typeof t.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(t,e)=>{if(typeof e=="object"){let i=Object.keys(e),r=["value"];if(i.length||this.throwMissingFieldsException("prediction",r),i.length===1&&!i.includes(r[0])&&this.throwInvalidParamException(i),i.length>1){tt.includes(t)&&r.push("playerId");let a=i.filter(s=>!r.includes(s));a.length&&this.throwInvalidParamException(a)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(t,e)=>{let i="playerId";t!==je&&(e||this.throwInvalidParamException([i]),typeof e!="string"&&this.throwInvalidType(i,"string"))};validateMarket=t=>{Object.values(K).includes(t)||this.throwInvalidMarketException(t)};validateMarketTopX=t=>{t!=="CORRECT_SCORE"&&t!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(t,"TOP_X")};isPredictionBoolean=t=>typeof t=="boolean";throwInvalidPredictionException=(t,e)=>{let i=Is(t,e);throw this.errorHandlingMode==="default"?new w(400,"INVALID_PREDICTION",i):new u(400,"INVALID_TYPE",i)};throwInvalidMarketException=(t,e)=>{let i=null;throw e&&e==="TOP_X"?i=Ps(t):i=Wo(t),this.errorHandlingMode==="default"?new w(400,"INVALID_MARKET",i):new u(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Ts(t);throw this.errorHandlingMode==="default"?new w(400,"INVALID_FIELD",e):new u(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=vs(t,e);throw this.errorHandlingMode==="default"?new w(400,"INVALID_FIELD",i):new u(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=_s(t,e);throw this.errorHandlingMode==="default"?new w(400,"INVALID_TYPE",i):new u(400,"INVALID_TYPE",i)}};var ca=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;errorHandlingMode=null;constructor(t,e,i,r){this.predictorHttps=e,this.idMapping=r,this.clientHttps=i,this.errorHandlingMode=t.errorHandlingMode,this.predictorValidator=new Mt(t.errorHandlingMode),this.predictorService=new ot(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let a=this.predictorValidator.validateFixture(t,e,i,r),s=new me;if(this.idMapping.idSchema!=="native"){let p=a.matchId,n="",l=await this.predictorService.remapMatchIdToNative([p]);if(a.matchId=l[0],this.errorHandlingMode==="default"&&!a.matchId)throw new w(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!a.matchId)throw new u(400,"INVALID_FIELD","Match id is invalid!");if(a instanceof j&&a.prediction.playerId!=="OWN_GOAL"){if(a.prediction.playerId&&(n=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&a.market!==je&&!a.prediction.playerId)throw new w(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&a.market!==je&&!a.prediction.playerId)throw new u(400,"INVALID_FIELD","Player id is invalid!")}s.fixtures=[a];let c=await this.predictorHttps.makeFootballPrediction(s);return c.fixtures.forEach(d=>{d.prediction.playerId&&d.prediction.playerId!=="OWN_GOAL"&&(d.prediction.playerId=n),d.matchId=p}),c}else return s.fixtures=[a],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(t,e)=>{let i=await this.getMatchSummaryBase(t,e),r=JSON.parse(JSON.stringify(i.predictions)),a=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=a,i};getMarketSummary=async(t,e,i,r)=>{try{let a=await this.getMatchSummaryBase(t,r);return await this.predictorService.getMarketSummary(a,e,i)}catch(a){throw a}};getMatchSummaryBase=async(t,e)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([t]))[0],a=await this.predictorHttps.getMatchSummary(r,e);return a.matchId=t,a}else return await this.predictorHttps.getMatchSummary(t,e)};getConfig=async()=>{let t=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getMyPredictions(e)};getMyPredictionsForMatches=async(t,e)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(t))throw new w(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new u(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let i=this.predictorService.initPredictionsFilters(e,"matches",t);return await this.predictorHttps.getMyPredictions(i)};getMyCurrentPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getMyPredictions(e)};getMyPastPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getMyPredictions(e)};getUserPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserCurrentPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserPastPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserPredictionsForMatches=async(t,e,i,r)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(e))throw new w(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new u(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let a=this.predictorService.initPredictionsFilters(i,"matches",e);return await this.predictorHttps.getUserPredictions(t,r,a)};getPredictionById=async t=>await this.predictorHttps.getPredictionById(t);getPredictionsByIds=async t=>await this.predictorHttps.getPredictionsByIds(t)};var ue=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(t){this.idMapping=new F(t),this.predictorHttps=new st(t,this.idMapping),this.clientHttps=new B(t),this.predictorFacade=new ca(t,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(t,e,i,r)=>await this.predictorFacade.makeFootballPrediction(t,e,i,r);getMatchSummary=async(t,e)=>await this.predictorFacade.getMatchSummary(t,e);getMarketSummary=async(t,e,i,r)=>await this.predictorFacade.getMarketSummary(t,e,i,r);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async t=>await this.predictorFacade.deleteFootballPrediction(t);getMyPredictions=async t=>await this.predictorFacade.getMyPredictions(t);getMyCurrentPredictions=async t=>await this.predictorFacade.getMyCurrentPredictions(t);getMyPastPredictions=async t=>await this.predictorFacade.getMyPastPredictions(t);getMyPredictionsForMatches=async(t,e)=>await this.predictorFacade.getMyPredictionsForMatches(t,e);getUserPredictions=async(t,e,i)=>await this.predictorFacade.getUserPredictions(t,e,i);getUserCurrentPredictions=async(t,e,i)=>await this.predictorFacade.getUserCurrentPredictions(t,e,i);getUserPastPredictions=async(t,e,i)=>await this.predictorFacade.getUserPastPredictions(t,e,i);getUserPredictionsForMatches=async(t,e,i,r)=>await this.predictorFacade.getUserPredictionsForMatches(t,e,i,r);getPredictionById=async t=>await this.predictorFacade.getPredictionById(t);getPredictionsByIds=async t=>await this.predictorFacade.getPredictionsByIds(t)};var da=class{rankType=null;fromDate=null;toDate=null;pagination=new ft};var he=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var ma=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new da;return e.rankType=t.rank_type,e.fromDate=t.from_date,e.toDate=t.to_date,e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e};remapData=t=>{let e=[];return t.forEach(i=>{let r=new he;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var ua=class{templateId="";templateModel=null;challengeId="";challengeModel=null;position="";points=0;type="challenge"};var ha=class{templateId="";templateModel=null;privateLeagueId="";privateLeagueModel=null;position="";points=0;type="private_league"};var ga=class extends he{id=null;rankType=null;model=null;gameType=null};var fa=class{remapRankings=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapRankingsPrivateLeague=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapDataUserRankingPrivateLeague(t.data),t);remapRankingsChallenge=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapDataUserRankingChallenge(t.data),t);remapMeta=t=>{let e=new W;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.numberOfPages=t.pagination.number_of_pages,e.pagination.totalItems=t.pagination.total_items,e};remapData(t){let e=[];return t.forEach(i=>{let r=new ga;r.id=i.id,r.rankType=i.rank_type,r.position=i.position,r.points=i.points,r.gameType=i.game_type,delete r.profileId,delete r.profileModel,delete r.predictionsMade,e.push(r)}),e}remapDataUserRankingPrivateLeague(t){let e=[];return t.forEach(i=>{let r=new ha;r.templateId=i.template_id,r.privateLeagueId=i.private_league_id,r.position=i.position,r.points=i.points,e.push(r)}),e}remapDataUserRankingChallenge(t){let e=[];return t.forEach(i=>{let r=new ua;r.templateId=i.template_id,r.challengeId=i.private_league_id,r.position=i.position,r.points=i.points,e.push(r)}),e}};var ya=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var ba=class{pagination=new ft;filters=new ya};var ge=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];groups=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;labels=null;customFields=null;flags=null;images=new at;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var Ma=class extends ge{adContent=null};var wa=class{fromDate=null;toDate=null;matchIds=[]};var Ia=class{groupId=null;label=null;filters=null};var Pa=class{remapResponse=t=>{let e=[];return t.forEach(i=>{let r=new ge;r.id=i.id,r.name=i.name,r.description=i.description,r.type=i.type,r.fromDate=i.from_date,r.toDate=i.to_date,r.markets=i.markets?i.markets:null,r.teamIds=i.team_ids?i.team_ids:null,r.matchIds=i.match_ids?i.match_ids:null,r.groups=i.groups?this.remapGroups(i.groups):null,r.gameIds=i.game_ids?i.game_ids:null,r.gameTypes=i.game_types?i.game_types:null,r.competitionIds=i.competition_ids?i.competition_ids:null,r.excludedProfileIds=i.excluded_profile_ids?i.excluded_profile_ids:null,r.rules=i.rules?i.rules:null,r.labels=i.labels?i.labels:null,r.customFields=i.custom_fields?i.custom_fields:null,r.flags=i.flags?i.flags:null,r.images=i.images?i.images:null,r.status=i.status?i.status:null,r.automaticallyChangeStatus=i.automatically_change_status,r.createdAt=i.created_at,r.updatedAt=i.updated_at,r.related=i.related?this.remapRelated(i.related):null,e.push(r)}),e};remapResponseId=t=>{let e=new Ma;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.fromDate=t.from_date,e.toDate=t.to_date,e.markets=t.markets?t.markets:null,e.teamIds=t.team_ids?t.team_ids:null,e.matchIds=t.match_ids?t.match_ids:null,e.groups=t.groups?this.remapGroups(t.groups):null,e.gameIds=t.game_ids?t.game_ids:null,e.gameTypes=t.game_types?t.game_types:null,e.competitionIds=t.competition_ids?t.competition_ids:null,e.excludedProfileIds=t.excluded_profile_ids?t.excluded_profile_ids:null,e.rules=t.rules?t.rules:null,e.flags=t.flags?t.flags:null,e.images=t.images?t.images:null,e.status=t.status?t.status:null,e.automaticallyChangeStatus=t.automatically_change_status,e.related=t.related?this.remapRelated(t.related):null,e.labels=t.labels,e.customFields=t.custom_fields,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMeta=t=>{let e=new ba;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e.filters.flags=t.filters.flags,e.filters.status=t.filters.status,e.filters.type=t.filters.type,e.filters.activeFrom=t.filters.active_from,e.filters.activeTo=t.filters.active_to,e.filters.createdFrom=t.filters.created_from,e.filters.createdTo=t.filters.created_to,e.filters.updatedFrom=t.filters.updated_from,e.filters.updatedTo=t.filters.updated_to,e};remapRelated=t=>t.map(e=>{let i=new de;return i.entityId=e.entity_id,i.entityType=e.entity_type,i});remapGroups=t=>t.map(e=>{let i=new Ia;return i.groupId=e.group_id,i.label=e.label,i.filters=this.remapGroupFilters(e.filters),i});remapGroupFilters=t=>{let e=new wa;return e.fromDate=t.from_date,e.toDate=t.to_date,e.matchIds=t.match_ids,e}};var Ta=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var va=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Ta;return i.position=e.position,i.points=e.points,i.predictionsMade=e.predictions_made,i.profileId=e.profile_id,i.successRatePercent=e.success_rate_percent,i})};var wt=class extends _{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,R(t.environment,"loyalty")),this.templateRemapper=new Pa,this.leaderboardRemapper=new ma,this.rankingsRemapper=new fa,this.highestSuccessRateRemapper=new va}getTemplates=async(t,e)=>{let i=t?`/leaderboard/templates/${this.apiSignInUrl}${t.constructFiltersUrl()}`:`/leaderboard/templates/${this.apiSignInUrl}`;i+=I(e)?M():"";let r="There was a problem fetching the list of templates",a=await this.fetchWithoutAuth(i,r),s=JSON.parse(JSON.stringify(a));return s.meta=this.templateRemapper.remapMeta(a.meta),s.data=this.templateRemapper.remapResponse(a.data),s};getTemplateById=async(t,e)=>{let i=I(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${M()}`:`/leaderboard/templates/${t}${this.apiSignInUrl}`,r=`There was a problem requesting the following template: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.templateRemapper.remapResponseId(a.data)};getLeaderboard=async(t,e,i)=>{let r=I(e)?`/leaderboard/${t}/${this.apiSignInUrl}${M()}`:`/leaderboard/${t}/${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following template: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getLeaderboardForGame=async(t,e,i)=>{let r=I(e)?`/leaderboard/games/${t}/${this.apiSignInUrl}${M()}`:`/leaderboard/games/${t}/${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following game: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getUserRankings=async(t,e,i)=>{let r=`/leaderboard/users/${t}/rankings/${this.apiSignInUrl}`,a=`There was a problem fetching the rankings for the following user: ${t}`;e&&(r+=`${e.constructFiltersUrl()}`),I(i)&&(r+=`${M()}`);let s=await this.fetchWithoutAuth(r,a);return this.rankingsRemapper.remapRankings(s)};getHighestSuccessRate=async(t,e)=>{let i=`/statistics/top${this.apiSignInUrl}`,r="There was a problem fetching highest success rate";t&&(i+=`${t.constructFiltersUrl()}`),I(e)&&(i+=`${M()}`);let a=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(a.data)};getEntitiesFollows=async(t,e)=>{let i=I(e)?`/statistics/follows${this.apiSignInUrl}${M()}`:`/statistics/follows${this.apiSignInUrl}`,r="There was a problem fetching follows for entities";return t.footballCompetitions&&(i+=`&competitions=${t.footballCompetitions.join(",")}`),t.footballTeams&&(i+=`&teams=${t.footballTeams.join(",")}`),t.footballPlayers&&(i+=`&players=${t.footballPlayers.join(",")}`),(await this.fetchWithoutAuth(i,r)).data};getUserRankingsForPrivateLeagueAndChallenges=async(t,e,i)=>{let r=`/private-league/users/${t}/rankings/${this.apiSignInUrl}&private_league_type=${e==="PRIVATE_LEAGUE"?"private":"one_vs_one"}`,a=`There was a problem fetching user rankings for ${e}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return e==="PRIVATE_LEAGUE"?this.rankingsRemapper.remapRankingsPrivateLeague(s):this.rankingsRemapper.remapRankingsChallenge(s)}};var _a=class{general;predictor;topX;matchQuiz};var fe=class{limit=null;page=null;constructor(t){this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null}constructFiltersUrl(){let t="";return this.limit&&(t+="&",t+=`limit=${this.limit}`),this.page&&(t+="&",t+=`page=${this.page}`),t}};var Fa=class extends fe{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(t){super(t),this.sortOrder=t.sortOrder,this.rankType=t.rankType,this.leaderboardIds=t.leaderboardIds,this.gameType=t.type&&t.type.toLowerCase()==="game"?t.gameType:null}constructFiltersUrl=()=>{let t=super.constructFiltersUrl();return this.sortOrder&&(t+="&",t+=`sort_order=${this.sortOrder}`),this.rankType&&(t+="&",t+=`rank_type=${this.rankType}`),this.leaderboardIds&&(t+="&",t+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(t+="&",t+=`game_type=${this.gameType}`),t}};var Ea=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new F(t),this.profileNamespace=new C(t),this.footballNamespace=new et(t),this.errorHandlingMode=t.errorHandlingMode}remapTemplatesIds=async t=>{if(t.length>0){let e=[],i=[],r=[],a=[],s=[],p=[];t.forEach(c=>{c.teamIds&&c.teamIds.length>0&&(e=[...e,...c.teamIds]),c.matchIds&&c.matchIds.length>0&&(r=[...r,...c.matchIds]),c.competitionIds&&c.competitionIds.length>0&&(s=[...s,...c.competitionIds])});let n={team:e,match:r,competition:s},l=await this.idMappingService.idMappingFacade.getEntitiesByIds(n,"native",this.idMappingService.idSchema);return i=[...l.team],a=[...l.match],p=[...l.competition],t.forEach(c=>{c.teamIds&&c.teamIds.length>0&&(c.teamIds=c.teamIds.map(d=>d=l.team.shift())),c.matchIds&&c.matchIds.length>0&&(c.matchIds=c.matchIds.map(d=>d=l.match.shift())),c.competitionIds&&c.competitionIds.length>0&&(c.competitionIds=c.competitionIds.map(d=>d=l.competition.shift()))}),t}return t};remapTemplateGroupMatchIds=async t=>{if(t&&t.length>0){for(let e of t)if(e.filters.matchIds&&e.filters.matchIds){let i={match:Array.from(e.filters.matchIds)},r=await this.idMappingService.idMappingFacade.getEntitiesByIds(i,"native",this.idMappingService.idSchema);e.filters.matchIds=Array.from(r.match)}}};addProfileModelToLeaderboad=async t=>{if(t.length>0){let e=[],i=t.map(a=>a.profileId);if(!i.length)return t;let r=await this.profileNamespace.getByIds(i);return t.forEach(a=>{r.forEach(s=>{s.id===a.profileId&&(delete s.interests,a.profileModel=s)}),a.profileModel||(a.profileModel=null),e.push(a)}),e}return t};buildClientBadges=t=>{let e=new _a;return e.general=this.extractEnabledBadgesId(t.general),e.predictor=this.extractEnabledBadgesId(t.predictor),e.topX=this.extractEnabledBadgesId(t.topX),e.matchQuiz=this.extractEnabledBadgesId(t.matchQuiz),e};initFilters=(t,e)=>{switch(e){case"loyalty":t&&(t=new fe(t));break;case"rankings":t&&(t=new Fa(t));break}return t};addProfileModelToHighestSuccessRate=async t=>{let e=t.map(r=>r.profileId);if(!e.length)return t;let i=await this.profileNamespace.getByIds(e);return t.map(r=>(i.forEach(a=>{a.id===r.profileId&&(delete a.interests,r.profileModel=a)}),r))};extractRankingsIdsMap=t=>{let e=[],i=[],r=[];return t.forEach(a=>{a.rankType==="GAME"&&a.gameType==="TOP_X"?e.push(a.id):a.rankType==="GAME"&&a.gameType==="MATCH_QUIZ"?i.push(a.id):a.rankType==="TEMPLATE"&&r.push(a.id)}),[e,i,r]};setModelsForUserRankings=(t,e,i,r)=>(r.data.forEach(a=>{a.gameType==="MATCH_QUIZ"&&e?a.model=e.filter(s=>s.id===a.id)[0]:a.gameType==="TOP_X"&&t?a.model=t.filter(s=>s.id===a.id)[0]:a.rankType==="TEMPLATE"&&i&&(a.model=i.filter(s=>s.id===a.id)[0])}),r);completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};validateEntitiesFollowsFilters=t=>{if(!t||(!t.footballCompetitions||!t.footballCompetitions.length)&&(!t.footballTeams||!t.footballTeams.length)&&(!t.footballPlayers||!t.footballPlayers.length))throw this.errorHandlingMode==="default"?new w(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new u(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters.");if(t.footballCompetitions&&t.footballCompetitions.length>24||t.footballTeams&&t.footballTeams.length>24||t.footballPlayers&&t.footballPlayers.length>24)throw this.errorHandlingMode==="default"?new w(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new u(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less.")};remapEntitiesFollowsFilters=async t=>{let e=JSON.parse(JSON.stringify(t)),i={},r={};e.footballCompetitions&&e.footballCompetitions.length&&(r.competition=e.footballCompetitions),e.footballTeams&&e.footballTeams.length&&(r.team=e.footballTeams),e.footballPlayers&&e.footballPlayers.length&&(r.player=e.footballPlayers);let a=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(a).forEach(s=>{s==="competition"?i.footballCompetitions=a[s]:s==="team"?i.footballTeams=a[s]:s==="player"&&(i.footballPlayers=a[s])}),i};addModelsToEntitiesFollows=async t=>{let e=[],i="fb:c:",r=new Map,a=[],s="fb:t:",p=new Map,n=[],l="fb:p:",c=null;return t.breakdown.forEach(d=>{d.id.includes(i)?e.push(d.id):d.id.includes(s)?a.push(d.id):d.id.includes(l)&&n.push(d.id)}),e.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(e)),a.length&&(p=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(a)),n.length&&(c=await this.footballNamespace.footballFacade.playerFacade.getPlayersMapWithNativeIds(n)),t.breakdown.forEach(d=>{d.id.includes(i)?(d.model=r.get(d.id),d.id=d.model.id):d.id.includes(s)?(d.model=p.get(d.id),d.id=d.model.id):d.id.includes(l)&&(d.model=c[d.id],d.id=d.model.id)}),t};extractEnabledBadgesId=t=>{let e=[];return t.forEach(i=>{i.enabled&&e.push(i.id)}),e}};var Ra=class{validate=(t,e)=>{t.market&&this.validateMarket(t.market,e),t.fromDate&&this.validateDate(t.fromDate,"fromDate",e),t.toDate&&this.validateDate(t.toDate,"toDate",e),t.usersCount&&this.validateNumberFilters(t.usersCount,"usersCount",e),t.minimumPredictions&&this.validateNumberFilters(t.minimumPredictions,"minimumPredictions",e)};validateMarket=(t,e)=>{if(!Object.keys(K).includes(t)){let r=Wo(t);throw e==="default"?new w(400,"INVALID_MARKET",r):new u(400,"INVALID_MARKET",r)}};validateDate=(t,e,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof t!="string")throw i==="default"?new w(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`):new u(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`);if(!r.test(t))throw i==="default"?new w(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`):new u(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`)};validateNumberFilters=(t,e,i)=>{let r=e==="usersCount"?1:0,a=e==="usersCount"?1e3:1e6;if(typeof t!="number")throw i==="default"?new w(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`):new u(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`);if(t<r||t>a)throw i==="default"?new w(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`):new u(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`)}};var ye=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;errorHandlingMode=null;constructor(t,e){this.idMapping=e,this.errorHandlingMode=t.errorHandlingMode,this.predictorValidator=new Mt(t.errorHandlingMode),this.predictorHttps=new st(t,e),this.predictorService=new ot(t,e),this.clientHttps=new B(t)}getConfig=async()=>{let t=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};getGames=async(t,e)=>{e=e||!1;let i=this.predictorService.initGameFilters("TOP_X",t),r=await this.predictorHttps.getGames(i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(t,e)=>{e=e||!1;let i=await this.predictorHttps.getGameById(t,e);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(t,e,i)=>(i=i||!1,e&&(e.type&&delete e.type,e.status&&delete e.status,e=new D(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new z(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e={status:"OPEN",type:"TOP_X"};e=new z(e);let i=await this.predictorHttps.getGames(e,t),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,t)).data[0]};play=async t=>{let e=new pe(t);if(e=this.predictorValidator.validateBodyFields("TOP_X",e),e.fixtures=e.fixtures.map(r=>this.predictorValidator.validateFixture(r.matchId,r.market,r.prediction.value)),this.idMapping.idSchema!=="native"){let r=[];e.fixtures.forEach(s=>r.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(r);e.fixtures.forEach(s=>s.matchId=a.shift())}let i=await this.predictorHttps.makeFootballPrediction(e);return i.fixtures.forEach(r=>{r.matchId=r.matchModel.id}),i};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("TOP_X",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,p)}else return new E};getMyGamePrediction=async t=>{let e=this.predictorService.initGameTypePredictions("TOP_X"),i=await this.predictorHttps.getMyPredictions(e);if(i.data.length>0){let r=i.data.filter(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&a.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("TOP_X",null,a),n=await this.predictorHttps.getUserGameEditions(p,i);return await this.predictorService.addPredictionProp(s,n)}else return new E};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.data.filter(p=>p.gameInstanceId===e);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(t,e)=>{let i=await this.predictorHttps.getMarketResultsForGame(t,e);return await this.predictorService.completeGameMarketResults(i,"TOP_X")};getGameWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getGameById(t);return i.contestModel=r,this.predictorService.completeContestWinners(i)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new w(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new u(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var be=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new Mt(t.errorHandlingMode),this.idMapping=new F(t),this.predictorHttps=new st(t,this.idMapping),this.predictorService=new ot(t,this.idMapping),this.clientHttps=new B(t),this.errorHandlingMode=t.errorHandlingMode}getConfig=async()=>{let t=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};play=async t=>{t=this.predictorValidator.validateBodyFields("MATCH_QUIZ",t);let e=t.fixtures.map(i=>this.predictorValidator.validateFixture(i.matchId,i.market,i.prediction.value,i.prediction.playerId));if(e&&e.length&&this.idMapping.idSchema!=="native"){let i=[],r=[];e.forEach(p=>{i.push(p.matchId),p instanceof j&&p.prediction.playerId&&p.prediction.playerId!=="OWN_GOAL"&&r.push(p.prediction.playerId)});let a=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),e.forEach((p,n)=>{p.matchId=a[n],p instanceof j&&p.prediction.playerId!=="OWN_GOAL"&&(p.prediction.playerId=s[p.prediction.playerId])})}return t.fixtures=e,await this.predictorHttps.makeFootballPrediction(t)};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getGames=async(t,e)=>{e=e||!1;let i=this.predictorService.initGameFilters("MATCH_QUIZ",t),r=await this.predictorHttps.getGames(i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(t,e)=>{e=e||!1;let i=await this.predictorHttps.getGameById(t,e);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(t,e,i)=>(i=i||!1,e&&(e.type&&delete e.type,e.status&&delete e.status,e=new D(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new L(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e={status:"OPEN",type:"MATCH_QUIZ"};e=new z(e);let i=await this.predictorHttps.getGames(e,t),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,t)).data[0]};getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,p)}else return new E};getMyGamePrediction=async t=>{let e=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=await this.predictorHttps.getMyPredictions(e);if(i.data.length>0){let r=i.data.filter(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&a.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("MATCH_QUIZ",null,a),n=await this.predictorHttps.getUserGameEditions(p,i);return await this.predictorService.addPredictionProp(s,n)}else return new E};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.data.filter(p=>p.gameInstanceId===e);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(t,e)=>{let i=await this.predictorHttps.getMarketResultsForGame(t,e);return await this.predictorService.completeGameMarketResults(i,"MATCH_QUIZ")};getGameWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getGameById(t);return i.contestModel=r,this.predictorService.completeContestWinners(i)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new w(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new u(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var Sa=class{market;fromDate;toDate;usersCount;minimumPredictions;constructor(t){this.market=t.market?t.market:null,this.fromDate=t.fromDate?t.fromDate:null,this.toDate=t.toDate?t.toDate:null,this.usersCount=t.usersCount?t.usersCount:null,this.minimumPredictions=t.minimumPredictions?t.minimumPredictions:null}constructFiltersUrl(){let t="";return this.market&&(t+="&",t+=`market=${this.market}`),this.fromDate&&(t+="&",t+=`from_date=${this.fromDate}`),this.toDate&&(t+="&",t+=`to_date=${this.toDate}`),this.usersCount&&(t+="&",t+=`users_count=${this.usersCount}`),this.minimumPredictions&&(t+="&",t+=`minimum_predictions=${this.minimumPredictions}`),t}};var Ca=class{flags=null;status=null;type=null;activeFrom=null;activeTo=null;createdFrom=null;createdTo=null;updatedFrom=null;updatedTo=null;constructor(t){this.flags=t.flags?t.flags:null,this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.activeFrom=t.activeFrom?t.activeFrom:null,this.activeTo=t.activeTo?t.activeTo:null,this.createdFrom=t.createdFrom?t.createdFrom:null,this.createdTo=t.createdTo?t.createdTo:null,this.updatedFrom=t.updatedFrom?t.updatedFrom:null,this.updatedTo=t.updatedTo?t.updatedTo:null}constructFiltersUrl(){let t="";return this.flags&&(t+="&",t+=`flags=${this.flags}`),this.status&&(t+="&",t+=`status=${this.status}`),this.type&&(t+="&",t+=`type=${this.type}`),this.activeFrom&&(t+="&",t+=`active_from=${this.activeFrom}`),this.activeTo&&(t+="&",t+=`active_to=${this.activeTo}`),this.createdFrom&&(t+="&",t+=`created_from=${this.createdFrom}`),this.createdTo&&(t+="&",t+=`created_to=${this.createdTo}`),this.updatedFrom&&(t+="&",t+=`updated_from=${this.updatedFrom}`),this.updatedTo&&(t+="&",t+=`updated_to=${this.updatedTo}`),t}};var Aa=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;football=null;constructor(t,e,i,r,a){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new J(a,r),this.loyaltyService=new Ea(this.config),this.loyaltyValidator=new Ra,this.idMapping=new F(t),this.topXFacade=new ye(t,this.idMapping),this.matchQuizFacade=new be(t),this.predictorHttps=new st(t,this.idMapping),this.errorHandlingMode=t.errorHandlingMode,this.football=new et(t)}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let t=await this.getConfig();return this.loyaltyService.buildClientBadges(t.rewards.badges)};getTemplates=async(t,e)=>{if(t&&(t=new Ca(t)),this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(t,e);let i=await this.loyaltyHttps.getTemplates(t,e);i.data=await this.loyaltyService.remapTemplatesIds([...i.data]);for(let r of i.data)await this.loyaltyService.remapTemplateGroupMatchIds(r.groups);return i};getTemplateById=async(t,e)=>{let i=await this.loyaltyHttps.getTemplateById(t,e);if(this.config.idSchema==="native")return i;let r=await this.loyaltyService.remapTemplatesIds([i]);return await this.loyaltyService.remapTemplateGroupMatchIds(r[0].groups),r[0]};getLeaderboard=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"loyalty");let r=await this.loyaltyHttps.getLeaderboard(t,i,e);return r.data=await this.loyaltyService.addProfileModelToLeaderboad(r.data),r};getLeaderboardForGame=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"loyalty");let r=await this.loyaltyHttps.getLeaderboardForGame(t,i,e);return r.data=await this.loyaltyService.addProfileModelToLeaderboad(r.data),r};getOwnRankings=async(t,e)=>{let{id:i}=await this.profileFacade.getOwn();return this.getUserRankings(i,t,e)};getUserRankings=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"rankings");let r=await this.loyaltyHttps.getUserRankings(t,e,i);return await this.getModelsForUserRankings(r)};getHighestSuccessRate=async(t,e)=>{t&&(t=new Sa(t),this.loyaltyValidator.validate(t,this.errorHandlingMode));let i=await this.loyaltyHttps.getHighestSuccessRate(t,e);return this.loyaltyService.addProfileModelToHighestSuccessRate(i)};getTemplateWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getTemplateById(t);return i.contestModel=r,this.loyaltyService.completeContestWinners(i)};getEntitiesFollows=async(t,e)=>{this.loyaltyService.validateEntitiesFollowsFilters(t),this.config.idSchema!=="native"&&(t=await this.loyaltyService.remapEntitiesFollowsFilters(t));let i=await this.loyaltyHttps.getEntitiesFollows(t,e);return await this.loyaltyService.addModelsToEntitiesFollows(i)};getModelsForUserRankings=async t=>{let e=null,i=null,r=null,[a,s,p]=this.loyaltyService.extractRankingsIdsMap(t.data);if(p.length&&(e=(await this.getTemplates()).data.filter(l=>p.includes(l.id))),a.length){let n={gameIds:a};i=(await this.topXFacade.getGames(n)).data}if(s.length){let n={gameIds:s};r=(await this.matchQuizFacade.getGames(n)).data}return this.loyaltyService.setModelsForUserRankings(i,r,e,t)};getTemplateMatches=async(t,e,i)=>{let r=await this.getTemplateById(t,i),a=[];if((!r.matchIds||r.matchIds.length===0)&&!r.groups||r.groups.length===0)return[];!e&&r.matchIds&&(a=Array.from(r.matchIds));let s=Array.from(r.groups.find(l=>l.groupId===e).filters.matchIds)||[];if(a=[...a,...s],!a.length)return[];let p=a.length;return(await this.football.getMatches({matchIds:a,limit:p},i)).data}};var Me=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new B(t),this.profileHttps=new Dt(t),this.loyaltyHttps=new wt(t),this.localCache=new V().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new Aa(t,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localCache)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getTemplates=async(t,e)=>await this.loyaltyFacade.getTemplates(t,e);getTemplateById=async(t,e)=>await this.loyaltyFacade.getTemplateById(t,e);getLeaderboard=async(t,e,i)=>await this.loyaltyFacade.getLeaderboard(t,e,i);getLeaderboardForGame=async(t,e,i)=>await this.loyaltyFacade.getLeaderboardForGame(t,e,i);getOwnRankings=async(t,e)=>await this.loyaltyFacade.getOwnRankings(t,e);getUserRankings=async(t,e,i)=>await this.loyaltyFacade.getUserRankings(t,e,i);getHighestSuccessRate=async(t,e)=>await this.loyaltyFacade.getHighestSuccessRate(t,e);getTemplateWinners=async(t,e)=>await this.loyaltyFacade.getTemplateWinners(t,e);getEntitiesFollows=async(t,e)=>await this.loyaltyFacade.getEntitiesFollows(t,e);getTemplateMatches=async(t,e,i)=>await this.loyaltyFacade.getTemplateMatches(t,e,i)};var Oa=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new F(t),this.topXFacade=new ye(t,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(t,e)=>await this.topXFacade.getGames(t,e);getGameById=async(t,e)=>await this.topXFacade.getGameById(t,e);getGamePredictions=async(t,e,i)=>await this.topXFacade.getGamePredictions(t,e,i);getGameResults=async(t,e,i)=>await this.topXFacade.getGameResults(t,e,i);getCurrentGameResults=async t=>await this.topXFacade.getCurrentGameResults(t);play=async t=>await this.topXFacade.play(t);delete=async t=>await this.topXFacade.delete(t);getMyGameEditions=async(t,e)=>await this.topXFacade.getMyGameEditions(t,e);getMyGamePrediction=async t=>await this.topXFacade.getMyGamePrediction(t);getUserGameEditions=async(t,e,i)=>await this.topXFacade.getUserGameEditions(t,e,i);getUserGamePrediction=async(t,e,i)=>await this.topXFacade.getUserGamePrediction(t,e,i);getMarketsResultsForGame=async(t,e)=>await this.topXFacade.getMarketsResultsForGame(t,e);getGameWinners=async(t,e)=>await this.topXFacade.getGameWinners(t,e)};var La=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new be(t)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async t=>await this.matchQuizFacade.play(t);delete=async t=>await this.matchQuizFacade.delete(t);getGames=async(t,e)=>await this.matchQuizFacade.getGames(t,e);getGameById=async(t,e)=>await this.matchQuizFacade.getGameById(t,e);getGamePredictions=async(t,e,i)=>await this.matchQuizFacade.getGamePredictions(t,e,i);getGameResults=async(t,e,i)=>await this.matchQuizFacade.getGameResults(t,e,i);getCurrentGameResults=async t=>await this.matchQuizFacade.getCurrentGameResults(t);getMyGameEditions=async(t,e)=>await this.matchQuizFacade.getMyGameEditions(t,e);getMyGamePrediction=async t=>await this.matchQuizFacade.getMyGamePrediction(t);getUserGameEditions=async(t,e,i)=>await this.matchQuizFacade.getUserGameEditions(t,e,i);getUserGamePrediction=async(t,e,i)=>await this.matchQuizFacade.getUserGamePrediction(t,e,i);getMarketsResultsForGame=async(t,e)=>await this.matchQuizFacade.getMarketsResultsForGame(t,e);getGameWinners=async(t,e)=>await this.matchQuizFacade.getGameWinners(t,e)};var Ye=class{action=null;context=new Zt;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var It=class{idSchema;idMapping;constructor(t){this.idSchema=t.idSchema,this.idMapping=new F(t)}remapTagsIds=async(t,e,i)=>{if(!t||!t.length)return t;let r={},a={},s=[];t.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],a[n.type]=[]),r[n.type].push(n.id),a[n.type].push(n)});let p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i);for(let[n,l]of Object.entries(a))l.forEach((c,d)=>{c.id=p[n][d],s.push(c)});return s}};var we=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var xa=class extends we{action=null;constructor(t){super(t),this.action=t.action?t.action:null}constructFilterUrl(){let t="";return this.action&&(t+="&",t+=`action=${this.action}`),this.page&&(t+="&",t+=`page=${this.page}`),this.limit&&(t+="&",t+=`limit=${this.limit}`),t}};var Da=class extends we{action=null;constructor(t){super(t),this.action=t.action?t.action:null}constructFilterUrl(){let t="";return this.action&&(t+="&",t+=`action=${this.action}`),this.page&&(t+="&",t+=`page=${this.page}`),this.limit&&(t+="&",t+=`limit=${this.limit}`),t}};var Ba=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new ee(t),this.activityService=new It(t)}add=async(t,e,i,r)=>{if(this.idSchema!="native"){let s=JSON.parse(JSON.stringify(e)),p=await this.activityService.remapTagsIds(e,this.idSchema,"native"),n=new Ye(t,p,i,r),l=await this.activityHttps.createActivity(n);return l.context.tags=s,l}let a=new Ye(t,e,i,r);return this.activityHttps.createActivity(a)};delete=async t=>await this.activityHttps.deleteActivity(t);like=async(t,e,i)=>{let r="like";return await this.add(r,t,e,i)};dislike=async(t,e,i)=>{let r="dislike";return await this.add(r,t,e,i)};addPageview=async(t,e,i)=>{let r="page_view";return await this.add(r,t,e,i)};addContentConsumed=async(t,e,i)=>{let r="content_consumed";return await this.add(r,t,e,i)};addShare=async(t,e,i)=>{let r="share";return await this.add(r,t,e,i)};addComment=async(t,e,i)=>{let r="comment";return await this.add(r,t,e,i)};addClickAd=async(t,e,i)=>{let r="click_ad";return await this.add(r,t,e,i)};addConversion=async(t,e,i)=>{let r="conversion";return await this.add(r,t,e,i)};getOwn=async(t,e)=>{if(e=e||!1,t&&(t=new xa(t)),this.idSchema!="native"){let i=await this.activityHttps.getOwnActivities(t,e);for(let r of i.data)await this.activityService.remapTagsIds(r.context.tags,"native",this.idSchema);return i}return await this.activityHttps.getOwnActivities(t,e)};getForUser=async(t,e,i)=>{if(i=i||!1,e&&(e=new Da(e)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(t,e,i),a=JSON.parse(JSON.stringify(r));for(let s of a.data)await this.activityService.remapTagsIds([...s.context.tags],"native",this.idSchema);return a}return await this.activityHttps.getActivitiesForUser(t,e,i)}};var Na=class{activityFacade;constructor(t){this.activityFacade=new Ba(t)}add=async(t,e,i,r)=>await this.activityFacade.add(t,e,i,r);delete=async t=>await this.activityFacade.delete(t);like=async(t,e,i)=>await this.activityFacade.like(t,e,i);dislike=async(t,e,i)=>await this.activityFacade.dislike(t,e,i);addPageview=async(t,e,i)=>await this.activityFacade.addPageview(t,e,i);addContentConsumed=async(t,e,i)=>await this.activityFacade.addContentConsumed(t,e,i);addShare=async(t,e,i)=>await this.activityFacade.addShare(t,e,i);addComment=async(t,e,i)=>await this.activityFacade.addComment(t,e,i);addClickAd=async(t,e,i)=>await this.activityFacade.addClickAd(t,e,i);addConversion=async(t,e,i)=>await this.activityFacade.addConversion(t,e,i);getOwn=async(t,e)=>await this.activityFacade.getOwn(t,e);getForUser=async(t,e,i)=>await this.activityFacade.getForUser(t,e,i)};var Ie=class{id=null;title=null;description=null;type=null;images=new at;participationCount=null;questionsCount=null;status=null;flags=null;customFields=null;labels=null;time=null;averageScore=null;perfectScore=null;adContent=null;context=null;createdAt=null;updatedAt=null};var Ua=class extends Ie{rules=null;questions=[]};var Ha=class{questionId=null;question=null;images=null;options=[]};var ka=class{optionId=null;option=null;images=null};var Ga=class{classicQuizId=null;userId=null;questions=[];correctOptions=null};var Va=class{questionId=null;optionId=null;correct=null;correctOptionId=null};var $a=class{classicQuizId=null;correct=null;classicQuizQuestions=null};var Pe=class{content=null;tags=[];campaign=null};var Te=class{id=null;model=null;source=null;type=null};var Wa=class{remapClassicQuizzes=t=>(t.meta.pagination=this.remapMetaPagination(t.meta.pagination),t.data=t.data.map(e=>this.remapBasicClassicQuiz(e)),t);remapClassicQuizById=t=>{let e=new Ua;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.participationCount=t.participation_count,e.questionsCount=t.questions_count,e.status=t.status,e.flags=t.flags,e.adContent=t.ad_content,e.rules=t.rules,e.customFields=t.custom_fields,e.labels=t.labels,e.time=t.time,e.context=t.context?this.remapContext(t.context):t.context,e.averageScore=t.average_score,e.perfectScore=t.perfect_score,e.questions=t.questions.map(i=>this.remapQuestions(i)),e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapClassicQuizParticipation=t=>{let e=new Ga;return e.classicQuizId=t.classic_quiz_id,e.userId=t.user_id,e.questions=t.questions?t.questions.map(i=>this.remapParticipationQuestions(i)):null,e.correctOptions=t.correct_options,e};remapClassicQuizParticipationBody=t=>t.map(e=>({question_id:e.questionId,option_id:e.optionId}));remapUserClassicQuizParticipations=t=>t.map(e=>{let i=new $a;return i.classicQuizId=e.classic_quiz_id,i.correct=e.correct,i.classicQuizQuestions=e.classic_quiz_questions,i});remapMetaPagination=t=>{let e=new dt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapBasicClassicQuiz=t=>{let e=new Ie;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.participationCount=t.participation_count,e.questionsCount=t.questions_count,e.status=t.status,e.flags=t.flags,e.customFields=t.custom_fields,e.labels=t.labels,e.time=t.time,e.averageScore=t.average_score,e.perfectScore=t.perfect_score,e.context=t.context?this.remapContext(t.context):t.context,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapQuestions=t=>{let e=new Ha;return e.questionId=t.question_id,e.question=t.question,e.images=t.images,e.options=t.options.map(i=>this.remapOptions(i)),e};remapOptions=t=>{let e=new ka;return e.optionId=t.option_id,e.option=t.option,e.images=t.images,e};remapParticipationQuestions=t=>{let e=new Va;return e.questionId=t.question_id,e.optionId=t.option_id,e.correct=t.correct,e.correctOptionId=t.correct_option_id,e};remapContext=t=>{let e=new Pe;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Te;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var ve=class{id="";title="";description="";images=new at;flags=[];status="";winningCondition="";lives=0;time=0;points=[];customFields=null;labels=null;adContent="";context=null;type="";createdAt="";updatedAt=""};var Ka=class extends ve{rules=""};var ja=class{correctSteps=0;score=0};var qa=class{eitherOrId="";personalBest=0};var za=class{instanceId="";eitherOrId="";gameStartedAt="";currentStep=0;currentStreak=0;remainingSteps=0;currentLives=0;currentPoints=0;personalBest=0;steps=[]};var Qa=class{main;mobile};var Je=class{id="";label="";images=new Qa;value=null};var Xa=class{pairId="";userSelection="";correct=null;played=null;timestamp="";optionOne=new Je;optionTwo=new Je};var Ya=class{rangeStartInclusive=0;rangeEndInclusive=0;totalUsers=0};var Ja=class{standings=[];breakdown=[]};var Za=class{userId="";userModel=null;personalBest=""};var to=class{remapEitherOrs=t=>(t.meta.pagination=this.remapMetaPagination(t.meta.pagination),t.data=t.data.map(e=>this.remapBasicEitherOr(e)),t);remapEitherOrById=t=>{let e=new Ka;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.winningCondition=t.winning_condition,e.lives=t.lives,e.flags=t.flags,e.customFields=t.custom_fields,e.labels=t.labels,e.time=t.time,e.context=t.context?this.remapContext(t.context):t.context,e.points=t.points?t.points.map(i=>this.remapPoints(i)):t.points,e.rules=t.rules,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapEitherOrOwnStats=t=>{let e=new qa;return e.eitherOrId=t.either_or_id,e.personalBest=t.personal_best,e};remapEitherOrResults=t=>{let e=new Ja;return e.standings=t.standings?t.standings.map(i=>this.remapResultsStandings(i)):t.standings,e.breakdown=t.breakdown?t.breakdown.map(i=>this.remapResultsBreakdown(i)):t.breakdown,e};remapEitherOrParticipation=t=>{let e=new za;return e.instanceId=t.instance_id,e.eitherOrId=t.either_or_id,e.gameStartedAt=t.game_started_at,e.currentStep=t.current_step,e.currentStreak=t.current_streak,e.remainingSteps=t.remaining_steps,e.currentLives=t.current_lives,e.currentPoints=t.current_points,e.personalBest=t.personal_best,e.steps=t.steps?t.steps.map(i=>this.remapParticipationSteps(i)):t.steps,e};remapBasicEitherOr=t=>{let e=new ve;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.winningCondition=t.winning_condition,e.lives=t.lives,e.flags=t.flags,e.customFields=t.custom_fields,e.labels=t.labels,e.adContent=t.ad_content,e.context=t.context?this.remapContext(t.context):t.context,e.time=t.time,e.points=t.points?t.points.map(i=>this.remapPoints(i)):t.points,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMetaPagination=t=>{let e=new dt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapPoints=t=>{let e=new ja;return e.correctSteps=t.correct_steps,e.score=t.score,e};remapResultsStandings=t=>{let e=new Za;return e.userId=t.user_id,e.personalBest=t.personal_best,e};remapResultsBreakdown=t=>{let e=new Ya;return e.rangeStartInclusive=t.range_start_inclusive,e.rangeEndInclusive=t.range_end_inclusive,e.totalUsers=t.total_users,e};remapParticipationSteps=t=>{let e=new Xa;return e.pairId=t.pair_id,e.userSelection=t.user_selection,e.correct=t.correct,e.played=t.played,e.timestamp=t.timestamp,e.optionOne=t.option_one,e.optionTwo=t.option_two,e};remapContext=t=>{let e=new Pe;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Te;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var _e=class extends _{classicQuizRemapper=null;eitherOrRemapper=null;constructor(t){super(t,R(t.environment,"miniGames")),this.classicQuizRemapper=new Wa,this.eitherOrRemapper=new to}getClassicQuizzes=async(t,e)=>{let i=`/classic-quizzes${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=I(e)?M():"";let r="There was a problem with fetching classic quizzes",a=await this.fetchWithoutAuth(i,r);return this.classicQuizRemapper.remapClassicQuizzes(a)};getClassicQuizById=async(t,e)=>{let i=`/classic-quizzes/${t}${this.apiSignInUrl}`;I(e)&&(i+=M());let r="There was a problem with fetching classic quiz by ID",a=await this.fetchWithoutAuth(i,r);return this.classicQuizRemapper.remapClassicQuizById(a.data)};participateInClassicQuiz=async(t,e,i)=>{let r=`/classic-quizzes/${t}/participate${this.apiSignInUrl}`,a=`There was a problem with participating in the following classic quiz: ${t}`,s="POST",p={questions:this.classicQuizRemapper.remapClassicQuizParticipationBody(e),include_correct_options:!!i},n=await this.fetchWithAuth(r,a,s,p);return this.classicQuizRemapper.remapClassicQuizParticipation(n.data)};getMyClassicQuizParticipations=async t=>{let e=`/classic-quizzes/participations/${this.apiSignInUrl}&classic_quiz_ids=${t?t.join(","):""}`,i="There was a problem with fetching user's own Classic Quiz participations",r=await this.fetchWithAuth(e,i);return this.classicQuizRemapper.remapUserClassicQuizParticipations(r.data)};getEitherOrs=async(t,e)=>{let i=`/either-or${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=I(e)?M():"";let r="There was a problem with fetching list of Either/Ors",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrs(a)};getEitherOrById=async(t,e)=>{let i=`/either-or/${t}${this.apiSignInUrl}`;I(e)&&(i+=M());let r="There was a problem with fetching Either/Or by ID",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrById(a.data)};getMyEitherOrStats=async t=>{let e=`/either-or/${t}/own-stats${this.apiSignInUrl}`,i="There was a problem with fetching Either/Or own statistics",r=await this.fetchWithAuth(e,i);return this.eitherOrRemapper.remapEitherOrOwnStats(r.data)};getEitherOrResults=async(t,e)=>{let i=`/either-or/${t}/results${this.apiSignInUrl}${I(e)?M():""}`,r="There was a problem with fetching Either/Or results",a=await this.fetchWithAuth(i,r);return this.eitherOrRemapper.remapEitherOrResults(a.data)};participateInEitherOr=async(t,e)=>{let i=`/either-or/${t}/participate${this.apiSignInUrl}`,r="There was a problem with participating in Either/Or",a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.eitherOrRemapper.remapEitherOrParticipation(s.data)}};var Fe=class extends L{flags=null;status=null;entityIds=null;entityType=null;constructor(t){super(t),this.flags=t&&t.flags?t.flags:null,this.status=t&&t.status?t.status:null,this.entityIds=t&&t.entityIds?t.entityIds:null,this.entityType=t&&t.entityType?t.entityType:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.flags&&(t+=`&flags=${this.flags.join(",")}`),this.status&&(t+=`&status=${this.status}`),this.entityIds&&(t+=`&entity_ids=${this.entityIds}`),t}};var eo=class extends Fe{classicQuizIds=null;constructor(t){super(t),this.classicQuizIds=t&&t.classicQuizIds?t.classicQuizIds:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.classicQuizIds&&(t+=`&classic_quiz_ids=${this.classicQuizIds.join(",")}`),t}};var io=class extends Fe{eitherOrIds=null;constructor(t){super(t),this.eitherOrIds=t&&t.eitherOrIds?t.eitherOrIds:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.eitherOrIds&&(t+=`&either_or_ids=${this.eitherOrIds.join(",")}`),t}};var ro=class{pair="";answer=""};var ao=class extends ro{expired=!1;time=0};var oo=class{errorHandlingModel=null;entityTypes=["competition","team","player"];constructor(t){this.errorHandlingModel=t.errorHandlingMode}validateFilters=t=>{!t.entityIds&&!t.entityType||(t.entityIds&&!t.entityType&&this.throwException(400,"invalid_filters","You need to use both 'entityIds' and 'entityType' filters together"),!t.entityIds&&t.entityType&&this.throwException(400,"invalid_filters","You need to use both 'entityIds' and 'entityType' filters together"),this.entityTypes.includes(t.entityType)||this.throwException(400,"invalid_filters","Invalid 'entityType' filter. Please use one of the following valid options: competition, team, or player"))};throwException=(t,e,i)=>{throw this.errorHandlingModel==="standard"?new u(t,e,i):new w(t,e,i)}};var so=class{idSchema=null;idMapping=null;validator=null;https=null;entityTypes=["competition","team","player"];profile=null;football=null;eitherOrTime=0;participationStartTimestamp=0;countdownTimer=0;intervalId=null;currentPairId="";constructor(t){this.idSchema=t.idSchema,this.idMapping=new F(t),this.validator=new oo(t),this.profile=new C(t),this.football=new et(t),this.https=new _e(t)}finalizeMiniGamesFilters=async t=>{if(this.validator.validateFilters(t),this.idSchema!=="native"&&t.entityIds&&t.entityIds.length>0){this.validator.validateFilters(t);let e=await this.idMapping.getEntityIdsBySchemaId(Array.from(t.entityIds),t.entityType,"native");t.entityIds=e[t.entityType]}};setProfileModelsForEitherOrStandings=async t=>{let e=t.standings.map(r=>r.userId);if(!e.length)return t;let i=await this.profile.getByIds(e);return t.standings.forEach(r=>r.userModel=i.find(a=>a.id===r.userId)||null),t};defaultEitherOrParticipation=async(t,e)=>{if(!this.eitherOrTime&&!e){let a=await this.https.getEitherOrById(t,!0);this.eitherOrTime=a.time;let s=await this.https.participateInEitherOr(t,null);return this.participationStartTimestamp=Date.now(),s}let i=0;if(this.participationStartTimestamp)i=(Date.now()-this.participationStartTimestamp)/1e3;else{if(!this.eitherOrTime){let a=await this.https.getEitherOrById(t,!0);this.eitherOrTime=a.time}i=this.eitherOrTime+1}let r=this.createNewParticipation(i,e);try{let a=await this.https.participateInEitherOr(t,r);return!a.currentLives||!a.remainingSteps?this.resetDefaultParticipationTimers():this.participationStartTimestamp=Date.now(),a}catch(a){throw this.resetDefaultParticipationTimers(),a}};handleEitherOrParticipationWithCallback=async(t,e,i)=>e?await this.eitherOrParticipationWithCallback(t,e,i):await this.initialEitherOrParticipationWithCallback(t,i);initialEitherOrParticipationWithCallback=async(t,e)=>{let i=await this.https.getEitherOrById(t,!0);this.eitherOrTime=i.time;let r=await this.https.participateInEitherOr(t,null);return this.participationStartTimestamp=Date.now(),this.countdownTimer=this.eitherOrTime,this.setCurrentPairId(r),await this.handleEitherOrParticipationCallbackInterface(t,e),r};eitherOrParticipationWithCallback=async(t,e,i)=>{this.intervalId&&clearInterval(this.intervalId);let r=0;if(this.participationStartTimestamp)r=(Date.now()-this.participationStartTimestamp)/1e3;else{if(!this.eitherOrTime){let s=await this.https.getEitherOrById(t,!0);this.eitherOrTime=s.time}r=this.eitherOrTime+1}let a=this.createNewParticipation(r,e);try{let s=await this.https.participateInEitherOr(t,a);return!s.currentLives||!s.remainingSteps?(this.resetCallbackParticipationTimers(),i.onElapsedResponse(s),clearInterval(this.intervalId)):(this.participationStartTimestamp=Date.now(),this.countdownTimer=this.eitherOrTime,this.setCurrentPairId(s),await this.handleEitherOrParticipationCallbackInterface(t,i)),s}catch(s){throw this.resetCallbackParticipationTimers(),clearInterval(this.intervalId),s}};setCurrentPairId=t=>{this.currentPairId=t.steps.find(e=>!e.played).pairId||""};handleEitherOrParticipationCallbackInterface=async(t,e)=>{this.intervalId=setInterval(async()=>{if(this.countdownTimer>0)this.countdownTimer--,e.onTimerTick(this.countdownTimer);else{clearInterval(this.intervalId);let i=(Date.now()-this.participationStartTimestamp)/1e3,r={pair:this.currentPairId,answer:this.currentPairId.split("_")[0]},a=this.createNewParticipation(i,r),s=await this.eitherOrParticipationWithCallback(t,a,e);e.onElapsedResponse(s)}},1e3)};createNewParticipation=(t,e)=>{let i=new ao;return i.expired=t>this.eitherOrTime,i.time=Number(t.toFixed(3)),i.pair=e.pair,i.answer=e.answer,i};resetCallbackParticipationTimers=()=>{this.resetDefaultParticipationTimers(),this.countdownTimer=0,this.currentPairId=""};resetDefaultParticipationTimers=()=>{this.eitherOrTime=0,this.participationStartTimestamp=0};setContextTagsModels=async t=>{let e={competitions:[],teams:[],players:[]};if(t.forEach(i=>{i.context&&i.context.tags&&i.context.tags.length>0&&(e.competitions=this.extractEntityIdsFromTags(i.context.tags,"competition"),e.teams=this.extractEntityIdsFromTags(i.context.tags,"team"),e.players=this.extractEntityIdsFromTags(i.context.tags,"player"))}),e.competitions.length){let i=await this.football.footballFacade.getCompetitionsMapWithNativeIds(e.competitions);this.setModelsForContextTags(t,i,"competition")}if(e.teams.length){let i=await this.football.footballFacade.getTeamsMapWithNativeIds(e.teams);this.setModelsForContextTags(t,i,"team")}if(e.players.length){let i=await this.football.footballFacade.getPlayersMapWithNativeIds(e.players);this.setModelsForContextTags(t,i,"player")}};extractEntityIdsFromTags=(t,e)=>t.filter(i=>i.type===e).map(i=>i.id);setModelsForContextTags=(t,e,i)=>{t.forEach(r=>{r.context.tags.forEach(a=>{a.type===i&&(a.model=e.get(a.id),a.id=a.model.id)})})}};var no=class{https=null;service=null;activityService=null;idSchema=null;constructor(t){this.https=new _e(t),this.service=new so(t),this.activityService=new It(t),this.idSchema=t.idSchema}getClassicQuizzes=async(t,e,i)=>{t&&(t=new eo(t),await this.service.finalizeMiniGamesFilters(t));let r=await this.https.getClassicQuizzes(t,i);if(e)await this.service.setContextTagsModels(r.data);else for(let a of r.data)await this.remapTags(a,"native",this.idSchema);return r};getClassicQuizById=async(t,e)=>{let i=await this.https.getClassicQuizById(t,e);return await this.service.setContextTagsModels([i]),i};participateInClassicQuiz=async(t,e,i)=>await this.https.participateInClassicQuiz(t,e,i);getMyClassicQuizParticipations=async t=>await this.https.getMyClassicQuizParticipations(t);getEitherOrs=async(t,e,i)=>{t&&(t=new io(t),await this.service.finalizeMiniGamesFilters(t));let r=await this.https.getEitherOrs(t,i);if(e)await this.service.setContextTagsModels(r.data);else for(let a of r.data)await this.remapTags(a,"native",this.idSchema);return r};getEitherOrById=async(t,e)=>{let i=await this.https.getEitherOrById(t,e);return await this.service.setContextTagsModels([i]),i};getMyEitherOrStats=async t=>await this.https.getMyEitherOrStats(t);getEitherOrResults=async(t,e)=>{let i=await this.https.getEitherOrResults(t,e);return await this.service.setProfileModelsForEitherOrStandings(i)};participateInEitherOr=async(t,e,i)=>i?await this.service.handleEitherOrParticipationWithCallback(t,e,i):await this.service.defaultEitherOrParticipation(t,e);remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var lo=class{facade=null;constructor(t){this.facade=new no(t)}getClassicQuizzes=async(t,e,i)=>await this.facade.getClassicQuizzes(t,e,i);getClassicQuizById=async(t,e)=>await this.facade.getClassicQuizById(t,e);participateInClassicQuiz=async(t,e,i)=>await this.facade.participateInClassicQuiz(t,e,i);getMyClassicQuizParticipations=async t=>await this.facade.getMyClassicQuizParticipations(t);getEitherOrs=async(t,e,i)=>await this.facade.getEitherOrs(t,e,i);getEitherOrById=async(t,e)=>await this.facade.getEitherOrById(t,e);getMyEitherOrStats=async t=>await this.facade.getMyEitherOrStats(t);getEitherOrResults=async(t,e)=>await this.facade.getEitherOrResults(t,e);participateInEitherOr=async(t,e,i)=>await this.facade.participateInEitherOr(t,e,i)};var po=class{id="";label="";discussionType="LEAGUE";moderationType="USER";postsCount=0;pinnedPosts=[];lastPostId="";context=null;createdAt="";updatedAt=""};var Pt=class{pagination={totalItems:0,nextPageStartsAfter:"",lastCommentCreateTimestamp:""}};var Ee=class{id="";userId="";discussionId="";content="";repliesCount=0;replyId="";reactions=[];reactionsCount=0;reports=[];reportsCount=0;versions=null;privatePost=!1;deleted=!1;deletedAt="";deletedBy="";moderated=!1;moderatedAt="";moderatedBy="";moderatedReason="";createdAt="";updatedAt=""};var co=class{meta=new Pt;data=[]};var mo=class{type="";userIds=[];reactionCount=0};var uo=class{updatedAt="";content=""};var ho=class{userId=null;reason="AD";reasonDetails=null};var go=class extends Ee{userModel=null};var fo=class{meta=new Pt;data=[]};var yo=class{meta=new G;data=[]};var Re=class{remapToDiscussions=t=>(t.meta=this.remapToMeta(t.meta),t.data=t.data.map(e=>this.remapToDiscussionById(e)),t);remapToDiscussionById=t=>{let e=new po;return e.id=t.id,e.label=t.label,e.discussionType=t.discussion_type,e.moderationType=t.moderation_type,e.postsCount=t.posts_count,e.pinnedPosts=t.pinned_posts,e.lastPostId=t.last_post_id,e.context=t.context,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostsForDiscussion=(t,e)=>{let i=new co,r=new fo;return i.meta=this.remapToPostMeta(t.meta),i.data=t.data.map(a=>this.remapToPostByIdBasic(a)),r.meta=this.remapToPostMeta(t.meta),r.data=t.data.map(a=>this.remapToPostByIdFull(a)),e==="basic"?i:r};remapToPosts=t=>{let e=new yo;return e.meta=this.remapToMeta(t.meta),e.data=t.data.map(i=>this.remapToPostByIdBasic(i)),e};remapToPostMeta=t=>{let e=new Pt;return e.pagination.totalItems=t.pagination.total_items,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.lastCommentCreateTimestamp=t.pagination.last_comment_create_timestamp,e};remapToMeta=t=>{let e=new G;return e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e};remapToPostByIdBasic=t=>{let e=new Ee;return e.id=t.id,e.userId=t.user_id,e.discussionId=t.discussion_id,e.content=t.content,e.reactionsCount=t.reactions_count,e.replyId=t.reply_id,e.reactions=t.reactions.length?t.reactions.map(i=>this.remapReactionsPost(i)):t.reactions,e.reactionsCount=t.reactions_count,e.reports=t.reports.length?t.reports.map(i=>this.remapReportPost(i)):t.reports,e.reportsCount=t.reports_count,e.versions=t.versions.length?t.versions.map(i=>this.remapVersionsPost(i)):t.versions,e.privatePost=t.private_post,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.moderated=t.moderated,e.moderatedAt=t.moderated_at,e.moderatedBy=t.moderated_by,e.moderatedReason=t.moderated_reason,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostByIdFull=t=>{let e=new go;return e.id=t.id,e.userId=t.user_id,e.discussionId=t.discussion_id,e.content=t.content,e.reactionsCount=t.reactions_count,e.replyId=t.reply_id,e.reactions=t.reactions.length?t.reactions.map(i=>this.remapReactionsPost(i)):t.reactions,e.reactionsCount=t.reactions_count,e.reports=t.reports.length?t.reports.map(i=>this.remapReportPost(i)):t.reports,e.reportsCount=t.reports_count,e.versions=t.versions.length?t.versions.map(i=>this.remapVersionsPost(i)):t.versions,e.privatePost=t.private_post,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.moderated=t.moderated,e.moderatedAt=t.moderated_at,e.moderatedBy=t.moderated_by,e.moderatedReason=t.moderated_reason,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapReactionsPost=t=>{let e=new mo;return e.type=t.type,e.userIds=t.user_ids,e.reactionCount=t.reaction_count,e};remapVersionsPost=t=>{let e=new uo;return e.content=t.content,e.updatedAt=t.updated_at,e};remapReportPost=t=>{let e=new ho;return e.userId=t.user_id,e.reason=t.reason,e.reasonDetails=t.reason_details,e}};var bo=class extends _{remapper=null;constructor(t){super(t,R(t.environment,"discussions")),this.remapper=new Re}getAll=async(t,e)=>{let i="/discussions"+this.apiSignInUrl;t&&(i+=`${t.constructMainFiltersUrl()}`),I(e)&&(i+=M());let r="There was a problem getting discussions",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToDiscussions(a)};getById=async t=>{let e=`/discussions/${t}`+this.apiSignInUrl,i="There was a problem getting discussion",r=await this.fetchWithoutAuth(e,i);return this.remapper.remapToDiscussionById(r.data)};createPost=async(t,e)=>{let i=`/discussions/${t}/posts`+this.apiSignInUrl,r="There was a problem creating post in discussion",a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.remapper.remapToPostByIdBasic(s.data)};getPostById=async t=>{let e=`/posts/${t}`+this.apiSignInUrl,i="There was a problem getting post by ID in discussion",r=await this.fetchWithoutAuth(e,i);return this.remapper.remapToPostByIdFull(r.data)};updatePost=async(t,e)=>{let i=`/posts/${t}`+this.apiSignInUrl,r="There was a problem editing post in discussion",a="PUT",s={content:e},p=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapToPostByIdBasic(p.data)};reactToPost=async(t,e)=>{let i=`/posts/${t}/reaction`+this.apiSignInUrl,r="There was a problem reacting to post in discussion",a="PUT",s={reaction:e.toLocaleLowerCase()},p=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapToPostByIdBasic(p.data)};deletePost=async t=>{let e=`/posts/${t}`+this.apiSignInUrl,i="There was a problem deleting post in discussion",r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getPosts=async(t,e)=>{let i=`/discussions/${t}/posts`+this.apiSignInUrl;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem getting posts in discussion",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostsForDiscussion(a,"full")};getPostReplies=async(t,e)=>{let i=`/posts/${t}/replies`+this.apiSignInUrl;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem getting post's replies in discussion",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostsForDiscussion(a,"full")};reportPost=async(t,e,i)=>{let r=`/posts/${t}/report`+this.apiSignInUrl,a="There was a problem reporting post in discussion",s="POST",p={reason:e.toLocaleUpperCase(),reason_details:i||null},n=await this.fetchWithAuth(r,a,s,p);return this.remapper.remapToPostByIdBasic(n.data)};getOwnPosts=async t=>{let e="/posts"+this.apiSignInUrl;t&&(e+=`${t.constructMainFiltersUrl()}`);let i="There was a problem getting own posts",r=await this.fetchWithAuth(e,i);return this.remapper.remapToPosts(r)};getUserPosts=async(t,e,i)=>{let r=`/posts/users/${t}`+this.apiSignInUrl;e&&(r+=`${e.constructMainFiltersUrl()}`),I(i)&&(r+=M());let a="There was a problem getting user's posts",s=await this.fetchWithoutAuth(r,a);return this.remapper.remapToPosts(s)}};var Mo=class{content="";reply_id="";context=null};var wo=class{createRequestBodyFromParam=t=>{let e=new Mo;return e.content=t.content,e.reply_id=t.replyId,e.context=t.context,e}};var Io=class extends L{discussionIds;label;fromDate;toDate;fromCount;toCount;sort;constructor(t){super(t),this.discussionIds=t&&t.discussionIds?t.discussionIds:null,this.label=t&&t.label?t.label:null,this.fromDate=t&&t.fromDate?t.fromDate:null,this.toDate=t&&t.toDate?t.toDate:null,this.fromCount=t&&t.fromCount?t.fromCount:null,this.toCount=t&&t.toCount?t.toCount:null,this.sort=t&&t.sort?t.sort:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.discussionIds!==null&&(t+=`&discussion_ids=${this.discussionIds.join(",")}`),this.label!==null&&(t+=`&label=${this.label}`),this.fromDate!==null&&(t+=`&from_date=${this.fromDate}`),this.toDate!==null&&(t+=`&to_date=${this.toDate}`),this.fromCount!==null&&(t+=`&from_count=${this.fromCount}`),this.toCount!==null&&(t+=`&to_count=${this.toCount}`),this.sort&&(t+=`&sort=${this.sort}`),t}};var At=class extends L{skipDeleted;sort;constructor(t){super(t),this.skipDeleted=t&&t.skipDeleted!==void 0?t.skipDeleted:null,this.sort=t&&t.sort?t.sort.toLocaleLowerCase():null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.skipDeleted!==null&&(t+=`&skip_deleted=${this.skipDeleted}`),this.sort&&(t+=`&sort=${this.sort}`),t}};var Tt=class{profile=null;constructor(t){this.profile=new C(t)}finalizePostFullModel=async t=>{let e=t.map(r=>r.userId),i=await this.profile.getByIds(e);return t.map(r=>(r.userModel=this.extractModelById(i,r.userId),r))};extractModelById=(t,e)=>{if(t.length){let i=t.find(r=>r.id===e);return i?(delete i.interests,i):null}return null}};var Po=class{idSchema=null;https=null;clientHttps=null;activityService=null;service=null;factory=null;constructor(t){this.idSchema=t.idSchema,this.https=new bo(t),this.clientHttps=new B(t),this.activityService=new It(t),this.service=new Tt(t),this.factory=new wo}getAll=async(t,e)=>{t&&(t=new Io(t));let i=await this.https.getAll(t,e);for(let r of i.data)await this.remapTags(r,"native",this.idSchema);return i};getById=async t=>{let e=await this.https.getById(t);return await this.remapTags(e,"native",this.idSchema),e};createPost=async(t,e)=>{let i=JSON.parse(JSON.stringify(e));await this.remapTags(i,this.idSchema,"native");let r=this.factory.createRequestBodyFromParam(i);return await this.https.createPost(t,r)};getPostById=async t=>{let e=await this.https.getPostById(t);return(await this.service.finalizePostFullModel([e]))[0]};updatePost=async(t,e)=>await this.https.updatePost(t,e);deletePost=async t=>await this.https.deletePost(t);getPosts=async(t,e)=>{e&&(e=new At(e));let i=await this.https.getPosts(t,e);return i.data=await this.service.finalizePostFullModel(i.data),i};getPostReplies=async(t,e)=>{e&&(e=new At(e));let i=await this.https.getPostReplies(t,e);return i.data=await this.service.finalizePostFullModel(i.data),i};reactToPost=async(t,e)=>await this.https.reactToPost(t,e);reportPost=async(t,e,i)=>await this.https.reportPost(t,e,i);getOwnPosts=async t=>(t&&(t=new At(t)),await this.https.getOwnPosts(t));getUserPosts=async(t,e,i)=>(e&&(e=new At(e)),await this.https.getUserPosts(t,e,i));getConfig=async()=>await this.clientHttps.getConfig("discussions");remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var To=class{facade=null;constructor(t){this.facade=new Po(t)}getAll=async(t,e)=>await this.facade.getAll(t,e);getById=async t=>await this.facade.getById(t);createPost=async(t,e)=>await this.facade.createPost(t,e);getPostById=async t=>await this.facade.getPostById(t);updatePost=async(t,e)=>await this.facade.updatePost(t,e);deletePost=async t=>await this.facade.deletePost(t);getPosts=async(t,e)=>await this.facade.getPosts(t,e);getPostReplies=async(t,e)=>await this.facade.getPostReplies(t,e);react=async(t,e)=>await this.facade.reactToPost(t,e);reportPost=async(t,e,i)=>await this.facade.reportPost(t,e,i);getOwnPosts=async t=>await this.facade.getOwnPosts(t);getUserPosts=async(t,e,i)=>await this.facade.getUserPosts(t,e,i);getConfig=async()=>await this.facade.getConfig()};var vo=class{profileId="";profileModel=null;challengeId="";challengeModel=null;message=""};var _o=class{profileId="";profileModel=null;leagueId="";leagueModel=null;message=""};var Fo=class{id="";name="";description="";type="";members=[];banned=[];invites=[];administrators=[];invitationCode="";templateId="";templateModel=null;pastTemplates=[];usersCanInviteUsers=!1;scoringStartsAt="";pinnedPosts=[]};var Eo=class{predictionId=null;predictionModel=null;profileId=null;profileModel=null};var Ro=class{remapToPrivateLeagues=t=>(t.meta=this.remapMetaPrivateLeagues(t.meta.pagination),t.data=t.data.map(e=>this.remapToPrivateLeagueById(e)),t);remapMetaPrivateLeagues=t=>{let e=new G;return e.pagination.itemsPerPage=t.items_per_page,e.pagination.nextPageStartsAfter=t.next_page_starts_after,e};remapToPrivateLeagueById=t=>{let e=new Fo;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.members=t.members,e.administrators=t.administrators,e.banned=t.banned,e.invites=t.invites,e.usersCanInviteUsers=t.users_can_invite_users,e.invitationCode=t.invitation_code,e.templateId=t.template_id,e.pastTemplates=t.past_templates,e.pinnedPosts=t.pinned_posts,e.scoringStartsAt=t.scoring_starts_at,e};remapToAcceptPrivateLeague=t=>{let e=new _o;return e.profileId=t.profile_id,e.leagueId=t.league_id,e.message=t.message,e};remapToAcceptChallenge=t=>{let e=new vo;return e.profileId=t.profile_id,e.challengeId=t.league_id,e.message=t.message,e};remapPredictions=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapPredictionsData(t.data),t);remapMeta=t=>{let e=new W;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.numberOfPages=t.pagination.number_of_pages,e.pagination.totalItems=t.pagination.total_items,e};remapPredictionsData=t=>t.map(e=>{let i=new Eo;return i.predictionId=e.prediction_id,i.profileId=e.profile_id,i})};var Se=class extends _{remapper=null;discussionsRemapper=null;discussionsBaseURL=null;constructor(t){super(t,R(t.environment,"privateLeagues")),this.discussionsBaseURL=R(t.environment,"discussions"),this.remapper=new Ro,this.discussionsRemapper=new Re}create=async(t,e)=>{let i="/leagues"+this.apiSignInUrl,a=`There was a problem ${e==="PRIVATE_LEAGUE"?"creating private league":"issuing challenge"}`,s="POST",p=await this.fetchWithAuth(i,a,s,t);return this.remapper.remapToPrivateLeagueById(p.data)};update=async(t,e,i)=>{let r=`/leagues/${t}`+this.apiSignInUrl,s=`There was a problem updating ${i==="PRIVATE_LEAGUE"?"private league":"challenge"}`,p="PUT",n=await this.fetchWithAuth(r,s,p,e);return this.remapper.remapToPrivateLeagueById(n.data)};updateLeagueTemplate=async(t,e,i,r)=>{let a=`/leagues/${t}/template`+this.apiSignInUrl,p=`There was a problem updating template for the ${r==="PRIVATE_LEAGUE"?"private league":"challenge"}`,n="POST",l={new_template_id:e,past_template_name:i},c=await this.fetchWithAuth(a,p,n,l);return this.remapper.remapToPrivateLeagueById(c.data)};getById=async(t,e,i)=>{let r=`/leagues/${t}`+this.apiSignInUrl;I(i)&&(r+=M());let s=`There was a problem getting ${e==="PRIVATE_LEAGUE"?"private league":"challenge"}`,p=await this.fetchWithAuth(r,s);return this.remapper.remapToPrivateLeagueById(p.data)};delete=async(t,e)=>{let i=`/leagues/${t}`+this.apiSignInUrl,a=`There was a problem deleting ${e==="PRIVATE_LEAGUE"?"private league":"challenge"}`,s="DELETE";return await this.fetchWithAuth(i,a,s),!0};invite=async(t,e)=>{let i=`/membership/invite/${t}`+this.apiSignInUrl,r=`There was a problem inviting the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};deleteInvitation=async(t,e)=>{let i=`/membership/invite/${t}`+this.apiSignInUrl,r=`There was a problem deleting invitation for the following users: ${e.join(",")}`,a="DELETE",s={profiles:e};return await this.fetchWithAuth(i,r,a,s),!0};accept=async(t,e,i)=>{let r=`/membership/accept/${t}`+this.apiSignInUrl+`&accept=${e?"ACCEPT":"REJECT"}`,s=`There was a problem ${e?"accepting":"rejecting"} invitation for ${i==="PRIVATE_LEAGUE"?"private league":"challenge"}: ${t}`,p="POST",n=await this.fetchWithAuth(r,s,p);return i==="PRIVATE_LEAGUE"?this.remapper.remapToAcceptPrivateLeague(n.data):this.remapper.remapToAcceptChallenge(n.data)};ban=async(t,e)=>{let i=`/membership/ban/${t}`+this.apiSignInUrl,r=`There was a problem banning the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};unban=async(t,e)=>{let i=`/membership/unban/${t}`+this.apiSignInUrl,r=`There was a problem unbanning the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};join=async t=>{let e="/membership/join"+this.apiSignInUrl+`&invitation_code=${t}`,i="There was a problem joining league",r="POST",a=await this.fetchWithAuth(e,i,r);return this.remapper.remapToAcceptPrivateLeague(a.data)};leave=async(t,e)=>{let i=`/membership/leave/${t}`+this.apiSignInUrl,a=`There was a problem leaving the following ${e==="PRIVATE_LEAGUE"?"league":"challenge"}: ${t}`,s="POST";return(await this.fetchWithAuth(i,a,s)).data};getInvitations=async(t,e)=>{let i="/membership/invitations"+this.apiSignInUrl+e.constructMainFiltersUrl(),a=`There was a problem getting invitations for ${t==="PRIVATE_LEAGUE"?"leagues":"challenges"}`,s=await this.fetchWithAuth(i,a);return this.remapper.remapToPrivateLeagues(s)};getReportedPosts=async(t,e)=>{let i=`/discussions/${t}/posts/reported${this.apiSignInUrl}`,r=`There was a problem fetching posts for the following: ${t}`;e&&(i+=e.constructMainFiltersUrl());let a=await this.fetchWithAuthNewBaseURL(this.discussionsBaseURL,i,r);return this.discussionsRemapper.remapToPostsForDiscussion(a,"full")};getPredictions=async(t,e)=>{let i=`/leagues/${t}/predictions`+this.apiSignInUrl,r=`There was a problem getting predictions for private league: ${t}`;e&&(i+=e.constructFiltersUrl());let a=await this.fetchWithAuth(i,r);return this.remapper.remapPredictions(a)};moderatePost=async(t,e)=>{let i=`/posts/${t}/admin/moderate${this.apiSignInUrl}`,r=`There was a problem moderating the following post: ${t}`,a="POST",s={moderation_reason:e},p=await this.fetchWithAuthNewBaseURL(this.discussionsBaseURL,i,r,a,s);return this.discussionsRemapper.remapToPostByIdBasic(p.data)}};var Ce=class{name="";description="";invitation_code="";template_id="";users_can_invite_users=!1;administrators=[];scoring_starts_at=""};var So=class extends Ce{type="ONE_VS_ONE"};var Co=class extends Ce{type="PRIVATE"};var Ae=class{name="";description="";invitation_code="";template_id="";users_can_invite_users=!1;administrators=[];pinned_posts=[];scoring_starts_at=""};var Ao=class extends Ae{type="PRIVATE"};var Oo=class extends Ae{type="ONE_VS_ONE"};var Oe=class{createRequestBodyFromParam=(t,e)=>{let i=e==="PRIVATE"?new Co:new So;return i.name=t.name,i.description=t.description,i.invitation_code=t.invitationCode,i.template_id=t.templateId,i.users_can_invite_users=t.usersCanInviteUsers,t.administrators?i.administrators=t.administrators:delete i.administrators,t.scoringStartsAt?i.scoring_starts_at=t.scoringStartsAt:delete i.scoring_starts_at,i};createUpdateRequestBodyFromParam=(t,e)=>{let i=e==="PRIVATE"?new Ao:new Oo;return i.name=t.name,i.description=t.description,i.invitation_code=t.invitationCode,i.template_id=t.templateId,i.users_can_invite_users=t.usersCanInviteUsers,i.administrators=t.administrators,i.pinned_posts=t.pinnedPosts,i.scoring_starts_at=t.scoringStartsAt,i}};var Le=class extends L{type=null;constructor(t){super(t),this.type=t&&t.type?t.type:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.type&&(t+=`&type=${this.type}`),t}};var Lo=class{limit=null;page=null;leagueId=null;templateId=null;sortOrder=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.leagueId=t&&t.leagueId?t.leagueId:null,this.templateId=t&&t.templateId?t.templateId:null,this.sortOrder=t&&t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.leagueId&&(t+=`&league_id=${this.leagueId}`),this.templateId&&(t+=`&template_id=${this.templateId}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),t}};var xe=class extends L{reportsCount=null;constructor(t){super(t),this.reportsCount=t.reportsCount?t.reportsCount:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.reportsCount&&(t+=`&reports_count=${this.reportsCount}`),t}};var De=class{limit=null;page=null;profileIds=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.profileIds=t&&t.profileIds?t.leagueId:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.profileIds&&(t+=`&profile_ids=${this.profileIds.join(",")}`),t}};var Be=class{loyalty=null;profile=null;predictor=null;constructor(t){this.loyalty=new Me(t),this.profile=new C(t),this.predictor=new ue(t)}setTemplateModels=async t=>{let e=await this.loyalty.getTemplates();t.templateModel=e.data.find(i=>i.id===t.templateId),t.pastTemplates&&t.pastTemplates.length>0&&t.pastTemplates.forEach(i=>{i.model=e.data.find(r=>r.id===i.id)})};setTemplateModelsInLeagues=async t=>{let e=await this.loyalty.getTemplates();t.forEach(i=>{i.templateModel=e.data.find(r=>r.id===i.templateId),i.pastTemplates&&i.pastTemplates.length>0&&i.pastTemplates.forEach(r=>{r.model=e.data.find(a=>a.id===r.id)})})};setTemplateModelsFromLeagueModels=(t,e)=>{if(e==="PRIVATE_LEAGUE"){t.forEach(i=>{i.templateModel=i.templateId===i.privateLeagueModel.templateId?i.privateLeagueModel.templateModel:i.privateLeagueModel.pastTemplates.find(r=>r.id===i.templateId).model});return}t.forEach(i=>{i.templateModel=i.templateId===i.challengeModel.templateId?i.challengeModel.templateModel:i.challengeModel.pastTemplates.find(r=>r.id===i.templateId).model})};setProfileModel=async t=>{let e=await this.profile.getById(t.profileId).getInfo();t.profileModel=e};setModelsForPredictions=async t=>{if(t.data.length){let e=t.data.map(s=>s.profileId),i=t.data.map(s=>s.predictionId),r=await this.getProfileModels(e),a=await this.getPredictionModels(i);t.data.forEach(s=>{s.profileModel=r.find(p=>p.id===s.profileId),s.predictionModel=a.find(p=>p.id===s.predictionId)})}return t};getProfileModels=async t=>await this.profile.getByIds(t);getPredictionModels=async t=>await this.predictor.getPredictionsByIds(t)};var xo=class{factory=null;privateLeagueHttps=null;loyaltyHttps=null;profile=null;service=null;discussionsService=null;constructor(t){this.factory=new Oe,this.privateLeagueHttps=new Se(t),this.loyaltyHttps=new wt(t),this.profile=new C(t),this.service=new Be(t),this.discussionsService=new Tt(t)}create=async t=>{let e=this.factory.createRequestBodyFromParam(t,"PRIVATE"),i=await this.privateLeagueHttps.create(e,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(i),i};getById=async(t,e)=>{let i=await this.privateLeagueHttps.getById(t,"PRIVATE_LEAGUE",e);return await this.service.setTemplateModels(i),i};update=async(t,e)=>{let i=this.factory.createUpdateRequestBodyFromParam(e,"PRIVATE"),r=await this.privateLeagueHttps.update(t,i,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(r),r};updateTemplate=async(t,e,i)=>{let r=await this.privateLeagueHttps.updateLeagueTemplate(t,e,i,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(r),r};delete=async t=>await this.privateLeagueHttps.delete(t,"PRIVATE_LEAGUE");invite=async(t,e)=>await this.privateLeagueHttps.invite(t,e);deleteInvitation=async(t,e)=>await this.privateLeagueHttps.deleteInvitation(t,e);accept=async t=>{let i=await this.privateLeagueHttps.accept(t,!0,"PRIVATE_LEAGUE");return await this.finalizeAcceptModel(i,!0)};reject=async t=>{let i=await this.privateLeagueHttps.accept(t,!1,"PRIVATE_LEAGUE");return await this.finalizeAcceptModel(i,!1)};banUsers=async(t,e)=>await this.privateLeagueHttps.ban(t,e);unbanUsers=async(t,e)=>await this.privateLeagueHttps.unban(t,e);join=async t=>{let e=await this.privateLeagueHttps.join(t);return await this.finalizeAcceptModel(e,!0)};leave=async t=>await this.privateLeagueHttps.leave(t,"PRIVATE_LEAGUE");finalizeAcceptModel=async(t,e)=>{if(e){let i=await this.getById(t.leagueId);t.leagueModel=i}return await this.service.setProfileModel(t),t};getMyLeagues=async t=>{t&&(t=new Lo(t));let e=await this.profile.getOwn().getInfo(),i=await this.loyaltyHttps.getUserRankingsForPrivateLeagueAndChallenges(e.id,"PRIVATE_LEAGUE",t);for(let r of i.data){let a=await this.getById(r.privateLeagueId);r.privateLeagueModel=a}return this.service.setTemplateModelsFromLeagueModels(i.data,"PRIVATE_LEAGUE"),i};getInvitations=async t=>{t=new Le(t),t.type="PRIVATE";let e=await this.privateLeagueHttps.getInvitations("PRIVATE_LEAGUE",t);return await this.service.setTemplateModelsInLeagues(e.data),e};getReportedPosts=async(t,e)=>{e&&(e=new xe(e));let i=await this.privateLeagueHttps.getReportedPosts(t,e);return i.data=await this.discussionsService.finalizePostFullModel(i.data),i};getPredictions=async(t,e)=>{if(e){if(e.limit&&e.limit>20)throw new u(400,"invalid_limit","Invalid limit filter. The maximum limit is 20");e=new De(e)}let i=await this.privateLeagueHttps.getPredictions(t,e);return await this.service.setModelsForPredictions(i)};moderatePost=async(t,e)=>await this.privateLeagueHttps.moderatePost(t,e)};var Do=class{privateLeaguesFacade=null;constructor(t){this.privateLeaguesFacade=new xo(t)}create=async t=>await this.privateLeaguesFacade.create(t);update=async(t,e)=>await this.privateLeaguesFacade.update(t,e);updateTemplate=async(t,e,i)=>await this.privateLeaguesFacade.updateTemplate(t,e,i);delete=async t=>await this.privateLeaguesFacade.delete(t);getById=async(t,e)=>await this.privateLeaguesFacade.getById(t,e);invite=async(t,e)=>await this.privateLeaguesFacade.invite(t,e);deleteInvitation=async(t,e)=>await this.privateLeaguesFacade.deleteInvitation(t,e);accept=async t=>await this.privateLeaguesFacade.accept(t);reject=async t=>await this.privateLeaguesFacade.reject(t);banUsers=async(t,e)=>await this.privateLeaguesFacade.banUsers(t,e);unbanUsers=async(t,e)=>await this.privateLeaguesFacade.unbanUsers(t,e);join=async t=>await this.privateLeaguesFacade.join(t);leave=async t=>await this.privateLeaguesFacade.leave(t);getMyLeagues=async t=>await this.privateLeaguesFacade.getMyLeagues(t);getInvitations=async t=>await this.privateLeaguesFacade.getInvitations(t);getReportedPosts=async(t,e)=>await this.privateLeaguesFacade.getReportedPosts(t,e);getPredictions=async(t,e)=>await this.privateLeaguesFacade.getPredictions(t,e);moderatePost=async(t,e)=>await this.privateLeaguesFacade.moderatePost(t,e)};var Bo=class{limit=null;page=null;challengeId=null;templateId=null;sortOrder=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.challengeId=t&&t.challengeId?t.challengeId:null,this.templateId=t&&t.templateId?t.templateId:null,this.sortOrder=t&&t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.challengeId&&(t+=`&league_id=${this.challengeId}`),this.templateId&&(t+=`&template_id=${this.templateId}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),t}};var No=class{factory=null;https=null;loyaltyHttps=null;profile=null;service=null;discussionsService=null;constructor(t){this.factory=new Oe,this.https=new Se(t),this.service=new Be(t),this.loyaltyHttps=new wt(t),this.profile=new C(t),this.discussionsService=new Tt(t)}issue=async(t,e)=>{let i=this.factory.createRequestBodyFromParam(t,"ONE_VS_ONE"),r=await this.https.create(i,"CHALLENGE");await this.service.setTemplateModels(r);let a=await this.https.invite(r.id,[e]);return r.invites=[],r.invites.push(a[0]),r};update=async(t,e)=>{let i=this.factory.createUpdateRequestBodyFromParam(e,"ONE_VS_ONE"),r=await this.https.update(t,i,"CHALLENGE");return await this.service.setTemplateModels(r),r};updateTemplate=async(t,e,i)=>{let r=await this.https.updateLeagueTemplate(t,e,i,"CHALLENGE");return await this.service.setTemplateModels(r),r};delete=async t=>await this.https.delete(t,"CHALLENGE");getById=async(t,e)=>{let i=await this.https.getById(t,"CHALLENGE",e);return await this.service.setTemplateModels(i),i};accept=async t=>{let i=await this.https.accept(t,!0,"CHALLENGE");return await this.finalizeAcceptModel(i,!0)};reject=async t=>{let i=await this.https.accept(t,!1,"CHALLENGE");return await this.finalizeAcceptModel(i,!1)};leave=async t=>await this.https.leave(t,"CHALLENGE");finalizeAcceptModel=async(t,e)=>{if(e){let i=await this.getById(t.challengeId);t.challengeModel=i}return await this.service.setProfileModel(t),t};getMyChallenges=async t=>{t&&(t=new Bo(t));let e=await this.profile.getOwn().getInfo(),i=await this.loyaltyHttps.getUserRankingsForPrivateLeagueAndChallenges(e.id,"CHALLENGE",t);for(let r of i.data){let a=await this.getById(r.challengeId);r.challengeModel=a}return this.service.setTemplateModelsFromLeagueModels(i.data,"CHALLENGE"),i};getInvitations=async t=>{t=new Le(t),t.type="ONE_VS_ONE";let e=await this.https.getInvitations("CHALLENGE",t);return await this.service.setTemplateModelsInLeagues(e.data),e};getReportedPosts=async(t,e)=>{e&&(e=new xe(e));let i=await this.https.getReportedPosts(t,e);return i.data=await this.discussionsService.finalizePostFullModel(i.data),i};getPredictions=async(t,e)=>{if(e){if(e.limit&&e.limit>20)throw new u(400,"invalid_limit","Invalid limit filter. The maximum limit is 20");e=new De(e)}let i=await this.https.getPredictions(t,e);return await this.service.setModelsForPredictions(i)};moderatePost=async(t,e)=>await this.https.moderatePost(t,e)};var Uo=class{facade=null;constructor(t){this.facade=new No(t)}issue=async(t,e)=>await this.facade.issue(t,e);update=async(t,e)=>await this.facade.update(t,e);updateTemplate=async(t,e,i)=>await this.facade.updateTemplate(t,e,i);delete=async t=>await this.facade.delete(t);getById=async(t,e)=>await this.facade.getById(t,e);accept=async t=>await this.facade.accept(t);reject=async t=>await this.facade.reject(t);leave=async t=>await this.facade.leave(t);getMyChallenges=async t=>await this.facade.getMyChallenges(t);getInvitations=async t=>await this.facade.getInvitations(t);getReportedPosts=async(t,e)=>await this.facade.getReportedPosts(t,e);getPredictions=async(t,e)=>await this.facade.getPredictions(t,e);moderatePost=async(t,e)=>await this.facade.moderatePost(t,e)};var Jo=null,us=null;function j_(o){if(fn(o)){let t=yn(o);if(t.isValid)return Jo={profile:new C(o),football:new et(o),predictor:new ue(o),loyalty:new Me(o),topX:new Oa(o),matchQuiz:new La(o),activity:new Na(o),miniGames:new lo(o),discussions:new To(o),privateLeagues:new Do(o),challenges:new Uo(o)},us={...o},Jo;bn(t)}return Jo}var fn=o=>!Jo||JSON.stringify(o)!==JSON.stringify(us)||o.authProvider.getIdToken()!==us.authProvider.getIdToken(),yn=o=>{let e=new Lr().validate(o);return(e.idSchema.validation==="missing"||e.idSchema.validation==="invalid")&&(console.warn(e.idSchema.message.text),o.idSchema="native"),(e.environment.validation==="missing"||e.environment.validation==="invalid")&&(console.warn(e.environment.message.text),o.environment="prod"),(e.lang.validation==="missing"||e.lang.validation==="invalid")&&(console.warn(e.lang.message.text),o.lang="en"),(e.errorHandlingMode.validation==="missing"||e.errorHandlingMode.validation==="invalid")&&(console.warn(e.errorHandlingMode.message.text),o.errorHandlingMode="default"),e.authProvider.validation==="invalid"&&console.warn(e.authProvider.message.text),e},bn=o=>{let t="authProvider",e="isValid";Object.keys(o).forEach(i=>{let r=o[i];if(i!==e&&i!==t){if(r.message.type==="error")throw new Error(r.message.text)}else i!==e&&i===t&&Object.keys(new St).forEach(a=>{if(r[a].message.type==="error")throw new Error(r[a].message.text)})})};export{j_ as FansUnitedSDK};
|
|
3
|
+
${rs.PREDICTOR_USER_RELATED_OPERATION}`},Is=(o,t)=>`The prediction '${o}' is invalid for market '${t}'. Please check again have you passed appropriate prediction model. For more information please visit our documentation: https://docs.fansunitedmedia.com/sdks/js/match.quiz#gamerelatedoperations`,Wo=o=>`The market '${o}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Ps=o=>`The market '${o}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Ts=o=>`The field/s '${o.length>1?o.join(", "):o[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,vs=(o,t)=>`The following field/s is/are missing from ${o}: '${t.length>1?t.join(", "):t[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,_s=(o,t)=>`The field ${o} has incorrect type. The correct type is ${t}`;var Ft=class{data={error:{code:0,status:"",message:""}};status=0;statusText="";headers=null;constructor(t,e){this.data.error.code=e.code,this.data.error.status=e.status,this.data.error.message=e.message,this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}errorMessage=()=>this.data.error.message};var u=class{error={code:0,status:"",message:""};constructor(t,e,i){this.error.code=t,this.error.status=e,this.error.message=i}};var _=class{baseUrl=null;apiSignInUrl=null;jwtToken=null;idSchema=null;retryRequest=!1;headers=null;authHeaders=null;errorHandlingMode=null;constructor(t,e){this.baseUrl=e,this.apiSignInUrl=`?key=${t.apiKey}&client_id=${t.clientId}`,this.jwtToken=t.authProvider.getIdToken(),this.errorHandlingMode=t.errorHandlingMode,this.idSchema=t.idSchema,this.headers={"Content-Type":"application/json"},this.authHeaders={"Content-Type":"application/json",Authorization:`Bearer ${t.authProvider.getIdToken()}`}}fetchWithoutAuth=async(t,e)=>{let i=await fetch(this.baseUrl+t,{headers:this.headers}),r=await i.json();if(!i.ok){let a=this.transformFetchException(i,r);throw console.warn(e,a),a}return r};fetchWithAuth=async(t,e,i,r)=>{this.validateJWTToken();let a=null,s=null;if(i&&r?a=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders,body:JSON.stringify(r)}):i&&!r?a=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders}):a=await fetch(this.baseUrl+t,{headers:this.authHeaders}),i!=="DELETE"&&(s=await a.json()),!a.ok){(a.status===401||a.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuth(t,e,i,r)),this.retryRequest=!1;let p=this.transformFetchException(a,s||await a.json());throw console.warn(e,p),p}return this.retryRequest=!1,s};fetchWithAuthNewBaseURL=async(t,e,i,r,a)=>{this.validateJWTToken();let s=null,p=null;if(r&&a?s=await fetch(t+e,{method:r,headers:this.authHeaders,body:JSON.stringify(a)}):r&&!a?s=await fetch(t+e,{method:r,headers:this.authHeaders}):s=await fetch(t+e,{headers:this.authHeaders}),r!=="DELETE"&&(p=await s.json()),!s.ok){(s.status===401||s.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuthNewBaseURL(t,e,i,r,a)),this.retryRequest=!1;let n=this.transformFetchException(s,p||await s.json());throw console.warn(i,n),n}return this.retryRequest=!1,p};transformFetchException=(t,e)=>{if(!e&&t.status===401){if(this.errorHandlingMode==="standard")return new u(401,"unauthorized","Invalid JWT token is provided");let s={code:401,status:"unauthorized",message:"Invalid JWT token is provided"};return new Ft(t,s)}let{code:i,status:r,message:a}=e.error;return this.errorHandlingMode==="standard"?new u(i,r,a):new Ft(t,e.error)};validateJWTToken=()=>{let t=null;try{t=Ms(this.jwtToken)}catch(i){if(this.errorHandlingMode==="default"){let r={status:401,statusText:i.message,headers:{}},a={code:401,status:"invalid_token",message:"Invalid JWT token is provided"};throw new Ft(r,a)}else if(this.errorHandlingMode==="standard")throw new u(401,"invalid_token","Invalid JWT token is provided")}if(Date.now()>t.exp*1e3){if(this.errorHandlingMode==="default"){let i={status:401,statusText:"",headers:{}},r={code:401,status:"invalid_token",message:"The provided JWT token is expired"};throw new Ft(i,r)}else if(this.errorHandlingMode==="standard")throw new u(401,"invalid_token","The provided JWT token is expired")}}};var sn="/countries",U="/profile",Ko="/profiles",Dt=class extends _{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(t){super(t,R(t.environment,"profile")),this.lang=t.lang,this.profileRemapper=new ai,this.followingRemapper=new si,this.followersRemapper=new li}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${sn}${this.apiSignInUrl}${e}`,r=Date.now(),a="There was a problem fetching profile countries";return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,a)).data};getProfile=async t=>{let e=`${U}${this.apiSignInUrl}`,i="";if(t){e=`${Ko}/${t}${this.apiSignInUrl}`,i=`There was a problem fetching the following profile: ${t}`;let r=await this.fetchWithoutAuth(e,i);return this.profileRemapper.fullProfileFromResponse(r.data)}else{i="There was a problem fetching your profile from API";let r=await this.fetchWithAuth(e,i);return this.profileRemapper.fullProfileFromResponse(r.data)}};getProfiles=async(t,e,i)=>{let r=Date.now(),a=`There was a problem fetching the following profiles: ${t.join(",")}`;if(t&&t.length){if(t.length>this.limitIds){let c=[],d=xt(t,this.limitIds);for(let m of d){let y=`${Ko}${this.apiSignInUrl}&profile_ids=${m.join(",")}`;a=`There was a problem fetching the following profiles: ${m.join(",")}`,i&&(y+=`&disable_cache=${r}`);let h=await this.fetchWithoutAuth(y,a);c.push(...this.profileRemapper.profilesFromResponse(h.data))}return c}let n=`${Ko}${this.apiSignInUrl}&profile_ids=${t.join(",")}`;i&&(n+=`&disable_cache=${r}`);let l=await this.fetchWithoutAuth(n,a);return this.profileRemapper.profilesFromResponse(l.data)}let s=`${Ko}${this.apiSignInUrl}&search=${e}`;i&&(s+=`&disable_cache=${r}`);let p=await this.fetchWithoutAuth(s,a);return this.profileRemapper.profilesFromResponse(p.data)};getFollowers=async(t,e)=>{let i=`${U}/followers${this.apiSignInUrl}`,r="There was a problem fetching the followers for own profile";if(t&&!e){i=`${U}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`;let s=await this.fetchWithAuth(i,r);return this.followersRemapper.followersFromResponse(s)}else if(!t&&!e){let s=await this.fetchWithAuth(i,r);return this.followersRemapper.followersFromResponse(s)}t&&e?i=`${U}/${e}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${U}/${e}/followers${this.apiSignInUrl}`),r=`There was a problem fetching the followers for profile: ${e}`;let a=await this.fetchWithoutAuth(i,r);return this.followersRemapper.followersFromResponse(a)};getFollowing=async(t,e)=>{let i=`${U}/following${this.apiSignInUrl}`,r="There was a problem fetching the followers of own profile";if(t&&!e){i=`${U}/following${this.apiSignInUrl}${t.constructFilterUrl()}`;let s=await this.fetchWithAuth(i,r);return this.followingRemapper.followingFromResponse(s)}else if(!t&&!e){let s=await this.fetchWithAuth(i,r);return this.followingRemapper.followingFromResponse(s)}t&&e?i=`${U}/${e}/following${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${U}/${e}/following${this.apiSignInUrl}`),r=`There was a problem fetching the followers of the following profile: ${e}`;let a=await this.fetchWithoutAuth(i,r);return this.followingRemapper.followingFromResponse(a)};follow=async t=>{let e=new Ue;e.profile_ids=t;let i=U+`/follow${this.apiSignInUrl}`,r=`There was a problem with following profiles: ${t.join(",")}`,a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.followingRemapper.followResponse(s.data)};unfollow=async t=>{let e=new Ue;e.profile_ids=t;let i=U+`/follow${this.apiSignInUrl}`,r=`There was a problem with unfollowing profiles: ${t.join(",")}`,a="DELETE";return await this.fetchWithAuth(i,r,a,e),!0};getBadges=async t=>{let e=`${U}/badges${this.apiSignInUrl}`,i="There was a problem with fetching own badges";return t?(e=`${U}/${t}/badges${this.apiSignInUrl}`,i="There was a problem with fetching the badges",(await this.fetchWithoutAuth(e,i)).data):(await this.fetchWithAuth(e,i)).data};updateProfile=async t=>{let e=U+this.apiSignInUrl,i="There was a problem updating the own profile",r="PATCH",a=await this.fetchWithAuth(e,i,r,t);return this.profileRemapper.fullProfileFromResponse(a.data)}};var x=(a=>(a.NATIVE="native",a.ENETPULSE="enetpulse",a.SPORTRADAR="sportradar",a.SPORTAL_365="sportal365",a.API_FOOTBALL="api_football",a))(x||{});var pi={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},ci=class extends _{constructor(t){super(t,R(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${pi[t]}=${e}`,r=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(i,r)};getEntityByIdAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${pi[t]}=${e}`,a=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(r,a)};getEntityIdsByIdsAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${pi[t]}=${e.join(",")}`,a=`There was a problem with id mapping request for the following ids: ${e.join(",")}`;return await this.fetchWithoutAuth(r,a)};getEntitiesByIds=async(t,e,i)=>{e.sort((s,p)=>s.localeCompare(p));let r=es(e),a=[];for(let s of r){let p=`/football${this.apiSignInUrl}&input_provider=${i}&${pi[t]}=${s.join(",")}`,n=`There was a problem with id mapping request for the following ids :${s.join(",")}`,l=await this.fetchWithoutAuth(p,n);a=[...a,...l.data]}return a};getEntitiesByIdObjs=async(t,e)=>{let i=[],r={},a=[];Object.keys(t).forEach(l=>{i.push.apply(i,t[l])});let s=_t(i),p=es(s);for(let l of p){let c="";if(Object.keys(t).forEach(d=>{r[d]=[];let m=l.filter(y=>t[d].includes(y));m&&m.length>0&&(r[d]=m)}),Object.keys(r).forEach(d=>{r[d].length>0&&(r[d].sort((m,y)=>m.localeCompare(y)),c+="&",c+=`${pi[d]}=${r[d].join(",")}`)}),c&&c.length>0){let d=`/football${this.apiSignInUrl}&input_provider=${e||"native"}${c}`,m="There was a problem with id mapping request",y=await this.fetchWithoutAuth(d,m);a.push(y.data)}else a.push([])}return Array.prototype.concat.apply([],a)};getTopEntities=async()=>{let t=`/football/top${this.apiSignInUrl}`,e="There was a problem with top id mappings request";return(await this.fetchWithoutAuth(t,e)).data}};var ss="FansUnited",ns={football:{ids:[],countries:[],competitions:[],expirations:{ids:0}},profile:{info:{},statistics:{},badges:null,countries:[],expirations:{profile:0,statistics:0,badges:0}},client:{features:{},expirations:{features:0}}},He=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t}static getInstance(t){return He.instance||(He.instance=new He(t)),He.instance}clearData=()=>{this.setData(ns)};getEntityById=(t="",e="")=>this.getData().football.ids.find(i=>{let r=A[this.idSchema];return i&&`${i[r]}`===e&&i.resource===t});getEntity=(t,e,i)=>Array.isArray(t)?this.getData().football.ids.filter(r=>{let a=A[i];return r&&t.includes(`${r[a]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let a=A[i];return r&&`${r[a]}`===t&&r.resource===e});getEntityByNativeId=(t="",e="")=>this.getData().football.ids.find(i=>i&&`${i.id}`===e&&i.resource===t);checkForExistingIdObjs=(t,e)=>{let i=A[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),l=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=A[i],a=A[e],s={};return Object.keys(t).forEach(p=>{let n=t[p],l=[];this.getData().football.ids.forEach(c=>{n.forEach((d,m)=>{d===c[a]&&p===c.resource&&(l[m]=c[r])})}),s[p]=l}),s};addIdMapping=t=>{let e=this.getData();e.football.ids.push(t),this.setData(e)};addIdMappings=t=>{let e=this.getData(),i=e.football.ids;i=[...i,...t],e.football.ids=i,this.setData(e)};addTopIdMappings=t=>{let e=this.getData();if(e.football.ids.length){let i=JSON.parse(JSON.stringify(e.football.ids));i=i.filter(r=>r.resource!=="match"),t=t.filter(r=>r.resource==="match"),i=[...i,...t],e.football.ids=i}else e.football.ids=t;e.football.expirations.ids=Math.floor(Date.now()/1e3)+this.expirationFootballIdsTimeout,this.setData(e)};setOwnProfile=t=>{let e=this.getData();e.profile.info=t,e.profile.expirations.profile=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(e)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=t=>{let e=this.getData();e.profile.countries=t,this.setData(e)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=t=>{let e=this.getData();e.profile.statistics=t,e.profile.expirations.statistics=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(e)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=t=>{let e=this.getData();e.profile.badges=t,e.profile.expirations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(e)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=t=>{let e=this.getData();e.football.countries=t,this.setData(e)};getCompetitions=t=>{let e=this.getData();return t?t.competitionSearchFilter(e.football.competitions):e.football.competitions};setCompetitions=t=>{let e=this.getData(),i=[...e.football.competitions];i.push(...t),e.football.competitions=this.makeCompetitionsUnique(i),this.setData(e)};getCompetitionsLength=()=>{let{football:t}=this.getData();return t.competitions.length};getClientFeatures=()=>this.getData().client.features;setClientFeatures=t=>{let e=this.getData(),i=JSON.parse(JSON.stringify(t));e.client.expirations.features=Math.floor(Date.now()/1e3)+this.expirationClientFeaturesTimeout,e.client.features=i,this.setData(e)};deleteClientFeatures=()=>{let t=this.getData(),e=JSON.parse(JSON.stringify(t));e.client={features:{},expirations:{features:0}},this.setData(e)};getExpiration=(t,e)=>{this.initialNewSchema(t,"expirations");let i=this.getData();switch(e){case"profile":return i.profile.expirations.profile;case"statistics":return i.profile.expirations.statistics;case"badges":return i.profile.expirations.badges;case"features":return i.client.expirations.features;case"ids":return i.football.expirations.ids}};makeCompetitionsUnique=t=>{let e=new Set;return t.filter(i=>{let r=!e.has(i.id);return e.add(i.id),r})};getData=()=>(localStorage.getItem(ss)||this.setData(ns),JSON.parse(localStorage.getItem(ss)));setData=t=>{localStorage.setItem(ss,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(ns)}},ke=He;ii(ke,"instance");var Ws=rn($s());var b=class{profileTTL=600;clientTTL=14400;profileBadgesTTL=3600;idMappingsExpiration=0;idSchema="";constructor(t){}static getInstance(t){return b.instance||(b.instance=new b(t),b.nodeCache.options.useClones=!1),b.instance}clearData=()=>b.nodeCache.flushAll();getEntityById=(t,e)=>{let i=b.nodeCache.get("ids");return i?i.find(r=>{let a=A[this.idSchema];return r&&`${r[a]}`===e&&r.resource===t}):null};getEntity=(t,e,i)=>{let r=b.nodeCache.get("ids");return r?Array.isArray(t)?[]:null:Array.isArray(t)?r.filter(a=>{let s=A[i];return a&&t.includes(`${a[s]}`)&&a.resource===e}):r.find(a=>{let s=A[i];return a&&`${a[s]}`===t&&a.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=A[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),l=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=A[i],a=A[e],s=b.nodeCache.get("ids"),p={};return s?(Object.keys(t).forEach(n=>{let l=t[n],c=[];s.forEach(d=>{l.forEach((m,y)=>{m===d[a]&&n===d.resource&&(c[y]=d[r])})}),p[n]=c}),p):null};addIdMapping=t=>{let e=b.nodeCache.get("ids");e.push(t),b.nodeCache.set("ids",e)};addIdMappings=t=>{let e=b.nodeCache.get("ids");e=[...e,...t],b.nodeCache.set("ids",e)};addTopIdMappings=t=>{let e=b.nodeCache.get("ids"),i=604800;if(e){let r=JSON.parse(JSON.stringify(e));r=r.filter(a=>a.resource!=="match"),t=t.filter(a=>a.resource==="match"),r=[...r,...t],b.nodeCache.set("ids",r)}else b.nodeCache.set("ids",t);this.idMappingsExpiration=Math.floor(Date.now()/1e3)+i};setOwnProfile=t=>b.nodeCache.set("profile",t,this.profileTTL);getOwnProfile=()=>b.nodeCache.get("profile");getProfileCountries=()=>b.nodeCache.get("profile_countries");setProfileCountries=t=>b.nodeCache.set("profile_countries",t);getProfileStats=()=>b.nodeCache.get("profile_stats");setProfileStats=t=>b.nodeCache.set("profile_stats",t,this.profileTTL);getProfileBadges=()=>b.nodeCache.get("profile_badges");setProfileBadges=t=>{b.nodeCache.set("profile_badges",t,this.profileBadgesTTL)};getFootballCountries=()=>b.nodeCache.get("football_countries");setFootballCountries=t=>b.nodeCache.set("football_countries",t);getCompetitions=t=>{let e=b.nodeCache.get("football_competitions");return e?t?t.competitionSearchFilter(e):e:null};setCompetitions=t=>b.nodeCache.set("football_competitions",t);getCompetitionsLength=()=>{let t=b.nodeCache.get("football_competitions");return t?t.length:0};getClientFeatures=()=>b.nodeCache.get("client");setClientFeatures=t=>b.nodeCache.set("client",t,this.clientTTL);deleteClientFeatures=()=>b.nodeCache.del("client");getExpiration=(t,e)=>{let i=this.getKeyFromExpirationType(e);return i==="ids"?this.idMappingsExpiration:b.nodeCache.getTtl(i)};getKeyFromExpirationType=t=>{switch(t){case"profile":return"profile";case"statistics":return"profile_stats";case"badges":return"profile_badges";case"features":return"client";case"ids":return"ids"}}},Bt=b;ii(Bt,"instance"),ii(Bt,"nodeCache",new Ws.default);var V=class{createLocalCacheInstance=t=>typeof window>"u"?Bt.getInstance(t):ke.getInstance(t)};var di=class{localCache=null;https=null;constructor(t){this.localCache=new V().createLocalCacheInstance(t.idSchema),this.https=new ci(t)}getEntitiesByIds=async(t,e,i)=>{await this.setTopIdMappings();try{let r=this.localCache.checkForExistingIdObjs(t,e),a=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(a.request,e);return this.localCache.addIdMappings(s),this.localCache.getIdsByType(t,e,i)}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}};getEntityById=async(t,e,i)=>{let r=this.localCache.getEntity(t,e,i);if(r)return r;let a=await this.requestEntity(t,e,i);return this.localCache.addIdMappings(a),a};splitForRequestAndExisting=t=>{let e={},i={};return Object.keys(t).forEach(r=>{e[r]=t[r].filter(a=>!a.exists).map(a=>a.id),i[r]=t[r].filter(a=>a.exists).map(a=>a.id)}),{existing:i,request:e}};requestEntity=async(t,e,i)=>{try{return t=Array.isArray(t)?t:[t],await this.https.getEntitiesByIds(e,t,i)}catch(r){return console.warn(`There was a problem retrieving the requested entity: ${r}`),null}};setTopIdMappings=async()=>{let t=Math.floor(Date.now()/1e3);if(this.localCache.getExpiration("football","ids")>t)return Promise.resolve();let i=await this.https.getTopEntities();this.localCache.addTopIdMappings(i)}};var Qo=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 mi=class{extractedObjIds={};traverse=(t,e)=>(e=Qo(e),Array.isArray(t)?this.traverseArrExtract(t,e):t&&typeof t=="object"&&this.traverseObjExtract(t,e),this.extractedObjIds);traverseArrExtract=(t,e)=>{t&&t.length>0&&t.forEach(i=>{this.traverseObjExtract(i,e)})};traverseObjExtract=(t,e)=>{t&&Object.keys(t).length>0&&Object.keys(t).forEach(i=>{let r=t[i];i==="id"||i==="teamId"?(this.extractedObjIds.hasOwnProperty(e)||(this.extractedObjIds[e]=[]),r&&this.extractedObjIds[e].push(r)):t[i]&&this.traverse(t[i],i)})}};var ui=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=Qo(e),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(i),this.remappedIdsObj=i),Array.isArray(t)?this.traverseArrReplace(t,e):t&&typeof t=="object"&&this.traverseObjReplace(t,e),t);initReplaceObjIdsIndex=t=>{this.replaceObjIdsIndex={},Object.keys(t).forEach(e=>{this.replaceObjIdsIndex[e]=0})};traverseArrReplace=(t,e)=>{t&&t.length>0&&t.forEach(i=>{this.traverseObjReplace(i,e)})};traverseObjReplace=(t,e)=>{t&&Object.keys(t).length>0&&Object.keys(t).forEach(i=>{i==="id"||i==="teamId"?t[i]&&(t[i]=this.remappedIdsObj[e][this.replaceObjIdsIndex[e]],this.replaceObjIdsIndex[e]=this.replaceObjIdsIndex[e]+1):t[i]&&this.traverse(t[i],i,this.remappedIdsObj)})}};var F=class{idSchema="";idMappingFacade=null;constructor(t){this.idSchema=t.idSchema,this.idMappingFacade=new di(t)}getEntityIdBySchemaId=(t,e)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(t,e)=>{let i=JSON.parse(JSON.stringify(t));try{if(this.idSchema!=="native"){let a=new mi().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new ui().traverse(i,e,s))}else return t}catch(r){return console.warn(`There was a problem remapping entity: ${e} with inner entity `,r),[]}};getEntityIdsBySchemaId=async(t,e,i)=>{let r={};return r[e]=t,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(r,this.idSchema,i):r}};var H=class{completed=!1;percentage;constructor(t){this.percentage=t}};var hi=class{teamFollowed=new H(10);teamFavourite=new H(15);playerFollowed=new H(10);playerFavourite=new H(10);competitionFollowed=new H(10);competitionFavourite=new H(5);addedBirthdate=new H(10);addedGender=new H(10);addedCountry=new H(10);addedAvatar=new H(10)};var gi=class{totalPercentage;breakdown=new hi};var Ve=class{limit=0;startAfter=null;constructor(t){this.limit=t.limit?t.limit:20,this.startAfter=t.startAfter?t.startAfter:null}constructFilterUrl=()=>{let t="";return this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.startAfter&&(t=t+"&",t=t+`start_after=${this.startAfter}`),t}};var J=class{localCache;profileHttps=null;activityHttps=null;constructor(t,e,i){this.localCache=t,this.profileHttps=e,this.activityHttps=i}getOwn=async()=>{let t=this.getLocalStorageData("profile");if(t)return JSON.parse(JSON.stringify(t));try{let e=await this.profileHttps.getProfile();return this.localCache.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let t=await this.profileHttps.getProfile();return this.localCache.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}};getByIds=async(t,e,i)=>{if(t&&t.length>0&&e||!t&&t.length===0&&!e)throw new u(400,"invalid_method_call","The method 'getByIds' from Profile namespace is not called correctly. You need to provide 'profileIds' OR 'search' parameters to the method, but you can't use both of them or neither of them.");try{return await this.profileHttps.getProfiles(t,e,i)}catch(r){throw console.warn(`There was a problem retrieving the selected profiles: ${t.join(",")} `,r),r}};getById=async t=>{try{return await this.profileHttps.getProfile(t)}catch(e){throw console.warn(`There was a problem retrieving the selected profile: ${t} `,e),e}};getCountries=async t=>{t=t||!1;let e=this.localCache.getProfileCountries();if(e&&e.length>0)return e;try{let i=await this.profileHttps.getCountries(t);return this.localCache.setProfileCountries(i),i}catch(i){throw console.warn("There was a problem retrieving profile countries: ",i),i}};getFollowers=async(t,e)=>{try{t&&(t=new Ve(t));let i=await this.profileHttps.getFollowers(t,e),r=i.data.map(a=>a.followerId);if(r.length){let a=await this.getByIds(r),s=i.data.map(p=>(a.forEach(n=>{p.followerId===n.id&&(p.name=n.name,p.nickname=n.nickname,p.avatar=n.avatar)}),p));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your followers: ",i),i}};getFollowing=async(t,e)=>{try{t&&(t=new Ve(t));let i=await this.profileHttps.getFollowing(t,e),r=i.data.map(a=>a.followingId);if(r.length){let a=await this.getByIds(r),s=i.data.map(p=>(a.forEach(n=>{p.followingId===n.id&&(p.name=n.name,p.nickname=n.nickname,p.avatar=n.avatar)}),p));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your following profiles: ",i),i}};follow=async t=>{try{return await this.profileHttps.follow(t)}catch(e){throw console.warn(`There was a problem following profiles: ${t.join(",")} `,e),e}};unfollow=async t=>{try{return await this.profileHttps.unfollow(t)}catch(e){throw console.warn(`There was a problem unfollowing profiles: ${t.join(",")} `,e),e}};showFullnessProfile=t=>{let e=new gi,i=0;return t.avatar&&(e.breakdown.addedAvatar.completed=!0,i+=e.breakdown.addedAvatar.percentage),t.birthDate&&(e.breakdown.addedBirthdate.completed=!0,i+=e.breakdown.addedBirthdate.percentage),t.country&&(e.breakdown.addedCountry.completed=!0,i+=e.breakdown.addedCountry.percentage),t.gender&&(e.breakdown.addedGender.completed=!0,i+=e.breakdown.addedGender.percentage),t.interests&&t.interests.length>0&&(t.interests.find(c=>c.type==="team"&&c.favourite)&&(e.breakdown.teamFavourite.completed=!0,i+=e.breakdown.teamFavourite.percentage),t.interests.find(c=>c.type==="team")&&(e.breakdown.teamFollowed.completed=!0,i+=e.breakdown.teamFollowed.percentage),t.interests.find(c=>c.type==="player"&&c.favourite)&&(e.breakdown.playerFavourite.completed=!0,i+=e.breakdown.playerFavourite.percentage),t.interests.find(c=>c.type==="player")&&(e.breakdown.playerFollowed.completed=!0,i+=e.breakdown.playerFollowed.percentage),t.interests.find(c=>c.type==="competition"&&c.favourite)&&(e.breakdown.competitionFavourite.completed=!0,i+=e.breakdown.competitionFavourite.percentage),t.interests.find(c=>c.type==="competition")&&(e.breakdown.competitionFollowed.completed=!0,i+=e.breakdown.competitionFollowed.percentage)),e.totalPercentage=i,e};getStats=async()=>{let t=["predictionsMade","predictions","tiers","badges"],e=this.getLocalStorageData("statistics"),i=e?t.every(r=>Object.keys(e).includes(r)):!1;if(e&&Object.keys(e).length&&i)return JSON.parse(JSON.stringify(e));try{let r=await this.activityHttps.getStats();return this.localCache.setProfileStats(r),r}catch(r){throw console.warn("There was a problem retrieving own profile statistics: ",r),r}};getBadges=async()=>{let t=this.getLocalStorageData("badges");if(t)return t;try{let e=await this.profileHttps.getBadges();return this.localCache.setProfileBadges(e),e}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=t=>{let e=Math.floor(Date.now()/1e3),i=this.localCache.getExpiration("profile",t);switch(t){case"profile":if(i>e)return this.localCache.getOwnProfile();case"statistics":if(i>e)return this.localCache.getProfileStats();case"badges":if(i>e)return this.localCache.getProfileBadges();default:return null}}};var fi=class{id=null;name=null;assets=null};var yi=class{extractUpdatedProps=(t,e)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(t).forEach(a=>{if(i.includes(a)&&t[a]!==e[a])r[a]=e[a];else if(a==="birthDate")(e[a]===null||t[a]===null&&e[a]||t[a]!==e[a])&&(r.birth_date=e[a]);else if(a==="country")e[a]===null?r.country_id=e[a]:(t[a]===null&&e[a]||t[a].id!==e[a].id)&&(r.country_id=e[a].id);else if(a==="interests"){let s=t[a],p=e[a];p.length&&this.isNewInterest(s,p)?r[a]=this.updateInterests(s,p):(!p.length&&s.length||s.length!==p.length&&!this.isNewInterest(s,p))&&(r[a]=p)}}),r};updateInterests=(t,e)=>{if(t.length===e.length){let[i,r]=this.extractSameAndNewInterests(t,e);return[...r,...i]}else return e};isNewInterest=(t,e)=>{let i=!1,[r]=this.extractSameAndNewInterests(t,e);return r.length&&(i=!0),i};extractSameAndNewInterests=(t,e)=>{let i=e.filter(a=>t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite));return[e.filter(a=>!t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite)),i]};isAvatarValidURL=t=>{try{return new URL(t),!0}catch{return!1}}};var w=class extends Error{code=0;status=null;message=null;constructor(t,e,i){super(),this.code=t,this.status=e,this.message=i}errorMessage=()=>this.message};var bi=class{idsRemapper=null;profileHttps=null;profileService=null;localCache=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;errorHandlingMode=null;constructor(t,e,i,r,a){this.idsRemapper=t,this.localCache=e,this.profileHttps=i,this.errorHandlingMode=a,this.profileService=new yi,this.profileFacade=new J(e,i,r)}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 t=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<t){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let e=await this.profileFacade.getOwn();this.setOwnProfile(e)}catch(e){throw this.isFetching=!1,e}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=t=>new Promise(e=>{setTimeout(e,t)});setOwnProfile=t=>{this.ownProfile=t};getInfo=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return delete e.interests,e};showInterests=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.remapInterests(e.interests)};showFullInterests=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.showFullInterests(e.interests)};getFollowers=async t=>await this.profileFacade.getFollowers(t);getFollowing=async t=>await this.profileFacade.getFollowing(t);follow=async t=>{let e=await this.profileFacade.follow(t),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),e};unfollow=async t=>{let e=await this.profileFacade.unfollow(t),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),e};getStats=async()=>{let t=await this.profileFacade.getStats();return await this.idsRemapper.remapProfileStats(t)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e;let r=this.ownProfile.interests.filter(a=>a.id!==i.id||a.type!==i.type||a.source!==i.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(i),this};addInterest=t=>(this.promises.push(this.addInterestPromise(t)),this);removeInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;return t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==i.id||r.type!==i.type||r.source!==i.source),this};removeInterest=t=>(this.promises.push(this.removeInterestPromise(t)),this);setBirthdatePromise=async t=>(this.modified=!0,await this.getOwnProfile(),t?this.ownProfile.birthDate=t:this.ownProfile.birthDate=null,this);setBirthdate=t=>(this.promises.push(this.setBirthdatePromise(t)),this);setGenderPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t==="male"||t==="female"?this.ownProfile.gender=t:this.ownProfile.gender="unspecified",this);setGender=t=>(this.promises.push(this.setGenderPromise(t)),this);setNicknamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=t,this);setNickname=t=>(this.promises.push(this.setNicknamePromise(t)),this);setNamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=t,this);setName=t=>(this.promises.push(this.setNamePromise(t)),this);setCountryPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t&&!this.ownProfile.country?(this.ownProfile.country=new fi,this.ownProfile.country.id=t):t&&this.ownProfile.country?this.ownProfile.country.id=t:this.ownProfile.country=null,this);setCountry=t=>(this.promises.push(this.setCountryPromise(t)),this);showFullnessProfile=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return this.profileFacade.showFullnessProfile(e)};setAvatarPromise=async t=>{if(this.modified=!0,await this.getOwnProfile(),this.profileService.isAvatarValidURL(t))this.ownProfile.avatar=t;else{if(this.errorHandlingMode==="default")throw new w(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.errorHandlingMode==="standard")throw new u(400,"invalid_avatar","Invalid URL syntax for avatar image.")}return this};setAvatar=t=>(this.promises.push(this.setAvatarPromise(t)),this);update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let t=await this.profileFacade.getOwn(),e=await this.getOwnProfile(),i=this.profileService.extractUpdatedProps(t,e);if(this.modified=!1,this.expireAt=0,Object.keys(i).length){let a=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(a));return this.setOwnProfile(s),this.localCache.setOwnProfile(s),delete a.interests,a}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r}};var Mi=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(t,e,i,r){this.idsRemapper=t,this.profileHttps=i,this.activityHttps=r,this.profileFacade=new J(e,i,r)}setId=t=>(this.profileId=t,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let t=await this.getProfile();return delete t.interests,t};showInterests=async()=>{let t=await this.getProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.remapInterests(e.interests)};showFullInterests=async()=>{let t=await this.getProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.showFullInterests(e.interests)};getFollowers=async t=>await this.profileFacade.getFollowers(t,this.profileId);getFollowing=async t=>await this.profileFacade.getFollowing(t,this.profileId);showFullnessProfile=async()=>{let t=await this.getProfile();return this.profileFacade.showFullnessProfile(t)};getStats=async t=>{let e=await this.activityHttps.getStats(this.profileId,t);return await this.idsRemapper.remapProfileStats(e)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var wi=class{localCache=null;https=null;idMapping=null;constructor(t,e,i){this.localCache=t,this.idMapping=i,this.https=e}getCountriesWithIdMapping=async t=>{try{let e=await this.getCountries(t);return this.idMapping.remapEntities(e,"country")}catch(e){throw console.warn("There was a problem browsing countries as football entities",e),e}};getCountries=async t=>{t=t||!1;let e=this.localCache.getFootballCountries();if(e&&e.length>0)return e;try{let i=await this.https.getCountries(t);return this.localCache.setFootballCountries(i),i}catch(i){throw console.warn("There was a problem retrieving countries as football entities",i),i}}};var $e=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(t){this.countryId=t.countryId?`${t.countryId}`:null,this.name=t.name?t.name:null,this.gender=t.gender?t.gender:null,this.type=t.type?t.type:null,this.sortField=t.sortField?`${t.sortField}`:null,this.sortOrder=t.sortOrder?`${t.sortOrder}`:null,this.competitionIds=t.competitionIds?t.competitionIds:null}constructFilterUrl=()=>{let t="";return this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.gender&&(t=t+"&",t=t+`gender=${this.gender}`),this.type&&(t=t+"&",t=t+`type=${this.type}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.competitionIds&&(t=t+"&",t=t+`competition_ids=${this.competitionIds.join(",")}`),t};competitionSearchFilter=t=>{try{let e=this.filter(t);return this.sortField||this.sortOrder?this.sort(e):e}catch(e){return console.warn("There was a problem filtering the local competitions",e),[]}};filter=t=>{let e=this.entitiesToSearchWith();return t.filter(i=>{let r=!0;return e.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?r&&=i.country.id===this[a]:a==="name"?r&&=i.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?r&&=this[a].some(s=>i.id===s):r&&=i[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),r})};entitiesToSearchWith=()=>{let t=[];return this.countryId&&t.push("countryId"),this.name&&t.push("name"),this.gender&&t.push("gender"),this.type&&t.push("type"),this.sortField&&t.push("sortField"),this.sortOrder&&t.push("sortOrder"),this.competitionIds&&t.push("competitionIds"),t};sort=t=>{let e=[];return this.sortField==="name"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.name.localeCompare(i.name):i.name.localeCompare(r.name)):this.sortField==="country"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.country.name.localeCompare(i.country.name):i.country.name.localeCompare(r.country.name)):this.sortField==="scope"?t.forEach(i=>e[this.competitionIds.indexOf(i.id)]=i):!this.sortField&&this.sortOrder==="desc"&&(e=t.sort((i,r)=>r.id.localeCompare(i.id))),e}};var Ii=class{localStorage=null;https=null;idMapping=null;constructor(t,e,i){this.localStorage=t,this.idMapping=i,this.https=e}getCompetitionsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new $e(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");a.competition.length===0&&(i=!0),t.competitionIds=a.competition}if(i)return[]}let r=await this.getCompetitions(t,e);return await this.idMapping.remapEntities(r,"competition")}catch(i){throw console.warn("There was a problem browsing all of the competitions",i),i}};getCompetitionsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new $e({competitionIds:t,limit:i}),a=await this.getCompetitions(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=Vo(t),p=await this.idMapping.remapEntities(a,"competition");return s.forEach((n,l)=>e.set(n,p[l])),e};getCompetitions=async(t,e)=>{let i=null;if(e=e||!1,!this.localStorage.getCompetitionsLength()){try{i=await this.https.getCompetitions()}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}this.localStorage.setCompetitions(i)}return this.localStorage.getCompetitions(t)};getCompetitionByIdIdMapping=async(t,e)=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([t],"competition","native")).competition[0],a=await this.getCompetitionById(r,e);return await this.idMapping.remapEntities(a,"competition")}catch(i){throw console.warn(`There was a problem browsing the following competition:${t}`,i),i}};getCompetitionById=async(t,e)=>{try{return e=e||!1,await this.https.getCompetitionById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the competition with the following id: ${t}`,i),i}};getTopCompetitionsIdMapping=async t=>{try{let e=await this.getTopCompetitions(t);return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async t=>{try{return t=t||!1,await this.https.getTopCompetitions(t)}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var We=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(t){this.name=t.name?t.name:null,this.countryId=t.countryId?`${t.countryId}`:null,this.national=t.national?t.national:!1,this.gender=t.gender?t.gender:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.scope=t.scope?t.scope:null,this.sortField=t.sortField?`${t.sortField}`:null,this.sortOrder=t.sortOrder?`${t.sortOrder}`:null,this.teamIds=t.teamIds?t.teamIds:null}constructFilterUrl=()=>{let t="";return this.name&&(t=t+"&",t=t+`name=${this.name}`),this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.national&&(t=t+"&",t=t+`national=${this.national}`),this.gender&&(t=t+"&",t=t+`gender=${this.gender}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.scope&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),this.teamIds&&(t=t+"&",t=t+`team_ids=${this.teamIds.join(",")}`),t}};var Pi=class{reason="";words=[]};var Nt=class{enabled=!1;moderateLinks=!1;linksWhitelist=[];moderatorProfileId="";dictionary=new Pi};var Ti=class{enabled=!1;clientId=null;automaticModeration=new Nt};var vi=class{general=[];predictor=[];topX=[];matchQuiz=[]};var mt=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var _i=class{id;label;assets={mainImageUrl:""};enabled;requirements=new mt};var Ut=class extends mt{postPoints=null;postsCount=null;reactionsCount=null;totalDiscussionPoints=null};var Fi=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Ut};var Ei=class{id;weight;multiplier;conditions};var Ri=class{value=[new Ei]};var Ht=class{points=null;tiers=null;badges=null};var Si=class{enabled=!1;clientId=null;conditions={list:null};actions=new Ri;rewards=new Ht};var Ci=class{general=null;predictor=null;activity=null;topX=null;matchQuiz=null;discussionPost=null};var kt=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var Gt=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Ai=class{competitions=[];teams=[];markets=[]};var Vt=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new Ai;userDataConfig=null};var Oi=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var Li=class{remapPredictorConfig=t=>{let e=new Vt;return e.enabled=t.enabled,e.clientId=t.client_id,e.fullCoverageCompetitions=t.full_coverage_competitions,e.markets=t.markets,e.successRateScopes=t.success_rate_scopes,e.userDataConfig=t.user_data_config?this.remapUserDataConfig(t.user_data_config):null,e};remapTopXConfig=t=>{let e=new Gt;return e.enabled=t.enabled,e.clientId=t.client_id,e.minFixtures=t.min_fixtures,e.maxFixtures=t.max_fixtures,e.competitionsWhitelist=t.competitions_whitelist,e};remapMatchQuizConfig=t=>{let e=new kt;return e.enabled=t.enabled,e.clientId=t.client_id,e.defaultMarkets=t.default_markets,e.competitionsWhitelist=t.competitions_whitelist,e};remapLoyaltyConfig=t=>{let e=new Si;return e.enabled=t.enabled,e.clientId=t.client_id,e.conditions.list=t.conditions.list,e.actions.value=t.actions.value,e.rewards=this.remapRewards(t.rewards),e};remapDiscussionsConfig=t=>{let e=new Ti;return e.enabled=t.enabled,e.clientId=t.client_id,e.automaticModeration=t.automatic_moderation?this.remapAutomaticModeration(t.automatic_moderation):null,e};remapAutomaticModeration=t=>{let e=new Nt;return e.enabled=t.enabled,e.moderateLinks=t.moderate_links,e.linksWhitelist=t.links_whitelist,e.moderatorProfileId=t.moderator_profile_id,e.dictionary=t.dictionary,e};remapRewards=t=>{let e=new Ht;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new Ci;return e.general=t.general,e.discussionPost=t.discussion_post,e.predictor=t.predictor,e.activity=t.activity,e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapBadges=t=>{let e=new vi;return e.general=this.remapGeneralBadgeValues(t.general),e.predictor=this.remapBadgeValues(t.predictor),e.topX=this.remapBadgeValues(t.top_x),e.matchQuiz=this.remapBadgeValues(t.match_quiz),e};remapBadgeValues=t=>t.map(e=>{let i=new _i;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapRequirements(e.requirements),i});remapRequirements=t=>{let e=new mt;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e};remapUserDataConfig=t=>{let e=new Oi;return e.storeIp=t.store_ip,e.storeDeviceId=t.store_device_id,e.storeAgent=t.store_agent,e};remapGeneralBadgeValues=t=>t.map(e=>{let i=new Fi;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapGeneralRequirements(e.requirements),i});remapGeneralRequirements=t=>{let e=new Ut;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e.postPoints=t.post_points,e.postsCount=t.posts_count,e.reactionsCount=t.reactions_count,e.totalDiscussionPoints=t.total_discussion_points,e}};var B=class extends _{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(t){super(t,R(t.environment,"client")),this.clientId=t.clientId,this.localStorage=new V().createLocalCacheInstance(t.idSchema),this.featureConfigRemapper=new Li}getConfig=async t=>{let e=this.getCachedFeatures();if(!e){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0],a=i+r,s="There was a problem fetching client features from Client API";e=(await this.fetchWithoutAuth(a,s)).data,this.localStorage.setClientFeatures(e)}switch(t){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(e.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(e.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(e.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(e.loyalty);case"discussions":return this.featureConfigRemapper.remapDiscussionsConfig(e.discussions)}};getCachedFeatures=()=>{let t=this.getLocalStorageData();if(!(!t||!Object.keys(t).length))return t.predictor.client_id&&t.predictor.client_id!==this.clientId?(this.localStorage.deleteClientFeatures(),null):t};getLocalStorageData=()=>{let t=Math.floor(Date.now()/1e3);return this.localStorage.getExpiration("client","features")>t?this.localStorage.getClientFeatures():null}};var ut=class{clientHttps=null;constructor(t){this.clientHttps=new B(t)}setAvailableMarketsForMatch=async t=>{let{fullCoverageCompetitions:e,markets:i}=await this.clientHttps.getConfig("predictor");if(Array.isArray(t))return t.map(r=>this.setAvailableMarkets(r,e,i));if(typeof t=="object"&&Object.keys(t).length)return this.setAvailableMarkets(t,e,i)};setAvailableMarkets=(t,e,i)=>{let r=t.context.competition?.id;return r&&this.isMatchInCoverageCompetition(r,e)?(t.availableMarkets=i.all,t):(t.availableMarkets=i.main,t)};isMatchInCoverageCompetition=(t,e)=>{let i=!1;return e.includes(t)&&(i=!0),i}};var Di=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new ut(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new We(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(t.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");a.team.length===0&&(i=!0),t.teamIds=a.team}}if(i)return[];let r=await this.getTeams(t,e);return r.data=await this.idMapping.remapEntities(r.data,"team"),r}catch(i){throw console.warn("There was a problem browsing all teams",i),i}};getTeamsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new We({teamIds:t,limit:i}),{data:a}=await this.getTeams(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=Vo(t),p=await this.idMapping.remapEntities(a,"team");return s.forEach((n,l)=>e.set(n,p[l])),e};getTeams=async(t,e)=>{try{return e=e||!1,await this.https.getTeams(t,e)}catch(i){throw console.warn("There was a problem retrieving all teams",i),i}};getTeamByIdIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getTeamById(t,e);return await this.idMapping.remapEntities(r,"team")}catch(i){throw console.warn(`There was a problem browsing the following team:${t}`,i),i}};getTeamById=async(t,e)=>{try{return e=e||!1,await this.https.getTeamById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following team: ${t}`,i),i}};getTopTeamsIdMapping=async t=>{try{let e=await this.getTopTeams(t);return await this.idMapping.remapEntities(e,"team")}catch(e){throw console.warn("There was a problem browsing the top teams",e),e}};getTopTeams=async t=>{try{return t=t||!1,await this.https.getTopTeams(t)}catch(e){throw console.warn("There was a problem retrieving the top teams",e),e}};getNextMatchForTeamIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getNextMatchForTeam(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for the following team:${t}`,i),i}};getNextMatchForTeam=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForTeam(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for the following team: ${t}`,i),i}};getPrevMatchForTeamIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getPrevMatchForTeam(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for the following team:${t}`,i),i}};getPrevMatchForTeam=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForTeam(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for the following team: ${t}`,i),i}}};var Ke=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(t){this.countryId=t.countryId?t.countryId:null,this.scope=t.scope?t.scope:null,this.name=t.name?t.name:null,this.playerIds=t.playerIds?t.playerIds:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.sortField=t.sortField?t.sortField:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFilterUrl=()=>{let t="";return this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.scope&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.playerIds&&(t=t+"&",t=t+`player_ids=${this.playerIds.join(",")}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),t}};var ht=class{https=null;footballService=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new ut(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new Ke(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([t.countryId],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.playerIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.playerIds,"player","native");a.player.length===0&&(i=!0),t.playerIds=a.player}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(i)return[]}let r=await this.getPlayers(t,e);return r.data=await this.idMapping.remapEntities(r.data,"player"),r}catch(i){throw console.warn("There was a problem browsing the players",i),i}};getPlayersWithNativeIds=async t=>{let e=t.length,i=new Ke({playerIds:t,limit:e}),r=await this.getPlayers(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async t=>{let e={},i=_t(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getPlayersWithNativeIds(i);return i.forEach((a,s)=>e[a]=r[s]),e};getPlayers=async(t,e)=>{try{return e=e||!1,await this.https.getPlayers(t,e)}catch(i){throw console.warn("There was a problem retrieving the players",i),i}};getPlayerIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"player","native"),r=await this.getPlayerById(i.player[0],e);return await this.idMapping.remapEntities(r,"player")}catch(i){throw console.warn(`There was a problem browsing the following player:${t}`,i),i}};getPlayerById=async(t,e)=>{try{return e=e||!1,await this.https.getPlayerById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following player: ${t}`,i),i}};getTopPlayersIdMapping=async t=>{try{let e=await this.getTopPlayers(t);return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async t=>{try{return t=t||!1,await this.https.getTopPlayers(t)}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getNextMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for player:${t}`,i),i}};getNextMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for player: ${t}`,i),i}};getPrevMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for player:${t}`,i),i}};getPrevMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for player: ${t}`,i),i}}};var $t=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(t){this.countryIds=t.countryIds?t.countryIds:null,this.competitionIds=t.competitionIds?t.competitionIds:null,this.matchIds=t.matchIds?t.matchIds:null,this.status=t.status?t.status:null,this.teamIds=t.teamIds?t.teamIds:null,this.fromDate=t.fromDate?t.fromDate:null,this.toDate=t.toDate?t.toDate:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.sortField=t.sortField?t.sortField:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFilterUrl=()=>{let t="";return this.countryIds&&(t=t+"&",t=t+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(t=t+"&",t=t+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(t=t+"&",t=t+`matches=${this.matchIds.join(",")}`),this.status&&(t=t+"&",t=t+`status=${this.status}`),this.teamIds&&(t=t+"&",t=t+`teams=${this.teamIds.join(",")}`),this.fromDate&&(t=t+"&",t=t+`from_date=${this.fromDate}`),this.toDate&&(t=t+"&",t=t+`to_date=${this.toDate}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),t}};var gt=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new ut(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new $t(t),t.countryIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.countryIds,"country","native");t.countryIds=r.country}if(t.competitionIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");t.competitionIds=r.competition}if(t.matchIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.matchIds,"match","native");t.matchIds=r.match}if(t.teamIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");t.teamIds=r.team}}let i=await this.getMatches(t,e);return i.data=await this.footballService.setAvailableMarketsForMatch([...i.data]),i.data=await this.idMapping.remapEntities(i.data,"match"),i}catch(i){throw console.warn("There was a problem browsing the matches",i),i}};getMatchesWithNativeIds=async t=>{let e=t.length,i=new $t({matchIds:t,limit:e}),r=await this.getMatches(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async t=>{let e={},i=_t(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let a=new $t({matchIds:i,limit:i.length}),s=await this.getMatches(a),p=i.filter(n=>{if(s.data.every(l=>l.id!==n))return n});i=i.filter(n=>{if(!p.includes(n))return n})}return i.forEach((a,s)=>e[a]=r[s]),e};getMatches=async(t,e)=>{try{return e=e||!1,await this.https.getMatches(t,e)}catch(i){throw console.warn("There was a problem retrieving the matches",i),i}};getMatchIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"match","native"),r=await this.getMatchById(i.match[0],e),a=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(a,"match")}catch(i){throw console.warn(`There was a problem browsing the following match: ${t}`,i),i}};getMatchById=async(t,e)=>{try{return e=e||!1,await this.https.getMatchById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following match: ${t}`,i),i}}};var Bi=class{entities=null;query=null;scope=null;constructor(t){this.entities=t.entities?t.entities:null,this.query=t.query?t.query:null,this.scope=t.scope?t.scope:null}constructFilterUrl=()=>{let t="";return this.entities&&(t=t+"&",t=t+`entities=${this.entities.join(",")}`),this.query&&(t=t+"&",t=t+`q=${this.query}`),this.scope&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),t}};var Ni=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new Bi(t),t.scope){let r=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");t.scope=r.competition}let i=await this.search(t,e);if(i.teams&&i.teams.length>0){let r=await this.idMapping.remapEntities(i.teams,"team");i.teams=r}if(i.players&&i.players.length>0){let r=await this.idMapping.remapEntities(i.players,"player");i.players=r}if(i.competitions&&i.competitions.length>0){let r=await this.idMapping.remapEntities(i.competitions,"competition");i.competitions=r}return i}catch(i){throw console.warn("There was a problem with browsing the search result",i),i}};search=async(t,e)=>{try{return await this.https.search(t,e)}catch(i){throw console.warn("There was a problem retrieving the search response",i),i}}};var Wt=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new wi(e,i,r),this.competitionsFacade=new Ii(e,i,r),this.teamsFacade=new Di(t,i,r),this.playerFacade=new ht(t,i,r),this.matchFacade=new gt(t,i,r),this.searchFacade=new Ni(i,r)}getCountries=async t=>this.countriesFacade.getCountriesWithIdMapping(t);getCompetitions=async(t,e)=>this.competitionsFacade.getCompetitionsIdMapping(t,e);getCompetitionById=async(t,e)=>this.competitionsFacade.getCompetitionByIdIdMapping(t,e);getTopCompetitions=async t=>this.competitionsFacade.getTopCompetitionsIdMapping(t);getCompetitionsMapWithNativeIds=async t=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(t);getTeams=async(t,e)=>this.teamsFacade.getTeamsIdMapping(t,e);getTeamById=async(t,e)=>this.teamsFacade.getTeamByIdIdMapping(t,e);getTopTeams=async t=>this.teamsFacade.getTopTeamsIdMapping(t);getNextMatchForTeam=async(t,e)=>this.teamsFacade.getNextMatchForTeamIdMapping(t,e);getPrevMatchForTeam=async(t,e)=>this.teamsFacade.getPrevMatchForTeamIdMapping(t,e);getTeamsMapWithNativeIds=async t=>await this.teamsFacade.getTeamsMapWithNativeIds(t);getPlayers=async(t,e)=>this.playerFacade.getPlayersIdMapping(t,e);getPlayerById=async(t,e)=>this.playerFacade.getPlayerIdMapping(t,e);getTopPlayers=async t=>this.playerFacade.getTopPlayersIdMapping(t);getNextMatchForPlayer=async(t,e)=>this.playerFacade.getNextMatchForPlayerIdMapping(t,e);getPrevMatchForPlayer=async(t,e)=>this.playerFacade.getPrevMatchForPlayerIdMapping(t,e);getPlayersMapWithNativeIds=async t=>this.playerFacade.getPlayersMapWithNativeIds(t);getMatches=async(t,e)=>this.matchFacade.getMatchesIdMapping(t,e);getMatchById=async(t,e)=>this.matchFacade.getMatchIdMapping(t,e);search=async(t,e)=>this.searchFacade.searchIdMapping(t,e)};var Ui=class{id="";alias="";countryCode="";assets=null;name=""};var S=class{countriesFromResponse=t=>{if(t)return t.map(e=>this.countryFromResponse(e))};countryFromResponse=t=>{try{if(t){let e=new Ui;return e.id=t.id,e.alias=t.alias,e.assets=t.assets,e.countryCode=t.country_code,e.name=t.name,e}}catch(e){throw e}return null}};var Hi=class{id="";country=null;gender="";assets=null;type="";name=""};var N=class{countryRemapper=null;constructor(){this.countryRemapper=new S}fromResponse(t){try{let e=new Hi;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.type=t.type,e.name=t.name,e}catch(e){throw console.warn("There was a problem remapping the competition response",e),e}}};var ki=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Gi=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName="";isDeleted=!1};var O=class{countryRemapper=null;constructor(){this.countryRemapper=new S}fromResponse(t){try{let e=new Gi;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.code=t.code,e.national=t.national,e.fullName=t.full_name,e.shortName=t.short_name,e.name=t.name,e.isDeleted=t.is_deleted,e}catch(e){throw console.warn("There was a problem remapping teams response",e),e}}};var Vi=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new S,this.teamBasicRemapper=new O}fromResponse(t){try{let e=new ki;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.type=t.type,e.name=t.name,e.participants=t.participants.map(i=>this.teamBasicRemapper.fromResponse(i)),e}catch(e){throw console.warn("There was a problem remapping the competition response",e),e}}};var $i=class{primary=null;secondary=null;tertiary=null};var Wi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new $i;squad=[]};var Ki=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var ji=class{countryRemapper=null;constructor(){this.countryRemapper=new S}fromResponse(t){try{let e=new Ki;return e.id=t.id,e.startDate=t.start_date,e.endDate=t.end_date,e.shirtNumber=t.shirt_number,e.loan=t.loan,e.position=t.position,e.country=this.countryRemapper.countryFromResponse(t.country),e.name=t.name,e.assets=t.assets,e.birthDate=t.birth_date,e}catch(e){throw console.warn("There was a problem remapping the player from squad",e),e}}};var qi=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new S,this.competitionRemapper=new N,this.playerRemapper=new ji}fromResponse(t){try{let e=new Wi;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.code=t.code,e.national=t.national,e.fullName=t.full_name,e.shortName=t.short_name,e.name=t.name,e.isDeleted=t.is_deleted,e.competitions=t.competitions?t.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],e.colors=t.colors?t.colors:e.colors,e.squad=t.squad?t.squad.map(i=>this.playerRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping team response",e),e}}};var zi=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;isDeleted=!1;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Qi=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Kt=class{fromResponse(t){try{let e=new Qi;return e.ftScore=this.statEntityFromResponse(t.ft_score),e.htScore=this.statEntityFromResponse(t.ht_score),e.aetScore=this.statEntityFromResponse(t.aet_score),e.aggScore=this.statEntityFromResponse(t.agg_score),e.penScore=this.statEntityFromResponse(t.pen_score),e}catch(e){throw console.warn("There was a problem remapping the scores",e),e}}statEntityFromResponse=t=>({homeGoals:t.home_goals,awayGoals:t.away_goals})};var Xi=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new O,this.competitionRemapper=new N,this.scoresRemapper=new Kt}fromResponse(t){try{let e=new zi;return e.id=t.id,e.kickoffAt=t.kickoff_at,e.finishedAt=t.finished_at,e.updatedAt=t.updated_at,e.isDeleted=t.is_deleted,e.homeTeam=this.teamRemapper.fromResponse(t.home_team),e.awayTeam=this.teamRemapper.fromResponse(t.away_team),e.lineupsConfirmed=t.lineups_confirmed,e.startedAt=t.started_at,e.minute=t.minute,e.scores=this.scoresRemapper.fromResponse(t.scores),e.context={competition:t.context.competition?this.competitionRemapper.fromResponse(t.context.competition):null},e.status={type:t.status.type,subType:t.status.sub_type},e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var $=class{type=null;subType=null};var Yi=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;isDeleted=!1;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status=new $;lineups=null};var Ji=class{corners=null;cornersFirstHalf=null;cornersSecondHalf=null;cornersExtraTime=null;crosses=null;crossesFirstHalf=null;crossesSecondHalf=null;crossesExtraTime=null;offside=null;offsideFirstHalf=null;offsideSecondHalf=null;offsideExtraTime=null;shotsOn=null;shotsOnFirstHalf=null;shotsOnSecondHalf=null;shotsOnExtraTime=null;throwIn=null;throwInFirstHalf=null;throwInSecondHalf=null;throwInExtraTime=null;redCards=null;redCardsFirstHalf=null;redCardsSecondHalf=null;redCardsExtraTime=null;shotsOff=null;shotsOffFirstHalf=null;shotsOffSecondHalf=null;shotsOffExtraTime=null;goalKicks=null;goalKicksFirstHalf=null;goalKicksSecondHalf=null;goalKicksExtraTime=null;possession=null;possessionFirstHalf=null;possessionSecondHalf=null;possessionExtraTime=null;treatments=null;treatmentsFirstHalf=null;treatmentsSecondHalf=null;treatmentsExtraTime=null;yellowCards=null;yellowCardsFirstHalf=null;yellowCardsSecondHalf=null;yellowCardsExtraTime=null;shotsBlocked=null;shotsBlockedFirstHalf=null;shotsBlockedSecondHalf=null;shotsBlockedExtraTime=null;substitutions=null;substitutionsFirstHalf=null;substitutionsSecondHalf=null;substitutionsExtraTime=null;counterAttacks=null;counterAttacksFirstHalf=null;counterAttacksSecondHalf=null;counterAttacksExtraTime=null;foulsCommitted=null;foulsCommittedFirstHalf=null;foulsCommittedSecondHalf=null;foulsCommittedExtraTime=null};var Zi=class{fromResponse(t){try{let e=new Ji;return e.corners=this.statEntityFromResponse(t.corners),e.cornersFirstHalf=this.statEntityFromResponse(t.corners_1h),e.cornersSecondHalf=this.statEntityFromResponse(t.corners_2h),e.cornersExtraTime=this.statEntityFromResponse(t.corners_et),e.crosses=this.statEntityFromResponse(t.crosses),e.crossesFirstHalf=this.statEntityFromResponse(t.crosses_1h),e.crossesSecondHalf=this.statEntityFromResponse(t.crosses_2h),e.crossesExtraTime=this.statEntityFromResponse(t.crosses_et),e.offside=this.statEntityFromResponse(t.offside),e.offsideFirstHalf=this.statEntityFromResponse(t.offside_1h),e.offsideSecondHalf=this.statEntityFromResponse(t.offside_2h),e.offsideExtraTime=this.statEntityFromResponse(t.offside_et),e.shotsOn=this.statEntityFromResponse(t.shots_on),e.shotsOnFirstHalf=this.statEntityFromResponse(t.shots_on_1h),e.shotsOnSecondHalf=this.statEntityFromResponse(t.shots_on_2h),e.shotsOnExtraTime=this.statEntityFromResponse(t.shots_on_et),e.throwIn=this.statEntityFromResponse(t.throw_in),e.throwInFirstHalf=this.statEntityFromResponse(t.throw_in_1h),e.throwInSecondHalf=this.statEntityFromResponse(t.throw_in_2h),e.throwInExtraTime=this.statEntityFromResponse(t.throw_in_et),e.redCards=this.statEntityFromResponse(t.red_cards),e.redCardsFirstHalf=this.statEntityFromResponse(t.red_cards_1h),e.redCardsSecondHalf=this.statEntityFromResponse(t.red_cards_2h),e.redCardsExtraTime=this.statEntityFromResponse(t.red_cards_et),e.shotsOff=this.statEntityFromResponse(t.shots_off),e.shotsOffFirstHalf=this.statEntityFromResponse(t.shots_off_1h),e.shotsOffSecondHalf=this.statEntityFromResponse(t.shots_off_2h),e.shotsOffExtraTime=this.statEntityFromResponse(t.shots_off_et),e.goalKicks=this.statEntityFromResponse(t.goal_kicks),e.goalKicksFirstHalf=this.statEntityFromResponse(t.goal_kicks_1h),e.goalKicksSecondHalf=this.statEntityFromResponse(t.goal_kicks_2h),e.goalKicksExtraTime=this.statEntityFromResponse(t.goal_kicks_et),e.possession=this.statEntityFromResponse(t.possession),e.possessionFirstHalf=this.statEntityFromResponse(t.possession_1h),e.possessionSecondHalf=this.statEntityFromResponse(t.possession_2h),e.possessionExtraTime=this.statEntityFromResponse(t.possession_et),e.treatments=this.statEntityFromResponse(t.treatments),e.treatmentsFirstHalf=this.statEntityFromResponse(t.treatments_1h),e.treatmentsSecondHalf=this.statEntityFromResponse(t.treatments_2h),e.treatmentsExtraTime=this.statEntityFromResponse(t.treatments_et),e.yellowCards=this.statEntityFromResponse(t.yellow_cards),e.yellowCardsFirstHalf=this.statEntityFromResponse(t.yellow_cards_1h),e.yellowCardsSecondHalf=this.statEntityFromResponse(t.yellow_cards_2h),e.yellowCardsExtraTime=this.statEntityFromResponse(t.yellow_cards_et),e.shotsBlocked=this.statEntityFromResponse(t.shots_blocked),e.shotsBlockedFirstHalf=this.statEntityFromResponse(t.shots_blocked_1h),e.shotsBlockedSecondHalf=this.statEntityFromResponse(t.shots_blocked_2h),e.shotsBlockedExtraTime=this.statEntityFromResponse(t.shots_blocked_et),e.substitutions=this.statEntityFromResponse(t.substitutions),e.substitutionsFirstHalf=this.statEntityFromResponse(t.substitutions_1h),e.substitutionsSecondHalf=this.statEntityFromResponse(t.substitutions_2h),e.substitutionsExtraTime=this.statEntityFromResponse(t.substitutions_et),e.counterAttacks=this.statEntityFromResponse(t.counter_attacks),e.counterAttacksFirstHalf=this.statEntityFromResponse(t.counter_attacks_1h),e.counterAttacksSecondHalf=this.statEntityFromResponse(t.counter_attacks_2h),e.counterAttacksExtraTime=this.statEntityFromResponse(t.counter_attacks_et),e.foulsCommitted=this.statEntityFromResponse(t.fouls_committed),e.foulsCommittedFirstHalf=this.statEntityFromResponse(t.fouls_committed_1h),e.foulsCommittedSecondHalf=this.statEntityFromResponse(t.fouls_committed_2h),e.foulsCommittedExtraTime=this.statEntityFromResponse(t.fouls_committed_et),e}catch(e){throw console.warn("There was a problem remapping the stats",e),e}}statEntityFromResponse=t=>({homeTeam:t?t.home_team:null,awayTeam:t?t.away_team:null})};var jt=class{homeTeam={players:[]};awayTeam={players:[]}};var tr=class{id="";name="";position="";shirtNumber;assets=null;type=""};var qt=class{fromResponse(t){try{let e=new tr;return e.id=t.id,e.name=t.name,e.position=t.position,e.shirtNumber=t.shirt_number,e.assets=t.assets,e.type=t.type,e}catch(e){throw console.warn("There was a problem remapping the player from timeline",e),e}}};var er=class{playerRemapper=null;constructor(){this.playerRemapper=new qt}fromResponse(t){try{let e=new jt;return e.homeTeam.players=t.home_team&&t.home_team.players?t.home_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],e.awayTeam.players=t.away_team&&t.away_team.players?t.away_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping the lineups",e),e}}};var ir=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var rr=class{playerRemapper=null;constructor(){this.playerRemapper=new qt}fromResponse(t){try{let e=new ir;return e.minute=t.minute,e.type=t.type,e.teamId=t.team_id,e.player=this.playerRemapper.fromResponse(t.player),e.relatedPlayer=t.related_player?this.playerRemapper.fromResponse(t.related_player):null,e.updatedAt=t.updated_at,e}catch(e){throw console.warn("There was a problem remapping timeline",e),e}}};var ar=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new O,this.competitionsMapper=new N,this.lineupsMapper=new er,this.scoresMapper=new Kt,this.statsMapper=new Zi,this.timelineMapper=new rr}fromResponse(t){try{let e=new Yi;return e.id=t.id,e.kickoffAt=t.kickoff_at,e.finishedAt=t.finished_at,e.updatedAt=t.updated_at,e.isDeleted=t.is_deleted,e.homeTeam=t.home_team?this.teamMapper.fromResponse(t.home_team):null,e.awayTeam=t.away_team?this.teamMapper.fromResponse(t.away_team):null,e.lineupsConfirmed=t.lineups_confirmed,e.startedAt=t.started_at,e.minute=t.minute,e.scores=this.scoresMapper.fromResponse(t.scores),e.stats=this.statsMapper.fromResponse(t.stats),e.context={competition:this.competitionsMapper.fromResponse(t.context.competition)},e.timeline=t.timeline?t.timeline.map(i=>this.timelineMapper.fromResponse(i)):[],e.status={type:t.status.type,subType:t.status.sub_type},e.lineups=t.lineups?this.lineupsMapper.fromResponse(t.lineups):new jt,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var or=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var sr=class{countryRemapper=null;constructor(){this.countryRemapper=new S}fromResponse(t){try{let e=new or;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.position=t.position,e}catch(e){throw console.warn("There was a problem remapping top player response",e),e}}};var nr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var zt=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new S,this.teamRemapper=new O}fromResponse(t){try{let e=new nr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.position=t.position,e.isDeleted=t.is_deleted,e}catch(e){throw console.warn("There was a problem remapping players response",e),e}}};var lr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var pr=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new S,this.teamRemapper=new O,this.competitionRemapper=new N}fromResponse(t){try{let e=new lr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.position=t.position,e.isDeleted=t.is_deleted,e.competitions=t.competitions?t.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping player response",e),e}}};var cr=class{teams=null;players=null;competitions=null};var dr=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new O,this.playerRemapper=new zt,this.competitionremapper=new N}fromResponse(t){try{let e=new cr;return e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.players=t.players?t.players.map(i=>this.playerRemapper.fromResponse(i)):[],e.competitions=t.competitions?t.competitions.map(i=>this.competitionremapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping search response",e),e}}};var ft=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var W=class{pagination=new ft};var Qt=class{meta=new W;data=[]};var mr=class{remapMetaProp=t=>{let e=new W;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e}};var Z=class extends _{limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(t){super(t,R(t.environment,"football")),this.apiSignInUrl=t.lang!=="en"?this.apiSignInUrl+`&lang=${t.lang}`:this.apiSignInUrl,this.countryRemapper=new S,this.competitionBasicRemapper=new N,this.competitionFullRemapper=new Vi,this.teamBasicRemapper=new O,this.teamFullRemapper=new qi,this.matchBasicRemapper=new Xi,this.matchFullRemapper=new ar,this.playerBasicRemapper=new zt,this.playerFullRemapper=new pr,this.topPlayerRemapper=new sr,this.searchRemapper=new dr,this.footballMetaRemapper=new mr}getCountries=async t=>{let e="There was a problem with the football countries request",i=`/countries${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let a=await this.fetchWithoutAuth(i,e);return this.countryRemapper.countriesFromResponse(a.data)};getCompetitions=async(t,e)=>{let i=Date.now(),r="There was a problem with football competitions request";if(e=e||!1,t&&t.competitionIds&&t.competitionIds.length>this.limitIds-1){let a=[],s=xt(t.competitionIds,this.limitIds);for(let n of s){t.competitionIds=n;let l=`/competitions${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);a.push(c.data.map(d=>this.competitionBasicRemapper.fromResponse(d)))}return Array.prototype.concat.apply([],a)}else{let a=`/competitions${this.apiSignInUrl}`;return t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(a,r)).data.map(p=>this.competitionBasicRemapper.fromResponse(p))}};getCompetitionById=async(t,e)=>{let i=`/competitions/${t}${this.apiSignInUrl}`,r="There was a problem with football competition by ID request",a=Date.now();e&&(i+=`&disable_cache=${a}`);let s=await this.fetchWithoutAuth(i,r);return this.competitionFullRemapper.fromResponse(s.data)};getTopCompetitions=async t=>{let e="There was a problem with top football competitions request",i=`/competitions/top${this.apiSignInUrl}`,r=Date.now();return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,e)).data.map(s=>this.competitionBasicRemapper.fromResponse(s))};getTeams=async(t,e)=>{let i=Date.now(),r="There was a problem with football teams request";if(t&&t.teamIds&&t.teamIds.length>this.limitIds){let a=[],s=xt(t.teamIds,this.limitIds);for(let n of s){t.teamIds=n;let l=`/teams${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);a.push(c.data.map(d=>this.teamBasicRemapper.fromResponse(d)))}return Array.prototype.concat.apply([],a)}else{let a=new Qt,s=`/teams${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(p.meta),a.data=p.data.map(n=>this.teamBasicRemapper.fromResponse(n)),a}};getTeamById=async(t,e)=>{let i="There was a problem with football team by ID request",r=`/teams/${t}${this.apiSignInUrl}`,a=Date.now();e&&(r+=`disable_cache=${a}`);let s=await this.fetchWithoutAuth(r,i);return this.teamFullRemapper.fromResponse(s.data)};getTopTeams=async t=>{let e=`/teams/top${this.apiSignInUrl}`,i="There was a problem with top football teams request",r=Date.now();t&&(e+=`$disable_cache=${r}`);let a=await this.fetchWithoutAuth(e,i);return a.data?a.data.map(s=>this.teamBasicRemapper.fromResponse(s)):[]};getNextMatchForTeam=async(t,e)=>{let i=`/teams/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for team request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForTeam=async(t,e)=>{let i=`/teams/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for team request";e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPlayers=async(t,e)=>{let i=Date.now(),r="There was a problem with football players request";if(t&&t.playerIds&&t.playerIds.length>this.limitIds-1){let a=[],s=xt(t.playerIds,this.limitIds);for(let n of s){t.playerIds=n;let l=`/players${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);a.push(c.data.map(d=>this.teamBasicRemapper.fromResponse(d)))}return Array.prototype.concat.apply([],a)}else{let a=new Qt,s=`/players${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(p.meta),a.data=p.data.map(n=>this.playerBasicRemapper.fromResponse(n)),a}};getPlayerById=async(t,e)=>{let i=`/players/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with football player by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.playerFullRemapper.fromResponse(s.data)};getTopPlayers=async t=>{let e=`/players/top${this.apiSignInUrl}`,i=Date.now(),r="There was a problem with top football players request";return t&&(e+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(e,r)).data.map(s=>this.topPlayerRemapper.fromResponse(s))};getNextMatchForPlayer=async(t,e)=>{let i=`/players/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForPlayer=async(t,e)=>{let i=`/players/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatchById=async(t,e)=>{let i=`/matches/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with match by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatches=async(t,e)=>{let i=new Qt,r="There was a problem with football matches request";if(t&&t.matchIds&&t.matchIds.length>this.limitIds-1){let a=[],s=xt(t.matchIds,this.limitIds);for(let n of s){t.matchIds=n;let l=`/matches${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=M());let c=await this.fetchWithoutAuth(l,r);i.meta=this.footballMetaRemapper.remapMetaProp(c.meta),a.push(c.data.map(d=>this.matchBasicRemapper.fromResponse(d)))}let p=Array.prototype.concat.apply([],a);return i.data=p,i}else{let a=`/matches${this.apiSignInUrl}`;t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=M());let s=await this.fetchWithoutAuth(a,r);return i.meta=this.footballMetaRemapper.remapMetaProp(s.meta),i.data=s.data.map(p=>this.matchBasicRemapper.fromResponse(p)),i}};search=async(t,e)=>{let i=`/search${this.apiSignInUrl}${t.constructFilterUrl()}`,r=Date.now(),a="There was a problem with football search request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.searchRemapper.fromResponse(s.data)}};var K=(g=>(g.FT_1X2="FT_1X2",g.HT_1X2="HT_1X2",g.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",g.DOUBLE_CHANCE="DOUBLE_CHANCE",g.HT_FT="HT_FT",g.PLAYER_SCORE="PLAYER_SCORE",g.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",g.PLAYER_RED_CARD="PLAYER_RED_CARD",g.RED_CARD_MATCH="RED_CARD_MATCH",g.PENALTY_MATCH="PENALTY_MATCH",g.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",g.CORNERS_MATCH="CORNERS_MATCH",g.CORRECT_SCORE="CORRECT_SCORE",g.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",g.CORRECT_SCORE_HT="CORRECT_SCORE_HT",g.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",g.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",g.OVER_GOALS_0_5="OVER_GOALS_0_5",g.OVER_GOALS_1_5="OVER_GOALS_1_5",g.OVER_GOALS_2_5="OVER_GOALS_2_5",g.OVER_GOALS_3_5="OVER_GOALS_3_5",g.OVER_GOALS_4_5="OVER_GOALS_4_5",g.OVER_GOALS_5_5="OVER_GOALS_5_5",g.OVER_GOALS_6_5="OVER_GOALS_6_5",g.OVER_CORNERS_6_5="OVER_CORNERS_6_5",g.OVER_CORNERS_7_5="OVER_CORNERS_7_5",g.OVER_CORNERS_8_5="OVER_CORNERS_8_5",g.OVER_CORNERS_9_5="OVER_CORNERS_9_5",g.OVER_CORNERS_10_5="OVER_CORNERS_10_5",g.OVER_CORNERS_11_5="OVER_CORNERS_11_5",g.OVER_CORNERS_12_5="OVER_CORNERS_12_5",g.OVER_CORNERS_13_5="OVER_CORNERS_13_5",g))(K||{}),Ks=["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"],js=["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"],tt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],qs=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],je="PLAYER_SCORE_FIRST_GOAL";var ur=class{id="";achievedAt=""};var Xt=class{totalPoints=null;postPoints=null;postsMade=null;reactionPoints=null;reactionCount=null};var qe=class{participations=0;points=0};var Et=class{footballCompetitions=[];footballTeams=[]};var Yt=class{predictionsMade=0;correct=0;points=0;breakdown=new Et};var Jt=class{single=new Yt;topX=new qe;matchQuiz=new qe};var hr=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var gr=class{profileId;tier;points;predictionsMade;successRates=new hr;predictions=new Jt;tiers=[];badges=[];discussions=new Xt};var fr=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var yr=class{successRatePercent;model=null};var Zt=class{content=null;tags=[];campaign=null};var te=class{id=null;profileId=null;property=null;value=null;action=null;context=new Zt;points=0};var br=class{meta=new W;data=[new te]};var Mr=class{remapSingleResponse=t=>{let e=new te;return e.id=t.id,e.profileId=t.profile_id,e.property=t.property,e.value=t.value,e.action=t.action,e.context.content=t.context.content,e.context.tags=t.context.tags,e.context.campaign=t.context.campaign,e.points=t.points,e};remapActivitiesResponse=t=>{let e=new br;return e.meta.pagination.currentPage=t.meta.pagination.current_page,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.meta.pagination.numberOfPages=t.meta.pagination.number_of_pages,e.meta.pagination.totalItems=t.meta.pagination.total_items,e.data=t.data.map(i=>this.remapSingleResponse(i)),e};remapStatsResponse=t=>{let e=new gr;return e.profileId=t.profile_id,e.tier=t.tier,e.points=t.points,e.predictionsMade=t.predictions_made,e.successRates.overallPercent=t.success_rates.overall_percent,e.successRates.byFootballCompetition=this.constructNewRecord(t.success_rates.by_competition),e.successRates.byFootballTeam=this.constructNewRecord(t.success_rates.by_team),e.successRates.byFootballMarket=this.constructNewRecord(t.success_rates.by_market),e.predictions=t.predictions?this.remapPredictionsStats(t.predictions):null,e.tiers=t.tiers?this.remapAchievementsStats(t.tiers):null,e.badges=t.badges?this.remapAchievementsStats(t.badges):null,e.discussions=t.discussions?this.remapDiscussionStats(t.discussions):null,e};constructNewRecord=t=>{let e;if(Object.entries(t).length)Object.entries(t).forEach(([i,r])=>{e={...e,[i]:this.remapSuccessRatePercent(r)},K[i]&&delete e[i].model});else return t;return e};remapSuccessRatePercent=t=>{let e=new yr;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new Jt;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new Yt;return e.predictionsMade=t.predictions_made,e.correct=t.correct,e.points=t.points,e.breakdown=this.remapBreakdownSinglePredictionsStats(t.breakdown),e};remapBreakdownSinglePredictionsStats=t=>{if(t&&Object.keys(t).length){let e=new Et,i=[],r=[];return Object.keys(t).forEach(a=>{let s=new fr;s.entityId=a,s.entityType=t[a].entity_type,s.entitySource=t[a].entity_source,s.predictionsMade=t[a].predictions_made,s.correct=t[a].correct,s.points=t[a].points,s.entityType==="competition"?i.push(s):s.entityType==="team"&&r.push(s)}),e.footballCompetitions=i,e.footballTeams=r,e}return new Et};remapAchievementsStats=t=>t.map(e=>{let i=new ur;return i.id=e.id,i.achievedAt=e.achieved_at,i});remapDiscussionStats=t=>{let e=new Xt;return e.totalPoints=t.total_points,e.postPoints=t.post_points,e.postsMade=t.posts_made,e.reactionPoints=t.reaction_points,e.reactionCount=t.reaction_count,e}};var ee=class extends _{activityRemapper=null;constructor(t){super(t,R(t.environment,"loyalty")),this.activityRemapper=new Mr}createActivity=async t=>{let e=`/activities${this.apiSignInUrl}`,i="There was a problem with creating activity",r="POST",a=await this.fetchWithAuth(e,i,r,t);return this.activityRemapper.remapSingleResponse(a)};deleteActivity=async t=>{let e=`/activities/${t}${this.apiSignInUrl}`,i=`There was a problem deleting the following activity: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getOwnActivities=async(t,e)=>{let i=`/activities${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with fetching own activities";t&&(i+=`${t.constructFilterUrl()}`),e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithAuth(i,a);return this.activityRemapper.remapActivitiesResponse(s)};getActivitiesForUser=async(t,e,i)=>{let r=`/users/${t}/activities${this.apiSignInUrl}`,a=Date.now(),s=`There was a problem with fetching activities for user: ${t}`;e&&(r+=`${e.constructFilterUrl()}`),i&&(r+=`disable_cache=${a}`);let p=await this.fetchWithoutAuth(r,s);return this.activityRemapper.remapActivitiesResponse(p)};getStats=async(t,e)=>{let i="",r="",a=null;return t?(i+=I(e)?`/users/${t}/statistics${this.apiSignInUrl}${M()}`:`/users/${t}/statistics${this.apiSignInUrl}`,r=`There was a problem fetching statistics for profile: ${t}`,a=await this.fetchWithoutAuth(i,r)):(i+=`/statistics${this.apiSignInUrl}`,r="There was a problem fetching profile`s statistics",a=await this.fetchWithAuth(i,r)),this.activityRemapper.remapStatsResponse(a.data)}};var wr=class{id="";source="";type="";favourite=!1};var Ir=class extends wr{model=null};var Pr=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(t,e,i){this.idMapping=i,this.idSchema=t.idSchema,this.footballFacade=e}remapProfileStats=async t=>{if(!t.predictions)return t;let{successRates:e,predictions:i}=t,r={competition:this.getIdsKeys(e.byFootballCompetition,i.single.breakdown.footballCompetitions),team:this.getIdsKeys(e.byFootballTeam,i.single.breakdown.footballTeams)};if(Object.values(r.competition).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballCompetition)),s=await this.getEntitiesMap(r.competition,"competition"),p=await this.setSuccessRatesModels(a,s);t.successRates.byFootballCompetition=p,i.single.breakdown.footballCompetitions=this.reconstructBreakdown(i.single.breakdown.footballCompetitions,s)}if(Object.values(r.team).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballTeam)),s=await this.getEntitiesMap(r.team,"team"),p=await this.setSuccessRatesModels(a,s);t.successRates.byFootballTeam=p,i.single.breakdown.footballTeams=this.reconstructBreakdown(i.single.breakdown.footballTeams,s)}return t};setSuccessRatesModels=async(t,e)=>{let i;return this.reconstructRecords(t,i,e)};getEntitiesMap=async(t,e)=>{switch(e){case"competition":return await this.footballFacade.getCompetitionsMapWithNativeIds(t);case"team":return await this.footballFacade.getTeamsMapWithNativeIds(t)}};reconstructRecords=(t,e,i)=>t&&Object.keys(t).length?(Object.keys(t).forEach(r=>{let a=i.get(r);e={...e,[a.id]:t[r]},e[a.id].model=a}),e):t;reconstructBreakdown=(t,e)=>t.length?t.map(i=>{let r=e.get(i.entityId);return i.entityId=r.id,i.model=r,i}):t;getIdsKeys=(t,e)=>{let i=Object.keys(t);if(e.length){let r=e.map(a=>a.entityId);return Array.from(new Set([...i,...r]))}return i};remapInterestsToIdSchema=async t=>{if(this.idSchema!==this.native)if(t&&t.length>0){let e={},i={},r=t.filter(n=>n.source.toLocaleUpperCase()==="FOOTBALL"),a=t.filter(n=>n.source.toLocaleUpperCase()!=="FOOTBALL");r.forEach(n=>{e.hasOwnProperty(n.type)||(e[n.type]=[],i[n.type]=[]),e[n.type].push(n.id),i[n.type].push(n)});let s=await this.remapIdsObj(e,this.native,this.idSchema),p=[];for(let[n,l]of Object.entries(i))l.forEach((c,d)=>{c.id=s[n][d],p.push(c)});return p.concat(a)}else return t;return t};remapInterestToNative=async t=>{if(this.idSchema!==this.native&&t.source.toLocaleUpperCase()==="FOOTBALL"){let e={},{id:i,type:r}=t;e[r]=[i];let a=await this.remapIdsObj(e,this.idSchema,this.native);return t.id=a[r][0],t}return t};inquiryCustomInterests=(t,e)=>{let i=[];return t&&t.length>0&&(i=t.filter(r=>r.source.toLocaleUpperCase()==="CUSTOM"),e)?i.map(r=>{let a=new Ir;return a.id=r.id,a.type=r.type,a.source=r.source,a.favourite=r.favourite,a}):i};remapInterests=async t=>{let i=this.inquiryCustomInterests(t,!1);if(i&&i.length>0){let r=t.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),a=await this.remapInterestsToIdSchema(r);return i.forEach(s=>a.push(s)),a}return await this.remapInterestsToIdSchema(t)};showFullInterests=async t=>{let e=[];if(t&&t.length>0){let r=this.inquiryCustomInterests(t,!0);e.push(r);let a=t.filter(c=>c.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:p,playersMap:n}=await this.getInterestsEntitiesMap(a),l=a.map(c=>{let d=null;if(c.source.toLocaleUpperCase()==="FOOTBALL"){if(c.type==="competition")return d=s.get(c.id),d&&(c.id=d.id),c.model=d,c;if(c.type==="team")return d=p.get(c.id),d&&(c.id=d.id),c.model=d,c;if(c.type==="player")return n?(c.model=n[c.id],c.id=n[c.id].id):c.model=d,c}else return c.model=d,c});return e.push(l),e.flat()}return e};getInterestsEntitiesMap=async t=>{let e=[],i=[],r=[],a=new Map,s=new Map,p=null;return t.forEach(n=>{n.type==="competition"&&n.source.toLocaleUpperCase()==="FOOTBALL"?e.push(n.id):n.type==="team"&&n.source.toLocaleUpperCase()==="FOOTBALL"?i.push(n.id):n.type==="player"&&n.source.toLocaleUpperCase()==="FOOTBALL"&&r.push(n.id)}),e.length&&(a=await this.footballFacade.getCompetitionsMapWithNativeIds(e)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(p=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:a,teamsMap:s,playersMap:p}};remapIdsObj=async(t,e,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(t,e,i)};var Tr=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new F(t),this.profileOperations=new Pr(t,e,this.idMapping)}remapProfileStats=async t=>await this.profileOperations.remapProfileStats(t);remapInterestToNative=async t=>await this.profileOperations.remapInterestToNative(t);remapInterests=async t=>await this.profileOperations.remapInterests(t);showFullInterests=async t=>await this.profileOperations.showFullInterests(t)};var C=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localCache=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(t){this.profileHttps=new Dt(t),this.activityHttps=new ee(t),this.footballHttps=new Z(t),this.idMapping=new F(t),this.localCache=new V().createLocalCacheInstance(t.idSchema),this.footballFacade=new Wt(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new J(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new Tr(t,this.footballFacade),this.ownProfileBuilder=new bi(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps,t.errorHandlingMode),this.profileBuilder=new Mi(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=t=>this.profileBuilder.setId(t);getCountries=async t=>await this.profileFacade.getCountries(t);getByIds=async(t,e,i)=>await this.profileFacade.getByIds(t,e,i)};var Xo=(h=>(h.EN="en",h.BG="bg",h.RO="ro",h.EL="el",h.SK="sk",h.PT="pt",h.SR="sr",h.HU="hu",h.SV="sv",h.ES="es",h.FR="fr",h.NL="nl",h.DE="de",h.IT="it",h))(Xo||{});var vr=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(Xo),i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no lang is passed the default one will be set which is: en"),t==="invalid"&&(e="This lang value is not supported, the default one will be set which is: en"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var _r=class{validate(t){let e=this.validateField(t.environment),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=["dev","staging","prod","watg"],i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no environment is passed the default one will be set which is: prod"),t==="invalid"&&(e="This environment value is not supported, the default one will be set which is: prod"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Fr=class{validate(t){let e=this.validateField(t.apiKey),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=null;return t!=null&&t.length>0?e="valid":e="missing",e};generateMessage=t=>{let e=null,i="error";return t==="missing"&&(e="The field apiKey with valid value must be provided to use Fans United JS SDK"),t==="valid"&&(i=null),{text:e,type:i}}};var Er=class{validate(t){let e=this.validateField(t.idSchema),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=Object.values(x),i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no idSchema is passed the default one will be set which is: native"),t==="invalid"&&(e="This idSchema value is not supported, the default one will be set which is: native"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var St=class{getIdToken=null;logout=null};var re=class{text=null;type=null};var Rr=class{validation=null;message=new re;getIdToken={validation:null,message:new re};logout={validation:null,message:new re}};var Sr=class{validate(t){let e=this.validateAuthProvider(t.authProvider);return e.validation!=="missing"&&(e=this.validateAuthProviderConfigFields(t.authProvider,e),e=this.generateAuthProviderConfigMessages(e),e=this.checkAuthProviderConfigMessagesForErrors(e)),e}validateAuthProvider=t=>{let e=Object.keys(new St),i=new Rr;if(t){let a=Object.keys(t).filter(s=>!e.includes(s));a.length>0?(i.validation="invalid",i.message.type="warning",i.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):i.validation="valid"}else i.validation="missing",i.message.type="error",i.message.text="The field authProvider must be provided to use this SDK";return i};validateAuthProviderConfigFields=(t,e)=>(Object.keys(new St).forEach(r=>{t[r]?e[r].validation="valid":e[r].validation="missing"}),e);generateAuthProviderConfigMessages=t=>(Object.keys(t).filter(e=>e!=="validation"&&e!=="message").forEach(e=>{let i=t[e];i.validation==="missing"&&(i.message.text=`${"The following property is missing from the authProvider object:"} ${e}`,i.message.type="error")}),t);checkAuthProviderConfigMessagesForErrors=t=>(Object.keys(t).filter(e=>e!=="validation"&&e!=="message").forEach(e=>{t[e].validation==="missing"&&t.validation==="valid"&&(t.validation="invalid",t.message.type="error",t.message.text="The field authProvider has missing properties")}),t)};var Qe=class{validation;message};var Cr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Qe,logout:new Qe};isValid=!1};var Ar=class{validate(t){let e=this.validateField(t.clientId),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=null;return t!=null&&t.length>0?e="valid":e="missing",e};generateMessage=t=>{let e=null,i="error";return t==="missing"&&(e="The field clientId must be provided to use Fans United JS SDK"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Or=class{validate=t=>{let e=this.validateField(t.errorHandlingMode),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=["default","standard"],i=null;return t?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no errorHandlingMode is passed the default one will be set which is: default"),t==="invalid"&&(e="This errorHandlingMode value is not supported, the default one will be set which is: default"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Lr=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new Cr,i={apiKey:new Fr,environment:new _r,idSchema:new Er,clientId:new Ar,lang:new vr,errorHandlingMode:new Or,authProvider:new Sr};for(let[r,a]of Object.entries(e))r!=="isValid"&&(a=i[r].validate(t));return Object.keys(i).forEach(r=>{e[r]=i[r].validate(t)}),e};containsErrorMessage=t=>{let e=!0;for(let[i,r]of Object.entries(t))if(i!=="authProvider"){if(i!=="isValid"&&r.message.type==="error")return e=!1,e;if(i!=="isValid"&&r.message.type==="warning")return e=!0,e}else if(r.message.type==="error")return e=!1,e;return e}};var et=class{https=null;idMapping=null;localCache=null;footballFacade=null;constructor(t){this.https=new Z(t),this.idMapping=new F(t),this.localCache=new V().createLocalCacheInstance(t.idSchema),this.footballFacade=new Wt(t,this.localCache,this.https,this.idMapping)}getCountries=async t=>await this.footballFacade.getCountries(t);getCompetitions=async(t,e)=>await this.footballFacade.getCompetitions(t,e);getCompetitionById=async(t,e)=>await this.footballFacade.getCompetitionById(t,e);getTopCompetitions=async t=>await this.footballFacade.getTopCompetitions(t);getTeams=async(t,e)=>await this.footballFacade.getTeams(t,e);getTeamById=async(t,e)=>await this.footballFacade.getTeamById(t,e);getTopTeams=async t=>await this.footballFacade.getTopTeams(t);getNextMatchForTeam=async(t,e)=>await this.footballFacade.getNextMatchForTeam(t,e);getPrevMatchForTeam=async(t,e)=>await this.footballFacade.getPrevMatchForTeam(t,e);getPlayers=async(t,e)=>await this.footballFacade.getPlayers(t,e);getPlayerById=async(t,e)=>await this.footballFacade.getPlayerById(t,e);getTopPlayers=async t=>await this.footballFacade.getTopPlayers(t);getNextMatchForPlayer=async(t,e)=>await this.footballFacade.getNextMatchForPlayer(t,e);getPrevMatchForPlayer=async(t,e)=>await this.footballFacade.getPrevMatchForPlayer(t,e);getMatches=async(t,e)=>await this.footballFacade.getMatches(t,e);getMatchById=async(t,e)=>await this.footballFacade.getMatchById(t,e);search=async(t,e)=>await this.footballFacade.search(t,e)};var xr=class{value=null;playerId=null;playerModel=null};var ae=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new xr;result=null};var Dr=class{value=!1;playerId=null};var j=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i,r){this.matchId=t,this.market=e,this.prediction=new Dr,this.prediction.value=i,this.prediction.playerId=r}};var oe=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var Br=class{value=null};var yt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new Br,this.prediction.value=i}};var q=class{value=!1};var se=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new q,this.prediction.value=i}};var ne=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new q,this.prediction.value=i}};var Nr=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e,i){this.matchFacade=t,this.playerFacade=e,this.predictorService=i}remapFixturesRequest=t=>{let e={};if(e.match_id=t.matchId,e.match_type="FOOTBALL",t instanceof j)e.market=t.market,e.prediction=t.prediction.value,e.player_id=t.prediction.playerId;else if(t instanceof se||t instanceof ne)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof yt){e.market=t.market;let i=t.prediction.value.split(":");e.goals_home=Number(i[0]),e.goals_away=Number(i[1])}else e.market=t.market,e.prediction=t.prediction.value;return e};remapFixturesResponse=async t=>{let e="OWN_GOAL",i=[],r=[],a=null,s=[];t.length>1&&t.sort((n,l)=>n.match_id.localeCompare(l.match_id));for(let n of t)i.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let p=await this.matchFacade.getMatchesMapWithNativeIds(i);r.sort((n,l)=>n.localeCompare(l)),r&&r.length>0&&!r.includes(e)&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of t){let l=new ae;n.target?l.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):l.market=n.market,l.matchId=p[n.match_id].id,l.matchType=n.match_type,l.matchModel=p?p[n.match_id]:null,delete l.matchModel.availableMarkets,n.goals_home!==void 0&&n.goals_away!==void 0?l.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():l.prediction.value=n.prediction,l.prediction.playerId=n.player_id?n.player_id:null,l.prediction.playerId&&l.prediction.playerId!==e&&(l.prediction.playerModel=a[n.player_id],l.prediction.playerId=a[n.player_id].id),l.result=this.remapResult(n.result),s.push(l)}return s};remapResult=t=>{let e=new oe;return e.settledAt=t.settled_at,e.resettledAt=t.resettled_at,e.status=t.status,e.outcome=t.outcome,e.points=t.points,e}};var it=class{goldenGoal=null};var Xe=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new it;points=null;createdAt=null;updatedAt=null};var T=class{no=0;yes=0};var Ur=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new T;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new T;penaltyMatch=new T;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new T;overOnePointFiveGoals=new T;overTwoPointFiveGoals=new T;overThreePointFiveGoals=new T;overFourPointFiveGoals=new T;overFivePointFiveGoals=new T;overSixPointFiveGoals=new T;overSixPointFiveCorners=new T;overSevenPointFiveCorners=new T;overEightPointFiveCorners=new T;overNinePointFiveCorners=new T;overTenPointFiveCorners=new T;overElevenPointFiveCorners=new T;overTwelvePointFiveCorners=new T;overThirteenPointFiveCorners=new T};var rt=class{timeTiebreaker=!1};var bt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new rt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null;predictionTiebreaker=new it};var Ct=class{userId=null;points=null;results=[];tiebreaker=null};var Yo=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(Yo||{}),ps=["WON","LOST","PARTIALLY_WON","CANCELED"];var D=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;gameIds=null;constructor(t){this.limit=t.limit?t.limit:null,this.startAfter=t.startAfter?t.startAfter:null,this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.matchIds=t.matchIds?t.matchIds:null,this.gameIds=t.gameIds?t.gameIds:null}constructFiltersUrl=()=>{let t="",e=!1;return this.status&&(e=Object.values(Yo).some(i=>this.status.includes(i))),this.limit&&(t+="&",t+=`limit=${this.limit}`),this.startAfter&&(t+="&",t+=`start_after=${this.startAfter}`),this.status&&e&&(t+="&",t+=`status=${this.status.join(",")}`),this.type&&(t+="&",t+=`game_types=${this.type}`),this.matchIds&&(t+="&",t+=`match_ids=${this.matchIds.join(",")}`),this.gameIds&&(t+="&",t+=`game_ids=${this.gameIds.join(",")}`),t}};var L=class{limit;startAfter;constructor(t){this.limit=t&&t.limit?t.limit:null,this.startAfter=t&&t.startAfter?t.startAfter:null}constructMainFiltersUrl(){let t="";return this.limit&&(t+="&",t+=`limit=${this.limit}`),this.startAfter&&(t+="&",t+=`start_after=${this.startAfter}`),t}};var Hr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(Hr||{});var z=class extends L{status=null;type=null;gameIds=null;sortOrder=null;constructor(t){super(t),this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.gameIds=t.gameIds?t.gameIds:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.status&&Object.values(Hr).includes(this.status)&&(t+="&",t+=`status=${this.status}`),this.type&&(t+="&",t+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(t+="&",t+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(t+="&",t+=`sort_order=${this.sortOrder}`),t}};var at=class{main=null;cover=null;mobile=null};var lt=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new rt;participantsCount=0;related=null;excludedProfileIds=null;rules=null;labels=null;customFields=null;flags=null;images=new at;createdAt=null;updatedAt=null};var pt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new rt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var le=class extends lt{adContent=null};var ot=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(t,e){this.footballHttps=new Z(t),this.idMapping=e,this.matchFacade=new gt(t,this.footballHttps,e),this.playerFacade=new ht(t,this.footballHttps,e),this.profileNamespace=new C(t)}remapMatchIdToNative=async t=>(await this.idMapping.getEntityIdsBySchemaId(t,"match","native")).match;remapPlayerIdToNative=async t=>(await this.idMapping.getEntityIdsBySchemaId(t,"player","native")).player[0];remapPlayerIdMapToNative=async t=>{let e={},i=_t(t),a=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,p)=>e[s]=a[p]),e};remapPlayerIdToIdSchema=async t=>{let e=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[a,s]of Object.entries(t))if(e.includes(a))for(let p of Object.keys(s))p!=="NOBODY"&&p!=="OWN_GOAL"&&i.push(p);if(!i.length)return t;let r=await this.playerFacade.getPlayersMapWithNativeIds(i);for(let[a,s]of Object.entries(t))if(e.includes(a))for(let p of Object.keys(s))p!=="NOBODY"&&p!=="OWN_GOAL"&&(s[r[p].id]=s[p],s[r[p].id].model=r[p],this.idMapping.idSchema!=="native"&&delete s[p]);return t};convertMarketForResponseModel=(t,e)=>{let i=e.toString();return t+"_"+i};getMarketSummary=async(t,e,i)=>{let r=ws.get(e),a={};if(a.matchId=t.matchId,a.matchType=t.matchType,Object.keys(t.predictions).includes(r))a[r]=t.predictions[r];else throw new Error("You have passed invalid market");if(tt.includes(e)&&i){let p="";if(i!=="OWN_GOAL"&&i!=="NOBODY"&&(p=(await this.idMapping.idMappingFacade.getEntitiesByIds({player:[i]},this.idMapping.idSchema,"native")).player[0]),p&&a[r][p]){let n=await this.playerFacade.getPlayersMapWithNativeIds([p]);return a[r][p].model=n[p],a[r][p]}else return p?(a[r][p]=new T,a[r][p]):a[r][i]}else if(tt.includes(e)&&!i){let p=Object.keys(a[r]).filter(l=>l!=="NOBODY"&&l!=="OWN_GOAL"),n=p.length?await this.playerFacade.getPlayersMapWithNativeIds(p):{};Object.keys(n).length&&Object.keys(a[r]).forEach(l=>{l!=="NOBODY"&&l!=="OWN_GOAL"&&(a[r][n[l].id]=a[r][l],a[r][n[l].id].model=n[l],this.idMapping.idSchema!=="native"&&delete a[r][l])})}return a};remapCompetitionsFromConfig=async t=>{if(t instanceof Vt){let e={competition:t.fullCoverageCompetitions},i={competition:t.successRateScopes.competitions},r={team:t.successRateScopes.teams},a=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return t.fullCoverageCompetitions=a.competition,t.successRateScopes.competitions=s.competition,t.successRateScopes.teams=p.team,t}if(t instanceof Gt||t instanceof kt){let e={competition:t.competitionsWhitelist},i=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema);return t.competitionsWhitelist=i.competition,t}};remapMatchIdsFixtures=async t=>{if(Array.isArray(t.data))if(t.data.length>0){let e=[],i=[];return t.data.forEach(r=>{r instanceof lt||r instanceof bt||r instanceof pt||r instanceof le?(r.fixtures.forEach(a=>e.push(a.matchId)),r instanceof pt&&r.fixtures.forEach(a=>{a.prediction.playerId&&a.prediction.playerId!=="OWN_GOAL"&&i.push(a.prediction.playerId)})):r instanceof Ct&&r.results.forEach(a=>e.push(a.matchId))}),await this.refactorResponseArrModel(t,e,i)}else return t;else return await this.refactorResponseObjModel(t)};refactorResponseArrModel=async(t,e,i)=>{let r=[],a=await this.matchFacade.getMatchesMapWithNativeIds(e),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),t.data.forEach(p=>{p instanceof lt||p instanceof bt||p instanceof pt?(p.fixtures.forEach(n=>{this.handleMatchModel(a,n),p instanceof pt&&n.prediction.playerId&&n.prediction.playerId!=="OWN_GOAL"&&(n.prediction.playerModel=s[n.prediction.playerId],n.prediction.playerId=s[n.prediction.playerId].id)}),r.push(p)):p instanceof Ct&&(p.results.forEach(n=>{n.matchModel=a[n.matchId],delete n.matchModel.availableMarkets,n.matchId=n.matchModel.id}),r.push(p))}),t.data=r,t};refactorResponseObjModel=async t=>{let e=[];t.fixtures.forEach(r=>e.push(r.matchId));let i=await this.matchFacade.getMatchesMapWithNativeIds(e);return t.fixtures.forEach(r=>this.handleMatchModel(i,r)),t};getCurrentGameId=t=>{let e=new Date;if(t.data.length>1){let i=[];return t.data.forEach(a=>i.push(a.predictionsCutoff)),t.data.sort((a,s)=>{let[p,n]=[a.predictionsCutoff,s.predictionsCutoff].map(l=>Math.abs(new Date(l)-e));return p-n})[0].id}else return t.data[0].id};initGameTypePredictions=(t,e)=>{let i={type:t,limit:null,startAfter:null};return e&&(i={...i,limit:e.limit,startAfter:e.startAfter}),i=new D(i),i};initGameFilters=(t,e,i)=>{if(e&&i)return e.type=t,e.gameIds=i,e=new z(e),e;if(e&&!i)return e.type=t,e=new z(e),e;if(!e&&i){let r={type:t,gameIds:i};return r=new z(r),r}else{let r={type:t};return r=new z(r),r}};addPredictionProp=async(t,e)=>(e.data.forEach(i=>{t.data.forEach(r=>{i.id===r.game_instance_id&&(i.predictionId=r.id,i.outcome=r.status,i.fixtures.forEach((a,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?a.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:a.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?a.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(a.prediction.target=r.fixtures[s].target),a.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof bt&&(r.tiebreaker?i.predictionTiebreaker.goldenGoal=r.tiebreaker.golden_goal:i.predictionTiebreaker=r.tiebreaker))})}),e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(e));remapResult=t=>{let e=new oe;return e.settledAt=t.settled_at,e.resettledAt=t.resettled_at,e.status=t.status,e.outcome=t.outcome,e.points=t.points,e};areIdsExceeded=t=>t.length>10;initPredictionsFilters=(t,e,i)=>{switch(e){case"user":t&&(t=new D(t));break;case"current":if(t)this.deleteUnexpectedProperties(t),t.status=["ACTIVE"],t=new D(t);else{let r={status:["ACTIVE"]};t=new D(r)}break;case"past":if(t)this.deleteUnexpectedProperties(t),t.status=ps,t=new D(t);else{let r={status:ps};t=new D(r)}break;case"matches":if(t)this.deleteUnexpectedProperties(t),t.matchIds=i,t=new D(t);else{let r={matchIds:i};t=new D(r)}break}return t};completeGameMarketResults=async(t,e)=>{switch(e){case"MATCH_QUIZ":let i={},r=t.results[0].matchId,a=t.results.map(l=>tt.includes(l.market)&&!l.result.includes("OWN_GOAL")?[...l.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return a.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(a)),t.results=t.results.map(l=>{if(l.matchModel=s[l.matchId]?s[l.matchId]:null,l.playerModels&&Object.keys(i).length&&l.result.forEach(d=>{let m=i[d];l.playerModels.push(m)}),this.idMapping.idSchema!=="native"&&(this.remapMatchIdForResultsMarkets(s,l),l.playerModels&&Object.keys(i).length)){let c=l.result;l.result=c.map(d=>i[d].id)}return l}),t;case"TOP_X":let p=t.results.map(l=>l.matchId),n=await this.matchFacade.getMatchesMapWithNativeIds(p);if(t.results=t.results.map(l=>(l.matchModel=n[l.matchId]?n[l.matchId]:null,this.idMapping.idSchema!=="native"&&this.remapMatchIdForResultsMarkets(n,l),l)),t.tieBreakers.goldenGoals.length){let l=t.tieBreakers.goldenGoals.map(d=>d.playerId),c=await this.playerFacade.getPlayersMapWithNativeIds(l);t.tieBreakers.goldenGoals=t.tieBreakers.goldenGoals.map(d=>(d.matchModel=n[d.matchId],d.playerModel=c[d.playerId],this.idMapping.idSchema!=="native"&&(d.matchId=n[d.matchId].id,d.playerId=c[d.playerId].id),d))}return t}};completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};handleMatchModel=(t,e)=>{t[e.matchId]?(e.matchModel=t[e.matchId],delete e.matchModel.availableMarkets,e.matchId=e.matchModel.id):(e.matchModel=null,this.idMapping.idSchema!=="native"&&this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[A[this.idMapping.idSchema]]}))};remapMatchIdForResultsMarkets=(t,e)=>{t[e.matchId]?e.matchId=t[e.matchId].id:this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[A[this.idMapping.idSchema]]})};deleteUnexpectedProperties=t=>(t.status&&(console.warn(os.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(os.UNEXPECTED_TYPE_PROP),delete t.type),t)};var pe=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new yt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var ce=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new Z(t),this.matchFacade=new gt(t,this.footballHttps,e),this.playerFacade=new ht(t,this.footballHttps,e),this.predictorService=new ot(t,e),this.fixturesRemapper=new Nr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=t=>{let e={};return e.game_instance_id=t.gameInstanceId,e.fixtures=t.fixtures.map(i=>this.fixturesRemapper.remapFixturesRequest(i)),t instanceof pe&&t.tiebreaker&&(e.tiebreaker={},e.tiebreaker.golden_goal=t.tiebreaker.goldenGoal?t.tiebreaker.goldenGoal:null),e};remapResponseArrayBody=async t=>{if(t.length){let e="OWN_GOAL",i=[],r=[],a={},s=[];t.forEach(n=>{n.fixtures.forEach(l=>{i.push(l.match_id),l.player_id&&l.player_id!==e&&r.push(l.player_id)})});let p=await this.matchFacade.getMatchesMapWithNativeIds(i);return r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r)),t.forEach(n=>{let l=new Xe,c=[];l.id=n.id,l.gameInstanceId=n.game_instance_id,l.gameType=n.game_type,l.wager=n.wager,l.totalFixtures=n.total_fixtures,l.settledFixtures=n.settled_fixtures,l.userId=n.user_id,n.fixtures.forEach(d=>{let m=new ae;d.target?m.market=this.predictorService.convertMarketForResponseModel(d.market,d.target):m.market=d.market,m.matchId=p[d.match_id].id,m.matchType=d.match_type,m.matchModel=p[d.match_id],delete m.matchModel.availableMarkets,d.goals_home!==void 0&&d.goals_away!==void 0?m.prediction.value=d.goals_home.toString()+":"+d.goals_away.toString():m.prediction.value=d.prediction,m.prediction.playerId=d.player_id?d.player_id:null,m.prediction.playerId&&m.prediction.playerId!==e&&(m.prediction.playerModel=a[m.prediction.playerId],m.prediction.playerId=a[m.prediction.playerId].id),m.result=this.fixturesRemapper.remapResult(d.result),c.push(m)}),l.fixtures=c,l.status=n.status,n.tiebreaker?l.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:l.tiebreaker=null,l.points=n.points,l.createdAt=n.created_at,l.updatedAt=n.updated_at,s.push(l)}),s}return t};remapResponseObjBody=async t=>{let e=new Xe;return e.id=t.id,e.gameInstanceId=t.game_instance_id,e.gameType=t.game_type,e.wager=t.wager,e.totalFixtures=t.total_fixtures,e.settledFixtures=t.settled_fixtures,e.userId=t.user_id,e.fixtures=await this.fixturesRemapper.remapFixturesResponse(t.fixtures),e.status=t.status,t.tiebreaker?e.tiebreaker.goldenGoal=t.tiebreaker.golden_goal:e.tiebreaker=null,e.points=t.points,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapPredictionModel=t=>{let e=new Ur;return e.fullTimeOneXTwo=t.FT_1X2,e.halfTimeOneXTwo=t.HT_1X2,e.bothTeamsScore=t.BOTH_TEAMS_SCORE,e.overZeroPointFiveGoals=t.OVER_GOALS_0_5,e.overOnePointFiveGoals=t.OVER_GOALS_1_5,e.overTwoPointFiveGoals=t.OVER_GOALS_2_5,e.overThreePointFiveGoals=t.OVER_GOALS_3_5,e.overFourPointFiveGoals=t.OVER_GOALS_4_5,e.overFivePointFiveGoals=t.OVER_GOALS_5_5,e.overSixPointFiveGoals=t.OVER_GOALS_6_5,e.overSixPointFiveCorners=t.OVER_CORNERS_6_5,e.overSevenPointFiveCorners=t.OVER_CORNERS_7_5,e.overEightPointFiveCorners=t.OVER_CORNERS_8_5,e.overNinePointFiveCorners=t.OVER_CORNERS_9_5,e.overTenPointFiveCorners=t.OVER_CORNERS_10_5,e.overElevenPointFiveCorners=t.OVER_CORNERS_11_5,e.overTwelvePointFiveCorners=t.OVER_CORNERS_12_5,e.overThirteenPointFiveCorners=t.OVER_CORNERS_13_5,e.doubleChance=t.DOUBLE_CHANCE,e.halfTimeFullTime=t.HT_FT,e.playerScore=t.PLAYER_SCORE,e.playerYellowCard=t.PLAYER_YELLOW_CARD,e.playerRedCard=t.PLAYER_RED_CARD,e.redCardMatch=t.RED_CARD_MATCH,e.penaltyMatch=t.PENALTY_MATCH,e.playerScoreFirstGoal=t.PLAYER_SCORE_FIRST_GOAL,e.cornersMatch=t.CORNERS_MATCH,e.correctScore=t.CORRECT_SCORE,e.correctScoreHalfTime=t.CORRECT_SCORE_HT,e.correctScoreAdvanced=t.CORRECT_SCORE_ADVANCED,e.playerScoreHattrick=t.PLAYER_SCORE_HATTRICK,e.playerScoreTwice=t.PLAYER_SCORE_TWICE,e}};var kr=class{matchId=null;matchType=null;predictions=null};var Gr=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new ce(t,e)}remapResponse=t=>{let e=new kr;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var Vr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new $};var $r=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Wr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new $;prediction=new $r};var Kr=class{value=null;result=null};var jr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new $;prediction=new Kr};var qr=class{matchId=null;matchModel=null;outcome=null};var zr=class{gameId=null;results=null;tieBreakers=null};var de=class{entityId=null;entityType=null};var Qr=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var Xr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Yr=class{remapPaginatedGames=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapGamesListResponse(i)),e};remapGamesListResponse=t=>{let e=new lt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.scheduleOpenAt=t.schedule_open_at,e.predictionsCutoff=t.predictions_cutoff,e.fixtures=t.fixtures.map(i=>this.remapFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.labels=t.labels,e.customFields=t.custom_fields,e.flags=t.flags,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapGameByIdResponse=t=>{let e=new le;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.scheduleOpenAt=t.schedule_open_at,e.predictionsCutoff=t.predictions_cutoff,e.fixtures=t.fixtures.map(i=>this.remapFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.adContent=t.ad_content,e.labels=t.labels,e.customFields=t.custom_fields,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapFixturesResponse=t=>{let e=new Vr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedUserTopXEditions=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapUserTopXEditionsResponse(i)),e};remapUserTopXEditionsResponse=t=>{let e=new bt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.predictionsCutoff=t.predictions_cutoff,e.scheduleOpenAt=t.schedule_open_at,e.fixtures=t.fixtures.map(i=>this.remapTopXFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapTopXFixturesResponse=t=>{let e=new jr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedUserMathQuizEditions=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapUserMatchQuizEditionsResponse(i)),e};remapUserMatchQuizEditionsResponse=t=>{let e=new pt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.predictionsCutoff=t.predictions_cutoff,e.scheduleOpenAt=t.schedule_open_at,e.fixtures=t.fixtures.map(i=>this.remapMatchQuizFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMatchQuizFixturesResponse=t=>{let e=new Wr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedGameResults=t=>{let e=new E;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapGameResults(i)),e};remapGameResults=t=>{let e=new Ct;return e.userId=t.user_id,e.points=t.points?t.points:0,e.results=t.results.map(i=>this.remapResults(i)),e.tiebreaker=t.tiebreaker?this.remapTiebreaker(t.tiebreaker):null,e};remapGameMarketsResults=t=>{let e=new zr;return e.gameId=t.game_id,e.results=this.remapMarketsResults(t.results),e.tieBreakers=t.tie_breakers?this.remapTieBreakers(t.tie_breakers):null,e};remapContestWinners=t=>{let e=new Qr;return e.contestId=t.contest_id,e.contestType=t.contest_type,e.description=t.description,e.userList=t.user_list?t.user_list.map(i=>this.remapUserListWinners(i)):null,e};remapUserListWinners=t=>{let e=new Xr;return e.position=t.position,e.profileId=t.profile_id,e.note=t.note,e.tags=t.tags,e};remapTieBreakers=t=>{let e={goldenGoals:[]};return e.goldenGoals=t.golden_goals.map(i=>({minute:i.minute,matchId:i.match_id,matchModel:null,playerId:i.player_id,playerModel:null,goalType:i.goal_type})),e};remapMarketsResults=t=>{let e=[];return t.forEach(i=>{let r={matchId:i.match_id,market:i.market,result:this.remapMarketResult(i.market,i.result),matchModel:null,playerModels:[],matchStatus:this.remapMarketsResultsMatchStatus(i.match_status)};e.push(this.deleteUnusefulField(r))}),e};remapMarketsResultsMatchStatus=t=>{let e=new $;return t&&(e.type=t.type,e.subType=t.sub_type),e};remapMarketResult=(t,e)=>{if(qs.includes(t))return e[0];if(tt.includes(t))return e;if(e[0]==="true")return!0;if(e[0]==="false")return!1};deleteUnusefulField=t=>((!tt.includes(t.market)||this.isPlayerMarketWithNoResult(t.market,t.result))&&delete t.playerModels,t);isPlayerMarketWithNoResult=(t,e)=>tt.includes(t)&&e.length===0;remapResults=t=>{let e=new qr;return e.matchId=t.match_id,e.outcome=t.outcome,e};remapTiebreaker=t=>{let e=new it;return e.goldenGoal=t.golden_goal,e};remapTimeTiebreaker=t=>{let e=new rt;return e.timeTiebreaker=t,e};remapRelated=t=>t.map(e=>{let i=new de;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Jr=class{remapMetaData=t=>{let e=new G;return e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.itemsPerPage=t.pagination.items_per_page,e}};var st=class extends _{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(t,e){super(t,R(t.environment,"predictor")),this.predictionRemapper=new ce(t,e),this.matchSummaryRemapper=new Gr(t,e),this.gamesRemapper=new Yr,this.metaRemapper=new Jr}makeFootballPrediction=async t=>{let e=`/predictions${this.apiSignInUrl}`,i="There was a problem making POST request",r="POST",a=await this.fetchWithAuth(e,i,r,this.predictionRemapper.remapRequestBody(t));return await this.predictionRemapper.remapResponseObjBody(a)};getMatchSummary=async(t,e)=>{let i=I(e)?`/predictions/summary/${t}${this.apiSignInUrl}${M()}`:`/predictions/summary/${t}${this.apiSignInUrl}`,r=`There was a problem fetching predictions for match: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.matchSummaryRemapper.remapResponse(a)};deleteFootballPrediction=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem deleting your prediction: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getMyPredictions=async t=>{let e=new E,i=`/predictions${this.apiSignInUrl}`,r="There was a problem fetching own predictions";t&&(i+=`${t.constructFiltersUrl()}`);let a=await this.fetchWithAuth(i,r);return e.meta=this.metaRemapper.remapMetaData(a.meta),e.data=await this.predictionRemapper.remapResponseArrayBody(a.data),e};getMyPredictionsNoRemap=async t=>{let e=`/predictions${this.apiSignInUrl}${t.constructFiltersUrl()}`,i="There was a problem fetching own predictions";return await this.fetchWithAuth(e,i)};getUserPredictions=async(t,e,i)=>{let r=new E,a=I(e)?`/predictions/users/${t}${this.apiSignInUrl}${M()}`:`/predictions/users/${t}${this.apiSignInUrl}`,s=`There was a problem fetching predictions for user: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(a,s);return r.meta=this.metaRemapper.remapMetaData(p.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(p.data),r};getUserPredictionsNoRemap=async(t,e)=>{let i=`/predictions/users/${t}${this.apiSignInUrl}${e.constructFiltersUrl()}`,r=`There was a problem fetching predictions for user: ${t}`;return await this.fetchWithoutAuth(i,r)};getGames=async(t,e)=>{let i=I(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${M()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,r="There was a problem fetching the games list",a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapPaginatedGames(a)};getGameById=async(t,e)=>{let i=I(e)?`/games/${t}${this.apiSignInUrl}${M()}`:`/games/${t}${this.apiSignInUrl}`,r=`There was a problem fetching the following game: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameByIdResponse(a)};getGamePredictions=async(t,e,i)=>{let r=new E,a=I(e)?`/games/${t}/predictions${this.apiSignInUrl}${M()}`:`/games/${t}/predictions${this.apiSignInUrl}`,s=`There was a problem fetching the predictions for game: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(a,s);return r.meta=this.metaRemapper.remapMetaData(p.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(p.data),r};getUserGameEditions=async(t,e)=>{let i=null,r=I(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${M()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,a="There was a problem fetching the games list",s=await this.fetchWithoutAuth(r,a);return s.data.forEach(p=>{p.type==="TOP_X"?i=this.gamesRemapper.remapPaginatedUserTopXEditions(s):p.type==="MATCH_QUIZ"&&(i=this.gamesRemapper.remapPaginatedUserMathQuizEditions(s))}),i};getGameResults=async(t,e,i)=>{let r=I(e)?`/games/${t}/results/${this.apiSignInUrl}${M()}`:`/games/${t}/results/${this.apiSignInUrl}`,a=`There was a problem fetching the results for the following game: ${t}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return this.gamesRemapper.remapPaginatedGameResults(s)};getMarketResultsForGame=async(t,e)=>{let i=`/games/${t}/correct-results/${this.apiSignInUrl}`,r=`There was a problem fetching the markets correct results for the following game: ${t}`;I(e)&&(i+=`${M()}`);let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(a.data)};getContestWinners=async(t,e)=>{let i=`/winners/${this.apiSignInUrl}&contest_id=${t}`,r=`There was a problem fetching winners for the following game: ${t}`;e&&(i+=M());let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapContestWinners(a)};getPredictionById=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem fetching info for the following prediction: ${t}`,r=await this.fetchWithoutAuth(e,i);return(await this.predictionRemapper.remapResponseArrayBody([r.data]))[0]};getPredictionsByIds=async t=>{let e=`/predictions/by-ids${this.apiSignInUrl}&prediction_ids=${t.join(",")}`,i="There was a problem fetching predictions",r=await this.fetchWithoutAuth(e,i);return await this.predictionRemapper.remapResponseArrayBody(r.data)}};var me=class{gameInstanceId=null;fixtures=null};var cs=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(cs||{}),ds=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(ds||{}),ms=(l=>(l.ONE_ONE="1/1",l.ONE_X="1/x",l.ONE_TWO="1/2",l.X_ONE="x/1",l.X_X="x/x",l.X_TWO="x/2",l.TWO_ONE="2/1",l.TWO_X="2/x",l.TWO_TWO="2/2",l))(ms||{});var Zr=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new q,this.prediction.value=e}};var ta=class{value};var ea=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new ta,this.prediction.value=e}};var ia=class{value=null};var ra=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new ia,this.prediction.value=e}};var aa=class{value=null};var oa=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new aa,this.prediction.value=i}};var sa=class{value=null};var na=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new sa,this.prediction.value=e}};var la=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new q,this.prediction.value=e}};var pa=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new q,this.prediction.value=e}};var Mt=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new me);switch(t){case"MATCH_QUIZ":i.forEach(n=>{r.includes(n)||this.throwInvalidParamException([n])});break;case"TOP_X":let s=e;s.fixtures.forEach(n=>this.validateMarketTopX(n.market));let p="tiebreaker";i.includes(p)&&s.tiebreaker&&this.validateTiebreaker(s.tiebreaker),i.forEach(n=>{n!=="tiebreaker"&&!r.includes(n)&&this.throwInvalidParamException([n])});break}let a=r.filter(s=>!i.includes(s));return a.length&&this.throwMissingFieldsException("game prediction body",a),e.fixtures.forEach(s=>{this.validateFixtureFields(s)}),e};validateFixture=(t,e,i,r)=>{this.validateMarket(e);let a=Object.values(cs),s=Object.values(ms),p=Object.values(ds);if(e==="FT_1X2"||e==="HT_1X2"){if(a.includes(i))return new oa(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new na(t,i)}else if(e==="DOUBLE_CHANCE"){if(p.includes(i))return new ra(t,i)}else if(e==="CORRECT_SCORE"||e==="CORRECT_SCORE_ADVANCED"||e==="CORRECT_SCORE_HT"){if(typeof i=="string"&&/\d+:\d+/.test(i))return new yt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new ea(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new Zr(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new pa(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new la(t,i)}else if(tt.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===je&&this.isPredictionBoolean(i)){let l=r&&r===n?n:r;return new j(t,e,i,l)}if(r&&this.isPredictionBoolean(i))return new j(t,e,i,r)}else if(Ks.includes(e)){if(this.isPredictionBoolean(i))return new ne(t,e,i)}else if(js.includes(e)&&this.isPredictionBoolean(i))return new se(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{as.includes(r)||this.throwInvalidParamException([r])});let i=as.filter(r=>{if(r!=="matchType"&&!e.includes(r))return r});i.length&&this.throwMissingFieldsException("fixtures",i),this.validatePredictionKey(t.market,t.prediction)};validateTiebreaker=t=>{let e=Object.keys(t);(!e.length||typeof t!="object")&&this.throwInvalidType("tiebreaker","object");let i=Object.keys(new it)[0];e.forEach(r=>{i!==r&&this.throwInvalidParamException([r])}),e.includes(i)||this.throwMissingFieldsException("tiebreaker",[i]),typeof t.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(t,e)=>{if(typeof e=="object"){let i=Object.keys(e),r=["value"];if(i.length||this.throwMissingFieldsException("prediction",r),i.length===1&&!i.includes(r[0])&&this.throwInvalidParamException(i),i.length>1){tt.includes(t)&&r.push("playerId");let a=i.filter(s=>!r.includes(s));a.length&&this.throwInvalidParamException(a)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(t,e)=>{let i="playerId";t!==je&&(e||this.throwInvalidParamException([i]),typeof e!="string"&&this.throwInvalidType(i,"string"))};validateMarket=t=>{Object.values(K).includes(t)||this.throwInvalidMarketException(t)};validateMarketTopX=t=>{t!=="CORRECT_SCORE"&&t!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(t,"TOP_X")};isPredictionBoolean=t=>typeof t=="boolean";throwInvalidPredictionException=(t,e)=>{let i=Is(t,e);throw this.errorHandlingMode==="default"?new w(400,"INVALID_PREDICTION",i):new u(400,"INVALID_TYPE",i)};throwInvalidMarketException=(t,e)=>{let i=null;throw e&&e==="TOP_X"?i=Ps(t):i=Wo(t),this.errorHandlingMode==="default"?new w(400,"INVALID_MARKET",i):new u(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Ts(t);throw this.errorHandlingMode==="default"?new w(400,"INVALID_FIELD",e):new u(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=vs(t,e);throw this.errorHandlingMode==="default"?new w(400,"INVALID_FIELD",i):new u(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=_s(t,e);throw this.errorHandlingMode==="default"?new w(400,"INVALID_TYPE",i):new u(400,"INVALID_TYPE",i)}};var ca=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;errorHandlingMode=null;constructor(t,e,i,r){this.predictorHttps=e,this.idMapping=r,this.clientHttps=i,this.errorHandlingMode=t.errorHandlingMode,this.predictorValidator=new Mt(t.errorHandlingMode),this.predictorService=new ot(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let a=this.predictorValidator.validateFixture(t,e,i,r),s=new me;if(this.idMapping.idSchema!=="native"){let p=a.matchId,n="",l=await this.predictorService.remapMatchIdToNative([p]);if(a.matchId=l[0],this.errorHandlingMode==="default"&&!a.matchId)throw new w(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!a.matchId)throw new u(400,"INVALID_FIELD","Match id is invalid!");if(a instanceof j&&a.prediction.playerId!=="OWN_GOAL"){if(a.prediction.playerId&&(n=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&a.market!==je&&!a.prediction.playerId)throw new w(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&a.market!==je&&!a.prediction.playerId)throw new u(400,"INVALID_FIELD","Player id is invalid!")}s.fixtures=[a];let c=await this.predictorHttps.makeFootballPrediction(s);return c.fixtures.forEach(d=>{d.prediction.playerId&&d.prediction.playerId!=="OWN_GOAL"&&(d.prediction.playerId=n),d.matchId=p}),c}else return s.fixtures=[a],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(t,e)=>{let i=await this.getMatchSummaryBase(t,e),r=JSON.parse(JSON.stringify(i.predictions)),a=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=a,i};getMarketSummary=async(t,e,i,r)=>{try{let a=await this.getMatchSummaryBase(t,r);return await this.predictorService.getMarketSummary(a,e,i)}catch(a){throw a}};getMatchSummaryBase=async(t,e)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([t]))[0],a=await this.predictorHttps.getMatchSummary(r,e);return a.matchId=t,a}else return await this.predictorHttps.getMatchSummary(t,e)};getConfig=async()=>{let t=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getMyPredictions(e)};getMyPredictionsForMatches=async(t,e)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(t))throw new w(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new u(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let i=this.predictorService.initPredictionsFilters(e,"matches",t);return await this.predictorHttps.getMyPredictions(i)};getMyCurrentPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getMyPredictions(e)};getMyPastPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getMyPredictions(e)};getUserPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserCurrentPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserPastPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserPredictionsForMatches=async(t,e,i,r)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(e))throw new w(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new u(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let a=this.predictorService.initPredictionsFilters(i,"matches",e);return await this.predictorHttps.getUserPredictions(t,r,a)};getPredictionById=async t=>await this.predictorHttps.getPredictionById(t);getPredictionsByIds=async t=>await this.predictorHttps.getPredictionsByIds(t)};var ue=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(t){this.idMapping=new F(t),this.predictorHttps=new st(t,this.idMapping),this.clientHttps=new B(t),this.predictorFacade=new ca(t,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(t,e,i,r)=>await this.predictorFacade.makeFootballPrediction(t,e,i,r);getMatchSummary=async(t,e)=>await this.predictorFacade.getMatchSummary(t,e);getMarketSummary=async(t,e,i,r)=>await this.predictorFacade.getMarketSummary(t,e,i,r);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async t=>await this.predictorFacade.deleteFootballPrediction(t);getMyPredictions=async t=>await this.predictorFacade.getMyPredictions(t);getMyCurrentPredictions=async t=>await this.predictorFacade.getMyCurrentPredictions(t);getMyPastPredictions=async t=>await this.predictorFacade.getMyPastPredictions(t);getMyPredictionsForMatches=async(t,e)=>await this.predictorFacade.getMyPredictionsForMatches(t,e);getUserPredictions=async(t,e,i)=>await this.predictorFacade.getUserPredictions(t,e,i);getUserCurrentPredictions=async(t,e,i)=>await this.predictorFacade.getUserCurrentPredictions(t,e,i);getUserPastPredictions=async(t,e,i)=>await this.predictorFacade.getUserPastPredictions(t,e,i);getUserPredictionsForMatches=async(t,e,i,r)=>await this.predictorFacade.getUserPredictionsForMatches(t,e,i,r);getPredictionById=async t=>await this.predictorFacade.getPredictionById(t);getPredictionsByIds=async t=>await this.predictorFacade.getPredictionsByIds(t)};var da=class{rankType=null;fromDate=null;toDate=null;pagination=new ft};var he=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var ma=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new da;return e.rankType=t.rank_type,e.fromDate=t.from_date,e.toDate=t.to_date,e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e};remapData=t=>{let e=[];return t.forEach(i=>{let r=new he;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var ua=class{templateId="";templateModel=null;challengeId="";challengeModel=null;position="";points=0;type="challenge"};var ha=class{templateId="";templateModel=null;privateLeagueId="";privateLeagueModel=null;position="";points=0;type="private_league"};var ga=class extends he{id=null;rankType=null;model=null;gameType=null};var fa=class{remapRankings=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapRankingsPrivateLeague=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapDataUserRankingPrivateLeague(t.data),t);remapRankingsChallenge=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapDataUserRankingChallenge(t.data),t);remapMeta=t=>{let e=new W;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.numberOfPages=t.pagination.number_of_pages,e.pagination.totalItems=t.pagination.total_items,e};remapData(t){let e=[];return t.forEach(i=>{let r=new ga;r.id=i.id,r.rankType=i.rank_type,r.position=i.position,r.points=i.points,r.gameType=i.game_type,delete r.profileId,delete r.profileModel,delete r.predictionsMade,e.push(r)}),e}remapDataUserRankingPrivateLeague(t){let e=[];return t.forEach(i=>{let r=new ha;r.templateId=i.template_id,r.privateLeagueId=i.private_league_id,r.position=i.position,r.points=i.points,e.push(r)}),e}remapDataUserRankingChallenge(t){let e=[];return t.forEach(i=>{let r=new ua;r.templateId=i.template_id,r.challengeId=i.private_league_id,r.position=i.position,r.points=i.points,e.push(r)}),e}};var ya=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var ba=class{pagination=new ft;filters=new ya};var ge=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];groups=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;labels=null;customFields=null;flags=null;images=new at;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var Ma=class extends ge{adContent=null};var wa=class{fromDate=null;toDate=null;matchIds=[]};var Ia=class{groupId=null;label=null;filters=null};var Pa=class{remapResponse=t=>{let e=[];return t.forEach(i=>{let r=new ge;r.id=i.id,r.name=i.name,r.description=i.description,r.type=i.type,r.fromDate=i.from_date,r.toDate=i.to_date,r.markets=i.markets?i.markets:null,r.teamIds=i.team_ids?i.team_ids:null,r.matchIds=i.match_ids?i.match_ids:null,r.groups=i.groups?this.remapGroups(i.groups):null,r.gameIds=i.game_ids?i.game_ids:null,r.gameTypes=i.game_types?i.game_types:null,r.competitionIds=i.competition_ids?i.competition_ids:null,r.excludedProfileIds=i.excluded_profile_ids?i.excluded_profile_ids:null,r.rules=i.rules?i.rules:null,r.labels=i.labels?i.labels:null,r.customFields=i.custom_fields?i.custom_fields:null,r.flags=i.flags?i.flags:null,r.images=i.images?i.images:null,r.status=i.status?i.status:null,r.automaticallyChangeStatus=i.automatically_change_status,r.createdAt=i.created_at,r.updatedAt=i.updated_at,r.related=i.related?this.remapRelated(i.related):null,e.push(r)}),e};remapResponseId=t=>{let e=new Ma;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.fromDate=t.from_date,e.toDate=t.to_date,e.markets=t.markets?t.markets:null,e.teamIds=t.team_ids?t.team_ids:null,e.matchIds=t.match_ids?t.match_ids:null,e.groups=t.groups?this.remapGroups(t.groups):null,e.gameIds=t.game_ids?t.game_ids:null,e.gameTypes=t.game_types?t.game_types:null,e.competitionIds=t.competition_ids?t.competition_ids:null,e.excludedProfileIds=t.excluded_profile_ids?t.excluded_profile_ids:null,e.rules=t.rules?t.rules:null,e.flags=t.flags?t.flags:null,e.images=t.images?t.images:null,e.status=t.status?t.status:null,e.automaticallyChangeStatus=t.automatically_change_status,e.related=t.related?this.remapRelated(t.related):null,e.labels=t.labels,e.customFields=t.custom_fields,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMeta=t=>{let e=new ba;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e.filters.flags=t.filters.flags,e.filters.status=t.filters.status,e.filters.type=t.filters.type,e.filters.activeFrom=t.filters.active_from,e.filters.activeTo=t.filters.active_to,e.filters.createdFrom=t.filters.created_from,e.filters.createdTo=t.filters.created_to,e.filters.updatedFrom=t.filters.updated_from,e.filters.updatedTo=t.filters.updated_to,e};remapRelated=t=>t.map(e=>{let i=new de;return i.entityId=e.entity_id,i.entityType=e.entity_type,i});remapGroups=t=>t.map(e=>{let i=new Ia;return i.groupId=e.group_id,i.label=e.label,i.filters=this.remapGroupFilters(e.filters),i});remapGroupFilters=t=>{let e=new wa;return e.fromDate=t.from_date,e.toDate=t.to_date,e.matchIds=t.match_ids,e}};var Ta=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var va=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Ta;return i.position=e.position,i.points=e.points,i.predictionsMade=e.predictions_made,i.profileId=e.profile_id,i.successRatePercent=e.success_rate_percent,i})};var wt=class extends _{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,R(t.environment,"loyalty")),this.templateRemapper=new Pa,this.leaderboardRemapper=new ma,this.rankingsRemapper=new fa,this.highestSuccessRateRemapper=new va}getTemplates=async(t,e)=>{let i=t?`/leaderboard/templates/${this.apiSignInUrl}${t.constructFiltersUrl()}`:`/leaderboard/templates/${this.apiSignInUrl}`;i+=I(e)?M():"";let r="There was a problem fetching the list of templates",a=await this.fetchWithoutAuth(i,r),s=JSON.parse(JSON.stringify(a));return s.meta=this.templateRemapper.remapMeta(a.meta),s.data=this.templateRemapper.remapResponse(a.data),s};getTemplateById=async(t,e)=>{let i=I(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${M()}`:`/leaderboard/templates/${t}${this.apiSignInUrl}`,r=`There was a problem requesting the following template: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.templateRemapper.remapResponseId(a.data)};getLeaderboard=async(t,e,i)=>{let r=I(e)?`/leaderboard/${t}/${this.apiSignInUrl}${M()}`:`/leaderboard/${t}/${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following template: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getLeaderboardForGame=async(t,e,i)=>{let r=I(e)?`/leaderboard/games/${t}/${this.apiSignInUrl}${M()}`:`/leaderboard/games/${t}/${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following game: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getUserRankings=async(t,e,i)=>{let r=`/leaderboard/users/${t}/rankings/${this.apiSignInUrl}`,a=`There was a problem fetching the rankings for the following user: ${t}`;e&&(r+=`${e.constructFiltersUrl()}`),I(i)&&(r+=`${M()}`);let s=await this.fetchWithoutAuth(r,a);return this.rankingsRemapper.remapRankings(s)};getHighestSuccessRate=async(t,e)=>{let i=`/statistics/top${this.apiSignInUrl}`,r="There was a problem fetching highest success rate";t&&(i+=`${t.constructFiltersUrl()}`),I(e)&&(i+=`${M()}`);let a=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(a.data)};getEntitiesFollows=async(t,e)=>{let i=I(e)?`/statistics/follows${this.apiSignInUrl}${M()}`:`/statistics/follows${this.apiSignInUrl}`,r="There was a problem fetching follows for entities";return t.footballCompetitions&&(i+=`&competitions=${t.footballCompetitions.join(",")}`),t.footballTeams&&(i+=`&teams=${t.footballTeams.join(",")}`),t.footballPlayers&&(i+=`&players=${t.footballPlayers.join(",")}`),(await this.fetchWithoutAuth(i,r)).data};getUserRankingsForPrivateLeagueAndChallenges=async(t,e,i)=>{let r=`/private-league/users/${t}/rankings/${this.apiSignInUrl}&private_league_type=${e==="PRIVATE_LEAGUE"?"private":"one_vs_one"}`,a=`There was a problem fetching user rankings for ${e}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return e==="PRIVATE_LEAGUE"?this.rankingsRemapper.remapRankingsPrivateLeague(s):this.rankingsRemapper.remapRankingsChallenge(s)}};var _a=class{general;predictor;topX;matchQuiz};var fe=class{limit=null;page=null;constructor(t){this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null}constructFiltersUrl(){let t="";return this.limit&&(t+="&",t+=`limit=${this.limit}`),this.page&&(t+="&",t+=`page=${this.page}`),t}};var Fa=class extends fe{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(t){super(t),this.sortOrder=t.sortOrder,this.rankType=t.rankType,this.leaderboardIds=t.leaderboardIds,this.gameType=t.type&&t.type.toLowerCase()==="game"?t.gameType:null}constructFiltersUrl=()=>{let t=super.constructFiltersUrl();return this.sortOrder&&(t+="&",t+=`sort_order=${this.sortOrder}`),this.rankType&&(t+="&",t+=`rank_type=${this.rankType}`),this.leaderboardIds&&(t+="&",t+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(t+="&",t+=`game_type=${this.gameType}`),t}};var Ea=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new F(t),this.profileNamespace=new C(t),this.footballNamespace=new et(t),this.errorHandlingMode=t.errorHandlingMode}remapTemplatesIds=async t=>{if(t.length>0){let e=[],i=[],r=[],a=[],s=[],p=[];t.forEach(c=>{c.teamIds&&c.teamIds.length>0&&(e=[...e,...c.teamIds]),c.matchIds&&c.matchIds.length>0&&(r=[...r,...c.matchIds]),c.competitionIds&&c.competitionIds.length>0&&(s=[...s,...c.competitionIds])});let n={team:e,match:r,competition:s},l=await this.idMappingService.idMappingFacade.getEntitiesByIds(n,"native",this.idMappingService.idSchema);return i=[...l.team],a=[...l.match],p=[...l.competition],t.forEach(c=>{c.teamIds&&c.teamIds.length>0&&(c.teamIds=c.teamIds.map(d=>d=l.team.shift())),c.matchIds&&c.matchIds.length>0&&(c.matchIds=c.matchIds.map(d=>d=l.match.shift())),c.competitionIds&&c.competitionIds.length>0&&(c.competitionIds=c.competitionIds.map(d=>d=l.competition.shift()))}),t}return t};remapTemplateGroupMatchIds=async t=>{if(t&&t.length>0){for(let e of t)if(e.filters.matchIds&&e.filters.matchIds){let i={match:Array.from(e.filters.matchIds)},r=await this.idMappingService.idMappingFacade.getEntitiesByIds(i,"native",this.idMappingService.idSchema);e.filters.matchIds=Array.from(r.match)}}};addProfileModelToLeaderboad=async t=>{if(t.length>0){let e=[],i=t.map(a=>a.profileId);if(!i.length)return t;let r=await this.profileNamespace.getByIds(i);return t.forEach(a=>{r.forEach(s=>{s.id===a.profileId&&(delete s.interests,a.profileModel=s)}),a.profileModel||(a.profileModel=null),e.push(a)}),e}return t};buildClientBadges=t=>{let e=new _a;return e.general=this.extractEnabledBadgesId(t.general),e.predictor=this.extractEnabledBadgesId(t.predictor),e.topX=this.extractEnabledBadgesId(t.topX),e.matchQuiz=this.extractEnabledBadgesId(t.matchQuiz),e};initFilters=(t,e)=>{switch(e){case"loyalty":t&&(t=new fe(t));break;case"rankings":t&&(t=new Fa(t));break}return t};addProfileModelToHighestSuccessRate=async t=>{let e=t.map(r=>r.profileId);if(!e.length)return t;let i=await this.profileNamespace.getByIds(e);return t.map(r=>(i.forEach(a=>{a.id===r.profileId&&(delete a.interests,r.profileModel=a)}),r))};extractRankingsIdsMap=t=>{let e=[],i=[],r=[];return t.forEach(a=>{a.rankType==="GAME"&&a.gameType==="TOP_X"?e.push(a.id):a.rankType==="GAME"&&a.gameType==="MATCH_QUIZ"?i.push(a.id):a.rankType==="TEMPLATE"&&r.push(a.id)}),[e,i,r]};setModelsForUserRankings=(t,e,i,r)=>(r.data.forEach(a=>{a.gameType==="MATCH_QUIZ"&&e?a.model=e.filter(s=>s.id===a.id)[0]:a.gameType==="TOP_X"&&t?a.model=t.filter(s=>s.id===a.id)[0]:a.rankType==="TEMPLATE"&&i&&(a.model=i.filter(s=>s.id===a.id)[0])}),r);completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};validateEntitiesFollowsFilters=t=>{if(!t||(!t.footballCompetitions||!t.footballCompetitions.length)&&(!t.footballTeams||!t.footballTeams.length)&&(!t.footballPlayers||!t.footballPlayers.length))throw this.errorHandlingMode==="default"?new w(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new u(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters.");if(t.footballCompetitions&&t.footballCompetitions.length>24||t.footballTeams&&t.footballTeams.length>24||t.footballPlayers&&t.footballPlayers.length>24)throw this.errorHandlingMode==="default"?new w(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new u(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less.")};remapEntitiesFollowsFilters=async t=>{let e=JSON.parse(JSON.stringify(t)),i={},r={};e.footballCompetitions&&e.footballCompetitions.length&&(r.competition=e.footballCompetitions),e.footballTeams&&e.footballTeams.length&&(r.team=e.footballTeams),e.footballPlayers&&e.footballPlayers.length&&(r.player=e.footballPlayers);let a=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(a).forEach(s=>{s==="competition"?i.footballCompetitions=a[s]:s==="team"?i.footballTeams=a[s]:s==="player"&&(i.footballPlayers=a[s])}),i};addModelsToEntitiesFollows=async t=>{let e=[],i="fb:c:",r=new Map,a=[],s="fb:t:",p=new Map,n=[],l="fb:p:",c=null;return t.breakdown.forEach(d=>{d.id.includes(i)?e.push(d.id):d.id.includes(s)?a.push(d.id):d.id.includes(l)&&n.push(d.id)}),e.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(e)),a.length&&(p=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(a)),n.length&&(c=await this.footballNamespace.footballFacade.playerFacade.getPlayersMapWithNativeIds(n)),t.breakdown.forEach(d=>{d.id.includes(i)?(d.model=r.get(d.id),d.id=d.model.id):d.id.includes(s)?(d.model=p.get(d.id),d.id=d.model.id):d.id.includes(l)&&(d.model=c[d.id],d.id=d.model.id)}),t};extractEnabledBadgesId=t=>{let e=[];return t.forEach(i=>{i.enabled&&e.push(i.id)}),e}};var Ra=class{validate=(t,e)=>{t.market&&this.validateMarket(t.market,e),t.fromDate&&this.validateDate(t.fromDate,"fromDate",e),t.toDate&&this.validateDate(t.toDate,"toDate",e),t.usersCount&&this.validateNumberFilters(t.usersCount,"usersCount",e),t.minimumPredictions&&this.validateNumberFilters(t.minimumPredictions,"minimumPredictions",e)};validateMarket=(t,e)=>{if(!Object.keys(K).includes(t)){let r=Wo(t);throw e==="default"?new w(400,"INVALID_MARKET",r):new u(400,"INVALID_MARKET",r)}};validateDate=(t,e,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof t!="string")throw i==="default"?new w(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`):new u(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`);if(!r.test(t))throw i==="default"?new w(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`):new u(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`)};validateNumberFilters=(t,e,i)=>{let r=e==="usersCount"?1:0,a=e==="usersCount"?1e3:1e6;if(typeof t!="number")throw i==="default"?new w(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`):new u(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`);if(t<r||t>a)throw i==="default"?new w(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`):new u(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`)}};var ye=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;errorHandlingMode=null;constructor(t,e){this.idMapping=e,this.errorHandlingMode=t.errorHandlingMode,this.predictorValidator=new Mt(t.errorHandlingMode),this.predictorHttps=new st(t,e),this.predictorService=new ot(t,e),this.clientHttps=new B(t)}getConfig=async()=>{let t=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};getGames=async(t,e)=>{e=e||!1;let i=this.predictorService.initGameFilters("TOP_X",t),r=await this.predictorHttps.getGames(i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(t,e)=>{e=e||!1;let i=await this.predictorHttps.getGameById(t,e);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(t,e,i)=>(i=i||!1,e&&(e.type&&delete e.type,e.status&&delete e.status,e=new D(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new z(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e={status:"OPEN",type:"TOP_X"};e=new z(e);let i=await this.predictorHttps.getGames(e,t),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,t)).data[0]};play=async t=>{let e=new pe(t);if(e=this.predictorValidator.validateBodyFields("TOP_X",e),e.fixtures=e.fixtures.map(r=>this.predictorValidator.validateFixture(r.matchId,r.market,r.prediction.value)),this.idMapping.idSchema!=="native"){let r=[];e.fixtures.forEach(s=>r.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(r);e.fixtures.forEach(s=>s.matchId=a.shift())}let i=await this.predictorHttps.makeFootballPrediction(e);return i.fixtures.forEach(r=>{r.matchId=r.matchModel.id}),i};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("TOP_X",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,p)}else return new E};getMyGamePrediction=async t=>{let e=this.predictorService.initGameTypePredictions("TOP_X"),i=await this.predictorHttps.getMyPredictions(e);if(i.data.length>0){let r=i.data.filter(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&a.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("TOP_X",null,a),n=await this.predictorHttps.getUserGameEditions(p,i);return await this.predictorService.addPredictionProp(s,n)}else return new E};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.data.filter(p=>p.gameInstanceId===e);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(t,e)=>{let i=await this.predictorHttps.getMarketResultsForGame(t,e);return await this.predictorService.completeGameMarketResults(i,"TOP_X")};getGameWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getGameById(t);return i.contestModel=r,this.predictorService.completeContestWinners(i)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new w(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new u(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var be=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new Mt(t.errorHandlingMode),this.idMapping=new F(t),this.predictorHttps=new st(t,this.idMapping),this.predictorService=new ot(t,this.idMapping),this.clientHttps=new B(t),this.errorHandlingMode=t.errorHandlingMode}getConfig=async()=>{let t=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};play=async t=>{t=this.predictorValidator.validateBodyFields("MATCH_QUIZ",t);let e=t.fixtures.map(i=>this.predictorValidator.validateFixture(i.matchId,i.market,i.prediction.value,i.prediction.playerId));if(e&&e.length&&this.idMapping.idSchema!=="native"){let i=[],r=[];e.forEach(p=>{i.push(p.matchId),p instanceof j&&p.prediction.playerId&&p.prediction.playerId!=="OWN_GOAL"&&r.push(p.prediction.playerId)});let a=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),e.forEach((p,n)=>{p.matchId=a[n],p instanceof j&&p.prediction.playerId!=="OWN_GOAL"&&(p.prediction.playerId=s[p.prediction.playerId])})}return t.fixtures=e,await this.predictorHttps.makeFootballPrediction(t)};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getGames=async(t,e)=>{e=e||!1;let i=this.predictorService.initGameFilters("MATCH_QUIZ",t),r=await this.predictorHttps.getGames(i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(t,e)=>{e=e||!1;let i=await this.predictorHttps.getGameById(t,e);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(t,e,i)=>(i=i||!1,e&&(e.type&&delete e.type,e.status&&delete e.status,e=new D(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new L(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e={status:"OPEN",type:"MATCH_QUIZ"};e=new z(e);let i=await this.predictorHttps.getGames(e,t),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,t)).data[0]};getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,p)}else return new E};getMyGamePrediction=async t=>{let e=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=await this.predictorHttps.getMyPredictions(e);if(i.data.length>0){let r=i.data.filter(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&a.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("MATCH_QUIZ",null,a),n=await this.predictorHttps.getUserGameEditions(p,i);return await this.predictorService.addPredictionProp(s,n)}else return new E};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.data.filter(p=>p.gameInstanceId===e);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(t,e)=>{let i=await this.predictorHttps.getMarketResultsForGame(t,e);return await this.predictorService.completeGameMarketResults(i,"MATCH_QUIZ")};getGameWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getGameById(t);return i.contestModel=r,this.predictorService.completeContestWinners(i)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new w(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new u(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var Sa=class{market;fromDate;toDate;usersCount;minimumPredictions;constructor(t){this.market=t.market?t.market:null,this.fromDate=t.fromDate?t.fromDate:null,this.toDate=t.toDate?t.toDate:null,this.usersCount=t.usersCount?t.usersCount:null,this.minimumPredictions=t.minimumPredictions?t.minimumPredictions:null}constructFiltersUrl(){let t="";return this.market&&(t+="&",t+=`market=${this.market}`),this.fromDate&&(t+="&",t+=`from_date=${this.fromDate}`),this.toDate&&(t+="&",t+=`to_date=${this.toDate}`),this.usersCount&&(t+="&",t+=`users_count=${this.usersCount}`),this.minimumPredictions&&(t+="&",t+=`minimum_predictions=${this.minimumPredictions}`),t}};var Ca=class{flags=null;status=null;type=null;activeFrom=null;activeTo=null;createdFrom=null;createdTo=null;updatedFrom=null;updatedTo=null;constructor(t){this.flags=t.flags?t.flags:null,this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.activeFrom=t.activeFrom?t.activeFrom:null,this.activeTo=t.activeTo?t.activeTo:null,this.createdFrom=t.createdFrom?t.createdFrom:null,this.createdTo=t.createdTo?t.createdTo:null,this.updatedFrom=t.updatedFrom?t.updatedFrom:null,this.updatedTo=t.updatedTo?t.updatedTo:null}constructFiltersUrl(){let t="";return this.flags&&(t+="&",t+=`flags=${this.flags}`),this.status&&(t+="&",t+=`status=${this.status}`),this.type&&(t+="&",t+=`type=${this.type}`),this.activeFrom&&(t+="&",t+=`active_from=${this.activeFrom}`),this.activeTo&&(t+="&",t+=`active_to=${this.activeTo}`),this.createdFrom&&(t+="&",t+=`created_from=${this.createdFrom}`),this.createdTo&&(t+="&",t+=`created_to=${this.createdTo}`),this.updatedFrom&&(t+="&",t+=`updated_from=${this.updatedFrom}`),this.updatedTo&&(t+="&",t+=`updated_to=${this.updatedTo}`),t}};var Aa=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;football=null;constructor(t,e,i,r,a){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new J(a,r),this.loyaltyService=new Ea(this.config),this.loyaltyValidator=new Ra,this.idMapping=new F(t),this.topXFacade=new ye(t,this.idMapping),this.matchQuizFacade=new be(t),this.predictorHttps=new st(t,this.idMapping),this.errorHandlingMode=t.errorHandlingMode,this.football=new et(t)}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let t=await this.getConfig();return this.loyaltyService.buildClientBadges(t.rewards.badges)};getTemplates=async(t,e)=>{if(t&&(t=new Ca(t)),this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(t,e);let i=await this.loyaltyHttps.getTemplates(t,e);i.data=await this.loyaltyService.remapTemplatesIds([...i.data]);for(let r of i.data)await this.loyaltyService.remapTemplateGroupMatchIds(r.groups);return i};getTemplateById=async(t,e)=>{let i=await this.loyaltyHttps.getTemplateById(t,e);if(this.config.idSchema==="native")return i;let r=await this.loyaltyService.remapTemplatesIds([i]);return await this.loyaltyService.remapTemplateGroupMatchIds(r[0].groups),r[0]};getLeaderboard=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"loyalty");let r=await this.loyaltyHttps.getLeaderboard(t,i,e);return r.data=await this.loyaltyService.addProfileModelToLeaderboad(r.data),r};getLeaderboardForGame=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"loyalty");let r=await this.loyaltyHttps.getLeaderboardForGame(t,i,e);return r.data=await this.loyaltyService.addProfileModelToLeaderboad(r.data),r};getOwnRankings=async(t,e)=>{let{id:i}=await this.profileFacade.getOwn();return this.getUserRankings(i,t,e)};getUserRankings=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"rankings");let r=await this.loyaltyHttps.getUserRankings(t,e,i);return await this.getModelsForUserRankings(r)};getHighestSuccessRate=async(t,e)=>{t&&(t=new Sa(t),this.loyaltyValidator.validate(t,this.errorHandlingMode));let i=await this.loyaltyHttps.getHighestSuccessRate(t,e);return this.loyaltyService.addProfileModelToHighestSuccessRate(i)};getTemplateWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getTemplateById(t);return i.contestModel=r,this.loyaltyService.completeContestWinners(i)};getEntitiesFollows=async(t,e)=>{this.loyaltyService.validateEntitiesFollowsFilters(t),this.config.idSchema!=="native"&&(t=await this.loyaltyService.remapEntitiesFollowsFilters(t));let i=await this.loyaltyHttps.getEntitiesFollows(t,e);return await this.loyaltyService.addModelsToEntitiesFollows(i)};getModelsForUserRankings=async t=>{let e=null,i=null,r=null,[a,s,p]=this.loyaltyService.extractRankingsIdsMap(t.data);if(p.length&&(e=(await this.getTemplates()).data.filter(l=>p.includes(l.id))),a.length){let n={gameIds:a};i=(await this.topXFacade.getGames(n)).data}if(s.length){let n={gameIds:s};r=(await this.matchQuizFacade.getGames(n)).data}return this.loyaltyService.setModelsForUserRankings(i,r,e,t)};getTemplateMatches=async(t,e,i)=>{let r=await this.getTemplateById(t,i),a=[];if((!r.matchIds||r.matchIds.length===0)&&!r.groups||r.groups.length===0)return[];!e&&r.matchIds&&(a=Array.from(r.matchIds));let s=Array.from(r.groups.find(l=>l.groupId===e).filters.matchIds)||[];if(a=[...a,...s],!a.length)return[];let p=a.length;return(await this.football.getMatches({matchIds:a,limit:p},i)).data}};var Me=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new B(t),this.profileHttps=new Dt(t),this.loyaltyHttps=new wt(t),this.localCache=new V().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new Aa(t,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localCache)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getTemplates=async(t,e)=>await this.loyaltyFacade.getTemplates(t,e);getTemplateById=async(t,e)=>await this.loyaltyFacade.getTemplateById(t,e);getLeaderboard=async(t,e,i)=>await this.loyaltyFacade.getLeaderboard(t,e,i);getLeaderboardForGame=async(t,e,i)=>await this.loyaltyFacade.getLeaderboardForGame(t,e,i);getOwnRankings=async(t,e)=>await this.loyaltyFacade.getOwnRankings(t,e);getUserRankings=async(t,e,i)=>await this.loyaltyFacade.getUserRankings(t,e,i);getHighestSuccessRate=async(t,e)=>await this.loyaltyFacade.getHighestSuccessRate(t,e);getTemplateWinners=async(t,e)=>await this.loyaltyFacade.getTemplateWinners(t,e);getEntitiesFollows=async(t,e)=>await this.loyaltyFacade.getEntitiesFollows(t,e);getTemplateMatches=async(t,e,i)=>await this.loyaltyFacade.getTemplateMatches(t,e,i)};var Oa=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new F(t),this.topXFacade=new ye(t,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(t,e)=>await this.topXFacade.getGames(t,e);getGameById=async(t,e)=>await this.topXFacade.getGameById(t,e);getGamePredictions=async(t,e,i)=>await this.topXFacade.getGamePredictions(t,e,i);getGameResults=async(t,e,i)=>await this.topXFacade.getGameResults(t,e,i);getCurrentGameResults=async t=>await this.topXFacade.getCurrentGameResults(t);play=async t=>await this.topXFacade.play(t);delete=async t=>await this.topXFacade.delete(t);getMyGameEditions=async(t,e)=>await this.topXFacade.getMyGameEditions(t,e);getMyGamePrediction=async t=>await this.topXFacade.getMyGamePrediction(t);getUserGameEditions=async(t,e,i)=>await this.topXFacade.getUserGameEditions(t,e,i);getUserGamePrediction=async(t,e,i)=>await this.topXFacade.getUserGamePrediction(t,e,i);getMarketsResultsForGame=async(t,e)=>await this.topXFacade.getMarketsResultsForGame(t,e);getGameWinners=async(t,e)=>await this.topXFacade.getGameWinners(t,e)};var La=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new be(t)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async t=>await this.matchQuizFacade.play(t);delete=async t=>await this.matchQuizFacade.delete(t);getGames=async(t,e)=>await this.matchQuizFacade.getGames(t,e);getGameById=async(t,e)=>await this.matchQuizFacade.getGameById(t,e);getGamePredictions=async(t,e,i)=>await this.matchQuizFacade.getGamePredictions(t,e,i);getGameResults=async(t,e,i)=>await this.matchQuizFacade.getGameResults(t,e,i);getCurrentGameResults=async t=>await this.matchQuizFacade.getCurrentGameResults(t);getMyGameEditions=async(t,e)=>await this.matchQuizFacade.getMyGameEditions(t,e);getMyGamePrediction=async t=>await this.matchQuizFacade.getMyGamePrediction(t);getUserGameEditions=async(t,e,i)=>await this.matchQuizFacade.getUserGameEditions(t,e,i);getUserGamePrediction=async(t,e,i)=>await this.matchQuizFacade.getUserGamePrediction(t,e,i);getMarketsResultsForGame=async(t,e)=>await this.matchQuizFacade.getMarketsResultsForGame(t,e);getGameWinners=async(t,e)=>await this.matchQuizFacade.getGameWinners(t,e)};var Ye=class{action=null;context=new Zt;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var It=class{idSchema;idMapping;constructor(t){this.idSchema=t.idSchema,this.idMapping=new F(t)}remapTagsIds=async(t,e,i)=>{if(!t||!t.length)return t;let r={},a={},s=[];t.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],a[n.type]=[]),r[n.type].push(n.id),a[n.type].push(n)});let p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i);for(let[n,l]of Object.entries(a))l.forEach((c,d)=>{c.id=p[n][d],s.push(c)});return s}};var we=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var xa=class extends we{action=null;constructor(t){super(t),this.action=t.action?t.action:null}constructFilterUrl(){let t="";return this.action&&(t+="&",t+=`action=${this.action}`),this.page&&(t+="&",t+=`page=${this.page}`),this.limit&&(t+="&",t+=`limit=${this.limit}`),t}};var Da=class extends we{action=null;constructor(t){super(t),this.action=t.action?t.action:null}constructFilterUrl(){let t="";return this.action&&(t+="&",t+=`action=${this.action}`),this.page&&(t+="&",t+=`page=${this.page}`),this.limit&&(t+="&",t+=`limit=${this.limit}`),t}};var Ba=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new ee(t),this.activityService=new It(t)}add=async(t,e,i,r)=>{if(this.idSchema!="native"){let s=JSON.parse(JSON.stringify(e)),p=await this.activityService.remapTagsIds(e,this.idSchema,"native"),n=new Ye(t,p,i,r),l=await this.activityHttps.createActivity(n);return l.context.tags=s,l}let a=new Ye(t,e,i,r);return this.activityHttps.createActivity(a)};delete=async t=>await this.activityHttps.deleteActivity(t);like=async(t,e,i)=>{let r="like";return await this.add(r,t,e,i)};dislike=async(t,e,i)=>{let r="dislike";return await this.add(r,t,e,i)};addPageview=async(t,e,i)=>{let r="page_view";return await this.add(r,t,e,i)};addContentConsumed=async(t,e,i)=>{let r="content_consumed";return await this.add(r,t,e,i)};addShare=async(t,e,i)=>{let r="share";return await this.add(r,t,e,i)};addComment=async(t,e,i)=>{let r="comment";return await this.add(r,t,e,i)};addClickAd=async(t,e,i)=>{let r="click_ad";return await this.add(r,t,e,i)};addConversion=async(t,e,i)=>{let r="conversion";return await this.add(r,t,e,i)};getOwn=async(t,e)=>{if(e=e||!1,t&&(t=new xa(t)),this.idSchema!="native"){let i=await this.activityHttps.getOwnActivities(t,e);for(let r of i.data)await this.activityService.remapTagsIds(r.context.tags,"native",this.idSchema);return i}return await this.activityHttps.getOwnActivities(t,e)};getForUser=async(t,e,i)=>{if(i=i||!1,e&&(e=new Da(e)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(t,e,i),a=JSON.parse(JSON.stringify(r));for(let s of a.data)await this.activityService.remapTagsIds([...s.context.tags],"native",this.idSchema);return a}return await this.activityHttps.getActivitiesForUser(t,e,i)}};var Na=class{activityFacade;constructor(t){this.activityFacade=new Ba(t)}add=async(t,e,i,r)=>await this.activityFacade.add(t,e,i,r);delete=async t=>await this.activityFacade.delete(t);like=async(t,e,i)=>await this.activityFacade.like(t,e,i);dislike=async(t,e,i)=>await this.activityFacade.dislike(t,e,i);addPageview=async(t,e,i)=>await this.activityFacade.addPageview(t,e,i);addContentConsumed=async(t,e,i)=>await this.activityFacade.addContentConsumed(t,e,i);addShare=async(t,e,i)=>await this.activityFacade.addShare(t,e,i);addComment=async(t,e,i)=>await this.activityFacade.addComment(t,e,i);addClickAd=async(t,e,i)=>await this.activityFacade.addClickAd(t,e,i);addConversion=async(t,e,i)=>await this.activityFacade.addConversion(t,e,i);getOwn=async(t,e)=>await this.activityFacade.getOwn(t,e);getForUser=async(t,e,i)=>await this.activityFacade.getForUser(t,e,i)};var Ie=class{id=null;title=null;description=null;type=null;images=new at;participationCount=null;questionsCount=null;status=null;flags=null;customFields=null;labels=null;time=null;averageScore=null;perfectScore=null;adContent=null;context=null;createdAt=null;updatedAt=null};var Ua=class extends Ie{rules=null;questions=[]};var Ha=class{questionId=null;question=null;images=null;options=[]};var ka=class{optionId=null;option=null;images=null};var Ga=class{classicQuizId=null;userId=null;questions=[];correctOptions=null};var Va=class{questionId=null;optionId=null;correct=null;correctOptionId=null};var $a=class{classicQuizId=null;correct=null;classicQuizQuestions=null};var Pe=class{content=null;tags=[];campaign=null};var Te=class{id=null;model=null;source=null;type=null};var Wa=class{remapClassicQuizzes=t=>(t.meta.pagination=this.remapMetaPagination(t.meta.pagination),t.data=t.data.map(e=>this.remapBasicClassicQuiz(e)),t);remapClassicQuizById=t=>{let e=new Ua;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.participationCount=t.participation_count,e.questionsCount=t.questions_count,e.status=t.status,e.flags=t.flags,e.adContent=t.ad_content,e.rules=t.rules,e.customFields=t.custom_fields,e.labels=t.labels,e.time=t.time,e.context=t.context?this.remapContext(t.context):t.context,e.averageScore=t.average_score,e.perfectScore=t.perfect_score,e.questions=t.questions.map(i=>this.remapQuestions(i)),e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapClassicQuizParticipation=t=>{let e=new Ga;return e.classicQuizId=t.classic_quiz_id,e.userId=t.user_id,e.questions=t.questions?t.questions.map(i=>this.remapParticipationQuestions(i)):null,e.correctOptions=t.correct_options,e};remapClassicQuizParticipationBody=t=>t.map(e=>({question_id:e.questionId,option_id:e.optionId}));remapUserClassicQuizParticipations=t=>t.map(e=>{let i=new $a;return i.classicQuizId=e.classic_quiz_id,i.correct=e.correct,i.classicQuizQuestions=e.classic_quiz_questions,i});remapMetaPagination=t=>{let e=new dt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapBasicClassicQuiz=t=>{let e=new Ie;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.participationCount=t.participation_count,e.questionsCount=t.questions_count,e.status=t.status,e.flags=t.flags,e.customFields=t.custom_fields,e.labels=t.labels,e.time=t.time,e.averageScore=t.average_score,e.perfectScore=t.perfect_score,e.context=t.context?this.remapContext(t.context):t.context,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapQuestions=t=>{let e=new Ha;return e.questionId=t.question_id,e.question=t.question,e.images=t.images,e.options=t.options.map(i=>this.remapOptions(i)),e};remapOptions=t=>{let e=new ka;return e.optionId=t.option_id,e.option=t.option,e.images=t.images,e};remapParticipationQuestions=t=>{let e=new Va;return e.questionId=t.question_id,e.optionId=t.option_id,e.correct=t.correct,e.correctOptionId=t.correct_option_id,e};remapContext=t=>{let e=new Pe;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Te;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var ve=class{id="";title="";description="";images=new at;flags=[];status="";winningCondition="";lives=0;time=0;points=[];customFields=null;labels=null;adContent="";context=null;type="";createdAt="";updatedAt=""};var Ka=class extends ve{rules=""};var ja=class{correctSteps=0;score=0};var qa=class{eitherOrId="";personalBest=0};var za=class{instanceId="";eitherOrId="";gameStartedAt="";currentStep=0;currentStreak=0;remainingSteps=0;currentLives=0;currentPoints=0;personalBest=0;steps=[]};var Qa=class{main;mobile};var Je=class{id="";label="";images=new Qa;value=null};var Xa=class{pairId="";userSelection="";correct=null;played=null;timestamp="";optionOne=new Je;optionTwo=new Je};var Ya=class{rangeStartInclusive=0;rangeEndInclusive=0;totalUsers=0};var Ja=class{standings=[];breakdown=[]};var Za=class{userId="";userModel=null;personalBest=""};var to=class{remapEitherOrs=t=>(t.meta.pagination=this.remapMetaPagination(t.meta.pagination),t.data=t.data.map(e=>this.remapBasicEitherOr(e)),t);remapEitherOrById=t=>{let e=new Ka;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.winningCondition=t.winning_condition,e.lives=t.lives,e.flags=t.flags,e.customFields=t.custom_fields,e.labels=t.labels,e.time=t.time,e.context=t.context?this.remapContext(t.context):t.context,e.points=t.points?t.points.map(i=>this.remapPoints(i)):t.points,e.rules=t.rules,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapEitherOrOwnStats=t=>{let e=new qa;return e.eitherOrId=t.either_or_id,e.personalBest=t.personal_best,e};remapEitherOrResults=t=>{let e=new Ja;return e.standings=t.standings?t.standings.map(i=>this.remapResultsStandings(i)):t.standings,e.breakdown=t.breakdown?t.breakdown.map(i=>this.remapResultsBreakdown(i)):t.breakdown,e};remapEitherOrParticipation=t=>{let e=new za;return e.instanceId=t.instance_id,e.eitherOrId=t.either_or_id,e.gameStartedAt=t.game_started_at,e.currentStep=t.current_step,e.currentStreak=t.current_streak,e.remainingSteps=t.remaining_steps,e.currentLives=t.current_lives,e.currentPoints=t.current_points,e.personalBest=t.personal_best,e.steps=t.steps?t.steps.map(i=>this.remapParticipationSteps(i)):t.steps,e};remapBasicEitherOr=t=>{let e=new ve;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.winningCondition=t.winning_condition,e.lives=t.lives,e.flags=t.flags,e.customFields=t.custom_fields,e.labels=t.labels,e.adContent=t.ad_content,e.context=t.context?this.remapContext(t.context):t.context,e.time=t.time,e.points=t.points?t.points.map(i=>this.remapPoints(i)):t.points,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMetaPagination=t=>{let e=new dt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapPoints=t=>{let e=new ja;return e.correctSteps=t.correct_steps,e.score=t.score,e};remapResultsStandings=t=>{let e=new Za;return e.userId=t.user_id,e.personalBest=t.personal_best,e};remapResultsBreakdown=t=>{let e=new Ya;return e.rangeStartInclusive=t.range_start_inclusive,e.rangeEndInclusive=t.range_end_inclusive,e.totalUsers=t.total_users,e};remapParticipationSteps=t=>{let e=new Xa;return e.pairId=t.pair_id,e.userSelection=t.user_selection,e.correct=t.correct,e.played=t.played,e.timestamp=t.timestamp,e.optionOne=t.option_one,e.optionTwo=t.option_two,e};remapContext=t=>{let e=new Pe;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Te;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var _e=class extends _{classicQuizRemapper=null;eitherOrRemapper=null;constructor(t){super(t,R(t.environment,"miniGames")),this.classicQuizRemapper=new Wa,this.eitherOrRemapper=new to}getClassicQuizzes=async(t,e)=>{let i=`/classic-quizzes${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=I(e)?M():"";let r="There was a problem with fetching classic quizzes",a=await this.fetchWithoutAuth(i,r);return this.classicQuizRemapper.remapClassicQuizzes(a)};getClassicQuizById=async(t,e)=>{let i=`/classic-quizzes/${t}${this.apiSignInUrl}`;I(e)&&(i+=M());let r="There was a problem with fetching classic quiz by ID",a=await this.fetchWithoutAuth(i,r);return this.classicQuizRemapper.remapClassicQuizById(a.data)};participateInClassicQuiz=async(t,e,i)=>{let r=`/classic-quizzes/${t}/participate${this.apiSignInUrl}`,a=`There was a problem with participating in the following classic quiz: ${t}`,s="POST",p={questions:this.classicQuizRemapper.remapClassicQuizParticipationBody(e),include_correct_options:!!i},n=await this.fetchWithAuth(r,a,s,p);return this.classicQuizRemapper.remapClassicQuizParticipation(n.data)};getMyClassicQuizParticipations=async t=>{let e=`/classic-quizzes/participations/${this.apiSignInUrl}&classic_quiz_ids=${t?t.join(","):""}`,i="There was a problem with fetching user's own Classic Quiz participations",r=await this.fetchWithAuth(e,i);return this.classicQuizRemapper.remapUserClassicQuizParticipations(r.data)};getEitherOrs=async(t,e)=>{let i=`/either-or${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=I(e)?M():"";let r="There was a problem with fetching list of Either/Ors",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrs(a)};getEitherOrById=async(t,e)=>{let i=`/either-or/${t}${this.apiSignInUrl}`;I(e)&&(i+=M());let r="There was a problem with fetching Either/Or by ID",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrById(a.data)};getMyEitherOrStats=async t=>{let e=`/either-or/${t}/own-stats${this.apiSignInUrl}`,i="There was a problem with fetching Either/Or own statistics",r=await this.fetchWithAuth(e,i);return this.eitherOrRemapper.remapEitherOrOwnStats(r.data)};getEitherOrResults=async(t,e)=>{let i=`/either-or/${t}/results${this.apiSignInUrl}${I(e)?M():""}`,r="There was a problem with fetching Either/Or results",a=await this.fetchWithAuth(i,r);return this.eitherOrRemapper.remapEitherOrResults(a.data)};participateInEitherOr=async(t,e)=>{let i=`/either-or/${t}/participate${this.apiSignInUrl}`,r="There was a problem with participating in Either/Or",a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.eitherOrRemapper.remapEitherOrParticipation(s.data)}};var Fe=class extends L{flags=null;status=null;entityIds=null;entityType=null;constructor(t){super(t),this.flags=t&&t.flags?t.flags:null,this.status=t&&t.status?t.status:null,this.entityIds=t&&t.entityIds?t.entityIds:null,this.entityType=t&&t.entityType?t.entityType:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.flags&&(t+=`&flags=${this.flags.join(",")}`),this.status&&(t+=`&status=${this.status}`),this.entityIds&&(t+=`&entity_ids=${this.entityIds}`),t}};var eo=class extends Fe{classicQuizIds=null;constructor(t){super(t),this.classicQuizIds=t&&t.classicQuizIds?t.classicQuizIds:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.classicQuizIds&&(t+=`&classic_quiz_ids=${this.classicQuizIds.join(",")}`),t}};var io=class extends Fe{eitherOrIds=null;constructor(t){super(t),this.eitherOrIds=t&&t.eitherOrIds?t.eitherOrIds:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.eitherOrIds&&(t+=`&either_or_ids=${this.eitherOrIds.join(",")}`),t}};var ro=class{pair="";answer=""};var ao=class extends ro{expired=!1;time=0};var oo=class{errorHandlingModel=null;entityTypes=["competition","team","player"];constructor(t){this.errorHandlingModel=t.errorHandlingMode}validateFilters=t=>{!t.entityIds&&!t.entityType||(t.entityIds&&!t.entityType&&this.throwException(400,"invalid_filters","You need to use both 'entityIds' and 'entityType' filters together"),!t.entityIds&&t.entityType&&this.throwException(400,"invalid_filters","You need to use both 'entityIds' and 'entityType' filters together"),this.entityTypes.includes(t.entityType)||this.throwException(400,"invalid_filters","Invalid 'entityType' filter. Please use one of the following valid options: competition, team, or player"))};throwException=(t,e,i)=>{throw this.errorHandlingModel==="standard"?new u(t,e,i):new w(t,e,i)}};var so=class{idSchema=null;idMapping=null;validator=null;https=null;entityTypes=["competition","team","player"];profile=null;football=null;eitherOrTime=0;participationStartTimestamp=0;countdownTimer=0;intervalId=null;currentPairId="";constructor(t){this.idSchema=t.idSchema,this.idMapping=new F(t),this.validator=new oo(t),this.profile=new C(t),this.football=new et(t),this.https=new _e(t)}finalizeMiniGamesFilters=async t=>{if(this.validator.validateFilters(t),this.idSchema!=="native"&&t.entityIds&&t.entityIds.length>0){this.validator.validateFilters(t);let e=await this.idMapping.getEntityIdsBySchemaId(Array.from(t.entityIds),t.entityType,"native");t.entityIds=e[t.entityType]}};setProfileModelsForEitherOrStandings=async t=>{let e=t.standings.map(r=>r.userId);if(!e.length)return t;let i=await this.profile.getByIds(e);return t.standings.forEach(r=>r.userModel=i.find(a=>a.id===r.userId)||null),t};defaultEitherOrParticipation=async(t,e)=>{if(!this.eitherOrTime&&!e){let a=await this.https.getEitherOrById(t,!0);this.eitherOrTime=a.time;let s=await this.https.participateInEitherOr(t,null);return this.participationStartTimestamp=Date.now(),s}let i=0;if(this.participationStartTimestamp)i=(Date.now()-this.participationStartTimestamp)/1e3;else{if(!this.eitherOrTime){let a=await this.https.getEitherOrById(t,!0);this.eitherOrTime=a.time}i=this.eitherOrTime+1}let r=this.createNewParticipation(i,e);try{let a=await this.https.participateInEitherOr(t,r);return!a.currentLives||!a.remainingSteps?this.resetDefaultParticipationTimers():this.participationStartTimestamp=Date.now(),a}catch(a){throw this.resetDefaultParticipationTimers(),a}};handleEitherOrParticipationWithCallback=async(t,e,i)=>e?await this.eitherOrParticipationWithCallback(t,e,i):await this.initialEitherOrParticipationWithCallback(t,i);initialEitherOrParticipationWithCallback=async(t,e)=>{let i=await this.https.getEitherOrById(t,!0);this.eitherOrTime=i.time;let r=await this.https.participateInEitherOr(t,null);return this.participationStartTimestamp=Date.now(),this.countdownTimer=this.eitherOrTime,this.setCurrentPairId(r),await this.handleEitherOrParticipationCallbackInterface(t,e),r};eitherOrParticipationWithCallback=async(t,e,i)=>{this.intervalId&&clearInterval(this.intervalId);let r=0;if(this.participationStartTimestamp)r=(Date.now()-this.participationStartTimestamp)/1e3;else{if(!this.eitherOrTime){let s=await this.https.getEitherOrById(t,!0);this.eitherOrTime=s.time}r=this.eitherOrTime+1}let a=this.createNewParticipation(r,e);try{let s=await this.https.participateInEitherOr(t,a);return!s.currentLives||!s.remainingSteps?(this.resetCallbackParticipationTimers(),i.onElapsedResponse(s),clearInterval(this.intervalId)):(this.participationStartTimestamp=Date.now(),this.countdownTimer=this.eitherOrTime,this.setCurrentPairId(s),await this.handleEitherOrParticipationCallbackInterface(t,i)),s}catch(s){throw this.resetCallbackParticipationTimers(),clearInterval(this.intervalId),s}};setCurrentPairId=t=>{this.currentPairId=t.steps.find(e=>!e.played).pairId||""};handleEitherOrParticipationCallbackInterface=async(t,e)=>{this.intervalId=setInterval(async()=>{if(this.countdownTimer>0)this.countdownTimer--,e.onTimerTick(this.countdownTimer);else{clearInterval(this.intervalId);let i=(Date.now()-this.participationStartTimestamp)/1e3,r={pair:this.currentPairId,answer:this.currentPairId.split("_")[0]},a=this.createNewParticipation(i,r),s=await this.eitherOrParticipationWithCallback(t,a,e);e.onElapsedResponse(s)}},1e3)};createNewParticipation=(t,e)=>{let i=new ao;return i.expired=t>this.eitherOrTime,i.time=Number(t.toFixed(3)),i.pair=e.pair,i.answer=e.answer,i};resetCallbackParticipationTimers=()=>{this.resetDefaultParticipationTimers(),this.countdownTimer=0,this.currentPairId=""};resetDefaultParticipationTimers=()=>{this.eitherOrTime=0,this.participationStartTimestamp=0};setContextTagsModels=async t=>{let e={competitions:[],teams:[],players:[]};if(t.forEach(i=>{i.context&&i.context.tags&&i.context.tags.length>0&&(e.competitions=[...e.competitions,...this.extractEntityIdsFromTags(i.context.tags,"competition")],e.competitions=Array.from(new Set(e.competitions)),e.teams=[...e.teams,...this.extractEntityIdsFromTags(i.context.tags,"team")],e.teams=Array.from(new Set(e.teams)),e.players=[...e.players,...this.extractEntityIdsFromTags(i.context.tags,"player")],e.players=Array.from(new Set(e.players)))}),e.competitions.length){let i=await this.football.footballFacade.getCompetitionsMapWithNativeIds(e.competitions);this.setModelsForContextTags(t,i,"competition")}if(e.teams.length){let i=await this.football.footballFacade.getTeamsMapWithNativeIds(e.teams);this.setModelsForContextTags(t,i,"team")}if(e.players.length){let i=await this.football.footballFacade.getPlayersMapWithNativeIds(e.players);this.setModelsForContextTags(t,i,"player")}};extractEntityIdsFromTags=(t,e)=>t.filter(i=>i.type===e).map(i=>i.id);setModelsForContextTags=(t,e,i)=>{t.forEach(r=>{r.context&&r.context.tags&&r.context.tags.length>0&&r.context.tags.forEach(a=>{a.type===i&&(a.model=i==="player"?e[a.id]:e.get(a.id),a.id=a.model.id)})})}};var no=class{https=null;service=null;activityService=null;idSchema=null;constructor(t){this.https=new _e(t),this.service=new so(t),this.activityService=new It(t),this.idSchema=t.idSchema}getClassicQuizzes=async(t,e,i)=>{t&&(t=new eo(t),await this.service.finalizeMiniGamesFilters(t));let r=await this.https.getClassicQuizzes(t,i);if(e)await this.service.setContextTagsModels(r.data);else for(let a of r.data)await this.remapTags(a,"native",this.idSchema);return r};getClassicQuizById=async(t,e)=>{let i=await this.https.getClassicQuizById(t,e);return await this.service.setContextTagsModels([i]),i};participateInClassicQuiz=async(t,e,i)=>await this.https.participateInClassicQuiz(t,e,i);getMyClassicQuizParticipations=async t=>await this.https.getMyClassicQuizParticipations(t);getEitherOrs=async(t,e,i)=>{t&&(t=new io(t),await this.service.finalizeMiniGamesFilters(t));let r=await this.https.getEitherOrs(t,i);if(e)await this.service.setContextTagsModels(r.data);else for(let a of r.data)await this.remapTags(a,"native",this.idSchema);return r};getEitherOrById=async(t,e)=>{let i=await this.https.getEitherOrById(t,e);return await this.service.setContextTagsModels([i]),i};getMyEitherOrStats=async t=>await this.https.getMyEitherOrStats(t);getEitherOrResults=async(t,e)=>{let i=await this.https.getEitherOrResults(t,e);return await this.service.setProfileModelsForEitherOrStandings(i)};participateInEitherOr=async(t,e,i)=>i?await this.service.handleEitherOrParticipationWithCallback(t,e,i):await this.service.defaultEitherOrParticipation(t,e);remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var lo=class{facade=null;constructor(t){this.facade=new no(t)}getClassicQuizzes=async(t,e,i)=>await this.facade.getClassicQuizzes(t,e,i);getClassicQuizById=async(t,e)=>await this.facade.getClassicQuizById(t,e);participateInClassicQuiz=async(t,e,i)=>await this.facade.participateInClassicQuiz(t,e,i);getMyClassicQuizParticipations=async t=>await this.facade.getMyClassicQuizParticipations(t);getEitherOrs=async(t,e,i)=>await this.facade.getEitherOrs(t,e,i);getEitherOrById=async(t,e)=>await this.facade.getEitherOrById(t,e);getMyEitherOrStats=async t=>await this.facade.getMyEitherOrStats(t);getEitherOrResults=async(t,e)=>await this.facade.getEitherOrResults(t,e);participateInEitherOr=async(t,e,i)=>await this.facade.participateInEitherOr(t,e,i)};var po=class{id="";label="";discussionType="LEAGUE";moderationType="USER";postsCount=0;pinnedPosts=[];lastPostId="";context=null;createdAt="";updatedAt=""};var Pt=class{pagination={totalItems:0,nextPageStartsAfter:"",lastCommentCreateTimestamp:""}};var Ee=class{id="";userId="";discussionId="";content="";repliesCount=0;replyId="";reactions=[];reactionsCount=0;reports=[];reportsCount=0;versions=null;privatePost=!1;deleted=!1;deletedAt="";deletedBy="";moderated=!1;moderatedAt="";moderatedBy="";moderatedReason="";createdAt="";updatedAt=""};var co=class{meta=new Pt;data=[]};var mo=class{type="";userIds=[];reactionCount=0};var uo=class{updatedAt="";content=""};var ho=class{userId=null;reason="AD";reasonDetails=null};var go=class extends Ee{userModel=null};var fo=class{meta=new Pt;data=[]};var yo=class{meta=new G;data=[]};var Re=class{remapToDiscussions=t=>(t.meta=this.remapToMeta(t.meta),t.data=t.data.map(e=>this.remapToDiscussionById(e)),t);remapToDiscussionById=t=>{let e=new po;return e.id=t.id,e.label=t.label,e.discussionType=t.discussion_type,e.moderationType=t.moderation_type,e.postsCount=t.posts_count,e.pinnedPosts=t.pinned_posts,e.lastPostId=t.last_post_id,e.context=t.context,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostsForDiscussion=(t,e)=>{let i=new co,r=new fo;return i.meta=this.remapToPostMeta(t.meta),i.data=t.data.map(a=>this.remapToPostByIdBasic(a)),r.meta=this.remapToPostMeta(t.meta),r.data=t.data.map(a=>this.remapToPostByIdFull(a)),e==="basic"?i:r};remapToPosts=t=>{let e=new yo;return e.meta=this.remapToMeta(t.meta),e.data=t.data.map(i=>this.remapToPostByIdBasic(i)),e};remapToPostMeta=t=>{let e=new Pt;return e.pagination.totalItems=t.pagination.total_items,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.lastCommentCreateTimestamp=t.pagination.last_comment_create_timestamp,e};remapToMeta=t=>{let e=new G;return e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e};remapToPostByIdBasic=t=>{let e=new Ee;return e.id=t.id,e.userId=t.user_id,e.discussionId=t.discussion_id,e.content=t.content,e.reactionsCount=t.reactions_count,e.replyId=t.reply_id,e.reactions=t.reactions.length?t.reactions.map(i=>this.remapReactionsPost(i)):t.reactions,e.reactionsCount=t.reactions_count,e.reports=t.reports.length?t.reports.map(i=>this.remapReportPost(i)):t.reports,e.reportsCount=t.reports_count,e.versions=t.versions.length?t.versions.map(i=>this.remapVersionsPost(i)):t.versions,e.privatePost=t.private_post,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.moderated=t.moderated,e.moderatedAt=t.moderated_at,e.moderatedBy=t.moderated_by,e.moderatedReason=t.moderated_reason,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostByIdFull=t=>{let e=new go;return e.id=t.id,e.userId=t.user_id,e.discussionId=t.discussion_id,e.content=t.content,e.reactionsCount=t.reactions_count,e.replyId=t.reply_id,e.reactions=t.reactions.length?t.reactions.map(i=>this.remapReactionsPost(i)):t.reactions,e.reactionsCount=t.reactions_count,e.reports=t.reports.length?t.reports.map(i=>this.remapReportPost(i)):t.reports,e.reportsCount=t.reports_count,e.versions=t.versions.length?t.versions.map(i=>this.remapVersionsPost(i)):t.versions,e.privatePost=t.private_post,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.moderated=t.moderated,e.moderatedAt=t.moderated_at,e.moderatedBy=t.moderated_by,e.moderatedReason=t.moderated_reason,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapReactionsPost=t=>{let e=new mo;return e.type=t.type,e.userIds=t.user_ids,e.reactionCount=t.reaction_count,e};remapVersionsPost=t=>{let e=new uo;return e.content=t.content,e.updatedAt=t.updated_at,e};remapReportPost=t=>{let e=new ho;return e.userId=t.user_id,e.reason=t.reason,e.reasonDetails=t.reason_details,e}};var bo=class extends _{remapper=null;constructor(t){super(t,R(t.environment,"discussions")),this.remapper=new Re}getAll=async(t,e)=>{let i="/discussions"+this.apiSignInUrl;t&&(i+=`${t.constructMainFiltersUrl()}`),I(e)&&(i+=M());let r="There was a problem getting discussions",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToDiscussions(a)};getById=async t=>{let e=`/discussions/${t}`+this.apiSignInUrl,i="There was a problem getting discussion",r=await this.fetchWithoutAuth(e,i);return this.remapper.remapToDiscussionById(r.data)};createPost=async(t,e)=>{let i=`/discussions/${t}/posts`+this.apiSignInUrl,r="There was a problem creating post in discussion",a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.remapper.remapToPostByIdBasic(s.data)};getPostById=async t=>{let e=`/posts/${t}`+this.apiSignInUrl,i="There was a problem getting post by ID in discussion",r=await this.fetchWithoutAuth(e,i);return this.remapper.remapToPostByIdFull(r.data)};updatePost=async(t,e)=>{let i=`/posts/${t}`+this.apiSignInUrl,r="There was a problem editing post in discussion",a="PUT",s={content:e},p=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapToPostByIdBasic(p.data)};reactToPost=async(t,e)=>{let i=`/posts/${t}/reaction`+this.apiSignInUrl,r="There was a problem reacting to post in discussion",a="PUT",s={reaction:e.toLocaleLowerCase()},p=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapToPostByIdBasic(p.data)};deletePost=async t=>{let e=`/posts/${t}`+this.apiSignInUrl,i="There was a problem deleting post in discussion",r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getPosts=async(t,e)=>{let i=`/discussions/${t}/posts`+this.apiSignInUrl;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem getting posts in discussion",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostsForDiscussion(a,"full")};getPostReplies=async(t,e)=>{let i=`/posts/${t}/replies`+this.apiSignInUrl;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem getting post's replies in discussion",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostsForDiscussion(a,"full")};reportPost=async(t,e,i)=>{let r=`/posts/${t}/report`+this.apiSignInUrl,a="There was a problem reporting post in discussion",s="POST",p={reason:e.toLocaleUpperCase(),reason_details:i||null},n=await this.fetchWithAuth(r,a,s,p);return this.remapper.remapToPostByIdBasic(n.data)};getOwnPosts=async t=>{let e="/posts"+this.apiSignInUrl;t&&(e+=`${t.constructMainFiltersUrl()}`);let i="There was a problem getting own posts",r=await this.fetchWithAuth(e,i);return this.remapper.remapToPosts(r)};getUserPosts=async(t,e,i)=>{let r=`/posts/users/${t}`+this.apiSignInUrl;e&&(r+=`${e.constructMainFiltersUrl()}`),I(i)&&(r+=M());let a="There was a problem getting user's posts",s=await this.fetchWithoutAuth(r,a);return this.remapper.remapToPosts(s)}};var Mo=class{content="";reply_id="";context=null};var wo=class{createRequestBodyFromParam=t=>{let e=new Mo;return e.content=t.content,e.reply_id=t.replyId,e.context=t.context,e}};var Io=class extends L{discussionIds;label;fromDate;toDate;fromCount;toCount;sort;constructor(t){super(t),this.discussionIds=t&&t.discussionIds?t.discussionIds:null,this.label=t&&t.label?t.label:null,this.fromDate=t&&t.fromDate?t.fromDate:null,this.toDate=t&&t.toDate?t.toDate:null,this.fromCount=t&&t.fromCount?t.fromCount:null,this.toCount=t&&t.toCount?t.toCount:null,this.sort=t&&t.sort?t.sort:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.discussionIds!==null&&(t+=`&discussion_ids=${this.discussionIds.join(",")}`),this.label!==null&&(t+=`&label=${this.label}`),this.fromDate!==null&&(t+=`&from_date=${this.fromDate}`),this.toDate!==null&&(t+=`&to_date=${this.toDate}`),this.fromCount!==null&&(t+=`&from_count=${this.fromCount}`),this.toCount!==null&&(t+=`&to_count=${this.toCount}`),this.sort&&(t+=`&sort=${this.sort}`),t}};var At=class extends L{skipDeleted;sort;constructor(t){super(t),this.skipDeleted=t&&t.skipDeleted!==void 0?t.skipDeleted:null,this.sort=t&&t.sort?t.sort.toLocaleLowerCase():null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.skipDeleted!==null&&(t+=`&skip_deleted=${this.skipDeleted}`),this.sort&&(t+=`&sort=${this.sort}`),t}};var Tt=class{profile=null;constructor(t){this.profile=new C(t)}finalizePostFullModel=async t=>{let e=t.map(r=>r.userId),i=await this.profile.getByIds(e);return t.map(r=>(r.userModel=this.extractModelById(i,r.userId),r))};extractModelById=(t,e)=>{if(t.length){let i=t.find(r=>r.id===e);return i?(delete i.interests,i):null}return null}};var Po=class{idSchema=null;https=null;clientHttps=null;activityService=null;service=null;factory=null;constructor(t){this.idSchema=t.idSchema,this.https=new bo(t),this.clientHttps=new B(t),this.activityService=new It(t),this.service=new Tt(t),this.factory=new wo}getAll=async(t,e)=>{t&&(t=new Io(t));let i=await this.https.getAll(t,e);for(let r of i.data)await this.remapTags(r,"native",this.idSchema);return i};getById=async t=>{let e=await this.https.getById(t);return await this.remapTags(e,"native",this.idSchema),e};createPost=async(t,e)=>{let i=JSON.parse(JSON.stringify(e));await this.remapTags(i,this.idSchema,"native");let r=this.factory.createRequestBodyFromParam(i);return await this.https.createPost(t,r)};getPostById=async t=>{let e=await this.https.getPostById(t);return(await this.service.finalizePostFullModel([e]))[0]};updatePost=async(t,e)=>await this.https.updatePost(t,e);deletePost=async t=>await this.https.deletePost(t);getPosts=async(t,e)=>{e&&(e=new At(e));let i=await this.https.getPosts(t,e);return i.data=await this.service.finalizePostFullModel(i.data),i};getPostReplies=async(t,e)=>{e&&(e=new At(e));let i=await this.https.getPostReplies(t,e);return i.data=await this.service.finalizePostFullModel(i.data),i};reactToPost=async(t,e)=>await this.https.reactToPost(t,e);reportPost=async(t,e,i)=>await this.https.reportPost(t,e,i);getOwnPosts=async t=>(t&&(t=new At(t)),await this.https.getOwnPosts(t));getUserPosts=async(t,e,i)=>(e&&(e=new At(e)),await this.https.getUserPosts(t,e,i));getConfig=async()=>await this.clientHttps.getConfig("discussions");remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var To=class{facade=null;constructor(t){this.facade=new Po(t)}getAll=async(t,e)=>await this.facade.getAll(t,e);getById=async t=>await this.facade.getById(t);createPost=async(t,e)=>await this.facade.createPost(t,e);getPostById=async t=>await this.facade.getPostById(t);updatePost=async(t,e)=>await this.facade.updatePost(t,e);deletePost=async t=>await this.facade.deletePost(t);getPosts=async(t,e)=>await this.facade.getPosts(t,e);getPostReplies=async(t,e)=>await this.facade.getPostReplies(t,e);react=async(t,e)=>await this.facade.reactToPost(t,e);reportPost=async(t,e,i)=>await this.facade.reportPost(t,e,i);getOwnPosts=async t=>await this.facade.getOwnPosts(t);getUserPosts=async(t,e,i)=>await this.facade.getUserPosts(t,e,i);getConfig=async()=>await this.facade.getConfig()};var vo=class{profileId="";profileModel=null;challengeId="";challengeModel=null;message=""};var _o=class{profileId="";profileModel=null;leagueId="";leagueModel=null;message=""};var Fo=class{id="";name="";description="";type="";members=[];banned=[];invites=[];administrators=[];invitationCode="";templateId="";templateModel=null;pastTemplates=[];usersCanInviteUsers=!1;scoringStartsAt="";pinnedPosts=[]};var Eo=class{predictionId=null;predictionModel=null;profileId=null;profileModel=null};var Ro=class{remapToPrivateLeagues=t=>(t.meta=this.remapMetaPrivateLeagues(t.meta.pagination),t.data=t.data.map(e=>this.remapToPrivateLeagueById(e)),t);remapMetaPrivateLeagues=t=>{let e=new G;return e.pagination.itemsPerPage=t.items_per_page,e.pagination.nextPageStartsAfter=t.next_page_starts_after,e};remapToPrivateLeagueById=t=>{let e=new Fo;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.members=t.members,e.administrators=t.administrators,e.banned=t.banned,e.invites=t.invites,e.usersCanInviteUsers=t.users_can_invite_users,e.invitationCode=t.invitation_code,e.templateId=t.template_id,e.pastTemplates=t.past_templates,e.pinnedPosts=t.pinned_posts,e.scoringStartsAt=t.scoring_starts_at,e};remapToAcceptPrivateLeague=t=>{let e=new _o;return e.profileId=t.profile_id,e.leagueId=t.league_id,e.message=t.message,e};remapToAcceptChallenge=t=>{let e=new vo;return e.profileId=t.profile_id,e.challengeId=t.league_id,e.message=t.message,e};remapPredictions=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapPredictionsData(t.data),t);remapMeta=t=>{let e=new W;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.numberOfPages=t.pagination.number_of_pages,e.pagination.totalItems=t.pagination.total_items,e};remapPredictionsData=t=>t.map(e=>{let i=new Eo;return i.predictionId=e.prediction_id,i.profileId=e.profile_id,i})};var Se=class extends _{remapper=null;discussionsRemapper=null;discussionsBaseURL=null;constructor(t){super(t,R(t.environment,"privateLeagues")),this.discussionsBaseURL=R(t.environment,"discussions"),this.remapper=new Ro,this.discussionsRemapper=new Re}create=async(t,e)=>{let i="/leagues"+this.apiSignInUrl,a=`There was a problem ${e==="PRIVATE_LEAGUE"?"creating private league":"issuing challenge"}`,s="POST",p=await this.fetchWithAuth(i,a,s,t);return this.remapper.remapToPrivateLeagueById(p.data)};update=async(t,e,i)=>{let r=`/leagues/${t}`+this.apiSignInUrl,s=`There was a problem updating ${i==="PRIVATE_LEAGUE"?"private league":"challenge"}`,p="PUT",n=await this.fetchWithAuth(r,s,p,e);return this.remapper.remapToPrivateLeagueById(n.data)};updateLeagueTemplate=async(t,e,i,r)=>{let a=`/leagues/${t}/template`+this.apiSignInUrl,p=`There was a problem updating template for the ${r==="PRIVATE_LEAGUE"?"private league":"challenge"}`,n="POST",l={new_template_id:e,past_template_name:i},c=await this.fetchWithAuth(a,p,n,l);return this.remapper.remapToPrivateLeagueById(c.data)};getById=async(t,e,i)=>{let r=`/leagues/${t}`+this.apiSignInUrl;I(i)&&(r+=M());let s=`There was a problem getting ${e==="PRIVATE_LEAGUE"?"private league":"challenge"}`,p=await this.fetchWithAuth(r,s);return this.remapper.remapToPrivateLeagueById(p.data)};delete=async(t,e)=>{let i=`/leagues/${t}`+this.apiSignInUrl,a=`There was a problem deleting ${e==="PRIVATE_LEAGUE"?"private league":"challenge"}`,s="DELETE";return await this.fetchWithAuth(i,a,s),!0};invite=async(t,e)=>{let i=`/membership/invite/${t}`+this.apiSignInUrl,r=`There was a problem inviting the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};deleteInvitation=async(t,e)=>{let i=`/membership/invite/${t}`+this.apiSignInUrl,r=`There was a problem deleting invitation for the following users: ${e.join(",")}`,a="DELETE",s={profiles:e};return await this.fetchWithAuth(i,r,a,s),!0};accept=async(t,e,i)=>{let r=`/membership/accept/${t}`+this.apiSignInUrl+`&accept=${e?"ACCEPT":"REJECT"}`,s=`There was a problem ${e?"accepting":"rejecting"} invitation for ${i==="PRIVATE_LEAGUE"?"private league":"challenge"}: ${t}`,p="POST",n=await this.fetchWithAuth(r,s,p);return i==="PRIVATE_LEAGUE"?this.remapper.remapToAcceptPrivateLeague(n.data):this.remapper.remapToAcceptChallenge(n.data)};ban=async(t,e)=>{let i=`/membership/ban/${t}`+this.apiSignInUrl,r=`There was a problem banning the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};unban=async(t,e)=>{let i=`/membership/unban/${t}`+this.apiSignInUrl,r=`There was a problem unbanning the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};join=async t=>{let e="/membership/join"+this.apiSignInUrl+`&invitation_code=${t}`,i="There was a problem joining league",r="POST",a=await this.fetchWithAuth(e,i,r);return this.remapper.remapToAcceptPrivateLeague(a.data)};leave=async(t,e)=>{let i=`/membership/leave/${t}`+this.apiSignInUrl,a=`There was a problem leaving the following ${e==="PRIVATE_LEAGUE"?"league":"challenge"}: ${t}`,s="POST";return(await this.fetchWithAuth(i,a,s)).data};getInvitations=async(t,e)=>{let i="/membership/invitations"+this.apiSignInUrl+e.constructMainFiltersUrl(),a=`There was a problem getting invitations for ${t==="PRIVATE_LEAGUE"?"leagues":"challenges"}`,s=await this.fetchWithAuth(i,a);return this.remapper.remapToPrivateLeagues(s)};getReportedPosts=async(t,e)=>{let i=`/discussions/${t}/posts/reported${this.apiSignInUrl}`,r=`There was a problem fetching posts for the following: ${t}`;e&&(i+=e.constructMainFiltersUrl());let a=await this.fetchWithAuthNewBaseURL(this.discussionsBaseURL,i,r);return this.discussionsRemapper.remapToPostsForDiscussion(a,"full")};getPredictions=async(t,e)=>{let i=`/leagues/${t}/predictions`+this.apiSignInUrl,r=`There was a problem getting predictions for private league: ${t}`;e&&(i+=e.constructFiltersUrl());let a=await this.fetchWithAuth(i,r);return this.remapper.remapPredictions(a)};moderatePost=async(t,e)=>{let i=`/posts/${t}/admin/moderate${this.apiSignInUrl}`,r=`There was a problem moderating the following post: ${t}`,a="POST",s={moderation_reason:e},p=await this.fetchWithAuthNewBaseURL(this.discussionsBaseURL,i,r,a,s);return this.discussionsRemapper.remapToPostByIdBasic(p.data)}};var Ce=class{name="";description="";invitation_code="";template_id="";users_can_invite_users=!1;administrators=[];scoring_starts_at=""};var So=class extends Ce{type="ONE_VS_ONE"};var Co=class extends Ce{type="PRIVATE"};var Ae=class{name="";description="";invitation_code="";template_id="";users_can_invite_users=!1;administrators=[];pinned_posts=[];scoring_starts_at=""};var Ao=class extends Ae{type="PRIVATE"};var Oo=class extends Ae{type="ONE_VS_ONE"};var Oe=class{createRequestBodyFromParam=(t,e)=>{let i=e==="PRIVATE"?new Co:new So;return i.name=t.name,i.description=t.description,i.invitation_code=t.invitationCode,i.template_id=t.templateId,i.users_can_invite_users=t.usersCanInviteUsers,t.administrators?i.administrators=t.administrators:delete i.administrators,t.scoringStartsAt?i.scoring_starts_at=t.scoringStartsAt:delete i.scoring_starts_at,i};createUpdateRequestBodyFromParam=(t,e)=>{let i=e==="PRIVATE"?new Ao:new Oo;return i.name=t.name,i.description=t.description,i.invitation_code=t.invitationCode,i.template_id=t.templateId,i.users_can_invite_users=t.usersCanInviteUsers,i.administrators=t.administrators,i.pinned_posts=t.pinnedPosts,i.scoring_starts_at=t.scoringStartsAt,i}};var Le=class extends L{type=null;constructor(t){super(t),this.type=t&&t.type?t.type:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.type&&(t+=`&type=${this.type}`),t}};var Lo=class{limit=null;page=null;leagueId=null;templateId=null;sortOrder=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.leagueId=t&&t.leagueId?t.leagueId:null,this.templateId=t&&t.templateId?t.templateId:null,this.sortOrder=t&&t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.leagueId&&(t+=`&league_id=${this.leagueId}`),this.templateId&&(t+=`&template_id=${this.templateId}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),t}};var xe=class extends L{reportsCount=null;constructor(t){super(t),this.reportsCount=t.reportsCount?t.reportsCount:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.reportsCount&&(t+=`&reports_count=${this.reportsCount}`),t}};var De=class{limit=null;page=null;profileIds=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.profileIds=t&&t.profileIds?t.leagueId:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.profileIds&&(t+=`&profile_ids=${this.profileIds.join(",")}`),t}};var Be=class{loyalty=null;profile=null;predictor=null;constructor(t){this.loyalty=new Me(t),this.profile=new C(t),this.predictor=new ue(t)}setTemplateModels=async t=>{let e=await this.loyalty.getTemplates();t.templateModel=e.data.find(i=>i.id===t.templateId),t.pastTemplates&&t.pastTemplates.length>0&&t.pastTemplates.forEach(i=>{i.model=e.data.find(r=>r.id===i.id)})};setTemplateModelsInLeagues=async t=>{let e=await this.loyalty.getTemplates();t.forEach(i=>{i.templateModel=e.data.find(r=>r.id===i.templateId),i.pastTemplates&&i.pastTemplates.length>0&&i.pastTemplates.forEach(r=>{r.model=e.data.find(a=>a.id===r.id)})})};setTemplateModelsFromLeagueModels=(t,e)=>{if(e==="PRIVATE_LEAGUE"){t.forEach(i=>{i.templateModel=i.templateId===i.privateLeagueModel.templateId?i.privateLeagueModel.templateModel:i.privateLeagueModel.pastTemplates.find(r=>r.id===i.templateId).model});return}t.forEach(i=>{i.templateModel=i.templateId===i.challengeModel.templateId?i.challengeModel.templateModel:i.challengeModel.pastTemplates.find(r=>r.id===i.templateId).model})};setProfileModel=async t=>{let e=await this.profile.getById(t.profileId).getInfo();t.profileModel=e};setModelsForPredictions=async t=>{if(t.data.length){let e=t.data.map(s=>s.profileId),i=t.data.map(s=>s.predictionId),r=await this.getProfileModels(e),a=await this.getPredictionModels(i);t.data.forEach(s=>{s.profileModel=r.find(p=>p.id===s.profileId),s.predictionModel=a.find(p=>p.id===s.predictionId)})}return t};getProfileModels=async t=>await this.profile.getByIds(t);getPredictionModels=async t=>await this.predictor.getPredictionsByIds(t)};var xo=class{factory=null;privateLeagueHttps=null;loyaltyHttps=null;profile=null;service=null;discussionsService=null;constructor(t){this.factory=new Oe,this.privateLeagueHttps=new Se(t),this.loyaltyHttps=new wt(t),this.profile=new C(t),this.service=new Be(t),this.discussionsService=new Tt(t)}create=async t=>{let e=this.factory.createRequestBodyFromParam(t,"PRIVATE"),i=await this.privateLeagueHttps.create(e,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(i),i};getById=async(t,e)=>{let i=await this.privateLeagueHttps.getById(t,"PRIVATE_LEAGUE",e);return await this.service.setTemplateModels(i),i};update=async(t,e)=>{let i=this.factory.createUpdateRequestBodyFromParam(e,"PRIVATE"),r=await this.privateLeagueHttps.update(t,i,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(r),r};updateTemplate=async(t,e,i)=>{let r=await this.privateLeagueHttps.updateLeagueTemplate(t,e,i,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(r),r};delete=async t=>await this.privateLeagueHttps.delete(t,"PRIVATE_LEAGUE");invite=async(t,e)=>await this.privateLeagueHttps.invite(t,e);deleteInvitation=async(t,e)=>await this.privateLeagueHttps.deleteInvitation(t,e);accept=async t=>{let i=await this.privateLeagueHttps.accept(t,!0,"PRIVATE_LEAGUE");return await this.finalizeAcceptModel(i,!0)};reject=async t=>{let i=await this.privateLeagueHttps.accept(t,!1,"PRIVATE_LEAGUE");return await this.finalizeAcceptModel(i,!1)};banUsers=async(t,e)=>await this.privateLeagueHttps.ban(t,e);unbanUsers=async(t,e)=>await this.privateLeagueHttps.unban(t,e);join=async t=>{let e=await this.privateLeagueHttps.join(t);return await this.finalizeAcceptModel(e,!0)};leave=async t=>await this.privateLeagueHttps.leave(t,"PRIVATE_LEAGUE");finalizeAcceptModel=async(t,e)=>{if(e){let i=await this.getById(t.leagueId);t.leagueModel=i}return await this.service.setProfileModel(t),t};getMyLeagues=async t=>{t&&(t=new Lo(t));let e=await this.profile.getOwn().getInfo(),i=await this.loyaltyHttps.getUserRankingsForPrivateLeagueAndChallenges(e.id,"PRIVATE_LEAGUE",t);for(let r of i.data){let a=await this.getById(r.privateLeagueId);r.privateLeagueModel=a}return this.service.setTemplateModelsFromLeagueModels(i.data,"PRIVATE_LEAGUE"),i};getInvitations=async t=>{t=new Le(t),t.type="PRIVATE";let e=await this.privateLeagueHttps.getInvitations("PRIVATE_LEAGUE",t);return await this.service.setTemplateModelsInLeagues(e.data),e};getReportedPosts=async(t,e)=>{e&&(e=new xe(e));let i=await this.privateLeagueHttps.getReportedPosts(t,e);return i.data=await this.discussionsService.finalizePostFullModel(i.data),i};getPredictions=async(t,e)=>{if(e){if(e.limit&&e.limit>20)throw new u(400,"invalid_limit","Invalid limit filter. The maximum limit is 20");e=new De(e)}let i=await this.privateLeagueHttps.getPredictions(t,e);return await this.service.setModelsForPredictions(i)};moderatePost=async(t,e)=>await this.privateLeagueHttps.moderatePost(t,e)};var Do=class{privateLeaguesFacade=null;constructor(t){this.privateLeaguesFacade=new xo(t)}create=async t=>await this.privateLeaguesFacade.create(t);update=async(t,e)=>await this.privateLeaguesFacade.update(t,e);updateTemplate=async(t,e,i)=>await this.privateLeaguesFacade.updateTemplate(t,e,i);delete=async t=>await this.privateLeaguesFacade.delete(t);getById=async(t,e)=>await this.privateLeaguesFacade.getById(t,e);invite=async(t,e)=>await this.privateLeaguesFacade.invite(t,e);deleteInvitation=async(t,e)=>await this.privateLeaguesFacade.deleteInvitation(t,e);accept=async t=>await this.privateLeaguesFacade.accept(t);reject=async t=>await this.privateLeaguesFacade.reject(t);banUsers=async(t,e)=>await this.privateLeaguesFacade.banUsers(t,e);unbanUsers=async(t,e)=>await this.privateLeaguesFacade.unbanUsers(t,e);join=async t=>await this.privateLeaguesFacade.join(t);leave=async t=>await this.privateLeaguesFacade.leave(t);getMyLeagues=async t=>await this.privateLeaguesFacade.getMyLeagues(t);getInvitations=async t=>await this.privateLeaguesFacade.getInvitations(t);getReportedPosts=async(t,e)=>await this.privateLeaguesFacade.getReportedPosts(t,e);getPredictions=async(t,e)=>await this.privateLeaguesFacade.getPredictions(t,e);moderatePost=async(t,e)=>await this.privateLeaguesFacade.moderatePost(t,e)};var Bo=class{limit=null;page=null;challengeId=null;templateId=null;sortOrder=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.challengeId=t&&t.challengeId?t.challengeId:null,this.templateId=t&&t.templateId?t.templateId:null,this.sortOrder=t&&t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.challengeId&&(t+=`&league_id=${this.challengeId}`),this.templateId&&(t+=`&template_id=${this.templateId}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),t}};var No=class{factory=null;https=null;loyaltyHttps=null;profile=null;service=null;discussionsService=null;constructor(t){this.factory=new Oe,this.https=new Se(t),this.service=new Be(t),this.loyaltyHttps=new wt(t),this.profile=new C(t),this.discussionsService=new Tt(t)}issue=async(t,e)=>{let i=this.factory.createRequestBodyFromParam(t,"ONE_VS_ONE"),r=await this.https.create(i,"CHALLENGE");await this.service.setTemplateModels(r);let a=await this.https.invite(r.id,[e]);return r.invites=[],r.invites.push(a[0]),r};update=async(t,e)=>{let i=this.factory.createUpdateRequestBodyFromParam(e,"ONE_VS_ONE"),r=await this.https.update(t,i,"CHALLENGE");return await this.service.setTemplateModels(r),r};updateTemplate=async(t,e,i)=>{let r=await this.https.updateLeagueTemplate(t,e,i,"CHALLENGE");return await this.service.setTemplateModels(r),r};delete=async t=>await this.https.delete(t,"CHALLENGE");getById=async(t,e)=>{let i=await this.https.getById(t,"CHALLENGE",e);return await this.service.setTemplateModels(i),i};accept=async t=>{let i=await this.https.accept(t,!0,"CHALLENGE");return await this.finalizeAcceptModel(i,!0)};reject=async t=>{let i=await this.https.accept(t,!1,"CHALLENGE");return await this.finalizeAcceptModel(i,!1)};leave=async t=>await this.https.leave(t,"CHALLENGE");finalizeAcceptModel=async(t,e)=>{if(e){let i=await this.getById(t.challengeId);t.challengeModel=i}return await this.service.setProfileModel(t),t};getMyChallenges=async t=>{t&&(t=new Bo(t));let e=await this.profile.getOwn().getInfo(),i=await this.loyaltyHttps.getUserRankingsForPrivateLeagueAndChallenges(e.id,"CHALLENGE",t);for(let r of i.data){let a=await this.getById(r.challengeId);r.challengeModel=a}return this.service.setTemplateModelsFromLeagueModels(i.data,"CHALLENGE"),i};getInvitations=async t=>{t=new Le(t),t.type="ONE_VS_ONE";let e=await this.https.getInvitations("CHALLENGE",t);return await this.service.setTemplateModelsInLeagues(e.data),e};getReportedPosts=async(t,e)=>{e&&(e=new xe(e));let i=await this.https.getReportedPosts(t,e);return i.data=await this.discussionsService.finalizePostFullModel(i.data),i};getPredictions=async(t,e)=>{if(e){if(e.limit&&e.limit>20)throw new u(400,"invalid_limit","Invalid limit filter. The maximum limit is 20");e=new De(e)}let i=await this.https.getPredictions(t,e);return await this.service.setModelsForPredictions(i)};moderatePost=async(t,e)=>await this.https.moderatePost(t,e)};var Uo=class{facade=null;constructor(t){this.facade=new No(t)}issue=async(t,e)=>await this.facade.issue(t,e);update=async(t,e)=>await this.facade.update(t,e);updateTemplate=async(t,e,i)=>await this.facade.updateTemplate(t,e,i);delete=async t=>await this.facade.delete(t);getById=async(t,e)=>await this.facade.getById(t,e);accept=async t=>await this.facade.accept(t);reject=async t=>await this.facade.reject(t);leave=async t=>await this.facade.leave(t);getMyChallenges=async t=>await this.facade.getMyChallenges(t);getInvitations=async t=>await this.facade.getInvitations(t);getReportedPosts=async(t,e)=>await this.facade.getReportedPosts(t,e);getPredictions=async(t,e)=>await this.facade.getPredictions(t,e);moderatePost=async(t,e)=>await this.facade.moderatePost(t,e)};var Jo=null,us=null;function j_(o){if(fn(o)){let t=yn(o);if(t.isValid)return Jo={profile:new C(o),football:new et(o),predictor:new ue(o),loyalty:new Me(o),topX:new Oa(o),matchQuiz:new La(o),activity:new Na(o),miniGames:new lo(o),discussions:new To(o),privateLeagues:new Do(o),challenges:new Uo(o)},us={...o},Jo;bn(t)}return Jo}var fn=o=>!Jo||JSON.stringify(o)!==JSON.stringify(us)||o.authProvider.getIdToken()!==us.authProvider.getIdToken(),yn=o=>{let e=new Lr().validate(o);return(e.idSchema.validation==="missing"||e.idSchema.validation==="invalid")&&(console.warn(e.idSchema.message.text),o.idSchema="native"),(e.environment.validation==="missing"||e.environment.validation==="invalid")&&(console.warn(e.environment.message.text),o.environment="prod"),(e.lang.validation==="missing"||e.lang.validation==="invalid")&&(console.warn(e.lang.message.text),o.lang="en"),(e.errorHandlingMode.validation==="missing"||e.errorHandlingMode.validation==="invalid")&&(console.warn(e.errorHandlingMode.message.text),o.errorHandlingMode="default"),e.authProvider.validation==="invalid"&&console.warn(e.authProvider.message.text),e},bn=o=>{let t="authProvider",e="isValid";Object.keys(o).forEach(i=>{let r=o[i];if(i!==e&&i!==t){if(r.message.type==="error")throw new Error(r.message.text)}else i!==e&&i===t&&Object.keys(new St).forEach(a=>{if(r[a].message.type==="error")throw new Error(r[a].message.text)})})};export{j_ as FansUnitedSDK};
|
|
4
4
|
//# sourceMappingURL=index.js.map
|