fansunited-sdk-esm 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.js.map +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
20
20
|
}`;var U=cm(function(){return V(m,C+"return "+F).apply(s,f)});if(U.source=F,Xl(U))throw U;return U}function Hw(i){return W(i).toLowerCase()}function Gw(i){return W(i).toUpperCase()}function kw(i,r,a){if(i=W(i),i&&(a||r===s))return bc(i);if(!i||!(r=He(r)))return i;var l=ot(i),c=ot(r),m=wc(l,c),f=vc(l,c)+1;return Wt(l,m,f).join("")}function $w(i,r,a){if(i=W(i),i&&(a||r===s))return i.slice(0,Ic(i)+1);if(!i||!(r=He(r)))return i;var l=ot(i),c=vc(l,ot(r))+1;return Wt(l,0,c).join("")}function Vw(i,r,a){if(i=W(i),i&&(a||r===s))return i.replace(Xs,"");if(!i||!(r=He(r)))return i;var l=ot(i),c=wc(l,ot(r));return Wt(l,c).join("")}function qw(i,r){var a=Nd,l=Dd;if(Z(r)){var c="separator"in r?r.separator:c;a="length"in r?D(r.length):a,l="omission"in r?He(r.omission):l}i=W(i);var m=i.length;if(_i(i)){var f=ot(i);m=f.length}if(a>=m)return i;var h=a-Ii(l);if(h<1)return l;var b=f?Wt(f,0,h).join(""):i.slice(0,h);if(c===s)return b+l;if(f&&(h+=b.length-h),Yl(c)){if(i.slice(h).search(c)){var P,R=b;for(c.global||(c=cl(c.source,W(kp.exec(c))+"g")),c.lastIndex=0;P=c.exec(R);)var F=P.index;b=b.slice(0,F===s?h:F)}}else if(i.indexOf(He(c),h)!=h){var T=b.lastIndexOf(c);T>-1&&(b=b.slice(0,T))}return b+l}function Ww(i){return i=W(i),i&&tf.test(i)?i.replace(Up,wh):i}var Kw=Ei(function(i,r,a){return i+(a?" ":"")+r.toUpperCase()}),Jl=uu("toUpperCase");function pm(i,r,a){return i=W(i),r=a?s:r,r===s?hh(i)?Ih(i):oh(i):i.match(r)||[]}var cm=H(function(i,r){try{return De(i,s,r)}catch(a){return Xl(a)?a:new B(a)}}),Xw=Et(function(i,r){return Xe(r,function(a){a=ht(a),St(i,a,Wl(i[a],i))}),i});function Yw(i){var r=i==null?0:i.length,a=x();return i=r?J(i,function(l){if(typeof l[1]!="function")throw new Ye(o);return[a(l[0]),l[1]]}):[],H(function(l){for(var c=-1;++c<r;){var m=i[c];if(De(m[0],this,l))return De(m[1],this,l)}})}function Qw(i){return wg(ze(i,v))}function Zl(i){return function(){return i}}function zw(i,r){return i==null||i!==i?r:i}var Jw=du(),Zw=du(!0);function Ae(i){return i}function jl(i){return Vc(typeof i=="function"?i:ze(i,v))}function jw(i){return Wc(ze(i,v))}function ev(i,r){return Kc(i,ze(r,v))}var tv=H(function(i,r){return function(a){return Or(a,i,r)}}),iv=H(function(i,r){return function(a){return Or(i,a,r)}});function ep(i,r,a){var l=ce(r),c=Bn(r,l);a==null&&!(Z(r)&&(c.length||!l.length))&&(a=r,r=i,i=this,c=Bn(r,ce(r)));var m=!(Z(a)&&"chain"in a)||!!a.chain,f=xt(i);return Xe(c,function(h){var b=r[h];i[h]=b,f&&(i.prototype[h]=function(){var P=this.__chain__;if(m||P){var R=i(this.__wrapped__),F=R.__actions__=Ee(this.__actions__);return F.push({func:b,args:arguments,thisArg:i}),R.__chain__=P,R}return b.apply(i,Ut([this.value()],arguments))})}),i}function rv(){return pe._===this&&(pe._=Eh),this}function tp(){}function nv(i){return i=D(i),H(function(r){return Xc(r,i)})}var av=Al(J),ov=Al(fc),sv=Al(rl);function um(i){return Hl(i)?nl(ht(i)):Dg(i)}function lv(i){return function(r){return i==null?s:li(i,r)}}var pv=hu(),cv=hu(!0);function ip(){return[]}function rp(){return!1}function uv(){return{}}function mv(){return""}function dv(){return!0}function fv(i,r){if(i=D(i),i<1||i>N)return[];var a=mt,l=ge(i,mt);r=x(r),i-=mt;for(var c=sl(l,r);++a<i;)r(a);return c}function hv(i){return L(i)?J(i,ht):Ge(i)?[i]:Ee(xu(W(i)))}function gv(i){var r=++Sh;return W(i)+r}var yv=Gn(function(i,r){return i+r},0),Mv=Ol("ceil"),bv=Gn(function(i,r){return i/r},1),wv=Ol("floor");function vv(i){return i&&i.length?On(i,Ae,Ml):s}function _v(i,r){return i&&i.length?On(i,x(r,2),Ml):s}function Iv(i){return yc(i,Ae)}function Pv(i,r){return yc(i,x(r,2))}function Rv(i){return i&&i.length?On(i,Ae,_l):s}function Fv(i,r){return i&&i.length?On(i,x(r,2),_l):s}var Sv=Gn(function(i,r){return i*r},1),Tv=Ol("round"),Ev=Gn(function(i,r){return i-r},0);function Cv(i){return i&&i.length?ol(i,Ae):0}function xv(i,r){return i&&i.length?ol(i,x(r,2)):0}return u.after=jM,u.ary=$u,u.assign=Gb,u.assignIn=im,u.assignInWith=jn,u.assignWith=kb,u.at=$b,u.before=Vu,u.bind=Wl,u.bindAll=Xw,u.bindKey=qu,u.castArray=ub,u.chain=Hu,u.chunk=wy,u.compact=vy,u.concat=_y,u.cond=Yw,u.conforms=Qw,u.constant=Zl,u.countBy=CM,u.create=Vb,u.curry=Wu,u.curryRight=Ku,u.debounce=Xu,u.defaults=qb,u.defaultsDeep=Wb,u.defer=eb,u.delay=tb,u.difference=Iy,u.differenceBy=Py,u.differenceWith=Ry,u.drop=Fy,u.dropRight=Sy,u.dropRightWhile=Ty,u.dropWhile=Ey,u.fill=Cy,u.filter=AM,u.flatMap=LM,u.flatMapDeep=NM,u.flatMapDepth=DM,u.flatten=Lu,u.flattenDeep=xy,u.flattenDepth=Ay,u.flip=ib,u.flow=Jw,u.flowRight=Zw,u.fromPairs=Oy,u.functions=Zb,u.functionsIn=jb,u.groupBy=UM,u.initial=Ly,u.intersection=Ny,u.intersectionBy=Dy,u.intersectionWith=Uy,u.invert=tw,u.invertBy=iw,u.invokeMap=GM,u.iteratee=jl,u.keyBy=kM,u.keys=ce,u.keysIn=xe,u.map=Xn,u.mapKeys=nw,u.mapValues=aw,u.matches=jw,u.matchesProperty=ev,u.memoize=Qn,u.merge=ow,u.mergeWith=rm,u.method=tv,u.methodOf=iv,u.mixin=ep,u.negate=zn,u.nthArg=nv,u.omit=sw,u.omitBy=lw,u.once=rb,u.orderBy=$M,u.over=av,u.overArgs=nb,u.overEvery=ov,u.overSome=sv,u.partial=Kl,u.partialRight=Yu,u.partition=VM,u.pick=pw,u.pickBy=nm,u.property=um,u.propertyOf=lv,u.pull=$y,u.pullAll=Du,u.pullAllBy=Vy,u.pullAllWith=qy,u.pullAt=Wy,u.range=pv,u.rangeRight=cv,u.rearg=ab,u.reject=KM,u.remove=Ky,u.rest=ob,u.reverse=Vl,u.sampleSize=YM,u.set=uw,u.setWith=mw,u.shuffle=QM,u.slice=Xy,u.sortBy=ZM,u.sortedUniq=eM,u.sortedUniqBy=tM,u.split=Lw,u.spread=sb,u.tail=iM,u.take=rM,u.takeRight=nM,u.takeRightWhile=aM,u.takeWhile=oM,u.tap=vM,u.throttle=lb,u.thru=Kn,u.toArray=ju,u.toPairs=am,u.toPairsIn=om,u.toPath=hv,u.toPlainObject=tm,u.transform=dw,u.unary=pb,u.union=sM,u.unionBy=lM,u.unionWith=pM,u.uniq=cM,u.uniqBy=uM,u.uniqWith=mM,u.unset=fw,u.unzip=ql,u.unzipWith=Uu,u.update=hw,u.updateWith=gw,u.values=Ai,u.valuesIn=yw,u.without=dM,u.words=pm,u.wrap=cb,u.xor=fM,u.xorBy=hM,u.xorWith=gM,u.zip=yM,u.zipObject=MM,u.zipObjectDeep=bM,u.zipWith=wM,u.entries=am,u.entriesIn=om,u.extend=im,u.extendWith=jn,ep(u,u),u.add=yv,u.attempt=cm,u.camelCase=vw,u.capitalize=sm,u.ceil=Mv,u.clamp=Mw,u.clone=mb,u.cloneDeep=fb,u.cloneDeepWith=hb,u.cloneWith=db,u.conformsTo=gb,u.deburr=lm,u.defaultTo=zw,u.divide=bv,u.endsWith=_w,u.eq=lt,u.escape=Iw,u.escapeRegExp=Pw,u.every=xM,u.find=OM,u.findIndex=Ou,u.findKey=Kb,u.findLast=BM,u.findLastIndex=Bu,u.findLastKey=Xb,u.floor=wv,u.forEach=Gu,u.forEachRight=ku,u.forIn=Yb,u.forInRight=Qb,u.forOwn=zb,u.forOwnRight=Jb,u.get=Ql,u.gt=yb,u.gte=Mb,u.has=ew,u.hasIn=zl,u.head=Nu,u.identity=Ae,u.includes=HM,u.indexOf=By,u.inRange=bw,u.invoke=rw,u.isArguments=ui,u.isArray=L,u.isArrayBuffer=bb,u.isArrayLike=Ce,u.isArrayLikeObject=te,u.isBoolean=wb,u.isBuffer=Kt,u.isDate=vb,u.isElement=_b,u.isEmpty=Ib,u.isEqual=Pb,u.isEqualWith=Rb,u.isError=Xl,u.isFinite=Fb,u.isFunction=xt,u.isInteger=Qu,u.isLength=Jn,u.isMap=zu,u.isMatch=Sb,u.isMatchWith=Tb,u.isNaN=Eb,u.isNative=Cb,u.isNil=Ab,u.isNull=xb,u.isNumber=Ju,u.isObject=Z,u.isObjectLike=ee,u.isPlainObject=Hr,u.isRegExp=Yl,u.isSafeInteger=Ob,u.isSet=Zu,u.isString=Zn,u.isSymbol=Ge,u.isTypedArray=xi,u.isUndefined=Bb,u.isWeakMap=Lb,u.isWeakSet=Nb,u.join=Hy,u.kebabCase=Rw,u.last=Ze,u.lastIndexOf=Gy,u.lowerCase=Fw,u.lowerFirst=Sw,u.lt=Db,u.lte=Ub,u.max=vv,u.maxBy=_v,u.mean=Iv,u.meanBy=Pv,u.min=Rv,u.minBy=Fv,u.stubArray=ip,u.stubFalse=rp,u.stubObject=uv,u.stubString=mv,u.stubTrue=dv,u.multiply=Sv,u.nth=ky,u.noConflict=rv,u.noop=tp,u.now=Yn,u.pad=Tw,u.padEnd=Ew,u.padStart=Cw,u.parseInt=xw,u.random=ww,u.reduce=qM,u.reduceRight=WM,u.repeat=Aw,u.replace=Ow,u.result=cw,u.round=Tv,u.runInContext=M,u.sample=XM,u.size=zM,u.snakeCase=Bw,u.some=JM,u.sortedIndex=Yy,u.sortedIndexBy=Qy,u.sortedIndexOf=zy,u.sortedLastIndex=Jy,u.sortedLastIndexBy=Zy,u.sortedLastIndexOf=jy,u.startCase=Nw,u.startsWith=Dw,u.subtract=Ev,u.sum=Cv,u.sumBy=xv,u.template=Uw,u.times=fv,u.toFinite=At,u.toInteger=D,u.toLength=em,u.toLower=Hw,u.toNumber=je,u.toSafeInteger=Hb,u.toString=W,u.toUpper=Gw,u.trim=kw,u.trimEnd=$w,u.trimStart=Vw,u.truncate=qw,u.unescape=Ww,u.uniqueId=gv,u.upperCase=Kw,u.upperFirst=Jl,u.each=Gu,u.eachRight=ku,u.first=Nu,ep(u,function(){var i={};return dt(u,function(r,a){X.call(u.prototype,a)||(i[a]=r)}),i}(),{chain:!1}),u.VERSION=e,Xe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){u[i].placeholder=u}),Xe(["drop","take"],function(i,r){k.prototype[i]=function(a){a=a===s?1:le(D(a),0);var l=this.__filtered__&&!r?new k(this):this.clone();return l.__filtered__?l.__takeCount__=ge(a,l.__takeCount__):l.__views__.push({size:ge(a,mt),type:i+(l.__dir__<0?"Right":"")}),l},k.prototype[i+"Right"]=function(a){return this.reverse()[i](a).reverse()}}),Xe(["filter","map","takeWhile"],function(i,r){var a=r+1,l=a==Lp||a==kd;k.prototype[i]=function(c){var m=this.clone();return m.__iteratees__.push({iteratee:x(c,3),type:a}),m.__filtered__=m.__filtered__||l,m}}),Xe(["head","last"],function(i,r){var a="take"+(r?"Right":"");k.prototype[i]=function(){return this[a](1).value()[0]}}),Xe(["initial","tail"],function(i,r){var a="drop"+(r?"":"Right");k.prototype[i]=function(){return this.__filtered__?new k(this):this[a](1)}}),k.prototype.compact=function(){return this.filter(Ae)},k.prototype.find=function(i){return this.filter(i).head()},k.prototype.findLast=function(i){return this.reverse().find(i)},k.prototype.invokeMap=H(function(i,r){return typeof i=="function"?new k(this):this.map(function(a){return Or(a,i,r)})}),k.prototype.reject=function(i){return this.filter(zn(x(i)))},k.prototype.slice=function(i,r){i=D(i);var a=this;return a.__filtered__&&(i>0||r<0)?new k(a):(i<0?a=a.takeRight(-i):i&&(a=a.drop(i)),r!==s&&(r=D(r),a=r<0?a.dropRight(-r):a.take(r-i)),a)},k.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},k.prototype.toArray=function(){return this.take(mt)},dt(k.prototype,function(i,r){var a=/^(?:filter|find|map|reject)|While$/.test(r),l=/^(?:head|last)$/.test(r),c=u[l?"take"+(r=="last"?"Right":""):r],m=l||/^find/.test(r);!c||(u.prototype[r]=function(){var f=this.__wrapped__,h=l?[1]:arguments,b=f instanceof k,P=h[0],R=b||L(f),F=function(G){var $=c.apply(u,Ut([G],h));return l&&T?$[0]:$};R&&a&&typeof P=="function"&&P.length!=1&&(b=R=!1);var T=this.__chain__,C=!!this.__actions__.length,A=m&&!T,U=b&&!C;if(!m&&R){f=U?f:new k(this);var O=i.apply(f,h);return O.__actions__.push({func:Kn,args:[F],thisArg:s}),new Qe(O,T)}return A&&U?i.apply(this,h):(O=this.thru(F),A?l?O.value()[0]:O.value():O)})}),Xe(["pop","push","shift","sort","splice","unshift"],function(i){var r=Mn[i],a=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",l=/^(?:pop|shift)$/.test(i);u.prototype[i]=function(){var c=arguments;if(l&&!this.__chain__){var m=this.value();return r.apply(L(m)?m:[],c)}return this[a](function(f){return r.apply(L(f)?f:[],c)})}}),dt(k.prototype,function(i,r){var a=u[r];if(a){var l=a.name+"";X.call(Fi,l)||(Fi[l]=[]),Fi[l].push({name:r,func:a})}}),Fi[Hn(s,ct).name]=[{name:"wrapper",func:s}],k.prototype.clone=Wh,k.prototype.reverse=Kh,k.prototype.value=Xh,u.prototype.at=_M,u.prototype.chain=IM,u.prototype.commit=PM,u.prototype.next=RM,u.prototype.plant=SM,u.prototype.reverse=TM,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=EM,u.prototype.first=u.prototype.head,Fr&&(u.prototype[Fr]=FM),u},Gt=Ph();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(pe._=Gt,define(function(){return Gt})):ri?((ri.exports=Gt)._=Gt,js._=Gt):pe._=Gt}).call(Oi)});var op=K((nI,ym)=>{"use strict";ym.exports=function(e,t){return function(){for(var o=new Array(arguments.length),p=0;p<o.length;p++)o[p]=arguments[p];return e.apply(t,o)}}});var Be=K((aI,wm)=>{"use strict";var Hv=op(),mi=Object.prototype.toString;function sp(s){return mi.call(s)==="[object Array]"}function lp(s){return typeof s=="undefined"}function Gv(s){return s!==null&&!lp(s)&&s.constructor!==null&&!lp(s.constructor)&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function kv(s){return mi.call(s)==="[object ArrayBuffer]"}function $v(s){return typeof FormData!="undefined"&&s instanceof FormData}function Vv(s){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&s.buffer instanceof ArrayBuffer,e}function qv(s){return typeof s=="string"}function Wv(s){return typeof s=="number"}function Mm(s){return s!==null&&typeof s=="object"}function pa(s){if(mi.call(s)!=="[object Object]")return!1;var e=Object.getPrototypeOf(s);return e===null||e===Object.prototype}function Kv(s){return mi.call(s)==="[object Date]"}function Xv(s){return mi.call(s)==="[object File]"}function Yv(s){return mi.call(s)==="[object Blob]"}function bm(s){return mi.call(s)==="[object Function]"}function Qv(s){return Mm(s)&&bm(s.pipe)}function zv(s){return typeof URLSearchParams!="undefined"&&s instanceof URLSearchParams}function Jv(s){return s.trim?s.trim():s.replace(/^\s+|\s+$/g,"")}function Zv(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function pp(s,e){if(!(s===null||typeof s=="undefined"))if(typeof s!="object"&&(s=[s]),sp(s))for(var t=0,n=s.length;t<n;t++)e.call(null,s[t],t,s);else for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&e.call(null,s[o],o,s)}function cp(){var s={};function e(o,p){pa(s[p])&&pa(o)?s[p]=cp(s[p],o):pa(o)?s[p]=cp({},o):sp(o)?s[p]=o.slice():s[p]=o}for(var t=0,n=arguments.length;t<n;t++)pp(arguments[t],e);return s}function jv(s,e,t){return pp(e,function(o,p){t&&typeof o=="function"?s[p]=Hv(o,t):s[p]=o}),s}function e_(s){return s.charCodeAt(0)===65279&&(s=s.slice(1)),s}wm.exports={isArray:sp,isArrayBuffer:kv,isBuffer:Gv,isFormData:$v,isArrayBufferView:Vv,isString:qv,isNumber:Wv,isObject:Mm,isPlainObject:pa,isUndefined:lp,isDate:Kv,isFile:Xv,isBlob:Yv,isFunction:bm,isStream:Qv,isURLSearchParams:zv,isStandardBrowserEnv:Zv,forEach:pp,merge:cp,extend:jv,trim:Jv,stripBOM:e_}});var up=K((oI,_m)=>{"use strict";var Li=Be();function vm(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}_m.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(Li.isURLSearchParams(t))o=t.toString();else{var p=[];Li.forEach(t,function(g,v){g===null||typeof g=="undefined"||(Li.isArray(g)?v=v+"[]":g=[g],Li.forEach(g,function(S){Li.isDate(S)?S=S.toISOString():Li.isObject(S)&&(S=JSON.stringify(S)),p.push(vm(v)+"="+vm(S))}))}),o=p.join("&")}if(o){var d=e.indexOf("#");d!==-1&&(e=e.slice(0,d)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}});var Pm=K((sI,Im)=>{"use strict";var t_=Be();function ca(){this.handlers=[]}ca.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};ca.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};ca.prototype.forEach=function(e){t_.forEach(this.handlers,function(n){n!==null&&e(n)})};Im.exports=ca});var Fm=K((lI,Rm)=>{"use strict";var i_=Be();Rm.exports=function(e,t){i_.forEach(e,function(o,p){p!==t&&p.toUpperCase()===t.toUpperCase()&&(e[t]=o,delete e[p])})}});var mp=K((pI,Sm)=>{"use strict";Sm.exports=function(e,t,n,o,p){return e.config=t,n&&(e.code=n),e.request=o,e.response=p,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var dp=K((cI,Tm)=>{"use strict";var r_=mp();Tm.exports=function(e,t,n,o,p){var d=new Error(e);return r_(d,t,n,o,p)}});var Cm=K((uI,Em)=>{"use strict";var n_=dp();Em.exports=function(e,t,n){var o=n.config.validateStatus;!n.status||!o||o(n.status)?e(n):t(n_("Request failed with status code "+n.status,n.config,null,n.request,n))}});var Am=K((mI,xm)=>{"use strict";var ua=Be();xm.exports=ua.isStandardBrowserEnv()?function(){return{write:function(t,n,o,p,d,y){var g=[];g.push(t+"="+encodeURIComponent(n)),ua.isNumber(o)&&g.push("expires="+new Date(o).toGMTString()),ua.isString(p)&&g.push("path="+p),ua.isString(d)&&g.push("domain="+d),y===!0&&g.push("secure"),document.cookie=g.join("; ")},read:function(t){var n=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var Bm=K((dI,Om)=>{"use strict";Om.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var Nm=K((fI,Lm)=>{"use strict";Lm.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}});var Um=K((hI,Dm)=>{"use strict";var a_=Bm(),o_=Nm();Dm.exports=function(e,t){return e&&!a_(t)?o_(e,t):t}});var Gm=K((gI,Hm)=>{"use strict";var fp=Be(),s_=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];Hm.exports=function(e){var t={},n,o,p;return e&&fp.forEach(e.split(`
|
|
21
21
|
`),function(y){if(p=y.indexOf(":"),n=fp.trim(y.substr(0,p)).toLowerCase(),o=fp.trim(y.substr(p+1)),n){if(t[n]&&s_.indexOf(n)>=0)return;n==="set-cookie"?t[n]=(t[n]?t[n]:[]).concat([o]):t[n]=t[n]?t[n]+", "+o:o}}),t}});var Vm=K((yI,$m)=>{"use strict";var km=Be();$m.exports=km.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),n;function o(p){var d=p;return e&&(t.setAttribute("href",d),d=t.href),t.setAttribute("href",d),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return n=o(window.location.href),function(d){var y=km.isString(d)?o(d):d;return y.protocol===n.protocol&&y.host===n.host}}():function(){return function(){return!0}}()});var Vr=K((MI,qm)=>{"use strict";function hp(s){this.message=s}hp.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};hp.prototype.__CANCEL__=!0;qm.exports=hp});var yp=K((bI,Wm)=>{"use strict";var ma=Be(),l_=Cm(),p_=Am(),c_=up(),u_=Um(),m_=Gm(),d_=Vm(),gp=dp(),f_=qr(),h_=Vr();Wm.exports=function(e){return new Promise(function(n,o){var p=e.data,d=e.headers,y=e.responseType,g;function v(){e.cancelToken&&e.cancelToken.unsubscribe(g),e.signal&&e.signal.removeEventListener("abort",g)}ma.isFormData(p)&&delete d["Content-Type"];var w=new XMLHttpRequest;if(e.auth){var S=e.auth.username||"",q=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(S+":"+q)}var Fe=u_(e.baseURL,e.url);w.open(e.method.toUpperCase(),c_(Fe,e.params,e.paramsSerializer),!0),w.timeout=e.timeout;function we(){if(!!w){var Se="getAllResponseHeaders"in w?m_(w.getAllResponseHeaders()):null,ue=!y||y==="text"||y==="json"?w.responseText:w.response,Te={data:ue,status:w.status,statusText:w.statusText,headers:Se,config:e,request:w};l_(function(ut){n(ut),v()},function(ut){o(ut),v()},Te),w=null}}if("onloadend"in w?w.onloadend=we:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(we)},w.onabort=function(){!w||(o(gp("Request aborted",e,"ECONNABORTED",w)),w=null)},w.onerror=function(){o(gp("Network Error",e,null,w)),w=null},w.ontimeout=function(){var ue=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",Te=e.transitional||f_.transitional;e.timeoutErrorMessage&&(ue=e.timeoutErrorMessage),o(gp(ue,e,Te.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",w)),w=null},ma.isStandardBrowserEnv()){var ct=(e.withCredentials||d_(Fe))&&e.xsrfCookieName?p_.read(e.xsrfCookieName):void 0;ct&&(d[e.xsrfHeaderName]=ct)}"setRequestHeader"in w&&ma.forEach(d,function(ue,Te){typeof p=="undefined"&&Te.toLowerCase()==="content-type"?delete d[Te]:w.setRequestHeader(Te,ue)}),ma.isUndefined(e.withCredentials)||(w.withCredentials=!!e.withCredentials),y&&y!=="json"&&(w.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&w.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&w.upload&&w.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(g=function(Se){!w||(o(!Se||Se&&Se.type?new h_("canceled"):Se),w.abort(),w=null)},e.cancelToken&&e.cancelToken.subscribe(g),e.signal&&(e.signal.aborted?g():e.signal.addEventListener("abort",g))),p||(p=null),w.send(p)})}});var qr=K((wI,Ym)=>{"use strict";var he=Be(),Km=Fm(),g_=mp(),y_={"Content-Type":"application/x-www-form-urlencoded"};function Xm(s,e){!he.isUndefined(s)&&he.isUndefined(s["Content-Type"])&&(s["Content-Type"]=e)}function M_(){var s;return typeof XMLHttpRequest!="undefined"?s=yp():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(s=yp()),s}function b_(s,e,t){if(he.isString(s))try{return(e||JSON.parse)(s),he.trim(s)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(s)}var da={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:M_(),transformRequest:[function(e,t){return Km(t,"Accept"),Km(t,"Content-Type"),he.isFormData(e)||he.isArrayBuffer(e)||he.isBuffer(e)||he.isStream(e)||he.isFile(e)||he.isBlob(e)?e:he.isArrayBufferView(e)?e.buffer:he.isURLSearchParams(e)?(Xm(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):he.isObject(e)||t&&t["Content-Type"]==="application/json"?(Xm(t,"application/json"),b_(e)):e}],transformResponse:[function(e){var t=this.transitional||da.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,p=!n&&this.responseType==="json";if(p||o&&he.isString(e)&&e.length)try{return JSON.parse(e)}catch(d){if(p)throw d.name==="SyntaxError"?g_(d,this,"E_JSON_PARSE"):d}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};he.forEach(["delete","get","head"],function(e){da.headers[e]={}});he.forEach(["post","put","patch"],function(e){da.headers[e]=he.merge(y_)});Ym.exports=da});var zm=K((vI,Qm)=>{"use strict";var w_=Be(),v_=qr();Qm.exports=function(e,t,n){var o=this||v_;return w_.forEach(n,function(d){e=d.call(o,e,t)}),e}});var Mp=K((_I,Jm)=>{"use strict";Jm.exports=function(e){return!!(e&&e.__CANCEL__)}});var ed=K((II,jm)=>{"use strict";var Zm=Be(),bp=zm(),__=Mp(),I_=qr(),P_=Vr();function wp(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new P_("canceled")}jm.exports=function(e){wp(e),e.headers=e.headers||{},e.data=bp.call(e,e.data,e.headers,e.transformRequest),e.headers=Zm.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Zm.forEach(["delete","get","head","post","put","patch","common"],function(o){delete e.headers[o]});var t=e.adapter||I_.adapter;return t(e).then(function(o){return wp(e),o.data=bp.call(e,o.data,o.headers,e.transformResponse),o},function(o){return __(o)||(wp(e),o&&o.response&&(o.response.data=bp.call(e,o.response.data,o.response.headers,e.transformResponse))),Promise.reject(o)})}});var vp=K((PI,td)=>{"use strict";var Ve=Be();td.exports=function(e,t){t=t||{};var n={};function o(w,S){return Ve.isPlainObject(w)&&Ve.isPlainObject(S)?Ve.merge(w,S):Ve.isPlainObject(S)?Ve.merge({},S):Ve.isArray(S)?S.slice():S}function p(w){if(Ve.isUndefined(t[w])){if(!Ve.isUndefined(e[w]))return o(void 0,e[w])}else return o(e[w],t[w])}function d(w){if(!Ve.isUndefined(t[w]))return o(void 0,t[w])}function y(w){if(Ve.isUndefined(t[w])){if(!Ve.isUndefined(e[w]))return o(void 0,e[w])}else return o(void 0,t[w])}function g(w){if(w in t)return o(e[w],t[w]);if(w in e)return o(void 0,e[w])}var v={url:d,method:d,data:d,baseURL:y,transformRequest:y,transformResponse:y,paramsSerializer:y,timeout:y,timeoutMessage:y,withCredentials:y,adapter:y,responseType:y,xsrfCookieName:y,xsrfHeaderName:y,onUploadProgress:y,onDownloadProgress:y,decompress:y,maxContentLength:y,maxBodyLength:y,transport:y,httpAgent:y,httpsAgent:y,cancelToken:y,socketPath:y,responseEncoding:y,validateStatus:g};return Ve.forEach(Object.keys(e).concat(Object.keys(t)),function(S){var q=v[S]||p,Fe=q(S);Ve.isUndefined(Fe)&&q!==g||(n[S]=Fe)}),n}});var _p=K((RI,id)=>{id.exports={version:"0.24.0"}});var ad=K((FI,nd)=>{"use strict";var R_=_p().version,Ip={};["object","boolean","number","function","string","symbol"].forEach(function(s,e){Ip[s]=function(n){return typeof n===s||"a"+(e<1?"n ":" ")+s}});var rd={};Ip.transitional=function(e,t,n){function o(p,d){return"[Axios v"+R_+"] Transitional option '"+p+"'"+d+(n?". "+n:"")}return function(p,d,y){if(e===!1)throw new Error(o(d," has been removed"+(t?" in "+t:"")));return t&&!rd[d]&&(rd[d]=!0,console.warn(o(d," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(p,d,y):!0}};function F_(s,e,t){if(typeof s!="object")throw new TypeError("options must be an object");for(var n=Object.keys(s),o=n.length;o-- >0;){var p=n[o],d=e[p];if(d){var y=s[p],g=y===void 0||d(y,p,s);if(g!==!0)throw new TypeError("option "+p+" must be "+g);continue}if(t!==!0)throw Error("Unknown option "+p)}}nd.exports={assertOptions:F_,validators:Ip}});var ud=K((SI,cd)=>{"use strict";var od=Be(),S_=up(),sd=Pm(),ld=ed(),fa=vp(),pd=ad(),Ni=pd.validators;function Wr(s){this.defaults=s,this.interceptors={request:new sd,response:new sd}}Wr.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=fa(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&pd.assertOptions(t,{silentJSONParsing:Ni.transitional(Ni.boolean),forcedJSONParsing:Ni.transitional(Ni.boolean),clarifyTimeoutError:Ni.transitional(Ni.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach(function(q){typeof q.runWhen=="function"&&q.runWhen(e)===!1||(o=o&&q.synchronous,n.unshift(q.fulfilled,q.rejected))});var p=[];this.interceptors.response.forEach(function(q){p.push(q.fulfilled,q.rejected)});var d;if(!o){var y=[ld,void 0];for(Array.prototype.unshift.apply(y,n),y=y.concat(p),d=Promise.resolve(e);y.length;)d=d.then(y.shift(),y.shift());return d}for(var g=e;n.length;){var v=n.shift(),w=n.shift();try{g=v(g)}catch(S){w(S);break}}try{d=ld(g)}catch(S){return Promise.reject(S)}for(;p.length;)d=d.then(p.shift(),p.shift());return d};Wr.prototype.getUri=function(e){return e=fa(this.defaults,e),S_(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};od.forEach(["delete","get","head","options"],function(e){Wr.prototype[e]=function(t,n){return this.request(fa(n||{},{method:e,url:t,data:(n||{}).data}))}});od.forEach(["post","put","patch"],function(e){Wr.prototype[e]=function(t,n,o){return this.request(fa(o||{},{method:e,url:t,data:n}))}});cd.exports=Wr});var dd=K((TI,md)=>{"use strict";var T_=Vr();function Di(s){if(typeof s!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(o){e=o});var t=this;this.promise.then(function(n){if(!!t._listeners){var o,p=t._listeners.length;for(o=0;o<p;o++)t._listeners[o](n);t._listeners=null}}),this.promise.then=function(n){var o,p=new Promise(function(d){t.subscribe(d),o=d}).then(n);return p.cancel=function(){t.unsubscribe(o)},p},s(function(o){t.reason||(t.reason=new T_(o),e(t.reason))})}Di.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Di.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Di.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};Di.source=function(){var e,t=new Di(function(o){e=o});return{token:t,cancel:e}};md.exports=Di});var hd=K((EI,fd)=>{"use strict";fd.exports=function(e){return function(n){return e.apply(null,n)}}});var yd=K((CI,gd)=>{"use strict";gd.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var wd=K((xI,Pp)=>{"use strict";var Md=Be(),E_=op(),ha=ud(),C_=vp(),x_=qr();function bd(s){var e=new ha(s),t=E_(ha.prototype.request,e);return Md.extend(t,ha.prototype,e),Md.extend(t,e),t.create=function(o){return bd(C_(s,o))},t}var gt=bd(x_);gt.Axios=ha;gt.Cancel=Vr();gt.CancelToken=dd();gt.isCancel=Mp();gt.VERSION=_p().version;gt.all=function(e){return Promise.all(e)};gt.spread=hd();gt.isAxiosError=yd();Pp.exports=gt;Pp.exports.default=gt});var _d=K((AI,vd)=>{vd.exports=wd()});var gm=dm(fm());var ap=s=>{let e=200,t=[],n=0;return t[n]=[],s.forEach(o=>{t[n].length<=e-1?t[n].push(o):(n++,t[n]=[o])}),t},ea=s=>{let e=[],t=200;for(;s.length>t;){let n=s.splice(0,t);e.push(n)}return e.push(s),e},Oe=(s,e)=>{let t="",n={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"},o={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"},p={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"};return s==="prod"?t=n[e]:s==="dev"?t=o[e]:t=p[e],t},Xt=s=>s.filter((t,n,o)=>n===o.indexOf(t)),ta=s=>Array.isArray(s)?s.map(e=>ta(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,t)=>({...e,[(0,gm.camelCase)(t)]:ta(s[t])}),{}):s,de=s=>s||!1,fe=()=>`&disable_cache=${Date.now()}`,kr=s=>s.sort((e,t)=>e.localeCompare(t));var ia=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var ra=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new ia;return t.id=e.id,t.name=e.name,t.nickname=e.nickname,t.avatar=e.avatar,t.gender=e.gender,t.country=e.country,t.birthDate=e.birth_date,t.interests=e.interests?e.interests:[],t.followingCount=e.following_count,t.followersCount=e.followers_count,t}};var na=class{nextPageStartsAfter=null;itemsPerPage=null};var Bi=class{pagination=new na};var re=class{meta=new Bi;data=[]};var aa=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var oa=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new aa;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t.nickname=e.nickname,t}};var sa=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var la=class{followersFromResponse=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new sa;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var $r=class{profile_ids=[]};var ya=dm(_d());function Rp(s){this.message=s}Rp.prototype=new Error,Rp.prototype.name="InvalidCharacterError";var Id=typeof window!="undefined"&&window.atob&&window.atob.bind(window)||function(s){var e=String(s).replace(/=+$/,"");if(e.length%4==1)throw new Rp("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,n,o=0,p=0,d="";n=e.charAt(p++);~n&&(t=o%4?64*t+n:n,o++%4)?d+=String.fromCharCode(255&t>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return d};function A_(s){var e=s.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Id(t).replace(/(.)/g,function(n,o){var p=o.charCodeAt(0).toString(16).toUpperCase();return p.length<2&&(p="0"+p),"%"+p}))}(e)}catch{return Id(e)}}function ga(s){this.message=s}function O_(s,e){if(typeof s!="string")throw new ga("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(A_(s.split(".")[t]))}catch(n){throw new ga("Invalid token specified: "+n.message)}}ga.prototype=new Error,ga.prototype.name="InvalidTokenError";var Pd=O_;var Rd=(s,e,t)=>{let n={data:s.data,status:e,statusText:t,headers:s.headers,config:s};return{code:String(e),config:s,isAxiosError:!0,toJSON:()=>({}),name:"Unauthorized",message:t,response:n}};var Me=class{instanceAuth=null;instance=null;constructor(e,t){this.instanceAuth=ya.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(n=>{let o=null;try{o=Pd(e.authProvider.getIdToken())}catch(d){throw Rd(n,401,d.message)}return Date.now()>o.exp&&(ya.default.defaults.headers.common.Authorization=`Bearer ${e.authProvider.getIdToken()}`,n.headers.Authorization=`Bearer ${e.authProvider.getIdToken()}`),n},n=>{Promise.reject(n)}),this.instanceAuth.interceptors.response.use(n=>n,n=>{let o=n.config;if((n.response?.status===403||n.response?.status===401)&&!o._retry){o._retry=!0;let p=e.authProvider.getIdToken();return o.headers.Authorization=`Bearer ${p}`,this.instanceAuth(o)}return Promise.reject(n)}),this.instance=ya.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}};var B_="/countries",Le="/profile",Fd="/profiles",Ui=class extends Me{apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){super(e,Oe(e.environment,"profile"));this.lang=e.lang,this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.profileRemapper=new ra,this.followingRemapper=new oa,this.followersRemapper=new la}getCountries=async e=>{try{let t=`&lang=${this.lang}`,n=`${B_}${this.apiSignInUrl}${t}`,o=Date.now();return e&&(n+=`&disable_cache=${o}`),(await this.instance.get(n)).data.data}catch(t){throw console.warn("There was a problem fetching the countries:",t),t.response}};getProfile=async e=>{let t=`${Le}${this.apiSignInUrl}`;if(e){t=`${Fd}/${e}${this.apiSignInUrl}`;try{let n=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profile: ${e}`,n),n.response}}else try{let n=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn("There was a problem fetching your profile from API:",n),n.response}};getProfiles=async(e,t)=>{try{let n=`${Fd}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.profileRemapper.profilesFromResponse(p.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,n),n.response}};getFollowers=async(e,t)=>{let n=`${Le}/followers${this.apiSignInUrl}`;if(e&&!t){n=`${Le}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}e&&t?n=`${Le}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Le}/${t}/followers${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,o),o.response}};getFollowing=async(e,t)=>{let n=`${Le}/following${this.apiSignInUrl}`;if(e&&!t){n=`${Le}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}e&&t?n=`${Le}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Le}/${t}/following${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o.response}};follow=async e=>{let t=new $r;t.profile_ids=e;try{let n=await this.instanceAuth.post(`${Le}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followResponse(n.data.data)}catch(n){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,n),n.response}};unfollow=async e=>{let t=new $r;t.profile_ids=e;try{return await this.instanceAuth.delete(`${Le}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(n){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,n),n.response}};getBadges=async e=>{let t=`${Le}/badges${this.apiSignInUrl}`;try{return e?(t=`${Le}/${e}/badges${this.apiSignInUrl}`,(await this.instance.get(t)).data.data):(await this.instanceAuth.get(t)).data.data}catch(n){throw console.warn("There was a problem with fetching the badges",n),n.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${Le}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var Bt={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},Fp={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},Sp=["matchId","matchType","market","prediction"];var Sd="FansUnited",Tp={football:{ids:[],countries:[],competitions:[]},profile:{info:{},statistics:{},badges:null,countries:[],exparations:{profile:0,statistics:0,badges:0}}},yt=class{idSchema="";expirationTimeout=600;expirationBadgesTimeout=3600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Tp)}clearData=()=>{this.setData(Tp)};getEntityById=(e="",t="")=>this.getData().football.ids.find(n=>{let o=Bt[this.idSchema];return n&&`${n[o]}`===t&&n.resource===e});getEntity=(e,t,n)=>Array.isArray(e)?this.getData().football.ids.filter(o=>{let p=Bt[n];return o&&e.includes(`${o[p]}`)&&o.resource===t}):this.getData().football.ids.find(o=>{let p=Bt[n];return o&&`${o[p]}`===e&&o.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===t&&n.resource===e);checkForExistingIdObjs=(e,t)=>{let n=Bt[t],o={};return Object.keys(e).forEach(p=>{let d=e[p],g=this.getEntity(d,p,t).map(w=>w[n]),v=e[p].filter(w=>!g.includes(w));o[p]=d.map(w=>v.includes(w)?{id:w,exists:!1}:{id:w,exists:!0})}),o};getIdsByType=(e,t,n)=>{let o=Bt[n],p=Bt[t],d={};return Object.keys(e).forEach(y=>{let g=e[y],v=[];this.getData().football.ids.forEach(w=>{g.forEach((S,q)=>{S===w[p]&&y===w.resource&&(v[q]=w[o])})}),d[y]=v}),d};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),n=t.football.ids;n=[...n,...e],t.football.ids=n,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.info=e,t.profile.exparations.profile=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=e=>{let t=this.getData();t.profile.statistics=e,t.profile.exparations.statistics=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=e=>{let t=this.getData();t.profile.badges=e,t.profile.exparations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData(),n=[...t.football.competitions];n.push(...e),t.football.competitions=this.makeCompetitionsUnique(n),this.setData(t)};getCompetitionsLength=()=>{let{football:e}=this.getData();return e.competitions.length};getExpiration=e=>{let t=this.getData();switch(this.initialNewSchema("exparations"),e){case"profile":return t.profile.exparations.profile;case"statistics":return t.profile.exparations.statistics;case"badges":return t.profile.exparations.badges}};makeCompetitionsUnique=e=>{let t=new Set;return e.filter(n=>{let o=!t.has(n.id);return t.add(n.id),o})};getData=()=>JSON.parse(localStorage.getItem(Sd));setData=e=>{localStorage.setItem(Sd,JSON.stringify(e))};initialNewSchema=e=>{this.getData().profile[e]||this.setData(Tp)}};var Kr={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Ma=class extends Me{apiSignInUrl="";constructor(e){super(e,Oe(e.environment,"idMapping"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Kr[e]}=${t}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,n),n.response}};getEntityByIdAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${t}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,o),o.response}};getEntityIdsByIdsAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${t.join(",")}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,o),o.response}};getEntitiesByIds=(e,t,n)=>{t.sort((d,y)=>d.localeCompare(y));let p=ap(t).map(d=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${d.join(",")}`)}catch(y){throw console.warn(`There was a problem with id mapping request for the following ids:${d.join(",")}`,y),y.response}});return Promise.all(p).then(d=>{let y=[];return d.forEach(g=>{y.push(...g.data.data)}),y})};getEntitiesByIdObjs=async(e,t)=>{let n=[],o={},p=[];Object.keys(e).forEach(v=>{n.push.apply(n,e[v])});let d=Xt(n),y=ap(d);for(let v of y){let w="";if(Object.keys(e).forEach(S=>{o[S]=[];let q=v.filter(Fe=>e[S].includes(Fe));q&&q.length>0&&(o[S]=q)}),Object.keys(o).forEach(S=>{o[S].length>0&&(o[S].sort((q,Fe)=>q.localeCompare(Fe)),w+="&",w+=`${Kr[S]}=${o[S].join(",")}`)}),w&&w.length>0)try{let S=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${w}`);p.push(S.data.data)}catch(S){throw console.warn("There was a problem with id mapping request",S),S.response}else p.push([])}return Array.prototype.concat.apply([],p)}};var ba=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new yt(e),this.https=new Ma(e)}getEntitiesByIds=async(e,t,n)=>{if(this.isBrowser)try{let o=this.localStorage.checkForExistingIdObjs(e,t),p=this.splitForRequestAndExisting(o),d=await this.https.getEntitiesByIdObjs(p.request,t);return this.localStorage.addIdMappings(d),this.localStorage.getIdsByType(e,t,n)}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}else try{let o=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(p=>{e[p]=o.filter(d=>d.resource===p).map(d=>d[Bt[n]])}),e}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}};getEntityById=async(e,t,n)=>{if(this.isBrowser){let o=this.localStorage.getEntity(e,t,n);if(o)return o;{let p=await this.requestEntity(e,t,n);return this.localStorage.addIdMappings(p),p}}else return await this.requestEntity(e,t,n)};splitForRequestAndExisting=e=>{let t={},n={};return Object.keys(e).forEach(o=>{t[o]=e[o].filter(p=>!p.exists).map(p=>p.id),n[o]=e[o].filter(p=>p.exists).map(p=>p.id)}),{existing:n,request:t}};requestEntity=async(e,t,n)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,n)}catch(o){return console.warn(`There was a problem retrieving the requested entity: ${o}`),null}}};var wa=s=>{switch(s){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 s}};var va=class{extractedObjIds={};traverse=(e,t)=>(t=wa(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjExtract(n,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{let o=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),o&&this.extractedObjIds[t].push(o)):e[n]&&this.traverse(e[n],n)})}};var _a=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,n)=>(t=wa(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(n),this.remappedIdsObj=n),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjReplace(n,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{n==="id"||n==="teamId"?e[n]&&(e[n]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[n]&&this.traverse(e[n],n,this.remappedIdsObj)})}};var ae=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new ba(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let n=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let p=new va().traverse(n,t);return this.idMappingFacade.getEntitiesByIds(p,"native",this.idSchema).then(d=>new _a().traverse(n,t,d))}else return e}catch(o){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,o),[]}};getEntityIdsBySchemaId=async(e,t,n)=>{let o={};return o[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(o,this.idSchema,n):o}};var qe=class{completed=!1;percentage;constructor(e){this.percentage=e}};var Ia=class{teamFollowed=new qe(10);teamFavourite=new qe(15);playerFollowed=new qe(10);playerFavourite=new qe(10);competitionFollowed=new qe(10);competitionFavourite=new qe(5);addedBirthdate=new qe(10);addedGender=new qe(10);addedCountry=new qe(10);addedAvatar=new qe(10)};var Pa=class{totalPercentage;breakdown=new Ia};var Xr=class{limit=0;startAfter=null;constructor(e){this.limit=e.limit?e.limit:20,this.startAfter=e.startAfter?e.startAfter:null}constructFilterUrl=()=>{let e="";return this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.startAfter&&(e=e+"&",e=e+`start_after=${this.startAfter}`),e}};var Mt=class{isBrowser=!1;localStorage={};profileHttps=null;activityHttps=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.profileHttps=t,this.activityHttps=n}getOwn=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("profile");if(e)return JSON.parse(JSON.stringify(e));try{let t=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}}else try{return await this.profileHttps.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let e=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.profileHttps.getProfiles(e,t)}catch(n){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,n),n}};getById=async e=>{try{return await this.profileHttps.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let n=await this.profileHttps.getCountries(e);return this.localStorage.setProfileCountries(n),n}catch(n){throw console.warn("There was a problem retrieving profile countries: ",n),n}}else try{return await this.profileHttps.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{e&&(e=new Xr(e));let n=await this.profileHttps.getFollowers(e,t),o=n.data.map(p=>p.followerId);if(o.length){let p=await this.getByIds(o),d=n.data.map(y=>(p.forEach(g=>{y.followerId===g.id&&(y.name=g.name,y.nickname=g.nickname,y.avatar=g.avatar)}),y));return n.data=d,n}return n}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,t)=>{try{e&&(e=new Xr(e));let n=await this.profileHttps.getFollowing(e,t),o=n.data.map(p=>p.followingId);if(o.length){let p=await this.getByIds(o),d=n.data.map(y=>(p.forEach(g=>{y.followingId===g.id&&(y.name=g.name,y.nickname=g.nickname,y.avatar=g.avatar)}),y));return n.data=d,n}return n}catch(n){throw console.warn("There was a problem retrieving your following profiles: ",n),n}};follow=async e=>{try{return await this.profileHttps.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.profileHttps.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new Pa,n=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,n+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,n+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,n+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,n+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(w=>w.type==="team"&&w.favourite)&&(t.breakdown.teamFavourite.completed=!0,n+=t.breakdown.teamFavourite.percentage),e.interests.find(w=>w.type==="team")&&(t.breakdown.teamFollowed.completed=!0,n+=t.breakdown.teamFollowed.percentage),e.interests.find(w=>w.type==="player"&&w.favourite)&&(t.breakdown.playerFavourite.completed=!0,n+=t.breakdown.playerFavourite.percentage),e.interests.find(w=>w.type==="player")&&(t.breakdown.playerFollowed.completed=!0,n+=t.breakdown.playerFollowed.percentage),e.interests.find(w=>w.type==="competition"&&w.favourite)&&(t.breakdown.competitionFavourite.completed=!0,n+=t.breakdown.competitionFavourite.percentage),e.interests.find(w=>w.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,n+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=n,t};getStats=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("statistics");if(e&&Object.keys(e).length)return JSON.parse(JSON.stringify(e));try{let t=await this.activityHttps.getStats();return this.localStorage.setProfileStats(t),t}catch(t){throw console.warn("There was a problem retrieving own profile statistics: ",t),t}}else try{return await this.activityHttps.getStats()}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("badges");if(e)return e;try{let t=await this.profileHttps.getBadges();return this.localStorage.setProfileBadges(t),t}catch(t){throw console.warn("There was a problem retrieving own profile badges: ",t),t}}else try{return await this.profileHttps.getBadges()}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=e=>{let t=Math.floor(Date.now()/1e3),n=this.localStorage.getExpiration(e);switch(e){case"profile":if(n>t)return this.localStorage.getOwnProfile();case"statistics":if(n>t)return this.localStorage.getProfileStats();case"badges":if(n>t)return this.localStorage.getProfileBadges();default:return null}}};var Ra=class{id=null;name=null;assets=null};var Fa=class{extractUpdatedProps=(e,t)=>{let n=["name","nickname","gender"],o={};return Object.keys(e).forEach(p=>{if(n.includes(p)&&e[p]!==t[p])o[p]=t[p];else if(p==="birthDate")(t[p]===null||e[p]===null&&t[p]||e[p]!==t[p])&&(o.birth_date=t[p]);else if(p==="country")t[p]===null?o.country_id=t[p]:(e[p]===null&&t[p]||e[p].id!==t[p].id)&&(o.country_id=t[p].id);else if(p==="interests"){let d=e[p],y=t[p];y.length&&this.isNewInterest(d,y)?o[p]=this.updateInterests(d,y):(!y.length&&d.length||d.length!==y.length&&!this.isNewInterest(d,y))&&(o[p]=y)}}),o};updateInterests=(e,t)=>{if(e.length===t.length){let[n,o]=this.extractSameAndNewInterests(e,t);return[...o,...n]}else return t};isNewInterest=(e,t)=>{let n=!1,[o]=this.extractSameAndNewInterests(e,t);return o.length&&(n=!0),n};extractSameAndNewInterests=(e,t)=>{let n=t.filter(p=>e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite));return[t.filter(p=>!e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite)),n]}};var Sa=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,n,o,p,d){this.idsRemapper=e,this.localStorage=t,this.profileHttps=n,this.profileService=new Fa,this.profileFacade=new Mt(t,n,o)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch(t){throw this.isFetching=!1,t}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>{let t=await this.profileFacade.follow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};unfollow=async e=>{let t=await this.profileFacade.unfollow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};getStats=async()=>{let e=await this.profileFacade.getStats();return await this.idsRemapper.remapSuccessRatesEntities(e)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e;let n=this.ownProfile.interests.filter(o=>o.id!==t.id||o.type!==t.type||o.source!==t.source);return this.ownProfile.interests=[...n],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(n=>n.id!==t.id||n.type!==t.type||n.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setNicknamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=e,this);setNickname=e=>(this.promises.push(this.setNicknamePromise(e)),this);setNamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=e,this);setName=e=>(this.promises.push(this.setNamePromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new Ra,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),n=this.profileService.extractUpdatedProps(e,t);if(this.modified=!1,this.expireAt=0,Object.keys(n).length){let p=await this.profileHttps.updateProfile(n),d=JSON.parse(JSON.stringify(p));return this.setOwnProfile(d),this.localStorage.setOwnProfile(d),delete p.interests,p}let o=JSON.parse(JSON.stringify(this.ownProfile));return delete o.interests,o}};var Ta=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(e,t,n,o){this.idsRemapper=e,this.profileHttps=n,this.activityHttps=o,this.profileFacade=new Mt(t,n,o)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var Ea=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let n=await this.https.getCountries(e);return this.localStorage.setFootballCountries(n),n}catch(n){throw console.warn("There was a problem retrieving countries as football entities",n),n}}else return this.https.getCountries(e)}};var Yr=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(n=>{let o=!0;return t.forEach(p=>{p!=="sortOrder"&&p!=="sortField"&&(p==="countryId"?o&&=n.country.id===this[p]:p==="name"?o&&=n.name.toLocaleLowerCase().includes(this[p].toLocaleLowerCase()):p==="competitionIds"?o&&=this[p].some(d=>n.id===d):o&&=n[p].toLocaleLowerCase()===this[p].toLocaleLowerCase())}),o})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((n,o)=>this.sortOrder&&this.sortOrder==="desc"?o.name.localeCompare(n.name):n.name.localeCompare(o.name)):this.sortField==="country"?t=e.sort((n,o)=>this.sortOrder&&this.sortOrder==="desc"?o.country.name.localeCompare(n.country.name):n.country.name.localeCompare(o.country.name)):this.sortField==="scope"?e.forEach(n=>t[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((n,o)=>o.id.localeCompare(n.id))),t}};var Ca=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Yr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.competitionIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");p.competition.length===0&&(n=!0),e.competitionIds=p.competition}if(n)return[]}let o=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(o,"competition")}catch(n){throw console.warn("There was a problem browsing all of the competitions",n),n}};getCompetitionsMapWithNativeIds=async e=>{let t=new Map,n=e.length,o=new Yr({competitionIds:e,limit:n}),p=await this.getCompetitions(o);p.sort((y,g)=>y.id.localeCompare(g.id));let d=await this.idMapping.remapEntities(p,"competition");return e.forEach((y,g)=>t.set(y,d[g])),t};getCompetitions=async(e,t)=>{let n=null;if(t=t||!1,this.isBrowser){if(!this.localStorage.getCompetitionsLength()){try{n=await this.https.getCompetitions()}catch(o){throw console.warn("There was a problem retrieving all competitions",o),o}this.localStorage.setCompetitions(n)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let o=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],p=await this.getCompetitionById(o,t);return await this.idMapping.remapEntities(p,"competition")}catch(n){throw console.warn(`There was a problem browsing the following competition:${e}`,n),n}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,n),n}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var Qr=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(e){this.name=e.name?e.name:null,this.countryId=e.countryId?`${e.countryId}`:null,this.national=e.national?e.national:!1,this.gender=e.gender?e.gender:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.scope=e.scope?e.scope:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.teamIds=e.teamIds?e.teamIds:null}constructFilterUrl=()=>{let e="";return this.name&&(e=e+"&",e=e+`name=${this.name}`),this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.national&&(e=e+"&",e=e+`national=${this.national}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.teamIds&&(e=e+"&",e=e+`team_ids=${this.teamIds.join(",")}`),e}};var xa=class{general=[];predictor=[];topX=[];matchQuiz=[]};var Hi=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var Aa=class{id;enabled;requirements=new Hi};var Oa=class{id;weight;multiplier;conditions};var Ba=class{value=[new Oa]};var Gi=class{points=null;tiers=null;badges=null};var La=class{enabled=!1;conditions={list:null};actions=new Ba;rewards=new Gi};var Na=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var ki=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var $i=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Da=class{competitions=[];teams=[];markets=[]};var Vi=class{enabled=!1;fullCoverageCompetitions=null;markets=null;successRateScopes=new Da};var Ua=class{remapPredictorConfig=e=>{let t=new Vi;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t.successRateScopes=e.success_rate_scopes,t};remapTopXConfig=e=>{let t=new $i;return t.enabled=e.enabled,t.minFixtures=e.min_fixtures,t.maxFixtures=e.max_fixtures,t.competitionsWhitelist=e.competitions_whitelist,t};remapMatchQuizConfig=e=>{let t=new ki;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new La;return t.enabled=e.enabled,t.conditions.list=e.conditions.list,t.actions.value=e.actions.value,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Gi;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Na;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t.matchQuiz=e.match_quiz,t};remapBadges=e=>{let t=new xa;return t.general=e.general,t.predictor=this.remapBadgeValues(e.predictor),t.topX=this.remapBadgeValues(e.top_x),t.matchQuiz=this.remapBadgeValues(e.match_quiz),t};remapBadgeValues=e=>e.map(t=>{let n=new Aa;return n.id=t.id,n.enabled=t.enabled,n.requirements=this.remapRequirements(t.requirements),n});remapRequirements=e=>{let t=new Hi;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.entityId=e.entity_id,t.entityType=e.entity_type,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var et=class extends Me{apiSignInUrl="";featureConfigRemapper=null;constructor(e){super(e,Oe(e.environment,"client"));this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.featureConfigRemapper=new Ua}getConfig=async e=>{try{let t=await this.instance.get(`${this.apiSignInUrl}`);switch(e){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(t.data.data.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(t.data.data.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(t.data.data.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(t.data.data.loyalty)}}catch(t){throw console.warn("There was a problem fetching configuration from Client API",t),t.response}}};var Yt=class{clientHttps=null;constructor(e){this.clientHttps=new et(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:n}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(o=>this.setAvailableMarkets(o,t,n));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,n)};setAvailableMarkets=(e,t,n)=>{let o=e.context.competition?.id;return o&&this.isMatchInCoverageCompetition(o,t)?(e.availableMarkets=n.all,e):(e.availableMarkets=n.main,e)};isMatchInCoverageCompetition=(e,t)=>{let n=!1;return t.includes(e)&&(n=!0),n}};var Ga=class{footballService=null;https=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getTeamsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Qr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(e.teamIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");p.team.length===0&&(n=!0),e.teamIds=p.team}}if(n)return[];let o=await this.getTeams(e,t);return o.data=await this.idMapping.remapEntities(o.data,"team"),o}catch(n){throw console.warn("There was a problem browsing all teams",n),n}};getTeamsMapWithNativeIds=async e=>{let t=new Map,n=e.length,o=new Qr({teamIds:e,limit:n}),{data:p}=await this.getTeams(o);p.sort((y,g)=>y.id.localeCompare(g.id));let d=await this.idMapping.remapEntities(p,"team");return e.forEach((y,g)=>t.set(y,d[g])),t};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(n){throw console.warn("There was a problem retrieving all teams",n),n}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getTeamById(e,t);return await this.idMapping.remapEntities(o,"team")}catch(n){throw console.warn(`There was a problem browsing the following team:${e}`,n),n}};getTeamById=async(e,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following team: ${e}`,n),n}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,n),n}};getNextMatchForTeam=async(e,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,n),n}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,n),n}};getPrevMatchForTeam=async(e,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,n),n}}};var zr=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var Qt=class{https=null;footballService=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getPlayersIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new zr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.playerIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");p.player.length===0&&(n=!0),e.playerIds=p.player}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(n)return[]}let o=await this.getPlayers(e,t);return o.data=await this.idMapping.remapEntities(o.data,"player"),o}catch(n){throw console.warn("There was a problem browsing the players",n),n}};getPlayersWithNativeIds=async e=>{let t=e.length,n=new zr({playerIds:e,limit:t}),o=await this.getPlayers(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getPlayersWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[d]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(n){throw console.warn("There was a problem retrieving the players",n),n}};getPlayerIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),o=await this.getPlayerById(n.player[0],t);return await this.idMapping.remapEntities(o,"player")}catch(n){throw console.warn(`There was a problem browsing the following player:${e}`,n),n}};getPlayerById=async(e,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following player: ${e}`,n),n}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let o=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for player:${e}`,n),n}};getNextMatchForPlayer=async(e,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,n),n}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let o=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for player:${e}`,n),n}};getPrevMatchForPlayer=async(e,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,n),n}}};var Jr=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryIds=e.countryIds?e.countryIds:null,this.competitionIds=e.competitionIds?e.competitionIds:null,this.matchIds=e.matchIds?e.matchIds:null,this.status=e.status?e.status:null,this.teamIds=e.teamIds?e.teamIds:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&(e=e+"&",e=e+`teams=${this.teamIds.join(",")}`),this.fromDate&&(e=e+"&",e=e+`from_date=${this.fromDate}`),this.toDate&&(e=e+"&",e=e+`to_date=${this.toDate}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var zt=class{https=null;idMapping=null;footballService=null;constructor(e,t,n){this.https=t,this.idMapping=n,this.footballService=new Yt(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Jr(e),e.countryIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=o.country}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=o.competition}if(e.matchIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=o.match}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=o.team}}let n=await this.getMatches(e,t);return n.data=await this.footballService.setAvailableMarketsForMatch([...n.data]),n.data=await this.idMapping.remapEntities(n.data,"match"),n}catch(n){throw console.warn("There was a problem browsing the matches",n),n}};getMatchesWithNativeIds=async e=>{let t=e.length,n=new Jr({matchIds:e,limit:t}),o=await this.getMatches(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getMatchesWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[d]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(n){throw console.warn("There was a problem retrieving the matches",n),n}};getMatchIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),o=await this.getMatchById(n.match[0],t),p=await this.footballService.setAvailableMarketsForMatch(o);return await this.idMapping.remapEntities(p,"match")}catch(n){throw console.warn(`There was a problem browsing the following match: ${e}`,n),n}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following match: ${e}`,n),n}}};var ka=class{entities=null;query=null;scope=null;constructor(e){this.entities=e.entities?e.entities:null,this.query=e.query?e.query:null,this.scope=e.scope?e.scope:null}constructFilterUrl=()=>{let e="";return this.entities&&(e=e+"&",e=e+`entities=${this.entities.join(",")}`),this.query&&(e=e+"&",e=e+`q=${this.query}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),e}};var $a=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new ka(e),e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=o.competition}let n=await this.search(e,t);if(n.teams&&n.teams.length>0){let o=await this.idMapping.remapEntities(n.teams,"team");n.teams=o}if(n.players&&n.players.length>0){let o=await this.idMapping.remapEntities(n.players,"player");n.players=o}if(n.competitions&&n.competitions.length>0){let o=await this.idMapping.remapEntities(n.competitions,"competition");n.competitions=o}return n}catch(n){throw console.warn("There was a problem with browsing the search result",n),n}};search=async(e,t)=>{try{return await this.https.search(e,t)}catch(n){throw console.warn("There was a problem retrieving the search response",n),n}}};var qi=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,n,o){this.countriesFacade=new Ea(t,n,o),this.competitionsFacade=new Ca(t,n,o),this.teamsFacade=new Ga(e,n,o),this.playerFacade=new Qt(e,n,o),this.matchFacade=new zt(e,n,o),this.searchFacade=new $a(n,o)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getPlayersMapWithNativeIds=async e=>this.playerFacade.getPlayersMapWithNativeIds(e);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var Va=class{id="";alias="";countryCode="";assets=null;name=""};var oe=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new Va;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var qa=class{id="";country=null;gender="";assets=null;type="";name=""};var Ne=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new qa;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Wa=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Ka=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var be=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new Ka;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var Xa=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new oe,this.teamBasicRemapper=new be}fromResponse(e){try{let t=new Wa;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(n=>this.teamBasicRemapper.fromResponse(n)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Ya=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var Qa=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var za=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new Qa;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var Ja=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new oe,this.competitionRemapper=new Ne,this.playerRemapper=new za}fromResponse(e){try{let t=new Ya;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t.squad=e.squad?e.squad.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var Za=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var ja=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Wi=class{fromResponse(e){try{let t=new ja;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var eo=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new be,this.competitionRemapper=new Ne,this.scoresRemapper=new Wi}fromResponse(e){try{let t=new Za;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var to=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var io=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 ro=class{fromResponse(e){try{let t=new io;return t.corners=this.statEntityFromResponse(e.corners),t.cornersFirstHalf=this.statEntityFromResponse(e.corners_1h),t.cornersSecondHalf=this.statEntityFromResponse(e.corners_2h),t.cornersExtraTime=this.statEntityFromResponse(e.corners_et),t.crosses=this.statEntityFromResponse(e.crosses),t.crossesFirstHalf=this.statEntityFromResponse(e.crosses_1h),t.crossesSecondHalf=this.statEntityFromResponse(e.crosses_2h),t.crossesExtraTime=this.statEntityFromResponse(e.crosses_et),t.offside=this.statEntityFromResponse(e.offside),t.offsideFirstHalf=this.statEntityFromResponse(e.offside_1h),t.offsideSecondHalf=this.statEntityFromResponse(e.offside_2h),t.offsideExtraTime=this.statEntityFromResponse(e.offside_et),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.shotsOnFirstHalf=this.statEntityFromResponse(e.shots_on_1h),t.shotsOnSecondHalf=this.statEntityFromResponse(e.shots_on_2h),t.shotsOnExtraTime=this.statEntityFromResponse(e.shots_on_et),t.throwIn=this.statEntityFromResponse(e.throw_in),t.throwInFirstHalf=this.statEntityFromResponse(e.throw_in_1h),t.throwInSecondHalf=this.statEntityFromResponse(e.throw_in_2h),t.throwInExtraTime=this.statEntityFromResponse(e.throw_in_et),t.redCards=this.statEntityFromResponse(e.red_cards),t.redCardsFirstHalf=this.statEntityFromResponse(e.red_cards_1h),t.redCardsSecondHalf=this.statEntityFromResponse(e.red_cards_2h),t.redCardsExtraTime=this.statEntityFromResponse(e.red_cards_et),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.shotsOffFirstHalf=this.statEntityFromResponse(e.shots_off_1h),t.shotsOffSecondHalf=this.statEntityFromResponse(e.shots_off_2h),t.shotsOffExtraTime=this.statEntityFromResponse(e.shots_off_et),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.goalKicksFirstHalf=this.statEntityFromResponse(e.goal_kicks_1h),t.goalKicksSecondHalf=this.statEntityFromResponse(e.goal_kicks_2h),t.goalKicksExtraTime=this.statEntityFromResponse(e.goal_kicks_et),t.possession=this.statEntityFromResponse(e.possession),t.possessionFirstHalf=this.statEntityFromResponse(e.possession_1h),t.possessionSecondHalf=this.statEntityFromResponse(e.possession_2h),t.possessionExtraTime=this.statEntityFromResponse(e.possession_et),t.treatments=this.statEntityFromResponse(e.treatments),t.treatmentsFirstHalf=this.statEntityFromResponse(e.treatments_1h),t.treatmentsSecondHalf=this.statEntityFromResponse(e.treatments_2h),t.treatmentsExtraTime=this.statEntityFromResponse(e.treatments_et),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.yellowCardsFirstHalf=this.statEntityFromResponse(e.yellow_cards_1h),t.yellowCardsSecondHalf=this.statEntityFromResponse(e.yellow_cards_2h),t.yellowCardsExtraTime=this.statEntityFromResponse(e.yellow_cards_et),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.shotsBlockedFirstHalf=this.statEntityFromResponse(e.shots_blocked_1h),t.shotsBlockedSecondHalf=this.statEntityFromResponse(e.shots_blocked_2h),t.shotsBlockedExtraTime=this.statEntityFromResponse(e.shots_blocked_et),t.substitutions=this.statEntityFromResponse(e.substitutions),t.substitutionsFirstHalf=this.statEntityFromResponse(e.substitutions_1h),t.substitutionsSecondHalf=this.statEntityFromResponse(e.substitutions_2h),t.substitutionsExtraTime=this.statEntityFromResponse(e.substitutions_et),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.counterAttacksFirstHalf=this.statEntityFromResponse(e.counter_attacks_1h),t.counterAttacksSecondHalf=this.statEntityFromResponse(e.counter_attacks_2h),t.counterAttacksExtraTime=this.statEntityFromResponse(e.counter_attacks_et),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t.foulsCommittedFirstHalf=this.statEntityFromResponse(e.fouls_committed_1h),t.foulsCommittedSecondHalf=this.statEntityFromResponse(e.fouls_committed_2h),t.foulsCommittedExtraTime=this.statEntityFromResponse(e.fouls_committed_et),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Ki=class{homeTeam={players:[]};awayTeam={players:[]}};var no=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Xi=class{fromResponse(e){try{let t=new no;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var ao=class{playerRemapper=null;constructor(){this.playerRemapper=new Xi}fromResponse(e){try{let t=new Ki;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var oo=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var so=class{playerRemapper=null;constructor(){this.playerRemapper=new Xi}fromResponse(e){try{let t=new oo;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var lo=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new be,this.competitionsMapper=new Ne,this.lineupsMapper=new ao,this.scoresMapper=new Wi,this.statsMapper=new ro,this.timelineMapper=new so}fromResponse(e){try{let t=new to;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(n=>this.timelineMapper.fromResponse(n)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Ki,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var po=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var co=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new po;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var uo=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var Yi=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new oe,this.teamRemapper=new be}fromResponse(e){try{let t=new uo;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var mo=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var fo=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new oe,this.teamRemapper=new be,this.competitionRemapper=new Ne}fromResponse(e){try{let t=new mo;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var ho=class{teams=null;players=null;competitions=null};var go=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new be,this.playerRemapper=new Yi,this.competitionremapper=new Ne}fromResponse(e){try{let t=new ho;return t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.players=e.players?e.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.competitions=e.competitions?e.competitions.map(n=>this.competitionremapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var Qi=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var Jt=class{pagination=new Qi};var zi=class{meta=new Jt;data=[]};var yo=class{remapMetaProp=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var bt=class extends Me{apiSignInUrl="";clientId="";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(e){super(e,Oe(e.environment,"football"));this.clientId=e.clientId,this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.countryRemapper=new oe,this.competitionBasicRemapper=new Ne,this.competitionFullRemapper=new Xa,this.teamBasicRemapper=new be,this.teamFullRemapper=new Ja,this.matchBasicRemapper=new eo,this.matchFullRemapper=new lo,this.playerBasicRemapper=new Yi,this.playerFullRemapper=new fo,this.topPlayerRemapper=new co,this.searchRemapper=new go,this.footballMetaRemapper=new yo}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(t+=`&disable_cache=${n}`);let o=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(o.data.data)}catch(t){throw console.warn("There was a problem with the football countries request",t),t}};getCompetitions=async(e,t)=>{try{let n={},o=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let p=[],d=ea(e.competitionIds);for(let g of d){e.competitionIds=g;let v=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(v+=`&disable_cache=${o}`),n=await this.instance.get(v),p.push(n.data.data.map(w=>this.competitionBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=`/competitions${this.apiSignInUrl}`;return e&&(p+=`${e.constructFilterUrl()}`),t&&(p+=`&disable_cache=${o}`),n=await this.instance.get(p),n.data.data.map(d=>this.competitionBasicRemapper.fromResponse(d))}}catch(n){throw console.warn("There was a problem with getCompetitions request",n),n.response}};getCompetitionById=async(e,t)=>{try{let n=`/competitions/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.competitionFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getCompetitionById request",n),n.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.competitionBasicRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopCompetitions request",t),t.response}};getTeams=async(e,t)=>{try{let n={},o=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let p=[],d=ea(e.teamIds);for(let g of d){e.teamIds=g;let v=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(v+=`disable_cache=${o}`),n=await this.instance.get(v),p.push(n.data.data.map(w=>this.teamBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=new zi,d=`/teams${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(y=>this.teamBasicRemapper.fromResponse(y)),p}}catch(n){throw console.warn("There was a problem with getTeams request",n),n.response}};getTeamById=async(e,t)=>{try{let n=`/teams/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`disable_cache=${o}`);let p=await this.instance.get(n);return this.teamFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getTeamById request",n),n.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();e&&(t+=`$disable_cache=${n}`);let o=await this.instance.get(t);return o.data.data?o.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)):[]}catch(t){throw console.warn("There was a problem with getTopTeams request",t),t.response}};getNextMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/next-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForTeam request",n),n.response}};getPrevMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/previous-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForTeam request",n),n.response}};getPlayers=async(e,t)=>{try{let n={},o=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let p=[],d=ea(e.playerIds);for(let g of d){e.playerIds=g;let v=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(v+=`&disable_cache=${o}`),n=await this.instance.get(v),p.push(n.data.data.map(w=>this.teamBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=new zi,d=`/players${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(y=>this.playerBasicRemapper.fromResponse(y)),p}}catch(n){throw console.warn("There was a problem with getPlayers request",n),n.response}};getPlayerById=async(e,t)=>{try{let n=`/players/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.playerFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPlayerById request",n),n.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.topPlayerRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopPlayers request",t),t.response}};getNextMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/next-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForPlayer request",n),n.response}};getPrevMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/previous-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForPlayer request",n),n.response}};getMatchById=async(e,t)=>{try{let n=`/matches/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getMatchById request",n),n.response}};getMatches=async(e,t)=>{try{let n=new zi,o=`/matches${this.apiSignInUrl}`,p=Date.now();e&&(o+=`${e.constructFilterUrl()}`),t&&(o+=`&disable_cache=${p}`);let d=await this.instance.get(o);return n.meta=this.footballMetaRemapper.remapMetaProp(d.data.meta),n.data=d.data.data.map(y=>this.matchBasicRemapper.fromResponse(y)),n}catch(n){throw console.warn("There was a problem with getMatches request",n),n.response}};search=async(e,t)=>{try{let n=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.searchRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with search request",n),n.response}}};var Pe=(N=>(N.FT_1X2="FT_1X2",N.HT_1X2="HT_1X2",N.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",N.DOUBLE_CHANCE="DOUBLE_CHANCE",N.HT_FT="HT_FT",N.PLAYER_SCORE="PLAYER_SCORE",N.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",N.PLAYER_RED_CARD="PLAYER_RED_CARD",N.RED_CARD_MATCH="RED_CARD_MATCH",N.PENALTY_MATCH="PENALTY_MATCH",N.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",N.CORNERS_MATCH="CORNERS_MATCH",N.CORRECT_SCORE="CORRECT_SCORE",N.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",N.CORRECT_SCORE_HT="CORRECT_SCORE_HT",N.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",N.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",N.OVER_GOALS_0_5="OVER_GOALS_0_5",N.OVER_GOALS_1_5="OVER_GOALS_1_5",N.OVER_GOALS_2_5="OVER_GOALS_2_5",N.OVER_GOALS_3_5="OVER_GOALS_3_5",N.OVER_GOALS_4_5="OVER_GOALS_4_5",N.OVER_GOALS_5_5="OVER_GOALS_5_5",N.OVER_GOALS_6_5="OVER_GOALS_6_5",N.OVER_CORNERS_6_5="OVER_CORNERS_6_5",N.OVER_CORNERS_7_5="OVER_CORNERS_7_5",N.OVER_CORNERS_8_5="OVER_CORNERS_8_5",N.OVER_CORNERS_9_5="OVER_CORNERS_9_5",N.OVER_CORNERS_10_5="OVER_CORNERS_10_5",N.OVER_CORNERS_11_5="OVER_CORNERS_11_5",N.OVER_CORNERS_12_5="OVER_CORNERS_12_5",N.OVER_CORNERS_13_5="OVER_CORNERS_13_5",N))(Pe||{}),Td=["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"],Ed=["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"],wt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Cd=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],Zr="PLAYER_SCORE_FIRST_GOAL";var Mo=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var bo=class{profileId;tier;points;successRates=new Mo};var wo=class{successRatePercent;model=null};var vo=class{id=null;label=null};var _o=class{type=null;id=null;label=null};var Ji=class{content=new _o;tags=[];campaign=new vo};var Zi=class{id=null;profileId=null;action=null;context=new Ji;points=0};var Io=class{totalItems=0};var Po=class{meta=new Io;data=[new Zi]};var Ro=class{remapSingleResponse=e=>{let t=new Zi;return t.id=e.id,t.profileId=e.profile_id,t.action=e.action,t.context.content=e.context.content??t.context.content,t.context.tags=e.context.tags,t.context.campaign=e.context.campaign??t.context.campaign,t.points=e.points,t};remapActivitiesResponse=e=>{let t=new Po;return t.meta.totalItems=e.meta.total_items,t.data=e.data.map(n=>this.remapSingleResponse(n)),t};remapStatsReponse=e=>{let t=new bo;return t.profileId=e.profile_id,t.tier=e.tier,t.points=e.points,t.successRates.overallPercent=e.success_rates.overall_percent,t.successRates.byFootballCompetition=this.constructNewRecord(e.success_rates.by_competition),t.successRates.byFootballTeam=this.constructNewRecord(e.success_rates.by_team),t.successRates.byFootballMarket=this.constructNewRecord(e.success_rates.by_market),t};constructNewRecord=e=>{let t;if(Object.entries(e).length)Object.entries(e).forEach(([n,o])=>{t={...t,[n]:this.remapSuccessRatePercent(o)},Pe[n]&&delete t[n].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new wo;return t.successRatePercent=e.success_rate_percent,t}};var ji=class extends Me{activityRemapper=null;apiSignInUrl=null;constructor(e){super(e,Oe(e.environment,"loyalty"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.activityRemapper=new Ro}createActivity=async e=>{try{let t=`/activities${this.apiSignInUrl}`,n=await this.instanceAuth.post(t,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(n.data)}catch(t){throw console.warn("There was a problem with creating activity for user",t),t}};deleteActivity=async e=>{try{let t=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(t),!0}catch(t){throw console.warn(`There was a problem deleting the following activity: ${e}`,t),t.response}};getOwnActivities=async(e,t)=>{try{let n=`/activities${this.apiSignInUrl}`,o=Date.now();e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`disable_cache=${o}`);let p=await this.instanceAuth.get(n);return this.activityRemapper.remapActivitiesResponse(p.data)}catch(n){throw console.warn("There was a problem with fetching own activities",n),n}};getActivitiesForUser=async(e,t,n)=>{try{let o=`/users/${e}/activities${this.apiSignInUrl}`,p=Date.now();t&&(o+=`${t.constructFilterUrl()}`),n&&(o+=`disable_cache=${p}`);let d=await this.instance.get(o);return this.activityRemapper.remapActivitiesResponse(d.data)}catch(o){throw console.warn(`There was a problem with fetching activities for user ${e}`,o),o}};getStats=async(e,t)=>{try{let n="",o=null;return e?(n+=de(t)?`/users/${e}/statistics${this.apiSignInUrl}${fe()}`:`/users/${e}/statistics${this.apiSignInUrl}`,o=await this.instance.get(n)):(n+=`/statistics${this.apiSignInUrl}`,o=await this.instanceAuth.get(n)),this.activityRemapper.remapStatsReponse(o.data.data)}catch(n){throw console.warn("There was a problem fetching profile`s statistics:",n),n.response}}};var Fo=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(e,t,n){this.idMapping=n,this.idSchema=e.idSchema,this.footballFacade=t}remapSuccessRatesEntities=async e=>{let{successRates:t}=e,n={competition:this.getIdsKeys(t.byFootballCompetition),team:this.getIdsKeys(t.byFootballTeam)};if(Object.values(n.competition).length){let o=e.successRates.byFootballCompetition;e.successRates.byFootballCompetition=await this.setModels(o,n.competition,"competition")}if(Object.values(n.team).length){let o=e.successRates.byFootballTeam;e.successRates.byFootballTeam=await this.setModels(o,n.team,"team")}return e};setModels=async(e,t,n)=>{let o=null,p;switch(t=kr(t),n){case"competition":o=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":o=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(d=>{let y=o.get(d);p={...p,[y.id]:e[d]},p[y.id].model=y}),p};getIdsKeys=e=>{let t=JSON.parse(JSON.stringify(e));return Object.keys(t)};remapInterestsToIdSchema=async e=>{if(this.idSchema!==this.native)if(e&&e.length>0){let t={},n={};e.forEach(d=>{t.hasOwnProperty(d.type)||(t[d.type]=[],n[d.type]=[]),t[d.type].push(d.id),n[d.type].push(d)});let o=await this.remapIdsObj(t,this.native,this.idSchema),p=[];for(let[d,y]of Object.entries(n))y.forEach((g,v)=>{g.id=o[d][v],p.push(g)});return p}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native){let t={},{id:n,type:o}=e;t[o]=[n];let p=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=p[o][0],e}return e};inquiryCustomInterests=e=>{let t=[];return e&&e.length>0&&(t=e.filter(n=>n.source.toLocaleUpperCase()==="CUSTOM")),t};remapInterests=async e=>{let t=this.inquiryCustomInterests(e);if(t&&t.length>0){let n=e.filter(p=>p.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(n);return t.forEach(p=>o.push(p)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0){let n=this.inquiryCustomInterests(e);t.push(n);let o=e.filter(v=>v.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:p,teamsMap:d,playersMap:y}=await this.getInterestsEntitiesMap(o),g=o.map(v=>{let w=null;if(v.type==="competition")return w=p.get(v.id),w&&(v.id=w.id),v.model=w,v;if(v.type==="team")return w=d.get(v.id),w&&(v.id=w.id),v.model=w,v;if(v.type==="player")return y?(v.model=y[v.id],v.id=y[v.id].id):v.model=w,v});return t.push(g),t.flat()}return t};getInterestsEntitiesMap=async e=>{let t=[],n=[],o=[],p=new Map,d=new Map,y=null;if(e.forEach(g=>{g.type==="competition"?t.push(g.id):g.type==="team"?n.push(g.id):g.type==="player"&&o.push(g.id)}),t.length){let g=kr(t);p=await this.footballFacade.getCompetitionsMapWithNativeIds(g)}if(n.length){let g=kr(n);d=await this.footballFacade.getTeamsMapWithNativeIds(g)}if(o.length){let g=kr(o);y=await this.footballFacade.getPlayersMapWithNativeIds(g)}return{competitionsMap:p,teamsMap:d,playersMap:y}};remapIdsObj=async(e,t,n)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,n)};var So=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new ae(e),this.profileOperations=new Fo(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);remapInterests=async e=>await this.profileOperations.remapInterests(e);showFullInterests=async e=>await this.profileOperations.showFullInterests(e)};var er=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Ui(e),this.activityHttps=new ji(e),this.footballHttps=new bt(e),this.idMapping=new ae(e),this.localStorage=new yt(e),this.footballFacade=new qi(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new Mt(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new So(e,this.footballFacade),this.ownProfileBuilder=new Sa(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade),this.profileBuilder=new Ta(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var To=class{validate=e=>{let t=this.validateField(e.lang),n=this.generateMessage(t);return{validation:t,message:n}};validateField=e=>{let t=["bg","ro","en"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: en"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: en"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Eo=class{validate(e){let t=this.validateField(e.environment),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["dev","staging","prod"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Co=class{validate(e){let t=this.validateField(e.apiKey),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use Fans United JS SDK"),e==="valid"&&(n=null),{text:t,type:n}}};var xo=class{validate(e){let t=this.validateField(e.idSchema),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var fi=class{getIdToken=null;logout=null};var ir=class{text=null;type=null};var Ao=class{validation=null;message=new ir;getIdToken={validation:null,message:new ir};logout={validation:null,message:new ir}};var Oo=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new fi),n=new Ao;if(e){let p=Object.keys(e).filter(d=>!t.includes(d));p.length>0?(n.validation="invalid",n.message.type="warning",n.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${p.join(",")}`):n.validation="valid"}else n.validation="missing",n.message.type="error",n.message.text="The field authProvider must be provided to use this SDK";return n};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new fi).forEach(o=>{e[o]?t[o].validation="valid":t[o].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let n=e[t];n.validation==="missing"&&(n.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,n.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var en=class{validation;message};var Bo=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new en,logout:new en};isValid=!1};var Lo=class{validate(e){let t=this.validateField(e.clientId),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field clientId must be provided to use Fans United JS SDK"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var No=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Bo,n={apiKey:new Co,environment:new Eo,idSchema:new xo,clientId:new Lo,lang:new To,authProvider:new Oo};for(let[o,p]of Object.entries(t))o!=="isValid"&&(p=n[o].validate(e));return Object.keys(n).forEach(o=>{t[o]=n[o].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[n,o]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&o.message.type==="error")return t=!1,t;if(n!=="isValid"&&o.message.type==="warning")return t=!0,t}else if(o.message.type==="error")return t=!1,t;return t}};var Do=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new bt(e),this.idMapping=new ae(e),this.localStorage=new yt(e),this.footballFacade=new qi(e,this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var Uo=class{value=null;playerId=null;playerModel=null};var rr=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Uo;result=null};var Ho=class{value=!1;playerId=null};var tt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n,o){this.matchId=e,this.market=t,this.prediction=new Ho,this.prediction.value=n,this.prediction.playerId=o}};var nr=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var Go=class{value=null};var Zt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new Go,this.prediction.value=n}};var it=class{value=!1};var ar=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new it,this.prediction.value=n}};var or=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new it,this.prediction.value=n}};var ko=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,n){this.matchFacade=e,this.playerFacade=t,this.predictorService=n}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof tt)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof ar||e instanceof or)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof Zt){t.market=e.market;let n=e.prediction.value.split(":");t.goals_home=Number(n[0]),t.goals_away=Number(n[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{let t="OWN_GOAL",n=[],o=[],p=null,d=[];e.length>1&&e.sort((g,v)=>g.match_id.localeCompare(v.match_id));for(let g of e)n.push(g.match_id),g.player_id&&!o.includes(g.player_id)&&o.push(g.player_id);let y=await this.matchFacade.getMatchesMapWithNativeIds(n);o.sort((g,v)=>g.localeCompare(v)),o&&o.length>0&&!o.includes(t)&&(p=await this.playerFacade.getPlayersMapWithNativeIds(o));for(let g of e){let v=new rr;g.target?v.market=this.predictorService.convertMarketForResponseModel(g.market,g.target):v.market=g.market,v.matchId=y[g.match_id].id,v.matchType=g.match_type,v.matchModel=y?y[g.match_id]:null,delete v.matchModel.availableMarkets,g.goals_home!==void 0&&g.goals_away!==void 0?v.prediction.value=g.goals_home.toString()+":"+g.goals_away.toString():v.prediction.value=g.prediction,v.prediction.playerId=g.player_id?g.player_id:null,v.prediction.playerId&&v.prediction.playerId!==t&&(v.prediction.playerModel=p[g.player_id],v.prediction.playerId=p[g.player_id].id),v.result=this.remapResult(g.result),d.push(v)}return d};remapResult=e=>{let t=new nr;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t}};var jt=class{goldenGoal=null};var tn=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new jt;points=null;createdAt=null;updatedAt=null};var j=class{no=0;yes=0};var sr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new j;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new j;penaltyMatch=new j;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new j;overOnePointFiveGoals=new j;overTwoPointFiveGoals=new j;overThreePointFiveGoals=new j;overFourPointFiveGoals=new j;overFivePointFiveGoals=new j;overSixPointFiveGoals=new j;overSixPointFiveCorners=new j;overSevenPointFiveCorners=new j;overEightPointFiveCorners=new j;overNinePointFiveCorners=new j;overTenPointFiveCorners=new j;overElevenPointFiveCorners=new j;overTwelvePointFiveCorners=new j;overThirteenPointFiveCorners=new j};var vt=class{timeTiebreaker=!1};var hi=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null};var gi=class{userId=null;points=null;results=[];tiebreaker=null};var $o=(p=>(p.ACTIVE="ACTIVE",p.WON="WON",p.LOST="LOST",p.PARTIALLY_WON="PARTIALLY_WON",p.CANCELED="CANCELED",p))($o||{}),Ep=["WON","LOST","PARTIALLY_WON","CANCELED"];var Re=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.matchIds=e.matchIds?e.matchIds:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values($o).some(n=>this.status.includes(n))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),this.matchIds&&(e+="&",e+=`match_ids=${this.matchIds.join(",")}`),e}};var lr=class{limit;startAfter;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null}constructMainFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),e}};var rn=(d=>(d.OPEN="OPEN",d.LIVE="LIVE",d.PENDING="PENDING",d.CANCELED="CANCELED",d.CLOSED="CLOSED",d.SETTLED="SETTLED",d))(rn||{});var rt=class extends lr{status=null;type=null;gameIds=null;sortOrder=null;constructor(e){super(e);this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFiltersUrl=()=>{let e=super.constructMainFiltersUrl();return this.status&&Object.values(rn).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),e}};var pr=class{main=null;cover=null;mobile=null};var yi=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;images=new pr;createdAt=null;updatedAt=null};var Nt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;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 Cp={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
22
22
|
${Fp.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:
|
|
23
|
-
${Fp.PREDICTOR_USER_RELATED_OPERATION}`},xd=(s,e)=>`The prediction '${s}' is invalid for market '${e}'. 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`,Vo=s=>`The market '${s}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Ad=s=>`The market '${s}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Od=s=>`The field/s '${s.length>1?s.join(", "):s[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Bd=(s,e)=>`The following field/s is/are missing from ${s}: '${e.length>1?e.join(", "):e[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Ld=(s,e)=>`The field ${s} has incorrect type. The correct type is ${e}`;var _t=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new bt(e),this.idMapping=t,this.matchFacade=new zt(e,this.footballHttps,t),this.playerFacade=new Qt(e,this.footballHttps,t)}remapMatchIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"match","native")).match;remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},n=Xt(e),p=(await this.idMapping.getEntityIdsBySchemaId(n,"player","native")).player;return n.forEach((d,y)=>t[d]=p[y]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[n,o]of Object.entries(e))if(t.includes(n))for(let p of Object.keys(o)){let d={player:[p]},g=(await this.idMapping.idMappingFacade.getEntitiesByIds(d,"native",this.idMapping.idSchema)).player[0];o[g]=o[p],delete o[p]}return e};convertMarket=e=>{let t=Object.keys(new sr),n=Object.values(Pe);for(let o=0;o<n.length;o++)e===n[o]&&(e=t[o]);return e};convertMarketForResponseModel=(e,t)=>{let n=t.toString();return e+"_"+n};getMarketSummary=(e,t,n)=>{let o=this.convertMarket(t),p={};if(p.matchId=e.matchId,p.matchType=e.matchType,Object.keys(e.predictions).includes(o))p[o]=e.predictions[o];else throw new Error("You have passed invalid market");return wt.includes(t)&&n?(p[o][n]||(p[o][n]=new j),p[o][n]):p};remapCompetitionsFromConfig=async e=>{if(e instanceof Vi){let t={competition:e.fullCoverageCompetitions},n={competition:e.successRateScopes.competitions},o={team:e.successRateScopes.teams},p=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema),d=await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",this.idMapping.idSchema),y=await this.idMapping.idMappingFacade.getEntitiesByIds(o,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=p.competition,e.successRateScopes.competitions=d.competition,e.successRateScopes.teams=y.team,e}if(e instanceof $i||e instanceof ki){let t={competition:e.competitionsWhitelist},n=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.competitionsWhitelist=n.competition,e}};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let t=[],n=[];return e.data.forEach(o=>{o instanceof yi||o instanceof hi||o instanceof Nt?(o.fixtures.forEach(p=>t.push(p.matchId)),o instanceof Nt&&o.fixtures.forEach(p=>{p.prediction.playerId&&n.push(p.prediction.playerId)})):o instanceof gi&&o.results.forEach(p=>t.push(p.matchId))}),await this.refactorResponseArrModel(e,t,n)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,n)=>{let o=[],p=await this.matchFacade.getMatchesMapWithNativeIds(t),d={};return n.length>0&&(d=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.data.forEach(y=>{y instanceof yi||y instanceof hi||y instanceof Nt?(y.fixtures.forEach(g=>{g.matchModel=p[g.matchId],delete g.matchModel.availableMarkets,g.matchId=g.matchModel.id,y instanceof Nt&&g.prediction.playerId&&(g.prediction.playerModel=d[g.prediction.playerId],g.prediction.playerId=d[g.prediction.playerId].id)}),o.push(y)):y instanceof gi&&(y.results.forEach(g=>{g.matchModel=p[g.matchId],delete g.matchModel.availableMarkets,g.matchId=g.matchModel.id}),o.push(y))}),e.data=o,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(o=>t.push(o.matchId));let n=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(o=>{o.matchModel=n[o.matchId],delete o.matchModel.availableMarkets,o.matchId=n[o.matchId].id}),e};getCurrentGameId=e=>{let t=new Date;if(e.data.length>1){let n=[];return e.data.forEach(p=>n.push(p.predictionsCutoff)),e.data.sort((p,d)=>{let[y,g]=[p.predictionsCutoff,d.predictionsCutoff].map(v=>Math.abs(new Date(v)-t));return y-g})[0].id}else return e.data[0].id};initGameTypePredictions=(e,t)=>{let n={type:e,limit:null,startAfter:null};return t&&(n={...n,limit:t.limit,startAfter:t.startAfter}),n=new Re(n),n};initGameFilters=(e,t,n)=>{if(t&&n)return t.type=e,t.gameIds=n,t=new rt(t),t;if(t&&!n)return t.type=e,t=new rt(t),t;if(!t&&n){let o={type:e,gameIds:n};return o=new rt(o),o}else{let o={type:e};return o=new rt(o),o}};addPredictionProp=async(e,t)=>(t.data.forEach(n=>{e.data.forEach(o=>{n.id===o.game_instance_id&&(n.predictionId=o.id,n.outcome=o.status,n.fixtures.forEach((p,d)=>{o.fixtures[d].goals_home!==void 0&&o.fixtures[d].goals_away!==void 0?p.prediction.value=o.fixtures[d].goals_home+":"+o.fixtures[d].goals_away:p.prediction.value=o.fixtures[d].prediction,o.fixtures[d].player_id?p.prediction.playerId=o.fixtures[d].player_id:o.fixtures[d].target&&(p.prediction.target=o.fixtures[d].target),p.prediction.result=this.remapResult(o.fixtures[d].result)}),n.predictionsMadeAt=o.created_at,n.points=o.points)})}),t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new nr;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t};areIdsExceeded=e=>{let t=10;return e.length>t};initPredictionsFilters=(e,t,n)=>{switch(t){case"user":e&&(e=new Re(e));break;case"current":if(e)this.deleteUnexpectedProperties(e),e.status=["ACTIVE"],e=new Re(e);else{let o={status:["ACTIVE"]};e=new Re(o)}break;case"past":if(e)this.deleteUnexpectedProperties(e),e.status=Ep,e=new Re(e);else{let o={status:Ep};e=new Re(o)}break;case"matches":if(e)this.deleteUnexpectedProperties(e),e.matchIds=n,e=new Re(e);else{let o={matchIds:n};e=new Re(o)}break}return e};completeGameMarketResults=async(e,t)=>{switch(t){case"MATCH_QUIZ":let n={},o=e.results[0].matchId,p=e.results.map(v=>wt.includes(v.market)&&!v.result.includes("OWN_GOAL")?[...v.result]:[]).flat(),d=await this.matchFacade.getMatchesMapWithNativeIds([o]);return p.length&&(n=await this.playerFacade.getPlayersMapWithNativeIds(p)),e.results=e.results.map(v=>{if(v.matchModel=d[v.matchId],v.playerModels&&Object.keys(n).length&&v.result.forEach(S=>{let q=n[S];v.playerModels.push(q)}),this.idMapping.idSchema!=="native"&&(v.matchId=d[v.matchId].id,v.playerModels&&Object.keys(n).length)){let w=v.result;v.result=w.map(S=>n[S].id)}return v}),e;case"TOP_X":let y=e.results.map(v=>v.matchId),g=await this.matchFacade.getMatchesMapWithNativeIds(y);if(e.results=e.results.map(v=>(v.matchModel=g[v.matchId],this.idMapping.idSchema!=="native"&&(v.matchId=g[v.matchId].id),v)),e.tieBreakers.goldenGoals.length){let v=e.tieBreakers.goldenGoals.map(S=>S.playerId),w=await this.playerFacade.getPlayersMapWithNativeIds(v);e.tieBreakers.goldenGoals=e.tieBreakers.goldenGoals.map(S=>(S.matchModel=g[S.matchId],S.playerModel=w[S.playerId],this.idMapping.idSchema!=="native"&&(S.matchId=g[S.matchId].id,S.playerId=w[S.playerId].id),S))}return e}};deleteUnexpectedProperties=e=>(e.status&&(console.warn(Cp.UNEXPECTED_STATUS_PROP),delete e.status),e.type&&(console.warn(Cp.UNEXPECTED_TYPE_PROP),delete e.type),e)};var cr=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new Zt(t.matchId,t.market,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var ur=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new bt(e),this.matchFacade=new zt(e,this.footballHttps,t),this.playerFacade=new Qt(e,this.footballHttps,t),this.predictorService=new _t(e,t),this.fixturesRemapper=new ko(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(n=>this.fixturesRemapper.remapFixturesRequest(n)),e instanceof cr&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{if(e.length){let t=[],n=[],o={},p=[];e.forEach(y=>{y.fixtures.forEach(g=>{t.push(g.match_id),g.player_id&&n.push(g.player_id)})});let d=await this.matchFacade.getMatchesMapWithNativeIds(t);return n.length>0&&(o=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.forEach(y=>{let g=new tn,v=[];g.id=y.id,g.gameInstanceId=y.game_instance_id,g.gameType=y.game_type,g.wager=y.wager,g.totalFixtures=y.total_fixtures,g.settledFixtures=y.settled_fixtures,g.userId=y.user_id,y.fixtures.forEach(w=>{let S=new rr;w.target?S.market=this.predictorService.convertMarketForResponseModel(w.market,w.target):S.market=w.market,S.matchId=d[w.match_id].id,S.matchType=w.match_type,S.matchModel=d[w.match_id],delete S.matchModel.availableMarkets,w.goals_home!==void 0&&w.goals_away!==void 0?S.prediction.value=w.goals_home.toString()+":"+w.goals_away.toString():S.prediction.value=w.prediction,S.prediction.playerId=w.player_id?w.player_id:null,S.prediction.playerId&&(S.prediction.playerModel=o[S.prediction.playerId],S.prediction.playerId=o[S.prediction.playerId].id),S.result=this.fixturesRemapper.remapResult(w.result),v.push(S)}),g.fixtures=v,g.status=y.status,y.tiebreaker?g.tiebreaker.goldenGoal=y.tiebreaker.golden_goal:g.tiebreaker=null,g.points=y.points,g.createdAt=y.created_at,g.updatedAt=y.updated_at,p.push(g)}),p}return e};remapResponseObjBody=async e=>{let t=new tn;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new sr;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS_0_5,t.overOnePointFiveGoals=e.OVER_GOALS_1_5,t.overTwoPointFiveGoals=e.OVER_GOALS_2_5,t.overThreePointFiveGoals=e.OVER_GOALS_3_5,t.overFourPointFiveGoals=e.OVER_GOALS_4_5,t.overFivePointFiveGoals=e.OVER_GOALS_5_5,t.overSixPointFiveGoals=e.OVER_GOALS_6_5,t.overSixPointFiveCorners=e.OVER_CORNERS_6_5,t.overSevenPointFiveCorners=e.OVER_CORNERS_7_5,t.overEightPointFiveCorners=e.OVER_CORNERS_8_5,t.overNinePointFiveCorners=e.OVER_CORNERS_9_5,t.overTenPointFiveCorners=e.OVER_CORNERS_10_5,t.overElevenPointFiveCorners=e.OVER_CORNERS_11_5,t.overTwelvePointFiveCorners=e.OVER_CORNERS_12_5,t.overThirteenPointFiveCorners=e.OVER_CORNERS_13_5,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.correctScoreHalfTime=e.CORRECT_SCORE_HT,t.correctScoreAdvanced=e.CORRECT_SCORE_ADVANCED,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var qo=class{matchId=null;matchType=null;predictions=null};var Wo=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new ur(e,t)}remapResponse=e=>{let t=new qo;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var Ko=class{matchId=null;matchType=null;market=null;matchModel=null};var Xo=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Yo=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Xo};var Qo=class{value=null;result=null};var zo=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Qo};var Jo=class{matchId=null;matchModel=null;outcome=null};var Zo=class{gameId=null;results=null;tieBreakers=null};var jo=class{entityId=null;entityType=null};var es=class{remapPaginatedGames=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapGamesListResponse(n)),t};remapGamesListResponse=e=>{let t=new yi;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.scheduleOpenAt=e.schedule_open_at,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(n=>this.remapFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new Ko;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserTopXEditions=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapUserTopXEditionsResponse(n)),t};remapUserTopXEditionsResponse=e=>{let t=new hi;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(n=>this.remapTopXFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new zo;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserMathQuizEditions=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapUserMatchQuizEditionsResponse(n)),t};remapUserMatchQuizEditionsResponse=e=>{let t=new Nt;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(n=>this.remapMatchQuizFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new Yo;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedGameResults=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapGameResults(n)),t};remapGameResults=e=>{let t=new gi;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(n=>this.remapResults(n)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapGameMarketsResults=e=>{let t=new Zo;return t.gameId=e.game_id,t.results=this.remapMarketsResults(e.results),t.tieBreakers=e.tie_breakers?this.remapTieBreakers(e.tie_breakers):null,t};remapTieBreakers=e=>{let t={goldenGoals:[]};return t.goldenGoals=e.golden_goals.map(n=>({minute:n.minute,matchId:n.match_id,matchModel:null,playerId:n.player_id,playerModel:null,goalType:n.goal_type})),t};remapMarketsResults=e=>{let t=[];return e.forEach(n=>{let o={matchId:n.match_id,market:n.market,result:this.remapMarketResult(n.market,n.result),matchModel:null,playerModels:[]};t.push(this.deleteUnusefulField(o))}),t};remapMarketResult=(e,t)=>{if(Cd.includes(e))return t[0];if(wt.includes(e))return t;if(t[0]==="true")return!0;if(t[0]==="false")return!1};deleteUnusefulField=e=>((!wt.includes(e.market)||this.isPlayerMarketWithNoResult(e.market,e.result))&&delete e.playerModels,e);isPlayerMarketWithNoResult=(e,t)=>wt.includes(e)&&t.length===0;remapResults=e=>{let t=new Jo;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new jt;return t.goldenGoal=e.golden_goal,t};remapTimeTiebreaker=e=>{let t=new vt;return t.timeTiebreaker=e,t};remapRelated=e=>e.map(t=>{let n=new jo;return n.entityId=t.entity_id,n.entityType=t.entity_type,n})};var ts=class{remapMetaData=e=>{let t=new Bi;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var ei=class extends Me{apiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){super(e,Oe(e.environment,"predictor"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new ur(e,t),this.matchSummaryRemapper=new Wo(e,t),this.gamesRemapper=new es,this.metaRemapper=new ts}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),n=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(n.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async(e,t)=>{let n=de(t)?`/predictions/summary/${e}${this.apiSignInUrl}${fe()}`:`/predictions/summary/${e}${this.apiSignInUrl}`;try{let o=await this.instance.get(n);return this.matchSummaryRemapper.remapResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching predictions for match: ${e} `,o),o.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=new re,n=`/predictions${this.apiSignInUrl}`;e&&(n+=`${e.constructFiltersUrl()}`);let o=await this.instanceAuth.get(n);return t.meta=this.metaRemapper.remapMetaData(o.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(o.data.data),t}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t,n)=>{try{let o=new re,p=de(t)?`/predictions/users/${e}${this.apiSignInUrl}${fe()}`:`/predictions/users/${e}${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return o.meta=this.metaRemapper.remapMetaData(d.data.meta),o.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),o}catch(o){throw console.warn(`There was a problem fetching predictions for user: ${e}`,o),o.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data}catch(n){throw console.warn(`There was a problem fetching predictions for user: ${e}`,n),n.response}};getGames=async(e,t)=>{try{let n=de(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${fe()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,o=await this.instance.get(n);return this.gamesRemapper.remapPaginatedGames(o.data)}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameById=async(e,t)=>{try{let n=de(t)?`/games/${e}${this.apiSignInUrl}${fe()}`:`/games/${e}${this.apiSignInUrl}`,o=await this.instance.get(n);return this.gamesRemapper.remapGamesListResponse(o.data)}catch(n){throw console.warn(`There was a problem fetching the following game: ${e}`,n),n.response}};getGamePredictions=async(e,t,n)=>{try{let o=new re,p=de(t)?`/games/${e}/predictions${this.apiSignInUrl}${fe()}`:`/games/${e}/predictions${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return o.meta=this.metaRemapper.remapMetaData(d.data.meta),o.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),o}catch(o){throw console.warn(`There was a problem fetching the predictions for game: ${e}`,o),o.response}};getUserGameEditions=async(e,t)=>{try{let n=null,o=de(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${fe()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,p=await this.instance.get(o);return p.data.data.forEach(d=>{d.type==="TOP_X"?n=this.gamesRemapper.remapPaginatedUserTopXEditions(p.data):d.type==="MATCH_QUIZ"&&(n=this.gamesRemapper.remapPaginatedUserMathQuizEditions(p.data))}),n}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameResults=async(e,t,n)=>{try{let o=de(t)?`/games/${e}/results/${this.apiSignInUrl}${fe()}`:`/games/${e}/results/${this.apiSignInUrl}`;n&&(o+=`${n.constructMainFiltersUrl()}`);let p=await this.instance.get(o);return this.gamesRemapper.remapPaginatedGameResults(p.data)}catch(o){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,o),o.response}};getMarketResultsForGame=async(e,t)=>{let n=`/games/${e}/correct-results/${this.apiSignInUrl}`;de(t)&&(n+=`${fe()}`);try{let o=await this.instance.get(n);return this.gamesRemapper.remapGameMarketsResults(o.data.data)}catch(o){throw console.warn(`There was a problem fetching the markets correct results for the following game: ${e}`,o),o.response}}};var mr=class{gameInstanceId=null;fixtures=null};var ne=class extends Error{code=0;status=null;message=null;constructor(e,t,n){super();this.code=e,this.status=t,this.message=n}errorMessage=()=>this.message};var xp=(n=>(n.ONE="1",n.X="x",n.TWO="2",n))(xp||{}),Ap=(n=>(n.ONE_X="1x",n.X_TWO="x2",n.ONE_TWO="12",n))(Ap||{}),Op=(v=>(v.ONE_ONE="1/1",v.ONE_X="1/x",v.ONE_TWO="1/2",v.X_ONE="x/1",v.X_X="x/x",v.X_TWO="x/2",v.TWO_ONE="2/1",v.TWO_X="2/x",v.TWO_TWO="2/2",v))(Op||{});var is=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var rs=class{value};var ns=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new rs,this.prediction.value=t}};var as=class{value=null};var os=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new as,this.prediction.value=t}};var ss=class{value=null};var ls=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new ss,this.prediction.value=n}};var ps=class{value=null};var cs=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ps,this.prediction.value=t}};var us=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var ms=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var ti=class{validateBodyFields=(e,t)=>{let n=Object.keys(t),o=Object.keys(new mr);switch(e){case"MATCH_QUIZ":n.forEach(g=>{o.includes(g)||this.throwInvalidParamException([g])});break;case"TOP_X":let d=t;d.fixtures.forEach(g=>this.validateMarketTopX(g.market));let y="tiebreaker";n.includes(y)&&d.tiebreaker&&this.validateTiebreaker(d.tiebreaker),n.forEach(g=>{g!=="tiebreaker"&&!o.includes(g)&&this.throwInvalidParamException([g])});break}let p=o.filter(d=>!n.includes(d));return p.length&&this.throwMissingFieldsException("game prediction body",p),t.fixtures.forEach(d=>{this.validateFixtureFields(d)}),t};validateFixture=(e,t,n,o)=>{this.validateMarket(t);let p=Object.values(xp),d=Object.values(Op),y=Object.values(Ap);if(t==="FT_1X2"||t==="HT_1X2"){if(p.includes(n))return new ls(e,t,n)}else if(t==="HT_FT"){if(d.includes(n))return new cs(e,n)}else if(t==="DOUBLE_CHANCE"){if(y.includes(n))return new os(e,n)}else if(t==="CORRECT_SCORE"||t==="CORRECT_SCORE_ADVANCED"||t==="CORRECT_SCORE_HT"){if(typeof n=="string"&&/\d+:\d+/.test(n))return new Zt(e,t,n)}else if(t==="CORNERS_MATCH"){if(typeof n=="number")return new ns(e,n)}else if(t==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(n))return new is(e,n)}else if(t==="RED_CARD_MATCH"){if(this.isPredictionBoolean(n))return new ms(e,n)}else if(t==="PENALTY_MATCH"){if(this.isPredictionBoolean(n))return new us(e,n)}else if(wt.includes(t)){let g="OWN_GOAL";if(this.validatePlayerId(t,o),t===Zr&&this.isPredictionBoolean(n)){let v=o&&o===g?g:o;return new tt(e,t,n,v)}if(o&&this.isPredictionBoolean(n))return new tt(e,t,n,o)}else if(Td.includes(t)){if(this.isPredictionBoolean(n))return new or(e,t,n)}else if(Ed.includes(t)&&this.isPredictionBoolean(n))return new ar(e,t,n);this.throwInvalidPredictionException(n,t)};validateFixtureFields=e=>{let t=Object.keys(e);t.forEach(o=>{Sp.includes(o)||this.throwInvalidParamException([o])});let n=Sp.filter(o=>{if(o!=="matchType"&&!t.includes(o))return o});n.length&&this.throwMissingFieldsException("fixtures",n),this.validatePredictionKey(e.market,e.prediction)};validateTiebreaker=e=>{let t=Object.keys(e);(!t.length||typeof e!="object")&&this.throwInvalidType("tiebreaker","object");let n=Object.keys(new jt)[0];t.forEach(o=>{n!==o&&this.throwInvalidParamException([o])}),t.includes(n)||this.throwMissingFieldsException("tiebreaker",[n]),typeof e.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(e,t)=>{if(typeof t=="object"){let n=Object.keys(t),o=["value"];if(n.length||this.throwMissingFieldsException("prediction",o),n.length===1&&!n.includes(o[0])&&this.throwInvalidParamException(n),n.length>1){wt.includes(e)&&o.push("playerId");let p=n.filter(d=>!o.includes(d));p.length&&this.throwInvalidParamException(p)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(e,t)=>{let n="playerId";e!==Zr&&(t||this.throwInvalidParamException([n]),typeof t!="string"&&this.throwInvalidType(n,"string"))};validateMarket=e=>{Object.values(Pe).includes(e)||this.throwInvalidMarketException(e)};validateMarketTopX=e=>{e!=="CORRECT_SCORE"&&e!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(e,"TOP_X")};isPredictionBoolean=e=>typeof e=="boolean";throwInvalidPredictionException=(e,t)=>{let n=xd(e,t);throw new ne(400,"INVALID_PREDICTION",n)};throwInvalidMarketException=(e,t)=>{let n=null;throw t&&t==="TOP_X"?n=Ad(e):n=Vo(e),new ne(400,"INVALID_MARKET",n)};throwInvalidParamException=e=>{let t=Od(e);throw new ne(400,"INVALID_FIELD",t)};throwMissingFieldsException=(e,t)=>{let n=Bd(e,t);throw new ne(400,"INVALID_FIELD",n)};throwInvalidType=(e,t)=>{let n=Ld(e,t);throw new ne(400,"INVALID_TYPE",n)}};var fs=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;constructor(e,t,n,o){this.predictorHttps=t,this.idMapping=o,this.clientHttps=n,this.predictorValidator=new ti,this.predictorService=new _t(e,o)}makeFootballPrediction=async(e,t,n,o)=>{let p=this.predictorValidator.validateFixture(e,t,n,o),d=new mr;if(this.idMapping.idSchema!=="native"){let y=p.matchId,g="",v=await this.predictorService.remapMatchIdToNative([y]);if(p.matchId=v[0],!p.matchId)throw new ne(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(p instanceof tt&&(g=p.prediction.playerId,p.prediction.playerId=g&&await this.predictorService.remapPlayerIdToNative([g]),p.market!==Zr&&!p.prediction.playerId))throw new ne(400,"INVALID_FIELD","Player id is invalid!").errorMessage();d.fixtures=[p];let w=await this.predictorHttps.makeFootballPrediction(d);return w.fixtures.forEach(S=>{S.prediction.playerId&&(S.prediction.playerId=g),S.matchId=y}),w}else return d.fixtures=[p],await this.predictorHttps.makeFootballPrediction(d)};getMatchSummary=async(e,t)=>{if(this.idMapping.idSchema!=="native"){let o=(await this.predictorService.remapMatchIdToNative([e]))[0],p=await this.predictorHttps.getMatchSummary(o,t);p.matchId=e;let d=p.predictions,y=await this.predictorService.remapPlayerIdToIdSchema(d);return p.predictions=y,p}else return await this.predictorHttps.getMatchSummary(e,t)};getMarketSummary=async(e,t,n,o)=>{try{let p=await this.getMatchSummary(e,o);return this.predictorService.getMarketSummary(p,t,n)}catch(p){return p.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getMyPredictions(t)};getMyPredictionsForMatches=async(e,t)=>{if(this.predictorService.areIdsExceeded(e))throw new ne(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let n=this.predictorService.initPredictionsFilters(t,"matches",e);return await this.predictorHttps.getMyPredictions(n)};getMyCurrentPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getMyPredictions(t)};getMyPastPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getMyPredictions(t)};getUserPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserCurrentPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserPastPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserPredictionsForMatches=async(e,t,n,o)=>{if(this.predictorService.areIdsExceeded(t))throw new ne(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let p=this.predictorService.initPredictionsFilters(n,"matches",t);return await this.predictorHttps.getUserPredictions(e,o,p)}};var hs=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new ae(e),this.predictorHttps=new ei(e,this.idMapping),this.clientHttps=new et(e),this.predictorFacade=new fs(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,n,o)=>await this.predictorFacade.makeFootballPrediction(e,t,n,o);getMatchSummary=async(e,t)=>await this.predictorFacade.getMatchSummary(e,t);getMarketSummary=async(e,t,n,o)=>await this.predictorFacade.getMarketSummary(e,t,n,o);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getMyPredictionsForMatches=async(e,t)=>await this.predictorFacade.getMyPredictionsForMatches(e,t);getUserPredictions=async(e,t,n)=>await this.predictorFacade.getUserPredictions(e,t,n);getUserCurrentPredictions=async(e,t,n)=>await this.predictorFacade.getUserCurrentPredictions(e,t,n);getUserPastPredictions=async(e,t,n)=>await this.predictorFacade.getUserPastPredictions(e,t,n);getUserPredictionsForMatches=async(e,t,n,o)=>await this.predictorFacade.getUserPredictionsForMatches(e,t,n,o)};var gs=class{rankType=null;fromDate=null;toDate=null;pagination=new Qi};var dr=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var ys=class{remapResponse=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new gs;return t.rankType=e.rank_type,t.fromDate=e.from_date,t.toDate=e.to_date,t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t};remapData=e=>{let t=[];return e.forEach(n=>{let o=new dr;o.position=n.position,o.profileId=n.profile_id,o.points=n.points,o.predictionsMade=n.predictions_made,t.push(o)}),t}};var Ms=class extends dr{id=null;rankType=null;model=null;gameType=null};var bs=class{remapRankings=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.numberOfPages=e.pagination.number_of_pages,t.pagination.totalItems=e.pagination.total_items,t};remapData(e){let t=[];return e.forEach(n=>{let o=new Ms;o.id=n.id,o.rankType=n.rank_type,o.position=n.position,o.points=n.points,o.gameType=n.game_type,delete o.profileId,delete o.profileModel,delete o.predictionsMade,t.push(o)}),t}};var ws=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;flags=null;images=new pr;status=null;automaticallyChangeStatus=!0};var vs=class{remapResponse=e=>{let t=[];return e.forEach(n=>{let o=new ws;o.id=n.id,o.name=n.name,o.description=n.description,o.type=n.type,o.fromDate=n.from_date,o.toDate=n.to_date,o.markets=n.markets?n.markets:null,o.teamIds=n.team_ids?n.team_ids:null,o.matchIds=n.match_ids?n.match_ids:null,o.gameIds=n.game_ids?n.game_ids:null,o.gameTypes=n.game_types?n.game_types:null,o.competitionIds=n.competition_ids?n.competition_ids:null,o.excludedProfileIds=n.excluded_profile_ids?n.excluded_profile_ids:null,o.rules=n.rules?n.rules:null,o.flags=n.flags?n.flags:null,o.images=n.images?n.images:null,o.status=n.status?n.status:null,o.automaticallyChangeStatus=n.automatically_change_status,t.push(o)}),t};remapMeta=e=>{let t={};return t.totalItems=e.pagination.total_items,t}};var _s=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Is=class{remapHighestSuccessRate=e=>e.map(t=>{let n=new _s;return n.position=t.position,n.points=t.points,n.predictionsMade=t.predictions_made,n.profileId=t.profile_id,n.successRatePercent=t.success_rate_percent,n})};var Ps=class extends Me{apiSignInUrl=null;templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(e){super(e,Oe(e.environment,"loyalty"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.templateRemapper=new vs,this.leaderboardRemapper=new ys,this.rankingsRemapper=new bs,this.highestSuccessRateRemapper=new Is}getTemplates=async(e,t)=>{try{let n=de(e)?`/leaderboard/templates/${this.apiSignInUrl}${fe()}`:`/leaderboard/templates/${this.apiSignInUrl}`,o=await this.instance.get(n);if(t){let p=JSON.parse(JSON.stringify(o.data));return p.meta=this.templateRemapper.remapMeta(o.data.meta),p.data=this.templateRemapper.remapResponse(o.data.data),p}return this.templateRemapper.remapResponse(o.data.data)}catch(n){throw console.warn("There was a problem fetching the list of templates",n),n.response}};getLeaderboard=async(e,t,n)=>{try{let o=de(t)?`/leaderboard/${e}/${this.apiSignInUrl}${fe()}`:`/leaderboard/${e}/${this.apiSignInUrl}`;n&&(o+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(o),d=JSON.parse(JSON.stringify(p.data));return this.leaderboardRemapper.remapResponse(d)}catch(o){throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,o),o.response}};getLeaderboardForGame=async(e,t,n)=>{try{let o=de(t)?`/leaderboard/games/${e}/${this.apiSignInUrl}${fe()}`:`/leaderboard/games/${e}/${this.apiSignInUrl}`;n&&(o+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(o),d=JSON.parse(JSON.stringify(p.data));return ta(d)}catch(o){throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,o),o.response}};getUserRankings=async(e,t,n)=>{let o=`/leaderboard/users/${e}/rankings/${this.apiSignInUrl}`;t&&(o+=`${t.constructFiltersUrl()}`),de(n)&&(o+=`${fe()}`);try{let p=await this.instance.get(o);return this.rankingsRemapper.remapRankings(p.data)}catch(p){throw console.warn(`There was a problem fetching the rankings for the following user: ${e}`,p),p.response}};getHighestSuccessRate=async(e,t)=>{let n=de(t)?`/statistics/top${this.apiSignInUrl}${fe()}`:`/statistics/top${this.apiSignInUrl}`;e&&(n+=`&market=${e}`);try{let o=await this.instance.get(n);return this.highestSuccessRateRemapper.remapHighestSuccessRate(o.data.data)}catch(o){throw console.warn("There was a problem fetching highest success rate",o),o.response}}};var Rs=class{general;predictor;topX;matchQuiz};var fr=class{limit=null;page=null;constructor(e){this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null}constructFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.page&&(e+="&",e+=`page=${this.page}`),e}};var Fs=class extends fr{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(e){super(e);this.sortOrder=e.sortOrder,this.rankType=e.rankType,this.leaderboardIds=e.leaderboardIds,this.gameType=e.type&&e.type.toLowerCase()==="game"?e.gameType:null}constructFiltersUrl=()=>{let e=super.constructFiltersUrl();return this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),this.rankType&&(e+="&",e+=`rank_type=${this.rankType}`),this.leaderboardIds&&(e+="&",e+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(e+="&",e+=`game_type=${this.gameType}`),e}};var Ss=class{idMappingService=null;profileNamespace=null;constructor(e){this.idMappingService=new ae(e),this.profileNamespace=new er(e)}remapTemplatesIds=async e=>{if(e.length>0){let t=[],n=[],o=[],p=[],d=[],y=[];e.forEach(w=>{w.teamIds&&w.teamIds.length>0?t=[...t,...w.teamIds]:w.matchIds&&w.matchIds.length>0?o=[...o,...w.matchIds]:w.competitionIds&&w.competitionIds.length>0&&(d=[...d,...w.competitionIds])});let g={team:t,match:o,competition:d},v=await this.idMappingService.idMappingFacade.getEntitiesByIds(g,"native",this.idMappingService.idSchema);return n=[...v.team],p=[...v.match],y=[...v.competition],e.forEach(w=>{w.teamIds&&w.teamIds.length>0?w.teamIds=w.teamIds.map(S=>S=v.team.shift()):w.matchIds&&w.matchIds.length>0?w.matchIds=w.matchIds.map(S=>S=v.match.shift()):w.competitionIds&&w.competitionIds.length>0&&(w.competitionIds=w.competitionIds.map(S=>S=v.competition.shift()))}),e}return e};addProfileModelToLeaderboad=async e=>{if(e.length>0){let t=[],n=[];e.forEach(p=>{t.push(p.profileId)});let o=await this.profileNamespace.getByIds(t);return e.forEach(p=>{o.forEach(d=>{d.id===p.profileId&&(delete d.interests,p.profileModel=d)}),p.profileModel||(p.profileModel=null),n.push(p)}),n}return e};buildClientBadges=e=>{let t=new Rs;return t.general=this.extractEnabledBadgesId(e.general),t.predictor=this.extractEnabledBadgesId(e.predictor),t.topX=this.extractEnabledBadgesId(e.topX),t.matchQuiz=this.extractEnabledBadgesId(e.matchQuiz),t};initFilters=(e,t)=>{switch(t){case"loyalty":e&&(e=new fr(e));break;case"rankings":e&&(e=new Fs(e));break}return e};addProfileModelToHighestSuccessRate=async e=>{let t=e.map(o=>o.profileId),n=await this.profileNamespace.getByIds(t);return e.map(o=>(n.forEach(p=>{p.id===o.profileId&&(delete p.interests,o.profileModel=p)}),o))};extractRankingsIdsMap=e=>{let t=[],n=[],o=[];return e.forEach(p=>{p.rankType==="GAME"&&p.gameType==="TOP_X"?t.push(p.id):p.rankType==="GAME"&&p.gameType==="MATCH_QUIZ"?n.push(p.id):p.rankType==="TEMPLATE"&&o.push(p.id)}),[t,n,o]};setModelsForUserRankings=(e,t,n,o)=>(o.data.forEach(p=>{p.gameType==="MATCH_QUIZ"&&t?p.model=t.filter(d=>d.id===p.id)[0]:p.gameType==="TOP_X"&&e?p.model=e.filter(d=>d.id===p.id)[0]:p.rankType==="TEMPLATE"&&n&&(p.model=n.filter(d=>d.id===p.id)[0])}),o);extractEnabledBadgesId=e=>{let t=[];return e.forEach(n=>{n.enabled&&t.push(n.id)}),t}};var Ts=class{validateMarket=e=>{if(!Object.keys(Pe).includes(e)){let n=Vo(e);throw new ne(400,"INVALID_MARKET",n)}}};var hr=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;constructor(e,t){this.idMapping=t,this.predictorValidator=new ti,this.predictorHttps=new ei(e,t),this.predictorService=new _t(e,t),this.clientHttps=new et(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};getGames=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameFilters("TOP_X",e),o=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getGameById=async(e,t)=>{t=t||!1;let n=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,t,n)=>(n=n||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new Re(t)),await this.predictorHttps.getGamePredictions(e,n,t));getGameResults=async(e,t,n)=>{n=n||!1,t&&(t=new rt(t));let o=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new rt(t);let n=await this.predictorHttps.getGames(t,e),o=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(o,null,e)).data[0]};play=async e=>{let t=new cr(e);if(t=this.predictorValidator.validateBodyFields("TOP_X",t),t.fixtures=t.fixtures.map(o=>this.predictorValidator.validateFixture(o.matchId,o.market,o.prediction.value)),this.idMapping.idSchema!=="native"){let o=[];t.fixtures.forEach(d=>o.push(d.matchId));let p=await this.predictorService.remapMatchIdToNative(o);t.fixtures.forEach(d=>d.matchId=p.shift())}let n=await this.predictorHttps.makeFootballPrediction(t);return n.fixtures.forEach(o=>{o.matchId=o.matchModel.id}),n};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let n=this.predictorService.initGameTypePredictions("TOP_X",e),o=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.data.length>0){p.data.forEach(g=>{g.game_instance_id&&o.push(g.game_instance_id)});let d=this.predictorService.initGameFilters("TOP_X",null,o),y=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,y)}else return new re};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),n=await this.predictorHttps.getMyPredictions(t);if(n.data.length>0){let o=n.data.filter(p=>p.gameInstanceId===e);return o.length?o[0]:null}return null};getUserGameEditions=async(e,t,n)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),n=n||!1;let o=this.predictorService.initGameTypePredictions("TOP_X",t),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,o);if(d.data.length>0){d.data.forEach(v=>{v.game_instance_id&&p.push(v.game_instance_id)});let y=this.predictorService.initGameFilters("TOP_X",null,p),g=await this.predictorHttps.getUserGameEditions(y,n);return await this.predictorService.addPredictionProp(d,g)}else return new re};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("TOP_X"),p=await this.predictorHttps.getUserPredictions(e,n,o);if(p.data.length>0){let d=p.data.filter(y=>y.gameInstanceId===t);return d.length?d[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"TOP_X")};validateLimitFilterOnGames=e=>{if(e>50)throw new ne(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var gr=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;constructor(e){this.predictorValidator=new ti,this.idMapping=new ae(e),this.predictorHttps=new ei(e,this.idMapping),this.predictorService=new _t(e,this.idMapping),this.clientHttps=new et(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};play=async e=>{e=this.predictorValidator.validateBodyFields("MATCH_QUIZ",e);let t=e.fixtures.map(n=>this.predictorValidator.validateFixture(n.matchId,n.market,n.prediction.value,n.prediction.playerId));if(t&&t.length&&this.idMapping.idSchema!=="native"){let n=[],o=[];t.forEach(y=>{n.push(y.matchId),y instanceof tt&&y.prediction.playerId&&o.push(y.prediction.playerId)});let p=await this.predictorService.remapMatchIdToNative(n),d={};o&&o.length>0&&(d=await this.predictorService.remapPlayerIdMapToNative(o)),t.forEach((y,g)=>{y.matchId=p[g],y instanceof tt&&(y.prediction.playerId=d[y.prediction.playerId])})}return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameFilters("MATCH_QUIZ",e),o=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getGameById=async(e,t)=>{t=t||!1;let n=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,t,n)=>(n=n||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new Re(t)),await this.predictorHttps.getGamePredictions(e,n,t));getGameResults=async(e,t,n)=>{n=n||!1,t&&(t=new lr(t));let o=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"MATCH_QUIZ"};t=new rt(t);let n=await this.predictorHttps.getGames(t,e),o=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(o,null,e)).data[0]};getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let n=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),o=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.data.length>0){p.data.forEach(g=>{g.game_instance_id&&o.push(g.game_instance_id)});let d=this.predictorService.initGameFilters("MATCH_QUIZ",null,o),y=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,y)}else return new re};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),n=await this.predictorHttps.getMyPredictions(t);if(n.data.length>0){let o=n.data.filter(p=>p.gameInstanceId===e);return o.length?o[0]:null}return null};getUserGameEditions=async(e,t,n)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),n=n||!1;let o=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,o);if(d.data.length>0){d.data.forEach(v=>{v.game_instance_id&&p.push(v.game_instance_id)});let y=this.predictorService.initGameFilters("MATCH_QUIZ",null,p),g=await this.predictorHttps.getUserGameEditions(y,n);return await this.predictorService.addPredictionProp(d,g)}else return new re};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),p=await this.predictorHttps.getUserPredictions(e,n,o);if(p.data.length>0){let d=p.data.filter(y=>y.gameInstanceId===t);return d.length?d[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"MATCH_QUIZ")};validateLimitFilterOnGames=e=>{if(e>50)throw new ne(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var Es=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;constructor(e,t,n,o,p){this.config=e,this.clientHttps=t,this.loyaltyHttps=n,this.profileFacade=new Mt(p,o),this.loyaltyService=new Ss(this.config),this.loyaltyValidator=new Ts,this.idMapping=new ae(e),this.topXFacade=new hr(e,this.idMapping),this.matchQuizFacade=new gr(e)}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let e=await this.getConfig();return this.loyaltyService.buildClientBadges(e.rewards.badges)};getTemplates=async e=>{let t=!0;if(this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(e,t);let n=await this.loyaltyHttps.getTemplates(e,t);return n.data=await this.loyaltyService.remapTemplatesIds([...n.data]),n};getTemplateById=async(e,t)=>{try{let n=!1,p=(await this.loyaltyHttps.getTemplates(t,n)).filter(y=>y.id===e);if(!p.length)throw new ne(400,"INVALID_TEMPLATE","Provided template ID does NOT exist! Try again with existing template ID.").errorMessage();return this.config.idSchema==="native"?p[0]:(await this.loyaltyService.remapTemplatesIds(p))[0]}catch(n){throw console.warn("There was a problem retrieving specified template: ",n),n}};getLeaderboard=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let o=await this.loyaltyHttps.getLeaderboard(e,n,t);return o.data=await this.loyaltyService.addProfileModelToLeaderboad(o.data),o};getLeaderboardForGame=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let o=await this.loyaltyHttps.getLeaderboardForGame(e,n,t);return o.data=await this.loyaltyService.addProfileModelToLeaderboad(o.data),o};getOwnRankings=async(e,t)=>{let{id:n}=await this.profileFacade.getOwn();return this.getUserRankings(n,e,t)};getUserRankings=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"rankings");let o=await this.loyaltyHttps.getUserRankings(e,t,n);return await this.getModelsForUserRankings(o)};getHighestSuccessRate=async(e,t)=>{e&&this.loyaltyValidator.validateMarket(e);let n=await this.loyaltyHttps.getHighestSuccessRate(e,t);return this.loyaltyService.addProfileModelToHighestSuccessRate(n)};getModelsForUserRankings=async e=>{let t=null,n=null,o=null,[p,d,y]=this.loyaltyService.extractRankingsIdsMap(e.data);if(y.length&&(t=(await this.getTemplates()).data.filter(v=>y.includes(v.id))),p.length){let g={gameIds:p};n=(await this.topXFacade.getGames(g)).data}if(d.length){let g={gameIds:d};o=(await this.matchQuizFacade.getGames(g)).data}return this.loyaltyService.setModelsForUserRankings(n,o,t,e)}};var Cs=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localStorage=null;constructor(e){this.clientHttps=new et(e),this.profileHttps=new Ui(e),this.loyaltyHttps=new Ps(e),this.localStorage=new yt(e),this.loyaltyFacade=new Es(e,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localStorage)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getTemplates=async e=>await this.loyaltyFacade.getTemplates(e);getTemplateById=async(e,t)=>await this.loyaltyFacade.getTemplateById(e,t);getLeaderboard=async(e,t,n)=>await this.loyaltyFacade.getLeaderboard(e,t,n);getLeaderboardForGame=async(e,t,n)=>await this.loyaltyFacade.getLeaderboardForGame(e,t,n);getOwnRankings=async(e,t)=>await this.loyaltyFacade.getOwnRankings(e,t);getUserRankings=async(e,t,n)=>await this.loyaltyFacade.getUserRankings(e,t,n);getHighestSuccessRate=async(e,t)=>await this.loyaltyFacade.getHighestSuccessRate(e,t)};var xs=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new ae(e),this.topXFacade=new hr(e,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(e,t)=>await this.topXFacade.getGames(e,t);getGameById=async(e,t)=>await this.topXFacade.getGameById(e,t);getGamePredictions=async(e,t,n)=>await this.topXFacade.getGamePredictions(e,t,n);getGameResults=async(e,t,n)=>await this.topXFacade.getGameResults(e,t,n);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,t)=>await this.topXFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,n)=>await this.topXFacade.getUserGameEditions(e,t,n);getUserGamePrediction=async(e,t,n)=>await this.topXFacade.getUserGamePrediction(e,t,n);getMarketsResultsForGame=async(e,t)=>await this.topXFacade.getMarketsResultsForGame(e,t)};var As=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new gr(e)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,t)=>await this.matchQuizFacade.getGames(e,t);getGameById=async(e,t)=>await this.matchQuizFacade.getGameById(e,t);getGamePredictions=async(e,t,n)=>await this.matchQuizFacade.getGamePredictions(e,t,n);getGameResults=async(e,t,n)=>await this.matchQuizFacade.getGameResults(e,t,n);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,t)=>await this.matchQuizFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,n)=>await this.matchQuizFacade.getUserGameEditions(e,t,n);getUserGamePrediction=async(e,t,n)=>await this.matchQuizFacade.getUserGamePrediction(e,t,n);getMarketsResultsForGame=async(e,t)=>await this.matchQuizFacade.getMarketsResultsForGame(e,t)};var an=class{action=null;page=null;limit=null;constructor(e){this.action=e.action?e.action:null,this.page=e.page?e.page:null,this.limit=e.limit?e.limit:null}constructFilterUrl=()=>{let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var on=class{action=null;context=new Ji;constructor(e,t,n,o){this.action=e,this.context.tags=t,n&&(this.context.content=n),o&&(this.context.campaign=o)}};var Os=class{idSchema;idMapping;constructor(e){this.idSchema=e.idSchema,this.idMapping=new ae(e)}remapTagsIds=async(e,t,n)=>{let o={},p={},d=[];e.forEach(g=>{o.hasOwnProperty(g.type)||(o[g.type]=[],p[g.type]=[]),o[g.type].push(g.id),p[g.type].push(g)});let y=await this.idMapping.idMappingFacade.getEntitiesByIds(o,t,n);for(let[g,v]of Object.entries(p))v.forEach((w,S)=>{w.id=y[g][S],d.push(w)});return d}};var Bs=class{idSchema;activityHttps;activityService;constructor(e){this.idSchema=e.idSchema,this.activityHttps=new ji(e),this.activityService=new Os(e)}add=async(e,t,n,o)=>{if(this.idSchema!="native"){let d=JSON.parse(JSON.stringify(t)),y=await this.activityService.remapTagsIds(t,this.idSchema,"native"),g=new on(e,y,n,o),v=await this.activityHttps.createActivity(g);return v.context.tags=d,v}let p=new on(e,t,n,o);return this.activityHttps.createActivity(p)};delete=async e=>await this.activityHttps.deleteActivity(e);like=async(e,t,n)=>{let o="like";return await this.add(o,e,t,n)};dislike=async(e,t,n)=>{let o="dislike";return await this.add(o,e,t,n)};addPageview=async(e,t,n)=>{let o="page_view";return await this.add(o,e,t,n)};addContentConsumed=async(e,t,n)=>{let o="content_consumed";return await this.add(o,e,t,n)};addShare=async(e,t,n)=>{let o="share";return await this.add(o,e,t,n)};addComment=async(e,t,n)=>{let o="comment";return await this.add(o,e,t,n)};addClickAd=async(e,t,n)=>{let o="click_ad";return await this.add(o,e,t,n)};addConversion=async(e,t,n)=>{let o="conversion";return await this.add(o,e,t,n)};getOwn=async(e,t)=>{if(t=t||!1,e&&(e=new an(e)),this.idSchema!="native"){let n=await this.activityHttps.getOwnActivities(e,t);for(let o of n.data)await this.activityService.remapTagsIds(o.context.tags,"native",this.idSchema);return n}return await this.activityHttps.getOwnActivities(e,t)};getForUser=async(e,t,n)=>{if(n=n||!1,t&&(t=new an(t)),this.idSchema!="native"){let o=await this.activityHttps.getActivitiesForUser(e,t,n);for(let p of o.data)await this.activityService.remapTagsIds(p.context.tags,"native",this.idSchema);return o}return await this.activityHttps.getActivitiesForUser(e,t,n)}};var Ls=class{activityFacade;constructor(e){this.activityFacade=new Bs(e)}add=async(e,t,n,o)=>await this.activityFacade.add(e,t,n,o);delete=async e=>await this.activityFacade.delete(e);like=async(e,t,n)=>await this.activityFacade.like(e,t,n);dislike=async(e,t,n)=>await this.activityFacade.dislike(e,t,n);addPageview=async(e,t,n)=>await this.activityFacade.addPageview(e,t,n);addContentConsumed=async(e,t,n)=>await this.activityFacade.addContentConsumed(e,t,n);addShare=async(e,t,n)=>await this.activityFacade.addShare(e,t,n);addComment=async(e,t,n)=>await this.activityFacade.addComment(e,t,n);addClickAd=async(e,t,n)=>await this.activityFacade.addClickAd(e,t,n);addConversion=async(e,t,n)=>await this.activityFacade.addConversion(e,t,n);getOwn=async(e,t)=>await this.activityFacade.getOwn(e,t);getForUser=async(e,t,n)=>await this.activityFacade.getForUser(e,t,n)};function wB(s){let t=new No().validate(s);if((t.idSchema.validation==="missing"||t.idSchema.validation==="invalid")&&(console.warn(t.idSchema.message.text),s.idSchema="native"),(t.environment.validation==="missing"||t.environment.validation==="invalid")&&(console.warn(t.environment.message.text),s.environment="prod"),(t.lang.validation==="missing"||t.lang.validation==="invalid")&&(console.warn(t.lang.message.text),s.lang="en"),t.authProvider.validation==="invalid"&&console.warn(t.authProvider.message.text),t.isValid)return{profile:new er(s),football:new Do(s),predictor:new hs(s),loyalty:new Cs(s),topX:new xs(s),matchQuiz:new As(s),activity:new Ls(s)};N_(t)}var N_=s=>{let e="authProvider",t="isValid";Object.keys(s).forEach(n=>{let o=s[n];if(n!==t&&n!==e){if(o.message.type==="error")throw new Error(o.message.text)}else n!==t&&n===e&&Object.keys(new fi).forEach(p=>{if(o[p].message.type==="error")throw new Error(o[p].message.text)})})};export{wB as FansUnitedSDK};
|
|
23
|
+
${Fp.PREDICTOR_USER_RELATED_OPERATION}`},xd=(s,e)=>`The prediction '${s}' is invalid for market '${e}'. 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`,Vo=s=>`The market '${s}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Ad=s=>`The market '${s}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Od=s=>`The field/s '${s.length>1?s.join(", "):s[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Bd=(s,e)=>`The following field/s is/are missing from ${s}: '${e.length>1?e.join(", "):e[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Ld=(s,e)=>`The field ${s} has incorrect type. The correct type is ${e}`;var _t=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new bt(e),this.idMapping=t,this.matchFacade=new zt(e,this.footballHttps,t),this.playerFacade=new Qt(e,this.footballHttps,t)}remapMatchIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"match","native")).match;remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},n=Xt(e),p=(await this.idMapping.getEntityIdsBySchemaId(n,"player","native")).player;return n.forEach((d,y)=>t[d]=p[y]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[n,o]of Object.entries(e))if(t.includes(n))for(let p of Object.keys(o)){let d={player:[p]},g=(await this.idMapping.idMappingFacade.getEntitiesByIds(d,"native",this.idMapping.idSchema)).player[0];o[g]=o[p],delete o[p]}return e};convertMarket=e=>{let t=Object.keys(new sr),n=Object.values(Pe);for(let o=0;o<n.length;o++)e===n[o]&&(e=t[o]);return e};convertMarketForResponseModel=(e,t)=>{let n=t.toString();return e+"_"+n};getMarketSummary=(e,t,n)=>{let o=this.convertMarket(t),p={};if(p.matchId=e.matchId,p.matchType=e.matchType,Object.keys(e.predictions).includes(o))p[o]=e.predictions[o];else throw new Error("You have passed invalid market");return wt.includes(t)&&n?(p[o][n]||(p[o][n]=new j),p[o][n]):p};remapCompetitionsFromConfig=async e=>{if(e instanceof Vi){let t={competition:e.fullCoverageCompetitions},n={competition:e.successRateScopes.competitions},o={team:e.successRateScopes.teams},p=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema),d=await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",this.idMapping.idSchema),y=await this.idMapping.idMappingFacade.getEntitiesByIds(o,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=p.competition,e.successRateScopes.competitions=d.competition,e.successRateScopes.teams=y.team,e}if(e instanceof $i||e instanceof ki){let t={competition:e.competitionsWhitelist},n=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.competitionsWhitelist=n.competition,e}};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let t=[],n=[];return e.data.forEach(o=>{o instanceof yi||o instanceof hi||o instanceof Nt?(o.fixtures.forEach(p=>t.push(p.matchId)),o instanceof Nt&&o.fixtures.forEach(p=>{p.prediction.playerId&&n.push(p.prediction.playerId)})):o instanceof gi&&o.results.forEach(p=>t.push(p.matchId))}),await this.refactorResponseArrModel(e,t,n)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,n)=>{let o=[],p=await this.matchFacade.getMatchesMapWithNativeIds(t),d={};return n.length>0&&(d=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.data.forEach(y=>{y instanceof yi||y instanceof hi||y instanceof Nt?(y.fixtures.forEach(g=>{g.matchModel=p[g.matchId],delete g.matchModel.availableMarkets,g.matchId=g.matchModel.id,y instanceof Nt&&g.prediction.playerId&&(g.prediction.playerModel=d[g.prediction.playerId],g.prediction.playerId=d[g.prediction.playerId].id)}),o.push(y)):y instanceof gi&&(y.results.forEach(g=>{g.matchModel=p[g.matchId],delete g.matchModel.availableMarkets,g.matchId=g.matchModel.id}),o.push(y))}),e.data=o,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(o=>t.push(o.matchId));let n=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(o=>{o.matchModel=n[o.matchId],delete o.matchModel.availableMarkets,o.matchId=n[o.matchId].id}),e};getCurrentGameId=e=>{let t=new Date;if(e.data.length>1){let n=[];return e.data.forEach(p=>n.push(p.predictionsCutoff)),e.data.sort((p,d)=>{let[y,g]=[p.predictionsCutoff,d.predictionsCutoff].map(v=>Math.abs(new Date(v)-t));return y-g})[0].id}else return e.data[0].id};initGameTypePredictions=(e,t)=>{let n={type:e,limit:null,startAfter:null};return t&&(n={...n,limit:t.limit,startAfter:t.startAfter}),n=new Re(n),n};initGameFilters=(e,t,n)=>{if(t&&n)return t.type=e,t.gameIds=n,t=new rt(t),t;if(t&&!n)return t.type=e,t=new rt(t),t;if(!t&&n){let o={type:e,gameIds:n};return o=new rt(o),o}else{let o={type:e};return o=new rt(o),o}};addPredictionProp=async(e,t)=>(t.data.forEach(n=>{e.data.forEach(o=>{n.id===o.game_instance_id&&(n.predictionId=o.id,n.outcome=o.status,n.fixtures.forEach((p,d)=>{o.fixtures[d].goals_home!==void 0&&o.fixtures[d].goals_away!==void 0?p.prediction.value=o.fixtures[d].goals_home+":"+o.fixtures[d].goals_away:p.prediction.value=o.fixtures[d].prediction,o.fixtures[d].player_id?p.prediction.playerId=o.fixtures[d].player_id:o.fixtures[d].target&&(p.prediction.target=o.fixtures[d].target),p.prediction.result=this.remapResult(o.fixtures[d].result)}),n.predictionsMadeAt=o.created_at,n.points=o.points)})}),t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new nr;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t};areIdsExceeded=e=>{let t=10;return e.length>t};initPredictionsFilters=(e,t,n)=>{switch(t){case"user":e&&(e=new Re(e));break;case"current":if(e)this.deleteUnexpectedProperties(e),e.status=["ACTIVE"],e=new Re(e);else{let o={status:["ACTIVE"]};e=new Re(o)}break;case"past":if(e)this.deleteUnexpectedProperties(e),e.status=Ep,e=new Re(e);else{let o={status:Ep};e=new Re(o)}break;case"matches":if(e)this.deleteUnexpectedProperties(e),e.matchIds=n,e=new Re(e);else{let o={matchIds:n};e=new Re(o)}break}return e};completeGameMarketResults=async(e,t)=>{switch(t){case"MATCH_QUIZ":let n={},o=e.results[0].matchId,p=e.results.map(v=>wt.includes(v.market)&&!v.result.includes("OWN_GOAL")?[...v.result]:[]).flat(),d=await this.matchFacade.getMatchesMapWithNativeIds([o]);return p.length&&(n=await this.playerFacade.getPlayersMapWithNativeIds(p)),e.results=e.results.map(v=>{if(v.matchModel=d[v.matchId],v.playerModels&&Object.keys(n).length&&v.result.forEach(S=>{let q=n[S];v.playerModels.push(q)}),this.idMapping.idSchema!=="native"&&(v.matchId=d[v.matchId].id,v.playerModels&&Object.keys(n).length)){let w=v.result;v.result=w.map(S=>n[S].id)}return v}),e;case"TOP_X":let y=e.results.map(v=>v.matchId),g=await this.matchFacade.getMatchesMapWithNativeIds(y);if(e.results=e.results.map(v=>(v.matchModel=g[v.matchId],this.idMapping.idSchema!=="native"&&(v.matchId=g[v.matchId].id),v)),e.tieBreakers.goldenGoals.length){let v=e.tieBreakers.goldenGoals.map(S=>S.playerId),w=await this.playerFacade.getPlayersMapWithNativeIds(v);e.tieBreakers.goldenGoals=e.tieBreakers.goldenGoals.map(S=>(S.matchModel=g[S.matchId],S.playerModel=w[S.playerId],this.idMapping.idSchema!=="native"&&(S.matchId=g[S.matchId].id,S.playerId=w[S.playerId].id),S))}return e}};deleteUnexpectedProperties=e=>(e.status&&(console.warn(Cp.UNEXPECTED_STATUS_PROP),delete e.status),e.type&&(console.warn(Cp.UNEXPECTED_TYPE_PROP),delete e.type),e)};var cr=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new Zt(t.matchId,t.market,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var ur=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new bt(e),this.matchFacade=new zt(e,this.footballHttps,t),this.playerFacade=new Qt(e,this.footballHttps,t),this.predictorService=new _t(e,t),this.fixturesRemapper=new ko(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(n=>this.fixturesRemapper.remapFixturesRequest(n)),e instanceof cr&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{if(e.length){let t=[],n=[],o={},p=[];e.forEach(y=>{y.fixtures.forEach(g=>{t.push(g.match_id),g.player_id&&n.push(g.player_id)})});let d=await this.matchFacade.getMatchesMapWithNativeIds(t);return n.length>0&&(o=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.forEach(y=>{let g=new tn,v=[];g.id=y.id,g.gameInstanceId=y.game_instance_id,g.gameType=y.game_type,g.wager=y.wager,g.totalFixtures=y.total_fixtures,g.settledFixtures=y.settled_fixtures,g.userId=y.user_id,y.fixtures.forEach(w=>{let S=new rr;w.target?S.market=this.predictorService.convertMarketForResponseModel(w.market,w.target):S.market=w.market,S.matchId=d[w.match_id].id,S.matchType=w.match_type,S.matchModel=d[w.match_id],delete S.matchModel.availableMarkets,w.goals_home!==void 0&&w.goals_away!==void 0?S.prediction.value=w.goals_home.toString()+":"+w.goals_away.toString():S.prediction.value=w.prediction,S.prediction.playerId=w.player_id?w.player_id:null,S.prediction.playerId&&(S.prediction.playerModel=o[S.prediction.playerId],S.prediction.playerId=o[S.prediction.playerId].id),S.result=this.fixturesRemapper.remapResult(w.result),v.push(S)}),g.fixtures=v,g.status=y.status,y.tiebreaker?g.tiebreaker.goldenGoal=y.tiebreaker.golden_goal:g.tiebreaker=null,g.points=y.points,g.createdAt=y.created_at,g.updatedAt=y.updated_at,p.push(g)}),p}return e};remapResponseObjBody=async e=>{let t=new tn;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new sr;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS_0_5,t.overOnePointFiveGoals=e.OVER_GOALS_1_5,t.overTwoPointFiveGoals=e.OVER_GOALS_2_5,t.overThreePointFiveGoals=e.OVER_GOALS_3_5,t.overFourPointFiveGoals=e.OVER_GOALS_4_5,t.overFivePointFiveGoals=e.OVER_GOALS_5_5,t.overSixPointFiveGoals=e.OVER_GOALS_6_5,t.overSixPointFiveCorners=e.OVER_CORNERS_6_5,t.overSevenPointFiveCorners=e.OVER_CORNERS_7_5,t.overEightPointFiveCorners=e.OVER_CORNERS_8_5,t.overNinePointFiveCorners=e.OVER_CORNERS_9_5,t.overTenPointFiveCorners=e.OVER_CORNERS_10_5,t.overElevenPointFiveCorners=e.OVER_CORNERS_11_5,t.overTwelvePointFiveCorners=e.OVER_CORNERS_12_5,t.overThirteenPointFiveCorners=e.OVER_CORNERS_13_5,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.correctScoreHalfTime=e.CORRECT_SCORE_HT,t.correctScoreAdvanced=e.CORRECT_SCORE_ADVANCED,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var qo=class{matchId=null;matchType=null;predictions=null};var Wo=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new ur(e,t)}remapResponse=e=>{let t=new qo;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var Ko=class{matchId=null;matchType=null;market=null;matchModel=null};var Xo=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Yo=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Xo};var Qo=class{value=null;result=null};var zo=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Qo};var Jo=class{matchId=null;matchModel=null;outcome=null};var Zo=class{gameId=null;results=null;tieBreakers=null};var jo=class{entityId=null;entityType=null};var es=class{remapPaginatedGames=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapGamesListResponse(n)),t};remapGamesListResponse=e=>{let t=new yi;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.scheduleOpenAt=e.schedule_open_at,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(n=>this.remapFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new Ko;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserTopXEditions=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapUserTopXEditionsResponse(n)),t};remapUserTopXEditionsResponse=e=>{let t=new hi;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(n=>this.remapTopXFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new zo;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserMathQuizEditions=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapUserMatchQuizEditionsResponse(n)),t};remapUserMatchQuizEditionsResponse=e=>{let t=new Nt;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(n=>this.remapMatchQuizFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new Yo;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedGameResults=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapGameResults(n)),t};remapGameResults=e=>{let t=new gi;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(n=>this.remapResults(n)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapGameMarketsResults=e=>{let t=new Zo;return t.gameId=e.game_id,t.results=this.remapMarketsResults(e.results),t.tieBreakers=e.tie_breakers?this.remapTieBreakers(e.tie_breakers):null,t};remapTieBreakers=e=>{let t={goldenGoals:[]};return t.goldenGoals=e.golden_goals.map(n=>({minute:n.minute,matchId:n.match_id,matchModel:null,playerId:n.player_id,playerModel:null,goalType:n.goal_type})),t};remapMarketsResults=e=>{let t=[];return e.forEach(n=>{let o={matchId:n.match_id,market:n.market,result:this.remapMarketResult(n.market,n.result),matchModel:null,playerModels:[]};t.push(this.deleteUnusefulField(o))}),t};remapMarketResult=(e,t)=>{if(Cd.includes(e))return t[0];if(wt.includes(e))return t;if(t[0]==="true")return!0;if(t[0]==="false")return!1};deleteUnusefulField=e=>((!wt.includes(e.market)||this.isPlayerMarketWithNoResult(e.market,e.result))&&delete e.playerModels,e);isPlayerMarketWithNoResult=(e,t)=>wt.includes(e)&&t.length===0;remapResults=e=>{let t=new Jo;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new jt;return t.goldenGoal=e.golden_goal,t};remapTimeTiebreaker=e=>{let t=new vt;return t.timeTiebreaker=e,t};remapRelated=e=>e.map(t=>{let n=new jo;return n.entityId=t.entity_id,n.entityType=t.entity_type,n})};var ts=class{remapMetaData=e=>{let t=new Bi;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var ei=class extends Me{apiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){super(e,Oe(e.environment,"predictor"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new ur(e,t),this.matchSummaryRemapper=new Wo(e,t),this.gamesRemapper=new es,this.metaRemapper=new ts}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),n=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(n.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async(e,t)=>{let n=de(t)?`/predictions/summary/${e}${this.apiSignInUrl}${fe()}`:`/predictions/summary/${e}${this.apiSignInUrl}`;try{let o=await this.instance.get(n);return this.matchSummaryRemapper.remapResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching predictions for match: ${e} `,o),o.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=new re,n=`/predictions${this.apiSignInUrl}`;e&&(n+=`${e.constructFiltersUrl()}`);let o=await this.instanceAuth.get(n);return t.meta=this.metaRemapper.remapMetaData(o.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(o.data.data),t}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t,n)=>{try{let o=new re,p=de(t)?`/predictions/users/${e}${this.apiSignInUrl}${fe()}`:`/predictions/users/${e}${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return o.meta=this.metaRemapper.remapMetaData(d.data.meta),o.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),o}catch(o){throw console.warn(`There was a problem fetching predictions for user: ${e}`,o),o.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data}catch(n){throw console.warn(`There was a problem fetching predictions for user: ${e}`,n),n.response}};getGames=async(e,t)=>{try{let n=de(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${fe()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,o=await this.instance.get(n);return this.gamesRemapper.remapPaginatedGames(o.data)}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameById=async(e,t)=>{try{let n=de(t)?`/games/${e}${this.apiSignInUrl}${fe()}`:`/games/${e}${this.apiSignInUrl}`,o=await this.instance.get(n);return this.gamesRemapper.remapGamesListResponse(o.data)}catch(n){throw console.warn(`There was a problem fetching the following game: ${e}`,n),n.response}};getGamePredictions=async(e,t,n)=>{try{let o=new re,p=de(t)?`/games/${e}/predictions${this.apiSignInUrl}${fe()}`:`/games/${e}/predictions${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return o.meta=this.metaRemapper.remapMetaData(d.data.meta),o.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),o}catch(o){throw console.warn(`There was a problem fetching the predictions for game: ${e}`,o),o.response}};getUserGameEditions=async(e,t)=>{try{let n=null,o=de(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${fe()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,p=await this.instance.get(o);return p.data.data.forEach(d=>{d.type==="TOP_X"?n=this.gamesRemapper.remapPaginatedUserTopXEditions(p.data):d.type==="MATCH_QUIZ"&&(n=this.gamesRemapper.remapPaginatedUserMathQuizEditions(p.data))}),n}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameResults=async(e,t,n)=>{try{let o=de(t)?`/games/${e}/results/${this.apiSignInUrl}${fe()}`:`/games/${e}/results/${this.apiSignInUrl}`;n&&(o+=`${n.constructMainFiltersUrl()}`);let p=await this.instance.get(o);return this.gamesRemapper.remapPaginatedGameResults(p.data)}catch(o){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,o),o.response}};getMarketResultsForGame=async(e,t)=>{let n=`/games/${e}/correct-results/${this.apiSignInUrl}`;de(t)&&(n+=`${fe()}`);try{let o=await this.instance.get(n);return this.gamesRemapper.remapGameMarketsResults(o.data.data)}catch(o){throw console.warn(`There was a problem fetching the markets correct results for the following game: ${e}`,o),o.response}}};var mr=class{gameInstanceId=null;fixtures=null};var ne=class extends Error{code=0;status=null;message=null;constructor(e,t,n){super();this.code=e,this.status=t,this.message=n}errorMessage=()=>this.message};var xp=(n=>(n.ONE="1",n.X="x",n.TWO="2",n))(xp||{}),Ap=(n=>(n.ONE_X="1x",n.X_TWO="x2",n.ONE_TWO="12",n))(Ap||{}),Op=(v=>(v.ONE_ONE="1/1",v.ONE_X="1/x",v.ONE_TWO="1/2",v.X_ONE="x/1",v.X_X="x/x",v.X_TWO="x/2",v.TWO_ONE="2/1",v.TWO_X="2/x",v.TWO_TWO="2/2",v))(Op||{});var is=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var rs=class{value};var ns=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new rs,this.prediction.value=t}};var as=class{value=null};var os=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new as,this.prediction.value=t}};var ss=class{value=null};var ls=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new ss,this.prediction.value=n}};var ps=class{value=null};var cs=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ps,this.prediction.value=t}};var us=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var ms=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var ti=class{validateBodyFields=(e,t)=>{let n=Object.keys(t),o=Object.keys(new mr);switch(e){case"MATCH_QUIZ":n.forEach(g=>{o.includes(g)||this.throwInvalidParamException([g])});break;case"TOP_X":let d=t;d.fixtures.forEach(g=>this.validateMarketTopX(g.market));let y="tiebreaker";n.includes(y)&&d.tiebreaker&&this.validateTiebreaker(d.tiebreaker),n.forEach(g=>{g!=="tiebreaker"&&!o.includes(g)&&this.throwInvalidParamException([g])});break}let p=o.filter(d=>!n.includes(d));return p.length&&this.throwMissingFieldsException("game prediction body",p),t.fixtures.forEach(d=>{this.validateFixtureFields(d)}),t};validateFixture=(e,t,n,o)=>{this.validateMarket(t);let p=Object.values(xp),d=Object.values(Op),y=Object.values(Ap);if(t==="FT_1X2"||t==="HT_1X2"){if(p.includes(n))return new ls(e,t,n)}else if(t==="HT_FT"){if(d.includes(n))return new cs(e,n)}else if(t==="DOUBLE_CHANCE"){if(y.includes(n))return new os(e,n)}else if(t==="CORRECT_SCORE"||t==="CORRECT_SCORE_ADVANCED"||t==="CORRECT_SCORE_HT"){if(typeof n=="string"&&/\d+:\d+/.test(n))return new Zt(e,t,n)}else if(t==="CORNERS_MATCH"){if(typeof n=="number")return new ns(e,n)}else if(t==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(n))return new is(e,n)}else if(t==="RED_CARD_MATCH"){if(this.isPredictionBoolean(n))return new ms(e,n)}else if(t==="PENALTY_MATCH"){if(this.isPredictionBoolean(n))return new us(e,n)}else if(wt.includes(t)){let g="OWN_GOAL";if(this.validatePlayerId(t,o),t===Zr&&this.isPredictionBoolean(n)){let v=o&&o===g?g:o;return new tt(e,t,n,v)}if(o&&this.isPredictionBoolean(n))return new tt(e,t,n,o)}else if(Td.includes(t)){if(this.isPredictionBoolean(n))return new or(e,t,n)}else if(Ed.includes(t)&&this.isPredictionBoolean(n))return new ar(e,t,n);this.throwInvalidPredictionException(n,t)};validateFixtureFields=e=>{let t=Object.keys(e);t.forEach(o=>{Sp.includes(o)||this.throwInvalidParamException([o])});let n=Sp.filter(o=>{if(o!=="matchType"&&!t.includes(o))return o});n.length&&this.throwMissingFieldsException("fixtures",n),this.validatePredictionKey(e.market,e.prediction)};validateTiebreaker=e=>{let t=Object.keys(e);(!t.length||typeof e!="object")&&this.throwInvalidType("tiebreaker","object");let n=Object.keys(new jt)[0];t.forEach(o=>{n!==o&&this.throwInvalidParamException([o])}),t.includes(n)||this.throwMissingFieldsException("tiebreaker",[n]),typeof e.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(e,t)=>{if(typeof t=="object"){let n=Object.keys(t),o=["value"];if(n.length||this.throwMissingFieldsException("prediction",o),n.length===1&&!n.includes(o[0])&&this.throwInvalidParamException(n),n.length>1){wt.includes(e)&&o.push("playerId");let p=n.filter(d=>!o.includes(d));p.length&&this.throwInvalidParamException(p)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(e,t)=>{let n="playerId";e!==Zr&&(t||this.throwInvalidParamException([n]),typeof t!="string"&&this.throwInvalidType(n,"string"))};validateMarket=e=>{Object.values(Pe).includes(e)||this.throwInvalidMarketException(e)};validateMarketTopX=e=>{e!=="CORRECT_SCORE"&&e!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(e,"TOP_X")};isPredictionBoolean=e=>typeof e=="boolean";throwInvalidPredictionException=(e,t)=>{let n=xd(e,t);throw new ne(400,"INVALID_PREDICTION",n)};throwInvalidMarketException=(e,t)=>{let n=null;throw t&&t==="TOP_X"?n=Ad(e):n=Vo(e),new ne(400,"INVALID_MARKET",n)};throwInvalidParamException=e=>{let t=Od(e);throw new ne(400,"INVALID_FIELD",t)};throwMissingFieldsException=(e,t)=>{let n=Bd(e,t);throw new ne(400,"INVALID_FIELD",n)};throwInvalidType=(e,t)=>{let n=Ld(e,t);throw new ne(400,"INVALID_TYPE",n)}};var fs=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;constructor(e,t,n,o){this.predictorHttps=t,this.idMapping=o,this.clientHttps=n,this.predictorValidator=new ti,this.predictorService=new _t(e,o)}makeFootballPrediction=async(e,t,n,o)=>{let p=this.predictorValidator.validateFixture(e,t,n,o),d=new mr;if(this.idMapping.idSchema!=="native"){let y=p.matchId,g="",v=await this.predictorService.remapMatchIdToNative([y]);if(p.matchId=v[0],!p.matchId)throw new ne(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(p instanceof tt&&p.prediction.playerId!=="OWN_GOAL"&&(p.prediction.playerId&&(g=p.prediction.playerId,p.prediction.playerId=await this.predictorService.remapPlayerIdToNative([g])),p.market!==Zr&&!p.prediction.playerId))throw new ne(400,"INVALID_FIELD","Player id is invalid!").errorMessage();d.fixtures=[p];let w=await this.predictorHttps.makeFootballPrediction(d);return w.fixtures.forEach(S=>{S.prediction.playerId&&S.prediction.playerId!=="OWN_GOAL"&&(S.prediction.playerId=g),S.matchId=y}),w}else return d.fixtures=[p],await this.predictorHttps.makeFootballPrediction(d)};getMatchSummary=async(e,t)=>{if(this.idMapping.idSchema!=="native"){let o=(await this.predictorService.remapMatchIdToNative([e]))[0],p=await this.predictorHttps.getMatchSummary(o,t);p.matchId=e;let d=p.predictions,y=await this.predictorService.remapPlayerIdToIdSchema(d);return p.predictions=y,p}else return await this.predictorHttps.getMatchSummary(e,t)};getMarketSummary=async(e,t,n,o)=>{try{let p=await this.getMatchSummary(e,o);return this.predictorService.getMarketSummary(p,t,n)}catch(p){return p.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getMyPredictions(t)};getMyPredictionsForMatches=async(e,t)=>{if(this.predictorService.areIdsExceeded(e))throw new ne(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let n=this.predictorService.initPredictionsFilters(t,"matches",e);return await this.predictorHttps.getMyPredictions(n)};getMyCurrentPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getMyPredictions(t)};getMyPastPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getMyPredictions(t)};getUserPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserCurrentPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserPastPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserPredictionsForMatches=async(e,t,n,o)=>{if(this.predictorService.areIdsExceeded(t))throw new ne(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let p=this.predictorService.initPredictionsFilters(n,"matches",t);return await this.predictorHttps.getUserPredictions(e,o,p)}};var hs=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new ae(e),this.predictorHttps=new ei(e,this.idMapping),this.clientHttps=new et(e),this.predictorFacade=new fs(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,n,o)=>await this.predictorFacade.makeFootballPrediction(e,t,n,o);getMatchSummary=async(e,t)=>await this.predictorFacade.getMatchSummary(e,t);getMarketSummary=async(e,t,n,o)=>await this.predictorFacade.getMarketSummary(e,t,n,o);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getMyPredictionsForMatches=async(e,t)=>await this.predictorFacade.getMyPredictionsForMatches(e,t);getUserPredictions=async(e,t,n)=>await this.predictorFacade.getUserPredictions(e,t,n);getUserCurrentPredictions=async(e,t,n)=>await this.predictorFacade.getUserCurrentPredictions(e,t,n);getUserPastPredictions=async(e,t,n)=>await this.predictorFacade.getUserPastPredictions(e,t,n);getUserPredictionsForMatches=async(e,t,n,o)=>await this.predictorFacade.getUserPredictionsForMatches(e,t,n,o)};var gs=class{rankType=null;fromDate=null;toDate=null;pagination=new Qi};var dr=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var ys=class{remapResponse=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new gs;return t.rankType=e.rank_type,t.fromDate=e.from_date,t.toDate=e.to_date,t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t};remapData=e=>{let t=[];return e.forEach(n=>{let o=new dr;o.position=n.position,o.profileId=n.profile_id,o.points=n.points,o.predictionsMade=n.predictions_made,t.push(o)}),t}};var Ms=class extends dr{id=null;rankType=null;model=null;gameType=null};var bs=class{remapRankings=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.numberOfPages=e.pagination.number_of_pages,t.pagination.totalItems=e.pagination.total_items,t};remapData(e){let t=[];return e.forEach(n=>{let o=new Ms;o.id=n.id,o.rankType=n.rank_type,o.position=n.position,o.points=n.points,o.gameType=n.game_type,delete o.profileId,delete o.profileModel,delete o.predictionsMade,t.push(o)}),t}};var ws=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;flags=null;images=new pr;status=null;automaticallyChangeStatus=!0};var vs=class{remapResponse=e=>{let t=[];return e.forEach(n=>{let o=new ws;o.id=n.id,o.name=n.name,o.description=n.description,o.type=n.type,o.fromDate=n.from_date,o.toDate=n.to_date,o.markets=n.markets?n.markets:null,o.teamIds=n.team_ids?n.team_ids:null,o.matchIds=n.match_ids?n.match_ids:null,o.gameIds=n.game_ids?n.game_ids:null,o.gameTypes=n.game_types?n.game_types:null,o.competitionIds=n.competition_ids?n.competition_ids:null,o.excludedProfileIds=n.excluded_profile_ids?n.excluded_profile_ids:null,o.rules=n.rules?n.rules:null,o.flags=n.flags?n.flags:null,o.images=n.images?n.images:null,o.status=n.status?n.status:null,o.automaticallyChangeStatus=n.automatically_change_status,t.push(o)}),t};remapMeta=e=>{let t={};return t.totalItems=e.pagination.total_items,t}};var _s=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Is=class{remapHighestSuccessRate=e=>e.map(t=>{let n=new _s;return n.position=t.position,n.points=t.points,n.predictionsMade=t.predictions_made,n.profileId=t.profile_id,n.successRatePercent=t.success_rate_percent,n})};var Ps=class extends Me{apiSignInUrl=null;templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(e){super(e,Oe(e.environment,"loyalty"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.templateRemapper=new vs,this.leaderboardRemapper=new ys,this.rankingsRemapper=new bs,this.highestSuccessRateRemapper=new Is}getTemplates=async(e,t)=>{try{let n=de(e)?`/leaderboard/templates/${this.apiSignInUrl}${fe()}`:`/leaderboard/templates/${this.apiSignInUrl}`,o=await this.instance.get(n);if(t){let p=JSON.parse(JSON.stringify(o.data));return p.meta=this.templateRemapper.remapMeta(o.data.meta),p.data=this.templateRemapper.remapResponse(o.data.data),p}return this.templateRemapper.remapResponse(o.data.data)}catch(n){throw console.warn("There was a problem fetching the list of templates",n),n.response}};getLeaderboard=async(e,t,n)=>{try{let o=de(t)?`/leaderboard/${e}/${this.apiSignInUrl}${fe()}`:`/leaderboard/${e}/${this.apiSignInUrl}`;n&&(o+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(o),d=JSON.parse(JSON.stringify(p.data));return this.leaderboardRemapper.remapResponse(d)}catch(o){throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,o),o.response}};getLeaderboardForGame=async(e,t,n)=>{try{let o=de(t)?`/leaderboard/games/${e}/${this.apiSignInUrl}${fe()}`:`/leaderboard/games/${e}/${this.apiSignInUrl}`;n&&(o+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(o),d=JSON.parse(JSON.stringify(p.data));return ta(d)}catch(o){throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,o),o.response}};getUserRankings=async(e,t,n)=>{let o=`/leaderboard/users/${e}/rankings/${this.apiSignInUrl}`;t&&(o+=`${t.constructFiltersUrl()}`),de(n)&&(o+=`${fe()}`);try{let p=await this.instance.get(o);return this.rankingsRemapper.remapRankings(p.data)}catch(p){throw console.warn(`There was a problem fetching the rankings for the following user: ${e}`,p),p.response}};getHighestSuccessRate=async(e,t)=>{let n=de(t)?`/statistics/top${this.apiSignInUrl}${fe()}`:`/statistics/top${this.apiSignInUrl}`;e&&(n+=`&market=${e}`);try{let o=await this.instance.get(n);return this.highestSuccessRateRemapper.remapHighestSuccessRate(o.data.data)}catch(o){throw console.warn("There was a problem fetching highest success rate",o),o.response}}};var Rs=class{general;predictor;topX;matchQuiz};var fr=class{limit=null;page=null;constructor(e){this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null}constructFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.page&&(e+="&",e+=`page=${this.page}`),e}};var Fs=class extends fr{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(e){super(e);this.sortOrder=e.sortOrder,this.rankType=e.rankType,this.leaderboardIds=e.leaderboardIds,this.gameType=e.type&&e.type.toLowerCase()==="game"?e.gameType:null}constructFiltersUrl=()=>{let e=super.constructFiltersUrl();return this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),this.rankType&&(e+="&",e+=`rank_type=${this.rankType}`),this.leaderboardIds&&(e+="&",e+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(e+="&",e+=`game_type=${this.gameType}`),e}};var Ss=class{idMappingService=null;profileNamespace=null;constructor(e){this.idMappingService=new ae(e),this.profileNamespace=new er(e)}remapTemplatesIds=async e=>{if(e.length>0){let t=[],n=[],o=[],p=[],d=[],y=[];e.forEach(w=>{w.teamIds&&w.teamIds.length>0?t=[...t,...w.teamIds]:w.matchIds&&w.matchIds.length>0?o=[...o,...w.matchIds]:w.competitionIds&&w.competitionIds.length>0&&(d=[...d,...w.competitionIds])});let g={team:t,match:o,competition:d},v=await this.idMappingService.idMappingFacade.getEntitiesByIds(g,"native",this.idMappingService.idSchema);return n=[...v.team],p=[...v.match],y=[...v.competition],e.forEach(w=>{w.teamIds&&w.teamIds.length>0?w.teamIds=w.teamIds.map(S=>S=v.team.shift()):w.matchIds&&w.matchIds.length>0?w.matchIds=w.matchIds.map(S=>S=v.match.shift()):w.competitionIds&&w.competitionIds.length>0&&(w.competitionIds=w.competitionIds.map(S=>S=v.competition.shift()))}),e}return e};addProfileModelToLeaderboad=async e=>{if(e.length>0){let t=[],n=[];e.forEach(p=>{t.push(p.profileId)});let o=await this.profileNamespace.getByIds(t);return e.forEach(p=>{o.forEach(d=>{d.id===p.profileId&&(delete d.interests,p.profileModel=d)}),p.profileModel||(p.profileModel=null),n.push(p)}),n}return e};buildClientBadges=e=>{let t=new Rs;return t.general=this.extractEnabledBadgesId(e.general),t.predictor=this.extractEnabledBadgesId(e.predictor),t.topX=this.extractEnabledBadgesId(e.topX),t.matchQuiz=this.extractEnabledBadgesId(e.matchQuiz),t};initFilters=(e,t)=>{switch(t){case"loyalty":e&&(e=new fr(e));break;case"rankings":e&&(e=new Fs(e));break}return e};addProfileModelToHighestSuccessRate=async e=>{let t=e.map(o=>o.profileId),n=await this.profileNamespace.getByIds(t);return e.map(o=>(n.forEach(p=>{p.id===o.profileId&&(delete p.interests,o.profileModel=p)}),o))};extractRankingsIdsMap=e=>{let t=[],n=[],o=[];return e.forEach(p=>{p.rankType==="GAME"&&p.gameType==="TOP_X"?t.push(p.id):p.rankType==="GAME"&&p.gameType==="MATCH_QUIZ"?n.push(p.id):p.rankType==="TEMPLATE"&&o.push(p.id)}),[t,n,o]};setModelsForUserRankings=(e,t,n,o)=>(o.data.forEach(p=>{p.gameType==="MATCH_QUIZ"&&t?p.model=t.filter(d=>d.id===p.id)[0]:p.gameType==="TOP_X"&&e?p.model=e.filter(d=>d.id===p.id)[0]:p.rankType==="TEMPLATE"&&n&&(p.model=n.filter(d=>d.id===p.id)[0])}),o);extractEnabledBadgesId=e=>{let t=[];return e.forEach(n=>{n.enabled&&t.push(n.id)}),t}};var Ts=class{validateMarket=e=>{if(!Object.keys(Pe).includes(e)){let n=Vo(e);throw new ne(400,"INVALID_MARKET",n)}}};var hr=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;constructor(e,t){this.idMapping=t,this.predictorValidator=new ti,this.predictorHttps=new ei(e,t),this.predictorService=new _t(e,t),this.clientHttps=new et(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};getGames=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameFilters("TOP_X",e),o=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getGameById=async(e,t)=>{t=t||!1;let n=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,t,n)=>(n=n||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new Re(t)),await this.predictorHttps.getGamePredictions(e,n,t));getGameResults=async(e,t,n)=>{n=n||!1,t&&(t=new rt(t));let o=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new rt(t);let n=await this.predictorHttps.getGames(t,e),o=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(o,null,e)).data[0]};play=async e=>{let t=new cr(e);if(t=this.predictorValidator.validateBodyFields("TOP_X",t),t.fixtures=t.fixtures.map(o=>this.predictorValidator.validateFixture(o.matchId,o.market,o.prediction.value)),this.idMapping.idSchema!=="native"){let o=[];t.fixtures.forEach(d=>o.push(d.matchId));let p=await this.predictorService.remapMatchIdToNative(o);t.fixtures.forEach(d=>d.matchId=p.shift())}let n=await this.predictorHttps.makeFootballPrediction(t);return n.fixtures.forEach(o=>{o.matchId=o.matchModel.id}),n};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let n=this.predictorService.initGameTypePredictions("TOP_X",e),o=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.data.length>0){p.data.forEach(g=>{g.game_instance_id&&o.push(g.game_instance_id)});let d=this.predictorService.initGameFilters("TOP_X",null,o),y=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,y)}else return new re};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),n=await this.predictorHttps.getMyPredictions(t);if(n.data.length>0){let o=n.data.filter(p=>p.gameInstanceId===e);return o.length?o[0]:null}return null};getUserGameEditions=async(e,t,n)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),n=n||!1;let o=this.predictorService.initGameTypePredictions("TOP_X",t),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,o);if(d.data.length>0){d.data.forEach(v=>{v.game_instance_id&&p.push(v.game_instance_id)});let y=this.predictorService.initGameFilters("TOP_X",null,p),g=await this.predictorHttps.getUserGameEditions(y,n);return await this.predictorService.addPredictionProp(d,g)}else return new re};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("TOP_X"),p=await this.predictorHttps.getUserPredictions(e,n,o);if(p.data.length>0){let d=p.data.filter(y=>y.gameInstanceId===t);return d.length?d[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"TOP_X")};validateLimitFilterOnGames=e=>{if(e>50)throw new ne(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var gr=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;constructor(e){this.predictorValidator=new ti,this.idMapping=new ae(e),this.predictorHttps=new ei(e,this.idMapping),this.predictorService=new _t(e,this.idMapping),this.clientHttps=new et(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};play=async e=>{e=this.predictorValidator.validateBodyFields("MATCH_QUIZ",e);let t=e.fixtures.map(n=>this.predictorValidator.validateFixture(n.matchId,n.market,n.prediction.value,n.prediction.playerId));if(t&&t.length&&this.idMapping.idSchema!=="native"){let n=[],o=[];t.forEach(y=>{n.push(y.matchId),y instanceof tt&&y.prediction.playerId&&y.prediction.playerId!=="OWN_GOAL"&&o.push(y.prediction.playerId)});let p=await this.predictorService.remapMatchIdToNative(n),d={};o&&o.length>0&&(d=await this.predictorService.remapPlayerIdMapToNative(o)),t.forEach((y,g)=>{y.matchId=p[g],y instanceof tt&&y.prediction.playerId!=="OWN_GOAL"&&(y.prediction.playerId=d[y.prediction.playerId])})}return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameFilters("MATCH_QUIZ",e),o=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getGameById=async(e,t)=>{t=t||!1;let n=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,t,n)=>(n=n||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new Re(t)),await this.predictorHttps.getGamePredictions(e,n,t));getGameResults=async(e,t,n)=>{n=n||!1,t&&(t=new lr(t));let o=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"MATCH_QUIZ"};t=new rt(t);let n=await this.predictorHttps.getGames(t,e),o=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(o,null,e)).data[0]};getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let n=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),o=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.data.length>0){p.data.forEach(g=>{g.game_instance_id&&o.push(g.game_instance_id)});let d=this.predictorService.initGameFilters("MATCH_QUIZ",null,o),y=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,y)}else return new re};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),n=await this.predictorHttps.getMyPredictions(t);if(n.data.length>0){let o=n.data.filter(p=>p.gameInstanceId===e);return o.length?o[0]:null}return null};getUserGameEditions=async(e,t,n)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),n=n||!1;let o=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,o);if(d.data.length>0){d.data.forEach(v=>{v.game_instance_id&&p.push(v.game_instance_id)});let y=this.predictorService.initGameFilters("MATCH_QUIZ",null,p),g=await this.predictorHttps.getUserGameEditions(y,n);return await this.predictorService.addPredictionProp(d,g)}else return new re};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),p=await this.predictorHttps.getUserPredictions(e,n,o);if(p.data.length>0){let d=p.data.filter(y=>y.gameInstanceId===t);return d.length?d[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"MATCH_QUIZ")};validateLimitFilterOnGames=e=>{if(e>50)throw new ne(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var Es=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;constructor(e,t,n,o,p){this.config=e,this.clientHttps=t,this.loyaltyHttps=n,this.profileFacade=new Mt(p,o),this.loyaltyService=new Ss(this.config),this.loyaltyValidator=new Ts,this.idMapping=new ae(e),this.topXFacade=new hr(e,this.idMapping),this.matchQuizFacade=new gr(e)}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let e=await this.getConfig();return this.loyaltyService.buildClientBadges(e.rewards.badges)};getTemplates=async e=>{let t=!0;if(this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(e,t);let n=await this.loyaltyHttps.getTemplates(e,t);return n.data=await this.loyaltyService.remapTemplatesIds([...n.data]),n};getTemplateById=async(e,t)=>{try{let n=!1,p=(await this.loyaltyHttps.getTemplates(t,n)).filter(y=>y.id===e);if(!p.length)throw new ne(400,"INVALID_TEMPLATE","Provided template ID does NOT exist! Try again with existing template ID.").errorMessage();return this.config.idSchema==="native"?p[0]:(await this.loyaltyService.remapTemplatesIds(p))[0]}catch(n){throw console.warn("There was a problem retrieving specified template: ",n),n}};getLeaderboard=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let o=await this.loyaltyHttps.getLeaderboard(e,n,t);return o.data=await this.loyaltyService.addProfileModelToLeaderboad(o.data),o};getLeaderboardForGame=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let o=await this.loyaltyHttps.getLeaderboardForGame(e,n,t);return o.data=await this.loyaltyService.addProfileModelToLeaderboad(o.data),o};getOwnRankings=async(e,t)=>{let{id:n}=await this.profileFacade.getOwn();return this.getUserRankings(n,e,t)};getUserRankings=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"rankings");let o=await this.loyaltyHttps.getUserRankings(e,t,n);return await this.getModelsForUserRankings(o)};getHighestSuccessRate=async(e,t)=>{e&&this.loyaltyValidator.validateMarket(e);let n=await this.loyaltyHttps.getHighestSuccessRate(e,t);return this.loyaltyService.addProfileModelToHighestSuccessRate(n)};getModelsForUserRankings=async e=>{let t=null,n=null,o=null,[p,d,y]=this.loyaltyService.extractRankingsIdsMap(e.data);if(y.length&&(t=(await this.getTemplates()).data.filter(v=>y.includes(v.id))),p.length){let g={gameIds:p};n=(await this.topXFacade.getGames(g)).data}if(d.length){let g={gameIds:d};o=(await this.matchQuizFacade.getGames(g)).data}return this.loyaltyService.setModelsForUserRankings(n,o,t,e)}};var Cs=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localStorage=null;constructor(e){this.clientHttps=new et(e),this.profileHttps=new Ui(e),this.loyaltyHttps=new Ps(e),this.localStorage=new yt(e),this.loyaltyFacade=new Es(e,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localStorage)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getTemplates=async e=>await this.loyaltyFacade.getTemplates(e);getTemplateById=async(e,t)=>await this.loyaltyFacade.getTemplateById(e,t);getLeaderboard=async(e,t,n)=>await this.loyaltyFacade.getLeaderboard(e,t,n);getLeaderboardForGame=async(e,t,n)=>await this.loyaltyFacade.getLeaderboardForGame(e,t,n);getOwnRankings=async(e,t)=>await this.loyaltyFacade.getOwnRankings(e,t);getUserRankings=async(e,t,n)=>await this.loyaltyFacade.getUserRankings(e,t,n);getHighestSuccessRate=async(e,t)=>await this.loyaltyFacade.getHighestSuccessRate(e,t)};var xs=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new ae(e),this.topXFacade=new hr(e,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(e,t)=>await this.topXFacade.getGames(e,t);getGameById=async(e,t)=>await this.topXFacade.getGameById(e,t);getGamePredictions=async(e,t,n)=>await this.topXFacade.getGamePredictions(e,t,n);getGameResults=async(e,t,n)=>await this.topXFacade.getGameResults(e,t,n);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,t)=>await this.topXFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,n)=>await this.topXFacade.getUserGameEditions(e,t,n);getUserGamePrediction=async(e,t,n)=>await this.topXFacade.getUserGamePrediction(e,t,n);getMarketsResultsForGame=async(e,t)=>await this.topXFacade.getMarketsResultsForGame(e,t)};var As=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new gr(e)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,t)=>await this.matchQuizFacade.getGames(e,t);getGameById=async(e,t)=>await this.matchQuizFacade.getGameById(e,t);getGamePredictions=async(e,t,n)=>await this.matchQuizFacade.getGamePredictions(e,t,n);getGameResults=async(e,t,n)=>await this.matchQuizFacade.getGameResults(e,t,n);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,t)=>await this.matchQuizFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,n)=>await this.matchQuizFacade.getUserGameEditions(e,t,n);getUserGamePrediction=async(e,t,n)=>await this.matchQuizFacade.getUserGamePrediction(e,t,n);getMarketsResultsForGame=async(e,t)=>await this.matchQuizFacade.getMarketsResultsForGame(e,t)};var an=class{action=null;page=null;limit=null;constructor(e){this.action=e.action?e.action:null,this.page=e.page?e.page:null,this.limit=e.limit?e.limit:null}constructFilterUrl=()=>{let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var on=class{action=null;context=new Ji;constructor(e,t,n,o){this.action=e,this.context.tags=t,n&&(this.context.content=n),o&&(this.context.campaign=o)}};var Os=class{idSchema;idMapping;constructor(e){this.idSchema=e.idSchema,this.idMapping=new ae(e)}remapTagsIds=async(e,t,n)=>{let o={},p={},d=[];e.forEach(g=>{o.hasOwnProperty(g.type)||(o[g.type]=[],p[g.type]=[]),o[g.type].push(g.id),p[g.type].push(g)});let y=await this.idMapping.idMappingFacade.getEntitiesByIds(o,t,n);for(let[g,v]of Object.entries(p))v.forEach((w,S)=>{w.id=y[g][S],d.push(w)});return d}};var Bs=class{idSchema;activityHttps;activityService;constructor(e){this.idSchema=e.idSchema,this.activityHttps=new ji(e),this.activityService=new Os(e)}add=async(e,t,n,o)=>{if(this.idSchema!="native"){let d=JSON.parse(JSON.stringify(t)),y=await this.activityService.remapTagsIds(t,this.idSchema,"native"),g=new on(e,y,n,o),v=await this.activityHttps.createActivity(g);return v.context.tags=d,v}let p=new on(e,t,n,o);return this.activityHttps.createActivity(p)};delete=async e=>await this.activityHttps.deleteActivity(e);like=async(e,t,n)=>{let o="like";return await this.add(o,e,t,n)};dislike=async(e,t,n)=>{let o="dislike";return await this.add(o,e,t,n)};addPageview=async(e,t,n)=>{let o="page_view";return await this.add(o,e,t,n)};addContentConsumed=async(e,t,n)=>{let o="content_consumed";return await this.add(o,e,t,n)};addShare=async(e,t,n)=>{let o="share";return await this.add(o,e,t,n)};addComment=async(e,t,n)=>{let o="comment";return await this.add(o,e,t,n)};addClickAd=async(e,t,n)=>{let o="click_ad";return await this.add(o,e,t,n)};addConversion=async(e,t,n)=>{let o="conversion";return await this.add(o,e,t,n)};getOwn=async(e,t)=>{if(t=t||!1,e&&(e=new an(e)),this.idSchema!="native"){let n=await this.activityHttps.getOwnActivities(e,t);for(let o of n.data)await this.activityService.remapTagsIds(o.context.tags,"native",this.idSchema);return n}return await this.activityHttps.getOwnActivities(e,t)};getForUser=async(e,t,n)=>{if(n=n||!1,t&&(t=new an(t)),this.idSchema!="native"){let o=await this.activityHttps.getActivitiesForUser(e,t,n);for(let p of o.data)await this.activityService.remapTagsIds(p.context.tags,"native",this.idSchema);return o}return await this.activityHttps.getActivitiesForUser(e,t,n)}};var Ls=class{activityFacade;constructor(e){this.activityFacade=new Bs(e)}add=async(e,t,n,o)=>await this.activityFacade.add(e,t,n,o);delete=async e=>await this.activityFacade.delete(e);like=async(e,t,n)=>await this.activityFacade.like(e,t,n);dislike=async(e,t,n)=>await this.activityFacade.dislike(e,t,n);addPageview=async(e,t,n)=>await this.activityFacade.addPageview(e,t,n);addContentConsumed=async(e,t,n)=>await this.activityFacade.addContentConsumed(e,t,n);addShare=async(e,t,n)=>await this.activityFacade.addShare(e,t,n);addComment=async(e,t,n)=>await this.activityFacade.addComment(e,t,n);addClickAd=async(e,t,n)=>await this.activityFacade.addClickAd(e,t,n);addConversion=async(e,t,n)=>await this.activityFacade.addConversion(e,t,n);getOwn=async(e,t)=>await this.activityFacade.getOwn(e,t);getForUser=async(e,t,n)=>await this.activityFacade.getForUser(e,t,n)};function wB(s){let t=new No().validate(s);if((t.idSchema.validation==="missing"||t.idSchema.validation==="invalid")&&(console.warn(t.idSchema.message.text),s.idSchema="native"),(t.environment.validation==="missing"||t.environment.validation==="invalid")&&(console.warn(t.environment.message.text),s.environment="prod"),(t.lang.validation==="missing"||t.lang.validation==="invalid")&&(console.warn(t.lang.message.text),s.lang="en"),t.authProvider.validation==="invalid"&&console.warn(t.authProvider.message.text),t.isValid)return{profile:new er(s),football:new Do(s),predictor:new hs(s),loyalty:new Cs(s),topX:new xs(s),matchQuiz:new As(s),activity:new Ls(s)};N_(t)}var N_=s=>{let e="authProvider",t="isValid";Object.keys(s).forEach(n=>{let o=s[n];if(n!==t&&n!==e){if(o.message.type==="error")throw new Error(o.message.text)}else n!==t&&n===e&&Object.keys(new fi).forEach(p=>{if(o[p].message.type==="error")throw new Error(o[p].message.text)})})};export{wB as FansUnitedSDK};
|
|
24
24
|
/**
|
|
25
25
|
* @license
|
|
26
26
|
* Lodash <https://lodash.com/>
|