@everymatrix/casino-challenge-card 0.0.1

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 (58) hide show
  1. package/dist/casino-challenge-card/app-globals-0f993ce5.js +1 -0
  2. package/dist/casino-challenge-card/casino-challenge-card-cf383ea4.js +1 -0
  3. package/dist/casino-challenge-card/casino-challenge-card.entry.js +1 -0
  4. package/dist/casino-challenge-card/casino-challenge-card.esm.js +1 -0
  5. package/dist/casino-challenge-card/index-fae081c3.js +2 -0
  6. package/dist/casino-challenge-card/index.esm.js +1 -0
  7. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  8. package/dist/cjs/casino-challenge-card-c10f3b5d.js +286 -0
  9. package/dist/cjs/casino-challenge-card.cjs.entry.js +10 -0
  10. package/dist/cjs/casino-challenge-card.cjs.js +25 -0
  11. package/dist/cjs/index-062e337e.js +1203 -0
  12. package/dist/cjs/index.cjs.js +10 -0
  13. package/dist/cjs/loader.cjs.js +15 -0
  14. package/dist/collection/collection-manifest.json +12 -0
  15. package/dist/collection/components/casino-challenge-card/casino-challenge-card.css +113 -0
  16. package/dist/collection/components/casino-challenge-card/casino-challenge-card.js +250 -0
  17. package/dist/collection/components/casino-challenge-card/index.js +1 -0
  18. package/dist/collection/index.js +1 -0
  19. package/dist/collection/utils/locale.utils.js +90 -0
  20. package/dist/collection/utils/types.js +40 -0
  21. package/dist/collection/utils/utils.js +20 -0
  22. package/dist/esm/app-globals-0f993ce5.js +3 -0
  23. package/dist/esm/casino-challenge-card-cf383ea4.js +284 -0
  24. package/dist/esm/casino-challenge-card.entry.js +2 -0
  25. package/dist/esm/casino-challenge-card.js +20 -0
  26. package/dist/esm/index-fae081c3.js +1177 -0
  27. package/dist/esm/index.js +2 -0
  28. package/dist/esm/loader.js +11 -0
  29. package/dist/index.cjs.js +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/stencil.config.dev.js +19 -0
  32. package/dist/stencil.config.js +19 -0
  33. package/dist/storybook/main.js +43 -0
  34. package/dist/storybook/preview.js +9 -0
  35. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  36. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/packages/stencil/casino-challenge-card/stencil.config.d.ts +2 -0
  37. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/packages/stencil/casino-challenge-card/stencil.config.dev.d.ts +2 -0
  38. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/packages/stencil/casino-challenge-card/storybook/main.d.ts +3 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/packages/stencil/casino-challenge-card/storybook/preview.d.ts +70 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/tools/plugins/index.d.ts +3 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-card/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  44. package/dist/types/components/casino-challenge-card/casino-challenge-card.d.ts +47 -0
  45. package/dist/types/components/casino-challenge-card/index.d.ts +1 -0
  46. package/dist/types/components.d.ts +87 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  49. package/dist/types/utils/locale.utils.d.ts +3 -0
  50. package/dist/types/utils/types.d.ts +124 -0
  51. package/dist/types/utils/utils.d.ts +2 -0
  52. package/loader/cdn.js +1 -0
  53. package/loader/index.cjs.js +1 -0
  54. package/loader/index.d.ts +24 -0
  55. package/loader/index.es2017.js +1 -0
  56. package/loader/index.js +2 -0
  57. package/loader/package.json +11 -0
  58. package/package.json +27 -0
@@ -0,0 +1,284 @@
1
+ import { r as registerInstance, h } from './index-fae081c3.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
+ },
18
+ ro: {
19
+ totalLevels: 'Niveluri totale:',
20
+ level1: 'Nivel 1:',
21
+ get: 'Obține:',
22
+ endsIn: 'Se termină în',
23
+ expired: 'Expirat',
24
+ viewDetails: 'Vezi detalii',
25
+ placeBetsOf: 'Plasează pariuri de',
26
+ place: 'Plasare',
27
+ bet: 'pariu',
28
+ bets: 'pariuri'
29
+ },
30
+ fr: {
31
+ totalLevels: 'Niveaux totaux :',
32
+ level1: 'Niveau 1 :',
33
+ get: 'Obtenir :',
34
+ endsIn: 'Se termine dans',
35
+ expired: 'Expiré',
36
+ viewDetails: 'Voir les détails',
37
+ placeBetsOf: 'Placez des paris de',
38
+ place: 'Placer',
39
+ bet: 'pari',
40
+ bets: 'paris'
41
+ },
42
+ ar: {
43
+ totalLevels: 'إجمالي المستويات:',
44
+ level1: 'المستوى 1:',
45
+ get: 'احصل على:',
46
+ endsIn: 'ينتهي في',
47
+ expired: 'منتهي الصلاحية',
48
+ viewDetails: 'عرض التفاصيل',
49
+ placeBetsOf: 'قم بوضع رهانات بقيمة',
50
+ place: 'ضع',
51
+ bet: 'رهان',
52
+ bets: 'رهانات'
53
+ },
54
+ hr: {
55
+ totalLevels: 'Ukupno razina:',
56
+ level1: 'Razina 1:',
57
+ get: 'Dobiti:',
58
+ endsIn: 'Završava za',
59
+ expired: 'Isteklo',
60
+ viewDetails: 'Pogledaj detalje',
61
+ placeBetsOf: 'Postavite oklade od',
62
+ place: 'Postavi',
63
+ bet: 'kladnja',
64
+ bets: 'kladnje'
65
+ }
66
+ };
67
+ const translate = (key, customLang) => {
68
+ const lang = customLang;
69
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
70
+ };
71
+ const getTranslations = (data) => {
72
+ Object.keys(data).forEach((item) => {
73
+ for (let key in data[item]) {
74
+ TRANSLATIONS[item][key] = data[item][key];
75
+ }
76
+ });
77
+ };
78
+ const resolveTranslationUrl = async (translationUrl) => {
79
+ if (translationUrl) {
80
+ try {
81
+ const response = await fetch(translationUrl);
82
+ if (!response.ok) {
83
+ throw new Error(`HTTP error! status: ${response.status}`);
84
+ }
85
+ const translations = await response.json();
86
+ getTranslations(translations);
87
+ }
88
+ catch (error) {
89
+ console.error('Failed to fetch or parse translations from URL:', error);
90
+ }
91
+ }
92
+ };
93
+
94
+ function getTimeLeft(endTime) {
95
+ const now = new Date();
96
+ const end = new Date(endTime);
97
+ let diff = end.getTime() - now.getTime();
98
+ if (diff <= 0) {
99
+ return;
100
+ }
101
+ const days = Math.floor(diff / (1000 * 60 * 60 * 24));
102
+ diff -= days * (1000 * 60 * 60 * 24);
103
+ const hours = Math.floor(diff / (1000 * 60 * 60));
104
+ diff -= hours * (1000 * 60 * 60);
105
+ const minutes = Math.floor(diff / (1000 * 60));
106
+ diff -= minutes * (1000 * 60);
107
+ const seconds = Math.floor(diff / 1000);
108
+ const pad = (n) => n.toString().padStart(2, '0');
109
+ return `${pad(days)} : ${pad(hours)} : ${pad(minutes)} : ${pad(seconds)}`;
110
+ }
111
+
112
+ /**
113
+ * @name setClientStyling
114
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
115
+ * @param {HTMLElement} stylingContainer The reference element of the widget
116
+ * @param {string} clientStyling The style content
117
+ */
118
+ function setClientStyling(stylingContainer, clientStyling) {
119
+ if (stylingContainer) {
120
+ const sheet = document.createElement('style');
121
+ sheet.innerHTML = clientStyling;
122
+ stylingContainer.appendChild(sheet);
123
+ }
124
+ }
125
+
126
+ /**
127
+ * @name setClientStylingURL
128
+ * @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
129
+ * @param {HTMLElement} stylingContainer The reference element of the widget
130
+ * @param {string} clientStylingUrl The URL of the style content
131
+ */
132
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
133
+ const url = new URL(clientStylingUrl);
134
+
135
+ fetch(url.href)
136
+ .then((res) => res.text())
137
+ .then((data) => {
138
+ const cssFile = document.createElement('style');
139
+ cssFile.innerHTML = data;
140
+ if (stylingContainer) {
141
+ stylingContainer.appendChild(cssFile);
142
+ }
143
+ })
144
+ .catch((err) => {
145
+ console.error('There was an error while trying to load client styling from URL', err);
146
+ });
147
+ }
148
+
149
+ /**
150
+ * @name setStreamLibrary
151
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
152
+ * @param {HTMLElement} stylingContainer The highest element of the widget
153
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
154
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
155
+ */
156
+ function setStreamStyling(stylingContainer, domain, subscription) {
157
+ if (window.emMessageBus) {
158
+ const sheet = document.createElement('style');
159
+
160
+ window.emMessageBus.subscribe(domain, (data) => {
161
+ sheet.innerHTML = data;
162
+ if (stylingContainer) {
163
+ stylingContainer.appendChild(sheet);
164
+ }
165
+ });
166
+ }
167
+ }
168
+
169
+ 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}";
170
+ const CasinoChallengeCardStyle0 = casinoChallengeCardCss;
171
+
172
+ const CasinoChallengeCard = class {
173
+ constructor(hostRef) {
174
+ registerInstance(this, hostRef);
175
+ this.defaultLanguage = 'en';
176
+ this.onMouseEnterHandler = (index, el) => {
177
+ if (el.scrollWidth > el.clientWidth) {
178
+ this.tooltipIndex = index;
179
+ }
180
+ };
181
+ this.onMouseLeaveHandler = () => {
182
+ this.tooltipIndex = null;
183
+ };
184
+ this.mbSource = undefined;
185
+ this.clientStyling = undefined;
186
+ this.clientStylingUrl = undefined;
187
+ this.translationUrl = '';
188
+ this.language = 'en';
189
+ this.challenge = undefined;
190
+ this.tooltipIndex = null;
191
+ this.timeLeft = undefined;
192
+ }
193
+ get infoItems() {
194
+ const level1 = this.challenge.ChallengeLevels[0];
195
+ const target = level1.Target;
196
+ const targetValue = target.TargetType === 0
197
+ ? `${translate('placeBetsOf', this.language)} ${target.Turnover}`
198
+ : target.TargetType === 1
199
+ ? `${translate('place', this.language)} ${target.Turnover} ${translate('bet', this.language)}`
200
+ : `${translate('place', this.language)} ${target.BetCount} ${translate('bets', this.language)}`;
201
+ const rewardValue = level1.Rewards.map((r) => r.RewardDescription).join(' + ');
202
+ return [
203
+ {
204
+ lable: translate('totalLevels', this.language),
205
+ value: this.challenge.ChallengeLevels.length
206
+ },
207
+ {
208
+ lable: translate('level1', this.language),
209
+ value: targetValue
210
+ },
211
+ {
212
+ lable: translate('get', this.language),
213
+ value: rewardValue
214
+ }
215
+ ];
216
+ }
217
+ handleClientStylingChange(newValue, oldValue) {
218
+ if (newValue != oldValue) {
219
+ setClientStyling(this.stylingContainer, this.clientStyling);
220
+ }
221
+ }
222
+ handleClientStylingUrlChange(newValue, oldValue) {
223
+ if (newValue != oldValue) {
224
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
225
+ }
226
+ }
227
+ handleMbSourceChange(newValue, oldValue) {
228
+ if (newValue != oldValue) {
229
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
230
+ }
231
+ }
232
+ connectedCallback() {
233
+ this.timerId = setInterval(() => {
234
+ this.updateTime();
235
+ }, 1000);
236
+ }
237
+ componentWillLoad() {
238
+ if (this.translationUrl) {
239
+ resolveTranslationUrl(this.translationUrl);
240
+ }
241
+ this.updateTime();
242
+ }
243
+ componentDidLoad() {
244
+ if (this.stylingContainer) {
245
+ if (this.mbSource)
246
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
247
+ if (this.clientStyling)
248
+ setClientStyling(this.stylingContainer, this.clientStyling);
249
+ if (this.clientStylingUrl)
250
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
251
+ }
252
+ }
253
+ disconnectedCallback() {
254
+ if (this.stylingSubscription) {
255
+ this.stylingSubscription.unsubscribe();
256
+ }
257
+ clearInterval(this.timerId);
258
+ }
259
+ updateTime() {
260
+ var _a;
261
+ this.timeLeft = getTimeLeft((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.ChallengeEndTime);
262
+ }
263
+ renderInfoItem(item, index) {
264
+ 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)));
265
+ }
266
+ renderCardBadge() {
267
+ return (h("div", { class: "card__badge" }, this.timeLeft
268
+ ? [translate('endsIn', this.language), ' - ', h("span", null, this.timeLeft)]
269
+ : translate('expired', this.language)));
270
+ }
271
+ render() {
272
+ return (h("div", { key: 'ddbd3e0d20b4d75ed70120798c45d7c03715b7df', ref: (el) => (this.stylingContainer = el) }, h("div", { key: '3ca0c4b6ad25b4f60077b894bf73c9686f67a677', class: "card" }, h("img", { key: '1712546c27e75e04bde5832c521038bfd418e57f', class: "card__image", src: this.challenge.ChallengePresentations[this.language].Url ||
273
+ this.challenge.ChallengePresentations[this.defaultLanguage].Url }), this.renderCardBadge(), h("div", { key: '238041db616391c2594bef46778649b8b6282097', class: "card__content" }, h("h1", { key: 'd377b99c7758460df8b1a6e8e39059959347430f', class: "card__title" }, this.challenge.ChallengePresentations[this.language].PresentationName ||
274
+ this.challenge.ChallengePresentations[this.defaultLanguage].PresentationName), this.infoItems.map((x, index) => this.renderInfoItem(x, index)), h("button", { key: 'b53707ce7881cbf16321e3d3728a0e769af6589a', class: "card__button" }, translate('viewDetails', this.language))))));
275
+ }
276
+ static get watchers() { return {
277
+ "clientStyling": ["handleClientStylingChange"],
278
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
279
+ "mbSource": ["handleMbSourceChange"]
280
+ }; }
281
+ };
282
+ CasinoChallengeCard.style = CasinoChallengeCardStyle0;
283
+
284
+ export { CasinoChallengeCard as C };
@@ -0,0 +1,2 @@
1
+ export { C as casino_challenge_card } from './casino-challenge-card-cf383ea4.js';
2
+ import './index-fae081c3.js';
@@ -0,0 +1,20 @@
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-fae081c3.js';
2
+ export { s as setNonce } from './index-fae081c3.js';
3
+ import { g as globalScripts } from './app-globals-0f993ce5.js';
4
+
5
+ /*
6
+ Stencil Client Patch Browser v4.19.2 | MIT Licensed | https://stenciljs.com
7
+ */
8
+ var patchBrowser = () => {
9
+ const importMeta = import.meta.url;
10
+ const opts = {};
11
+ if (importMeta !== "") {
12
+ opts.resourcesUrl = new URL(".", importMeta).href;
13
+ }
14
+ return promiseResolve(opts);
15
+ };
16
+
17
+ patchBrowser().then(async (options) => {
18
+ await globalScripts();
19
+ return bootstrapLazy([["casino-challenge-card",[[1,"casino-challenge-card",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"language":[513],"challenge":[16],"tooltipIndex":[32],"timeLeft":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
20
+ });