@everymatrix/helper-tabs 1.87.26 → 1.87.28

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.
@@ -76,6 +76,8 @@ const getTranslations = (data) => {
76
76
  });
77
77
  };
78
78
 
79
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
80
+
79
81
  /**
80
82
  * @name setClientStyling
81
83
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -121,18 +123,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
121
123
  * @param {HTMLElement} stylingContainer The highest element of the widget
122
124
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
123
125
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
126
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
124
127
  */
125
- function setStreamStyling(stylingContainer, domain, subscription) {
126
- if (window.emMessageBus) {
127
- const sheet = document.createElement('style');
128
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
129
+ if (!window.emMessageBus) return;
128
130
 
129
- window.emMessageBus.subscribe(domain, (data) => {
130
- sheet.innerHTML = data;
131
- if (stylingContainer) {
132
- stylingContainer.appendChild(sheet);
133
- }
134
- });
131
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
132
+
133
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
134
+ subscription = getStyleTagSubscription(stylingContainer, domain);
135
+
136
+ return subscription;
137
+ }
138
+
139
+ if (!window[StyleCacheKey]) {
140
+ window[StyleCacheKey] = {};
135
141
  }
142
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
143
+
144
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
145
+ const wrappedUnsubscribe = () => {
146
+ if (window[StyleCacheKey][domain]) {
147
+ const cachedObject = window[StyleCacheKey][domain];
148
+ cachedObject.refCount > 1
149
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
150
+ : delete window[StyleCacheKey][domain];
151
+ }
152
+
153
+ originalUnsubscribe();
154
+ };
155
+ subscription.unsubscribe = wrappedUnsubscribe;
156
+
157
+ return subscription;
158
+ }
159
+
160
+ function getStyleTagSubscription(stylingContainer, domain) {
161
+ const sheet = document.createElement('style');
162
+
163
+ return window.emMessageBus.subscribe(domain, (data) => {
164
+ if (stylingContainer) {
165
+ sheet.innerHTML = data;
166
+ stylingContainer.appendChild(sheet);
167
+ }
168
+ });
169
+ }
170
+
171
+ function getAdoptStyleSubscription(stylingContainer, domain) {
172
+ return window.emMessageBus.subscribe(domain, (data) => {
173
+ if (!stylingContainer) return;
174
+
175
+ const shadowRoot = stylingContainer.getRootNode();
176
+ const cacheStyleObject = window[StyleCacheKey];
177
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
178
+
179
+ if (!cachedStyle) {
180
+ cachedStyle = new CSSStyleSheet();
181
+ cachedStyle.replaceSync(data);
182
+ cacheStyleObject[domain] = {
183
+ sheet: cachedStyle,
184
+ refCount: 1
185
+ };
186
+ } else {
187
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
188
+ }
189
+
190
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
191
+ if (!currentSheets.includes(cachedStyle)) {
192
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
193
+ }
194
+ });
136
195
  }
137
196
 
138
197
  const helperTabCss = ":host{display:block}.TabContent{font-size:14px;color:var(--emw--color-typography, #000);font-weight:normal}";
@@ -168,7 +227,7 @@ const HelperTab = class {
168
227
  componentDidLoad() {
169
228
  if (this.stylingContainer) {
170
229
  if (window.emMessageBus != undefined) {
171
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
230
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
172
231
  }
173
232
  else {
174
233
  if (this.clientStyling)
@@ -254,7 +313,7 @@ const HelperTabs = class {
254
313
  componentDidLoad() {
255
314
  if (this.stylingContainer) {
256
315
  if (window.emMessageBus != undefined) {
257
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
316
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
258
317
  }
259
318
  else {
260
319
  if (this.clientStyling)
@@ -72,6 +72,8 @@ const getTranslations = (data) => {
72
72
  });
73
73
  };
74
74
 
75
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
76
+
75
77
  /**
76
78
  * @name setClientStyling
77
79
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -117,18 +119,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
117
119
  * @param {HTMLElement} stylingContainer The highest element of the widget
118
120
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
119
121
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
122
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
120
123
  */
121
- function setStreamStyling(stylingContainer, domain, subscription) {
122
- if (window.emMessageBus) {
123
- const sheet = document.createElement('style');
124
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
125
+ if (!window.emMessageBus) return;
124
126
 
125
- window.emMessageBus.subscribe(domain, (data) => {
126
- sheet.innerHTML = data;
127
- if (stylingContainer) {
128
- stylingContainer.appendChild(sheet);
129
- }
130
- });
127
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
128
+
129
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
130
+ subscription = getStyleTagSubscription(stylingContainer, domain);
131
+
132
+ return subscription;
133
+ }
134
+
135
+ if (!window[StyleCacheKey]) {
136
+ window[StyleCacheKey] = {};
131
137
  }
138
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
139
+
140
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
141
+ const wrappedUnsubscribe = () => {
142
+ if (window[StyleCacheKey][domain]) {
143
+ const cachedObject = window[StyleCacheKey][domain];
144
+ cachedObject.refCount > 1
145
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
146
+ : delete window[StyleCacheKey][domain];
147
+ }
148
+
149
+ originalUnsubscribe();
150
+ };
151
+ subscription.unsubscribe = wrappedUnsubscribe;
152
+
153
+ return subscription;
154
+ }
155
+
156
+ function getStyleTagSubscription(stylingContainer, domain) {
157
+ const sheet = document.createElement('style');
158
+
159
+ return window.emMessageBus.subscribe(domain, (data) => {
160
+ if (stylingContainer) {
161
+ sheet.innerHTML = data;
162
+ stylingContainer.appendChild(sheet);
163
+ }
164
+ });
165
+ }
166
+
167
+ function getAdoptStyleSubscription(stylingContainer, domain) {
168
+ return window.emMessageBus.subscribe(domain, (data) => {
169
+ if (!stylingContainer) return;
170
+
171
+ const shadowRoot = stylingContainer.getRootNode();
172
+ const cacheStyleObject = window[StyleCacheKey];
173
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
174
+
175
+ if (!cachedStyle) {
176
+ cachedStyle = new CSSStyleSheet();
177
+ cachedStyle.replaceSync(data);
178
+ cacheStyleObject[domain] = {
179
+ sheet: cachedStyle,
180
+ refCount: 1
181
+ };
182
+ } else {
183
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
184
+ }
185
+
186
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
187
+ if (!currentSheets.includes(cachedStyle)) {
188
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
189
+ }
190
+ });
132
191
  }
133
192
 
134
193
  const helperTabCss = ":host{display:block}.TabContent{font-size:14px;color:var(--emw--color-typography, #000);font-weight:normal}";
@@ -164,7 +223,7 @@ const HelperTab = class {
164
223
  componentDidLoad() {
165
224
  if (this.stylingContainer) {
166
225
  if (window.emMessageBus != undefined) {
167
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
226
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
168
227
  }
169
228
  else {
170
229
  if (this.clientStyling)
@@ -250,7 +309,7 @@ const HelperTabs = class {
250
309
  componentDidLoad() {
251
310
  if (this.stylingContainer) {
252
311
  if (window.emMessageBus != undefined) {
253
- setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
312
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
254
313
  }
255
314
  else {
256
315
  if (this.clientStyling)
@@ -1 +1 @@
1
- import{r as e,h as i,g as t}from"./index-3174302b.js";const o="en",a=["en"],n={en:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"},ro:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"},fr:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"},ar:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"},hr:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"}},s=(e,i)=>{const t=i;return n[void 0!==t&&a.includes(t)?t:o][e]};function r(e,i){if(e){const t=document.createElement("style");t.innerHTML=i,e.appendChild(t)}}function c(e,i){if(!e||!i)return;const t=new URL(i);fetch(t.href).then((e=>e.text())).then((i=>{const t=document.createElement("style");t.innerHTML=i,e&&e.appendChild(t)})).catch((e=>{console.error("There was an error while trying to load client styling from URL",e)}))}function l(e,i){if(window.emMessageBus){const t=document.createElement("style");window.emMessageBus.subscribe(i,(i=>{t.innerHTML=i,e&&e.appendChild(t)}))}}const u=class{constructor(i){e(this,i),this.selectedIndex=0,this.cmsEndpoint=void 0,this.mbSource=void 0,this.clientStyling="",this.clientStylingUrl="",this.lowNumber=void 0,this.highNumber=void 0,this.minimumAllowed=void 0,this.maxinumAllowed=void 0,this.language="en",this.translationUrl=void 0,this.tabContent=""}handleClientStylingChange(e,i){e!=i&&r(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(e,i){e!=i&&this.clientStylingUrl&&c(this.stylingContainer,this.clientStylingUrl)}componentDidLoad(){this.stylingContainer&&(null!=window.emMessageBus?l(this.stylingContainer,`${this.mbSource}.Style`):(this.clientStyling&&r(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&c(this.stylingContainer,this.clientStylingUrl)))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}componentWillLoad(){var e;this.translationUrl&&(e=JSON.parse(this.translationUrl),Object.keys(e).forEach((i=>{for(let t in e[i])n[i][t]=e[i][t]})))}getHowToPlay(){return this.lowNumber&&this.highNumber&&this.maxinumAllowed&&this.minimumAllowed?((e,i)=>{const t=i.lang;let s=n[void 0!==t&&a.includes(t)?t:o][e];return i?(Object.keys(i).forEach((e=>{s=s.replace(new RegExp("\\${"+e+"}","gm"),i[e])})),s):n[void 0!==t&&a.includes(t)?t:o][e]})("howToPlay",{lowNumber:this.lowNumber,highNumber:this.highNumber,maxinumAllowed:this.maxinumAllowed,minimumAllowed:this.minimumAllowed,lang:this.language}):""}render(){return this.tabContent=i("div",{key:"92877a17361066f68fce6299cb8f65901f6abc60",class:"TabContent",ref:e=>this.stylingContainer=e},this.getHowToPlay()),this.selectedIndex+1==2?this.tabContent=i("div",{key:"9876b9250371034ef40dab0f5fc3fe1a5631a370",class:"TabContent",ref:e=>this.stylingContainer=e},i("ol",{key:"ef2097eb54aeb640f06871277d8cafd2f4455109"},i("li",{key:"e9a0237e1fdead445abcd9240174276ffef81a67"},s("register",this.language)),i("li",{key:"2bdfaffdc9f1a7ae021913cb0ba346132140dcfd"},s("butTickets",this.language)),i("li",{key:"bff38eaeabeaece83dc8ed1697e5b052802753f6"},s("reviewPurchase",this.language)))):this.selectedIndex+1==3&&(this.tabContent=i("div",{key:"49a7fb3435fb50b54572ec38d1e632e2eacf56fb",class:"TabContent",ref:e=>this.stylingContainer=e},i("ul",{key:"7f642625f35a1ed1eae7655144c0b8b1bfe25f55"},i("li",{key:"037a5913be57dd1e2dcde5a061e9c64e70365e8d"},s("odds",this.language)),i("li",{key:"8775a1b2e8eda285e2c248b8d7235f06ac593fc6"},s("winGame",this.language)),i("li",{key:"5297fc5e757c29a1349049f1fe294e926255d518"},s("claimPrize",this.language))))),this.tabContent}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}}};u.style=":host{display:block}.TabContent{font-size:14px;color:var(--emw--color-typography, #000);font-weight:normal}";const h=class{constructor(i){e(this,i),this.disabled=!1,this.label=void 0,this.selected=!1,this.cmsEndpoint=void 0,this.selectedIndex=0,this.tabs=[{label:"How to Play"},{label:"About"},{label:"FAQs"}],this.clientStyling="",this.mbSource=void 0,this.clientStylingurl="",this.clientStylingUrl="",this.lowNumber=void 0,this.highNumber=void 0,this.minimumAllowed=void 0,this.maxinumAllowed=void 0,this.language="en",this.translationUrl=void 0}connectedCallback(){}handleClientStylingChange(e,i){e!=i&&r(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(e,i){e!=i&&this.clientStylingUrl&&c(this.stylingContainer,this.clientStylingUrl)}componentDidLoad(){this.stylingContainer&&(null!=window.emMessageBus?l(this.stylingContainer,`${this.mbSource}.Style`):(this.clientStyling&&r(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&c(this.stylingContainer,this.clientStylingUrl)))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}render(){return i("div",{key:"173c4774748482dc56fcffb4bac4e1666fa9170f",ref:e=>this.stylingContainer=e},i("div",{key:"680b65218e4b00f134b354f593c0c20fb5882dca",class:"Tabs"},this.tabs.map(((e,t)=>i("button",{class:"TabButton"+(this.selectedIndex==t?" Active":""),onClick:()=>this.selectedIndex=t},e.label)))),i("div",{key:"67aa26c92fb416c5d0934988fb071481f805685b"},i("helper-tab",{key:"63c8dfc253d4fc12b0310a2585a44b90807e1a9f","low-number":this.lowNumber,"high-number":this.highNumber,"minimum-allowed":this.minimumAllowed,"maxinum-allowed":this.maxinumAllowed,selectedIndex:this.selectedIndex,"client-styling":this.clientStyling,language:this.language,"translation-url":this.translationUrl,"client-stylingurl":this.clientStylingurl,"client-styling-url-content":this.clientStylingUrl,"mb-source":this.mbSource})))}get host(){return t(this)}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}}};h.style='@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap");:host{display:block;font-family:"Roboto", sans-serif}.Tabs{display:flex;gap:10px;overflow-x:auto}.TabButton{cursor:pointer;width:auto;border-radius:var(--emw--button-border-radius, 4px);padding:8px 15px;margin:5px 0 10px;border:1px solid var(--emw--color-primary, #009993);background:var(--emw--color-background, #fff);color:var(--emw--color-typography, #000);font-size:12px;transition:all 0.2s linear;text-align:center;letter-spacing:0;white-space:nowrap}.TabButton:hover{background:var(--emw--color-background-secondary, #f5f5f5)}.TabButton.Active{background:var(--emw--color-primary, #009993);color:var(--emw--color-background, #fff)}';export{u as helper_tab,h as helper_tabs}
1
+ import{r as e,h as t,g as i}from"./index-3174302b.js";const o="en",n=["en"],a={en:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"},ro:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"},fr:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"},ar:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"},hr:{howToPlay:"Each play includes one set of numbers from ${lowNumber} to ${highNumber} with a selectable number of ${maxinumAllowed} and a minimum selection of ${minimumAllowed}. The winnings are automatically credited to your account.",register:"Register or Login",butTickets:'Buy tickets. Select "Buy Tickets" to pick your numbers. Want us to automatically generate random numbers for you? Choose “quick pick”.',reviewPurchase:"Review and Complete your purchase. Once you've chosen your total number of plays, and confirmed your number of selections, review your ticket details and complete your purchase!",odds:"What are my odds of winning?",winGame:"How can I find out if I’ve won a draw game?",claimPrize:"How do I claim my prize?"}},s=(e,t)=>{const i=t;return a[void 0!==i&&n.includes(i)?i:o][e]},r="__WIDGET_GLOBAL_STYLE_CACHE__";function c(e,t){if(e){const i=document.createElement("style");i.innerHTML=t,e.appendChild(i)}}function l(e,t){if(!e||!t)return;const i=new URL(t);fetch(i.href).then((e=>e.text())).then((t=>{const i=document.createElement("style");i.innerHTML=t,e&&e.appendChild(i)})).catch((e=>{console.error("There was an error while trying to load client styling from URL",e)}))}function u(e,t,i,o=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!o)return i=function(e,t){const i=document.createElement("style");return window.emMessageBus.subscribe(t,(t=>{e&&(i.innerHTML=t,e.appendChild(i))}))}(e,t),i;window[r]||(window[r]={}),i=function(e,t){return window.emMessageBus.subscribe(t,(i=>{if(!e)return;const o=e.getRootNode(),n=window[r];let a=n[t]?.sheet;a?n[t].refCount=n[t].refCount+1:(a=new CSSStyleSheet,a.replaceSync(i),n[t]={sheet:a,refCount:1});const s=o.adoptedStyleSheets||[];s.includes(a)||(o.adoptedStyleSheets=[...s,a])}))}(e,t);const n=i.unsubscribe.bind(i);return i.unsubscribe=()=>{if(window[r][t]){const e=window[r][t];e.refCount>1?e.refCount=e.refCount-1:delete window[r][t]}n()},i}const d=class{constructor(t){e(this,t),this.selectedIndex=0,this.cmsEndpoint=void 0,this.mbSource=void 0,this.clientStyling="",this.clientStylingUrl="",this.lowNumber=void 0,this.highNumber=void 0,this.minimumAllowed=void 0,this.maxinumAllowed=void 0,this.language="en",this.translationUrl=void 0,this.tabContent=""}handleClientStylingChange(e,t){e!=t&&c(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(e,t){e!=t&&this.clientStylingUrl&&l(this.stylingContainer,this.clientStylingUrl)}componentDidLoad(){this.stylingContainer&&(null!=window.emMessageBus?u(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription):(this.clientStyling&&c(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&l(this.stylingContainer,this.clientStylingUrl)))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}componentWillLoad(){var e;this.translationUrl&&(e=JSON.parse(this.translationUrl),Object.keys(e).forEach((t=>{for(let i in e[t])a[t][i]=e[t][i]})))}getHowToPlay(){return this.lowNumber&&this.highNumber&&this.maxinumAllowed&&this.minimumAllowed?((e,t)=>{const i=t.lang;let s=a[void 0!==i&&n.includes(i)?i:o][e];return t?(Object.keys(t).forEach((e=>{s=s.replace(new RegExp("\\${"+e+"}","gm"),t[e])})),s):a[void 0!==i&&n.includes(i)?i:o][e]})("howToPlay",{lowNumber:this.lowNumber,highNumber:this.highNumber,maxinumAllowed:this.maxinumAllowed,minimumAllowed:this.minimumAllowed,lang:this.language}):""}render(){return this.tabContent=t("div",{key:"92877a17361066f68fce6299cb8f65901f6abc60",class:"TabContent",ref:e=>this.stylingContainer=e},this.getHowToPlay()),this.selectedIndex+1==2?this.tabContent=t("div",{key:"9876b9250371034ef40dab0f5fc3fe1a5631a370",class:"TabContent",ref:e=>this.stylingContainer=e},t("ol",{key:"ef2097eb54aeb640f06871277d8cafd2f4455109"},t("li",{key:"e9a0237e1fdead445abcd9240174276ffef81a67"},s("register",this.language)),t("li",{key:"2bdfaffdc9f1a7ae021913cb0ba346132140dcfd"},s("butTickets",this.language)),t("li",{key:"bff38eaeabeaece83dc8ed1697e5b052802753f6"},s("reviewPurchase",this.language)))):this.selectedIndex+1==3&&(this.tabContent=t("div",{key:"49a7fb3435fb50b54572ec38d1e632e2eacf56fb",class:"TabContent",ref:e=>this.stylingContainer=e},t("ul",{key:"7f642625f35a1ed1eae7655144c0b8b1bfe25f55"},t("li",{key:"037a5913be57dd1e2dcde5a061e9c64e70365e8d"},s("odds",this.language)),t("li",{key:"8775a1b2e8eda285e2c248b8d7235f06ac593fc6"},s("winGame",this.language)),t("li",{key:"5297fc5e757c29a1349049f1fe294e926255d518"},s("claimPrize",this.language))))),this.tabContent}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}}};d.style=":host{display:block}.TabContent{font-size:14px;color:var(--emw--color-typography, #000);font-weight:normal}";const h=class{constructor(t){e(this,t),this.disabled=!1,this.label=void 0,this.selected=!1,this.cmsEndpoint=void 0,this.selectedIndex=0,this.tabs=[{label:"How to Play"},{label:"About"},{label:"FAQs"}],this.clientStyling="",this.mbSource=void 0,this.clientStylingurl="",this.clientStylingUrl="",this.lowNumber=void 0,this.highNumber=void 0,this.minimumAllowed=void 0,this.maxinumAllowed=void 0,this.language="en",this.translationUrl=void 0}connectedCallback(){}handleClientStylingChange(e,t){e!=t&&c(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(e,t){e!=t&&this.clientStylingUrl&&l(this.stylingContainer,this.clientStylingUrl)}componentDidLoad(){this.stylingContainer&&(null!=window.emMessageBus?u(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription):(this.clientStyling&&c(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&l(this.stylingContainer,this.clientStylingUrl)))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}render(){return t("div",{key:"173c4774748482dc56fcffb4bac4e1666fa9170f",ref:e=>this.stylingContainer=e},t("div",{key:"680b65218e4b00f134b354f593c0c20fb5882dca",class:"Tabs"},this.tabs.map(((e,i)=>t("button",{class:"TabButton"+(this.selectedIndex==i?" Active":""),onClick:()=>this.selectedIndex=i},e.label)))),t("div",{key:"67aa26c92fb416c5d0934988fb071481f805685b"},t("helper-tab",{key:"63c8dfc253d4fc12b0310a2585a44b90807e1a9f","low-number":this.lowNumber,"high-number":this.highNumber,"minimum-allowed":this.minimumAllowed,"maxinum-allowed":this.maxinumAllowed,selectedIndex:this.selectedIndex,"client-styling":this.clientStyling,language:this.language,"translation-url":this.translationUrl,"client-stylingurl":this.clientStylingurl,"client-styling-url-content":this.clientStylingUrl,"mb-source":this.mbSource})))}get host(){return i(this)}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}}};h.style='@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap");:host{display:block;font-family:"Roboto", sans-serif}.Tabs{display:flex;gap:10px;overflow-x:auto}.TabButton{cursor:pointer;width:auto;border-radius:var(--emw--button-border-radius, 4px);padding:8px 15px;margin:5px 0 10px;border:1px solid var(--emw--color-primary, #009993);background:var(--emw--color-background, #fff);color:var(--emw--color-typography, #000);font-size:12px;transition:all 0.2s linear;text-align:center;letter-spacing:0;white-space:nowrap}.TabButton:hover{background:var(--emw--color-background-secondary, #f5f5f5)}.TabButton.Active{background:var(--emw--color-primary, #009993);color:var(--emw--color-background, #fff)}';export{d as helper_tab,h as helper_tabs}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/helper-tabs",
3
- "version": "1.87.26",
3
+ "version": "1.87.28",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",