@everymatrix/bonus-elevate-shop 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 (88) hide show
  1. package/dist/assets/avaliable.false.svg +47 -0
  2. package/dist/assets/avaliable.true.svg +47 -0
  3. package/dist/bonus-elevate-shop/bonus-elevate-shop.esm.js +1 -0
  4. package/dist/bonus-elevate-shop/index.esm.js +0 -0
  5. package/dist/bonus-elevate-shop/p-6410647b.entry.js +1 -0
  6. package/dist/bonus-elevate-shop/p-75b51599.js +1 -0
  7. package/dist/bonus-elevate-shop/p-a76542bd.entry.js +1 -0
  8. package/dist/bonus-elevate-shop/p-d4f6c446.entry.js +1 -0
  9. package/dist/bonus-elevate-shop/p-e2f63c46.js +1 -0
  10. package/dist/cjs/bonus-elevate-shop.cjs.js +19 -0
  11. package/dist/cjs/bonus-elevate-shop_4.cjs.entry.js +787 -0
  12. package/dist/cjs/index-ec3ffb89.js +1680 -0
  13. package/dist/cjs/index.cjs.js +2 -0
  14. package/dist/cjs/loader.cjs.js +21 -0
  15. package/dist/cjs/player-elevate-card-items-8154b78f.js +2477 -0
  16. package/dist/cjs/player-elevate-card.cjs.entry.js +77 -0
  17. package/dist/cjs/player-elevate-loyaltycard.cjs.entry.js +84 -0
  18. package/dist/collection/collection-manifest.json +28 -0
  19. package/dist/collection/components/bonus-elevate-shop/bonus-elevate-shop.css +84 -0
  20. package/dist/collection/components/bonus-elevate-shop/bonus-elevate-shop.js +186 -0
  21. package/dist/collection/index.js +1 -0
  22. package/dist/collection/renders/renderGifts.js +41 -0
  23. package/dist/collection/static/avaliable.false.svg +47 -0
  24. package/dist/collection/static/avaliable.true.svg +47 -0
  25. package/dist/collection/utils/fetch.js +29 -0
  26. package/dist/collection/utils/translation.js +6 -0
  27. package/dist/collection/utils/types.js +1 -0
  28. package/dist/components/bonus-elevate-shop.d.ts +11 -0
  29. package/dist/components/bonus-elevate-shop.js +279 -0
  30. package/dist/components/general-styling-wrapper.js +6 -0
  31. package/dist/components/general-styling-wrapper2.js +103 -0
  32. package/dist/components/index.d.ts +26 -0
  33. package/dist/components/index.js +1 -0
  34. package/dist/components/player-elevate-card-data.js +6 -0
  35. package/dist/components/player-elevate-card-data2.js +624 -0
  36. package/dist/components/player-elevate-card-items.js +2250 -0
  37. package/dist/components/player-elevate-card.js +118 -0
  38. package/dist/components/player-elevate-loyaltycard.js +124 -0
  39. package/dist/components/player-elevate-pointcard.js +6 -0
  40. package/dist/components/player-elevate-pointcard2.js +124 -0
  41. package/dist/esm/bonus-elevate-shop.js +17 -0
  42. package/dist/esm/bonus-elevate-shop_4.entry.js +780 -0
  43. package/dist/esm/index-2b126a46.js +1651 -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-88f5a140.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/polyfills/core-js.js +11 -0
  50. package/dist/esm/polyfills/css-shim.js +1 -0
  51. package/dist/esm/polyfills/dom.js +79 -0
  52. package/dist/esm/polyfills/es5-html-element.js +1 -0
  53. package/dist/esm/polyfills/index.js +34 -0
  54. package/dist/esm/polyfills/system.js +6 -0
  55. package/dist/index.cjs.js +1 -0
  56. package/dist/index.js +1 -0
  57. package/dist/static/button-default.svg +42 -0
  58. package/dist/static/button-disabled.svg +4 -0
  59. package/dist/static/button-hover.svg +4 -0
  60. package/dist/static/button-level.svg +27 -0
  61. package/dist/static/button-pressed.svg +18 -0
  62. package/dist/static/button-redeem.svg +36 -0
  63. package/dist/static/card-ground-over.png +0 -0
  64. package/dist/static/card-ground-over.svg +903 -0
  65. package/dist/static/card-ground.png +0 -0
  66. package/dist/static/card-ground.svg +34 -0
  67. package/dist/static/info.svg +4 -0
  68. package/dist/static/level-badge.png +0 -0
  69. package/dist/static/level-percent.svg +80 -0
  70. package/dist/static/tips-info.svg +21 -0
  71. package/dist/static/user.svg +3 -0
  72. package/dist/stencil.config.js +34 -0
  73. package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/bonus-elevate-shop/.stencil/packages/bonus-elevate-shop/stencil.config.d.ts +2 -0
  74. package/dist/types/components/bonus-elevate-shop/bonus-elevate-shop.d.ts +36 -0
  75. package/dist/types/components.d.ts +85 -0
  76. package/dist/types/index.d.ts +1 -0
  77. package/dist/types/renders/renderGifts.d.ts +3 -0
  78. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  79. package/dist/types/utils/fetch.d.ts +3 -0
  80. package/dist/types/utils/translation.d.ts +7 -0
  81. package/dist/types/utils/types.d.ts +12 -0
  82. package/loader/cdn.js +3 -0
  83. package/loader/index.cjs.js +3 -0
  84. package/loader/index.d.ts +12 -0
  85. package/loader/index.es2017.js +3 -0
  86. package/loader/index.js +4 -0
  87. package/loader/package.json +10 -0
  88. package/package.json +27 -0
@@ -0,0 +1,780 @@
1
+ import { h, r as registerInstance, g as getElement, c as createEvent, a as getAssetPath, F as Fragment } from './index-2b126a46.js';
2
+ import { r as requiredArgs, t as toDate, g as getTimezoneOffsetInMilliseconds, a as translateWithParams, T as TRANSLATIONS, P as PlayerAvatar, b as translate, c as PlayerPoints } from './player-elevate-card-items-88f5a140.js';
3
+
4
+ const getUrl = (path, params = {}) => {
5
+ return path + '?' + Object.keys(params).map(key => `${key}=${params[key]}`).join('&');
6
+ };
7
+ const fetcher = async (input, init = {}) => {
8
+ let res;
9
+ // @ts-ignore
10
+ res = await fetch(input, init);
11
+ res = await res.text();
12
+ try {
13
+ res = JSON.parse(res);
14
+ }
15
+ catch (e) {
16
+ console.error(e);
17
+ }
18
+ return res;
19
+ };
20
+ async function fetchNorwayApi(path, params = {}, init = {}) {
21
+ const { endpoint, language, session } = this;
22
+ const fetchParams = params;
23
+ if (!init.method || init.method === 'GET') {
24
+ fetchParams.language = language;
25
+ }
26
+ const url = getUrl(`${endpoint}${path}`, fetchParams);
27
+ if (!init.headers)
28
+ init.headers = {};
29
+ init.headers['x-SessionId'] = session;
30
+ const res = await fetcher(url, init);
31
+ return res;
32
+ }
33
+
34
+ const translation = {
35
+ en: {
36
+ Points: 'Points',
37
+ Point: 'Point',
38
+ }
39
+ };
40
+
41
+ const avaliableTrueSvg = `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
42
+ <g filter="url(#filter0_bd_179_6145)">
43
+ <circle cx="23" cy="19" r="19" style="fill: var(--emfe-w-elevate-avaliable-button-enabled-color, #53B65C);" />
44
+ <circle cx="23" cy="19" r="18" stroke="url(#paint0_linear_179_6145)" stroke-opacity="0.6" stroke-width="2"/>
45
+ <circle cx="23" cy="19" r="18" stroke="url(#paint1_linear_179_6145)" stroke-width="2"/>
46
+ <circle cx="23" cy="19" r="18" stroke="url(#paint2_linear_179_6145)" stroke-width="2"/>
47
+ </g>
48
+ <g filter="url(#filter1_d_179_6145)">
49
+ <path d="M31.1977 11C31.7015 11 32.1279 11.1777 32.4767 11.5332C32.8256 11.8887 33 12.3203 33 12.8281V18.9102C33 20.2852 32.7364 21.5977 32.2093 22.8477C31.6822 24.0977 30.9748 25.1719 30.0872 26.0703C29.1996 26.9688 28.1376 27.6816 26.9012 28.209C25.6647 28.7363 24.3682 29 23.0116 29C21.6473 29 20.3469 28.7363 19.1105 28.209C17.874 27.6816 16.8101 26.9688 15.9186 26.0703C15.0271 25.1719 14.3178 24.0977 13.7907 22.8477C13.2636 21.5977 13 20.2852 13 18.9102V12.8281C13 12.3281 13.1783 11.8984 13.5349 11.5391C13.8915 11.1797 14.3178 11 14.814 11H31.1977ZM23.0116 23.4688C23.376 23.4688 23.6938 23.3398 23.9651 23.082L28.6628 18.5352C28.9496 18.2617 29.093 17.9297 29.093 17.5391C29.093 17.1562 28.9593 16.8301 28.6919 16.5605C28.4244 16.291 28.1008 16.1562 27.7209 16.1562C27.3566 16.1562 27.0388 16.2852 26.7674 16.543L23.0116 20.1758L19.2558 16.543C18.9845 16.2852 18.6705 16.1562 18.314 16.1562C17.9341 16.1562 17.6105 16.291 17.343 16.5605C17.0756 16.8301 16.9419 17.1562 16.9419 17.5391C16.9419 17.9375 17.0814 18.2695 17.3605 18.5352L22.0698 23.082C22.3256 23.3398 22.6395 23.4688 23.0116 23.4688Z" fill="white"/>
50
+ </g>
51
+ <defs>
52
+ <filter id="filter0_bd_179_6145" x="-36" y="-40" width="118" height="118" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
53
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
54
+ <feGaussianBlur in="BackgroundImageFix" stdDeviation="20"/>
55
+ <feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur_179_6145"/>
56
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
57
+ <feOffset dy="4"/>
58
+ <feGaussianBlur stdDeviation="2"/>
59
+ <feComposite in2="hardAlpha" operator="out"/>
60
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
61
+ <feBlend mode="normal" in2="effect1_backgroundBlur_179_6145" result="effect2_dropShadow_179_6145"/>
62
+ <feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow_179_6145" result="shape"/>
63
+ </filter>
64
+ <filter id="filter1_d_179_6145" x="11" y="10" width="24" height="22" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
65
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
66
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
67
+ <feOffset dy="1"/>
68
+ <feGaussianBlur stdDeviation="1"/>
69
+ <feComposite in2="hardAlpha" operator="out"/>
70
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
71
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_179_6145"/>
72
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_179_6145" result="shape"/>
73
+ </filter>
74
+ <linearGradient id="paint0_linear_179_6145" x1="49.2869" y1="15.1911" x2="36.3103" y2="15.603" gradientUnits="userSpaceOnUse">
75
+ <stop stop-color="white"/>
76
+ <stop offset="1" stop-color="#EFEFEF" stop-opacity="0"/>
77
+ </linearGradient>
78
+ <linearGradient id="paint1_linear_179_6145" x1="4" y1="0" x2="19.3776" y2="8.17396" gradientUnits="userSpaceOnUse">
79
+ <stop stop-color="white" stop-opacity="0.5"/>
80
+ <stop offset="1" stop-color="white" stop-opacity="0"/>
81
+ </linearGradient>
82
+ <linearGradient id="paint2_linear_179_6145" x1="42" y1="38" x2="27.0558" y2="34.3156" gradientUnits="userSpaceOnUse">
83
+ <stop stop-color="white" stop-opacity="0.5"/>
84
+ <stop offset="1" stop-color="white" stop-opacity="0"/>
85
+ </linearGradient>
86
+ </defs>
87
+ </svg>
88
+ `;
89
+
90
+ const avaliableFalseSvg = `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
91
+ <g filter="url(#filter0_bd_183_6497)">
92
+ <circle cx="23" cy="19" r="19" style="fill: var(--emfe-w-elevate-avaliable-button-disabled-color, #B7B7B7);" />
93
+ <circle cx="23" cy="19" r="18" stroke="url(#paint0_linear_183_6497)" stroke-opacity="0.6" stroke-width="2"/>
94
+ <circle cx="23" cy="19" r="18" stroke="url(#paint1_linear_183_6497)" stroke-width="2"/>
95
+ <circle cx="23" cy="19" r="18" stroke="url(#paint2_linear_183_6497)" stroke-width="2"/>
96
+ </g>
97
+ <g filter="url(#filter1_d_183_6497)">
98
+ <path d="M31.1977 11C31.7015 11 32.1279 11.1777 32.4767 11.5332C32.8256 11.8887 33 12.3203 33 12.8281V18.9102C33 20.2852 32.7364 21.5977 32.2093 22.8477C31.6822 24.0977 30.9748 25.1719 30.0872 26.0703C29.1996 26.9688 28.1376 27.6816 26.9012 28.209C25.6647 28.7363 24.3682 29 23.0116 29C21.6473 29 20.3469 28.7363 19.1105 28.209C17.874 27.6816 16.8101 26.9688 15.9186 26.0703C15.0271 25.1719 14.3178 24.0977 13.7907 22.8477C13.2636 21.5977 13 20.2852 13 18.9102V12.8281C13 12.3281 13.1783 11.8984 13.5349 11.5391C13.8915 11.1797 14.3178 11 14.814 11H31.1977ZM23.0116 23.4688C23.376 23.4688 23.6938 23.3398 23.9651 23.082L28.6628 18.5352C28.9496 18.2617 29.093 17.9297 29.093 17.5391C29.093 17.1562 28.9593 16.8301 28.6919 16.5605C28.4244 16.291 28.1008 16.1562 27.7209 16.1562C27.3566 16.1562 27.0388 16.2852 26.7674 16.543L23.0116 20.1758L19.2558 16.543C18.9845 16.2852 18.6705 16.1562 18.314 16.1562C17.9341 16.1562 17.6105 16.291 17.343 16.5605C17.0756 16.8301 16.9419 17.1562 16.9419 17.5391C16.9419 17.9375 17.0814 18.2695 17.3605 18.5352L22.0698 23.082C22.3256 23.3398 22.6395 23.4688 23.0116 23.4688Z" fill="#F0F0F0"/>
99
+ </g>
100
+ <defs>
101
+ <filter id="filter0_bd_183_6497" x="-36" y="-40" width="118" height="118" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
102
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
103
+ <feGaussianBlur in="BackgroundImageFix" stdDeviation="20"/>
104
+ <feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur_183_6497"/>
105
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
106
+ <feOffset dy="4"/>
107
+ <feGaussianBlur stdDeviation="2"/>
108
+ <feComposite in2="hardAlpha" operator="out"/>
109
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
110
+ <feBlend mode="normal" in2="effect1_backgroundBlur_183_6497" result="effect2_dropShadow_183_6497"/>
111
+ <feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow_183_6497" result="shape"/>
112
+ </filter>
113
+ <filter id="filter1_d_183_6497" x="11" y="10" width="24" height="22" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
114
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
115
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
116
+ <feOffset dy="1"/>
117
+ <feGaussianBlur stdDeviation="1"/>
118
+ <feComposite in2="hardAlpha" operator="out"/>
119
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
120
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_183_6497"/>
121
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_183_6497" result="shape"/>
122
+ </filter>
123
+ <linearGradient id="paint0_linear_183_6497" x1="49.2869" y1="15.1911" x2="36.3103" y2="15.603" gradientUnits="userSpaceOnUse">
124
+ <stop stop-color="white"/>
125
+ <stop offset="1" stop-color="#EFEFEF" stop-opacity="0"/>
126
+ </linearGradient>
127
+ <linearGradient id="paint1_linear_183_6497" x1="4" y1="0" x2="19.3776" y2="8.17396" gradientUnits="userSpaceOnUse">
128
+ <stop stop-color="white" stop-opacity="0.5"/>
129
+ <stop offset="1" stop-color="white" stop-opacity="0"/>
130
+ </linearGradient>
131
+ <linearGradient id="paint2_linear_183_6497" x1="42" y1="38" x2="27.0558" y2="34.3156" gradientUnits="userSpaceOnUse">
132
+ <stop stop-color="white" stop-opacity="0.5"/>
133
+ <stop offset="1" stop-color="white" stop-opacity="0"/>
134
+ </linearGradient>
135
+ </defs>
136
+ </svg>
137
+ `;
138
+
139
+ const getStatusData = (gift, redeem) => {
140
+ switch (gift.available) {
141
+ case "true":
142
+ return {
143
+ extraClass: ' active',
144
+ onClick: () => redeem(gift.id),
145
+ icon: avaliableTrueSvg
146
+ };
147
+ case "false":
148
+ return {
149
+ extraClass: ' deactive',
150
+ onClick: () => { },
151
+ icon: avaliableFalseSvg
152
+ };
153
+ }
154
+ };
155
+ const renderGifts = (gifts, locale, redeem) => {
156
+ return (h("div", { class: "Gifts FlexLayout" }, gifts.map(gift => {
157
+ var _a;
158
+ const statusData = getStatusData(gift, redeem);
159
+ const presentation = gift.presentation;
160
+ const getPropForBackgroundImage = (asset) => asset ?
161
+ { backgroundImage: `url('${asset}')` } :
162
+ {};
163
+ return (h("div", { class: "Gift" },
164
+ h("div", { class: "ImgContainer", onClick: () => window.postMessage({ type: 'BEEShopImgClicked', itemId: gift.id }, window.location.href), style: Object.assign({}, getPropForBackgroundImage(((_a = presentation.assets) === null || _a === void 0 ? void 0 : _a.length) > 0 ? presentation.assets[0] : '')) }),
165
+ h("div", { class: "InfoContainer" },
166
+ h("div", null,
167
+ h("div", { class: "Point" },
168
+ gift.points,
169
+ " ",
170
+ gift.points === 1 ? locale.Point : locale.Points),
171
+ h("div", { class: "Title" }, (presentation === null || presentation === void 0 ? void 0 : presentation.displayName) || gift.displayName),
172
+ h("div", { class: "Description" }, (presentation === null || presentation === void 0 ? void 0 : presentation.description) || '')),
173
+ h("div", { class: "AvaliableWrap" + statusData.extraClass, onClick: () => statusData.onClick() },
174
+ h("span", { innerHTML: statusData.icon })))));
175
+ })));
176
+ };
177
+
178
+ const bonusElevateShopCss = ":host{display:block}svg circle{shape-rendering:crispEdges}.MainContainer{max-width:420px}.MainContainer player-elevate-pointcard{width:100%;height:220px}.Gifts{display:flex;justify-content:space-between;padding:15px;padding-left:-8px;padding-right:-8px;flex:0 0 45.1282051282%;flex-wrap:wrap;justify-content:flex-start;background:var(--emfe-w-color-white, #FFFFFF);color:var(--emfe-w-color-black-150, #000000);font-weight:500;gap:10px;margin-top:-100px;position:relative;min-height:200px}.InfoContainer{display:flex;margin-top:17px;justify-content:space-between}.Gift{display:block;margin-bottom:10px;padding:8px;box-shadow:0px 18px 45px 0px var(--emfe-w-color-black-150, #A7A7A733);border-radius:11px;background:var(--emfe-w-color-white, #FFFFFF)}.Gift .ImgContainer{width:160px;height:107px;border-radius:11px;box-shadow:0px 2px 6px 0px var(--emfe-w-color-black-200, #00000040);cursor:pointer;background-size:cover;background-position:center center;background-repeat:no-repeat}.Gift .Point{font-size:20px}.Gift .Title,.Gift .Description{padding-left:3px}.Gift .Title{font-size:14px;margin-top:10px}.Gift .Description{font-size:12px;color:var(--emfe-w-color-black-100, #767171)}.Gift .AvaliableWrap{align-self:self-end}.Gift .AvaliableWrap.active{cursor:pointer}.Gift .AvaliableWrap.deactive{cursor:not-allowed}.Gift .AvaliableWrap span svg{width:var(--emfe-w-elevate-avaliable-button-size, 46px)}";
179
+
180
+ const BonusElevateShop = class {
181
+ constructor(hostRef) {
182
+ registerInstance(this, hostRef);
183
+ /**
184
+ * Language of the widget
185
+ */
186
+ this.language = 'en';
187
+ /**
188
+ * Client custom styling via string
189
+ */
190
+ this.clientStyling = '';
191
+ /**
192
+ * Client custom styling via url
193
+ */
194
+ this.clientStylingUrl = '';
195
+ /**
196
+ * translation via url
197
+ */
198
+ this.translationUrl = '';
199
+ this.locale = translation['en'];
200
+ this.gifts = [];
201
+ }
202
+ async updateGifts() {
203
+ const res = await fetchNorwayApi.bind(this, '/v1/elevate/shop', {}).call();
204
+ this.gifts = res.data || [];
205
+ }
206
+ async redeemGift(id) {
207
+ if (!confirm('Are you sure to redeem this gift?'))
208
+ return;
209
+ const res = await fetchNorwayApi.bind(this, '/v1/elevate/redeem', {}, {
210
+ method: 'PUT',
211
+ body: JSON.stringify({ giftID: id }),
212
+ headers: {
213
+ 'Content-Type': 'application/json-patch+json',
214
+ }
215
+ }).call();
216
+ if (res.success) {
217
+ window.postMessage({ type: 'BEEGiftRedeem', itemId: id }, window.location.href);
218
+ }
219
+ }
220
+ render() {
221
+ return (h("main", { class: "MainContainer" }, h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: translation, translationUrl: this.translationUrl }), h("player-elevate-pointcard", { endpoint: this.endpoint, session: this.session, language: this.language, clientStylingUrl: this.clientStylingUrl, clientStyling: this.clientStyling, translationUrl: this.translationUrl }), renderGifts(this.gifts, this.locale, this.redeemGift.bind(this))));
222
+ }
223
+ async componentDidLoad() {
224
+ this.updateGifts();
225
+ }
226
+ static get assetsDirs() { return ["static"]; }
227
+ static get watchers() { return {
228
+ "endpoint": ["updateGifts"],
229
+ "language": ["updateGifts"],
230
+ "session": ["updateGifts"]
231
+ }; }
232
+ };
233
+ BonusElevateShop.style = bonusElevateShopCss;
234
+
235
+ const mergeTranslations = (url, target) => {
236
+ return new Promise((resolve) => {
237
+ fetch(url)
238
+ .then((res) => res.json())
239
+ .then((data) => {
240
+ Object.keys(data).forEach((item) => {
241
+ target[item] = target[item] ? target[item] : {};
242
+ for (let key in data[item]) {
243
+ target[item][key] = data[item][key];
244
+ }
245
+ });
246
+ resolve(true);
247
+ });
248
+ });
249
+ };
250
+
251
+ const generalStylingWrapperCss = ":host{display:block}";
252
+
253
+ const GeneralStylingWrapper = class {
254
+ constructor(hostRef) {
255
+ registerInstance(this, hostRef);
256
+ /**
257
+ * Client custom styling via inline styles
258
+ */
259
+ this.clientStyling = '';
260
+ /**
261
+ * Client custom styling via url
262
+ */
263
+ this.clientStylingUrl = '';
264
+ /**
265
+ * Translation via url
266
+ */
267
+ this.translationUrl = '';
268
+ this.stylingAppends = false;
269
+ this.setClientStyling = () => {
270
+ let sheet = document.createElement('style');
271
+ sheet.innerHTML = this.clientStyling;
272
+ this.el.prepend(sheet);
273
+ };
274
+ this.setClientStylingURL = () => {
275
+ let url = new URL(this.clientStylingUrl);
276
+ let cssFile = document.createElement('style');
277
+ fetch(url.href)
278
+ .then((res) => res.text())
279
+ .then((data) => {
280
+ cssFile.innerHTML = data;
281
+ setTimeout(() => {
282
+ this.el.prepend(cssFile);
283
+ }, 1);
284
+ })
285
+ .catch((err) => {
286
+ console.log('error ', err);
287
+ });
288
+ };
289
+ }
290
+ componentDidRender() {
291
+ // start custom styling area
292
+ if (!this.stylingAppends) {
293
+ if (this.clientStyling)
294
+ this.setClientStyling();
295
+ if (this.clientStylingUrl)
296
+ this.setClientStylingURL();
297
+ this.stylingAppends = true;
298
+ }
299
+ // end custom styling area
300
+ }
301
+ async componentWillLoad() {
302
+ const promises = [];
303
+ if (this.translationUrl) {
304
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
305
+ promises.push(translationPromise);
306
+ }
307
+ return await Promise.all(promises);
308
+ }
309
+ render() {
310
+ return (h("div", { class: "StyleShell" }, h("slot", { name: "mainContent" })));
311
+ }
312
+ get el() { return getElement(this); }
313
+ };
314
+ GeneralStylingWrapper.style = generalStylingWrapperCss;
315
+
316
+ /**
317
+ * @name startOfDay
318
+ * @category Day Helpers
319
+ * @summary Return the start of a day for the given date.
320
+ *
321
+ * @description
322
+ * Return the start of a day for the given date.
323
+ * The result will be in the local timezone.
324
+ *
325
+ * @param {Date|Number} date - the original date
326
+ * @returns {Date} the start of a day
327
+ * @throws {TypeError} 1 argument required
328
+ *
329
+ * @example
330
+ * // The start of a day for 2 September 2014 11:55:00:
331
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
332
+ * //=> Tue Sep 02 2014 00:00:00
333
+ */
334
+ function startOfDay(dirtyDate) {
335
+ requiredArgs(1, arguments);
336
+ var date = toDate(dirtyDate);
337
+ date.setHours(0, 0, 0, 0);
338
+ return date;
339
+ }
340
+
341
+ var MILLISECONDS_IN_DAY = 86400000;
342
+
343
+ /**
344
+ * @name differenceInCalendarDays
345
+ * @category Day Helpers
346
+ * @summary Get the number of calendar days between the given dates.
347
+ *
348
+ * @description
349
+ * Get the number of calendar days between the given dates. This means that the times are removed
350
+ * from the dates and then the difference in days is calculated.
351
+ *
352
+ * @param {Date|Number} dateLeft - the later date
353
+ * @param {Date|Number} dateRight - the earlier date
354
+ * @returns {Number} the number of calendar days
355
+ * @throws {TypeError} 2 arguments required
356
+ *
357
+ * @example
358
+ * // How many calendar days are between
359
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
360
+ * const result = differenceInCalendarDays(
361
+ * new Date(2012, 6, 2, 0, 0),
362
+ * new Date(2011, 6, 2, 23, 0)
363
+ * )
364
+ * //=> 366
365
+ * // How many calendar days are between
366
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
367
+ * const result = differenceInCalendarDays(
368
+ * new Date(2011, 6, 3, 0, 1),
369
+ * new Date(2011, 6, 2, 23, 59)
370
+ * )
371
+ * //=> 1
372
+ */
373
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
374
+ requiredArgs(2, arguments);
375
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
376
+ var startOfDayRight = startOfDay(dirtyDateRight);
377
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
378
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
379
+
380
+ // Round the number of days to the nearest integer
381
+ // because the number of milliseconds in a day is not constant
382
+ // (e.g. it's different in the day of the daylight saving time clock shift)
383
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
384
+ }
385
+
386
+ /**
387
+ * Days in 1 week.
388
+ *
389
+ * @name daysInWeek
390
+ * @constant
391
+ * @type {number}
392
+ * @default
393
+ */
394
+
395
+ /**
396
+ * Milliseconds in 1 hour
397
+ *
398
+ * @name millisecondsInHour
399
+ * @constant
400
+ * @type {number}
401
+ * @default
402
+ */
403
+ var millisecondsInHour = 3600000;
404
+
405
+ /**
406
+ * @name differenceInMilliseconds
407
+ * @category Millisecond Helpers
408
+ * @summary Get the number of milliseconds between the given dates.
409
+ *
410
+ * @description
411
+ * Get the number of milliseconds between the given dates.
412
+ *
413
+ * @param {Date|Number} dateLeft - the later date
414
+ * @param {Date|Number} dateRight - the earlier date
415
+ * @returns {Number} the number of milliseconds
416
+ * @throws {TypeError} 2 arguments required
417
+ *
418
+ * @example
419
+ * // How many milliseconds are between
420
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
421
+ * const result = differenceInMilliseconds(
422
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
423
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
424
+ * )
425
+ * //=> 1100
426
+ */
427
+ function differenceInMilliseconds(dateLeft, dateRight) {
428
+ requiredArgs(2, arguments);
429
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
430
+ }
431
+
432
+ var roundingMap = {
433
+ ceil: Math.ceil,
434
+ round: Math.round,
435
+ floor: Math.floor,
436
+ trunc: function trunc(value) {
437
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
438
+ } // Math.trunc is not supported by IE
439
+ };
440
+
441
+ var defaultRoundingMethod = 'trunc';
442
+ function getRoundingMethod(method) {
443
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
444
+ }
445
+
446
+ /**
447
+ * @name differenceInHours
448
+ * @category Hour Helpers
449
+ * @summary Get the number of hours between the given dates.
450
+ *
451
+ * @description
452
+ * Get the number of hours between the given dates.
453
+ *
454
+ * @param {Date|Number} dateLeft - the later date
455
+ * @param {Date|Number} dateRight - the earlier date
456
+ * @param {Object} [options] - an object with options.
457
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
458
+ * @returns {Number} the number of hours
459
+ * @throws {TypeError} 2 arguments required
460
+ *
461
+ * @example
462
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
463
+ * const result = differenceInHours(
464
+ * new Date(2014, 6, 2, 19, 0),
465
+ * new Date(2014, 6, 2, 6, 50)
466
+ * )
467
+ * //=> 12
468
+ */
469
+ function differenceInHours(dateLeft, dateRight, options) {
470
+ requiredArgs(2, arguments);
471
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
472
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
473
+ }
474
+
475
+ /**
476
+ * @name isBefore
477
+ * @category Common Helpers
478
+ * @summary Is the first date before the second one?
479
+ *
480
+ * @description
481
+ * Is the first date before the second one?
482
+ *
483
+ * @param {Date|Number} date - the date that should be before the other one to return true
484
+ * @param {Date|Number} dateToCompare - the date to compare with
485
+ * @returns {Boolean} the first date is before the second date
486
+ * @throws {TypeError} 2 arguments required
487
+ *
488
+ * @example
489
+ * // Is 10 July 1989 before 11 February 1987?
490
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
491
+ * //=> false
492
+ */
493
+ function isBefore(dirtyDate, dirtyDateToCompare) {
494
+ requiredArgs(2, arguments);
495
+ var date = toDate(dirtyDate);
496
+ var dateToCompare = toDate(dirtyDateToCompare);
497
+ return date.getTime() < dateToCompare.getTime();
498
+ }
499
+
500
+ function updateProgressSvg(progressElementRef, percent) {
501
+ const svgElement = progressElementRef.querySelector('#total_level');
502
+ const endLockWidth = 15;
503
+ const barWidth = svgElement.getBBox().width;
504
+ const widthOnBar = percent * barWidth - endLockWidth < 0 ? 0 : percent * barWidth - endLockWidth;
505
+ //update bar's width, widthOnBar
506
+ const levelBar = progressElementRef.querySelector('#current_level');
507
+ //update filters, x = widthOnBar
508
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
509
+ //update circle, widthOnBar+10
510
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
511
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
512
+ levelBar.setAttribute('width', `${widthOnBar}`);
513
+ levelCircle.setAttribute('cx', `${widthOnBar + 3}`);
514
+ levelFilter.setAttribute('x', `${widthOnBar - 4}`);
515
+ //update lock location
516
+ const endLockElement = progressElementRef.querySelector('#lock');
517
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
518
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
519
+ // ball in endlockfilter2_i_305_23
520
+ const filter2 = progressElementRef.querySelector('#filter_ball');
521
+ // heart in endlockfilter3_d_305_23
522
+ const filter3 = progressElementRef.querySelector('#filter_heart');
523
+ //wrapper of lockfilter4_d_305_23
524
+ const filterLock = progressElementRef.querySelector('#filter_lock');
525
+ // shadow of ball paint0_linear_305_23
526
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
527
+ //paint in lockpaint1_linear_305_23
528
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
529
+ // box of lock and heart, for move position dynamically
530
+ const lockBox = progressElementRef.querySelector('#lock_box');
531
+ const heartBox = progressElementRef.querySelector('#heart_box');
532
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
533
+ //set cx of lockElement
534
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
535
+ //set cx of sub Elements
536
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
537
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
538
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
539
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
540
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
541
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
542
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
543
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
544
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
545
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
546
+ }
547
+
548
+ 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}";
549
+
550
+ const PlayerElevateCardData = class {
551
+ constructor(hostRef) {
552
+ registerInstance(this, hostRef);
553
+ this.playerElevateLeveLoaded = createEvent(this, "playerElevateLeveLoaded", 7);
554
+ }
555
+ handleWindowResizs() {
556
+ this.initLevelProgressbar();
557
+ }
558
+ onRedeemClick() {
559
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
560
+ }
561
+ loadLevels() {
562
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
563
+ return new Promise((resolve, reject) => {
564
+ return fetch(url.href, {
565
+ method: 'GET',
566
+ })
567
+ .then((res) => res.json())
568
+ .then((res) => {
569
+ this.levels = res.data;
570
+ resolve(true);
571
+ })
572
+ .catch((err) => {
573
+ reject(err);
574
+ });
575
+ });
576
+ }
577
+ calcuatePointsToBeExpired(walletTotalInfo) {
578
+ let pointExpireInfoAsString = '';
579
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
580
+ walletTotalInfo.aboutToExpire.length == 0 ||
581
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
582
+ return pointExpireInfoAsString;
583
+ }
584
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
585
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
586
+ ? -1
587
+ : 1;
588
+ });
589
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
590
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
591
+ let hoursToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
592
+ if (daysToExpried == 0) {
593
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date());
594
+ expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
595
+ }
596
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
597
+ expirationPoints: aboutToExpire.points,
598
+ expireDay: daysToExpried,
599
+ });
600
+ return pointExpireInfoAsString;
601
+ }
602
+ loadPlayerLevelInfo() {
603
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
604
+ return new Promise((resolve, reject) => {
605
+ return fetch(url.href, {
606
+ method: 'GET',
607
+ headers: {
608
+ 'X-Sessionid': this.params.session,
609
+ 'Content-Type': 'application/json',
610
+ },
611
+ })
612
+ .then((res) => res.json())
613
+ .then((res) => {
614
+ var _a, _b, _c;
615
+ if (!res.success) {
616
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
617
+ reject(true);
618
+ return;
619
+ }
620
+ let playerElevateInfo = res.data;
621
+ this.playerElevateLevel = playerElevateInfo.level;
622
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
623
+ this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
624
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
625
+ const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
626
+ const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
627
+ this.playerElevateLeveLoaded.emit({
628
+ elevateLevelWalletTotal: spendableTotal,
629
+ loyaltyWalletTotal
630
+ });
631
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
632
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
633
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
634
+ this.playerElevateLeveLoaded.emit({
635
+ pointExpireString: spExpireInfoAsString,
636
+ xpExpireString: xpExpireInfoAsString
637
+ });
638
+ }
639
+ resolve(this.playerElevateLevel);
640
+ })
641
+ .catch((err) => {
642
+ console.log('error ', err);
643
+ reject(true);
644
+ });
645
+ });
646
+ }
647
+ setLoyaltyProgress(percent) {
648
+ updateProgressSvg(this.loyaltyProgressEle, percent);
649
+ }
650
+ initLevelProgressbar() {
651
+ setTimeout(() => {
652
+ this.loyaltyProgressEle =
653
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
654
+ if (!this.loyaltyProgressEle) {
655
+ return;
656
+ }
657
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
658
+ ? 1
659
+ : (this.playerElevateLevel.loyaltyPoints -
660
+ this.playerElevateLevel.entryPoints) /
661
+ (this.playerElevateLevel.nextLevel.entryPoints -
662
+ this.playerElevateLevel.loyaltyPoints));
663
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
664
+ }, 80);
665
+ }
666
+ componentWillRender() { }
667
+ componentDidRender() {
668
+ this.initLevelProgressbar();
669
+ }
670
+ componentWillLoad() {
671
+ if (!this.params.endpoint || !this.params.session) {
672
+ return;
673
+ }
674
+ const promises = [];
675
+ promises.push(this.loadPlayerLevelInfo());
676
+ if (this.params.calculateLevelFlag) {
677
+ promises.push(this.loadLevels());
678
+ }
679
+ Promise.all(promises).then((res) => {
680
+ console.log('elevate-init', res);
681
+ this.initLevelProgressbar();
682
+ if (!this.levels) {
683
+ return;
684
+ }
685
+ this.levels.sort((level1, level2) => {
686
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
687
+ });
688
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
689
+ let playerLevelNumber = 0;
690
+ this.levels.forEach((elevateLevel, idx) => {
691
+ if (playerPoints > elevateLevel.firstEntryPoints) {
692
+ playerLevelNumber = idx;
693
+ }
694
+ });
695
+ this.playerElevateLeveLoaded.emit({
696
+ calculatedLevelFlag: playerLevelNumber,
697
+ });
698
+ });
699
+ }
700
+ get elevateCardRef() { return getElement(this); }
701
+ };
702
+ PlayerElevateCardData.style = playerElevateCardDataCss;
703
+
704
+ 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}";
705
+
706
+ const PlayerElevatePointcard = class {
707
+ constructor(hostRef) {
708
+ registerInstance(this, hostRef);
709
+ /**
710
+ * The style that widget shows,available value: Dark, Light
711
+ * Default: Dark
712
+ */
713
+ this.theme = 'Dark';
714
+ /**
715
+ * Widget Language to show
716
+ */
717
+ this.language = 'en';
718
+ /**
719
+ * Check if the card used in points details widget, default: 'earningRule'
720
+ * value: 'details'/'earningRule'
721
+ * It effected the button in card
722
+ * 'earningRule': button text, 'earning rules', post 'BEEPointRulesClicked' when clicked
723
+ * 'details': button text, 'details', post 'BEEDetailsClicked' when clicked
724
+ */
725
+ this.buttonType = 'earningRule';
726
+ /**
727
+ * datePattern
728
+ */
729
+ this.dateFormat = 'yyyy-MM-dd';
730
+ /**
731
+ * Client custom styling via inline styles
732
+ */
733
+ this.clientStyling = '';
734
+ /**
735
+ * Client custom styling via url
736
+ */
737
+ this.clientStylingUrl = '';
738
+ /**
739
+ * Translation via url
740
+ */
741
+ this.translationUrl = '';
742
+ this.isPointDetailCard = this.buttonType === 'earningRule';
743
+ }
744
+ playerElevateLeveLoadedHandler(event) {
745
+ if (!event.detail) {
746
+ return;
747
+ }
748
+ if (event.detail['elevateLevelWalletTotal']) {
749
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
750
+ this.elevateSPTotal = event.detail['loyaltyWalletTotal'];
751
+ }
752
+ if (event.detail['elevateLevel']) {
753
+ this.playerElevateLevel = event.detail['elevateLevel'];
754
+ }
755
+ if (event.detail['pointExpireString']) {
756
+ this.pointExpireString = event.detail.pointExpireString;
757
+ }
758
+ }
759
+ onDetailsClick() {
760
+ window.postMessage({ type: this.isPointDetailCard ? 'BEEPointRulesClicked' : 'BEEDetailsClicked',
761
+ path: this.isPointDetailCard ? 'player-elevate-level' : 'player-elevate-point-details' }, window.location.href);
762
+ }
763
+ componentWillLoad() {
764
+ this.paramProxy = {
765
+ endpoint: this.endpoint,
766
+ session: this.session,
767
+ language: this.language,
768
+ };
769
+ }
770
+ render() {
771
+ const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
772
+ const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
773
+ 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, 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('spendablePoints')), h("div", { class: 'PointsTxt SPPoints' }, h(PlayerPoints, { spendablePoints: this.playerElevateLevel.spendablePoints, language: this.language }), h("a", { class: "TC", onClick: () => {
774
+ this.onDetailsClick();
775
+ } }, translate('termAndConditions', this.language))), this.pointExpireString && (h("div", { class: 'ExpirationPoints' }, this.pointExpireString, " "))))))))));
776
+ }
777
+ };
778
+ PlayerElevatePointcard.style = playerElevatePointcardCss;
779
+
780
+ export { BonusElevateShop as bonus_elevate_shop, GeneralStylingWrapper as general_styling_wrapper, PlayerElevateCardData as player_elevate_card_data, PlayerElevatePointcard as player_elevate_pointcard };