game.js 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449
  1. /*! game-api - v0.21.2 - 2015-07-31 */
  2. (function(e) {
  3. "use strict";
  4. function t() {}
  5. function n(e) {
  6. if (e = e || {},
  7. this.IS_MASTER = e.isMaster || !1, !this.IS_MASTER) throw Error("The DataStore can only be instantiated by the Master");
  8. this.dataStore = {}
  9. }
  10. function i(e, t) {
  11. e = e || {},
  12. this.IS_MASTER = e.isMaster,
  13. this.IS_SLAVE = !this.IS_MASTER,
  14. this.IS_STANDALONE = e.isStandalone,
  15. this.messenger = e.messenger,
  16. this.moduleReady = t || !1,
  17. this.appTimer = null,
  18. this.appDelayMin = 1e4,
  19. this.appDelayMax = 24e4,
  20. this.appError = !1,
  21. this.appTimerDelay = this.appDelayMax,
  22. this.appToken = null
  23. }
  24. function a(e, t) {
  25. e = e || {},
  26. this.IS_MASTER = e.isMaster,
  27. this.IS_SLAVE = !this.IS_MASTER,
  28. this.IS_STANDALONE = e.isStandalone,
  29. this.messenger = e.messenger,
  30. this.eventTracking = e.eventTracking,
  31. this.appToken = e.appToken,
  32. this.moduleReady = t || !1,
  33. this.isGamestate = !1,
  34. this.endpoint = null,
  35. this.spilStorageId = null,
  36. this.flushTimer = null,
  37. this.flushDelayMin = 500,
  38. this.flushDelayMax = 3e4,
  39. this.flushTimerDelay = this.flushDelayMin,
  40. this.gameState = {
  41. started: !1,
  42. userId: null,
  43. appId: null,
  44. dirtyKeys: []
  45. }
  46. }
  47. function s(e, t) {
  48. if (this.IS_MASTER = e && e.isMaster ? e.isMaster: !1, this.IS_SLAVE = !this.IS_MASTER, this.messenger = null, this.subscribers = {},
  49. this.moduleReady = t ? t: !1, this.data = e.data || null, this.gameState = "resume", !e || !e.messenger) throw Error("No messenger passed to the Game module instance");
  50. this.messenger = e.messenger,
  51. window.addEventListener ? window.addEventListener("message", this._performAction.bind(this), !1) : window.attachEvent && window.attachEvent("onmessage", this._performAction.bind(this)),
  52. this.IS_MASTER && this.messenger.subscribe("gameapi.game.adjustHeight", this.adjustHeight, this)
  53. }
  54. function r(e, t) {
  55. e = e || {},
  56. this.isMaster = e.isMaster,
  57. this.isStandalone = e.isStandalone,
  58. this.messenger = e.messenger,
  59. this.moduleReady = t ? t: !1
  60. }
  61. function o(e, t) {
  62. e = e || {},
  63. this.IS_MASTER = e.isMaster,
  64. this.IS_STANDALONE = e.isStandalone,
  65. this.messenger = e.messenger,
  66. this.eventTracking = e.eventTracking,
  67. this.moduleReady = t ? t: !1,
  68. this.isAvailable = !1,
  69. this.locale = ""
  70. }
  71. function l(e, t) {
  72. e = e || {},
  73. this.IS_MASTER = e.isMaster,
  74. this.IS_STANDALONE = e.isStandalone,
  75. this.messenger = e.messenger,
  76. this.eventTracking = e.eventTracking,
  77. this.moduleReady = t ? t: !1,
  78. this.isAvailable = !1
  79. }
  80. function p(e, t) {
  81. e = e || {},
  82. this.IS_MASTER = e.isMaster,
  83. this.IS_SLAVE = !this.IS_MASTER,
  84. this.moduleReady = t ? t: !1,
  85. this.messenger = e.messenger,
  86. this.data = e.data || null,
  87. this.eventTracking = e.eventTracking,
  88. this.initialHeight = e.initialHeight,
  89. this._setupMasterEvent()
  90. }
  91. function u(e, t) {
  92. e = e || {},
  93. this.IS_MASTER = e.isMaster,
  94. this.IS_SLAVE = !this.IS_MASTER,
  95. this.moduleReady = t ? t: !1,
  96. this.messenger = e.messenger,
  97. this.data = e.data || null,
  98. this.eventTracking = e.eventTracking,
  99. this.initialHeight = e.initialHeight,
  100. this._setupMasterEvent()
  101. }
  102. function d(e, t) {
  103. e = e || {},
  104. this.isMaster = e.isMaster,
  105. this.isStandalone = e.isStandalone,
  106. this.messenger = e.messenger,
  107. this.moduleReady = t ? t: !1,
  108. this.timeoutAfter = 500,
  109. this.timeout = !1,
  110. this.adRequested = !1,
  111. this._callbacks = {
  112. pause: !1,
  113. resume: !1
  114. }
  115. }
  116. function c(e, t) {
  117. e = e || {},
  118. this.IS_MASTER = e.isMaster,
  119. this.isStandalone = e.isStandalone,
  120. this.messenger = e.messenger,
  121. this.eventTracking = e.eventTracking,
  122. this.moduleReady = t ? t: !1,
  123. this.events = {
  124. GAME_START: "GAME_START",
  125. GAME_END: "GAME_END",
  126. GAME_PAUSE: "GAME_PAUSE",
  127. GAME_CONTINUE: "GAME_CONTINUE",
  128. GAME_MUTE: "GAME_MUTE",
  129. LEVEL_FAIL: "LEVEL_FAIL",
  130. LEVEL_COMPLETE: "LEVEL_COMPLETE"
  131. },
  132. this._setupEvents()
  133. }
  134. function h(e, t) {
  135. e = e || {},
  136. this.IS_MASTER = e.isMaster,
  137. this.IS_SLAVE = !this.IS_MASTER,
  138. this.IS_STANDALONE = e.isStandalone,
  139. this.data = e.data,
  140. this.messenger = e.messenger,
  141. this.moduleReady = t ? t: !1,
  142. this.gamePlayTracking = {
  143. started: !1,
  144. appid: null,
  145. host: null,
  146. timestamp: null
  147. },
  148. this.timeInGameTracking = {
  149. started: !1,
  150. appid: null,
  151. timestamp: null
  152. },
  153. this.isGamestate = !1
  154. }
  155. function g(e, t) {
  156. e = e || {},
  157. this.IS_MASTER = e.isMaster,
  158. this.IS_SLAVE = !this.IS_MASTER,
  159. this.IS_STANDALONE = e.isStandalone,
  160. this.moduleReady = t ? t: !1,
  161. this.messenger = e.messenger,
  162. this.components = e.components,
  163. this.data = e.data || null
  164. }
  165. function f(e) {
  166. var t = "string" == typeof e ? m(e) : e;
  167. t && (this.type = t.type, this.callbackId = t.callbackId, this.data = t.data)
  168. }
  169. function m(e) {
  170. var t, n, i, a = !1,
  171. s = [];
  172. if ("string" == typeof e && (s = e.split("|"), "gameapi" === s[0])) {
  173. s.shift(),
  174. t = s.shift(),
  175. i = parseInt(s.shift(), 10),
  176. n = s.join("|");
  177. try {
  178. a = {
  179. type: t,
  180. callbackId: i,
  181. data: "" !== n ? JSON.parse(n) : ""
  182. }
  183. } catch(r) {}
  184. }
  185. return a
  186. }
  187. function y(e) {
  188. e = e || {},
  189. this.IS_MASTER = "boolean" == typeof e.isMaster ? e.isMaster: !1,
  190. this.IS_SLAVE = !this.IS_MASTER,
  191. this.api = e.api ? e.api: {},
  192. this._targets = e.targets ? e.targets: [],
  193. this._callbacks = [],
  194. this._channels = [],
  195. this.IS_MASTER && e.dataStore && (this.dataStore = e.dataStore),
  196. this._setupEventListener()
  197. }
  198. function v(e, n, d, h, g) {
  199. window.outerHeight - window.innerHeight,
  200. this.version = "0.21.2",
  201. this.isReady = !1,
  202. this._setRole(),
  203. this.__ = {},
  204. this.__.dataStore = this.IS_MASTER ? new e({
  205. isMaster: !0
  206. }) : null,
  207. this.__.messenger = new n({
  208. isMaster: this.IS_MASTER,
  209. api: this,
  210. targets: this._getTargets(),
  211. dataStore: this.__.dataStore
  212. }),
  213. this.__.components = new t;
  214. var f = this._addBasic({});
  215. this.__.EventTracking = new h(f, !1);
  216. var m = this._addComponents(f),
  217. y = this._addEventTracking(m),
  218. v = this._addInitialHeight(y);
  219. this.AppToken = new i(y, !1),
  220. this.GameState = new a(this._addAppToken(y), !1),
  221. this.Branding = new d(m, !1),
  222. this.GameBreak = new g(f, !1),
  223. this.Game = new s(f, !1),
  224. this.Score = new p(v, !1),
  225. this.Award = new u(v, !1),
  226. this.User = new o(y, !1),
  227. this.Friends = new l(y, !1),
  228. this.GameEvent = new c(y, !1),
  229. this.Localization = new r(y, !1)
  230. } (function(e) {
  231. if ("function" == typeof bootstrap) bootstrap("promise", e);
  232. else if ("object" == typeof exports && "object" == typeof module) module.exports = e();
  233. else if ("function" == typeof define && define.amd) define(e);
  234. else if ("undefined" != typeof ses) {
  235. if (!ses.ok()) return;
  236. ses.makeQ = e
  237. } else {
  238. if ("undefined" == typeof window && "undefined" == typeof self) throw Error("This environment was not anticipated by Q. Please file a bug.");
  239. var t = "undefined" != typeof window ? window: self,
  240. n = t.Q;
  241. t.Q = e(),
  242. t.Q.noConflict = function() {
  243. return t.Q = n,
  244. this
  245. }
  246. }
  247. })(function() {
  248. function e(e) {
  249. return function() {
  250. return Q.apply(e, arguments)
  251. }
  252. }
  253. function t(e) {
  254. return e === Object(e)
  255. }
  256. function n(e) {
  257. return "[object StopIteration]" === nt(e) || e instanceof J
  258. }
  259. function i(e, t) {
  260. if (F && t.stack && "object" == typeof e && null !== e && e.stack && -1 === e.stack.indexOf(it)) {
  261. for (var n = [], i = t; i; i = i.source) i.stack && n.unshift(i.stack);
  262. n.unshift(e.stack);
  263. var s = n.join("\n" + it + "\n");
  264. e.stack = a(s)
  265. }
  266. }
  267. function a(e) {
  268. for (var t = e.split("\n"), n = [], i = 0; t.length > i; ++i) {
  269. var a = t[i];
  270. o(a) || s(a) || !a || n.push(a)
  271. }
  272. return n.join("\n")
  273. }
  274. function s(e) {
  275. return - 1 !== e.indexOf("(module.js:") || -1 !== e.indexOf("(node.js:")
  276. }
  277. function r(e) {
  278. var t = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);
  279. if (t) return [t[1], Number(t[2])];
  280. var n = /at ([^ ]+):(\d+):(?:\d+)$/.exec(e);
  281. if (n) return [n[1], Number(n[2])];
  282. var i = /.*@(.+):(\d+)$/.exec(e);
  283. return i ? [i[1], Number(i[2])] : void 0
  284. }
  285. function o(e) {
  286. var t = r(e);
  287. if (!t) return ! 1;
  288. var n = t[0],
  289. i = t[1];
  290. return n === B && i >= V && lt >= i
  291. }
  292. function l() {
  293. if (F) try {
  294. throw Error()
  295. } catch(e) {
  296. var t = e.stack.split("\n"),
  297. n = t[0].indexOf("@") > 0 ? t[1] : t[2],
  298. i = r(n);
  299. if (!i) return;
  300. return B = i[0],
  301. i[1]
  302. }
  303. }
  304. function p(e, t, n) {
  305. return function() {
  306. return "undefined" != typeof console && "function" == typeof console.warn && console.warn(t + " is deprecated, use " + n + " instead.", Error("").stack),
  307. e.apply(e, arguments)
  308. }
  309. }
  310. function u(e) {
  311. return e instanceof g ? e: v(e) ? k(e) : I(e)
  312. }
  313. function d() {
  314. function e(e) {
  315. t = e,
  316. s.source = e,
  317. z(n,
  318. function(t, n) {
  319. u.nextTick(function() {
  320. e.promiseDispatch.apply(e, n)
  321. })
  322. },
  323. void 0),
  324. n = void 0,
  325. i = void 0
  326. }
  327. var t, n = [],
  328. i = [],
  329. a = Z(d.prototype),
  330. s = Z(g.prototype);
  331. if (s.promiseDispatch = function(e, a, s) {
  332. var r = K(arguments);
  333. n ? (n.push(r), "when" === a && s[1] && i.push(s[1])) : u.nextTick(function() {
  334. t.promiseDispatch.apply(t, r)
  335. })
  336. },
  337. s.valueOf = function() {
  338. if (n) return s;
  339. var e = m(t);
  340. return y(e) && (t = e),
  341. e
  342. },
  343. s.inspect = function() {
  344. return t ? t.inspect() : {
  345. state: "pending"
  346. }
  347. },
  348. u.longStackSupport && F) try {
  349. throw Error()
  350. } catch(r) {
  351. s.stack = r.stack.substring(r.stack.indexOf("\n") + 1)
  352. }
  353. return a.promise = s,
  354. a.resolve = function(n) {
  355. t || e(u(n))
  356. },
  357. a.fulfill = function(n) {
  358. t || e(I(n))
  359. },
  360. a.reject = function(n) {
  361. t || e(E(n))
  362. },
  363. a.notify = function(e) {
  364. t || z(i,
  365. function(t, n) {
  366. u.nextTick(function() {
  367. n(e)
  368. })
  369. },
  370. void 0)
  371. },
  372. a
  373. }
  374. function c(e) {
  375. if ("function" != typeof e) throw new TypeError("resolver must be a function.");
  376. var t = d();
  377. try {
  378. e(t.resolve, t.reject, t.notify)
  379. } catch(n) {
  380. t.reject(n)
  381. }
  382. return t.promise
  383. }
  384. function h(e) {
  385. return c(function(t, n) {
  386. for (var i = 0,
  387. a = e.length; a > i; i++) u(e[i]).then(t, n)
  388. })
  389. }
  390. function g(e, t, n) {
  391. void 0 === t && (t = function(e) {
  392. return E(Error("Promise does not support operation: " + e))
  393. }),
  394. void 0 === n && (n = function() {
  395. return {
  396. state: "unknown"
  397. }
  398. });
  399. var i = Z(g.prototype);
  400. if (i.promiseDispatch = function(n, a, s) {
  401. var r;
  402. try {
  403. r = e[a] ? e[a].apply(i, s) : t.call(i, a, s)
  404. } catch(o) {
  405. r = E(o)
  406. }
  407. n && n(r)
  408. },
  409. i.inspect = n, n) {
  410. var a = n();
  411. "rejected" === a.state && (i.exception = a.reason),
  412. i.valueOf = function() {
  413. var e = n();
  414. return "pending" === e.state || "rejected" === e.state ? i: e.value
  415. }
  416. }
  417. return i
  418. }
  419. function f(e, t, n, i) {
  420. return u(e).then(t, n, i)
  421. }
  422. function m(e) {
  423. if (y(e)) {
  424. var t = e.inspect();
  425. if ("fulfilled" === t.state) return t.value
  426. }
  427. return e
  428. }
  429. function y(e) {
  430. return e instanceof g
  431. }
  432. function v(e) {
  433. return t(e) && "function" == typeof e.then
  434. }
  435. function S(e) {
  436. return y(e) && "pending" === e.inspect().state
  437. }
  438. function _(e) {
  439. return ! y(e) || "fulfilled" === e.inspect().state
  440. }
  441. function A(e) {
  442. return y(e) && "rejected" === e.inspect().state
  443. }
  444. function T() {
  445. at.length = 0,
  446. st.length = 0,
  447. ot || (ot = !0)
  448. }
  449. function w(e, t) {
  450. ot && ("object" == typeof process && "function" == typeof process.emit && u.nextTick.runAfter(function() { - 1 !== Y(st, e) && (process.emit("unhandledRejection", t, e), rt.push(e))
  451. }), st.push(e), t && t.stack !== void 0 ? at.push(t.stack) : at.push("(no stack) " + t))
  452. }
  453. function b(e) {
  454. if (ot) {
  455. var t = Y(st, e); - 1 !== t && ("object" == typeof process && "function" == typeof process.emit && u.nextTick.runAfter(function() {
  456. var n = Y(rt, e); - 1 !== n && (process.emit("rejectionHandled", at[t], e), rt.splice(n, 1))
  457. }), st.splice(t, 1), at.splice(t, 1))
  458. }
  459. }
  460. function E(e) {
  461. var t = g({
  462. when: function(t) {
  463. return t && b(this),
  464. t ? t(e) : this
  465. }
  466. },
  467. function() {
  468. return this
  469. },
  470. function() {
  471. return {
  472. state: "rejected",
  473. reason: e
  474. }
  475. });
  476. return w(t, e),
  477. t
  478. }
  479. function I(e) {
  480. return g({
  481. when: function() {
  482. return e
  483. },
  484. get: function(t) {
  485. return e[t]
  486. },
  487. set: function(t, n) {
  488. e[t] = n
  489. },
  490. "delete": function(t) {
  491. delete e[t]
  492. },
  493. post: function(t, n) {
  494. return null === t || void 0 === t ? e.apply(void 0, n) : e[t].apply(e, n)
  495. },
  496. apply: function(t, n) {
  497. return e.apply(t, n)
  498. },
  499. keys: function() {
  500. return tt(e)
  501. }
  502. },
  503. void 0,
  504. function() {
  505. return {
  506. state: "fulfilled",
  507. value: e
  508. }
  509. })
  510. }
  511. function k(e) {
  512. var t = d();
  513. return u.nextTick(function() {
  514. try {
  515. e.then(t.resolve, t.reject, t.notify)
  516. } catch(n) {
  517. t.reject(n)
  518. }
  519. }),
  520. t.promise
  521. }
  522. function R(e) {
  523. return g({
  524. isDef: function() {}
  525. },
  526. function(t, n) {
  527. return N(e, t, n)
  528. },
  529. function() {
  530. return u(e).inspect()
  531. })
  532. }
  533. function M(e, t, n) {
  534. return u(e).spread(t, n)
  535. }
  536. function G(e) {
  537. return function() {
  538. function t(e, t) {
  539. var r;
  540. if ("undefined" == typeof StopIteration) {
  541. try {
  542. r = i[e](t)
  543. } catch(o) {
  544. return E(o)
  545. }
  546. return r.done ? u(r.value) : f(r.value, a, s)
  547. }
  548. try {
  549. r = i[e](t)
  550. } catch(o) {
  551. return n(o) ? u(o.value) : E(o)
  552. }
  553. return f(r, a, s)
  554. }
  555. var i = e.apply(this, arguments),
  556. a = t.bind(t, "next"),
  557. s = t.bind(t, "throw");
  558. return a()
  559. }
  560. }
  561. function P(e) {
  562. u.done(u.async(e)())
  563. }
  564. function L(e) {
  565. throw new J(e)
  566. }
  567. function x(e) {
  568. return function() {
  569. return M([this, D(arguments)],
  570. function(t, n) {
  571. return e.apply(t, n)
  572. })
  573. }
  574. }
  575. function N(e, t, n) {
  576. return u(e).dispatch(t, n)
  577. }
  578. function D(e) {
  579. return f(e,
  580. function(e) {
  581. var t = 0,
  582. n = d();
  583. return z(e,
  584. function(i, a, s) {
  585. var r;
  586. y(a) && "fulfilled" === (r = a.inspect()).state ? e[s] = r.value: (++t, f(a,
  587. function(i) {
  588. e[s] = i,
  589. 0 === --t && n.resolve(e)
  590. },
  591. n.reject,
  592. function(e) {
  593. n.notify({
  594. index: s,
  595. value: e
  596. })
  597. }))
  598. },
  599. void 0),
  600. 0 === t && n.resolve(e),
  601. n.promise
  602. })
  603. }
  604. function O(e) {
  605. if (0 === e.length) return u.resolve();
  606. var t = u.defer(),
  607. n = 0;
  608. return z(e,
  609. function(i, a, s) {
  610. function r(e) {
  611. t.resolve(e)
  612. }
  613. function o() {
  614. n--,
  615. 0 === n && t.reject(Error("Can't get fulfillment value from any promise, all promises were rejected."))
  616. }
  617. function l(e) {
  618. t.notify({
  619. index: s,
  620. value: e
  621. })
  622. }
  623. var p = e[s];
  624. n++,
  625. f(p, r, o, l)
  626. },
  627. void 0),
  628. t.promise
  629. }
  630. function C(e) {
  631. return f(e,
  632. function(e) {
  633. return e = $(e, u),
  634. f(D($(e,
  635. function(e) {
  636. return f(e, W, W)
  637. })),
  638. function() {
  639. return e
  640. })
  641. })
  642. }
  643. function j(e) {
  644. return u(e).allSettled()
  645. }
  646. function U(e, t) {
  647. return u(e).then(void 0, void 0, t)
  648. }
  649. function H(e, t) {
  650. return u(e).nodeify(t)
  651. }
  652. var F = !1;
  653. try {
  654. throw Error()
  655. } catch(q) {
  656. F = !!q.stack
  657. }
  658. var B, J, V = l(),
  659. W = function() {},
  660. X = function() {
  661. function e() {
  662. for (var e, i; n.next;) n = n.next,
  663. e = n.task,
  664. n.task = void 0,
  665. i = n.domain,
  666. i && (n.domain = void 0, i.enter()),
  667. t(e, i);
  668. for (; o.length;) e = o.pop(),
  669. t(e);
  670. a = !1
  671. }
  672. function t(t, n) {
  673. try {
  674. t()
  675. } catch(i) {
  676. if (r) throw n && n.exit(),
  677. setTimeout(e, 0),
  678. n && n.enter(),
  679. i;
  680. setTimeout(function() {
  681. throw i
  682. },
  683. 0)
  684. }
  685. n && n.exit()
  686. }
  687. var n = {
  688. task: void 0,
  689. next: null
  690. },
  691. i = n,
  692. a = !1,
  693. s = void 0,
  694. r = !1,
  695. o = [];
  696. if (X = function(e) {
  697. i = i.next = {
  698. task: e,
  699. domain: r && process.domain,
  700. next: null
  701. },
  702. a || (a = !0, s())
  703. },
  704. "object" == typeof process && "[object process]" == "" + process && process.nextTick) r = !0,
  705. s = function() {
  706. process.nextTick(e)
  707. };
  708. else if ("function" == typeof setImmediate) s = "undefined" != typeof window ? setImmediate.bind(window, e) : function() {
  709. setImmediate(e)
  710. };
  711. else if ("undefined" != typeof MessageChannel) {
  712. var l = new MessageChannel;
  713. l.port1.onmessage = function() {
  714. s = p,
  715. l.port1.onmessage = e,
  716. e()
  717. };
  718. var p = function() {
  719. l.port2.postMessage(0)
  720. };
  721. s = function() {
  722. setTimeout(e, 0),
  723. p()
  724. }
  725. } else s = function() {
  726. setTimeout(e, 0)
  727. };
  728. return X.runAfter = function(e) {
  729. o.push(e),
  730. a || (a = !0, s())
  731. },
  732. X
  733. } (),
  734. Q = Function.call,
  735. K = e(Array.prototype.slice),
  736. z = e(Array.prototype.reduce ||
  737. function(e, t) {
  738. var n = 0,
  739. i = this.length;
  740. if (1 === arguments.length) for (;;) {
  741. if (n in this) {
  742. t = this[n++];
  743. break
  744. }
  745. if (++n >= i) throw new TypeError
  746. }
  747. for (; i > n; n++) n in this && (t = e(t, this[n], n));
  748. return t
  749. }),
  750. Y = e(Array.prototype.indexOf ||
  751. function(e) {
  752. for (var t = 0; this.length > t; t++) if (this[t] === e) return t;
  753. return - 1
  754. }),
  755. $ = e(Array.prototype.map ||
  756. function(e, t) {
  757. var n = this,
  758. i = [];
  759. return z(n,
  760. function(a, s, r) {
  761. i.push(e.call(t, s, r, n))
  762. },
  763. void 0),
  764. i
  765. }),
  766. Z = Object.create ||
  767. function(e) {
  768. function t() {}
  769. return t.prototype = e,
  770. new t
  771. },
  772. et = e(Object.prototype.hasOwnProperty),
  773. tt = Object.keys ||
  774. function(e) {
  775. var t = [];
  776. for (var n in e) et(e, n) && t.push(n);
  777. return t
  778. },
  779. nt = e(Object.prototype.toString);
  780. J = "undefined" != typeof ReturnValue ? ReturnValue: function(e) {
  781. this.value = e
  782. };
  783. var it = "From previous event:";
  784. u.resolve = u,
  785. u.nextTick = X,
  786. u.longStackSupport = !1,
  787. "object" == typeof process && process && process.env && process.env.Q_DEBUG && (u.longStackSupport = !0),
  788. u.defer = d,
  789. d.prototype.makeNodeResolver = function() {
  790. var e = this;
  791. return function(t, n) {
  792. t ? e.reject(t) : arguments.length > 2 ? e.resolve(K(arguments, 1)) : e.resolve(n)
  793. }
  794. },
  795. u.Promise = c,
  796. u.promise = c,
  797. c.race = h,
  798. c.all = D,
  799. c.reject = E,
  800. c.resolve = u,
  801. u.passByCopy = function(e) {
  802. return e
  803. },
  804. g.prototype.passByCopy = function() {
  805. return this
  806. },
  807. u.join = function(e, t) {
  808. return u(e).join(t)
  809. },
  810. g.prototype.join = function(e) {
  811. return u([this, e]).spread(function(e, t) {
  812. if (e === t) return e;
  813. throw Error("Can't join: not the same: " + e + " " + t)
  814. })
  815. },
  816. u.race = h,
  817. g.prototype.race = function() {
  818. return this.then(u.race)
  819. },
  820. u.makePromise = g,
  821. g.prototype.toString = function() {
  822. return "[object Promise]"
  823. },
  824. g.prototype.then = function(e, t, n) {
  825. function a(t) {
  826. try {
  827. return "function" == typeof e ? e(t) : t
  828. } catch(n) {
  829. return E(n)
  830. }
  831. }
  832. function s(e) {
  833. if ("function" == typeof t) {
  834. i(e, o);
  835. try {
  836. return t(e)
  837. } catch(n) {
  838. return E(n)
  839. }
  840. }
  841. return E(e)
  842. }
  843. function r(e) {
  844. return "function" == typeof n ? n(e) : e
  845. }
  846. var o = this,
  847. l = d(),
  848. p = !1;
  849. return u.nextTick(function() {
  850. o.promiseDispatch(function(e) {
  851. p || (p = !0, l.resolve(a(e)))
  852. },
  853. "when", [function(e) {
  854. p || (p = !0, l.resolve(s(e)))
  855. }])
  856. }),
  857. o.promiseDispatch(void 0, "when", [void 0,
  858. function(e) {
  859. var t, n = !1;
  860. try {
  861. t = r(e)
  862. } catch(i) {
  863. if (n = !0, !u.onerror) throw i;
  864. u.onerror(i)
  865. }
  866. n || l.notify(t)
  867. }]),
  868. l.promise
  869. },
  870. u.tap = function(e, t) {
  871. return u(e).tap(t)
  872. },
  873. g.prototype.tap = function(e) {
  874. return e = u(e),
  875. this.then(function(t) {
  876. return e.fcall(t).thenResolve(t)
  877. })
  878. },
  879. u.when = f,
  880. g.prototype.thenResolve = function(e) {
  881. return this.then(function() {
  882. return e
  883. })
  884. },
  885. u.thenResolve = function(e, t) {
  886. return u(e).thenResolve(t)
  887. },
  888. g.prototype.thenReject = function(e) {
  889. return this.then(function() {
  890. throw e
  891. })
  892. },
  893. u.thenReject = function(e, t) {
  894. return u(e).thenReject(t)
  895. },
  896. u.nearer = m,
  897. u.isPromise = y,
  898. u.isPromiseAlike = v,
  899. u.isPending = S,
  900. g.prototype.isPending = function() {
  901. return "pending" === this.inspect().state
  902. },
  903. u.isFulfilled = _,
  904. g.prototype.isFulfilled = function() {
  905. return "fulfilled" === this.inspect().state
  906. },
  907. u.isRejected = A,
  908. g.prototype.isRejected = function() {
  909. return "rejected" === this.inspect().state
  910. };
  911. var at = [],
  912. st = [],
  913. rt = [],
  914. ot = !0;
  915. u.resetUnhandledRejections = T,
  916. u.getUnhandledReasons = function() {
  917. return at.slice()
  918. },
  919. u.stopUnhandledRejectionTracking = function() {
  920. T(),
  921. ot = !1
  922. },
  923. T(),
  924. u.reject = E,
  925. u.fulfill = I,
  926. u.master = R,
  927. u.spread = M,
  928. g.prototype.spread = function(e, t) {
  929. return this.all().then(function(t) {
  930. return e.apply(void 0, t)
  931. },
  932. t)
  933. },
  934. u.async = G,
  935. u.spawn = P,
  936. u["return"] = L,
  937. u.promised = x,
  938. u.dispatch = N,
  939. g.prototype.dispatch = function(e, t) {
  940. var n = this,
  941. i = d();
  942. return u.nextTick(function() {
  943. n.promiseDispatch(i.resolve, e, t)
  944. }),
  945. i.promise
  946. },
  947. u.get = function(e, t) {
  948. return u(e).dispatch("get", [t])
  949. },
  950. g.prototype.get = function(e) {
  951. return this.dispatch("get", [e])
  952. },
  953. u.set = function(e, t, n) {
  954. return u(e).dispatch("set", [t, n])
  955. },
  956. g.prototype.set = function(e, t) {
  957. return this.dispatch("set", [e, t])
  958. },
  959. u.del = u["delete"] = function(e, t) {
  960. return u(e).dispatch("delete", [t])
  961. },
  962. g.prototype.del = g.prototype["delete"] = function(e) {
  963. return this.dispatch("delete", [e])
  964. },
  965. u.mapply = u.post = function(e, t, n) {
  966. return u(e).dispatch("post", [t, n])
  967. },
  968. g.prototype.mapply = g.prototype.post = function(e, t) {
  969. return this.dispatch("post", [e, t])
  970. },
  971. u.send = u.mcall = u.invoke = function(e, t) {
  972. return u(e).dispatch("post", [t, K(arguments, 2)])
  973. },
  974. g.prototype.send = g.prototype.mcall = g.prototype.invoke = function(e) {
  975. return this.dispatch("post", [e, K(arguments, 1)])
  976. },
  977. u.fapply = function(e, t) {
  978. return u(e).dispatch("apply", [void 0, t])
  979. },
  980. g.prototype.fapply = function(e) {
  981. return this.dispatch("apply", [void 0, e])
  982. },
  983. u["try"] = u.fcall = function(e) {
  984. return u(e).dispatch("apply", [void 0, K(arguments, 1)])
  985. },
  986. g.prototype.fcall = function() {
  987. return this.dispatch("apply", [void 0, K(arguments)])
  988. },
  989. u.fbind = function(e) {
  990. var t = u(e),
  991. n = K(arguments, 1);
  992. return function() {
  993. return t.dispatch("apply", [this, n.concat(K(arguments))])
  994. }
  995. },
  996. g.prototype.fbind = function() {
  997. var e = this,
  998. t = K(arguments);
  999. return function() {
  1000. return e.dispatch("apply", [this, t.concat(K(arguments))])
  1001. }
  1002. },
  1003. u.keys = function(e) {
  1004. return u(e).dispatch("keys", [])
  1005. },
  1006. g.prototype.keys = function() {
  1007. return this.dispatch("keys", [])
  1008. },
  1009. u.all = D,
  1010. g.prototype.all = function() {
  1011. return D(this)
  1012. },
  1013. u.any = O,
  1014. g.prototype.any = function() {
  1015. return O(this)
  1016. },
  1017. u.allResolved = p(C, "allResolved", "allSettled"),
  1018. g.prototype.allResolved = function() {
  1019. return C(this)
  1020. },
  1021. u.allSettled = j,
  1022. g.prototype.allSettled = function() {
  1023. return this.then(function(e) {
  1024. return D($(e,
  1025. function(e) {
  1026. function t() {
  1027. return e.inspect()
  1028. }
  1029. return e = u(e),
  1030. e.then(t, t)
  1031. }))
  1032. })
  1033. },
  1034. u.fail = u["catch"] = function(e, t) {
  1035. return u(e).then(void 0, t)
  1036. },
  1037. g.prototype.fail = g.prototype["catch"] = function(e) {
  1038. return this.then(void 0, e)
  1039. },
  1040. u.progress = U,
  1041. g.prototype.progress = function(e) {
  1042. return this.then(void 0, void 0, e)
  1043. },
  1044. u.fin = u["finally"] = function(e, t) {
  1045. return u(e)["finally"](t)
  1046. },
  1047. g.prototype.fin = g.prototype["finally"] = function(e) {
  1048. return e = u(e),
  1049. this.then(function(t) {
  1050. return e.fcall().then(function() {
  1051. return t
  1052. })
  1053. },
  1054. function(t) {
  1055. return e.fcall().then(function() {
  1056. throw t
  1057. })
  1058. })
  1059. },
  1060. u.done = function(e, t, n, i) {
  1061. return u(e).done(t, n, i)
  1062. },
  1063. g.prototype.done = function(e, t, n) {
  1064. var a = function(e) {
  1065. u.nextTick(function() {
  1066. if (i(e, s), !u.onerror) throw e;
  1067. u.onerror(e)
  1068. })
  1069. },
  1070. s = e || t || n ? this.then(e, t, n) : this;
  1071. "object" == typeof process && process && process.domain && (a = process.domain.bind(a)),
  1072. s.then(void 0, a)
  1073. },
  1074. u.timeout = function(e, t, n) {
  1075. return u(e).timeout(t, n)
  1076. },
  1077. g.prototype.timeout = function(e, t) {
  1078. var n = d(),
  1079. i = setTimeout(function() {
  1080. t && "string" != typeof t || (t = Error(t || "Timed out after " + e + " ms"), t.code = "ETIMEDOUT"),
  1081. n.reject(t)
  1082. },
  1083. e);
  1084. return this.then(function(e) {
  1085. clearTimeout(i),
  1086. n.resolve(e)
  1087. },
  1088. function(e) {
  1089. clearTimeout(i),
  1090. n.reject(e)
  1091. },
  1092. n.notify),
  1093. n.promise
  1094. },
  1095. u.delay = function(e, t) {
  1096. return void 0 === t && (t = e, e = void 0),
  1097. u(e).delay(t)
  1098. },
  1099. g.prototype.delay = function(e) {
  1100. return this.then(function(t) {
  1101. var n = d();
  1102. return setTimeout(function() {
  1103. n.resolve(t)
  1104. },
  1105. e),
  1106. n.promise
  1107. })
  1108. },
  1109. u.nfapply = function(e, t) {
  1110. return u(e).nfapply(t)
  1111. },
  1112. g.prototype.nfapply = function(e) {
  1113. var t = d(),
  1114. n = K(e);
  1115. return n.push(t.makeNodeResolver()),
  1116. this.fapply(n).fail(t.reject),
  1117. t.promise
  1118. },
  1119. u.nfcall = function(e) {
  1120. var t = K(arguments, 1);
  1121. return u(e).nfapply(t)
  1122. },
  1123. g.prototype.nfcall = function() {
  1124. var e = K(arguments),
  1125. t = d();
  1126. return e.push(t.makeNodeResolver()),
  1127. this.fapply(e).fail(t.reject),
  1128. t.promise
  1129. },
  1130. u.nfbind = u.denodeify = function(e) {
  1131. var t = K(arguments, 1);
  1132. return function() {
  1133. var n = t.concat(K(arguments)),
  1134. i = d();
  1135. return n.push(i.makeNodeResolver()),
  1136. u(e).fapply(n).fail(i.reject),
  1137. i.promise
  1138. }
  1139. },
  1140. g.prototype.nfbind = g.prototype.denodeify = function() {
  1141. var e = K(arguments);
  1142. return e.unshift(this),
  1143. u.denodeify.apply(void 0, e)
  1144. },
  1145. u.nbind = function(e, t) {
  1146. var n = K(arguments, 2);
  1147. return function() {
  1148. function i() {
  1149. return e.apply(t, arguments)
  1150. }
  1151. var a = n.concat(K(arguments)),
  1152. s = d();
  1153. return a.push(s.makeNodeResolver()),
  1154. u(i).fapply(a).fail(s.reject),
  1155. s.promise
  1156. }
  1157. },
  1158. g.prototype.nbind = function() {
  1159. var e = K(arguments, 0);
  1160. return e.unshift(this),
  1161. u.nbind.apply(void 0, e)
  1162. },
  1163. u.nmapply = u.npost = function(e, t, n) {
  1164. return u(e).npost(t, n)
  1165. },
  1166. g.prototype.nmapply = g.prototype.npost = function(e, t) {
  1167. var n = K(t || []),
  1168. i = d();
  1169. return n.push(i.makeNodeResolver()),
  1170. this.dispatch("post", [e, n]).fail(i.reject),
  1171. i.promise
  1172. },
  1173. u.nsend = u.nmcall = u.ninvoke = function(e, t) {
  1174. var n = K(arguments, 2),
  1175. i = d();
  1176. return n.push(i.makeNodeResolver()),
  1177. u(e).dispatch("post", [t, n]).fail(i.reject),
  1178. i.promise
  1179. },
  1180. g.prototype.nsend = g.prototype.nmcall = g.prototype.ninvoke = function(e) {
  1181. var t = K(arguments, 1),
  1182. n = d();
  1183. return t.push(n.makeNodeResolver()),
  1184. this.dispatch("post", [e, t]).fail(n.reject),
  1185. n.promise
  1186. },
  1187. u.nodeify = H,
  1188. g.prototype.nodeify = function(e) {
  1189. return e ? (this.then(function(t) {
  1190. u.nextTick(function() {
  1191. e(null, t)
  1192. })
  1193. },
  1194. function(t) {
  1195. u.nextTick(function() {
  1196. e(t)
  1197. })
  1198. }), void 0) : this
  1199. },
  1200. u.noConflict = function() {
  1201. throw Error("Q.noConflict only works when Q is used as a global")
  1202. };
  1203. var lt = l();
  1204. return u
  1205. }),
  1206. function(e) {
  1207. var t = "Promise" in e && "cast" in e.Promise && "resolve" in e.Promise && "reject" in e.Promise && "all" in e.Promise && "race" in e.Promise && "spread" in e.Promise;
  1208. t || (e.Promise = e.Q.promise, e.Promise.all = e.Q.all, e.Promise.timeout = e.Q.timeout, e.Q.stopUnhandledRejectionTracking())
  1209. } (e !== void 0 ? e: this);
  1210. var S = {
  1211. timeout: 3e3
  1212. };
  1213. S.getGameConfig = function() {
  1214. var t = e.Q.defer();
  1215. return SpilGames(["JSLib"],
  1216. function(e) {
  1217. var n = e.get("current.game.integration.info");
  1218. n ? t.resolve(n) : t.reject(Error("No data retrieved from JSLib"))
  1219. }),
  1220. t.promise.timeout(this.timeout)
  1221. },
  1222. S.getBrandingConfig = function(t) {
  1223. var n = e.Q.defer(),
  1224. i = "./configs",
  1225. a = t.portal.siteId,
  1226. s = t.portal.channelId,
  1227. r = t.portal.applicationId,
  1228. o = "en-EN",
  1229. l = [i, s, a, r].join("/");
  1230. return navigator && "undefined" != typeof navigator && (navigator.languages !== void 0 && navigator.languages[0] !== void 0 ? o = navigator.languages[0] : navigator.userLanguage !== void 0 && (o = navigator.userLanguage)),
  1231. l = l + "?locale=" + o,
  1232. SpilGames(["Net", "JSLib"],
  1233. function(e, t) {
  1234. e.send({
  1235. url: l,
  1236. type: "GET",
  1237. dataType: "JSON"
  1238. },
  1239. function(e) {
  1240. if (e && e.configar) window.postMessage(new f({
  1241. type: "success",
  1242. callbackId: null,
  1243. data: "log.configar.getBranding.success"
  1244. }), "*"),
  1245. n.resolve(e.configar);
  1246. else {
  1247. var i = {};
  1248. try {
  1249. i = t.get("configar.data.cached") || i
  1250. } catch(a) {}
  1251. n.reject(i)
  1252. }
  1253. })
  1254. }),
  1255. n.promise.timeout(this.timeout)
  1256. };
  1257. var _ = {};
  1258. _.argsToArray = function(e) {
  1259. return e ? Array.prototype.slice.apply(e) : []
  1260. },
  1261. _.isA10 = function() {
  1262. return /4399.com/.test(window.location.host)
  1263. },
  1264. _.disableKeys = function(e) {
  1265. var t = e.keyCode; (8 === t || 9 === t || t >= 32 && 40 >= t || 46 === t) && e.preventDefault()
  1266. },
  1267. _.trackGA = function() {
  1268. try {
  1269. if ("www8.agame.com" === window.location.host) {
  1270. var e = function(e, t, n, i, a, s, r) {
  1271. e.GoogleAnalyticsObject = a,
  1272. e[a] = e[a] ||
  1273. function() { (e[a].q = e[a].q || []).push(arguments)
  1274. },
  1275. e[a].l = 1 * new Date,
  1276. s = t.createElement(n),
  1277. r = t.getElementsByTagName(n)[0],
  1278. s.async = 1,
  1279. s.src = i,
  1280. r.parentNode.insertBefore(s, r)
  1281. };
  1282. e(window, document, "script", "", "ga"),
  1283. ga("create", "UA-8223336-3", "auto"),
  1284. ga("send", "pageview")
  1285. }
  1286. } catch(t) {}
  1287. },
  1288. _.getRole = function() {
  1289. var e = "function" == typeof window.SpilGames,
  1290. t = window.self !== window.top,
  1291. n = null;
  1292. if (_.isA10()) return window.onkeydown = this.disableKeys,
  1293. {
  1294. IS_MASTER: !0,
  1295. IS_SLAVE: !0,
  1296. IS_STANDALONE: !0
  1297. };
  1298. if (e) {
  1299. var i = document.getElementById("#iframegame");
  1300. switch (i) {
  1301. case "null":
  1302. n = {
  1303. IS_MASTER: !0,
  1304. IS_SLAVE: !0,
  1305. IS_STANDALONE: !1
  1306. };
  1307. break;
  1308. default:
  1309. n = {
  1310. IS_MASTER: !0,
  1311. IS_SLAVE: !1,
  1312. IS_STANDALONE: !1
  1313. }
  1314. }
  1315. } else t ? (window.onkeydown = this.disableKeys, this.trackGA(), n = {
  1316. IS_MASTER: !1,
  1317. IS_SLAVE: !0,
  1318. IS_STANDALONE: !1
  1319. }) : (window.onkeydown = this.disableKeys, this.trackGA(), n = {
  1320. IS_MASTER: !0,
  1321. IS_SLAVE: !0,
  1322. IS_STANDALONE: !0
  1323. });
  1324. return n
  1325. },
  1326. _.callConfigar = function(e, t) {
  1327. var n, i, a = e.site || 500,
  1328. s = e.channel || 100,
  1329. r = e.id || null;
  1330. window.XDomainRequest ? (n = new XDomainRequest, n.onload = function() {
  1331. t(200, n.responseText)
  1332. },
  1333. n.onerror = function() {
  1334. t(404, null)
  1335. },
  1336. n.onprogress = function() {}) : window.XMLHttpRequest ? (n = new XMLHttpRequest, n.onreadystatechange = function() {
  1337. 4 === n.readyState && t(n.status, n.responseText)
  1338. }) : window.ActiveXObject && (n = new ActiveXObject("Microsoft.XMLHTTP"), n.onreadystatechange = function() {
  1339. 4 === n.readyState && t(n.status, n.responseText)
  1340. }),
  1341. r && (i = ["./configs", s, a, r].join("/"), n.open("GET", i, !0), n.timeout = 3e3, n.ontimeout = function() {
  1342. t(404, null)
  1343. },
  1344. n.send())
  1345. },
  1346. _.submitData = function(e, t, n) {
  1347. var i, a = e || "",
  1348. s = t || {},
  1349. r = n ||
  1350. function() {};
  1351. window.XDomainRequest ? (i = new XDomainRequest, i.onload = function() {
  1352. r(200, i.responseText)
  1353. },
  1354. i.onerror = function() {
  1355. r(404, null)
  1356. },
  1357. i.onprogress = function() {},
  1358. i.open("POST", a, !0)) : window.XMLHttpRequest ? (navigator.userAgent.match(/Trident\/7.0;.* rv:11/) ? i = this.getJSONP() : (i = new XMLHttpRequest, i.onreadystatechange = function() {
  1359. 4 === i.readyState && r(i.status, i.responseText)
  1360. }), i.open("POST", a, !0), i.setRequestHeader("Content-type", "application/x-www-form-urlencoded")) : window.ActiveXObject && (i = new ActiveXObject("Microsoft.XMLHTTP"), i.onreadystatechange = function() {
  1361. 4 === i.readyState && r(i.status, i.responseText)
  1362. },
  1363. i.open("POST", a, !0)),
  1364. i.timeout = 3e3,
  1365. i.ontimeout = function() {
  1366. r(404, null)
  1367. }
  1368. //,i.send(JSON.stringify(s))
  1369. },
  1370. _.getJSONP = function() {
  1371. var e = "",
  1372. t = "jsonpspilgames" + +new Date,
  1373. n = {
  1374. open: function(t, n) {
  1375. t = null,
  1376. e = n
  1377. },
  1378. onreadystatechange: function() {},
  1379. setRequestHeader: function() {},
  1380. set: function(e, t) {
  1381. n.set[e] = t
  1382. },
  1383. send: function(i) {
  1384. var a = n.set.callback || 0,
  1385. s = n.set.data || 0; (i || a || s) && (e += /\?/.test(e) ? "&": "?", i && (e += s ? s + "=" + encodeURIComponent(i) : i, a && (e += "&")), a && (e += a + "=" + t));
  1386. var r = document.createElement("script");
  1387. r.src = e,
  1388. document.getElementsByTagName("head")[0].appendChild(r)
  1389. }
  1390. };
  1391. return window[t] = function() {
  1392. n.onreadystatechange.apply(this, arguments)
  1393. },
  1394. n
  1395. },
  1396. _.xdr = function(e, t) {
  1397. var n, i, a = e.url || "",
  1398. s = (e.type || "GET").toUpperCase(),
  1399. r = void 0 !== e.data ? e.data: {},
  1400. o = e.headers || {},
  1401. l = function() {
  1402. t({
  1403. isError: !0
  1404. })
  1405. },
  1406. p = void 0 !== e.async ? e.async: !0;
  1407. if (XMLHttpRequest) {
  1408. if (n = new XMLHttpRequest, "withCredentials" in n) {
  1409. n.open(s, a, p),
  1410. n.onerror = l,
  1411. n.onreadystatechange = function() {
  1412. 4 === n.readyState && (n.status >= 200 && 400 > n.status ? t({
  1413. data: n.responseText,
  1414. status: n.status
  1415. }) : t({
  1416. isError: !0,
  1417. status: n.status
  1418. }))
  1419. };
  1420. for (i in o) o.hasOwnProperty(i) && n.setRequestHeader(i, o[i]);
  1421. n.send(r)
  1422. }
  1423. } else if (XDomainRequest) {
  1424. n = new XDomainRequest,
  1425. n.open(s, a),
  1426. n.onerror = l,
  1427. n.onload = function() {
  1428. t(n.responseText)
  1429. };
  1430. for (i in o) o.hasOwnProperty(i) && n.setRequestHeader(i, o[i]);
  1431. n.send(r)
  1432. } else t({
  1433. isError: !0,
  1434. message: "CORS not supported"
  1435. })
  1436. },
  1437. _.log = function() {
  1438. if (window.console && window.console.log) {
  1439. var e = Array.prototype.slice.call(arguments);
  1440. console.log.apply(console, e)
  1441. }
  1442. },
  1443. _.getServiceEndpoint = function(e) {
  1444. return "stg" === e ? "": ""
  1445. },
  1446. _.isWrapped = function() {
  1447. return void 0 !== (window.PhoneGap || window.cordova || window.Cordova)
  1448. },
  1449. _.isArray = Array.isArray ||
  1450. function(e) {
  1451. return "[object Array]" === Object.prototype.toString.call(e)
  1452. },
  1453. _._getQueryString = function() {
  1454. return window.location.search
  1455. },
  1456. _._getPortalHost = function() {
  1457. return window && window.location && window.location.hostname ? window.location.hostname: "unknown"
  1458. },
  1459. _.validateSchema = function(e, t) {
  1460. for (var n in t) if (t.hasOwnProperty(n)) {
  1461. if (!e.hasOwnProperty(n)) return {
  1462. error: "Wrong argument passed: " + n
  1463. };
  1464. if (e.hasOwnProperty(n)) {
  1465. var i = "object" == typeof e[n] ? e[n].type: e[n];
  1466. if (t[n].constructor.name !== i) return {
  1467. error: "Wrong value type for " + n + ": expected " + e[n] + ", got " + t[n].constructor.name
  1468. };
  1469. var a = e[n] && e[n].values || [];
  1470. if ( - 1 === a.indexOf(t[n])) return {
  1471. error: "Wrong value for " + n + ": expected " + a.join(" or ") + ", got " + t[n]
  1472. }
  1473. }
  1474. }
  1475. return {
  1476. error: !1
  1477. }
  1478. };
  1479. var A = {};
  1480. A.getGameConfig = function() {
  1481. return S.getGameConfig().
  1482. catch(function() {
  1483. return A.getLocalConfig()
  1484. })
  1485. },
  1486. A.getBrandingConfig = function(e) {
  1487. return new Promise(function(t) {
  1488. return S.getBrandingConfig(e).then(t,
  1489. function(e) {
  1490. t(e),
  1491. window.postMessage(new f({
  1492. type: "warning",
  1493. callbackId: null,
  1494. data: "log.configar.getBranding.failure"
  1495. }), "*")
  1496. })
  1497. })
  1498. },
  1499. A.getLocalConfig = function(e) {
  1500. e = e && Object.keys(e).length ? e: {
  1501. portal: {},
  1502. game: {},
  1503. branding: {},
  1504. user: {}
  1505. };
  1506. var t = {
  1507. isLocal: e.isLocal || !1,
  1508. game: {
  1509. applicationId: e.portal.applicationId || "0",
  1510. contentarId: e.portal.contentarId || "0",
  1511. info: e.game.info || {},
  1512. settings: e.game.objectSettings || {},
  1513. properties: e.game.properties || {},
  1514. features: {
  1515. achievements: e.game.achievements || !1,
  1516. gameSidePanel: e.game.gameSidePanel || !1,
  1517. highscores: e.game.highscores || !1,
  1518. recommendedGames: e.game.recommendedGames || !1
  1519. }
  1520. },
  1521. user: {
  1522. authenticated: e.portal.authenticated || !1,
  1523. username: e.portal.username || "",
  1524. appToken: e.user.appToken || "",
  1525. userId: e.user.userId || ""
  1526. },
  1527. portal: {
  1528. host: _._getPortalHost(),
  1529. siteId: e.portal.siteId || 0,
  1530. channelId: e.portal.channelId || 0,
  1531. applicationId: e.portal.applicationId || "0",
  1532. gamestate: e.portal.gamestate || !1,
  1533. env: "stg" === e.portal.env ? "stg": "prd",
  1534. spilStorageId: e.portal.spilStorageId || ""
  1535. },
  1536. branding: e.branding || {}
  1537. };
  1538. return t.branding.logo = t.branding.logo || {},
  1539. t.branding.logo.url = t.branding.logo.url || !1,
  1540. t.branding.logo.image = t.branding.logo.image || !1,
  1541. t
  1542. },
  1543. A.configFromData = function(e) {
  1544. var t = {
  1545. game: {
  1546. applicationId: e.id
  1547. },
  1548. user: {
  1549. userId: e.userid ? e.userid: void 0,
  1550. appToken: e.appToken ? e.appToken: void 0
  1551. },
  1552. portal: {
  1553. applicationId: e.id,
  1554. siteId: e.site ? e.site: 187,
  1555. channelId: e.channel ? e.channel: 100,
  1556. gamestate: e.gamestate ? e.gamestate: !1,
  1557. env: "stg" === e.env ? "stg": "prd",
  1558. spilStorageId: e.spilStorageId
  1559. }
  1560. };
  1561. return t
  1562. },
  1563. A.setupStandaloneMode = function(e, t) {
  1564. var n = {},
  1565. i = {
  1566. configar: {
  1567. branding: {
  1568. main: {
  1569. label: "main",
  1570. image: "",
  1571. url: "",
  1572. style: "",
  1573. width: "202",
  1574. height: "50",
  1575. mime: "image/png",
  1576. type: "png",
  1577. handler: "newTab",
  1578. blacklisted: !0
  1579. },
  1580. logo: {
  1581. label: "logo",
  1582. image: "",
  1583. url: "",
  1584. style: "",
  1585. width: "202",
  1586. height: "50",
  1587. mime: "image/png",
  1588. type: "png",
  1589. handler: "newTab",
  1590. blacklisted: !1
  1591. },
  1592. more_games: {
  1593. label: "more_games",
  1594. image: null,
  1595. url: "",
  1596. style: "",
  1597. width: null,
  1598. height: null,
  1599. mime: null,
  1600. type: null,
  1601. handler: "newTab",
  1602. blacklisted: !1
  1603. },
  1604. splash_screen: {
  1605. label: "splash_screen",
  1606. image: "place_holder_string",
  1607. url: "",
  1608. style: "",
  1609. width: "0",
  1610. height: "0",
  1611. mime: "image/png",
  1612. type: "png",
  1613. handler: "newTab",
  1614. blacklisted: !1
  1615. }
  1616. }
  1617. }
  1618. };
  1619. n.JSLib = {
  1620. memory: {},
  1621. _channels: {},
  1622. get: function(e) {
  1623. return this.memory[e] ? this.memory[e] : !1
  1624. },
  1625. set: function(e, t) {
  1626. return this.memory[e] = t,
  1627. t
  1628. },
  1629. publish: function(e, t) {
  1630. this._channels[e] && this._channels[e].forEach(function(e) {
  1631. try {
  1632. e.fn.call(this, t)
  1633. } catch(n) {}
  1634. })
  1635. },
  1636. subscribe: function(e, t) {
  1637. if ("function" != typeof t) throw Error("Callback has to be a function");
  1638. if ("string" != typeof e) throw Error("Channel name has to be a string");
  1639. this._channels[e] || (this._channels[e] = []),
  1640. this._channels[e].push({
  1641. fn: t
  1642. })
  1643. }
  1644. },
  1645. n.Net = {
  1646. send: function(e, t) {
  1647. t.call(this, {})
  1648. }
  1649. },
  1650. window.SpilGamesBootstrap = [],
  1651. window.SpilGames = function() {
  1652. var e = arguments;
  1653. if (e[0] && "string" == typeof e[0]) n.JSLib.publish(e[0], e[1] || null);
  1654. else if (e[0] && e[0] instanceof Array) {
  1655. var t, i, a = [];
  1656. for (t = 0, i = e[0].length; i > t; t++) a.push(n[e[0][t]]);
  1657. e[1].apply(this, a)
  1658. }
  1659. },
  1660. e && e.id ? _.callConfigar(e,
  1661. function(n, a) {
  1662. if (200 === n && "string" == typeof a && JSON.parse(a)) {
  1663. var s = JSON.parse(a),
  1664. r = A.configFromData(e);
  1665. r.branding = s.configar && s.configar.branding ? s.configar.branding: i.configar.branding,
  1666. t.call(this, r)
  1667. } else t.call(this, {
  1668. isLocal: !0,
  1669. branding: i.configar.branding
  1670. })
  1671. }) : t.call(this, {
  1672. isLocal: !0,
  1673. branding: i.configar.branding
  1674. })
  1675. },
  1676. A.getCachedConfig = function() {},
  1677. t.prototype.newTab = function(e) {
  1678. },
  1679. t.prototype.moreGames = function(e) {
  1680. var t = e.brandName || "a10";
  1681. e.isStandalone ? this.newTab(e) : e.messenger && e.messenger.post && e.messenger.post("game.moregames", {
  1682. branding: t
  1683. })
  1684. },
  1685. t.prototype.displayOnTop = function(e) {
  1686. if (e === void 0 || e.url === void 0 || "string" != typeof e.url || e.action === void 0 || "function" != typeof e.action) return e.callback !== void 0 || "function" == typeof e.callback ? (e.callback(), void 0) : void 0;
  1687. var t = document.createElement("div"),
  1688. n = e.url,
  1689. i = e.action,
  1690. a = e.callback;
  1691. t.setAttribute("id", "spilgames-splash-screen-sample"),
  1692. document.body.appendChild(t);
  1693. var s = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
  1694. r = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
  1695. return t.style.left = "0",
  1696. t.style.top = "0",
  1697. t.style.width = s + "px",
  1698. t.style.height = r + "px",
  1699. t.style.position = "absolute",
  1700. t.style.zIndex = "10000",
  1701. t.onclick = i,
  1702. n && (t.style.background = "url('" + n + "') center center no-repeat #FFF"),
  1703. window.setTimeout(function() {
  1704. var e = document.getElementById("spilgames-splash-screen-sample");
  1705. e.parentNode.removeChild(e),
  1706. a && a()
  1707. },
  1708. 2e3),
  1709. t
  1710. },
  1711. n.prototype.get = function(e) {
  1712. for (var t = this.dataStore,
  1713. n = e.split("."), i = n.length, a = 0; i - 1 > a; a++) {
  1714. if (!t[n[a]]) return null;
  1715. t = t[n[a]]
  1716. }
  1717. return t[n[i - 1]] || null
  1718. },
  1719. n.prototype.put = function(e, t) {
  1720. for (var n = this.dataStore,
  1721. i = e.split("."), a = i.length, s = 0; a - 1 > s; s++) {
  1722. var r = i[s];
  1723. n[r] || (n[r] = {}),
  1724. n = n[r]
  1725. }
  1726. n[i[a - 1]] = t
  1727. },
  1728. n.prototype.set = function(e, t) {
  1729. this.put(e, t);
  1730. var n = Date.parse(new Date);
  1731. return this.notify({
  1732. type: "new",
  1733. key: e,
  1734. current: t,
  1735. previous: null,
  1736. timestamp: n
  1737. }),
  1738. t
  1739. },
  1740. n.prototype.update = function(e, t) {
  1741. var n, i, a = null;
  1742. return this.get(e) ? (n = "update", a = this.get(e)) : n = "new",
  1743. this.put(e, t),
  1744. i = Date.parse(new Date),
  1745. this.notify({
  1746. type: n,
  1747. key: e,
  1748. current: t,
  1749. previous: a,
  1750. timestamp: i
  1751. }),
  1752. t
  1753. },
  1754. n.prototype.remove = function(e) {
  1755. if (this.get(e)) {
  1756. var t, n = this.get(e);
  1757. return this.put(e, null),
  1758. t = Date.parse(new Date),
  1759. this.notify({
  1760. type: "remove",
  1761. key: e,
  1762. current: null,
  1763. previous: n,
  1764. timestamp: t
  1765. }),
  1766. !0
  1767. }
  1768. return ! 1
  1769. },
  1770. n.prototype._setCache = function(e) {console.log(e)
  1771. this.dataStore = e
  1772. },
  1773. n.prototype._getCache = function() {
  1774. return this.dataStore
  1775. },
  1776. n.prototype.notify = function(e) {
  1777. if (this.IS_MASTER) {
  1778. var t = new f({
  1779. type: "datachange",
  1780. callbackId: null,
  1781. data: e
  1782. }).encode();
  1783. return window.postMessage(t, "*"),
  1784. t
  1785. }
  1786. },
  1787. i.prototype.init = function(e) {
  1788. e = e || {},
  1789. this.data = e.data || this.data,
  1790. this.data && this.data.game && this.data.user && (this.appId = this.data.game.applicationId || null, this.appToken = this.data.user.appToken || null),
  1791. this._setupEvents(),
  1792. (this.IS_SLAVE || this.IS_STANDALONE || _.isWrapped()) && this._scheduleRefresh()
  1793. },
  1794. i.prototype.getAppToken = function() {
  1795. return this.appToken
  1796. },
  1797. i.prototype._setupEvents = function() {
  1798. this.IS_MASTER ? this.messenger.subscribe("gameapi.apptoken.getAppToken", this._getAppToken, this) : this.messenger.subscribe("gameapi.apptoken.getAppTokenResponse", this._getAppTokenResponse, this)
  1799. },
  1800. i.prototype._retryAppToken = function(e) { (e || this.appTimerDelay !== this.appDelayMax) && (e && !this.appError && (this.appTimerDelay = this.appDelayMin, this.appError = !0), this._unschedule(), e ? this._increaseDelay() : this._resetDelay(), this._scheduleRefresh())
  1801. },
  1802. i.prototype._scheduleRefresh = function() {
  1803. var e = this;
  1804. null === this.appTimer && (this.appTimer = setInterval(function() {
  1805. e._getAppToken()
  1806. },
  1807. this.appTimerDelay))
  1808. },
  1809. i.prototype._unschedule = function() {
  1810. this.appTimer && clearTimeout(this.appTimer),
  1811. this.appTimer = null
  1812. },
  1813. i.prototype._increaseDelay = function() {
  1814. this.appTimerDelay = Math.min(2 * this.appTimerDelay, this.appDelayMax)
  1815. },
  1816. i.prototype._resetDelay = function() {
  1817. this.appTimerDelay = this.appDelayMax
  1818. },
  1819. i.prototype._getAppToken = function() {
  1820. var e = this.messenger;
  1821. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1822. this.IS_MASTER || this.messenger._postMessage({},
  1823. void 0, "gameapi.apptoken.getAppToken"),
  1824. this.IS_MASTER && ("function" == typeof SpilGames ? SpilGames("api.account.getApplicationToken", {
  1825. cache: !1,
  1826. applicationId: this.appId
  1827. },
  1828. function(t) {
  1829. t.error || !t.appAuth.token ? e._postMessage({},
  1830. void 0, "gameapi.apptoken.getAppTokenResponse") : e._postMessage({
  1831. appToken: t.appAuth.token,
  1832. level: t.level
  1833. },
  1834. void 0, "gameapi.apptoken.getAppTokenResponse")
  1835. }) : e._postMessage({},
  1836. void 0, "gameapi.apptoken.getAppTokenResponse"))
  1837. },
  1838. i.prototype._getAppTokenResponse = function(e) {
  1839. e.appToken ? (this.appToken = e.appToken, this._retryAppToken(!1)) : this._retryAppToken(!0)
  1840. },
  1841. a.prototype.init = function(e) {
  1842. e = e || {},
  1843. this.data = e.data || this.data,
  1844. this.data && this.data.game && this.data.user && this.data.portal && (this.gameState.appId = this.data.game.applicationId || null, this.gameState.userId = this.data.user.userId || null, this.isGamestate = this.data.portal.gamestate || !1, this.endpoint = _.getServiceEndpoint(this.data.portal.env), this.spilStorageId = this.data.portal.spilStorageId),
  1845. this.isGamestate && (this.IS_SLAVE || this.IS_STANDALONE || _.isWrapped()) && (this.listenStorageEvents(), this.preloadGameState())
  1846. },
  1847. a.prototype.listenStorageEvents = function() {
  1848. var e = function(e) {
  1849. this.onStorageEvent(e)
  1850. }.bind(this);
  1851. window.addEventListener("storage", e, !1)
  1852. },
  1853. a.prototype.flagDirtyKey = function(e) { - 1 === this.gameState.dirtyKeys.indexOf(e) && (this.gameState.dirtyKeys.push(e), this.scheduleSyncState())
  1854. },
  1855. a.prototype.unschedule = function() {
  1856. this.flushTimer && clearTimeout(this.flushTimer),
  1857. this.flushTimer = null
  1858. },
  1859. a.prototype.scheduleSyncState = function() {
  1860. var e = this;
  1861. null === this.flushTimer && (this.flushTimer = setInterval(function() {
  1862. e.syncState()
  1863. },
  1864. this.flushTimerDelay))
  1865. },
  1866. a.prototype.increaseDelaySyncState = function() {
  1867. this.flushTimerDelay = Math.min(2 * this.flushTimerDelay, this.flushDelayMax)
  1868. },
  1869. a.prototype.resetDelaySyncState = function() {
  1870. this.flushTimerDelay = this.flushDelayMin
  1871. },
  1872. a.prototype.onStorageEvent = function(e) {
  1873. e && e.url && e.url.indexOf("spilStorageId=" + this.spilStorageId) > 0 && this.flagDirtyKey(e.key)
  1874. },
  1875. a.prototype.preloadGameState = function() {
  1876. var e = {
  1877. url: this.endpoint + "/v1/gamestate/" + this.gameState.userId + "/" + this.gameState.appId,
  1878. type: "GET",
  1879. dataType: "JSON",
  1880. headers: {
  1881. "x-auth-token": this.appToken.getAppToken()
  1882. }
  1883. };
  1884. _.xdr(e,
  1885. function(e) {
  1886. if (e.isError) _.log("GameAPIGameState failed preloading: " + e.status);
  1887. else {
  1888. var t = JSON.parse(e.data);
  1889. if (t && t.gamestate) {
  1890. var n = t.gamestate,
  1891. i = 0,
  1892. a = null;
  1893. for (a in n) n.hasOwnProperty(a) && (window.localStorage[a] = n[a], i++);
  1894. _.log("GameAPIGameState preloaded: " + i + " keys")
  1895. }
  1896. }
  1897. })
  1898. },
  1899. a.prototype.retrySyncState = function(e) {
  1900. _.log(e),
  1901. this.increaseDelaySyncState(),
  1902. this.scheduleSyncState()
  1903. },
  1904. a.prototype.syncState = function() {
  1905. if (this.unschedule(), !this.gameState.appId) return this.retrySyncState("GameAPIGameState.prototype.syncStat no appId");
  1906. if (!this.gameState.userId) return this.retrySyncState("GameAPIGameState.prototype.syncState no userId");
  1907. for (var e, t = this.gameState.appId,
  1908. n = this.gameState.userId,
  1909. i = this.gameState.dirtyKeys,
  1910. a = {
  1911. set: {},
  1912. remove: []
  1913. },
  1914. s = 0, r = this, o = 0; i.length > o; o++) e = window.localStorage[i[o]],
  1915. void 0 === e ? a.remove.push(i[o]) : (a.set[i[o]] = e, s = Math.max(e.length, s));
  1916. if (i.length > 0) {
  1917. var l = {
  1918. url: this.endpoint + "/v1/gamestate/" + n + "/" + t,
  1919. type: "POST",
  1920. data: JSON.stringify(a),
  1921. async: !0,
  1922. headers: {
  1923. "x-auth-token": this.appToken.getAppToken()
  1924. }
  1925. };
  1926. _.xdr(l,
  1927. function(e) {
  1928. e.isError ? r.retrySyncState("GameAPIGameState error syncing state") : (_.log("GameAPIGameState synced " + i.length + " keys"), r.resetDelaySyncState(), r.gameState.dirtyKeys = [])
  1929. });
  1930. var p = {
  1931. numkeys: i.length,
  1932. maxdatalength: s,
  1933. userid: n
  1934. };
  1935. this.eventTracking.trackGameAPIEvent("gameState", p)
  1936. }
  1937. return ! 0
  1938. },
  1939. s.prototype.init = function(e) {
  1940. this.data = e.data || null
  1941. },
  1942. s.prototype._performAction = function(e) {
  1943. var t = new f(e.data || {}),
  1944. n = this.messenger,
  1945. i = this.subscribers || {};
  1946. if (t && t.type && t.data) switch (t.type) {
  1947. case "gameEvent":
  1948. t.data[0] && i[t.data[0]] && i[t.data[0]].length > 0 ? i[t.data[0]].forEach(function(e) {
  1949. e.call(this),
  1950. n._postMessage([t.data[0], {
  1951. origin: "slave"
  1952. },
  1953. null], null, "gameState")
  1954. }) : t.data[0] && t.data[1] && "slave" === t.data[1].origin && "function" == typeof SWFtoJS && SWFtoJS({
  1955. call: t.data[0],
  1956. params: {}
  1957. });
  1958. break;
  1959. case "gameState":
  1960. t.data[0] && t.data[1] && "slave" === t.data[1].origin && (this.gameState = t.data[0])
  1961. }
  1962. },
  1963. s.prototype.on = function(e, t) {
  1964. this.IS_SLAVE && (this.subscribers[e] || (this.subscribers[e] = []), this.subscribers[e].push(t))
  1965. },
  1966. s.prototype.emit = function(e) {
  1967. if (!this.IS_MASTER) throw Error("Only the master environment can emit game events");
  1968. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1969. if (e === this.gameState) throw Error("The game is already in state: `" + e + "`");
  1970. this.messenger._postMessage([e, {
  1971. origin: "master"
  1972. },
  1973. null], null, "gameEvent")
  1974. },
  1975. s.prototype.isSiteLock = function() {
  1976. var e = !0;
  1977. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1978. return this.data && this.data.portal && this.data.portal.siteId && 500 > this.data.portal.siteId && (e = !1),
  1979. e
  1980. },
  1981. s.prototype.adjustHeight = function(e) {
  1982. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1983. this.IS_MASTER ? "function" == typeof SpilGames && SpilGames.Events !== void 0 && "function" == typeof SpilGames.Events.publish && SpilGames.Events.publish("portal.adjustheight", {
  1984. height: e,
  1985. onsuccess: function() {}
  1986. }) : (this.messenger._postMessage(e, void 0, "gameapi.game.adjustHeight"), this.messenger._postMessage(["log.gameapi.game.adjustHeight", {
  1987. origin: "slave",
  1988. height: e
  1989. },
  1990. null], null, "log"))
  1991. },
  1992. r.prototype.init = function() {},
  1993. r.prototype.getLocalizedText = function() {
  1994. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1995. return key
  1996. },
  1997. o.prototype.init = function(e) {
  1998. this._setLocale(e),
  1999. this._setupEvents(),
  2000. e && e.data && e.data.portal && e.data.portal.siteId && 500 > e.data.portal.siteId && "0" !== e.data.portal.siteId && (this.isAvailable = !0)
  2001. },
  2002. o.prototype._setupEvents = function() {
  2003. this.IS_MASTER ? (this.messenger.subscribe("gameapi.user.forceAuthentication", this.forceAuthentication, this), this.messenger.subscribe("gameapi.user.getUser", this.getUser, this)) : this.messenger.subscribe("gameapi.user.getUserResponse", this._getUserResponse, this)
  2004. },
  2005. o.prototype.forceAuthentication = function() {
  2006. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2007. this.IS_MASTER ? "function" == typeof SpilGames && SpilGames.Portal !== void 0 && "function" == typeof SpilGames.Portal.forceAuthentication && SpilGames.Portal.forceAuthentication({
  2008. onsuccess: function() {}
  2009. }) : (this.messenger._postMessage({},
  2010. void 0, "gameapi.user.forceAuthentication"), this.messenger._postMessage(["log.gameapi.user.forceAuthentication", {
  2011. origin: "slave"
  2012. },
  2013. null], null, "log"))
  2014. },
  2015. o.prototype.getUser = function(e) {
  2016. var t = this.messenger;
  2017. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2018. if (this.IS_MASTER)"function" == typeof SpilGames ? SpilGames(["JSLib"],
  2019. function(e) {
  2020. e && "function" == typeof e ? e("api.user.getExtended",
  2021. function(e) {
  2022. t._postMessage(e, void 0, "gameapi.user.getUserResponse")
  2023. }) : t._postMessage({
  2024. userInfoExtended: {}
  2025. },
  2026. void 0, "gameapi.user.getUserResponse")
  2027. }) : t._postMessage({
  2028. userInfoExtended: {}
  2029. },
  2030. void 0, "gameapi.user.getUserResponse");
  2031. else {
  2032. if ("function" != typeof e) throw Error("The argument passed to the GameAPI.User.getUser method should be a function");
  2033. this.usercallback = e,
  2034. t._postMessage({},
  2035. void 0, "gameapi.user.getUser"),
  2036. t._postMessage(["log.gameapi.user.getUser", {
  2037. origin: "slave",
  2038. argumentType: typeof e
  2039. },
  2040. null], null, "log")
  2041. }
  2042. },
  2043. o.prototype._getUserResponse = function(e) {
  2044. var t = e.userInfoExtended || {},
  2045. n = this._validateData(t),
  2046. i = !1;
  2047. "" === t.guid && (i = !0),
  2048. this.eventTracking.trackGameAPIEvent("userGet", {
  2049. guid: n.guid || "",
  2050. fail: i
  2051. }),
  2052. this.usercallback(n)
  2053. },
  2054. o.prototype._validateData = function(e) {
  2055. var t = {
  2056. uid: e.uid || "",
  2057. guid: e.guid || "",
  2058. displayName: e.name || "",
  2059. pic_square: e.avatarUrl || "",
  2060. pic_square_large: e.avatarLargeUrl || "",
  2061. gender: e.gender || "",
  2062. age: e.age || "",
  2063. birthday: e.birthdate || "",
  2064. level: e.level || "",
  2065. locale: this.locale || ""
  2066. };
  2067. return t
  2068. },
  2069. o.prototype._setLocale = function(e) {
  2070. e && e.data && e.data.portal && e.data.portal.siteId && (this.locale = this._getLang(e.data.portal.siteId))
  2071. },
  2072. o.prototype._getLang = function(e) {
  2073. for (var t = [{
  2074. siteid: 1,
  2075. lang: "nl-NL"
  2076. },
  2077. {
  2078. siteid: 2,
  2079. lang: "en-US"
  2080. },
  2081. {
  2082. siteid: 5,
  2083. lang: "de-DE"
  2084. },
  2085. {
  2086. siteid: 11,
  2087. lang: "fr-FR"
  2088. },
  2089. {
  2090. siteid: 12,
  2091. lang: "fr-FR"
  2092. },
  2093. {
  2094. siteid: 15,
  2095. lang: "it-IT"
  2096. },
  2097. {
  2098. siteid: 16,
  2099. lang: "pl-PL"
  2100. },
  2101. {
  2102. siteid: 24,
  2103. lang: "en-US"
  2104. },
  2105. {
  2106. siteid: 25,
  2107. lang: "nl-NL"
  2108. },
  2109. {
  2110. siteid: 26,
  2111. lang: "de-DE"
  2112. },
  2113. {
  2114. siteid: 44,
  2115. lang: "sv-SE"
  2116. },
  2117. {
  2118. siteid: 50,
  2119. lang: "pt-BR"
  2120. },
  2121. {
  2122. siteid: 55,
  2123. lang: "en-ID"
  2124. },
  2125. {
  2126. siteid: 79,
  2127. lang: "en-US"
  2128. },
  2129. {
  2130. siteid: 86,
  2131. lang: "es-ES"
  2132. },
  2133. {
  2134. siteid: 87,
  2135. lang: "pt-BR"
  2136. },
  2137. {
  2138. siteid: 88,
  2139. lang: "en-US"
  2140. },
  2141. {
  2142. siteid: 90,
  2143. lang: "en-US"
  2144. },
  2145. {
  2146. siteid: 91,
  2147. lang: "pt-BR"
  2148. },
  2149. {
  2150. siteid: 92,
  2151. lang: "en-GB"
  2152. },
  2153. {
  2154. siteid: 93,
  2155. lang: "nl-NL"
  2156. },
  2157. {
  2158. siteid: 94,
  2159. lang: "de-DE"
  2160. },
  2161. {
  2162. siteid: 95,
  2163. lang: "fr-FR"
  2164. },
  2165. {
  2166. siteid: 96,
  2167. lang: "es-ES"
  2168. },
  2169. {
  2170. siteid: 97,
  2171. lang: "es-ES"
  2172. },
  2173. {
  2174. siteid: 98,
  2175. lang: "pl-PL"
  2176. },
  2177. {
  2178. siteid: 99,
  2179. lang: "it-IT"
  2180. },
  2181. {
  2182. siteid: 100,
  2183. lang: "sv-SE"
  2184. },
  2185. {
  2186. siteid: 101,
  2187. lang: "pt-BR"
  2188. },
  2189. {
  2190. siteid: 102,
  2191. lang: "en-GB"
  2192. },
  2193. {
  2194. siteid: 103,
  2195. lang: "ru-RU"
  2196. },
  2197. {
  2198. siteid: 104,
  2199. lang: "ru-RU"
  2200. },
  2201. {
  2202. siteid: 105,
  2203. lang: "ru-RU"
  2204. },
  2205. {
  2206. siteid: 106,
  2207. lang: "it-IT"
  2208. },
  2209. {
  2210. siteid: 107,
  2211. lang: "en-GB"
  2212. },
  2213. {
  2214. siteid: 108,
  2215. lang: "sv-SE"
  2216. },
  2217. {
  2218. siteid: 109,
  2219. lang: "pl-PL"
  2220. },
  2221. {
  2222. siteid: 115,
  2223. lang: "en-GB"
  2224. },
  2225. {
  2226. siteid: 116,
  2227. lang: "tr-TR"
  2228. },
  2229. {
  2230. siteid: 118,
  2231. lang: "ms-MY"
  2232. },
  2233. {
  2234. siteid: 119,
  2235. lang: "en-GB"
  2236. },
  2237. {
  2238. siteid: 120,
  2239. lang: "jp-JP"
  2240. },
  2241. {
  2242. siteid: 121,
  2243. lang: "en-US"
  2244. },
  2245. {
  2246. siteid: 122,
  2247. lang: "es-ES"
  2248. },
  2249. {
  2250. siteid: 123,
  2251. lang: "en-US"
  2252. },
  2253. {
  2254. siteid: 124,
  2255. lang: "en-US"
  2256. },
  2257. {
  2258. siteid: 125,
  2259. lang: "AR"
  2260. },
  2261. {
  2262. siteid: 126,
  2263. lang: "en-US"
  2264. },
  2265. {
  2266. siteid: 127,
  2267. lang: "en-US"
  2268. },
  2269. {
  2270. siteid: 128,
  2271. lang: "nl-NL"
  2272. },
  2273. {
  2274. siteid: 129,
  2275. lang: "es-AR"
  2276. },
  2277. {
  2278. siteid: 130,
  2279. lang: "es-MX"
  2280. },
  2281. {
  2282. siteid: 131,
  2283. lang: "de-DE"
  2284. },
  2285. {
  2286. siteid: 132,
  2287. lang: "en-EN"
  2288. },
  2289. {
  2290. siteid: 133,
  2291. lang: "en-EN"
  2292. },
  2293. {
  2294. siteid: 134,
  2295. lang: "en-ID"
  2296. },
  2297. {
  2298. siteid: 135,
  2299. lang: "de-DE"
  2300. },
  2301. {
  2302. siteid: 136,
  2303. lang: "pl-PL"
  2304. },
  2305. {
  2306. siteid: 137,
  2307. lang: "en-EN"
  2308. },
  2309. {
  2310. siteid: 138,
  2311. lang: "it-IT"
  2312. },
  2313. {
  2314. siteid: 139,
  2315. lang: "uk-UA"
  2316. },
  2317. {
  2318. siteid: 140,
  2319. lang: "en-ID"
  2320. },
  2321. {
  2322. siteid: 141,
  2323. lang: "uk-UA"
  2324. },
  2325. {
  2326. siteid: 142,
  2327. lang: "ja-JP"
  2328. },
  2329. {
  2330. siteid: 143,
  2331. lang: "nl-NL"
  2332. },
  2333. {
  2334. siteid: 144,
  2335. lang: "en-US"
  2336. },
  2337. {
  2338. siteid: 145,
  2339. lang: "en-US"
  2340. },
  2341. {
  2342. siteid: 146,
  2343. lang: "en-US"
  2344. },
  2345. {
  2346. siteid: 147,
  2347. lang: "en-US"
  2348. },
  2349. {
  2350. siteid: 148,
  2351. lang: "en-US"
  2352. },
  2353. {
  2354. siteid: 149,
  2355. lang: "en-IN"
  2356. },
  2357. {
  2358. siteid: 150,
  2359. lang: "tr-TR"
  2360. },
  2361. {
  2362. siteid: 151,
  2363. lang: "de-DE"
  2364. },
  2365. {
  2366. siteid: 152,
  2367. lang: "ru-RU"
  2368. },
  2369. {
  2370. siteid: 153,
  2371. lang: "ru-RU"
  2372. },
  2373. {
  2374. siteid: 154,
  2375. lang: "ru-RU"
  2376. },
  2377. {
  2378. siteid: 155,
  2379. lang: "en-US"
  2380. },
  2381. {
  2382. siteid: 156,
  2383. lang: "tr-TR"
  2384. },
  2385. {
  2386. siteid: 157,
  2387. lang: "tr-TR"
  2388. },
  2389. {
  2390. siteid: 158,
  2391. lang: "tr-TR"
  2392. },
  2393. {
  2394. siteid: 159,
  2395. lang: "en-US"
  2396. },
  2397. {
  2398. siteid: 160,
  2399. lang: "en-US"
  2400. },
  2401. {
  2402. siteid: 161,
  2403. lang: "en-US"
  2404. },
  2405. {
  2406. siteid: 162,
  2407. lang: "en-US"
  2408. },
  2409. {
  2410. siteid: 163,
  2411. lang: "en-US"
  2412. },
  2413. {
  2414. siteid: 164,
  2415. lang: "en-US"
  2416. },
  2417. {
  2418. siteid: 165,
  2419. lang: "en-US"
  2420. },
  2421. {
  2422. siteid: 166,
  2423. lang: "en-US"
  2424. },
  2425. {
  2426. siteid: 167,
  2427. lang: "en-US"
  2428. },
  2429. {
  2430. siteid: 168,
  2431. lang: "en-US"
  2432. },
  2433. {
  2434. siteid: 169,
  2435. lang: "en-US"
  2436. },
  2437. {
  2438. siteid: 170,
  2439. lang: "en-US"
  2440. },
  2441. {
  2442. siteid: 171,
  2443. lang: "en-US"
  2444. },
  2445. {
  2446. siteid: 172,
  2447. lang: "en-US"
  2448. },
  2449. {
  2450. siteid: 173,
  2451. lang: "en-US"
  2452. },
  2453. {
  2454. siteid: 174,
  2455. lang: "en-US"
  2456. },
  2457. {
  2458. siteid: 175,
  2459. lang: "en-US"
  2460. },
  2461. {
  2462. siteid: 176,
  2463. lang: "en-US"
  2464. },
  2465. {
  2466. siteid: 177,
  2467. lang: "en-US"
  2468. },
  2469. {
  2470. siteid: 178,
  2471. lang: "en-US"
  2472. },
  2473. {
  2474. siteid: 179,
  2475. lang: "en-US"
  2476. },
  2477. {
  2478. siteid: 180,
  2479. lang: "en-UK"
  2480. },
  2481. {
  2482. siteid: 181,
  2483. lang: "nl-NL"
  2484. },
  2485. {
  2486. siteid: 182,
  2487. lang: "fr-FR"
  2488. },
  2489. {
  2490. siteid: 183,
  2491. lang: "de-DE"
  2492. },
  2493. {
  2494. siteid: 184,
  2495. lang: "en-US"
  2496. },
  2497. {
  2498. siteid: 185,
  2499. lang: "en-US"
  2500. },
  2501. {
  2502. siteid: 186,
  2503. lang: "en-EN"
  2504. },
  2505. {
  2506. siteid: 187,
  2507. lang: "en-EN"
  2508. },
  2509. {
  2510. siteid: 188,
  2511. lang: "en-EN"
  2512. },
  2513. {
  2514. siteid: 189,
  2515. lang: "en-EN"
  2516. },
  2517. {
  2518. siteid: 190,
  2519. lang: "en-EN"
  2520. },
  2521. {
  2522. siteid: 191,
  2523. lang: "en-US"
  2524. },
  2525. {
  2526. siteid: 192,
  2527. lang: "pt-BR"
  2528. },
  2529. {
  2530. siteid: 193,
  2531. lang: "en-US"
  2532. },
  2533. {
  2534. siteid: 450,
  2535. lang: "en-US"
  2536. },
  2537. {
  2538. siteid: 451,
  2539. lang: "nl-NL"
  2540. },
  2541. {
  2542. siteid: 452,
  2543. lang: "de-DE"
  2544. },
  2545. {
  2546. siteid: 453,
  2547. lang: "fr-FR"
  2548. },
  2549. {
  2550. siteid: 454,
  2551. lang: "es-ES"
  2552. },
  2553. {
  2554. siteid: 455,
  2555. lang: "it-IT"
  2556. },
  2557. {
  2558. siteid: 456,
  2559. lang: "en-GB"
  2560. },
  2561. {
  2562. siteid: 457,
  2563. lang: "en-ID"
  2564. },
  2565. {
  2566. siteid: 458,
  2567. lang: "es-AR"
  2568. },
  2569. {
  2570. siteid: 459,
  2571. lang: "es-LA"
  2572. },
  2573. {
  2574. siteid: 460,
  2575. lang: "es-MX"
  2576. },
  2577. {
  2578. siteid: 461,
  2579. lang: "jp-JP"
  2580. },
  2581. {
  2582. siteid: 462,
  2583. lang: "ms-MY"
  2584. },
  2585. {
  2586. siteid: 463,
  2587. lang: "pl-PL"
  2588. },
  2589. {
  2590. siteid: 464,
  2591. lang: "pt-BR"
  2592. },
  2593. {
  2594. siteid: 465,
  2595. lang: "pt-PT"
  2596. },
  2597. {
  2598. siteid: 466,
  2599. lang: "ru-RU"
  2600. },
  2601. {
  2602. siteid: 467,
  2603. lang: "sv-SE"
  2604. },
  2605. {
  2606. siteid: 468,
  2607. lang: "tr-TR"
  2608. }], n = 0; t.length > n; n++) if (t[n].siteid === e) return t[n].lang;
  2609. return ""
  2610. },
  2611. l.prototype.init = function(e) {
  2612. this._setupEvents(),
  2613. e && e.data && e.data.portal && e.data.portal.siteId && 500 > e.data.portal.siteId && "0" !== e.data.portal.siteId && (this.isAvailable = !0)
  2614. },
  2615. l.prototype._setupEvents = function() {
  2616. this.IS_MASTER ? (this.messenger.subscribe("gameapi.friends.showInvite", this.showInvite, this), this.messenger.subscribe("gameapi.friends.getFriends", this.getFriends, this)) : this.messenger.subscribe("gameapi.friends.getFriendsResponse", this._getFriendsResponse, this)
  2617. },
  2618. l.prototype.showInvite = function() {
  2619. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2620. this.IS_MASTER ? "function" == typeof SpilGames && SpilGames.Events !== void 0 && "function" == typeof SpilGames.Events.publish && SpilGames.Events.publish("invitefriends.request") : (this.messenger._postMessage({},
  2621. void 0, "gameapi.friends.showInvite"), this.messenger._postMessage(["log.gameapi.friends.showInvite", {
  2622. origin: "slave"
  2623. },
  2624. null], null, "log"), this.eventTracking.trackGameAPIEvent("friendsInvite", {
  2625. guid: this.guid || ""
  2626. }))
  2627. },
  2628. l.prototype.getFriends = function(e) {
  2629. var t = this.messenger;
  2630. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2631. if (this.IS_MASTER) {
  2632. if ("function" == typeof SpilGames) {
  2633. var n = this;
  2634. SpilGames(["JSLib"],
  2635. function(e) {
  2636. e && "function" == typeof e ? e("api.user.getExtended",
  2637. function(e) {
  2638. e.userInfoExtended && "guest" !== e.userInfoExtended.name && e.userInfoExtended.guid ? (this.userGuid = e.userInfoExtended.guid, n._getFriendsFromPortal([], 1)) : t._postMessage({
  2639. friendList: {}
  2640. },
  2641. void 0, "gameapi.friends.getFriendsResponse")
  2642. }) : t._postMessage({
  2643. friendList: {}
  2644. },
  2645. void 0, "gameapi.friends.getFriendsResponse")
  2646. })
  2647. }
  2648. } else "function" == typeof e && (this.friendscallback = e),
  2649. t._postMessage({},
  2650. void 0, "gameapi.friends.getFriends"),
  2651. t._postMessage(["log.gameapi.friends.getFriends", {
  2652. origin: "slave"
  2653. },
  2654. null], null, "log")
  2655. },
  2656. l.prototype._getFriendsFromPortal = function(e, t) {
  2657. var n = this.messenger,
  2658. i = e;
  2659. if ("function" == typeof SpilGames) {
  2660. var a = this;
  2661. SpilGames("api.friend.list", {
  2662. guid: this.userGuid,
  2663. pageControl: {
  2664. page: t,
  2665. pageSize: 500
  2666. }
  2667. },
  2668. function(e) {
  2669. e.error ? n._postMessage(i, void 0, "gameapi.friends.getFriendsResponse") : (i = i.concat(e.friendList), e.pageControl && e.pageControl.totalPages > t ? a._getFriendsFromPortal(i, t + 1) : n._postMessage({
  2670. friendList: i
  2671. },
  2672. void 0, "gameapi.friends.getFriendsResponse"))
  2673. })
  2674. } else n._postMessage({
  2675. friendList: e
  2676. },
  2677. void 0, "gameapi.friends.getFriendsResponse")
  2678. },
  2679. l.prototype._getFriendsResponse = function(e) {
  2680. var t = this._validateData(e.friendList),
  2681. n = !1;
  2682. 0 === t.length && (n = !0),
  2683. this.eventTracking.trackGameAPIEvent("friendsGet", {
  2684. guid: this.guid || "",
  2685. fail: n
  2686. }),
  2687. this.friendscallback(t)
  2688. },
  2689. l.prototype._validateData = function(e) {
  2690. for (var t = [], n = 0; e.length > n; n++) {
  2691. var i = {
  2692. uid: e[n].uid || "",
  2693. guid: e[n].guid || "",
  2694. displayName: e[n].name || "",
  2695. pic_square: e[n].avatarUrl || "",
  2696. pic_square_large: e[n].avatarLargeUrl || "",
  2697. gender: e[n].gender || "",
  2698. age: e[n].age || ""
  2699. };
  2700. t.push(i)
  2701. }
  2702. return t
  2703. },
  2704. p.prototype._setupMasterEvent = function() {
  2705. this.IS_MASTER && this.messenger.subscribe("gameapi.score", this.submit, this)
  2706. },
  2707. p.prototype.submit = function(e) {
  2708. // updateShare(e);
  2709. Play68.setRankingScoreDesc(e);
  2710. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2711. if (this.IS_MASTER) {
  2712. var t = !1,
  2713. n = window.outerHeight - window.innerHeight;
  2714. n === this.initialHeight && (t = !0),
  2715. this.eventTracking.trackGameAPIEvent("scoreSubmit", {
  2716. score: e,
  2717. initialheight: this.initialHeight,
  2718. submitheight: n,
  2719. equals: t
  2720. }),
  2721. "function" == typeof SWFtoJS && SWFtoJS({
  2722. call: "UPDATE_HIGHSCORE",
  2723. params: {
  2724. score: e
  2725. }
  2726. })
  2727. } else this.messenger._postMessage(e, void 0, "gameapi.score"),
  2728. this.messenger._postMessage(["log.gameapi.score.submit", {
  2729. origin: "slave",
  2730. score: e
  2731. },
  2732. null], null, "log");
  2733. return {
  2734. success: !0,
  2735. value: e
  2736. }
  2737. },
  2738. u.prototype._setupMasterEvent = function() {
  2739. this.IS_MASTER && this.messenger.subscribe("gameapi.award", this.submit, this)
  2740. },
  2741. u.prototype.submit = function(e) {
  2742. var t = e.award || "";
  2743. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2744. if (this.IS_MASTER) {
  2745. var n = !1;
  2746. window.outerHeight - window.innerHeight === this.initialHeight && (n = !0),
  2747. this.eventTracking.trackGameAPIEvent("awardSubmit", {
  2748. award: t,
  2749. initialheight: this.initialHeight,
  2750. submitheight: window.outerHeight - window.innerHeight,
  2751. equals: n
  2752. })
  2753. } else this.messenger._postMessage(e, void 0, "gameapi.award"),
  2754. this.messenger._postMessage(["log.gameapi.award.submit", {
  2755. origin: "slave",
  2756. award: t
  2757. },
  2758. null], null, "log");
  2759. return {
  2760. success: !0,
  2761. value: e.award
  2762. }
  2763. },
  2764. d.prototype.init = function(e) {
  2765. e = e || {},
  2766. this.data = e.data || this.data,
  2767. this._setupEvents()
  2768. },
  2769. d.prototype._setupEvents = function() {
  2770. var e = this.messenger,
  2771. t = this;
  2772. this.isMaster ? (SpilGames(["JSLib"],
  2773. function(n) {
  2774. n.subscribe("ad.request.accepted",
  2775. function(n) { ! 0 === n && t.adRequested && (t.adRequested = !1, SpilGames("game.ad.accepted", !0), e._postMessage(!0, void 0, "ad.request.accepted"))
  2776. }),
  2777. n.subscribe("ad.complete",
  2778. function() {
  2779. e._postMessage("", "", "ad.complete")
  2780. })
  2781. }), this.messenger.subscribe("gameapi.ad.request", this._setupAd, this), this.messenger.subscribe("game.ad.request", this._triggerAd, this), this.messenger.subscribe("game.force.break", this._forceGamebreak, this)) : (this.messenger.subscribe("ad.request.accepted", this._onAdAccepted, this), this.messenger.subscribe("ad.complete", this._onAdCompleted, this))
  2782. },
  2783. d.prototype._setupAd = function() {
  2784. this.adRequested = !0
  2785. },
  2786. d.prototype._triggerAd = function() {
  2787. SpilGames("game.ad.request")
  2788. },
  2789. d.prototype._forceGamebreak = function() {
  2790. SpilGames("game.ad.accepted", !0)
  2791. },
  2792. d.prototype._runCallback = function(e) {
  2793. this._callbacks[e] && (this._callbacks[e](), this._callbacks[e] = !1)
  2794. },
  2795. d.prototype.isAvailable = function() {
  2796. var e = !1;
  2797. return this.data && this.data.portal && this.data.portal.siteId && 500 > this.data.portal.siteId && (e = !0),
  2798. e
  2799. },
  2800. d.prototype.reward = function(e, t) {
  2801. if ("function" != typeof e) throw Error("pauseGame argument should be a function");
  2802. if ("function" != typeof t) throw Error("resumeGame argument should be a function");
  2803. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2804. e(),
  2805. this.isMaster ? t() : (this._callbacks.resume = t, this.messenger._postMessage(void 0, void 0, "game.force.break"))
  2806. },
  2807. d.prototype.request = function(e, t) {
  2808. var n = this;
  2809. if ("function" != typeof e) throw Error("pauseGame argument should be a function");
  2810. if ("function" != typeof t) throw Error("resumeGame argument should be a function");
  2811. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2812. this._callbacks.pause = e,
  2813. this._callbacks.resume = t,
  2814. this.isMaster || (this.messenger._postMessage(void 0, void 0, "gameapi.ad.request"), this.messenger._postMessage(["log.gameapi.ad.requested", {
  2815. origin: "slave"
  2816. },
  2817. null], null, "log")),
  2818. this.messenger._postMessage(void 0, void 0, "game.ad.request"),
  2819. this.timeout = setTimeout(function() {
  2820. n._requestTimeout()
  2821. },
  2822. this.timeoutAfter)
  2823. },
  2824. d.prototype._onAdAccepted = function(e) {
  2825. var t = this.messenger;
  2826. this.timeout && clearTimeout(this.timeout),
  2827. !this.isMaster && e && (t._postMessage(["log.gameapi.ad.start", {
  2828. origin: "slave"
  2829. },
  2830. null], null, "log"), this._runCallback("pause"))
  2831. },
  2832. d.prototype._onAdCompleted = function() {
  2833. var e = this.messenger;
  2834. this.isMaster || e._postMessage(["log.gameapi.ad.complete", {
  2835. origin: "slave"
  2836. },
  2837. null], null, "log"),
  2838. this._runCallback("resume")
  2839. },
  2840. d.prototype._requestTimeout = function() {
  2841. this._onAdCompleted()
  2842. },
  2843. c.prototype._setupEvents = function() {
  2844. this.IS_MASTER && this.messenger.subscribe("gameapi.gameevent", this.emit, this)
  2845. },
  2846. c.prototype._validateEvent = function(e) {
  2847. var t = !1;
  2848. return this.events[e] && this.events[e] !== void 0 && (t = !0),
  2849. t
  2850. },
  2851. c.prototype.emit = function(e) {
  2852. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  2853. this._validateEvent(e) ? this.IS_MASTER ? "function" == typeof SWFtoJS && SWFtoJS({
  2854. call: e
  2855. }) : (this.messenger._postMessage(e, void 0, "gameapi.gameevent"), this.messenger._postMessage(["log.gameapi.gameevent.emit", {
  2856. origin: "slave",
  2857. evt: e
  2858. },
  2859. null], null, "log")) : this.IS_MASTER || this.messenger._postMessage(["log.gameapi.gameevent.emit", {
  2860. origin: "slave"
  2861. },
  2862. null], null, "log")
  2863. },
  2864. h.prototype.init = function(e) {
  2865. e = e || {},
  2866. this.data = e.data || this.data;
  2867. var t = this.data && this.data.game && this.data.game.applicationId ? this.data.game.applicationId: null,
  2868. n = new Date,
  2869. i = window.location.hostname;
  2870. this.data && this.data.portal ? (this.isGamestate = this.data.portal.gamestate || !1, this.siteId = this.data.portal.siteId ? this.data.portal.siteId: null, this.channelId = this.data.portal.channelId ? this.data.portal.channelId: null) : (this.siteId = null, this.channelId = null),
  2871. this.configureInternalTracking(t, n, i),
  2872. this.isGamestate || (this.IS_SLAVE || this.IS_STANDALONE || _.isWrapped()) && this.startInternalTracking()
  2873. },
  2874. h.prototype._createEventObject = function(e, t, n) {
  2875. return {
  2876. eventCategory: e,
  2877. eventAction: t,
  2878. properties: n
  2879. }
  2880. },
  2881. h.prototype._sendSETEvent = function(e, t, n) {
  2882. return this.IS_STANDALONE ? _.submitData("", t, n) : this.messenger && this.messenger.post("tracker.event." + e, t, n),
  2883. t
  2884. },
  2885. h.prototype.trackGamePlay = function(e) {
  2886. if (!this.gamePlayTracking.started) return ! 1;
  2887. var t = this.gamePlayTracking.appid,
  2888. n = this.gamePlayTracking.timestamp,
  2889. i = this.gamePlayTracking.host,
  2890. a = this._createEventObject("game", "gameplay", {
  2891. applicationId: t,
  2892. start: n,
  2893. host: i
  2894. }),
  2895. s = this.data.isLocal,
  2896. r = !0,
  2897. o = 0,
  2898. l = 0;
  2899. this.siteId && (o = parseInt(this.siteId, 10)),
  2900. this.channelId && (l = parseInt(this.channelId, 10)),
  2901. this.data && this.data.branding && this.data.branding.logo && this.data.branding.logo.image && (r = !1);
  2902. var p = this._createEventObject("gameapi", "load", {
  2903. siteid: o,
  2904. appid: t,
  2905. channelid: l,
  2906. domainname: i,
  2907. isstandalone: this.IS_STANDALONE,
  2908. isfallbackconfig: s,
  2909. iswhitelisted: r
  2910. });
  2911. return this._sendSETEvent("express", a, e),
  2912. this._sendSETEvent("express", p,
  2913. function() {}),
  2914. a
  2915. },
  2916. h.prototype.trackTimeInGame = function(e) {
  2917. if (!this.timeInGameTracking.started) return ! 1;
  2918. var t = this.timeInGameTracking.appid,
  2919. n = this.timeInGameTracking.timestamp,
  2920. i = this._createEventObject("game", "heartbeat", {
  2921. applicationId: t,
  2922. start: n
  2923. });
  2924. return this._sendSETEvent("express", i, e),
  2925. i
  2926. },
  2927. h.prototype.trackGameAPIEvent = function(e, t) {
  2928. t.appid = this.gamePlayTracking.appid,
  2929. t.domainname = this.gamePlayTracking.host,
  2930. t.siteid = parseInt(this.siteId, 10),
  2931. t.channelid = parseInt(this.channelId, 10);
  2932. var n = this._createEventObject("gameapi", e, t);
  2933. this._sendSETEvent("express", n,
  2934. function() {})
  2935. },
  2936. h.prototype.configureInternalTracking = function(e, t, n) {
  2937. return e ? (this.gamePlayTracking.appid = e, this.gamePlayTracking.timestamp = Date.parse(t), this.gamePlayTracking.host = n, this.timeInGameTracking.appid = e, this.timeInGameTracking.timestamp = Date.parse(t), void 0) : {
  2938. error: "No application ID defined for this game"
  2939. }
  2940. },
  2941. h.prototype.startInternalTracking = function() {
  2942. var e = this,
  2943. t = 6e4,
  2944. n = function(e) {
  2945. if (!e) throw "Could not save the time in game"
  2946. };
  2947. return this.moduleReady ? this.gamePlayTracking.appid ? (this.gamePlayTracking.started = !0, this.timeInGameTracking.started = !0, this.trackGamePlay(function(e) {
  2948. if (!e) throw "Could not save the game play"
  2949. }), this.trackTimeInGame(n), setInterval(function() {
  2950. e.trackTimeInGame(n)
  2951. },
  2952. t), this.gamePlayTracking.started && this.timeInGameTracking.started) : {
  2953. error: "No application ID defined for this game"
  2954. }: {
  2955. error: "This method cannot be called before the API is loaded"
  2956. }
  2957. },
  2958. g.prototype.init = function(e) {
  2959. var t;
  2960. e = e || {},
  2961. this.data = e.data || this.data,
  2962. this.data && this.data.portal && this.data.portal.siteId && (t = this.data.portal.siteId, (t > 499 || 12 === t || 25 === t || 26 === t || 55 === t || 79 === t || 97 === t || 105 === t || 108 === t || 138 === t || 157 === t || 121 === t || 1 === t || 5 === t || 11 === t || 15 === t || 16 === t || 44 === t || 50 === t || 87 === t || 86 === t || 88 === t || 92 === t || 103 === t || 140 === t || 90 === t || 93 === t || 95 === t || 94 === t || 96 === t || 98 === t || 99 === t || 100 === t || 101 === t || 102 === t || 104 === t || 134 === t) && this.data.branding && this.data.branding.more_games && this.data.branding.more_games.handler && "moreGames" !== this.data.branding.more_games.handler && (this.data.branding.more_games.handler = "moreGames"))
  2963. },
  2964. g.prototype.getLogo = function(e) {
  2965. if (!this.moduleReady) return {
  2966. error: "This method cannot be called before the API is loaded"
  2967. };
  2968. var t = this.IS_MASTER ? "master": "slave";
  2969. this.messenger._postMessage(["log.branding.getlogo", {
  2970. origin: t
  2971. },
  2972. null], null, "log");
  2973. var n, i, a = {
  2974. type: {
  2975. type: "String",
  2976. values: ["png"]
  2977. },
  2978. width: "Number",
  2979. height: "Number"
  2980. };
  2981. return n = this._getLink("logo"),
  2982. e && "object" == typeof e && (i = _.validateSchema(a, e), i.error && (n.error = i.error)),
  2983. n
  2984. },
  2985. g.prototype.getLink = function(e) {
  2986. if (!e) return {
  2987. error: "No link identifier provided"
  2988. };
  2989. var t = this.listLinks();
  2990. if ( - 1 !== t.indexOf(e)) {
  2991. var n = this.IS_MASTER ? "master": "slave";
  2992. return this.messenger._postMessage(["log.branding.getlink", {
  2993. origin: n,
  2994. linkName: e
  2995. },
  2996. null], null, "log"),
  2997. this._getLink(e)
  2998. }
  2999. return {
  3000. error: "Invalid option: '" + e + "'",
  3001. action: function() {}
  3002. }
  3003. },
  3004. g.prototype._getLink = function(e) {
  3005. if (!e) return {
  3006. error: "No link identifier provided"
  3007. };
  3008. var t = this.data && this.data.branding ? this.data.branding: {};
  3009. return t && t[e] ? {
  3010. linkName: e,
  3011. image: t[e].image || !1,
  3012. action: this._executeHandler.bind(this, e)
  3013. }: {
  3014. error: "Invalid option: '" + e + "'",
  3015. action: function() {}
  3016. }
  3017. },
  3018. g.prototype._getGMLink = function(e) {
  3019. var t = null;
  3020. if (!e) return {
  3021. error: "No link identifier provided"
  3022. };
  3023. var n = this.data && this.data.branding ? this.data.branding: {};
  3024. return n && n[e] ? (t = this._tagUrl(n[e].url, e), {
  3025. linkName: e,
  3026. url: t
  3027. }) : {
  3028. error: "Invalid option: '" + e + "'",
  3029. url: null
  3030. }
  3031. },
  3032. g.prototype.getLinks = function() {
  3033. var e = {},
  3034. t = this.listLinks();
  3035. if (0 === t.length) e = {
  3036. more_games: {
  3037. action: function() {}
  3038. }
  3039. };
  3040. else for (var n = 0; t.length > n; n++) {
  3041. var i = t[n];
  3042. e[i] = this._getLink(i)
  3043. }
  3044. return e
  3045. },
  3046. g.prototype._executeHandler = function(e) {
  3047. var t = this.data && this.data.branding ? this.data.branding: {},
  3048. n = t[e],
  3049. i = n.handler,
  3050. a = this._tagUrl(n.url, e),
  3051. s = this._getBrandName(t);
  3052. if (n.url && n.url.length > 0 && i && this.components[i]) {
  3053. var r = this.IS_MASTER ? "master": "slave";
  3054. return this.messenger._postMessage(["log.branding.linkAction", {
  3055. origin: r,
  3056. linkName: e
  3057. },
  3058. null], null, "log"),
  3059. this.components[i]({
  3060. url: a,
  3061. messenger: this.messenger,
  3062. isStandalone: this.IS_STANDALONE,
  3063. brandName: s
  3064. })
  3065. }
  3066. return function() {}
  3067. },
  3068. g.prototype._getBrandName = function(e) {
  3069. // var t = "a10";
  3070. if (e && e.more_games && e.more_games.url) {
  3071. _czc.push(["_trackEvent","open进入游戏","戳爆他们","","",""]);
  3072. if(document.referrer)
  3073. Play68.goHome();
  3074. else
  3075. play68_goHome();
  3076. // var n = e.more_games.url;
  3077. // t = n.replace(/(.*)www./, "").replace(/\..*/, "")
  3078. }
  3079. // return t
  3080. },
  3081. g.prototype.listLinks = function() {
  3082. var e = [],
  3083. t = this.data && this.data.branding ? this.data.branding: {},
  3084. n = Object.keys(t);
  3085. return e = n.filter(function(e) {
  3086. return ! t[e].blacklisted
  3087. })
  3088. },
  3089. g.prototype.getSplashScreen = function() {
  3090. var e, t = this.IS_MASTER ? "master": "slave";
  3091. if (this.data && this.data.branding && this.data.branding.splash_screen) {
  3092. var n = !0;
  3093. this.data.branding.splash_screen.image || this.data.branding.splash_screen.url || (n = !1),
  3094. e = {
  3095. show: n,
  3096. action: this._getLink("splash_screen").action ||
  3097. function() {}
  3098. }
  3099. } else e = {
  3100. show: !0,
  3101. action: function() {}
  3102. };
  3103. return this.messenger._postMessage(["log.branding.splashScreen", {
  3104. origin: t
  3105. },
  3106. null], null, "log"),
  3107. e
  3108. },
  3109. g.prototype.displaySplashScreen = function(e) {
  3110. if ("function" != typeof e) throw Error("argument passed to displaySplashScreen method should be a function");
  3111. var t = this.IS_MASTER ? "master": "slave",
  3112. n = this._getLink("logo").image;
  3113. n && this.getSplashScreen().show ? ("master" !== t && this.messenger._postMessage(["log.branding.displaySplashScreen", {
  3114. origin: t
  3115. },
  3116. null], null, "log"), this.components.displayOnTop({
  3117. url: n,
  3118. action: this.getSplashScreen().action,
  3119. callback: e
  3120. })) : e()
  3121. },
  3122. g.prototype._tagUrl = function(e, t) {
  3123. var n, i, a, s = this.data && this.data.portal ? this.data.portal: {},
  3124. r = this.data && this.data.game ? this.data.game: {},
  3125. o = parseInt(s.siteId, 10);
  3126. if ("string" != typeof e) throw Error("No url specified");
  3127. return n = "string" == typeof t ? t: "logo",
  3128. i = "brandedgames_" + (o > 0 && 500 > o ? "internal": "external"),
  3129. a = ["utm_medium=" + i, "utm_campaign=" + r.applicationId, "utm_source=" + s.host, "utm_content=" + n].join("&"),
  3130. e += e.indexOf("?") > -1 ? "&": "?",
  3131. e + a
  3132. },
  3133. f.prototype.encode = function() {
  3134. var e = ["gameapi", this.type, this.callbackId, this.data ? JSON.stringify(this.data) : ""].join("|");
  3135. return e
  3136. },
  3137. y.prototype._postMessage = function(e, t, n) {
  3138. var i, a;
  3139. i = _.isArray(e) && "function" == typeof e[e.length - 1] ? this._callbacks.push(e.pop()) - 1 : t,
  3140. a = new f({
  3141. type: n || "jslib",
  3142. callbackId: i,
  3143. data: e
  3144. }).encode();
  3145. for (var s = 0; this._targets.length > s; s++) this._targets[s].postMessage(a, "*")
  3146. },
  3147. y.prototype._callJSLib = function() {
  3148. SpilGames.apply(SpilGames, _.argsToArray(arguments))
  3149. },
  3150. y.prototype._setupEventListener = function() {
  3151. window.addEventListener ? window.addEventListener("message", this._handleMessage.bind(this), !1) : window.attachEvent && window.attachEvent("onmessage", this._handleMessage.bind(this))
  3152. },
  3153. y.prototype._handleMessage = function(e) {
  3154. var t, n, i, a, s = this,
  3155. r = new f(e.data);
  3156. if (r) if (t = r.type, n = r.callbackId, i = r.data, a = this._callbacks[n] || !1, this.IS_MASTER) switch (t) {
  3157. case "jslib":
  3158. "Array" === i.constructor.name && i.push(function(e) {
  3159. s._postMessage(e, n)
  3160. }),
  3161. this._callJSLib.apply(this, i);
  3162. break;
  3163. case "ugapi":
  3164. this._handleUGARequest(e);
  3165. break;
  3166. case "datachange":
  3167. this._postMessage(i, null, "datachange");
  3168. break;
  3169. default:
  3170. this.publish(t, i)
  3171. } else this.IS_SLAVE && ("function" == typeof a ? (delete this._callbacks[n], a(i)) : "datachange" === t || "jslib" !== t && this.publish(t, i));
  3172. return ! 1
  3173. },
  3174. y.prototype._handleUGARequest = function(e) {
  3175. var t, n, i, a = this,
  3176. s = new f(e.data);
  3177. if (s) switch (t = s.data[0], n = s.callbackId, i = s.data[1] ? s.data[1] : null, t) {
  3178. case "GameAPI.data":
  3179. a._postMessage(this.dataStore._getCache(), n, "ugapi");
  3180. break;
  3181. case "GameAPI.isReady":
  3182. a._postMessage({
  3183. isready:
  3184. this.api.isReady
  3185. },
  3186. n, "ugapi")
  3187. }
  3188. },
  3189. y.prototype.post = function() {
  3190. var e = _.argsToArray(arguments);
  3191. return this.IS_SLAVE ? this._postMessage(e) : this._callJSLib.apply(this, e),
  3192. this
  3193. },
  3194. y.prototype.publish = function(e, t) {
  3195. return this._channels[e] && this._channels[e].forEach(function(e) {
  3196. try {
  3197. e.fn.call(e.ctx, t)
  3198. } catch(n) {}
  3199. }),
  3200. this
  3201. },
  3202. y.prototype.subscribe = function(e, t, n) {
  3203. if ("function" != typeof t) throw Error("Callback has to be a function");
  3204. if ("string" != typeof e) throw Error("Channel name has to be a string");
  3205. return this._channels[e] || (this._channels[e] = []),
  3206. this._channels[e].push({
  3207. fn: t,
  3208. ctx: n
  3209. }),
  3210. this
  3211. },
  3212. y.prototype.unsubscribe = function(e, t) {
  3213. return this._channels[e] && "function" == typeof t && (this._channels[e] = this._channels[e].filter(function(e) {
  3214. return e.fn !== t
  3215. })),
  3216. this
  3217. },
  3218. y.prototype.subscribeOnce = function(e, t, n) {
  3219. function i(n) {
  3220. a.unsubscribe(e, i),
  3221. t.call(this, n)
  3222. }
  3223. var a = this;
  3224. return this.subscribe(e, i, n)
  3225. },
  3226. y.prototype.requestFromParent = function(e, t, n) {
  3227. if (!this.IS_SLAVE) throw "You are the parent, stop talking to yourself";
  3228. t = t || {},
  3229. this._postMessage([e, t, n], null, "ugapi")
  3230. },
  3231. v.prototype._addBasic = function(e, t) {
  3232. var n = t || {};
  3233. return n.isMaster = this.IS_MASTER,
  3234. n.isStandalone = this.IS_STANDALONE,
  3235. n.messenger = this.__.messenger,
  3236. n.data = null,
  3237. n
  3238. },
  3239. v.prototype._addEventTracking = function(e) {
  3240. var t = e || {};
  3241. return t.eventTracking = this.__.EventTracking,
  3242. t
  3243. },
  3244. v.prototype._addComponents = function(e) {
  3245. var t = e || {};
  3246. return t.components = this.__.components,
  3247. t
  3248. },
  3249. v.prototype._addInitialHeight = function(e) {
  3250. var t = e || {};
  3251. return t.initialHeight = window.outerHeight - window.innerHeight,
  3252. t
  3253. },
  3254. v.prototype._addAppToken = function(e) {
  3255. var t = e || {};
  3256. return t.appToken = this.AppToken,
  3257. t
  3258. },
  3259. v.prototype._setRole = function() {
  3260. var e = _.getRole();
  3261. this.IS_MASTER = e.IS_MASTER,
  3262. this.IS_SLAVE = e.IS_SLAVE,
  3263. this.IS_STANDALONE = e.IS_STANDALONE
  3264. },
  3265. v.prototype._getTargets = function() {
  3266. if (this.IS_STANDALONE) return [window];
  3267. if (this.IS_MASTER) {
  3268. for (var e = ["iframegame", "iframeGameState"], t = null, n = [], i = 0; e.length > i; i++) t = document.getElementById(e[i]),
  3269. t && t.contentWindow && n.push(t.contentWindow);
  3270. return n
  3271. }
  3272. return [window.parent]
  3273. },
  3274. v.prototype.loadAPI = function(e, t) {
  3275. function i(t) {
  3276. p.IS_MASTER && (t = a(t));
  3277. var n = t.portal.gamestate || !1;
  3278. return p.isReady = !0,
  3279. p.Branding.moduleReady = !0,
  3280. p.__.EventTracking.moduleReady = !0,
  3281. p.GameState.moduleReady = !0,
  3282. p.GameBreak.moduleReady = !0,
  3283. p.Game.moduleReady = !0,
  3284. p.Score.moduleReady = !0,
  3285. p.Award.moduleReady = !0,
  3286. p.User.moduleReady = !0,
  3287. p.Friends.moduleReady = !0,
  3288. p.GameEvent.moduleReady = !0,
  3289. p.Localization.moduleReady = !0,
  3290. p.AppToken.moduleReady = !0,
  3291. (n || p.IS_MASTER) && p.AppToken.init({
  3292. data: t
  3293. }),
  3294. p.__.EventTracking.init({
  3295. data: t
  3296. }),
  3297. n && p.GameState.init({
  3298. data: t
  3299. }),
  3300. n || (p.Branding.init({
  3301. data: t
  3302. }), p.Game.init({
  3303. data: t
  3304. }), p.GameBreak.init({
  3305. data: t
  3306. }), p.Friends.init({
  3307. data: t
  3308. }), p.User.init({
  3309. data: t
  3310. }), p.Localization.init({
  3311. data: t
  3312. })),
  3313. p.__.messenger._postMessage(["log.gameapi.loadapi.finish", {
  3314. origin: u,
  3315. version: p.version
  3316. },
  3317. null], null, "log"),
  3318. e(p)
  3319. }
  3320. function a(e) {
  3321. var t = e.game || {},
  3322. n = e.user || {},
  3323. i = e.portal || {},
  3324. a = e.branding || {};
  3325. return A.getLocalConfig({
  3326. game: t,
  3327. user: n,
  3328. portal: i,
  3329. branding: a
  3330. })
  3331. }
  3332. function s() {
  3333. p.__.messenger.requestFromParent("GameAPI.data", {},
  3334. function(e) {
  3335. i(e)
  3336. })
  3337. }
  3338. function r() {
  3339. p.IS_STANDALONE = !0,
  3340. p.IS_MASTER = !0,
  3341. p.IS_SLAVE = !0,
  3342. p.__.dataStore = new n({
  3343. isMaster: !0
  3344. }),
  3345. t = t || null,
  3346. A.setupStandaloneMode(t,
  3347. function(e) {
  3348. p.__.dataStore._setCache(a(e)),
  3349. i(e)
  3350. })
  3351. }
  3352. function o() {
  3353. p.__.messenger.requestFromParent("GameAPI.isReady", {},
  3354. function(e) {
  3355. l && clearTimeout(l),
  3356. e.isready ? s() : 5 > d ? (d++, setTimeout(o, 500)) : (_.log("GameAPI:checkMasterReady not ready but reached max wait"), s())
  3357. })
  3358. }
  3359. var l, p = this,
  3360. u = this.IS_MASTER ? "master": "slave",
  3361. d = 0;
  3362. if (t !== void 0 && t.id !== void 0 && "576742227280293562" === t.id && (window.onkeydown = null), "function" != typeof e) throw Error("argument passed to loadAPI method should be a function");
  3363. return ! 0 === this.isReady ? (_.log("WARNING: Detected multiple executions of GameAPI.loadAPI(). This method should only be executed once per page load!"), e(p)) : (this.__.messenger._postMessage(["log.gameapi.loadapi.start", {
  3364. origin: u,
  3365. version: p.version,
  3366. spildata: t
  3367. },
  3368. null], null, "log"), this.IS_STANDALONE ? r() : this.IS_MASTER ? A.getGameConfig().then(function(e) {
  3369. A.getBrandingConfig(e).then(function(t) {
  3370. e && !e.isError ? (e.branding = t.branding, p.__.dataStore._setCache(a(e))) : _.log("GameAPI gameConfig error: ", e.isError),
  3371. i(e)
  3372. })
  3373. }) : t && t.gamestate ? i(A.configFromData(t)) : (l = setTimeout(r, 600), o()), void 0)
  3374. };
  3375. var T = new v(n, y, g, h, d);
  3376. "function" == typeof define && define.amd && define("GameAPI", T),
  3377. e.GameAPI = T
  3378. })(window),
  3379. function() {
  3380. "use strict";
  3381. function e(e) {
  3382. e && (e.setTargetValueAtTime || (e.setTargetValueAtTime = e.setTargetAtTime))
  3383. }
  3384. window.hasOwnProperty("AudioContext") && (window.webkitAudioContext = AudioContext, AudioContext.prototype.hasOwnProperty("internal_createGain") || (AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain, AudioContext.prototype.createGain = function() {
  3385. var t = this.internal_createGain();
  3386. return e(t.gain),
  3387. t
  3388. }), AudioContext.prototype.hasOwnProperty("internal_createDelay") || (AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay, AudioContext.prototype.createDelay = function() {
  3389. var t = this.internal_createDelay();
  3390. return e(t.delayTime),
  3391. t
  3392. }), AudioContext.prototype.hasOwnProperty("internal_createBufferSource") || (AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource, AudioContext.prototype.createBufferSource = function() {
  3393. var t = this.internal_createBufferSource();
  3394. return t.noteOn || (t.noteOn = t.start),
  3395. t.noteGrainOn || (t.noteGrainOn = t.start),
  3396. t.noteOff || (t.noteOff = t.stop),
  3397. e(t.playbackRate),
  3398. t
  3399. }), AudioContext.prototype.hasOwnProperty("internal_createDynamicsCompressor") || (AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor, AudioContext.prototype.createDynamicsCompressor = function() {
  3400. var t = this.internal_createDynamicsCompressor();
  3401. return e(t.threshold),
  3402. e(t.knee),
  3403. e(t.ratio),
  3404. e(t.reduction),
  3405. e(t.attack),
  3406. e(t.release),
  3407. t
  3408. }), AudioContext.prototype.hasOwnProperty("internal_createBiquadFilter") || (AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter, AudioContext.prototype.createBiquadFilter = function() {
  3409. var t = this.internal_createBiquadFilter();
  3410. e(t.frequency),
  3411. e(t.detune),
  3412. e(t.Q),
  3413. e(t.gain);
  3414. for (var n = ["LOWPASS", "HIGHPASS", "BANDPASS", "LOWSHELF", "HIGHSHELF", "PEAKING", "NOTCH", "ALLPASS"], i = 0; n.length > i; ++i) {
  3415. var a = n[i],
  3416. s = a.toLowerCase();
  3417. t.hasOwnProperty(a) || (t[a] = s)
  3418. }
  3419. return t
  3420. }), AudioContext.prototype.hasOwnProperty("internal_createOscillator") || AudioContext.prototype.hasOwnProperty("createOscillator") && (AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator, AudioContext.prototype.createOscillator = function() {
  3421. var t = this.internal_createOscillator();
  3422. t.noteOn || (t.noteOn = t.start),
  3423. t.noteOff || (t.noteOff = t.stop),
  3424. e(t.frequency),
  3425. e(t.detune);
  3426. for (var n = ["SINE", "SQUARE", "SAWTOOTH", "TRIANGLE", "CUSTOM"], i = 0; n.length > i; ++i) {
  3427. var a = n[i],
  3428. s = a.toLowerCase();
  3429. t.hasOwnProperty(a) || (t[a] = s)
  3430. }
  3431. return t.hasOwnProperty("setWaveTable") || (t.setWaveTable = t.setPeriodicTable),
  3432. t
  3433. }), AudioContext.prototype.hasOwnProperty("internal_createPanner") || (AudioContext.prototype.internal_createPanner = AudioContext.prototype.createPanner, AudioContext.prototype.createPanner = function() {
  3434. var e = this.internal_createPanner(),
  3435. t = {
  3436. EQUALPOWER: "equalpower",
  3437. HRTF: "HRTF",
  3438. LINEAR_DISTANCE: "linear",
  3439. INVERSE_DISTANCE: "inverse",
  3440. EXPONENTIAL_DISTANCE: "exponential"
  3441. };
  3442. for (var n in t) {
  3443. var i = t[n];
  3444. e.hasOwnProperty(n) || (e[n] = i)
  3445. }
  3446. return e
  3447. }), AudioContext.prototype.hasOwnProperty("createGainNode") || (AudioContext.prototype.createGainNode = AudioContext.prototype.createGain), AudioContext.prototype.hasOwnProperty("createDelayNode") || (AudioContext.prototype.createDelayNode = AudioContext.prototype.createDelay), AudioContext.prototype.hasOwnProperty("createJavaScriptNode") || (AudioContext.prototype.createJavaScriptNode = AudioContext.prototype.createScriptProcessor), AudioContext.prototype.hasOwnProperty("createWaveTable") || (AudioContext.prototype.createWaveTable = AudioContext.prototype.createPeriodicWave))
  3448. } ();