game.js 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137
  1. /*! game-api - v0.13.7 - 2014-10-06 */
  2. (function(t) {
  3. "use strict";
  4. function e() {}
  5. function n(t) {
  6. if (t = t || {},
  7. this.IS_MASTER = t.isMaster || !1, !this.IS_MASTER) throw Error("The DataStore can only be instantiated by the Master");
  8. this.dataStore = {}
  9. }
  10. function r(t, e) {
  11. if (this.IS_MASTER = t && t.isMaster ? t.isMaster: !1, this.IS_SLAVE = !this.IS_MASTER, this.messenger = null, this.subscribers = {},
  12. this.moduleReady = e ? e: !1, this.gameState = "resume", !t || !t.messenger) throw Error("No messenger passed to the Game module instance");
  13. this.messenger = t.messenger,
  14. window.addEventListener ? window.addEventListener("message", this._performAction.bind(this), !1) : window.attachEvent && window.attachEvent("onmessage", this._performAction.bind(this))
  15. }
  16. function i(t, e) {
  17. t = t || {},
  18. this.IS_MASTER = t.isMaster,
  19. this.IS_SLAVE = !this.IS_MASTER,
  20. this.moduleReady = e ? e: !1,
  21. this.messenger = t.messenger,
  22. this.data = t.data || null,
  23. this._setupMasterEvent()
  24. }
  25. function o(t, e) {
  26. t = t || {},
  27. this.isMaster = t.isMaster,
  28. this.isStandalone = t.isStandalone,
  29. this.messenger = t.messenger,
  30. this.moduleReady = e ? e: !1,
  31. this.timeoutAfter = 500,
  32. this.timeout = !1,
  33. this._callbacks = {
  34. pause: !1,
  35. resume: !1
  36. }
  37. }
  38. function a(t, e) {
  39. t = t || {},
  40. this.IS_MASTER = t.isMaster,
  41. this.isStandalone = t.isStandalone,
  42. this.messenger = t.messenger,
  43. this.eventTracking = t.eventTracking,
  44. this.moduleReady = e ? e: !1,
  45. this.events = {
  46. GAME_START: "GAME_START",
  47. GAME_END: "GAME_END",
  48. GAME_PAUSE: "GAME_PAUSE",
  49. GAME_CONTINUE: "GAME_CONTINUE",
  50. GAME_MUTE: "GAME_MUTE",
  51. LEVEL_FAIL: "LEVEL_FAIL",
  52. LEVEL_COMPLETE: "LEVEL_COMPLETE"
  53. },
  54. this._setupEvents()
  55. }
  56. function s(t, e) {
  57. t = t || {},
  58. this.IS_MASTER = t.isMaster,
  59. this.IS_SLAVE = !this.IS_MASTER,
  60. this.data = t.data,
  61. this.messenger = t.messenger,
  62. this.moduleReady = e ? e: !1,
  63. this.gamePlayTracking = {
  64. started: !1,
  65. appid: null,
  66. host: null,
  67. timestamp: null
  68. },
  69. this.timeInGameTracking = {
  70. started: !1,
  71. appid: null,
  72. timestamp: null
  73. }
  74. }
  75. function u(t, e) {
  76. t = t || {},
  77. this.IS_MASTER = t.isMaster,
  78. this.IS_SLAVE = !this.IS_MASTER,
  79. this.moduleReady = e ? e: !1,
  80. this.messenger = t.messenger,
  81. this.components = t.components,
  82. this.data = t.data || null
  83. }
  84. function c(t) {
  85. var e = "string" == typeof t ? p(t) : t;
  86. e && (this.type = e.type, this.callbackId = e.callbackId, this.data = e.data)
  87. }
  88. function p(t) {
  89. var e, n, r, i = !1,
  90. o = [];
  91. if ("string" == typeof t && (o = t.split("|"), "gameapi" === o[0])) {
  92. o.shift(),
  93. e = o.shift(),
  94. r = parseInt(o.shift(), 10),
  95. n = o.join("|");
  96. try {
  97. i = {
  98. type: e,
  99. callbackId: r,
  100. data: "" !== n ? JSON.parse(n) : ""
  101. }
  102. } catch(a) {}
  103. }
  104. return i
  105. }
  106. function l(t) {
  107. t = t || {},
  108. this.IS_MASTER = "boolean" == typeof t.isMaster ? t.isMaster: !1,
  109. this.IS_SLAVE = !this.IS_MASTER,
  110. this.api = t.api ? t.api: {},
  111. this._target = t.target ? t.target: {},
  112. this._callbacks = [],
  113. this._channels = [],
  114. this.IS_MASTER && t.dataStore && (this.dataStore = t.dataStore),
  115. this._setupEventListener()
  116. }
  117. function d(t, n, o, s, u) {
  118. this.version = "0.13.7",
  119. this.isReady = !1,
  120. this._setRole(),
  121. this.__ = {},
  122. this.__.dataStore = this.IS_MASTER ? new t({
  123. isMaster: !0
  124. }) : null,
  125. this.__.messenger = new n({
  126. isMaster: this.IS_MASTER,
  127. api: this,
  128. target: this._getTarget(),
  129. dataStore: this.__.dataStore
  130. }),
  131. this.__.components = new e,
  132. this.Branding = new o({
  133. isMaster: this.IS_MASTER,
  134. messenger: this.__.messenger,
  135. components: this.__.components
  136. },
  137. !1),
  138. this.__.EventTracking = new s({
  139. isMaster: this.IS_MASTER,
  140. data: null,
  141. messenger: this.__.messenger
  142. },
  143. !1),
  144. this.GameBreak = new u({
  145. isMaster: this.IS_MASTER,
  146. isStandalone: this.IS_STANDALONE,
  147. messenger: this.__.messenger
  148. },
  149. !1),
  150. this.Game = new r({
  151. isMaster: this.IS_MASTER,
  152. messenger: this.__.messenger
  153. },
  154. !1),
  155. this.Score = new i({
  156. isMaster: this.IS_MASTER,
  157. messenger: this.__.messenger
  158. },
  159. !1),
  160. this.GameEvent = new a({
  161. isMaster: this.IS_MASTER,
  162. messenger: this.__.messenger,
  163. eventTracking: this.__.EventTracking
  164. },
  165. !1)
  166. }
  167. var h; (function(t) {
  168. if ("function" == typeof bootstrap) bootstrap("promise", t);
  169. else if ("object" == typeof exports) module.exports = t();
  170. else if ("function" == typeof define && define.amd) define(t);
  171. else if ("undefined" != typeof ses) {
  172. if (!ses.ok()) return;
  173. ses.makeQ = t
  174. } else h = t()
  175. })(function() {
  176. function t(t) {
  177. return function() {
  178. return X.apply(t, arguments)
  179. }
  180. }
  181. function e(t) {
  182. return t === Object(t)
  183. }
  184. function n(t) {
  185. return "[object StopIteration]" === ee(t) || t instanceof W
  186. }
  187. function r(t, e) {
  188. if (q && e.stack && "object" == typeof t && null !== t && t.stack && -1 === t.stack.indexOf(ne)) {
  189. for (var n = [], r = e; r; r = r.source) r.stack && n.unshift(r.stack);
  190. n.unshift(t.stack);
  191. var o = n.join("\n" + ne + "\n");
  192. t.stack = i(o)
  193. }
  194. }
  195. function i(t) {
  196. for (var e = t.split("\n"), n = [], r = 0; e.length > r; ++r) {
  197. var i = e[r];
  198. s(i) || o(i) || !i || n.push(i)
  199. }
  200. return n.join("\n")
  201. }
  202. function o(t) {
  203. return - 1 !== t.indexOf("(module.js:") || -1 !== t.indexOf("(node.js:")
  204. }
  205. function a(t) {
  206. var e = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);
  207. if (e) return [e[1], Number(e[2])];
  208. var n = /at ([^ ]+):(\d+):(?:\d+)$/.exec(t);
  209. if (n) return [n[1], Number(n[2])];
  210. var r = /.*@(.+):(\d+)$/.exec(t);
  211. return r ? [r[1], Number(r[2])] : void 0
  212. }
  213. function s(t) {
  214. var e = a(t);
  215. if (!e) return ! 1;
  216. var n = e[0],
  217. r = e[1];
  218. return n === F && r >= J && ae >= r
  219. }
  220. function u() {
  221. if (q) try {
  222. throw Error()
  223. } catch(t) {
  224. var e = t.stack.split("\n"),
  225. n = e[0].indexOf("@") > 0 ? e[1] : e[2],
  226. r = a(n);
  227. if (!r) return;
  228. return F = r[0],
  229. r[1]
  230. }
  231. }
  232. function c(t, e, n) {
  233. return function() {
  234. return "undefined" != typeof console && "function" == typeof console.warn && console.warn(e + " is deprecated, use " + n + " instead.", Error("").stack),
  235. t.apply(t, arguments)
  236. }
  237. }
  238. function p(t) {
  239. return y(t) ? t: v(t) ? I(t) : k(t)
  240. }
  241. function l() {
  242. function t(t) {
  243. e = t,
  244. o.source = t,
  245. Q(n,
  246. function(e, n) {
  247. H(function() {
  248. t.promiseDispatch.apply(t, n)
  249. })
  250. },
  251. void 0),
  252. n = void 0,
  253. r = void 0
  254. }
  255. var e, n = [],
  256. r = [],
  257. i = Y(l.prototype),
  258. o = Y(f.prototype);
  259. if (o.promiseDispatch = function(t, i, o) {
  260. var a = K(arguments);
  261. n ? (n.push(a), "when" === i && o[1] && r.push(o[1])) : H(function() {
  262. e.promiseDispatch.apply(e, a)
  263. })
  264. },
  265. o.valueOf = function() {
  266. if (n) return o;
  267. var t = m(e);
  268. return y(t) && (e = t),
  269. t
  270. },
  271. o.inspect = function() {
  272. return e ? e.inspect() : {
  273. state: "pending"
  274. }
  275. },
  276. p.longStackSupport && q) try {
  277. throw Error()
  278. } catch(a) {
  279. o.stack = a.stack.substring(a.stack.indexOf("\n") + 1)
  280. }
  281. return i.promise = o,
  282. i.resolve = function(n) {
  283. e || t(p(n))
  284. },
  285. i.fulfill = function(n) {
  286. e || t(k(n))
  287. },
  288. i.reject = function(n) {
  289. e || t(T(n))
  290. },
  291. i.notify = function(t) {
  292. e || Q(r,
  293. function(e, n) {
  294. H(function() {
  295. n(t)
  296. })
  297. },
  298. void 0)
  299. },
  300. i
  301. }
  302. function d(t) {
  303. if ("function" != typeof t) throw new TypeError("resolver must be a function.");
  304. var e = l();
  305. try {
  306. t(e.resolve, e.reject, e.notify)
  307. } catch(n) {
  308. e.reject(n)
  309. }
  310. return e.promise
  311. }
  312. function h(t) {
  313. return d(function(e, n) {
  314. for (var r = 0,
  315. i = t.length; i > r; r++) p(t[r]).then(e, n)
  316. })
  317. }
  318. function f(t, e, n) {
  319. void 0 === e && (e = function(t) {
  320. return T(Error("Promise does not support operation: " + t))
  321. }),
  322. void 0 === n && (n = function() {
  323. return {
  324. state: "unknown"
  325. }
  326. });
  327. var r = Y(f.prototype);
  328. if (r.promiseDispatch = function(n, i, o) {
  329. var a;
  330. try {
  331. a = t[i] ? t[i].apply(r, o) : e.call(r, i, o)
  332. } catch(s) {
  333. a = T(s)
  334. }
  335. n && n(a)
  336. },
  337. r.inspect = n, n) {
  338. var i = n();
  339. "rejected" === i.state && (r.exception = i.reason),
  340. r.valueOf = function() {
  341. var t = n();
  342. return "pending" === t.state || "rejected" === t.state ? r: t.value
  343. }
  344. }
  345. return r
  346. }
  347. function g(t, e, n, r) {
  348. return p(t).then(e, n, r)
  349. }
  350. function m(t) {
  351. if (y(t)) {
  352. var e = t.inspect();
  353. if ("fulfilled" === e.state) return e.value
  354. }
  355. return t
  356. }
  357. function y(t) {
  358. return e(t) && "function" == typeof t.promiseDispatch && "function" == typeof t.inspect
  359. }
  360. function v(t) {
  361. return e(t) && "function" == typeof t.then
  362. }
  363. function _(t) {
  364. return y(t) && "pending" === t.inspect().state
  365. }
  366. function S(t) {
  367. return ! y(t) || "fulfilled" === t.inspect().state
  368. }
  369. function w(t) {
  370. return y(t) && "rejected" === t.inspect().state
  371. }
  372. function b() {
  373. re.length = 0,
  374. ie.length = 0,
  375. oe || (oe = !0)
  376. }
  377. function A(t, e) {
  378. oe && (ie.push(t), e && e.stack !== void 0 ? re.push(e.stack) : re.push("(no stack) " + e))
  379. }
  380. function E(t) {
  381. if (oe) {
  382. var e = $(ie, t); - 1 !== e && (ie.splice(e, 1), re.splice(e, 1))
  383. }
  384. }
  385. function T(t) {
  386. var e = f({
  387. when: function(e) {
  388. return e && E(this),
  389. e ? e(t) : this
  390. }
  391. },
  392. function() {
  393. return this
  394. },
  395. function() {
  396. return {
  397. state: "rejected",
  398. reason: t
  399. }
  400. });
  401. return A(e, t),
  402. e
  403. }
  404. function k(t) {
  405. return f({
  406. when: function() {
  407. return t
  408. },
  409. get: function(e) {
  410. return t[e]
  411. },
  412. set: function(e, n) {
  413. t[e] = n
  414. },
  415. "delete": function(e) {
  416. delete t[e]
  417. },
  418. post: function(e, n) {
  419. return null === e || void 0 === e ? t.apply(void 0, n) : t[e].apply(t, n)
  420. },
  421. apply: function(e, n) {
  422. return t.apply(e, n)
  423. },
  424. keys: function() {
  425. return te(t)
  426. }
  427. },
  428. void 0,
  429. function() {
  430. return {
  431. state: "fulfilled",
  432. value: t
  433. }
  434. })
  435. }
  436. function I(t) {
  437. var e = l();
  438. return H(function() {
  439. try {
  440. t.then(e.resolve, e.reject, e.notify)
  441. } catch(n) {
  442. e.reject(n)
  443. }
  444. }),
  445. e.promise
  446. }
  447. function M(t) {
  448. return f({
  449. isDef: function() {}
  450. },
  451. function(e, n) {
  452. return L(t, e, n)
  453. },
  454. function() {
  455. return p(t).inspect()
  456. })
  457. }
  458. function R(t, e, n) {
  459. return p(t).spread(e, n)
  460. }
  461. function C(t) {
  462. return function() {
  463. function e(t, e) {
  464. var a;
  465. if ("undefined" == typeof StopIteration) {
  466. try {
  467. a = r[t](e)
  468. } catch(s) {
  469. return T(s)
  470. }
  471. return a.done ? a.value: g(a.value, i, o)
  472. }
  473. try {
  474. a = r[t](e)
  475. } catch(s) {
  476. return n(s) ? s.value: T(s)
  477. }
  478. return g(a, i, o)
  479. }
  480. var r = t.apply(this, arguments),
  481. i = e.bind(e, "next"),
  482. o = e.bind(e, "throw");
  483. return i()
  484. }
  485. }
  486. function P(t) {
  487. p.done(p.async(t)())
  488. }
  489. function O(t) {
  490. throw new W(t)
  491. }
  492. function x(t) {
  493. return function() {
  494. return R([this, G(arguments)],
  495. function(e, n) {
  496. return t.apply(e, n)
  497. })
  498. }
  499. }
  500. function L(t, e, n) {
  501. return p(t).dispatch(e, n)
  502. }
  503. function G(t) {
  504. return g(t,
  505. function(t) {
  506. var e = 0,
  507. n = l();
  508. return Q(t,
  509. function(r, i, o) {
  510. var a;
  511. y(i) && "fulfilled" === (a = i.inspect()).state ? t[o] = a.value: (++e, g(i,
  512. function(r) {
  513. t[o] = r,
  514. 0 === --e && n.resolve(t)
  515. },
  516. n.reject,
  517. function(t) {
  518. n.notify({
  519. index: o,
  520. value: t
  521. })
  522. }))
  523. },
  524. void 0),
  525. 0 === e && n.resolve(t),
  526. n.promise
  527. })
  528. }
  529. function N(t) {
  530. return g(t,
  531. function(t) {
  532. return t = z(t, p),
  533. g(G(z(t,
  534. function(t) {
  535. return g(t, U, U)
  536. })),
  537. function() {
  538. return t
  539. })
  540. })
  541. }
  542. function j(t) {
  543. return p(t).allSettled()
  544. }
  545. function D(t, e) {
  546. return p(t).then(void 0, void 0, e)
  547. }
  548. function B(t, e) {
  549. return p(t).nodeify(e)
  550. }
  551. var q = !1;
  552. try {
  553. throw Error()
  554. } catch(V) {
  555. q = !!V.stack
  556. }
  557. var F, W, J = u(),
  558. U = function() {},
  559. H = function() {
  560. function t() {
  561. for (; e.next;) {
  562. e = e.next;
  563. var n = e.task;
  564. e.task = void 0;
  565. var i = e.domain;
  566. i && (e.domain = void 0, i.enter());
  567. try {
  568. n()
  569. } catch(a) {
  570. if (o) throw i && i.exit(),
  571. setTimeout(t, 0),
  572. i && i.enter(),
  573. a;
  574. setTimeout(function() {
  575. throw a
  576. },
  577. 0)
  578. }
  579. i && i.exit()
  580. }
  581. r = !1
  582. }
  583. var e = {
  584. task: void 0,
  585. next: null
  586. },
  587. n = e,
  588. r = !1,
  589. i = void 0,
  590. o = !1;
  591. if (H = function(t) {
  592. n = n.next = {
  593. task: t,
  594. domain: o && process.domain,
  595. next: null
  596. },
  597. r || (r = !0, i())
  598. },
  599. "undefined" != typeof process && process.nextTick) o = !0,
  600. i = function() {
  601. process.nextTick(t)
  602. };
  603. else if ("function" == typeof setImmediate) i = "undefined" != typeof window ? setImmediate.bind(window, t) : function() {
  604. setImmediate(t)
  605. };
  606. else if ("undefined" != typeof MessageChannel) {
  607. var a = new MessageChannel;
  608. a.port1.onmessage = function() {
  609. i = s,
  610. a.port1.onmessage = t,
  611. t()
  612. };
  613. var s = function() {
  614. a.port2.postMessage(0)
  615. };
  616. i = function() {
  617. setTimeout(t, 0),
  618. s()
  619. }
  620. } else i = function() {
  621. setTimeout(t, 0)
  622. };
  623. return H
  624. } (),
  625. X = Function.call,
  626. K = t(Array.prototype.slice),
  627. Q = t(Array.prototype.reduce ||
  628. function(t, e) {
  629. var n = 0,
  630. r = this.length;
  631. if (1 === arguments.length) for (;;) {
  632. if (n in this) {
  633. e = this[n++];
  634. break
  635. }
  636. if (++n >= r) throw new TypeError
  637. }
  638. for (; r > n; n++) n in this && (e = t(e, this[n], n));
  639. return e
  640. }),
  641. $ = t(Array.prototype.indexOf ||
  642. function(t) {
  643. for (var e = 0; this.length > e; e++) if (this[e] === t) return e;
  644. return - 1
  645. }),
  646. z = t(Array.prototype.map ||
  647. function(t, e) {
  648. var n = this,
  649. r = [];
  650. return Q(n,
  651. function(i, o, a) {
  652. r.push(t.call(e, o, a, n))
  653. },
  654. void 0),
  655. r
  656. }),
  657. Y = Object.create ||
  658. function(t) {
  659. function e() {}
  660. return e.prototype = t,
  661. new e
  662. },
  663. Z = t(Object.prototype.hasOwnProperty),
  664. te = Object.keys ||
  665. function(t) {
  666. var e = [];
  667. for (var n in t) Z(t, n) && e.push(n);
  668. return e
  669. },
  670. ee = t(Object.prototype.toString);
  671. W = "undefined" != typeof ReturnValue ? ReturnValue: function(t) {
  672. this.value = t
  673. };
  674. var ne = "From previous event:";
  675. p.resolve = p,
  676. p.nextTick = H,
  677. p.longStackSupport = !1,
  678. p.defer = l,
  679. l.prototype.makeNodeResolver = function() {
  680. var t = this;
  681. return function(e, n) {
  682. e ? t.reject(e) : arguments.length > 2 ? t.resolve(K(arguments, 1)) : t.resolve(n)
  683. }
  684. },
  685. p.Promise = d,
  686. p.promise = d,
  687. d.race = h,
  688. d.all = G,
  689. d.reject = T,
  690. d.resolve = p,
  691. p.passByCopy = function(t) {
  692. return t
  693. },
  694. f.prototype.passByCopy = function() {
  695. return this
  696. },
  697. p.join = function(t, e) {
  698. return p(t).join(e)
  699. },
  700. f.prototype.join = function(t) {
  701. return p([this, t]).spread(function(t, e) {
  702. if (t === e) return t;
  703. throw Error("Can't join: not the same: " + t + " " + e)
  704. })
  705. },
  706. p.race = h,
  707. f.prototype.race = function() {
  708. return this.then(p.race)
  709. },
  710. p.makePromise = f,
  711. f.prototype.toString = function() {
  712. return "[object Promise]"
  713. },
  714. f.prototype.then = function(t, e, n) {
  715. function i(e) {
  716. try {
  717. return "function" == typeof t ? t(e) : e
  718. } catch(n) {
  719. return T(n)
  720. }
  721. }
  722. function o(t) {
  723. if ("function" == typeof e) {
  724. r(t, s);
  725. try {
  726. return e(t)
  727. } catch(n) {
  728. return T(n)
  729. }
  730. }
  731. return T(t)
  732. }
  733. function a(t) {
  734. return "function" == typeof n ? n(t) : t
  735. }
  736. var s = this,
  737. u = l(),
  738. c = !1;
  739. return H(function() {
  740. s.promiseDispatch(function(t) {
  741. c || (c = !0, u.resolve(i(t)))
  742. },
  743. "when", [function(t) {
  744. c || (c = !0, u.resolve(o(t)))
  745. }])
  746. }),
  747. s.promiseDispatch(void 0, "when", [void 0,
  748. function(t) {
  749. var e, n = !1;
  750. try {
  751. e = a(t)
  752. } catch(r) {
  753. if (n = !0, !p.onerror) throw r;
  754. p.onerror(r)
  755. }
  756. n || u.notify(e)
  757. }]),
  758. u.promise
  759. },
  760. p.when = g,
  761. f.prototype.thenResolve = function(t) {
  762. return this.then(function() {
  763. return t
  764. })
  765. },
  766. p.thenResolve = function(t, e) {
  767. return p(t).thenResolve(e)
  768. },
  769. f.prototype.thenReject = function(t) {
  770. return this.then(function() {
  771. throw t
  772. })
  773. },
  774. p.thenReject = function(t, e) {
  775. return p(t).thenReject(e)
  776. },
  777. p.nearer = m,
  778. p.isPromise = y,
  779. p.isPromiseAlike = v,
  780. p.isPending = _,
  781. f.prototype.isPending = function() {
  782. return "pending" === this.inspect().state
  783. },
  784. p.isFulfilled = S,
  785. f.prototype.isFulfilled = function() {
  786. return "fulfilled" === this.inspect().state
  787. },
  788. p.isRejected = w,
  789. f.prototype.isRejected = function() {
  790. return "rejected" === this.inspect().state
  791. };
  792. var re = [],
  793. ie = [],
  794. oe = !0;
  795. p.resetUnhandledRejections = b,
  796. p.getUnhandledReasons = function() {
  797. return re.slice()
  798. },
  799. p.stopUnhandledRejectionTracking = function() {
  800. b(),
  801. oe = !1
  802. },
  803. b(),
  804. p.reject = T,
  805. p.fulfill = k,
  806. p.master = M,
  807. p.spread = R,
  808. f.prototype.spread = function(t, e) {
  809. return this.all().then(function(e) {
  810. return t.apply(void 0, e)
  811. },
  812. e)
  813. },
  814. p.async = C,
  815. p.spawn = P,
  816. p["return"] = O,
  817. p.promised = x,
  818. p.dispatch = L,
  819. f.prototype.dispatch = function(t, e) {
  820. var n = this,
  821. r = l();
  822. return H(function() {
  823. n.promiseDispatch(r.resolve, t, e)
  824. }),
  825. r.promise
  826. },
  827. p.get = function(t, e) {
  828. return p(t).dispatch("get", [e])
  829. },
  830. f.prototype.get = function(t) {
  831. return this.dispatch("get", [t])
  832. },
  833. p.set = function(t, e, n) {
  834. return p(t).dispatch("set", [e, n])
  835. },
  836. f.prototype.set = function(t, e) {
  837. return this.dispatch("set", [t, e])
  838. },
  839. p.del = p["delete"] = function(t, e) {
  840. return p(t).dispatch("delete", [e])
  841. },
  842. f.prototype.del = f.prototype["delete"] = function(t) {
  843. return this.dispatch("delete", [t])
  844. },
  845. p.mapply = p.post = function(t, e, n) {
  846. return p(t).dispatch("post", [e, n])
  847. },
  848. f.prototype.mapply = f.prototype.post = function(t, e) {
  849. return this.dispatch("post", [t, e])
  850. },
  851. p.send = p.mcall = p.invoke = function(t, e) {
  852. return p(t).dispatch("post", [e, K(arguments, 2)])
  853. },
  854. f.prototype.send = f.prototype.mcall = f.prototype.invoke = function(t) {
  855. return this.dispatch("post", [t, K(arguments, 1)])
  856. },
  857. p.fapply = function(t, e) {
  858. return p(t).dispatch("apply", [void 0, e])
  859. },
  860. f.prototype.fapply = function(t) {
  861. return this.dispatch("apply", [void 0, t])
  862. },
  863. p["try"] = p.fcall = function(t) {
  864. return p(t).dispatch("apply", [void 0, K(arguments, 1)])
  865. },
  866. f.prototype.fcall = function() {
  867. return this.dispatch("apply", [void 0, K(arguments)])
  868. },
  869. p.fbind = function(t) {
  870. var e = p(t),
  871. n = K(arguments, 1);
  872. return function() {
  873. return e.dispatch("apply", [this, n.concat(K(arguments))])
  874. }
  875. },
  876. f.prototype.fbind = function() {
  877. var t = this,
  878. e = K(arguments);
  879. return function() {
  880. return t.dispatch("apply", [this, e.concat(K(arguments))])
  881. }
  882. },
  883. p.keys = function(t) {
  884. return p(t).dispatch("keys", [])
  885. },
  886. f.prototype.keys = function() {
  887. return this.dispatch("keys", [])
  888. },
  889. p.all = G,
  890. f.prototype.all = function() {
  891. return G(this)
  892. },
  893. p.allResolved = c(N, "allResolved", "allSettled"),
  894. f.prototype.allResolved = function() {
  895. return N(this)
  896. },
  897. p.allSettled = j,
  898. f.prototype.allSettled = function() {
  899. return this.then(function(t) {
  900. return G(z(t,
  901. function(t) {
  902. function e() {
  903. return t.inspect()
  904. }
  905. return t = p(t),
  906. t.then(e, e)
  907. }))
  908. })
  909. },
  910. p.fail = p["catch"] = function(t, e) {
  911. return p(t).then(void 0, e)
  912. },
  913. f.prototype.fail = f.prototype["catch"] = function(t) {
  914. return this.then(void 0, t)
  915. },
  916. p.progress = D,
  917. f.prototype.progress = function(t) {
  918. return this.then(void 0, void 0, t)
  919. },
  920. p.fin = p["finally"] = function(t, e) {
  921. return p(t)["finally"](e)
  922. },
  923. f.prototype.fin = f.prototype["finally"] = function(t) {
  924. return t = p(t),
  925. this.then(function(e) {
  926. return t.fcall().then(function() {
  927. return e
  928. })
  929. },
  930. function(e) {
  931. return t.fcall().then(function() {
  932. throw e
  933. })
  934. })
  935. },
  936. p.done = function(t, e, n, r) {
  937. return p(t).done(e, n, r)
  938. },
  939. f.prototype.done = function(t, e, n) {
  940. var i = function(t) {
  941. H(function() {
  942. if (r(t, o), !p.onerror) throw t;
  943. p.onerror(t)
  944. })
  945. },
  946. o = t || e || n ? this.then(t, e, n) : this;
  947. "object" == typeof process && process && process.domain && (i = process.domain.bind(i)),
  948. o.then(void 0, i)
  949. },
  950. p.timeout = function(t, e, n) {
  951. return p(t).timeout(e, n)
  952. },
  953. f.prototype.timeout = function(t, e) {
  954. var n = l(),
  955. r = setTimeout(function() {
  956. n.reject(Error(e || "Timed out after " + t + " ms"))
  957. },
  958. t);
  959. return this.then(function(t) {
  960. clearTimeout(r),
  961. n.resolve(t)
  962. },
  963. function(t) {
  964. clearTimeout(r),
  965. n.reject(t)
  966. },
  967. n.notify),
  968. n.promise
  969. },
  970. p.delay = function(t, e) {
  971. return void 0 === e && (e = t, t = void 0),
  972. p(t).delay(e)
  973. },
  974. f.prototype.delay = function(t) {
  975. return this.then(function(e) {
  976. var n = l();
  977. return setTimeout(function() {
  978. n.resolve(e)
  979. },
  980. t),
  981. n.promise
  982. })
  983. },
  984. p.nfapply = function(t, e) {
  985. return p(t).nfapply(e)
  986. },
  987. f.prototype.nfapply = function(t) {
  988. var e = l(),
  989. n = K(t);
  990. return n.push(e.makeNodeResolver()),
  991. this.fapply(n).fail(e.reject),
  992. e.promise
  993. },
  994. p.nfcall = function(t) {
  995. var e = K(arguments, 1);
  996. return p(t).nfapply(e)
  997. },
  998. f.prototype.nfcall = function() {
  999. var t = K(arguments),
  1000. e = l();
  1001. return t.push(e.makeNodeResolver()),
  1002. this.fapply(t).fail(e.reject),
  1003. e.promise
  1004. },
  1005. p.nfbind = p.denodeify = function(t) {
  1006. var e = K(arguments, 1);
  1007. return function() {
  1008. var n = e.concat(K(arguments)),
  1009. r = l();
  1010. return n.push(r.makeNodeResolver()),
  1011. p(t).fapply(n).fail(r.reject),
  1012. r.promise
  1013. }
  1014. },
  1015. f.prototype.nfbind = f.prototype.denodeify = function() {
  1016. var t = K(arguments);
  1017. return t.unshift(this),
  1018. p.denodeify.apply(void 0, t)
  1019. },
  1020. p.nbind = function(t, e) {
  1021. var n = K(arguments, 2);
  1022. return function() {
  1023. function r() {
  1024. return t.apply(e, arguments)
  1025. }
  1026. var i = n.concat(K(arguments)),
  1027. o = l();
  1028. return i.push(o.makeNodeResolver()),
  1029. p(r).fapply(i).fail(o.reject),
  1030. o.promise
  1031. }
  1032. },
  1033. f.prototype.nbind = function() {
  1034. var t = K(arguments, 0);
  1035. return t.unshift(this),
  1036. p.nbind.apply(void 0, t)
  1037. },
  1038. p.nmapply = p.npost = function(t, e, n) {
  1039. return p(t).npost(e, n)
  1040. },
  1041. f.prototype.nmapply = f.prototype.npost = function(t, e) {
  1042. var n = K(e || []),
  1043. r = l();
  1044. return n.push(r.makeNodeResolver()),
  1045. this.dispatch("post", [t, n]).fail(r.reject),
  1046. r.promise
  1047. },
  1048. p.nsend = p.nmcall = p.ninvoke = function(t, e) {
  1049. var n = K(arguments, 2),
  1050. r = l();
  1051. return n.push(r.makeNodeResolver()),
  1052. p(t).dispatch("post", [e, n]).fail(r.reject),
  1053. r.promise
  1054. },
  1055. f.prototype.nsend = f.prototype.nmcall = f.prototype.ninvoke = function(t) {
  1056. var e = K(arguments, 1),
  1057. n = l();
  1058. return e.push(n.makeNodeResolver()),
  1059. this.dispatch("post", [t, e]).fail(n.reject),
  1060. n.promise
  1061. },
  1062. p.nodeify = B,
  1063. f.prototype.nodeify = function(t) {
  1064. return t ? (this.then(function(e) {
  1065. H(function() {
  1066. t(null, e)
  1067. })
  1068. },
  1069. function(e) {
  1070. H(function() {
  1071. t(e)
  1072. })
  1073. }), void 0) : this
  1074. };
  1075. var ae = u();
  1076. return p
  1077. }),
  1078. function(t) {
  1079. var e = "Promise" in t && "cast" in t.Promise && "resolve" in t.Promise && "reject" in t.Promise && "all" in t.Promise && "race" in t.Promise && "spread" in t.Promise;
  1080. e || (t.Promise = h.promise, t.Promise.all = h.all, t.Promise.timeout = h.timeout, h.stopUnhandledRejectionTracking())
  1081. } (t !== void 0 ? t: this);
  1082. var f = {
  1083. timeout: 3e3
  1084. };
  1085. f.getGameConfig = function() {
  1086. var t = h.defer();
  1087. return SpilGames(["JSLib"],
  1088. function(e) {
  1089. var n = e.get("current.game.integration.info");
  1090. n ? t.resolve(n) : t.reject(Error("No data retrieved from JSLib"))
  1091. }),
  1092. t.promise.timeout(this.timeout)
  1093. },
  1094. f.getBrandingConfig = function(t) {
  1095. var e = h.defer(),
  1096. n = "#",
  1097. r = t.portal.siteId,
  1098. i = t.portal.channelId,
  1099. o = t.portal.applicationId;
  1100. return SpilGames(["Net", "JSLib"],
  1101. function(t, a) {
  1102. t.send({
  1103. url: [n, i, r, o].join("/"),
  1104. type: "GET",
  1105. dataType: "JSON"
  1106. },
  1107. function(t) {
  1108. if (t && t.configar) window.postMessage(new c({
  1109. type: "success",
  1110. callbackId: null,
  1111. data: "log.configar.getBranding.success"
  1112. }), "*"),
  1113. e.resolve(t.configar);
  1114. else {
  1115. var n = {};
  1116. try {
  1117. n = a.get("configar.data.cached") || n
  1118. } catch(r) {}
  1119. e.reject(n)
  1120. }
  1121. })
  1122. }),
  1123. e.promise.timeout(this.timeout)
  1124. };
  1125. var g = {};
  1126. g.argsToArray = function(t) {
  1127. return t ? Array.prototype.slice.apply(t) : []
  1128. },
  1129. g.isA10 = function() {
  1130. return /#/.test(window.location.host)
  1131. },
  1132. g.disableKeys = function(t) {
  1133. var e = t.keyCode; (8 === e || 9 === e || e >= 32 && 40 >= e || 46 === e) && t.preventDefault()
  1134. },
  1135. g.trackGA = function() {
  1136. try {
  1137. var t = function(t, e, n, r, i, o, a) {
  1138. t.GoogleAnalyticsObject = i,
  1139. t[i] = t[i] ||
  1140. function() { (t[i].q = t[i].q || []).push(arguments)
  1141. },
  1142. t[i].l = 1 * new Date,
  1143. o = e.createElement(n),
  1144. a = e.getElementsByTagName(n)[0],
  1145. o.async = 1,
  1146. o.src = r,
  1147. a.parentNode.insertBefore(o, a);
  1148. t(window, document, "script", "#", "ga"),
  1149. ga("create", "UA-8223336-3", "auto"),
  1150. ga("send", "pageview")
  1151. }
  1152. } catch(e) {}
  1153. },
  1154. g.getRole = function() {
  1155. var t = "function" == typeof window.SpilGames,
  1156. e = window.self !== window.top,
  1157. n = null;
  1158. if (g.isA10()) return window.onkeydown = this.disableKeys,
  1159. {
  1160. IS_MASTER: !0,
  1161. IS_SLAVE: !0,
  1162. IS_STANDALONE: !0
  1163. };
  1164. if (t) {
  1165. var r = document.getElementById("#iframegame");
  1166. switch (r) {
  1167. case "null":
  1168. n = {
  1169. IS_MASTER: !0,
  1170. IS_SLAVE: !0,
  1171. IS_STANDALONE: !1
  1172. };
  1173. break;
  1174. default:
  1175. n = {
  1176. IS_MASTER: !0,
  1177. IS_SLAVE: !1,
  1178. IS_STANDALONE: !1
  1179. }
  1180. }
  1181. } else e ? (window.onkeydown = this.disableKeys, this.trackGA(), n = {
  1182. IS_MASTER: !1,
  1183. IS_SLAVE: !0,
  1184. IS_STANDALONE: !1
  1185. }) : (window.onkeydown = this.disableKeys, this.trackGA(), n = {
  1186. IS_MASTER: !0,
  1187. IS_SLAVE: !0,
  1188. IS_STANDALONE: !0
  1189. });
  1190. return n
  1191. },
  1192. g.callConfigar = function(t, e) {
  1193. var n, r, i = t.site || 500,
  1194. o = t.channel || 100,
  1195. a = t.id || null;
  1196. window.XDomainRequest ? (n = new XDomainRequest, n.onload = function() {
  1197. e(200, n.responseText)
  1198. },
  1199. n.onerror = function() {
  1200. e(404, null)
  1201. },
  1202. n.onprogress = function() {}) : window.XMLHttpRequest ? (n = new XMLHttpRequest, n.onreadystatechange = function() {
  1203. 4 === n.readyState && e(n.status, n.responseText)
  1204. }) : window.ActiveXObject && (n = new ActiveXObject("Microsoft.XMLHTTP"), n.onreadystatechange = function() {
  1205. 4 === n.readyState && e(n.status, n.responseText)
  1206. }),
  1207. a && (r = ["http://api.configar.org/cf/pb/1/configs", o, i, a].join("/"), n.open("GET", r, !0), n.timeout = 3e3, n.ontimeout = function() {
  1208. e(404, null)
  1209. },
  1210. n.send())
  1211. },
  1212. g.isWrapped = function() {
  1213. return void 0 !== (window.PhoneGap || window.cordova || window.Cordova)
  1214. },
  1215. g.isArray = Array.isArray ||
  1216. function(t) {
  1217. return "[object Array]" === Object.prototype.toString.call(t)
  1218. },
  1219. g._getQueryString = function() {
  1220. return window.location.search
  1221. },
  1222. g._getPortalHost = function() {
  1223. return window && window.location && window.location.hostname ? window.location.hostname: "unknown"
  1224. },
  1225. g.validateSchema = function(t, e) {
  1226. for (var n in e) if (e.hasOwnProperty(n)) {
  1227. if (!t.hasOwnProperty(n)) return {
  1228. error: "Wrong argument passed: " + n
  1229. };
  1230. if (t.hasOwnProperty(n)) {
  1231. var r = "object" == typeof t[n] ? t[n].type: t[n];
  1232. if (e[n].constructor.name !== r) return {
  1233. error: "Wrong value type for " + n + ": expected " + t[n] + ", got " + e[n].constructor.name
  1234. };
  1235. var i = t[n] && t[n].values || [];
  1236. if ( - 1 === i.indexOf(e[n])) return {
  1237. error: "Wrong value for " + n + ": expected " + i.join(" or ") + ", got " + e[n]
  1238. }
  1239. }
  1240. }
  1241. return {
  1242. error: !1
  1243. }
  1244. };
  1245. var m = {};
  1246. m.getGameConfig = function() {
  1247. return f.getGameConfig().
  1248. catch(function() {
  1249. return m.getLocalConfig()
  1250. })
  1251. },
  1252. m.getBrandingConfig = function(t) {
  1253. return new Promise(function(e) {
  1254. return f.getBrandingConfig(t).then(e,
  1255. function(t) {
  1256. e(t),
  1257. window.postMessage(new c({
  1258. type: "warning",
  1259. callbackId: null,
  1260. data: "log.configar.getBranding.failure"
  1261. }), "*")
  1262. })
  1263. })
  1264. },
  1265. m.getLocalConfig = function(t) {
  1266. t = t && Object.keys(t).length ? t: {
  1267. portal: {},
  1268. game: {},
  1269. branding: {}
  1270. };
  1271. var e = {
  1272. game: {
  1273. applicationId: t.portal.applicationId || "0",
  1274. contentarId: t.portal.contentarId || "0",
  1275. info: t.game.info || {},
  1276. settings: t.game.objectSettings || {},
  1277. features: {
  1278. achievements: t.game.achievements || !1,
  1279. gameSidePanel: t.game.gameSidePanel || !1,
  1280. highscores: t.game.highscores || !1,
  1281. recommendedGames: t.game.recommendedGames || !1
  1282. }
  1283. },
  1284. user: {
  1285. authenticated: t.portal.authenticated || !1,
  1286. username: t.portal.username || ""
  1287. },
  1288. portal: {
  1289. host: g._getPortalHost(),
  1290. siteId: t.portal.siteId || 0,
  1291. channelId: t.portal.channelId || 0,
  1292. applicationId: t.portal.applicationId || "0"
  1293. },
  1294. branding: t.branding || {}
  1295. };
  1296. return e.branding.logo = e.branding.logo || {},
  1297. e.branding.logo.url = e.branding.logo.url || !1,
  1298. e.branding.logo.image = e.branding.logo.image || !1,
  1299. e
  1300. },
  1301. m.setupStandaloneMode = function(t, e) {
  1302. var n = {},
  1303. r = {
  1304. configar: {
  1305. branding: {
  1306. main: {
  1307. label: "main",
  1308. image: "#",
  1309. url: "#",
  1310. style: "",
  1311. width: "202",
  1312. height: "50",
  1313. mime: "image/png",
  1314. type: "png",
  1315. handler: "newTab",
  1316. blacklisted: !0
  1317. },
  1318. logo: {
  1319. label: "logo",
  1320. image: "#",
  1321. url: "#",
  1322. style: "",
  1323. width: "202",
  1324. height: "50",
  1325. mime: "image/png",
  1326. type: "png",
  1327. handler: "newTab",
  1328. blacklisted: !1
  1329. },
  1330. more_games: {
  1331. label: "more_games",
  1332. image: null,
  1333. url: "#",
  1334. style: "",
  1335. width: null,
  1336. height: null,
  1337. mime: null,
  1338. type: null,
  1339. handler: "newTab",
  1340. blacklisted: !1
  1341. },
  1342. splash_screen: {
  1343. label: "splash_screen",
  1344. image: "place_holder_string",
  1345. url: "#",
  1346. style: "",
  1347. width: "0",
  1348. height: "0",
  1349. mime: "image/png",
  1350. type: "png",
  1351. handler: "newTab",
  1352. blacklisted: !1
  1353. }
  1354. }
  1355. }
  1356. };
  1357. n.JSLib = {
  1358. memory: {},
  1359. _channels: {},
  1360. get: function(t) {
  1361. return this.memory[t] ? this.memory[t] : !1
  1362. },
  1363. set: function(t, e) {
  1364. return this.memory[t] = e,
  1365. e
  1366. },
  1367. publish: function(t, e) {
  1368. this._channels[t] && this._channels[t].forEach(function(t) {
  1369. try {
  1370. t.fn.call(this, e)
  1371. } catch(n) {}
  1372. })
  1373. },
  1374. subscribe: function(t, e) {
  1375. if ("function" != typeof e) throw Error("Callback has to be a function");
  1376. if ("string" != typeof t) throw Error("Channel name has to be a string");
  1377. this._channels[t] || (this._channels[t] = []),
  1378. this._channels[t].push({
  1379. fn: e
  1380. })
  1381. }
  1382. },
  1383. n.Net = {
  1384. send: function(t, e) {
  1385. e.call(this, {})
  1386. }
  1387. },
  1388. window.SpilGamesBootstrap = [],
  1389. window.SpilGames = function() {
  1390. var t = arguments;
  1391. if (t[0] && "string" == typeof t[0]) n.JSLib.publish(t[0], t[1] || null);
  1392. else if (t[0] && t[0] instanceof Array) {
  1393. var e, r, i = [];
  1394. for (e = 0, r = t[0].length; r > e; e++) i.push(n[t[0][e]]);
  1395. t[1].apply(this, i)
  1396. }
  1397. },
  1398. t && t.id ? g.callConfigar(t,
  1399. function(n, i) {
  1400. if (200 === n && "string" == typeof i && JSON.parse(i)) {
  1401. var o = JSON.parse(i);
  1402. e.call(this, {
  1403. branding: o.configar && o.configar.branding ? o.configar.branding: r.configar.branding,
  1404. portal: {
  1405. applicationId: t.id,
  1406. siteId: t.site ? t.site: 500,
  1407. channelId: t.channel ? t.channel: 100
  1408. }
  1409. })
  1410. } else e.call(this, {
  1411. branding: r.configar.branding
  1412. })
  1413. }) : e.call(this, {
  1414. branding: r.configar.branding
  1415. })
  1416. },
  1417. m.getCachedConfig = function() {},
  1418. e.prototype.newTab = function(t) {
  1419. var e = window.navigator.userAgent.toLowerCase().match(/android.*applewebkit\/([\d.]+)/),
  1420. n = e && 537 > e[1],
  1421. r = n ? "_self": "_blank",
  1422. i = t.url,
  1423. o = window.open(i, r);
  1424. return o && o.focus(),
  1425. o
  1426. },
  1427. e.prototype.displayOnTop = function(t) {
  1428. if (t === void 0 || t.url === void 0 || "string" != typeof t.url || t.action === void 0 || "function" != typeof t.action) return t.callback !== void 0 || "function" == typeof t.callback ? (t.callback(), void 0) : void 0;
  1429. var e = document.createElement("div"),
  1430. n = t.url,
  1431. r = t.action,
  1432. i = t.callback;
  1433. return e.setAttribute("id", "spilgames-splash-screen-sample"),
  1434. document.body.appendChild(e),
  1435. e.style.left = "0",
  1436. e.style.top = "0",
  1437. e.style.width = "100%",
  1438. e.style.height = "100%",
  1439. e.style.position = "absolute",
  1440. e.style.zIndex = "10000",
  1441. e.onclick = r,
  1442. n && (e.style.background = "url('" + n + "') center center no-repeat #FFF"),
  1443. window.setTimeout(function() {
  1444. var t = document.getElementById("spilgames-splash-screen-sample");
  1445. t.parentNode.removeChild(t),
  1446. i && i()
  1447. },
  1448. 2e3),
  1449. e
  1450. },
  1451. n.prototype.get = function(t) {
  1452. for (var e = this.dataStore,
  1453. n = t.split("."), r = n.length, i = 0; r - 1 > i; i++) {
  1454. if (!e[n[i]]) return null;
  1455. e = e[n[i]]
  1456. }
  1457. return e[n[r - 1]] || null
  1458. },
  1459. n.prototype.put = function(t, e) {
  1460. for (var n = this.dataStore,
  1461. r = t.split("."), i = r.length, o = 0; i - 1 > o; o++) {
  1462. var a = r[o];
  1463. n[a] || (n[a] = {}),
  1464. n = n[a]
  1465. }
  1466. n[r[i - 1]] = e
  1467. },
  1468. n.prototype.set = function(t, e) {
  1469. this.put(t, e);
  1470. var n = Date.parse(new Date);
  1471. return this.notify({
  1472. type: "new",
  1473. key: t,
  1474. current: e,
  1475. previous: null,
  1476. timestamp: n
  1477. }),
  1478. e
  1479. },
  1480. n.prototype.update = function(t, e) {
  1481. var n, r, i = null;
  1482. return this.get(t) ? (n = "update", i = this.get(t)) : n = "new",
  1483. this.put(t, e),
  1484. r = Date.parse(new Date),
  1485. this.notify({
  1486. type: n,
  1487. key: t,
  1488. current: e,
  1489. previous: i,
  1490. timestamp: r
  1491. }),
  1492. e
  1493. },
  1494. n.prototype.remove = function(t) {
  1495. if (this.get(t)) {
  1496. var e, n = this.get(t);
  1497. return this.put(t, null),
  1498. e = Date.parse(new Date),
  1499. this.notify({
  1500. type: "remove",
  1501. key: t,
  1502. current: null,
  1503. previous: n,
  1504. timestamp: e
  1505. }),
  1506. !0
  1507. }
  1508. return ! 1
  1509. },
  1510. n.prototype._setCache = function(t) {
  1511. this.dataStore = t
  1512. },
  1513. n.prototype._getCache = function() {
  1514. return this.dataStore
  1515. },
  1516. n.prototype.notify = function(t) {
  1517. if (this.IS_MASTER) {
  1518. var e = new c({
  1519. type: "datachange",
  1520. callbackId: null,
  1521. data: t
  1522. }).encode();
  1523. return window.postMessage(e, "*"),
  1524. e
  1525. }
  1526. },
  1527. r.prototype._performAction = function(t) {
  1528. var e = new c(t.data || {}),
  1529. n = this.messenger,
  1530. r = this.subscribers || {};
  1531. if (e && e.type && e.data) switch (e.type) {
  1532. case "gameEvent":
  1533. e.data[0] && r[e.data[0]] && r[e.data[0]].length > 0 ? r[e.data[0]].forEach(function(t) {
  1534. t.call(this),
  1535. n._postMessage([e.data[0], {
  1536. origin: "slave"
  1537. },
  1538. null], null, "gameState")
  1539. }) : e.data[0] && e.data[1] && "slave" === e.data[1].origin && "function" == typeof SWFtoJS && SWFtoJS({
  1540. call: e.data[0],
  1541. params: {}
  1542. });
  1543. break;
  1544. case "gameState":
  1545. e.data[0] && e.data[1] && "slave" === e.data[1].origin && (this.gameState = e.data[0])
  1546. }
  1547. },
  1548. r.prototype.on = function(t, e) {
  1549. this.IS_SLAVE && (this.subscribers[t] || (this.subscribers[t] = []), this.subscribers[t].push(e))
  1550. },
  1551. r.prototype.emit = function(t) {
  1552. if (!this.IS_MASTER) throw Error("Only the master environment can emit game events");
  1553. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1554. if (t === this.gameState) throw Error("The game is already in state: `" + t + "`");
  1555. this.messenger._postMessage([t, {
  1556. origin: "master"
  1557. },
  1558. null], null, "gameEvent")
  1559. },
  1560. i.prototype._setupMasterEvent = function() {
  1561. this.IS_MASTER && this.messenger.subscribe("gameapi.score", this.submit, this)
  1562. },
  1563. i.prototype.submit = function(t) {
  1564. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1565. return this.IS_MASTER ? "function" == typeof SWFtoJS && SWFtoJS({
  1566. call: "UPDATE_HIGHSCORE",
  1567. params: {
  1568. score: t
  1569. }
  1570. }) : (this.messenger._postMessage(t, void 0, "gameapi.score"), this.messenger._postMessage(["log.gameapi.score.submit", {
  1571. origin: "slave",
  1572. score: t
  1573. },
  1574. null], null, "log")),
  1575. {
  1576. success: !0,
  1577. value: t
  1578. }
  1579. },
  1580. o.prototype.init = function() {
  1581. this._setupEvents()
  1582. },
  1583. o.prototype._setupEvents = function() {
  1584. var t = this.messenger;
  1585. this.isMaster ? (SpilGames(["JSLib"],
  1586. function(e) {
  1587. e.subscribe("ad.request.accepted",
  1588. function(e) { ! 0 === e && (SpilGames("game.ad.accepted", !0), t._postMessage(!0, void 0, "ad.request.accepted"))
  1589. }),
  1590. e.subscribe("ad.complete",
  1591. function() {
  1592. t._postMessage("", "", "ad.complete")
  1593. })
  1594. }), this.messenger.subscribe("game.ad.request", this._triggerAd, this)) : (this.messenger.subscribe("ad.request.accepted", this._onAdAccepted, this), this.messenger.subscribe("ad.complete", this._onAdCompleted, this))
  1595. },
  1596. o.prototype._triggerAd = function() {
  1597. SpilGames("game.ad.request")
  1598. },
  1599. o.prototype._runCallback = function(t) {
  1600. this._callbacks[t] && (this._callbacks[t](), this._callbacks[t] = !1)
  1601. },
  1602. o.prototype.request = function(t, e) {
  1603. var n = this;
  1604. if ("function" != typeof t) throw Error("pauseGame argument should be a function");
  1605. if ("function" != typeof e) throw Error("resumeGame argument should be a function");
  1606. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1607. this._callbacks.pause = t,
  1608. this._callbacks.resume = e,
  1609. this.messenger._postMessage(void 0, void 0, "game.ad.request"),
  1610. this.isMaster || this.messenger._postMessage(["log.gameapi.ad.requested", {
  1611. origin: "slave"
  1612. },
  1613. null], null, "log"),
  1614. this.timeout = setTimeout(function() {
  1615. n._requestTimeout()
  1616. },
  1617. this.timeoutAfter)
  1618. },
  1619. o.prototype._onAdAccepted = function(t) {
  1620. var e = this.messenger;
  1621. this.timeout && clearTimeout(this.timeout),
  1622. !this.isMaster && t && (e._postMessage(["log.gameapi.ad.start", {
  1623. origin: "slave"
  1624. },
  1625. null], null, "log"), this._runCallback("pause"))
  1626. },
  1627. o.prototype._onAdCompleted = function() {
  1628. var t = this.messenger;
  1629. this.isMaster || t._postMessage(["log.gameapi.ad.complete", {
  1630. origin: "slave"
  1631. },
  1632. null], null, "log"),
  1633. this._runCallback("resume")
  1634. },
  1635. o.prototype._requestTimeout = function() {
  1636. this._onAdCompleted()
  1637. },
  1638. a.prototype._setupEvents = function() {
  1639. this.IS_MASTER && this.messenger.subscribe("gameapi.gameevent", this.emit, this)
  1640. },
  1641. a.prototype._validateEvent = function(t) {
  1642. var e = !1;
  1643. return this.events[t] && this.events[t] !== void 0 && (e = !0),
  1644. e
  1645. },
  1646. a.prototype.emit = function(t, e) {
  1647. if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
  1648. this._validateEvent(t) ? this.IS_MASTER ? "function" == typeof SWFtoJS && SWFtoJS({
  1649. call: t
  1650. }) : (this.messenger._postMessage(t, void 0, "gameapi.gameevent"), this.messenger._postMessage(["log.gameapi.gameevent.emit", {
  1651. origin: "slave",
  1652. evt: t
  1653. },
  1654. null], null, "log")) : this.IS_MASTER || this.messenger._postMessage(["log.gameapi.gameevent.emit", {
  1655. origin: "slave"
  1656. },
  1657. null], null, "log")
  1658. },
  1659. s.prototype.init = function(t) {
  1660. t = t || {},
  1661. this.data = t.data || this.data;
  1662. var e = this.data && this.data.game && this.data.game.applicationId ? this.data.game.applicationId: null,
  1663. n = new Date,
  1664. r = window.location.hostname; (this.IS_SLAVE || g.isWrapped()) && this.startInternalTracking(e, n, r)
  1665. },
  1666. s.prototype._createEventObject = function(t, e, n) {
  1667. return {
  1668. eventCategory: t,
  1669. eventAction: e,
  1670. properties: n
  1671. }
  1672. },
  1673. s.prototype._sendSETEvent = function(t, e, n) {
  1674. return this.messenger && (this.IS_SLAVE || g.isWrapped()) && this.messenger.post("tracker.event." + t, e, n),
  1675. e
  1676. },
  1677. s.prototype.trackGamePlay = function(t) {
  1678. if (!this.gamePlayTracking.started) return ! 1;
  1679. var e = this.gamePlayTracking.gid,
  1680. n = this.gamePlayTracking.timestamp,
  1681. r = this.gamePlayTracking.host,
  1682. i = this._createEventObject("game", "gameplay", {
  1683. applicationId: e,
  1684. start: n,
  1685. host: r
  1686. });
  1687. return this._sendSETEvent("express", i, t),
  1688. i
  1689. },
  1690. s.prototype.trackTimeInGame = function(t) {
  1691. if (!this.timeInGameTracking.started) return ! 1;
  1692. var e = this.timeInGameTracking.gid,
  1693. n = this.timeInGameTracking.timestamp,
  1694. r = this._createEventObject("game", "heartbeat", {
  1695. applicationId: e,
  1696. start: n
  1697. });
  1698. return this._sendSETEvent("express", r, t),
  1699. r
  1700. },
  1701. s.prototype.startInternalTracking = function(t, e, n) {
  1702. var r = this,
  1703. i = 6e4,
  1704. o = function(t) {
  1705. if (!t) throw "Could not save the time in game"
  1706. };
  1707. return this.moduleReady ? t ? (this.gamePlayTracking.gid = t, this.gamePlayTracking.timestamp = Date.parse(e), this.gamePlayTracking.host = n, this.gamePlayTracking.started = !0, this.timeInGameTracking.gid = t, this.timeInGameTracking.timestamp = Date.parse(e), this.timeInGameTracking.started = !0, this.trackGamePlay(function(t) {
  1708. if (!t) throw "Could not save the game play"
  1709. }), this.trackTimeInGame(o), setInterval(function() {
  1710. r.trackTimeInGame(o)
  1711. },
  1712. i), this.gamePlayTracking.started && this.timeInGameTracking.started) : {
  1713. error: "No application ID defined for this game"
  1714. }: {
  1715. error: "This method cannot be called before the API is loaded"
  1716. }
  1717. },
  1718. u.prototype.init = function(t) {
  1719. t = t || {},
  1720. this.data = t.data || this.data
  1721. },
  1722. u.prototype.getLogo = function(t) {
  1723. if (!this.moduleReady) return {
  1724. error: "This method cannot be called before the API is loaded"
  1725. };
  1726. var e = this.IS_MASTER ? "master": "slave";
  1727. this.messenger._postMessage(["log.branding.getlogo", {
  1728. origin: e
  1729. },
  1730. null], null, "log");
  1731. var n, r, i = {
  1732. type: {
  1733. type: "String",
  1734. values: ["png"]
  1735. },
  1736. width: "Number",
  1737. height: "Number"
  1738. };
  1739. return n = this._getLink("logo"),
  1740. t && "object" == typeof t && (r = g.validateSchema(i, t), r.error && (n.error = r.error)),
  1741. n
  1742. },
  1743. u.prototype.getLink = function(t) {
  1744. if (!t) return {
  1745. error: "No link identifier provided"
  1746. };
  1747. var e = this.listLinks();
  1748. if ( - 1 !== e.indexOf(t)) {
  1749. var n = this.IS_MASTER ? "master": "slave";
  1750. return this.messenger._postMessage(["log.branding.getlink", {
  1751. origin: n,
  1752. linkName: t
  1753. },
  1754. null], null, "log"),
  1755. this._getLink(t)
  1756. }
  1757. return {
  1758. error: "Invalid option: '" + t + "'",
  1759. action: function() {}
  1760. }
  1761. },
  1762. u.prototype._getLink = function(t) {
  1763. if (!t) return {
  1764. error: "No link identifier provided"
  1765. };
  1766. var e = this.data && this.data.branding ? this.data.branding: {};
  1767. return e && e[t] ? {
  1768. linkName: t,
  1769. image: e[t].image || !1,
  1770. action: this._executeHandler.bind(this, t)
  1771. }: {
  1772. error: "Invalid option: '" + t + "'",
  1773. action: function() {}
  1774. }
  1775. },
  1776. u.prototype._getGMLink = function(t) {
  1777. var e = null;
  1778. if (!t) return {
  1779. error: "No link identifier provided"
  1780. };
  1781. var n = this.data && this.data.branding ? this.data.branding: {};
  1782. return n && n[t] ? (e = this._tagUrl(n[t].url, t), {
  1783. linkName: t,
  1784. url: e
  1785. }) : {
  1786. error: "Invalid option: '" + t + "'",
  1787. url: null
  1788. }
  1789. },
  1790. u.prototype.getLinks = function() {
  1791. var t = {},
  1792. e = this.listLinks();
  1793. if (0 === e.length) t = {
  1794. more_games: {
  1795. action: function() {}
  1796. }
  1797. };
  1798. else for (var n = 0; e.length > n; n++) {
  1799. var r = e[n];
  1800. t[r] = this._getLink(r)
  1801. }
  1802. return t
  1803. },
  1804. u.prototype._executeHandler = function(t) {
  1805. var e = this.data && this.data.branding ? this.data.branding: {},
  1806. n = e[t],
  1807. r = n.handler,
  1808. i = this._tagUrl(n.url, t);
  1809. if (n.url && n.url.length > 0 && r && this.components[r]) {
  1810. var o = this.IS_MASTER ? "master": "slave";
  1811. return this.messenger._postMessage(["log.branding.linkAction", {
  1812. origin: o,
  1813. linkName: t
  1814. },
  1815. null], null, "log"),
  1816. this.components[r]({
  1817. url: i
  1818. })
  1819. }
  1820. return function() {}
  1821. },
  1822. u.prototype.listLinks = function() {
  1823. var t = [],
  1824. e = this.data && this.data.branding ? this.data.branding: {},
  1825. n = Object.keys(e);
  1826. return t = n.filter(function(t) {
  1827. return ! e[t].blacklisted
  1828. })
  1829. },
  1830. u.prototype.getSplashScreen = function() {
  1831. var t, e = this.IS_MASTER ? "master": "slave";
  1832. if (this.data && this.data.branding && this.data.branding.splash_screen) {
  1833. var n = !0;
  1834. this.data.branding.splash_screen.image || this.data.branding.splash_screen.url || (n = !1),
  1835. t = {
  1836. show: n,
  1837. action: this._getLink("splash_screen").action ||
  1838. function() {}
  1839. }
  1840. } else t = {
  1841. show: !0,
  1842. action: function() {}
  1843. };
  1844. return this.messenger._postMessage(["log.branding.splashScreen", {
  1845. origin: e
  1846. },
  1847. null], null, "log"),
  1848. t
  1849. },
  1850. u.prototype.displaySplashScreen = function(t) {
  1851. if ("function" != typeof t) throw Error("argument passed to displaySplashScreen method should be a function");
  1852. var e = this.IS_MASTER ? "master": "slave",
  1853. n = this._getLink("logo").image;
  1854. n && this.getSplashScreen().show ? ("master" !== e && this.messenger._postMessage(["log.branding.displaySplashScreen", {
  1855. origin: e
  1856. },
  1857. null], null, "log"), this.components.displayOnTop({
  1858. url: n,
  1859. action: this.getSplashScreen().action,
  1860. callback: t
  1861. })) : t()
  1862. },
  1863. u.prototype._tagUrl = function(t, e) {
  1864. var n, r, i, o = this.data && this.data.portal ? this.data.portal: {},
  1865. a = this.data && this.data.game ? this.data.game: {},
  1866. s = parseInt(o.siteId, 10);
  1867. if ("string" != typeof t) throw Error("No url specified");
  1868. return n = "string" == typeof e ? e: "logo",
  1869. r = "brandedgames_" + (s > 0 && 500 > s ? "internal": "external"),
  1870. i = ["utm_medium=" + r, "utm_campaign=" + a.applicationId, "utm_source=" + o.host, "utm_content=" + n].join("&"),
  1871. t += t.indexOf("?") > -1 ? "&": "?",
  1872. t + i
  1873. },
  1874. c.prototype.encode = function() {
  1875. var t = ["gameapi", this.type, this.callbackId, this.data ? JSON.stringify(this.data) : ""].join("|");
  1876. return t
  1877. },
  1878. l.prototype._postMessage = function(t, e, n) {
  1879. var r, i;
  1880. r = g.isArray(t) && "function" == typeof t[t.length - 1] ? this._callbacks.push(t.pop()) - 1 : e,
  1881. i = new c({
  1882. type: n || "jslib",
  1883. callbackId: r,
  1884. data: t
  1885. }).encode(),
  1886. this._target.postMessage(i, "*")
  1887. },
  1888. l.prototype._callJSLib = function() {
  1889. SpilGames.apply(SpilGames, g.argsToArray(arguments))
  1890. },
  1891. l.prototype._setupEventListener = function() {
  1892. window.addEventListener ? window.addEventListener("message", this._handleMessage.bind(this), !1) : window.attachEvent && window.attachEvent("onmessage", this._handleMessage.bind(this))
  1893. },
  1894. l.prototype._handleMessage = function(t) {
  1895. var e, n, r, i, o = this,
  1896. a = new c(t.data);
  1897. if (a) if (e = a.type, n = a.callbackId, r = a.data, i = this._callbacks[n] || !1, this.IS_MASTER) switch (e) {
  1898. case "jslib":
  1899. "Array" === r.constructor.name && r.push(function(t) {
  1900. o._postMessage(t, n)
  1901. }),
  1902. this._callJSLib.apply(this, r);
  1903. break;
  1904. case "ugapi":
  1905. this._handleUGARequest(t);
  1906. break;
  1907. case "datachange":
  1908. this._postMessage(r, null, "datachange");
  1909. break;
  1910. default:
  1911. this.publish(e, r)
  1912. } else this.IS_SLAVE && ("function" == typeof i ? (delete this._callbacks[n], i(r)) : "datachange" === e || "jslib" !== e && this.publish(e, r));
  1913. return ! 1
  1914. },
  1915. l.prototype._handleUGARequest = function(t) {
  1916. var e, n, r, i = this,
  1917. o = new c(t.data);
  1918. if (o) switch (e = o.data[0], n = o.callbackId, r = o.data[1] ? o.data[1] : null, e) {
  1919. case "GameAPI.data":
  1920. i._postMessage(this.dataStore._getCache(), n, "ugapi");
  1921. break;
  1922. case "GameAPI.isReady":
  1923. i._postMessage({
  1924. isready:
  1925. this.api.isReady
  1926. },
  1927. n, "ugapi")
  1928. }
  1929. },
  1930. l.prototype.post = function() {
  1931. var t = g.argsToArray(arguments);
  1932. return this.IS_SLAVE ? this._postMessage(t) : this._callJSLib.apply(this, t),
  1933. this
  1934. },
  1935. l.prototype.publish = function(t, e) {
  1936. return this._channels[t] && this._channels[t].forEach(function(t) {
  1937. try {
  1938. t.fn.call(t.ctx, e)
  1939. } catch(n) {}
  1940. }),
  1941. this
  1942. },
  1943. l.prototype.subscribe = function(t, e, n) {
  1944. if ("function" != typeof e) throw Error("Callback has to be a function");
  1945. if ("string" != typeof t) throw Error("Channel name has to be a string");
  1946. return this._channels[t] || (this._channels[t] = []),
  1947. this._channels[t].push({
  1948. fn: e,
  1949. ctx: n
  1950. }),
  1951. this
  1952. },
  1953. l.prototype.unsubscribe = function(t, e) {
  1954. return this._channels[t] && "function" == typeof e && (this._channels[t] = this._channels[t].filter(function(t) {
  1955. return t.fn !== e
  1956. })),
  1957. this
  1958. },
  1959. l.prototype.subscribeOnce = function(t, e, n) {
  1960. function r(n) {
  1961. i.unsubscribe(t, r),
  1962. e.call(this, n)
  1963. }
  1964. var i = this;
  1965. return this.subscribe(t, r, n)
  1966. },
  1967. l.prototype.requestFromParent = function(t, e, n) {
  1968. if (!this.IS_SLAVE) throw "You are the parent, stop talking to yourself";
  1969. e = e || {},
  1970. this._postMessage([t, e, n], null, "ugapi")
  1971. },
  1972. d.prototype._setRole = function() {
  1973. var t = g.getRole();
  1974. this.IS_MASTER = t.IS_MASTER,
  1975. this.IS_SLAVE = t.IS_SLAVE,
  1976. this.IS_STANDALONE = t.IS_STANDALONE
  1977. },
  1978. d.prototype._getTarget = function() {
  1979. if (this.IS_STANDALONE) return window;
  1980. var t = document.getElementById("iframegame"),
  1981. e = t && t.contentWindow ? t.contentWindow: window.parent;
  1982. return this.IS_MASTER ? e: window.parent
  1983. },
  1984. d.prototype.loadAPI = function(t, e) {
  1985. function r(e) {
  1986. return c.IS_MASTER && (e = i(e)),
  1987. c.isReady = !0,
  1988. c.Branding.moduleReady = !0,
  1989. c.__.EventTracking.moduleReady = !0,
  1990. c.GameBreak.moduleReady = !0,
  1991. c.Game.moduleReady = !0,
  1992. c.Score.moduleReady = !0,
  1993. c.GameEvent.moduleReady = !0,
  1994. c.Branding.init({
  1995. data: e
  1996. }),
  1997. c.__.EventTracking.init({
  1998. data: e
  1999. }),
  2000. c.GameBreak.init(),
  2001. c.__.messenger._postMessage(["log.gameapi.loadapi.finish", {
  2002. origin: p,
  2003. version: c.version
  2004. },
  2005. null], null, "log"),
  2006. t(c)
  2007. }
  2008. function i(t) {
  2009. var e = t.game || {},
  2010. n = t.user || {},
  2011. r = t.portal || {},
  2012. i = t.branding || {};
  2013. return m.getLocalConfig({
  2014. game: e,
  2015. user: n,
  2016. portal: r,
  2017. branding: i
  2018. })
  2019. }
  2020. function o() {
  2021. c.__.messenger.requestFromParent("GameAPI.data", {},
  2022. function(t) {
  2023. r(t)
  2024. })
  2025. }
  2026. function a() {
  2027. c.IS_STANDALONE = !0,
  2028. c.IS_MASTER = !0,
  2029. c.IS_SLAVE = !0,
  2030. c.__.dataStore = new n({
  2031. isMaster: !0
  2032. }),
  2033. e = e || null,
  2034. m.setupStandaloneMode(e,
  2035. function(t) {
  2036. c.__.dataStore._setCache(i(t)),
  2037. r(t)
  2038. })
  2039. }
  2040. function s() {
  2041. c.__.messenger.requestFromParent("GameAPI.isReady", {},
  2042. function(t) {
  2043. u && clearTimeout(u),
  2044. t.isready ? o() : 5 > l ? (l++, setTimeout(s, 500)) : o()
  2045. })
  2046. }
  2047. var u, c = this,
  2048. p = this.IS_MASTER ? "master": "slave",
  2049. l = 0;
  2050. if ("function" != typeof t) throw Error("argument passed to loadAPI method should be a function");
  2051. return ! 0 === this.isReady ? (window.console && window.console.log && console.log("WARNING: Detected multiple executions of GameAPI.loadAPI(). This method should only be executed once per page load!"), t(c)) : (this.__.messenger._postMessage(["log.gameapi.loadapi.start", {
  2052. origin: p,
  2053. version: c.version,
  2054. spildata: e
  2055. },
  2056. null], null, "log"), this.IS_STANDALONE ? a() : this.IS_MASTER ? m.getGameConfig().then(function(t) {
  2057. m.getBrandingConfig(t).then(function(e) {
  2058. t && !t.isError && (t.branding = e.branding, c.__.dataStore._setCache(i(t))),
  2059. r(t)
  2060. })
  2061. }) : (u = setTimeout(a, 600), s()), void 0)
  2062. };
  2063. var y = new d(n, l, u, s, o);
  2064. "function" == typeof define && define.amd && define("GameAPI", y),
  2065. t.GameAPI = y
  2066. })(window),
  2067. function() {
  2068. "use strict";
  2069. function t(t) {
  2070. t && (t.setTargetValueAtTime || (t.setTargetValueAtTime = t.setTargetAtTime))
  2071. }
  2072. window.hasOwnProperty("AudioContext") && (window.webkitAudioContext = AudioContext, AudioContext.prototype.hasOwnProperty("internal_createGain") || (AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain, AudioContext.prototype.createGain = function() {
  2073. var e = this.internal_createGain();
  2074. return t(e.gain),
  2075. e
  2076. }), AudioContext.prototype.hasOwnProperty("internal_createDelay") || (AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay, AudioContext.prototype.createDelay = function() {
  2077. var e = this.internal_createDelay();
  2078. return t(e.delayTime),
  2079. e
  2080. }), AudioContext.prototype.hasOwnProperty("internal_createBufferSource") || (AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource, AudioContext.prototype.createBufferSource = function() {
  2081. var e = this.internal_createBufferSource();
  2082. return e.noteOn || (e.noteOn = e.start),
  2083. e.noteGrainOn || (e.noteGrainOn = e.start),
  2084. e.noteOff || (e.noteOff = e.stop),
  2085. t(e.playbackRate),
  2086. e
  2087. }), AudioContext.prototype.hasOwnProperty("internal_createDynamicsCompressor") || (AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor, AudioContext.prototype.createDynamicsCompressor = function() {
  2088. var e = this.internal_createDynamicsCompressor();
  2089. return t(e.threshold),
  2090. t(e.knee),
  2091. t(e.ratio),
  2092. t(e.reduction),
  2093. t(e.attack),
  2094. t(e.release),
  2095. e
  2096. }), AudioContext.prototype.hasOwnProperty("internal_createBiquadFilter") || (AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter, AudioContext.prototype.createBiquadFilter = function() {
  2097. var e = this.internal_createBiquadFilter();
  2098. t(e.frequency),
  2099. t(e.detune),
  2100. t(e.Q),
  2101. t(e.gain);
  2102. for (var n = ["LOWPASS", "HIGHPASS", "BANDPASS", "LOWSHELF", "HIGHSHELF", "PEAKING", "NOTCH", "ALLPASS"], r = 0; n.length > r; ++r) {
  2103. var i = n[r],
  2104. o = i.toLowerCase();
  2105. e.hasOwnProperty(i) || (e[i] = o)
  2106. }
  2107. return e
  2108. }), AudioContext.prototype.hasOwnProperty("internal_createOscillator") || AudioContext.prototype.hasOwnProperty("createOscillator") && (AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator, AudioContext.prototype.createOscillator = function() {
  2109. var e = this.internal_createOscillator();
  2110. e.noteOn || (e.noteOn = e.start),
  2111. e.noteOff || (e.noteOff = e.stop),
  2112. t(e.frequency),
  2113. t(e.detune);
  2114. for (var n = ["SINE", "SQUARE", "SAWTOOTH", "TRIANGLE", "CUSTOM"], r = 0; n.length > r; ++r) {
  2115. var i = n[r],
  2116. o = i.toLowerCase();
  2117. e.hasOwnProperty(i) || (e[i] = o)
  2118. }
  2119. return e.hasOwnProperty("setWaveTable") || (e.setWaveTable = e.setPeriodicTable),
  2120. e
  2121. }), AudioContext.prototype.hasOwnProperty("internal_createPanner") || (AudioContext.prototype.internal_createPanner = AudioContext.prototype.createPanner, AudioContext.prototype.createPanner = function() {
  2122. var t = this.internal_createPanner(),
  2123. e = {
  2124. EQUALPOWER: "equalpower",
  2125. HRTF: "HRTF",
  2126. LINEAR_DISTANCE: "linear",
  2127. INVERSE_DISTANCE: "inverse",
  2128. EXPONENTIAL_DISTANCE: "exponential"
  2129. };
  2130. for (var n in e) {
  2131. var r = e[n];
  2132. t.hasOwnProperty(n) || (t[n] = r)
  2133. }
  2134. return t
  2135. }), 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))
  2136. } (window);