@everymatrix/casino-engagement-suite-challenges-list 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.esm.js +1 -0
  2. package/dist/casino-engagement-suite-challenges-list/index.esm.js +0 -0
  3. package/dist/casino-engagement-suite-challenges-list/p-7e171791.js +1 -0
  4. package/dist/casino-engagement-suite-challenges-list/p-eb36cbe7.entry.js +1 -0
  5. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.entry.js +1147 -0
  6. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.js +19 -0
  7. package/dist/cjs/index-79c88755.js +1299 -0
  8. package/dist/cjs/index.cjs.js +2 -0
  9. package/dist/cjs/loader.cjs.js +21 -0
  10. package/dist/collection/collection-manifest.json +12 -0
  11. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.css +225 -0
  12. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.js +368 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/models/challenge.js +15 -0
  15. package/dist/collection/utils/locale.utils.js +16 -0
  16. package/dist/components/casino-engagement-suite-challenges-list.d.ts +11 -0
  17. package/dist/components/casino-engagement-suite-challenges-list.js +1170 -0
  18. package/dist/components/index.d.ts +26 -0
  19. package/dist/components/index.js +1 -0
  20. package/dist/esm/casino-engagement-suite-challenges-list.entry.js +1143 -0
  21. package/dist/esm/casino-engagement-suite-challenges-list.js +17 -0
  22. package/dist/esm/index-70e47fe0.js +1272 -0
  23. package/dist/esm/index.js +1 -0
  24. package/dist/esm/loader.js +17 -0
  25. package/dist/esm/polyfills/core-js.js +11 -0
  26. package/dist/esm/polyfills/css-shim.js +1 -0
  27. package/dist/esm/polyfills/dom.js +79 -0
  28. package/dist/esm/polyfills/es5-html-element.js +1 -0
  29. package/dist/esm/polyfills/index.js +34 -0
  30. package/dist/esm/polyfills/system.js +6 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/stencil.config.js +22 -0
  34. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/casino-engagement-suite-challenges-list/.stencil/packages/casino-engagement-suite-challenges-list/stencil.config.d.ts +2 -0
  35. package/dist/types/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.d.ts +60 -0
  36. package/dist/types/components.d.ts +79 -0
  37. package/dist/types/index.d.ts +1 -0
  38. package/dist/types/models/challenge.d.ts +57 -0
  39. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  40. package/dist/types/utils/locale.utils.d.ts +1 -0
  41. package/loader/cdn.js +3 -0
  42. package/loader/index.cjs.js +3 -0
  43. package/loader/index.d.ts +12 -0
  44. package/loader/index.es2017.js +3 -0
  45. package/loader/index.js +4 -0
  46. package/loader/package.json +10 -0
  47. package/package.json +19 -0
@@ -0,0 +1,1147 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-79c88755.js');
6
+ require('@everymatrix/casino-engagement-suite-progress-bar');
7
+
8
+ var ChallengeLevelProgressStatus;
9
+ (function (ChallengeLevelProgressStatus) {
10
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Closed"] = 0] = "Closed";
11
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["InProgress"] = 1] = "InProgress";
12
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Fillup"] = 2] = "Fillup";
13
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Completed"] = 3] = "Completed";
14
+ })(ChallengeLevelProgressStatus || (ChallengeLevelProgressStatus = {}));
15
+ var ChallengeProgressStatus;
16
+ (function (ChallengeProgressStatus) {
17
+ ChallengeProgressStatus[ChallengeProgressStatus["Started"] = 0] = "Started";
18
+ ChallengeProgressStatus[ChallengeProgressStatus["InProgress"] = 1] = "InProgress";
19
+ ChallengeProgressStatus[ChallengeProgressStatus["PendingLevelReward"] = 2] = "PendingLevelReward";
20
+ ChallengeProgressStatus[ChallengeProgressStatus["Completed"] = 3] = "Completed";
21
+ ChallengeProgressStatus[ChallengeProgressStatus["Expired"] = 4] = "Expired";
22
+ })(ChallengeProgressStatus || (ChallengeProgressStatus = {}));
23
+
24
+ const DEFAULT_LANGUAGE = 'en';
25
+ const SUPPORTED_LANGUAGES = ['en'];
26
+ const TRANSLATIONS = {
27
+ en: {
28
+ challenges: 'Challenges',
29
+ join: 'Join',
30
+ unjoin: 'Unjoin',
31
+ noChallenges: 'No Challenges yet',
32
+ tryOtherGames: 'Try winning Challenges as rewards or launching other booster games',
33
+ tooltip: 'Competition where your real money bets contribute towards the level progress to achieve the level reward'
34
+ }
35
+ };
36
+ const translate = (key, customLang) => {
37
+ const lang = customLang;
38
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
39
+ };
40
+
41
+ function _typeof(o) {
42
+ "@babel/helpers - typeof";
43
+
44
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
45
+ return typeof o;
46
+ } : function (o) {
47
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
48
+ }, _typeof(o);
49
+ }
50
+
51
+ function requiredArgs(required, args) {
52
+ if (args.length < required) {
53
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
54
+ }
55
+ }
56
+
57
+ /**
58
+ * @name toDate
59
+ * @category Common Helpers
60
+ * @summary Convert the given argument to an instance of Date.
61
+ *
62
+ * @description
63
+ * Convert the given argument to an instance of Date.
64
+ *
65
+ * If the argument is an instance of Date, the function returns its clone.
66
+ *
67
+ * If the argument is a number, it is treated as a timestamp.
68
+ *
69
+ * If the argument is none of the above, the function returns Invalid Date.
70
+ *
71
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
72
+ *
73
+ * @param {Date|Number} argument - the value to convert
74
+ * @returns {Date} the parsed date in the local time zone
75
+ * @throws {TypeError} 1 argument required
76
+ *
77
+ * @example
78
+ * // Clone the date:
79
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
80
+ * //=> Tue Feb 11 2014 11:30:30
81
+ *
82
+ * @example
83
+ * // Convert the timestamp to date:
84
+ * const result = toDate(1392098430000)
85
+ * //=> Tue Feb 11 2014 11:30:30
86
+ */
87
+ function toDate(argument) {
88
+ requiredArgs(1, arguments);
89
+ var argStr = Object.prototype.toString.call(argument);
90
+
91
+ // Clone the date
92
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
93
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
94
+ return new Date(argument.getTime());
95
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
96
+ return new Date(argument);
97
+ } else {
98
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
99
+ // eslint-disable-next-line no-console
100
+ 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");
101
+ // eslint-disable-next-line no-console
102
+ console.warn(new Error().stack);
103
+ }
104
+ return new Date(NaN);
105
+ }
106
+ }
107
+
108
+ /**
109
+ * @name compareAsc
110
+ * @category Common Helpers
111
+ * @summary Compare the two dates and return -1, 0 or 1.
112
+ *
113
+ * @description
114
+ * Compare the two dates and return 1 if the first date is after the second,
115
+ * -1 if the first date is before the second or 0 if dates are equal.
116
+ *
117
+ * @param {Date|Number} dateLeft - the first date to compare
118
+ * @param {Date|Number} dateRight - the second date to compare
119
+ * @returns {Number} the result of the comparison
120
+ * @throws {TypeError} 2 arguments required
121
+ *
122
+ * @example
123
+ * // Compare 11 February 1987 and 10 July 1989:
124
+ * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
125
+ * //=> -1
126
+ *
127
+ * @example
128
+ * // Sort the array of dates:
129
+ * const result = [
130
+ * new Date(1995, 6, 2),
131
+ * new Date(1987, 1, 11),
132
+ * new Date(1989, 6, 10)
133
+ * ].sort(compareAsc)
134
+ * //=> [
135
+ * // Wed Feb 11 1987 00:00:00,
136
+ * // Mon Jul 10 1989 00:00:00,
137
+ * // Sun Jul 02 1995 00:00:00
138
+ * // ]
139
+ */
140
+ function compareAsc(dirtyDateLeft, dirtyDateRight) {
141
+ requiredArgs(2, arguments);
142
+ var dateLeft = toDate(dirtyDateLeft);
143
+ var dateRight = toDate(dirtyDateRight);
144
+ var diff = dateLeft.getTime() - dateRight.getTime();
145
+ if (diff < 0) {
146
+ return -1;
147
+ } else if (diff > 0) {
148
+ return 1;
149
+ // Return 0 if diff is 0; return NaN if diff is NaN
150
+ } else {
151
+ return diff;
152
+ }
153
+ }
154
+
155
+ function toInteger(dirtyNumber) {
156
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
157
+ return NaN;
158
+ }
159
+ var number = Number(dirtyNumber);
160
+ if (isNaN(number)) {
161
+ return number;
162
+ }
163
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
164
+ }
165
+
166
+ /**
167
+ * @name addDays
168
+ * @category Day Helpers
169
+ * @summary Add the specified number of days to the given date.
170
+ *
171
+ * @description
172
+ * Add the specified number of days to the given date.
173
+ *
174
+ * @param {Date|Number} date - the date to be changed
175
+ * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
176
+ * @returns {Date} - the new date with the days added
177
+ * @throws {TypeError} - 2 arguments required
178
+ *
179
+ * @example
180
+ * // Add 10 days to 1 September 2014:
181
+ * const result = addDays(new Date(2014, 8, 1), 10)
182
+ * //=> Thu Sep 11 2014 00:00:00
183
+ */
184
+ function addDays(dirtyDate, dirtyAmount) {
185
+ requiredArgs(2, arguments);
186
+ var date = toDate(dirtyDate);
187
+ var amount = toInteger(dirtyAmount);
188
+ if (isNaN(amount)) {
189
+ return new Date(NaN);
190
+ }
191
+ if (!amount) {
192
+ // If 0 days, no-op to avoid changing times in the hour before end of DST
193
+ return date;
194
+ }
195
+ date.setDate(date.getDate() + amount);
196
+ return date;
197
+ }
198
+
199
+ /**
200
+ * @name addMonths
201
+ * @category Month Helpers
202
+ * @summary Add the specified number of months to the given date.
203
+ *
204
+ * @description
205
+ * Add the specified number of months to the given date.
206
+ *
207
+ * @param {Date|Number} date - the date to be changed
208
+ * @param {Number} amount - the amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
209
+ * @returns {Date} the new date with the months added
210
+ * @throws {TypeError} 2 arguments required
211
+ *
212
+ * @example
213
+ * // Add 5 months to 1 September 2014:
214
+ * const result = addMonths(new Date(2014, 8, 1), 5)
215
+ * //=> Sun Feb 01 2015 00:00:00
216
+ */
217
+ function addMonths(dirtyDate, dirtyAmount) {
218
+ requiredArgs(2, arguments);
219
+ var date = toDate(dirtyDate);
220
+ var amount = toInteger(dirtyAmount);
221
+ if (isNaN(amount)) {
222
+ return new Date(NaN);
223
+ }
224
+ if (!amount) {
225
+ // If 0 months, no-op to avoid changing times in the hour before end of DST
226
+ return date;
227
+ }
228
+ var dayOfMonth = date.getDate();
229
+
230
+ // The JS Date object supports date math by accepting out-of-bounds values for
231
+ // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
232
+ // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
233
+ // want except that dates will wrap around the end of a month, meaning that
234
+ // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
235
+ // we'll default to the end of the desired month by adding 1 to the desired
236
+ // month and using a date of 0 to back up one day to the end of the desired
237
+ // month.
238
+ var endOfDesiredMonth = new Date(date.getTime());
239
+ endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0);
240
+ var daysInMonth = endOfDesiredMonth.getDate();
241
+ if (dayOfMonth >= daysInMonth) {
242
+ // If we're already at the end of the month, then this is the correct date
243
+ // and we're done.
244
+ return endOfDesiredMonth;
245
+ } else {
246
+ // Otherwise, we now know that setting the original day-of-month value won't
247
+ // cause an overflow, so set the desired day-of-month. Note that we can't
248
+ // just set the date of `endOfDesiredMonth` because that object may have had
249
+ // its time changed in the unusual case where where a DST transition was on
250
+ // the last day of the month and its local time was in the hour skipped or
251
+ // repeated next to a DST transition. So we use `date` instead which is
252
+ // guaranteed to still have the original time.
253
+ date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
254
+ return date;
255
+ }
256
+ }
257
+
258
+ /**
259
+ * @name add
260
+ * @category Common Helpers
261
+ * @summary Add the specified years, months, weeks, days, hours, minutes and seconds to the given date.
262
+ *
263
+ * @description
264
+ * Add the specified years, months, weeks, days, hours, minutes and seconds to the given date.
265
+ *
266
+ * @param {Date|Number} date - the date to be changed
267
+ * @param {Duration} duration - the object with years, months, weeks, days, hours, minutes and seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
268
+ *
269
+ * | Key | Description |
270
+ * |----------------|------------------------------------|
271
+ * | years | Amount of years to be added |
272
+ * | months | Amount of months to be added |
273
+ * | weeks | Amount of weeks to be added |
274
+ * | days | Amount of days to be added |
275
+ * | hours | Amount of hours to be added |
276
+ * | minutes | Amount of minutes to be added |
277
+ * | seconds | Amount of seconds to be added |
278
+ *
279
+ * All values default to 0
280
+ *
281
+ * @returns {Date} the new date with the seconds added
282
+ * @throws {TypeError} 2 arguments required
283
+ *
284
+ * @example
285
+ * // Add the following duration to 1 September 2014, 10:19:50
286
+ * const result = add(new Date(2014, 8, 1, 10, 19, 50), {
287
+ * years: 2,
288
+ * months: 9,
289
+ * weeks: 1,
290
+ * days: 7,
291
+ * hours: 5,
292
+ * minutes: 9,
293
+ * seconds: 30,
294
+ * })
295
+ * //=> Thu Jun 15 2017 15:29:20
296
+ */
297
+ function add(dirtyDate, duration) {
298
+ requiredArgs(2, arguments);
299
+ if (!duration || _typeof(duration) !== 'object') return new Date(NaN);
300
+ var years = duration.years ? toInteger(duration.years) : 0;
301
+ var months = duration.months ? toInteger(duration.months) : 0;
302
+ var weeks = duration.weeks ? toInteger(duration.weeks) : 0;
303
+ var days = duration.days ? toInteger(duration.days) : 0;
304
+ var hours = duration.hours ? toInteger(duration.hours) : 0;
305
+ var minutes = duration.minutes ? toInteger(duration.minutes) : 0;
306
+ var seconds = duration.seconds ? toInteger(duration.seconds) : 0;
307
+
308
+ // Add years and months
309
+ var date = toDate(dirtyDate);
310
+ var dateWithMonths = months || years ? addMonths(date, months + years * 12) : date;
311
+
312
+ // Add weeks and days
313
+ var dateWithDays = days || weeks ? addDays(dateWithMonths, days + weeks * 7) : dateWithMonths;
314
+
315
+ // Add days, hours, minutes and seconds
316
+ var minutesToAdd = minutes + hours * 60;
317
+ var secondsToAdd = seconds + minutesToAdd * 60;
318
+ var msToAdd = secondsToAdd * 1000;
319
+ var finalDate = new Date(dateWithDays.getTime() + msToAdd);
320
+ return finalDate;
321
+ }
322
+
323
+ /**
324
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
325
+ * They usually appear for dates that denote time before the timezones were introduced
326
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
327
+ * and GMT+01:00:00 after that date)
328
+ *
329
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
330
+ * which would lead to incorrect calculations.
331
+ *
332
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
333
+ */
334
+ function getTimezoneOffsetInMilliseconds(date) {
335
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
336
+ utcDate.setUTCFullYear(date.getFullYear());
337
+ return date.getTime() - utcDate.getTime();
338
+ }
339
+
340
+ /**
341
+ * @name startOfDay
342
+ * @category Day Helpers
343
+ * @summary Return the start of a day for the given date.
344
+ *
345
+ * @description
346
+ * Return the start of a day for the given date.
347
+ * The result will be in the local timezone.
348
+ *
349
+ * @param {Date|Number} date - the original date
350
+ * @returns {Date} the start of a day
351
+ * @throws {TypeError} 1 argument required
352
+ *
353
+ * @example
354
+ * // The start of a day for 2 September 2014 11:55:00:
355
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
356
+ * //=> Tue Sep 02 2014 00:00:00
357
+ */
358
+ function startOfDay(dirtyDate) {
359
+ requiredArgs(1, arguments);
360
+ var date = toDate(dirtyDate);
361
+ date.setHours(0, 0, 0, 0);
362
+ return date;
363
+ }
364
+
365
+ var MILLISECONDS_IN_DAY = 86400000;
366
+
367
+ /**
368
+ * @name differenceInCalendarDays
369
+ * @category Day Helpers
370
+ * @summary Get the number of calendar days between the given dates.
371
+ *
372
+ * @description
373
+ * Get the number of calendar days between the given dates. This means that the times are removed
374
+ * from the dates and then the difference in days is calculated.
375
+ *
376
+ * @param {Date|Number} dateLeft - the later date
377
+ * @param {Date|Number} dateRight - the earlier date
378
+ * @returns {Number} the number of calendar days
379
+ * @throws {TypeError} 2 arguments required
380
+ *
381
+ * @example
382
+ * // How many calendar days are between
383
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
384
+ * const result = differenceInCalendarDays(
385
+ * new Date(2012, 6, 2, 0, 0),
386
+ * new Date(2011, 6, 2, 23, 0)
387
+ * )
388
+ * //=> 366
389
+ * // How many calendar days are between
390
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
391
+ * const result = differenceInCalendarDays(
392
+ * new Date(2011, 6, 3, 0, 1),
393
+ * new Date(2011, 6, 2, 23, 59)
394
+ * )
395
+ * //=> 1
396
+ */
397
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
398
+ requiredArgs(2, arguments);
399
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
400
+ var startOfDayRight = startOfDay(dirtyDateRight);
401
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
402
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
403
+
404
+ // Round the number of days to the nearest integer
405
+ // because the number of milliseconds in a day is not constant
406
+ // (e.g. it's different in the day of the daylight saving time clock shift)
407
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
408
+ }
409
+
410
+ // for accurate equality comparisons of UTC timestamps that end up
411
+ // having the same representation in local time, e.g. one hour before
412
+ // DST ends vs. the instant that DST ends.
413
+ function compareLocalAsc(dateLeft, dateRight) {
414
+ var diff = dateLeft.getFullYear() - dateRight.getFullYear() || dateLeft.getMonth() - dateRight.getMonth() || dateLeft.getDate() - dateRight.getDate() || dateLeft.getHours() - dateRight.getHours() || dateLeft.getMinutes() - dateRight.getMinutes() || dateLeft.getSeconds() - dateRight.getSeconds() || dateLeft.getMilliseconds() - dateRight.getMilliseconds();
415
+ if (diff < 0) {
416
+ return -1;
417
+ } else if (diff > 0) {
418
+ return 1;
419
+ // Return 0 if diff is 0; return NaN if diff is NaN
420
+ } else {
421
+ return diff;
422
+ }
423
+ }
424
+
425
+ /**
426
+ * @name differenceInDays
427
+ * @category Day Helpers
428
+ * @summary Get the number of full days between the given dates.
429
+ *
430
+ * @description
431
+ * Get the number of full day periods between two dates. Fractional days are
432
+ * truncated towards zero.
433
+ *
434
+ * One "full day" is the distance between a local time in one day to the same
435
+ * local time on the next or previous day. A full day can sometimes be less than
436
+ * or more than 24 hours if a daylight savings change happens between two dates.
437
+ *
438
+ * To ignore DST and only measure exact 24-hour periods, use this instead:
439
+ * `Math.floor(differenceInHours(dateLeft, dateRight)/24)|0`.
440
+ *
441
+ *
442
+ * @param {Date|Number} dateLeft - the later date
443
+ * @param {Date|Number} dateRight - the earlier date
444
+ * @returns {Number} the number of full days according to the local timezone
445
+ * @throws {TypeError} 2 arguments required
446
+ *
447
+ * @example
448
+ * // How many full days are between
449
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
450
+ * const result = differenceInDays(
451
+ * new Date(2012, 6, 2, 0, 0),
452
+ * new Date(2011, 6, 2, 23, 0)
453
+ * )
454
+ * //=> 365
455
+ * // How many full days are between
456
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
457
+ * const result = differenceInDays(
458
+ * new Date(2011, 6, 3, 0, 1),
459
+ * new Date(2011, 6, 2, 23, 59)
460
+ * )
461
+ * //=> 0
462
+ * // How many full days are between
463
+ * // 1 March 2020 0:00 and 1 June 2020 0:00 ?
464
+ * // Note: because local time is used, the
465
+ * // result will always be 92 days, even in
466
+ * // time zones where DST starts and the
467
+ * // period has only 92*24-1 hours.
468
+ * const result = differenceInDays(
469
+ * new Date(2020, 5, 1),
470
+ * new Date(2020, 2, 1)
471
+ * )
472
+ //=> 92
473
+ */
474
+ function differenceInDays(dirtyDateLeft, dirtyDateRight) {
475
+ requiredArgs(2, arguments);
476
+ var dateLeft = toDate(dirtyDateLeft);
477
+ var dateRight = toDate(dirtyDateRight);
478
+ var sign = compareLocalAsc(dateLeft, dateRight);
479
+ var difference = Math.abs(differenceInCalendarDays(dateLeft, dateRight));
480
+ dateLeft.setDate(dateLeft.getDate() - sign * difference);
481
+
482
+ // Math.abs(diff in full days - diff in calendar days) === 1 if last calendar day is not full
483
+ // If so, result must be decreased by 1 in absolute value
484
+ var isLastDayNotFull = Number(compareLocalAsc(dateLeft, dateRight) === -sign);
485
+ var result = sign * (difference - isLastDayNotFull);
486
+ // Prevent negative zero
487
+ return result === 0 ? 0 : result;
488
+ }
489
+
490
+ /**
491
+ * Days in 1 week.
492
+ *
493
+ * @name daysInWeek
494
+ * @constant
495
+ * @type {number}
496
+ * @default
497
+ */
498
+
499
+ /**
500
+ * Milliseconds in 1 minute
501
+ *
502
+ * @name millisecondsInMinute
503
+ * @constant
504
+ * @type {number}
505
+ * @default
506
+ */
507
+ var millisecondsInMinute = 60000;
508
+
509
+ /**
510
+ * Milliseconds in 1 hour
511
+ *
512
+ * @name millisecondsInHour
513
+ * @constant
514
+ * @type {number}
515
+ * @default
516
+ */
517
+ var millisecondsInHour = 3600000;
518
+
519
+ /**
520
+ * @name differenceInMilliseconds
521
+ * @category Millisecond Helpers
522
+ * @summary Get the number of milliseconds between the given dates.
523
+ *
524
+ * @description
525
+ * Get the number of milliseconds between the given dates.
526
+ *
527
+ * @param {Date|Number} dateLeft - the later date
528
+ * @param {Date|Number} dateRight - the earlier date
529
+ * @returns {Number} the number of milliseconds
530
+ * @throws {TypeError} 2 arguments required
531
+ *
532
+ * @example
533
+ * // How many milliseconds are between
534
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
535
+ * const result = differenceInMilliseconds(
536
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
537
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
538
+ * )
539
+ * //=> 1100
540
+ */
541
+ function differenceInMilliseconds(dateLeft, dateRight) {
542
+ requiredArgs(2, arguments);
543
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
544
+ }
545
+
546
+ var roundingMap = {
547
+ ceil: Math.ceil,
548
+ round: Math.round,
549
+ floor: Math.floor,
550
+ trunc: function trunc(value) {
551
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
552
+ } // Math.trunc is not supported by IE
553
+ };
554
+
555
+ var defaultRoundingMethod = 'trunc';
556
+ function getRoundingMethod(method) {
557
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
558
+ }
559
+
560
+ /**
561
+ * @name differenceInHours
562
+ * @category Hour Helpers
563
+ * @summary Get the number of hours between the given dates.
564
+ *
565
+ * @description
566
+ * Get the number of hours between the given dates.
567
+ *
568
+ * @param {Date|Number} dateLeft - the later date
569
+ * @param {Date|Number} dateRight - the earlier date
570
+ * @param {Object} [options] - an object with options.
571
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
572
+ * @returns {Number} the number of hours
573
+ * @throws {TypeError} 2 arguments required
574
+ *
575
+ * @example
576
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
577
+ * const result = differenceInHours(
578
+ * new Date(2014, 6, 2, 19, 0),
579
+ * new Date(2014, 6, 2, 6, 50)
580
+ * )
581
+ * //=> 12
582
+ */
583
+ function differenceInHours(dateLeft, dateRight, options) {
584
+ requiredArgs(2, arguments);
585
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
586
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
587
+ }
588
+
589
+ /**
590
+ * @name differenceInMinutes
591
+ * @category Minute Helpers
592
+ * @summary Get the number of minutes between the given dates.
593
+ *
594
+ * @description
595
+ * Get the signed number of full (rounded towards 0) minutes between the given dates.
596
+ *
597
+ * @param {Date|Number} dateLeft - the later date
598
+ * @param {Date|Number} dateRight - the earlier date
599
+ * @param {Object} [options] - an object with options.
600
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
601
+ * @returns {Number} the number of minutes
602
+ * @throws {TypeError} 2 arguments required
603
+ *
604
+ * @example
605
+ * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
606
+ * const result = differenceInMinutes(
607
+ * new Date(2014, 6, 2, 12, 20, 0),
608
+ * new Date(2014, 6, 2, 12, 7, 59)
609
+ * )
610
+ * //=> 12
611
+ *
612
+ * @example
613
+ * // How many minutes are between 10:01:59 and 10:00:00
614
+ * const result = differenceInMinutes(
615
+ * new Date(2000, 0, 1, 10, 0, 0),
616
+ * new Date(2000, 0, 1, 10, 1, 59)
617
+ * )
618
+ * //=> -1
619
+ */
620
+ function differenceInMinutes(dateLeft, dateRight, options) {
621
+ requiredArgs(2, arguments);
622
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
623
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
624
+ }
625
+
626
+ /**
627
+ * @name differenceInCalendarMonths
628
+ * @category Month Helpers
629
+ * @summary Get the number of calendar months between the given dates.
630
+ *
631
+ * @description
632
+ * Get the number of calendar months between the given dates.
633
+ *
634
+ * @param {Date|Number} dateLeft - the later date
635
+ * @param {Date|Number} dateRight - the earlier date
636
+ * @returns {Number} the number of calendar months
637
+ * @throws {TypeError} 2 arguments required
638
+ *
639
+ * @example
640
+ * // How many calendar months are between 31 January 2014 and 1 September 2014?
641
+ * const result = differenceInCalendarMonths(
642
+ * new Date(2014, 8, 1),
643
+ * new Date(2014, 0, 31)
644
+ * )
645
+ * //=> 8
646
+ */
647
+ function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {
648
+ requiredArgs(2, arguments);
649
+ var dateLeft = toDate(dirtyDateLeft);
650
+ var dateRight = toDate(dirtyDateRight);
651
+ var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();
652
+ var monthDiff = dateLeft.getMonth() - dateRight.getMonth();
653
+ return yearDiff * 12 + monthDiff;
654
+ }
655
+
656
+ /**
657
+ * @name endOfDay
658
+ * @category Day Helpers
659
+ * @summary Return the end of a day for the given date.
660
+ *
661
+ * @description
662
+ * Return the end of a day for the given date.
663
+ * The result will be in the local timezone.
664
+ *
665
+ * @param {Date|Number} date - the original date
666
+ * @returns {Date} the end of a day
667
+ * @throws {TypeError} 1 argument required
668
+ *
669
+ * @example
670
+ * // The end of a day for 2 September 2014 11:55:00:
671
+ * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
672
+ * //=> Tue Sep 02 2014 23:59:59.999
673
+ */
674
+ function endOfDay(dirtyDate) {
675
+ requiredArgs(1, arguments);
676
+ var date = toDate(dirtyDate);
677
+ date.setHours(23, 59, 59, 999);
678
+ return date;
679
+ }
680
+
681
+ /**
682
+ * @name endOfMonth
683
+ * @category Month Helpers
684
+ * @summary Return the end of a month for the given date.
685
+ *
686
+ * @description
687
+ * Return the end of a month for the given date.
688
+ * The result will be in the local timezone.
689
+ *
690
+ * @param {Date|Number} date - the original date
691
+ * @returns {Date} the end of a month
692
+ * @throws {TypeError} 1 argument required
693
+ *
694
+ * @example
695
+ * // The end of a month for 2 September 2014 11:55:00:
696
+ * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
697
+ * //=> Tue Sep 30 2014 23:59:59.999
698
+ */
699
+ function endOfMonth(dirtyDate) {
700
+ requiredArgs(1, arguments);
701
+ var date = toDate(dirtyDate);
702
+ var month = date.getMonth();
703
+ date.setFullYear(date.getFullYear(), month + 1, 0);
704
+ date.setHours(23, 59, 59, 999);
705
+ return date;
706
+ }
707
+
708
+ /**
709
+ * @name isLastDayOfMonth
710
+ * @category Month Helpers
711
+ * @summary Is the given date the last day of a month?
712
+ *
713
+ * @description
714
+ * Is the given date the last day of a month?
715
+ *
716
+ * @param {Date|Number} date - the date to check
717
+ * @returns {Boolean} the date is the last day of a month
718
+ * @throws {TypeError} 1 argument required
719
+ *
720
+ * @example
721
+ * // Is 28 February 2014 the last day of a month?
722
+ * const result = isLastDayOfMonth(new Date(2014, 1, 28))
723
+ * //=> true
724
+ */
725
+ function isLastDayOfMonth(dirtyDate) {
726
+ requiredArgs(1, arguments);
727
+ var date = toDate(dirtyDate);
728
+ return endOfDay(date).getTime() === endOfMonth(date).getTime();
729
+ }
730
+
731
+ /**
732
+ * @name differenceInMonths
733
+ * @category Month Helpers
734
+ * @summary Get the number of full months between the given dates.
735
+ *
736
+ * @description
737
+ * Get the number of full months between the given dates using trunc as a default rounding method.
738
+ *
739
+ * @param {Date|Number} dateLeft - the later date
740
+ * @param {Date|Number} dateRight - the earlier date
741
+ * @returns {Number} the number of full months
742
+ * @throws {TypeError} 2 arguments required
743
+ *
744
+ * @example
745
+ * // How many full months are between 31 January 2014 and 1 September 2014?
746
+ * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31))
747
+ * //=> 7
748
+ */
749
+ function differenceInMonths(dirtyDateLeft, dirtyDateRight) {
750
+ requiredArgs(2, arguments);
751
+ var dateLeft = toDate(dirtyDateLeft);
752
+ var dateRight = toDate(dirtyDateRight);
753
+ var sign = compareAsc(dateLeft, dateRight);
754
+ var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight));
755
+ var result;
756
+
757
+ // Check for the difference of less than month
758
+ if (difference < 1) {
759
+ result = 0;
760
+ } else {
761
+ if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) {
762
+ // This will check if the date is end of Feb and assign a higher end of month date
763
+ // to compare it with Jan
764
+ dateLeft.setDate(30);
765
+ }
766
+ dateLeft.setMonth(dateLeft.getMonth() - sign * difference);
767
+
768
+ // Math.abs(diff in full months - diff in calendar months) === 1 if last calendar month is not full
769
+ // If so, result must be decreased by 1 in absolute value
770
+ var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign;
771
+
772
+ // Check for cases of one full calendar month
773
+ if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) {
774
+ isLastMonthNotFull = false;
775
+ }
776
+ result = sign * (difference - Number(isLastMonthNotFull));
777
+ }
778
+
779
+ // Prevent negative zero
780
+ return result === 0 ? 0 : result;
781
+ }
782
+
783
+ /**
784
+ * @name differenceInSeconds
785
+ * @category Second Helpers
786
+ * @summary Get the number of seconds between the given dates.
787
+ *
788
+ * @description
789
+ * Get the number of seconds between the given dates.
790
+ *
791
+ * @param {Date|Number} dateLeft - the later date
792
+ * @param {Date|Number} dateRight - the earlier date
793
+ * @param {Object} [options] - an object with options.
794
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
795
+ * @returns {Number} the number of seconds
796
+ * @throws {TypeError} 2 arguments required
797
+ *
798
+ * @example
799
+ * // How many seconds are between
800
+ * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000?
801
+ * const result = differenceInSeconds(
802
+ * new Date(2014, 6, 2, 12, 30, 20, 0),
803
+ * new Date(2014, 6, 2, 12, 30, 7, 999)
804
+ * )
805
+ * //=> 12
806
+ */
807
+ function differenceInSeconds(dateLeft, dateRight, options) {
808
+ requiredArgs(2, arguments);
809
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / 1000;
810
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
811
+ }
812
+
813
+ /**
814
+ * @name differenceInCalendarYears
815
+ * @category Year Helpers
816
+ * @summary Get the number of calendar years between the given dates.
817
+ *
818
+ * @description
819
+ * Get the number of calendar years between the given dates.
820
+ *
821
+ * @param {Date|Number} dateLeft - the later date
822
+ * @param {Date|Number} dateRight - the earlier date
823
+ * @returns {Number} the number of calendar years
824
+ * @throws {TypeError} 2 arguments required
825
+ *
826
+ * @example
827
+ * // How many calendar years are between 31 December 2013 and 11 February 2015?
828
+ * const result = differenceInCalendarYears(
829
+ * new Date(2015, 1, 11),
830
+ * new Date(2013, 11, 31)
831
+ * )
832
+ * //=> 2
833
+ */
834
+ function differenceInCalendarYears(dirtyDateLeft, dirtyDateRight) {
835
+ requiredArgs(2, arguments);
836
+ var dateLeft = toDate(dirtyDateLeft);
837
+ var dateRight = toDate(dirtyDateRight);
838
+ return dateLeft.getFullYear() - dateRight.getFullYear();
839
+ }
840
+
841
+ /**
842
+ * @name differenceInYears
843
+ * @category Year Helpers
844
+ * @summary Get the number of full years between the given dates.
845
+ *
846
+ * @description
847
+ * Get the number of full years between the given dates.
848
+ *
849
+ * @param {Date|Number} dateLeft - the later date
850
+ * @param {Date|Number} dateRight - the earlier date
851
+ * @returns {Number} the number of full years
852
+ * @throws {TypeError} 2 arguments required
853
+ *
854
+ * @example
855
+ * // How many full years are between 31 December 2013 and 11 February 2015?
856
+ * const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31))
857
+ * //=> 1
858
+ */
859
+ function differenceInYears(dirtyDateLeft, dirtyDateRight) {
860
+ requiredArgs(2, arguments);
861
+ var dateLeft = toDate(dirtyDateLeft);
862
+ var dateRight = toDate(dirtyDateRight);
863
+ var sign = compareAsc(dateLeft, dateRight);
864
+ var difference = Math.abs(differenceInCalendarYears(dateLeft, dateRight));
865
+
866
+ // Set both dates to a valid leap year for accurate comparison when dealing
867
+ // with leap days
868
+ dateLeft.setFullYear(1584);
869
+ dateRight.setFullYear(1584);
870
+
871
+ // Math.abs(diff in full years - diff in calendar years) === 1 if last calendar year is not full
872
+ // If so, result must be decreased by 1 in absolute value
873
+ var isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;
874
+ var result = sign * (difference - Number(isLastYearNotFull));
875
+ // Prevent negative zero
876
+ return result === 0 ? 0 : result;
877
+ }
878
+
879
+ /**
880
+ * @name intervalToDuration
881
+ * @category Common Helpers
882
+ * @summary Convert interval to duration
883
+ *
884
+ * @description
885
+ * Convert a interval object to a duration object.
886
+ *
887
+ * @param {Interval} interval - the interval to convert to duration
888
+ *
889
+ * @returns {Duration} The duration Object
890
+ * @throws {TypeError} Requires 2 arguments
891
+ * @throws {RangeError} `start` must not be Invalid Date
892
+ * @throws {RangeError} `end` must not be Invalid Date
893
+ *
894
+ * @example
895
+ * // Get the duration between January 15, 1929 and April 4, 1968.
896
+ * intervalToDuration({
897
+ * start: new Date(1929, 0, 15, 12, 0, 0),
898
+ * end: new Date(1968, 3, 4, 19, 5, 0)
899
+ * })
900
+ * // => { years: 39, months: 2, days: 20, hours: 7, minutes: 5, seconds: 0 }
901
+ */
902
+ function intervalToDuration(interval) {
903
+ requiredArgs(1, arguments);
904
+ var start = toDate(interval.start);
905
+ var end = toDate(interval.end);
906
+ if (isNaN(start.getTime())) throw new RangeError('Start Date is invalid');
907
+ if (isNaN(end.getTime())) throw new RangeError('End Date is invalid');
908
+ var duration = {};
909
+ duration.years = Math.abs(differenceInYears(end, start));
910
+ var sign = compareAsc(end, start);
911
+ var remainingMonths = add(start, {
912
+ years: sign * duration.years
913
+ });
914
+ duration.months = Math.abs(differenceInMonths(end, remainingMonths));
915
+ var remainingDays = add(remainingMonths, {
916
+ months: sign * duration.months
917
+ });
918
+ duration.days = Math.abs(differenceInDays(end, remainingDays));
919
+ var remainingHours = add(remainingDays, {
920
+ days: sign * duration.days
921
+ });
922
+ duration.hours = Math.abs(differenceInHours(end, remainingHours));
923
+ var remainingMinutes = add(remainingHours, {
924
+ hours: sign * duration.hours
925
+ });
926
+ duration.minutes = Math.abs(differenceInMinutes(end, remainingMinutes));
927
+ var remainingSeconds = add(remainingMinutes, {
928
+ minutes: sign * duration.minutes
929
+ });
930
+ duration.seconds = Math.abs(differenceInSeconds(end, remainingSeconds));
931
+ return duration;
932
+ }
933
+
934
+ 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}.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}.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}.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}";
935
+
936
+ const CasinoEngagementSuiteChallengesList = class {
937
+ constructor(hostRef) {
938
+ index.registerInstance(this, hostRef);
939
+ this.close = index.createEvent(this, "close", 7);
940
+ /**
941
+ * Client custom styling via string
942
+ */
943
+ this.clientStyling = '';
944
+ /**
945
+ * Client custom styling via url
946
+ */
947
+ this.clientStylingUrl = '';
948
+ /**
949
+ * Language of the widget
950
+ */
951
+ this.language = 'en';
952
+ /**
953
+ * User's device type
954
+ */
955
+ this.device = 'Mobile';
956
+ /**
957
+ * List of challenges
958
+ */
959
+ this.challenges = [];
960
+ this.tooltip = false;
961
+ this.timers = {};
962
+ this.limitStylingAppends = false;
963
+ this.setClientStyling = () => {
964
+ let sheet = document.createElement('style');
965
+ sheet.innerHTML = this.clientStyling;
966
+ this.host.prepend(sheet);
967
+ };
968
+ this.setClientStylingURL = () => {
969
+ let url = new URL(this.clientStylingUrl);
970
+ let cssFile = document.createElement('style');
971
+ fetch(url.href)
972
+ .then((res) => res.text())
973
+ .then((data) => {
974
+ cssFile.innerHTML = data;
975
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
976
+ })
977
+ .catch((err) => {
978
+ console.log('Error ', err);
979
+ });
980
+ };
981
+ this.handleCloseClick = () => {
982
+ this.close.emit();
983
+ this.tooltip = false;
984
+ };
985
+ this.handleChallengeClick = (ev) => {
986
+ const id = +ev.currentTarget.getAttribute('data-id');
987
+ window.postMessage({ type: `ChallengeClick`, id });
988
+ };
989
+ this.showTooltip = () => {
990
+ this.tooltip = true;
991
+ };
992
+ this.hideTooltip = () => {
993
+ this.tooltip = false;
994
+ };
995
+ }
996
+ challengesPropHandler(value) {
997
+ if (!this.interval && value.length) {
998
+ this.updateTimers();
999
+ this.startCountdown();
1000
+ }
1001
+ if (this.interval && !value.length) {
1002
+ clearInterval(this.interval);
1003
+ }
1004
+ }
1005
+ handleEvent(e) {
1006
+ const newChallenge = e.data.data;
1007
+ if (e.data.type === 'ChallengeGrant') {
1008
+ const index = this.challenges.findIndex(challenge => differenceInSeconds(new Date(challenge.ExpirationTime), new Date(newChallenge.ExpirationTime)) > 0);
1009
+ if (index > -1) {
1010
+ this.challenges.splice(index, 0, newChallenge);
1011
+ }
1012
+ else {
1013
+ this.challenges.unshift(newChallenge);
1014
+ }
1015
+ }
1016
+ }
1017
+ componentWillLoad() {
1018
+ this.challengesPropHandler(this.challenges);
1019
+ }
1020
+ componentDidRender() {
1021
+ if (!this.limitStylingAppends && this.host) {
1022
+ if (this.clientStyling)
1023
+ this.setClientStyling();
1024
+ if (this.clientStylingUrl)
1025
+ this.setClientStylingURL();
1026
+ this.limitStylingAppends = true;
1027
+ }
1028
+ }
1029
+ disconnectedCallback() {
1030
+ this.interval && clearInterval(this.interval);
1031
+ }
1032
+ startCountdown() {
1033
+ this.interval = setInterval(() => {
1034
+ this.updateTimers();
1035
+ }, 1000);
1036
+ }
1037
+ updateTimers() {
1038
+ const now = new Date();
1039
+ this.timers = this.challenges.filter(challenge => challenge.Status !== ChallengeProgressStatus.Expired).reduce((acc, challenge) => {
1040
+ const expirationDate = new Date(challenge.ExpirationTime);
1041
+ const diff = differenceInSeconds(expirationDate, now);
1042
+ const duration = intervalToDuration({
1043
+ start: now,
1044
+ end: expirationDate
1045
+ });
1046
+ let countdown = '00h:00m:00s';
1047
+ if (diff < 1) {
1048
+ this.removeChallenge(challenge.Id);
1049
+ }
1050
+ else {
1051
+ const days = duration.days.toString().padStart(2, '0');
1052
+ const hours = duration.hours.toString().padStart(2, '0');
1053
+ const minutes = duration.minutes.toString().padStart(2, '0');
1054
+ const seconds = duration.seconds.toString().padStart(2, '0');
1055
+ countdown = days === '00'
1056
+ ? `${hours}h:${minutes}m:${seconds}s`
1057
+ : `${days}d:${hours}h:${minutes}m`;
1058
+ }
1059
+ return Object.assign(Object.assign({}, acc), { [challenge.Id]: countdown });
1060
+ }, {});
1061
+ }
1062
+ removeChallenge(id) {
1063
+ const index = this.challenges.findIndex(challenge => challenge.Id === id);
1064
+ if (index > -1) {
1065
+ this.challenges.splice(index, 1);
1066
+ window.postMessage({ type: 'ChallengeHasExpired', id });
1067
+ }
1068
+ }
1069
+ getChallengeClasses(challenge) {
1070
+ return {
1071
+ ChallengeCard: true,
1072
+ InProgress: challenge.Status === ChallengeProgressStatus.InProgress,
1073
+ Completed: this.isChallengeCompleted(challenge),
1074
+ Paused: this.isChallengePaused(challenge)
1075
+ };
1076
+ }
1077
+ isChallengePaused(challenge) {
1078
+ return challenge.Status === ChallengeProgressStatus.Started
1079
+ && challenge.LevelProgresses[0].ProgressPercentage > 0;
1080
+ }
1081
+ isChallengeCompleted(challenge) {
1082
+ return challenge.Status === ChallengeProgressStatus.Completed
1083
+ || (challenge.Status === ChallengeProgressStatus.PendingLevelReward
1084
+ && challenge.LevelProgresses.every(progress => progress.ProgressPercentage === 100));
1085
+ }
1086
+ getChallengeProgress(challenge) {
1087
+ if (challenge.Status === ChallengeProgressStatus.Completed) {
1088
+ return 100;
1089
+ }
1090
+ if (this.isChallengePaused(challenge)
1091
+ || challenge.Status === ChallengeProgressStatus.PendingLevelReward
1092
+ || challenge.Status === ChallengeProgressStatus.InProgress) {
1093
+ const activeLevel = challenge.LevelProgresses
1094
+ .find(level => level.ProgressStatus === ChallengeLevelProgressStatus.InProgress);
1095
+ /**
1096
+ * It is possible that Paused/InProgress challenge
1097
+ * doesn't have InProgress level
1098
+ * because level becomes InProgress after user's bet.
1099
+ * In this case should be displayed progress of the next level (0%)
1100
+ */
1101
+ return activeLevel ? activeLevel.ProgressPercentage : 0;
1102
+ }
1103
+ return -1;
1104
+ }
1105
+ getChallengeHeaderTemplate(challenge) {
1106
+ return index.h("div", { class: "ChallengeCardHeader" }, index.h("div", { class: "ChallengeName" }, challenge.ChallengePresentation.PresentationName), index.h("button", { class: challenge.Status === ChallengeProgressStatus.InProgress ? 'ChallengeJoinButton Joined' : 'ChallengeJoinButton' }, challenge.Status === ChallengeProgressStatus.InProgress
1107
+ ? translate('unjoin', this.language)
1108
+ : translate('join', this.language)));
1109
+ }
1110
+ getChallengeTemplate(challenge) {
1111
+ const challengeProgress = this.getChallengeProgress(challenge);
1112
+ const countdown = this.timers[challenge.Id];
1113
+ const progressTemplate = challengeProgress > -1
1114
+ ? index.h("casino-engagement-suite-progress-bar", { class: this.device, value: challengeProgress, disabled: this.isChallengePaused(challenge) }, index.h("span", { slot: "Title", class: "ChallengeCountdown" }, countdown))
1115
+ : index.h("span", { class: "ChallengeCountdown" }, countdown);
1116
+ return (index.h("div", { class: this.getChallengeClasses(challenge), onClick: this.handleChallengeClick, key: challenge.Id, "data-id": challenge.Id }, this.getChallengeHeaderTemplate(challenge), progressTemplate));
1117
+ }
1118
+ getHeaderTemplate() {
1119
+ return index.h("header", { class: "ChallengesListPopupHeader" }, index.h("button", { onClick: this.showTooltip, class: "ChallengesIconButton" }, index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/help.svg", alt: "Show tooltip" })), index.h("div", { class: "ChallengesListPopupHeaderName" }, translate('challenges', this.language)), index.h("button", { class: "ChallengesIconButton", onClick: this.handleCloseClick }, index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "\u0421lose challenges list" })));
1120
+ }
1121
+ getListTemplate() {
1122
+ if (this.challenges.length) {
1123
+ return index.h("div", { class: "ChallengesListWrapper" }, index.h("div", { class: "ChallengesList" }, this.challenges.map(challenge => this.getChallengeTemplate(challenge))));
1124
+ }
1125
+ else {
1126
+ return index.h("div", { class: "ChallengesListEmpty" }, index.h("h2", null, translate('noChallenges', this.language)), index.h("p", null, translate('tryOtherGames', this.language)));
1127
+ }
1128
+ }
1129
+ getTooltipTemplate() {
1130
+ if (this.tooltip) {
1131
+ return index.h("div", { class: "ChallengesTooltipBackdrop" }, index.h("div", { class: "ChallengesTooltip" }, index.h("button", { class: "ChallengesIconButton", onClick: this.hideTooltip }, index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "\u0421lose tooltip" })), translate('tooltip', this.language)));
1132
+ }
1133
+ else {
1134
+ return '';
1135
+ }
1136
+ }
1137
+ render() {
1138
+ return index.h("div", { class: `ChallengesListPopup ${this.device}` }, this.getHeaderTemplate(), this.getListTemplate(), this.getTooltipTemplate());
1139
+ }
1140
+ get host() { return index.getElement(this); }
1141
+ static get watchers() { return {
1142
+ "challenges": ["challengesPropHandler"]
1143
+ }; }
1144
+ };
1145
+ CasinoEngagementSuiteChallengesList.style = casinoEngagementSuiteChallengesListCss;
1146
+
1147
+ exports.casino_engagement_suite_challenges_list = CasinoEngagementSuiteChallengesList;