@everymatrix/casino-engagement-suite-luckywheel-list 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 (51) hide show
  1. package/dist/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.esm.js +1 -0
  2. package/dist/casino-engagement-suite-luckywheel-list/index.esm.js +1 -0
  3. package/dist/casino-engagement-suite-luckywheel-list/p-c227cdc7.js +2 -0
  4. package/dist/casino-engagement-suite-luckywheel-list/p-d1ea0bae.entry.js +1 -0
  5. package/dist/casino-engagement-suite-luckywheel-list/p-e1255160.js +1 -0
  6. package/dist/casino-engagement-suite-luckywheel-list/p-f007d81f.js +1 -0
  7. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  8. package/dist/cjs/casino-engagement-suite-luckywheel-list-726f2e8f.js +2574 -0
  9. package/dist/cjs/casino-engagement-suite-luckywheel-list.cjs.js +25 -0
  10. package/dist/cjs/casino-engagement-suite-luckywheel-list_2.cjs.entry.js +73 -0
  11. package/dist/cjs/index-3815b8e0.js +1333 -0
  12. package/dist/cjs/index.cjs.js +10 -0
  13. package/dist/cjs/loader.cjs.js +15 -0
  14. package/dist/collection/collection-manifest.json +19 -0
  15. package/dist/collection/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.css +454 -0
  16. package/dist/collection/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.js +467 -0
  17. package/dist/collection/components/casino-engagement-suite-luckywheel-list/index.js +1 -0
  18. package/dist/collection/index.js +1 -0
  19. package/dist/collection/models/luckywheel.js +14 -0
  20. package/dist/collection/renders/LuckyWheelsHistory.js +52 -0
  21. package/dist/collection/utils/locale.utils.js +46 -0
  22. package/dist/collection/utils/utils.js +3 -0
  23. package/dist/esm/app-globals-0f993ce5.js +3 -0
  24. package/dist/esm/casino-engagement-suite-luckywheel-list-864bcb68.js +2572 -0
  25. package/dist/esm/casino-engagement-suite-luckywheel-list.js +20 -0
  26. package/dist/esm/casino-engagement-suite-luckywheel-list_2.entry.js +68 -0
  27. package/dist/esm/index-68de30f0.js +1305 -0
  28. package/dist/esm/index.js +2 -0
  29. package/dist/esm/loader.js +11 -0
  30. package/dist/index.cjs.js +1 -0
  31. package/dist/index.js +1 -0
  32. package/dist/stencil.config.dev.js +14 -0
  33. package/dist/stencil.config.js +17 -0
  34. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/casino-engagement-suite-luckywheel-list/.stencil/packages/stencil/casino-engagement-suite-luckywheel-list/stencil.config.d.ts +2 -0
  35. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/casino-engagement-suite-luckywheel-list/.stencil/packages/stencil/casino-engagement-suite-luckywheel-list/stencil.config.dev.d.ts +2 -0
  36. package/dist/types/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.d.ts +84 -0
  37. package/dist/types/components/casino-engagement-suite-luckywheel-list/index.d.ts +1 -0
  38. package/dist/types/components.d.ts +119 -0
  39. package/dist/types/index.d.ts +1 -0
  40. package/dist/types/models/luckywheel.d.ts +41 -0
  41. package/dist/types/renders/LuckyWheelsHistory.d.ts +6 -0
  42. package/dist/types/stencil-public-runtime.d.ts +1680 -0
  43. package/dist/types/utils/locale.utils.d.ts +2 -0
  44. package/dist/types/utils/utils.d.ts +1 -0
  45. package/loader/cdn.js +1 -0
  46. package/loader/index.cjs.js +1 -0
  47. package/loader/index.d.ts +24 -0
  48. package/loader/index.es2017.js +1 -0
  49. package/loader/index.js +2 -0
  50. package/loader/package.json +11 -0
  51. package/package.json +26 -0
@@ -0,0 +1,467 @@
1
+ import { h } from "@stencil/core";
2
+ import { translate, getTranslations } from "../../utils/locale.utils";
3
+ import "../../../../../casino-engagement-suite-progress-bar/dist/types/index";
4
+ import "../../../../../../svelte/general-animation-loading/es2015/general-animation-loading";
5
+ import { getHistoryLoaderTemplate, getLuckyWheelsHistoryTemplate } from "../../renders/LuckyWheelsHistory";
6
+ export class CasinoEngagementSuiteLuckyWheelList {
7
+ constructor() {
8
+ this.setClientStyling = () => {
9
+ let sheet = document.createElement('style');
10
+ sheet.innerHTML = this.clientStyling;
11
+ this.host.prepend(sheet);
12
+ };
13
+ this.setClientStylingURL = () => {
14
+ let url = new URL(this.clientStylingUrl);
15
+ let cssFile = document.createElement('style');
16
+ fetch(url.href)
17
+ .then((res) => res.text())
18
+ .then((data) => {
19
+ cssFile.innerHTML = data;
20
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
21
+ })
22
+ .catch((err) => {
23
+ console.log('Error ', err);
24
+ });
25
+ };
26
+ this.handleCloseClick = () => {
27
+ this.close.emit();
28
+ this.tooltip = false;
29
+ };
30
+ this.handleLuckyWheelClick = (ev) => {
31
+ const id = ev.currentTarget.getAttribute('data-id');
32
+ const index = ev.currentTarget.getAttribute('data-index');
33
+ window.postMessage({ type: 'LuckyWheelClick', id, index });
34
+ };
35
+ this.showTooltip = () => {
36
+ this.tooltip = true;
37
+ };
38
+ this.hideTooltip = () => {
39
+ this.tooltip = false;
40
+ };
41
+ this.handleTabChange = (e) => {
42
+ this.activeTab = +(e.target.getAttribute('data-index'));
43
+ if (this.activeTab === 2) {
44
+ if (!this.historyLoaded) {
45
+ this.sendHistoryRequest();
46
+ }
47
+ }
48
+ };
49
+ this.toggleLuckyWheelHistory = (ev) => {
50
+ const id = ev.currentTarget.getAttribute('data-id');
51
+ const index = this.openedHistoryIds.findIndex(historyId => historyId === id);
52
+ if (index > -1) {
53
+ this.openedHistoryIds = this.openedHistoryIds.filter((historyId) => historyId !== id);
54
+ }
55
+ else {
56
+ this.openedHistoryIds.push(id);
57
+ }
58
+ this.openedHistoryIds = [...this.openedHistoryIds];
59
+ };
60
+ this.clientStyling = '';
61
+ this.clientStylingUrl = '';
62
+ this.language = 'en';
63
+ this.device = 'Mobile';
64
+ this.luckywheels = [];
65
+ this.endpoint = undefined;
66
+ this.session = undefined;
67
+ this.translationUrl = '';
68
+ this.tooltip = false;
69
+ this.timers = {};
70
+ this.limitStylingAppends = false;
71
+ this.activeTab = 1;
72
+ this.historyLoading = false;
73
+ this.luckywheelHistory = {};
74
+ this.openedHistoryIds = [];
75
+ this.historyLoaded = false;
76
+ this.isLoading = false;
77
+ }
78
+ handleEvent(e) {
79
+ const { type } = e === null || e === void 0 ? void 0 : e.data;
80
+ if (type === 'BarLuckyWheelsClick') {
81
+ this.activeTab = 1;
82
+ this.openedHistoryIds = [];
83
+ }
84
+ }
85
+ luckywheelsPropHandler(value) {
86
+ if (!this.interval && value.length) {
87
+ this.updateTimers();
88
+ this.startCountdown();
89
+ }
90
+ if (this.interval && !value.length) {
91
+ clearInterval(this.interval);
92
+ }
93
+ }
94
+ componentWillLoad() {
95
+ const promises = [];
96
+ this.luckywheels = [];
97
+ if (this.endpoint) {
98
+ const consentsPromise = this.getLuckyWheels();
99
+ promises.push(consentsPromise);
100
+ }
101
+ if (this.translationUrl) {
102
+ const translationPromise = getTranslations(this.translationUrl);
103
+ promises.push(translationPromise);
104
+ }
105
+ return Promise.all(promises);
106
+ }
107
+ getLuckyWheels() {
108
+ let url = new URL(this.endpoint + `/v1/wof/lotteries`);
109
+ let reqHeaders = new Headers();
110
+ url.searchParams.append('language', this.language);
111
+ if (this.session) {
112
+ reqHeaders.append('X-SessionId', this.session);
113
+ }
114
+ let requestOptions = {
115
+ method: 'GET',
116
+ headers: reqHeaders,
117
+ };
118
+ this.isLoading = true;
119
+ fetch(url.href, requestOptions).then((res) => res.json()).then((res) => {
120
+ this.luckywheels = res.items;
121
+ }).catch((err) => {
122
+ throw new Error(err);
123
+ }).finally(() => {
124
+ this.isLoading = false;
125
+ });
126
+ }
127
+ getLuckyWheelsHistory(luckywheelId) {
128
+ let url = new URL(this.endpoint + `/v1/wof/outcome/${luckywheelId}`);
129
+ let reqHeaders = new Headers();
130
+ url.searchParams.append('language', this.language);
131
+ if (this.session) {
132
+ reqHeaders.append('X-SessionId', this.session);
133
+ }
134
+ let requestOptions = {
135
+ method: 'GET',
136
+ headers: reqHeaders,
137
+ };
138
+ return fetch(url.href, requestOptions).then((res) => res.json());
139
+ }
140
+ componentDidRender() {
141
+ if (!this.limitStylingAppends && this.host) {
142
+ if (this.clientStyling)
143
+ this.setClientStyling();
144
+ if (this.clientStylingUrl)
145
+ this.setClientStylingURL();
146
+ this.limitStylingAppends = true;
147
+ }
148
+ }
149
+ disconnectedCallback() {
150
+ this.interval && clearInterval(this.interval);
151
+ }
152
+ startCountdown() {
153
+ this.interval = setInterval(() => {
154
+ this.updateTimers();
155
+ }, 1000);
156
+ }
157
+ updateTimers() {
158
+ const now = new Date().getTime();
159
+ this.timers = this.luckywheels.reduce((acc, luckywheel) => {
160
+ var _a;
161
+ const expirationDate = new Date((_a = luckywheel.current) === null || _a === void 0 ? void 0 : _a.endTime).getTime();
162
+ const diff = expirationDate - now;
163
+ let countdown = '00h:00m:00s';
164
+ if (diff < 1) {
165
+ this.removeLuckyWheel(luckywheel.program.id);
166
+ }
167
+ else {
168
+ const { days, hours, minutes, seconds } = {
169
+ days: String(Math.floor(diff / (1000 * 60 * 60 * 24))).padStart(2, '0'),
170
+ hours: String(Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
171
+ minutes: String(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
172
+ seconds: String(Math.floor((diff % (1000 * 60)) / 1000)).padStart(2, '0')
173
+ };
174
+ countdown = days === '00'
175
+ ? `${hours}h:${minutes}m:${seconds}s`
176
+ : `${days}d:${hours}h:${minutes}m`;
177
+ }
178
+ return Object.assign(Object.assign({}, acc), { [luckywheel.program.id]: countdown });
179
+ }, {});
180
+ }
181
+ removeLuckyWheel(id) {
182
+ this.luckywheels = this.luckywheels.filter((luckywheel) => luckywheel.program.id !== id);
183
+ window.postMessage({ type: 'LuckyWheelHasExpired', id });
184
+ }
185
+ async sendHistoryRequest() {
186
+ this.historyLoading = true;
187
+ if (!this.luckywheels.length) {
188
+ return;
189
+ }
190
+ const promises = [];
191
+ this.luckywheels.forEach(async (luckywheel) => {
192
+ promises.push(this.getLuckyWheelsHistory(luckywheel.program.id).then(res => {
193
+ this.luckywheelHistory[luckywheel.program.id] = res.items;
194
+ }));
195
+ });
196
+ await Promise.all(promises);
197
+ this.historyLoading = false;
198
+ this.historyLoaded = true;
199
+ }
200
+ getLuckyWheelClasses(luckyWheel) {
201
+ return {
202
+ LuckyWheelsCard: true,
203
+ LuckyWheelsEmptyNumber: luckyWheel.current.remainingTimes === 0
204
+ };
205
+ }
206
+ getLuckyWheelName(luckywheel) {
207
+ var _a, _b;
208
+ return ((_a = luckywheel.program) === null || _a === void 0 ? void 0 : _a.name['en']) || ((_b = luckywheel.program) === null || _b === void 0 ? void 0 : _b.name['*']);
209
+ }
210
+ getLuckyWheelHeaderTemplate(luckywheel) {
211
+ var _a, _b;
212
+ return (h("div", { class: "LuckyWheelsCardHeader" }, h("div", { class: `LuckyWheelsName` }, this.getLuckyWheelName(luckywheel)), (h("div", { class: "LuckyWheelsCounter" }, h("div", { class: `${((_a = luckywheel.current) === null || _a === void 0 ? void 0 : _a.remainingTimes) ? 'LuckyWheelsHighlightedCounter' : 'LuckyWheelsEmptyCounter'}` }, (_b = luckywheel.current) === null || _b === void 0 ? void 0 : _b.remainingTimes)))));
213
+ }
214
+ getLuckyWheelTemplate(luckywheel, index) {
215
+ const countdown = this.timers[luckywheel.program.id];
216
+ //TODO: canceled status
217
+ const isCanceled = luckywheel.current.remainingTimes === 0;
218
+ return (h("div", { class: this.getLuckyWheelClasses(luckywheel), onClick: this.handleLuckyWheelClick, key: luckywheel.program.id, "data-id": luckywheel.program.id, "data-index": index }, this.getLuckyWheelHeaderTemplate(luckywheel), isCanceled ? (h("div", { class: "ForfeitedMessage" }, h("div", null, translate('canceled', this.language)), h("div", null, translate('support', this.language)))) : (h("div", { class: "LuckyWheelsCountdownWrapper" }, h("span", { class: "LuckyWheelsCountdown" }, countdown)))));
219
+ }
220
+ getHeaderTemplate() {
221
+ return h("header", { class: "LuckyWheelsListPopupHeader" }, h("button", { onClick: this.showTooltip, class: "EngagementSuiteIconButton Help" }), h("div", { class: "LuckyWheelsListPopupHeaderName" }, translate('luckyWheel', this.language)), h("button", { class: "EngagementSuiteIconButton Close", onClick: this.handleCloseClick }));
222
+ }
223
+ getListTemplate() {
224
+ if (this.isLoading) {
225
+ return h("general-animation-loading", null);
226
+ }
227
+ if (this.luckywheels.length) {
228
+ return h("div", { class: "LuckyWheelsListWrapper" }, h("div", { class: "LuckyWheelsList" }, this.luckywheels.map((luckywheel, index) => this.getLuckyWheelTemplate(luckywheel, index))));
229
+ }
230
+ else {
231
+ return h("div", { class: "LuckyWheelsListEmpty" }, h("h2", null, translate('noluckywheels', this.language)), h("p", null, translate('tryOtherGames', this.language)));
232
+ }
233
+ }
234
+ getTooltipTemplate() {
235
+ if (this.tooltip) {
236
+ return h("div", { class: "EngagementSuiteTooltipBackdrop" }, h("div", { class: "EngagementSuiteTooltip" }, h("button", { class: "EngagementSuiteIconButton Close", onClick: this.hideTooltip }), translate('tooltip', this.language)));
237
+ }
238
+ else {
239
+ return '';
240
+ }
241
+ }
242
+ getTabsTemplate() {
243
+ return h("div", { class: "EngagementSuiteTabsWrapper" }, h("div", { class: "EngagementSuiteTabs" }, h("div", { "data-index": "1", onClick: this.handleTabChange, class: `EngagementSuiteTab ${this.activeTab === 1 ? 'Active' : ''}` }, translate('luckywheels', this.language)), h("div", { "data-index": "2", onClick: this.handleTabChange, class: `EngagementSuiteTab ${this.activeTab === 2 ? 'Active' : ''}` }, translate('history', this.language))));
244
+ }
245
+ getHistoryTabTemplate() {
246
+ return h("div", { class: "HistoryWrapper" }, h("div", { class: "HistoryCols" }, h("div", { class: "HistoryColName Rewards" }, translate('rewards', this.language)), h("div", { class: "HistoryColName Issued" }, translate('issued', this.language)), h("div", { class: "HistoryColName Time" }, translate('time', this.language))), this.historyLoading
247
+ ? getHistoryLoaderTemplate(this.language)
248
+ : getLuckyWheelsHistoryTemplate(this.luckywheels, this.luckywheelHistory, this.openedHistoryIds, this.toggleLuckyWheelHistory, this.language));
249
+ }
250
+ getTabsContentTemplate() {
251
+ return this.activeTab === 1
252
+ ? this.getListTemplate()
253
+ : this.getHistoryTabTemplate();
254
+ }
255
+ render() {
256
+ return h("div", { key: 'bec9d35e1b9362a5098ab53c9fddb620b407b17e', class: `LuckyWheelsListPopup ${this.device}` }, this.getHeaderTemplate(), this.getTabsTemplate(), this.getTabsContentTemplate(), this.getTooltipTemplate());
257
+ }
258
+ static get is() { return "casino-engagement-suite-luckywheel-list"; }
259
+ static get encapsulation() { return "shadow"; }
260
+ static get originalStyleUrls() {
261
+ return {
262
+ "$": ["casino-engagement-suite-luckywheel-list.scss"]
263
+ };
264
+ }
265
+ static get styleUrls() {
266
+ return {
267
+ "$": ["casino-engagement-suite-luckywheel-list.css"]
268
+ };
269
+ }
270
+ static get properties() {
271
+ return {
272
+ "clientStyling": {
273
+ "type": "string",
274
+ "mutable": false,
275
+ "complexType": {
276
+ "original": "string",
277
+ "resolved": "string",
278
+ "references": {}
279
+ },
280
+ "required": false,
281
+ "optional": false,
282
+ "docs": {
283
+ "tags": [],
284
+ "text": "Client custom styling via string"
285
+ },
286
+ "attribute": "client-styling",
287
+ "reflect": true,
288
+ "defaultValue": "''"
289
+ },
290
+ "clientStylingUrl": {
291
+ "type": "string",
292
+ "mutable": false,
293
+ "complexType": {
294
+ "original": "string",
295
+ "resolved": "string",
296
+ "references": {}
297
+ },
298
+ "required": false,
299
+ "optional": false,
300
+ "docs": {
301
+ "tags": [],
302
+ "text": "Client custom styling via url"
303
+ },
304
+ "attribute": "client-styling-url",
305
+ "reflect": true,
306
+ "defaultValue": "''"
307
+ },
308
+ "language": {
309
+ "type": "string",
310
+ "mutable": false,
311
+ "complexType": {
312
+ "original": "string",
313
+ "resolved": "string",
314
+ "references": {}
315
+ },
316
+ "required": false,
317
+ "optional": false,
318
+ "docs": {
319
+ "tags": [],
320
+ "text": "Language of the widget"
321
+ },
322
+ "attribute": "language",
323
+ "reflect": false,
324
+ "defaultValue": "'en'"
325
+ },
326
+ "device": {
327
+ "type": "string",
328
+ "mutable": false,
329
+ "complexType": {
330
+ "original": "\"Mobile\" | \"Tablet\" | \"Desktop\"",
331
+ "resolved": "\"Desktop\" | \"Mobile\" | \"Tablet\"",
332
+ "references": {}
333
+ },
334
+ "required": false,
335
+ "optional": false,
336
+ "docs": {
337
+ "tags": [],
338
+ "text": "User's device type"
339
+ },
340
+ "attribute": "device",
341
+ "reflect": false,
342
+ "defaultValue": "'Mobile' as 'Mobile' | 'Tablet' | 'Desktop'"
343
+ },
344
+ "luckywheels": {
345
+ "type": "unknown",
346
+ "mutable": true,
347
+ "complexType": {
348
+ "original": "LuckyWheel[]",
349
+ "resolved": "LuckyWheel[]",
350
+ "references": {
351
+ "LuckyWheel": {
352
+ "location": "import",
353
+ "path": "../../components",
354
+ "id": "../../../../packages/stencil/casino-engagement-suite-luckywheel-list/src/components.d.ts::unknown"
355
+ }
356
+ }
357
+ },
358
+ "required": false,
359
+ "optional": false,
360
+ "docs": {
361
+ "tags": [],
362
+ "text": "List of lucky wheels"
363
+ },
364
+ "defaultValue": "[] as Array<LuckyWheel>"
365
+ },
366
+ "endpoint": {
367
+ "type": "string",
368
+ "mutable": false,
369
+ "complexType": {
370
+ "original": "string",
371
+ "resolved": "string",
372
+ "references": {}
373
+ },
374
+ "required": true,
375
+ "optional": false,
376
+ "docs": {
377
+ "tags": [],
378
+ "text": "The NWA endpoint"
379
+ },
380
+ "attribute": "endpoint",
381
+ "reflect": false
382
+ },
383
+ "session": {
384
+ "type": "string",
385
+ "mutable": false,
386
+ "complexType": {
387
+ "original": "string",
388
+ "resolved": "string",
389
+ "references": {}
390
+ },
391
+ "required": false,
392
+ "optional": true,
393
+ "docs": {
394
+ "tags": [],
395
+ "text": "The NWA session for the logged-in user"
396
+ },
397
+ "attribute": "session",
398
+ "reflect": false
399
+ },
400
+ "translationUrl": {
401
+ "type": "string",
402
+ "mutable": false,
403
+ "complexType": {
404
+ "original": "string",
405
+ "resolved": "string",
406
+ "references": {}
407
+ },
408
+ "required": false,
409
+ "optional": true,
410
+ "docs": {
411
+ "tags": [],
412
+ "text": "Translations via URL"
413
+ },
414
+ "attribute": "translation-url",
415
+ "reflect": false,
416
+ "defaultValue": "''"
417
+ }
418
+ };
419
+ }
420
+ static get states() {
421
+ return {
422
+ "tooltip": {},
423
+ "timers": {},
424
+ "limitStylingAppends": {},
425
+ "activeTab": {},
426
+ "historyLoading": {},
427
+ "luckywheelHistory": {},
428
+ "openedHistoryIds": {},
429
+ "historyLoaded": {},
430
+ "isLoading": {}
431
+ };
432
+ }
433
+ static get events() {
434
+ return [{
435
+ "method": "close",
436
+ "name": "close",
437
+ "bubbles": true,
438
+ "cancelable": true,
439
+ "composed": true,
440
+ "docs": {
441
+ "tags": [],
442
+ "text": ""
443
+ },
444
+ "complexType": {
445
+ "original": "void",
446
+ "resolved": "void",
447
+ "references": {}
448
+ }
449
+ }];
450
+ }
451
+ static get elementRef() { return "host"; }
452
+ static get watchers() {
453
+ return [{
454
+ "propName": "luckywheels",
455
+ "methodName": "luckywheelsPropHandler"
456
+ }];
457
+ }
458
+ static get listeners() {
459
+ return [{
460
+ "name": "message",
461
+ "method": "handleEvent",
462
+ "target": "window",
463
+ "capture": false,
464
+ "passive": false
465
+ }];
466
+ }
467
+ }
@@ -0,0 +1 @@
1
+ export { CasinoEngagementSuiteLuckyWheelList } from './casino-engagement-suite-luckywheel-list';
@@ -0,0 +1 @@
1
+ export * from './components/casino-engagement-suite-luckywheel-list';
@@ -0,0 +1,14 @@
1
+ export var LuckyWheelRewardType;
2
+ (function (LuckyWheelRewardType) {
3
+ LuckyWheelRewardType[LuckyWheelRewardType["FreeSpins"] = 0] = "FreeSpins";
4
+ LuckyWheelRewardType[LuckyWheelRewardType["LuckyWheel"] = 1] = "LuckyWheel";
5
+ LuckyWheelRewardType[LuckyWheelRewardType["Leaderboard"] = 2] = "Leaderboard";
6
+ LuckyWheelRewardType[LuckyWheelRewardType["Challenge"] = 3] = "Challenge";
7
+ LuckyWheelRewardType[LuckyWheelRewardType["Custom"] = 4] = "Custom";
8
+ })(LuckyWheelRewardType || (LuckyWheelRewardType = {}));
9
+ export var LuckyWheelHistoryLevelStatus;
10
+ (function (LuckyWheelHistoryLevelStatus) {
11
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Completed"] = 0] = "Completed";
12
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Expired"] = 1] = "Expired";
13
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Forfeited"] = 2] = "Forfeited";
14
+ })(LuckyWheelHistoryLevelStatus || (LuckyWheelHistoryLevelStatus = {}));
@@ -0,0 +1,52 @@
1
+ import { LuckyWheelRewardType } from "../models/luckywheel";
2
+ import { h } from "@stencil/core";
3
+ import { translate } from "../utils/locale.utils";
4
+ import { format } from "date-fns";
5
+ export const getHistoryLoaderTemplate = (lang) => {
6
+ return h("div", { class: "HistoryLoader" }, h("casino-engagement-suite-progress-bar", { indeterminate: true }), h("span", null, translate('loading', lang)));
7
+ };
8
+ const getRewardNameByType = (type, lang) => {
9
+ switch (type) {
10
+ case 0: return translate('freeSpins', lang);
11
+ case 1: return translate('luckyWheel', lang);
12
+ case 2: return translate('leaderboard', lang);
13
+ case 3: return translate('mission', lang);
14
+ }
15
+ };
16
+ export const getRewardTemplate = (reward, lang) => {
17
+ const isCustom = reward.Type === LuckyWheelRewardType.Custom;
18
+ const rewardName = isCustom ? reward.RewardDescription : getRewardNameByType(reward.Type, lang);
19
+ const isRewarded = isCustom || reward.IsRewarded;
20
+ return h("div", { class: `HistoryRewardsItem ${isRewarded || isCustom ? 'IsRewarded' : 'IsNotRewarded'}` }, h("span", { class: "HistoryRewardsItemName" }, rewardName), !isCustom && h("div", { class: `EngagementSuiteIconButton ${isRewarded ? 'Check' : 'Close'}` }));
21
+ };
22
+ export const getHistoryLevelRewardsTemplate = (level, lang) => {
23
+ return h("div", { class: "HistoryRewardsList" }, h("div", { class: "EngagementSuiteIconButton CupRewardList" }), Object.values(level.Rewards).map(reward => getRewardTemplate(reward, lang)));
24
+ };
25
+ export const getHistoryLevelTemplate = (level, index, lang) => {
26
+ return h("div", { class: "HistoryLevelInfo" }, h("span", { class: "Level" }, `${translate('level', lang)} ${index + 1}`), h("span", { class: "Time" }, format(new Date(level.Time), 'LLL d, yyyy HH:mm:ss')));
27
+ };
28
+ const getRewards = (luckywheel, result) => {
29
+ var _a, _b, _c, _d;
30
+ const index = result.wheelOfFortunePartitionIndex || 0;
31
+ const name = (_b = (_a = luckywheel.program.wheelOfFortune) === null || _a === void 0 ? void 0 : _a.partitions[index]) === null || _b === void 0 ? void 0 : _b.name;
32
+ const displayName = name['en'] || name['*'];
33
+ const assets = (_d = (_c = luckywheel.program.wheelOfFortune) === null || _c === void 0 ? void 0 : _c.partitions[index]) === null || _d === void 0 ? void 0 : _d.image1;
34
+ const displayAssets = assets['en'] || assets['*'];
35
+ const programName = luckywheel.program.name['en'] || luckywheel.program.name['*'];
36
+ return h("div", { class: "HistoryRewards" }, displayName ? displayName : displayAssets ? (h("img", { src: displayAssets })) : programName);
37
+ };
38
+ const getStatus = (state) => {
39
+ return state === 'fulfilled' ? 'Success' : 'Failed';
40
+ };
41
+ export const getLuckyWheelsHistoryTemplate = (luckywheels, historyGroups, openedHistoryIds, toggleLuckyWheelHistory, lang) => {
42
+ if (luckywheels.length === 0) {
43
+ return h("p", { class: "HistoryEmptyMessage" }, translate('noHistory', lang));
44
+ }
45
+ return h("div", { class: "HistoryList" }, luckywheels.map((luckywheel) => {
46
+ return h("div", { key: luckywheel.program.id, class: `HistoryListItem ${openedHistoryIds.includes(luckywheel.program.id) ? 'Opened' : 'Closed'}` }, h("header", { class: "HistoryListItemHeader", "data-id": luckywheel.program.id, onClick: toggleLuckyWheelHistory }, luckywheel.program.name['en'] || luckywheel.program.name['*'], h("button", { class: "EngagementSuiteIconButton ArrowDown" })), h("div", { class: "HistoryListItemBody" }, h("div", { class: "HistoryInfoRow" }, Object.entries(historyGroups).map((histories) => {
47
+ return histories[0] === luckywheel.program.id && histories[1].map((history) => {
48
+ return h("div", { class: "HistoryInfo" }, h("div", { class: "HistoryCol Rewards" }, getRewards(luckywheel, history.draw.result)), h("div", { class: "HistoryCol Issued" }, getStatus(history.draw.state)), h("div", { class: "HistoryCol Time" }, format(new Date(history.draw.time), 'LLL d, yyyy HH:mm:ss')));
49
+ });
50
+ }))));
51
+ }));
52
+ };
@@ -0,0 +1,46 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const SUPPORTED_LANGUAGES = ['en'];
3
+ const TRANSLATIONS = {
4
+ en: {
5
+ luckywheels: 'LuckyWheels',
6
+ join: 'Join',
7
+ unjoin: 'Unjoin',
8
+ new: 'new',
9
+ noluckywheels: 'No Unlocked LuckyWheel',
10
+ tryOtherGames: 'Try winning LuckyWheel as rewards or launching other booster games',
11
+ tooltip: 'LuckyWheels where your real money bets contribute towards the level progress to achieve the level reward',
12
+ history: 'History',
13
+ rewards: 'Rewards',
14
+ issued: 'Issued',
15
+ time: 'Time',
16
+ loading: 'Loading...',
17
+ noHistory: 'No LuckyWheels’ history available (last 30 days)',
18
+ freeSpins: 'Free Spins',
19
+ luckyWheel: 'LuckyWheel',
20
+ leaderboard: 'Leaderboard',
21
+ mission: 'Mission',
22
+ canceled: 'The luckywheel has been canceled.',
23
+ support: 'Please, contact support.'
24
+ }
25
+ };
26
+ export const translate = (key, customLang) => {
27
+ const lang = customLang;
28
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
29
+ };
30
+ export const getTranslations = (url) => {
31
+ // fetch url, get the data, replace the TRANSLATIONS content
32
+ return new Promise((resolve, reject) => {
33
+ fetch(url)
34
+ .then((res) => res.json())
35
+ .then((data) => {
36
+ Object.keys(data).forEach((item) => {
37
+ for (let key in data[item]) {
38
+ TRANSLATIONS[item][key] = data[item][key];
39
+ }
40
+ });
41
+ resolve(TRANSLATIONS);
42
+ }).catch(err => {
43
+ reject(err);
44
+ });
45
+ });
46
+ };
@@ -0,0 +1,3 @@
1
+ export function format(first, middle, last) {
2
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
3
+ }
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };