@everymatrix/gamification-dropdown 1.40.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 (80) hide show
  1. package/dist/cjs/gamification-dropdown.cjs.js +19 -0
  2. package/dist/cjs/gamification-dropdown_4.cjs.entry.js +751 -0
  3. package/dist/cjs/index-afa95f63.js +1704 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/cjs/player-elevate-card-items-37501652.js +2376 -0
  7. package/dist/cjs/player-elevate-card.cjs.entry.js +85 -0
  8. package/dist/cjs/player-elevate-pointcard.cjs.entry.js +92 -0
  9. package/dist/collection/collection-manifest.json +28 -0
  10. package/dist/collection/components/gamification-dropdown/gamification-dropdown.css +47 -0
  11. package/dist/collection/components/gamification-dropdown/gamification-dropdown.js +259 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/utils/locale.utils.js +48 -0
  14. package/dist/collection/utils/utils.js +3 -0
  15. package/dist/components/gamification-dropdown.d.ts +11 -0
  16. package/dist/components/gamification-dropdown.js +229 -0
  17. package/dist/components/general-styling-wrapper.js +6 -0
  18. package/dist/components/general-styling-wrapper2.js +103 -0
  19. package/dist/components/index.d.ts +26 -0
  20. package/dist/components/index.js +1 -0
  21. package/dist/components/player-elevate-card-data.js +6 -0
  22. package/dist/components/player-elevate-card-data2.js +632 -0
  23. package/dist/components/player-elevate-card-items.js +2149 -0
  24. package/dist/components/player-elevate-card.js +126 -0
  25. package/dist/components/player-elevate-loyaltycard.js +6 -0
  26. package/dist/components/player-elevate-loyaltycard2.js +129 -0
  27. package/dist/components/player-elevate-pointcard.js +135 -0
  28. package/dist/esm/gamification-dropdown.js +17 -0
  29. package/dist/esm/gamification-dropdown_4.entry.js +744 -0
  30. package/dist/esm/index-76ec399c.js +1675 -0
  31. package/dist/esm/index.js +1 -0
  32. package/dist/esm/loader.js +17 -0
  33. package/dist/esm/player-elevate-card-items-5d6e44ca.js +2363 -0
  34. package/dist/esm/player-elevate-card.entry.js +81 -0
  35. package/dist/esm/player-elevate-pointcard.entry.js +88 -0
  36. package/dist/esm/polyfills/core-js.js +11 -0
  37. package/dist/esm/polyfills/css-shim.js +1 -0
  38. package/dist/esm/polyfills/dom.js +79 -0
  39. package/dist/esm/polyfills/es5-html-element.js +1 -0
  40. package/dist/esm/polyfills/index.js +34 -0
  41. package/dist/esm/polyfills/system.js +6 -0
  42. package/dist/gamification-dropdown/gamification-dropdown.esm.js +1 -0
  43. package/dist/gamification-dropdown/index.esm.js +0 -0
  44. package/dist/gamification-dropdown/p-2d5bddc0.js +1 -0
  45. package/dist/gamification-dropdown/p-4eba8e43.entry.js +1 -0
  46. package/dist/gamification-dropdown/p-5e3064ce.js +1 -0
  47. package/dist/gamification-dropdown/p-62327671.entry.js +1 -0
  48. package/dist/gamification-dropdown/p-bbd6d5a3.entry.js +1 -0
  49. package/dist/index.cjs.js +1 -0
  50. package/dist/index.js +1 -0
  51. package/dist/static/button-default.svg +42 -0
  52. package/dist/static/button-disabled.svg +4 -0
  53. package/dist/static/button-hover.svg +4 -0
  54. package/dist/static/button-level.svg +27 -0
  55. package/dist/static/button-pressed.svg +18 -0
  56. package/dist/static/button-redeem.svg +36 -0
  57. package/dist/static/card-ground-over.png +0 -0
  58. package/dist/static/card-ground-over.svg +903 -0
  59. package/dist/static/card-ground.png +0 -0
  60. package/dist/static/card-ground.svg +34 -0
  61. package/dist/static/info.svg +4 -0
  62. package/dist/static/level-badge.png +0 -0
  63. package/dist/static/level-percent.svg +80 -0
  64. package/dist/static/tips-info.svg +21 -0
  65. package/dist/static/user.svg +3 -0
  66. package/dist/stencil.config.js +22 -0
  67. package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/gamification-dropdown/.stencil/packages/gamification-dropdown/stencil.config.d.ts +2 -0
  68. package/dist/types/components/gamification-dropdown/gamification-dropdown.d.ts +41 -0
  69. package/dist/types/components.d.ts +85 -0
  70. package/dist/types/index.d.ts +1 -0
  71. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  72. package/dist/types/utils/locale.utils.d.ts +2 -0
  73. package/dist/types/utils/utils.d.ts +1 -0
  74. package/loader/cdn.js +3 -0
  75. package/loader/index.cjs.js +3 -0
  76. package/loader/index.d.ts +12 -0
  77. package/loader/index.es2017.js +3 -0
  78. package/loader/index.js +4 -0
  79. package/loader/package.json +10 -0
  80. package/package.json +22 -0
@@ -0,0 +1,632 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent } from '@stencil/core/internal/client';
2
+
3
+ function _typeof(o) {
4
+ "@babel/helpers - typeof";
5
+
6
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
7
+ return typeof o;
8
+ } : function (o) {
9
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
10
+ }, _typeof(o);
11
+ }
12
+
13
+ function requiredArgs(required, args) {
14
+ if (args.length < required) {
15
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
16
+ }
17
+ }
18
+
19
+ /**
20
+ * @name toDate
21
+ * @category Common Helpers
22
+ * @summary Convert the given argument to an instance of Date.
23
+ *
24
+ * @description
25
+ * Convert the given argument to an instance of Date.
26
+ *
27
+ * If the argument is an instance of Date, the function returns its clone.
28
+ *
29
+ * If the argument is a number, it is treated as a timestamp.
30
+ *
31
+ * If the argument is none of the above, the function returns Invalid Date.
32
+ *
33
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
34
+ *
35
+ * @param {Date|Number} argument - the value to convert
36
+ * @returns {Date} the parsed date in the local time zone
37
+ * @throws {TypeError} 1 argument required
38
+ *
39
+ * @example
40
+ * // Clone the date:
41
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
42
+ * //=> Tue Feb 11 2014 11:30:30
43
+ *
44
+ * @example
45
+ * // Convert the timestamp to date:
46
+ * const result = toDate(1392098430000)
47
+ * //=> Tue Feb 11 2014 11:30:30
48
+ */
49
+ function toDate(argument) {
50
+ requiredArgs(1, arguments);
51
+ var argStr = Object.prototype.toString.call(argument);
52
+
53
+ // Clone the date
54
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
55
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
56
+ return new Date(argument.getTime());
57
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
58
+ return new Date(argument);
59
+ } else {
60
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
61
+ // eslint-disable-next-line no-console
62
+ 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");
63
+ // eslint-disable-next-line no-console
64
+ console.warn(new Error().stack);
65
+ }
66
+ return new Date(NaN);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
72
+ * They usually appear for dates that denote time before the timezones were introduced
73
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
74
+ * and GMT+01:00:00 after that date)
75
+ *
76
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
77
+ * which would lead to incorrect calculations.
78
+ *
79
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
80
+ */
81
+ function getTimezoneOffsetInMilliseconds(date) {
82
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
83
+ utcDate.setUTCFullYear(date.getFullYear());
84
+ return date.getTime() - utcDate.getTime();
85
+ }
86
+
87
+ /**
88
+ * @name startOfDay
89
+ * @category Day Helpers
90
+ * @summary Return the start of a day for the given date.
91
+ *
92
+ * @description
93
+ * Return the start of a day for the given date.
94
+ * The result will be in the local timezone.
95
+ *
96
+ * @param {Date|Number} date - the original date
97
+ * @returns {Date} the start of a day
98
+ * @throws {TypeError} 1 argument required
99
+ *
100
+ * @example
101
+ * // The start of a day for 2 September 2014 11:55:00:
102
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
103
+ * //=> Tue Sep 02 2014 00:00:00
104
+ */
105
+ function startOfDay(dirtyDate) {
106
+ requiredArgs(1, arguments);
107
+ var date = toDate(dirtyDate);
108
+ date.setHours(0, 0, 0, 0);
109
+ return date;
110
+ }
111
+
112
+ var MILLISECONDS_IN_DAY = 86400000;
113
+
114
+ /**
115
+ * @name differenceInCalendarDays
116
+ * @category Day Helpers
117
+ * @summary Get the number of calendar days between the given dates.
118
+ *
119
+ * @description
120
+ * Get the number of calendar days between the given dates. This means that the times are removed
121
+ * from the dates and then the difference in days is calculated.
122
+ *
123
+ * @param {Date|Number} dateLeft - the later date
124
+ * @param {Date|Number} dateRight - the earlier date
125
+ * @returns {Number} the number of calendar days
126
+ * @throws {TypeError} 2 arguments required
127
+ *
128
+ * @example
129
+ * // How many calendar days are between
130
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
131
+ * const result = differenceInCalendarDays(
132
+ * new Date(2012, 6, 2, 0, 0),
133
+ * new Date(2011, 6, 2, 23, 0)
134
+ * )
135
+ * //=> 366
136
+ * // How many calendar days are between
137
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
138
+ * const result = differenceInCalendarDays(
139
+ * new Date(2011, 6, 3, 0, 1),
140
+ * new Date(2011, 6, 2, 23, 59)
141
+ * )
142
+ * //=> 1
143
+ */
144
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
145
+ requiredArgs(2, arguments);
146
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
147
+ var startOfDayRight = startOfDay(dirtyDateRight);
148
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
149
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
150
+
151
+ // Round the number of days to the nearest integer
152
+ // because the number of milliseconds in a day is not constant
153
+ // (e.g. it's different in the day of the daylight saving time clock shift)
154
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
155
+ }
156
+
157
+ /**
158
+ * Days in 1 week.
159
+ *
160
+ * @name daysInWeek
161
+ * @constant
162
+ * @type {number}
163
+ * @default
164
+ */
165
+
166
+ /**
167
+ * Milliseconds in 1 hour
168
+ *
169
+ * @name millisecondsInHour
170
+ * @constant
171
+ * @type {number}
172
+ * @default
173
+ */
174
+ var millisecondsInHour = 3600000;
175
+
176
+ /**
177
+ * @name differenceInMilliseconds
178
+ * @category Millisecond Helpers
179
+ * @summary Get the number of milliseconds between the given dates.
180
+ *
181
+ * @description
182
+ * Get the number of milliseconds between the given dates.
183
+ *
184
+ * @param {Date|Number} dateLeft - the later date
185
+ * @param {Date|Number} dateRight - the earlier date
186
+ * @returns {Number} the number of milliseconds
187
+ * @throws {TypeError} 2 arguments required
188
+ *
189
+ * @example
190
+ * // How many milliseconds are between
191
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
192
+ * const result = differenceInMilliseconds(
193
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
194
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
195
+ * )
196
+ * //=> 1100
197
+ */
198
+ function differenceInMilliseconds(dateLeft, dateRight) {
199
+ requiredArgs(2, arguments);
200
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
201
+ }
202
+
203
+ var roundingMap = {
204
+ ceil: Math.ceil,
205
+ round: Math.round,
206
+ floor: Math.floor,
207
+ trunc: function trunc(value) {
208
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
209
+ } // Math.trunc is not supported by IE
210
+ };
211
+
212
+ var defaultRoundingMethod = 'trunc';
213
+ function getRoundingMethod(method) {
214
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
215
+ }
216
+
217
+ /**
218
+ * @name differenceInHours
219
+ * @category Hour Helpers
220
+ * @summary Get the number of hours between the given dates.
221
+ *
222
+ * @description
223
+ * Get the number of hours between the given dates.
224
+ *
225
+ * @param {Date|Number} dateLeft - the later date
226
+ * @param {Date|Number} dateRight - the earlier date
227
+ * @param {Object} [options] - an object with options.
228
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
229
+ * @returns {Number} the number of hours
230
+ * @throws {TypeError} 2 arguments required
231
+ *
232
+ * @example
233
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
234
+ * const result = differenceInHours(
235
+ * new Date(2014, 6, 2, 19, 0),
236
+ * new Date(2014, 6, 2, 6, 50)
237
+ * )
238
+ * //=> 12
239
+ */
240
+ function differenceInHours(dateLeft, dateRight, options) {
241
+ requiredArgs(2, arguments);
242
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
243
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
244
+ }
245
+
246
+ /**
247
+ * @name isBefore
248
+ * @category Common Helpers
249
+ * @summary Is the first date before the second one?
250
+ *
251
+ * @description
252
+ * Is the first date before the second one?
253
+ *
254
+ * @param {Date|Number} date - the date that should be before the other one to return true
255
+ * @param {Date|Number} dateToCompare - the date to compare with
256
+ * @returns {Boolean} the first date is before the second date
257
+ * @throws {TypeError} 2 arguments required
258
+ *
259
+ * @example
260
+ * // Is 10 July 1989 before 11 February 1987?
261
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
262
+ * //=> false
263
+ */
264
+ function isBefore(dirtyDate, dirtyDateToCompare) {
265
+ requiredArgs(2, arguments);
266
+ var date = toDate(dirtyDate);
267
+ var dateToCompare = toDate(dirtyDateToCompare);
268
+ return date.getTime() < dateToCompare.getTime();
269
+ }
270
+
271
+ const DEFAULT_LANGUAGE = 'en';
272
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
273
+ const TRANSLATIONS = {
274
+ en: {
275
+ redeem: 'Redeem',
276
+ expireOn: 'Expire on ',
277
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
278
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
279
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
280
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
281
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
282
+ spendablePoints: 'Spendable Points:',
283
+ details: 'Details',
284
+ earningRules: 'Earning Rules',
285
+ xp: 'XP',
286
+ sp: 'Coins',
287
+ termAndConditions: 'Term & Conditions',
288
+ },
289
+ 'zh-hk': {
290
+ redeem: '兑奖',
291
+ expireOn: 'Expire on ',
292
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
293
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
294
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
295
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
296
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
297
+ spendablePoints: 'Spendable Points:',
298
+ details: '明细',
299
+ earningRules: 'Earning Rules',
300
+ xp: 'XP',
301
+ sp: 'Coins',
302
+ termAndConditions: 'Term & Conditions',
303
+ },
304
+ de: {
305
+ redeem: 'Redeem',
306
+ expireOn: 'Expire on ',
307
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
308
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
309
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
310
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
311
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
312
+ spendablePoints: 'Spendable Points:',
313
+ details: 'Details',
314
+ earningRules: 'Earning Rules',
315
+ xp: 'XP',
316
+ sp: 'Coins',
317
+ termAndConditions: 'Term & Conditions',
318
+ },
319
+ it: {
320
+ redeem: 'Redeem',
321
+ expireOn: 'Expire on ',
322
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
323
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
324
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
325
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
326
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
327
+ spendablePoints: 'Spendable Points:',
328
+ details: 'Details',
329
+ earningRules: 'Earning Rules',
330
+ xp: 'XP',
331
+ sp: 'Coins',
332
+ termAndConditions: 'Term & Conditions',
333
+ },
334
+ fr: {
335
+ redeem: 'Redeem',
336
+ expireOn: 'Expire on ',
337
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
338
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
339
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
340
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
341
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
342
+ spendablePoints: 'Spendable Points:',
343
+ details: 'Details',
344
+ earningRules: 'Earning Rules',
345
+ xp: 'XP',
346
+ sp: 'Coins',
347
+ termAndConditions: 'Term & Conditions',
348
+ },
349
+ es: {
350
+ redeem: 'Redeem'
351
+ },
352
+ tr: {
353
+ redeem: 'Redeem'
354
+ },
355
+ ru: {
356
+ redeem: 'Redeem'
357
+ },
358
+ ro: {
359
+ redeem: 'Redeem'
360
+ },
361
+ hr: {
362
+ redeem: 'Otkupiti',
363
+ expireOn: 'Istječe',
364
+ pointsToBeExpired: '${expirationPoints} bodova ističe za ${expireDay} dana',
365
+ tipsForNextLevel: 'Trebate ${pointsToReach} da dosegnete razinu ${levelName}',
366
+ spendablePoints: 'Bodovi za potrošit:',
367
+ details: 'Detalji',
368
+ xp: 'XP',
369
+ },
370
+ hu: {
371
+ redeem: 'Redeem'
372
+ },
373
+ pl: {
374
+ redeem: 'Redeem'
375
+ },
376
+ pt: {
377
+ redeem: 'Redeem'
378
+ },
379
+ sl: {
380
+ redeem: 'Redeem'
381
+ },
382
+ sr: {
383
+ redeem: 'Redeem'
384
+ }
385
+ };
386
+ const translate = (key, customLang) => {
387
+ const lang = customLang;
388
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
389
+ };
390
+ const translateWithParams = (key, params) => {
391
+ const lang = params['lang'];
392
+ let templateString = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
393
+ if (!params) {
394
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
395
+ }
396
+ Object.keys(params).forEach((paramName) => {
397
+ templateString = templateString.replace(new RegExp('\\$\{' + paramName + '\}', 'gm'), params[paramName]);
398
+ });
399
+ return templateString;
400
+ };
401
+
402
+ function updateProgressSvg(progressElementRef, percent) {
403
+ const svgElement = progressElementRef.querySelector('#total_level');
404
+ const endLockWidth = 17, pointR = 6.5;
405
+ //Total Widget of the progress
406
+ const barWidth = svgElement.getBBox().width;
407
+ //The filled width according to current progress
408
+ const levelPercent = percent > 1 ? 1 : percent;
409
+ const widthOnBar = (levelPercent * barWidth - endLockWidth) < 0 ? 0 : levelPercent * barWidth - endLockWidth;
410
+ //update bar's width, widthOnBar
411
+ const levelBar = progressElementRef.querySelector('#current_level');
412
+ //update filters, x = widthOnBar
413
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
414
+ //update circle, widthOnBar+10
415
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
416
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
417
+ levelBar.setAttribute('width', `${widthOnBar}`);
418
+ levelCircle.setAttribute('cx', `${(widthOnBar < pointR ? pointR : widthOnBar)}`);
419
+ levelFilter.setAttribute('x', `${widthOnBar - 8}`);
420
+ //update lock location
421
+ const endLockElement = progressElementRef.querySelector('#lock');
422
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
423
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
424
+ // ball in endlockfilter2_i_305_23
425
+ const filter2 = progressElementRef.querySelector('#filter_ball');
426
+ // heart in endlockfilter3_d_305_23
427
+ const filter3 = progressElementRef.querySelector('#filter_heart');
428
+ //wrapper of lockfilter4_d_305_23
429
+ const filterLock = progressElementRef.querySelector('#filter_lock');
430
+ // shadow of ball paint0_linear_305_23
431
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
432
+ //paint in lockpaint1_linear_305_23
433
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
434
+ // box of lock and heart, for move position dynamically
435
+ const lockBox = progressElementRef.querySelector('#lock_box');
436
+ const heartBox = progressElementRef.querySelector('#heart_box');
437
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
438
+ //set cx of lockElement
439
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
440
+ //set cx of sub Elements
441
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
442
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
443
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
444
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
445
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
446
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
447
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
448
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
449
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
450
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
451
+ svgElement.parentElement.style.opacity = '1';
452
+ }
453
+
454
+ const playerElevateCardDataCss = ":host {\n display: block;\n width: 360px;\n height: 230px;\n}\n\n.ElevateCardWrapper {\n contain: layout inline-size;\n width: 100%;\n height: fit-content;\n min-height: 218px;\n}\n\n.Outer {\n container-type: inline-size;\n font-size: 12px;\n background-size: cover;\n background-repeat: no-repeat;\n line-height: initial;\n width: 100%;\n height: 100%;\n}\n\n.Dark {\n color: var(--emfe-w-color-gray150, #efefef);\n}\n\n.Light {\n color: var(--emfe-w-color-black, #0e0e0e);\n}\n\n@container (min-width: 381px) {\n .Outer {\n background-size: cover;\n }\n .Outer .OuterCover {\n min-height: 190px;\n }\n}\n@container (min-width: 260px) {\n .Outer {\n background-size: contain;\n }\n}\n.OuterCover {\n width: 100%;\n height: 100%;\n content: \"\";\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 15px;\n}\n\n.Inner {\n display: flex;\n flex-direction: column;\n min-height: 158px;\n}\n.Inner .Content {\n padding: 15px;\n flex-wrap: wrap;\n gap: 8px;\n}\n.Inner .Row {\n display: flex;\n flex-direction: row;\n}\n.Inner .CardCell {\n display: flex;\n}\n.Inner .LevelProgress svg {\n transition: opacity 0.4s;\n}\n.Inner .LevelInfo {\n display: flex;\n flex-direction: column;\n}\n.Inner .LevelInfo .ElevateLevel .LevelName {\n height: 28px;\n border-radius: 5px;\n line-height: 28px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.Inner .LevelInfo.Level0 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level0button-shadow, rgba(191, 84, 6, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level0-bg0, #E2792C) 0%, var(--emfe-w-elevate-color-level0-bg1, rgba(242, 151, 99, 0)) 100%);\n}\n.Inner .LevelInfo.Level1 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level1button-shadow, rgba(151, 151, 151, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level1-bg0, #BEBFED) 0%, var(--emfe-w-elevate-color-level1-bg1, rgba(216, 217, 233, 0)) 100%);\n}\n.Inner .LevelInfo.Level2 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level2button-shadow, rgba(191, 120, 6, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level2-bg0, #FCC410) 0%, var(--emfe-w-elevate-color-level2-bg1, rgba(255, 189, 43, 0)) 100%);\n}\n.Inner .LevelInfo.Level3 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level3button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level3-bg0, #B1A2DB) 0%, var(--emfe-w-elevate-color-level3-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo.Level4 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level4button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level4-bg0, #B1A2DB) 0%, var(--emfe-w-elevate-color-level4-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo .ElevateLevel {\n display: flex;\n}\n.Inner .LevelInfo {\n flex: 1;\n flex-grow: 1;\n min-width: 150px;\n}\n.Inner .PlayerImg {\n width: 29%;\n margin: auto;\n max-width: 100px;\n min-width: 30px;\n order: 0;\n}\n.Inner .PlayerAvatar {\n max-width: 100px;\n flex-basis: 100px;\n height: auto;\n margin: auto;\n padding-top: 10px;\n}\n.Inner .PlayerAvatar .Avatar, .Inner .PlayerAvatar .Badge {\n width: 100%;\n height: 100%;\n}\n.Inner .PlayerAvatar .Avatar {\n border-radius: 50%;\n background-size: contain;\n background-repeat: no-repeat;\n}\n.Inner .ElevateLevel .ExpirationDate {\n max-width: 138px;\n min-width: 118px;\n}\n.Inner .PlayerName, .Inner .RedeemButton, .Inner .ElevateLevel {\n text-transform: capitalize;\n width: 100%;\n}\n.Inner .PlayerName {\n font-size: 16px;\n}\n.Inner .Row .PointsInfo {\n display: table;\n font-weight: 600;\n}\n.Inner .Row .Redeem {\n justify-content: flex-end;\n margin-left: auto;\n}\n.Inner .Row .Redeem:hover {\n color: var(--emfe-w-elevate-color-redeem-hover, #00ABA4);\n cursor: pointer;\n}\n.Inner .Row .RedeemButton:hover span {\n color: var(emfe-w-elevate-color-redeem-text-hover, #f1f1f1);\n font-weight: bold;\n}\n.Inner .Row .RedeemButton {\n width: 95px;\n height: 35px;\n display: flex;\n align-items: center;\n border-radius: 10px;\n background: var(--emfe-w-elevate-color-redeem-bg, linear-gradient(0deg, #26CC37, #26CC37)), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%);\n box-shadow: 0px 4px 4px 0px #00000040;\n}\n.Inner .Row .RedeemButton span {\n color: var(--emfe-w-color-white, #fff);\n line-height: 18px;\n font-size: 15px;\n text-align: center;\n width: 100%;\n}\n.Inner .Row .Points {\n font-size: large;\n vertical-align: middle;\n}\n.Inner .Row .Points .XP {\n font-size: x-small;\n}\n.Inner .Row .ExpirationPoints {\n font-size: small;\n text-align: right;\n font-weight: bold;\n color: var(--emfe-w-color-red, #9e595f);\n}";
455
+
456
+ const PlayerElevateCardData = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
457
+ constructor() {
458
+ super();
459
+ this.__registerHost();
460
+ this.playerElevateLeveLoaded = createEvent(this, "playerElevateLeveLoaded", 7);
461
+ }
462
+ handleWindowResizs() {
463
+ this.initLevelProgressbar();
464
+ }
465
+ onParamsChanged() {
466
+ this.loadElevateInfo();
467
+ }
468
+ onRedeemClick() {
469
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
470
+ }
471
+ loadLevels() {
472
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
473
+ return new Promise((resolve, reject) => {
474
+ return fetch(url.href, {
475
+ method: 'GET',
476
+ })
477
+ .then((res) => res.json())
478
+ .then((res) => {
479
+ this.levels = res.data;
480
+ resolve(true);
481
+ })
482
+ .catch((err) => {
483
+ reject(err);
484
+ });
485
+ });
486
+ }
487
+ calcuatePointsToBeExpired(walletTotalInfo) {
488
+ let pointExpireInfoAsString = '';
489
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
490
+ walletTotalInfo.aboutToExpire.length == 0 ||
491
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
492
+ return pointExpireInfoAsString;
493
+ }
494
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
495
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
496
+ ? -1
497
+ : 1;
498
+ });
499
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
500
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
501
+ let hoursToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
502
+ if (daysToExpried == 0) {
503
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date());
504
+ expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
505
+ }
506
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
507
+ expirationPoints: aboutToExpire.points,
508
+ expireDay: daysToExpried,
509
+ });
510
+ return pointExpireInfoAsString;
511
+ }
512
+ loadPlayerLevelInfo() {
513
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
514
+ return new Promise((resolve, reject) => {
515
+ return fetch(url.href, {
516
+ method: 'GET',
517
+ headers: {
518
+ 'X-Sessionid': this.params.session,
519
+ 'Content-Type': 'application/json',
520
+ },
521
+ })
522
+ .then((res) => res.json())
523
+ .then((res) => {
524
+ var _a, _b, _c;
525
+ if (!res.success) {
526
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
527
+ reject(true);
528
+ return;
529
+ }
530
+ let playerElevateInfo = res.data;
531
+ this.playerElevateLevel = playerElevateInfo.level;
532
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
533
+ this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
534
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
535
+ const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
536
+ const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
537
+ this.playerElevateLeveLoaded.emit({
538
+ elevateLevelWalletTotal: spendableTotal,
539
+ loyaltyWalletTotal
540
+ });
541
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
542
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
543
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
544
+ this.playerElevateLeveLoaded.emit({
545
+ pointExpireString: spExpireInfoAsString,
546
+ xpExpireString: xpExpireInfoAsString
547
+ });
548
+ }
549
+ resolve(this.playerElevateLevel);
550
+ })
551
+ .catch((err) => {
552
+ console.log('error ', err);
553
+ reject(true);
554
+ });
555
+ });
556
+ }
557
+ setLoyaltyProgress(percent) {
558
+ updateProgressSvg(this.loyaltyProgressEle, percent);
559
+ }
560
+ initLevelProgressbar() {
561
+ setTimeout(() => {
562
+ this.loyaltyProgressEle =
563
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
564
+ if (!this.loyaltyProgressEle) {
565
+ return;
566
+ }
567
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
568
+ ? 1 : (this.playerElevateLevel.loyaltyPoints / this.playerElevateLevel.nextLevel.entryPoints));
569
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
570
+ }, 80);
571
+ }
572
+ componentDidRender() {
573
+ this.initLevelProgressbar();
574
+ }
575
+ loadElevateInfo() {
576
+ if (!this.params.endpoint || !this.params.session) {
577
+ return;
578
+ }
579
+ const promises = [];
580
+ promises.push(this.loadPlayerLevelInfo());
581
+ if (this.params.calculateLevelFlag) {
582
+ promises.push(this.loadLevels());
583
+ }
584
+ Promise.all(promises).then((res) => {
585
+ console.log('elevate-init', res);
586
+ this.initLevelProgressbar();
587
+ if (!this.levels) {
588
+ return;
589
+ }
590
+ this.levels.sort((level1, level2) => {
591
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
592
+ });
593
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
594
+ let playerLevelNumber = 0;
595
+ this.levels.forEach((elevateLevel, idx) => {
596
+ if (playerPoints > elevateLevel.firstEntryPoints) {
597
+ playerLevelNumber = idx;
598
+ }
599
+ });
600
+ this.playerElevateLeveLoaded.emit({
601
+ calculatedLevelFlag: playerLevelNumber,
602
+ });
603
+ });
604
+ }
605
+ componentWillLoad() {
606
+ this.loadElevateInfo();
607
+ }
608
+ get elevateCardRef() { return this; }
609
+ static get watchers() { return {
610
+ "params": ["onParamsChanged"]
611
+ }; }
612
+ static get style() { return playerElevateCardDataCss; }
613
+ }, [0, "player-elevate-card-data", {
614
+ "params": [8],
615
+ "playerElevateLevel": [32],
616
+ "pointExpireString": [32]
617
+ }, [[9, "resize", "handleWindowResizs"]]]);
618
+ function defineCustomElement() {
619
+ if (typeof customElements === "undefined") {
620
+ return;
621
+ }
622
+ const components = ["player-elevate-card-data"];
623
+ components.forEach(tagName => { switch (tagName) {
624
+ case "player-elevate-card-data":
625
+ if (!customElements.get(tagName)) {
626
+ customElements.define(tagName, PlayerElevateCardData);
627
+ }
628
+ break;
629
+ } });
630
+ }
631
+
632
+ export { PlayerElevateCardData as P, TRANSLATIONS as T, _typeof as _, toDate as a, translate as b, defineCustomElement as d, getTimezoneOffsetInMilliseconds as g, requiredArgs as r, translateWithParams as t };