@everymatrix/casino-game-thumb-view 1.32.4 → 1.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/assets/baccarat.svg +43 -0
  2. package/dist/assets/fav.svg +9 -0
  3. package/dist/assets/favorite.svg +12 -0
  4. package/dist/assets/seat.svg +6 -0
  5. package/dist/assets/unfav.svg +20 -0
  6. package/dist/casino-game-thumb-view/casino-game-thumb-view.esm.js +1 -0
  7. package/dist/casino-game-thumb-view/index.esm.js +0 -0
  8. package/dist/casino-game-thumb-view/p-1bbf4b70.entry.js +1 -0
  9. package/dist/casino-game-thumb-view/p-1e63a1ab.js +1 -0
  10. package/dist/casino-game-thumb-view/p-2d5f59fe.js +1 -0
  11. package/dist/casino-game-thumb-view/p-42bf2034.entry.js +1 -0
  12. package/dist/casino-game-thumb-view/p-46dbb1cb.js +1 -0
  13. package/dist/casino-game-thumb-view/p-6a6b2a78.js +8 -0
  14. package/dist/casino-game-thumb-view/p-7ae107ed.entry.js +1 -0
  15. package/dist/casino-game-thumb-view/p-9cbfffbc.entry.js +1 -0
  16. package/dist/casino-game-thumb-view/p-d961aec4.entry.js +1 -0
  17. package/dist/casino-game-thumb-view/p-db43bb56.entry.js +7 -0
  18. package/dist/cjs/casino-extrainfo-baccarat.cjs.entry.js +366 -0
  19. package/dist/cjs/casino-extrainfo-blackjack.cjs.entry.js +58 -0
  20. package/dist/cjs/casino-extrainfo-roulette.cjs.entry.js +45 -0
  21. package/dist/cjs/casino-game-thumb-view.cjs.js +19 -0
  22. package/dist/cjs/casino-game-thumb-view_2.cjs.entry.js +1612 -0
  23. package/dist/cjs/casino-game-thumbnail-betlimit_2.cjs.entry.js +278 -0
  24. package/dist/cjs/casino-normal-game-thumbnail.cjs.entry.js +23 -0
  25. package/dist/cjs/game-thumbnail-31d518f0.js +78 -0
  26. package/dist/cjs/index-65a1d768.js +1796 -0
  27. package/dist/cjs/index.cjs.js +2 -0
  28. package/dist/cjs/loader.cjs.js +21 -0
  29. package/dist/cjs/locale.utils-aa160787.js +132 -0
  30. package/dist/cjs/utils-a0afc0a9.js +5745 -0
  31. package/dist/collection/collection-manifest.json +19 -0
  32. package/dist/collection/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.css +116 -0
  33. package/dist/collection/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.js +240 -0
  34. package/dist/collection/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.css +64 -0
  35. package/dist/collection/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.js +119 -0
  36. package/dist/collection/components/casino-extrainfo-roulette/casino-extrainfo-roulette.css +40 -0
  37. package/dist/collection/components/casino-extrainfo-roulette/casino-extrainfo-roulette.js +123 -0
  38. package/dist/collection/components/casino-game-thumb-view/casino-game-thumb-view.css +361 -0
  39. package/dist/collection/components/casino-game-thumb-view/casino-game-thumb-view.js +1064 -0
  40. package/dist/collection/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.css +3 -0
  41. package/dist/collection/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.js +86 -0
  42. package/dist/collection/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.css +154 -0
  43. package/dist/collection/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.js +158 -0
  44. package/dist/collection/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.css +58 -0
  45. package/dist/collection/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.js +209 -0
  46. package/dist/collection/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.css +3 -0
  47. package/dist/collection/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.js +62 -0
  48. package/dist/collection/constants/game-thumbnail.js +85 -0
  49. package/dist/collection/index.js +1 -0
  50. package/dist/collection/models/casino-game-thumb-view.js +12 -0
  51. package/dist/collection/models/currency-symbols.js +173 -0
  52. package/dist/collection/static/baccarat.svg +43 -0
  53. package/dist/collection/static/fav.svg +9 -0
  54. package/dist/collection/static/favorite.svg +12 -0
  55. package/dist/collection/static/seat.svg +6 -0
  56. package/dist/collection/static/unfav.svg +20 -0
  57. package/dist/collection/utils/baccarat-board-svg.js +234 -0
  58. package/dist/collection/utils/locale.utils.js +128 -0
  59. package/dist/collection/utils/utils.js +65 -0
  60. package/dist/components/casino-extrainfo-baccarat.d.ts +11 -0
  61. package/dist/components/casino-extrainfo-baccarat.js +400 -0
  62. package/dist/components/casino-extrainfo-blackjack.d.ts +11 -0
  63. package/dist/components/casino-extrainfo-blackjack.js +92 -0
  64. package/dist/components/casino-extrainfo-roulette.d.ts +11 -0
  65. package/dist/components/casino-extrainfo-roulette.js +78 -0
  66. package/dist/components/casino-game-thumb-view.d.ts +11 -0
  67. package/dist/components/casino-game-thumb-view.js +1625 -0
  68. package/dist/components/casino-game-thumbnail-betlimit.d.ts +11 -0
  69. package/dist/components/casino-game-thumbnail-betlimit.js +6 -0
  70. package/dist/components/casino-game-thumbnail-betlimit2.js +227 -0
  71. package/dist/components/casino-game-thumbnail-extrainfo.d.ts +11 -0
  72. package/dist/components/casino-game-thumbnail-extrainfo.js +6 -0
  73. package/dist/components/casino-game-thumbnail-extrainfo2.js +96 -0
  74. package/dist/components/casino-game-thumbnail-overlay.d.ts +11 -0
  75. package/dist/components/casino-game-thumbnail-overlay.js +6 -0
  76. package/dist/components/casino-game-thumbnail-overlay2.js +69 -0
  77. package/dist/components/casino-normal-game-thumbnail.d.ts +11 -0
  78. package/dist/components/casino-normal-game-thumbnail.js +52 -0
  79. package/dist/components/game-thumbnail.js +72 -0
  80. package/dist/components/index.d.ts +26 -0
  81. package/dist/components/index.js +1 -0
  82. package/dist/components/locale.utils.js +130 -0
  83. package/dist/components/utils.js +5739 -0
  84. package/dist/esm/casino-extrainfo-baccarat.entry.js +362 -0
  85. package/dist/esm/casino-extrainfo-blackjack.entry.js +54 -0
  86. package/dist/esm/casino-extrainfo-roulette.entry.js +41 -0
  87. package/dist/esm/casino-game-thumb-view.js +17 -0
  88. package/dist/esm/casino-game-thumb-view_2.entry.js +1607 -0
  89. package/dist/esm/casino-game-thumbnail-betlimit_2.entry.js +273 -0
  90. package/dist/esm/casino-normal-game-thumbnail.entry.js +19 -0
  91. package/dist/esm/game-thumbnail-0a56ee03.js +72 -0
  92. package/dist/esm/index-1e44dd9f.js +1769 -0
  93. package/dist/esm/index.js +1 -0
  94. package/dist/esm/loader.js +17 -0
  95. package/dist/esm/locale.utils-e0cf897e.js +130 -0
  96. package/dist/esm/polyfills/core-js.js +11 -0
  97. package/dist/esm/polyfills/css-shim.js +1 -0
  98. package/dist/esm/polyfills/dom.js +79 -0
  99. package/dist/esm/polyfills/es5-html-element.js +1 -0
  100. package/dist/esm/polyfills/index.js +34 -0
  101. package/dist/esm/polyfills/system.js +6 -0
  102. package/dist/esm/utils-e9314132.js +5739 -0
  103. package/dist/index.cjs.js +1 -0
  104. package/dist/index.js +1 -0
  105. package/dist/stencil.config.js +40 -0
  106. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/casino-game-thumb-view/.stencil/packages/casino-game-thumb-view/stencil.config.d.ts +2 -0
  107. package/dist/types/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.d.ts +40 -0
  108. package/dist/types/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.d.ts +36 -0
  109. package/dist/types/components/casino-extrainfo-roulette/casino-extrainfo-roulette.d.ts +21 -0
  110. package/dist/types/components/casino-game-thumb-view/casino-game-thumb-view.d.ts +221 -0
  111. package/dist/types/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.d.ts +17 -0
  112. package/dist/types/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.d.ts +16 -0
  113. package/dist/types/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.d.ts +31 -0
  114. package/dist/types/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.d.ts +7 -0
  115. package/dist/types/components.d.ts +480 -0
  116. package/dist/types/constants/game-thumbnail.d.ts +83 -0
  117. package/dist/types/index.d.ts +1 -0
  118. package/dist/types/models/casino-game-thumb-view.d.ts +132 -0
  119. package/dist/types/models/currency-symbols.d.ts +172 -0
  120. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  121. package/dist/types/utils/baccarat-board-svg.d.ts +31 -0
  122. package/dist/types/utils/locale.utils.d.ts +1 -0
  123. package/dist/types/utils/utils.d.ts +19 -0
  124. package/loader/cdn.js +3 -0
  125. package/loader/index.cjs.js +3 -0
  126. package/loader/index.d.ts +12 -0
  127. package/loader/index.es2017.js +3 -0
  128. package/loader/index.js +4 -0
  129. package/loader/package.json +10 -0
  130. package/package.json +2 -3
  131. package/LICENSE +0 -21
@@ -0,0 +1,1607 @@
1
+ import { r as registerInstance, c as createEvent, h } from './index-1e44dd9f.js';
2
+ import { c as convertGicBaccaratUpdateItem, i as isMobile } from './utils-e9314132.js';
3
+ import { G as GAME_CATEGORY, a as GAME_TYPE, W as WIDGETTYPE_GAMECATEGORY } from './game-thumbnail-0a56ee03.js';
4
+ import { t as translate } from './locale.utils-e0cf897e.js';
5
+
6
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
7
+
8
+ function createCommonjsModule(fn, basedir, module) {
9
+ return module = {
10
+ path: basedir,
11
+ exports: {},
12
+ require: function (path, base) {
13
+ return commonjsRequire();
14
+ }
15
+ }, fn(module, module.exports), module.exports;
16
+ }
17
+
18
+ function commonjsRequire () {
19
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
20
+ }
21
+
22
+ var eventsource = createCommonjsModule(function (module, exports) {
23
+ /** @license
24
+ * eventsource.js
25
+ * Available under MIT License (MIT)
26
+ * https://github.com/Yaffle/EventSource/
27
+ */
28
+
29
+ /*jslint indent: 2, vars: true, plusplus: true */
30
+ /*global setTimeout, clearTimeout */
31
+
32
+ (function (global) {
33
+
34
+ var setTimeout = global.setTimeout;
35
+ var clearTimeout = global.clearTimeout;
36
+ var XMLHttpRequest = global.XMLHttpRequest;
37
+ var XDomainRequest = global.XDomainRequest;
38
+ var ActiveXObject = global.ActiveXObject;
39
+ var NativeEventSource = global.EventSource;
40
+
41
+ var document = global.document;
42
+ var Promise = global.Promise;
43
+ var fetch = global.fetch;
44
+ var Response = global.Response;
45
+ var TextDecoder = global.TextDecoder;
46
+ var TextEncoder = global.TextEncoder;
47
+ var AbortController = global.AbortController;
48
+
49
+ if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) { // Firefox 2
50
+ document.readyState = "loading";
51
+ window.addEventListener("load", function (event) {
52
+ document.readyState = "complete";
53
+ }, false);
54
+ }
55
+
56
+ if (XMLHttpRequest == null && ActiveXObject != null) { // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6
57
+ XMLHttpRequest = function () {
58
+ return new ActiveXObject("Microsoft.XMLHTTP");
59
+ };
60
+ }
61
+
62
+ if (Object.create == undefined) {
63
+ Object.create = function (C) {
64
+ function F(){}
65
+ F.prototype = C;
66
+ return new F();
67
+ };
68
+ }
69
+
70
+ if (!Date.now) {
71
+ Date.now = function now() {
72
+ return new Date().getTime();
73
+ };
74
+ }
75
+
76
+ // see #118 (Promise#finally with polyfilled Promise)
77
+ // see #123 (data URLs crash Edge)
78
+ // see #125 (CSP violations)
79
+ // see pull/#138
80
+ // => No way to polyfill Promise#finally
81
+
82
+ if (AbortController == undefined) {
83
+ var originalFetch2 = fetch;
84
+ fetch = function (url, options) {
85
+ var signal = options.signal;
86
+ return originalFetch2(url, {headers: options.headers, credentials: options.credentials, cache: options.cache}).then(function (response) {
87
+ var reader = response.body.getReader();
88
+ signal._reader = reader;
89
+ if (signal._aborted) {
90
+ signal._reader.cancel();
91
+ }
92
+ return {
93
+ status: response.status,
94
+ statusText: response.statusText,
95
+ headers: response.headers,
96
+ body: {
97
+ getReader: function () {
98
+ return reader;
99
+ }
100
+ }
101
+ };
102
+ });
103
+ };
104
+ AbortController = function () {
105
+ this.signal = {
106
+ _reader: null,
107
+ _aborted: false
108
+ };
109
+ this.abort = function () {
110
+ if (this.signal._reader != null) {
111
+ this.signal._reader.cancel();
112
+ }
113
+ this.signal._aborted = true;
114
+ };
115
+ };
116
+ }
117
+
118
+ function TextDecoderPolyfill() {
119
+ this.bitsNeeded = 0;
120
+ this.codePoint = 0;
121
+ }
122
+
123
+ TextDecoderPolyfill.prototype.decode = function (octets) {
124
+ function valid(codePoint, shift, octetsCount) {
125
+ if (octetsCount === 1) {
126
+ return codePoint >= 0x0080 >> shift && codePoint << shift <= 0x07FF;
127
+ }
128
+ if (octetsCount === 2) {
129
+ return codePoint >= 0x0800 >> shift && codePoint << shift <= 0xD7FF || codePoint >= 0xE000 >> shift && codePoint << shift <= 0xFFFF;
130
+ }
131
+ if (octetsCount === 3) {
132
+ return codePoint >= 0x010000 >> shift && codePoint << shift <= 0x10FFFF;
133
+ }
134
+ throw new Error();
135
+ }
136
+ function octetsCount(bitsNeeded, codePoint) {
137
+ if (bitsNeeded === 6 * 1) {
138
+ return codePoint >> 6 > 15 ? 3 : codePoint > 31 ? 2 : 1;
139
+ }
140
+ if (bitsNeeded === 6 * 2) {
141
+ return codePoint > 15 ? 3 : 2;
142
+ }
143
+ if (bitsNeeded === 6 * 3) {
144
+ return 3;
145
+ }
146
+ throw new Error();
147
+ }
148
+ var REPLACER = 0xFFFD;
149
+ var string = "";
150
+ var bitsNeeded = this.bitsNeeded;
151
+ var codePoint = this.codePoint;
152
+ for (var i = 0; i < octets.length; i += 1) {
153
+ var octet = octets[i];
154
+ if (bitsNeeded !== 0) {
155
+ if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
156
+ bitsNeeded = 0;
157
+ codePoint = REPLACER;
158
+ string += String.fromCharCode(codePoint);
159
+ }
160
+ }
161
+ if (bitsNeeded === 0) {
162
+ if (octet >= 0 && octet <= 127) {
163
+ bitsNeeded = 0;
164
+ codePoint = octet;
165
+ } else if (octet >= 192 && octet <= 223) {
166
+ bitsNeeded = 6 * 1;
167
+ codePoint = octet & 31;
168
+ } else if (octet >= 224 && octet <= 239) {
169
+ bitsNeeded = 6 * 2;
170
+ codePoint = octet & 15;
171
+ } else if (octet >= 240 && octet <= 247) {
172
+ bitsNeeded = 6 * 3;
173
+ codePoint = octet & 7;
174
+ } else {
175
+ bitsNeeded = 0;
176
+ codePoint = REPLACER;
177
+ }
178
+ if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
179
+ bitsNeeded = 0;
180
+ codePoint = REPLACER;
181
+ }
182
+ } else {
183
+ bitsNeeded -= 6;
184
+ codePoint = codePoint << 6 | octet & 63;
185
+ }
186
+ if (bitsNeeded === 0) {
187
+ if (codePoint <= 0xFFFF) {
188
+ string += String.fromCharCode(codePoint);
189
+ } else {
190
+ string += String.fromCharCode(0xD800 + (codePoint - 0xFFFF - 1 >> 10));
191
+ string += String.fromCharCode(0xDC00 + (codePoint - 0xFFFF - 1 & 0x3FF));
192
+ }
193
+ }
194
+ }
195
+ this.bitsNeeded = bitsNeeded;
196
+ this.codePoint = codePoint;
197
+ return string;
198
+ };
199
+
200
+ // Firefox < 38 throws an error with stream option
201
+ var supportsStreamOption = function () {
202
+ try {
203
+ return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
204
+ } catch (error) {
205
+ console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
206
+ }
207
+ return false;
208
+ };
209
+
210
+ // IE, Edge
211
+ if (TextDecoder == undefined || TextEncoder == undefined || !supportsStreamOption()) {
212
+ TextDecoder = TextDecoderPolyfill;
213
+ }
214
+
215
+ var k = function () {
216
+ };
217
+
218
+ function XHRWrapper(xhr) {
219
+ this.withCredentials = false;
220
+ this.readyState = 0;
221
+ this.status = 0;
222
+ this.statusText = "";
223
+ this.responseText = "";
224
+ this.onprogress = k;
225
+ this.onload = k;
226
+ this.onerror = k;
227
+ this.onreadystatechange = k;
228
+ this._contentType = "";
229
+ this._xhr = xhr;
230
+ this._sendTimeout = 0;
231
+ this._abort = k;
232
+ }
233
+
234
+ XHRWrapper.prototype.open = function (method, url) {
235
+ this._abort(true);
236
+
237
+ var that = this;
238
+ var xhr = this._xhr;
239
+ var state = 1;
240
+ var timeout = 0;
241
+
242
+ this._abort = function (silent) {
243
+ if (that._sendTimeout !== 0) {
244
+ clearTimeout(that._sendTimeout);
245
+ that._sendTimeout = 0;
246
+ }
247
+ if (state === 1 || state === 2 || state === 3) {
248
+ state = 4;
249
+ xhr.onload = k;
250
+ xhr.onerror = k;
251
+ xhr.onabort = k;
252
+ xhr.onprogress = k;
253
+ xhr.onreadystatechange = k;
254
+ // IE 8 - 9: XDomainRequest#abort() does not fire any event
255
+ // Opera < 10: XMLHttpRequest#abort() does not fire any event
256
+ xhr.abort();
257
+ if (timeout !== 0) {
258
+ clearTimeout(timeout);
259
+ timeout = 0;
260
+ }
261
+ if (!silent) {
262
+ that.readyState = 4;
263
+ that.onabort(null);
264
+ that.onreadystatechange();
265
+ }
266
+ }
267
+ state = 0;
268
+ };
269
+
270
+ var onStart = function () {
271
+ if (state === 1) {
272
+ //state = 2;
273
+ var status = 0;
274
+ var statusText = "";
275
+ var contentType = undefined;
276
+ if (!("contentType" in xhr)) {
277
+ try {
278
+ status = xhr.status;
279
+ statusText = xhr.statusText;
280
+ contentType = xhr.getResponseHeader("Content-Type");
281
+ } catch (error) {
282
+ // IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
283
+ // Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
284
+ // https://bugs.webkit.org/show_bug.cgi?id=29121
285
+ status = 0;
286
+ statusText = "";
287
+ contentType = undefined;
288
+ // Firefox < 14, Chrome ?, Safari ?
289
+ // https://bugs.webkit.org/show_bug.cgi?id=29658
290
+ // https://bugs.webkit.org/show_bug.cgi?id=77854
291
+ }
292
+ } else {
293
+ status = 200;
294
+ statusText = "OK";
295
+ contentType = xhr.contentType;
296
+ }
297
+ if (status !== 0) {
298
+ state = 2;
299
+ that.readyState = 2;
300
+ that.status = status;
301
+ that.statusText = statusText;
302
+ that._contentType = contentType;
303
+ that.onreadystatechange();
304
+ }
305
+ }
306
+ };
307
+ var onProgress = function () {
308
+ onStart();
309
+ if (state === 2 || state === 3) {
310
+ state = 3;
311
+ var responseText = "";
312
+ try {
313
+ responseText = xhr.responseText;
314
+ } catch (error) {
315
+ // IE 8 - 9 with XMLHttpRequest
316
+ }
317
+ that.readyState = 3;
318
+ that.responseText = responseText;
319
+ that.onprogress();
320
+ }
321
+ };
322
+ var onFinish = function (type, event) {
323
+ if (event == null || event.preventDefault == null) {
324
+ event = {
325
+ preventDefault: k
326
+ };
327
+ }
328
+ // Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
329
+ // IE 8 fires "onload" without "onprogress"
330
+ onProgress();
331
+ if (state === 1 || state === 2 || state === 3) {
332
+ state = 4;
333
+ if (timeout !== 0) {
334
+ clearTimeout(timeout);
335
+ timeout = 0;
336
+ }
337
+ that.readyState = 4;
338
+ if (type === "load") {
339
+ that.onload(event);
340
+ } else if (type === "error") {
341
+ that.onerror(event);
342
+ } else if (type === "abort") {
343
+ that.onabort(event);
344
+ } else {
345
+ throw new TypeError();
346
+ }
347
+ that.onreadystatechange();
348
+ }
349
+ };
350
+ var onReadyStateChange = function (event) {
351
+ if (xhr != undefined) { // Opera 12
352
+ if (xhr.readyState === 4) {
353
+ if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
354
+ onFinish(xhr.responseText === "" ? "error" : "load", event);
355
+ }
356
+ } else if (xhr.readyState === 3) {
357
+ if (!("onprogress" in xhr)) { // testing XMLHttpRequest#responseText too many times is too slow in IE 11
358
+ // and in Firefox 3.6
359
+ onProgress();
360
+ }
361
+ } else if (xhr.readyState === 2) {
362
+ onStart();
363
+ }
364
+ }
365
+ };
366
+ var onTimeout = function () {
367
+ timeout = setTimeout(function () {
368
+ onTimeout();
369
+ }, 500);
370
+ if (xhr.readyState === 3) {
371
+ onProgress();
372
+ }
373
+ };
374
+
375
+ // XDomainRequest#abort removes onprogress, onerror, onload
376
+ if ("onload" in xhr) {
377
+ xhr.onload = function (event) {
378
+ onFinish("load", event);
379
+ };
380
+ }
381
+ if ("onerror" in xhr) {
382
+ xhr.onerror = function (event) {
383
+ onFinish("error", event);
384
+ };
385
+ }
386
+ // improper fix to match Firefox behaviour, but it is better than just ignore abort
387
+ // see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
388
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=880200
389
+ // https://code.google.com/p/chromium/issues/detail?id=153570
390
+ // IE 8 fires "onload" without "onprogress
391
+ if ("onabort" in xhr) {
392
+ xhr.onabort = function (event) {
393
+ onFinish("abort", event);
394
+ };
395
+ }
396
+
397
+ if ("onprogress" in xhr) {
398
+ xhr.onprogress = onProgress;
399
+ }
400
+
401
+ // IE 8 - 9 (XMLHTTPRequest)
402
+ // Opera < 12
403
+ // Firefox < 3.5
404
+ // Firefox 3.5 - 3.6 - ? < 9.0
405
+ // onprogress is not fired sometimes or delayed
406
+ // see also #64 (significant lag in IE 11)
407
+ if ("onreadystatechange" in xhr) {
408
+ xhr.onreadystatechange = function (event) {
409
+ onReadyStateChange(event);
410
+ };
411
+ }
412
+
413
+ if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
414
+ url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
415
+ }
416
+ xhr.open(method, url, true);
417
+
418
+ if ("readyState" in xhr) {
419
+ // workaround for Opera 12 issue with "progress" events
420
+ // #91 (XMLHttpRequest onprogress not fired for streaming response in Edge 14-15-?)
421
+ timeout = setTimeout(function () {
422
+ onTimeout();
423
+ }, 0);
424
+ }
425
+ };
426
+ XHRWrapper.prototype.abort = function () {
427
+ this._abort(false);
428
+ };
429
+ XHRWrapper.prototype.getResponseHeader = function (name) {
430
+ return this._contentType;
431
+ };
432
+ XHRWrapper.prototype.setRequestHeader = function (name, value) {
433
+ var xhr = this._xhr;
434
+ if ("setRequestHeader" in xhr) {
435
+ xhr.setRequestHeader(name, value);
436
+ }
437
+ };
438
+ XHRWrapper.prototype.getAllResponseHeaders = function () {
439
+ // XMLHttpRequest#getAllResponseHeaders returns null for CORS requests in Firefox 3.6.28
440
+ return this._xhr.getAllResponseHeaders != undefined ? this._xhr.getAllResponseHeaders() || "" : "";
441
+ };
442
+ XHRWrapper.prototype.send = function () {
443
+ // loading indicator in Safari < ? (6), Chrome < 14, Firefox
444
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=736723
445
+ if ((!("ontimeout" in XMLHttpRequest.prototype) || (!("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype))) &&
446
+ document != undefined &&
447
+ document.readyState != undefined &&
448
+ document.readyState !== "complete") {
449
+ var that = this;
450
+ that._sendTimeout = setTimeout(function () {
451
+ that._sendTimeout = 0;
452
+ that.send();
453
+ }, 4);
454
+ return;
455
+ }
456
+
457
+ var xhr = this._xhr;
458
+ // withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
459
+ if ("withCredentials" in xhr) {
460
+ xhr.withCredentials = this.withCredentials;
461
+ }
462
+ try {
463
+ // xhr.send(); throws "Not enough arguments" in Firefox 3.0
464
+ xhr.send(undefined);
465
+ } catch (error1) {
466
+ // Safari 5.1.7, Opera 12
467
+ throw error1;
468
+ }
469
+ };
470
+
471
+ function toLowerCase(name) {
472
+ return name.replace(/[A-Z]/g, function (c) {
473
+ return String.fromCharCode(c.charCodeAt(0) + 0x20);
474
+ });
475
+ }
476
+
477
+ function HeadersPolyfill(all) {
478
+ // Get headers: implemented according to mozilla's example code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
479
+ var map = Object.create(null);
480
+ var array = all.split("\r\n");
481
+ for (var i = 0; i < array.length; i += 1) {
482
+ var line = array[i];
483
+ var parts = line.split(": ");
484
+ var name = parts.shift();
485
+ var value = parts.join(": ");
486
+ map[toLowerCase(name)] = value;
487
+ }
488
+ this._map = map;
489
+ }
490
+ HeadersPolyfill.prototype.get = function (name) {
491
+ return this._map[toLowerCase(name)];
492
+ };
493
+
494
+ if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) { // IE < 9, Firefox 3.6
495
+ XMLHttpRequest.HEADERS_RECEIVED = 2;
496
+ }
497
+
498
+ function XHRTransport() {
499
+ }
500
+
501
+ XHRTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
502
+ xhr.open("GET", url);
503
+ var offset = 0;
504
+ xhr.onprogress = function () {
505
+ var responseText = xhr.responseText;
506
+ var chunk = responseText.slice(offset);
507
+ offset += chunk.length;
508
+ onProgressCallback(chunk);
509
+ };
510
+ xhr.onerror = function (event) {
511
+ event.preventDefault();
512
+ onFinishCallback(new Error("NetworkError"));
513
+ };
514
+ xhr.onload = function () {
515
+ onFinishCallback(null);
516
+ };
517
+ xhr.onabort = function () {
518
+ onFinishCallback(null);
519
+ };
520
+ xhr.onreadystatechange = function () {
521
+ if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
522
+ var status = xhr.status;
523
+ var statusText = xhr.statusText;
524
+ var contentType = xhr.getResponseHeader("Content-Type");
525
+ var headers = xhr.getAllResponseHeaders();
526
+ onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers));
527
+ }
528
+ };
529
+ xhr.withCredentials = withCredentials;
530
+ for (var name in headers) {
531
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
532
+ xhr.setRequestHeader(name, headers[name]);
533
+ }
534
+ }
535
+ xhr.send();
536
+ return xhr;
537
+ };
538
+
539
+ function HeadersWrapper(headers) {
540
+ this._headers = headers;
541
+ }
542
+ HeadersWrapper.prototype.get = function (name) {
543
+ return this._headers.get(name);
544
+ };
545
+
546
+ function FetchTransport() {
547
+ }
548
+
549
+ FetchTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
550
+ var reader = null;
551
+ var controller = new AbortController();
552
+ var signal = controller.signal;
553
+ var textDecoder = new TextDecoder();
554
+ fetch(url, {
555
+ headers: headers,
556
+ credentials: withCredentials ? "include" : "same-origin",
557
+ signal: signal,
558
+ cache: "no-store"
559
+ }).then(function (response) {
560
+ reader = response.body.getReader();
561
+ onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
562
+ // see https://github.com/promises-aplus/promises-spec/issues/179
563
+ return new Promise(function (resolve, reject) {
564
+ var readNextChunk = function () {
565
+ reader.read().then(function (result) {
566
+ if (result.done) {
567
+ //Note: bytes in textDecoder are ignored
568
+ resolve(undefined);
569
+ } else {
570
+ var chunk = textDecoder.decode(result.value, {stream: true});
571
+ onProgressCallback(chunk);
572
+ readNextChunk();
573
+ }
574
+ })["catch"](function (error) {
575
+ reject(error);
576
+ });
577
+ };
578
+ readNextChunk();
579
+ });
580
+ })["catch"](function (error) {
581
+ if (error.name === "AbortError") {
582
+ return undefined;
583
+ } else {
584
+ return error;
585
+ }
586
+ }).then(function (error) {
587
+ onFinishCallback(error);
588
+ });
589
+ return {
590
+ abort: function () {
591
+ if (reader != null) {
592
+ reader.cancel(); // https://bugzilla.mozilla.org/show_bug.cgi?id=1583815
593
+ }
594
+ controller.abort();
595
+ }
596
+ };
597
+ };
598
+
599
+ function EventTarget() {
600
+ this._listeners = Object.create(null);
601
+ }
602
+
603
+ function throwError(e) {
604
+ setTimeout(function () {
605
+ throw e;
606
+ }, 0);
607
+ }
608
+
609
+ EventTarget.prototype.dispatchEvent = function (event) {
610
+ event.target = this;
611
+ var typeListeners = this._listeners[event.type];
612
+ if (typeListeners != undefined) {
613
+ var length = typeListeners.length;
614
+ for (var i = 0; i < length; i += 1) {
615
+ var listener = typeListeners[i];
616
+ try {
617
+ if (typeof listener.handleEvent === "function") {
618
+ listener.handleEvent(event);
619
+ } else {
620
+ listener.call(this, event);
621
+ }
622
+ } catch (e) {
623
+ throwError(e);
624
+ }
625
+ }
626
+ }
627
+ };
628
+ EventTarget.prototype.addEventListener = function (type, listener) {
629
+ type = String(type);
630
+ var listeners = this._listeners;
631
+ var typeListeners = listeners[type];
632
+ if (typeListeners == undefined) {
633
+ typeListeners = [];
634
+ listeners[type] = typeListeners;
635
+ }
636
+ var found = false;
637
+ for (var i = 0; i < typeListeners.length; i += 1) {
638
+ if (typeListeners[i] === listener) {
639
+ found = true;
640
+ }
641
+ }
642
+ if (!found) {
643
+ typeListeners.push(listener);
644
+ }
645
+ };
646
+ EventTarget.prototype.removeEventListener = function (type, listener) {
647
+ type = String(type);
648
+ var listeners = this._listeners;
649
+ var typeListeners = listeners[type];
650
+ if (typeListeners != undefined) {
651
+ var filtered = [];
652
+ for (var i = 0; i < typeListeners.length; i += 1) {
653
+ if (typeListeners[i] !== listener) {
654
+ filtered.push(typeListeners[i]);
655
+ }
656
+ }
657
+ if (filtered.length === 0) {
658
+ delete listeners[type];
659
+ } else {
660
+ listeners[type] = filtered;
661
+ }
662
+ }
663
+ };
664
+
665
+ function Event(type) {
666
+ this.type = type;
667
+ this.target = undefined;
668
+ }
669
+
670
+ function MessageEvent(type, options) {
671
+ Event.call(this, type);
672
+ this.data = options.data;
673
+ this.lastEventId = options.lastEventId;
674
+ }
675
+
676
+ MessageEvent.prototype = Object.create(Event.prototype);
677
+
678
+ function ConnectionEvent(type, options) {
679
+ Event.call(this, type);
680
+ this.status = options.status;
681
+ this.statusText = options.statusText;
682
+ this.headers = options.headers;
683
+ }
684
+
685
+ ConnectionEvent.prototype = Object.create(Event.prototype);
686
+
687
+ function ErrorEvent(type, options) {
688
+ Event.call(this, type);
689
+ this.error = options.error;
690
+ }
691
+
692
+ ErrorEvent.prototype = Object.create(Event.prototype);
693
+
694
+ var WAITING = -1;
695
+ var CONNECTING = 0;
696
+ var OPEN = 1;
697
+ var CLOSED = 2;
698
+
699
+ var AFTER_CR = -1;
700
+ var FIELD_START = 0;
701
+ var FIELD = 1;
702
+ var VALUE_START = 2;
703
+ var VALUE = 3;
704
+
705
+ var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
706
+
707
+ var MINIMUM_DURATION = 1000;
708
+ var MAXIMUM_DURATION = 18000000;
709
+
710
+ var parseDuration = function (value, def) {
711
+ var n = value == null ? def : parseInt(value, 10);
712
+ if (n !== n) {
713
+ n = def;
714
+ }
715
+ return clampDuration(n);
716
+ };
717
+ var clampDuration = function (n) {
718
+ return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
719
+ };
720
+
721
+ var fire = function (that, f, event) {
722
+ try {
723
+ if (typeof f === "function") {
724
+ f.call(that, event);
725
+ }
726
+ } catch (e) {
727
+ throwError(e);
728
+ }
729
+ };
730
+
731
+ function EventSourcePolyfill(url, options) {
732
+ EventTarget.call(this);
733
+ options = options || {};
734
+
735
+ this.onopen = undefined;
736
+ this.onmessage = undefined;
737
+ this.onerror = undefined;
738
+
739
+ this.url = undefined;
740
+ this.readyState = undefined;
741
+ this.withCredentials = undefined;
742
+ this.headers = undefined;
743
+
744
+ this._close = undefined;
745
+
746
+ start(this, url, options);
747
+ }
748
+
749
+ function getBestXHRTransport() {
750
+ return (XMLHttpRequest != undefined && ("withCredentials" in XMLHttpRequest.prototype)) || XDomainRequest == undefined
751
+ ? new XMLHttpRequest()
752
+ : new XDomainRequest();
753
+ }
754
+
755
+ var isFetchSupported = fetch != undefined && Response != undefined && "body" in Response.prototype;
756
+
757
+ function start(es, url, options) {
758
+ url = String(url);
759
+ var withCredentials = Boolean(options.withCredentials);
760
+ var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
761
+
762
+ var initialRetry = clampDuration(1000);
763
+ var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45000);
764
+
765
+ var lastEventId = "";
766
+ var retry = initialRetry;
767
+ var wasActivity = false;
768
+ var textLength = 0;
769
+ var headers = options.headers || {};
770
+ var TransportOption = options.Transport;
771
+ var xhr = isFetchSupported && TransportOption == undefined ? undefined : new XHRWrapper(TransportOption != undefined ? new TransportOption() : getBestXHRTransport());
772
+ var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : (xhr == undefined ? new FetchTransport() : new XHRTransport());
773
+ var abortController = undefined;
774
+ var timeout = 0;
775
+ var currentState = WAITING;
776
+ var dataBuffer = "";
777
+ var lastEventIdBuffer = "";
778
+ var eventTypeBuffer = "";
779
+
780
+ var textBuffer = "";
781
+ var state = FIELD_START;
782
+ var fieldStart = 0;
783
+ var valueStart = 0;
784
+
785
+ var onStart = function (status, statusText, contentType, headers) {
786
+ if (currentState === CONNECTING) {
787
+ if (status === 200 && contentType != undefined && contentTypeRegExp.test(contentType)) {
788
+ currentState = OPEN;
789
+ wasActivity = Date.now();
790
+ retry = initialRetry;
791
+ es.readyState = OPEN;
792
+ var event = new ConnectionEvent("open", {
793
+ status: status,
794
+ statusText: statusText,
795
+ headers: headers
796
+ });
797
+ es.dispatchEvent(event);
798
+ fire(es, es.onopen, event);
799
+ } else {
800
+ var message = "";
801
+ if (status !== 200) {
802
+ if (statusText) {
803
+ statusText = statusText.replace(/\s+/g, " ");
804
+ }
805
+ message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
806
+ } else {
807
+ message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == undefined ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
808
+ }
809
+ close();
810
+ var event = new ConnectionEvent("error", {
811
+ status: status,
812
+ statusText: statusText,
813
+ headers: headers
814
+ });
815
+ es.dispatchEvent(event);
816
+ fire(es, es.onerror, event);
817
+ console.error(message);
818
+ }
819
+ }
820
+ };
821
+
822
+ var onProgress = function (textChunk) {
823
+ if (currentState === OPEN) {
824
+ var n = -1;
825
+ for (var i = 0; i < textChunk.length; i += 1) {
826
+ var c = textChunk.charCodeAt(i);
827
+ if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
828
+ n = i;
829
+ }
830
+ }
831
+ var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
832
+ textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
833
+ if (textChunk !== "") {
834
+ wasActivity = Date.now();
835
+ textLength += textChunk.length;
836
+ }
837
+ for (var position = 0; position < chunk.length; position += 1) {
838
+ var c = chunk.charCodeAt(position);
839
+ if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
840
+ state = FIELD_START;
841
+ } else {
842
+ if (state === AFTER_CR) {
843
+ state = FIELD_START;
844
+ }
845
+ if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
846
+ if (state !== FIELD_START) {
847
+ if (state === FIELD) {
848
+ valueStart = position + 1;
849
+ }
850
+ var field = chunk.slice(fieldStart, valueStart - 1);
851
+ var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
852
+ if (field === "data") {
853
+ dataBuffer += "\n";
854
+ dataBuffer += value;
855
+ } else if (field === "id") {
856
+ lastEventIdBuffer = value;
857
+ } else if (field === "event") {
858
+ eventTypeBuffer = value;
859
+ } else if (field === "retry") {
860
+ initialRetry = parseDuration(value, initialRetry);
861
+ retry = initialRetry;
862
+ } else if (field === "heartbeatTimeout") {
863
+ heartbeatTimeout = parseDuration(value, heartbeatTimeout);
864
+ if (timeout !== 0) {
865
+ clearTimeout(timeout);
866
+ timeout = setTimeout(function () {
867
+ onTimeout();
868
+ }, heartbeatTimeout);
869
+ }
870
+ }
871
+ }
872
+ if (state === FIELD_START) {
873
+ if (dataBuffer !== "") {
874
+ lastEventId = lastEventIdBuffer;
875
+ if (eventTypeBuffer === "") {
876
+ eventTypeBuffer = "message";
877
+ }
878
+ var event = new MessageEvent(eventTypeBuffer, {
879
+ data: dataBuffer.slice(1),
880
+ lastEventId: lastEventIdBuffer
881
+ });
882
+ es.dispatchEvent(event);
883
+ if (eventTypeBuffer === "open") {
884
+ fire(es, es.onopen, event);
885
+ } else if (eventTypeBuffer === "message") {
886
+ fire(es, es.onmessage, event);
887
+ } else if (eventTypeBuffer === "error") {
888
+ fire(es, es.onerror, event);
889
+ }
890
+ if (currentState === CLOSED) {
891
+ return;
892
+ }
893
+ }
894
+ dataBuffer = "";
895
+ eventTypeBuffer = "";
896
+ }
897
+ state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
898
+ } else {
899
+ if (state === FIELD_START) {
900
+ fieldStart = position;
901
+ state = FIELD;
902
+ }
903
+ if (state === FIELD) {
904
+ if (c === ":".charCodeAt(0)) {
905
+ valueStart = position + 1;
906
+ state = VALUE_START;
907
+ }
908
+ } else if (state === VALUE_START) {
909
+ state = VALUE;
910
+ }
911
+ }
912
+ }
913
+ }
914
+ }
915
+ };
916
+
917
+ var onFinish = function (error) {
918
+ if (currentState === OPEN || currentState === CONNECTING) {
919
+ currentState = WAITING;
920
+ if (timeout !== 0) {
921
+ clearTimeout(timeout);
922
+ timeout = 0;
923
+ }
924
+ timeout = setTimeout(function () {
925
+ onTimeout();
926
+ }, retry);
927
+ retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
928
+
929
+ es.readyState = CONNECTING;
930
+ var event = new ErrorEvent("error", {error: error});
931
+ es.dispatchEvent(event);
932
+ fire(es, es.onerror, event);
933
+ if (error != undefined) {
934
+ console.error(error);
935
+ }
936
+ }
937
+ };
938
+
939
+ var close = function () {
940
+ currentState = CLOSED;
941
+ if (abortController != undefined) {
942
+ abortController.abort();
943
+ abortController = undefined;
944
+ }
945
+ if (timeout !== 0) {
946
+ clearTimeout(timeout);
947
+ timeout = 0;
948
+ }
949
+ es.readyState = CLOSED;
950
+ };
951
+
952
+ var onTimeout = function () {
953
+ timeout = 0;
954
+
955
+ if (currentState !== WAITING) {
956
+ if (!wasActivity && abortController != undefined) {
957
+ onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds." + " " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " " + "Reconnecting."));
958
+ if (abortController != undefined) {
959
+ abortController.abort();
960
+ abortController = undefined;
961
+ }
962
+ } else {
963
+ var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
964
+ wasActivity = false;
965
+ timeout = setTimeout(function () {
966
+ onTimeout();
967
+ }, nextHeartbeat);
968
+ }
969
+ return;
970
+ }
971
+
972
+ wasActivity = false;
973
+ textLength = 0;
974
+ timeout = setTimeout(function () {
975
+ onTimeout();
976
+ }, heartbeatTimeout);
977
+
978
+ currentState = CONNECTING;
979
+ dataBuffer = "";
980
+ eventTypeBuffer = "";
981
+ lastEventIdBuffer = lastEventId;
982
+ textBuffer = "";
983
+ fieldStart = 0;
984
+ valueStart = 0;
985
+ state = FIELD_START;
986
+
987
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=428916
988
+ // Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
989
+ var requestURL = url;
990
+ if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
991
+ if (lastEventId !== "") {
992
+ // Remove the lastEventId parameter if it's already part of the request URL.
993
+ var i = url.indexOf("?");
994
+ requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function (p, paramName) {
995
+ return paramName === lastEventIdQueryParameterName ? '' : p;
996
+ });
997
+ // Append the current lastEventId to the request URL.
998
+ requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName +"=" + encodeURIComponent(lastEventId);
999
+ }
1000
+ }
1001
+ var withCredentials = es.withCredentials;
1002
+ var requestHeaders = {};
1003
+ requestHeaders["Accept"] = "text/event-stream";
1004
+ var headers = es.headers;
1005
+ if (headers != undefined) {
1006
+ for (var name in headers) {
1007
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
1008
+ requestHeaders[name] = headers[name];
1009
+ }
1010
+ }
1011
+ }
1012
+ try {
1013
+ abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials, requestHeaders);
1014
+ } catch (error) {
1015
+ close();
1016
+ throw error;
1017
+ }
1018
+ };
1019
+
1020
+ es.url = url;
1021
+ es.readyState = CONNECTING;
1022
+ es.withCredentials = withCredentials;
1023
+ es.headers = headers;
1024
+ es._close = close;
1025
+
1026
+ onTimeout();
1027
+ }
1028
+
1029
+ EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
1030
+ EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
1031
+ EventSourcePolyfill.prototype.OPEN = OPEN;
1032
+ EventSourcePolyfill.prototype.CLOSED = CLOSED;
1033
+ EventSourcePolyfill.prototype.close = function () {
1034
+ this._close();
1035
+ };
1036
+
1037
+ EventSourcePolyfill.CONNECTING = CONNECTING;
1038
+ EventSourcePolyfill.OPEN = OPEN;
1039
+ EventSourcePolyfill.CLOSED = CLOSED;
1040
+ EventSourcePolyfill.prototype.withCredentials = undefined;
1041
+
1042
+ var R = NativeEventSource;
1043
+ if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {
1044
+ // Why replace a native EventSource ?
1045
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=444328
1046
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=831392
1047
+ // https://code.google.com/p/chromium/issues/detail?id=260144
1048
+ // https://code.google.com/p/chromium/issues/detail?id=225654
1049
+ // ...
1050
+ R = EventSourcePolyfill;
1051
+ }
1052
+
1053
+ (function (factory) {
1054
+ {
1055
+ var v = factory(exports);
1056
+ if (v !== undefined) module.exports = v;
1057
+ }
1058
+ })(function (exports) {
1059
+ exports.EventSourcePolyfill = EventSourcePolyfill;
1060
+ exports.NativeEventSource = NativeEventSource;
1061
+ exports.EventSource = R;
1062
+ });
1063
+ }(typeof globalThis === 'undefined' ? (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal) : globalThis));
1064
+ });
1065
+
1066
+ const Fav = `<svg
1067
+ version="1.1"
1068
+ xmlns="http://www.w3.org/2000/svg"
1069
+ viewBox="0 0 19.481 19.481"
1070
+ enable-background="new 0 0 19.481 19.481"
1071
+ >
1072
+ <path
1073
+ d="m10.201,.758l2.478,5.865 6.344,.545c0.44,0.038 0.619,0.587 0.285,0.876l-4.812,4.169 1.442,6.202c0.1,0.431-0.367,0.77-0.745,0.541l-5.452-3.288-5.452,3.288c-0.379,0.228-0.845-0.111-0.745-0.541l1.442-6.202-4.813-4.17c-0.334-0.289-0.156-0.838 0.285-0.876l6.344-.545 2.478-5.864c0.172-0.408 0.749-0.408 0.921,0z"/>
1074
+ </svg>
1075
+ `;
1076
+
1077
+ const UnFavSvg = `<svg
1078
+ version="1.1"
1079
+ class="UnfavoredIcon"
1080
+ xmlns="http://www.w3.org/2000/svg"
1081
+ x="20px"
1082
+ y="20px"
1083
+ viewBox="0 0 512.001 512.001"
1084
+ >
1085
+ <path
1086
+ d="M511.266,197.256c-1.764-5.431-6.458-9.388-12.108-10.209l-158.722-23.065L269.452,20.155
1087
+ c-2.527-5.12-7.741-8.361-13.451-8.361c-5.709,0-10.924,3.242-13.451,8.361l-70.988,143.828L12.843,187.047
1088
+ c-5.65,0.821-10.344,4.779-12.108,10.209c-1.765,5.43-0.293,11.391,3.795,15.376l114.848,111.955L92.27,482.67
1089
+ c-0.965,5.627,1.349,11.315,5.968,14.67c4.618,3.355,10.74,3.798,15.797,1.142L256,423.846l141.961,74.637
1090
+ c2.195,1.154,4.591,1.723,6.979,1.723c3.11,0,6.206-0.966,8.818-2.865c4.619-3.356,6.933-9.043,5.968-14.671L392.61,324.587
1091
+ l114.86-111.954C511.559,208.647,513.031,202.686,511.266,197.256z M366.023,308.608c-3.536,3.446-5.15,8.412-4.314,13.278
1092
+ l23.311,135.898l-122.038-64.162c-4.37-2.297-9.591-2.297-13.961,0l-122.045,64.163l23.304-135.9
1093
+ c0.834-4.866-0.779-9.83-4.313-13.276l-98.731-96.244l136.445-19.829c4.886-0.71,9.108-3.778,11.294-8.205L256,60.685
1094
+ l61.023,123.645c2.186,4.427,6.408,7.496,11.294,8.206l136.447,19.828L366.023,308.608z"
1095
+ />
1096
+ </svg>
1097
+ `;
1098
+
1099
+ const casinoGameThumbViewCss = ":host{display:block}*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}.GameContainer{width:100%;height:100%;position:relative}.GameInnerContainer{position:relative;width:100%;height:100%;overflow:hidden;border-radius:5px}.GameInnerContainer .GameBg{width:100%;height:100%;object-fit:unset;transition:all 150ms ease-in-out}.GameInnerContainer .GameBg.GameBg-1x2,.GameInnerContainer .GameBg.GameBg-2x1,.GameInnerContainer .GameBg.GameBg-2x2{object-fit:cover}.GameInnerContainer:hover{cursor:pointer}.GameInnerContainer:hover .GameInfoWrapper{display:block}.GameInnerContainer:hover .GameBg{filter:blur(5px) grayscale(1)}.ListGame.GameBackdrop .GameInnerContainer::after{content:\"\";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(0deg, black 15%, rgba(0, 0, 0, 0) 100%)}.ListGame .GameInnerContainer{z-index:0}.ListGame .GameInnerContainer .GameBg{z-index:5}.ListGame .GameInnerContainer::after{content:\"\";position:absolute;top:0;right:0;bottom:0;left:0}.ListGame .GameInnerContainer.GameInnerContainerUnavailable::after{content:\"\";position:absolute;top:0;right:0;bottom:0;left:0;background:rgba(0, 0, 0, 0.9)}.ListGame .GameInnerContainer .ListGame:hover .OpenSeat,.ListGame .GameInnerContainer .ListGame:hover .ClosedSeat,.ListGame .GameInnerContainer .ListGame:hover .LiveLimits,.ListGame .GameInnerContainer .ListGame:hover .LatestResult,.ListGame .GameInnerContainer .ListGame:hover .FullTable,.ListGame .GameInnerContainer .ListGame:active .OpenSeat,.ListGame .GameInnerContainer .ListGame:active .ClosedSeat,.ListGame .GameInnerContainer .ListGame:active .LiveLimits,.ListGame .GameInnerContainer .ListGame:active .LatestResult,.ListGame .GameInnerContainer .ListGame:active .FullTable{opacity:0.2}.ListGame .GameInnerContainer .ListGame.GameContainerDimmed:before{display:block;content:\" \";width:100%;height:100%;position:absolute;top:0;right:0;bottom:0;left:0;z-index:5;background:rgba(0, 0, 0, 0.4);color:var(--emfe-w-color-white, #FFFFFF);fill:var(--emfe-w-color-white, #FFFFFF);opacity:1;border-radius:4px}.ListGame .GameInnerContainer .ListGame.GameContainerFullyDimmed:before{display:block;content:\" \";width:100%;height:100%;position:absolute;top:0;right:0;bottom:0;left:0;z-index:5;background:rgba(0, 0, 0, 0.8);color:var(--emfe-w-color-white, #FFFFFF);fill:var(--emfe-w-color-white, #FFFFFF);opacity:1;border-radius:4px}.ListGame .GameInnerContainer .ListGame:hover .LiveProps,.ListGame .GameInnerContainer .ListGameLink:hover .LiveProps{opacity:0}@keyframes red-pulse{0%{box-shadow:0 0 2px 0 rgba(255, 0, 0, 0.75)}15%{box-shadow:0 0 10px 2px rgba(255, 0, 0, 0.75)}30%{box-shadow:0 0 2px 0 rgba(255, 0, 0, 0.75)}50%{box-shadow:0 0 10px 2px rgba(255, 0, 0, 0.75)}65%{box-shadow:0 0 2px 0 rgba(255, 0, 0, 0.75)}80%{box-shadow:0 0 10px 2px rgba(255, 0, 0, 0.75)}100%{box-shadow:0 0 0 0 rgba(255, 0, 0, 0.75)}}@keyframes green-pulse{0%{box-shadow:0 0 2px 0 rgba(86, 168, 10, 0.75)}15%{box-shadow:0 0 10px 2px rgba(86, 168, 10, 0.75)}30%{box-shadow:0 0 2px 0 rgba(86, 168, 10, 0.75)}50%{box-shadow:0 0 10px 2px rgba(86, 168, 10, 0.75)}65%{box-shadow:0 0 2px 0 rgba(86, 168, 10, 0.75)}80%{box-shadow:0 0 10px 2px rgba(86, 168, 10, 0.75)}100%{box-shadow:0 0 0 0 rgba(86, 168, 10, 0.75)}}@keyframes flip-open{0%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, 90deg);transform:perspective(400px) rotate3d(0, 1, 0, 90deg);-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in;opacity:0}40%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, -20deg);transform:perspective(400px) rotate3d(0, 1, 0, -20deg);-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in}60%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, 10deg);transform:perspective(400px) rotate3d(0, 1, 0, 10deg);opacity:1}80%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, -5deg);transform:perspective(400px) rotate3d(0, 1, 0, -5deg)}100%{-webkit-transform:perspective(400px);transform:perspective(400px)}}.ListGame .GameInnerContainer .silde-in-from-left{-webkit-animation-name:silde-in-from-left;animation-name:silde-in-from-left;-webkit-animation-duration:1s;animation-duration:1s;-webkit-animation-fill-mode:both;animation-fill-mode:both}@-webkit-keyframes silde-in-from-left{0%{-webkit-transform:translateX(-100%);transform:translateX(-100%);visibility:visible}100%{-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes silde-in-from-left{0%{-webkit-transform:translateX(-100%);transform:translateX(-100%);visibility:visible}100%{-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes flip-closed-seat{0%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, 90deg);transform:perspective(400px) rotate3d(0, 1, 0, 90deg);-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in;opacity:0}40%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, -20deg);transform:perspective(400px) rotate3d(0, 1, 0, -20deg);-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in}60%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, 10deg);transform:perspective(400px) rotate3d(0, 1, 0, 10deg);opacity:1}80%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, -5deg);transform:perspective(400px) rotate3d(0, 1, 0, -5deg)}100%{-webkit-transform:perspective(400px);transform:perspective(400px)}}.ListGame .GameInnerContainer .ListGame.PulsatingGreenShadow{animation:green-pulse 2s linear}.ListGame .GameInnerContainer .ListGame.PulsatingRedShadow{animation:red-pulse 2s linear}.ListGame .GameInnerContainer .Blue{color:#4d90a7}.ListGame .GameInnerContainer .Red{background-color:red}.ListGame .GameInnerContainer .Black{background-color:var(--emfe-w-color-black, #000000)}.ListGame .GameInnerContainer .Green{background-color:#56A80A}.ListGame .GameInnerContainer .White{background-color:var(--emfe-w-color-white, #FFFFFF)}.ListGame .GameInnerContainer .Yellow{background-color:#eeca3d}.ListGame .GameInnerContainer .Gold{background-color:#866d0c}.ListGame .GameInnerContainer .Orange{background-color:#574708}.ListGame .GameInnerContainer .Purple{background-color:#330033}.ListGame .GameInnerContainer .Tie{background-color:var(--emfe-w-color-white, #FFFFFF);background-image:linear-gradient(135deg, var(--emfe-w-color-white, #FFFFFF) 25%, transparent 25%, transparent 50%, #212121 50%, var(--emfe-w-color-white, #FFFFFF) 75%, transparent 75%, var(--emfe-w-color-white, #FFFFFF))}.ListGame .GameInnerContainer .PlayersDisplay{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;padding:2px 10px;background:linear-gradient(to bottom, rgba(33, 33, 33, 0.9) 0%, rgba(33, 33, 33, 0.1) 100%);color:var(--emfe-w-color-white, #FFFFFF)}.ListGame .GameInnerContainer .PlayersDisplay .PlayersIcon{width:14px;height:14px;margin-right:4px}.ListGame .GameInnerContainer .PlayersDisplay .PlayersIcon svg{fill:var(--emfe-w-color-white, #FFFFFF);width:100%;height:100%}.ListGame .GameInnerContainer .ClosedGame{opacity:1;z-index:10;padding:8px 10px;color:var(--emfe-w-color-white, #FFFFFF);font-size:18px}.ListGame .GameInnerContainer .ClosedGame span{font-size:18px}.ListGame .GameInnerContainer .Players{display:inline-block;width:19px;height:19px}.FavIconContainer{position:absolute;top:10px;right:10px;cursor:pointer;z-index:16;width:15px;height:15px;opacity:0}.FavIconContainer.Favorited{opacity:1}.FavIconContainer svg path{fill:#fff}.Hovered .FavIconContainer{opacity:1}.GameNameBelow{color:var(--emfe-w-color-white, #FFFFFF);position:relative;bottom:-5px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";
1100
+
1101
+ const CasinoGameThumbView = class {
1102
+ constructor(hostRef) {
1103
+ registerInstance(this, hostRef);
1104
+ this.toggleFavoriteCasinoGameEvent = createEvent(this, "toggleCasinoGameFavorite", 7);
1105
+ /**
1106
+ * Widget Setting, Game language
1107
+ */
1108
+ this.language = 'en';
1109
+ /**
1110
+ * Widget Setting, Client custom styling via string
1111
+ */
1112
+ this.clientStyling = '';
1113
+ /**
1114
+ * Widget Setting, Client custom styling via url content
1115
+ */
1116
+ this.clientStylingUrl = '';
1117
+ /**
1118
+ * Widget Setting, show game in a frame when user clicked 'start'
1119
+ */
1120
+ this.integratedGameframeMobile = false;
1121
+ /**
1122
+ * Widget Setting, show game in a frame when user clicked 'start', Open game aframe,
1123
+ * gamepageModalurl value should be set
1124
+ */
1125
+ this.integratedGameframeDesktop = false;
1126
+ /**
1127
+ * Widget Setting, Load game details when set it as true, default value: false
1128
+ * When loadDetails is true and type=='live-casino-tables',
1129
+ * Load gameDetails by endpoint/vendor/gameId if livelobbyEndpoint is null
1130
+ */
1131
+ this.loadDetails = false;
1132
+ /**
1133
+ * Widget Setting, showRoundBoard, default value: false
1134
+ */
1135
+ this.showRoundBoard = false;
1136
+ /**
1137
+ * Game Property, default ''
1138
+ */
1139
+ this.gameCategory = '';
1140
+ /**
1141
+ * Game Property, Game lunch platform
1142
+ */
1143
+ this.platform = 'PC';
1144
+ this.thumbnailLoaded = false;
1145
+ this.containerClassWhenDetailChange = '';
1146
+ this.isUserLoggedIn = false;
1147
+ this.limitStylingAppends = false;
1148
+ //customize style setting
1149
+ this.setClientStyling = () => {
1150
+ let sheet = document.createElement('style');
1151
+ sheet.innerHTML = this.clientStyling;
1152
+ this.stylingContainer.prepend(sheet);
1153
+ };
1154
+ //customize style setting
1155
+ this.setClientStylingURL = () => {
1156
+ let url = new URL(this.clientStylingUrl);
1157
+ let cssFile = document.createElement('style');
1158
+ fetch(url.href)
1159
+ .then((res) => res.text())
1160
+ .then((data) => {
1161
+ cssFile.innerHTML = data;
1162
+ setTimeout(() => {
1163
+ this.stylingContainer.prepend(cssFile);
1164
+ }, 1);
1165
+ })
1166
+ .catch((err) => {
1167
+ console.error('error ', err);
1168
+ });
1169
+ };
1170
+ this.getGameCategoryType = () => {
1171
+ if (this.isLiveCasino &&
1172
+ this.gameCategory &&
1173
+ this.getWidgetTypeByGameCategory(this.gameCategory)) {
1174
+ return `casino-extrainfo-${this.getWidgetTypeByGameCategory(this.gameCategory).toLowerCase()}`;
1175
+ }
1176
+ return `casino-normal-game-thumbnail`;
1177
+ };
1178
+ this.getGameContainerClass = () => {
1179
+ let gameContainerClass = `GameContainer `;
1180
+ if (this.gameInfo) {
1181
+ if (this.gameInfo && this.gameInfo.details) {
1182
+ gameContainerClass += ' ListGame ';
1183
+ if (this.gameInfo.details.isOpen &&
1184
+ this.gameInfo.details.currentRouletteNumbers) {
1185
+ gameContainerClass += ' GameBackdrop ';
1186
+ }
1187
+ }
1188
+ }
1189
+ return gameContainerClass;
1190
+ };
1191
+ }
1192
+ onSessionChanged() {
1193
+ this.isUserLoggedIn = !!(this.session && this.userId);
1194
+ }
1195
+ onTableFullChanged(newVal, oldVal) {
1196
+ if (oldVal == undefined) {
1197
+ return;
1198
+ }
1199
+ this.containerClassWhenDetailChange =
1200
+ newVal && !oldVal ? 'PulsatingRedShadow' : 'PulsatingGreenShadow';
1201
+ }
1202
+ handleMouseOver(event) {
1203
+ this.hover = event.type === 'mouseenter';
1204
+ }
1205
+ gameFavoritedHandler(event) {
1206
+ let eventDetail = event.detail;
1207
+ this.gameInfo.isFavorite = eventDetail[this.gameId];
1208
+ this.gameInfo = Object.assign({}, this.gameInfo);
1209
+ }
1210
+ connectLiveHandler() {
1211
+ this.toggleConnect();
1212
+ }
1213
+ visibilityConnectHandler() {
1214
+ this.toggleVisibilityConnect();
1215
+ }
1216
+ gameDetailChangeHandler(e) {
1217
+ var _a, _b;
1218
+ let message = JSON.parse(e.data);
1219
+ if (message.needReconnect && this.liveLobbyConnection) {
1220
+ this.liveLobbyConnection.close();
1221
+ this.liveLobbyConnection = null;
1222
+ this.connectGameToLiveLobby();
1223
+ return;
1224
+ }
1225
+ if (!(message && message.InternalTableId == this.gameId)) {
1226
+ return;
1227
+ }
1228
+ let MessageType = message.MessageType;
1229
+ switch (MessageType) {
1230
+ case 'TableOpened':
1231
+ case 'TableClosed':
1232
+ this.gameInfo.details.isOpen = message.Open;
1233
+ break;
1234
+ case 'PlayersUpdated':
1235
+ this.gameInfo.details.numberOfPlayers = message.Players;
1236
+ break;
1237
+ case 'RouletteResultsUpdated':
1238
+ this.gameInfo.details.currentRouletteNumbers = message.Results;
1239
+ break;
1240
+ case 'DoubleBallRouletteResultsUpdated':
1241
+ this.gameInfo.details.currentDoubleBallRouletteNumbers =
1242
+ message.Results;
1243
+ break;
1244
+ case 'SeatsUpdated':
1245
+ this.gameInfo.details.currentOccupiedSeats = message.Seats;
1246
+ break;
1247
+ case 'DealerChanged':
1248
+ this.gameInfo.details.dealer = message.Dealer;
1249
+ break;
1250
+ case 'BaccaratResultsUpdated':
1251
+ if (this.showRoundBoard) {
1252
+ const Results = message.Results;
1253
+ this.gameInfo.details.results = [];
1254
+ Results.forEach((item) => {
1255
+ this.gameInfo.details.results.push(convertGicBaccaratUpdateItem(item));
1256
+ });
1257
+ (_a = this.extraInfoRef) === null || _a === void 0 ? void 0 : _a.onBaccaratResultChanged(this.gameInfo.details.results);
1258
+ }
1259
+ break;
1260
+ }
1261
+ this.resetLiveProperties();
1262
+ (_b = this.extraInfoRef) === null || _b === void 0 ? void 0 : _b.onGameDetailUpdated(this.gameInfo.details);
1263
+ window.postMessage({ messageType: MessageType, value: e.data });
1264
+ }
1265
+ messageHandler(e) {
1266
+ if (e.data.type === `AddFavoriteThumbnail_${this.gameId}` &&
1267
+ !this.showFavoredCategory) {
1268
+ this.gameInfo.isFavorite = true;
1269
+ }
1270
+ if (e.data.type === `RemoveFavoriteThumbnail_${this.gameId}` &&
1271
+ !this.showFavoredCategory) {
1272
+ this.gameInfo.isFavorite = false;
1273
+ }
1274
+ if (e.data.type === 'UserSessionID') {
1275
+ this.isUserLoggedIn = true;
1276
+ this.session = e.data.session;
1277
+ this.userId = e.data.userID;
1278
+ }
1279
+ }
1280
+ resetLiveProperties() {
1281
+ var _a, _b;
1282
+ const details = this.gameInfo.details;
1283
+ if (this.isBlackJack(this.gameCategory.toLowerCase())) {
1284
+ this.isTableFull =
1285
+ details.totalSeats == ((_a = details.currentOccupiedSeats) === null || _a === void 0 ? void 0 : _a.length);
1286
+ }
1287
+ else if (this.isBaccarat(this.gameCategory.toLowerCase()) &&
1288
+ ((_b = details.baccaratResults) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1289
+ this.gameInfo.details.results = [];
1290
+ details.baccaratResults.forEach((item) => {
1291
+ this.gameInfo.details.results.push(convertGicBaccaratUpdateItem(item));
1292
+ });
1293
+ delete details.baccaratResults;
1294
+ }
1295
+ }
1296
+ isBlackJack(gameCategory) {
1297
+ return gameCategory.toLowerCase() === GAME_CATEGORY.BLACKJACK;
1298
+ }
1299
+ isBaccarat(gameCategory) {
1300
+ return gameCategory.toLowerCase() === GAME_CATEGORY.BACCARAT;
1301
+ }
1302
+ /**
1303
+ * Calculate component properties by game info,
1304
+ * eg: isLiveCasino, gameInfo, isTableFull
1305
+ */
1306
+ initCtrlProperties() {
1307
+ var _a;
1308
+ if (this.isLiveCasino && ((_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.details)) {
1309
+ this.resetLiveProperties();
1310
+ }
1311
+ this.gameInfo = Object.assign({}, this.gameInfo);
1312
+ this.triggerExtraInfoLoad();
1313
+ if (this.isLiveCasino && this.connectLive === 'connect') {
1314
+ this.connectGameToLiveLobby();
1315
+ }
1316
+ }
1317
+ /**
1318
+ * Parse game info by game info api response
1319
+ * @param data
1320
+ */
1321
+ parseGameResponse(data) {
1322
+ if (data.length == 1) {
1323
+ this.gameInfo = data[0];
1324
+ if (this.isLiveCasino) {
1325
+ if (!this.gameInfo.details) {
1326
+ this.loadGameDetailInfo();
1327
+ }
1328
+ else {
1329
+ this.parseGameDetailsResponse();
1330
+ }
1331
+ }
1332
+ else {
1333
+ this.initCtrlProperties();
1334
+ }
1335
+ }
1336
+ }
1337
+ /**
1338
+ * Parse game detail info, set it to game info
1339
+ */
1340
+ parseGameDetailsResponse() {
1341
+ this.initCtrlProperties();
1342
+ }
1343
+ connectGameToLiveLobby() {
1344
+ if (EventSource && !this.liveLobbyConnection) {
1345
+ const updateUrl = `${this.endpoint}/v1/encoder/lobby/updates/${this.gameInfo.vendor.name}/${this.gameInfo.id}`;
1346
+ this.liveLobbyConnection = new eventsource.EventSourcePolyfill(updateUrl);
1347
+ this.liveLobbyConnection.addEventListener('message', (evt) => {
1348
+ this.gameDetailChangeHandler(evt);
1349
+ });
1350
+ }
1351
+ }
1352
+ disconnectGameFromLiveLobby() {
1353
+ if (this.liveLobbyConnection) {
1354
+ this.liveLobbyConnection.removeEventListener('message');
1355
+ this.liveLobbyConnection.close();
1356
+ this.liveLobbyConnection = undefined;
1357
+ }
1358
+ }
1359
+ toggleConnect() {
1360
+ if (!this.isLiveCasino) {
1361
+ return;
1362
+ }
1363
+ if (this.connectLive === 'disconnect') {
1364
+ this.disconnectGameFromLiveLobby();
1365
+ }
1366
+ else if (this.connectLive === 'connect') {
1367
+ this.connectGameToLiveLobby();
1368
+ }
1369
+ }
1370
+ toggleVisibilityConnect() {
1371
+ if (!this.isLiveCasino) {
1372
+ return;
1373
+ }
1374
+ if (this.visibilityConnect === 'disconnect') {
1375
+ this.disconnectGameFromLiveLobby();
1376
+ }
1377
+ else if (this.visibilityConnect === 'connect' &&
1378
+ this.connectLive === 'connect') {
1379
+ this.connectGameToLiveLobby();
1380
+ }
1381
+ }
1382
+ /**
1383
+ * Get game base info from game api(casino/games/{id})
1384
+ * @private
1385
+ */
1386
+ loadGameById() {
1387
+ let url = `${this.endpoint}/v1/casino/games/${this.gameId}?expand=vendor&platform=${this.platform}&language=${this.language}`;
1388
+ fetch(url)
1389
+ .then((res) => res.json())
1390
+ .then((data) => this.parseGameResponse(data))
1391
+ .catch((err) => {
1392
+ console.error(err);
1393
+ });
1394
+ }
1395
+ /*
1396
+ * Load game info when widget property 'livelobbyEndpoint' set
1397
+ * @private
1398
+ */
1399
+ loadGameInfoByLobbyEndpoint() {
1400
+ let url = new URL(`${this.livelobbyEndpoint.split('?')[0]}`);
1401
+ url.searchParams.append('expand', 'vendor');
1402
+ url.searchParams.append('platform', this.platform);
1403
+ url.searchParams.append('language', this.language);
1404
+ fetch(url.toString())
1405
+ .then((res) => res.json())
1406
+ .then((data) => this.parseGameResponse(data))
1407
+ .catch((error) => console.error(error));
1408
+ }
1409
+ /*
1410
+ * load game info when widget property 'livelobbyEndpoint' setted
1411
+ * @private
1412
+ */
1413
+ loadGameDetailInfo() {
1414
+ let url = new URL(`${this.endpoint}/v1/lobby/tables/${this.gameId}`);
1415
+ url.searchParams.append('platform', this.platform);
1416
+ url.searchParams.append('language', this.language);
1417
+ fetch(url.toString())
1418
+ .then((res) => res.json())
1419
+ .then((data) => {
1420
+ if (!(data === null || data === void 0 ? void 0 : data.category)) {
1421
+ return;
1422
+ }
1423
+ this.gameInfo.details = data;
1424
+ this.parseGameDetailsResponse();
1425
+ })
1426
+ .catch((err) => {
1427
+ console.error(err);
1428
+ setTimeout(() => this.loadGameDetailInfo(), 1000);
1429
+ });
1430
+ }
1431
+ /**
1432
+ * Toggle game favorite property
1433
+ * @param gameId
1434
+ * @private
1435
+ */
1436
+ toggleFavoriteGame(gameId) {
1437
+ let triggerFactor = 'thumbnail';
1438
+ if (this.gameInfo.isFavorite) {
1439
+ window.postMessage({ type: 'SetUnfavoredGame', gameId, triggerFactor }, window.location.href);
1440
+ }
1441
+ else {
1442
+ window.postMessage({ type: 'SetFavoredGame', gameId, triggerFactor }, window.location.href);
1443
+ }
1444
+ this.toggleFavoriteCasinoGameEvent.emit(gameId);
1445
+ }
1446
+ /**
1447
+ * Generate gameInfo obj by props
1448
+ * @private
1449
+ */
1450
+ generateGameInfoByProps() {
1451
+ return {
1452
+ id: this.gameId,
1453
+ name: this.gameName,
1454
+ subVendor: this.subVendor,
1455
+ hasFunMode: this.hasFunMode,
1456
+ hasAnonymousFunMode: this.hasAnonymousFunMode,
1457
+ thumbnail: this.thumbnail,
1458
+ cellSize: this.cellSize,
1459
+ gameTag: this.gameTag,
1460
+ vendor: { href: '', name: this.gameVendor },
1461
+ isFavorite: this.isFavorite,
1462
+ isNew: this.isNew,
1463
+ type: this.type,
1464
+ liveCasinoCategory: this.gameCategory || '',
1465
+ };
1466
+ }
1467
+ triggerExtraInfoLoad() {
1468
+ var _a, _b;
1469
+ //Init this.extraInfoRef, prepare for data loader, this.gameInfo did not inited might
1470
+ this.extraInfoRef =
1471
+ this.extraInfoRef ||
1472
+ ((_a = this.extraInfoSlotRef) === null || _a === void 0 ? void 0 : _a.querySelector(this.getGameCategoryType()));
1473
+ (_b = this.extraInfoRef) === null || _b === void 0 ? void 0 : _b.onGameLoaded(this.gameInfo);
1474
+ window.postMessage({
1475
+ type: 'casinoGameLoaded',
1476
+ gameInfo: this.gameInfo,
1477
+ });
1478
+ }
1479
+ componentDidRender() {
1480
+ // start custom styling area
1481
+ if (!this.limitStylingAppends && this.stylingContainer) {
1482
+ if (this.clientStyling)
1483
+ this.setClientStyling();
1484
+ if (this.clientStylingUrl)
1485
+ this.setClientStylingURL();
1486
+ this.limitStylingAppends = true;
1487
+ }
1488
+ // end custom styling area 500)
1489
+ if (this.gameInfo) {
1490
+ this.triggerExtraInfoLoad();
1491
+ }
1492
+ }
1493
+ componentDidLoad() {
1494
+ window.addEventListener('message', this.messageHandler);
1495
+ }
1496
+ componentWillLoad() {
1497
+ this.isLiveCasino = this.type == GAME_TYPE.LIVE_CASINO;
1498
+ this.extraInfoWidget = this.getGameCategoryType();
1499
+ this.isUserLoggedIn = !!(this.session && this.userId);
1500
+ if (this.isLiveCasino && this.livelobbyEndpoint) {
1501
+ this.loadGameInfoByLobbyEndpoint();
1502
+ return;
1503
+ }
1504
+ //generate gameInfo obj by props
1505
+ if (this.thumbnail) {
1506
+ this.gameInfo = this.generateGameInfoByProps();
1507
+ // loadLiveDetails if game is live casino
1508
+ if (this.isLiveCasino &&
1509
+ this.endpoint &&
1510
+ this.loadDetails &&
1511
+ this.gameId) {
1512
+ this.loadGameDetailInfo();
1513
+ }
1514
+ return;
1515
+ }
1516
+ //fetch data from api if no game properties set except gameId
1517
+ if (this.gameId && this.endpoint) {
1518
+ this.loadGameById();
1519
+ }
1520
+ }
1521
+ disconnectedCallback() {
1522
+ if (this.liveLobbyConnection) {
1523
+ this.liveLobbyConnection.removeEventListener('message', this.gameDetailChangeHandler);
1524
+ }
1525
+ window.removeEventListener('message', this.messageHandler);
1526
+ }
1527
+ // end custom styling area
1528
+ getWidgetTypeByGameCategory(gameCategory) {
1529
+ return WIDGETTYPE_GAMECATEGORY[gameCategory.toLowerCase()];
1530
+ }
1531
+ getGameOverlayProps() {
1532
+ var _a, _b;
1533
+ return {
1534
+ gameName: this.gameInfo.name,
1535
+ gameId: this.gameInfo.gameId,
1536
+ gameVendor: this.gameVendor || ((_b = (_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.vendor) === null || _b === void 0 ? void 0 : _b.name),
1537
+ hasFunMode: this.gameInfo.hasFunMode,
1538
+ language: this.language,
1539
+ integratedGameframeMobile: this.integratedGameframeMobile,
1540
+ integratedGameframeDesktop: this.integratedGameframeDesktop,
1541
+ gamepageModalurl: this.gamepageModalurl,
1542
+ };
1543
+ }
1544
+ render() {
1545
+ var _a, _b;
1546
+ if (!this.gameInfo) {
1547
+ return (h("div", { class: "GameInnerContainer", part: "GameInnerContainer", slot: "Game-Inner" }, h("img", { src: this.thumbnail, alt: "", loading: "lazy", part: "GameContainer", class: "GameContainer", onLoad: () => (this.thumbnailLoaded = true) })));
1548
+ }
1549
+ const gameOverlayProps = this.getGameOverlayProps();
1550
+ const gameThumbnail = ((_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.thumbnail) || ((_b = this.gameInfo) === null || _b === void 0 ? void 0 : _b.defaultThumbnail);
1551
+ const gameContainerClass = this.getGameContainerClass();
1552
+ const gameThumbnailClass = `GameBg ${this.cellSize ? 'GameBg-' + this.cellSize : ''}
1553
+ ${this.hover ? ' GameContainerHovered' : ''} ${this.thumbnailLoaded ? ' Loaded' : ''}`;
1554
+ return (h("div", { class: `${gameContainerClass} ${this.containerClassWhenDetailChange}`, part: `${gameContainerClass} ${this.containerClassWhenDetailChange}`, ref: (el) => (this.stylingContainer = el), "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrl }, h("div", { class: `GameInnerContainer ${this.hover ? 'Hovered' : ''}`, part: `GameInnerContainer ${this.hover ? 'Hovered' : ''}` }, h("img", { src: gameThumbnail, alt: "Game Thumbnail ", loading: "lazy", part: gameThumbnailClass, class: gameThumbnailClass, onLoad: () => (this.thumbnailLoaded = true) }), this.isUserLoggedIn && (h("div", { class: `FavIconContainer ${this.gameInfo.isFavorite ? 'Favorited' : ''}`, part: `FavIconContainer ${this.gameInfo.isFavorite ? 'Favorited' : ''}`, onClick: () => this.toggleFavoriteGame(this.gameId) }, this.gameInfo.isFavorite ? (h("slot", { name: "fav-icon" }, h("span", { class: "FavoredIcon", part: "FavoredIcon", innerHTML: Fav }))) : (h("slot", { name: "UnFavIcon" }, !isMobile(window.navigator.userAgent) && (h("span", { class: "UnfavoredIcon", part: "UnfavoredIcon", innerHTML: UnFavSvg })))))), h("slot", { name: "game-overlay" }, h("casino-game-thumbnail-overlay", Object.assign({ language: this.language }, gameOverlayProps))), h("slot", { name: "extra-info", ref: (el) => (this.extraInfoSlotRef = el) }, h(this.extraInfoWidget, { language: this.language, "show-round-board": this.showRoundBoard })), h("slot", { name: "game-property-slot" })), this.showGameName && (h("slot", { name: "game-name" }, h("p", { class: "GameNameBelow", part: "GameNameBelow", title: gameOverlayProps.gameName }, gameOverlayProps.gameName)))));
1555
+ }
1556
+ static get assetsDirs() { return ["static"]; }
1557
+ static get watchers() { return {
1558
+ "session": ["onSessionChanged"],
1559
+ "userId": ["onSessionChanged"],
1560
+ "isTableFull": ["onTableFullChanged"],
1561
+ "connectLive": ["connectLiveHandler"],
1562
+ "visibilityConnect": ["visibilityConnectHandler"]
1563
+ }; }
1564
+ };
1565
+ CasinoGameThumbView.style = casinoGameThumbViewCss;
1566
+
1567
+ const casinoGameThumbnailOverlayCss = ":host{display:block}.GameInfoWrapper{display:none;position:absolute;width:100%;height:100%;top:0;right:0;bottom:0;left:0;background:rgba(0, 0, 0, 0.65);z-index:15}.GameInfoWrapper .GameInfo{display:flex;width:100%;height:100%;flex-direction:column;align-items:center;justify-content:center}.GameInfoWrapper .GameInfoName{color:white;margin-bottom:10px;text-align:center;font-size:14px}.GameInfoWrapper .GameInfoBtn{appearance:none;padding:6px;background:var(--emfe-w-color-primary, #D0046C);color:var(--emfe-w-color-primary-50, #FBECF4);font-size:16px;border:2px solid var(--emfe-w-color-primary-600, #99034F);border-radius:5px;cursor:pointer;transition:border 150ms ease-in-out}.GameInfoWrapper .GameInfoBtn:hover{border:2px solid var(--emfe-w-color-primary-100, #F1BED9)}.GameInfoVendor{display:block;position:absolute;bottom:8px;right:8px;color:white;font-size:12px;font-weight:normal}.GameInfoWrapper:hover{display:block !important}";
1568
+
1569
+ const CasinoGameThumbnailOverlay = class {
1570
+ constructor(hostRef) {
1571
+ registerInstance(this, hostRef);
1572
+ this.playClicked = createEvent(this, "playCasinoGame", 7);
1573
+ /**
1574
+ * Widget Setting, show game in a frame when user clicked 'start', default: false
1575
+ */
1576
+ this.integratedGameframeMobile = false;
1577
+ /**
1578
+ * Widget Setting, show game in a frame when user clicked 'start', default: false
1579
+ * Open game in a frame, gamepageModalurl value should be set
1580
+ */
1581
+ this.integratedGameframeDesktop = false;
1582
+ /**
1583
+ * Language
1584
+ */
1585
+ this.language = 'en';
1586
+ this.userAgent = window.navigator.userAgent;
1587
+ }
1588
+ onPlayNowClicked() {
1589
+ this.playClicked.emit(this.gameId);
1590
+ let modalEventData = {
1591
+ gameId: this.gameId,
1592
+ isMobile: isMobile(this.userAgent),
1593
+ };
1594
+ let isFrameMode = this.integratedGameframeMobile || this.integratedGameframeDesktop;
1595
+ window.postMessage({
1596
+ type: isFrameMode ? 'OpenGameFrame' : 'ShowGameModal',
1597
+ eventData: isFrameMode
1598
+ ? Object.assign(Object.assign({}, modalEventData), { gamefunmode: this.hasFunMode, source: 'GameThumbnail', identifier: 'Lobby' }) : modalEventData,
1599
+ }, window.location.href);
1600
+ }
1601
+ render() {
1602
+ return (h("div", { class: "GameInfoWrapper", part: "GameInfoWrapper" }, h("div", { class: "GameInfo ", part: "GameInfo " }, h("p", { class: "GameInfoName", part: "GameInfoName", title: this.gameName }, ' ', this.gameName, ' '), h("button", { class: "GameInfoBtn", part: "GameInfoBtn", onClick: () => this.onPlayNowClicked() }, translate('playNow', this.language))), h("slot", { name: "vendor-name" }, h("span", { class: "GameInfoVendor", part: "GameInfoVendor" }, this.gameVendor))));
1603
+ }
1604
+ };
1605
+ CasinoGameThumbnailOverlay.style = casinoGameThumbnailOverlayCss;
1606
+
1607
+ export { CasinoGameThumbView as casino_game_thumb_view, CasinoGameThumbnailOverlay as casino_game_thumbnail_overlay };