@everymatrix/casino-challenges-overlay-drawer 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/casino-challenges-overlay-drawer/app-globals-0f993ce5.js +1 -0
  2. package/dist/casino-challenges-overlay-drawer/casino-challenge-details-events_21.entry.js +1 -0
  3. package/dist/casino-challenges-overlay-drawer/casino-challenges-overlay-drawer-b6d3a238.js +1 -0
  4. package/dist/casino-challenges-overlay-drawer/casino-challenges-overlay-drawer.esm.js +1 -0
  5. package/dist/casino-challenges-overlay-drawer/index-25fd45d2.js +2 -0
  6. package/dist/casino-challenges-overlay-drawer/index.esm.js +1 -0
  7. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  8. package/dist/cjs/casino-challenge-details-events_21.cjs.entry.js +4459 -0
  9. package/dist/cjs/casino-challenges-overlay-drawer-ee68086b.js +1002 -0
  10. package/dist/cjs/casino-challenges-overlay-drawer.cjs.js +25 -0
  11. package/dist/cjs/index-d2288c94.js +1592 -0
  12. package/dist/cjs/index.cjs.js +10 -0
  13. package/dist/cjs/loader.cjs.js +15 -0
  14. package/dist/collection/assets/arrow-down.svg +3 -0
  15. package/dist/collection/assets/arrow-up.svg +3 -0
  16. package/dist/collection/assets/check.svg +3 -0
  17. package/dist/collection/assets/chevron-up.svg +3 -0
  18. package/dist/collection/assets/chevron.svg +4 -0
  19. package/dist/collection/assets/cross.svg +4 -0
  20. package/dist/collection/assets/crown.svg +12 -0
  21. package/dist/collection/assets/error.svg +3 -0
  22. package/dist/collection/assets/gift.svg +24 -0
  23. package/dist/collection/assets/link.svg +3 -0
  24. package/dist/collection/assets/lock.svg +3 -0
  25. package/dist/collection/assets/notification.svg +20 -0
  26. package/dist/collection/assets/opt-out.svg +3 -0
  27. package/dist/collection/assets/revert-icon.svg +4 -0
  28. package/dist/collection/assets/reward-gift.svg +123 -0
  29. package/dist/collection/assets/slot.svg +59 -0
  30. package/dist/collection/assets/sport.svg +34 -0
  31. package/dist/collection/assets/swipe.svg +3 -0
  32. package/dist/collection/assets/target.svg +16 -0
  33. package/dist/collection/assets/term-and-condition.svg +3 -0
  34. package/dist/collection/collection-manifest.json +48 -0
  35. package/dist/collection/components/casino-challenges-overlay-drawer/casino-challenges-overlay-drawer.css +260 -0
  36. package/dist/collection/components/casino-challenges-overlay-drawer/casino-challenges-overlay-drawer.js +793 -0
  37. package/dist/collection/components/casino-challenges-overlay-drawer/index.js +1 -0
  38. package/dist/collection/components/components/casino-challenge-opt-out-modal/casino-challenge-opt-out-modal.css +141 -0
  39. package/dist/collection/components/components/casino-challenge-opt-out-modal/casino-challenge-opt-out-modal.js +124 -0
  40. package/dist/collection/components/components/casino-challenge-overlay-background/casino-challenge-overlay-background.css +89 -0
  41. package/dist/collection/components/components/casino-challenge-overlay-background/casino-challenge-overlay-background.js +44 -0
  42. package/dist/collection/components/components/casino-challenges-claim-code/casino-challenges-claim-code.css +143 -0
  43. package/dist/collection/components/components/casino-challenges-claim-code/casino-challenges-claim-code.js +260 -0
  44. package/dist/collection/components/components/casino-challenges-empty-state/casino-challenges-empty-state.css +35 -0
  45. package/dist/collection/components/components/casino-challenges-empty-state/casino-challenges-empty-state.js +80 -0
  46. package/dist/collection/components/components/casino-challenges-overlay-drawer-history/casino-challenges-overlay-drawer-history.css +37 -0
  47. package/dist/collection/components/components/casino-challenges-overlay-drawer-history/casino-challenges-overlay-drawer-history.js +335 -0
  48. package/dist/collection/components/components/casino-challenges-overlay-drawer-history/components/casino-challenge-drawer-history-item/casino-challenge-drawer-history-item.css +170 -0
  49. package/dist/collection/components/components/casino-challenges-overlay-drawer-history/components/casino-challenge-drawer-history-item/casino-challenge-drawer-history-item.js +173 -0
  50. package/dist/collection/components/components/casino-challenges-overlay-loader/casino-challenges-overlay-loader.css +83 -0
  51. package/dist/collection/components/components/casino-challenges-overlay-loader/casino-challenges-overlay-loader.js +63 -0
  52. package/dist/collection/components/components/casino-challenges-overlay-tabs/casino-challenges-overlay-tabs.css +116 -0
  53. package/dist/collection/components/components/casino-challenges-overlay-tabs/casino-challenges-overlay-tabs.js +171 -0
  54. package/dist/collection/components/components/swipe-up/swipe-up.css +61 -0
  55. package/dist/collection/components/components/swipe-up/swipe-up.js +155 -0
  56. package/dist/collection/consts.js +3829 -0
  57. package/dist/collection/index.js +1 -0
  58. package/dist/collection/utils/general-info-utils.js +105 -0
  59. package/dist/collection/utils/levels-utils.js +55 -0
  60. package/dist/collection/utils/locale.utils.js +146 -0
  61. package/dist/collection/utils/types.js +160 -0
  62. package/dist/collection/utils/utils.js +54 -0
  63. package/dist/esm/app-globals-0f993ce5.js +3 -0
  64. package/dist/esm/casino-challenge-details-events_21.entry.js +4436 -0
  65. package/dist/esm/casino-challenges-overlay-drawer-b6d3a238.js +994 -0
  66. package/dist/esm/casino-challenges-overlay-drawer.js +20 -0
  67. package/dist/esm/index-25fd45d2.js +1563 -0
  68. package/dist/esm/index.js +2 -0
  69. package/dist/esm/loader.js +11 -0
  70. package/dist/index.cjs.js +1 -0
  71. package/dist/index.js +1 -0
  72. package/dist/stencil.config.dev.js +19 -0
  73. package/dist/stencil.config.js +19 -0
  74. package/dist/storybook/main.js +43 -0
  75. package/dist/storybook/preview.js +9 -0
  76. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  77. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/packages/stencil/casino-challenges-overlay-drawer/stencil.config.d.ts +2 -0
  78. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/packages/stencil/casino-challenges-overlay-drawer/stencil.config.dev.d.ts +2 -0
  79. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/packages/stencil/casino-challenges-overlay-drawer/storybook/main.d.ts +3 -0
  80. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/packages/stencil/casino-challenges-overlay-drawer/storybook/preview.d.ts +70 -0
  81. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/tools/plugins/index.d.ts +4 -0
  82. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  83. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  84. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  85. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-overlay-drawer/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  86. package/dist/types/components/casino-challenges-overlay-drawer/casino-challenges-overlay-drawer.d.ts +77 -0
  87. package/dist/types/components/casino-challenges-overlay-drawer/index.d.ts +1 -0
  88. package/dist/types/components/components/casino-challenge-opt-out-modal/casino-challenge-opt-out-modal.d.ts +12 -0
  89. package/dist/types/components/components/casino-challenge-overlay-background/casino-challenge-overlay-background.d.ts +6 -0
  90. package/dist/types/components/components/casino-challenges-claim-code/casino-challenges-claim-code.d.ts +49 -0
  91. package/dist/types/components/components/casino-challenges-empty-state/casino-challenges-empty-state.d.ts +6 -0
  92. package/dist/types/components/components/casino-challenges-overlay-drawer-history/casino-challenges-overlay-drawer-history.d.ts +33 -0
  93. package/dist/types/components/components/casino-challenges-overlay-drawer-history/components/casino-challenge-drawer-history-item/casino-challenge-drawer-history-item.d.ts +12 -0
  94. package/dist/types/components/components/casino-challenges-overlay-loader/casino-challenges-overlay-loader.d.ts +5 -0
  95. package/dist/types/components/components/casino-challenges-overlay-tabs/casino-challenges-overlay-tabs.d.ts +16 -0
  96. package/dist/types/components/components/swipe-up/swipe-up.d.ts +20 -0
  97. package/dist/types/components.d.ts +362 -0
  98. package/dist/types/consts.d.ts +585 -0
  99. package/dist/types/index.d.ts +1 -0
  100. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  101. package/dist/types/utils/general-info-utils.d.ts +10 -0
  102. package/dist/types/utils/levels-utils.d.ts +5 -0
  103. package/dist/types/utils/locale.utils.d.ts +12 -0
  104. package/dist/types/utils/types.d.ts +327 -0
  105. package/dist/types/utils/utils.d.ts +7 -0
  106. package/loader/cdn.js +1 -0
  107. package/loader/index.cjs.js +1 -0
  108. package/loader/index.d.ts +24 -0
  109. package/loader/index.es2017.js +1 -0
  110. package/loader/index.js +2 -0
  111. package/loader/package.json +11 -0
  112. package/package.json +27 -0
@@ -0,0 +1,793 @@
1
+ import { h } from "@stencil/core";
2
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
3
+ import { hasUpdateDataChanged, isMobile as isMobileView } from "../../utils/utils";
4
+ import { resolveTranslationUrl, translate, TRANSLATIONS } from "../../utils/locale.utils";
5
+ import { EChallengeProgressStatus, EChallengesTabs, EChallengeStatus, EPostMessageRequestType, EPostMessageResponseType } from "../../utils/types";
6
+ import crossSvg from "../../assets/cross.svg";
7
+ import errorIcon from "../../assets/error.svg";
8
+ import checkIcon from "../../assets/check.svg";
9
+ import "../../../../../casino-challenges-overlay-slider/dist/types/index";
10
+ import "../../../../../casino-challenges-overlay-drawer-details/dist/types/index";
11
+ import "../../../../../casino-challenges-modal/dist/types/index";
12
+ export class CasinoChallengesOverlayDrawer {
13
+ constructor() {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
15
+ this.EMPTY_STATE_PAGE_DESCRIPTION_MAP = {
16
+ [EChallengesTabs.Promo]: {
17
+ header: (_a = TRANSLATIONS[this.language]) === null || _a === void 0 ? void 0 : _a.promoTabEmptyHeader,
18
+ description: (_b = TRANSLATIONS[this.language]) === null || _b === void 0 ? void 0 : _b.promoTabEmptyDescription
19
+ },
20
+ [EChallengesTabs.Active]: {
21
+ header: (_c = TRANSLATIONS[this.language]) === null || _c === void 0 ? void 0 : _c.activeTabEmptyHeader,
22
+ description: (_d = TRANSLATIONS[this.language]) === null || _d === void 0 ? void 0 : _d.activeTabEmptyDescription
23
+ },
24
+ [EChallengesTabs.Pending]: {
25
+ header: (_e = TRANSLATIONS[this.language]) === null || _e === void 0 ? void 0 : _e.pendingTabEmptyHeader,
26
+ description: (_f = TRANSLATIONS[this.language]) === null || _f === void 0 ? void 0 : _f.pendingTabEmptyDescription
27
+ },
28
+ [EChallengesTabs.Finished]: {
29
+ header: (_g = TRANSLATIONS[this.language]) === null || _g === void 0 ? void 0 : _g.finishedTabEmptyHeader,
30
+ description: (_h = TRANSLATIONS[this.language]) === null || _h === void 0 ? void 0 : _h.finishedTabEmptyDescription
31
+ }
32
+ };
33
+ this.onActiveChallengeChange = (e) => {
34
+ var _a, _b, _c;
35
+ if (!(e === null || e === void 0 ? void 0 : e.detail)) {
36
+ return;
37
+ }
38
+ this.removeOptedOutChallenge();
39
+ if (this.activeTabIndex === EChallengesTabs.Active) {
40
+ this.updateActiveChallenge((_a = this.activeChallenges) === null || _a === void 0 ? void 0 : _a.find((challenge) => (challenge === null || challenge === void 0 ? void 0 : challenge.Id) === e.detail));
41
+ }
42
+ else if (this.activeTabIndex === EChallengesTabs.Pending) {
43
+ this.updateActiveChallenge((_b = this.pendingChallenges) === null || _b === void 0 ? void 0 : _b.find((challenge) => (challenge === null || challenge === void 0 ? void 0 : challenge.Id) === e.detail));
44
+ }
45
+ else {
46
+ this.updateActiveChallenge((_c = this.promoChallenges) === null || _c === void 0 ? void 0 : _c.find((challenge) => (challenge === null || challenge === void 0 ? void 0 : challenge.Id) === e.detail));
47
+ }
48
+ };
49
+ this.onSeeMoreClick = (e) => {
50
+ this.detailsSubPageInfo = { open: e.detail.open, tab: e.detail.tab };
51
+ };
52
+ this.onLoadMorePlayerHistory = (e) => {
53
+ window.postMessage({
54
+ type: EPostMessageRequestType.ChallengesHistory,
55
+ data: e.detail
56
+ });
57
+ };
58
+ this.isInactiveChallenge = (challenge) => [
59
+ EChallengeProgressStatus.Awaiting,
60
+ EChallengeProgressStatus.Forfeited,
61
+ EChallengeProgressStatus.Completed,
62
+ EChallengeProgressStatus.Expired
63
+ ].includes(challenge.Status) || challenge.ChallengeStatus === EChallengeStatus.Paused;
64
+ this.updateActiveChallenge = (challenge) => {
65
+ var _a;
66
+ this.activeChallenge = challenge;
67
+ this.activeProgressId = (_a = this.activeChallenge) === null || _a === void 0 ? void 0 : _a.Id;
68
+ };
69
+ this.removeOptedOutChallenge = () => {
70
+ var _a;
71
+ if (this.isOptedOut) {
72
+ this.isOptedOut = false;
73
+ this.activeChallenges = (_a = this.activeChallenges) === null || _a === void 0 ? void 0 : _a.filter((activeChallenge) => { var _a; return (activeChallenge === null || activeChallenge === void 0 ? void 0 : activeChallenge.Id) !== ((_a = this.activeChallenge) === null || _a === void 0 ? void 0 : _a.Id); });
74
+ this.activeChallenge = null;
75
+ }
76
+ };
77
+ this.handleTabClick = (event) => {
78
+ if (event.detail !== this.activeTabIndex) {
79
+ this.removeOptedOutChallenge();
80
+ this.activeTabIndex = event.detail;
81
+ if (this.activeTabIndex === EChallengesTabs.Promo) {
82
+ window.postMessage({
83
+ type: EPostMessageRequestType.ChallengePromoTab,
84
+ data: {}
85
+ });
86
+ }
87
+ if (this.activeTabIndex === EChallengesTabs.Active) {
88
+ this.updateActiveChallenge(this.activeChallenges[0]);
89
+ }
90
+ if (this.activeTabIndex === EChallengesTabs.Pending) {
91
+ this.updateActiveChallenge(this.pendingChallenges[0]);
92
+ }
93
+ if (this.activeTabIndex === EChallengesTabs.Finished) {
94
+ window.postMessage({
95
+ type: EPostMessageRequestType.ChallengesHistory,
96
+ data: {
97
+ PageSize: 20,
98
+ PageNumber: 0
99
+ }
100
+ });
101
+ }
102
+ if (event.detail !== EChallengesTabs.Code)
103
+ this.emptyState = this.EMPTY_STATE_PAGE_DESCRIPTION_MAP[event.detail];
104
+ }
105
+ };
106
+ this.openNotification = (notification) => {
107
+ this.notification = notification;
108
+ setTimeout(() => (this.notification = null), 10000);
109
+ };
110
+ this.renderNotification = () => {
111
+ var _a, _b, _c;
112
+ return (h("div", { class: `notification ${((_a = this.notification) === null || _a === void 0 ? void 0 : _a.errored) ? 'errored' : ''}` }, h("div", { class: "row" }, h("img", { src: ((_b = this.notification) === null || _b === void 0 ? void 0 : _b.errored) ? errorIcon : checkIcon, class: "notification__icon", alt: "" }), h("p", { class: "notification__message" }, (_c = this.notification) === null || _c === void 0 ? void 0 : _c.message))));
113
+ };
114
+ this.renderHeader = (isMobile) => {
115
+ return (h("div", null, h("h1", { class: "challenges__drawer__title" }, h("span", null, translate('title', this.language)), h("button", { class: "challenges__drawer__close", onClick: this.onCloseClick }, h("img", { src: crossSvg, alt: "" }))), h("casino-challenges-overlay-tabs", { onTabClick: this.handleTabClick, activeTabIndex: this.activeTabIndex, activeTabHasNotification: false, pendingTabHasNotification: false, language: this.language, "is-mobile": isMobile })));
116
+ };
117
+ this.isEmptyState = () => {
118
+ if (!this.loading && this.activeTabIndex !== EChallengesTabs.Code) {
119
+ if (this.activeTabIndex === EChallengesTabs.Active && !this.activeChallenges.length) {
120
+ return true;
121
+ }
122
+ else if (this.activeTabIndex === EChallengesTabs.Pending && !this.pendingChallenges.length) {
123
+ return true;
124
+ }
125
+ else if (this.activeTabIndex === EChallengesTabs.Promo && !this.promoChallenges.length) {
126
+ return true;
127
+ }
128
+ else if (this.activeTabIndex === EChallengesTabs.Finished && !this.playerHistory.length) {
129
+ return true;
130
+ }
131
+ }
132
+ return false;
133
+ };
134
+ this.renderEmptyState = (isMobile) => {
135
+ var _a, _b;
136
+ return (h("div", null, this.renderHeader(isMobile), h("casino-challenges-empty-state", { header: (_a = this.emptyState) === null || _a === void 0 ? void 0 : _a.header, description: (_b = this.emptyState) === null || _b === void 0 ? void 0 : _b.description, "is-mobile": isMobile })));
137
+ };
138
+ this.renderFinishedTab = (isMobile) => {
139
+ return (h("div", null, this.renderHeader(isMobile), h("casino-challenges-overlay-drawer-history", { mbSource: this.mbSource, clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, translationUrl: this.translationUrl, language: this.language, isMobile: isMobile, historyItems: this.playerHistory, hasMore: this.hasMorePlayerHistory, onLoadMore: this.onLoadMorePlayerHistory, loading: this.loading })));
140
+ };
141
+ this.renderCodeTab = (isMobile) => {
142
+ return (h("div", null, this.renderHeader(isMobile), h("casino-challenges-claim-code", { "is-mobile": isMobile })));
143
+ };
144
+ this.renderChallengeDetails = (isMobile, isUnique = false) => {
145
+ return (h("casino-challenges-overlay-drawer-details", { challenge: this.activeChallenge, swipped: this.swipped, progress: this.progress, "is-mobile": isMobile, "is-unique": isUnique, "is-opted-out": this.isOptedOut, "active-challenges-tab-index": this.activeTabIndex, onSeeMoreClick: this.onSeeMoreClick, detailsSubPageInfo: this.detailsSubPageInfo, challengeGames: this.challengeGames, onCloseClick: this.onCloseClick }));
146
+ };
147
+ this.renderChallengesTabs = (isMobile) => {
148
+ const challenges = this.activeTabIndex === EChallengesTabs.Active
149
+ ? this.activeChallenges
150
+ : this.activeTabIndex === EChallengesTabs.Pending
151
+ ? this.pendingChallenges
152
+ : this.promoChallenges;
153
+ const isUnique = challenges.length === 1;
154
+ return (h("swipe-up", { onSwippedUp: (e) => {
155
+ this.swipped = e.detail.swipped;
156
+ this.progress = e.detail.progress;
157
+ }, isMobile: isMobile, isOneSlider: isUnique }, h("div", { class: "content-header", slot: "header" }, this.renderHeader(isMobile), h("div", { class: { 'content-spacer': this.swipped || !isMobile, 'one-slide': isUnique && this.swipped } }, h("casino-challenges-overlay-slider", { mbSource: this.mbSource, clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, translationUrl: this.translationUrl, language: this.language, challenges: challenges, isMobile: isMobile, onActiveChallengeChange: this.onActiveChallengeChange, initialProgressId: this.activeProgressId, activeTabIndex: this.activeTabIndex }))), h("div", { class: "content-details", slot: "details" }, this.renderChallengeDetails(isMobile, isUnique))));
158
+ };
159
+ this.onCloseClick = () => {
160
+ var _a, _b;
161
+ this.pendingChallenges = (_a = this.pendingChallenges) === null || _a === void 0 ? void 0 : _a.filter((c) => c.Status === EChallengeProgressStatus.Awaiting);
162
+ this.activeChallenges = (_b = this.activeChallenges) === null || _b === void 0 ? void 0 : _b.filter((challenge) => !this.isInactiveChallenge(challenge));
163
+ this.detailsSubPageInfo = { open: false, tab: null };
164
+ this.loading = false;
165
+ this.isOptedOut = false;
166
+ this.handleClose();
167
+ };
168
+ this.mbSource = undefined;
169
+ this.clientStyling = undefined;
170
+ this.clientStylingUrl = undefined;
171
+ this.translationUrl = '';
172
+ this.language = 'en';
173
+ this.isOpen = false;
174
+ this.handleClose = () => { };
175
+ this.challenges = [];
176
+ this.initialProgressId = '';
177
+ this.activeChallenge = null;
178
+ this.activeProgressId = '';
179
+ this.activeTabIndex = EChallengesTabs.Active;
180
+ this.error = '';
181
+ this.hasError = false;
182
+ this.swipped = false;
183
+ this.detailsSubPageInfo = undefined;
184
+ this.progress = 0;
185
+ this.loading = false;
186
+ this.notification = null;
187
+ this.optOutModaIsOpen = false;
188
+ this.isOptedOut = false;
189
+ this.prevUpdateEvent = undefined;
190
+ this.challengeGames = [];
191
+ this.activeChallenges = [];
192
+ this.pendingChallenges = [];
193
+ this.promoChallenges = [];
194
+ this.playerHistory = [];
195
+ this.hasMorePlayerHistory = false;
196
+ this.emptyState = {
197
+ header: (_j = TRANSLATIONS[this.language]) === null || _j === void 0 ? void 0 : _j.activeTabEmptyHeader,
198
+ description: (_k = TRANSLATIONS[this.language]) === null || _k === void 0 ? void 0 : _k.activeTabEmptyDescription
199
+ };
200
+ }
201
+ handleClientStylingChange(newValue, oldValue) {
202
+ if (newValue != oldValue) {
203
+ setClientStyling(this.stylingContainer, this.clientStyling);
204
+ }
205
+ }
206
+ handleClientStylingUrlChange(newValue, oldValue) {
207
+ if (newValue != oldValue) {
208
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
209
+ }
210
+ }
211
+ handleMbSourceChange(newValue, oldValue) {
212
+ if (newValue != oldValue) {
213
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
214
+ }
215
+ }
216
+ handleIsOpenChange(newValue) {
217
+ var _a;
218
+ if (newValue) {
219
+ if (this.initialProgressId && this.challenges.length) {
220
+ this.activeTabIndex = EChallengesTabs.Active;
221
+ this.activeProgressId = this.initialProgressId;
222
+ const currentChallenge = ((_a = this.activeChallenges) === null || _a === void 0 ? void 0 : _a.find((x) => x.Id === this.activeProgressId)) || this.activeChallenges[0];
223
+ this.updateActiveChallenge(currentChallenge || null);
224
+ }
225
+ else {
226
+ this.activeTabIndex = EChallengesTabs.Promo;
227
+ window.postMessage({
228
+ type: EPostMessageRequestType.ChallengePromoTab,
229
+ data: {}
230
+ });
231
+ }
232
+ }
233
+ }
234
+ onActiveChallengeChanged() {
235
+ this.challengeGames = [];
236
+ }
237
+ onOpenOptOut() {
238
+ this.optOutModaIsOpen = true;
239
+ }
240
+ onCloseOptOut() {
241
+ this.optOutModaIsOpen = false;
242
+ }
243
+ onConfirmOptOut() {
244
+ window.postMessage({
245
+ type: EPostMessageRequestType.ForfeitChallenge,
246
+ data: {
247
+ ChallengeId: this.activeChallenge.ChallengeId
248
+ }
249
+ });
250
+ }
251
+ onChallengeExpired(event) {
252
+ if (!(event === null || event === void 0 ? void 0 : event.detail)) {
253
+ return;
254
+ }
255
+ switch (this.activeTabIndex) {
256
+ case EChallengesTabs.Active:
257
+ this.activeChallenges = this.updateChallenge(this.activeChallenges, event.detail, {
258
+ Status: EChallengeProgressStatus.Expired
259
+ });
260
+ break;
261
+ case EChallengesTabs.Pending:
262
+ this.pendingChallenges = this.updateChallenge(this.pendingChallenges, event.detail, {
263
+ Status: EChallengeProgressStatus.Expired
264
+ });
265
+ break;
266
+ case EChallengesTabs.Promo:
267
+ this.promoChallenges = this.updateChallenge(this.promoChallenges, event.detail, {
268
+ Status: EChallengeProgressStatus.Expired
269
+ });
270
+ break;
271
+ }
272
+ }
273
+ handleEvent(e) {
274
+ var _a, _b, _c, _d;
275
+ const { type, data, success, errorMessage } = e === null || e === void 0 ? void 0 : e.data;
276
+ console.log('\nReceived event: ', e === null || e === void 0 ? void 0 : e.data.type);
277
+ console.log(e); // left here temporarily for debugging in the developer environment
278
+ switch (type) {
279
+ case EPostMessageResponseType.ChallengePromoTab: {
280
+ if (success) {
281
+ this.promoChallenges = data || [];
282
+ this.updateActiveChallenge(this.promoChallenges[0]);
283
+ }
284
+ else {
285
+ this.promoChallenges = [];
286
+ this.updateActiveChallenge(null);
287
+ this.openNotification({ message: errorMessage, errored: true });
288
+ }
289
+ this.loading = false;
290
+ break;
291
+ }
292
+ case EPostMessageResponseType.ChallengesHistory: {
293
+ if (success) {
294
+ if (this.playerHistory.length < ((_a = e === null || e === void 0 ? void 0 : e.data) === null || _a === void 0 ? void 0 : _a.totalItem)) {
295
+ this.playerHistory = [...this.playerHistory, ...data];
296
+ }
297
+ else {
298
+ this.playerHistory = data;
299
+ }
300
+ this.hasMorePlayerHistory = ((_b = e === null || e === void 0 ? void 0 : e.data) === null || _b === void 0 ? void 0 : _b.totalItem) > this.playerHistory.length;
301
+ }
302
+ else {
303
+ this.openNotification({ message: errorMessage, errored: true });
304
+ }
305
+ this.loading = false;
306
+ break;
307
+ }
308
+ case EPostMessageResponseType.ClaimChallengeByCode: {
309
+ if (success) {
310
+ this.openNotification({ message: translate('claimCodeSuccessMessage', this.language) });
311
+ this.activeChallenges = [...this.activeChallenges, data];
312
+ }
313
+ else {
314
+ this.openNotification({ message: errorMessage, errored: true });
315
+ }
316
+ this.loading = false;
317
+ break;
318
+ }
319
+ case EPostMessageResponseType.ChallengeJoin: {
320
+ if (success) {
321
+ const isJoining = [EChallengeProgressStatus.Paused, EChallengeProgressStatus.Started].includes((_c = this.activeChallenge) === null || _c === void 0 ? void 0 : _c.Status);
322
+ const id = isJoining ? data === null || data === void 0 ? void 0 : data.joinId : data === null || data === void 0 ? void 0 : data.unjoinId;
323
+ const status = isJoining ? EChallengeProgressStatus.InProgress : EChallengeProgressStatus.Paused;
324
+ this.activeChallenges = this.updateChallenge(this.activeChallenges, id, {
325
+ Status: status
326
+ });
327
+ }
328
+ else {
329
+ this.openNotification({ message: errorMessage, errored: true });
330
+ }
331
+ this.loading = false;
332
+ break;
333
+ }
334
+ case EPostMessageResponseType.ChallengeIsNew: {
335
+ if (success) {
336
+ this.updateChallengeByProgressId(data === null || data === void 0 ? void 0 : data.challengeProgressId, { IsNew: false });
337
+ }
338
+ else {
339
+ this.openNotification({ message: errorMessage, errored: true });
340
+ }
341
+ break;
342
+ }
343
+ case EPostMessageResponseType.GetChallengeGames: {
344
+ if (success) {
345
+ this.challengeGames = data;
346
+ }
347
+ else {
348
+ this.openNotification({ message: errorMessage, errored: true });
349
+ }
350
+ this.loading = false;
351
+ break;
352
+ }
353
+ case EPostMessageResponseType.ClaimChallengeByButton: {
354
+ if (success) {
355
+ const challenge = Array.isArray(data) ? data[0] : data;
356
+ if (challenge) {
357
+ challenge.IsNew = false;
358
+ this.activeChallenges = [...this.activeChallenges, challenge];
359
+ this.updateActiveChallenge(challenge);
360
+ this.activeTabIndex = EChallengesTabs.Active;
361
+ this.openNotification({ message: translate('grantClaimByButtonSuccessMessage', this.language) });
362
+ }
363
+ }
364
+ else {
365
+ this.openNotification({ message: errorMessage, errored: true });
366
+ }
367
+ this.loading = false;
368
+ break;
369
+ }
370
+ case EPostMessageResponseType.ForfeitChallenge: {
371
+ this.optOutModaIsOpen = false;
372
+ if (success) {
373
+ this.openNotification({ message: translate('optOutSuccessMessage', this.language) });
374
+ this.detailsSubPageInfo = { open: false, tab: null };
375
+ this.isOptedOut = true;
376
+ }
377
+ else {
378
+ this.openNotification({ message: errorMessage, errored: true });
379
+ }
380
+ this.loading = false;
381
+ break;
382
+ }
383
+ //
384
+ case EPostMessageResponseType.ChangeChallengeProgressStatus: {
385
+ this.updateChallengeByProgressId(data === null || data === void 0 ? void 0 : data.ChallengeProgressId, { Status: data === null || data === void 0 ? void 0 : data.ChallengeProgressStatus });
386
+ break;
387
+ }
388
+ case EPostMessageResponseType.ChallengeChangeStatusNotification: {
389
+ this.updateChallengeById(data === null || data === void 0 ? void 0 : data.ChallengeId, {
390
+ ChallengeStatus: (data === null || data === void 0 ? void 0 : data.IsEnabled) ? EChallengeStatus.Enabled : EChallengeStatus.Paused
391
+ });
392
+ break;
393
+ }
394
+ case EPostMessageResponseType.ChallengeForfeitNotification: {
395
+ this.updateChallengeById(data === null || data === void 0 ? void 0 : data.ChallengeId, { Status: EChallengeProgressStatus.Forfeited });
396
+ break;
397
+ }
398
+ case EPostMessageResponseType.UpdateChallengeProgress: {
399
+ const newChallenge = data;
400
+ if (!hasUpdateDataChanged(this.prevUpdateEvent, newChallenge)) {
401
+ return;
402
+ }
403
+ this.prevUpdateEvent = newChallenge;
404
+ this.activeChallenges = (_d = this.activeChallenges) === null || _d === void 0 ? void 0 : _d.map((challenge) => {
405
+ if (challenge.Id !== (newChallenge === null || newChallenge === void 0 ? void 0 : newChallenge.ProgressId))
406
+ return challenge;
407
+ const updatedLevels = challenge.LevelProgresses.map((level) => {
408
+ const newLevelData = newChallenge === null || newChallenge === void 0 ? void 0 : newChallenge.Levels.find((l) => l.LevelId === level.LevelId);
409
+ if (!newLevelData)
410
+ return level;
411
+ return Object.assign(Object.assign({}, level), { ProgressStatus: newLevelData.ProgressStatus, ProgressPercentage: newLevelData.ProgressPercentage });
412
+ });
413
+ return Object.assign(Object.assign({}, challenge), { Status: newChallenge === null || newChallenge === void 0 ? void 0 : newChallenge.Status, LevelProgresses: updatedLevels });
414
+ });
415
+ break;
416
+ }
417
+ case EPostMessageResponseType.NewChallengeProgressGranted:
418
+ const isPending = (data === null || data === void 0 ? void 0 : data.Status) === EChallengeProgressStatus.Awaiting;
419
+ const challenges = isPending ? this.pendingChallenges : this.activeChallenges;
420
+ if (challenges === null || challenges === void 0 ? void 0 : challenges.some((x) => x.Id === (data === null || data === void 0 ? void 0 : data.Id)))
421
+ break;
422
+ if (isPending) {
423
+ this.pendingChallenges = [...challenges, data];
424
+ }
425
+ else {
426
+ this.activeChallenges = [...challenges, data];
427
+ }
428
+ break;
429
+ // component loading state processing for requests
430
+ case EPostMessageRequestType.ChallengeJoin:
431
+ case EPostMessageRequestType.GetChallengeGames:
432
+ case EPostMessageRequestType.ClaimChallengeByButton:
433
+ case EPostMessageRequestType.RedirectToDepositPage:
434
+ case EPostMessageRequestType.ChallengeInGameRedirect:
435
+ case EPostMessageRequestType.ChallengesHistory:
436
+ case EPostMessageRequestType.ChallengePromoTab:
437
+ case EPostMessageRequestType.ClaimChallengeByCode:
438
+ case EPostMessageRequestType.ForfeitChallenge:
439
+ this.loading = true;
440
+ break;
441
+ }
442
+ }
443
+ componentWillLoad() {
444
+ var _a;
445
+ if (this.translationUrl) {
446
+ resolveTranslationUrl(this.translationUrl);
447
+ }
448
+ if ((_a = this.challenges) === null || _a === void 0 ? void 0 : _a.length) {
449
+ const challenges = [...this.challenges];
450
+ this.pendingChallenges = challenges.filter((c) => c.Status === EChallengeProgressStatus.Awaiting);
451
+ this.activeChallenges = challenges.filter((challenge) => !this.isInactiveChallenge(challenge));
452
+ }
453
+ }
454
+ componentDidLoad() {
455
+ if (this.stylingContainer) {
456
+ if (this.mbSource)
457
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
458
+ if (this.clientStyling)
459
+ setClientStyling(this.stylingContainer, this.clientStyling);
460
+ if (this.clientStylingUrl)
461
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
462
+ }
463
+ }
464
+ disconnectedCallback() {
465
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
466
+ }
467
+ updateChallenge(challenges, progressId, updates) {
468
+ var _a;
469
+ if (((_a = this.activeChallenge) === null || _a === void 0 ? void 0 : _a.Id) === progressId) {
470
+ this.activeChallenge = Object.assign(Object.assign({}, this.activeChallenge), updates);
471
+ }
472
+ return challenges.map((challenge) => (challenge.Id === progressId ? Object.assign(Object.assign({}, challenge), updates) : challenge));
473
+ }
474
+ updateChallengeList(list, challengeId, updates) {
475
+ let changed = false;
476
+ const updated = list.map((challenge) => {
477
+ if (challenge.ChallengeId === challengeId) {
478
+ changed = true;
479
+ return Object.assign(Object.assign({}, challenge), updates);
480
+ }
481
+ return challenge;
482
+ });
483
+ return changed ? updated : list;
484
+ }
485
+ updateChallengeById(challengeId, updates) {
486
+ var _a;
487
+ if (((_a = this.activeChallenge) === null || _a === void 0 ? void 0 : _a.ChallengeId) === challengeId) {
488
+ this.activeChallenge = Object.assign(Object.assign({}, this.activeChallenge), updates);
489
+ }
490
+ this.activeChallenges = this.updateChallengeList(this.activeChallenges, challengeId, updates);
491
+ this.pendingChallenges = this.updateChallengeList(this.pendingChallenges, challengeId, updates);
492
+ this.promoChallenges = this.updateChallengeList(this.promoChallenges, challengeId, updates);
493
+ }
494
+ updateChallengeByProgressId(progressId, updates) {
495
+ var _a;
496
+ if (((_a = this.activeChallenge) === null || _a === void 0 ? void 0 : _a.Id) === progressId) {
497
+ this.activeChallenge = Object.assign(Object.assign({}, this.activeChallenge), updates);
498
+ }
499
+ if (this.activeChallenges.find((x) => x.Id === progressId)) {
500
+ this.activeChallenges = this.activeChallenges.map((challenge) => challenge.Id === progressId ? Object.assign(Object.assign({}, challenge), updates) : challenge);
501
+ }
502
+ else if (this.pendingChallenges.find((x) => x.Id === progressId)) {
503
+ this.pendingChallenges = this.pendingChallenges.map((challenge) => challenge.Id === progressId ? Object.assign(Object.assign({}, challenge), updates) : challenge);
504
+ }
505
+ else {
506
+ this.promoChallenges = this.promoChallenges.map((challenge) => challenge.Id === progressId ? Object.assign(Object.assign({}, challenge), updates) : challenge);
507
+ }
508
+ }
509
+ renderContent(isMobile, showEmptyState) {
510
+ var _a;
511
+ if (showEmptyState) {
512
+ return this.renderEmptyState(isMobile);
513
+ }
514
+ if ((_a = this.detailsSubPageInfo) === null || _a === void 0 ? void 0 : _a.open) {
515
+ return (h("div", { class: "content-sub-page", slot: "details" }, this.renderChallengeDetails(isMobile)));
516
+ }
517
+ switch (this.activeTabIndex) {
518
+ case EChallengesTabs.Promo:
519
+ case EChallengesTabs.Active:
520
+ case EChallengesTabs.Pending:
521
+ return this.renderChallengesTabs(isMobile);
522
+ case EChallengesTabs.Code:
523
+ return this.renderCodeTab(isMobile);
524
+ case EChallengesTabs.Finished:
525
+ return this.renderFinishedTab(isMobile);
526
+ default:
527
+ return;
528
+ }
529
+ }
530
+ render() {
531
+ if (!this.isOpen) {
532
+ return;
533
+ }
534
+ const isMobile = isMobileView() || window.innerWidth <= 768;
535
+ const showEmptyState = this.isEmptyState();
536
+ return (h("div", { ref: (el) => (this.stylingContainer = el), class: {
537
+ container: true,
538
+ mobile: isMobile
539
+ } }, h("div", { class: "challenges__backdrop", onClick: this.onCloseClick }), h("div", { class: "challenges__drawer" }, h("casino-challenge-overlay-background", { empty: showEmptyState }), h("div", { class: "challenges__drawer__content" }, this.renderContent(isMobile, showEmptyState)), this.loading && h("casino-challenges-overlay-loader", { "full-size": true, "is-mobile": isMobile }), h("casino-challenge-opt-out-modal", { open: this.optOutModaIsOpen, "is-mobile": isMobile, language: this.language })), this.notification && this.renderNotification()));
540
+ }
541
+ static get is() { return "casino-challenges-overlay-drawer"; }
542
+ static get encapsulation() { return "shadow"; }
543
+ static get originalStyleUrls() {
544
+ return {
545
+ "$": ["casino-challenges-overlay-drawer.scss"]
546
+ };
547
+ }
548
+ static get styleUrls() {
549
+ return {
550
+ "$": ["casino-challenges-overlay-drawer.css"]
551
+ };
552
+ }
553
+ static get properties() {
554
+ return {
555
+ "mbSource": {
556
+ "type": "string",
557
+ "mutable": false,
558
+ "complexType": {
559
+ "original": "string",
560
+ "resolved": "string",
561
+ "references": {}
562
+ },
563
+ "required": false,
564
+ "optional": true,
565
+ "docs": {
566
+ "tags": [],
567
+ "text": ""
568
+ },
569
+ "attribute": "mb-source",
570
+ "reflect": true
571
+ },
572
+ "clientStyling": {
573
+ "type": "string",
574
+ "mutable": false,
575
+ "complexType": {
576
+ "original": "string",
577
+ "resolved": "string",
578
+ "references": {}
579
+ },
580
+ "required": false,
581
+ "optional": true,
582
+ "docs": {
583
+ "tags": [],
584
+ "text": ""
585
+ },
586
+ "attribute": "client-styling",
587
+ "reflect": true
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": true,
599
+ "docs": {
600
+ "tags": [],
601
+ "text": ""
602
+ },
603
+ "attribute": "client-styling-url",
604
+ "reflect": true
605
+ },
606
+ "translationUrl": {
607
+ "type": "string",
608
+ "mutable": false,
609
+ "complexType": {
610
+ "original": "string",
611
+ "resolved": "string",
612
+ "references": {}
613
+ },
614
+ "required": false,
615
+ "optional": false,
616
+ "docs": {
617
+ "tags": [],
618
+ "text": ""
619
+ },
620
+ "attribute": "translation-url",
621
+ "reflect": true,
622
+ "defaultValue": "''"
623
+ },
624
+ "language": {
625
+ "type": "string",
626
+ "mutable": false,
627
+ "complexType": {
628
+ "original": "string",
629
+ "resolved": "string",
630
+ "references": {}
631
+ },
632
+ "required": false,
633
+ "optional": false,
634
+ "docs": {
635
+ "tags": [],
636
+ "text": ""
637
+ },
638
+ "attribute": "language",
639
+ "reflect": true,
640
+ "defaultValue": "'en'"
641
+ },
642
+ "isOpen": {
643
+ "type": "boolean",
644
+ "mutable": false,
645
+ "complexType": {
646
+ "original": "boolean",
647
+ "resolved": "boolean",
648
+ "references": {}
649
+ },
650
+ "required": false,
651
+ "optional": false,
652
+ "docs": {
653
+ "tags": [],
654
+ "text": ""
655
+ },
656
+ "attribute": "is-open",
657
+ "reflect": true,
658
+ "defaultValue": "false"
659
+ },
660
+ "handleClose": {
661
+ "type": "unknown",
662
+ "mutable": false,
663
+ "complexType": {
664
+ "original": "() => void",
665
+ "resolved": "() => void",
666
+ "references": {}
667
+ },
668
+ "required": false,
669
+ "optional": false,
670
+ "docs": {
671
+ "tags": [],
672
+ "text": ""
673
+ },
674
+ "defaultValue": "() => {}"
675
+ },
676
+ "challenges": {
677
+ "type": "unknown",
678
+ "mutable": false,
679
+ "complexType": {
680
+ "original": "IChallenge[]",
681
+ "resolved": "IChallenge[]",
682
+ "references": {
683
+ "IChallenge": {
684
+ "location": "import",
685
+ "path": "../../utils/types",
686
+ "id": "../../../../packages/stencil/casino-challenges-overlay-drawer/src/utils/types.ts::IChallenge"
687
+ }
688
+ }
689
+ },
690
+ "required": false,
691
+ "optional": false,
692
+ "docs": {
693
+ "tags": [],
694
+ "text": ""
695
+ },
696
+ "defaultValue": "[]"
697
+ },
698
+ "initialProgressId": {
699
+ "type": "string",
700
+ "mutable": false,
701
+ "complexType": {
702
+ "original": "string",
703
+ "resolved": "string",
704
+ "references": {}
705
+ },
706
+ "required": false,
707
+ "optional": false,
708
+ "docs": {
709
+ "tags": [],
710
+ "text": ""
711
+ },
712
+ "attribute": "initial-progress-id",
713
+ "reflect": true,
714
+ "defaultValue": "''"
715
+ }
716
+ };
717
+ }
718
+ static get states() {
719
+ return {
720
+ "activeChallenge": {},
721
+ "activeProgressId": {},
722
+ "activeTabIndex": {},
723
+ "error": {},
724
+ "hasError": {},
725
+ "swipped": {},
726
+ "detailsSubPageInfo": {},
727
+ "progress": {},
728
+ "loading": {},
729
+ "notification": {},
730
+ "optOutModaIsOpen": {},
731
+ "isOptedOut": {},
732
+ "prevUpdateEvent": {},
733
+ "challengeGames": {},
734
+ "activeChallenges": {},
735
+ "pendingChallenges": {},
736
+ "promoChallenges": {},
737
+ "playerHistory": {},
738
+ "hasMorePlayerHistory": {},
739
+ "emptyState": {}
740
+ };
741
+ }
742
+ static get watchers() {
743
+ return [{
744
+ "propName": "clientStyling",
745
+ "methodName": "handleClientStylingChange"
746
+ }, {
747
+ "propName": "clientStylingUrl",
748
+ "methodName": "handleClientStylingUrlChange"
749
+ }, {
750
+ "propName": "mbSource",
751
+ "methodName": "handleMbSourceChange"
752
+ }, {
753
+ "propName": "isOpen",
754
+ "methodName": "handleIsOpenChange"
755
+ }, {
756
+ "propName": "activeChallenge",
757
+ "methodName": "onActiveChallengeChanged"
758
+ }];
759
+ }
760
+ static get listeners() {
761
+ return [{
762
+ "name": "openOptOutModal",
763
+ "method": "onOpenOptOut",
764
+ "target": undefined,
765
+ "capture": false,
766
+ "passive": false
767
+ }, {
768
+ "name": "closeOptOutModal",
769
+ "method": "onCloseOptOut",
770
+ "target": undefined,
771
+ "capture": false,
772
+ "passive": false
773
+ }, {
774
+ "name": "confirmOptOut",
775
+ "method": "onConfirmOptOut",
776
+ "target": undefined,
777
+ "capture": false,
778
+ "passive": false
779
+ }, {
780
+ "name": "challengeExpired",
781
+ "method": "onChallengeExpired",
782
+ "target": undefined,
783
+ "capture": false,
784
+ "passive": false
785
+ }, {
786
+ "name": "message",
787
+ "method": "handleEvent",
788
+ "target": "window",
789
+ "capture": false,
790
+ "passive": false
791
+ }];
792
+ }
793
+ }