@everymatrix/casino-engagement-suite-container 1.0.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/casino-engagement-suite-container/casino-engagement-suite-container.esm.js +1 -0
  2. package/dist/casino-engagement-suite-container/index.esm.js +0 -0
  3. package/dist/casino-engagement-suite-container/p-2c9a2139.entry.js +1 -0
  4. package/dist/casino-engagement-suite-container/p-e1255160.js +1 -0
  5. package/dist/casino-engagement-suite-container/p-efde3fd4.js +2 -0
  6. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  7. package/dist/cjs/casino-engagement-suite-bar_11.cjs.entry.js +4833 -0
  8. package/dist/cjs/casino-engagement-suite-container.cjs.js +25 -0
  9. package/dist/cjs/index-4ca644e2.js +1348 -0
  10. package/dist/cjs/index.cjs.js +2 -0
  11. package/dist/cjs/loader.cjs.js +15 -0
  12. package/dist/collection/collection-manifest.json +73 -0
  13. package/dist/collection/components/casino-engagement-suite-container/casino-engagement-suite-container.css +39 -0
  14. package/dist/collection/components/casino-engagement-suite-container/casino-engagement-suite-container.js +745 -0
  15. package/dist/collection/components/casino-engagement-suite-container/index.js +1 -0
  16. package/dist/collection/index.js +1 -0
  17. package/dist/collection/models/casino-engagement-suite-config.js +17 -0
  18. package/dist/collection/utils/constants.js +6 -0
  19. package/dist/collection/utils/utils.js +24 -0
  20. package/dist/esm/app-globals-0f993ce5.js +3 -0
  21. package/dist/esm/casino-engagement-suite-bar_11.entry.js +4819 -0
  22. package/dist/esm/casino-engagement-suite-container.js +20 -0
  23. package/dist/esm/index-2bd77432.js +1320 -0
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/loader.js +11 -0
  26. package/dist/index.cjs.js +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/stencil.config.dev.js +17 -0
  29. package/dist/stencil.config.js +17 -0
  30. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/casino-engagement-suite-container/.stencil/packages/stencil/casino-engagement-suite-container/stencil.config.d.ts +2 -0
  31. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/casino-engagement-suite-container/.stencil/packages/stencil/casino-engagement-suite-container/stencil.config.dev.d.ts +2 -0
  32. package/dist/types/components/casino-engagement-suite-container/casino-engagement-suite-container.d.ts +98 -0
  33. package/dist/types/components/casino-engagement-suite-container/index.d.ts +1 -0
  34. package/dist/types/components.d.ts +86 -0
  35. package/dist/types/index.d.ts +1 -0
  36. package/dist/types/models/casino-engagement-suite-config.d.ts +163 -0
  37. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  38. package/dist/types/utils/constants.d.ts +6 -0
  39. package/dist/types/utils/utils.d.ts +2 -0
  40. package/loader/cdn.js +1 -0
  41. package/loader/index.cjs.js +1 -0
  42. package/loader/index.d.ts +24 -0
  43. package/loader/index.es2017.js +1 -0
  44. package/loader/index.js +2 -0
  45. package/loader/package.json +11 -0
  46. package/package.json +36 -0
@@ -0,0 +1,745 @@
1
+ import { __rest } from "tslib";
2
+ import { h } from "@stencil/core";
3
+ import "../../../../../casino-engagement-suite-challenges-details/dist/types/index";
4
+ import "../../../../../casino-engagement-suite-bar/dist/types/index";
5
+ import "../../../../../casino-engagement-suite-challenges-list/dist/types/index";
6
+ import "../../../../../casino-engagement-suite-free-spins-list/dist/types/index";
7
+ import "../../../../../casino-engagement-suite-free-spins-details/dist/types/index";
8
+ import "../../../../../casino-engagement-suite-jackpots-list/dist/types/index";
9
+ import "../../../../../casino-engagement-suite-jackpot-details/dist/types/index";
10
+ import "@everymatrix/casino-engagement-suite-tournament";
11
+ import "../../../../../casino-engagement-suite-modal-container/dist/types/index";
12
+ import { ChallengeLevelProgressStatus, ChallengeProgressStatus } from "../../models/casino-engagement-suite-config";
13
+ import { getDeviceType, getScreenOrientation } from "../../utils/utils";
14
+ import { MODAL_TYPES } from "../../utils/constants";
15
+ import differenceInSeconds from "date-fns/differenceInSeconds";
16
+ export class CasinoEngagementSuiteContainer {
17
+ constructor() {
18
+ this.handlePopupClose = (listName, detailsName) => () => {
19
+ if (listName === 'showChallengesList' && this.isForfeitedChallengeLabel) {
20
+ this.isForfeitedChallengeLabel = false;
21
+ this.setChallengePercent();
22
+ }
23
+ this[listName] = false;
24
+ this[detailsName] = false;
25
+ this.activeWidget = '';
26
+ };
27
+ this.handleJackpotsPopupClose = () => {
28
+ this.showJackpotsList = false;
29
+ this.showJackpotDetails = false;
30
+ this.activeWidget = '';
31
+ };
32
+ this.handleChallengePopupBack = () => {
33
+ this.showChallengeDetails = false;
34
+ this.showChallengesList = true;
35
+ };
36
+ this.handleFreeSpinsPopupBack = () => {
37
+ this.showFreeSpinsDetails = false;
38
+ this.showFreeSpinsList = true;
39
+ };
40
+ this.handleResetNewChallengeLabel = (e) => {
41
+ if (!this.challenges)
42
+ return;
43
+ if (e.detail === 'list') {
44
+ this.challenges.forEach(c => c.IsNew = false);
45
+ this.isChallengeLabel = false;
46
+ }
47
+ else {
48
+ const challenge = this.challenges.find(item => item.Id === e.detail);
49
+ if (challenge) {
50
+ challenge.IsNew = false;
51
+ }
52
+ }
53
+ this.challenges = [...this.challenges];
54
+ };
55
+ this.handleJackpotPopupBack = () => {
56
+ this.showJackpotDetails = false;
57
+ this.showJackpotsList = true;
58
+ };
59
+ this.orientationChangeHandler = () => {
60
+ this.orientation = getScreenOrientation();
61
+ this.barHeight = this.barWrapperEl.offsetHeight;
62
+ };
63
+ this.setClientStyling = () => {
64
+ let sheet = document.createElement('style');
65
+ sheet.innerHTML = this.clientStyling;
66
+ this.host.prepend(sheet);
67
+ };
68
+ this.setClientStylingURL = () => {
69
+ let url = new URL(this.clientStylingUrl);
70
+ let cssFile = document.createElement('style');
71
+ fetch(url.href)
72
+ .then((res) => res.text())
73
+ .then((data) => {
74
+ cssFile.innerHTML = data;
75
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
76
+ })
77
+ .catch((err) => {
78
+ console.log('Error ', err);
79
+ });
80
+ };
81
+ this.jackpotChangeStatusRequest = (ev) => {
82
+ ev.stopPropagation();
83
+ const id = ev.currentTarget.getAttribute('data-id');
84
+ this.jackpots = this.jackpots.map(jackpot => {
85
+ const matchedJackpotId = String(id) === String(jackpot.JackpotId);
86
+ return matchedJackpotId
87
+ ? Object.assign(Object.assign({}, jackpot), { Pending: true }) : jackpot;
88
+ });
89
+ if (this.showJackpotDetails) {
90
+ const updatedSelectedJackpot = this.jackpots.find(jackpot => jackpot.JackpotId === this.selectedJackpotId);
91
+ if (updatedSelectedJackpot) {
92
+ this.selectedJackpot = Object.assign({}, updatedSelectedJackpot);
93
+ }
94
+ }
95
+ const jackpotsEnabledStatuses = this.jackpots.reduce((acc, jackpot) => {
96
+ if (jackpot.Pending) {
97
+ acc[jackpot.JackpotId] = !jackpot.Enabled;
98
+ }
99
+ else {
100
+ acc[jackpot.JackpotId] = jackpot.Enabled;
101
+ }
102
+ return acc;
103
+ }, {});
104
+ window.postMessage({
105
+ type: 'JackpotChangeStatusRequest',
106
+ data: jackpotsEnabledStatuses,
107
+ });
108
+ };
109
+ this.onLeaderboardsClose = () => {
110
+ this.showLeaderboardWidget = false;
111
+ this.activeWidget = '';
112
+ };
113
+ this.clientStyling = '';
114
+ this.clientStylingUrl = '';
115
+ this.language = 'en';
116
+ this.orientation = 'Landscape';
117
+ this.device = 'Mobile';
118
+ this.showChallengesList = false;
119
+ this.showFreeSpinsList = false;
120
+ this.showJackpotsList = false;
121
+ this.showChallengeDetails = false;
122
+ this.showFreeSpinsDetails = false;
123
+ this.showJackpotDetails = false;
124
+ this.showLeaderboardWidget = false;
125
+ this.challengePercent = undefined;
126
+ this.remainingFreeSpins = undefined;
127
+ this.highlightChallenge = false;
128
+ this.limitStylingAppends = false;
129
+ this.activeWidget = undefined;
130
+ this.challenges = undefined;
131
+ this.inProgressChallenges = undefined;
132
+ this.jackpots = [];
133
+ this.freeSpins = undefined;
134
+ this.leaderboards = undefined;
135
+ this.gameSlug = '';
136
+ this.pausedChallengeIds = [];
137
+ this.isChallengeLabel = false;
138
+ this.isForfeitedSpinsLabel = false;
139
+ this.isForfeitedChallengeLabel = false;
140
+ this.isJoiningToChallenge = false;
141
+ this.selectedChallenge = undefined;
142
+ this.selectedJackpot = undefined;
143
+ this.selectedSpin = undefined;
144
+ this.selectedSpinId = undefined;
145
+ this.selectedChallengeId = undefined;
146
+ this.selectedJackpotId = undefined;
147
+ this.barHeight = 0;
148
+ }
149
+ handleEvent(e) {
150
+ var _a;
151
+ const _b = e === null || e === void 0 ? void 0 : e.data, { type } = _b, rest = __rest(_b, ["type"]);
152
+ switch (type) {
153
+ case 'ChallengeGrant': {
154
+ const newChallenge = e.data.data.challengeProgressData[0];
155
+ const index = this.challenges.findIndex(challenge => differenceInSeconds(new Date(challenge.ExpirationTime), new Date(newChallenge.ExpirationTime)) > 0);
156
+ if (index > -1) {
157
+ this.challenges.splice(index, 0, newChallenge);
158
+ }
159
+ else {
160
+ this.challenges.push(newChallenge);
161
+ }
162
+ this.challenges = [...this.challenges];
163
+ this.isChallengeLabel = true;
164
+ break;
165
+ }
166
+ case 'CampaignGrant': {
167
+ this.grantFreeSpinCampaigns(e.data.data);
168
+ break;
169
+ }
170
+ case 'ForfeitCampaign': {
171
+ const forfeitedId = e.data.data.toString();
172
+ const forfeitedItem = this.freeSpins.find(fs => fs.Id === forfeitedId);
173
+ forfeitedItem.IsForfeited = true;
174
+ this.freeSpins = [...this.freeSpins];
175
+ this.isForfeitedSpinsLabel = true;
176
+ this.setRemainingFreeSpins();
177
+ break;
178
+ }
179
+ case 'ChallengeForfeitNotification': {
180
+ const forfeitedChallenge = (_a = this.challenges) === null || _a === void 0 ? void 0 : _a.find(c => c.ChallengeId === e.data.data.ChallengeId);
181
+ if (forfeitedChallenge) {
182
+ forfeitedChallenge.Status = 5;
183
+ this.inProgressChallenges = [...this.inProgressChallenges.filter(id => id !== forfeitedChallenge.Id)];
184
+ this.challenges = [...this.challenges];
185
+ this.isForfeitedChallengeLabel = true;
186
+ this.setChallengePercent();
187
+ }
188
+ break;
189
+ }
190
+ case 'ChallengeHasExpired': {
191
+ this.setChallengePercent();
192
+ break;
193
+ }
194
+ case 'FreeSpinHasExpired': {
195
+ this.setRemainingFreeSpins();
196
+ break;
197
+ }
198
+ case 'BarLeaderboardsClick': {
199
+ this.showLeaderboardWidget = true;
200
+ this.showFreeSpinsList = false;
201
+ this.showChallengesList = false;
202
+ this.showJackpotsList = false;
203
+ this.showChallengeDetails = false;
204
+ this.showJackpotDetails = false;
205
+ this.showFreeSpinsDetails = false;
206
+ this.activeWidget = 'Leaderboards';
207
+ break;
208
+ }
209
+ case 'BarChallengesClick': {
210
+ this.showChallengesList = true;
211
+ this.showFreeSpinsList = false;
212
+ this.showJackpotsList = false;
213
+ this.showChallengeDetails = false;
214
+ this.showJackpotDetails = false;
215
+ this.showFreeSpinsDetails = false;
216
+ this.showLeaderboardWidget = false;
217
+ this.activeWidget = 'Challenges';
218
+ this.isChallengeLabel = false;
219
+ break;
220
+ }
221
+ case 'BarFreeSpinsClick': {
222
+ this.showFreeSpinsList = true;
223
+ this.showChallengesList = false;
224
+ this.showJackpotsList = false;
225
+ this.showChallengeDetails = false;
226
+ this.showJackpotDetails = false;
227
+ this.showFreeSpinsDetails = false;
228
+ this.showLeaderboardWidget = false;
229
+ this.isForfeitedSpinsLabel = false;
230
+ this.activeWidget = 'FreeSpins';
231
+ break;
232
+ }
233
+ case 'BarJackpotsClick': {
234
+ this.showJackpotsList = true;
235
+ this.showFreeSpinsList = false;
236
+ this.showChallengesList = false;
237
+ this.showChallengeDetails = false;
238
+ this.showJackpotDetails = false;
239
+ this.showFreeSpinsDetails = false;
240
+ this.showLeaderboardWidget = false;
241
+ this.activeWidget = 'Jackpots';
242
+ break;
243
+ }
244
+ case 'ChallengeClick': {
245
+ this.selectedChallengeId = e.data.id;
246
+ this.selectedChallenge = this.challenges.find(challenge => challenge.Id === this.selectedChallengeId);
247
+ this.isChallengeLabel = false;
248
+ this.showChallengesList = false;
249
+ this.showChallengeDetails = true;
250
+ break;
251
+ }
252
+ case 'FreeSpinClick': {
253
+ this.selectedSpinId = e.data.id;
254
+ this.selectedSpin = this.freeSpins.find(spin => spin.AwardBonusId === this.selectedSpinId);
255
+ this.isForfeitedSpinsLabel = false;
256
+ this.showFreeSpinsList = false;
257
+ this.showFreeSpinsDetails = true;
258
+ break;
259
+ }
260
+ case 'JackpotClick': {
261
+ this.selectedJackpotId = e.data.id;
262
+ this.selectedJackpot = this.jackpots.find(jackpot => jackpot.JackpotId === this.selectedJackpotId);
263
+ this.showJackpotsList = false;
264
+ this.showJackpotDetails = true;
265
+ break;
266
+ }
267
+ case 'UpdateChallengeProgress': {
268
+ this.updateChallengeProgress(e.data.data);
269
+ break;
270
+ }
271
+ case 'UpdateFreeSpinsProgress': {
272
+ this.updateFreeSpinsProgress(e.data.data);
273
+ break;
274
+ }
275
+ case 'ChallengeChangeStatusNotification': {
276
+ const { IsEnabled, ChallengeId } = e.data.data;
277
+ if (!IsEnabled && !this.pausedChallengeIds.includes(ChallengeId)) {
278
+ this.pausedChallengeIds = [...this.pausedChallengeIds, ChallengeId];
279
+ }
280
+ else {
281
+ this.pausedChallengeIds = this.pausedChallengeIds.filter(id => id !== ChallengeId);
282
+ }
283
+ break;
284
+ }
285
+ case 'ShowChallengeRewardModal': {
286
+ const { ChallengeId, LevelId, HasError, ProcessedRewards } = rest.data;
287
+ const type = (ProcessedRewards === null || ProcessedRewards === void 0 ? void 0 : ProcessedRewards.length) ? MODAL_TYPES.REWARD_MODAL : MODAL_TYPES.SUPPORT_MODAL;
288
+ const event = {
289
+ modalType: type,
290
+ rewardMessage: this.getRewardMessage(ChallengeId, LevelId),
291
+ hasError: HasError
292
+ };
293
+ this.openModal.emit(event);
294
+ break;
295
+ }
296
+ case 'ShowConfirmationModal': {
297
+ const event = {
298
+ modalType: MODAL_TYPES.TARGET_MODAL,
299
+ confirmationData: rest,
300
+ };
301
+ this.openModal.emit(event);
302
+ break;
303
+ }
304
+ case 'ChallengeJoinRequest': {
305
+ this.isJoiningToChallenge = true;
306
+ break;
307
+ }
308
+ case 'JoinChallengeResult': {
309
+ const { Success, JoinId, UnjoinId } = e.data.data;
310
+ if (Success) {
311
+ if (JoinId) {
312
+ this.updateChallengeStatus(JoinId, 1, true);
313
+ }
314
+ if (UnjoinId) {
315
+ this.updateChallengeStatus(UnjoinId, 0, false);
316
+ }
317
+ this.challenges = [...this.challenges];
318
+ const updatedSelectedChallenge = this.challenges.find(challenge => challenge.Id === this.selectedChallengeId);
319
+ this.selectedChallenge = Object.assign({}, updatedSelectedChallenge);
320
+ }
321
+ this.isJoiningToChallenge = false;
322
+ this.closeModal.emit(MODAL_TYPES.TARGET_MODAL);
323
+ this.setChallengePercent();
324
+ break;
325
+ }
326
+ case 'ShowJackpotRewardModal': {
327
+ const { Amount, Currency } = e.data.data;
328
+ const event = {
329
+ modalType: MODAL_TYPES.JACKPOT_REWARD_MODAL,
330
+ winAmount: {
331
+ amount: Amount,
332
+ currency: Currency
333
+ }
334
+ };
335
+ this.openModal.emit(event);
336
+ break;
337
+ }
338
+ case 'UpdateJackpotBalance':
339
+ this.updateJackpotBalance(e.data.data);
340
+ break;
341
+ case 'UpdateJackpotStatus':
342
+ this.updateJackpotStatus(e.data.data);
343
+ break;
344
+ case 'JoinJackpotResult':
345
+ this.joinJackpotResult(e.data.data);
346
+ break;
347
+ }
348
+ }
349
+ componentDidLoad() {
350
+ this.orientation = getScreenOrientation();
351
+ this.device = getDeviceType();
352
+ window.screen.orientation.addEventListener('change', this.orientationChangeHandler);
353
+ }
354
+ componentDidRender() {
355
+ // start custom styling area
356
+ if (!this.limitStylingAppends && this.host) {
357
+ if (this.clientStyling)
358
+ this.setClientStyling();
359
+ if (this.clientStylingUrl)
360
+ this.setClientStylingURL();
361
+ this.limitStylingAppends = true;
362
+ }
363
+ // end custom styling area
364
+ this.barHeight = this.barWrapperEl.offsetHeight;
365
+ }
366
+ disconnectedCallback() {
367
+ window.screen.orientation.removeEventListener('change', this.orientationChangeHandler);
368
+ }
369
+ /**
370
+ * Called to initialize widget
371
+ * @param config
372
+ */
373
+ async init(config) {
374
+ var _a;
375
+ this.challenges = config.challenges;
376
+ this.inProgressChallenges = (_a = config.challenges) === null || _a === void 0 ? void 0 : _a.filter(c => c.Status === ChallengeProgressStatus.InProgress
377
+ || c.Status === ChallengeProgressStatus.PendingLevelReward).map(c => c.Id);
378
+ this.leaderboards = config.leaderboards;
379
+ this.jackpots = config.jackpots || [];
380
+ this.freeSpins = config.freeSpins;
381
+ this.gameSlug = config.slug;
382
+ this.setChallengePercent();
383
+ this.setChallengeLabel();
384
+ this.setRemainingFreeSpins();
385
+ this.setSpinsForfeitedLabel();
386
+ }
387
+ setChallengeLabel() {
388
+ if (!this.challenges)
389
+ return;
390
+ this.isChallengeLabel = !!this.challenges.filter((challenge) => challenge.IsNew).length;
391
+ }
392
+ setSpinsForfeitedLabel() {
393
+ var _a;
394
+ if (!this.freeSpins)
395
+ return;
396
+ this.isForfeitedSpinsLabel = !!((_a = this.freeSpins) === null || _a === void 0 ? void 0 : _a.filter((spin) => spin.IsForfeited).length);
397
+ }
398
+ setChallengePercent() {
399
+ if (!this.challenges)
400
+ return;
401
+ this.highlightChallenge = this.isForfeitedChallengeLabel;
402
+ const activeChallenge = this.challenges
403
+ .find(challenge => challenge.Status === ChallengeProgressStatus.InProgress);
404
+ if (activeChallenge) {
405
+ const activeLevel = activeChallenge.LevelProgresses
406
+ .find(progress => progress.ProgressStatus === ChallengeLevelProgressStatus.InProgress);
407
+ const completedLevel = activeChallenge.LevelProgresses
408
+ .filter(progress => progress.ProgressStatus === ChallengeLevelProgressStatus.Fillup ||
409
+ progress.ProgressStatus === ChallengeLevelProgressStatus.Completed).slice(-1)[0];
410
+ this.highlightChallenge = activeChallenge.LevelProgresses.every(progress => progress.ProgressPercentage === 100) ||
411
+ this.isForfeitedChallengeLabel;
412
+ this.challengePercent = activeLevel ? `${activeLevel.ProgressPercentage}%`
413
+ : (completedLevel ? `${completedLevel.ProgressPercentage}%` : '0%');
414
+ }
415
+ else {
416
+ this.challengePercent = '—';
417
+ }
418
+ }
419
+ setRemainingFreeSpins() {
420
+ if (!this.freeSpins)
421
+ return;
422
+ if (this.freeSpins.length) {
423
+ this.remainingFreeSpins = this.freeSpins.filter(f => !f.IsForfeited)
424
+ .reduce((acc, item) => acc + (item.NumberOfFreeSpins - item.NumberOfUsedFreeSpins), 0)
425
+ .toString();
426
+ }
427
+ else {
428
+ this.remainingFreeSpins = '—';
429
+ }
430
+ }
431
+ updateChallengeProgress(data) {
432
+ var _a;
433
+ const challenge = (_a = this.challenges) === null || _a === void 0 ? void 0 : _a.find(challenge => challenge.ChallengeId === data.ChallengeId);
434
+ if (challenge) {
435
+ if (data.Status === ChallengeProgressStatus.Completed) {
436
+ challenge.Status = data.Status;
437
+ this.inProgressChallenges = [...this.inProgressChallenges.filter(c => c !== challenge.Id)];
438
+ }
439
+ challenge.LevelProgresses = challenge.LevelProgresses.map(level => {
440
+ var _a;
441
+ const updatedLevel = (_a = data.Levels) === null || _a === void 0 ? void 0 : _a.find(l => l.LevelId === level.LevelId);
442
+ return updatedLevel
443
+ ? Object.assign(Object.assign({}, level), { ProgressPercentage: updatedLevel.ProgressPercentage, ProgressStatus: updatedLevel.ProgressStatus }) : level;
444
+ });
445
+ this.challenges = [...this.challenges];
446
+ }
447
+ if (this.showChallengeDetails) {
448
+ const updatedSelectedChallenge = this.challenges.find(challenge => challenge.Id === this.selectedChallengeId);
449
+ if (updatedSelectedChallenge) {
450
+ this.selectedChallenge = Object.assign({}, updatedSelectedChallenge);
451
+ }
452
+ }
453
+ this.setChallengePercent();
454
+ }
455
+ updateFreeSpinsProgress(data) {
456
+ var _a;
457
+ const campaign = (_a = this.freeSpins) === null || _a === void 0 ? void 0 : _a.find(campaign => campaign.AwardBonusId === data.AwardBonusId);
458
+ if (campaign) {
459
+ campaign.NumberOfUsedFreeSpins = data.NumberOfUsedFreeSpins;
460
+ campaign.VendorFreeSpinsRemainingCost = data.VendorFreeSpinsRemainingCost;
461
+ this.freeSpins = [...this.freeSpins];
462
+ }
463
+ if (this.showFreeSpinsDetails && this.selectedSpinId === data.AwardBonusId) {
464
+ const updatedSelectedCampaign = this.freeSpins.find(campaign => campaign.AwardBonusId === this.selectedSpinId);
465
+ if (updatedSelectedCampaign) {
466
+ this.selectedSpin = Object.assign({}, updatedSelectedCampaign);
467
+ }
468
+ }
469
+ this.setRemainingFreeSpins();
470
+ }
471
+ updateChallengeStatus(id, status, addToInProgress) {
472
+ var _a;
473
+ const challenge = (_a = this.challenges) === null || _a === void 0 ? void 0 : _a.find(c => c.Id === id);
474
+ if (challenge) {
475
+ challenge.Status = status;
476
+ this.inProgressChallenges = addToInProgress
477
+ ? [...this.inProgressChallenges, challenge.Id]
478
+ : this.inProgressChallenges.filter(id => id !== challenge.Id);
479
+ }
480
+ }
481
+ updateJackpotBalance(updatedJackpots) {
482
+ this.jackpots = this.jackpots.map(jackpot => {
483
+ const updatedJackpot = updatedJackpots.find(updatedJackpot => updatedJackpot.JackpotId === jackpot.JackpotId);
484
+ return updatedJackpot
485
+ ? Object.assign(Object.assign({}, jackpot), { Balance: updatedJackpot.Balance, WinBalance: updatedJackpot.WinBalance }) : jackpot;
486
+ });
487
+ if (this.showJackpotDetails) {
488
+ const updatedSelectedJackpot = this.jackpots.find(jackpot => jackpot.JackpotId === this.selectedJackpotId);
489
+ if (updatedSelectedJackpot) {
490
+ this.selectedJackpot = Object.assign({}, updatedSelectedJackpot);
491
+ }
492
+ }
493
+ }
494
+ updateJackpotStatus(statusUpdate) {
495
+ this.jackpots = this.jackpots.map(jackpot => {
496
+ const jackpotToUpdate = String(jackpot.JackpotId) === String(statusUpdate.JackpotId);
497
+ return jackpotToUpdate
498
+ ? Object.assign(Object.assign({}, jackpot), { IsClosed: statusUpdate.IsClosed, JackpotEndTime: statusUpdate.JackpotEndTime, Reason: statusUpdate.Reason }) : jackpot;
499
+ });
500
+ if (this.showJackpotDetails) {
501
+ const updatedSelectedJackpot = this.jackpots.find(jackpot => jackpot.JackpotId === this.selectedJackpotId);
502
+ if (updatedSelectedJackpot) {
503
+ this.selectedJackpot = Object.assign({}, updatedSelectedJackpot);
504
+ }
505
+ }
506
+ }
507
+ joinJackpotResult(joinResult) {
508
+ if (joinResult.Success) {
509
+ const jackpotIds = Object.keys(joinResult.JackpotIds);
510
+ if (jackpotIds.length > 0) {
511
+ this.jackpots = this.jackpots.map(jackpot => {
512
+ const matchedJackpotId = jackpotIds.find(jackpotId => String(jackpotId) === String(jackpot.JackpotId));
513
+ return matchedJackpotId
514
+ ? Object.assign(Object.assign(Object.assign({}, jackpot), (jackpot.Enabled !== joinResult.JackpotIds[matchedJackpotId] && { Pending: false })), { Enabled: joinResult.JackpotIds[matchedJackpotId] }) : jackpot;
515
+ });
516
+ }
517
+ if (this.showJackpotDetails) {
518
+ const updatedSelectedJackpot = this.jackpots.find(jackpot => jackpot.JackpotId === this.selectedJackpotId);
519
+ if (updatedSelectedJackpot) {
520
+ this.selectedJackpot = Object.assign({}, updatedSelectedJackpot);
521
+ }
522
+ }
523
+ }
524
+ }
525
+ grantFreeSpinCampaigns(campaigns) {
526
+ campaigns.forEach(newCampaign => {
527
+ const index = this.freeSpins.findIndex(campaign => differenceInSeconds(new Date(campaign.ExpiryDate), new Date(newCampaign.ExpiryDate)) > 0);
528
+ if (index > -1) {
529
+ this.freeSpins.splice(index, 0, newCampaign);
530
+ }
531
+ else {
532
+ this.freeSpins.push(newCampaign);
533
+ }
534
+ this.freeSpins = [...this.freeSpins];
535
+ });
536
+ this.setRemainingFreeSpins();
537
+ }
538
+ getChallengesWidgets() {
539
+ return h("div", null, h("div", { class: this.showChallengesList ? 'Backdrop Opened' : 'Backdrop' }, h("casino-engagement-suite-challenges-list", { device: this.device, class: "CasinoEngagementSuiteDialog", onResetNewChallengeLabel: this.handleResetNewChallengeLabel, onClose: this.handlePopupClose('showChallengesList', 'showChallengeDetails'), challenges: this.challenges, inProgressChallenges: this.inProgressChallenges, isJoiningToChallenge: this.isJoiningToChallenge, pausedChallengeIds: this.pausedChallengeIds })), h("div", { class: this.showChallengeDetails ? 'Backdrop Opened' : 'Backdrop' }, this.showChallengeDetails && (h("casino-engagement-suite-challenges-details", { device: this.device, class: "CasinoEngagementSuiteDialog", onResetNewChallengeLabel: this.handleResetNewChallengeLabel, onBack: this.handleChallengePopupBack, onClose: this.handlePopupClose('showChallengesList', 'showChallengeDetails'), "game-slug": this.gameSlug, challenge: this.selectedChallenge, inProgressChallenges: this.inProgressChallenges, isJoiningToChallenge: this.isJoiningToChallenge, pausedChallengeIds: this.pausedChallengeIds }))));
540
+ }
541
+ getLeaderboardsWidgets() {
542
+ return (h("div", { class: this.showLeaderboardWidget ? 'Backdrop Opened' : 'Backdrop' }, h("casino-engagement-suite-tournament", { class: "CasinoEngagementSuiteDialog", leaderboardsInit: this.leaderboards, onClose: this.onLeaderboardsClose })));
543
+ }
544
+ getFreeSpinWidgets() {
545
+ return h("div", null, h("div", { class: this.showFreeSpinsList ? 'Backdrop Opened' : 'Backdrop' }, h("casino-engagement-suite-free-spins-list", { device: this.device, class: "CasinoEngagementSuiteDialog", onClose: this.handlePopupClose('showFreeSpinsList', 'showFreeSpinsDetails'), freeSpins: this.freeSpins })), h("div", { class: this.showFreeSpinsDetails ? 'Backdrop Opened' : 'Backdrop' }, this.showFreeSpinsDetails && (h("casino-engagement-suite-free-spins-details", { device: this.device, class: "CasinoEngagementSuiteDialog", onBack: this.handleFreeSpinsPopupBack, onClose: this.handlePopupClose('showFreeSpinsList', 'showFreeSpinsDetails'), "game-slug": this.gameSlug, spin: this.selectedSpin }))));
546
+ }
547
+ getJackpotsWidgets() {
548
+ return h("div", null, h("div", { class: this.showJackpotsList ? 'Backdrop Opened' : 'Backdrop' }, h("casino-engagement-suite-jackpots-list", { device: this.device, class: "CasinoEngagementSuiteDialog", onClose: this.handleJackpotsPopupClose, jackpots: this.jackpots, jackpotChangeStatusRequest: this.jackpotChangeStatusRequest })), this.showJackpotDetails && h("div", { class: "Backdrop Opened" }, h("casino-engagement-suite-jackpot-details", { device: this.device, class: "CasinoEngagementSuiteDialog", onBack: this.handleJackpotPopupBack, onClose: this.handleJackpotsPopupClose, "game-slug": this.gameSlug, jackpot: this.selectedJackpot, jackpotChangeStatusRequest: this.jackpotChangeStatusRequest })));
549
+ }
550
+ getRewardMessage(challengeId, levelId) {
551
+ var _a, _b, _c, _d;
552
+ return ((_d = (_c = (_b = (_a = this.challenges) === null || _a === void 0 ? void 0 : _a.find(el => el.Id === challengeId)) === null || _b === void 0 ? void 0 : _b.LevelProgresses) === null || _c === void 0 ? void 0 : _c.find(el => el.LevelId === levelId)) === null || _d === void 0 ? void 0 : _d.CustomRewardMessage) || '';
553
+ }
554
+ render() {
555
+ return (h("div", { key: '70922a17bf1ca3ac0f1a02b42a1963437037b76f', class: `CasinoEngagementSuiteContainer ${this.device} ${this.orientation}`, style: { ['--barHeight']: `${this.barHeight}px` } }, h("div", { key: '77f2b9e4f14ea09a453760225117ed228986c5f8', class: "barWrapper", ref: el => this.barWrapperEl = el }, h("casino-engagement-suite-bar", { key: 'd01b26a0945b4ad0d828d3740dfbf17fc1f9cbda', orientation: this.orientation, device: this.device, "active-widget": this.activeWidget, "is-challenge-label": this.isChallengeLabel, "is-spin-forfeited-label": this.isForfeitedSpinsLabel, leaderboards: this.leaderboards, jackpots: this.jackpots, remainingFreeSpins: this.remainingFreeSpins, highlightChallenge: this.highlightChallenge, "challenge-percent": this.challengePercent, "is-forfeited-challenge-label": this.isForfeitedChallengeLabel })), this.challenges && this.getChallengesWidgets(), this.freeSpins && this.getFreeSpinWidgets(), !!this.jackpots.length && this.getJackpotsWidgets(), this.leaderboards && this.getLeaderboardsWidgets(), h("casino-engagement-suite-modal-container", { key: '9551803550c768a85c85861a1d2619050684943f', device: this.device, isJoiningToChallenge: this.isJoiningToChallenge })));
556
+ }
557
+ static get is() { return "casino-engagement-suite-container"; }
558
+ static get encapsulation() { return "shadow"; }
559
+ static get originalStyleUrls() {
560
+ return {
561
+ "$": ["casino-engagement-suite-container.scss"]
562
+ };
563
+ }
564
+ static get styleUrls() {
565
+ return {
566
+ "$": ["casino-engagement-suite-container.css"]
567
+ };
568
+ }
569
+ static get properties() {
570
+ return {
571
+ "clientStyling": {
572
+ "type": "string",
573
+ "mutable": false,
574
+ "complexType": {
575
+ "original": "string",
576
+ "resolved": "string",
577
+ "references": {}
578
+ },
579
+ "required": false,
580
+ "optional": false,
581
+ "docs": {
582
+ "tags": [],
583
+ "text": "Client custom styling via string"
584
+ },
585
+ "attribute": "client-styling",
586
+ "reflect": true,
587
+ "defaultValue": "''"
588
+ },
589
+ "clientStylingUrl": {
590
+ "type": "string",
591
+ "mutable": false,
592
+ "complexType": {
593
+ "original": "string",
594
+ "resolved": "string",
595
+ "references": {}
596
+ },
597
+ "required": false,
598
+ "optional": false,
599
+ "docs": {
600
+ "tags": [],
601
+ "text": "Client custom styling via url"
602
+ },
603
+ "attribute": "client-styling-url",
604
+ "reflect": true,
605
+ "defaultValue": "''"
606
+ },
607
+ "language": {
608
+ "type": "string",
609
+ "mutable": false,
610
+ "complexType": {
611
+ "original": "string",
612
+ "resolved": "string",
613
+ "references": {}
614
+ },
615
+ "required": false,
616
+ "optional": false,
617
+ "docs": {
618
+ "tags": [],
619
+ "text": "Language of the widget"
620
+ },
621
+ "attribute": "language",
622
+ "reflect": false,
623
+ "defaultValue": "'en'"
624
+ }
625
+ };
626
+ }
627
+ static get states() {
628
+ return {
629
+ "orientation": {},
630
+ "device": {},
631
+ "showChallengesList": {},
632
+ "showFreeSpinsList": {},
633
+ "showJackpotsList": {},
634
+ "showChallengeDetails": {},
635
+ "showFreeSpinsDetails": {},
636
+ "showJackpotDetails": {},
637
+ "showLeaderboardWidget": {},
638
+ "challengePercent": {},
639
+ "remainingFreeSpins": {},
640
+ "highlightChallenge": {},
641
+ "limitStylingAppends": {},
642
+ "activeWidget": {},
643
+ "challenges": {},
644
+ "inProgressChallenges": {},
645
+ "jackpots": {},
646
+ "freeSpins": {},
647
+ "leaderboards": {},
648
+ "gameSlug": {},
649
+ "pausedChallengeIds": {},
650
+ "isChallengeLabel": {},
651
+ "isForfeitedSpinsLabel": {},
652
+ "isForfeitedChallengeLabel": {},
653
+ "isJoiningToChallenge": {},
654
+ "selectedChallenge": {},
655
+ "selectedJackpot": {},
656
+ "selectedSpin": {},
657
+ "selectedSpinId": {},
658
+ "selectedChallengeId": {},
659
+ "selectedJackpotId": {},
660
+ "barHeight": {}
661
+ };
662
+ }
663
+ static get events() {
664
+ return [{
665
+ "method": "openModal",
666
+ "name": "openModal",
667
+ "bubbles": true,
668
+ "cancelable": true,
669
+ "composed": true,
670
+ "docs": {
671
+ "tags": [],
672
+ "text": ""
673
+ },
674
+ "complexType": {
675
+ "original": "OpenModalEvent",
676
+ "resolved": "OpenModalEvent",
677
+ "references": {
678
+ "OpenModalEvent": {
679
+ "location": "import",
680
+ "path": "../../models/casino-engagement-suite-config",
681
+ "id": "../../../../packages/stencil/casino-engagement-suite-container/src/models/casino-engagement-suite-config.ts::OpenModalEvent"
682
+ }
683
+ }
684
+ }
685
+ }, {
686
+ "method": "closeModal",
687
+ "name": "closeModal",
688
+ "bubbles": true,
689
+ "cancelable": true,
690
+ "composed": true,
691
+ "docs": {
692
+ "tags": [],
693
+ "text": ""
694
+ },
695
+ "complexType": {
696
+ "original": "string",
697
+ "resolved": "string",
698
+ "references": {}
699
+ }
700
+ }];
701
+ }
702
+ static get methods() {
703
+ return {
704
+ "init": {
705
+ "complexType": {
706
+ "signature": "(config: CasinoEngagementSuiteConfig) => Promise<void>",
707
+ "parameters": [{
708
+ "name": "config",
709
+ "type": "CasinoEngagementSuiteConfig",
710
+ "docs": ""
711
+ }],
712
+ "references": {
713
+ "Promise": {
714
+ "location": "global",
715
+ "id": "global::Promise"
716
+ },
717
+ "CasinoEngagementSuiteConfig": {
718
+ "location": "import",
719
+ "path": "../../models/casino-engagement-suite-config",
720
+ "id": "../../../../packages/stencil/casino-engagement-suite-container/src/models/casino-engagement-suite-config.ts::CasinoEngagementSuiteConfig"
721
+ }
722
+ },
723
+ "return": "Promise<void>"
724
+ },
725
+ "docs": {
726
+ "text": "Called to initialize widget",
727
+ "tags": [{
728
+ "name": "param",
729
+ "text": "config"
730
+ }]
731
+ }
732
+ }
733
+ };
734
+ }
735
+ static get elementRef() { return "host"; }
736
+ static get listeners() {
737
+ return [{
738
+ "name": "message",
739
+ "method": "handleEvent",
740
+ "target": "window",
741
+ "capture": false,
742
+ "passive": false
743
+ }];
744
+ }
745
+ }