@everymatrix/player-elevate-points-history 1.31.2

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 (100) hide show
  1. package/dist/assets/back.svg +3 -0
  2. package/dist/assets/menu.svg +5 -0
  3. package/dist/cjs/bonus-pagination-limits_6.cjs.entry.js +1115 -0
  4. package/dist/cjs/index-974f5239.js +1686 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/loader.cjs.js +21 -0
  7. package/dist/cjs/player-elevate-card-items-67656c5f.js +2477 -0
  8. package/dist/cjs/player-elevate-card.cjs.entry.js +77 -0
  9. package/dist/cjs/player-elevate-loyaltycard.cjs.entry.js +84 -0
  10. package/dist/cjs/player-elevate-points-history.cjs.js +19 -0
  11. package/dist/collection/collection-manifest.json +40 -0
  12. package/dist/collection/components/player-elevate-points-history/player-elevate-points-history.css +174 -0
  13. package/dist/collection/components/player-elevate-points-history/player-elevate-points-history.js +395 -0
  14. package/dist/collection/index.js +1 -0
  15. package/dist/collection/renders/renderTabs.js +11 -0
  16. package/dist/collection/renders/renderTopBar.js +12 -0
  17. package/dist/collection/renders/renderWallets.js +44 -0
  18. package/dist/collection/static/back.svg +3 -0
  19. package/dist/collection/static/menu.svg +5 -0
  20. package/dist/collection/utils/business.js +17 -0
  21. package/dist/collection/utils/fetch.js +17 -0
  22. package/dist/collection/utils/translation.js +35 -0
  23. package/dist/collection/utils/types.js +6 -0
  24. package/dist/collection/utils/util.js +16 -0
  25. package/dist/components/bonus-pagination-limits.js +6 -0
  26. package/dist/components/bonus-pagination-limits2.js +111 -0
  27. package/dist/components/bonus-pagination-nav.js +6 -0
  28. package/dist/components/bonus-pagination-nav2.js +219 -0
  29. package/dist/components/general-styling-wrapper.js +6 -0
  30. package/dist/components/general-styling-wrapper2.js +104 -0
  31. package/dist/components/index.d.ts +26 -0
  32. package/dist/components/index.js +1 -0
  33. package/dist/components/player-elevate-card-data.js +6 -0
  34. package/dist/components/player-elevate-card-data2.js +625 -0
  35. package/dist/components/player-elevate-card-items.js +2250 -0
  36. package/dist/components/player-elevate-card.js +119 -0
  37. package/dist/components/player-elevate-loyaltycard.js +125 -0
  38. package/dist/components/player-elevate-pointcard.js +6 -0
  39. package/dist/components/player-elevate-pointcard2.js +125 -0
  40. package/dist/components/player-elevate-points-history.d.ts +11 -0
  41. package/dist/components/player-elevate-points-history.js +363 -0
  42. package/dist/esm/bonus-pagination-limits_6.entry.js +1106 -0
  43. package/dist/esm/index-18159ab2.js +1657 -0
  44. package/dist/esm/index.js +1 -0
  45. package/dist/esm/loader.js +17 -0
  46. package/dist/esm/player-elevate-card-items-96ed621b.js +2464 -0
  47. package/dist/esm/player-elevate-card.entry.js +73 -0
  48. package/dist/esm/player-elevate-loyaltycard.entry.js +80 -0
  49. package/dist/esm/player-elevate-points-history.js +17 -0
  50. package/dist/esm/polyfills/core-js.js +11 -0
  51. package/dist/esm/polyfills/css-shim.js +1 -0
  52. package/dist/esm/polyfills/dom.js +79 -0
  53. package/dist/esm/polyfills/es5-html-element.js +1 -0
  54. package/dist/esm/polyfills/index.js +34 -0
  55. package/dist/esm/polyfills/system.js +6 -0
  56. package/dist/index.cjs.js +1 -0
  57. package/dist/index.js +1 -0
  58. package/dist/player-elevate-points-history/index.esm.js +0 -0
  59. package/dist/player-elevate-points-history/p-3073cebd.js +1 -0
  60. package/dist/player-elevate-points-history/p-50a08f34.entry.js +1 -0
  61. package/dist/player-elevate-points-history/p-a937ac54.js +1 -0
  62. package/dist/player-elevate-points-history/p-b0fd409d.entry.js +1 -0
  63. package/dist/player-elevate-points-history/p-e44be562.entry.js +1 -0
  64. package/dist/player-elevate-points-history/player-elevate-points-history.esm.js +1 -0
  65. package/dist/static/button-default.svg +42 -0
  66. package/dist/static/button-disabled.svg +4 -0
  67. package/dist/static/button-hover.svg +4 -0
  68. package/dist/static/button-level.svg +27 -0
  69. package/dist/static/button-pressed.svg +18 -0
  70. package/dist/static/button-redeem.svg +36 -0
  71. package/dist/static/card-ground-over.png +0 -0
  72. package/dist/static/card-ground-over.svg +903 -0
  73. package/dist/static/card-ground.png +0 -0
  74. package/dist/static/card-ground.svg +34 -0
  75. package/dist/static/info.svg +4 -0
  76. package/dist/static/level-badge.png +0 -0
  77. package/dist/static/level-percent.svg +80 -0
  78. package/dist/static/tips-info.svg +21 -0
  79. package/dist/static/user.svg +3 -0
  80. package/dist/stencil.config.js +31 -0
  81. package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/player-elevate-points-history/.stencil/packages/player-elevate-points-history/stencil.config.d.ts +2 -0
  82. package/dist/types/components/player-elevate-points-history/player-elevate-points-history.d.ts +66 -0
  83. package/dist/types/components.d.ts +126 -0
  84. package/dist/types/index.d.ts +1 -0
  85. package/dist/types/renders/renderTabs.d.ts +3 -0
  86. package/dist/types/renders/renderTopBar.d.ts +3 -0
  87. package/dist/types/renders/renderWallets.d.ts +3 -0
  88. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  89. package/dist/types/utils/business.d.ts +2 -0
  90. package/dist/types/utils/fetch.d.ts +2 -0
  91. package/dist/types/utils/translation.d.ts +35 -0
  92. package/dist/types/utils/types.d.ts +41 -0
  93. package/dist/types/utils/util.d.ts +1 -0
  94. package/loader/cdn.js +3 -0
  95. package/loader/index.cjs.js +3 -0
  96. package/loader/index.d.ts +12 -0
  97. package/loader/index.es2017.js +3 -0
  98. package/loader/index.js +4 -0
  99. package/loader/package.json +10 -0
  100. package/package.json +31 -0
@@ -0,0 +1,1106 @@
1
+ import { r as registerInstance, c as createEvent, h, g as getElement, a as getAssetPath, F as Fragment } from './index-18159ab2.js';
2
+ import { r as requiredArgs, t as toDate, g as getTimezoneOffsetInMilliseconds, a as translateWithParams, T as TRANSLATIONS$2, P as PlayerAvatar, b as translate$2, c as PlayerPoints } from './player-elevate-card-items-96ed621b.js';
3
+
4
+ const DEFAULT_LANGUAGE$1 = 'en';
5
+ const SUPPORTED_LANGUAGES$1 = ['pt-br', 'en', 'es-mx', 'hu', 'hr'];
6
+ const TRANSLATIONS$1 = {
7
+ en: {
8
+ "pageLimitLabel": 'Show',
9
+ },
10
+ hu: {
11
+ "pageLimitLabel": 'Show',
12
+ },
13
+ hr: {
14
+ "pageLimitLabel": 'Show',
15
+ },
16
+ "pt-br": {
17
+ "pageLimitLabel": 'Show',
18
+ },
19
+ "es-mx": {
20
+ "pageLimitLabel": 'Show',
21
+ }
22
+ };
23
+ const translate$1 = (key, customLang) => {
24
+ const lang = customLang;
25
+ return TRANSLATIONS$1[lang !== undefined && SUPPORTED_LANGUAGES$1.includes(lang) ? lang : DEFAULT_LANGUAGE$1][key];
26
+ };
27
+
28
+ const bonusPaginationLimitsCss = ":host{display:block}.NoOfItemsToDisplayMessage{display:inline-block;margin:0.1rem;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--emfe-w-color-primary, #191a19);line-height:1.8}.PaginationWrapper{display:flex;flex-direction:row}ul.PaginationArea{margin-block:5px;display:flex;flex-direction:row;padding:0px}ul.PaginationArea li.Item.Active:hover{color:var(--emfe-w-color-primary, #eaefea);background-color:var(--emfe-w-color-secondary, #191a19)}ul.PaginationArea li.Item.Active,ul.PaginationArea li.Item:hover{background-color:var(--emfe-w-color-primary, rgba(169, 171, 169, 0.7));font-weight:bold;border-radius:0.3rem}ul.PaginationArea li.Item{padding-inline-start:0px;list-style:none;padding:5px 6px;margin:2px;cursor:pointer;display:inline-block}";
29
+
30
+ const BonusPaginationLimits = class {
31
+ constructor(hostRef) {
32
+ registerInstance(this, hostRef);
33
+ this.pageLimitChanged = createEvent(this, "pageLimitChanged", 7);
34
+ /**
35
+ * Language of the widget
36
+ */
37
+ this.language = 'en';
38
+ /**
39
+ * Translation via url
40
+ */
41
+ this.translationUrl = '';
42
+ /**
43
+ * Default limit for per page, default: 10
44
+ */
45
+ this.limit = 10;
46
+ this.pageLimits = [10, 25, 50];
47
+ }
48
+ onPageLimitClicked(pageLimit) {
49
+ this.limit = pageLimit;
50
+ this.pageLimitChanged.emit({ limit: this.limit });
51
+ }
52
+ componentWillLoad() {
53
+ if (!this.pageLimitOptions) {
54
+ return;
55
+ }
56
+ try {
57
+ this.pageLimits = this.pageLimitOptions.split(',').map((item) => {
58
+ return parseInt(item);
59
+ });
60
+ // if there is an array of custom limits provided (string to array - e.g. [5, 10, 15])
61
+ // and the value for the custom set limit (e.g. 8) isn't part of the provided array,
62
+ // then ignore the set the custom set limit and make the limit equal to the first value of the array
63
+ // (as part of the example so far, this would be 5)
64
+ if (!this.pageLimits.includes(this.limit)) {
65
+ this.limit = this.pageLimits[0];
66
+ }
67
+ }
68
+ catch (e) {
69
+ console.error('Error when parse PageLimitOptions', e);
70
+ }
71
+ }
72
+ renderStylingWrapper() {
73
+ return h("general-styling-wrapper", { targetTranslations: TRANSLATIONS$1, translationUrl: this.translationUrl });
74
+ }
75
+ render() {
76
+ return h("div", { class: 'PaginationWrapper' }, h("span", { class: 'NoOfItemsToDisplayMessage' }, translate$1('pageLimitLabel', this.language)), h("ul", { class: 'PaginationArea' }, this.pageLimits.map((pageLimit) => {
77
+ return (h("li", { class: `${this.limit == pageLimit ? 'Active' : ''} PageSize Item`, onClick: () => {
78
+ this.onPageLimitClicked(pageLimit);
79
+ } }, pageLimit));
80
+ })), h("general-styling-wrapper", { targetTranslations: TRANSLATIONS$1, translationUrl: this.translationUrl }), this.renderStylingWrapper());
81
+ }
82
+ };
83
+ BonusPaginationLimits.style = bonusPaginationLimitsCss;
84
+
85
+ const DEFAULT_LANGUAGE = 'en';
86
+ const SUPPORTED_LANGUAGES = ['pt-br', 'en', 'es-mx', 'hu', 'hr'];
87
+ const TRANSLATIONS = {
88
+ "en": {
89
+ "firstPage": '|<',
90
+ "lastPage": '>|',
91
+ "prePage": '<',
92
+ "nextPage": '>',
93
+ "pageOfTotal": '{start}-{end} of {total}',
94
+ },
95
+ "hu": {
96
+ "firstPage": 'First',
97
+ "lastPage": 'Last',
98
+ "prePage": '<',
99
+ "nextPage": '>',
100
+ "pageOfTotal": '{start}-{end} of {total}',
101
+ },
102
+ "hr": {
103
+ "firstPage": 'First',
104
+ "lastPage": 'Last',
105
+ "prePage": '<',
106
+ "nextPage": '>',
107
+ "pageOfTotal": '{start}-{end} of {total}',
108
+ },
109
+ "pt-br": {
110
+ "firstPage": 'First',
111
+ "lastPage": 'Last',
112
+ "prePage": '<',
113
+ "nextPage": '>',
114
+ "pageOfTotal": '{start}-{end} of {total}',
115
+ },
116
+ "es-mx": {
117
+ "firstPage": 'First',
118
+ "lastPage": 'Last',
119
+ "prePage": '<',
120
+ "nextPage": '>',
121
+ "pageOfTotal": '{start}-{end} of {total}',
122
+ }
123
+ };
124
+ const translate = (key, customLang, values) => {
125
+ const lang = customLang;
126
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
127
+ if (values !== undefined) {
128
+ for (const [key, value] of Object.entries(values.values)) {
129
+ const regex = new RegExp(`{${key}}`, 'g');
130
+ translation = translation.replace(regex, value);
131
+ }
132
+ }
133
+ return translation;
134
+ };
135
+
136
+ const bonusPaginationNavCss = ":host{display:block}.PageNavigationWrapper{display:flex;flex-direction:row}.PageNavigationWrapper .PageOfMessage{margin:5px;padding:5px 6px;margin:2px}.PageNavigation{display:flex;flex-direction:row;align-items:center}.PageNavigation .PageArrow{color:var(--emfe-w-color-primary, #777676);padding:6px 5px;cursor:pointer;font-weight:bold;width:1.2rem;text-align:center}.PageNavigation .PageArrow.Disabled{color:var(--emfe-w-color-gray-100, #e0e0e0)}ul.PaginationArea{list-style:none;padding:0px;margin:0px;display:flex}ul.PaginationArea li.PageItem{cursor:pointer;padding:5px 6px;margin:2px;width:0.9rem;text-align:center}ul.PaginationArea li.PageItem.Active,ul.PaginationArea li.PageItem:hover{font-weight:bold;color:var(--emfe-w-color-primary, #f5f1f1);background-color:var(--emfe-w-color-secondary, #8c8989);border-radius:0.3rem}";
137
+
138
+ const BonusPaginationNav = class {
139
+ constructor(hostRef) {
140
+ registerInstance(this, hostRef);
141
+ this.reloadPageEmitter = createEvent(this, "reloadPageByType", 7);
142
+ /**
143
+ * The received length of dataset
144
+ */
145
+ this.total = 1;
146
+ /**
147
+ * The received limit for the number of pages
148
+ */
149
+ this.limit = 10;
150
+ /**
151
+ * The offset of dataset
152
+ */
153
+ this.offset = 0;
154
+ /**
155
+ * The table id, use to identify which table listen the page change message
156
+ * when there is more than 1 table on same page
157
+ */
158
+ this.tableId = 'default';
159
+ /**
160
+ * Language
161
+ */
162
+ this.language = 'en';
163
+ /**
164
+ * Translation via url
165
+ */
166
+ this.translationUrl = '';
167
+ /**
168
+ * Customize pagination: Activate pagination arrows
169
+ */
170
+ this.arrowsActive = true;
171
+ /**
172
+ * Customize pagination: Activate pagination secondary arrows
173
+ */
174
+ this.secondaryArrowsActive = true;
175
+ /**
176
+ * Customize pagination: Activate pagination numbered navigation
177
+ */
178
+ this.displayPageNumbers = true;
179
+ this.endPageIndex = 0;
180
+ this.currentPage = 1;
181
+ }
182
+ pageLimitChangedHandler(event) {
183
+ this.limit = event.detail.limit ? event.detail.limit : this.limit;
184
+ //reset offset = 0, this.currentPage = 1 when page limit changed
185
+ this.currentPage = 1;
186
+ this.offset = 0;
187
+ this.updatePageStatus();
188
+ if (event.type == 'pageLimitChanged') {
189
+ this.reloadPageEmitter.emit({ offset: 0, limit: this.limit, tableId: this.tableId });
190
+ }
191
+ }
192
+ goTo(step) {
193
+ if (step == '...' || step == 0 || step > this.endPageIndex + 1) {
194
+ return;
195
+ }
196
+ this.currentPage = step;
197
+ let offset = (this.currentPage - 1) * this.limit;
198
+ this.reloadPageEmitter.emit({ offset, limit: this.limit, tableId: this.tableId });
199
+ }
200
+ renderPageList() {
201
+ return h("ul", { class: 'PaginationArea' }, this.pagesArray.map((page) => {
202
+ return (h("li", { class: `PageItem ${this.currentPage == page ? 'Active' : ''}`, onClick: () => {
203
+ this.goTo(page);
204
+ } }, page));
205
+ }));
206
+ }
207
+ renderStylingWrapper() {
208
+ return h("general-styling-wrapper", { targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl });
209
+ }
210
+ updatePageStatus() {
211
+ this.endPageIndex = (Math.ceil(this.total / this.limit) - 1);
212
+ this.endPageIndex = this.endPageIndex < 0 ? this.endPageIndex = 0 : this.endPageIndex;
213
+ this.pagesArray = [];
214
+ if (this.endPageIndex < 5) {
215
+ this.pagesArray = Array.from({ length: this.endPageIndex + 1 }, (_, i) => i + 1);
216
+ }
217
+ else {
218
+ /**
219
+ * Construct numbered navigation area based on current page position
220
+ */
221
+ if (this.currentPage == 1 || this.currentPage == 2) {
222
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
223
+ this.pagesArray.push('...');
224
+ }
225
+ else if (this.currentPage >= 3 && ((this.endPageIndex - this.currentPage) >= 2)) {
226
+ this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
227
+ this.pagesArray.push('...');
228
+ this.pagesArray.unshift('...');
229
+ }
230
+ else if ((this.endPageIndex - this.currentPage) < 3) {
231
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endPageIndex - 2 + i);
232
+ this.pagesArray.unshift('...');
233
+ }
234
+ }
235
+ }
236
+ componentWillRender() {
237
+ this.currentPage = Math.floor(this.offset / this.limit) + 1;
238
+ this.updatePageStatus();
239
+ }
240
+ render() {
241
+ const startOffset = (this.currentPage - 1) * this.limit + 1;
242
+ const endOffset = this.currentPage * this.limit > this.total ? this.total : this.currentPage * this.limit;
243
+ return h("div", { class: 'PageNavigationWrapper' }, this.displayRangeOfTotal && this.total > 0 && h("span", { class: 'PageOfMessage' }, translate('pageOfTotal', this.language, {
244
+ values: {
245
+ start: startOffset,
246
+ end: endOffset,
247
+ total: this.total
248
+ }
249
+ })), h("div", { class: 'PageNavigation' }, this.arrowsActive &&
250
+ h("div", { class: `PageArrow FirstPage ${this.currentPage == 1 ? 'Disabled' : ''}`, onClick: () => {
251
+ this.goTo(1);
252
+ } }, translate('firstPage', this.language)), this.secondaryArrowsActive &&
253
+ h("span", { class: `PageArrow PrePage ${this.currentPage == 1 ? 'Disabled' : ''}`, onClick: () => {
254
+ this.goTo(this.currentPage - 1);
255
+ } }, translate('prePage', this.language)), this.displayPageNumbers && this.renderPageList(), this.secondaryArrowsActive &&
256
+ h("span", { class: `PageArrow NextPage ${this.currentPage == (this.endPageIndex + 1) ? 'Disabled' : ''}`, onClick: () => {
257
+ this.goTo(this.currentPage + 1);
258
+ } }, translate('nextPage', this.language)), this.arrowsActive &&
259
+ h("div", { class: `PageArrow LastPage ${this.currentPage == this.endPageIndex + 1 ? 'Disabled' : ''}`, onClick: () => {
260
+ this.goTo(this.endPageIndex + 1);
261
+ } }, " ", translate('lastPage', this.language), " "), this.renderStylingWrapper()));
262
+ }
263
+ };
264
+ BonusPaginationNav.style = bonusPaginationNavCss;
265
+
266
+ const mergeTranslations = (url, target) => {
267
+ return new Promise((resolve) => {
268
+ fetch(url)
269
+ .then((res) => res.json())
270
+ .then((data) => {
271
+ Object.keys(data).forEach((item) => {
272
+ target[item] = target[item] ? target[item] : {};
273
+ for (let key in data[item]) {
274
+ target[item][key] = data[item][key];
275
+ }
276
+ });
277
+ resolve(true);
278
+ });
279
+ });
280
+ };
281
+
282
+ const generalStylingWrapperCss = ":host{display:block}";
283
+
284
+ const GeneralStylingWrapper = class {
285
+ constructor(hostRef) {
286
+ registerInstance(this, hostRef);
287
+ /**
288
+ * Client custom styling via inline styles
289
+ */
290
+ this.clientStyling = '';
291
+ /**
292
+ * Client custom styling via url
293
+ */
294
+ this.clientStylingUrl = '';
295
+ /**
296
+ * Translation via url
297
+ */
298
+ this.translationUrl = '';
299
+ this.stylingAppends = false;
300
+ this.setClientStyling = () => {
301
+ let sheet = document.createElement('style');
302
+ sheet.innerHTML = this.clientStyling;
303
+ this.el.prepend(sheet);
304
+ };
305
+ this.setClientStylingURL = () => {
306
+ let url = new URL(this.clientStylingUrl);
307
+ let cssFile = document.createElement('style');
308
+ fetch(url.href)
309
+ .then((res) => res.text())
310
+ .then((data) => {
311
+ cssFile.innerHTML = data;
312
+ setTimeout(() => {
313
+ this.el.prepend(cssFile);
314
+ }, 1);
315
+ })
316
+ .catch((err) => {
317
+ console.log('error ', err);
318
+ });
319
+ };
320
+ }
321
+ componentDidRender() {
322
+ // start custom styling area
323
+ if (!this.stylingAppends) {
324
+ if (this.clientStyling)
325
+ this.setClientStyling();
326
+ if (this.clientStylingUrl)
327
+ this.setClientStylingURL();
328
+ this.stylingAppends = true;
329
+ }
330
+ // end custom styling area
331
+ }
332
+ async componentWillLoad() {
333
+ const promises = [];
334
+ if (this.translationUrl) {
335
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
336
+ promises.push(translationPromise);
337
+ }
338
+ return await Promise.all(promises);
339
+ }
340
+ render() {
341
+ return (h("div", { class: "StyleShell" }, h("slot", { name: "mainContent" })));
342
+ }
343
+ get el() { return getElement(this); }
344
+ };
345
+ GeneralStylingWrapper.style = generalStylingWrapperCss;
346
+
347
+ /**
348
+ * @name startOfDay
349
+ * @category Day Helpers
350
+ * @summary Return the start of a day for the given date.
351
+ *
352
+ * @description
353
+ * Return the start of a day for the given date.
354
+ * The result will be in the local timezone.
355
+ *
356
+ * @param {Date|Number} date - the original date
357
+ * @returns {Date} the start of a day
358
+ * @throws {TypeError} 1 argument required
359
+ *
360
+ * @example
361
+ * // The start of a day for 2 September 2014 11:55:00:
362
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
363
+ * //=> Tue Sep 02 2014 00:00:00
364
+ */
365
+ function startOfDay(dirtyDate) {
366
+ requiredArgs(1, arguments);
367
+ var date = toDate(dirtyDate);
368
+ date.setHours(0, 0, 0, 0);
369
+ return date;
370
+ }
371
+
372
+ var MILLISECONDS_IN_DAY = 86400000;
373
+
374
+ /**
375
+ * @name differenceInCalendarDays
376
+ * @category Day Helpers
377
+ * @summary Get the number of calendar days between the given dates.
378
+ *
379
+ * @description
380
+ * Get the number of calendar days between the given dates. This means that the times are removed
381
+ * from the dates and then the difference in days is calculated.
382
+ *
383
+ * @param {Date|Number} dateLeft - the later date
384
+ * @param {Date|Number} dateRight - the earlier date
385
+ * @returns {Number} the number of calendar days
386
+ * @throws {TypeError} 2 arguments required
387
+ *
388
+ * @example
389
+ * // How many calendar days are between
390
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
391
+ * const result = differenceInCalendarDays(
392
+ * new Date(2012, 6, 2, 0, 0),
393
+ * new Date(2011, 6, 2, 23, 0)
394
+ * )
395
+ * //=> 366
396
+ * // How many calendar days are between
397
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
398
+ * const result = differenceInCalendarDays(
399
+ * new Date(2011, 6, 3, 0, 1),
400
+ * new Date(2011, 6, 2, 23, 59)
401
+ * )
402
+ * //=> 1
403
+ */
404
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
405
+ requiredArgs(2, arguments);
406
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
407
+ var startOfDayRight = startOfDay(dirtyDateRight);
408
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
409
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
410
+
411
+ // Round the number of days to the nearest integer
412
+ // because the number of milliseconds in a day is not constant
413
+ // (e.g. it's different in the day of the daylight saving time clock shift)
414
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
415
+ }
416
+
417
+ /**
418
+ * Days in 1 week.
419
+ *
420
+ * @name daysInWeek
421
+ * @constant
422
+ * @type {number}
423
+ * @default
424
+ */
425
+
426
+ /**
427
+ * Milliseconds in 1 hour
428
+ *
429
+ * @name millisecondsInHour
430
+ * @constant
431
+ * @type {number}
432
+ * @default
433
+ */
434
+ var millisecondsInHour = 3600000;
435
+
436
+ /**
437
+ * @name differenceInMilliseconds
438
+ * @category Millisecond Helpers
439
+ * @summary Get the number of milliseconds between the given dates.
440
+ *
441
+ * @description
442
+ * Get the number of milliseconds between the given dates.
443
+ *
444
+ * @param {Date|Number} dateLeft - the later date
445
+ * @param {Date|Number} dateRight - the earlier date
446
+ * @returns {Number} the number of milliseconds
447
+ * @throws {TypeError} 2 arguments required
448
+ *
449
+ * @example
450
+ * // How many milliseconds are between
451
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
452
+ * const result = differenceInMilliseconds(
453
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
454
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
455
+ * )
456
+ * //=> 1100
457
+ */
458
+ function differenceInMilliseconds(dateLeft, dateRight) {
459
+ requiredArgs(2, arguments);
460
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
461
+ }
462
+
463
+ var roundingMap = {
464
+ ceil: Math.ceil,
465
+ round: Math.round,
466
+ floor: Math.floor,
467
+ trunc: function trunc(value) {
468
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
469
+ } // Math.trunc is not supported by IE
470
+ };
471
+
472
+ var defaultRoundingMethod = 'trunc';
473
+ function getRoundingMethod(method) {
474
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
475
+ }
476
+
477
+ /**
478
+ * @name differenceInHours
479
+ * @category Hour Helpers
480
+ * @summary Get the number of hours between the given dates.
481
+ *
482
+ * @description
483
+ * Get the number of hours between the given dates.
484
+ *
485
+ * @param {Date|Number} dateLeft - the later date
486
+ * @param {Date|Number} dateRight - the earlier date
487
+ * @param {Object} [options] - an object with options.
488
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
489
+ * @returns {Number} the number of hours
490
+ * @throws {TypeError} 2 arguments required
491
+ *
492
+ * @example
493
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
494
+ * const result = differenceInHours(
495
+ * new Date(2014, 6, 2, 19, 0),
496
+ * new Date(2014, 6, 2, 6, 50)
497
+ * )
498
+ * //=> 12
499
+ */
500
+ function differenceInHours(dateLeft, dateRight, options) {
501
+ requiredArgs(2, arguments);
502
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
503
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
504
+ }
505
+
506
+ /**
507
+ * @name isBefore
508
+ * @category Common Helpers
509
+ * @summary Is the first date before the second one?
510
+ *
511
+ * @description
512
+ * Is the first date before the second one?
513
+ *
514
+ * @param {Date|Number} date - the date that should be before the other one to return true
515
+ * @param {Date|Number} dateToCompare - the date to compare with
516
+ * @returns {Boolean} the first date is before the second date
517
+ * @throws {TypeError} 2 arguments required
518
+ *
519
+ * @example
520
+ * // Is 10 July 1989 before 11 February 1987?
521
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
522
+ * //=> false
523
+ */
524
+ function isBefore(dirtyDate, dirtyDateToCompare) {
525
+ requiredArgs(2, arguments);
526
+ var date = toDate(dirtyDate);
527
+ var dateToCompare = toDate(dirtyDateToCompare);
528
+ return date.getTime() < dateToCompare.getTime();
529
+ }
530
+
531
+ function updateProgressSvg(progressElementRef, percent) {
532
+ const svgElement = progressElementRef.querySelector('#total_level');
533
+ const endLockWidth = 15;
534
+ const barWidth = svgElement.getBBox().width;
535
+ const widthOnBar = percent * barWidth - endLockWidth < 0 ? 0 : percent * barWidth - endLockWidth;
536
+ //update bar's width, widthOnBar
537
+ const levelBar = progressElementRef.querySelector('#current_level');
538
+ //update filters, x = widthOnBar
539
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
540
+ //update circle, widthOnBar+10
541
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
542
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
543
+ levelBar.setAttribute('width', `${widthOnBar}`);
544
+ levelCircle.setAttribute('cx', `${widthOnBar + 3}`);
545
+ levelFilter.setAttribute('x', `${widthOnBar - 4}`);
546
+ //update lock location
547
+ const endLockElement = progressElementRef.querySelector('#lock');
548
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
549
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
550
+ // ball in endlockfilter2_i_305_23
551
+ const filter2 = progressElementRef.querySelector('#filter_ball');
552
+ // heart in endlockfilter3_d_305_23
553
+ const filter3 = progressElementRef.querySelector('#filter_heart');
554
+ //wrapper of lockfilter4_d_305_23
555
+ const filterLock = progressElementRef.querySelector('#filter_lock');
556
+ // shadow of ball paint0_linear_305_23
557
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
558
+ //paint in lockpaint1_linear_305_23
559
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
560
+ // box of lock and heart, for move position dynamically
561
+ const lockBox = progressElementRef.querySelector('#lock_box');
562
+ const heartBox = progressElementRef.querySelector('#heart_box');
563
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
564
+ //set cx of lockElement
565
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
566
+ //set cx of sub Elements
567
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
568
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
569
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
570
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
571
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
572
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
573
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
574
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
575
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
576
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
577
+ }
578
+
579
+ 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 .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}";
580
+
581
+ const PlayerElevateCardData = class {
582
+ constructor(hostRef) {
583
+ registerInstance(this, hostRef);
584
+ this.playerElevateLeveLoaded = createEvent(this, "playerElevateLeveLoaded", 7);
585
+ }
586
+ handleWindowResizs() {
587
+ this.initLevelProgressbar();
588
+ }
589
+ onRedeemClick() {
590
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
591
+ }
592
+ loadLevels() {
593
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
594
+ return new Promise((resolve, reject) => {
595
+ return fetch(url.href, {
596
+ method: 'GET',
597
+ })
598
+ .then((res) => res.json())
599
+ .then((res) => {
600
+ this.levels = res.data;
601
+ resolve(true);
602
+ })
603
+ .catch((err) => {
604
+ reject(err);
605
+ });
606
+ });
607
+ }
608
+ calcuatePointsToBeExpired(walletTotalInfo) {
609
+ let pointExpireInfoAsString = '';
610
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
611
+ walletTotalInfo.aboutToExpire.length == 0 ||
612
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
613
+ return pointExpireInfoAsString;
614
+ }
615
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
616
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
617
+ ? -1
618
+ : 1;
619
+ });
620
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
621
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
622
+ let hoursToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
623
+ if (daysToExpried == 0) {
624
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date());
625
+ expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
626
+ }
627
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
628
+ expirationPoints: aboutToExpire.points,
629
+ expireDay: daysToExpried,
630
+ });
631
+ return pointExpireInfoAsString;
632
+ }
633
+ loadPlayerLevelInfo() {
634
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
635
+ return new Promise((resolve, reject) => {
636
+ return fetch(url.href, {
637
+ method: 'GET',
638
+ headers: {
639
+ 'X-Sessionid': this.params.session,
640
+ 'Content-Type': 'application/json',
641
+ },
642
+ })
643
+ .then((res) => res.json())
644
+ .then((res) => {
645
+ var _a, _b, _c;
646
+ if (!res.success) {
647
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
648
+ reject(true);
649
+ return;
650
+ }
651
+ let playerElevateInfo = res.data;
652
+ this.playerElevateLevel = playerElevateInfo.level;
653
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
654
+ this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
655
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
656
+ const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
657
+ const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
658
+ this.playerElevateLeveLoaded.emit({
659
+ elevateLevelWalletTotal: spendableTotal,
660
+ loyaltyWalletTotal
661
+ });
662
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
663
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
664
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
665
+ this.playerElevateLeveLoaded.emit({
666
+ pointExpireString: spExpireInfoAsString,
667
+ xpExpireString: xpExpireInfoAsString
668
+ });
669
+ }
670
+ resolve(this.playerElevateLevel);
671
+ })
672
+ .catch((err) => {
673
+ console.log('error ', err);
674
+ reject(true);
675
+ });
676
+ });
677
+ }
678
+ setLoyaltyProgress(percent) {
679
+ updateProgressSvg(this.loyaltyProgressEle, percent);
680
+ }
681
+ initLevelProgressbar() {
682
+ setTimeout(() => {
683
+ this.loyaltyProgressEle =
684
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
685
+ if (!this.loyaltyProgressEle) {
686
+ return;
687
+ }
688
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
689
+ ? 1
690
+ : (this.playerElevateLevel.loyaltyPoints -
691
+ this.playerElevateLevel.entryPoints) /
692
+ (this.playerElevateLevel.nextLevel.entryPoints -
693
+ this.playerElevateLevel.loyaltyPoints));
694
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
695
+ }, 80);
696
+ }
697
+ componentWillRender() { }
698
+ componentDidRender() {
699
+ this.initLevelProgressbar();
700
+ }
701
+ componentWillLoad() {
702
+ if (!this.params.endpoint || !this.params.session) {
703
+ return;
704
+ }
705
+ const promises = [];
706
+ promises.push(this.loadPlayerLevelInfo());
707
+ if (this.params.calculateLevelFlag) {
708
+ promises.push(this.loadLevels());
709
+ }
710
+ Promise.all(promises).then((res) => {
711
+ console.log('elevate-init', res);
712
+ this.initLevelProgressbar();
713
+ if (!this.levels) {
714
+ return;
715
+ }
716
+ this.levels.sort((level1, level2) => {
717
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
718
+ });
719
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
720
+ let playerLevelNumber = 0;
721
+ this.levels.forEach((elevateLevel, idx) => {
722
+ if (playerPoints > elevateLevel.firstEntryPoints) {
723
+ playerLevelNumber = idx;
724
+ }
725
+ });
726
+ this.playerElevateLeveLoaded.emit({
727
+ calculatedLevelFlag: playerLevelNumber,
728
+ });
729
+ });
730
+ }
731
+ get elevateCardRef() { return getElement(this); }
732
+ };
733
+ PlayerElevateCardData.style = playerElevateCardDataCss;
734
+
735
+ const playerElevatePointcardCss = ":host{display:block}.PointsCard .Inner .Row .ExpirationPoints{text-align:left}.PointsCard .Inner .PlayerAvatar .Avatar{display:none}.PointsCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%;position:inherit}.PointsCard .Inner .PointsTxt{display:flex;flex-direction:row;justify-content:space-between}.PointsCard .Inner .DetailButton{background:linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%), linear-gradient(0deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6));border-radius:5px;box-shadow:0px 4px 4px 0px rgba(0, 0, 0, 0.25);border:2px solid;font-size:11px;width:108px;padding:4px;cursor:pointer;margin-top:5px;height:16px;min-width:45px;text-align:center}.PointsCard .Inner .DetailButton span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .DetailButton span{display:inline-block;vertical-align:middle}.PointsCard .Inner .DetailButton:hover span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .LevelInfo{gap:15px;width:70%}.PointsCard .Inner .LevelInfo .PointsTxt{font-size:15px}.PointsCard .Inner .LevelInfo .PointsTxt.Label{display:none}.PointsCard .Inner .LevelInfo .PointsTxt.SPPoints{padding-top:15px}.PointsCard .Inner .LevelInfo .PointsTxt .TC{font-size:x-small;color:var(--emw--color-gray-300, #58586B);display:flex;align-content:center;height:100%;flex-wrap:wrap;text-decoration:underline;cursor:pointer;display:none}";
736
+
737
+ const PlayerElevatePointcard = class {
738
+ constructor(hostRef) {
739
+ registerInstance(this, hostRef);
740
+ /**
741
+ * The style that widget shows,available value: Dark, Light
742
+ * Default: Dark
743
+ */
744
+ this.theme = 'Dark';
745
+ /**
746
+ * Widget Language to show
747
+ */
748
+ this.language = 'en';
749
+ /**
750
+ * Check if the card used in points details widget, default: 'earningRule'
751
+ * value: 'details'/'earningRule'
752
+ * It effected the button in card
753
+ * 'earningRule': button text, 'earning rules', post 'BEEPointRulesClicked' when clicked
754
+ * 'details': button text, 'details', post 'BEEDetailsClicked' when clicked
755
+ */
756
+ this.buttonType = 'earningRule';
757
+ /**
758
+ * datePattern
759
+ */
760
+ this.dateFormat = 'yyyy-MM-dd';
761
+ /**
762
+ * Client custom styling via inline styles
763
+ */
764
+ this.clientStyling = '';
765
+ /**
766
+ * Client custom styling via url
767
+ */
768
+ this.clientStylingUrl = '';
769
+ /**
770
+ * Translation via url
771
+ */
772
+ this.translationUrl = '';
773
+ this.isPointDetailCard = this.buttonType === 'earningRule';
774
+ }
775
+ playerElevateLeveLoadedHandler(event) {
776
+ if (!event.detail) {
777
+ return;
778
+ }
779
+ if (event.detail['elevateLevelWalletTotal']) {
780
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
781
+ this.elevateSPTotal = event.detail['loyaltyWalletTotal'];
782
+ }
783
+ if (event.detail['elevateLevel']) {
784
+ this.playerElevateLevel = event.detail['elevateLevel'];
785
+ }
786
+ if (event.detail['pointExpireString']) {
787
+ this.pointExpireString = event.detail.pointExpireString;
788
+ }
789
+ }
790
+ onDetailsClick() {
791
+ window.postMessage({ type: this.isPointDetailCard ? 'BEEPointRulesClicked' : 'BEEDetailsClicked',
792
+ path: this.isPointDetailCard ? 'player-elevate-level' : 'player-elevate-point-details' }, window.location.href);
793
+ }
794
+ componentWillLoad() {
795
+ this.paramProxy = {
796
+ endpoint: this.endpoint,
797
+ session: this.session,
798
+ language: this.language,
799
+ };
800
+ }
801
+ render() {
802
+ const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
803
+ const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
804
+ return (h("div", { class: `ElevateCardWrapper ${this.theme}` }, h("div", { class: "PointsCard Outer ", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS$2, translationUrl: this.translationUrl }), h("player-elevate-card-data", { params: this.paramProxy }), h("div", { class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, h("div", { class: 'Content Row' }, this.playerElevateLevel && (h(Fragment, null, h("div", { class: "PlayerImg" }, h(PlayerAvatar, { onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), h("div", { class: `LevelInfo ${this.playerElevateLevel.name}` }, h("div", { class: "PointsTxt Label" }, this.cardTitle ? this.cardTitle : translate$2('spendablePoints')), h("div", { class: 'PointsTxt SPPoints' }, h(PlayerPoints, { spendablePoints: this.playerElevateLevel.spendablePoints, language: this.language }), h("a", { class: "TC", onClick: () => {
805
+ this.onDetailsClick();
806
+ } }, translate$2('termAndConditions', this.language))), this.pointExpireString && (h("div", { class: 'ExpirationPoints' }, this.pointExpireString, " "))))))))));
807
+ }
808
+ };
809
+ PlayerElevatePointcard.style = playerElevatePointcardCss;
810
+
811
+ var WalletType;
812
+ (function (WalletType) {
813
+ WalletType["spendable"] = "spendable";
814
+ WalletType["loyalty"] = "loyalty";
815
+ WalletType["history"] = "history";
816
+ })(WalletType || (WalletType = {}));
817
+
818
+ const translation = {
819
+ en: {
820
+ tabTitle: {
821
+ [WalletType.spendable]: 'Coins',
822
+ [WalletType.loyalty]: 'XP',
823
+ [WalletType.history]: 'Conversion History'
824
+ },
825
+ barTitle: {
826
+ [WalletType.spendable]: 'Coins History',
827
+ [WalletType.loyalty]: 'Experience Points History',
828
+ [WalletType.history]: 'Conversion History'
829
+ },
830
+ bonus: 'Bonus',
831
+ redeem: 'Redeem',
832
+ reload: 'Reload',
833
+ reloadMsgWhenError: 'Network Problem, please ',
834
+ pointType: {
835
+ registration: 'Registration',
836
+ cancelledRegistration: 'Cancelled Registration',
837
+ expiredRegistration: 'Expired Registration',
838
+ manual: 'Manual',
839
+ cancelledManual: 'Cancelled Manual',
840
+ expiredManual: 'Expired Manual',
841
+ wageringByRealMoney: 'Real Money Wager',
842
+ wageringByBonusMoney: 'Bonus Money Wager',
843
+ cancelledWageringByRealMoney: 'Cancelled Real Money Wager',
844
+ cancelledWageringByBonusMoney: 'Cancelled Bonus Money Wager',
845
+ expiredWageringByRealMoney: 'Expired Real Money Wager',
846
+ expiredWageringByBonusMoney: 'Expired Bonus Money Wager',
847
+ levelExpired: 'Level Expiration',
848
+ bonus: 'Bonus Redeem',
849
+ }
850
+ }
851
+ };
852
+
853
+ const getUrl = (path, params = {}) => {
854
+ return path + '?' + Object.keys(params).map(key => `${key}=${params[key]}`).join('&');
855
+ };
856
+ const fetcher = async (input, init = {}) => {
857
+ let res;
858
+ // @ts-ignore
859
+ res = await fetch(input, init);
860
+ res = await res.text();
861
+ try {
862
+ res = JSON.parse(res);
863
+ }
864
+ catch (e) {
865
+ console.error(e);
866
+ throw e;
867
+ }
868
+ return res;
869
+ };
870
+
871
+ const getWallets = async (endpoint, language, type, session, pageSetting) => {
872
+ const params = {
873
+ type,
874
+ language,
875
+ pagination: `offset=${pageSetting.offset},limit=${pageSetting.limit}`
876
+ };
877
+ const url = getUrl(endpoint + getUriByWalletType(params.type), params);
878
+ const res = await fetcher(url, {
879
+ headers: {
880
+ 'x-SessionId': session
881
+ }
882
+ });
883
+ return res;
884
+ };
885
+ const getUriByWalletType = (type) => `/v1/elevate/${type == WalletType.history ? 'redeemHistory' : 'pointsHistory'}`;
886
+
887
+ const renderWallets = (locale, wallets, pageSetting) => wallets && (h(Fragment, null,
888
+ h("div", { class: "Records" }, wallets.map(wallet => (h("div", { class: "RecordContainer" },
889
+ h("div", { class: "Row" },
890
+ h("div", { class: "Title" }, locale.pointType[wallet.pointType] || wallet.pointType),
891
+ h("div", { class: `Amount ${getAmountConfig(wallet.points).class}` },
892
+ getAmountConfig(wallet.points).symbol,
893
+ wallet.points)),
894
+ wallet.payload && wallet.payload.displayName &&
895
+ h("div", { class: "Row Desc", innerHTML: wallet.payload.displayName['*'] }),
896
+ h("div", { class: "Row" },
897
+ h("div", { class: "DateTime" }, formatDate(new Date(wallet.modified)))))))),
898
+ h("div", { class: "PaginationContainer" },
899
+ h("bonus-pagination-nav", { offset: pageSetting.offset, limit: pageSetting.limit, displayPageNumbers: pageSetting.displayPageNumbers, tableId: pageSetting.tableId, secondaryArrowsActive: pageSetting.secondaryArrowsActive, total: pageSetting.total }))));
900
+ const getAmountConfig = (amount) => {
901
+ if (amount > 0) {
902
+ return {
903
+ class: 'Positive',
904
+ symbol: '+'
905
+ };
906
+ }
907
+ else {
908
+ return {
909
+ class: 'Negative',
910
+ symbol: ''
911
+ };
912
+ }
913
+ };
914
+ const padTo2Digits = (num) => {
915
+ return num.toString().padStart(2, '0');
916
+ };
917
+ const formatDate = (date) => {
918
+ return ([
919
+ date.getFullYear(),
920
+ padTo2Digits(date.getMonth() + 1),
921
+ padTo2Digits(date.getDate()),
922
+ ].join('-') +
923
+ ' ' +
924
+ [
925
+ padTo2Digits(date.getHours()),
926
+ padTo2Digits(date.getMinutes()),
927
+ padTo2Digits(date.getSeconds()),
928
+ ].join(':'));
929
+ };
930
+
931
+ const backSvg = `<svg width="9" height="15" viewBox="0 0 9 15" fill="none" xmlns="http://www.w3.org/2000/svg">
932
+ <path d="M7.75 1L1.25 7.5L7.75 14" stroke="#242424" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
933
+ </svg>
934
+ `;
935
+
936
+ const menuSvg = `<svg width="30" height="8" viewBox="0 0 30 8" fill="none" xmlns="http://www.w3.org/2000/svg">
937
+ <circle cx="4" cy="4" r="4" fill="black"/>
938
+ <circle cx="15" cy="4" r="4" fill="black"/>
939
+ <circle cx="26" cy="4" r="4" fill="black"/>
940
+ </svg>
941
+ `;
942
+
943
+ const renderTopBar = (locale, type, pageSetting) => h("div", { class: "TopBarContainer" },
944
+ h("div", { class: "BackImageContainer" },
945
+ h("span", { class: "BackImage", innerHTML: backSvg })),
946
+ h("div", { class: "TitleContainer" },
947
+ h("div", { class: "Title", title: locale.barTitle[type] }, locale.barTitle[type]),
948
+ h("div", { class: 'Limits' },
949
+ h("bonus-pagination-limits", { pageLimitOptions: pageSetting.pageLimitOptions, limit: pageSetting.limit }))),
950
+ h("div", null,
951
+ h("span", { class: "MenuImage", innerHTML: menuSvg })));
952
+
953
+ const renderTabs = (locale, type, onChangeTab) => h("div", { class: "Tabs Row" }, Object.keys(WalletType).map(key => {
954
+ const isActive = key === type;
955
+ const cssActive = isActive ? 'active' : '';
956
+ return (h("div", null,
957
+ h("div", { class: `TabText ${cssActive}`, onClick: () => {
958
+ onChangeTab(key);
959
+ } }, locale.tabTitle[key]),
960
+ h("div", { class: `TabBorderBottom ${cssActive}` })));
961
+ }));
962
+
963
+ const playerElevatePointsHistoryCss = ":host{display:block}main{max-width:420px}main player-elevate-pointcard{width:100%;height:220px}.PlayerElevatePointsDetaisContainer{background:#FFFFFF;padding:20px 10px 0;margin-top:-100px;position:relative;min-height:360px}.PlayerElevatePointsDetaisContainer .ReloadMsg{padding:20px}.PlayerElevatePointsDetaisContainer .ReloadMsg a.Reload{cursor:pointer}.TitleContainer{font-size:20px;font-weight:500;line-height:25px;letter-spacing:0em;text-align:left;display:flex;justify-content:space-between}.TopBarContainer{display:flex;align-items:center;justify-content:space-between}.TopBarContainer .TitleContainer{width:100%}.TopBarContainer .Title{background:#303030;padding:5px 16px;color:#FFFFFF;box-shadow:0px 4px 13px 0px #00000040;border-radius:8px;width:fit-content;margin-left:7px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.PaginationContainer{display:flex;justify-content:center}.MonthStat{margin-top:25px;display:none;font-size:16px;font-weight:500;line-height:19px;letter-spacing:0px;text-align:left;color:#242424}.MonthStat .Amount{color:#53B65A}.BackImageContainer{width:35px;height:35px;flex:0 0 35px;border-radius:6px;text-align:center;line-height:35px;box-shadow:0px 4px 40px 0px #8A959E33;display:none}.Records{margin-top:16px}.MenuImage,.BackImage{cursor:pointer;display:none}.Row{display:flex;justify-content:space-between;align-items:center}.Row:nth-child(n+2){margin-top:3px}.Tabs.Row{justify-content:space-around;margin-top:20px}.Tabs.Row .TabText{font-size:16px;margin:10px 15px;color:#9C9C9C;cursor:pointer}.Tabs.Row .TabText.active{color:#242424;font-weight:600}.Tabs.Row .TabBorderBottom{height:5px;border-radius:4px;background:transparent}.Tabs.Row .TabBorderBottom.active{background:#242424}.RecordContainer{margin:5px 0;padding:10px;box-shadow:0px 0px 8px 0px #0000001A;border-radius:5px}.RecordContainer .Title{color:#242424;font-size:16px;font-weight:600;line-height:19px;letter-spacing:0px;text-align:left}.RecordContainer .Amount{font-size:16px;font-weight:600;line-height:19px;letter-spacing:0px;text-align:left}.RecordContainer .Amount.Positive{color:#53B65A}.RecordContainer .Amount.Negative{color:#B41E2D}.RecordContainer .DateTime{color:#9C9C9C;font-size:16px;font-weight:400;line-height:19px;letter-spacing:0px;text-align:left}.RecordContainer .Tag{font-size:12px;font-weight:500;line-height:14px;letter-spacing:0em;text-align:center;color:#767171;padding:8px 30px;border-radius:8px;box-shadow:0px 2px 4px 0px #00000040}";
964
+
965
+ const PlayerElevatePointsHistory = class {
966
+ constructor(hostRef) {
967
+ registerInstance(this, hostRef);
968
+ this.paginationReset = createEvent(this, "paginationReset", 7);
969
+ /**
970
+ * Customize pagination: Activate pagination secondary arrows
971
+ */
972
+ this.secondaryArrowsActive = true;
973
+ /**
974
+ * Customize pagination: Activate pagination numbered navigation
975
+ */
976
+ this.displayPageNumbers = false;
977
+ /**
978
+ * Customize page list options, default: 10,25,50
979
+ */
980
+ this.pageLimitOptions = '10,25,50';
981
+ /**
982
+ * Language of the widget
983
+ */
984
+ this.language = 'en';
985
+ /**
986
+ * Client custom styling via string
987
+ */
988
+ this.clientStyling = '';
989
+ /**
990
+ * Client custom styling via url
991
+ */
992
+ this.clientStylingUrl = '';
993
+ /**
994
+ * translation via url
995
+ */
996
+ this.translationUrl = '';
997
+ this.locale = translation['en'];
998
+ this.type = WalletType.spendable;
999
+ this.pointsWallets = {};
1000
+ }
1001
+ switchTab(type) {
1002
+ var _a, _b;
1003
+ this.type = type;
1004
+ if (this.pointsWallets[type] || !((_a = this.pointsWallets[type]) === null || _a === void 0 ? void 0 : _a.isLoadFailed)) {
1005
+ return;
1006
+ }
1007
+ this.paginationReset.emit({ limit: ((_b = this.pointsWallets[type]) === null || _b === void 0 ? void 0 : _b.pageSetting.limit) || this.limit, tableId: this.type });
1008
+ }
1009
+ getPageSettingByType(type) {
1010
+ return this.pointsWallets[type] ? this.pointsWallets[type].pageSetting : {
1011
+ limit: this.limit, total: 0, offset: 0, tableId: type,
1012
+ secondaryArrowsActive: this.secondaryArrowsActive,
1013
+ displayPageNumbers: this.displayPageNumbers,
1014
+ pageLimitOptions: this.pageLimitOptions || undefined
1015
+ };
1016
+ }
1017
+ render() {
1018
+ var _a, _b;
1019
+ const pageSetting = this.getPageSettingByType(this.type);
1020
+ return (h("main", null, h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl,
1021
+ // @ts-ignore
1022
+ targetTranslations: translation, translationUrl: this.translationUrl }), h("player-elevate-pointcard", { playerAvatarUrl: this.playerAvatarUrl, endpoint: this.endpoint, session: this.session, language: this.language, clientStylingUrl: this.clientStylingUrl, clientStyling: this.clientStyling, translationUrl: this.translationUrl }), h("div", { class: "PlayerElevatePointsDetaisContainer" }, [
1023
+ renderTopBar(this.locale, this.type, pageSetting),
1024
+ renderTabs(this.locale, this.type, (type) => this.switchTab(type)),
1025
+ ((_a = this.pointsWallets[this.type]) === null || _a === void 0 ? void 0 : _a.isLoadFailed)
1026
+ ? h("div", { class: 'ReloadMsg' }, this.locale['reloadMsgWhenError'], h("a", { class: 'Reload', onClick: () => { this.updateWallets(); } }, this.locale['reload']))
1027
+ : renderWallets(this.locale, ((_b = this.pointsWallets[this.type]) === null || _b === void 0 ? void 0 : _b.wallets) || [], pageSetting)
1028
+ ])));
1029
+ }
1030
+ walletTypeChangedHandler() {
1031
+ //do not reload when loaded tab switched back
1032
+ if (this.pointsWallets[this.type]) {
1033
+ return;
1034
+ }
1035
+ this.updateWallets();
1036
+ }
1037
+ async updateWallets() {
1038
+ let pageSetting = this.pointsWallets[this.type]
1039
+ ? this.pointsWallets[this.type].pageSetting
1040
+ : this.getPageSettingByType(this.type);
1041
+ try {
1042
+ const walletsDetail = await getWallets(this.endpoint, this.language, this.type, this.session, pageSetting);
1043
+ const wallets = walletsDetail.data || [];
1044
+ if (walletsDetail.success) {
1045
+ pageSetting.total = walletsDetail.total;
1046
+ this.pointsWallets[this.type] = { wallets, pageSetting };
1047
+ this.pointsWallets = Object.assign({}, this.pointsWallets);
1048
+ }
1049
+ else {
1050
+ console.error(walletsDetail);
1051
+ this.pointsWallets[this.type].isLoadFailed = true;
1052
+ //pageSetting.total = 0;
1053
+ }
1054
+ }
1055
+ catch (e) {
1056
+ console.error(e);
1057
+ this.pointsWallets[this.type].isLoadFailed = true;
1058
+ }
1059
+ }
1060
+ reloadPageByTypeHandler(event) {
1061
+ if (event.detail.tableId != this.type) {
1062
+ return;
1063
+ }
1064
+ //reset all wallets when limit changed
1065
+ //otherwise fetch new data with new offset when offset changed
1066
+ if (this.limit != event.detail.limit) {
1067
+ this.pointsWallets = {};
1068
+ this.limit = event.detail.limit;
1069
+ }
1070
+ else {
1071
+ let pageSetting = this.pointsWallets[this.type].pageSetting || this.getPageSettingByType(this.type);
1072
+ pageSetting.offset = event.detail.offset;
1073
+ this.pointsWallets[this.type].pageSetting = pageSetting;
1074
+ }
1075
+ this.updateWallets();
1076
+ }
1077
+ setLimit() {
1078
+ try {
1079
+ const pageLimits = this.pageLimitOptions.split(',').map((item) => {
1080
+ return parseInt(item);
1081
+ });
1082
+ if (pageLimits.includes(this.limit)) ;
1083
+ else {
1084
+ this.limit = pageLimits[0];
1085
+ }
1086
+ }
1087
+ catch (e) {
1088
+ console.error('Error when parse PageLimitOptions', e);
1089
+ this.limit = 10;
1090
+ }
1091
+ }
1092
+ async componentWillLoad() {
1093
+ this.setLimit();
1094
+ this.updateWallets();
1095
+ }
1096
+ static get assetsDirs() { return ["static"]; }
1097
+ static get watchers() { return {
1098
+ "type": ["walletTypeChangedHandler"],
1099
+ "endpoint": ["updateWallets"],
1100
+ "language": ["updateWallets"],
1101
+ "session": ["updateWallets"]
1102
+ }; }
1103
+ };
1104
+ PlayerElevatePointsHistory.style = playerElevatePointsHistoryCss;
1105
+
1106
+ export { BonusPaginationLimits as bonus_pagination_limits, BonusPaginationNav as bonus_pagination_nav, GeneralStylingWrapper as general_styling_wrapper, PlayerElevateCardData as player_elevate_card_data, PlayerElevatePointcard as player_elevate_pointcard, PlayerElevatePointsHistory as player_elevate_points_history };