@everymatrix/casino-challenges-claim-code 0.10.28 → 0.10.30

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.
@@ -0,0 +1 @@
1
+ import{r as t,c as e,h as n}from"./index-05d7637d.js";const o="__WIDGET_GLOBAL_STYLE_CACHE__";function i(t,e){if(t){const n=document.createElement("style");n.innerHTML=e,t.appendChild(n)}}function r(t,e){if(!t||!e)return;const n=new URL(e);fetch(n.href).then((t=>t.text())).then((e=>{const n=document.createElement("style");n.innerHTML=e,t&&t.appendChild(n)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}function s(t,e,n,i=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!i)return n=function(t,e){const n=document.createElement("style");return window.emMessageBus.subscribe(e,(e=>{t&&(n.innerHTML=e,t.appendChild(n))}))}(t,e),n;window[o]||(window[o]={}),n=function(t,e){return window.emMessageBus.subscribe(e,(n=>{if(!t)return;const i=t.getRootNode(),r=window[o];let s=r[e]?.sheet;s?r[e].refCount=r[e].refCount+1:(s=new CSSStyleSheet,s.replaceSync(n),r[e]={sheet:s,refCount:1});const c=i.adoptedStyleSheets||[];c.includes(s)||(i.adoptedStyleSheets=[...c,s])}))}(t,e);const r=n.unsubscribe.bind(n);return n.unsubscribe=()=>{if(window[o][e]){const t=window[o][e];t.refCount>1?t.refCount=t.refCount-1:delete window[o][e]}r()},n}const c={en:{claimCodeTitle:"Enter the secret code to unlock hidden quests and rewards.",claimCodeSuccessMessage:"The code was successfully applied.",claimCodeInputLabel:"3–30 characters, no spaces",claimCodeBtnText:"Apply code"}},a=(t,e)=>c[void 0!==e&&e in c?e:"en"][t],d=class{constructor(n){t(this,n),this.openNotification=e(this,"openNotification",7),this.asciiPrintableRegex=/^[\x21-\x7E]+$/,this.handleSubmit=async()=>{if(this.endpoint&&this.session&&this.domain){const t=await this.applyCode();t.Success?this.openNotification.emit({message:a("claimCodeSuccessMessage",this.language)}):(this.hasError=!0,this.openNotification.emit({message:t.ErrorMessage,errored:!0,showTabLink:3002===t.ErrorCode||3023===t.ErrorCode||3003===t.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((t=>t.json())).finally((()=>this.loading=!1))),this.handleInput=t=>{this.code=t.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(t,e){t!=e&&i(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(t,e){t!=e&&r(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(t,e){t!=e&&s(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription)}componentWillLoad(){this.translationUrl&&(async t=>{if(t)try{const n=await fetch(t);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const o=await n.json();e=o,Object.keys(e).forEach((t=>{c[t]||(c[t]={});for(let n in e[t])c[t][n]=e[t][n]}))}catch(t){console.error("Failed to fetch or parse translations from URL:",t)}var e})(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(t){return t.length>=3&&t.length<=30&&this.asciiPrintableRegex.test(t)}render(){return n("div",{key:"1851f81fab42f91bf0fc6caf7cd511a2d65cd2dc",ref:t=>this.stylingContainer=t},n("div",{key:"21f59630652cb8ea012fff54aa4aacc3599622c1",class:"container"},n("p",{key:"601bbd84b46e514275037c2fc95587eff435215d",class:"container__title"},a("claimCodeTitle",this.language)),n("input",{key:"fb2ae2a629c064e5cce8c9dbcfcc6f2d134ee1e8",class:"code-input "+(this.hasError?"errored":""),type:"text",placeholder:"e.g. SPRING24",onInput:this.handleInput}),n("p",{key:"6aec852b1620e4784b2f9e563a87290a66d46801",class:"code-input__text"},a("claimCodeInputLabel",this.language)),n("button",{key:"e7b489081cd2c3d9ec9c52db60064f6c6fbef662",class:"container__button",onClick:this.handleSubmit,disabled:this.loading||!this.code||this.hasError},a("claimCodeBtnText",this.language))))}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};d.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{d as C}
@@ -1 +1 @@
1
- export{C as casino_challenges_claim_code}from"./casino-challenges-claim-code-3171841e.js";import"./index-05d7637d.js";
1
+ export{C as casino_challenges_claim_code}from"./casino-challenges-claim-code-f585a2d9.js";import"./index-05d7637d.js";
@@ -1 +1 @@
1
- export{C as CasinoChallengesClaimCode}from"./casino-challenges-claim-code-3171841e.js";import"./index-05d7637d.js";
1
+ export{C as CasinoChallengesClaimCode}from"./casino-challenges-claim-code-f585a2d9.js";import"./index-05d7637d.js";
@@ -123,19 +123,11 @@ function getAdoptStyleSubscription(stylingContainer, domain) {
123
123
  const DEFAULT_LANGUAGE = 'en';
124
124
  const TRANSLATIONS = {
125
125
  en: {
126
- title: 'Enter the secret code to unlock hidden quests and rewards.',
127
- btnText: 'Apply code',
128
- successMessage: 'The code was successfully applied.',
129
- inputLabel: '3–30 characters, no spaces',
130
- lengthMinError: 'Code must be at least 3 characters',
131
- lengthMaxError: 'Too long — max 30 characters',
132
- formatError: 'Invalid code format. Please use only Latin letters (case-sensitive), numbers, and special characters.',
133
- genericError: 'Something went wrong, please retry'
134
- },
135
- ro: {},
136
- fr: {},
137
- ar: {},
138
- hr: {}
126
+ claimCodeTitle: 'Enter the secret code to unlock hidden quests and rewards.',
127
+ claimCodeSuccessMessage: 'The code was successfully applied.',
128
+ claimCodeInputLabel: '3–30 characters, no spaces',
129
+ claimCodeBtnText: 'Apply code',
130
+ }
139
131
  };
140
132
  const translate = (key, customLang) => {
141
133
  const lang = customLang;
@@ -143,6 +135,9 @@ const translate = (key, customLang) => {
143
135
  };
144
136
  const getTranslations = (data) => {
145
137
  Object.keys(data).forEach((item) => {
138
+ if (!TRANSLATIONS[item]) {
139
+ TRANSLATIONS[item] = {};
140
+ }
146
141
  for (let key in data[item]) {
147
142
  TRANSLATIONS[item][key] = data[item][key];
148
143
  }
@@ -176,7 +171,7 @@ const CasinoChallengesClaimCode = class {
176
171
  if (this.endpoint && this.session && this.domain) {
177
172
  const response = await this.applyCode();
178
173
  if (response.Success) {
179
- this.openNotification.emit({ message: translate('successMessage', this.language) });
174
+ this.openNotification.emit({ message: translate('claimCodeSuccessMessage', this.language) });
180
175
  }
181
176
  else {
182
177
  this.hasError = true;
@@ -262,7 +257,7 @@ const CasinoChallengesClaimCode = class {
262
257
  return val.length >= 3 && val.length <= 30 && this.asciiPrintableRegex.test(val);
263
258
  }
264
259
  render() {
265
- return (index.h("div", { key: '241aeeb9f0f0984bbf0367a7c925e0b84ef15fa0', ref: (el) => (this.stylingContainer = el) }, index.h("div", { key: 'f20ec43253905cb0e9a356f65d1e51e695f784cf', class: "container" }, index.h("p", { key: 'a4c3b0ca894db101c192f7c62ff141ec51eaede1', class: "container__title" }, translate('title', this.language)), index.h("input", { key: 'c99bdd43659c9d2fc06702fe041eab8458bb0ee5', class: `code-input ${this.hasError ? 'errored' : ''}`, type: "text", placeholder: "e.g. SPRING24", onInput: this.handleInput }), index.h("p", { key: 'c2aacc2d4a23c7d222f895dce3a3a47b8f03f587', class: "code-input__text" }, translate('inputLabel', this.language)), index.h("button", { key: '51e79d07278368567026d31b0c70e8c9f0eb4840', class: "container__button", onClick: this.handleSubmit, disabled: this.loading || !this.code || this.hasError }, translate('btnText', this.language)))));
260
+ return (index.h("div", { key: '1851f81fab42f91bf0fc6caf7cd511a2d65cd2dc', ref: (el) => (this.stylingContainer = el) }, index.h("div", { key: '21f59630652cb8ea012fff54aa4aacc3599622c1', class: "container" }, index.h("p", { key: '601bbd84b46e514275037c2fc95587eff435215d', class: "container__title" }, translate('claimCodeTitle', this.language)), index.h("input", { key: 'fb2ae2a629c064e5cce8c9dbcfcc6f2d134ee1e8', class: `code-input ${this.hasError ? 'errored' : ''}`, type: "text", placeholder: "e.g. SPRING24", onInput: this.handleInput }), index.h("p", { key: '6aec852b1620e4784b2f9e563a87290a66d46801', class: "code-input__text" }, translate('claimCodeInputLabel', this.language)), index.h("button", { key: 'e7b489081cd2c3d9ec9c52db60064f6c6fbef662', class: "container__button", onClick: this.handleSubmit, disabled: this.loading || !this.code || this.hasError }, translate('claimCodeBtnText', this.language)))));
266
261
  }
267
262
  static get watchers() { return {
268
263
  "clientStyling": ["handleClientStylingChange"],
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const casinoChallengesClaimCode = require('./casino-challenges-claim-code-a2ea5795.js');
5
+ const casinoChallengesClaimCode = require('./casino-challenges-claim-code-2b9461f1.js');
6
6
  require('./index-718e2d1c.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const casinoChallengesClaimCode = require('./casino-challenges-claim-code-a2ea5795.js');
5
+ const casinoChallengesClaimCode = require('./casino-challenges-claim-code-2b9461f1.js');
6
6
  require('./index-718e2d1c.js');
7
7
 
8
8
 
@@ -8,7 +8,7 @@ export class CasinoChallengesClaimCode {
8
8
  if (this.endpoint && this.session && this.domain) {
9
9
  const response = await this.applyCode();
10
10
  if (response.Success) {
11
- this.openNotification.emit({ message: translate('successMessage', this.language) });
11
+ this.openNotification.emit({ message: translate('claimCodeSuccessMessage', this.language) });
12
12
  }
13
13
  else {
14
14
  this.hasError = true;
@@ -94,7 +94,7 @@ export class CasinoChallengesClaimCode {
94
94
  return val.length >= 3 && val.length <= 30 && this.asciiPrintableRegex.test(val);
95
95
  }
96
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)))));
97
+ return (h("div", { key: '1851f81fab42f91bf0fc6caf7cd511a2d65cd2dc', ref: (el) => (this.stylingContainer = el) }, h("div", { key: '21f59630652cb8ea012fff54aa4aacc3599622c1', class: "container" }, h("p", { key: '601bbd84b46e514275037c2fc95587eff435215d', class: "container__title" }, translate('claimCodeTitle', this.language)), h("input", { key: 'fb2ae2a629c064e5cce8c9dbcfcc6f2d134ee1e8', class: `code-input ${this.hasError ? 'errored' : ''}`, type: "text", placeholder: "e.g. SPRING24", onInput: this.handleInput }), h("p", { key: '6aec852b1620e4784b2f9e563a87290a66d46801', class: "code-input__text" }, translate('claimCodeInputLabel', this.language)), h("button", { key: 'e7b489081cd2c3d9ec9c52db60064f6c6fbef662', class: "container__button", onClick: this.handleSubmit, disabled: this.loading || !this.code || this.hasError }, translate('claimCodeBtnText', this.language)))));
98
98
  }
99
99
  static get is() { return "casino-challenges-claim-code"; }
100
100
  static get encapsulation() { return "shadow"; }
@@ -1,19 +1,11 @@
1
1
  const DEFAULT_LANGUAGE = 'en';
2
2
  const TRANSLATIONS = {
3
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: {}
4
+ claimCodeTitle: 'Enter the secret code to unlock hidden quests and rewards.',
5
+ claimCodeSuccessMessage: 'The code was successfully applied.',
6
+ claimCodeInputLabel: '3–30 characters, no spaces',
7
+ claimCodeBtnText: 'Apply code',
8
+ }
17
9
  };
18
10
  export const translate = (key, customLang) => {
19
11
  const lang = customLang;
@@ -21,6 +13,9 @@ export const translate = (key, customLang) => {
21
13
  };
22
14
  export const getTranslations = (data) => {
23
15
  Object.keys(data).forEach((item) => {
16
+ if (!TRANSLATIONS[item]) {
17
+ TRANSLATIONS[item] = {};
18
+ }
24
19
  for (let key in data[item]) {
25
20
  TRANSLATIONS[item][key] = data[item][key];
26
21
  }
@@ -121,19 +121,11 @@ function getAdoptStyleSubscription(stylingContainer, domain) {
121
121
  const DEFAULT_LANGUAGE = 'en';
122
122
  const TRANSLATIONS = {
123
123
  en: {
124
- title: 'Enter the secret code to unlock hidden quests and rewards.',
125
- btnText: 'Apply code',
126
- successMessage: 'The code was successfully applied.',
127
- inputLabel: '3–30 characters, no spaces',
128
- lengthMinError: 'Code must be at least 3 characters',
129
- lengthMaxError: 'Too long — max 30 characters',
130
- formatError: 'Invalid code format. Please use only Latin letters (case-sensitive), numbers, and special characters.',
131
- genericError: 'Something went wrong, please retry'
132
- },
133
- ro: {},
134
- fr: {},
135
- ar: {},
136
- hr: {}
124
+ claimCodeTitle: 'Enter the secret code to unlock hidden quests and rewards.',
125
+ claimCodeSuccessMessage: 'The code was successfully applied.',
126
+ claimCodeInputLabel: '3–30 characters, no spaces',
127
+ claimCodeBtnText: 'Apply code',
128
+ }
137
129
  };
138
130
  const translate = (key, customLang) => {
139
131
  const lang = customLang;
@@ -141,6 +133,9 @@ const translate = (key, customLang) => {
141
133
  };
142
134
  const getTranslations = (data) => {
143
135
  Object.keys(data).forEach((item) => {
136
+ if (!TRANSLATIONS[item]) {
137
+ TRANSLATIONS[item] = {};
138
+ }
144
139
  for (let key in data[item]) {
145
140
  TRANSLATIONS[item][key] = data[item][key];
146
141
  }
@@ -174,7 +169,7 @@ const CasinoChallengesClaimCode = class {
174
169
  if (this.endpoint && this.session && this.domain) {
175
170
  const response = await this.applyCode();
176
171
  if (response.Success) {
177
- this.openNotification.emit({ message: translate('successMessage', this.language) });
172
+ this.openNotification.emit({ message: translate('claimCodeSuccessMessage', this.language) });
178
173
  }
179
174
  else {
180
175
  this.hasError = true;
@@ -260,7 +255,7 @@ const CasinoChallengesClaimCode = class {
260
255
  return val.length >= 3 && val.length <= 30 && this.asciiPrintableRegex.test(val);
261
256
  }
262
257
  render() {
263
- 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)))));
258
+ return (h("div", { key: '1851f81fab42f91bf0fc6caf7cd511a2d65cd2dc', ref: (el) => (this.stylingContainer = el) }, h("div", { key: '21f59630652cb8ea012fff54aa4aacc3599622c1', class: "container" }, h("p", { key: '601bbd84b46e514275037c2fc95587eff435215d', class: "container__title" }, translate('claimCodeTitle', this.language)), h("input", { key: 'fb2ae2a629c064e5cce8c9dbcfcc6f2d134ee1e8', class: `code-input ${this.hasError ? 'errored' : ''}`, type: "text", placeholder: "e.g. SPRING24", onInput: this.handleInput }), h("p", { key: '6aec852b1620e4784b2f9e563a87290a66d46801', class: "code-input__text" }, translate('claimCodeInputLabel', this.language)), h("button", { key: 'e7b489081cd2c3d9ec9c52db60064f6c6fbef662', class: "container__button", onClick: this.handleSubmit, disabled: this.loading || !this.code || this.hasError }, translate('claimCodeBtnText', this.language)))));
264
259
  }
265
260
  static get watchers() { return {
266
261
  "clientStyling": ["handleClientStylingChange"],
@@ -1,2 +1,2 @@
1
- export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-3171841e.js';
1
+ export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-f585a2d9.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-3171841e.js';
1
+ export { C as CasinoChallengesClaimCode } from './casino-challenges-claim-code-f585a2d9.js';
2
2
  import './index-05d7637d.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-challenges-claim-code",
3
- "version": "0.10.28",
3
+ "version": "0.10.30",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1 +0,0 @@
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}