fansunited-sdk-esm 1.49.2 → 1.49.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/index.js.map +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Zo=Object.create;var io=Object.defineProperty;var ts=Object.getOwnPropertyDescriptor;var es=Object.getOwnPropertyNames;var is=Object.getPrototypeOf,rs=Object.prototype.hasOwnProperty;var as=(o,t,e)=>t in o?io(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var $a=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var os=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of es(t))!rs.call(o,r)&&r!==e&&io(o,r,{get:()=>t[r],enumerable:!(i=ts(t,r))||i.enumerable});return o};var ss=(o,t,e)=>(e=o!=null?Zo(is(o)):{},os(t||!o||!o.__esModule?io(e,"default",{value:o,enumerable:!0}):e,o));var ro=(o,t,e)=>(as(o,typeof t!="symbol"?t+"":t,e),e);var Co=$a((wn,Xa)=>{var cs=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,u){typeof d=="object"&&(m=d.depth,y=d.prototype,u=d.includeNonEnumerable,d=d.circular);var gt=[],Rt=[],vt=typeof Buffer<"u";typeof d>"u"&&(d=!0),typeof m>"u"&&(m=1/0);function k(f,ot){if(f===null)return null;if(ot===0)return f;var T,Oe;if(typeof f!="object")return f;if(o(f,t))T=new t;else if(o(f,e))T=new e;else if(o(f,i))T=new i(function(xe,h){f.then(function(De){xe(k(De,ot-1))},function(De){h(k(De,ot-1))})});else if(r.__isArray(f))T=[];else if(r.__isRegExp(f))T=new RegExp(f.source,l(f)),f.lastIndex&&(T.lastIndex=f.lastIndex);else if(r.__isDate(f))T=new Date(f.getTime());else{if(vt&&Buffer.isBuffer(f))return Buffer.allocUnsafe?T=Buffer.allocUnsafe(f.length):T=new Buffer(f.length),f.copy(T),T;o(f,Error)?T=Object.create(f):typeof y>"u"?(Oe=Object.getPrototypeOf(f),T=Object.create(Oe)):(T=Object.create(y),Oe=y)}if(d){var yo=gt.indexOf(f);if(yo!=-1)return Rt[yo];gt.push(f),Rt.push(T)}o(f,t)&&f.forEach(function(xe,h){var De=k(h,ot-1),Jo=k(xe,ot-1);T.set(De,Jo)}),o(f,e)&&f.forEach(function(xe){var h=k(xe,ot-1);T.add(h)});for(var K in f){var eo;Oe&&(eo=Object.getOwnPropertyDescriptor(Oe,K)),!(eo&&eo.set==null)&&(T[K]=k(f[K],ot-1))}if(Object.getOwnPropertySymbols)for(var Mo=Object.getOwnPropertySymbols(f),K=0;K<Mo.length;K++){var Ga=Mo[K],be=Object.getOwnPropertyDescriptor(f,Ga);be&&!be.enumerable&&!u||(T[Ga]=k(f[Ga],ot-1),be.enumerable||Object.defineProperty(T,Ga,{enumerable:!1}))}if(u)for(var bo=Object.getOwnPropertyNames(f),K=0;K<bo.length;K++){var Va=bo[K],be=Object.getOwnPropertyDescriptor(f,Va);be&&be.enumerable||(T[Va]=k(f[Va],ot-1),Object.defineProperty(T,Va,{enumerable:!1}))}return T}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 Xa=="object"&&Xa.exports&&(Xa.exports=cs)});var Go=$a((In,co)=>{"use strict";var Ie=typeof Reflect=="object"?Reflect:null,Ao=Ie&&typeof Ie.apply=="function"?Ie.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)},qa;Ie&&typeof Ie.ownKeys=="function"?qa=Ie.ownKeys:Object.getOwnPropertySymbols?qa=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:qa=function(t){return Object.getOwnPropertyNames(t)};function ds(o){console&&console.warn&&console.warn(o)}var xo=Number.isNaN||function(t){return t!==t};function w(){w.init.call(this)}co.exports=w;co.exports.once=fs;w.EventEmitter=w;w.prototype._events=void 0;w.prototype._eventsCount=0;w.prototype._maxListeners=void 0;var Oo=10;function za(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return Oo},set:function(o){if(typeof o!="number"||o<0||xo(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");Oo=o}});w.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};w.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||xo(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 Do(o){return o._maxListeners===void 0?w.defaultMaxListeners:o._maxListeners}w.prototype.getMaxListeners=function(){return Do(this)};w.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")Ao(n,this,e);else for(var l=n.length,c=Ho(n,l),i=0;i<l;++i)Ao(c[i],this,e);return!0};function Lo(o,t,e,i){var r,a,s;if(za(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=Do(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,ds(p)}return o}w.prototype.addListener=function(t,e){return Lo(this,t,e,!1)};w.prototype.on=w.prototype.addListener;w.prototype.prependListener=function(t,e){return Lo(this,t,e,!0)};function ms(){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 Bo(o,t,e){var i={fired:!1,wrapFn:void 0,target:o,type:t,listener:e},r=ms.bind(i);return r.listener=e,i.wrapFn=r,r}w.prototype.once=function(t,e){return za(e),this.on(t,Bo(this,t,e)),this};w.prototype.prependOnceListener=function(t,e){return za(e),this.prependListener(t,Bo(this,t,e)),this};w.prototype.removeListener=function(t,e){var i,r,a,s,p;if(za(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():us(i,a),i.length===1&&(r[t]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",t,p||e)}return this};w.prototype.off=w.prototype.removeListener;w.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 No(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?hs(r):Ho(r,r.length)}w.prototype.listeners=function(t){return No(this,t,!0)};w.prototype.rawListeners=function(t){return No(this,t,!1)};w.listenerCount=function(o,t){return typeof o.listenerCount=="function"?o.listenerCount(t):ko.call(o,t)};w.prototype.listenerCount=ko;function ko(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}w.prototype.eventNames=function(){return this._eventsCount>0?qa(this._events):[]};function Ho(o,t){for(var e=new Array(t),i=0;i<t;++i)e[i]=o[i];return e}function us(o,t){for(;t+1<o.length;t++)o[t]=o[t+1];o.pop()}function hs(o){for(var t=new Array(o.length),e=0;e<t.length;++e)t[e]=o[e].listener||o[e];return t}function fs(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))}Uo(o,t,a,{once:!0}),t!=="error"&&gs(o,r,{once:!0})})}function gs(o,t,e){typeof o.on=="function"&&Uo(o,"error",t,e)}function Uo(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 Wo=$a((Vo,$o)=>{(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=Co(),o=Go().EventEmitter,$o.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,u,gt;if(u=d,[...d]=u,[m]=i.call(d,-1),typeof m=="function")try{gt=c(...d),m(null,gt)}catch(Rt){y=Rt,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,u;if(r(this,s),!Array.isArray(n))throw l=this._error("EKEYSTYPE"),l;for(u={},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++,u[m]=this._unwrap(this.data[m])):this.stats.misses++}return u}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,u,gt,Rt,vt,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,gt=n.length;d<gt;d++){if(u=n[d],{key:y,val:k,ttl:vt}=u,vt&&typeof vt!="number")throw l=this._error("ETTLTYPE"),l;if((c=this._isInvalidKey(y))!=null)throw c}for(m=0,Rt=n.length;m<Rt;m++)u=n[m],{key:y,val:k,ttl:vt}=u,this.set(y,k,vt);return!0}del(n){var l,c,d,m,y,u;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++,u=this.data[m],delete this.data[m],this.emit("del",m,u.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,u;return r(this,s),this.options.useClones||(c=!1),m=Date.now(),d=0,u=1e3,l===0?d=0:l?d=m+l*u:this.options.stdTTL===0?d=this.options.stdTTL:d=m+this.options.stdTTL*u,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(Vo)});var Qo=$a((Ko,jo)=>{(function(){var o;o=jo.exports=Wo(),o.version="5.1.2"}).call(Ko)});var ao=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},Et=(o,t)=>{let e=[];for(;o.length>t;){let i=o.splice(0,t);e.push(i)}return e.push(o),e},S=(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"},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"},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"},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"};return o==="prod"?e=i[t]:o==="dev"?e=a[t]:o==="watg"?e=r[t]:e=s[t],e},yt=o=>o.filter((e,i,r)=>i===r.indexOf(e)),P=o=>o||!1,I=()=>`&disable_cache=${Date.now()}`,Wa=o=>JSON.parse(JSON.stringify(o.sort((t,e)=>t.localeCompare(e))));var Le=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var Be=class{profilesFromResponse=t=>t?t.map(e=>this.fullProfileFromResponse(e)):null;fullProfileFromResponse=t=>{let e=new Le;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 St=class{nextPageStartsAfter=null;itemsPerPage=null};var j=class{pagination=new St};var _=class{meta=new j;data=[]};var Ne=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var ke=class{followResponse=t=>t.map(e=>this.remapResponse(e));followingFromResponse=t=>{let e=new _;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 Ne;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 He=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var Ue=class{followersFromResponse=t=>{let e=new _;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 He;return e.avatar=t.avatar,e.followerId=t.follower_id,e.name=t.name,e.profileId=t.profile_id,e}};var we=class{profile_ids=[]};function oo(o){this.message=o}oo.prototype=new Error,oo.prototype.name="InvalidCharacterError";var Io=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(o){var t=String(o).replace(/=+$/,"");if(t.length%4==1)throw new oo("'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 ns(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(Io(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 Io(t)}}function Ka(o){this.message=o}function ls(o,t){if(typeof o!="string")throw new Ka("Invalid token specified");var e=(t=t||{}).header===!0?0:1;try{return JSON.parse(ns(o.split(".")[e]))}catch(i){throw new Ka("Invalid token specified: "+i.message)}}Ka.prototype=new Error,Ka.prototype.name="InvalidTokenError";var Po=ls;var C={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id",api_football:"api_football_id"},so={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},no=["matchId","matchType","market","prediction"],Fo=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 lo={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
1
|
+
var Zo=Object.create;var io=Object.defineProperty;var ts=Object.getOwnPropertyDescriptor;var es=Object.getOwnPropertyNames;var is=Object.getPrototypeOf,rs=Object.prototype.hasOwnProperty;var as=(o,t,e)=>t in o?io(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var $a=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var os=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of es(t))!rs.call(o,r)&&r!==e&&io(o,r,{get:()=>t[r],enumerable:!(i=ts(t,r))||i.enumerable});return o};var ss=(o,t,e)=>(e=o!=null?Zo(is(o)):{},os(t||!o||!o.__esModule?io(e,"default",{value:o,enumerable:!0}):e,o));var ro=(o,t,e)=>(as(o,typeof t!="symbol"?t+"":t,e),e);var Co=$a((wn,Xa)=>{var cs=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,u){typeof d=="object"&&(m=d.depth,y=d.prototype,u=d.includeNonEnumerable,d=d.circular);var gt=[],Rt=[],vt=typeof Buffer<"u";typeof d>"u"&&(d=!0),typeof m>"u"&&(m=1/0);function k(f,ot){if(f===null)return null;if(ot===0)return f;var F,Oe;if(typeof f!="object")return f;if(o(f,t))F=new t;else if(o(f,e))F=new e;else if(o(f,i))F=new i(function(De,h){f.then(function(xe){De(k(xe,ot-1))},function(xe){h(k(xe,ot-1))})});else if(r.__isArray(f))F=[];else if(r.__isRegExp(f))F=new RegExp(f.source,l(f)),f.lastIndex&&(F.lastIndex=f.lastIndex);else if(r.__isDate(f))F=new Date(f.getTime());else{if(vt&&Buffer.isBuffer(f))return Buffer.allocUnsafe?F=Buffer.allocUnsafe(f.length):F=new Buffer(f.length),f.copy(F),F;o(f,Error)?F=Object.create(f):typeof y>"u"?(Oe=Object.getPrototypeOf(f),F=Object.create(Oe)):(F=Object.create(y),Oe=y)}if(d){var yo=gt.indexOf(f);if(yo!=-1)return Rt[yo];gt.push(f),Rt.push(F)}o(f,t)&&f.forEach(function(De,h){var xe=k(h,ot-1),Jo=k(De,ot-1);F.set(xe,Jo)}),o(f,e)&&f.forEach(function(De){var h=k(De,ot-1);F.add(h)});for(var K in f){var eo;Oe&&(eo=Object.getOwnPropertyDescriptor(Oe,K)),!(eo&&eo.set==null)&&(F[K]=k(f[K],ot-1))}if(Object.getOwnPropertySymbols)for(var Mo=Object.getOwnPropertySymbols(f),K=0;K<Mo.length;K++){var Ga=Mo[K],be=Object.getOwnPropertyDescriptor(f,Ga);be&&!be.enumerable&&!u||(F[Ga]=k(f[Ga],ot-1),be.enumerable||Object.defineProperty(F,Ga,{enumerable:!1}))}if(u)for(var bo=Object.getOwnPropertyNames(f),K=0;K<bo.length;K++){var Va=bo[K],be=Object.getOwnPropertyDescriptor(f,Va);be&&be.enumerable||(F[Va]=k(f[Va],ot-1),Object.defineProperty(F,Va,{enumerable:!1}))}return F}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 Xa=="object"&&Xa.exports&&(Xa.exports=cs)});var Go=$a((In,co)=>{"use strict";var Ie=typeof Reflect=="object"?Reflect:null,Ao=Ie&&typeof Ie.apply=="function"?Ie.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)},qa;Ie&&typeof Ie.ownKeys=="function"?qa=Ie.ownKeys:Object.getOwnPropertySymbols?qa=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:qa=function(t){return Object.getOwnPropertyNames(t)};function ds(o){console&&console.warn&&console.warn(o)}var Do=Number.isNaN||function(t){return t!==t};function w(){w.init.call(this)}co.exports=w;co.exports.once=fs;w.EventEmitter=w;w.prototype._events=void 0;w.prototype._eventsCount=0;w.prototype._maxListeners=void 0;var Oo=10;function za(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return Oo},set:function(o){if(typeof o!="number"||o<0||Do(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");Oo=o}});w.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};w.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Do(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 xo(o){return o._maxListeners===void 0?w.defaultMaxListeners:o._maxListeners}w.prototype.getMaxListeners=function(){return xo(this)};w.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")Ao(n,this,e);else for(var l=n.length,c=Ho(n,l),i=0;i<l;++i)Ao(c[i],this,e);return!0};function Lo(o,t,e,i){var r,a,s;if(za(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=xo(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,ds(p)}return o}w.prototype.addListener=function(t,e){return Lo(this,t,e,!1)};w.prototype.on=w.prototype.addListener;w.prototype.prependListener=function(t,e){return Lo(this,t,e,!0)};function ms(){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 Bo(o,t,e){var i={fired:!1,wrapFn:void 0,target:o,type:t,listener:e},r=ms.bind(i);return r.listener=e,i.wrapFn=r,r}w.prototype.once=function(t,e){return za(e),this.on(t,Bo(this,t,e)),this};w.prototype.prependOnceListener=function(t,e){return za(e),this.prependListener(t,Bo(this,t,e)),this};w.prototype.removeListener=function(t,e){var i,r,a,s,p;if(za(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():us(i,a),i.length===1&&(r[t]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",t,p||e)}return this};w.prototype.off=w.prototype.removeListener;w.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 No(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?hs(r):Ho(r,r.length)}w.prototype.listeners=function(t){return No(this,t,!0)};w.prototype.rawListeners=function(t){return No(this,t,!1)};w.listenerCount=function(o,t){return typeof o.listenerCount=="function"?o.listenerCount(t):ko.call(o,t)};w.prototype.listenerCount=ko;function ko(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}w.prototype.eventNames=function(){return this._eventsCount>0?qa(this._events):[]};function Ho(o,t){for(var e=new Array(t),i=0;i<t;++i)e[i]=o[i];return e}function us(o,t){for(;t+1<o.length;t++)o[t]=o[t+1];o.pop()}function hs(o){for(var t=new Array(o.length),e=0;e<t.length;++e)t[e]=o[e].listener||o[e];return t}function fs(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))}Uo(o,t,a,{once:!0}),t!=="error"&&gs(o,r,{once:!0})})}function gs(o,t,e){typeof o.on=="function"&&Uo(o,"error",t,e)}function Uo(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 Wo=$a((Vo,$o)=>{(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=Co(),o=Go().EventEmitter,$o.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,u,gt;if(u=d,[...d]=u,[m]=i.call(d,-1),typeof m=="function")try{gt=c(...d),m(null,gt)}catch(Rt){y=Rt,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,u;if(r(this,s),!Array.isArray(n))throw l=this._error("EKEYSTYPE"),l;for(u={},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++,u[m]=this._unwrap(this.data[m])):this.stats.misses++}return u}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,u,gt,Rt,vt,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,gt=n.length;d<gt;d++){if(u=n[d],{key:y,val:k,ttl:vt}=u,vt&&typeof vt!="number")throw l=this._error("ETTLTYPE"),l;if((c=this._isInvalidKey(y))!=null)throw c}for(m=0,Rt=n.length;m<Rt;m++)u=n[m],{key:y,val:k,ttl:vt}=u,this.set(y,k,vt);return!0}del(n){var l,c,d,m,y,u;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++,u=this.data[m],delete this.data[m],this.emit("del",m,u.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,u;return r(this,s),this.options.useClones||(c=!1),m=Date.now(),d=0,u=1e3,l===0?d=0:l?d=m+l*u:this.options.stdTTL===0?d=this.options.stdTTL:d=m+this.options.stdTTL*u,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(Vo)});var Qo=$a((Ko,jo)=>{(function(){var o;o=jo.exports=Wo(),o.version="5.1.2"}).call(Ko)});var ao=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},Et=(o,t)=>{let e=[];for(;o.length>t;){let i=o.splice(0,t);e.push(i)}return e.push(o),e},S=(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"},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"},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"},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"};return o==="prod"?e=i[t]:o==="dev"?e=a[t]:o==="watg"?e=r[t]:e=s[t],e},yt=o=>o.filter((e,i,r)=>i===r.indexOf(e)),P=o=>o||!1,I=()=>`&disable_cache=${Date.now()}`,Wa=o=>JSON.parse(JSON.stringify(o.sort((t,e)=>t.localeCompare(e))));var Le=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var Be=class{profilesFromResponse=t=>t?t.map(e=>this.fullProfileFromResponse(e)):null;fullProfileFromResponse=t=>{let e=new Le;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 St=class{nextPageStartsAfter=null;itemsPerPage=null};var j=class{pagination=new St};var T=class{meta=new j;data=[]};var Ne=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var ke=class{followResponse=t=>t.map(e=>this.remapResponse(e));followingFromResponse=t=>{let e=new T;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 Ne;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 He=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var Ue=class{followersFromResponse=t=>{let e=new T;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 He;return e.avatar=t.avatar,e.followerId=t.follower_id,e.name=t.name,e.profileId=t.profile_id,e}};var we=class{profile_ids=[]};function oo(o){this.message=o}oo.prototype=new Error,oo.prototype.name="InvalidCharacterError";var Io=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(o){var t=String(o).replace(/=+$/,"");if(t.length%4==1)throw new oo("'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 ns(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(Io(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 Io(t)}}function Ka(o){this.message=o}function ls(o,t){if(typeof o!="string")throw new Ka("Invalid token specified");var e=(t=t||{}).header===!0?0:1;try{return JSON.parse(ns(o.split(".")[e]))}catch(i){throw new Ka("Invalid token specified: "+i.message)}}Ka.prototype=new Error,Ka.prototype.name="InvalidTokenError";var Po=ls;var C={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id",api_football:"api_football_id"},so={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},no=["matchId","matchType","market","prediction"],_o=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 lo={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
2
2
|
${so.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
|
-
${so.PREDICTOR_USER_RELATED_OPERATION}`},To=(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`,ja=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`,_o=o=>`The market '${o}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Ro=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`,vo=(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`,Eo=(o,t)=>`The field ${o} has incorrect type. The correct type is ${t}`;var Mt=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 g=class{error={code:0,status:"",message:""};constructor(t,e,i){this.error.code=t,this.error.status=e,this.error.message=i}};var R=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};transformFetchException=(t,e)=>{if(!e&&t.status===401){if(this.errorHandlingMode==="standard")return new g(401,"unauthorized","Invalid JWT token is provided");let s={code:401,status:"unauthorized",message:"Invalid JWT token is provided"};return new Mt(t,s)}let{code:i,status:r,message:a}=e.error;return this.errorHandlingMode==="standard"?new g(i,r,a):new Mt(t,e.error)};validateJWTToken=()=>{let t=null;try{t=Po(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 Mt(r,a)}else if(this.errorHandlingMode==="standard")throw new g(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 Mt(i,r)}else if(this.errorHandlingMode==="standard")throw new g(401,"invalid_token","The provided JWT token is expired")}}};var ps="/countries",L="/profile",Qa="/profiles",At=class extends R{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(t){super(t,S(t.environment,"profile")),this.lang=t.lang,this.profileRemapper=new Be,this.followingRemapper=new ke,this.followersRemapper=new Ue}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${ps}${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=`${L}${this.apiSignInUrl}`,i="";if(t){e=`${Qa}/${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=Et(t,this.limitIds);for(let m of d){let y=`${Qa}${this.apiSignInUrl}&profile_ids=${m.join(",")}`;a=`There was a problem fetching the following profiles: ${m.join(",")}`,i&&(y+=`&disable_cache=${r}`);let u=await this.fetchWithoutAuth(y,a);c.push(...this.profileRemapper.profilesFromResponse(u.data))}return c}let n=`${Qa}${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=`${Qa}${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=`${L}/followers${this.apiSignInUrl}`,r="There was a problem fetching the followers for own profile";if(t&&!e){i=`${L}/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=`${L}/${e}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${L}/${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=`${L}/following${this.apiSignInUrl}`,r="There was a problem fetching the followers of own profile";if(t&&!e){i=`${L}/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=`${L}/${e}/following${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${L}/${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 we;e.profile_ids=t;let i=L+`/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 we;e.profile_ids=t;let i=L+`/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=`${L}/badges${this.apiSignInUrl}`,i="There was a problem with fetching own badges";return t?(e=`${L}/${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=L+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 B=(a=>(a.NATIVE="native",a.ENETPULSE="enetpulse",a.SPORTRADAR="sportradar",a.SPORTAL_365="sportal365",a.API_FOOTBALL="api_football",a))(B||{});var Ge={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Ve=class extends R{constructor(t){super(t,S(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${Ge[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}&${Ge[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}&${Ge[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=ao(e),a=[];for(let s of r){let p=`/football${this.apiSignInUrl}&input_provider=${i}&${Ge[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=yt(i),p=ao(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+=`${Ge[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 So="FansUnited",po={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}}},$e=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t,(this.getData()===void 0||this.getData()===null)&&this.setData(po)}clearData=()=>{this.setData(po)};getEntityById=(t="",e="")=>this.getData().football.ids.find(i=>{let r=C[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=C[i];return r&&t.includes(`${r[a]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let a=C[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=C[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=C[i],a=C[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=()=>JSON.parse(localStorage.getItem(So));setData=t=>{localStorage.setItem(So,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(po)}};var Xo=ss(Qo());var M=class{profileTTL=600;clientTTL=14400;profileBadgesTTL=3600;idMappingsExpiration=0;idSchema="";constructor(t){}static getInstance(t){return M.instance||(M.instance=new M(t),M.nodeCache.options.useClones=!1),M.instance}clearData=()=>M.nodeCache.flushAll();getEntityById=(t,e)=>{let i=M.nodeCache.get("ids");return i?i.find(r=>{let a=C[this.idSchema];return r&&`${r[a]}`===e&&r.resource===t}):null};getEntity=(t,e,i)=>{let r=M.nodeCache.get("ids");return r?Array.isArray(t)?[]:null:Array.isArray(t)?r.filter(a=>{let s=C[i];return a&&t.includes(`${a[s]}`)&&a.resource===e}):r.find(a=>{let s=C[i];return a&&`${a[s]}`===t&&a.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=C[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=C[i],a=C[e],s=M.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=M.nodeCache.get("ids");e.push(t),M.nodeCache.set("ids",e)};addIdMappings=t=>{let e=M.nodeCache.get("ids");e=[...e,...t],M.nodeCache.set("ids",e)};addTopIdMappings=t=>{let e=M.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],M.nodeCache.set("ids",r)}else M.nodeCache.set("ids",t);this.idMappingsExpiration=Math.floor(Date.now()/1e3)+i};setOwnProfile=t=>M.nodeCache.set("profile",t,this.profileTTL);getOwnProfile=()=>M.nodeCache.get("profile");getProfileCountries=()=>M.nodeCache.get("profile_countries");setProfileCountries=t=>M.nodeCache.set("profile_countries",t);getProfileStats=()=>M.nodeCache.get("profile_stats");setProfileStats=t=>M.nodeCache.set("profile_stats",t,this.profileTTL);getProfileBadges=()=>M.nodeCache.get("profile_badges");setProfileBadges=t=>{M.nodeCache.set("profile_badges",t,this.profileBadgesTTL)};getFootballCountries=()=>M.nodeCache.get("football_countries");setFootballCountries=t=>M.nodeCache.set("football_countries",t);getCompetitions=t=>{let e=M.nodeCache.get("football_competitions");return e?t?t.competitionSearchFilter(e):e:null};setCompetitions=t=>M.nodeCache.set("football_competitions",t);getCompetitionsLength=()=>{let t=M.nodeCache.get("football_competitions");return t?t.length:0};getClientFeatures=()=>M.nodeCache.get("client");setClientFeatures=t=>M.nodeCache.set("client",t,this.clientTTL);deleteClientFeatures=()=>M.nodeCache.del("client");getExpiration=(t,e)=>{let i=this.getKeyFromExpirationType(e);return i==="ids"?this.idMappingsExpiration:M.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"}}},Ot=M;ro(Ot,"instance"),ro(Ot,"nodeCache",new Xo.default);var H=class{createLocalCacheInstance=t=>typeof window>"u"?Ot.getInstance(t):new $e(t)};var We=class{localCache=null;https=null;constructor(t){this.localCache=new H().createLocalCacheInstance(t.idSchema),this.https=new Ve(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 Ya=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 Ke=class{extractedObjIds={};traverse=(t,e)=>(e=Ya(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 je=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=Ya(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 v=class{idSchema="";idMappingFacade=null;constructor(t){this.idSchema=t.idSchema,this.idMappingFacade=new We(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 Ke().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new je().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 N=class{completed=!1;percentage;constructor(t){this.percentage=t}};var Qe=class{teamFollowed=new N(10);teamFavourite=new N(15);playerFollowed=new N(10);playerFavourite=new N(10);competitionFollowed=new N(10);competitionFavourite=new N(5);addedBirthdate=new N(10);addedGender=new N(10);addedCountry=new N(10);addedAvatar=new N(10)};var Xe=class{totalPercentage;breakdown=new Qe};var Pe=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 Q=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 g(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 Pe(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 Pe(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 Xe,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 qe=class{id=null;name=null;assets=null};var ze=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 b=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 Ye=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 ze,this.profileFacade=new Q(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 qe,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 b(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.errorHandlingMode==="standard")throw new g(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 Je=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 Q(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 Ze=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 Fe=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 ti=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 Fe(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 Fe({competitionIds:t,limit:i}),a=await this.getCompetitions(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=Wa(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 Te=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 ei=class{reason="";words=[]};var xt=class{enabled=!1;moderateLinks=!1;linksWhitelist=[];moderatorProfileId="";dictionary=new ei};var ii=class{enabled=!1;clientId=null;automaticModeration=new xt};var ri=class{general=[];predictor=[];topX=[];matchQuiz=[]};var st=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var ai=class{id;label;assets={mainImageUrl:""};enabled;requirements=new st};var Dt=class extends st{postPoints=null;postsCount=null;reactionsCount=null;totalDiscussionPoints=null};var oi=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Dt};var si=class{id;weight;multiplier;conditions};var ni=class{value=[new si]};var Lt=class{points=null;tiers=null;badges=null};var li=class{enabled=!1;clientId=null;conditions={list:null};actions=new ni;rewards=new Lt};var pi=class{general=null;predictor=null;activity=null;topX=null;matchQuiz=null;discussionPost=null};var Bt=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var Nt=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var ci=class{competitions=[];teams=[];markets=[]};var kt=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new ci;userDataConfig=null};var di=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var mi=class{remapPredictorConfig=t=>{let e=new kt;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 Nt;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 Bt;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 li;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 ii;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 xt;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 Lt;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new pi;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 ri;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 ai;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 st;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 di;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 oi;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 Dt;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 x=class extends R{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(t){super(t,S(t.environment,"client")),this.clientId=t.clientId,this.localStorage=new H().createLocalCacheInstance(t.idSchema),this.featureConfigRemapper=new mi}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 nt=class{clientHttps=null;constructor(t){this.clientHttps=new x(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 hi=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new nt(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new Te(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 Te({teamIds:t,limit:i}),{data:a}=await this.getTeams(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=Wa(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 _e=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 lt=class{https=null;footballService=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new nt(t)}getPlayersIdMapping=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.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 _e({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=yt(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 Ht=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 pt=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new nt(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new Ht(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 Ht({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=yt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let a=new Ht({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 fi=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 gi=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new fi(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 Ut=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new Ze(e,i,r),this.competitionsFacade=new ti(e,i,r),this.teamsFacade=new hi(t,i,r),this.playerFacade=new lt(t,i,r),this.matchFacade=new pt(t,i,r),this.searchFacade=new gi(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 yi=class{id="";alias="";countryCode="";assets=null;name=""};var E=class{countriesFromResponse=t=>{if(t)return t.map(e=>this.countryFromResponse(e))};countryFromResponse=t=>{try{if(t){let e=new yi;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 Mi=class{id="";country=null;gender="";assets=null;type="";name=""};var D=class{countryRemapper=null;constructor(){this.countryRemapper=new E}fromResponse(t){try{let e=new Mi;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 bi=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var wi=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName="";isDeleted=!1};var A=class{countryRemapper=null;constructor(){this.countryRemapper=new E}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}catch(e){throw console.warn("There was a problem remapping teams response",e),e}}};var Ii=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new E,this.teamBasicRemapper=new A}fromResponse(t){try{let e=new bi;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 Pi=class{primary=null;secondary=null;tertiary=null};var Fi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new Pi;squad=[]};var Ti=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var _i=class{countryRemapper=null;constructor(){this.countryRemapper=new E}fromResponse(t){try{let e=new Ti;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 Ri=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new E,this.competitionRemapper=new D,this.playerRemapper=new _i}fromResponse(t){try{let e=new Fi;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 vi=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 Ei=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Gt=class{fromResponse(t){try{let e=new Ei;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 Si=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new A,this.competitionRemapper=new D,this.scoresRemapper=new Gt}fromResponse(t){try{let e=new vi;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 U=class{type=null;subType=null};var Ci=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 U;lineups=null};var Ai=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 Oi=class{fromResponse(t){try{let e=new Ai;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 Vt=class{homeTeam={players:[]};awayTeam={players:[]}};var xi=class{id="";name="";position="";shirtNumber;assets=null;type=""};var $t=class{fromResponse(t){try{let e=new xi;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 Di=class{playerRemapper=null;constructor(){this.playerRemapper=new $t}fromResponse(t){try{let e=new Vt;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 Li=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Bi=class{playerRemapper=null;constructor(){this.playerRemapper=new $t}fromResponse(t){try{let e=new Li;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 Ni=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new A,this.competitionsMapper=new D,this.lineupsMapper=new Di,this.scoresMapper=new Gt,this.statsMapper=new Oi,this.timelineMapper=new Bi}fromResponse(t){try{let e=new Ci;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 Vt,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var ki=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Hi=class{countryRemapper=null;constructor(){this.countryRemapper=new E}fromResponse(t){try{let e=new ki;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 Ui=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var Wt=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new E,this.teamRemapper=new A}fromResponse(t){try{let e=new Ui;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 Gi=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Vi=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new E,this.teamRemapper=new A,this.competitionRemapper=new D}fromResponse(t){try{let e=new Gi;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 $i=class{teams=null;players=null;competitions=null};var Wi=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new A,this.playerRemapper=new Wt,this.competitionremapper=new D}fromResponse(t){try{let e=new $i;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 ct=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var X=class{pagination=new ct};var Kt=class{meta=new X;data=[]};var Ki=class{remapMetaProp=t=>{let e=new X;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 q=class extends R{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,S(t.environment,"football")),this.apiSignInUrl=t.lang!=="en"?this.apiSignInUrl+`&lang=${t.lang}`:this.apiSignInUrl,this.countryRemapper=new E,this.competitionBasicRemapper=new D,this.competitionFullRemapper=new Ii,this.teamBasicRemapper=new A,this.teamFullRemapper=new Ri,this.matchBasicRemapper=new Si,this.matchFullRemapper=new Ni,this.playerBasicRemapper=new Wt,this.playerFullRemapper=new Vi,this.topPlayerRemapper=new Hi,this.searchRemapper=new Wi,this.footballMetaRemapper=new Ki}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=Et(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=Et(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 Kt,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=Et(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 Kt,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 Kt,r="There was a problem with football matches request";if(t&&t.matchIds&&t.matchIds.length>this.limitIds-1){let a=[],s=Et(t.matchIds,this.limitIds);for(let n of s){t.matchIds=n;let l=`/matches${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=I());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+=I());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 G=(h=>(h.FT_1X2="FT_1X2",h.HT_1X2="HT_1X2",h.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",h.DOUBLE_CHANCE="DOUBLE_CHANCE",h.HT_FT="HT_FT",h.PLAYER_SCORE="PLAYER_SCORE",h.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",h.PLAYER_RED_CARD="PLAYER_RED_CARD",h.RED_CARD_MATCH="RED_CARD_MATCH",h.PENALTY_MATCH="PENALTY_MATCH",h.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",h.CORNERS_MATCH="CORNERS_MATCH",h.CORRECT_SCORE="CORRECT_SCORE",h.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",h.CORRECT_SCORE_HT="CORRECT_SCORE_HT",h.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",h.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",h.OVER_GOALS_0_5="OVER_GOALS_0_5",h.OVER_GOALS_1_5="OVER_GOALS_1_5",h.OVER_GOALS_2_5="OVER_GOALS_2_5",h.OVER_GOALS_3_5="OVER_GOALS_3_5",h.OVER_GOALS_4_5="OVER_GOALS_4_5",h.OVER_GOALS_5_5="OVER_GOALS_5_5",h.OVER_GOALS_6_5="OVER_GOALS_6_5",h.OVER_CORNERS_6_5="OVER_CORNERS_6_5",h.OVER_CORNERS_7_5="OVER_CORNERS_7_5",h.OVER_CORNERS_8_5="OVER_CORNERS_8_5",h.OVER_CORNERS_9_5="OVER_CORNERS_9_5",h.OVER_CORNERS_10_5="OVER_CORNERS_10_5",h.OVER_CORNERS_11_5="OVER_CORNERS_11_5",h.OVER_CORNERS_12_5="OVER_CORNERS_12_5",h.OVER_CORNERS_13_5="OVER_CORNERS_13_5",h))(G||{}),qo=["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"],zo=["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"],z=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Yo=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],Re="PLAYER_SCORE_FIRST_GOAL";var ji=class{id="";achievedAt=""};var jt=class{totalPoints=null;postPoints=null;postsMade=null;reactionPoints=null;reactionCount=null};var ve=class{participations=0;points=0};var It=class{footballCompetitions=[];footballTeams=[]};var Qt=class{predictionsMade=0;correct=0;points=0;breakdown=new It};var Xt=class{single=new Qt;topX=new ve;matchQuiz=new ve};var Qi=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var Xi=class{profileId;tier;points;predictionsMade;successRates=new Qi;predictions=new Xt;tiers=[];badges=[];discussions=new jt};var qi=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var zi=class{successRatePercent;model=null};var qt=class{content=null;tags=[];campaign=null};var zt=class{id=null;profileId=null;property=null;value=null;action=null;context=new qt;points=0};var Yi=class{meta=new X;data=[new zt]};var Ji=class{remapSingleResponse=t=>{let e=new zt;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 Yi;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 Xi;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)},G[i]&&delete e[i].model});else return t;return e};remapSuccessRatePercent=t=>{let e=new zi;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new Xt;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new Qt;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 It,i=[],r=[];return Object.keys(t).forEach(a=>{let s=new qi;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 It};remapAchievementsStats=t=>t.map(e=>{let i=new ji;return i.id=e.id,i.achievedAt=e.achieved_at,i});remapDiscussionStats=t=>{let e=new jt;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 Yt=class extends R{activityRemapper=null;constructor(t){super(t,S(t.environment,"loyalty")),this.activityRemapper=new Ji}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+=P(e)?`/users/${t}/statistics${this.apiSignInUrl}${I()}`:`/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 Zi=class{id="";source="";type="";favourite=!1};var tr=class extends Zi{model=null};var er=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 tr;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 ir=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new v(t),this.profileOperations=new er(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 Y=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 At(t),this.activityHttps=new Yt(t),this.footballHttps=new q(t),this.idMapping=new v(t),this.localCache=new H().createLocalCacheInstance(t.idSchema),this.footballFacade=new Ut(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new Q(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new ir(t,this.footballFacade),this.ownProfileBuilder=new Ye(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps,t.errorHandlingMode),this.profileBuilder=new Je(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 Ja=(u=>(u.EN="en",u.BG="bg",u.RO="ro",u.EL="el",u.SK="sk",u.PT="pt",u.SR="sr",u.HU="hu",u.SV="sv",u.ES="es",u.FR="fr",u.NL="nl",u.DE="de",u.IT="it",u))(Ja||{});var rr=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(Ja),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 ar=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 or=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 sr=class{validate(t){let e=this.validateField(t.idSchema),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=Object.values(B),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 Ft=class{getIdToken=null;logout=null};var Zt=class{text=null;type=null};var nr=class{validation=null;message=new Zt;getIdToken={validation:null,message:new Zt};logout={validation:null,message:new Zt}};var lr=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 Ft),i=new nr;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 Ft).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 Se=class{validation;message};var pr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Se,logout:new Se};isValid=!1};var cr=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 dr=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 mr=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new pr,i={apiKey:new or,environment:new ar,idSchema:new sr,clientId:new cr,lang:new rr,errorHandlingMode:new dr,authProvider:new lr};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 te=class{https=null;idMapping=null;localCache=null;footballFacade=null;constructor(t){this.https=new q(t),this.idMapping=new v(t),this.localCache=new H().createLocalCacheInstance(t.idSchema),this.footballFacade=new Ut(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 ur=class{value=null;playerId=null;playerModel=null};var ee=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new ur;result=null};var hr=class{value=!1;playerId=null};var V=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i,r){this.matchId=t,this.market=e,this.prediction=new hr,this.prediction.value=i,this.prediction.playerId=r}};var ie=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var fr=class{value=null};var dt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new fr,this.prediction.value=i}};var $=class{value=!1};var re=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new $,this.prediction.value=i}};var ae=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new $,this.prediction.value=i}};var gr=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 V)e.market=t.market,e.prediction=t.prediction.value,e.player_id=t.prediction.playerId;else if(t instanceof re||t instanceof ae)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof dt){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 ee;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 ie;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 J=class{goldenGoal=null};var Ce=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new J;points=null;createdAt=null;updatedAt=null};var F=class{no=0;yes=0};var yr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new F;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new F;penaltyMatch=new F;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new F;overOnePointFiveGoals=new F;overTwoPointFiveGoals=new F;overThreePointFiveGoals=new F;overFourPointFiveGoals=new F;overFivePointFiveGoals=new F;overSixPointFiveGoals=new F;overSixPointFiveCorners=new F;overSevenPointFiveCorners=new F;overEightPointFiveCorners=new F;overNinePointFiveCorners=new F;overTenPointFiveCorners=new F;overElevenPointFiveCorners=new F;overTwelvePointFiveCorners=new F;overThirteenPointFiveCorners=new F};var Z=class{timeTiebreaker=!1};var mt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Z;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 J};var Tt=class{userId=null;points=null;results=[];tiebreaker=null};var Za=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(Za||{}),mo=["WON","LOST","PARTIALLY_WON","CANCELED"];var O=class{limit=null;startAfter=null;status=null;type=null;matchIds=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}constructFiltersUrl=()=>{let t="",e=!1;return this.status&&(e=Object.values(Za).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(",")}`),t}};var tt=class{limit;startAfter;constructor(t){this.limit=t.limit?t.limit:null,this.startAfter=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 Mr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(Mr||{});var W=class extends tt{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(Mr).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 ut=class{main=null;cover=null;mobile=null};var rt=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Z;participantsCount=0;related=null;excludedProfileIds=null;rules=null;labels=null;customFields=null;flags=null;images=new ut;createdAt=null;updatedAt=null};var at=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Z;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 oe=class extends rt{adContent=null};var et=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(t,e){this.footballHttps=new q(t),this.idMapping=e,this.matchFacade=new pt(t,this.footballHttps,e),this.playerFacade=new lt(t,this.footballHttps,e),this.profileNamespace=new Y(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=yt(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=Fo.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(z.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 F,a[r][p]):a[r][i]}else if(z.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 kt){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 Nt||t instanceof Bt){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 rt||r instanceof mt||r instanceof at||r instanceof oe?(r.fixtures.forEach(a=>e.push(a.matchId)),r instanceof at&&r.fixtures.forEach(a=>{a.prediction.playerId&&a.prediction.playerId!=="OWN_GOAL"&&i.push(a.prediction.playerId)})):r instanceof Tt&&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 rt||p instanceof mt||p instanceof at?(p.fixtures.forEach(n=>{this.handleMatchModel(a,n),p instanceof at&&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 Tt&&(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 O(i),i};initGameFilters=(t,e,i)=>{if(e&&i)return e.type=t,e.gameIds=i,e=new W(e),e;if(e&&!i)return e.type=t,e=new W(e),e;if(!e&&i){let r={type:t,gameIds:i};return r=new W(r),r}else{let r={type:t};return r=new W(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 mt&&(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 ie;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 O(t));break;case"current":if(t)this.deleteUnexpectedProperties(t),t.status=["ACTIVE"],t=new O(t);else{let r={status:["ACTIVE"]};t=new O(r)}break;case"past":if(t)this.deleteUnexpectedProperties(t),t.status=mo,t=new O(t);else{let r={status:mo};t=new O(r)}break;case"matches":if(t)this.deleteUnexpectedProperties(t),t.matchIds=i,t=new O(t);else{let r={matchIds:i};t=new O(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=>z.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[C[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[C[this.idMapping.idSchema]]})};deleteUnexpectedProperties=t=>(t.status&&(console.warn(lo.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(lo.UNEXPECTED_TYPE_PROP),delete t.type),t)};var se=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new dt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var ne=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new q(t),this.matchFacade=new pt(t,this.footballHttps,e),this.playerFacade=new lt(t,this.footballHttps,e),this.predictorService=new et(t,e),this.fixturesRemapper=new gr(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 se&&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 Ce,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 ee;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 Ce;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 yr;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 br=class{matchId=null;matchType=null;predictions=null};var wr=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new ne(t,e)}remapResponse=t=>{let e=new br;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var Ir=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U};var Pr=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Fr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new Pr};var Tr=class{value=null;result=null};var _r=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new Tr};var Rr=class{matchId=null;matchModel=null;outcome=null};var vr=class{gameId=null;results=null;tieBreakers=null};var le=class{entityId=null;entityType=null};var Er=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var Sr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Cr=class{remapPaginatedGames=t=>{let e=new _;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 rt;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 oe;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 Ir;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedUserTopXEditions=t=>{let e=new _;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 mt;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 _r;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedUserMathQuizEditions=t=>{let e=new _;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 at;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 Fr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedGameResults=t=>{let e=new _;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 Tt;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 vr;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 Er;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 Sr;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 U;return e.type=t.type,e.subType=t.sub_type,e};remapMarketResult=(t,e)=>{if(Yo.includes(t))return e[0];if(z.includes(t))return e;if(e[0]==="true")return!0;if(e[0]==="false")return!1};deleteUnusefulField=t=>((!z.includes(t.market)||this.isPlayerMarketWithNoResult(t.market,t.result))&&delete t.playerModels,t);isPlayerMarketWithNoResult=(t,e)=>z.includes(t)&&e.length===0;remapResults=t=>{let e=new Rr;return e.matchId=t.match_id,e.outcome=t.outcome,e};remapTiebreaker=t=>{let e=new J;return e.goldenGoal=t.golden_goal,e};remapTimeTiebreaker=t=>{let e=new Z;return e.timeTiebreaker=t,e};remapRelated=t=>t.map(e=>{let i=new le;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Ar=class{remapMetaData=t=>{let e=new j;return e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.itemsPerPage=t.pagination.items_per_page,e}};var it=class extends R{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(t,e){super(t,S(t.environment,"predictor")),this.predictionRemapper=new ne(t,e),this.matchSummaryRemapper=new wr(t,e),this.gamesRemapper=new Cr,this.metaRemapper=new Ar}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=P(e)?`/predictions/summary/${t}${this.apiSignInUrl}${I()}`:`/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 _,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 _,a=P(e)?`/predictions/users/${t}${this.apiSignInUrl}${I()}`:`/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=P(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${I()}`:`/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=P(e)?`/games/${t}${this.apiSignInUrl}${I()}`:`/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 _,a=P(e)?`/games/${t}/predictions${this.apiSignInUrl}${I()}`:`/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=P(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${I()}`:`/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=P(e)?`/games/${t}/results/${this.apiSignInUrl}${I()}`:`/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}`;P(e)&&(i+=`${I()}`);let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(a.data)};getContestWinners=async t=>{let e=`/winners/${this.apiSignInUrl}&contest_id=${t}`,i=`There was a problem fetching winners for the following game: ${t}`,r=await this.fetchWithoutAuth(e,i);return this.gamesRemapper.remapContestWinners(r)};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]}};var pe=class{gameInstanceId=null;fixtures=null};var uo=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(uo||{}),ho=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(ho||{}),fo=(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))(fo||{});var Or=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var xr=class{value};var Dr=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new xr,this.prediction.value=e}};var Lr=class{value=null};var Br=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Lr,this.prediction.value=e}};var Nr=class{value=null};var kr=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new Nr,this.prediction.value=i}};var Hr=class{value=null};var Ur=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Hr,this.prediction.value=e}};var Gr=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Vr=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var ht=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new pe);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(uo),s=Object.values(fo),p=Object.values(ho);if(e==="FT_1X2"||e==="HT_1X2"){if(a.includes(i))return new kr(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new Ur(t,i)}else if(e==="DOUBLE_CHANCE"){if(p.includes(i))return new Br(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 dt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new Dr(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new Or(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new Vr(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new Gr(t,i)}else if(z.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===Re&&this.isPredictionBoolean(i)){let l=r&&r===n?n:r;return new V(t,e,i,l)}if(r&&this.isPredictionBoolean(i))return new V(t,e,i,r)}else if(qo.includes(e)){if(this.isPredictionBoolean(i))return new ae(t,e,i)}else if(zo.includes(e)&&this.isPredictionBoolean(i))return new re(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{no.includes(r)||this.throwInvalidParamException([r])});let i=no.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 J)[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){z.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!==Re&&(e||this.throwInvalidParamException([i]),typeof e!="string"&&this.throwInvalidType(i,"string"))};validateMarket=t=>{Object.values(G).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=To(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_PREDICTION",i):new g(400,"INVALID_TYPE",i)};throwInvalidMarketException=(t,e)=>{let i=null;throw e&&e==="TOP_X"?i=_o(t):i=ja(t),this.errorHandlingMode==="default"?new b(400,"INVALID_MARKET",i):new g(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Ro(t);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",e):new g(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=vo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",i):new g(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=Eo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_TYPE",i):new g(400,"INVALID_TYPE",i)}};var $r=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 ht(t.errorHandlingMode),this.predictorService=new et(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let a=this.predictorValidator.validateFixture(t,e,i,r),s=new pe;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 b(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!a.matchId)throw new g(400,"INVALID_FIELD","Match id is invalid!");if(a instanceof V&&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!==Re&&!a.prediction.playerId)throw new b(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&a.market!==Re&&!a.prediction.playerId)throw new g(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 b(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new g(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 b(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new g(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)};var Wr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(t){this.idMapping=new v(t),this.predictorHttps=new it(t,this.idMapping),this.clientHttps=new x(t),this.predictorFacade=new $r(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)};var Kr=class{rankType=null;fromDate=null;toDate=null;pagination=new ct};var ce=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var jr=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new Kr;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 ce;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var Qr=class extends ce{id=null;rankType=null;model=null;gameType=null};var Xr=class{remapRankings=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new X;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 Qr;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}};var qr=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var zr=class{pagination=new ct;filters=new qr};var de=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;labels=null;customFields=null;flags=null;images=new ut;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var Yr=class extends de{adContent=null};var Jr=class{remapResponse=t=>{let e=[];return t.forEach(i=>{let r=new de;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.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 Yr;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.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 zr;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 le;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Zr=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var ta=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Zr;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 ea=class extends R{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,S(t.environment,"loyalty")),this.templateRemapper=new Jr,this.leaderboardRemapper=new jr,this.rankingsRemapper=new Xr,this.highestSuccessRateRemapper=new ta}getTemplates=async(t,e)=>{let i=t?`/leaderboard/templates/${this.apiSignInUrl}${t.constructFiltersUrl()}`:`/leaderboard/templates/${this.apiSignInUrl}`;i+=P(e)?I():"";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=P(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${I()}`:`/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=P(e)?`/leaderboard/${t}/${this.apiSignInUrl}${I()}`:`/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=P(e)?`/leaderboard/games/${t}/${this.apiSignInUrl}${I()}`:`/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()}`),P(i)&&(r+=`${I()}`);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()}`),P(e)&&(i+=`${I()}`);let a=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(a.data)};getEntitiesFollows=async(t,e)=>{let i=P(e)?`/statistics/follows${this.apiSignInUrl}${I()}`:`/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}};var ia=class{general;predictor;topX;matchQuiz};var me=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 ra=class extends me{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 aa=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new v(t),this.profileNamespace=new Y(t),this.footballNamespace=new te(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};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 ia;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 me(t));break;case"rankings":t&&(t=new ra(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 b(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new g(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 b(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new g(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 oa=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(G).includes(t)){let r=ja(t);throw e==="default"?new b(400,"INVALID_MARKET",r):new g(400,"INVALID_MARKET",r)}};validateDate=(t,e,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof t!="string")throw i==="default"?new b(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`):new g(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`);if(!r.test(t))throw i==="default"?new b(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`):new g(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 b(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`):new g(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 b(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`):new g(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`)}};var ue=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 ht(t.errorHandlingMode),this.predictorHttps=new it(t,e),this.predictorService=new et(t,e),this.clientHttps=new x(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 O(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new W(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 W(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 se(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 _};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 _};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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getGameById(t);return e.contestModel=i,this.predictorService.completeContestWinners(e)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new b(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new g(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var he=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new ht(t.errorHandlingMode),this.idMapping=new v(t),this.predictorHttps=new it(t,this.idMapping),this.predictorService=new et(t,this.idMapping),this.clientHttps=new x(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 V&&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 V&&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 O(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new tt(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 W(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 _};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 _};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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getGameById(t);return e.contestModel=i,this.predictorService.completeContestWinners(e)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new b(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new g(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 na=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 la=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;constructor(t,e,i,r,a){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new Q(a,r),this.loyaltyService=new aa(this.config),this.loyaltyValidator=new oa,this.idMapping=new v(t),this.topXFacade=new ue(t,this.idMapping),this.matchQuizFacade=new he(t),this.predictorHttps=new it(t,this.idMapping),this.errorHandlingMode=t.errorHandlingMode}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 na(t)),this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(t,e);let i=await this.loyaltyHttps.getTemplates(t,e);return i.data=await this.loyaltyService.remapTemplatesIds([...i.data]),i};getTemplateById=async(t,e)=>{let i=await this.loyaltyHttps.getTemplateById(t,e);return this.config.idSchema==="native"?i:(await this.loyaltyService.remapTemplatesIds([i]))[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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getTemplateById(t);return e.contestModel=i,this.loyaltyService.completeContestWinners(e)};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)}};var pa=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new x(t),this.profileHttps=new At(t),this.loyaltyHttps=new ea(t),this.localCache=new H().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new la(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=>await this.loyaltyFacade.getTemplateWinners(t);getEntitiesFollows=async(t,e)=>await this.loyaltyFacade.getEntitiesFollows(t,e)};var ca=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new v(t),this.topXFacade=new ue(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=>await this.topXFacade.getGameWinners(t)};var da=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new he(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=>await this.matchQuizFacade.getGameWinners(t)};var Ae=class{action=null;context=new qt;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var fe=class{idSchema;idMapping;constructor(t){this.idSchema=t.idSchema,this.idMapping=new v(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 ge=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var ma=class extends ge{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 ua=class extends ge{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 ha=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new Yt(t),this.activityService=new fe(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 Ae(t,p,i,r),l=await this.activityHttps.createActivity(n);return l.context.tags=s,l}let a=new Ae(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 ma(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 ua(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 fa=class{activityFacade;constructor(t){this.activityFacade=new ha(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 ye=class{id=null;title=null;description=null;images=new ut;participationCount=null;status=null;flags=null;createdAt=null;updatedAt=null};var ga=class extends ye{questions=[]};var ya=class{questionId=null;question=null;images=null;options=[]};var Ma=class{optionId=null;option=null;images=null};var ba=class{classicQuizId=null;userId=null;questions=[]};var wa=class{questionId=null;optionId=null;correct=null};var Ia=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 ga;return e.id=t.id,e.title=t.title,e.description=t.description,e.images=t.images,e.participationCount=t.participation_count,e.status=t.status,e.flags=t.flags,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 ba;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};remapClassicQuizParticipationBody=t=>t.map(e=>({question_id:e.questionId,option_id:e.optionId}));remapMetaPagination=t=>{let e=new St;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapBasicClassicQuiz=t=>{let e=new ye;return e.id=t.id,e.title=t.title,e.description=t.description,e.images=t.images,e.participationCount=t.participation_count,e.status=t.status,e.flags=t.flags,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapQuestions=t=>{let e=new ya;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 Ma;return e.optionId=t.option_id,e.option=t.option,e.images=t.images,e};remapParticipationQuestions=t=>{let e=new wa;return e.questionId=t.question_id,e.optionId=t.option_id,e.correct=t.correct,e}};var Pa=class extends R{remapper=null;constructor(t){super(t,S(t.environment,"miniGames")),this.remapper=new Ia}getClassicQuizzes=async(t,e)=>{let i=`/classic-quizzes${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=P(e)?I():"";let r="There was a problem with fetching classic quizzes",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapClassicQuizzes(a)};getClassicQuizById=async(t,e)=>{let i=`/classic-quizzes/${t}${this.apiSignInUrl}`;P(e)&&(i+=I());let r="There was a problem with fetching classic quiz by ID",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapClassicQuizById(a.data)};participateInClassicQuiz=async(t,e)=>{let i=`/classic-quizzes/${t}/participate${this.apiSignInUrl}`,r=`There was a problem with participating in the following classic quiz: ${t}`,a="POST",s={questions:this.remapper.remapClassicQuizParticipationBody(e)},p=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapClassicQuizParticipation(p.data)}};var Fa=class extends tt{flags=null;status=null;constructor(t){super(t),this.flags=t&&t.flags?t.flags:null,this.status=t&&t.status?t.status:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.flags&&(t+=`&flags=${this.flags.join(",")}`),this.status&&(t+=`&status=${this.status}`),t}};var Ta=class{https=null;constructor(t){this.https=new Pa(t)}getClassicQuizzes=async(t,e)=>(t&&(t=new Fa(t)),await this.https.getClassicQuizzes(t,e));getClassicQuizById=async(t,e)=>await this.https.getClassicQuizById(t,e);participateInClassicQuiz=async(t,e)=>await this.https.participateInClassicQuiz(t,e)};var _a=class{facade=null;constructor(t){this.facade=new Ta(t)}getClassicQuizzes=async(t,e)=>await this.facade.getClassicQuizzes(t,e);getClassicQuizById=async(t,e)=>await this.facade.getClassicQuizById(t,e);participateInClassicQuiz=async(t,e)=>await this.facade.participateInClassicQuiz(t,e)};var Ra=class{id="";label="";discussionType="LEAGUE";moderationType="USER";postsCount=0;pinnedPosts=[];lastPostId="";context=null;createdAt="";updatedAt=""};var ft=class{pagination={totalItems:0,nextPageStartsAfter:"",lastCommentCreateTimestamp:""}};var Me=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 va=class{meta=new ft;data=[]};var Ea=class{type="";userIds=[];reactionCount=0};var Sa=class{updatedAt="";content=""};var Ca=class{userId=null;reason="AD";reasonDetails=null};var Aa=class extends Me{userModel=null};var Oa=class{meta=new ft;data=[]};var xa=class{meta=new j;data=[]};var Da=class{remapToDiscussionById=t=>{let e=new Ra;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 va,r=new Oa;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 xa;return e.meta=this.remapToMeta(t.meta),e.data=t.data.map(i=>this.remapToPostByIdBasic(i)),e};remapToPostMeta=t=>{let e=new ft;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 j;return e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e};remapToPostByIdBasic=t=>{let e=new Me;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 Aa;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 Ea;return e.type=t.type,e.userIds=t.user_ids,e.reactionCount=t.reaction_count,e};remapVersionsPost=t=>{let e=new Sa;return e.content=t.content,e.updatedAt=t.updated_at,e};remapReportPost=t=>{let e=new Ca;return e.userId=t.user_id,e.reason=t.reason,e.reasonDetails=t.reason_details,e}};var La=class extends R{remapper=null;constructor(t){super(t,S(t.environment,"discussions")),this.remapper=new Da}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()}`),P(i)&&(r+=I());let a="There was a problem getting user's posts",s=await this.fetchWithoutAuth(r,a);return this.remapper.remapToPosts(s)}};var Ba=class{content="";reply_id="";context=null};var Na=class{createRequestBodyFromParam=t=>{let e=new Ba;return e.content=t.content,e.reply_id=t.replyId,e.context=t.context,e}};var _t=class extends tt{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 ka=class{profile=null;constructor(t){this.profile=new Y(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 Ha=class{idSchema=null;https=null;clientHttps=null;activityService=null;service=null;factory=null;constructor(t){this.idSchema=t.idSchema,this.https=new La(t),this.clientHttps=new x(t),this.activityService=new fe(t),this.service=new ka(t),this.factory=new Na}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 _t(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 _t(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 _t(t)),await this.https.getOwnPosts(t));getUserPosts=async(t,e,i)=>(e&&(e=new _t(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.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 Ua=class{facade=null;constructor(t){this.facade=new Ha(t)}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 to=null,go=null;function lP(o){if(bs(o)){let t=ws(o);if(t.isValid)return to={profile:new Y(o),football:new te(o),predictor:new Wr(o),loyalty:new pa(o),topX:new ca(o),matchQuiz:new da(o),activity:new fa(o),miniGames:new _a(o),discussions:new Ua(o)},go={...o},to;Is(t)}return to}var bs=o=>!to||JSON.stringify(o)!==JSON.stringify(go)||o.authProvider.getIdToken()!==go.authProvider.getIdToken(),ws=o=>{let e=new mr().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},Is=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 Ft).forEach(a=>{if(r[a].message.type==="error")throw new Error(r[a].message.text)})})};export{lP as FansUnitedSDK};
|
|
3
|
+
${so.PREDICTOR_USER_RELATED_OPERATION}`},Fo=(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`,ja=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`,To=o=>`The market '${o}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Ro=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`,vo=(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`,Eo=(o,t)=>`The field ${o} has incorrect type. The correct type is ${t}`;var Mt=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 g=class{error={code:0,status:"",message:""};constructor(t,e,i){this.error.code=t,this.error.status=e,this.error.message=i}};var R=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};transformFetchException=(t,e)=>{if(!e&&t.status===401){if(this.errorHandlingMode==="standard")return new g(401,"unauthorized","Invalid JWT token is provided");let s={code:401,status:"unauthorized",message:"Invalid JWT token is provided"};return new Mt(t,s)}let{code:i,status:r,message:a}=e.error;return this.errorHandlingMode==="standard"?new g(i,r,a):new Mt(t,e.error)};validateJWTToken=()=>{let t=null;try{t=Po(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 Mt(r,a)}else if(this.errorHandlingMode==="standard")throw new g(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 Mt(i,r)}else if(this.errorHandlingMode==="standard")throw new g(401,"invalid_token","The provided JWT token is expired")}}};var ps="/countries",L="/profile",Qa="/profiles",At=class extends R{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(t){super(t,S(t.environment,"profile")),this.lang=t.lang,this.profileRemapper=new Be,this.followingRemapper=new ke,this.followersRemapper=new Ue}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${ps}${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=`${L}${this.apiSignInUrl}`,i="";if(t){e=`${Qa}/${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=Et(t,this.limitIds);for(let m of d){let y=`${Qa}${this.apiSignInUrl}&profile_ids=${m.join(",")}`;a=`There was a problem fetching the following profiles: ${m.join(",")}`,i&&(y+=`&disable_cache=${r}`);let u=await this.fetchWithoutAuth(y,a);c.push(...this.profileRemapper.profilesFromResponse(u.data))}return c}let n=`${Qa}${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=`${Qa}${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=`${L}/followers${this.apiSignInUrl}`,r="There was a problem fetching the followers for own profile";if(t&&!e){i=`${L}/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=`${L}/${e}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${L}/${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=`${L}/following${this.apiSignInUrl}`,r="There was a problem fetching the followers of own profile";if(t&&!e){i=`${L}/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=`${L}/${e}/following${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${L}/${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 we;e.profile_ids=t;let i=L+`/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 we;e.profile_ids=t;let i=L+`/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=`${L}/badges${this.apiSignInUrl}`,i="There was a problem with fetching own badges";return t?(e=`${L}/${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=L+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 B=(a=>(a.NATIVE="native",a.ENETPULSE="enetpulse",a.SPORTRADAR="sportradar",a.SPORTAL_365="sportal365",a.API_FOOTBALL="api_football",a))(B||{});var Ge={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Ve=class extends R{constructor(t){super(t,S(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${Ge[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}&${Ge[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}&${Ge[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=ao(e),a=[];for(let s of r){let p=`/football${this.apiSignInUrl}&input_provider=${i}&${Ge[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=yt(i),p=ao(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+=`${Ge[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 So="FansUnited",po={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}}},$e=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t,(this.getData()===void 0||this.getData()===null)&&this.setData(po)}clearData=()=>{this.setData(po)};getEntityById=(t="",e="")=>this.getData().football.ids.find(i=>{let r=C[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=C[i];return r&&t.includes(`${r[a]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let a=C[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=C[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=C[i],a=C[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=()=>JSON.parse(localStorage.getItem(So));setData=t=>{localStorage.setItem(So,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(po)}};var Xo=ss(Qo());var M=class{profileTTL=600;clientTTL=14400;profileBadgesTTL=3600;idMappingsExpiration=0;idSchema="";constructor(t){}static getInstance(t){return M.instance||(M.instance=new M(t),M.nodeCache.options.useClones=!1),M.instance}clearData=()=>M.nodeCache.flushAll();getEntityById=(t,e)=>{let i=M.nodeCache.get("ids");return i?i.find(r=>{let a=C[this.idSchema];return r&&`${r[a]}`===e&&r.resource===t}):null};getEntity=(t,e,i)=>{let r=M.nodeCache.get("ids");return r?Array.isArray(t)?[]:null:Array.isArray(t)?r.filter(a=>{let s=C[i];return a&&t.includes(`${a[s]}`)&&a.resource===e}):r.find(a=>{let s=C[i];return a&&`${a[s]}`===t&&a.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=C[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=C[i],a=C[e],s=M.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=M.nodeCache.get("ids");e.push(t),M.nodeCache.set("ids",e)};addIdMappings=t=>{let e=M.nodeCache.get("ids");e=[...e,...t],M.nodeCache.set("ids",e)};addTopIdMappings=t=>{let e=M.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],M.nodeCache.set("ids",r)}else M.nodeCache.set("ids",t);this.idMappingsExpiration=Math.floor(Date.now()/1e3)+i};setOwnProfile=t=>M.nodeCache.set("profile",t,this.profileTTL);getOwnProfile=()=>M.nodeCache.get("profile");getProfileCountries=()=>M.nodeCache.get("profile_countries");setProfileCountries=t=>M.nodeCache.set("profile_countries",t);getProfileStats=()=>M.nodeCache.get("profile_stats");setProfileStats=t=>M.nodeCache.set("profile_stats",t,this.profileTTL);getProfileBadges=()=>M.nodeCache.get("profile_badges");setProfileBadges=t=>{M.nodeCache.set("profile_badges",t,this.profileBadgesTTL)};getFootballCountries=()=>M.nodeCache.get("football_countries");setFootballCountries=t=>M.nodeCache.set("football_countries",t);getCompetitions=t=>{let e=M.nodeCache.get("football_competitions");return e?t?t.competitionSearchFilter(e):e:null};setCompetitions=t=>M.nodeCache.set("football_competitions",t);getCompetitionsLength=()=>{let t=M.nodeCache.get("football_competitions");return t?t.length:0};getClientFeatures=()=>M.nodeCache.get("client");setClientFeatures=t=>M.nodeCache.set("client",t,this.clientTTL);deleteClientFeatures=()=>M.nodeCache.del("client");getExpiration=(t,e)=>{let i=this.getKeyFromExpirationType(e);return i==="ids"?this.idMappingsExpiration:M.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"}}},Ot=M;ro(Ot,"instance"),ro(Ot,"nodeCache",new Xo.default);var H=class{createLocalCacheInstance=t=>typeof window>"u"?Ot.getInstance(t):new $e(t)};var We=class{localCache=null;https=null;constructor(t){this.localCache=new H().createLocalCacheInstance(t.idSchema),this.https=new Ve(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 Ya=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 Ke=class{extractedObjIds={};traverse=(t,e)=>(e=Ya(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 je=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=Ya(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 v=class{idSchema="";idMappingFacade=null;constructor(t){this.idSchema=t.idSchema,this.idMappingFacade=new We(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 Ke().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new je().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 N=class{completed=!1;percentage;constructor(t){this.percentage=t}};var Qe=class{teamFollowed=new N(10);teamFavourite=new N(15);playerFollowed=new N(10);playerFavourite=new N(10);competitionFollowed=new N(10);competitionFavourite=new N(5);addedBirthdate=new N(10);addedGender=new N(10);addedCountry=new N(10);addedAvatar=new N(10)};var Xe=class{totalPercentage;breakdown=new Qe};var Pe=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 Q=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 g(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 Pe(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 Pe(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 Xe,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 qe=class{id=null;name=null;assets=null};var ze=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 b=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 Ye=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 ze,this.profileFacade=new Q(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 qe,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 b(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.errorHandlingMode==="standard")throw new g(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 Je=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 Q(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 Ze=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 ti=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=Wa(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 Fe=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 ei=class{reason="";words=[]};var Dt=class{enabled=!1;moderateLinks=!1;linksWhitelist=[];moderatorProfileId="";dictionary=new ei};var ii=class{enabled=!1;clientId=null;automaticModeration=new Dt};var ri=class{general=[];predictor=[];topX=[];matchQuiz=[]};var st=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var ai=class{id;label;assets={mainImageUrl:""};enabled;requirements=new st};var xt=class extends st{postPoints=null;postsCount=null;reactionsCount=null;totalDiscussionPoints=null};var oi=class{id;label;assets={mainImageUrl:""};enabled;requirements=new xt};var si=class{id;weight;multiplier;conditions};var ni=class{value=[new si]};var Lt=class{points=null;tiers=null;badges=null};var li=class{enabled=!1;clientId=null;conditions={list:null};actions=new ni;rewards=new Lt};var pi=class{general=null;predictor=null;activity=null;topX=null;matchQuiz=null;discussionPost=null};var Bt=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var Nt=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var ci=class{competitions=[];teams=[];markets=[]};var kt=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new ci;userDataConfig=null};var di=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var mi=class{remapPredictorConfig=t=>{let e=new kt;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 Nt;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 Bt;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 li;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 ii;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 Dt;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 Lt;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new pi;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 ri;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 ai;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 st;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 di;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 oi;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 xt;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 D=class extends R{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(t){super(t,S(t.environment,"client")),this.clientId=t.clientId,this.localStorage=new H().createLocalCacheInstance(t.idSchema),this.featureConfigRemapper=new mi}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 nt=class{clientHttps=null;constructor(t){this.clientHttps=new D(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 hi=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new nt(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new Fe(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 Fe({teamIds:t,limit:i}),{data:a}=await this.getTeams(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=Wa(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 Te=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 lt=class{https=null;footballService=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new nt(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new Te(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 Te({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=yt(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 Ht=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 pt=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new nt(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new Ht(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 Ht({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=yt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let a=new Ht({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 fi=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 gi=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new fi(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 Ut=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new Ze(e,i,r),this.competitionsFacade=new ti(e,i,r),this.teamsFacade=new hi(t,i,r),this.playerFacade=new lt(t,i,r),this.matchFacade=new pt(t,i,r),this.searchFacade=new gi(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 yi=class{id="";alias="";countryCode="";assets=null;name=""};var E=class{countriesFromResponse=t=>{if(t)return t.map(e=>this.countryFromResponse(e))};countryFromResponse=t=>{try{if(t){let e=new yi;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 Mi=class{id="";country=null;gender="";assets=null;type="";name=""};var x=class{countryRemapper=null;constructor(){this.countryRemapper=new E}fromResponse(t){try{let e=new Mi;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 bi=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var wi=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName="";isDeleted=!1};var A=class{countryRemapper=null;constructor(){this.countryRemapper=new E}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}catch(e){throw console.warn("There was a problem remapping teams response",e),e}}};var Ii=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new E,this.teamBasicRemapper=new A}fromResponse(t){try{let e=new bi;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 Pi=class{primary=null;secondary=null;tertiary=null};var _i=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new Pi;squad=[]};var Fi=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var Ti=class{countryRemapper=null;constructor(){this.countryRemapper=new E}fromResponse(t){try{let e=new Fi;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 Ri=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new E,this.competitionRemapper=new x,this.playerRemapper=new Ti}fromResponse(t){try{let e=new _i;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 vi=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 Ei=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Gt=class{fromResponse(t){try{let e=new Ei;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 Si=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new A,this.competitionRemapper=new x,this.scoresRemapper=new Gt}fromResponse(t){try{let e=new vi;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 U=class{type=null;subType=null};var Ci=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 U;lineups=null};var Ai=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 Oi=class{fromResponse(t){try{let e=new Ai;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 Vt=class{homeTeam={players:[]};awayTeam={players:[]}};var Di=class{id="";name="";position="";shirtNumber;assets=null;type=""};var $t=class{fromResponse(t){try{let e=new Di;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 xi=class{playerRemapper=null;constructor(){this.playerRemapper=new $t}fromResponse(t){try{let e=new Vt;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 Li=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Bi=class{playerRemapper=null;constructor(){this.playerRemapper=new $t}fromResponse(t){try{let e=new Li;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 Ni=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new A,this.competitionsMapper=new x,this.lineupsMapper=new xi,this.scoresMapper=new Gt,this.statsMapper=new Oi,this.timelineMapper=new Bi}fromResponse(t){try{let e=new Ci;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 Vt,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var ki=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Hi=class{countryRemapper=null;constructor(){this.countryRemapper=new E}fromResponse(t){try{let e=new ki;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 Ui=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var Wt=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new E,this.teamRemapper=new A}fromResponse(t){try{let e=new Ui;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 Gi=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Vi=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new E,this.teamRemapper=new A,this.competitionRemapper=new x}fromResponse(t){try{let e=new Gi;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 $i=class{teams=null;players=null;competitions=null};var Wi=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new A,this.playerRemapper=new Wt,this.competitionremapper=new x}fromResponse(t){try{let e=new $i;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 ct=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var X=class{pagination=new ct};var Kt=class{meta=new X;data=[]};var Ki=class{remapMetaProp=t=>{let e=new X;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 q=class extends R{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,S(t.environment,"football")),this.apiSignInUrl=t.lang!=="en"?this.apiSignInUrl+`&lang=${t.lang}`:this.apiSignInUrl,this.countryRemapper=new E,this.competitionBasicRemapper=new x,this.competitionFullRemapper=new Ii,this.teamBasicRemapper=new A,this.teamFullRemapper=new Ri,this.matchBasicRemapper=new Si,this.matchFullRemapper=new Ni,this.playerBasicRemapper=new Wt,this.playerFullRemapper=new Vi,this.topPlayerRemapper=new Hi,this.searchRemapper=new Wi,this.footballMetaRemapper=new Ki}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=Et(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=Et(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 Kt,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=Et(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 Kt,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 Kt,r="There was a problem with football matches request";if(t&&t.matchIds&&t.matchIds.length>this.limitIds-1){let a=[],s=Et(t.matchIds,this.limitIds);for(let n of s){t.matchIds=n;let l=`/matches${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=I());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+=I());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 G=(h=>(h.FT_1X2="FT_1X2",h.HT_1X2="HT_1X2",h.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",h.DOUBLE_CHANCE="DOUBLE_CHANCE",h.HT_FT="HT_FT",h.PLAYER_SCORE="PLAYER_SCORE",h.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",h.PLAYER_RED_CARD="PLAYER_RED_CARD",h.RED_CARD_MATCH="RED_CARD_MATCH",h.PENALTY_MATCH="PENALTY_MATCH",h.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",h.CORNERS_MATCH="CORNERS_MATCH",h.CORRECT_SCORE="CORRECT_SCORE",h.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",h.CORRECT_SCORE_HT="CORRECT_SCORE_HT",h.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",h.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",h.OVER_GOALS_0_5="OVER_GOALS_0_5",h.OVER_GOALS_1_5="OVER_GOALS_1_5",h.OVER_GOALS_2_5="OVER_GOALS_2_5",h.OVER_GOALS_3_5="OVER_GOALS_3_5",h.OVER_GOALS_4_5="OVER_GOALS_4_5",h.OVER_GOALS_5_5="OVER_GOALS_5_5",h.OVER_GOALS_6_5="OVER_GOALS_6_5",h.OVER_CORNERS_6_5="OVER_CORNERS_6_5",h.OVER_CORNERS_7_5="OVER_CORNERS_7_5",h.OVER_CORNERS_8_5="OVER_CORNERS_8_5",h.OVER_CORNERS_9_5="OVER_CORNERS_9_5",h.OVER_CORNERS_10_5="OVER_CORNERS_10_5",h.OVER_CORNERS_11_5="OVER_CORNERS_11_5",h.OVER_CORNERS_12_5="OVER_CORNERS_12_5",h.OVER_CORNERS_13_5="OVER_CORNERS_13_5",h))(G||{}),qo=["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"],zo=["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"],z=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Yo=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],Re="PLAYER_SCORE_FIRST_GOAL";var ji=class{id="";achievedAt=""};var jt=class{totalPoints=null;postPoints=null;postsMade=null;reactionPoints=null;reactionCount=null};var ve=class{participations=0;points=0};var It=class{footballCompetitions=[];footballTeams=[]};var Qt=class{predictionsMade=0;correct=0;points=0;breakdown=new It};var Xt=class{single=new Qt;topX=new ve;matchQuiz=new ve};var Qi=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var Xi=class{profileId;tier;points;predictionsMade;successRates=new Qi;predictions=new Xt;tiers=[];badges=[];discussions=new jt};var qi=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var zi=class{successRatePercent;model=null};var qt=class{content=null;tags=[];campaign=null};var zt=class{id=null;profileId=null;property=null;value=null;action=null;context=new qt;points=0};var Yi=class{meta=new X;data=[new zt]};var Ji=class{remapSingleResponse=t=>{let e=new zt;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 Yi;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 Xi;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)},G[i]&&delete e[i].model});else return t;return e};remapSuccessRatePercent=t=>{let e=new zi;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new Xt;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new Qt;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 It,i=[],r=[];return Object.keys(t).forEach(a=>{let s=new qi;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 It};remapAchievementsStats=t=>t.map(e=>{let i=new ji;return i.id=e.id,i.achievedAt=e.achieved_at,i});remapDiscussionStats=t=>{let e=new jt;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 Yt=class extends R{activityRemapper=null;constructor(t){super(t,S(t.environment,"loyalty")),this.activityRemapper=new Ji}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+=P(e)?`/users/${t}/statistics${this.apiSignInUrl}${I()}`:`/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 Zi=class{id="";source="";type="";favourite=!1};var tr=class extends Zi{model=null};var er=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 tr;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 ir=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new v(t),this.profileOperations=new er(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 Y=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 At(t),this.activityHttps=new Yt(t),this.footballHttps=new q(t),this.idMapping=new v(t),this.localCache=new H().createLocalCacheInstance(t.idSchema),this.footballFacade=new Ut(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new Q(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new ir(t,this.footballFacade),this.ownProfileBuilder=new Ye(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps,t.errorHandlingMode),this.profileBuilder=new Je(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 Ja=(u=>(u.EN="en",u.BG="bg",u.RO="ro",u.EL="el",u.SK="sk",u.PT="pt",u.SR="sr",u.HU="hu",u.SV="sv",u.ES="es",u.FR="fr",u.NL="nl",u.DE="de",u.IT="it",u))(Ja||{});var rr=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(Ja),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 ar=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 or=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 sr=class{validate(t){let e=this.validateField(t.idSchema),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=Object.values(B),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 _t=class{getIdToken=null;logout=null};var Zt=class{text=null;type=null};var nr=class{validation=null;message=new Zt;getIdToken={validation:null,message:new Zt};logout={validation:null,message:new Zt}};var lr=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 _t),i=new nr;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 _t).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 Se=class{validation;message};var pr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Se,logout:new Se};isValid=!1};var cr=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 dr=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 mr=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new pr,i={apiKey:new or,environment:new ar,idSchema:new sr,clientId:new cr,lang:new rr,errorHandlingMode:new dr,authProvider:new lr};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 te=class{https=null;idMapping=null;localCache=null;footballFacade=null;constructor(t){this.https=new q(t),this.idMapping=new v(t),this.localCache=new H().createLocalCacheInstance(t.idSchema),this.footballFacade=new Ut(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 ur=class{value=null;playerId=null;playerModel=null};var ee=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new ur;result=null};var hr=class{value=!1;playerId=null};var V=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i,r){this.matchId=t,this.market=e,this.prediction=new hr,this.prediction.value=i,this.prediction.playerId=r}};var ie=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var fr=class{value=null};var dt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new fr,this.prediction.value=i}};var $=class{value=!1};var re=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new $,this.prediction.value=i}};var ae=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new $,this.prediction.value=i}};var gr=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 V)e.market=t.market,e.prediction=t.prediction.value,e.player_id=t.prediction.playerId;else if(t instanceof re||t instanceof ae)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof dt){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 ee;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 ie;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 J=class{goldenGoal=null};var Ce=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new J;points=null;createdAt=null;updatedAt=null};var _=class{no=0;yes=0};var yr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new _;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new _;penaltyMatch=new _;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new _;overOnePointFiveGoals=new _;overTwoPointFiveGoals=new _;overThreePointFiveGoals=new _;overFourPointFiveGoals=new _;overFivePointFiveGoals=new _;overSixPointFiveGoals=new _;overSixPointFiveCorners=new _;overSevenPointFiveCorners=new _;overEightPointFiveCorners=new _;overNinePointFiveCorners=new _;overTenPointFiveCorners=new _;overElevenPointFiveCorners=new _;overTwelvePointFiveCorners=new _;overThirteenPointFiveCorners=new _};var Z=class{timeTiebreaker=!1};var mt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Z;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 J};var Ft=class{userId=null;points=null;results=[];tiebreaker=null};var Za=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(Za||{}),mo=["WON","LOST","PARTIALLY_WON","CANCELED"];var O=class{limit=null;startAfter=null;status=null;type=null;matchIds=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}constructFiltersUrl=()=>{let t="",e=!1;return this.status&&(e=Object.values(Za).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(",")}`),t}};var tt=class{limit;startAfter;constructor(t){this.limit=t.limit?t.limit:null,this.startAfter=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 Mr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(Mr||{});var W=class extends tt{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(Mr).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 ut=class{main=null;cover=null;mobile=null};var rt=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Z;participantsCount=0;related=null;excludedProfileIds=null;rules=null;labels=null;customFields=null;flags=null;images=new ut;createdAt=null;updatedAt=null};var at=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Z;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 oe=class extends rt{adContent=null};var et=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(t,e){this.footballHttps=new q(t),this.idMapping=e,this.matchFacade=new pt(t,this.footballHttps,e),this.playerFacade=new lt(t,this.footballHttps,e),this.profileNamespace=new Y(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=yt(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=_o.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(z.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 _,a[r][p]):a[r][i]}else if(z.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 kt){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 Nt||t instanceof Bt){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 rt||r instanceof mt||r instanceof at||r instanceof oe?(r.fixtures.forEach(a=>e.push(a.matchId)),r instanceof at&&r.fixtures.forEach(a=>{a.prediction.playerId&&a.prediction.playerId!=="OWN_GOAL"&&i.push(a.prediction.playerId)})):r instanceof Ft&&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 rt||p instanceof mt||p instanceof at?(p.fixtures.forEach(n=>{this.handleMatchModel(a,n),p instanceof at&&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 Ft&&(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 O(i),i};initGameFilters=(t,e,i)=>{if(e&&i)return e.type=t,e.gameIds=i,e=new W(e),e;if(e&&!i)return e.type=t,e=new W(e),e;if(!e&&i){let r={type:t,gameIds:i};return r=new W(r),r}else{let r={type:t};return r=new W(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 mt&&(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 ie;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 O(t));break;case"current":if(t)this.deleteUnexpectedProperties(t),t.status=["ACTIVE"],t=new O(t);else{let r={status:["ACTIVE"]};t=new O(r)}break;case"past":if(t)this.deleteUnexpectedProperties(t),t.status=mo,t=new O(t);else{let r={status:mo};t=new O(r)}break;case"matches":if(t)this.deleteUnexpectedProperties(t),t.matchIds=i,t=new O(t);else{let r={matchIds:i};t=new O(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=>z.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[C[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[C[this.idMapping.idSchema]]})};deleteUnexpectedProperties=t=>(t.status&&(console.warn(lo.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(lo.UNEXPECTED_TYPE_PROP),delete t.type),t)};var se=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new dt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var ne=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new q(t),this.matchFacade=new pt(t,this.footballHttps,e),this.playerFacade=new lt(t,this.footballHttps,e),this.predictorService=new et(t,e),this.fixturesRemapper=new gr(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 se&&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 Ce,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 ee;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 Ce;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 yr;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 br=class{matchId=null;matchType=null;predictions=null};var wr=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new ne(t,e)}remapResponse=t=>{let e=new br;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var Ir=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U};var Pr=class{value=null;target=null;playerId=null;playerModel=null;result=null};var _r=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new Pr};var Fr=class{value=null;result=null};var Tr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new Fr};var Rr=class{matchId=null;matchModel=null;outcome=null};var vr=class{gameId=null;results=null;tieBreakers=null};var le=class{entityId=null;entityType=null};var Er=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var Sr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Cr=class{remapPaginatedGames=t=>{let e=new T;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 rt;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 oe;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 Ir;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 T;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 mt;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 Tr;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 T;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 at;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 _r;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 T;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 Ft;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 vr;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 Er;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 Sr;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 U;return t&&(e.type=t.type,e.subType=t.sub_type),e};remapMarketResult=(t,e)=>{if(Yo.includes(t))return e[0];if(z.includes(t))return e;if(e[0]==="true")return!0;if(e[0]==="false")return!1};deleteUnusefulField=t=>((!z.includes(t.market)||this.isPlayerMarketWithNoResult(t.market,t.result))&&delete t.playerModels,t);isPlayerMarketWithNoResult=(t,e)=>z.includes(t)&&e.length===0;remapResults=t=>{let e=new Rr;return e.matchId=t.match_id,e.outcome=t.outcome,e};remapTiebreaker=t=>{let e=new J;return e.goldenGoal=t.golden_goal,e};remapTimeTiebreaker=t=>{let e=new Z;return e.timeTiebreaker=t,e};remapRelated=t=>t.map(e=>{let i=new le;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Ar=class{remapMetaData=t=>{let e=new j;return e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.itemsPerPage=t.pagination.items_per_page,e}};var it=class extends R{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(t,e){super(t,S(t.environment,"predictor")),this.predictionRemapper=new ne(t,e),this.matchSummaryRemapper=new wr(t,e),this.gamesRemapper=new Cr,this.metaRemapper=new Ar}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=P(e)?`/predictions/summary/${t}${this.apiSignInUrl}${I()}`:`/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 T,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 T,a=P(e)?`/predictions/users/${t}${this.apiSignInUrl}${I()}`:`/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=P(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${I()}`:`/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=P(e)?`/games/${t}${this.apiSignInUrl}${I()}`:`/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 T,a=P(e)?`/games/${t}/predictions${this.apiSignInUrl}${I()}`:`/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=P(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${I()}`:`/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=P(e)?`/games/${t}/results/${this.apiSignInUrl}${I()}`:`/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}`;P(e)&&(i+=`${I()}`);let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(a.data)};getContestWinners=async t=>{let e=`/winners/${this.apiSignInUrl}&contest_id=${t}`,i=`There was a problem fetching winners for the following game: ${t}`,r=await this.fetchWithoutAuth(e,i);return this.gamesRemapper.remapContestWinners(r)};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]}};var pe=class{gameInstanceId=null;fixtures=null};var uo=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(uo||{}),ho=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(ho||{}),fo=(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))(fo||{});var Or=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Dr=class{value};var xr=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Dr,this.prediction.value=e}};var Lr=class{value=null};var Br=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Lr,this.prediction.value=e}};var Nr=class{value=null};var kr=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new Nr,this.prediction.value=i}};var Hr=class{value=null};var Ur=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Hr,this.prediction.value=e}};var Gr=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Vr=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var ht=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new pe);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(uo),s=Object.values(fo),p=Object.values(ho);if(e==="FT_1X2"||e==="HT_1X2"){if(a.includes(i))return new kr(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new Ur(t,i)}else if(e==="DOUBLE_CHANCE"){if(p.includes(i))return new Br(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 dt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new xr(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new Or(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new Vr(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new Gr(t,i)}else if(z.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===Re&&this.isPredictionBoolean(i)){let l=r&&r===n?n:r;return new V(t,e,i,l)}if(r&&this.isPredictionBoolean(i))return new V(t,e,i,r)}else if(qo.includes(e)){if(this.isPredictionBoolean(i))return new ae(t,e,i)}else if(zo.includes(e)&&this.isPredictionBoolean(i))return new re(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{no.includes(r)||this.throwInvalidParamException([r])});let i=no.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 J)[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){z.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!==Re&&(e||this.throwInvalidParamException([i]),typeof e!="string"&&this.throwInvalidType(i,"string"))};validateMarket=t=>{Object.values(G).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=Fo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_PREDICTION",i):new g(400,"INVALID_TYPE",i)};throwInvalidMarketException=(t,e)=>{let i=null;throw e&&e==="TOP_X"?i=To(t):i=ja(t),this.errorHandlingMode==="default"?new b(400,"INVALID_MARKET",i):new g(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Ro(t);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",e):new g(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=vo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",i):new g(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=Eo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_TYPE",i):new g(400,"INVALID_TYPE",i)}};var $r=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 ht(t.errorHandlingMode),this.predictorService=new et(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let a=this.predictorValidator.validateFixture(t,e,i,r),s=new pe;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 b(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!a.matchId)throw new g(400,"INVALID_FIELD","Match id is invalid!");if(a instanceof V&&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!==Re&&!a.prediction.playerId)throw new b(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&a.market!==Re&&!a.prediction.playerId)throw new g(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 b(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new g(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 b(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new g(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)};var Wr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(t){this.idMapping=new v(t),this.predictorHttps=new it(t,this.idMapping),this.clientHttps=new D(t),this.predictorFacade=new $r(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)};var Kr=class{rankType=null;fromDate=null;toDate=null;pagination=new ct};var ce=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var jr=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new Kr;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 ce;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var Qr=class extends ce{id=null;rankType=null;model=null;gameType=null};var Xr=class{remapRankings=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new X;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 Qr;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}};var qr=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var zr=class{pagination=new ct;filters=new qr};var de=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;labels=null;customFields=null;flags=null;images=new ut;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var Yr=class extends de{adContent=null};var Jr=class{remapResponse=t=>{let e=[];return t.forEach(i=>{let r=new de;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.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 Yr;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.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 zr;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 le;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Zr=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var ta=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Zr;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 ea=class extends R{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,S(t.environment,"loyalty")),this.templateRemapper=new Jr,this.leaderboardRemapper=new jr,this.rankingsRemapper=new Xr,this.highestSuccessRateRemapper=new ta}getTemplates=async(t,e)=>{let i=t?`/leaderboard/templates/${this.apiSignInUrl}${t.constructFiltersUrl()}`:`/leaderboard/templates/${this.apiSignInUrl}`;i+=P(e)?I():"";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=P(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${I()}`:`/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=P(e)?`/leaderboard/${t}/${this.apiSignInUrl}${I()}`:`/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=P(e)?`/leaderboard/games/${t}/${this.apiSignInUrl}${I()}`:`/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()}`),P(i)&&(r+=`${I()}`);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()}`),P(e)&&(i+=`${I()}`);let a=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(a.data)};getEntitiesFollows=async(t,e)=>{let i=P(e)?`/statistics/follows${this.apiSignInUrl}${I()}`:`/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}};var ia=class{general;predictor;topX;matchQuiz};var me=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 ra=class extends me{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 aa=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new v(t),this.profileNamespace=new Y(t),this.footballNamespace=new te(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};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 ia;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 me(t));break;case"rankings":t&&(t=new ra(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 b(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new g(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 b(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new g(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 oa=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(G).includes(t)){let r=ja(t);throw e==="default"?new b(400,"INVALID_MARKET",r):new g(400,"INVALID_MARKET",r)}};validateDate=(t,e,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof t!="string")throw i==="default"?new b(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`):new g(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`);if(!r.test(t))throw i==="default"?new b(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`):new g(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 b(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`):new g(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 b(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`):new g(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`)}};var ue=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 ht(t.errorHandlingMode),this.predictorHttps=new it(t,e),this.predictorService=new et(t,e),this.clientHttps=new D(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 O(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new W(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 W(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 se(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 T};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 T};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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getGameById(t);return e.contestModel=i,this.predictorService.completeContestWinners(e)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new b(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new g(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var he=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new ht(t.errorHandlingMode),this.idMapping=new v(t),this.predictorHttps=new it(t,this.idMapping),this.predictorService=new et(t,this.idMapping),this.clientHttps=new D(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 V&&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 V&&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 O(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new tt(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 W(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 T};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 T};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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getGameById(t);return e.contestModel=i,this.predictorService.completeContestWinners(e)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new b(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new g(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 na=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 la=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;constructor(t,e,i,r,a){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new Q(a,r),this.loyaltyService=new aa(this.config),this.loyaltyValidator=new oa,this.idMapping=new v(t),this.topXFacade=new ue(t,this.idMapping),this.matchQuizFacade=new he(t),this.predictorHttps=new it(t,this.idMapping),this.errorHandlingMode=t.errorHandlingMode}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 na(t)),this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(t,e);let i=await this.loyaltyHttps.getTemplates(t,e);return i.data=await this.loyaltyService.remapTemplatesIds([...i.data]),i};getTemplateById=async(t,e)=>{let i=await this.loyaltyHttps.getTemplateById(t,e);return this.config.idSchema==="native"?i:(await this.loyaltyService.remapTemplatesIds([i]))[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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getTemplateById(t);return e.contestModel=i,this.loyaltyService.completeContestWinners(e)};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)}};var pa=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new D(t),this.profileHttps=new At(t),this.loyaltyHttps=new ea(t),this.localCache=new H().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new la(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=>await this.loyaltyFacade.getTemplateWinners(t);getEntitiesFollows=async(t,e)=>await this.loyaltyFacade.getEntitiesFollows(t,e)};var ca=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new v(t),this.topXFacade=new ue(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=>await this.topXFacade.getGameWinners(t)};var da=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new he(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=>await this.matchQuizFacade.getGameWinners(t)};var Ae=class{action=null;context=new qt;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var fe=class{idSchema;idMapping;constructor(t){this.idSchema=t.idSchema,this.idMapping=new v(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 ge=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var ma=class extends ge{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 ua=class extends ge{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 ha=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new Yt(t),this.activityService=new fe(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 Ae(t,p,i,r),l=await this.activityHttps.createActivity(n);return l.context.tags=s,l}let a=new Ae(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 ma(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 ua(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 fa=class{activityFacade;constructor(t){this.activityFacade=new ha(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 ye=class{id=null;title=null;description=null;images=new ut;participationCount=null;status=null;flags=null;createdAt=null;updatedAt=null};var ga=class extends ye{questions=[]};var ya=class{questionId=null;question=null;images=null;options=[]};var Ma=class{optionId=null;option=null;images=null};var ba=class{classicQuizId=null;userId=null;questions=[]};var wa=class{questionId=null;optionId=null;correct=null};var Ia=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 ga;return e.id=t.id,e.title=t.title,e.description=t.description,e.images=t.images,e.participationCount=t.participation_count,e.status=t.status,e.flags=t.flags,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 ba;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};remapClassicQuizParticipationBody=t=>t.map(e=>({question_id:e.questionId,option_id:e.optionId}));remapMetaPagination=t=>{let e=new St;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapBasicClassicQuiz=t=>{let e=new ye;return e.id=t.id,e.title=t.title,e.description=t.description,e.images=t.images,e.participationCount=t.participation_count,e.status=t.status,e.flags=t.flags,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapQuestions=t=>{let e=new ya;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 Ma;return e.optionId=t.option_id,e.option=t.option,e.images=t.images,e};remapParticipationQuestions=t=>{let e=new wa;return e.questionId=t.question_id,e.optionId=t.option_id,e.correct=t.correct,e}};var Pa=class extends R{remapper=null;constructor(t){super(t,S(t.environment,"miniGames")),this.remapper=new Ia}getClassicQuizzes=async(t,e)=>{let i=`/classic-quizzes${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=P(e)?I():"";let r="There was a problem with fetching classic quizzes",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapClassicQuizzes(a)};getClassicQuizById=async(t,e)=>{let i=`/classic-quizzes/${t}${this.apiSignInUrl}`;P(e)&&(i+=I());let r="There was a problem with fetching classic quiz by ID",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapClassicQuizById(a.data)};participateInClassicQuiz=async(t,e)=>{let i=`/classic-quizzes/${t}/participate${this.apiSignInUrl}`,r=`There was a problem with participating in the following classic quiz: ${t}`,a="POST",s={questions:this.remapper.remapClassicQuizParticipationBody(e)},p=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapClassicQuizParticipation(p.data)}};var _a=class extends tt{flags=null;status=null;constructor(t){super(t),this.flags=t&&t.flags?t.flags:null,this.status=t&&t.status?t.status:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.flags&&(t+=`&flags=${this.flags.join(",")}`),this.status&&(t+=`&status=${this.status}`),t}};var Fa=class{https=null;constructor(t){this.https=new Pa(t)}getClassicQuizzes=async(t,e)=>(t&&(t=new _a(t)),await this.https.getClassicQuizzes(t,e));getClassicQuizById=async(t,e)=>await this.https.getClassicQuizById(t,e);participateInClassicQuiz=async(t,e)=>await this.https.participateInClassicQuiz(t,e)};var Ta=class{facade=null;constructor(t){this.facade=new Fa(t)}getClassicQuizzes=async(t,e)=>await this.facade.getClassicQuizzes(t,e);getClassicQuizById=async(t,e)=>await this.facade.getClassicQuizById(t,e);participateInClassicQuiz=async(t,e)=>await this.facade.participateInClassicQuiz(t,e)};var Ra=class{id="";label="";discussionType="LEAGUE";moderationType="USER";postsCount=0;pinnedPosts=[];lastPostId="";context=null;createdAt="";updatedAt=""};var ft=class{pagination={totalItems:0,nextPageStartsAfter:"",lastCommentCreateTimestamp:""}};var Me=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 va=class{meta=new ft;data=[]};var Ea=class{type="";userIds=[];reactionCount=0};var Sa=class{updatedAt="";content=""};var Ca=class{userId=null;reason="AD";reasonDetails=null};var Aa=class extends Me{userModel=null};var Oa=class{meta=new ft;data=[]};var Da=class{meta=new j;data=[]};var xa=class{remapToDiscussionById=t=>{let e=new Ra;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 va,r=new Oa;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 Da;return e.meta=this.remapToMeta(t.meta),e.data=t.data.map(i=>this.remapToPostByIdBasic(i)),e};remapToPostMeta=t=>{let e=new ft;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 j;return e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e};remapToPostByIdBasic=t=>{let e=new Me;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 Aa;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 Ea;return e.type=t.type,e.userIds=t.user_ids,e.reactionCount=t.reaction_count,e};remapVersionsPost=t=>{let e=new Sa;return e.content=t.content,e.updatedAt=t.updated_at,e};remapReportPost=t=>{let e=new Ca;return e.userId=t.user_id,e.reason=t.reason,e.reasonDetails=t.reason_details,e}};var La=class extends R{remapper=null;constructor(t){super(t,S(t.environment,"discussions")),this.remapper=new xa}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()}`),P(i)&&(r+=I());let a="There was a problem getting user's posts",s=await this.fetchWithoutAuth(r,a);return this.remapper.remapToPosts(s)}};var Ba=class{content="";reply_id="";context=null};var Na=class{createRequestBodyFromParam=t=>{let e=new Ba;return e.content=t.content,e.reply_id=t.replyId,e.context=t.context,e}};var Tt=class extends tt{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 ka=class{profile=null;constructor(t){this.profile=new Y(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 Ha=class{idSchema=null;https=null;clientHttps=null;activityService=null;service=null;factory=null;constructor(t){this.idSchema=t.idSchema,this.https=new La(t),this.clientHttps=new D(t),this.activityService=new fe(t),this.service=new ka(t),this.factory=new Na}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 Tt(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 Tt(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 Tt(t)),await this.https.getOwnPosts(t));getUserPosts=async(t,e,i)=>(e&&(e=new Tt(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.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 Ua=class{facade=null;constructor(t){this.facade=new Ha(t)}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 to=null,go=null;function lP(o){if(bs(o)){let t=ws(o);if(t.isValid)return to={profile:new Y(o),football:new te(o),predictor:new Wr(o),loyalty:new pa(o),topX:new ca(o),matchQuiz:new da(o),activity:new fa(o),miniGames:new Ta(o),discussions:new Ua(o)},go={...o},to;Is(t)}return to}var bs=o=>!to||JSON.stringify(o)!==JSON.stringify(go)||o.authProvider.getIdToken()!==go.authProvider.getIdToken(),ws=o=>{let e=new mr().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},Is=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 _t).forEach(a=>{if(r[a].message.type==="error")throw new Error(r[a].message.text)})})};export{lP as FansUnitedSDK};
|
|
4
4
|
//# sourceMappingURL=index.js.map
|