@everymatrix/casino-challenges-claim-code 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 (59) hide show
  1. package/dist/casino-challenges-claim-code/app-globals-0f993ce5.js +1 -0
  2. package/dist/casino-challenges-claim-code/casino-challenges-claim-code-746b4197.js +1 -0
  3. package/dist/casino-challenges-claim-code/casino-challenges-claim-code.entry.js +1 -0
  4. package/dist/casino-challenges-claim-code/casino-challenges-claim-code.esm.js +1 -0
  5. package/dist/casino-challenges-claim-code/index-05d7637d.js +2 -0
  6. package/dist/casino-challenges-claim-code/index.esm.js +1 -0
  7. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  8. package/dist/cjs/casino-challenges-claim-code-a4324416.js +214 -0
  9. package/dist/cjs/casino-challenges-claim-code.cjs.entry.js +10 -0
  10. package/dist/cjs/casino-challenges-claim-code.cjs.js +25 -0
  11. package/dist/cjs/index-718e2d1c.js +1214 -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-challenges-claim-code/casino-challenges-claim-code.css +81 -0
  16. package/dist/collection/components/casino-challenges-claim-code/casino-challenges-claim-code.js +300 -0
  17. package/dist/collection/components/casino-challenges-claim-code/index.js +1 -0
  18. package/dist/collection/index.js +1 -0
  19. package/dist/collection/utils/locale.utils.js +43 -0
  20. package/dist/collection/utils/types.js +1 -0
  21. package/dist/collection/utils/utils.js +3 -0
  22. package/dist/esm/app-globals-0f993ce5.js +3 -0
  23. package/dist/esm/casino-challenges-claim-code-746b4197.js +212 -0
  24. package/dist/esm/casino-challenges-claim-code.entry.js +2 -0
  25. package/dist/esm/casino-challenges-claim-code.js +20 -0
  26. package/dist/esm/index-05d7637d.js +1187 -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-challenges-claim-code/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  36. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/packages/stencil/casino-challenges-claim-code/stencil.config.d.ts +2 -0
  37. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/packages/stencil/casino-challenges-claim-code/stencil.config.dev.d.ts +2 -0
  38. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/packages/stencil/casino-challenges-claim-code/storybook/main.d.ts +3 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/packages/stencil/casino-challenges-claim-code/storybook/preview.d.ts +70 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/tools/plugins/index.d.ts +4 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  44. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenges-claim-code/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  45. package/dist/types/components/casino-challenges-claim-code/casino-challenges-claim-code.d.ts +56 -0
  46. package/dist/types/components/casino-challenges-claim-code/index.d.ts +1 -0
  47. package/dist/types/components.d.ts +119 -0
  48. package/dist/types/index.d.ts +1 -0
  49. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  50. package/dist/types/utils/locale.utils.d.ts +3 -0
  51. package/dist/types/utils/types.d.ts +15 -0
  52. package/dist/types/utils/utils.d.ts +1 -0
  53. package/loader/cdn.js +1 -0
  54. package/loader/index.cjs.js +1 -0
  55. package/loader/index.d.ts +24 -0
  56. package/loader/index.es2017.js +1 -0
  57. package/loader/index.js +2 -0
  58. package/loader/package.json +11 -0
  59. package/package.json +27 -0
@@ -0,0 +1,212 @@
1
+ import { r as registerInstance, c as createEvent, h } from './index-05d7637d.js';
2
+
3
+ /**
4
+ * @name setClientStyling
5
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
6
+ * @param {HTMLElement} stylingContainer The reference element of the widget
7
+ * @param {string} clientStyling The style content
8
+ */
9
+ function setClientStyling(stylingContainer, clientStyling) {
10
+ if (stylingContainer) {
11
+ const sheet = document.createElement('style');
12
+ sheet.innerHTML = clientStyling;
13
+ stylingContainer.appendChild(sheet);
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @name setClientStylingURL
19
+ * @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
20
+ * @param {HTMLElement} stylingContainer The reference element of the widget
21
+ * @param {string} clientStylingUrl The URL of the style content
22
+ */
23
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
24
+ const url = new URL(clientStylingUrl);
25
+
26
+ fetch(url.href)
27
+ .then((res) => res.text())
28
+ .then((data) => {
29
+ const cssFile = document.createElement('style');
30
+ cssFile.innerHTML = data;
31
+ if (stylingContainer) {
32
+ stylingContainer.appendChild(cssFile);
33
+ }
34
+ })
35
+ .catch((err) => {
36
+ console.error('There was an error while trying to load client styling from URL', err);
37
+ });
38
+ }
39
+
40
+ /**
41
+ * @name setStreamLibrary
42
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
43
+ * @param {HTMLElement} stylingContainer The highest element of the widget
44
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
45
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
46
+ */
47
+ function setStreamStyling(stylingContainer, domain, subscription) {
48
+ if (window.emMessageBus) {
49
+ const sheet = document.createElement('style');
50
+
51
+ window.emMessageBus.subscribe(domain, (data) => {
52
+ sheet.innerHTML = data;
53
+ if (stylingContainer) {
54
+ stylingContainer.appendChild(sheet);
55
+ }
56
+ });
57
+ }
58
+ }
59
+
60
+ const DEFAULT_LANGUAGE = 'en';
61
+ const TRANSLATIONS = {
62
+ en: {
63
+ title: 'Enter the secret code to unlock hidden quests and rewards.',
64
+ btnText: 'Apply code',
65
+ successMessage: 'The code was successfully applied.',
66
+ inputLabel: '3–30 characters, no spaces',
67
+ lengthMinError: 'Code must be at least 3 characters',
68
+ lengthMaxError: 'Too long — max 30 characters',
69
+ formatError: 'Invalid code format. Please use only Latin letters (case-sensitive), numbers, and special characters.',
70
+ genericError: 'Something went wrong, please retry'
71
+ },
72
+ ro: {},
73
+ fr: {},
74
+ ar: {},
75
+ hr: {}
76
+ };
77
+ const translate = (key, customLang) => {
78
+ const lang = customLang;
79
+ return TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key];
80
+ };
81
+ const getTranslations = (data) => {
82
+ Object.keys(data).forEach((item) => {
83
+ for (let key in data[item]) {
84
+ TRANSLATIONS[item][key] = data[item][key];
85
+ }
86
+ });
87
+ };
88
+ const resolveTranslationUrl = async (translationUrl) => {
89
+ if (translationUrl) {
90
+ try {
91
+ const response = await fetch(translationUrl);
92
+ if (!response.ok) {
93
+ throw new Error(`HTTP error! status: ${response.status}`);
94
+ }
95
+ const translations = await response.json();
96
+ getTranslations(translations);
97
+ }
98
+ catch (error) {
99
+ console.error('Failed to fetch or parse translations from URL:', error);
100
+ }
101
+ }
102
+ };
103
+
104
+ const casinoChallengesClaimCodeCss = ".container {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: 80px 0;\n text-align: center;\n}\n.container__title {\n font-size: var(--emw--font-size-medium-plus, 18px);\n font-weight: var(--emw--font-weight-medium, 500);\n line-height: 22px;\n color: var(--emw--color-white, white);\n margin: 0 0 32px;\n}\n.container__button {\n margin-top: 45px;\n padding: 14px 20px;\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, #083B17);\n font-size: var(--emw--font-size-x-small, 12px);\n font-weight: var(--emw--font-weight-bold, 700);\n color: var(--emw--color-white, #FFFFFF);\n background-color: var(--emw--button-background-color, #18CE51);\n cursor: pointer;\n}\n.container__button:hover {\n color: var(--emw--color-gray-300, #083B17);\n border-color: transparent;\n box-shadow: 0 0 4px 0 rgba(188, 252, 177, 0.2), 0 0 20px 0 rgba(0, 183, 79, 0.5);\n}\n.container__button:disabled, .container__button:disabled:hover {\n color: var(--emw--color-gray-50, #E2E2E2);\n border: 2px solid var(--emw--button-border-color, #083B17);\n opacity: 0.7;\n cursor: not-allowed;\n}\n@container challenges-container (max-width: 576px) {\n .container__button {\n width: calc(100% - 32px);\n position: absolute;\n bottom: 50px;\n }\n}\n\n.code-input {\n border: 1px solid var(--emw--button-border-color, #083B17);\n background: var(--emw--color-background-secondary, rgba(221, 255, 207, 0.1019607843));\n border-radius: 6px;\n padding: 12px 0;\n line-height: 24px;\n color: var(--emw--color-white, #FFFFFF);\n text-align: center;\n font-size: var(--emw--font-size-medium, 16px);\n min-width: 340px;\n}\n.code-input:focus {\n outline: 1px solid var(--emw--border-success-color, #00B74F);\n}\n.code-input:focus.errored {\n outline-color: var(--emw--color-error, #D6421E);\n}\n.code-input.errored {\n border-color: var(--emw--color-error, #D6421E);\n}\n.code-input__text {\n margin: 8px 0 0;\n line-height: 22px;\n font-size: var(--emw--font-size-x-small, 12px);\n font-weight: var(--emw--font-weight-medium, 500);\n color: var(--emw--color-gray-150, #C8D6CE);\n}\n.code-input__text.errored {\n color: var(--emw--color-error, #D6421E);\n}\n@container challenges-container (max-width: 576px) {\n .code-input {\n min-width: 100%;\n }\n}";
105
+ const CasinoChallengesClaimCodeStyle0 = casinoChallengesClaimCodeCss;
106
+
107
+ const CasinoChallengesClaimCode = class {
108
+ constructor(hostRef) {
109
+ registerInstance(this, hostRef);
110
+ this.openNotification = createEvent(this, "openNotification", 7);
111
+ this.asciiPrintableRegex = /^[\x21-\x7E]+$/;
112
+ this.handleSubmit = async () => {
113
+ if (this.endpoint && this.session && this.domain) {
114
+ const response = await this.applyCode();
115
+ if (response.Success) {
116
+ this.openNotification.emit({ message: translate('successMessage', this.language) });
117
+ }
118
+ else {
119
+ this.hasError = true;
120
+ const showTabLink = response.ErrorCode === 3002 || response.ErrorCode === 3023 || response.ErrorCode === 3003;
121
+ this.openNotification.emit({ message: response.ErrorMessage, errored: true, showTabLink });
122
+ }
123
+ }
124
+ };
125
+ this.applyCode = async () => {
126
+ this.loading = true;
127
+ const url = `${this.endpoint}/challenge/GrantChallengeByCode`;
128
+ const body = {
129
+ DomainId: this.domain,
130
+ PlayerSessionId: this.session,
131
+ ActivationCode: this.code
132
+ };
133
+ return fetch(url, {
134
+ method: 'POST',
135
+ headers: {
136
+ 'Content-Type': 'application/json'
137
+ },
138
+ body: JSON.stringify(body)
139
+ })
140
+ .then((res) => res.json())
141
+ .finally(() => (this.loading = false));
142
+ };
143
+ this.handleInput = (event) => {
144
+ this.code = event.target.value;
145
+ if (this.debounceTime) {
146
+ clearTimeout(this.debounceTime);
147
+ }
148
+ this.debounceTime = setTimeout(() => {
149
+ this.hasError = !this.validate(this.code);
150
+ }, 200);
151
+ };
152
+ this.mbSource = undefined;
153
+ this.clientStyling = undefined;
154
+ this.clientStylingUrl = undefined;
155
+ this.translationUrl = '';
156
+ this.language = 'en';
157
+ this.endpoint = '';
158
+ this.domain = '';
159
+ this.session = '';
160
+ this.loading = false;
161
+ this.hasError = false;
162
+ this.code = '';
163
+ this.notificationMessage = '';
164
+ }
165
+ handleClientStylingChange(newValue, oldValue) {
166
+ if (newValue != oldValue) {
167
+ setClientStyling(this.stylingContainer, this.clientStyling);
168
+ }
169
+ }
170
+ handleClientStylingUrlChange(newValue, oldValue) {
171
+ if (newValue != oldValue) {
172
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
173
+ }
174
+ }
175
+ handleMbSourceChange(newValue, oldValue) {
176
+ if (newValue != oldValue) {
177
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
178
+ }
179
+ }
180
+ componentWillLoad() {
181
+ if (this.translationUrl) {
182
+ resolveTranslationUrl(this.translationUrl);
183
+ }
184
+ }
185
+ componentDidLoad() {
186
+ if (this.stylingContainer) {
187
+ if (this.mbSource)
188
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
189
+ if (this.clientStyling)
190
+ setClientStyling(this.stylingContainer, this.clientStyling);
191
+ if (this.clientStylingUrl)
192
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
193
+ }
194
+ }
195
+ disconnectedCallback() {
196
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
197
+ }
198
+ validate(val) {
199
+ return val.length >= 3 && val.length <= 30 && this.asciiPrintableRegex.test(val);
200
+ }
201
+ render() {
202
+ return (h("div", { key: '241aeeb9f0f0984bbf0367a7c925e0b84ef15fa0', ref: (el) => (this.stylingContainer = el) }, h("div", { key: 'f20ec43253905cb0e9a356f65d1e51e695f784cf', class: "container" }, h("p", { key: 'a4c3b0ca894db101c192f7c62ff141ec51eaede1', class: "container__title" }, translate('title', this.language)), h("input", { key: 'c99bdd43659c9d2fc06702fe041eab8458bb0ee5', class: `code-input ${this.hasError ? 'errored' : ''}`, type: "text", placeholder: "e.g. SPRING24", onInput: this.handleInput }), h("p", { key: 'c2aacc2d4a23c7d222f895dce3a3a47b8f03f587', class: "code-input__text" }, translate('inputLabel', this.language)), h("button", { key: '51e79d07278368567026d31b0c70e8c9f0eb4840', class: "container__button", onClick: this.handleSubmit, disabled: this.loading || !this.code || this.hasError }, translate('btnText', this.language)))));
203
+ }
204
+ static get watchers() { return {
205
+ "clientStyling": ["handleClientStylingChange"],
206
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
207
+ "mbSource": ["handleMbSourceChange"]
208
+ }; }
209
+ };
210
+ CasinoChallengesClaimCode.style = CasinoChallengesClaimCodeStyle0;
211
+
212
+ export { CasinoChallengesClaimCode as C };
@@ -0,0 +1,2 @@
1
+ export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-746b4197.js';
2
+ import './index-05d7637d.js';
@@ -0,0 +1,20 @@
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-05d7637d.js';
2
+ export { s as setNonce } from './index-05d7637d.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-challenges-claim-code",[[1,"casino-challenges-claim-code",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"language":[513],"endpoint":[513],"domain":[513],"session":[513],"loading":[32],"hasError":[32],"code":[32],"notificationMessage":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
20
+ });