@everymatrix/casino-game-thumb-view 0.0.2-9.1 → 1.0.69

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 (132) hide show
  1. package/dist/casino-game-thumb-view/casino-game-thumb-view.esm.js +1 -1
  2. package/dist/casino-game-thumb-view/p-2207062c.entry.js +1 -0
  3. package/dist/casino-game-thumb-view/p-39684b4a.entry.js +1 -0
  4. package/dist/casino-game-thumb-view/p-59ceeaaa.js +1 -0
  5. package/dist/casino-game-thumb-view/p-af0284b5.entry.js +1 -0
  6. package/dist/casino-game-thumb-view/p-b73b7a18.entry.js +1 -0
  7. package/dist/casino-game-thumb-view/p-bd016895.entry.js +7 -0
  8. package/dist/casino-game-thumb-view/p-d2580653.js +8 -0
  9. package/dist/casino-game-thumb-view/p-d48c3566.entry.js +1 -0
  10. package/dist/casino-game-thumb-view/p-e1255160.js +1 -0
  11. package/dist/casino-game-thumb-view/p-eef6f908.js +2 -0
  12. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  13. package/dist/cjs/casino-extrainfo-baccarat.cjs.entry.js +327 -322
  14. package/dist/cjs/casino-extrainfo-blackjack.cjs.entry.js +45 -45
  15. package/dist/cjs/casino-extrainfo-roulette.cjs.entry.js +35 -33
  16. package/dist/cjs/casino-game-thumb-view.cjs.js +17 -11
  17. package/dist/cjs/casino-game-thumb-view_2.cjs.entry.js +469 -511
  18. package/dist/cjs/casino-game-thumbnail-betlimit_2.cjs.entry.js +259 -249
  19. package/dist/cjs/casino-normal-game-thumbnail.cjs.entry.js +14 -12
  20. package/dist/cjs/game-thumbnail-5a34c727.js +78 -0
  21. package/dist/cjs/index-48d13981.js +1709 -0
  22. package/dist/cjs/loader.cjs.js +7 -13
  23. package/dist/cjs/locale.utils-53bf703a.js +132 -0
  24. package/dist/cjs/{utils-a0afc0a9.js → utils-c4ed3adc.js} +407 -404
  25. package/dist/collection/collection-manifest.json +10 -10
  26. package/dist/collection/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.js +251 -230
  27. package/dist/collection/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.js +136 -114
  28. package/dist/collection/components/casino-extrainfo-roulette/casino-extrainfo-roulette.js +126 -118
  29. package/dist/collection/components/casino-game-thumb-view/casino-game-thumb-view.css +1 -1
  30. package/dist/collection/components/casino-game-thumb-view/casino-game-thumb-view.js +1023 -1020
  31. package/dist/collection/components/casino-game-thumb-view/index.js +1 -0
  32. package/dist/collection/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.js +78 -80
  33. package/dist/collection/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.js +154 -148
  34. package/dist/collection/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.js +201 -205
  35. package/dist/collection/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.js +71 -58
  36. package/dist/collection/constants/game-thumbnail.js +66 -66
  37. package/dist/collection/models/casino-game-thumb-view.js +6 -6
  38. package/dist/collection/models/currency-symbols.js +170 -170
  39. package/dist/collection/utils/baccarat-board-svg.js +225 -225
  40. package/dist/collection/utils/locale.utils.js +123 -123
  41. package/dist/collection/utils/utils.js +41 -41
  42. package/dist/esm/app-globals-0f993ce5.js +3 -0
  43. package/dist/esm/casino-extrainfo-baccarat.entry.js +327 -322
  44. package/dist/esm/casino-extrainfo-blackjack.entry.js +45 -45
  45. package/dist/esm/casino-extrainfo-roulette.entry.js +35 -33
  46. package/dist/esm/casino-game-thumb-view.js +14 -11
  47. package/dist/esm/casino-game-thumb-view_2.entry.js +469 -511
  48. package/dist/esm/casino-game-thumbnail-betlimit_2.entry.js +259 -249
  49. package/dist/esm/casino-normal-game-thumbnail.entry.js +14 -12
  50. package/dist/esm/game-thumbnail-035e97e2.js +72 -0
  51. package/dist/esm/index-8c9a8030.js +1681 -0
  52. package/dist/esm/loader.js +7 -13
  53. package/dist/esm/locale.utils-0c514ca8.js +130 -0
  54. package/dist/{components/utils.js → esm/utils-090ac2e9.js} +407 -404
  55. package/dist/stencil.config.dev.js +17 -0
  56. package/dist/stencil.config.js +12 -35
  57. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/casino-game-thumb-view/.stencil/packages/stencil/casino-game-thumb-view/stencil.config.d.ts +2 -0
  58. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/casino-game-thumb-view/.stencil/packages/stencil/casino-game-thumb-view/stencil.config.dev.d.ts +2 -0
  59. package/dist/types/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.d.ts +36 -36
  60. package/dist/types/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.d.ts +33 -33
  61. package/dist/types/components/casino-extrainfo-roulette/casino-extrainfo-roulette.d.ts +18 -18
  62. package/dist/types/components/casino-game-thumb-view/casino-game-thumb-view.d.ts +213 -213
  63. package/dist/types/components/casino-game-thumb-view/index.d.ts +1 -0
  64. package/dist/types/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.d.ts +14 -14
  65. package/dist/types/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.d.ts +13 -13
  66. package/dist/types/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.d.ts +28 -27
  67. package/dist/types/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.d.ts +4 -4
  68. package/dist/types/components.d.ts +55 -24
  69. package/dist/types/constants/game-thumbnail.d.ts +66 -66
  70. package/dist/types/models/casino-game-thumb-view.d.ts +107 -107
  71. package/dist/types/models/currency-symbols.d.ts +170 -170
  72. package/dist/types/stencil-public-runtime.d.ts +142 -33
  73. package/dist/types/utils/baccarat-board-svg.d.ts +29 -29
  74. package/loader/cdn.js +1 -3
  75. package/loader/index.cjs.js +1 -3
  76. package/loader/index.d.ts +13 -1
  77. package/loader/index.es2017.js +1 -3
  78. package/loader/index.js +1 -3
  79. package/loader/package.json +1 -0
  80. package/package.json +8 -8
  81. package/dist/assets/baccarat.svg +0 -43
  82. package/dist/assets/fav.svg +0 -9
  83. package/dist/assets/favorite.svg +0 -12
  84. package/dist/assets/seat.svg +0 -6
  85. package/dist/assets/unfav.svg +0 -20
  86. package/dist/casino-game-thumb-view/p-0bd6266b.entry.js +0 -1
  87. package/dist/casino-game-thumb-view/p-1bbf4b70.entry.js +0 -1
  88. package/dist/casino-game-thumb-view/p-2b51ea79.js +0 -1
  89. package/dist/casino-game-thumb-view/p-46dbb1cb.js +0 -1
  90. package/dist/casino-game-thumb-view/p-58134a43.entry.js +0 -7
  91. package/dist/casino-game-thumb-view/p-6a6b2a78.js +0 -8
  92. package/dist/casino-game-thumb-view/p-b153f943.entry.js +0 -1
  93. package/dist/casino-game-thumb-view/p-d961aec4.entry.js +0 -1
  94. package/dist/casino-game-thumb-view/p-eb23569d.entry.js +0 -1
  95. package/dist/cjs/game-thumbnail-31d518f0.js +0 -78
  96. package/dist/cjs/index-65a1d768.js +0 -1796
  97. package/dist/cjs/locale.utils-09067b6b.js +0 -132
  98. package/dist/components/casino-extrainfo-baccarat.d.ts +0 -11
  99. package/dist/components/casino-extrainfo-baccarat.js +0 -400
  100. package/dist/components/casino-extrainfo-blackjack.d.ts +0 -11
  101. package/dist/components/casino-extrainfo-blackjack.js +0 -92
  102. package/dist/components/casino-extrainfo-roulette.d.ts +0 -11
  103. package/dist/components/casino-extrainfo-roulette.js +0 -77
  104. package/dist/components/casino-game-thumb-view.d.ts +0 -11
  105. package/dist/components/casino-game-thumb-view.js +0 -1618
  106. package/dist/components/casino-game-thumbnail-betlimit.d.ts +0 -11
  107. package/dist/components/casino-game-thumbnail-betlimit.js +0 -6
  108. package/dist/components/casino-game-thumbnail-betlimit2.js +0 -227
  109. package/dist/components/casino-game-thumbnail-extrainfo.d.ts +0 -11
  110. package/dist/components/casino-game-thumbnail-extrainfo.js +0 -6
  111. package/dist/components/casino-game-thumbnail-extrainfo2.js +0 -93
  112. package/dist/components/casino-game-thumbnail-overlay.d.ts +0 -11
  113. package/dist/components/casino-game-thumbnail-overlay.js +0 -6
  114. package/dist/components/casino-game-thumbnail-overlay2.js +0 -68
  115. package/dist/components/casino-normal-game-thumbnail.d.ts +0 -11
  116. package/dist/components/casino-normal-game-thumbnail.js +0 -52
  117. package/dist/components/game-thumbnail.js +0 -72
  118. package/dist/components/index.d.ts +0 -26
  119. package/dist/components/index.js +0 -1
  120. package/dist/components/locale.utils.js +0 -130
  121. package/dist/esm/game-thumbnail-0a56ee03.js +0 -72
  122. package/dist/esm/index-1e44dd9f.js +0 -1769
  123. package/dist/esm/locale.utils-1c69bea3.js +0 -130
  124. package/dist/esm/polyfills/core-js.js +0 -11
  125. package/dist/esm/polyfills/css-shim.js +0 -1
  126. package/dist/esm/polyfills/dom.js +0 -79
  127. package/dist/esm/polyfills/es5-html-element.js +0 -1
  128. package/dist/esm/polyfills/index.js +0 -34
  129. package/dist/esm/polyfills/system.js +0 -6
  130. package/dist/esm/utils-e9314132.js +0 -5739
  131. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/casino-game-thumb-view/.stencil/packages/casino-game-thumb-view/stencil.config.d.ts +0 -2
  132. /package/dist/casino-game-thumb-view/{p-2d5f59fe.js → p-2d02adb1.js} +0 -0
@@ -1,1618 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { c as convertGicBaccaratUpdateItem, i as isMobile } from './utils.js';
3
- import { G as GAME_CATEGORY, c as GAME_TYPE, a as WIDGETTYPE_GAMECATEGORY } from './game-thumbnail.js';
4
- import { d as defineCustomElement$2 } from './casino-game-thumbnail-overlay2.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$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
1102
- constructor() {
1103
- super();
1104
- this.__registerHost();
1105
- this.__attachShadow();
1106
- this.toggleFavoriteCasinoGameEvent = createEvent(this, "toggleCasinoGameFavorite", 7);
1107
- /**
1108
- * Widget Setting, Game language
1109
- */
1110
- this.language = 'en';
1111
- /**
1112
- * Widget Setting, Client custom styling via string
1113
- */
1114
- this.clientStyling = '';
1115
- /**
1116
- * Widget Setting, Client custom styling via url content
1117
- */
1118
- this.clientStylingUrl = '';
1119
- /**
1120
- * Widget Setting, show game in a frame when user clicked 'start'
1121
- */
1122
- this.integratedGameFrameMobile = false;
1123
- /**
1124
- * Widget Setting, show game in a frame when user clicked 'start', Open game aframe,
1125
- * gamepageModalUrl value should be set
1126
- */
1127
- this.integratedGameFrameDesktop = false;
1128
- /**
1129
- * Widget Setting, Load game details when set it as true, default value: false
1130
- * When loadDetails is true and type=='live-casino-tables',
1131
- * Load gameDetails by endpoint/vendor/gameId if livelobbyEndpoint is null
1132
- */
1133
- this.loadDetails = false;
1134
- /**
1135
- * Widget Setting, showRoundBoard, default value: false
1136
- */
1137
- this.showRoundBoard = false;
1138
- /**
1139
- * Game Property, default ''
1140
- */
1141
- this.gameCategory = '';
1142
- /**
1143
- * Game Property, Game lunch platform
1144
- */
1145
- this.platform = 'PC';
1146
- this.thumbnailLoaded = false;
1147
- this.containerClassWhenDetailChange = '';
1148
- this.isUserLoggedIn = false;
1149
- this.limitStylingAppends = false;
1150
- //customize style setting
1151
- this.setClientStyling = () => {
1152
- let sheet = document.createElement('style');
1153
- sheet.innerHTML = this.clientStyling;
1154
- this.stylingContainer.prepend(sheet);
1155
- };
1156
- //customize style setting
1157
- this.setClientStylingURL = () => {
1158
- let url = new URL(this.clientStylingUrl);
1159
- let cssFile = document.createElement('style');
1160
- fetch(url.href)
1161
- .then((res) => res.text())
1162
- .then((data) => {
1163
- cssFile.innerHTML = data;
1164
- setTimeout(() => {
1165
- this.stylingContainer.prepend(cssFile);
1166
- }, 1);
1167
- })
1168
- .catch((err) => {
1169
- console.error('error ', err);
1170
- });
1171
- };
1172
- this.getGameCategoryType = () => {
1173
- if (this.isLiveCasino && 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.connectGameToLiveLobby();
1222
- return;
1223
- }
1224
- if (!(message && message.InternalTableId == this.gameId)) {
1225
- return;
1226
- }
1227
- let MessageType = message.MessageType;
1228
- switch (MessageType) {
1229
- case 'TableOpened':
1230
- case 'TableClosed':
1231
- this.gameInfo.details.isOpen = message.Open;
1232
- break;
1233
- case 'PlayersUpdated':
1234
- this.gameInfo.details.numberOfPlayers = message.Players;
1235
- break;
1236
- case 'RouletteResultsUpdated':
1237
- this.gameInfo.details.currentRouletteNumbers = message.Results;
1238
- break;
1239
- case 'DoubleBallRouletteResultsUpdated':
1240
- this.gameInfo.details.currentDoubleBallRouletteNumbers =
1241
- message.Results;
1242
- break;
1243
- case 'SeatsUpdated':
1244
- this.gameInfo.details.currentOccupiedSeats = message.Seats;
1245
- break;
1246
- case 'DealerChanged':
1247
- this.gameInfo.details.dealer = message.Dealer;
1248
- break;
1249
- case 'BaccaratResultsUpdated':
1250
- if (this.showRoundBoard) {
1251
- const Results = message.Results;
1252
- this.gameInfo.details.results = [];
1253
- Results.forEach((item) => {
1254
- this.gameInfo.details.results.push(convertGicBaccaratUpdateItem(item));
1255
- });
1256
- (_a = this.extraInfoRef) === null || _a === void 0 ? void 0 : _a.onBaccaratResultChanged(this.gameInfo.details.results);
1257
- }
1258
- break;
1259
- }
1260
- this.resetLiveProperties();
1261
- (_b = this.extraInfoRef) === null || _b === void 0 ? void 0 : _b.onGameDetailUpdated(this.gameInfo.details);
1262
- window.postMessage({ messageType: MessageType, value: e.data });
1263
- }
1264
- messageHandler(e) {
1265
- if (e.data.type === `AddFavoriteThumbnail_${this.gameId}` &&
1266
- !this.showFavoredCategory) {
1267
- this.gameInfo.isFavorite = true;
1268
- }
1269
- if (e.data.type === `RemoveFavoriteThumbnail_${this.gameId}` &&
1270
- !this.showFavoredCategory) {
1271
- this.gameInfo.isFavorite = false;
1272
- }
1273
- if (e.data.type === 'UserSessionID') {
1274
- this.isUserLoggedIn = true;
1275
- this.session = e.data.session;
1276
- this.userId = e.data.userID;
1277
- }
1278
- }
1279
- resetLiveProperties() {
1280
- var _a, _b;
1281
- const details = this.gameInfo.details;
1282
- if (this.isBlackJack(this.gameCategory.toLowerCase())) {
1283
- this.isTableFull =
1284
- details.totalSeats == ((_a = details.currentOccupiedSeats) === null || _a === void 0 ? void 0 : _a.length);
1285
- }
1286
- else if (this.isBaccarat(this.gameCategory.toLowerCase()) &&
1287
- ((_b = details.baccaratResults) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1288
- this.gameInfo.details.results = [];
1289
- details.baccaratResults.forEach((item) => {
1290
- this.gameInfo.details.results.push(convertGicBaccaratUpdateItem(item));
1291
- });
1292
- delete details.baccaratResults;
1293
- }
1294
- }
1295
- isBlackJack(gameCategory) {
1296
- return gameCategory.toLowerCase() === GAME_CATEGORY.BLACKJACK;
1297
- }
1298
- isBaccarat(gameCategory) {
1299
- return gameCategory.toLowerCase() === GAME_CATEGORY.BACCARAT;
1300
- }
1301
- /**
1302
- * Calculate component properties by game info,
1303
- * eg: isLiveCasino, gameInfo, isTableFull
1304
- */
1305
- initCtrlProperties() {
1306
- var _a;
1307
- if (this.isLiveCasino && ((_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.details)) {
1308
- this.resetLiveProperties();
1309
- }
1310
- this.gameInfo = Object.assign({}, this.gameInfo);
1311
- this.triggerExtraInfoLoad();
1312
- }
1313
- /**
1314
- * Parse game info by game info api response
1315
- * @param data
1316
- */
1317
- parseGameResponse(data) {
1318
- if (data.length == 1) {
1319
- this.gameInfo = data[0];
1320
- if (this.isLiveCasino) {
1321
- if (!this.gameInfo.details) {
1322
- this.loadGameDetailInfo();
1323
- }
1324
- else {
1325
- this.parseGameDetailsResponse();
1326
- }
1327
- }
1328
- else {
1329
- this.initCtrlProperties();
1330
- }
1331
- }
1332
- }
1333
- /**
1334
- * Parse game detail info, set it to game info
1335
- */
1336
- parseGameDetailsResponse() {
1337
- this.initCtrlProperties();
1338
- }
1339
- connectGameToLiveLobby() {
1340
- if (EventSource && !this.liveLobbyConnection) {
1341
- const updateUrl = `${this.endpoint}/encoder/lobby/updates/${this.gameInfo.vendor.name}/${this.gameInfo.id}`;
1342
- this.liveLobbyConnection = new eventsource.EventSourcePolyfill(updateUrl);
1343
- this.liveLobbyConnection.addEventListener('message', (evt) => {
1344
- this.gameDetailChangeHandler(evt);
1345
- });
1346
- }
1347
- }
1348
- disconnectGameFromLiveLobby() {
1349
- if (this.liveLobbyConnection) {
1350
- this.liveLobbyConnection.removeEventListener('message');
1351
- this.liveLobbyConnection.close();
1352
- this.liveLobbyConnection = undefined;
1353
- }
1354
- }
1355
- toggleConnect() {
1356
- if (!this.isLiveCasino) {
1357
- return;
1358
- }
1359
- if (this.connectLive === 'disconnect') {
1360
- this.disconnectGameFromLiveLobby();
1361
- }
1362
- else if (this.connectLive === 'connect') {
1363
- this.connectGameToLiveLobby();
1364
- }
1365
- }
1366
- toggleVisibilityConnect() {
1367
- if (!this.isLiveCasino) {
1368
- return;
1369
- }
1370
- if (this.visibilityConnect === 'disconnect') {
1371
- this.disconnectGameFromLiveLobby();
1372
- }
1373
- else if (this.visibilityConnect === 'connect' &&
1374
- this.connectLive === 'connect') {
1375
- this.connectGameToLiveLobby();
1376
- }
1377
- }
1378
- /**
1379
- * Get game base info from game api(casino/games/{id})
1380
- * @private
1381
- */
1382
- loadGameById() {
1383
- let url = `${this.endpoint}/casino/games/${this.gameId}?expand=vendor&platform=${this.platform}&language=${this.language}`;
1384
- fetch(url)
1385
- .then((res) => res.json())
1386
- .then((data) => this.parseGameResponse(data))
1387
- .catch((err) => {
1388
- console.error(err);
1389
- });
1390
- }
1391
- /*
1392
- * Load game info when widget property 'livelobbyEndpoint' set
1393
- * @private
1394
- */
1395
- loadGameInfoByLobbyEndpoint() {
1396
- let url = new URL(`${this.livelobbyEndpoint.split('?')[0]}`);
1397
- url.searchParams.append('expand', 'vendor');
1398
- url.searchParams.append('platform', this.platform);
1399
- url.searchParams.append('language', this.language);
1400
- fetch(url.toString())
1401
- .then((res) => res.json())
1402
- .then((data) => this.parseGameResponse(data))
1403
- .catch((error) => console.error(error));
1404
- }
1405
- /*
1406
- * load game info when widget property 'livelobbyEndpoint' setted
1407
- * @private
1408
- */
1409
- loadGameDetailInfo() {
1410
- let url = new URL(`${this.endpoint}/lobby/tables/${this.gameId}`);
1411
- url.searchParams.append('platform', this.platform);
1412
- url.searchParams.append('language', this.language);
1413
- fetch(url.toString())
1414
- .then((res) => res.json())
1415
- .then((data) => {
1416
- if (!(data === null || data === void 0 ? void 0 : data.category)) {
1417
- return;
1418
- }
1419
- this.gameInfo.details = data;
1420
- this.parseGameDetailsResponse();
1421
- })
1422
- .catch((err) => {
1423
- console.error(err);
1424
- setTimeout(() => this.loadGameDetailInfo(), 1000);
1425
- });
1426
- }
1427
- /**
1428
- * Toggle game favorite property
1429
- * @param gameId
1430
- * @private
1431
- */
1432
- toggleFavoriteGame(gameId) {
1433
- let triggerFactor = 'thumbnail';
1434
- if (this.gameInfo.isFavorite) {
1435
- window.postMessage({ type: 'SetUnfavoredGame', gameId, triggerFactor }, window.location.href);
1436
- }
1437
- else {
1438
- window.postMessage({ type: 'SetFavoredGame', gameId, triggerFactor }, window.location.href);
1439
- }
1440
- this.toggleFavoriteCasinoGameEvent.emit(gameId);
1441
- }
1442
- /**
1443
- * Generate gameInfo obj by props
1444
- * @private
1445
- */
1446
- generateGameInfoByProps() {
1447
- return {
1448
- id: this.gameId,
1449
- name: this.gameName,
1450
- subVendor: this.subVendor,
1451
- hasFunMode: this.hasFunMode,
1452
- hasAnonymousFunMode: this.hasAnonymousFunMode,
1453
- thumbnail: this.thumbnail,
1454
- cellSize: this.cellSize,
1455
- gameTag: this.gameTag,
1456
- vendor: { href: '', name: this.gameVendor },
1457
- isFavorite: this.isFavorite,
1458
- isNew: this.isNew,
1459
- type: this.type,
1460
- liveCasinoCategory: this.gameCategory || '',
1461
- };
1462
- }
1463
- triggerExtraInfoLoad() {
1464
- var _a;
1465
- (_a = this.extraInfoRef) === null || _a === void 0 ? void 0 : _a.onGameLoaded(this.gameInfo);
1466
- window.postMessage({
1467
- type: 'casinoGameLoaded',
1468
- gameInfo: this.gameInfo,
1469
- });
1470
- }
1471
- componentDidRender() {
1472
- // start custom styling area
1473
- if (!this.limitStylingAppends && this.stylingContainer) {
1474
- if (this.clientStyling)
1475
- this.setClientStyling();
1476
- if (this.clientStylingUrl)
1477
- this.setClientStylingURL();
1478
- this.limitStylingAppends = true;
1479
- }
1480
- // end custom styling area 500)
1481
- if (this.gameInfo && this.extraInfoRef) {
1482
- this.triggerExtraInfoLoad();
1483
- }
1484
- }
1485
- componentDidLoad() {
1486
- var _a;
1487
- //Init this.extraInfoRef, prepare for data loader, this.gameInfo did not inited might
1488
- this.extraInfoRef = (_a = this.extraInfoSlotRef) === null || _a === void 0 ? void 0 : _a.querySelector(this.getGameCategoryType());
1489
- window.addEventListener('message', this.messageHandler);
1490
- }
1491
- componentWillLoad() {
1492
- this.isLiveCasino = this.type == GAME_TYPE.LIVE_CASINO;
1493
- this.extraInfoWidget = this.getGameCategoryType();
1494
- this.isUserLoggedIn = !!(this.session && this.userId);
1495
- if (this.isLiveCasino && this.livelobbyEndpoint) {
1496
- this.loadGameInfoByLobbyEndpoint();
1497
- return;
1498
- }
1499
- //generate gameInfo obj by props
1500
- if (this.thumbnail) {
1501
- this.gameInfo = this.generateGameInfoByProps();
1502
- // loadLiveDetails if game is live casino
1503
- if (this.isLiveCasino &&
1504
- this.endpoint &&
1505
- this.loadDetails &&
1506
- this.gameId) {
1507
- this.loadGameDetailInfo();
1508
- }
1509
- return;
1510
- }
1511
- //fetch data from api if no game properties set except gameId
1512
- if (this.gameId && this.endpoint) {
1513
- this.loadGameById();
1514
- }
1515
- }
1516
- disconnectedCallback() {
1517
- if (this.liveLobbyConnection) {
1518
- this.liveLobbyConnection.removeEventListener('message', this.gameDetailChangeHandler);
1519
- }
1520
- window.removeEventListener('message', this.messageHandler);
1521
- }
1522
- // end custom styling area
1523
- getWidgetTypeByGameCategory(gameCategory) {
1524
- return WIDGETTYPE_GAMECATEGORY[gameCategory.toLowerCase()];
1525
- }
1526
- getGameOverlayProps() {
1527
- var _a, _b;
1528
- return {
1529
- gameName: this.gameInfo.name,
1530
- gameId: this.gameInfo.gameId,
1531
- gameVendor: this.gameVendor || ((_b = (_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.vendor) === null || _b === void 0 ? void 0 : _b.name),
1532
- hasFunMode: this.gameInfo.hasFunMode,
1533
- language: this.language,
1534
- integratedGameFrameMobile: this.integratedGameFrameMobile,
1535
- integratedGameFrameDesktop: this.integratedGameFrameDesktop,
1536
- gamepageModalUrl: this.gamepageModalUrl,
1537
- };
1538
- }
1539
- render() {
1540
- var _a, _b;
1541
- if (!this.gameInfo) {
1542
- 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) })));
1543
- }
1544
- const gameOverlayProps = this.getGameOverlayProps();
1545
- const gameThumbnail = ((_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.thumbnail) || ((_b = this.gameInfo) === null || _b === void 0 ? void 0 : _b.defaultThumbnail);
1546
- const gameContainerClass = this.getGameContainerClass();
1547
- const gameThumbnailClass = `GameBg ${this.cellSize ? 'GameBg-' + this.cellSize : ''}
1548
- ${this.hover ? ' GameContainerHovered' : ''} ${this.thumbnailLoaded ? ' Loaded' : ''}`;
1549
- 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)))));
1550
- }
1551
- static get assetsDirs() { return ["static"]; }
1552
- static get watchers() { return {
1553
- "session": ["onSessionChanged"],
1554
- "userId": ["onSessionChanged"],
1555
- "isTableFull": ["onTableFullChanged"],
1556
- "connectLive": ["connectLiveHandler"],
1557
- "visibilityConnect": ["visibilityConnectHandler"]
1558
- }; }
1559
- static get style() { return casinoGameThumbViewCss; }
1560
- }, [1, "casino-game-thumb-view", {
1561
- "language": [1],
1562
- "endpoint": [1],
1563
- "userId": [8, "user-id"],
1564
- "showGameName": [4, "show-game-name"],
1565
- "session": [1],
1566
- "showFavoredCategory": [4, "show-favored-category"],
1567
- "clientStyling": [1, "client-styling"],
1568
- "clientStylingUrl": [1, "client-styling-url"],
1569
- "integratedGameFrameMobile": [4, "integrated-game-frame-mobile"],
1570
- "gamepageModalUrl": [1, "gamepage-modal-url"],
1571
- "integratedGameFrameDesktop": [4, "integrated-game-frame-desktop"],
1572
- "loadDetails": [4, "load-details"],
1573
- "showRoundBoard": [4, "show-round-board"],
1574
- "visibilityConnect": [1, "visibility-connect"],
1575
- "connectLive": [1, "connect-live"],
1576
- "gameCategory": [1, "game-category"],
1577
- "livelobbyEndpoint": [1, "livelobby-endpoint"],
1578
- "gameId": [8, "game-id"],
1579
- "gameName": [1, "game-name"],
1580
- "subVendor": [1, "sub-vendor"],
1581
- "gameVendor": [1, "game-vendor"],
1582
- "hasFunMode": [4, "has-fun-mode"],
1583
- "hasAnonymousFunMode": [4, "has-anonymous-fun-mode"],
1584
- "platform": [1],
1585
- "thumbnail": [1],
1586
- "isFavorite": [4, "is-favorite"],
1587
- "isNew": [4, "is-new"],
1588
- "cellSize": [1, "cell-size"],
1589
- "gameTag": [1, "game-tag"],
1590
- "type": [1],
1591
- "gameInfo": [32],
1592
- "isTableFull": [32],
1593
- "hover": [32]
1594
- }, [[1, "mouseenter", "handleMouseOver"], [1, "mouseleave", "handleMouseOver"], [4, "gameFavorited", "gameFavoritedHandler"], [0, "gameDetailChange", "gameDetailChangeHandler"]]]);
1595
- function defineCustomElement$1() {
1596
- if (typeof customElements === "undefined") {
1597
- return;
1598
- }
1599
- const components = ["casino-game-thumb-view", "casino-game-thumbnail-overlay"];
1600
- components.forEach(tagName => { switch (tagName) {
1601
- case "casino-game-thumb-view":
1602
- if (!customElements.get(tagName)) {
1603
- customElements.define(tagName, CasinoGameThumbView$1);
1604
- }
1605
- break;
1606
- case "casino-game-thumbnail-overlay":
1607
- if (!customElements.get(tagName)) {
1608
- defineCustomElement$2();
1609
- }
1610
- break;
1611
- } });
1612
- }
1613
- defineCustomElement$1();
1614
-
1615
- const CasinoGameThumbView = CasinoGameThumbView$1;
1616
- const defineCustomElement = defineCustomElement$1;
1617
-
1618
- export { CasinoGameThumbView, defineCustomElement };