(()=>{function e(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class t{constructor(){e(this,"cookieName","ezSession"),e(this,"domain",`${window.location.protocol}//${window.location.host}`),e(this,"appId",""),e(this,"authData",{}),e(this,"user",null),e(this,"logged",!1)}static setCookie(e){const t=new Date;t.setSeconds(t.getSeconds()+(e.expires_in||0)),document.cookie=`selc=${e.access_token};expires=${t.toUTCString()};path=/`}static removeCookie(){document.cookie="selc=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/"}init(e){let{onLogin:t,onLogout:o,appId:s}=e;this.onLogin=t,this.onLogout=o,this.appId=s,this.bindEvents(),this.getLocalData(),this.user?(this.logged=!0,this.readyCallback&&this.readyCallback(),this.onLogin&&this.onLogin()):this.getCurrentSession()}bindEvents(){window.addEventListener("message",(e=>{if(!new RegExp(`^https?://${window.location.host}`).test(e.origin))return;let o=null;try{o=JSON.parse(e.data)}catch(e){console.log(e)}if(o&&!o.trigger&&"helloWebsite"!==o.type)switch(o.event){case"userInfoUpdate":const{firstName:e,lastName:s,email:i,profilePictureUrl:n,hasPromoAccount:a}=o.data;this.user={...this.user||{},firstName:e,lastName:s,email:i,profilePictureUrl:n,hasPromoAccount:a},this.setLocalData(),this.onLogin&&this.onLogin();break;case"deleteUser":this.logout((()=>{window.location.href="/"}));break;case"forceChangePwd":window.location.href="/change-password-force";break;default:const{access_token:l,expires_in:r,state:c,token_type:h}=o;this.authData={...this.authData,access_token:l,expires_in:r,state:c,token_type:h},this.popup&&document.body.removeChild(this.popup),t.setCookie(this.authData),this.logged=!0,this.signUpToPromo(this.onLogin)}}))}login(e,t){for(let e=0;edocument.head.removeChild(s)))}getSlidelySession(e){t.sendJsonp({url:`${this.domain}/data/user/session`,callback:t=>{if(t.connected)if(this.user){const{firstName:o,userToken:s,email:i,profilePictureUrl:n}=this.user;t.firstName!==o||t.token!==s||t.email!==i||t.profilePictureUrl!==n?this.logout((()=>this.login(e))):e&&e()}else this.user={firstName:t.firstName,lastName:t.lastName,email:t.email,profilePictureUrl:t.profilePictureUrl,userToken:t.token,timestamp:Date.now(),hasPromoAccount:t.hasPromoAccount},this.setLocalData(),this.logged=!0,this.onLogin&&this.onLogin(),e&&e();else this.logout((()=>this.login(e)))}})}async signUpToPromo(e){const t=await(await fetch("/promoVideos/user/sign-up",{method:"POST"})).json();t.response&&t.response.success&&this.getCurrentSession(e)}openLoginPopup(e,o){var s;this.popup=document.createElement("div"),this.popup.setAttribute("class",`login-dialog-wrapper ${e}`);let i="";Object.entries(o).forEach((e=>{let[t,o]=e;i+=`&${encodeURIComponent(t)}=${encodeURIComponent(o)}`}));const{domain:n,appId:a}=this,l=`${n}/${e}?client_id=${a}&display=popup&state=${t.generateState()}${i}`;this.popup.innerHTML=`
\n \n \n
`,document.body.appendChild(this.popup),null===(s=document.querySelector(".login-close-button"))||void 0===s||s.addEventListener("click",(()=>{this.popup&&document.body.removeChild(this.popup),this.cancelCallback&&this.cancelCallback()})),setTimeout((()=>{const e=document.querySelector(".login-close-button");e&&(e.className="login-close-button")}),2e3)}async logout(e){for(let e=0;e