@everymatrix/casino-challenges-claim-code 0.10.25 → 0.10.27
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.
- package/dist/casino-challenges-claim-code/casino-challenges-claim-code-3171841e.js +1 -0
- package/dist/casino-challenges-claim-code/casino-challenges-claim-code.entry.js +1 -1
- package/dist/casino-challenges-claim-code/index.esm.js +1 -1
- package/dist/cjs/{casino-challenges-claim-code-b7ee2d2d.js → casino-challenges-claim-code-a2ea5795.js} +70 -11
- package/dist/cjs/casino-challenges-claim-code.cjs.entry.js +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/esm/{casino-challenges-claim-code-b1eeb8bc.js → casino-challenges-claim-code-3171841e.js} +70 -11
- package/dist/esm/casino-challenges-claim-code.entry.js +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
- package/dist/casino-challenges-claim-code/casino-challenges-claim-code-b1eeb8bc.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,c as t,h as n}from"./index-05d7637d.js";const o="__WIDGET_GLOBAL_STYLE_CACHE__";function i(e,t){if(e){const n=document.createElement("style");n.innerHTML=t,e.appendChild(n)}}function r(e,t){if(!e||!t)return;const n=new URL(t);fetch(n.href).then((e=>e.text())).then((t=>{const n=document.createElement("style");n.innerHTML=t,e&&e.appendChild(n)})).catch((e=>{console.error("There was an error while trying to load client styling from URL",e)}))}function s(e,t,n,i=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!i)return n=function(e,t){const n=document.createElement("style");return window.emMessageBus.subscribe(t,(t=>{e&&(n.innerHTML=t,e.appendChild(n))}))}(e,t),n;window[o]||(window[o]={}),n=function(e,t){return window.emMessageBus.subscribe(t,(n=>{if(!e)return;const i=e.getRootNode(),r=window[o];let s=r[t]?.sheet;s?r[t].refCount=r[t].refCount+1:(s=new CSSStyleSheet,s.replaceSync(n),r[t]={sheet:s,refCount:1});const a=i.adoptedStyleSheets||[];a.includes(s)||(i.adoptedStyleSheets=[...a,s])}))}(e,t);const r=n.unsubscribe.bind(n);return n.unsubscribe=()=>{if(window[o][t]){const e=window[o][t];e.refCount>1?e.refCount=e.refCount-1:delete window[o][t]}r()},n}const a={en:{title:"Enter the secret code to unlock hidden quests and rewards.",btnText:"Apply code",successMessage:"The code was successfully applied.",inputLabel:"3–30 characters, no spaces",lengthMinError:"Code must be at least 3 characters",lengthMaxError:"Too long — max 30 characters",formatError:"Invalid code format. Please use only Latin letters (case-sensitive), numbers, and special characters.",genericError:"Something went wrong, please retry"},ro:{},fr:{},ar:{},hr:{}},c=(e,t)=>a[void 0!==t&&t in a?t:"en"][e],h=class{constructor(n){e(this,n),this.openNotification=t(this,"openNotification",7),this.asciiPrintableRegex=/^[\x21-\x7E]+$/,this.handleSubmit=async()=>{if(this.endpoint&&this.session&&this.domain){const e=await this.applyCode();e.Success?this.openNotification.emit({message:c("successMessage",this.language)}):(this.hasError=!0,this.openNotification.emit({message:e.ErrorMessage,errored:!0,showTabLink:3002===e.ErrorCode||3023===e.ErrorCode||3003===e.ErrorCode}))}},this.applyCode=async()=>(this.loading=!0,fetch(`${this.endpoint}/challenge/GrantChallengeByCode`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({DomainId:this.domain,PlayerSessionId:this.session,ActivationCode:this.code})}).then((e=>e.json())).finally((()=>this.loading=!1))),this.handleInput=e=>{this.code=e.target.value,this.debounceTime&&clearTimeout(this.debounceTime),this.debounceTime=setTimeout((()=>{this.hasError=!this.validate(this.code)}),200)},this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0,this.translationUrl="",this.language="en",this.endpoint="",this.domain="",this.session="",this.loading=!1,this.hasError=!1,this.code="",this.notificationMessage=""}handleClientStylingChange(e,t){e!=t&&i(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(e,t){e!=t&&r(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(e,t){e!=t&&s(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription)}componentWillLoad(){this.translationUrl&&(async e=>{if(e)try{const n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const o=await n.json();t=o,Object.keys(t).forEach((e=>{for(let n in t[e])a[e][n]=t[e][n]}))}catch(e){console.error("Failed to fetch or parse translations from URL:",e)}var t})(this.translationUrl)}componentDidLoad(){this.stylingContainer&&(this.mbSource&&s(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&i(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&r(this.stylingContainer,this.clientStylingUrl))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}validate(e){return e.length>=3&&e.length<=30&&this.asciiPrintableRegex.test(e)}render(){return n("div",{key:"241aeeb9f0f0984bbf0367a7c925e0b84ef15fa0",ref:e=>this.stylingContainer=e},n("div",{key:"f20ec43253905cb0e9a356f65d1e51e695f784cf",class:"container"},n("p",{key:"a4c3b0ca894db101c192f7c62ff141ec51eaede1",class:"container__title"},c("title",this.language)),n("input",{key:"c99bdd43659c9d2fc06702fe041eab8458bb0ee5",class:"code-input "+(this.hasError?"errored":""),type:"text",placeholder:"e.g. SPRING24",onInput:this.handleInput}),n("p",{key:"c2aacc2d4a23c7d222f895dce3a3a47b8f03f587",class:"code-input__text"},c("inputLabel",this.language)),n("button",{key:"51e79d07278368567026d31b0c70e8c9f0eb4840",class:"container__button",onClick:this.handleSubmit,disabled:this.loading||!this.code||this.hasError},c("btnText",this.language))))}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};h.style=".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: 100%;\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}";export{h as C}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{C as casino_challenges_claim_code}from"./casino-challenges-claim-code-
|
|
1
|
+
export{C as casino_challenges_claim_code}from"./casino-challenges-claim-code-3171841e.js";import"./index-05d7637d.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{C as CasinoChallengesClaimCode}from"./casino-challenges-claim-code-
|
|
1
|
+
export{C as CasinoChallengesClaimCode}from"./casino-challenges-claim-code-3171841e.js";import"./index-05d7637d.js";
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const index = require('./index-718e2d1c.js');
|
|
4
4
|
|
|
5
|
+
const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* @name setClientStyling
|
|
7
9
|
* @description Method used to create and append to the passed element of the widget a style element with the content received
|
|
@@ -47,18 +49,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
|
|
|
47
49
|
* @param {HTMLElement} stylingContainer The highest element of the widget
|
|
48
50
|
* @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
|
|
49
51
|
* @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
|
|
52
|
+
* @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
|
|
50
53
|
*/
|
|
51
|
-
function setStreamStyling(stylingContainer, domain, subscription) {
|
|
52
|
-
if (window.emMessageBus)
|
|
53
|
-
const sheet = document.createElement('style');
|
|
54
|
+
function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
|
|
55
|
+
if (!window.emMessageBus) return;
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
|
|
58
|
+
|
|
59
|
+
if (!supportAdoptStyle || !useAdoptedStyleSheets) {
|
|
60
|
+
subscription = getStyleTagSubscription(stylingContainer, domain);
|
|
61
|
+
|
|
62
|
+
return subscription;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!window[StyleCacheKey]) {
|
|
66
|
+
window[StyleCacheKey] = {};
|
|
61
67
|
}
|
|
68
|
+
subscription = getAdoptStyleSubscription(stylingContainer, domain);
|
|
69
|
+
|
|
70
|
+
const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
|
|
71
|
+
const wrappedUnsubscribe = () => {
|
|
72
|
+
if (window[StyleCacheKey][domain]) {
|
|
73
|
+
const cachedObject = window[StyleCacheKey][domain];
|
|
74
|
+
cachedObject.refCount > 1
|
|
75
|
+
? (cachedObject.refCount = cachedObject.refCount - 1)
|
|
76
|
+
: delete window[StyleCacheKey][domain];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
originalUnsubscribe();
|
|
80
|
+
};
|
|
81
|
+
subscription.unsubscribe = wrappedUnsubscribe;
|
|
82
|
+
|
|
83
|
+
return subscription;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getStyleTagSubscription(stylingContainer, domain) {
|
|
87
|
+
const sheet = document.createElement('style');
|
|
88
|
+
|
|
89
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
90
|
+
if (stylingContainer) {
|
|
91
|
+
sheet.innerHTML = data;
|
|
92
|
+
stylingContainer.appendChild(sheet);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getAdoptStyleSubscription(stylingContainer, domain) {
|
|
98
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
99
|
+
if (!stylingContainer) return;
|
|
100
|
+
|
|
101
|
+
const shadowRoot = stylingContainer.getRootNode();
|
|
102
|
+
const cacheStyleObject = window[StyleCacheKey];
|
|
103
|
+
let cachedStyle = cacheStyleObject[domain]?.sheet;
|
|
104
|
+
|
|
105
|
+
if (!cachedStyle) {
|
|
106
|
+
cachedStyle = new CSSStyleSheet();
|
|
107
|
+
cachedStyle.replaceSync(data);
|
|
108
|
+
cacheStyleObject[domain] = {
|
|
109
|
+
sheet: cachedStyle,
|
|
110
|
+
refCount: 1
|
|
111
|
+
};
|
|
112
|
+
} else {
|
|
113
|
+
cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const currentSheets = shadowRoot.adoptedStyleSheets || [];
|
|
117
|
+
if (!currentSheets.includes(cachedStyle)) {
|
|
118
|
+
shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
62
121
|
}
|
|
63
122
|
|
|
64
123
|
const DEFAULT_LANGUAGE = 'en';
|
|
@@ -178,7 +237,7 @@ const CasinoChallengesClaimCode = class {
|
|
|
178
237
|
}
|
|
179
238
|
handleMbSourceChange(newValue, oldValue) {
|
|
180
239
|
if (newValue != oldValue) {
|
|
181
|
-
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style
|
|
240
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
182
241
|
}
|
|
183
242
|
}
|
|
184
243
|
componentWillLoad() {
|
|
@@ -189,7 +248,7 @@ const CasinoChallengesClaimCode = class {
|
|
|
189
248
|
componentDidLoad() {
|
|
190
249
|
if (this.stylingContainer) {
|
|
191
250
|
if (this.mbSource)
|
|
192
|
-
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style
|
|
251
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
193
252
|
if (this.clientStyling)
|
|
194
253
|
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
195
254
|
if (this.clientStylingUrl)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const casinoChallengesClaimCode = require('./casino-challenges-claim-code-
|
|
5
|
+
const casinoChallengesClaimCode = require('./casino-challenges-claim-code-a2ea5795.js');
|
|
6
6
|
require('./index-718e2d1c.js');
|
|
7
7
|
|
|
8
8
|
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const casinoChallengesClaimCode = require('./casino-challenges-claim-code-
|
|
5
|
+
const casinoChallengesClaimCode = require('./casino-challenges-claim-code-a2ea5795.js');
|
|
6
6
|
require('./index-718e2d1c.js');
|
|
7
7
|
|
|
8
8
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h } from './index-05d7637d.js';
|
|
2
2
|
|
|
3
|
+
const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* @name setClientStyling
|
|
5
7
|
* @description Method used to create and append to the passed element of the widget a style element with the content received
|
|
@@ -45,18 +47,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
|
|
|
45
47
|
* @param {HTMLElement} stylingContainer The highest element of the widget
|
|
46
48
|
* @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
|
|
47
49
|
* @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
|
|
50
|
+
* @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
|
|
48
51
|
*/
|
|
49
|
-
function setStreamStyling(stylingContainer, domain, subscription) {
|
|
50
|
-
if (window.emMessageBus)
|
|
51
|
-
const sheet = document.createElement('style');
|
|
52
|
+
function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
|
|
53
|
+
if (!window.emMessageBus) return;
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
|
|
56
|
+
|
|
57
|
+
if (!supportAdoptStyle || !useAdoptedStyleSheets) {
|
|
58
|
+
subscription = getStyleTagSubscription(stylingContainer, domain);
|
|
59
|
+
|
|
60
|
+
return subscription;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!window[StyleCacheKey]) {
|
|
64
|
+
window[StyleCacheKey] = {};
|
|
59
65
|
}
|
|
66
|
+
subscription = getAdoptStyleSubscription(stylingContainer, domain);
|
|
67
|
+
|
|
68
|
+
const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
|
|
69
|
+
const wrappedUnsubscribe = () => {
|
|
70
|
+
if (window[StyleCacheKey][domain]) {
|
|
71
|
+
const cachedObject = window[StyleCacheKey][domain];
|
|
72
|
+
cachedObject.refCount > 1
|
|
73
|
+
? (cachedObject.refCount = cachedObject.refCount - 1)
|
|
74
|
+
: delete window[StyleCacheKey][domain];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
originalUnsubscribe();
|
|
78
|
+
};
|
|
79
|
+
subscription.unsubscribe = wrappedUnsubscribe;
|
|
80
|
+
|
|
81
|
+
return subscription;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function getStyleTagSubscription(stylingContainer, domain) {
|
|
85
|
+
const sheet = document.createElement('style');
|
|
86
|
+
|
|
87
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
88
|
+
if (stylingContainer) {
|
|
89
|
+
sheet.innerHTML = data;
|
|
90
|
+
stylingContainer.appendChild(sheet);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getAdoptStyleSubscription(stylingContainer, domain) {
|
|
96
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
97
|
+
if (!stylingContainer) return;
|
|
98
|
+
|
|
99
|
+
const shadowRoot = stylingContainer.getRootNode();
|
|
100
|
+
const cacheStyleObject = window[StyleCacheKey];
|
|
101
|
+
let cachedStyle = cacheStyleObject[domain]?.sheet;
|
|
102
|
+
|
|
103
|
+
if (!cachedStyle) {
|
|
104
|
+
cachedStyle = new CSSStyleSheet();
|
|
105
|
+
cachedStyle.replaceSync(data);
|
|
106
|
+
cacheStyleObject[domain] = {
|
|
107
|
+
sheet: cachedStyle,
|
|
108
|
+
refCount: 1
|
|
109
|
+
};
|
|
110
|
+
} else {
|
|
111
|
+
cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const currentSheets = shadowRoot.adoptedStyleSheets || [];
|
|
115
|
+
if (!currentSheets.includes(cachedStyle)) {
|
|
116
|
+
shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
60
119
|
}
|
|
61
120
|
|
|
62
121
|
const DEFAULT_LANGUAGE = 'en';
|
|
@@ -176,7 +235,7 @@ const CasinoChallengesClaimCode = class {
|
|
|
176
235
|
}
|
|
177
236
|
handleMbSourceChange(newValue, oldValue) {
|
|
178
237
|
if (newValue != oldValue) {
|
|
179
|
-
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style
|
|
238
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
180
239
|
}
|
|
181
240
|
}
|
|
182
241
|
componentWillLoad() {
|
|
@@ -187,7 +246,7 @@ const CasinoChallengesClaimCode = class {
|
|
|
187
246
|
componentDidLoad() {
|
|
188
247
|
if (this.stylingContainer) {
|
|
189
248
|
if (this.mbSource)
|
|
190
|
-
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style
|
|
249
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
191
250
|
if (this.clientStyling)
|
|
192
251
|
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
193
252
|
if (this.clientStylingUrl)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-
|
|
1
|
+
export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-3171841e.js';
|
|
2
2
|
import './index-05d7637d.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as CasinoChallengesClaimCode } from './casino-challenges-claim-code-
|
|
1
|
+
export { C as CasinoChallengesClaimCode } from './casino-challenges-claim-code-3171841e.js';
|
|
2
2
|
import './index-05d7637d.js';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,c as t,h as n}from"./index-05d7637d.js";function o(e,t){if(e){const n=document.createElement("style");n.innerHTML=t,e.appendChild(n)}}function i(e,t){if(!e||!t)return;const n=new URL(t);fetch(n.href).then((e=>e.text())).then((t=>{const n=document.createElement("style");n.innerHTML=t,e&&e.appendChild(n)})).catch((e=>{console.error("There was an error while trying to load client styling from URL",e)}))}function r(e,t){if(window.emMessageBus){const n=document.createElement("style");window.emMessageBus.subscribe(t,(t=>{n.innerHTML=t,e&&e.appendChild(n)}))}}const s={en:{title:"Enter the secret code to unlock hidden quests and rewards.",btnText:"Apply code",successMessage:"The code was successfully applied.",inputLabel:"3–30 characters, no spaces",lengthMinError:"Code must be at least 3 characters",lengthMaxError:"Too long — max 30 characters",formatError:"Invalid code format. Please use only Latin letters (case-sensitive), numbers, and special characters.",genericError:"Something went wrong, please retry"},ro:{},fr:{},ar:{},hr:{}},a=(e,t)=>s[void 0!==t&&t in s?t:"en"][e],c=class{constructor(n){e(this,n),this.openNotification=t(this,"openNotification",7),this.asciiPrintableRegex=/^[\x21-\x7E]+$/,this.handleSubmit=async()=>{if(this.endpoint&&this.session&&this.domain){const e=await this.applyCode();e.Success?this.openNotification.emit({message:a("successMessage",this.language)}):(this.hasError=!0,this.openNotification.emit({message:e.ErrorMessage,errored:!0,showTabLink:3002===e.ErrorCode||3023===e.ErrorCode||3003===e.ErrorCode}))}},this.applyCode=async()=>(this.loading=!0,fetch(`${this.endpoint}/challenge/GrantChallengeByCode`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({DomainId:this.domain,PlayerSessionId:this.session,ActivationCode:this.code})}).then((e=>e.json())).finally((()=>this.loading=!1))),this.handleInput=e=>{this.code=e.target.value,this.debounceTime&&clearTimeout(this.debounceTime),this.debounceTime=setTimeout((()=>{this.hasError=!this.validate(this.code)}),200)},this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0,this.translationUrl="",this.language="en",this.endpoint="",this.domain="",this.session="",this.loading=!1,this.hasError=!1,this.code="",this.notificationMessage=""}handleClientStylingChange(e,t){e!=t&&o(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(e,t){e!=t&&i(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(e,t){e!=t&&r(this.stylingContainer,`${this.mbSource}.Style`)}componentWillLoad(){this.translationUrl&&(async e=>{if(e)try{const n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const o=await n.json();t=o,Object.keys(t).forEach((e=>{for(let n in t[e])s[e][n]=t[e][n]}))}catch(e){console.error("Failed to fetch or parse translations from URL:",e)}var t})(this.translationUrl)}componentDidLoad(){this.stylingContainer&&(this.mbSource&&r(this.stylingContainer,`${this.mbSource}.Style`),this.clientStyling&&o(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&i(this.stylingContainer,this.clientStylingUrl))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}validate(e){return e.length>=3&&e.length<=30&&this.asciiPrintableRegex.test(e)}render(){return n("div",{key:"241aeeb9f0f0984bbf0367a7c925e0b84ef15fa0",ref:e=>this.stylingContainer=e},n("div",{key:"f20ec43253905cb0e9a356f65d1e51e695f784cf",class:"container"},n("p",{key:"a4c3b0ca894db101c192f7c62ff141ec51eaede1",class:"container__title"},a("title",this.language)),n("input",{key:"c99bdd43659c9d2fc06702fe041eab8458bb0ee5",class:"code-input "+(this.hasError?"errored":""),type:"text",placeholder:"e.g. SPRING24",onInput:this.handleInput}),n("p",{key:"c2aacc2d4a23c7d222f895dce3a3a47b8f03f587",class:"code-input__text"},a("inputLabel",this.language)),n("button",{key:"51e79d07278368567026d31b0c70e8c9f0eb4840",class:"container__button",onClick:this.handleSubmit,disabled:this.loading||!this.code||this.hasError},a("btnText",this.language))))}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};c.style=".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: 100%;\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}";export{c as C}
|