@everymatrix/bonus-elevate-levels 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.
@@ -1 +1 @@
1
- import{r as e,h as t,c as i,H as s,g as l}from"./index-422aaa76.js";const n=["ro","en","fr","hr","tr"],o={en:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},fr:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},hr:{level:"Razina",seeAll:"Vidi sve",privilegesFor:"Privilegije za",termsAndConditions:"Uvjeti i odredbe",noLevelsSet:"There is no level set",points:"Points"},ro:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},tr:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"}},a=(e,t)=>{const i=t;return o[void 0!==i&&(n.includes(i)||o[i])?i:"en"][e]},r=class{constructor(t){e(this,t),this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.endpoint=void 0,this.language="en",this.translationUrl="",this.selectedLevelId=void 0,this.showDefault=void 0,this.elevateLevelParamProxy=void 0,this.elevateLevels=[],this.currentLevel=void 0,this.errorMessage=void 0}selectedLevelChangedHandler(e){e.detail&&(this.currentLevel=Object.assign({},e.detail.level))}selectedLevelIdChangedHandler(){if(this.selectedLevelId&&this.elevateLevels){const e=this.elevateLevels.filter((e=>e.id==this.selectedLevelId))[0];this.currentLevel=Object.assign({},e)}}onSessionOrEndpointChange(){this.elevateLevelParamProxy=Object.assign(Object.assign({},this.elevateLevelParamProxy),{endpoint:this.endpoint,language:this.language})}elevateLevelsDataChangeHandler(e){e.detail&&(e.detail.currentLevel&&(this.currentLevel=Object.assign({},e.detail.currentLevel)),e.detail.elevateLevels&&(this.elevateLevels=[...e.detail.elevateLevels]),e.detail.clearError&&(this.errorMessage=null),e.detail.errorMessage&&e.detail.errorMessage.errorWhenLoadElevateLevels&&(this.errorMessage=a("loadElevateLevelErrorMessage",this.language)))}onTCClick(){window.postMessage({type:"termAndConditionClicked"},window.location.href)}componentWillLoad(){this.elevateLevelParamProxy={endpoint:this.endpoint,language:this.language,selectedLevelId:this.selectedLevelId,showDefault:this.showDefault}}render(){var e;return t("div",{key:"6bc46c87633a9a295108e50886096f67dd35d44a",class:"ElevateLevelContent"},t("elevate-levels-data",{key:"902d2796991a8acf293761255ab10f2cee54a92e",scopeParams:this.elevateLevelParamProxy}),t("div",{key:"7e47a25dce1d0fba40e3e432dd9c805aa5bbe308",class:"LevelContent"},(null===(e=this.elevateLevels)||void 0===e?void 0:e.length)?t("elevate-level-list",{language:this.language,selectedLevelId:this.selectedLevelId,levels:this.elevateLevels}):a("noLevelsSet",this.language),this.currentLevel&&t("elevate-level-presentation",{key:"dcfad9aa4422545fa74a7b8b957eb72001506046",elevateLevel:this.currentLevel})),this.errorMessage&&t("div",{key:"7e2741168e50a1ee2adebe39c2c3433b5c9bf7ca"},this.errorMessage),t("general-styling-wrapper",{key:"74cae021838f61964a519c2f200cfbb1f8470778",clientStyling:this.clientStyling,clientStylingUrl:this.clientStylingUrl,targetTranslations:o,translationUrl:this.translationUrl,mbSource:this.mbSource}))}static get watchers(){return{selectedLevelId:["selectedLevelIdChangedHandler"],elevateLevels:["selectedLevelIdChangedHandler"],endpoint:["onSessionOrEndpointChange"],language:["onSessionOrEndpointChange"]}}};var h;r.style=":host{display:block}.ElevateLevelContent{padding:20px;position:relative}.ElevateLevelContent .Privileges{padding-bottom:30px}.ElevateLevelContent .tc{position:absolute;right:10px;bottom:10px;text-align:right;display:none}",function(e){e[e.slideToRight=1]="slideToRight",e[e.slideToLeft=-1]="slideToLeft"}(h||(h={}));const d=class{constructor(t){var s;e(this,t),this.selectedLevelChanged=i(this,"selectedLevelChanged",7),this.minOffset=0,this.isMobile=!!((s=window.navigator.userAgent).toLowerCase().match(/android/i)||s.toLowerCase().match(/blackberry|bb/i)||s.toLowerCase().match(/iphone|ipad|ipod/i)||s.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i)),this.levels=void 0,this.language=void 0,this.selectedLevelId=void 0,this.showSliderButton=!1,this.touchPosStart=void 0,this.touchPosEnd=void 0,this.offset=0}onLevelClicked(e){this.selectedLevelChanged.emit({level:e}),this.selectedLevelId=e.id}levelsChangedHandler(){this.initOffsetOfLevelItems()}initOffsetOfLevelItems(){if(!this.levels||0==this.levels.length||!this.selectedLevelId)return;const e=this.levels.findIndex((e=>this.selectedLevelId==e.id));if(this.onLevelClicked(this.levels[-1==e?0:e]),this.levels.length<=this.moveCountForOneTouch)return;let t=Math.floor((-1==e?1:e+1)/this.moveCountForOneTouch)*this.moveCountForOneTouch*this.childElementWidth*-1;this.offset=t<=this.minOffset?this.minOffset:t>=0?0:t}onTouchStart(e){this.touchPosStart={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY}}onTouchMove(e){this.touchPosEnd={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY};const t=this.touchPosEnd.clientX-this.touchPosStart.clientX,i=this.touchPosEnd.clientY-this.touchPosStart.clientY;Math.abs(t)>Math.abs(i)&&this.slideTo(t>0?h.slideToRight:h.slideToLeft)}slideTo(e){let t=this.levelsElement.offsetLeft+this.childElementWidth*this.moveCountForOneTouch*e;if(t%this.childElementWidth!=0){const i=Math.floor(t/this.childElementWidth)*this.childElementWidth,s=Math.ceil(t/this.childElementWidth)*this.childElementWidth;t=e==h.slideToRight?i:s}this.offset=t<this.minOffset?this.minOffset:t>=0?0:t}initLevelSlider(){var e;if(!(null===(e=this.levelsElement)||void 0===e?void 0:e.firstElementChild))return void console.log("Widget[elevate-level-list] DOM is not ready.");this.showSliderButton=!this.isMobile&&this.levelsElement.clientWidth>this.levelsElement.parentElement.clientWidth,this.minOffset=this.levelsElement.parentElement.clientWidth-this.levelsElement.clientWidth,this.childElementWidth=this.levelsElement.firstElementChild.clientWidth,this.moveCountForOneTouch=Math.ceil(this.levelsElement.parentElement.clientWidth/this.childElementWidth)-1;const t=this.levelsElement.childElementCount;this.childElementWidth+=(this.levelsElement.clientWidth-this.childElementWidth*t)/(t-1)}debounce(e,t){{let i;return()=>{clearTimeout(i),i=setTimeout((()=>{e()}),t)}}}convertNumberToCompactForm(e){return e>=1e9?(e/1e9).toFixed(1).replace(/\.0$/,"")+"b":e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"m":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"k":e.toString()}handleResize(){this.debounce(this.initLevelSlider.bind(this),200)()}componentDidRender(){this.host.componentOnReady().then((()=>{this.initLevelSlider()}))}render(){return t(s,{key:"c2eb983ff3df4868204eec8e527efa08c9e5afa0"},this.levels&&[t("div",{key:"9f6563c030a7725761b9a73cffb8e2d8d8f47c32",class:`SliderButton LeftButton ${0==this.offset?"Disabled":""} ${this.showSliderButton?"":"Hidden"}`,onClick:()=>this.slideTo(h.slideToRight)},t("svg",{key:"9e3d3422bd2171d26821c1f74e3ab7418b97643d",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"ac0002e40e037edd0c0893c9250f36e18e451f16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"}))),t("div",{key:"242903f38deb464844d722e0e7fe90665de99d6a",class:"LevelItemsWrapper"},t("div",{key:"739328ff99ecd777b9e2ff6914034a5bbc7eac90",style:{left:`${this.offset}px`},class:"LevelItems "+(this.isMobile?"Mobile":""),id:"levelItems",ref:e=>{this.levelsElement=e}},this.levels.map(((e,i)=>t("div",{class:"Item "+(this.selectedLevelId==e.id?"Active":""),onClick:this.onLevelClicked.bind(this,e)},t("img",{alt:`Presentation Icon for ${e.presentation.displayName}`,class:"LevelImg",src:e.presentation.asset}),t("span",{class:"LevelName",title:e.presentation.displayName},e.presentation.displayName),t("span",{class:"LevelPoints"},0==i?"":">",this.convertNumberToCompactForm(e.firstEntryPoints)," ",a("points",this.language))))))),t("div",{key:"2366c09b46bfec309bd4f8d5991d457f04dbf038",class:`SliderButton RightButton ${this.offset<=this.minOffset?"Disabled":""} ${this.showSliderButton?"":"Hidden"}`,onClick:()=>this.slideTo(h.slideToLeft)},t("svg",{key:"c52ef4f99444d1185e9b8ce4287f0f2886c622ae",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"acc266646133bb636b52f8776380e6aedc93f937","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})))])}get host(){return l(this)}static get watchers(){return{selectedLevelId:["levelsChangedHandler"]}}};d.style="elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emw--color-gray-50, rgb(244, 244, 244));box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emw--color-gray-100, rgb(118, 113, 113));font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emw--color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}";const c=class{constructor(t){e(this,t),this.elevateLevel=void 0}render(){return t(s,{key:"16d128717e716f7ca7d3bb77fc3a2e67209318b6"},t("div",{key:"658657abdfc64844bd2af40562efe40385e1735a",class:"Row Desc"},t("h3",{key:"ec5871c2f810c8c120bf99510717381175bc1ef4"},this.elevateLevel.presentation.displayName),t("p",{key:"865915c6eea90295238fb47eaa91c8f968199ca5"},t("span",{key:"2b90c6c5d6957b73fc4a0f53d53da0ca023a4f0a",class:"TxtDesc",innerHTML:this.elevateLevel.presentation.description}))))}};c.style=":host{display:block}.PriviliegeList{padding-inline-start:5px}.PriviliegeList li{display:flex}.PriviliegeList li .Img{width:80px}.PriviliegeList li .Img img{width:60px;margin:10px}.PriviliegeList li .Content h4{text-transform:capitalize;margin-block-start:10px}";var v,f,p,g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},b={exports:{}};v=b,f=b.exports,p=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==g)return g;throw new Error("unable to locate global object")}(),v.exports=f=p.fetch,p.fetch&&(f.default=p.fetch.bind(p)),f.Headers=p.Headers,f.Request=p.Request,f.Response=p.Response;const u=b.exports,m=class{constructor(t){e(this,t),this.elevateLevelsDataChange=i(this,"elevateLevelsDataChange",7),this.scopeParams=void 0}async componentWillRender(){if(!this.scopeParams.endpoint)return;let e=new URL(`${this.scopeParams.endpoint}/v1/elevate/levels?language=${this.scopeParams.language}`);await u(e.href).then((e=>e.json())).then((e=>{const t=e.data.sort(((e,t)=>e.firstEntryPoints<t.firstEntryPoints?-1:1));let i=this.scopeParams.selectedLevelId;if(!i&&this.scopeParams.showDefault&&t.length>0&&(i=t[0].id),i){const e=t.filter((e=>e.id==i))[0];this.elevateLevelsDataChange.emit({currentLevel:e})}this.elevateLevelsDataChange.emit({clearError:!0}),this.elevateLevelsDataChange.emit({elevateLevels:t})})).catch((e=>{this.elevateLevelsDataChange.emit({errorMessage:{type:"errorWhenLoadElevateLevels",err:e}}),console.error(e)}))}};function w(e,t){if(e){const i=document.createElement("style");i.innerHTML=t,e.appendChild(i)}}function y(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)}))}m.style=":host{display:block}";const L=class{constructor(t){e(this,t),this.stylingAppends=!1,this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.translationUrl="",this.targetTranslations=void 0}componentDidLoad(){this.el&&(null!=window.emMessageBus?function(e,t){if(window.emMessageBus){const i=document.createElement("style");window.emMessageBus.subscribe(t,(t=>{i.innerHTML=t,e&&e.appendChild(i)}))}}(this.el,`${this.mbSource}.Style`):(this.clientStyling&&w(this.el,this.clientStyling),this.clientStylingUrl&&y(this.el,this.clientStylingUrl),this.stylingAppends=!0))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleClientStylingChange(e,t){e!=t&&w(this.el,this.clientStyling)}handleClientStylingUrlChange(e,t){e!=t&&this.clientStylingUrl&&y(this.el,this.clientStylingUrl)}componentDidRender(){this.stylingAppends||(this.clientStyling&&w(this.el,this.clientStyling),this.clientStylingUrl&&y(this.el,this.clientStylingUrl),this.stylingAppends=!0)}async componentWillLoad(){const e=[];if(this.translationUrl){const s=(t=this.translationUrl,i=this.targetTranslations,new Promise((e=>{fetch(t).then((e=>e.json())).then((t=>{Object.keys(t).forEach((e=>{i[e]=i[e]||{},Object.keys(t[e]).forEach((s=>{if(!i.en[s])return;const l=i.en[s];"object"==typeof t[e][s]?(i[e][s]=i[e][s]||Object.assign({},l),Object.keys(t[e][s]).forEach((l=>{i[e][s][l]=t[e][s][l]}))):i[e][s]=t[e][s]||Object.assign({},l)}))})),e(!0)})).catch((t=>{console.error("Failed to load translations:",t),e(!1)}))})));e.push(s)}var t,i;return await Promise.all(e)}render(){return t("div",{key:"09ad83748bbad518743c8671b986c541c52bf3f0",class:"StyleShell"},t("slot",{key:"3b28b776d3944410c717b002b70946d274a4e8e7",name:"mainContent"}))}get el(){return l(this)}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"]}}};L.style=":host{display:block}";export{r as bonus_elevate_levels,d as elevate_level_list,c as elevate_level_presentation,m as elevate_levels_data,L as general_styling_wrapper}
1
+ import{r as e,h as t,c as i,H as s,g as l}from"./index-422aaa76.js";const n=["ro","en","fr","hr","tr"],o={en:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},fr:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},hr:{level:"Razina",seeAll:"Vidi sve",privilegesFor:"Privilegije za",termsAndConditions:"Uvjeti i odredbe",noLevelsSet:"There is no level set",points:"Points"},ro:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},tr:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"}},a=(e,t)=>{const i=t;return o[void 0!==i&&(n.includes(i)||o[i])?i:"en"][e]},r=class{constructor(t){e(this,t),this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.endpoint=void 0,this.language="en",this.translationUrl="",this.selectedLevelId=void 0,this.showDefault=void 0,this.elevateLevelParamProxy=void 0,this.elevateLevels=[],this.currentLevel=void 0,this.errorMessage=void 0}selectedLevelChangedHandler(e){e.detail&&(this.currentLevel=Object.assign({},e.detail.level))}selectedLevelIdChangedHandler(){if(this.selectedLevelId&&this.elevateLevels){const e=this.elevateLevels.filter((e=>e.id==this.selectedLevelId))[0];this.currentLevel=Object.assign({},e)}}onSessionOrEndpointChange(){this.elevateLevelParamProxy=Object.assign(Object.assign({},this.elevateLevelParamProxy),{endpoint:this.endpoint,language:this.language})}elevateLevelsDataChangeHandler(e){e.detail&&(e.detail.currentLevel&&(this.currentLevel=Object.assign({},e.detail.currentLevel)),e.detail.elevateLevels&&(this.elevateLevels=[...e.detail.elevateLevels]),e.detail.clearError&&(this.errorMessage=null),e.detail.errorMessage&&e.detail.errorMessage.errorWhenLoadElevateLevels&&(this.errorMessage=a("loadElevateLevelErrorMessage",this.language)))}onTCClick(){window.postMessage({type:"termAndConditionClicked"},window.location.href)}componentWillLoad(){this.elevateLevelParamProxy={endpoint:this.endpoint,language:this.language,selectedLevelId:this.selectedLevelId,showDefault:this.showDefault}}render(){var e;return t("div",{key:"6bc46c87633a9a295108e50886096f67dd35d44a",class:"ElevateLevelContent"},t("elevate-levels-data",{key:"902d2796991a8acf293761255ab10f2cee54a92e",scopeParams:this.elevateLevelParamProxy}),t("div",{key:"7e47a25dce1d0fba40e3e432dd9c805aa5bbe308",class:"LevelContent"},(null===(e=this.elevateLevels)||void 0===e?void 0:e.length)?t("elevate-level-list",{language:this.language,selectedLevelId:this.selectedLevelId,levels:this.elevateLevels}):a("noLevelsSet",this.language),this.currentLevel&&t("elevate-level-presentation",{key:"dcfad9aa4422545fa74a7b8b957eb72001506046",elevateLevel:this.currentLevel})),this.errorMessage&&t("div",{key:"7e2741168e50a1ee2adebe39c2c3433b5c9bf7ca"},this.errorMessage),t("general-styling-wrapper",{key:"74cae021838f61964a519c2f200cfbb1f8470778",clientStyling:this.clientStyling,clientStylingUrl:this.clientStylingUrl,targetTranslations:o,translationUrl:this.translationUrl,mbSource:this.mbSource}))}static get watchers(){return{selectedLevelId:["selectedLevelIdChangedHandler"],elevateLevels:["selectedLevelIdChangedHandler"],endpoint:["onSessionOrEndpointChange"],language:["onSessionOrEndpointChange"]}}};var h;r.style=":host{display:block}.ElevateLevelContent{padding:20px;position:relative}.ElevateLevelContent .Privileges{padding-bottom:30px}.ElevateLevelContent .tc{position:absolute;right:10px;bottom:10px;text-align:right;display:none}",function(e){e[e.slideToRight=1]="slideToRight",e[e.slideToLeft=-1]="slideToLeft"}(h||(h={}));const d=class{constructor(t){var s;e(this,t),this.selectedLevelChanged=i(this,"selectedLevelChanged",7),this.minOffset=0,this.isMobile=!!((s=window.navigator.userAgent).toLowerCase().match(/android/i)||s.toLowerCase().match(/blackberry|bb/i)||s.toLowerCase().match(/iphone|ipad|ipod/i)||s.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i)),this.levels=void 0,this.language=void 0,this.selectedLevelId=void 0,this.showSliderButton=!1,this.touchPosStart=void 0,this.touchPosEnd=void 0,this.offset=0}onLevelClicked(e){this.selectedLevelChanged.emit({level:e}),this.selectedLevelId=e.id}levelsChangedHandler(){this.initOffsetOfLevelItems()}initOffsetOfLevelItems(){if(!this.levels||0==this.levels.length||!this.selectedLevelId)return;const e=this.levels.findIndex((e=>this.selectedLevelId==e.id));if(this.onLevelClicked(this.levels[-1==e?0:e]),this.levels.length<=this.moveCountForOneTouch)return;let t=Math.floor((-1==e?1:e+1)/this.moveCountForOneTouch)*this.moveCountForOneTouch*this.childElementWidth*-1;this.offset=t<=this.minOffset?this.minOffset:t>=0?0:t}onTouchStart(e){this.touchPosStart={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY}}onTouchMove(e){this.touchPosEnd={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY};const t=this.touchPosEnd.clientX-this.touchPosStart.clientX,i=this.touchPosEnd.clientY-this.touchPosStart.clientY;Math.abs(t)>Math.abs(i)&&this.slideTo(t>0?h.slideToRight:h.slideToLeft)}slideTo(e){let t=this.levelsElement.offsetLeft+this.childElementWidth*this.moveCountForOneTouch*e;if(t%this.childElementWidth!=0){const i=Math.floor(t/this.childElementWidth)*this.childElementWidth,s=Math.ceil(t/this.childElementWidth)*this.childElementWidth;t=e==h.slideToRight?i:s}this.offset=t<this.minOffset?this.minOffset:t>=0?0:t}initLevelSlider(){var e;if(!(null===(e=this.levelsElement)||void 0===e?void 0:e.firstElementChild))return void console.log("Widget[elevate-level-list] DOM is not ready.");this.showSliderButton=!this.isMobile&&this.levelsElement.clientWidth>this.levelsElement.parentElement.clientWidth,this.minOffset=this.levelsElement.parentElement.clientWidth-this.levelsElement.clientWidth,this.childElementWidth=this.levelsElement.firstElementChild.clientWidth,this.moveCountForOneTouch=Math.ceil(this.levelsElement.parentElement.clientWidth/this.childElementWidth)-1;const t=this.levelsElement.childElementCount;this.childElementWidth+=(this.levelsElement.clientWidth-this.childElementWidth*t)/(t-1)}debounce(e,t){{let i;return()=>{clearTimeout(i),i=setTimeout((()=>{e()}),t)}}}convertNumberToCompactForm(e){return e>=1e9?(e/1e9).toFixed(1).replace(/\.0$/,"")+"b":e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"m":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"k":e.toString()}handleResize(){this.debounce(this.initLevelSlider.bind(this),200)()}componentDidRender(){this.host.componentOnReady().then((()=>{this.initLevelSlider()}))}render(){return t(s,{key:"c2eb983ff3df4868204eec8e527efa08c9e5afa0"},this.levels&&[t("div",{key:"9f6563c030a7725761b9a73cffb8e2d8d8f47c32",class:`SliderButton LeftButton ${0==this.offset?"Disabled":""} ${this.showSliderButton?"":"Hidden"}`,onClick:()=>this.slideTo(h.slideToRight)},t("svg",{key:"9e3d3422bd2171d26821c1f74e3ab7418b97643d",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"ac0002e40e037edd0c0893c9250f36e18e451f16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"}))),t("div",{key:"242903f38deb464844d722e0e7fe90665de99d6a",class:"LevelItemsWrapper"},t("div",{key:"739328ff99ecd777b9e2ff6914034a5bbc7eac90",style:{left:`${this.offset}px`},class:"LevelItems "+(this.isMobile?"Mobile":""),id:"levelItems",ref:e=>{this.levelsElement=e}},this.levels.map(((e,i)=>t("div",{class:"Item "+(this.selectedLevelId==e.id?"Active":""),onClick:this.onLevelClicked.bind(this,e)},t("img",{alt:`Presentation Icon for ${e.presentation.displayName}`,class:"LevelImg",src:e.presentation.asset}),t("span",{class:"LevelName",title:e.presentation.displayName},e.presentation.displayName),t("span",{class:"LevelPoints"},0==i?"":">",this.convertNumberToCompactForm(e.firstEntryPoints)," ",a("points",this.language))))))),t("div",{key:"2366c09b46bfec309bd4f8d5991d457f04dbf038",class:`SliderButton RightButton ${this.offset<=this.minOffset?"Disabled":""} ${this.showSliderButton?"":"Hidden"}`,onClick:()=>this.slideTo(h.slideToLeft)},t("svg",{key:"c52ef4f99444d1185e9b8ce4287f0f2886c622ae",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"acc266646133bb636b52f8776380e6aedc93f937","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})))])}get host(){return l(this)}static get watchers(){return{selectedLevelId:["levelsChangedHandler"]}}};d.style="elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emw--color-gray-50, rgb(244, 244, 244));box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emw--color-gray-100, rgb(118, 113, 113));font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emw--color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}";const c=class{constructor(t){e(this,t),this.elevateLevel=void 0}render(){return t(s,{key:"16d128717e716f7ca7d3bb77fc3a2e67209318b6"},t("div",{key:"658657abdfc64844bd2af40562efe40385e1735a",class:"Row Desc"},t("h3",{key:"ec5871c2f810c8c120bf99510717381175bc1ef4"},this.elevateLevel.presentation.displayName),t("p",{key:"865915c6eea90295238fb47eaa91c8f968199ca5"},t("span",{key:"2b90c6c5d6957b73fc4a0f53d53da0ca023a4f0a",class:"TxtDesc",innerHTML:this.elevateLevel.presentation.description}))))}};c.style=":host{display:block}.PriviliegeList{padding-inline-start:5px}.PriviliegeList li{display:flex}.PriviliegeList li .Img{width:80px}.PriviliegeList li .Img img{width:60px;margin:10px}.PriviliegeList li .Content h4{text-transform:capitalize;margin-block-start:10px}";var v,f,p,g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},b={exports:{}};v=b,f=b.exports,p=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==g)return g;throw new Error("unable to locate global object")}(),v.exports=f=p.fetch,p.fetch&&(f.default=p.fetch.bind(p)),f.Headers=p.Headers,f.Request=p.Request,f.Response=p.Response;const u=b.exports,w=class{constructor(t){e(this,t),this.elevateLevelsDataChange=i(this,"elevateLevelsDataChange",7),this.scopeParams=void 0}async componentWillRender(){if(!this.scopeParams.endpoint)return;let e=new URL(`${this.scopeParams.endpoint}/v1/elevate/levels?language=${this.scopeParams.language}`);await u(e.href).then((e=>e.json())).then((e=>{const t=e.data.sort(((e,t)=>e.firstEntryPoints<t.firstEntryPoints?-1:1));let i=this.scopeParams.selectedLevelId;if(!i&&this.scopeParams.showDefault&&t.length>0&&(i=t[0].id),i){const e=t.filter((e=>e.id==i))[0];this.elevateLevelsDataChange.emit({currentLevel:e})}this.elevateLevelsDataChange.emit({clearError:!0}),this.elevateLevelsDataChange.emit({elevateLevels:t})})).catch((e=>{this.elevateLevelsDataChange.emit({errorMessage:{type:"errorWhenLoadElevateLevels",err:e}}),console.error(e)}))}};w.style=":host{display:block}";const m="__WIDGET_GLOBAL_STYLE_CACHE__";function y(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)}))}const x=class{constructor(t){e(this,t),this.stylingAppends=!1,this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.translationUrl="",this.targetTranslations=void 0}componentDidLoad(){this.el&&(null!=window.emMessageBus?function(e,t,i,s=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!s)return function(e,t){const i=document.createElement("style");return window.emMessageBus.subscribe(t,(t=>{e&&(i.innerHTML=t,e.appendChild(i))}))}(e,t);window[m]||(window[m]={});const l=(i=function(e,t){return window.emMessageBus.subscribe(t,(i=>{if(!e)return;const s=e.getRootNode(),l=window[m];let n=l[t]?.sheet;n?l[t].refCount=l[t].refCount+1:(n=new CSSStyleSheet,n.replaceSync(i),l[t]={sheet:n,refCount:1});const o=s.adoptedStyleSheets||[];o.includes(n)||(s.adoptedStyleSheets=[...o,n])}))}(e,t)).unsubscribe.bind(i);i.unsubscribe=()=>{if(window[m][t]){const e=window[m][t];e.refCount>1?e.refCount=e.refCount-1:delete window[m][t]}l()}}(this.el,`${this.mbSource}.Style`,this.stylingSubscription):(this.clientStyling&&y(this.el,this.clientStyling),this.clientStylingUrl&&L(this.el,this.clientStylingUrl),this.stylingAppends=!0))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleClientStylingChange(e,t){e!=t&&y(this.el,this.clientStyling)}handleClientStylingUrlChange(e,t){e!=t&&this.clientStylingUrl&&L(this.el,this.clientStylingUrl)}componentDidRender(){this.stylingAppends||(this.clientStyling&&y(this.el,this.clientStyling),this.clientStylingUrl&&L(this.el,this.clientStylingUrl),this.stylingAppends=!0)}async componentWillLoad(){const e=[];if(this.translationUrl){const s=(t=this.translationUrl,i=this.targetTranslations,new Promise((e=>{fetch(t).then((e=>e.json())).then((t=>{Object.keys(t).forEach((e=>{i[e]=i[e]||{},Object.keys(t[e]).forEach((s=>{if(!i.en[s])return;const l=i.en[s];"object"==typeof t[e][s]?(i[e][s]=i[e][s]||Object.assign({},l),Object.keys(t[e][s]).forEach((l=>{i[e][s][l]=t[e][s][l]}))):i[e][s]=t[e][s]||Object.assign({},l)}))})),e(!0)})).catch((t=>{console.error("Failed to load translations:",t),e(!1)}))})));e.push(s)}var t,i;return await Promise.all(e)}render(){return t("div",{key:"09ad83748bbad518743c8671b986c541c52bf3f0",class:"StyleShell"},t("slot",{key:"3b28b776d3944410c717b002b70946d274a4e8e7",name:"mainContent"}))}get el(){return l(this)}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"]}}};x.style=":host{display:block}";export{r as bonus_elevate_levels,d as elevate_level_list,c as elevate_level_presentation,w as elevate_levels_data,x as general_styling_wrapper}
@@ -395,6 +395,8 @@ const mergeTranslations = (url, target) => {
395
395
  });
396
396
  };
397
397
 
398
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
399
+
398
400
  /**
399
401
  * @name setClientStyling
400
402
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -440,18 +442,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
440
442
  * @param {HTMLElement} stylingContainer The highest element of the widget
441
443
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
442
444
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
445
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
443
446
  */
444
- function setStreamStyling(stylingContainer, domain, subscription) {
445
- if (window.emMessageBus) {
446
- const sheet = document.createElement('style');
447
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
448
+ if (!window.emMessageBus) return;
447
449
 
448
- window.emMessageBus.subscribe(domain, (data) => {
449
- sheet.innerHTML = data;
450
- if (stylingContainer) {
451
- stylingContainer.appendChild(sheet);
452
- }
453
- });
450
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
451
+
452
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
453
+ subscription = getStyleTagSubscription(stylingContainer, domain);
454
+
455
+ return subscription;
456
+ }
457
+
458
+ if (!window[StyleCacheKey]) {
459
+ window[StyleCacheKey] = {};
454
460
  }
461
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
462
+
463
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
464
+ const wrappedUnsubscribe = () => {
465
+ if (window[StyleCacheKey][domain]) {
466
+ const cachedObject = window[StyleCacheKey][domain];
467
+ cachedObject.refCount > 1
468
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
469
+ : delete window[StyleCacheKey][domain];
470
+ }
471
+
472
+ originalUnsubscribe();
473
+ };
474
+ subscription.unsubscribe = wrappedUnsubscribe;
475
+
476
+ return subscription;
477
+ }
478
+
479
+ function getStyleTagSubscription(stylingContainer, domain) {
480
+ const sheet = document.createElement('style');
481
+
482
+ return window.emMessageBus.subscribe(domain, (data) => {
483
+ if (stylingContainer) {
484
+ sheet.innerHTML = data;
485
+ stylingContainer.appendChild(sheet);
486
+ }
487
+ });
488
+ }
489
+
490
+ function getAdoptStyleSubscription(stylingContainer, domain) {
491
+ return window.emMessageBus.subscribe(domain, (data) => {
492
+ if (!stylingContainer) return;
493
+
494
+ const shadowRoot = stylingContainer.getRootNode();
495
+ const cacheStyleObject = window[StyleCacheKey];
496
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
497
+
498
+ if (!cachedStyle) {
499
+ cachedStyle = new CSSStyleSheet();
500
+ cachedStyle.replaceSync(data);
501
+ cacheStyleObject[domain] = {
502
+ sheet: cachedStyle,
503
+ refCount: 1
504
+ };
505
+ } else {
506
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
507
+ }
508
+
509
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
510
+ if (!currentSheets.includes(cachedStyle)) {
511
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
512
+ }
513
+ });
455
514
  }
456
515
 
457
516
  const generalStylingWrapperCss = ":host{display:block}";
@@ -470,7 +529,7 @@ const GeneralStylingWrapper = class {
470
529
  componentDidLoad() {
471
530
  if (this.el) {
472
531
  if (window.emMessageBus != undefined) {
473
- setStreamStyling(this.el, `${this.mbSource}.Style`);
532
+ setStreamStyling(this.el, `${this.mbSource}.Style`, this.stylingSubscription);
474
533
  }
475
534
  else {
476
535
  if (this.clientStyling)
@@ -391,6 +391,8 @@ const mergeTranslations = (url, target) => {
391
391
  });
392
392
  };
393
393
 
394
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
395
+
394
396
  /**
395
397
  * @name setClientStyling
396
398
  * @description Method used to create and append to the passed element of the widget a style element with the content received
@@ -436,18 +438,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
436
438
  * @param {HTMLElement} stylingContainer The highest element of the widget
437
439
  * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
438
440
  * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
441
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
439
442
  */
440
- function setStreamStyling(stylingContainer, domain, subscription) {
441
- if (window.emMessageBus) {
442
- const sheet = document.createElement('style');
443
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
444
+ if (!window.emMessageBus) return;
443
445
 
444
- window.emMessageBus.subscribe(domain, (data) => {
445
- sheet.innerHTML = data;
446
- if (stylingContainer) {
447
- stylingContainer.appendChild(sheet);
448
- }
449
- });
446
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
447
+
448
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
449
+ subscription = getStyleTagSubscription(stylingContainer, domain);
450
+
451
+ return subscription;
452
+ }
453
+
454
+ if (!window[StyleCacheKey]) {
455
+ window[StyleCacheKey] = {};
450
456
  }
457
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
458
+
459
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
460
+ const wrappedUnsubscribe = () => {
461
+ if (window[StyleCacheKey][domain]) {
462
+ const cachedObject = window[StyleCacheKey][domain];
463
+ cachedObject.refCount > 1
464
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
465
+ : delete window[StyleCacheKey][domain];
466
+ }
467
+
468
+ originalUnsubscribe();
469
+ };
470
+ subscription.unsubscribe = wrappedUnsubscribe;
471
+
472
+ return subscription;
473
+ }
474
+
475
+ function getStyleTagSubscription(stylingContainer, domain) {
476
+ const sheet = document.createElement('style');
477
+
478
+ return window.emMessageBus.subscribe(domain, (data) => {
479
+ if (stylingContainer) {
480
+ sheet.innerHTML = data;
481
+ stylingContainer.appendChild(sheet);
482
+ }
483
+ });
484
+ }
485
+
486
+ function getAdoptStyleSubscription(stylingContainer, domain) {
487
+ return window.emMessageBus.subscribe(domain, (data) => {
488
+ if (!stylingContainer) return;
489
+
490
+ const shadowRoot = stylingContainer.getRootNode();
491
+ const cacheStyleObject = window[StyleCacheKey];
492
+ let cachedStyle = cacheStyleObject[domain]?.sheet;
493
+
494
+ if (!cachedStyle) {
495
+ cachedStyle = new CSSStyleSheet();
496
+ cachedStyle.replaceSync(data);
497
+ cacheStyleObject[domain] = {
498
+ sheet: cachedStyle,
499
+ refCount: 1
500
+ };
501
+ } else {
502
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
503
+ }
504
+
505
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
506
+ if (!currentSheets.includes(cachedStyle)) {
507
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
508
+ }
509
+ });
451
510
  }
452
511
 
453
512
  const generalStylingWrapperCss = ":host{display:block}";
@@ -466,7 +525,7 @@ const GeneralStylingWrapper = class {
466
525
  componentDidLoad() {
467
526
  if (this.el) {
468
527
  if (window.emMessageBus != undefined) {
469
- setStreamStyling(this.el, `${this.mbSource}.Style`);
528
+ setStreamStyling(this.el, `${this.mbSource}.Style`, this.stylingSubscription);
470
529
  }
471
530
  else {
472
531
  if (this.clientStyling)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/bonus-elevate-levels",
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",