1import{t as e}from"./js.cookie.LuQ0sRX_.js";import{t}from"./module-manager.CqXtpMP0.js";import{t as n}from"./template.BE1O4iVs.js";import{t as r}from"./config.CtyhlRqQ.js";var i=class{constructor(e){this.el=e,this.cookieName=`voucher`,this.init()}init(){document.addEventListener(`OTC0003`,()=>this.validate())}validate(){let t=e.get(this.cookieName),n,r;if(t){let e=new URLSearchParams(`?`+t);n=e.get(`actionId`),r=e.get(`voucherCode`)}else{let e=new URLSearchParams(window.location.search);n=e.get(`actionId`),r=e.get(`voucherCode`)}if(n&&r){let i=new URLSearchParams({actionId:n,voucherCode:r});fetch(`${this.el.dataset.url}?${i}`).then(e=>e.json()).catch(e=>{throw console.log(`error ->`,e),e}).then(i=>{i.campaignDurationInSeconds>0&&i.voucherCode.valid&&i.voucherCode.status===`OPEN`?(t||this.createCookie(n,r,i.campaignDurationInSeconds,i.campaign.descriptionExternal),this.render(i)):e.remove(this.cookieName)})}}render(t){let r=n(document.getElementById(`header-voucher-tmpl`).textContent),i=e.get(this.cookieName),a=new URLSearchParams(`?`+i),o=a.get(`closed`),s=new Date(a.get(`expiresTimestamp`)).getTime(),c=a.get(`modalText`),l=a.get(`voucherCode`),u=s-Date.now();u<=0||o!==`false`||(document.querySelector(`.module-voucher`)?.classList.remove(`d-none`),document.querySelector(`#modal-voucher .modal-body`).innerHTML=c,document.querySelector(`#modal-voucher .modal-body`).innerHTML=c,this.templateOptions={code:l,time:this.formatTime(u),value:t.campaign.value,currency:t.campaign.currency},this.startCountdown(s),this.el.innerHTML=r(this.templateOptions),this.el.classList.add(`rendered`),this.el.addEventListener(`closed.bs.alert`,()=>{this.close()}))}createCookie(t,n,i,a){let o=Date.now()+i*1e3,s=`actionId=${t}&voucherCode=${n}&expiresTimestamp=${new Date(o).toUTCString()}&modalText=${a}&closed=false`;e.set(this.cookieName,s,{...r,expires:i})}close(){clearInterval(this.countdownInterval),this.el.innerHTML=``;let t=e.get(this.cookieName),n=new URLSearchParams(`?`+t),r=`actionId=${n.get(`actionId`)}&voucherCode=${n.get(`voucherCode`)}&expiresTimestamp=${n.get(`expiresTimestamp`)}&modalText=${n.get(`modalText`)}&closed=true`,i=new Date,a=new Date(n.get(`expiresTimestamp`)),o=Math.round((a-i)/1e3);e.set(this.cookieName,r,{expires:o})}startCountdown(e){this.countdownInterval=setInterval(()=>{let t=e-Date.now();if(t<=0){this.hideBanner(),clearInterval(this.countdownInterval);return}this.templateOptions.time=this.formatTime(t);let r=n(document.getElementById(`header-voucher-tmpl`).textContent);this.el.innerHTML=r(this.templateOptions)},1e3)}formatTime(e){let t=Math.floor(e%36e5/6e4),n=Math.floor(e%6e4/1e3);return`${(`0`+t).slice(-2)}:${(`0`+n).slice(-2)}`}hideBanner(){e.remove(this.cookieName),this.el.innerHTML=``}};t.register(()=>{document.querySelectorAll(`.module-header-voucher`).forEach(e=>{new i(e)})});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.