@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,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const casinoChallengesClaimCode = require('./casino-challenges-claim-code-a4324416.js');
6
+ require('./index-718e2d1c.js');
7
+
8
+
9
+
10
+ exports.CasinoChallengesClaimCode = casinoChallengesClaimCode.CasinoChallengesClaimCode;
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-718e2d1c.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
7
+
8
+ const defineCustomElements = async (win, options) => {
9
+ if (typeof window === 'undefined') return undefined;
10
+ await appGlobals.globalScripts();
11
+ return index.bootstrapLazy([["casino-challenges-claim-code.cjs",[[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);
12
+ };
13
+
14
+ exports.setNonce = index.setNonce;
15
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,12 @@
1
+ {
2
+ "entries": [
3
+ "components/casino-challenges-claim-code/casino-challenges-claim-code.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "4.19.2",
8
+ "typescriptVersion": "5.4.5"
9
+ },
10
+ "collections": [],
11
+ "bundles": []
12
+ }
@@ -0,0 +1,81 @@
1
+ .container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ align-items: center;
5
+ padding: 80px 0;
6
+ text-align: center;
7
+ }
8
+ .container__title {
9
+ font-size: var(--emw--font-size-medium-plus, 18px);
10
+ font-weight: var(--emw--font-weight-medium, 500);
11
+ line-height: 22px;
12
+ color: var(--emw--color-white, white);
13
+ margin: 0 0 32px;
14
+ }
15
+ .container__button {
16
+ margin-top: 45px;
17
+ padding: 14px 20px;
18
+ background: transparent;
19
+ text-transform: uppercase;
20
+ border-radius: var(--emw--button-border-radius, 99px);
21
+ border: 2px solid var(--emw--button-border-color, #083B17);
22
+ font-size: var(--emw--font-size-x-small, 12px);
23
+ font-weight: var(--emw--font-weight-bold, 700);
24
+ color: var(--emw--color-white, #FFFFFF);
25
+ background-color: var(--emw--button-background-color, #18CE51);
26
+ cursor: pointer;
27
+ }
28
+ .container__button:hover {
29
+ color: var(--emw--color-gray-300, #083B17);
30
+ border-color: transparent;
31
+ box-shadow: 0 0 4px 0 rgba(188, 252, 177, 0.2), 0 0 20px 0 rgba(0, 183, 79, 0.5);
32
+ }
33
+ .container__button:disabled, .container__button:disabled:hover {
34
+ color: var(--emw--color-gray-50, #E2E2E2);
35
+ border: 2px solid var(--emw--button-border-color, #083B17);
36
+ opacity: 0.7;
37
+ cursor: not-allowed;
38
+ }
39
+ @container challenges-container (max-width: 576px) {
40
+ .container__button {
41
+ width: calc(100% - 32px);
42
+ position: absolute;
43
+ bottom: 50px;
44
+ }
45
+ }
46
+
47
+ .code-input {
48
+ border: 1px solid var(--emw--button-border-color, #083B17);
49
+ background: var(--emw--color-background-secondary, rgba(221, 255, 207, 0.1019607843));
50
+ border-radius: 6px;
51
+ padding: 12px 0;
52
+ line-height: 24px;
53
+ color: var(--emw--color-white, #FFFFFF);
54
+ text-align: center;
55
+ font-size: var(--emw--font-size-medium, 16px);
56
+ min-width: 340px;
57
+ }
58
+ .code-input:focus {
59
+ outline: 1px solid var(--emw--border-success-color, #00B74F);
60
+ }
61
+ .code-input:focus.errored {
62
+ outline-color: var(--emw--color-error, #D6421E);
63
+ }
64
+ .code-input.errored {
65
+ border-color: var(--emw--color-error, #D6421E);
66
+ }
67
+ .code-input__text {
68
+ margin: 8px 0 0;
69
+ line-height: 22px;
70
+ font-size: var(--emw--font-size-x-small, 12px);
71
+ font-weight: var(--emw--font-weight-medium, 500);
72
+ color: var(--emw--color-gray-150, #C8D6CE);
73
+ }
74
+ .code-input__text.errored {
75
+ color: var(--emw--color-error, #D6421E);
76
+ }
77
+ @container challenges-container (max-width: 576px) {
78
+ .code-input {
79
+ min-width: 100%;
80
+ }
81
+ }
@@ -0,0 +1,300 @@
1
+ import { h } from "@stencil/core";
2
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
3
+ import { resolveTranslationUrl, translate } from "../../utils/locale.utils";
4
+ export class CasinoChallengesClaimCode {
5
+ constructor() {
6
+ this.asciiPrintableRegex = /^[\x21-\x7E]+$/;
7
+ this.handleSubmit = async () => {
8
+ if (this.endpoint && this.session && this.domain) {
9
+ const response = await this.applyCode();
10
+ if (response.Success) {
11
+ this.openNotification.emit({ message: translate('successMessage', this.language) });
12
+ }
13
+ else {
14
+ this.hasError = true;
15
+ const showTabLink = response.ErrorCode === 3002 || response.ErrorCode === 3023 || response.ErrorCode === 3003;
16
+ this.openNotification.emit({ message: response.ErrorMessage, errored: true, showTabLink });
17
+ }
18
+ }
19
+ };
20
+ this.applyCode = async () => {
21
+ this.loading = true;
22
+ const url = `${this.endpoint}/challenge/GrantChallengeByCode`;
23
+ const body = {
24
+ DomainId: this.domain,
25
+ PlayerSessionId: this.session,
26
+ ActivationCode: this.code
27
+ };
28
+ return fetch(url, {
29
+ method: 'POST',
30
+ headers: {
31
+ 'Content-Type': 'application/json'
32
+ },
33
+ body: JSON.stringify(body)
34
+ })
35
+ .then((res) => res.json())
36
+ .finally(() => (this.loading = false));
37
+ };
38
+ this.handleInput = (event) => {
39
+ this.code = event.target.value;
40
+ if (this.debounceTime) {
41
+ clearTimeout(this.debounceTime);
42
+ }
43
+ this.debounceTime = setTimeout(() => {
44
+ this.hasError = !this.validate(this.code);
45
+ }, 200);
46
+ };
47
+ this.mbSource = undefined;
48
+ this.clientStyling = undefined;
49
+ this.clientStylingUrl = undefined;
50
+ this.translationUrl = '';
51
+ this.language = 'en';
52
+ this.endpoint = '';
53
+ this.domain = '';
54
+ this.session = '';
55
+ this.loading = false;
56
+ this.hasError = false;
57
+ this.code = '';
58
+ this.notificationMessage = '';
59
+ }
60
+ handleClientStylingChange(newValue, oldValue) {
61
+ if (newValue != oldValue) {
62
+ setClientStyling(this.stylingContainer, this.clientStyling);
63
+ }
64
+ }
65
+ handleClientStylingUrlChange(newValue, oldValue) {
66
+ if (newValue != oldValue) {
67
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
68
+ }
69
+ }
70
+ handleMbSourceChange(newValue, oldValue) {
71
+ if (newValue != oldValue) {
72
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
73
+ }
74
+ }
75
+ componentWillLoad() {
76
+ if (this.translationUrl) {
77
+ resolveTranslationUrl(this.translationUrl);
78
+ }
79
+ }
80
+ componentDidLoad() {
81
+ if (this.stylingContainer) {
82
+ if (this.mbSource)
83
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
84
+ if (this.clientStyling)
85
+ setClientStyling(this.stylingContainer, this.clientStyling);
86
+ if (this.clientStylingUrl)
87
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
88
+ }
89
+ }
90
+ disconnectedCallback() {
91
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
92
+ }
93
+ validate(val) {
94
+ return val.length >= 3 && val.length <= 30 && this.asciiPrintableRegex.test(val);
95
+ }
96
+ render() {
97
+ 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)))));
98
+ }
99
+ static get is() { return "casino-challenges-claim-code"; }
100
+ static get encapsulation() { return "shadow"; }
101
+ static get originalStyleUrls() {
102
+ return {
103
+ "$": ["casino-challenges-claim-code.scss"]
104
+ };
105
+ }
106
+ static get styleUrls() {
107
+ return {
108
+ "$": ["casino-challenges-claim-code.css"]
109
+ };
110
+ }
111
+ static get properties() {
112
+ return {
113
+ "mbSource": {
114
+ "type": "string",
115
+ "mutable": false,
116
+ "complexType": {
117
+ "original": "string",
118
+ "resolved": "string",
119
+ "references": {}
120
+ },
121
+ "required": false,
122
+ "optional": false,
123
+ "docs": {
124
+ "tags": [],
125
+ "text": "Client custom styling via message bus"
126
+ },
127
+ "attribute": "mb-source",
128
+ "reflect": true
129
+ },
130
+ "clientStyling": {
131
+ "type": "string",
132
+ "mutable": false,
133
+ "complexType": {
134
+ "original": "string",
135
+ "resolved": "string",
136
+ "references": {}
137
+ },
138
+ "required": false,
139
+ "optional": false,
140
+ "docs": {
141
+ "tags": [],
142
+ "text": "Client custom styling via string"
143
+ },
144
+ "attribute": "client-styling",
145
+ "reflect": true
146
+ },
147
+ "clientStylingUrl": {
148
+ "type": "string",
149
+ "mutable": false,
150
+ "complexType": {
151
+ "original": "string",
152
+ "resolved": "string",
153
+ "references": {}
154
+ },
155
+ "required": false,
156
+ "optional": false,
157
+ "docs": {
158
+ "tags": [],
159
+ "text": "Client custom styling via css file url"
160
+ },
161
+ "attribute": "client-styling-url",
162
+ "reflect": true
163
+ },
164
+ "translationUrl": {
165
+ "type": "string",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "string",
169
+ "resolved": "string",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": false,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": "Client custom translation via json file url"
177
+ },
178
+ "attribute": "translation-url",
179
+ "reflect": true,
180
+ "defaultValue": "''"
181
+ },
182
+ "language": {
183
+ "type": "string",
184
+ "mutable": false,
185
+ "complexType": {
186
+ "original": "string",
187
+ "resolved": "string",
188
+ "references": {}
189
+ },
190
+ "required": false,
191
+ "optional": false,
192
+ "docs": {
193
+ "tags": [],
194
+ "text": "Client custom language for translation"
195
+ },
196
+ "attribute": "language",
197
+ "reflect": true,
198
+ "defaultValue": "'en'"
199
+ },
200
+ "endpoint": {
201
+ "type": "string",
202
+ "mutable": false,
203
+ "complexType": {
204
+ "original": "string",
205
+ "resolved": "string",
206
+ "references": {}
207
+ },
208
+ "required": false,
209
+ "optional": false,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": "Client endpoint to fetch data"
213
+ },
214
+ "attribute": "endpoint",
215
+ "reflect": true,
216
+ "defaultValue": "''"
217
+ },
218
+ "domain": {
219
+ "type": "string",
220
+ "mutable": false,
221
+ "complexType": {
222
+ "original": "string",
223
+ "resolved": "string",
224
+ "references": {}
225
+ },
226
+ "required": false,
227
+ "optional": false,
228
+ "docs": {
229
+ "tags": [],
230
+ "text": "Domain Id"
231
+ },
232
+ "attribute": "domain",
233
+ "reflect": true,
234
+ "defaultValue": "''"
235
+ },
236
+ "session": {
237
+ "type": "string",
238
+ "mutable": false,
239
+ "complexType": {
240
+ "original": "string",
241
+ "resolved": "string",
242
+ "references": {}
243
+ },
244
+ "required": false,
245
+ "optional": false,
246
+ "docs": {
247
+ "tags": [],
248
+ "text": "User session Id"
249
+ },
250
+ "attribute": "session",
251
+ "reflect": true,
252
+ "defaultValue": "''"
253
+ }
254
+ };
255
+ }
256
+ static get states() {
257
+ return {
258
+ "loading": {},
259
+ "hasError": {},
260
+ "code": {},
261
+ "notificationMessage": {}
262
+ };
263
+ }
264
+ static get events() {
265
+ return [{
266
+ "method": "openNotification",
267
+ "name": "openNotification",
268
+ "bubbles": true,
269
+ "cancelable": true,
270
+ "composed": true,
271
+ "docs": {
272
+ "tags": [],
273
+ "text": ""
274
+ },
275
+ "complexType": {
276
+ "original": "INotificationOptions",
277
+ "resolved": "INotificationOptions",
278
+ "references": {
279
+ "INotificationOptions": {
280
+ "location": "import",
281
+ "path": "../../utils/types",
282
+ "id": "../../../../packages/stencil/casino-challenges-claim-code/src/utils/types.ts::INotificationOptions"
283
+ }
284
+ }
285
+ }
286
+ }];
287
+ }
288
+ static get watchers() {
289
+ return [{
290
+ "propName": "clientStyling",
291
+ "methodName": "handleClientStylingChange"
292
+ }, {
293
+ "propName": "clientStylingUrl",
294
+ "methodName": "handleClientStylingUrlChange"
295
+ }, {
296
+ "propName": "mbSource",
297
+ "methodName": "handleMbSourceChange"
298
+ }];
299
+ }
300
+ }
@@ -0,0 +1 @@
1
+ export { CasinoChallengesClaimCode } from './casino-challenges-claim-code';
@@ -0,0 +1 @@
1
+ export * from './components/casino-challenges-claim-code';
@@ -0,0 +1,43 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const TRANSLATIONS = {
3
+ en: {
4
+ title: 'Enter the secret code to unlock hidden quests and rewards.',
5
+ btnText: 'Apply code',
6
+ successMessage: 'The code was successfully applied.',
7
+ inputLabel: '3–30 characters, no spaces',
8
+ lengthMinError: 'Code must be at least 3 characters',
9
+ lengthMaxError: 'Too long — max 30 characters',
10
+ formatError: 'Invalid code format. Please use only Latin letters (case-sensitive), numbers, and special characters.',
11
+ genericError: 'Something went wrong, please retry'
12
+ },
13
+ ro: {},
14
+ fr: {},
15
+ ar: {},
16
+ hr: {}
17
+ };
18
+ export const translate = (key, customLang) => {
19
+ const lang = customLang;
20
+ return TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key];
21
+ };
22
+ export const getTranslations = (data) => {
23
+ Object.keys(data).forEach((item) => {
24
+ for (let key in data[item]) {
25
+ TRANSLATIONS[item][key] = data[item][key];
26
+ }
27
+ });
28
+ };
29
+ export const resolveTranslationUrl = async (translationUrl) => {
30
+ if (translationUrl) {
31
+ try {
32
+ const response = await fetch(translationUrl);
33
+ if (!response.ok) {
34
+ throw new Error(`HTTP error! status: ${response.status}`);
35
+ }
36
+ const translations = await response.json();
37
+ getTranslations(translations);
38
+ }
39
+ catch (error) {
40
+ console.error('Failed to fetch or parse translations from URL:', error);
41
+ }
42
+ }
43
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export function format(first, middle, last) {
2
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
3
+ }
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };