@everymatrix/casino-engagement-suite-challenges-list 1.35.0 → 1.36.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 (26) hide show
  1. package/dist/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.esm.js +1 -1
  2. package/dist/casino-engagement-suite-challenges-list/p-26d7de05.entry.js +1 -0
  3. package/dist/casino-engagement-suite-challenges-list/p-fad4589e.js +1 -0
  4. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.js +2 -2
  5. package/dist/cjs/casino-engagement-suite-challenges-list_2.cjs.entry.js +513 -0
  6. package/dist/cjs/{index-79c88755.js → index-0a011384.js} +38 -1
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/collection/collection-manifest.json +8 -1
  9. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.css +34 -0
  10. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.js +128 -38
  11. package/dist/collection/utils/locale.utils.js +1 -0
  12. package/dist/components/casino-engagement-suite-challenges-list.js +97 -791
  13. package/dist/components/casino-engagement-suite-progress-bar.js +6 -0
  14. package/dist/components/casino-engagement-suite-progress-bar2.js +94 -0
  15. package/dist/esm/casino-engagement-suite-challenges-list.js +2 -2
  16. package/dist/esm/casino-engagement-suite-challenges-list_2.entry.js +508 -0
  17. package/dist/esm/{index-70e47fe0.js → index-ddf7e990.js} +38 -1
  18. package/dist/esm/loader.js +2 -2
  19. package/dist/types/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.d.ts +11 -0
  20. package/dist/types/components.d.ts +16 -0
  21. package/dist/types/models/challenge.d.ts +3 -0
  22. package/package.json +1 -1
  23. package/dist/casino-engagement-suite-challenges-list/p-7e171791.js +0 -1
  24. package/dist/casino-engagement-suite-challenges-list/p-eb36cbe7.entry.js +0 -1
  25. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.entry.js +0 -1147
  26. package/dist/esm/casino-engagement-suite-challenges-list.entry.js +0 -1143
@@ -0,0 +1,6 @@
1
+ import { C as CasinoEngagementSuiteProgressBar$1, d as defineCustomElement$1 } from './casino-engagement-suite-progress-bar2.js';
2
+
3
+ const CasinoEngagementSuiteProgressBar = CasinoEngagementSuiteProgressBar$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { CasinoEngagementSuiteProgressBar, defineCustomElement };
@@ -0,0 +1,94 @@
1
+ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
+
3
+ const casinoEngagementSuiteProgressBarCss = ":host{display:block;font-family:inherit}:host(.Desktop) .ProgressBarPercent{font-size:14px;line-height:14px}.ProgressBarBackground{height:8px;background-color:var(--emw--color-background, #666178);border-radius:4px;position:relative}.ProgressBarLine{position:absolute;left:0;top:0;bottom:0;border-radius:4px;background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);transition:width ease-out 0.3s}.ProgressBarInfo{margin-bottom:8px;display:flex;justify-content:space-between;align-items:center}.ProgressBarPercent{font-weight:700;font-size:12px;line-height:12px}.HidePercent .ProgressBarPercent{display:none}.ProgressBar:not(.Disabled) .ProgressBarPercent{background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.ProgressBar.Disabled .ProgressBarPercent{color:var(--emw--color-background, #666178)}.ProgressBar.Disabled .ProgressBarLine{background:var(--emw--color-background-secondary, #474668)}";
4
+
5
+ const CasinoEngagementSuiteProgressBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6
+ constructor() {
7
+ super();
8
+ this.__registerHost();
9
+ this.__attachShadow();
10
+ /**
11
+ * Value for the widget
12
+ */
13
+ this.value = 0;
14
+ /**
15
+ * Shows disabled styles
16
+ */
17
+ this.disabled = false;
18
+ /**
19
+ * Hide percent value
20
+ */
21
+ this.hidePercent = false;
22
+ /**
23
+ * Client custom styling via string
24
+ */
25
+ this.clientStyling = '';
26
+ /**
27
+ * Client custom styling via url
28
+ */
29
+ this.clientStylingUrl = '';
30
+ this.limitStylingAppends = false;
31
+ this.setClientStyling = () => {
32
+ let sheet = document.createElement('style');
33
+ sheet.innerHTML = this.clientStyling;
34
+ this.host.prepend(sheet);
35
+ };
36
+ this.setClientStylingURL = () => {
37
+ let url = new URL(this.clientStylingUrl);
38
+ let cssFile = document.createElement('style');
39
+ fetch(url.href)
40
+ .then((res) => res.text())
41
+ .then((data) => {
42
+ cssFile.innerHTML = data;
43
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
44
+ })
45
+ .catch((err) => {
46
+ console.log('Error ', err);
47
+ });
48
+ };
49
+ }
50
+ componentDidRender() {
51
+ if (!this.limitStylingAppends && this.host) {
52
+ if (this.clientStyling)
53
+ this.setClientStyling();
54
+ if (this.clientStylingUrl)
55
+ this.setClientStylingURL();
56
+ this.limitStylingAppends = true;
57
+ }
58
+ }
59
+ getProgressBarClasses() {
60
+ return {
61
+ ProgressBar: true,
62
+ Completed: this.value === 100,
63
+ Disabled: this.disabled,
64
+ HidePercent: this.hidePercent
65
+ };
66
+ }
67
+ render() {
68
+ return h("div", { class: this.getProgressBarClasses(), part: "ProgressBar" }, h("div", { class: "ProgressBarInfo", part: "ProgressBarInfo" }, h("slot", { name: "Title" }, h("div", null)), h("slot", { name: "Percent" }, h("div", { class: "ProgressBarPercent", part: "ProgressBarPercent" }, this.value, "%"))), h("div", { class: "ProgressBarBackground", part: "ProgressBarBackground" }, h("div", { class: "ProgressBarLine", part: "ProgressBarLine", style: { width: this.value + '%' } })));
69
+ }
70
+ get host() { return this; }
71
+ static get style() { return casinoEngagementSuiteProgressBarCss; }
72
+ }, [1, "casino-engagement-suite-progress-bar", {
73
+ "value": [2],
74
+ "disabled": [4],
75
+ "hidePercent": [4, "hide-percent"],
76
+ "clientStyling": [513, "client-styling"],
77
+ "clientStylingUrl": [513, "client-styling-url"],
78
+ "limitStylingAppends": [32]
79
+ }]);
80
+ function defineCustomElement() {
81
+ if (typeof customElements === "undefined") {
82
+ return;
83
+ }
84
+ const components = ["casino-engagement-suite-progress-bar"];
85
+ components.forEach(tagName => { switch (tagName) {
86
+ case "casino-engagement-suite-progress-bar":
87
+ if (!customElements.get(tagName)) {
88
+ customElements.define(tagName, CasinoEngagementSuiteProgressBar);
89
+ }
90
+ break;
91
+ } });
92
+ }
93
+
94
+ export { CasinoEngagementSuiteProgressBar as C, defineCustomElement as d };
@@ -1,4 +1,4 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-70e47fe0.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-ddf7e990.js';
2
2
 
3
3
  /*
4
4
  Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["casino-engagement-suite-challenges-list",[[1,"casino-engagement-suite-challenges-list",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"language":[1],"device":[1],"challenges":[1040],"tooltip":[32],"timers":[32],"limitStylingAppends":[32]},[[8,"message","handleEvent"]]]]]], options);
16
+ return bootstrapLazy([["casino-engagement-suite-challenges-list_2",[[1,"casino-engagement-suite-challenges-list",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"language":[1],"device":[1],"challenges":[1040],"isJoiningToChallenge":[1028,"is-joining-to-challenge"],"inProgressChallenges":[1040],"tooltip":[32],"timers":[32],"limitStylingAppends":[32],"newChallengeIds":[32],"pausedChallengeIds":[32]},[[8,"message","handleEvent"]]],[1,"casino-engagement-suite-progress-bar",{"value":[2],"disabled":[4],"hidePercent":[4,"hide-percent"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"limitStylingAppends":[32]}]]]], options);
17
17
  });
@@ -0,0 +1,508 @@
1
+ import { r as registerInstance, c as createEvent, h, g as getElement } from './index-ddf7e990.js';
2
+
3
+ var ChallengeLevelProgressStatus;
4
+ (function (ChallengeLevelProgressStatus) {
5
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Closed"] = 0] = "Closed";
6
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["InProgress"] = 1] = "InProgress";
7
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Fillup"] = 2] = "Fillup";
8
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Completed"] = 3] = "Completed";
9
+ })(ChallengeLevelProgressStatus || (ChallengeLevelProgressStatus = {}));
10
+ var ChallengeProgressStatus;
11
+ (function (ChallengeProgressStatus) {
12
+ ChallengeProgressStatus[ChallengeProgressStatus["Started"] = 0] = "Started";
13
+ ChallengeProgressStatus[ChallengeProgressStatus["InProgress"] = 1] = "InProgress";
14
+ ChallengeProgressStatus[ChallengeProgressStatus["PendingLevelReward"] = 2] = "PendingLevelReward";
15
+ ChallengeProgressStatus[ChallengeProgressStatus["Completed"] = 3] = "Completed";
16
+ ChallengeProgressStatus[ChallengeProgressStatus["Expired"] = 4] = "Expired";
17
+ })(ChallengeProgressStatus || (ChallengeProgressStatus = {}));
18
+
19
+ const DEFAULT_LANGUAGE = 'en';
20
+ const SUPPORTED_LANGUAGES = ['en'];
21
+ const TRANSLATIONS = {
22
+ en: {
23
+ challenges: 'Challenges',
24
+ join: 'Join',
25
+ unjoin: 'Unjoin',
26
+ new: 'new',
27
+ noChallenges: 'No Challenges yet',
28
+ tryOtherGames: 'Try winning Challenges as rewards or launching other booster games',
29
+ tooltip: 'Competition where your real money bets contribute towards the level progress to achieve the level reward'
30
+ }
31
+ };
32
+ const translate = (key, customLang) => {
33
+ const lang = customLang;
34
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
35
+ };
36
+
37
+ function _typeof(o) {
38
+ "@babel/helpers - typeof";
39
+
40
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
41
+ return typeof o;
42
+ } : function (o) {
43
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
44
+ }, _typeof(o);
45
+ }
46
+
47
+ function requiredArgs(required, args) {
48
+ if (args.length < required) {
49
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @name toDate
55
+ * @category Common Helpers
56
+ * @summary Convert the given argument to an instance of Date.
57
+ *
58
+ * @description
59
+ * Convert the given argument to an instance of Date.
60
+ *
61
+ * If the argument is an instance of Date, the function returns its clone.
62
+ *
63
+ * If the argument is a number, it is treated as a timestamp.
64
+ *
65
+ * If the argument is none of the above, the function returns Invalid Date.
66
+ *
67
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
68
+ *
69
+ * @param {Date|Number} argument - the value to convert
70
+ * @returns {Date} the parsed date in the local time zone
71
+ * @throws {TypeError} 1 argument required
72
+ *
73
+ * @example
74
+ * // Clone the date:
75
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
76
+ * //=> Tue Feb 11 2014 11:30:30
77
+ *
78
+ * @example
79
+ * // Convert the timestamp to date:
80
+ * const result = toDate(1392098430000)
81
+ * //=> Tue Feb 11 2014 11:30:30
82
+ */
83
+ function toDate(argument) {
84
+ requiredArgs(1, arguments);
85
+ var argStr = Object.prototype.toString.call(argument);
86
+
87
+ // Clone the date
88
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
89
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
90
+ return new Date(argument.getTime());
91
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
92
+ return new Date(argument);
93
+ } else {
94
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
95
+ // eslint-disable-next-line no-console
96
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
97
+ // eslint-disable-next-line no-console
98
+ console.warn(new Error().stack);
99
+ }
100
+ return new Date(NaN);
101
+ }
102
+ }
103
+
104
+ /**
105
+ * @name differenceInMilliseconds
106
+ * @category Millisecond Helpers
107
+ * @summary Get the number of milliseconds between the given dates.
108
+ *
109
+ * @description
110
+ * Get the number of milliseconds between the given dates.
111
+ *
112
+ * @param {Date|Number} dateLeft - the later date
113
+ * @param {Date|Number} dateRight - the earlier date
114
+ * @returns {Number} the number of milliseconds
115
+ * @throws {TypeError} 2 arguments required
116
+ *
117
+ * @example
118
+ * // How many milliseconds are between
119
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
120
+ * const result = differenceInMilliseconds(
121
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
122
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
123
+ * )
124
+ * //=> 1100
125
+ */
126
+ function differenceInMilliseconds(dateLeft, dateRight) {
127
+ requiredArgs(2, arguments);
128
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
129
+ }
130
+
131
+ var roundingMap = {
132
+ ceil: Math.ceil,
133
+ round: Math.round,
134
+ floor: Math.floor,
135
+ trunc: function trunc(value) {
136
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
137
+ } // Math.trunc is not supported by IE
138
+ };
139
+
140
+ var defaultRoundingMethod = 'trunc';
141
+ function getRoundingMethod(method) {
142
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
143
+ }
144
+
145
+ /**
146
+ * @name differenceInSeconds
147
+ * @category Second Helpers
148
+ * @summary Get the number of seconds between the given dates.
149
+ *
150
+ * @description
151
+ * Get the number of seconds between the given dates.
152
+ *
153
+ * @param {Date|Number} dateLeft - the later date
154
+ * @param {Date|Number} dateRight - the earlier date
155
+ * @param {Object} [options] - an object with options.
156
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
157
+ * @returns {Number} the number of seconds
158
+ * @throws {TypeError} 2 arguments required
159
+ *
160
+ * @example
161
+ * // How many seconds are between
162
+ * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000?
163
+ * const result = differenceInSeconds(
164
+ * new Date(2014, 6, 2, 12, 30, 20, 0),
165
+ * new Date(2014, 6, 2, 12, 30, 7, 999)
166
+ * )
167
+ * //=> 12
168
+ */
169
+ function differenceInSeconds(dateLeft, dateRight, options) {
170
+ requiredArgs(2, arguments);
171
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / 1000;
172
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
173
+ }
174
+
175
+ const casinoEngagementSuiteChallengesListCss = "@import url(\"https://fonts.googleapis.com/css2?family=Montserrat:wght@600&display=swap\");:host{display:block;font-family:inherit}*{box-sizing:border-box;margin:0;padding:0}button{border:none;background:none;cursor:pointer}button:focus{outline:none}.ChallengesListPopup{display:flex;height:100%;background-color:var(--emw--color-background, #1E1638);border-radius:8px;overflow:hidden;flex-direction:column;position:relative}.ChallengesListPopupHeader{display:flex;justify-content:space-between;align-items:center;padding:12px 8px 8px}.ChallengesIconButton{width:16px;height:16px;cursor:pointer}.ChallengesListPopupHeaderName{color:var(--emw--color-gray-100, #BBB9C3);font-size:14px;font-weight:500;line-height:14px}.ChallengesListWrapper{overflow-y:auto;-ms-overflow-style:none;scrollbar-width:none}.ChallengesListWrapper::-webkit-scrollbar{display:none}.ChallengesList{display:flex;flex-direction:column;row-gap:12px;padding:8px 19px 0}.ChallengeCard{padding:15px 15px 19px;border:1px solid var(--emw--button-border-color, #403956);border-radius:6px;position:relative;cursor:pointer}.ChallengeJoinButton.Joined::before,.ChallengeCard.InProgress::before{content:\"\";position:absolute;inset:0;border-radius:var(--emw--button-border-radius, 4px);padding:1px;background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);-webkit-mask:linear-gradient(#FFF 0 0) content-box, linear-gradient(#FFF 0 0);-webkit-mask-composite:xor;mask-composite:exclude}.ChallengeCardHeader{display:flex;justify-content:space-between;gap:24px;margin-bottom:12px}.ChallengeName{color:var(--emw--color-typography, #FFFFFF);font-family:\"Montserrat\", sans-serif;line-height:22px;font-weight:700;font-size:18px;word-break:break-word}.ChallengeJoinButton{transition:all 0.5s ease-out;background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);color:var(--emw--color-typography, #1E1638);border-radius:99px;min-width:88px;height:32px;font-size:14px;font-weight:700;position:relative;font-family:\"Montserrat\", sans-serif}.ChallengeJoinButton.Joined{background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.ChallengeJoinButton.Joined::before{border-radius:99px}.Disabled{opacity:0.5;pointer-events:none;cursor:auto}.ChallengesListEmpty{padding:20px 32px}.ChallengesListEmpty h2{margin:0 0 16px 0;text-align:center;font-weight:600;font-size:20px;line-height:24px;font-family:\"Montserrat\", sans-serif;color:var(--emw--color-typography, #FFFFFF)}.ChallengesListEmpty p{font-size:14px;line-height:17px;color:var(--emw--color-gray-100, #BBB9C3)}.ChallengeCountdown{color:var(--emw--color-gray-100, #BBB9C3);font-size:12px;line-height:12px}.ChallengeLabel{min-width:35px;height:18px;background:linear-gradient(180deg, #FFB801 15.86%, #FEF746 31.36%, #FBFFE0 36.86%, #FFFA60 47.86%, #FF9400 87.36%);border-radius:2px;display:none;position:absolute;top:-11px;right:11px;padding:0 2px;align-items:center;justify-content:center}.ChallengeLabel span{display:inline-block;text-transform:uppercase;font-size:10px;line-height:10px;font-weight:700;font-family:\"Montserrat\", sans-serif;color:var(--emw--color-typography, #1E1638)}.ShowChallengeLabel{display:inline-flex}.ChallengesTooltipBackdrop{padding:48px 30px 0;position:absolute;width:100%;height:100%;inset:0;background-color:rgba(0, 0, 0, 0.5)}.ChallengesTooltipBackdrop .ChallengesTooltip{border:1px solid var(--emw--button-border-color, #403956);background-color:var(--emw--color-background, #1E1638);border-radius:8px;padding:32px;font-size:14px;line-height:17px;color:var(--emw--color-gray-100, #BBB9C3);position:relative}.ChallengesTooltipBackdrop .ChallengesTooltip .ChallengesIconButton{top:12px;right:6px;position:absolute}.ChallengesListPopup.Tablet .ChallengesListPopupHeader,.ChallengesListPopup.Desktop .ChallengesListPopupHeader{padding-top:16px}.ChallengesListPopup.Tablet .ChallengesListPopupHeaderName,.ChallengesListPopup.Desktop .ChallengesListPopupHeaderName{font-size:16px;line-height:16px}.ChallengesListPopup.Tablet .ChallengesIconButton,.ChallengesListPopup.Desktop .ChallengesIconButton{width:24px;height:24px}.ChallengesListPopup.Tablet .ChallengesList,.ChallengesListPopup.Desktop .ChallengesList{padding:20px 24px 0;row-gap:20px}.ChallengesListPopup.Tablet .ChallengeCardHeader,.ChallengesListPopup.Desktop .ChallengeCardHeader{margin-bottom:16px}.ChallengesListPopup.Tablet .ChallengeName,.ChallengesListPopup.Desktop .ChallengeName{line-height:27px;font-size:22px}.ChallengesListPopup.Tablet .ChallengeJoinButton,.ChallengesListPopup.Desktop .ChallengeJoinButton{min-width:100px;height:36px;font-size:16px}.ChallengesListPopup.Tablet .ChallengeCountdown,.ChallengesListPopup.Desktop .ChallengeCountdown{font-size:14px;line-height:14px}.ChallengesListPopup.Tablet .ChallengesTooltip,.ChallengesListPopup.Desktop .ChallengesTooltip{padding:60px 65px;font-size:16px;line-height:20px}.ChallengesListPopup.Tablet .ChallengesTooltip .ChallengesIconButton,.ChallengesListPopup.Desktop .ChallengesTooltip .ChallengesIconButton{top:24px;right:24px}";
176
+
177
+ const CasinoEngagementSuiteChallengesList = class {
178
+ constructor(hostRef) {
179
+ registerInstance(this, hostRef);
180
+ this.close = createEvent(this, "close", 7);
181
+ /**
182
+ * Client custom styling via string
183
+ */
184
+ this.clientStyling = '';
185
+ /**
186
+ * Client custom styling via url
187
+ */
188
+ this.clientStylingUrl = '';
189
+ /**
190
+ * Language of the widget
191
+ */
192
+ this.language = 'en';
193
+ /**
194
+ * User's device type
195
+ */
196
+ this.device = 'Mobile';
197
+ /**
198
+ * List of challenges
199
+ */
200
+ this.challenges = [];
201
+ this.tooltip = false;
202
+ this.timers = {};
203
+ this.limitStylingAppends = false;
204
+ this.newChallengeIds = [];
205
+ this.pausedChallengeIds = [];
206
+ this.setClientStyling = () => {
207
+ let sheet = document.createElement('style');
208
+ sheet.innerHTML = this.clientStyling;
209
+ this.host.prepend(sheet);
210
+ };
211
+ this.setClientStylingURL = () => {
212
+ let url = new URL(this.clientStylingUrl);
213
+ let cssFile = document.createElement('style');
214
+ fetch(url.href)
215
+ .then((res) => res.text())
216
+ .then((data) => {
217
+ cssFile.innerHTML = data;
218
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
219
+ })
220
+ .catch((err) => {
221
+ console.log('Error ', err);
222
+ });
223
+ };
224
+ this.handleCloseClick = () => {
225
+ this.close.emit();
226
+ this.tooltip = false;
227
+ this.newChallengeIds = [];
228
+ };
229
+ this.handleChallengeClick = (ev) => {
230
+ const id = +ev.currentTarget.getAttribute('data-id');
231
+ window.postMessage({ type: 'ChallengeClick', id });
232
+ this.newChallengeIds = this.newChallengeIds.filter(item => item !== id);
233
+ };
234
+ this.showTooltip = () => {
235
+ this.tooltip = true;
236
+ };
237
+ this.hideTooltip = () => {
238
+ this.tooltip = false;
239
+ };
240
+ this.changeChallengeStatus = (e) => {
241
+ var _a, _b;
242
+ e.stopPropagation();
243
+ const id = +e.currentTarget.getAttribute('data-id');
244
+ if ((_a = this.inProgressChallenges) === null || _a === void 0 ? void 0 : _a.includes(id)) {
245
+ window.postMessage({
246
+ type: 'ShowConfirmationModal',
247
+ ProgressToDeactivate: id,
248
+ });
249
+ return;
250
+ }
251
+ if (((_b = this.inProgressChallenges) === null || _b === void 0 ? void 0 : _b.length) > 0) {
252
+ window.postMessage({
253
+ type: 'ShowConfirmationModal',
254
+ ProgressToActivate: id,
255
+ ProgressToDeactivate: this.inProgressChallenges[0],
256
+ });
257
+ return;
258
+ }
259
+ window.postMessage({
260
+ type: 'ChallengeJoinRequest',
261
+ data: {
262
+ ProgressToActivate: id,
263
+ },
264
+ });
265
+ };
266
+ }
267
+ challengesPropHandler(value) {
268
+ if (!this.interval && value.length) {
269
+ this.updateTimers();
270
+ this.startCountdown();
271
+ }
272
+ if (this.interval && !value.length) {
273
+ clearInterval(this.interval);
274
+ }
275
+ }
276
+ handleEvent(e) {
277
+ const type = e.data.type;
278
+ switch (type) {
279
+ case 'ChallengeGrant': {
280
+ const newChallenge = e.data.data;
281
+ const index = this.challenges.findIndex(challenge => differenceInSeconds(new Date(challenge.ExpirationTime), new Date(newChallenge.ExpirationTime)) > 0);
282
+ if (index > -1) {
283
+ this.challenges.splice(index, 0, newChallenge);
284
+ }
285
+ else {
286
+ this.challenges.unshift(newChallenge);
287
+ }
288
+ this.challenges = [...this.challenges];
289
+ this.newChallengeIds.push(newChallenge.Id);
290
+ window.postMessage({ type: 'UpdateChallenges' });
291
+ break;
292
+ }
293
+ case 'ChallengeChangeStatusNotification': {
294
+ const isEnabled = e.data.data.IsEnabled;
295
+ const id = e.data.data.ChallengeId;
296
+ if (!isEnabled) {
297
+ this.pausedChallengeIds.push(id);
298
+ }
299
+ else {
300
+ this.pausedChallengeIds = this.pausedChallengeIds.filter(c => c !== id);
301
+ }
302
+ break;
303
+ }
304
+ }
305
+ }
306
+ componentWillLoad() {
307
+ var _a;
308
+ this.challengesPropHandler(this.challenges);
309
+ if ((_a = this.challenges) === null || _a === void 0 ? void 0 : _a.length) {
310
+ this.newChallengeIds = this.challenges.filter(challenge => challenge.IsNew)
311
+ .map(challenge => challenge.Id);
312
+ }
313
+ }
314
+ componentDidRender() {
315
+ if (!this.limitStylingAppends && this.host) {
316
+ if (this.clientStyling)
317
+ this.setClientStyling();
318
+ if (this.clientStylingUrl)
319
+ this.setClientStylingURL();
320
+ this.limitStylingAppends = true;
321
+ }
322
+ }
323
+ disconnectedCallback() {
324
+ this.interval && clearInterval(this.interval);
325
+ }
326
+ startCountdown() {
327
+ this.interval = setInterval(() => {
328
+ this.updateTimers();
329
+ }, 1000);
330
+ }
331
+ updateTimers() {
332
+ const now = new Date().getTime();
333
+ this.timers = this.challenges.filter(challenge => challenge.Status !== ChallengeProgressStatus.Expired).reduce((acc, challenge) => {
334
+ const expirationDate = new Date(challenge.ExpirationTime).getTime();
335
+ const diff = expirationDate - now;
336
+ let countdown = '00h:00m:00s';
337
+ if (diff < 1) {
338
+ this.removeChallenge(challenge.Id);
339
+ }
340
+ else {
341
+ const { days, hours, minutes, seconds } = {
342
+ days: String(Math.floor(diff / (1000 * 60 * 60 * 24))).padStart(2, '0'),
343
+ hours: String(Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
344
+ minutes: String(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
345
+ seconds: String(Math.floor((diff % (1000 * 60)) / 1000)).padStart(2, '0')
346
+ };
347
+ countdown = days === '00'
348
+ ? `${hours}h:${minutes}m:${seconds}s`
349
+ : `${days}d:${hours}h:${minutes}m`;
350
+ }
351
+ return Object.assign(Object.assign({}, acc), { [challenge.Id]: countdown });
352
+ }, {});
353
+ }
354
+ removeChallenge(id) {
355
+ const index = this.challenges.findIndex(challenge => challenge.Id === id);
356
+ if (index > -1) {
357
+ this.challenges.splice(index, 1);
358
+ window.postMessage({ type: 'ChallengeHasExpired', id });
359
+ }
360
+ }
361
+ getChallengeClasses(challenge) {
362
+ return {
363
+ ChallengeCard: true,
364
+ InProgress: challenge.Status === ChallengeProgressStatus.InProgress
365
+ && !this.pausedChallengeIds.includes(challenge.Id),
366
+ Completed: this.isChallengeCompleted(challenge),
367
+ Paused: this.isChallengePaused(challenge)
368
+ };
369
+ }
370
+ isChallengePaused(challenge) {
371
+ return (challenge.Status === ChallengeProgressStatus.Started
372
+ && challenge.LevelProgresses[0].ProgressPercentage > 0)
373
+ || this.pausedChallengeIds.includes(challenge.Id);
374
+ }
375
+ isChallengeCompleted(challenge) {
376
+ return challenge.Status === ChallengeProgressStatus.Completed
377
+ || (challenge.Status === ChallengeProgressStatus.PendingLevelReward
378
+ && challenge.LevelProgresses.every(progress => progress.ProgressPercentage === 100));
379
+ }
380
+ getChallengeProgress(challenge) {
381
+ if (challenge.Status === ChallengeProgressStatus.Completed) {
382
+ return 100;
383
+ }
384
+ if (this.isChallengePaused(challenge)
385
+ || challenge.Status === ChallengeProgressStatus.PendingLevelReward
386
+ || challenge.Status === ChallengeProgressStatus.InProgress) {
387
+ const activeLevel = challenge.LevelProgresses
388
+ .find(level => level.ProgressStatus === ChallengeLevelProgressStatus.InProgress);
389
+ /**
390
+ * It is possible that Paused/InProgress challenge
391
+ * doesn't have InProgress level
392
+ * because level becomes InProgress after user's bet.
393
+ * In this case should be displayed progress of the next level (0%)
394
+ */
395
+ return activeLevel ? activeLevel.ProgressPercentage : 0;
396
+ }
397
+ return -1;
398
+ }
399
+ getChallengeHeaderTemplate(challenge) {
400
+ const { Id } = challenge;
401
+ return h("div", { class: "ChallengeCardHeader" }, h("div", { class: "ChallengeName" }, challenge.ChallengePresentation.PresentationName), h("button", { class: `${challenge.Status === ChallengeProgressStatus.InProgress ?
402
+ 'ChallengeJoinButton Joined' : 'ChallengeJoinButton'} ${this.isJoiningToChallenge ? 'Disabled' : ''}`, onClick: this.changeChallengeStatus, "data-id": Id }, challenge.Status === ChallengeProgressStatus.InProgress
403
+ ? translate('unjoin', this.language)
404
+ : translate('join', this.language)));
405
+ }
406
+ getChallengeTemplate(challenge) {
407
+ const challengeProgress = this.getChallengeProgress(challenge);
408
+ const countdown = this.timers[challenge.Id];
409
+ const isNewChallenge = this.newChallengeIds.includes(challenge.Id);
410
+ const progressTemplate = challengeProgress > -1
411
+ ? h("casino-engagement-suite-progress-bar", { class: this.device, value: challengeProgress, disabled: this.isChallengePaused(challenge) }, h("span", { slot: "Title", class: "ChallengeCountdown" }, countdown))
412
+ : h("span", { class: "ChallengeCountdown" }, countdown);
413
+ return (h("div", { class: this.getChallengeClasses(challenge), onClick: this.handleChallengeClick, key: challenge.Id, "data-id": challenge.Id }, this.getChallengeHeaderTemplate(challenge), progressTemplate, h("div", { class: `ChallengeLabel ${isNewChallenge ? 'ShowChallengeLabel' : ''}` }, h("span", null, translate('new', this.language)))));
414
+ }
415
+ getHeaderTemplate() {
416
+ return h("header", { class: "ChallengesListPopupHeader" }, h("button", { onClick: this.showTooltip, class: "ChallengesIconButton" }, h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/help.svg", alt: "Show tooltip" })), h("div", { class: "ChallengesListPopupHeaderName" }, translate('challenges', this.language)), h("button", { class: "ChallengesIconButton", onClick: this.handleCloseClick }, h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "Close challenges list" })));
417
+ }
418
+ getListTemplate() {
419
+ if (this.challenges.length) {
420
+ return h("div", { class: "ChallengesListWrapper" }, h("div", { class: "ChallengesList" }, this.challenges.map(challenge => this.getChallengeTemplate(challenge))));
421
+ }
422
+ else {
423
+ return h("div", { class: "ChallengesListEmpty" }, h("h2", null, translate('noChallenges', this.language)), h("p", null, translate('tryOtherGames', this.language)));
424
+ }
425
+ }
426
+ getTooltipTemplate() {
427
+ return h("div", { class: "ChallengesTooltipBackdrop" }, h("div", { class: "ChallengesTooltip" }, h("button", { class: "ChallengesIconButton", onClick: this.hideTooltip }, h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "Close tooltip" })), translate('tooltip', this.language)));
428
+ }
429
+ render() {
430
+ return h("div", { class: `ChallengesListPopup ${this.device}` }, this.getHeaderTemplate(), this.getListTemplate(), this.tooltip && this.getTooltipTemplate());
431
+ }
432
+ get host() { return getElement(this); }
433
+ static get watchers() { return {
434
+ "challenges": ["challengesPropHandler"]
435
+ }; }
436
+ };
437
+ CasinoEngagementSuiteChallengesList.style = casinoEngagementSuiteChallengesListCss;
438
+
439
+ const casinoEngagementSuiteProgressBarCss = ":host{display:block;font-family:inherit}:host(.Desktop) .ProgressBarPercent{font-size:14px;line-height:14px}.ProgressBarBackground{height:8px;background-color:var(--emw--color-background, #666178);border-radius:4px;position:relative}.ProgressBarLine{position:absolute;left:0;top:0;bottom:0;border-radius:4px;background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);transition:width ease-out 0.3s}.ProgressBarInfo{margin-bottom:8px;display:flex;justify-content:space-between;align-items:center}.ProgressBarPercent{font-weight:700;font-size:12px;line-height:12px}.HidePercent .ProgressBarPercent{display:none}.ProgressBar:not(.Disabled) .ProgressBarPercent{background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.ProgressBar.Disabled .ProgressBarPercent{color:var(--emw--color-background, #666178)}.ProgressBar.Disabled .ProgressBarLine{background:var(--emw--color-background-secondary, #474668)}";
440
+
441
+ const CasinoEngagementSuiteProgressBar = class {
442
+ constructor(hostRef) {
443
+ registerInstance(this, hostRef);
444
+ /**
445
+ * Value for the widget
446
+ */
447
+ this.value = 0;
448
+ /**
449
+ * Shows disabled styles
450
+ */
451
+ this.disabled = false;
452
+ /**
453
+ * Hide percent value
454
+ */
455
+ this.hidePercent = false;
456
+ /**
457
+ * Client custom styling via string
458
+ */
459
+ this.clientStyling = '';
460
+ /**
461
+ * Client custom styling via url
462
+ */
463
+ this.clientStylingUrl = '';
464
+ this.limitStylingAppends = false;
465
+ this.setClientStyling = () => {
466
+ let sheet = document.createElement('style');
467
+ sheet.innerHTML = this.clientStyling;
468
+ this.host.prepend(sheet);
469
+ };
470
+ this.setClientStylingURL = () => {
471
+ let url = new URL(this.clientStylingUrl);
472
+ let cssFile = document.createElement('style');
473
+ fetch(url.href)
474
+ .then((res) => res.text())
475
+ .then((data) => {
476
+ cssFile.innerHTML = data;
477
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
478
+ })
479
+ .catch((err) => {
480
+ console.log('Error ', err);
481
+ });
482
+ };
483
+ }
484
+ componentDidRender() {
485
+ if (!this.limitStylingAppends && this.host) {
486
+ if (this.clientStyling)
487
+ this.setClientStyling();
488
+ if (this.clientStylingUrl)
489
+ this.setClientStylingURL();
490
+ this.limitStylingAppends = true;
491
+ }
492
+ }
493
+ getProgressBarClasses() {
494
+ return {
495
+ ProgressBar: true,
496
+ Completed: this.value === 100,
497
+ Disabled: this.disabled,
498
+ HidePercent: this.hidePercent
499
+ };
500
+ }
501
+ render() {
502
+ return h("div", { class: this.getProgressBarClasses(), part: "ProgressBar" }, h("div", { class: "ProgressBarInfo", part: "ProgressBarInfo" }, h("slot", { name: "Title" }, h("div", null)), h("slot", { name: "Percent" }, h("div", { class: "ProgressBarPercent", part: "ProgressBarPercent" }, this.value, "%"))), h("div", { class: "ProgressBarBackground", part: "ProgressBarBackground" }, h("div", { class: "ProgressBarLine", part: "ProgressBarLine", style: { width: this.value + '%' } })));
503
+ }
504
+ get host() { return getElement(this); }
505
+ };
506
+ CasinoEngagementSuiteProgressBar.style = casinoEngagementSuiteProgressBarCss;
507
+
508
+ export { CasinoEngagementSuiteChallengesList as casino_engagement_suite_challenges_list, CasinoEngagementSuiteProgressBar as casino_engagement_suite_progress_bar };