@everymatrix/pam-account-balance-modal 0.1.0

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 (56) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-f01eba32.js +1227 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/pam-account-balance-modal-81ade12d.js +1704 -0
  6. package/dist/cjs/pam-account-balance-modal.cjs.js +25 -0
  7. package/dist/cjs/pam-account-balance-modal_2.cjs.entry.js +175 -0
  8. package/dist/collection/collection-manifest.json +19 -0
  9. package/dist/collection/components/pam-account-balance-modal/index.js +1 -0
  10. package/dist/collection/components/pam-account-balance-modal/pam-account-balance-modal.css +217 -0
  11. package/dist/collection/components/pam-account-balance-modal/pam-account-balance-modal.interface.js +1 -0
  12. package/dist/collection/components/pam-account-balance-modal/pam-account-balance-modal.js +635 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/utils/locale.utils.js +227 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/index-ee727666.js +1200 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/loader.js +11 -0
  19. package/dist/esm/pam-account-balance-modal-8ebcc863.js +1702 -0
  20. package/dist/esm/pam-account-balance-modal.js +20 -0
  21. package/dist/esm/pam-account-balance-modal_2.entry.js +170 -0
  22. package/dist/index.cjs.js +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/pam-account-balance-modal/index.esm.js +1 -0
  25. package/dist/pam-account-balance-modal/p-86b371f2.js +2 -0
  26. package/dist/pam-account-balance-modal/p-b60c42bd.js +7 -0
  27. package/dist/pam-account-balance-modal/p-d74c687e.entry.js +1 -0
  28. package/dist/pam-account-balance-modal/p-e1255160.js +1 -0
  29. package/dist/pam-account-balance-modal/pam-account-balance-modal.esm.js +1 -0
  30. package/dist/stencil.config.dev.js +19 -0
  31. package/dist/stencil.config.js +18 -0
  32. package/dist/storybook/main.js +43 -0
  33. package/dist/storybook/preview.js +9 -0
  34. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  35. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/packages/stencil/pam-account-balance-modal/stencil.config.d.ts +2 -0
  36. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/packages/stencil/pam-account-balance-modal/stencil.config.dev.d.ts +2 -0
  37. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/packages/stencil/pam-account-balance-modal/storybook/main.d.ts +3 -0
  38. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/packages/stencil/pam-account-balance-modal/storybook/preview.d.ts +70 -0
  39. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/tools/plugins/index.d.ts +3 -0
  40. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  41. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  42. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  43. package/dist/types/components/pam-account-balance-modal/index.d.ts +1 -0
  44. package/dist/types/components/pam-account-balance-modal/pam-account-balance-modal.d.ts +52 -0
  45. package/dist/types/components/pam-account-balance-modal/pam-account-balance-modal.interface.d.ts +10 -0
  46. package/dist/types/components.d.ts +65 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  49. package/dist/types/utils/locale.utils.d.ts +31 -0
  50. package/loader/cdn.js +1 -0
  51. package/loader/index.cjs.js +1 -0
  52. package/loader/index.d.ts +24 -0
  53. package/loader/index.es2017.js +1 -0
  54. package/loader/index.js +2 -0
  55. package/loader/package.json +11 -0
  56. package/package.json +27 -0
@@ -0,0 +1,1704 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-f01eba32.js');
4
+
5
+ /**
6
+ * @name setClientStyling
7
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
8
+ * @param {HTMLElement} stylingContainer The reference element of the widget
9
+ * @param {string} clientStyling The style content
10
+ */
11
+ function setClientStyling(stylingContainer, clientStyling) {
12
+ if (stylingContainer) {
13
+ const sheet = document.createElement('style');
14
+ sheet.innerHTML = clientStyling;
15
+ stylingContainer.appendChild(sheet);
16
+ }
17
+ }
18
+
19
+ /**
20
+ * @name setClientStylingURL
21
+ * @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
22
+ * @param {HTMLElement} stylingContainer The reference element of the widget
23
+ * @param {string} clientStylingUrl The URL of the style content
24
+ */
25
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
26
+ const url = new URL(clientStylingUrl);
27
+
28
+ fetch(url.href)
29
+ .then((res) => res.text())
30
+ .then((data) => {
31
+ const cssFile = document.createElement('style');
32
+ cssFile.innerHTML = data;
33
+ if (stylingContainer) {
34
+ stylingContainer.appendChild(cssFile);
35
+ }
36
+ })
37
+ .catch((err) => {
38
+ console.error('There was an error while trying to load client styling from URL', err);
39
+ });
40
+ }
41
+
42
+ /**
43
+ * @name setStreamLibrary
44
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
45
+ * @param {HTMLElement} stylingContainer The highest element of the widget
46
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
47
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
48
+ */
49
+ function setStreamStyling(stylingContainer, domain, subscription) {
50
+ if (window.emMessageBus) {
51
+ const sheet = document.createElement('style');
52
+
53
+ window.emMessageBus.subscribe(domain, (data) => {
54
+ sheet.innerHTML = data;
55
+ if (stylingContainer) {
56
+ stylingContainer.appendChild(sheet);
57
+ }
58
+ });
59
+ }
60
+ }
61
+
62
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
63
+
64
+ var eventsource = {exports: {}};
65
+
66
+ /** @license
67
+ * eventsource.js
68
+ * Available under MIT License (MIT)
69
+ * https://github.com/Yaffle/EventSource/
70
+ */
71
+
72
+ (function (module, exports) {
73
+ /*jslint indent: 2, vars: true, plusplus: true */
74
+ /*global setTimeout, clearTimeout */
75
+
76
+ (function (global) {
77
+
78
+ var setTimeout = global.setTimeout;
79
+ var clearTimeout = global.clearTimeout;
80
+ var XMLHttpRequest = global.XMLHttpRequest;
81
+ var XDomainRequest = global.XDomainRequest;
82
+ var ActiveXObject = global.ActiveXObject;
83
+ var NativeEventSource = global.EventSource;
84
+
85
+ var document = global.document;
86
+ var Promise = global.Promise;
87
+ var fetch = global.fetch;
88
+ var Response = global.Response;
89
+ var TextDecoder = global.TextDecoder;
90
+ var TextEncoder = global.TextEncoder;
91
+ var AbortController = global.AbortController;
92
+
93
+ if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) { // Firefox 2
94
+ document.readyState = "loading";
95
+ window.addEventListener("load", function (event) {
96
+ document.readyState = "complete";
97
+ }, false);
98
+ }
99
+
100
+ if (XMLHttpRequest == null && ActiveXObject != null) { // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6
101
+ XMLHttpRequest = function () {
102
+ return new ActiveXObject("Microsoft.XMLHTTP");
103
+ };
104
+ }
105
+
106
+ if (Object.create == undefined) {
107
+ Object.create = function (C) {
108
+ function F(){}
109
+ F.prototype = C;
110
+ return new F();
111
+ };
112
+ }
113
+
114
+ if (!Date.now) {
115
+ Date.now = function now() {
116
+ return new Date().getTime();
117
+ };
118
+ }
119
+
120
+ // see #118 (Promise#finally with polyfilled Promise)
121
+ // see #123 (data URLs crash Edge)
122
+ // see #125 (CSP violations)
123
+ // see pull/#138
124
+ // => No way to polyfill Promise#finally
125
+
126
+ if (AbortController == undefined) {
127
+ var originalFetch2 = fetch;
128
+ fetch = function (url, options) {
129
+ var signal = options.signal;
130
+ return originalFetch2(url, {headers: options.headers, credentials: options.credentials, cache: options.cache}).then(function (response) {
131
+ var reader = response.body.getReader();
132
+ signal._reader = reader;
133
+ if (signal._aborted) {
134
+ signal._reader.cancel();
135
+ }
136
+ return {
137
+ status: response.status,
138
+ statusText: response.statusText,
139
+ headers: response.headers,
140
+ body: {
141
+ getReader: function () {
142
+ return reader;
143
+ }
144
+ }
145
+ };
146
+ });
147
+ };
148
+ AbortController = function () {
149
+ this.signal = {
150
+ _reader: null,
151
+ _aborted: false
152
+ };
153
+ this.abort = function () {
154
+ if (this.signal._reader != null) {
155
+ this.signal._reader.cancel();
156
+ }
157
+ this.signal._aborted = true;
158
+ };
159
+ };
160
+ }
161
+
162
+ function TextDecoderPolyfill() {
163
+ this.bitsNeeded = 0;
164
+ this.codePoint = 0;
165
+ }
166
+
167
+ TextDecoderPolyfill.prototype.decode = function (octets) {
168
+ function valid(codePoint, shift, octetsCount) {
169
+ if (octetsCount === 1) {
170
+ return codePoint >= 0x0080 >> shift && codePoint << shift <= 0x07FF;
171
+ }
172
+ if (octetsCount === 2) {
173
+ return codePoint >= 0x0800 >> shift && codePoint << shift <= 0xD7FF || codePoint >= 0xE000 >> shift && codePoint << shift <= 0xFFFF;
174
+ }
175
+ if (octetsCount === 3) {
176
+ return codePoint >= 0x010000 >> shift && codePoint << shift <= 0x10FFFF;
177
+ }
178
+ throw new Error();
179
+ }
180
+ function octetsCount(bitsNeeded, codePoint) {
181
+ if (bitsNeeded === 6 * 1) {
182
+ return codePoint >> 6 > 15 ? 3 : codePoint > 31 ? 2 : 1;
183
+ }
184
+ if (bitsNeeded === 6 * 2) {
185
+ return codePoint > 15 ? 3 : 2;
186
+ }
187
+ if (bitsNeeded === 6 * 3) {
188
+ return 3;
189
+ }
190
+ throw new Error();
191
+ }
192
+ var REPLACER = 0xFFFD;
193
+ var string = "";
194
+ var bitsNeeded = this.bitsNeeded;
195
+ var codePoint = this.codePoint;
196
+ for (var i = 0; i < octets.length; i += 1) {
197
+ var octet = octets[i];
198
+ if (bitsNeeded !== 0) {
199
+ if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
200
+ bitsNeeded = 0;
201
+ codePoint = REPLACER;
202
+ string += String.fromCharCode(codePoint);
203
+ }
204
+ }
205
+ if (bitsNeeded === 0) {
206
+ if (octet >= 0 && octet <= 127) {
207
+ bitsNeeded = 0;
208
+ codePoint = octet;
209
+ } else if (octet >= 192 && octet <= 223) {
210
+ bitsNeeded = 6 * 1;
211
+ codePoint = octet & 31;
212
+ } else if (octet >= 224 && octet <= 239) {
213
+ bitsNeeded = 6 * 2;
214
+ codePoint = octet & 15;
215
+ } else if (octet >= 240 && octet <= 247) {
216
+ bitsNeeded = 6 * 3;
217
+ codePoint = octet & 7;
218
+ } else {
219
+ bitsNeeded = 0;
220
+ codePoint = REPLACER;
221
+ }
222
+ if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
223
+ bitsNeeded = 0;
224
+ codePoint = REPLACER;
225
+ }
226
+ } else {
227
+ bitsNeeded -= 6;
228
+ codePoint = codePoint << 6 | octet & 63;
229
+ }
230
+ if (bitsNeeded === 0) {
231
+ if (codePoint <= 0xFFFF) {
232
+ string += String.fromCharCode(codePoint);
233
+ } else {
234
+ string += String.fromCharCode(0xD800 + (codePoint - 0xFFFF - 1 >> 10));
235
+ string += String.fromCharCode(0xDC00 + (codePoint - 0xFFFF - 1 & 0x3FF));
236
+ }
237
+ }
238
+ }
239
+ this.bitsNeeded = bitsNeeded;
240
+ this.codePoint = codePoint;
241
+ return string;
242
+ };
243
+
244
+ // Firefox < 38 throws an error with stream option
245
+ var supportsStreamOption = function () {
246
+ try {
247
+ return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
248
+ } catch (error) {
249
+ console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
250
+ }
251
+ return false;
252
+ };
253
+
254
+ // IE, Edge
255
+ if (TextDecoder == undefined || TextEncoder == undefined || !supportsStreamOption()) {
256
+ TextDecoder = TextDecoderPolyfill;
257
+ }
258
+
259
+ var k = function () {
260
+ };
261
+
262
+ function XHRWrapper(xhr) {
263
+ this.withCredentials = false;
264
+ this.readyState = 0;
265
+ this.status = 0;
266
+ this.statusText = "";
267
+ this.responseText = "";
268
+ this.onprogress = k;
269
+ this.onload = k;
270
+ this.onerror = k;
271
+ this.onreadystatechange = k;
272
+ this._contentType = "";
273
+ this._xhr = xhr;
274
+ this._sendTimeout = 0;
275
+ this._abort = k;
276
+ }
277
+
278
+ XHRWrapper.prototype.open = function (method, url) {
279
+ this._abort(true);
280
+
281
+ var that = this;
282
+ var xhr = this._xhr;
283
+ var state = 1;
284
+ var timeout = 0;
285
+
286
+ this._abort = function (silent) {
287
+ if (that._sendTimeout !== 0) {
288
+ clearTimeout(that._sendTimeout);
289
+ that._sendTimeout = 0;
290
+ }
291
+ if (state === 1 || state === 2 || state === 3) {
292
+ state = 4;
293
+ xhr.onload = k;
294
+ xhr.onerror = k;
295
+ xhr.onabort = k;
296
+ xhr.onprogress = k;
297
+ xhr.onreadystatechange = k;
298
+ // IE 8 - 9: XDomainRequest#abort() does not fire any event
299
+ // Opera < 10: XMLHttpRequest#abort() does not fire any event
300
+ xhr.abort();
301
+ if (timeout !== 0) {
302
+ clearTimeout(timeout);
303
+ timeout = 0;
304
+ }
305
+ if (!silent) {
306
+ that.readyState = 4;
307
+ that.onabort(null);
308
+ that.onreadystatechange();
309
+ }
310
+ }
311
+ state = 0;
312
+ };
313
+
314
+ var onStart = function () {
315
+ if (state === 1) {
316
+ //state = 2;
317
+ var status = 0;
318
+ var statusText = "";
319
+ var contentType = undefined;
320
+ if (!("contentType" in xhr)) {
321
+ try {
322
+ status = xhr.status;
323
+ statusText = xhr.statusText;
324
+ contentType = xhr.getResponseHeader("Content-Type");
325
+ } catch (error) {
326
+ // IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
327
+ // Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
328
+ // https://bugs.webkit.org/show_bug.cgi?id=29121
329
+ status = 0;
330
+ statusText = "";
331
+ contentType = undefined;
332
+ // Firefox < 14, Chrome ?, Safari ?
333
+ // https://bugs.webkit.org/show_bug.cgi?id=29658
334
+ // https://bugs.webkit.org/show_bug.cgi?id=77854
335
+ }
336
+ } else {
337
+ status = 200;
338
+ statusText = "OK";
339
+ contentType = xhr.contentType;
340
+ }
341
+ if (status !== 0) {
342
+ state = 2;
343
+ that.readyState = 2;
344
+ that.status = status;
345
+ that.statusText = statusText;
346
+ that._contentType = contentType;
347
+ that.onreadystatechange();
348
+ }
349
+ }
350
+ };
351
+ var onProgress = function () {
352
+ onStart();
353
+ if (state === 2 || state === 3) {
354
+ state = 3;
355
+ var responseText = "";
356
+ try {
357
+ responseText = xhr.responseText;
358
+ } catch (error) {
359
+ // IE 8 - 9 with XMLHttpRequest
360
+ }
361
+ that.readyState = 3;
362
+ that.responseText = responseText;
363
+ that.onprogress();
364
+ }
365
+ };
366
+ var onFinish = function (type, event) {
367
+ if (event == null || event.preventDefault == null) {
368
+ event = {
369
+ preventDefault: k
370
+ };
371
+ }
372
+ // Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
373
+ // IE 8 fires "onload" without "onprogress"
374
+ onProgress();
375
+ if (state === 1 || state === 2 || state === 3) {
376
+ state = 4;
377
+ if (timeout !== 0) {
378
+ clearTimeout(timeout);
379
+ timeout = 0;
380
+ }
381
+ that.readyState = 4;
382
+ if (type === "load") {
383
+ that.onload(event);
384
+ } else if (type === "error") {
385
+ that.onerror(event);
386
+ } else if (type === "abort") {
387
+ that.onabort(event);
388
+ } else {
389
+ throw new TypeError();
390
+ }
391
+ that.onreadystatechange();
392
+ }
393
+ };
394
+ var onReadyStateChange = function (event) {
395
+ if (xhr != undefined) { // Opera 12
396
+ if (xhr.readyState === 4) {
397
+ if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
398
+ onFinish(xhr.responseText === "" ? "error" : "load", event);
399
+ }
400
+ } else if (xhr.readyState === 3) {
401
+ if (!("onprogress" in xhr)) { // testing XMLHttpRequest#responseText too many times is too slow in IE 11
402
+ // and in Firefox 3.6
403
+ onProgress();
404
+ }
405
+ } else if (xhr.readyState === 2) {
406
+ onStart();
407
+ }
408
+ }
409
+ };
410
+ var onTimeout = function () {
411
+ timeout = setTimeout(function () {
412
+ onTimeout();
413
+ }, 500);
414
+ if (xhr.readyState === 3) {
415
+ onProgress();
416
+ }
417
+ };
418
+
419
+ // XDomainRequest#abort removes onprogress, onerror, onload
420
+ if ("onload" in xhr) {
421
+ xhr.onload = function (event) {
422
+ onFinish("load", event);
423
+ };
424
+ }
425
+ if ("onerror" in xhr) {
426
+ xhr.onerror = function (event) {
427
+ onFinish("error", event);
428
+ };
429
+ }
430
+ // improper fix to match Firefox behaviour, but it is better than just ignore abort
431
+ // see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
432
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=880200
433
+ // https://code.google.com/p/chromium/issues/detail?id=153570
434
+ // IE 8 fires "onload" without "onprogress
435
+ if ("onabort" in xhr) {
436
+ xhr.onabort = function (event) {
437
+ onFinish("abort", event);
438
+ };
439
+ }
440
+
441
+ if ("onprogress" in xhr) {
442
+ xhr.onprogress = onProgress;
443
+ }
444
+
445
+ // IE 8 - 9 (XMLHTTPRequest)
446
+ // Opera < 12
447
+ // Firefox < 3.5
448
+ // Firefox 3.5 - 3.6 - ? < 9.0
449
+ // onprogress is not fired sometimes or delayed
450
+ // see also #64 (significant lag in IE 11)
451
+ if ("onreadystatechange" in xhr) {
452
+ xhr.onreadystatechange = function (event) {
453
+ onReadyStateChange(event);
454
+ };
455
+ }
456
+
457
+ if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
458
+ url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
459
+ }
460
+ xhr.open(method, url, true);
461
+
462
+ if ("readyState" in xhr) {
463
+ // workaround for Opera 12 issue with "progress" events
464
+ // #91 (XMLHttpRequest onprogress not fired for streaming response in Edge 14-15-?)
465
+ timeout = setTimeout(function () {
466
+ onTimeout();
467
+ }, 0);
468
+ }
469
+ };
470
+ XHRWrapper.prototype.abort = function () {
471
+ this._abort(false);
472
+ };
473
+ XHRWrapper.prototype.getResponseHeader = function (name) {
474
+ return this._contentType;
475
+ };
476
+ XHRWrapper.prototype.setRequestHeader = function (name, value) {
477
+ var xhr = this._xhr;
478
+ if ("setRequestHeader" in xhr) {
479
+ xhr.setRequestHeader(name, value);
480
+ }
481
+ };
482
+ XHRWrapper.prototype.getAllResponseHeaders = function () {
483
+ // XMLHttpRequest#getAllResponseHeaders returns null for CORS requests in Firefox 3.6.28
484
+ return this._xhr.getAllResponseHeaders != undefined ? this._xhr.getAllResponseHeaders() || "" : "";
485
+ };
486
+ XHRWrapper.prototype.send = function () {
487
+ // loading indicator in Safari < ? (6), Chrome < 14, Firefox
488
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=736723
489
+ if ((!("ontimeout" in XMLHttpRequest.prototype) || (!("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype))) &&
490
+ document != undefined &&
491
+ document.readyState != undefined &&
492
+ document.readyState !== "complete") {
493
+ var that = this;
494
+ that._sendTimeout = setTimeout(function () {
495
+ that._sendTimeout = 0;
496
+ that.send();
497
+ }, 4);
498
+ return;
499
+ }
500
+
501
+ var xhr = this._xhr;
502
+ // withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
503
+ if ("withCredentials" in xhr) {
504
+ xhr.withCredentials = this.withCredentials;
505
+ }
506
+ try {
507
+ // xhr.send(); throws "Not enough arguments" in Firefox 3.0
508
+ xhr.send(undefined);
509
+ } catch (error1) {
510
+ // Safari 5.1.7, Opera 12
511
+ throw error1;
512
+ }
513
+ };
514
+
515
+ function toLowerCase(name) {
516
+ return name.replace(/[A-Z]/g, function (c) {
517
+ return String.fromCharCode(c.charCodeAt(0) + 0x20);
518
+ });
519
+ }
520
+
521
+ function HeadersPolyfill(all) {
522
+ // Get headers: implemented according to mozilla's example code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
523
+ var map = Object.create(null);
524
+ var array = all.split("\r\n");
525
+ for (var i = 0; i < array.length; i += 1) {
526
+ var line = array[i];
527
+ var parts = line.split(": ");
528
+ var name = parts.shift();
529
+ var value = parts.join(": ");
530
+ map[toLowerCase(name)] = value;
531
+ }
532
+ this._map = map;
533
+ }
534
+ HeadersPolyfill.prototype.get = function (name) {
535
+ return this._map[toLowerCase(name)];
536
+ };
537
+
538
+ if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) { // IE < 9, Firefox 3.6
539
+ XMLHttpRequest.HEADERS_RECEIVED = 2;
540
+ }
541
+
542
+ function XHRTransport() {
543
+ }
544
+
545
+ XHRTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
546
+ xhr.open("GET", url);
547
+ var offset = 0;
548
+ xhr.onprogress = function () {
549
+ var responseText = xhr.responseText;
550
+ var chunk = responseText.slice(offset);
551
+ offset += chunk.length;
552
+ onProgressCallback(chunk);
553
+ };
554
+ xhr.onerror = function (event) {
555
+ event.preventDefault();
556
+ onFinishCallback(new Error("NetworkError"));
557
+ };
558
+ xhr.onload = function () {
559
+ onFinishCallback(null);
560
+ };
561
+ xhr.onabort = function () {
562
+ onFinishCallback(null);
563
+ };
564
+ xhr.onreadystatechange = function () {
565
+ if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
566
+ var status = xhr.status;
567
+ var statusText = xhr.statusText;
568
+ var contentType = xhr.getResponseHeader("Content-Type");
569
+ var headers = xhr.getAllResponseHeaders();
570
+ onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers));
571
+ }
572
+ };
573
+ xhr.withCredentials = withCredentials;
574
+ for (var name in headers) {
575
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
576
+ xhr.setRequestHeader(name, headers[name]);
577
+ }
578
+ }
579
+ xhr.send();
580
+ return xhr;
581
+ };
582
+
583
+ function HeadersWrapper(headers) {
584
+ this._headers = headers;
585
+ }
586
+ HeadersWrapper.prototype.get = function (name) {
587
+ return this._headers.get(name);
588
+ };
589
+
590
+ function FetchTransport() {
591
+ }
592
+
593
+ FetchTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
594
+ var reader = null;
595
+ var controller = new AbortController();
596
+ var signal = controller.signal;
597
+ var textDecoder = new TextDecoder();
598
+ fetch(url, {
599
+ headers: headers,
600
+ credentials: withCredentials ? "include" : "same-origin",
601
+ signal: signal,
602
+ cache: "no-store"
603
+ }).then(function (response) {
604
+ reader = response.body.getReader();
605
+ onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
606
+ // see https://github.com/promises-aplus/promises-spec/issues/179
607
+ return new Promise(function (resolve, reject) {
608
+ var readNextChunk = function () {
609
+ reader.read().then(function (result) {
610
+ if (result.done) {
611
+ //Note: bytes in textDecoder are ignored
612
+ resolve(undefined);
613
+ } else {
614
+ var chunk = textDecoder.decode(result.value, {stream: true});
615
+ onProgressCallback(chunk);
616
+ readNextChunk();
617
+ }
618
+ })["catch"](function (error) {
619
+ reject(error);
620
+ });
621
+ };
622
+ readNextChunk();
623
+ });
624
+ })["catch"](function (error) {
625
+ if (error.name === "AbortError") {
626
+ return undefined;
627
+ } else {
628
+ return error;
629
+ }
630
+ }).then(function (error) {
631
+ onFinishCallback(error);
632
+ });
633
+ return {
634
+ abort: function () {
635
+ if (reader != null) {
636
+ reader.cancel(); // https://bugzilla.mozilla.org/show_bug.cgi?id=1583815
637
+ }
638
+ controller.abort();
639
+ }
640
+ };
641
+ };
642
+
643
+ function EventTarget() {
644
+ this._listeners = Object.create(null);
645
+ }
646
+
647
+ function throwError(e) {
648
+ setTimeout(function () {
649
+ throw e;
650
+ }, 0);
651
+ }
652
+
653
+ EventTarget.prototype.dispatchEvent = function (event) {
654
+ event.target = this;
655
+ var typeListeners = this._listeners[event.type];
656
+ if (typeListeners != undefined) {
657
+ var length = typeListeners.length;
658
+ for (var i = 0; i < length; i += 1) {
659
+ var listener = typeListeners[i];
660
+ try {
661
+ if (typeof listener.handleEvent === "function") {
662
+ listener.handleEvent(event);
663
+ } else {
664
+ listener.call(this, event);
665
+ }
666
+ } catch (e) {
667
+ throwError(e);
668
+ }
669
+ }
670
+ }
671
+ };
672
+ EventTarget.prototype.addEventListener = function (type, listener) {
673
+ type = String(type);
674
+ var listeners = this._listeners;
675
+ var typeListeners = listeners[type];
676
+ if (typeListeners == undefined) {
677
+ typeListeners = [];
678
+ listeners[type] = typeListeners;
679
+ }
680
+ var found = false;
681
+ for (var i = 0; i < typeListeners.length; i += 1) {
682
+ if (typeListeners[i] === listener) {
683
+ found = true;
684
+ }
685
+ }
686
+ if (!found) {
687
+ typeListeners.push(listener);
688
+ }
689
+ };
690
+ EventTarget.prototype.removeEventListener = function (type, listener) {
691
+ type = String(type);
692
+ var listeners = this._listeners;
693
+ var typeListeners = listeners[type];
694
+ if (typeListeners != undefined) {
695
+ var filtered = [];
696
+ for (var i = 0; i < typeListeners.length; i += 1) {
697
+ if (typeListeners[i] !== listener) {
698
+ filtered.push(typeListeners[i]);
699
+ }
700
+ }
701
+ if (filtered.length === 0) {
702
+ delete listeners[type];
703
+ } else {
704
+ listeners[type] = filtered;
705
+ }
706
+ }
707
+ };
708
+
709
+ function Event(type) {
710
+ this.type = type;
711
+ this.target = undefined;
712
+ }
713
+
714
+ function MessageEvent(type, options) {
715
+ Event.call(this, type);
716
+ this.data = options.data;
717
+ this.lastEventId = options.lastEventId;
718
+ }
719
+
720
+ MessageEvent.prototype = Object.create(Event.prototype);
721
+
722
+ function ConnectionEvent(type, options) {
723
+ Event.call(this, type);
724
+ this.status = options.status;
725
+ this.statusText = options.statusText;
726
+ this.headers = options.headers;
727
+ }
728
+
729
+ ConnectionEvent.prototype = Object.create(Event.prototype);
730
+
731
+ function ErrorEvent(type, options) {
732
+ Event.call(this, type);
733
+ this.error = options.error;
734
+ }
735
+
736
+ ErrorEvent.prototype = Object.create(Event.prototype);
737
+
738
+ var WAITING = -1;
739
+ var CONNECTING = 0;
740
+ var OPEN = 1;
741
+ var CLOSED = 2;
742
+
743
+ var AFTER_CR = -1;
744
+ var FIELD_START = 0;
745
+ var FIELD = 1;
746
+ var VALUE_START = 2;
747
+ var VALUE = 3;
748
+
749
+ var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
750
+
751
+ var MINIMUM_DURATION = 1000;
752
+ var MAXIMUM_DURATION = 18000000;
753
+
754
+ var parseDuration = function (value, def) {
755
+ var n = value == null ? def : parseInt(value, 10);
756
+ if (n !== n) {
757
+ n = def;
758
+ }
759
+ return clampDuration(n);
760
+ };
761
+ var clampDuration = function (n) {
762
+ return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
763
+ };
764
+
765
+ var fire = function (that, f, event) {
766
+ try {
767
+ if (typeof f === "function") {
768
+ f.call(that, event);
769
+ }
770
+ } catch (e) {
771
+ throwError(e);
772
+ }
773
+ };
774
+
775
+ function EventSourcePolyfill(url, options) {
776
+ EventTarget.call(this);
777
+ options = options || {};
778
+
779
+ this.onopen = undefined;
780
+ this.onmessage = undefined;
781
+ this.onerror = undefined;
782
+
783
+ this.url = undefined;
784
+ this.readyState = undefined;
785
+ this.withCredentials = undefined;
786
+ this.headers = undefined;
787
+
788
+ this._close = undefined;
789
+
790
+ start(this, url, options);
791
+ }
792
+
793
+ function getBestXHRTransport() {
794
+ return (XMLHttpRequest != undefined && ("withCredentials" in XMLHttpRequest.prototype)) || XDomainRequest == undefined
795
+ ? new XMLHttpRequest()
796
+ : new XDomainRequest();
797
+ }
798
+
799
+ var isFetchSupported = fetch != undefined && Response != undefined && "body" in Response.prototype;
800
+
801
+ function start(es, url, options) {
802
+ url = String(url);
803
+ var withCredentials = Boolean(options.withCredentials);
804
+ var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
805
+
806
+ var initialRetry = clampDuration(1000);
807
+ var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45000);
808
+
809
+ var lastEventId = "";
810
+ var retry = initialRetry;
811
+ var wasActivity = false;
812
+ var textLength = 0;
813
+ var headers = options.headers || {};
814
+ var TransportOption = options.Transport;
815
+ var xhr = isFetchSupported && TransportOption == undefined ? undefined : new XHRWrapper(TransportOption != undefined ? new TransportOption() : getBestXHRTransport());
816
+ var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : (xhr == undefined ? new FetchTransport() : new XHRTransport());
817
+ var abortController = undefined;
818
+ var timeout = 0;
819
+ var currentState = WAITING;
820
+ var dataBuffer = "";
821
+ var lastEventIdBuffer = "";
822
+ var eventTypeBuffer = "";
823
+
824
+ var textBuffer = "";
825
+ var state = FIELD_START;
826
+ var fieldStart = 0;
827
+ var valueStart = 0;
828
+
829
+ var onStart = function (status, statusText, contentType, headers) {
830
+ if (currentState === CONNECTING) {
831
+ if (status === 200 && contentType != undefined && contentTypeRegExp.test(contentType)) {
832
+ currentState = OPEN;
833
+ wasActivity = Date.now();
834
+ retry = initialRetry;
835
+ es.readyState = OPEN;
836
+ var event = new ConnectionEvent("open", {
837
+ status: status,
838
+ statusText: statusText,
839
+ headers: headers
840
+ });
841
+ es.dispatchEvent(event);
842
+ fire(es, es.onopen, event);
843
+ } else {
844
+ var message = "";
845
+ if (status !== 200) {
846
+ if (statusText) {
847
+ statusText = statusText.replace(/\s+/g, " ");
848
+ }
849
+ message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
850
+ } else {
851
+ message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == undefined ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
852
+ }
853
+ close();
854
+ var event = new ConnectionEvent("error", {
855
+ status: status,
856
+ statusText: statusText,
857
+ headers: headers
858
+ });
859
+ es.dispatchEvent(event);
860
+ fire(es, es.onerror, event);
861
+ console.error(message);
862
+ }
863
+ }
864
+ };
865
+
866
+ var onProgress = function (textChunk) {
867
+ if (currentState === OPEN) {
868
+ var n = -1;
869
+ for (var i = 0; i < textChunk.length; i += 1) {
870
+ var c = textChunk.charCodeAt(i);
871
+ if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
872
+ n = i;
873
+ }
874
+ }
875
+ var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
876
+ textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
877
+ if (textChunk !== "") {
878
+ wasActivity = Date.now();
879
+ textLength += textChunk.length;
880
+ }
881
+ for (var position = 0; position < chunk.length; position += 1) {
882
+ var c = chunk.charCodeAt(position);
883
+ if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
884
+ state = FIELD_START;
885
+ } else {
886
+ if (state === AFTER_CR) {
887
+ state = FIELD_START;
888
+ }
889
+ if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
890
+ if (state !== FIELD_START) {
891
+ if (state === FIELD) {
892
+ valueStart = position + 1;
893
+ }
894
+ var field = chunk.slice(fieldStart, valueStart - 1);
895
+ var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
896
+ if (field === "data") {
897
+ dataBuffer += "\n";
898
+ dataBuffer += value;
899
+ } else if (field === "id") {
900
+ lastEventIdBuffer = value;
901
+ } else if (field === "event") {
902
+ eventTypeBuffer = value;
903
+ } else if (field === "retry") {
904
+ initialRetry = parseDuration(value, initialRetry);
905
+ retry = initialRetry;
906
+ } else if (field === "heartbeatTimeout") {
907
+ heartbeatTimeout = parseDuration(value, heartbeatTimeout);
908
+ if (timeout !== 0) {
909
+ clearTimeout(timeout);
910
+ timeout = setTimeout(function () {
911
+ onTimeout();
912
+ }, heartbeatTimeout);
913
+ }
914
+ }
915
+ }
916
+ if (state === FIELD_START) {
917
+ if (dataBuffer !== "") {
918
+ lastEventId = lastEventIdBuffer;
919
+ if (eventTypeBuffer === "") {
920
+ eventTypeBuffer = "message";
921
+ }
922
+ var event = new MessageEvent(eventTypeBuffer, {
923
+ data: dataBuffer.slice(1),
924
+ lastEventId: lastEventIdBuffer
925
+ });
926
+ es.dispatchEvent(event);
927
+ if (eventTypeBuffer === "open") {
928
+ fire(es, es.onopen, event);
929
+ } else if (eventTypeBuffer === "message") {
930
+ fire(es, es.onmessage, event);
931
+ } else if (eventTypeBuffer === "error") {
932
+ fire(es, es.onerror, event);
933
+ }
934
+ if (currentState === CLOSED) {
935
+ return;
936
+ }
937
+ }
938
+ dataBuffer = "";
939
+ eventTypeBuffer = "";
940
+ }
941
+ state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
942
+ } else {
943
+ if (state === FIELD_START) {
944
+ fieldStart = position;
945
+ state = FIELD;
946
+ }
947
+ if (state === FIELD) {
948
+ if (c === ":".charCodeAt(0)) {
949
+ valueStart = position + 1;
950
+ state = VALUE_START;
951
+ }
952
+ } else if (state === VALUE_START) {
953
+ state = VALUE;
954
+ }
955
+ }
956
+ }
957
+ }
958
+ }
959
+ };
960
+
961
+ var onFinish = function (error) {
962
+ if (currentState === OPEN || currentState === CONNECTING) {
963
+ currentState = WAITING;
964
+ if (timeout !== 0) {
965
+ clearTimeout(timeout);
966
+ timeout = 0;
967
+ }
968
+ timeout = setTimeout(function () {
969
+ onTimeout();
970
+ }, retry);
971
+ retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
972
+
973
+ es.readyState = CONNECTING;
974
+ var event = new ErrorEvent("error", {error: error});
975
+ es.dispatchEvent(event);
976
+ fire(es, es.onerror, event);
977
+ if (error != undefined) {
978
+ console.error(error);
979
+ }
980
+ }
981
+ };
982
+
983
+ var close = function () {
984
+ currentState = CLOSED;
985
+ if (abortController != undefined) {
986
+ abortController.abort();
987
+ abortController = undefined;
988
+ }
989
+ if (timeout !== 0) {
990
+ clearTimeout(timeout);
991
+ timeout = 0;
992
+ }
993
+ es.readyState = CLOSED;
994
+ };
995
+
996
+ var onTimeout = function () {
997
+ timeout = 0;
998
+
999
+ if (currentState !== WAITING) {
1000
+ if (!wasActivity && abortController != undefined) {
1001
+ onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds." + " " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " " + "Reconnecting."));
1002
+ if (abortController != undefined) {
1003
+ abortController.abort();
1004
+ abortController = undefined;
1005
+ }
1006
+ } else {
1007
+ var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
1008
+ wasActivity = false;
1009
+ timeout = setTimeout(function () {
1010
+ onTimeout();
1011
+ }, nextHeartbeat);
1012
+ }
1013
+ return;
1014
+ }
1015
+
1016
+ wasActivity = false;
1017
+ textLength = 0;
1018
+ timeout = setTimeout(function () {
1019
+ onTimeout();
1020
+ }, heartbeatTimeout);
1021
+
1022
+ currentState = CONNECTING;
1023
+ dataBuffer = "";
1024
+ eventTypeBuffer = "";
1025
+ lastEventIdBuffer = lastEventId;
1026
+ textBuffer = "";
1027
+ fieldStart = 0;
1028
+ valueStart = 0;
1029
+ state = FIELD_START;
1030
+
1031
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=428916
1032
+ // Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
1033
+ var requestURL = url;
1034
+ if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
1035
+ if (lastEventId !== "") {
1036
+ // Remove the lastEventId parameter if it's already part of the request URL.
1037
+ var i = url.indexOf("?");
1038
+ requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function (p, paramName) {
1039
+ return paramName === lastEventIdQueryParameterName ? '' : p;
1040
+ });
1041
+ // Append the current lastEventId to the request URL.
1042
+ requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName +"=" + encodeURIComponent(lastEventId);
1043
+ }
1044
+ }
1045
+ var withCredentials = es.withCredentials;
1046
+ var requestHeaders = {};
1047
+ requestHeaders["Accept"] = "text/event-stream";
1048
+ var headers = es.headers;
1049
+ if (headers != undefined) {
1050
+ for (var name in headers) {
1051
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
1052
+ requestHeaders[name] = headers[name];
1053
+ }
1054
+ }
1055
+ }
1056
+ try {
1057
+ abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials, requestHeaders);
1058
+ } catch (error) {
1059
+ close();
1060
+ throw error;
1061
+ }
1062
+ };
1063
+
1064
+ es.url = url;
1065
+ es.readyState = CONNECTING;
1066
+ es.withCredentials = withCredentials;
1067
+ es.headers = headers;
1068
+ es._close = close;
1069
+
1070
+ onTimeout();
1071
+ }
1072
+
1073
+ EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
1074
+ EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
1075
+ EventSourcePolyfill.prototype.OPEN = OPEN;
1076
+ EventSourcePolyfill.prototype.CLOSED = CLOSED;
1077
+ EventSourcePolyfill.prototype.close = function () {
1078
+ this._close();
1079
+ };
1080
+
1081
+ EventSourcePolyfill.CONNECTING = CONNECTING;
1082
+ EventSourcePolyfill.OPEN = OPEN;
1083
+ EventSourcePolyfill.CLOSED = CLOSED;
1084
+ EventSourcePolyfill.prototype.withCredentials = undefined;
1085
+
1086
+ var R = NativeEventSource;
1087
+ if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {
1088
+ // Why replace a native EventSource ?
1089
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=444328
1090
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=831392
1091
+ // https://code.google.com/p/chromium/issues/detail?id=260144
1092
+ // https://code.google.com/p/chromium/issues/detail?id=225654
1093
+ // ...
1094
+ R = EventSourcePolyfill;
1095
+ }
1096
+
1097
+ (function (factory) {
1098
+ {
1099
+ var v = factory(exports);
1100
+ if (v !== undefined) module.exports = v;
1101
+ }
1102
+ })(function (exports) {
1103
+ exports.EventSourcePolyfill = EventSourcePolyfill;
1104
+ exports.NativeEventSource = NativeEventSource;
1105
+ exports.EventSource = R;
1106
+ });
1107
+ }(typeof globalThis === 'undefined' ? (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal) : globalThis));
1108
+ }(eventsource, eventsource.exports));
1109
+
1110
+ var currency_min$1 = {exports: {}};
1111
+
1112
+ /*
1113
+ currency.js - v2.0.4
1114
+ http://scurker.github.io/currency.js
1115
+
1116
+ Copyright (c) 2021 Jason Wilson
1117
+ Released under MIT license
1118
+ */
1119
+
1120
+ (function (module, exports) {
1121
+ (function(e,g){module.exports=g();})(commonjsGlobal,function(){function e(b,a){if(!(this instanceof e))return new e(b,a);a=Object.assign({},m,a);var d=Math.pow(10,a.precision);this.intValue=b=g(b,a);this.value=b/d;a.increment=a.increment||1/d;a.groups=a.useVedic?n:p;this.s=a;this.p=d;}function g(b,a){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:!0;var c=a.decimal;
1122
+ var h=a.errorOnInvalid,k=a.fromCents,l=Math.pow(10,a.precision),f=b instanceof e;if(f&&k)return b.intValue;if("number"===typeof b||f)c=f?b.value:b;else if("string"===typeof b)h=new RegExp("[^-\\d"+c+"]","g"),c=new RegExp("\\"+c,"g"),c=(c=b.replace(/\((.*)\)/,"-$1").replace(h,"").replace(c,"."))||0;else {if(h)throw Error("Invalid Input");c=0;}k||(c=(c*l).toFixed(4));return d?Math.round(c):c}var m={symbol:"$",separator:",",decimal:".",errorOnInvalid:!1,precision:2,pattern:"!#",negativePattern:"-!#",format:function(b,
1123
+ a){var d=a.pattern,c=a.negativePattern,h=a.symbol,k=a.separator,l=a.decimal;a=a.groups;var f=(""+b).replace(/^-/,"").split("."),q=f[0];f=f[1];return (0<=b.value?d:c).replace("!",h).replace("#",q.replace(a,"$1"+k)+(f?l+f:""))},fromCents:!1},p=/(\d)(?=(\d{3})+\b)/g,n=/(\d)(?=(\d\d)+\d\b)/g;e.prototype={add:function(b){var a=this.s,d=this.p;return e((this.intValue+g(b,a))/(a.fromCents?1:d),a)},subtract:function(b){var a=this.s,d=this.p;return e((this.intValue-g(b,a))/(a.fromCents?1:d),a)},multiply:function(b){var a=
1124
+ this.s;return e(this.intValue*b/(a.fromCents?1:Math.pow(10,a.precision)),a)},divide:function(b){var a=this.s;return e(this.intValue/g(b,a,!1),a)},distribute:function(b){var a=this.intValue,d=this.p,c=this.s,h=[],k=Math[0<=a?"floor":"ceil"](a/b),l=Math.abs(a-k*b);for(d=c.fromCents?1:d;0!==b;b--){var f=e(k/d,c);0<l--&&(f=f[0<=a?"add":"subtract"](1/d));h.push(f);}return h},dollars:function(){return ~~this.value},cents:function(){return ~~(this.intValue%this.p)},format:function(b){var a=this.s;return "function"===
1125
+ typeof b?b(this,a):a.format(this,Object.assign({},a,b))},toString:function(){var b=this.s,a=b.increment;return (Math.round(this.intValue/this.p/a)*a).toFixed(b.precision)},toJSON:function(){return this.value}};return e});
1126
+ }(currency_min$1));
1127
+
1128
+ const currency_min = currency_min$1.exports;
1129
+
1130
+ const DEFAULT_LANGUAGE = 'en';
1131
+ const TRANSLATIONS = {
1132
+ "en": {
1133
+ "Title": "Your Balance",
1134
+ "Total": "Total Balance",
1135
+ "Real": "Cash Balance",
1136
+ "Bonus": "Bonus Balance",
1137
+ "Credit": "Credit Balance",
1138
+ "Casino": "Casino",
1139
+ "Sports": "Sports",
1140
+ "DepositButton": "Deposit",
1141
+ "Loading": "Loading ..."
1142
+ },
1143
+ "zh-hk": {
1144
+ "Title": "您的結餘",
1145
+ "Total": "總結餘",
1146
+ "Real": "現金結餘",
1147
+ "Bonus": "紅利結餘",
1148
+ "Credit": "信用結餘",
1149
+ "Casino": "賭場",
1150
+ "Sports": "體育",
1151
+ "DepositButton": "存款",
1152
+ "Loading": "載入中 ..."
1153
+ },
1154
+ "de": {
1155
+ "Title": "Ihr Guthaben",
1156
+ "Total": "Gesamtguthaben",
1157
+ "Real": "Barguthaben",
1158
+ "Bonus": "Bonusguthaben",
1159
+ "Credit": "Kreditguthaben",
1160
+ "Casino": "Casino",
1161
+ "Sports": "Sport",
1162
+ "DepositButton": "Einzahlen",
1163
+ "Loading": "Wird geladen ..."
1164
+ },
1165
+ "it": {
1166
+ "Title": "Il tuo saldo",
1167
+ "Total": "Saldo totale",
1168
+ "Real": "Saldo in contanti",
1169
+ "Bonus": "Saldo bonus",
1170
+ "Credit": "Saldo di credito",
1171
+ "Casino": "Casinò",
1172
+ "Sports": "Sport",
1173
+ "DepositButton": "Deposita",
1174
+ "Loading": "Caricamento ..."
1175
+ },
1176
+ "fr": {
1177
+ "Title": "Votre solde",
1178
+ "Total": "Solde total",
1179
+ "Real": "Solde en espèces",
1180
+ "Bonus": "Solde bonus",
1181
+ "Credit": "Solde de crédit",
1182
+ "Casino": "Casino",
1183
+ "Sports": "Sports",
1184
+ "DepositButton": "Dépôt",
1185
+ "Loading": "Chargement ..."
1186
+ },
1187
+ "es": {
1188
+ "Title": "Tu saldo",
1189
+ "Total": "Saldo total",
1190
+ "Real": "Saldo en efectivo",
1191
+ "Bonus": "Saldo de bono",
1192
+ "Credit": "Saldo de crédito",
1193
+ "Casino": "Casino",
1194
+ "Sports": "Deportes",
1195
+ "DepositButton": "Depósito",
1196
+ "Loading": "Cargando ..."
1197
+ },
1198
+ "tr": {
1199
+ "Title": "Bakiyeniz",
1200
+ "Total": "Toplam Bakiye",
1201
+ "Real": "Nakit Bakiye",
1202
+ "Bonus": "Bonus Bakiyesi",
1203
+ "Credit": "Kredi Bakiyesi",
1204
+ "Casino": "Kumarhane",
1205
+ "Sports": "Spor",
1206
+ "DepositButton": "Yatır",
1207
+ "Loading": "Yükleniyor ..."
1208
+ },
1209
+ "ru": {
1210
+ "Title": "Ваш баланс",
1211
+ "Total": "Общий баланс",
1212
+ "Real": "Денежный баланс",
1213
+ "Bonus": "Бонусный баланс",
1214
+ "Credit": "Кредитный баланс",
1215
+ "Casino": "Казино",
1216
+ "Sports": "Спорт",
1217
+ "DepositButton": "Депозит",
1218
+ "Loading": "Загружается ..."
1219
+ },
1220
+ "ro": {
1221
+ "Title": "Soldul tău",
1222
+ "Total": "Sold total",
1223
+ "Real": "Sold în numerar",
1224
+ "Bonus": "Sold bonus",
1225
+ "Credit": "Sold credit",
1226
+ "Casino": "Cazinou",
1227
+ "Sports": "Sporturi",
1228
+ "DepositButton": "Depozit",
1229
+ "Loading": "Se încarcă ..."
1230
+ },
1231
+ "hr": {
1232
+ "Title": "Vaš saldo",
1233
+ "Total": "Ukupni saldo",
1234
+ "Real": "Gotovinski saldo",
1235
+ "Bonus": "Bonus saldo",
1236
+ "Credit": "Kreditni saldo",
1237
+ "Casino": "Casino",
1238
+ "Sports": "Sportovi",
1239
+ "DepositButton": "Depozit",
1240
+ "Loading": "Učitavanje ..."
1241
+ },
1242
+ "hu": {
1243
+ "Title": "Az egyenleged",
1244
+ "Total": "Teljes egyenleg",
1245
+ "Real": "Készpénz egyenleg",
1246
+ "Bonus": "Bónusz egyenleg",
1247
+ "Credit": "Hitel egyenleg",
1248
+ "Casino": "Kaszinó",
1249
+ "Sports": "Sport",
1250
+ "DepositButton": "Befizetés",
1251
+ "Loading": "Betöltés ..."
1252
+ },
1253
+ "pl": {
1254
+ "Title": "Twoje saldo",
1255
+ "Total": "Całkowite saldo",
1256
+ "Real": "Saldo gotówkowe",
1257
+ "Bonus": "Saldo bonusowe",
1258
+ "Credit": "Saldo kredytowe",
1259
+ "Casino": "Kasyno",
1260
+ "Sports": "Sport",
1261
+ "DepositButton": "Wpłać",
1262
+ "Loading": "Ładowanie ..."
1263
+ },
1264
+ "pt": {
1265
+ "Title": "Seu Saldo",
1266
+ "Total": "Saldo Total",
1267
+ "Real": "Saldo em Dinheiro",
1268
+ "Bonus": "Saldo de Bônus",
1269
+ "Credit": "Saldo de Crédito",
1270
+ "Casino": "Cassino",
1271
+ "Sports": "Esportes",
1272
+ "DepositButton": "Depositar",
1273
+ "Loading": "Carregando ..."
1274
+ },
1275
+ "sl": {
1276
+ "Title": "Vaš saldo",
1277
+ "Total": "Skupni saldo",
1278
+ "Real": "Gotovinski saldo",
1279
+ "Bonus": "Bonus saldo",
1280
+ "Credit": "Kreditni saldo",
1281
+ "Casino": "Kasino",
1282
+ "Sports": "Šport",
1283
+ "DepositButton": "Depozit",
1284
+ "Loading": "Nalaganje ..."
1285
+ },
1286
+ "sr": {
1287
+ "Title": "Vaš saldo",
1288
+ "Total": "Ukupan saldo",
1289
+ "Real": "Gotovinski saldo",
1290
+ "Bonus": "Bonus saldo",
1291
+ "Credit": "Kreditni saldo",
1292
+ "Casino": "Kasino",
1293
+ "Sports": "Sport",
1294
+ "DepositButton": "Depozit",
1295
+ "Loading": "Učitavanje ..."
1296
+ },
1297
+ "pt-br": {
1298
+ "Title": "Seu Saldo",
1299
+ "Total": "Saldo Total",
1300
+ "Real": "Saldo em Dinheiro",
1301
+ "Bonus": "Saldo de Bônus",
1302
+ "Credit": "Saldo de Crédito",
1303
+ "Casino": "Cassino",
1304
+ "Sports": "Esportes",
1305
+ "DepositButton": "Depositar",
1306
+ "Loading": "Carregando ..."
1307
+ },
1308
+ "es-mx": {
1309
+ "Title": "Tu saldo",
1310
+ "Total": "Saldo total",
1311
+ "Real": "Saldo en efectivo",
1312
+ "Bonus": "Saldo de bono",
1313
+ "Credit": "Saldo de crédito",
1314
+ "Casino": "Casino",
1315
+ "Sports": "Deportes",
1316
+ "DepositButton": "Depósito",
1317
+ "Loading": "Cargando ..."
1318
+ },
1319
+ "en-us": {
1320
+ "Title": "Your Balance",
1321
+ "Total": "Total Balance",
1322
+ "Real": "Cash Balance",
1323
+ "Bonus": "Bonus Balance",
1324
+ "Credit": "Credit Balance",
1325
+ "Casino": "Casino",
1326
+ "Sports": "Sports",
1327
+ "DepositButton": "Deposit",
1328
+ "Loading": "Loading ..."
1329
+ }
1330
+ };
1331
+ const translate = (key, customLang, values) => {
1332
+ let lang = TRANSLATIONS[customLang] ? customLang : DEFAULT_LANGUAGE;
1333
+ let translation = TRANSLATIONS[lang][key];
1334
+ if (values !== undefined) {
1335
+ for (const [key, value] of Object.entries(values.values)) {
1336
+ const regex = new RegExp(`{${key}}`, 'g');
1337
+ translation = translation.replace(regex, value);
1338
+ }
1339
+ }
1340
+ return translation;
1341
+ };
1342
+
1343
+ const pamAccountBalanceModalCss = "*,*::before,*::after{font-family:inherit}:host{font-family:inherit}input,textarea,button{font-family:inherit}p{padding:0;margin:0}.PamAccountBalanceModal{position:relative}.PamAccountBalanceModal .LoadingSkeleton{border-radius:10px;overflow:hidden;width:60px}.PamAccountBalanceModal .BalanceValue{font-size:14px;cursor:pointer;background:transparent;border:none;font:inherit;color:inherit;display:flex;flex-wrap:nowrap;white-space:nowrap}.PamAccountBalanceModal .BalanceValue svg{width:16px;fill:var(--emw--color-black, #000000)}.PamAccountBalanceModal .BalanceValue span{padding-left:5px}.PamAccountBalanceModal .BalanceValue .TriangleActive,.PamAccountBalanceModal .BalanceValue .TriangleInactive{display:block;margin:0 3px;transition:all 0.2s}.PamAccountBalanceModal .BalanceValue .TriangleActive:hover,.PamAccountBalanceModal .BalanceValue .TriangleInactive:hover{transform:scale(1.2)}.PamAccountBalanceModal .BalanceValue .TriangleActive svg,.PamAccountBalanceModal .BalanceValue .TriangleInactive svg{margin:2px 0px}.PamAccountBalanceModal .BalanceValue .TriangleActive{transform:scale(1.1) rotateX(180deg) translateY(3px)}.PamAccountBalanceModal .BalanceValue .TriangleActive:hover{transform:scale(1.1) rotateX(180deg) translateY(3px)}@media only screen and (max-width: 360px){.PamAccountBalanceModal .BalanceValue{font-size:12px}.PamAccountBalanceModal .BalanceValue svg{width:12px}}.PamAccountBalanceModal .BalanceModalWrapper{background:linear-gradient(90deg, rgb(42, 79, 55) 0%, rgb(0, 61, 92) 100%);position:absolute;top:40px;padding:10px;transform:translateX(-45%);box-shadow:0px 30px 30px var(--emw--header-color-primary, var(--emw--color-primary, #22B04E));border-radius:5px;z-index:17;box-shadow:0px 5px 20px 0px #191919;transition:all 0.2s ease-in;opacity:0}.PamAccountBalanceModal .BalanceModalWrapper:before{content:\"\";background:linear-gradient(90deg, rgb(42, 79, 55) 0%, rgb(0, 61, 92) 100%);clip-path:polygon(50% 0, 0% 100%, 100% 100%);position:absolute;top:-8px;left:50%;width:25px;height:10px;z-index:1}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModalClose{position:absolute;top:5px;right:5px;width:20px;height:20px;z-index:1;cursor:pointer;transition:all 0.3s ease;background:transparent;border:none;font:inherit}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModalClose:before{content:\"\";background:var(--emw--color-secondary, #FFFFFF);position:absolute;top:8px;left:0;width:20px;height:2px;transform:rotate(45deg)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModalClose:after{content:\"\";background:var(--emw--color-secondary, #FFFFFF);position:absolute;top:8px;left:0;width:20px;height:2px;transform:rotate(-45deg)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModalClose:hover{transform:scale(1.1)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal{transition:all 0.2s ease-in;width:270px}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalHeader{display:flex;align-items:center;justify-content:center;padding:20px 0}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalHeader .BalanceModalTitle{font-size:16px;font-weight:bold;color:var(--emw--header-contrast, var(--emw--color-contrast, #FFFFFF))}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth{display:flex;flex-direction:column;gap:5px;padding:20px 0;border-bottom:1px solid var(--emw--color-gray-100, #E6E6E6)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth:last-child{border-bottom:none}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth .BalanceModalRowLine{display:flex;width:100%;justify-content:space-between}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth .BalanceModalText{color:var(--emw--header-contrast, var(--emw--color-contrast, #FFFFFF));font-size:14px;text-transform:capitalize}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth .BalanceModalValue{font-size:14px;font-weight:bold;color:var(--emw--header-contrast, var(--emw--color-contrast, #FFFFFF))}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalFooter{display:flex;align-items:center;padding:20px 0 10px}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalFooter .BalanceModalAction{background:var(--emw--color-primary, #22B04E);font-size:12px;color:var(--emw--color-white, #FFFFFF);text-transform:uppercase;width:100%;border-radius:30px;border:none;padding:10px 0;cursor:pointer;transition:all 0.2s ease-in;box-shadow:0px 3px 7px 0px rgba(0, 0, 0, 0.2)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalFooter .BalanceModalAction:hover{background:rgba(255, 255, 255, 0.1);color:var(--emw--color-primary, #22B04E);box-shadow:0px 0px 0px 2px inset var(--emw--color-primary, #22B04E);font-size:14px}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalFooter .BalanceModalAction:active{background:rgba(255, 255, 255, 0.5)}.PamAccountBalanceModal .BalanceModalWrapper.Open{opacity:1}.PamAccountBalanceModalOverlay{background-color:rgba(0, 0, 0, 0.7);position:fixed;top:0;bottom:0;left:0;right:0;z-index:16;opacity:0;transition:all 0.2s linear}.PamAccountBalanceModalOverlay.Open{opacity:1}";
1344
+ const PamAccountBalanceModalStyle0 = pamAccountBalanceModalCss;
1345
+
1346
+ const PamAccountBalanceModal = class {
1347
+ constructor(hostRef) {
1348
+ index.registerInstance(this, hostRef);
1349
+ this.totalCalculationModes = ['totalCashAmount', 'totalRealAmount'];
1350
+ this.setLocaleIdentifier = () => {
1351
+ if (this.customLocaleIdentifier.includes(this.language)) {
1352
+ return this.customLocaleIdentifier;
1353
+ }
1354
+ };
1355
+ this.formatBalance = (balance) => {
1356
+ if (this.customLocaleIdentifier) {
1357
+ return new Intl.NumberFormat(this.setLocaleIdentifier(), { useGrouping: true }).format(balance);
1358
+ }
1359
+ if (this.currencySeparator && this.currencyDecimal) {
1360
+ // @ts-ignore
1361
+ return currency_min(balance, { separator: this.currencySeparator, decimal: this.currencyDecimal, symbol: '', precision: parseInt(this.currencyPrecision || '2', 10) }).format();
1362
+ }
1363
+ // @ts-ignore
1364
+ return currency_min(balance, { separator: '.', decimal: ',', symbol: '', precision: parseInt(this.currencyPrecision || '2', 10) }).format();
1365
+ };
1366
+ this.getBalances = () => {
1367
+ this.isLoading = true;
1368
+ const url = new URL(`/v2/player/${this.userId}/balance/`, this.endpoint);
1369
+ const headers = new Headers();
1370
+ headers.append('X-SessionID', this.session);
1371
+ const params = {
1372
+ method: 'GET',
1373
+ headers: headers
1374
+ };
1375
+ return new Promise((resolve) => {
1376
+ return fetch(url, params)
1377
+ .then(res => res.json())
1378
+ .then(res => resolve(res))
1379
+ .catch((err) => {
1380
+ console.log('Balance fetch error', err);
1381
+ throw new Error('Failed to fetch balance data!');
1382
+ })
1383
+ .finally(() => this.isLoading = false);
1384
+ });
1385
+ };
1386
+ this.subscribeToBalanceUpdates = () => {
1387
+ if (this.currentStream) {
1388
+ this.currentStream.close();
1389
+ }
1390
+ if (this.session.length < 1) {
1391
+ return;
1392
+ }
1393
+ const url = new URL(`/v2/player/${this.userId}/information/updates/`, this.endpoint);
1394
+ const headers = {
1395
+ 'accept': 'text/event-stream',
1396
+ 'X-SessionId': this.session
1397
+ };
1398
+ const stream = new eventsource.exports.EventSourcePolyfill(url, { headers: headers });
1399
+ this.currentStream = stream;
1400
+ stream.addEventListener("message", this.updateBalances);
1401
+ };
1402
+ this.parseData = (data) => {
1403
+ let parsedData;
1404
+ try {
1405
+ parsedData = JSON.parse(data);
1406
+ }
1407
+ catch (e) {
1408
+ console.log('Balance stream failed: ', e);
1409
+ return;
1410
+ }
1411
+ return parsedData;
1412
+ };
1413
+ this.updateRealAmount = (currentRealAmount, state, balanceItem) => {
1414
+ let updatedRealAmount = null;
1415
+ switch (balanceItem.walletAccountType) {
1416
+ case 'Ordinary':
1417
+ if (balanceItem.afterAmount !== balanceItem.affectedAmount || state.lastOrdinaryAfterAmount === 0) {
1418
+ state.lastOrdinaryAfterAmount = balanceItem.afterAmount;
1419
+ if (!state.showCreditLineAfterAmount) {
1420
+ updatedRealAmount = balanceItem.afterAmount;
1421
+ }
1422
+ }
1423
+ break;
1424
+ case 'CreditLine':
1425
+ if (balanceItem.afterAmount !== 0) {
1426
+ updatedRealAmount = balanceItem.afterAmount;
1427
+ state.showCreditLineAfterAmount = true;
1428
+ }
1429
+ else {
1430
+ updatedRealAmount = state.lastOrdinaryAfterAmount;
1431
+ state.showCreditLineAfterAmount = false;
1432
+ }
1433
+ break;
1434
+ default:
1435
+ updatedRealAmount = balanceItem.afterAmount;
1436
+ }
1437
+ return updatedRealAmount === null ? currentRealAmount : updatedRealAmount;
1438
+ };
1439
+ this.updateTotalAmount = () => {
1440
+ switch (this.totalCalculationMode) {
1441
+ case 'totalCashAmount':
1442
+ let totalCashAmount = 0;
1443
+ for (const balanceType of ['Real', 'Bonus']) {
1444
+ for (const balance of this.balances[balanceType]) {
1445
+ totalCashAmount += Math.max(balance.amount, 0);
1446
+ }
1447
+ }
1448
+ this.balances['Total'][0].amount = totalCashAmount;
1449
+ break;
1450
+ case 'totalRealAmount':
1451
+ if (!this.isSplitWallet) {
1452
+ return;
1453
+ }
1454
+ let totalRealAmount = 0;
1455
+ for (const balance of this.balances['Real']) {
1456
+ totalRealAmount += balance.amount;
1457
+ }
1458
+ this.balances['Total'][0].amount = totalRealAmount;
1459
+ break;
1460
+ }
1461
+ };
1462
+ this.updateBalances = (e) => {
1463
+ const parsedData = this.parseData(e.data);
1464
+ if (!parsedData) {
1465
+ this.subscribeToBalanceUpdates();
1466
+ return;
1467
+ }
1468
+ if (parsedData.type !== 'BALANCE_UPDATE_V2') {
1469
+ return;
1470
+ }
1471
+ const balanceChange = parsedData.body.balanceChange;
1472
+ for (const [balanceType, balanceItem] of Object.entries(balanceChange)) {
1473
+ // Compute totalRealAmount for single wallet
1474
+ if (this.totalCalculationMode === 'totalRealAmount' && balanceType === 'Real' && !this.isSplitWallet) {
1475
+ this.balances["Total"][0].amount = this.updateRealAmount(this.balances["Total"][0].amount, this.updateRealAmountState, balanceItem);
1476
+ }
1477
+ if (!this.balances[balanceType]) {
1478
+ continue;
1479
+ }
1480
+ // Assign new balance values
1481
+ for (const balance of this.balances[balanceType]) {
1482
+ if (!this.isSplitWallet) {
1483
+ balance.amount = balanceType === 'Real'
1484
+ ? this.updateRealAmount(balance.amount, this.updateRealAmountState, balanceItem)
1485
+ : balanceItem.afterAmount;
1486
+ continue;
1487
+ }
1488
+ if (balanceItem.productType === balance.productType) {
1489
+ balance.amount = balanceType === 'Real'
1490
+ ? this.updateRealAmount(balance.amount, this.updateRealAmountState[balance.productType], balanceItem)
1491
+ : balanceItem.afterAmount;
1492
+ }
1493
+ }
1494
+ }
1495
+ this.updateTotalAmount();
1496
+ this.balances = Object.assign({}, this.balances);
1497
+ };
1498
+ this.balanceModalOpenDeposit = () => {
1499
+ this.toggleModal('close');
1500
+ window.postMessage({ type: 'GoToDeposit' }, window.location.href);
1501
+ // @ts-ignore Analytics event
1502
+ if (typeof gtag == 'function') {
1503
+ // @ts-ignore
1504
+ gtag('event', 'GoToDeposit', {
1505
+ 'context': 'PlayerAccountBalanceModal'
1506
+ });
1507
+ }
1508
+ };
1509
+ this.validateTotalCalculationMode = () => {
1510
+ if (!this.totalCalculationModes.includes(this.totalCalculationMode)) {
1511
+ console.error(`Unsupported value ('${this.totalCalculationMode}') for totalcalculationmode parameter. Only the following values are supported ${this.totalCalculationModes}. Using default value ('${this.totalCalculationModes[0]}').`);
1512
+ this.totalCalculationMode = this.totalCalculationModes[0];
1513
+ }
1514
+ };
1515
+ this.messageHandler = (e) => e.data && e.data.type === 'LogoutSuccessfull' && this.currentStream.close();
1516
+ this.updateBalanceStyling = () => {
1517
+ window.postMessage({ type: 'UpdateBalanceBackground' }, window.location.href);
1518
+ };
1519
+ this.toggleModal = (action) => {
1520
+ switch (action) {
1521
+ case 'open':
1522
+ window.postMessage({ type: 'BalanceModalStatus', status: 'open' }, window.location.href);
1523
+ this.isModalDisplayed = true;
1524
+ break;
1525
+ case 'close':
1526
+ window.postMessage({ type: 'BalanceModalStatus', status: 'close' }, window.location.href);
1527
+ this.isModalDisplayed = false;
1528
+ break;
1529
+ }
1530
+ };
1531
+ this.userId = undefined;
1532
+ this.session = undefined;
1533
+ this.endpoint = undefined;
1534
+ this.customLocaleIdentifier = undefined;
1535
+ this.displayBalanceOption = undefined;
1536
+ this.totalCalculationMode = undefined;
1537
+ this.currencySeparator = undefined;
1538
+ this.currencyDecimal = undefined;
1539
+ this.currencyPrecision = undefined;
1540
+ this.mbSource = undefined;
1541
+ this.clientStyling = undefined;
1542
+ this.clientStylingUrl = undefined;
1543
+ this.translationUrl = undefined;
1544
+ this.language = 'en';
1545
+ this.isLoading = true;
1546
+ this.isModalDisplayed = false;
1547
+ this.isSplitWallet = false;
1548
+ this.currentStream = undefined;
1549
+ this.currency = undefined;
1550
+ this.updateRealAmountState = undefined;
1551
+ this.balances = { Total: [], Real: [], Bonus: [], Credit: [] };
1552
+ }
1553
+ handleClientStylingChange(newValue, oldValue) {
1554
+ if (newValue != oldValue) {
1555
+ setClientStyling(this.stylingContainer, this.clientStyling);
1556
+ }
1557
+ }
1558
+ handleClientStylingUrlChange(newValue, oldValue) {
1559
+ if (newValue != oldValue) {
1560
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
1561
+ }
1562
+ }
1563
+ handleMbSourceChange(newValue, oldValue) {
1564
+ if (newValue != oldValue) {
1565
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
1566
+ }
1567
+ }
1568
+ componentWillLoad() {
1569
+ this.validateTotalCalculationMode();
1570
+ this.getBalances()
1571
+ .then(balanceData => this.setBalances(balanceData));
1572
+ this.subscribeToBalanceUpdates();
1573
+ }
1574
+ componentDidLoad() {
1575
+ if (this.stylingContainer) {
1576
+ if (this.mbSource)
1577
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
1578
+ if (this.clientStyling)
1579
+ setClientStyling(this.stylingContainer, this.clientStyling);
1580
+ if (this.clientStylingUrl)
1581
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
1582
+ }
1583
+ }
1584
+ disconnectedCallback() {
1585
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
1586
+ }
1587
+ setBalances(balanceData) {
1588
+ if (!balanceData[this.totalCalculationMode]) {
1589
+ this.totalCalculationMode = this.totalCalculationModes[0];
1590
+ }
1591
+ this.balances.Total.push({ amount: 0, productType: '' });
1592
+ // we consider the first real ordinary balance to be a source of truth
1593
+ const firstRealOrdinaryBalance = balanceData.items.find(item => item['type'] === 'Real' && item['walletAccountType'] === 'Ordinary');
1594
+ this.currency = firstRealOrdinaryBalance['currency'];
1595
+ this.isSplitWallet = Boolean(firstRealOrdinaryBalance['productType']);
1596
+ if (this.isSplitWallet) {
1597
+ this.setBalancesWhenSplitWallet(balanceData);
1598
+ }
1599
+ else {
1600
+ this.setBalancesWhenSingleWallet(balanceData);
1601
+ }
1602
+ }
1603
+ setBalancesWhenSingleWallet(balanceData) {
1604
+ this.updateRealAmountState = { lastOrdinaryAfterAmount: 0, showCreditLineAfterAmount: false };
1605
+ this.balances['Total'][0].amount = balanceData[this.totalCalculationMode][this.currency];
1606
+ for (const balance of balanceData.items) {
1607
+ switch (balance.type) {
1608
+ case 'Bonus':
1609
+ if (this.balances['Bonus'].length === 0) {
1610
+ this.balances['Bonus'].push({ amount: balance.amount, productType: '' });
1611
+ }
1612
+ else {
1613
+ this.balances['Bonus'][0].amount += balance.amount;
1614
+ }
1615
+ break;
1616
+ case 'Real':
1617
+ if (balance.creditLine && this.balances['Credit'].length === 0) {
1618
+ this.balances['Credit'].push({ amount: balance.creditLine, productType: '' });
1619
+ }
1620
+ /*
1621
+ In the case of "totalRealAmount", Real and Total will always have the same value,
1622
+ therefore we only show the Total balance ( required for Fitzdares )
1623
+ **/
1624
+ if (this.totalCalculationMode === 'totalRealAmount') {
1625
+ continue;
1626
+ }
1627
+ if (this.balances['Real'].length === 0) {
1628
+ this.balances['Real'].push({ amount: balance.amount, productType: '' });
1629
+ }
1630
+ else {
1631
+ this.balances['Real'][0].amount += balance.amount;
1632
+ }
1633
+ break;
1634
+ }
1635
+ }
1636
+ for (const [balanceType, balance] of Object.entries(this.balances)) {
1637
+ if (balance.length < 1) {
1638
+ delete this.balances[balanceType];
1639
+ }
1640
+ }
1641
+ }
1642
+ setBalancesWhenSplitWallet(balanceData) {
1643
+ this.updateRealAmountState = {
1644
+ 'Casino': { lastOrdinaryAfterAmount: 0, showCreditLineAfterAmount: false },
1645
+ 'Sports': { lastOrdinaryAfterAmount: 0, showCreditLineAfterAmount: false }
1646
+ };
1647
+ let balanceItems = balanceData.items;
1648
+ if (this.displayBalanceOption && this.displayBalanceOption !== 'All') {
1649
+ balanceItems = balanceData.items.filter((elem) => elem.productType === this.displayBalanceOption);
1650
+ }
1651
+ for (const balance of balanceItems) {
1652
+ let idx;
1653
+ switch (balance.type) {
1654
+ case 'Bonus':
1655
+ idx = this.balances['Bonus'].findIndex(b => b.productType === balance.productType);
1656
+ if (idx > 0) {
1657
+ this.balances['Bonus'][idx].amount += balance.amount;
1658
+ }
1659
+ else {
1660
+ this.balances['Bonus'].push({ amount: balance.amount, productType: balance.productType });
1661
+ }
1662
+ break;
1663
+ case 'Real':
1664
+ if (balance.creditLine) {
1665
+ this.balances['Credit'].push({ amount: balance.creditLine, productType: balance.productType });
1666
+ }
1667
+ idx = this.balances['Real'].findIndex(b => b.productType === balance.productType);
1668
+ if (idx > 0) {
1669
+ this.balances['Real'][idx].amount += balance.amount;
1670
+ }
1671
+ else {
1672
+ this.balances['Real'].push({ amount: balance.amount, productType: balance.productType });
1673
+ }
1674
+ break;
1675
+ }
1676
+ }
1677
+ this.updateTotalAmount();
1678
+ for (const [balanceType, balance] of Object.entries(this.balances)) {
1679
+ if (balance.length < 1) {
1680
+ delete this.balances[balanceType];
1681
+ }
1682
+ }
1683
+ }
1684
+ render() {
1685
+ const balanceButton = (index.h("button", { class: "BalanceValue", onClick: () => this.toggleModal('open') }, index.h("p", null, this.balances['Total'].length > 0 ? this.formatBalance(this.balances['Total'][0].amount) : '0', " ", this.currency), index.h("span", { class: " {isModalDisplayed ? 'TriangleActive' : 'TriangleInactive'}" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "6.835", viewBox: "0 0 14 6.835" }, index.h("path", { id: "arrow", d: "M281.541,447.921a.488.488,0,0,0,.295-.122l6.5-5.851a.488.488,0,1,0-.65-.726l-6.176,5.556-6.176-5.556h0a.488.488,0,1,0-.65.726l6.5,5.851a.488.488,0,0,0,.355.122Z", transform: "translate(-274.511 -441.088)", fill: "#d1d1d1" })))));
1686
+ const balanceModal = (index.h("div", { class: this.isModalDisplayed ? 'BalanceModalWrapper Open' : 'BalanceModalWrapper' }, index.h("button", { class: "BalanceModalClose", onClick: () => this.toggleModal('close') }), index.h("div", { class: "BalanceModal" }, index.h("div", { class: "ModalContent" }, index.h("div", { class: "BalanceModalHeader" }, index.h("p", { class: "BalanceModalTitle" }, translate('Title', this.language))), index.h("div", { class: "BalanceModalBody" }, Object.keys(this.balances).map((key) => {
1687
+ return (index.h("div", { class: "BalanceModalRowBoth" }, this.balances[key].map((balance) => {
1688
+ return (index.h("div", { class: "BalanceModalRowLine" }, index.h("p", { class: "BalanceModalText" }, translate(key, this.language), " ", balance.productType ? translate(balance.productType, this.language) : ''), index.h("p", { class: "BalanceModalValue" }, index.h("span", { class: "BalanceModalAmount" }, balance.amount ? this.formatBalance(balance.amount) : '0'), index.h("span", { class: "BalanceModalCurrency" }, " " + this.currency))));
1689
+ })));
1690
+ })), index.h("div", { class: "BalanceModalFooter" }, index.h("button", { class: "BalanceModalAction", onClick: () => this.balanceModalOpenDeposit() }, translate('DepositButton', this.language)))))));
1691
+ const skeleton = (index.h("div", { class: "LoadingSkeleton" }, index.h("ui-skeleton", { structure: "title", height: "20px", width: "auto" })));
1692
+ return (index.h("div", { ref: (el) => (this.stylingContainer = el) }, index.h("div", { class: "PamAccountBalanceModal" }, this.isLoading
1693
+ ? skeleton
1694
+ : index.h("div", null, balanceButton, balanceModal)), this.isModalDisplayed && (index.h("button", { class: "PamAccountBalanceModalOverlay", onClick: () => this.toggleModal('close') }))));
1695
+ }
1696
+ static get watchers() { return {
1697
+ "clientStyling": ["handleClientStylingChange"],
1698
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
1699
+ "mbSource": ["handleMbSourceChange"]
1700
+ }; }
1701
+ };
1702
+ PamAccountBalanceModal.style = PamAccountBalanceModalStyle0;
1703
+
1704
+ exports.PamAccountBalanceModal = PamAccountBalanceModal;