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