@everymatrix/gamification-dropdown 0.1.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 (71) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/gamification-dropdown-b0044320.js +173 -0
  3. package/dist/cjs/gamification-dropdown.cjs.js +25 -0
  4. package/dist/cjs/gamification-dropdown_4.cjs.entry.js +559 -0
  5. package/dist/cjs/index-1c31b1d6.js +1675 -0
  6. package/dist/cjs/index.cjs.js +10 -0
  7. package/dist/cjs/loader.cjs.js +15 -0
  8. package/dist/cjs/player-elevate-card-items-77750a62.js +2364 -0
  9. package/dist/cjs/player-elevate-card.cjs.entry.js +74 -0
  10. package/dist/cjs/player-elevate-pointcard.cjs.entry.js +76 -0
  11. package/dist/collection/collection-manifest.json +28 -0
  12. package/dist/collection/components/gamification-dropdown/gamification-dropdown.css +57 -0
  13. package/dist/collection/components/gamification-dropdown/gamification-dropdown.js +256 -0
  14. package/dist/collection/components/gamification-dropdown/index.js +1 -0
  15. package/dist/collection/index.js +1 -0
  16. package/dist/collection/utils/locale.utils.js +42 -0
  17. package/dist/collection/utils/utils.js +3 -0
  18. package/dist/esm/app-globals-0f993ce5.js +3 -0
  19. package/dist/esm/gamification-dropdown-498ae904.js +171 -0
  20. package/dist/esm/gamification-dropdown.js +20 -0
  21. package/dist/esm/gamification-dropdown_4.entry.js +552 -0
  22. package/dist/esm/index-0ad2daf0.js +1645 -0
  23. package/dist/esm/index.js +2 -0
  24. package/dist/esm/loader.js +11 -0
  25. package/dist/esm/player-elevate-card-items-50dbfe39.js +2351 -0
  26. package/dist/esm/player-elevate-card.entry.js +70 -0
  27. package/dist/esm/player-elevate-pointcard.entry.js +72 -0
  28. package/dist/gamification-dropdown/gamification-dropdown.esm.js +1 -0
  29. package/dist/gamification-dropdown/index.esm.js +1 -0
  30. package/dist/gamification-dropdown/p-09730cb4.entry.js +1 -0
  31. package/dist/gamification-dropdown/p-58a784a0.js +1 -0
  32. package/dist/gamification-dropdown/p-72844c24.js +1 -0
  33. package/dist/gamification-dropdown/p-95a21693.js +2 -0
  34. package/dist/gamification-dropdown/p-be2f5b0a.entry.js +1 -0
  35. package/dist/gamification-dropdown/p-d1603dd0.entry.js +1 -0
  36. package/dist/gamification-dropdown/p-e1255160.js +1 -0
  37. package/dist/index.cjs.js +1 -0
  38. package/dist/index.js +1 -0
  39. package/dist/static/button-default.svg +42 -0
  40. package/dist/static/button-disabled.svg +4 -0
  41. package/dist/static/button-hover.svg +4 -0
  42. package/dist/static/button-level.svg +27 -0
  43. package/dist/static/button-pressed.svg +18 -0
  44. package/dist/static/button-redeem.svg +36 -0
  45. package/dist/static/card-ground-over.png +0 -0
  46. package/dist/static/card-ground-over.svg +903 -0
  47. package/dist/static/card-ground.png +0 -0
  48. package/dist/static/card-ground.svg +34 -0
  49. package/dist/static/info.svg +4 -0
  50. package/dist/static/level-badge.png +0 -0
  51. package/dist/static/level-percent.svg +80 -0
  52. package/dist/static/tips-info.svg +21 -0
  53. package/dist/static/user.svg +3 -0
  54. package/dist/stencil.config.dev.js +15 -0
  55. package/dist/stencil.config.js +17 -0
  56. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/gamification-dropdown/.stencil/packages/stencil/gamification-dropdown/stencil.config.d.ts +2 -0
  57. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/gamification-dropdown/.stencil/packages/stencil/gamification-dropdown/stencil.config.dev.d.ts +2 -0
  58. package/dist/types/components/gamification-dropdown/gamification-dropdown.d.ts +43 -0
  59. package/dist/types/components/gamification-dropdown/index.d.ts +1 -0
  60. package/dist/types/components.d.ts +85 -0
  61. package/dist/types/index.d.ts +1 -0
  62. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  63. package/dist/types/utils/locale.utils.d.ts +2 -0
  64. package/dist/types/utils/utils.d.ts +1 -0
  65. package/loader/cdn.js +1 -0
  66. package/loader/index.cjs.js +1 -0
  67. package/loader/index.d.ts +24 -0
  68. package/loader/index.es2017.js +1 -0
  69. package/loader/index.js +2 -0
  70. package/loader/package.json +11 -0
  71. package/package.json +29 -0
@@ -0,0 +1,552 @@
1
+ export { G as gamification_dropdown } from './gamification-dropdown-498ae904.js';
2
+ import { r as registerInstance, h, g as getElement, c as createEvent, a as getAssetPath, F as Fragment } from './index-0ad2daf0.js';
3
+ import { r as requiredArgs, t as toDate, g as getTimezoneOffsetInMilliseconds, a as translateWithParams, T as TRANSLATIONS, P as PlayerAvatar, b as PlayerElevateLoyaltyLevel, c as PlayerPoints, d as PlayerLoyaltyProcess } from './player-elevate-card-items-50dbfe39.js';
4
+
5
+ const mergeTranslations = (url, target) => {
6
+ return new Promise((resolve) => {
7
+ fetch(url)
8
+ .then((res) => res.json())
9
+ .then((data) => {
10
+ Object.keys(data).forEach((item) => {
11
+ target[item] = target[item] ? target[item] : {};
12
+ for (let key in data[item]) {
13
+ target[item][key] = data[item][key];
14
+ }
15
+ });
16
+ resolve(true);
17
+ });
18
+ });
19
+ };
20
+
21
+ const generalStylingWrapperCss = ":host{display:block}";
22
+ const GeneralStylingWrapperStyle0 = generalStylingWrapperCss;
23
+
24
+ const GeneralStylingWrapper = class {
25
+ constructor(hostRef) {
26
+ registerInstance(this, hostRef);
27
+ this.stylingAppends = false;
28
+ this.setClientStyling = () => {
29
+ let sheet = document.createElement('style');
30
+ sheet.innerHTML = this.clientStyling;
31
+ this.el.prepend(sheet);
32
+ };
33
+ this.setClientStylingURL = () => {
34
+ let url = new URL(this.clientStylingUrl);
35
+ let cssFile = document.createElement('style');
36
+ fetch(url.href)
37
+ .then((res) => res.text())
38
+ .then((data) => {
39
+ cssFile.innerHTML = data;
40
+ setTimeout(() => {
41
+ this.el.prepend(cssFile);
42
+ }, 1);
43
+ })
44
+ .catch((err) => {
45
+ console.log('error ', err);
46
+ });
47
+ };
48
+ this.clientStyling = '';
49
+ this.clientStylingUrl = '';
50
+ this.translationUrl = '';
51
+ this.targetTranslations = undefined;
52
+ }
53
+ componentDidRender() {
54
+ // start custom styling area
55
+ if (!this.stylingAppends) {
56
+ if (this.clientStyling)
57
+ this.setClientStyling();
58
+ if (this.clientStylingUrl)
59
+ this.setClientStylingURL();
60
+ this.stylingAppends = true;
61
+ }
62
+ // end custom styling area
63
+ }
64
+ async componentWillLoad() {
65
+ const promises = [];
66
+ if (this.translationUrl) {
67
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
68
+ promises.push(translationPromise);
69
+ }
70
+ return await Promise.all(promises);
71
+ }
72
+ render() {
73
+ return (h("div", { key: '4d3414408c7662f88331dbe655966237f74d6958', class: "StyleShell" }, h("slot", { key: '1d004644d84602c4314bdf5dfc26b55b160f57df', name: "mainContent" })));
74
+ }
75
+ get el() { return getElement(this); }
76
+ };
77
+ GeneralStylingWrapper.style = GeneralStylingWrapperStyle0;
78
+
79
+ /**
80
+ * @name startOfDay
81
+ * @category Day Helpers
82
+ * @summary Return the start of a day for the given date.
83
+ *
84
+ * @description
85
+ * Return the start of a day for the given date.
86
+ * The result will be in the local timezone.
87
+ *
88
+ * @param {Date|Number} date - the original date
89
+ * @returns {Date} the start of a day
90
+ * @throws {TypeError} 1 argument required
91
+ *
92
+ * @example
93
+ * // The start of a day for 2 September 2014 11:55:00:
94
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
95
+ * //=> Tue Sep 02 2014 00:00:00
96
+ */
97
+ function startOfDay(dirtyDate) {
98
+ requiredArgs(1, arguments);
99
+ var date = toDate(dirtyDate);
100
+ date.setHours(0, 0, 0, 0);
101
+ return date;
102
+ }
103
+
104
+ var MILLISECONDS_IN_DAY = 86400000;
105
+
106
+ /**
107
+ * @name differenceInCalendarDays
108
+ * @category Day Helpers
109
+ * @summary Get the number of calendar days between the given dates.
110
+ *
111
+ * @description
112
+ * Get the number of calendar days between the given dates. This means that the times are removed
113
+ * from the dates and then the difference in days is calculated.
114
+ *
115
+ * @param {Date|Number} dateLeft - the later date
116
+ * @param {Date|Number} dateRight - the earlier date
117
+ * @returns {Number} the number of calendar days
118
+ * @throws {TypeError} 2 arguments required
119
+ *
120
+ * @example
121
+ * // How many calendar days are between
122
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
123
+ * const result = differenceInCalendarDays(
124
+ * new Date(2012, 6, 2, 0, 0),
125
+ * new Date(2011, 6, 2, 23, 0)
126
+ * )
127
+ * //=> 366
128
+ * // How many calendar days are between
129
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
130
+ * const result = differenceInCalendarDays(
131
+ * new Date(2011, 6, 3, 0, 1),
132
+ * new Date(2011, 6, 2, 23, 59)
133
+ * )
134
+ * //=> 1
135
+ */
136
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
137
+ requiredArgs(2, arguments);
138
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
139
+ var startOfDayRight = startOfDay(dirtyDateRight);
140
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
141
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
142
+
143
+ // Round the number of days to the nearest integer
144
+ // because the number of milliseconds in a day is not constant
145
+ // (e.g. it's different in the day of the daylight saving time clock shift)
146
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
147
+ }
148
+
149
+ /**
150
+ * Days in 1 week.
151
+ *
152
+ * @name daysInWeek
153
+ * @constant
154
+ * @type {number}
155
+ * @default
156
+ */
157
+
158
+ /**
159
+ * Milliseconds in 1 hour
160
+ *
161
+ * @name millisecondsInHour
162
+ * @constant
163
+ * @type {number}
164
+ * @default
165
+ */
166
+ var millisecondsInHour = 3600000;
167
+
168
+ /**
169
+ * @name differenceInMilliseconds
170
+ * @category Millisecond Helpers
171
+ * @summary Get the number of milliseconds between the given dates.
172
+ *
173
+ * @description
174
+ * Get the number of milliseconds between the given dates.
175
+ *
176
+ * @param {Date|Number} dateLeft - the later date
177
+ * @param {Date|Number} dateRight - the earlier date
178
+ * @returns {Number} the number of milliseconds
179
+ * @throws {TypeError} 2 arguments required
180
+ *
181
+ * @example
182
+ * // How many milliseconds are between
183
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
184
+ * const result = differenceInMilliseconds(
185
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
186
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
187
+ * )
188
+ * //=> 1100
189
+ */
190
+ function differenceInMilliseconds(dateLeft, dateRight) {
191
+ requiredArgs(2, arguments);
192
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
193
+ }
194
+
195
+ var roundingMap = {
196
+ ceil: Math.ceil,
197
+ round: Math.round,
198
+ floor: Math.floor,
199
+ trunc: function trunc(value) {
200
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
201
+ } // Math.trunc is not supported by IE
202
+ };
203
+
204
+ var defaultRoundingMethod = 'trunc';
205
+ function getRoundingMethod(method) {
206
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
207
+ }
208
+
209
+ /**
210
+ * @name differenceInHours
211
+ * @category Hour Helpers
212
+ * @summary Get the number of hours between the given dates.
213
+ *
214
+ * @description
215
+ * Get the number of hours between the given dates.
216
+ *
217
+ * @param {Date|Number} dateLeft - the later date
218
+ * @param {Date|Number} dateRight - the earlier date
219
+ * @param {Object} [options] - an object with options.
220
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
221
+ * @returns {Number} the number of hours
222
+ * @throws {TypeError} 2 arguments required
223
+ *
224
+ * @example
225
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
226
+ * const result = differenceInHours(
227
+ * new Date(2014, 6, 2, 19, 0),
228
+ * new Date(2014, 6, 2, 6, 50)
229
+ * )
230
+ * //=> 12
231
+ */
232
+ function differenceInHours(dateLeft, dateRight, options) {
233
+ requiredArgs(2, arguments);
234
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
235
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
236
+ }
237
+
238
+ /**
239
+ * @name isBefore
240
+ * @category Common Helpers
241
+ * @summary Is the first date before the second one?
242
+ *
243
+ * @description
244
+ * Is the first date before the second one?
245
+ *
246
+ * @param {Date|Number} date - the date that should be before the other one to return true
247
+ * @param {Date|Number} dateToCompare - the date to compare with
248
+ * @returns {Boolean} the first date is before the second date
249
+ * @throws {TypeError} 2 arguments required
250
+ *
251
+ * @example
252
+ * // Is 10 July 1989 before 11 February 1987?
253
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
254
+ * //=> false
255
+ */
256
+ function isBefore(dirtyDate, dirtyDateToCompare) {
257
+ requiredArgs(2, arguments);
258
+ var date = toDate(dirtyDate);
259
+ var dateToCompare = toDate(dirtyDateToCompare);
260
+ return date.getTime() < dateToCompare.getTime();
261
+ }
262
+
263
+ function updateProgressSvg(progressElementRef, percent) {
264
+ const svgElement = progressElementRef.querySelector('#total_level');
265
+ const endLockWidth = 17, pointR = 6.5;
266
+ //Total Widget of the progress
267
+ const barWidth = svgElement.getBBox().width;
268
+ //The filled width according to current progress
269
+ const levelPercent = percent > 1 ? 1 : percent;
270
+ const widthOnBar = (levelPercent * barWidth - endLockWidth) < 0 ? 0 : levelPercent * barWidth - endLockWidth;
271
+ //update bar's width, widthOnBar
272
+ const levelBar = progressElementRef.querySelector('#current_level');
273
+ //update filters, x = widthOnBar
274
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
275
+ //update circle, widthOnBar+10
276
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
277
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
278
+ levelBar.setAttribute('width', `${widthOnBar}`);
279
+ levelCircle.setAttribute('cx', `${(widthOnBar < pointR ? pointR : widthOnBar)}`);
280
+ levelFilter.setAttribute('x', `${widthOnBar - 8}`);
281
+ //update lock location
282
+ const endLockElement = progressElementRef.querySelector('#lock');
283
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
284
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
285
+ // ball in endlockfilter2_i_305_23
286
+ const filter2 = progressElementRef.querySelector('#filter_ball');
287
+ // heart in endlockfilter3_d_305_23
288
+ const filter3 = progressElementRef.querySelector('#filter_heart');
289
+ //wrapper of lockfilter4_d_305_23
290
+ const filterLock = progressElementRef.querySelector('#filter_lock');
291
+ // shadow of ball paint0_linear_305_23
292
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
293
+ //paint in lockpaint1_linear_305_23
294
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
295
+ // box of lock and heart, for move position dynamically
296
+ const lockBox = progressElementRef.querySelector('#lock_box');
297
+ const heartBox = progressElementRef.querySelector('#heart_box');
298
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
299
+ //set cx of lockElement
300
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
301
+ //set cx of sub Elements
302
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
303
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
304
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
305
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
306
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
307
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
308
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
309
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
310
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
311
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
312
+ svgElement.parentElement.style.opacity = '1';
313
+ }
314
+
315
+ 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 rgba(0, 0, 0, 0.2509803922);\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}";
316
+ const PlayerElevateCardDataStyle0 = playerElevateCardDataCss;
317
+
318
+ const PlayerElevateCardData = class {
319
+ constructor(hostRef) {
320
+ registerInstance(this, hostRef);
321
+ this.playerElevateLeveLoaded = createEvent(this, "playerElevateLeveLoaded", 7);
322
+ this.params = undefined;
323
+ this.playerElevateLevel = undefined;
324
+ this.pointExpireString = undefined;
325
+ }
326
+ handleWindowResizs() {
327
+ this.initLevelProgressbar();
328
+ }
329
+ onParamsChanged() {
330
+ this.loadElevateInfo();
331
+ }
332
+ onRedeemClick() {
333
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
334
+ }
335
+ loadLevels() {
336
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
337
+ return new Promise((resolve, reject) => {
338
+ return fetch(url.href, {
339
+ method: 'GET',
340
+ })
341
+ .then((res) => res.json())
342
+ .then((res) => {
343
+ this.levels = res.data;
344
+ resolve(true);
345
+ })
346
+ .catch((err) => {
347
+ reject(err);
348
+ });
349
+ });
350
+ }
351
+ calcuatePointsToBeExpired(walletTotalInfo) {
352
+ let pointExpireInfoAsString = '';
353
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
354
+ walletTotalInfo.aboutToExpire.length == 0 ||
355
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
356
+ return pointExpireInfoAsString;
357
+ }
358
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
359
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
360
+ ? -1
361
+ : 1;
362
+ });
363
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
364
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
365
+ let hoursToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
366
+ if (daysToExpried == 0) {
367
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date());
368
+ expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
369
+ }
370
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
371
+ expirationPoints: aboutToExpire.points,
372
+ expireDay: daysToExpried,
373
+ });
374
+ return pointExpireInfoAsString;
375
+ }
376
+ loadPlayerLevelInfo() {
377
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
378
+ return new Promise((resolve, reject) => {
379
+ return fetch(url.href, {
380
+ method: 'GET',
381
+ headers: {
382
+ 'X-Sessionid': this.params.session,
383
+ 'Content-Type': 'application/json',
384
+ },
385
+ })
386
+ .then((res) => res.json())
387
+ .then((res) => {
388
+ var _a, _b, _c;
389
+ if (!res.success) {
390
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
391
+ reject(true);
392
+ return;
393
+ }
394
+ let playerElevateInfo = res.data;
395
+ this.playerElevateLevel = playerElevateInfo.level;
396
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
397
+ this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
398
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
399
+ const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
400
+ const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
401
+ this.playerElevateLeveLoaded.emit({
402
+ elevateLevelWalletTotal: spendableTotal,
403
+ loyaltyWalletTotal
404
+ });
405
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
406
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
407
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
408
+ this.playerElevateLeveLoaded.emit({
409
+ pointExpireString: spExpireInfoAsString,
410
+ xpExpireString: xpExpireInfoAsString
411
+ });
412
+ }
413
+ resolve(this.playerElevateLevel);
414
+ })
415
+ .catch((err) => {
416
+ console.log('error ', err);
417
+ reject(true);
418
+ });
419
+ });
420
+ }
421
+ setLoyaltyProgress(percent) {
422
+ updateProgressSvg(this.loyaltyProgressEle, percent);
423
+ }
424
+ initLevelProgressbar() {
425
+ setTimeout(() => {
426
+ this.loyaltyProgressEle =
427
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
428
+ if (!this.loyaltyProgressEle) {
429
+ return;
430
+ }
431
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
432
+ ? 1 : (this.playerElevateLevel.loyaltyPoints / this.playerElevateLevel.nextLevel.entryPoints));
433
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
434
+ }, 80);
435
+ }
436
+ componentDidRender() {
437
+ this.initLevelProgressbar();
438
+ }
439
+ loadElevateInfo() {
440
+ if (!this.params.endpoint || !this.params.session) {
441
+ return;
442
+ }
443
+ const promises = [];
444
+ promises.push(this.loadPlayerLevelInfo());
445
+ if (this.params.calculateLevelFlag) {
446
+ promises.push(this.loadLevels());
447
+ }
448
+ Promise.all(promises).then((res) => {
449
+ console.log('elevate-init', res);
450
+ this.initLevelProgressbar();
451
+ if (!this.levels) {
452
+ return;
453
+ }
454
+ this.levels.sort((level1, level2) => {
455
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
456
+ });
457
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
458
+ let playerLevelNumber = 0;
459
+ this.levels.forEach((elevateLevel, idx) => {
460
+ if (playerPoints > elevateLevel.firstEntryPoints) {
461
+ playerLevelNumber = idx;
462
+ }
463
+ });
464
+ this.playerElevateLeveLoaded.emit({
465
+ calculatedLevelFlag: playerLevelNumber,
466
+ });
467
+ });
468
+ }
469
+ componentWillLoad() {
470
+ this.loadElevateInfo();
471
+ }
472
+ get elevateCardRef() { return getElement(this); }
473
+ static get watchers() { return {
474
+ "params": ["onParamsChanged"]
475
+ }; }
476
+ };
477
+ PlayerElevateCardData.style = PlayerElevateCardDataStyle0;
478
+
479
+ const playerElevateLoyaltycardCss = ":host{display:block}@media screen and (min-width: 501px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:nowrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:11px;margin-left:5px}}@media screen and (max-width: 500px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:wrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:0px;margin-left:0px}}.LoyaltyCard .Inner .LevelProgress{margin-left:0px}.LoyaltyCard .Inner .Row .PointsInfo{width:100%}.LoyaltyCard .Inner .Row .PointsInfo.ExpirationPoints{text-align:left;color:var(--emfe-w-color-red-50, red)}.LoyaltyCard .Inner .PlayerAvatar .Avatar{display:none}.LoyaltyCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%}.LoyaltyCard .Inner .LevelInfo .ElevateLevel{display:flex;flex:1;align-items:center}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{position:relative;padding-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate .ExpireTime{margin-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .LevelName{padding-left:0;font-size:var(--emfe-w-elevate-fontsize-2xlarge, 21px);position:relative;width:auto;color:var(--emfe-w-elevate-color-levelname, #FFBD2B);font-weight:bold}.LoyaltyCard .NextLevelTip{text-align:right;font-size:11px;color:var(--emfe-w-color-black, #000);opacity:0.8;font-weight:bold}";
480
+ const PlayerElevateLoyaltycardStyle0 = playerElevateLoyaltycardCss;
481
+
482
+ const PlayerElevateLoyaltycard = class {
483
+ constructor(hostRef) {
484
+ registerInstance(this, hostRef);
485
+ this.endpoint = undefined;
486
+ this.theme = 'Dark';
487
+ this.session = undefined;
488
+ this.playerAvatarUrl = undefined;
489
+ this.language = 'en';
490
+ this.playerName = undefined;
491
+ this.dateFormat = 'yyyy-MM-dd';
492
+ this.clientStyling = '';
493
+ this.clientStylingUrl = '';
494
+ this.translationUrl = '';
495
+ this.pointExpireString = undefined;
496
+ this.playerElevateLevel = undefined;
497
+ this.elevateWalletTotal = undefined;
498
+ }
499
+ onSessionOrEndpointChange() {
500
+ this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
501
+ }
502
+ playerElevateLeveLoadedHandler(event) {
503
+ if (!event.detail) {
504
+ return;
505
+ }
506
+ if (event.detail['elevateLevelWalletTotal']) {
507
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
508
+ }
509
+ if (event.detail['elevateLevel']) {
510
+ this.playerElevateLevel = event.detail['elevateLevel'];
511
+ }
512
+ if (event.detail['pointExpireString']) {
513
+ this.pointExpireString = event.detail.xpExpireString;
514
+ }
515
+ }
516
+ onRedeemClick() {
517
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
518
+ }
519
+ componentWillLoad() {
520
+ this.paramProxy = {
521
+ endpoint: this.endpoint,
522
+ session: this.session,
523
+ language: this.language,
524
+ };
525
+ }
526
+ getNextLevelTips() {
527
+ var _a;
528
+ //need xx to reach Diamond
529
+ let nextLevel = (_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel;
530
+ if (this.playerElevateLevel && nextLevel) {
531
+ const pointsToReach = (nextLevel.entryPoints - this.playerElevateLevel.loyaltyPoints).toFixed(2);
532
+ return translateWithParams('tipsForNextLevel', {
533
+ pointsToReach,
534
+ levelName: nextLevel.name,
535
+ });
536
+ }
537
+ return '';
538
+ }
539
+ render() {
540
+ const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
541
+ const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
542
+ return (h("div", { key: 'd32d09786bf66e0abef026482e7ea04a53c051b1', class: `ElevateCardWrapper ${this.theme}` }, h("div", { key: 'dd2685eb840341b8823f24db9b72d0f6b7d340ae', class: "LoyaltyCard Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, h("general-styling-wrapper", { key: '3e2a00d1697c89441a8254cb81c6dc72e5b9f534', clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), h("player-elevate-card-data", { key: '56221e6d50df3b09c4269000637818009807c994', params: this.paramProxy }), h("div", { key: 'f11201024b280d6beb2ce1978ebfa7f2c7c59678', class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, h("div", { key: '948a023268fad3945b5069686eb29312111042a2', class: 'Content Row' }, this.playerElevateLevel && (h(Fragment, { key: 'de7c52faa07386949ce1ca728968534922e9d880' }, h("div", { key: '7c1a0c6ea5dbe7ee2375813b3819efa61e283232', class: "PlayerImg" }, h(PlayerAvatar, { key: '70ae13ee168c6de7bf4618f6ab8761462c8812b2', onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), h("div", { key: 'c11f916999b52e43e04ee472b0f54691012409a5', class: `LevelInfo ${this.playerElevateLevel.name}` }, h(PlayerElevateLoyaltyLevel, { key: '6aa61d117b24f9abbee9c5d33e882d6f023f205b', hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), h(PlayerPoints, { key: '7cc02e34d4682c25095dbf6a3077b314410d8093', loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language }), this.pointExpireString && (h("div", { key: '793e388644891e15b32e003ac8914e57e758e86b', class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), h(PlayerLoyaltyProcess, { key: 'a4f6c3b9f9cd5e8c6a025c26154702f9495bbe5b' }), h("div", { key: 'd91eda0f963ba9ffd481237f4b16bd4ef638d25e', class: "NextLevelTip" }, this.getNextLevelTips())))))))));
543
+ }
544
+ static get watchers() { return {
545
+ "session": ["onSessionOrEndpointChange"],
546
+ "endpoint": ["onSessionOrEndpointChange"],
547
+ "language": ["onSessionOrEndpointChange"]
548
+ }; }
549
+ };
550
+ PlayerElevateLoyaltycard.style = PlayerElevateLoyaltycardStyle0;
551
+
552
+ export { GeneralStylingWrapper as general_styling_wrapper, PlayerElevateCardData as player_elevate_card_data, PlayerElevateLoyaltycard as player_elevate_loyaltycard };