@everymatrix/casino-challenge-card 1.77.5 → 1.77.6

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 (31) hide show
  1. package/dist/casino-challenge-card/casino-challenge-card-f02ce133.js +1 -0
  2. package/dist/casino-challenge-card/casino-challenge-card.entry.js +1 -1
  3. package/dist/casino-challenge-card/casino-challenge-card.esm.js +1 -1
  4. package/dist/casino-challenge-card/index-98abeec4.js +2 -0
  5. package/dist/casino-challenge-card/index.esm.js +1 -1
  6. package/dist/cjs/casino-challenge-card-1f059b3e.js +505 -0
  7. package/dist/cjs/casino-challenge-card.cjs.entry.js +2 -2
  8. package/dist/cjs/casino-challenge-card.cjs.js +2 -2
  9. package/dist/cjs/{index-4b50b479.js → index-c337b778.js} +25 -1
  10. package/dist/cjs/index.cjs.js +2 -2
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/collection/assets/finish.svg +7 -0
  13. package/dist/collection/assets/trophy.svg +14 -0
  14. package/dist/collection/components/casino-challenge-card/casino-challenge-card.css +129 -5
  15. package/dist/collection/components/casino-challenge-card/casino-challenge-card.js +193 -14
  16. package/dist/collection/utils/locale.utils.js +35 -5
  17. package/dist/collection/utils/types.js +25 -5
  18. package/dist/esm/casino-challenge-card-f02ce133.js +503 -0
  19. package/dist/esm/casino-challenge-card.entry.js +2 -2
  20. package/dist/esm/casino-challenge-card.js +3 -3
  21. package/dist/esm/{index-d72835d2.js → index-98abeec4.js} +25 -1
  22. package/dist/esm/index.js +2 -2
  23. package/dist/esm/loader.js +3 -3
  24. package/dist/types/components/casino-challenge-card/casino-challenge-card.d.ts +26 -1
  25. package/dist/types/components.d.ts +32 -0
  26. package/dist/types/utils/types.d.ts +17 -7
  27. package/package.json +1 -1
  28. package/dist/casino-challenge-card/casino-challenge-card-1c0b899b.js +0 -1
  29. package/dist/casino-challenge-card/index-d72835d2.js +0 -2
  30. package/dist/cjs/casino-challenge-card-e1c638cc.js +0 -349
  31. package/dist/esm/casino-challenge-card-1c0b899b.js +0 -347
@@ -1,347 +0,0 @@
1
- import { r as registerInstance, c as createEvent, h } from './index-d72835d2.js';
2
-
3
- const DEFAULT_LANGUAGE = 'en';
4
- const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr'];
5
- const TRANSLATIONS = {
6
- en: {
7
- totalLevels: 'Total levels:',
8
- level1: 'Level 1:',
9
- get: 'Get:',
10
- endsIn: 'Ends In',
11
- expired: 'Expired',
12
- viewDetails: 'View details',
13
- placeBetsOf: 'Place bets of',
14
- place: 'Place',
15
- bet: 'bet',
16
- bets: 'bets',
17
- minBet: 'min bet'
18
- },
19
- ro: {
20
- totalLevels: 'Niveluri totale:',
21
- level1: 'Nivel 1:',
22
- get: 'Obține:',
23
- endsIn: 'Se termină în',
24
- expired: 'Expirat',
25
- viewDetails: 'Vezi detalii',
26
- placeBetsOf: 'Plasează pariuri de',
27
- place: 'Plasare',
28
- bet: 'pariu',
29
- bets: 'pariuri',
30
- minBet: 'pariu minim'
31
- },
32
- fr: {
33
- totalLevels: 'Niveaux totaux :',
34
- level1: 'Niveau 1 :',
35
- get: 'Obtenir :',
36
- endsIn: 'Se termine dans',
37
- expired: 'Expiré',
38
- viewDetails: 'Voir les détails',
39
- placeBetsOf: 'Placez des paris de',
40
- place: 'Placer',
41
- bet: 'pari',
42
- bets: 'paris',
43
- minBet: 'mise minimale'
44
- },
45
- ar: {
46
- totalLevels: 'إجمالي المستويات:',
47
- level1: 'المستوى 1:',
48
- get: 'احصل على:',
49
- endsIn: 'ينتهي في',
50
- expired: 'منتهي الصلاحية',
51
- viewDetails: 'عرض التفاصيل',
52
- placeBetsOf: 'قم بوضع رهانات بقيمة',
53
- place: 'ضع',
54
- bet: 'رهان',
55
- bets: 'رهانات',
56
- minBet: 'الحد الأدنى للرهان'
57
- },
58
- hr: {
59
- totalLevels: 'Ukupno razina:',
60
- level1: 'Razina 1:',
61
- get: 'Dobiti:',
62
- endsIn: 'Završava za',
63
- expired: 'Isteklo',
64
- viewDetails: 'Pogledaj detalje',
65
- placeBetsOf: 'Postavite oklade od',
66
- place: 'Postavi',
67
- bet: 'kladnja',
68
- bets: 'kladnje',
69
- minBet: 'minimalna oklada'
70
- }
71
- };
72
- const translate = (key, customLang) => {
73
- const lang = customLang;
74
- return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
75
- };
76
- const getTranslations = (data) => {
77
- Object.keys(data).forEach((item) => {
78
- for (let key in data[item]) {
79
- TRANSLATIONS[item][key] = data[item][key];
80
- }
81
- });
82
- };
83
- const resolveTranslationUrl = async (translationUrl) => {
84
- if (translationUrl) {
85
- try {
86
- const response = await fetch(translationUrl);
87
- if (!response.ok) {
88
- throw new Error(`HTTP error! status: ${response.status}`);
89
- }
90
- const translations = await response.json();
91
- getTranslations(translations);
92
- }
93
- catch (error) {
94
- console.error('Failed to fetch or parse translations from URL:', error);
95
- }
96
- }
97
- };
98
-
99
- var EChallengeLevelTargetType;
100
- (function (EChallengeLevelTargetType) {
101
- EChallengeLevelTargetType[EChallengeLevelTargetType["Accumulative"] = 0] = "Accumulative";
102
- EChallengeLevelTargetType[EChallengeLevelTargetType["SingleBet"] = 1] = "SingleBet";
103
- EChallengeLevelTargetType[EChallengeLevelTargetType["MultipleOneBetSize"] = 2] = "MultipleOneBetSize";
104
- })(EChallengeLevelTargetType || (EChallengeLevelTargetType = {}));
105
- var EChallengeRecurrenceType;
106
- (function (EChallengeRecurrenceType) {
107
- EChallengeRecurrenceType[EChallengeRecurrenceType["Single"] = 0] = "Single";
108
- EChallengeRecurrenceType[EChallengeRecurrenceType["Daily"] = 1] = "Daily";
109
- EChallengeRecurrenceType[EChallengeRecurrenceType["Weekly"] = 2] = "Weekly";
110
- EChallengeRecurrenceType[EChallengeRecurrenceType["Monthly"] = 3] = "Monthly";
111
- })(EChallengeRecurrenceType || (EChallengeRecurrenceType = {}));
112
- var EChallengeRewardType;
113
- (function (EChallengeRewardType) {
114
- EChallengeRewardType[EChallengeRewardType["FreeSpins"] = 0] = "FreeSpins";
115
- EChallengeRewardType[EChallengeRewardType["LuckyWheel"] = 1] = "LuckyWheel";
116
- EChallengeRewardType[EChallengeRewardType["Leaderboard"] = 2] = "Leaderboard";
117
- EChallengeRewardType[EChallengeRewardType["Challenge"] = 3] = "Challenge";
118
- EChallengeRewardType[EChallengeRewardType["Custom"] = 4] = "Custom";
119
- })(EChallengeRewardType || (EChallengeRewardType = {}));
120
- var EChallengeStatus;
121
- (function (EChallengeStatus) {
122
- EChallengeStatus[EChallengeStatus["Setup"] = 0] = "Setup";
123
- EChallengeStatus[EChallengeStatus["Active"] = 1] = "Active";
124
- EChallengeStatus[EChallengeStatus["Paused"] = 2] = "Paused";
125
- EChallengeStatus[EChallengeStatus["Closed"] = 3] = "Closed";
126
- EChallengeStatus[EChallengeStatus["Deleted"] = 4] = "Deleted";
127
- })(EChallengeStatus || (EChallengeStatus = {}));
128
- var EChallengeTriggerType;
129
- (function (EChallengeTriggerType) {
130
- EChallengeTriggerType[EChallengeTriggerType["GameLaunch"] = 0] = "GameLaunch";
131
- EChallengeTriggerType[EChallengeTriggerType["Reward"] = 1] = "Reward";
132
- EChallengeTriggerType[EChallengeTriggerType["Manual"] = 2] = "Manual";
133
- })(EChallengeTriggerType || (EChallengeTriggerType = {}));
134
- var EChallengeValidityType;
135
- (function (EChallengeValidityType) {
136
- EChallengeValidityType[EChallengeValidityType["Period"] = 0] = "Period";
137
- EChallengeValidityType[EChallengeValidityType["Date"] = 1] = "Date";
138
- })(EChallengeValidityType || (EChallengeValidityType = {}));
139
-
140
- function getTimeLeft(endTime) {
141
- const now = new Date();
142
- const end = new Date(endTime);
143
- let diff = end.getTime() - now.getTime();
144
- if (diff <= 0) {
145
- return;
146
- }
147
- const days = Math.floor(diff / (1000 * 60 * 60 * 24));
148
- diff -= days * (1000 * 60 * 60 * 24);
149
- const hours = Math.floor(diff / (1000 * 60 * 60));
150
- diff -= hours * (1000 * 60 * 60);
151
- const minutes = Math.floor(diff / (1000 * 60));
152
- diff -= minutes * (1000 * 60);
153
- const seconds = Math.floor(diff / 1000);
154
- const pad = (n) => n.toString().padStart(2, '0');
155
- return `${pad(days)} : ${pad(hours)} : ${pad(minutes)} : ${pad(seconds)}`;
156
- }
157
-
158
- /**
159
- * @name setClientStyling
160
- * @description Method used to create and append to the passed element of the widget a style element with the content received
161
- * @param {HTMLElement} stylingContainer The reference element of the widget
162
- * @param {string} clientStyling The style content
163
- */
164
- function setClientStyling(stylingContainer, clientStyling) {
165
- if (stylingContainer) {
166
- const sheet = document.createElement('style');
167
- sheet.innerHTML = clientStyling;
168
- stylingContainer.appendChild(sheet);
169
- }
170
- }
171
-
172
- /**
173
- * @name setClientStylingURL
174
- * @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
175
- * @param {HTMLElement} stylingContainer The reference element of the widget
176
- * @param {string} clientStylingUrl The URL of the style content
177
- */
178
- function setClientStylingURL(stylingContainer, clientStylingUrl) {
179
- const url = new URL(clientStylingUrl);
180
-
181
- fetch(url.href)
182
- .then((res) => res.text())
183
- .then((data) => {
184
- const cssFile = document.createElement('style');
185
- cssFile.innerHTML = data;
186
- if (stylingContainer) {
187
- stylingContainer.appendChild(cssFile);
188
- }
189
- })
190
- .catch((err) => {
191
- console.error('There was an error while trying to load client styling from URL', err);
192
- });
193
- }
194
-
195
- /**
196
- * @name setStreamLibrary
197
- * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
198
- * @param {HTMLElement} stylingContainer The highest element of the widget
199
- * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
200
- * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
201
- */
202
- function setStreamStyling(stylingContainer, domain, subscription) {
203
- if (window.emMessageBus) {
204
- const sheet = document.createElement('style');
205
-
206
- window.emMessageBus.subscribe(domain, (data) => {
207
- sheet.innerHTML = data;
208
- if (stylingContainer) {
209
- stylingContainer.appendChild(sheet);
210
- }
211
- });
212
- }
213
- }
214
-
215
- const casinoChallengeCardCss = ".card {\n width: 308px;\n border-radius: 16px;\n border: 2px solid var(--emw--button-border-color, rgba(221, 255, 207, 0.1019607843));\n background-color: var(--emw--color-background, #141515);\n box-sizing: border-box;\n position: relative;\n}\n@container challenge-list (max-width: 576px) {\n .card {\n width: 100%;\n }\n}\n.card:hover {\n background: linear-gradient(90deg, rgb(0, 62, 92) 0%, rgb(17, 59, 33) 100%);\n cursor: pointer;\n}\n.card__image {\n width: 100%;\n height: 200px;\n border-radius: 16px 16px 0 0;\n}\n@container challenge-list (max-width: 576px) {\n .card__image {\n height: 224px;\n }\n}\n.card__title {\n color: var(--emw--color-white, #FFFFFF);\n font-size: var(--emw--font-size-medium, 16px);\n margin: 0 0 10px;\n}\n.card__content {\n padding: 20px;\n}\n.card__button {\n margin-top: 20px;\n width: 100%;\n height: 34px;\n background: transparent;\n text-transform: uppercase;\n border-radius: var(--emw--button-border-radius, 99px);\n border: 2px solid var(--emw--button-border-color, #727672);\n font-size: var(--emw--font-size-x-small, 12px);\n font-weight: var(--emw--font-weight-bold, 700);\n color: var(--emw--color-secondary, #e9931e);\n}\n.card__button:hover {\n border-color: var(--emw--color-secondary, #e9931e);\n cursor: pointer;\n}\n.card__badge {\n position: absolute;\n background: white;\n top: 6px;\n right: 6px;\n border-radius: 30px;\n padding: 2px 12px;\n line-height: 22px;\n font-weight: var(--emw--font-weight-medium, 500);\n font-size: var(--emw--font-size-x-small, 12px);\n box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.25);\n backdrop-filter: blur(20px);\n}\n.card__badge span {\n font-weight: var(--emw--font-weight-bold, 700);\n}\n\n.info-item {\n line-height: 24px;\n font-size: var(--emw--font-size-small, 14px);\n font-weight: var(--emw--font-weight-bold, 700);\n color: var(--emw--color-primary, #1dbf51);\n}\n@container challenge-list (min-width: 576px) {\n .info-item {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n vertical-align: bottom;\n }\n}\n.info-item__label {\n font-weight: var(--emw--font-weight-medium, 500);\n margin-right: 3px;\n color: var(--emw--color-gray-150, #C8D6CE);\n}\n.info-item__tooltip {\n position: absolute;\n line-height: 22px;\n padding: 8px 12px;\n border-radius: 8px;\n opacity: 1;\n z-index: 200;\n white-space: nowrap;\n font-size: var(--emw--font-size-x-small, 12px);\n font-weight: var(--emw--font-weight-medium, 500);\n color: var(--emw--color-white, #FFFFFF);\n background-color: var(--emw--color-background-secondary, #1B1C2B);\n}\n.info-item__tooltip::before {\n content: \"\";\n position: absolute;\n top: -5px;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-bottom: 6px solid var(--emw--color-background-secondary, #1B1C2B);\n width: 0;\n height: 0;\n z-index: 201;\n}";
216
- const CasinoChallengeCardStyle0 = casinoChallengeCardCss;
217
-
218
- const CasinoChallengeCard = class {
219
- constructor(hostRef) {
220
- registerInstance(this, hostRef);
221
- this.timerExpired = createEvent(this, "timerExpired", 7);
222
- this.calculateTargetValue = (level, currencySymbol) => {
223
- var _a;
224
- if (!level)
225
- return '';
226
- const minbet = ((_a = level.BetRange) === null || _a === void 0 ? void 0 : _a.MinBet)
227
- ? `, ${translate('minBet', this.language)} ${currencySymbol + level.BetRange.MinBet}`
228
- : '';
229
- switch (level.LevelTargetType) {
230
- case EChallengeLevelTargetType.Accumulative:
231
- return `${translate('placeBetsOf', this.language)} ${currencySymbol + level.DisplayCurrencyTargetTurnover + minbet}`;
232
- case EChallengeLevelTargetType.SingleBet:
233
- return `${translate('place', this.language)} ${currencySymbol + level.TargetTurnover} ${translate('bet', this.language)}`;
234
- case EChallengeLevelTargetType.MultipleOneBetSize:
235
- return `${translate('place', this.language)} ${level.TargetBetCount} ${translate('bets', this.language) + minbet}`;
236
- }
237
- };
238
- this.onMouseEnterHandler = (index, el) => {
239
- if (el.scrollWidth > el.clientWidth) {
240
- this.tooltipIndex = index;
241
- }
242
- };
243
- this.onMouseLeaveHandler = () => {
244
- this.tooltipIndex = null;
245
- };
246
- this.mbSource = undefined;
247
- this.clientStyling = undefined;
248
- this.clientStylingUrl = undefined;
249
- this.translationUrl = '';
250
- this.language = 'en';
251
- this.challenge = undefined;
252
- this.tooltipIndex = null;
253
- this.timeLeft = undefined;
254
- }
255
- get infoItems() {
256
- var _a, _b, _c, _d;
257
- const level1 = (_a = this.challenge) === null || _a === void 0 ? void 0 : _a.LevelProgresses.find((x) => x.OrderNumber === 0);
258
- if (level1) {
259
- const rewardValue = (_b = level1.Rewards) === null || _b === void 0 ? void 0 : _b.slice(0, 2).map((r) => r.RewardDescription).join(' + ');
260
- return [
261
- {
262
- lable: translate('totalLevels', this.language),
263
- value: (_c = this.challenge.LevelProgresses) === null || _c === void 0 ? void 0 : _c.length
264
- },
265
- {
266
- lable: translate('level1', this.language),
267
- value: this.calculateTargetValue(level1, (_d = this.challenge) === null || _d === void 0 ? void 0 : _d.CurrencySymbol)
268
- },
269
- {
270
- lable: translate('get', this.language),
271
- value: rewardValue
272
- }
273
- ];
274
- }
275
- return [];
276
- }
277
- handleClientStylingChange(newValue, oldValue) {
278
- if (newValue != oldValue) {
279
- setClientStyling(this.stylingContainer, this.clientStyling);
280
- }
281
- }
282
- handleClientStylingUrlChange(newValue, oldValue) {
283
- if (newValue != oldValue) {
284
- setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
285
- }
286
- }
287
- handleMbSourceChange(newValue, oldValue) {
288
- if (newValue != oldValue) {
289
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
290
- }
291
- }
292
- connectedCallback() {
293
- this.timerId = setInterval(() => {
294
- this.updateTime();
295
- }, 1000);
296
- }
297
- componentWillLoad() {
298
- if (this.translationUrl) {
299
- resolveTranslationUrl(this.translationUrl);
300
- }
301
- this.updateTime();
302
- }
303
- componentDidLoad() {
304
- if (this.stylingContainer) {
305
- if (this.mbSource)
306
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
307
- if (this.clientStyling)
308
- setClientStyling(this.stylingContainer, this.clientStyling);
309
- if (this.clientStylingUrl)
310
- setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
311
- }
312
- }
313
- disconnectedCallback() {
314
- if (this.stylingSubscription) {
315
- this.stylingSubscription.unsubscribe();
316
- }
317
- clearInterval(this.timerId);
318
- }
319
- updateTime() {
320
- var _a;
321
- this.timeLeft = getTimeLeft((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.ExpirationTime);
322
- if (!this.timeLeft && this.timerExpired) {
323
- clearInterval(this.timerId);
324
- this.timerExpired.emit(this.challenge.Id);
325
- }
326
- }
327
- renderInfoItem(item, index) {
328
- return (h("div", { class: "info-item", onMouseEnter: (e) => this.onMouseEnterHandler(index, e.currentTarget), onMouseLeave: this.onMouseLeaveHandler }, h("span", { class: "info-item__label" }, item.lable), item.value, this.tooltipIndex === index && h("div", { class: "info-item__tooltip" }, item.value)));
329
- }
330
- renderCardBadge() {
331
- return (h("div", { class: "card__badge" }, this.timeLeft
332
- ? [translate('endsIn', this.language), ' - ', h("span", null, this.timeLeft)]
333
- : translate('expired', this.language)));
334
- }
335
- render() {
336
- var _a, _b, _c, _d;
337
- return (h("div", { key: '5df3a2d368e6057d1b47cf5d4766126406c4afc8', ref: (el) => (this.stylingContainer = el) }, h("div", { key: 'de708f82c0fbe5324419fafcb395f115c020d021', class: "card" }, h("img", { key: '209c1f05bb70c3182b4ff6211e7c9398999b30fc', class: "card__image", src: (_b = (_a = this.challenge) === null || _a === void 0 ? void 0 : _a.ChallengePresentation) === null || _b === void 0 ? void 0 : _b.Url }), this.renderCardBadge(), h("div", { key: 'aa3a5f3eee8bdb7c2606bc8a232c441ff4a22006', class: "card__content" }, h("h1", { key: '524933e67d8eac476d678aee9f2643b6ac1449ff', class: "card__title" }, (_d = (_c = this.challenge) === null || _c === void 0 ? void 0 : _c.ChallengePresentation) === null || _d === void 0 ? void 0 : _d.PresentationName), this.infoItems.map((x, index) => this.renderInfoItem(x, index)), h("button", { key: '52fec7d22602a2757c1a36238fb0b797f6bb4306', class: "card__button" }, translate('viewDetails', this.language))))));
338
- }
339
- static get watchers() { return {
340
- "clientStyling": ["handleClientStylingChange"],
341
- "clientStylingUrl": ["handleClientStylingUrlChange"],
342
- "mbSource": ["handleMbSourceChange"]
343
- }; }
344
- };
345
- CasinoChallengeCard.style = CasinoChallengeCardStyle0;
346
-
347
- export { CasinoChallengeCard as C };