var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n({connectError:e}={}){return`
    <div class="offlinescreen_screen">
      <div class="offlinescreen_status">Offline</div>
      <div class="offlinescreen_version">v0.0.7</div>
      <div class="offlinescreen_center">
        ${e?`<div class="offlinescreen_connect_error">${e}</div>`:``}
      </div>
      <div class="offlinescreen_bottom_nav">
        <button type="button" class="offlinescreen_nav_btn" data-offlinescreen-action="connect">Connect</button>
        <button type="button" class="offlinescreen_nav_btn">System</button>
        <button type="button" class="offlinescreen_nav_btn">Reboot</button>
        <button type="button" class="offlinescreen_nav_btn" data-offlinescreen-action="power-off">Power Off</button>
      </div>
    </div>
  `}function r(e,{onAction:t}){e.querySelectorAll(`[data-offlinescreen-action]`).forEach(e=>{e.addEventListener(`click`,()=>{t(e.dataset.offlinescreenAction)})})}function i(){return`
    <div class="onlinescreen_screen">
      <div class="onlinescreen_status">Online</div>
      <div class="onlinescreen_center">Connected....</div>
      <div class="onlinescreen_bottom_nav">
        <button type="button" class="onlinescreen_nav_btn" data-onlinescreen-action="disconnect">Disconnect</button>
        <button type="button" class="onlinescreen_nav_btn" data-onlinescreen-action="login-screen">Login</button>
        <button type="button" class="onlinescreen_nav_btn">System</button>
        <button type="button" class="onlinescreen_nav_btn">Reboot</button>
        <button type="button" class="onlinescreen_nav_btn" data-onlinescreen-action="power-off">Power Off</button>
      </div>
    </div>
  `}function a(e,{onAction:t}){e.querySelectorAll(`[data-onlinescreen-action]`).forEach(e=>{e.addEventListener(`click`,()=>{t(e.dataset.onlinescreenAction)})})}var o=Object.create(null);o.open=`0`,o.close=`1`,o.ping=`2`,o.pong=`3`,o.message=`4`,o.upgrade=`5`,o.noop=`6`;var s=Object.create(null);Object.keys(o).forEach(e=>{s[o[e]]=e});var c={type:`error`,data:`parser error`},l=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,u=typeof ArrayBuffer==`function`,d=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,f=({type:e,data:t},n,r)=>l&&t instanceof Blob?n?r(t):p(t,r):u&&(t instanceof ArrayBuffer||d(t))?n?r(t):p(new Blob([t]),r):r(o[e]+(t||``)),p=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function m(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var h;function g(e,t){if(l&&e.data instanceof Blob)return e.data.arrayBuffer().then(m).then(t);if(u&&(e.data instanceof ArrayBuffer||d(e.data)))return t(m(e.data));f(e,!1,e=>{h||=new TextEncoder,t(h.encode(e))})}var _=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,v=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)v[_.charCodeAt(e)]=e;var ee=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=v[e.charCodeAt(r)],o=v[e.charCodeAt(r+1)],s=v[e.charCodeAt(r+2)],c=v[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},te=typeof ArrayBuffer==`function`,ne=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:ie(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:re(e.substring(1),t)}:s[n]?e.length>1?{type:s[n],data:e.substring(1)}:{type:s[n]}:c},re=(e,t)=>te?ie(ee(e),t):{base64:!0,data:e},ie=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},ae=``,oe=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{f(e,!1,e=>{r[a]=e,++i===n&&t(r.join(ae))})})},se=(e,t)=>{let n=e.split(ae),r=[];for(let e=0;e<n.length;e++){let i=ne(n[e],t);if(r.push(i),i.type===`error`)break}return r};function ce(){return new TransformStream({transform(e,t){g(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var le;function ue(e){return e.reduce((e,t)=>e+t.length,0)}function de(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function fe(e,t){le||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(ue(n)<1)break;let e=de(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(ue(n)<2)break;let e=de(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(ue(n)<8)break;let e=de(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(c);break}i=a*2**32+t.getUint32(4),r=3}else{if(ue(n)<i)break;let e=de(n,i);s.enqueue(ne(a?e:le.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(c);break}}}})}function y(e){if(e)return pe(e)}function pe(e){for(var t in y.prototype)e[t]=y.prototype[t];return e}y.prototype.on=y.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},y.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},y.prototype.off=y.prototype.removeListener=y.prototype.removeAllListeners=y.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},y.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},y.prototype.emitReserved=y.prototype.emit,y.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},y.prototype.hasListeners=function(e){return!!this.listeners(e).length};var me=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),b=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),he=`arraybuffer`;function ge(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var _e=b.setTimeout,ve=b.clearTimeout;function ye(e,t){t.useNativeTimers?(e.setTimeoutFn=_e.bind(b),e.clearTimeoutFn=ve.bind(b)):(e.setTimeoutFn=b.setTimeout.bind(b),e.clearTimeoutFn=b.clearTimeout.bind(b))}var be=1.33;function xe(e){return typeof e==`string`?Se(e):Math.ceil((e.byteLength||e.size)*be)}function Se(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Ce(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function we(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function Te(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var Ee=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},De=class extends y{constructor(e){super(),this.writable=!1,ye(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new Ee(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=ne(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=we(e);return t.length?`?`+t:``}},Oe=class extends De{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){se(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,oe(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ce()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},ke=!1;try{ke=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Ae=ke;function je(){}var Me=class extends Oe{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},Ne=class e extends y{constructor(e,t,n){super(),this.createRequest=e,ye(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=ge(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=je,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(Ne.requestsCount=0,Ne.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,Pe);else if(typeof addEventListener==`function`){let e=`onpagehide`in b?`pagehide`:`unload`;addEventListener(e,Pe,!1)}}function Pe(){for(let e in Ne.requests)Ne.requests.hasOwnProperty(e)&&Ne.requests[e].abort()}var Fe=(function(){let e=Le({xdomain:!1});return e&&e.responseType!==null})(),Ie=class extends Me{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Fe&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Ne(Le,this.uri(),e)}};function Le(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Ae))return new XMLHttpRequest}catch{}if(!t)try{return new b[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var Re=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,ze=class extends De{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Re?{}:ge(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;f(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&me(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ce()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Be=b.WebSocket||b.MozWebSocket,Ve={websocket:class extends ze{createSocket(e,t,n){return Re?new Be(e,t,n):t?new Be(e,t):new Be(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends De{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=fe(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=ce();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&me(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:Ie},He=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ue=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function We(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=He.exec(e||``),a={},o=14;for(;o--;)a[Ue[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=Ge(a,a.path),a.queryKey=Ke(a,a.query),a}function Ge(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function Ke(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var qe=typeof addEventListener==`function`&&typeof removeEventListener==`function`,Je=[];qe&&addEventListener(`offline`,()=>{Je.forEach(e=>e())},!1);var Ye=class e extends y{constructor(e,t){if(super(),this.binaryType=he,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=We(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=We(t.host).host);ye(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=Te(this.opts.query)),qe&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},Je.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=xe(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,me(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),qe&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=Je.indexOf(this._offlineEventListener);e!==-1&&Je.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};Ye.protocol=4;var Xe=class extends Ye{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;Ye.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;Ye.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},Ze=class extends Xe{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>Ve[e]).filter(e=>!!e)),super(e,n)}};Ze.protocol;function Qe(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=We(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var $e=typeof ArrayBuffer==`function`,et=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,tt=Object.prototype.toString,nt=typeof Blob==`function`||typeof Blob<`u`&&tt.call(Blob)===`[object BlobConstructor]`,rt=typeof File==`function`||typeof File<`u`&&tt.call(File)===`[object FileConstructor]`;function it(e){return $e&&(e instanceof ArrayBuffer||et(e))||nt&&e instanceof Blob||rt&&e instanceof File}function at(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(at(e[t]))return!0;return!1}if(it(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return at(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&at(e[t]))return!0;return!1}function ot(e){let t=[],n=e.data,r=e;return r.data=st(n,t),r.attachments=t.length,{packet:r,buffers:t}}function st(e,t){if(!e)return e;if(it(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=st(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=st(e[r],t));return n}return e}function ct(e,t){return e.data=lt(e.data,t),delete e.attachments,e}function lt(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=lt(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=lt(e[n],t));return e}var ut=t({Decoder:()=>pt,Encoder:()=>ft,PacketType:()=>x,isPacketValid:()=>bt,protocol:()=>5}),dt=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],x;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(x||={});var ft=class{constructor(e){this.replacer=e}encode(e){return(e.type===x.EVENT||e.type===x.ACK)&&at(e)?this.encodeAsBinary({type:e.type===x.EVENT?x.BINARY_EVENT:x.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===x.BINARY_EVENT||e.type===x.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=ot(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},pt=class e extends y{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===x.BINARY_EVENT;n||t.type===x.BINARY_ACK?(t.type=n?x.EVENT:x.ACK,this.reconstructor=new mt(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(it(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(x[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===x.BINARY_EVENT||r.type===x.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!gt(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case x.CONNECT:return vt(t);case x.DISCONNECT:return t===void 0;case x.CONNECT_ERROR:return typeof t==`string`||vt(t);case x.EVENT:case x.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&dt.indexOf(t[0])===-1);case x.ACK:case x.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},mt=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=ct(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function ht(e){return typeof e==`string`}var gt=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function _t(e){return e===void 0||gt(e)}function vt(e){return Object.prototype.toString.call(e)===`[object Object]`}function yt(e,t){switch(e){case x.CONNECT:return t===void 0||vt(t);case x.DISCONNECT:return t===void 0;case x.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&dt.indexOf(t[0])===-1);case x.ACK:return Array.isArray(t);case x.CONNECT_ERROR:return typeof t==`string`||vt(t);default:return!1}}function bt(e){return ht(e.nsp)&&_t(e.id)&&yt(e.type,e.data)}function S(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var xt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),St=class extends y{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[S(e,`open`,this.onopen.bind(this)),S(e,`packet`,this.onpacket.bind(this)),S(e,`error`,this.onerror.bind(this)),S(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(xt.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:x.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:x.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case x.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case x.EVENT:case x.BINARY_EVENT:this.onevent(e);break;case x.ACK:case x.BINARY_ACK:this.onack(e);break;case x.DISCONNECT:this.ondisconnect();break;case x.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:x.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:x.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function Ct(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ct.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},Ct.prototype.reset=function(){this.attempts=0},Ct.prototype.setMin=function(e){this.ms=e},Ct.prototype.setMax=function(e){this.max=e},Ct.prototype.setJitter=function(e){this.jitter=e};var wt=class extends y{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,ye(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new Ct({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||ut;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new Ze(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=S(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=S(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(S(e,`ping`,this.onping.bind(this)),S(e,`data`,this.ondata.bind(this)),S(e,`error`,this.onerror.bind(this)),S(e,`close`,this.onclose.bind(this)),S(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){me(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new St(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},Tt={};function Et(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=Qe(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=Tt[i]&&a in Tt[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new wt(r,t):(Tt[i]||(Tt[i]=new wt(r,t)),c=Tt[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(Et,{Manager:wt,Socket:St,io:Et,connect:Et});var Dt=`deluxInstallDeviceId`;function Ot(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`d-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,14)}`}function kt(){try{let e=localStorage.getItem(Dt);return(!e||String(e).trim()===``)&&(e=Ot(),localStorage.setItem(Dt,e)),String(e).trim().slice(0,64)}catch{return Ot().slice(0,64)}}var At=`[delux_socket_client]`,C=null;function jt(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(jt);let t={};for(let[n,r]of Object.entries(e))/password|passwd|pwd|secret|token|authorization/i.test(n)?t[n]=r!=null&&String(r).length>0?`***`:r:typeof r==`object`&&r?t[n]=jt(r):t[n]=r;return t}function w(e,t,n){let r=jt(n),i=r===void 0?``:` ${JSON.stringify(r)}`;console.log(`${At} ${e} evt=${t}${i}`)}function Mt(e){if(e)try{e.disconnect()}catch{}}function Nt(e){e.onAny((e,...t)=>{w(`IN`,e,t.length===0?void 0:t.length===1?t[0]:t)}),e.on(`connect`,()=>{w(`CONN`,`socket_connect`,{id:e.id})}),e.on(`disconnect`,e=>{w(`DISC`,`socket_disconnect`,{reason:e})}),e.on(`connect_error`,e=>{w(`ERR`,`socket_connect_error`,{message:e?.message})})}function Pt(){return`http://68.178.166.16:5677`}function Ft(){return Pt()}async function It(){let e=Pt();return C?.connected?C:(C&&=(Mt(C),null),w(`OPEN`,`io`,{url:e}),C=Et(e,{transports:[`websocket`,`polling`],reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1e3}),Nt(C),new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`CONNECT_TIMEOUT`))},15e3);C.once(`connect`,()=>{clearTimeout(n),e(C)}),C.once(`connect_error`,e=>{clearTimeout(n),Mt(C),C=null,t(e)})}))}function Lt(){C&&=(w(`CLOSE`,`disconnectDeluxSocket`,{}),Mt(C),null)}async function Rt(e,t){if(!C?.connected)return w(`SKIP`,`delux_login`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let n=kt();return w(`OUT`,`delux_login`,{userCode:e,password:t,deviceId:n}),new Promise(r=>{let i=setTimeout(()=>{C.off(`delux_login_response`,a),w(`ERR`,`delux_login_timeout`,{error:`TIMEOUT`}),r({ok:!1,error:`TIMEOUT`})},15e3);function a(e){clearTimeout(i),r(e)}C.once(`delux_login_response`,a),C.emit(`delux_login`,{userCode:e,password:t,deviceId:n})})}async function zt(e,t,n){return C?.connected?(w(`OUT`,`delux_place_bet`,{userCode:e,drawTime:t,betListArray:n}),new Promise(r=>{let i=setTimeout(()=>{C.off(`delux_place_bet_response`,a),w(`ERR`,`delux_place_bet_timeout`,{error:`TIMEOUT`}),r({ok:!1,error:`TIMEOUT`})},15e3);function a(e){clearTimeout(i),r(e)}C.once(`delux_place_bet_response`,a),C.emit(`delux_place_bet`,{userCode:e,drawTime:t,mainbetarray:n})})):(w(`SKIP`,`delux_place_bet`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`})}async function Bt(e){if(!C?.connected)return w(`SKIP`,`delux_get_user_ac`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let t=e==null?``:String(e).trim();return t?(w(`OUT`,`delux_get_user_ac`,{userCode:t}),new Promise(e=>{let n=setTimeout(()=>{C.off(`delux_get_user_ac_response`,r),w(`ERR`,`delux_get_user_ac_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`})},15e3);function r(t){clearTimeout(n),e(t)}C.once(`delux_get_user_ac_response`,r),C.emit(`delux_get_user_ac`,{userCode:t})})):(w(`SKIP`,`delux_get_user_ac`,{ok:!1,error:`MISSING_FIELDS`}),{ok:!1,error:`MISSING_FIELDS`})}async function Vt(e,t){if(!C?.connected)return w(`SKIP`,`delux_set_user_ac`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let n=e==null?``:String(e).trim(),r=Number(t);return!n||r!==1&&r!==0?(w(`SKIP`,`delux_set_user_ac`,{ok:!1,error:`MISSING_FIELDS`}),{ok:!1,error:`MISSING_FIELDS`}):(w(`OUT`,`delux_set_user_ac`,{userCode:n,ac:r}),new Promise(e=>{let t=setTimeout(()=>{C.off(`delux_set_user_ac_response`,i),w(`ERR`,`delux_set_user_ac_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`})},15e3);function i(n){clearTimeout(t),e(n)}C.once(`delux_set_user_ac_response`,i),C.emit(`delux_set_user_ac`,{userCode:n,ac:r})}))}async function Ht(e){return C?.connected?(w(`OUT`,`delux_get_balance`,{userCode:e}),new Promise(t=>{let n=setTimeout(()=>{C.off(`delux_get_balance_response`,r),w(`ERR`,`delux_get_balance_timeout`,{error:`TIMEOUT`}),t({ok:!1,error:`TIMEOUT`})},15e3);function r(e){clearTimeout(n),t(e)}C.once(`delux_get_balance_response`,r),C.emit(`delux_get_balance`,{userCode:e})})):(w(`SKIP`,`delux_get_balance`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`})}async function Ut(e,t){if(!C?.connected)return w(`SKIP`,`delux_get_result_history`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let n={userCode:e};return t!=null&&String(t).trim()!==``&&(n.lotdate=String(t).trim()),w(`OUT`,`delux_get_result_history`,n),new Promise(e=>{let t=setTimeout(()=>{C.off(`delux_get_result_history_response`,r),w(`ERR`,`delux_get_result_history_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`})},15e3);function r(n){clearTimeout(t),e(n)}C.once(`delux_get_result_history_response`,r),C.emit(`delux_get_result_history`,n)})}async function Wt(){return C?.connected?(w(`OUT`,`delux_get_winning_number`,{}),new Promise(e=>{let t=setTimeout(()=>{C.off(`delux_get_winning_number_response`,n),w(`ERR`,`delux_get_winning_number_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`})},15e3);function n(n){clearTimeout(t),e(n)}C.once(`delux_get_winning_number_response`,n),C.emit(`delux_get_winning_number`,{})})):(w(`SKIP`,`delux_get_winning_number`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`})}async function Gt(e){if(!C?.connected)return w(`SKIP`,`delux_get_last_bet_receipt`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let t=e==null?``:String(e).trim();return t?(w(`OUT`,`delux_get_last_bet_receipt`,{userCode:t}),new Promise(e=>{let n=setTimeout(()=>{C.off(`delux_get_last_bet_receipt_response`,r),w(`ERR`,`delux_get_last_bet_receipt_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`})},15e3);function r(t){clearTimeout(n),e(t)}C.once(`delux_get_last_bet_receipt_response`,r),C.emit(`delux_get_last_bet_receipt`,{userCode:t})})):(w(`SKIP`,`delux_get_last_bet_receipt`,{ok:!1,error:`MISSING_FIELDS`}),{ok:!1,error:`MISSING_FIELDS`})}async function Kt(e,t={}){if(!C?.connected)return w(`SKIP`,`delux_get_user_tickets`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let n=typeof t==`object`&&t&&!Array.isArray(t)?{...t}:{},r=e==null?``:String(e).trim();if(r)n.userCode=r,delete n.regid;else if(n.regid!=null&&n.regid!==``){let e=Number(n.regid);n.regid=Number.isFinite(e)?e:n.regid}if(!n.userCode&&(n.regid==null||n.regid===``))return w(`SKIP`,`delux_get_user_tickets`,{ok:!1,error:`MISSING_FIELDS`}),{ok:!1,error:`MISSING_FIELDS`};let i=n;return w(`OUT`,`delux_get_user_tickets`,i),new Promise(e=>{let t=setTimeout(()=>{C.off(`delux_get_user_tickets_response`,n),w(`ERR`,`delux_get_user_tickets_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`})},3e4);function n(n){clearTimeout(t),e(n)}C.once(`delux_get_user_tickets_response`,n),C.emit(`delux_get_user_tickets`,i)})}async function qt(e,t){let n=Ft();try{let r=await fetch(`${n}/api/tickets/single-detail`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({userCode:e,barcode:t})}),i=await r.json().catch(()=>({}));return r.status===404?{ok:!1,error:`NOT_FOUND`,...i}:r.ok?i:{ok:!1,error:i.error||`HTTP_${r.status}`,...i}}catch{return{ok:!1,error:`NETWORK_ERROR`}}}async function Jt(e,t){let n=Ft();try{let r=await fetch(`${n}/api/tickets/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({userCode:e,barcode:t})}),i=await r.json().catch(()=>({}));return r.ok?i:{ok:!1,error:i.error||`HTTP_${r.status}`,...i}}catch{return{ok:!1,error:`NETWORK_ERROR`}}}async function Yt(e,t,n){if(!C?.connected)return w(`SKIP`,`lottery_ws_getCounterSale`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let r=e==null?``:String(e).trim(),i=t==null?``:String(t).trim(),a=n==null?``:String(n).trim();return!r||!i||!a?(w(`SKIP`,`lottery_ws_getCounterSale`,{ok:!1,error:`MISSING_FIELDS`}),{ok:!1,error:`MISSING_FIELDS`}):(w(`OUT`,`lottery_ws_getCounterSale`,{userCode:r,fromDate:i,toDate:a}),new Promise(e=>{let t=setTimeout(()=>{C.off(`lottery_ws_getCounterSale_response`,n),w(`ERR`,`lottery_ws_getCounterSale_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`})},3e4);function n(n){clearTimeout(t),e(n)}C.once(`lottery_ws_getCounterSale_response`,n),C.emit(`lottery_ws_getCounterSale`,r,i,a)}))}async function Xt(e,t){return C?.connected?(w(`OUT`,`delux_check_user_winning`,{userCode:e,lottime:t}),new Promise(n=>{let r=setTimeout(()=>{C.off(`delux_check_user_winning_response`,i),w(`ERR`,`delux_check_user_winning_timeout`,{error:`TIMEOUT`}),n({ok:!1,error:`TIMEOUT`})},15e3);function i(e){clearTimeout(r),n(e)}C.once(`delux_check_user_winning_response`,i),C.emit(`delux_check_user_winning`,{userCode:e,lottime:t})})):(w(`SKIP`,`delux_check_user_winning`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`})}async function Zt(e){if(!C?.connected)return w(`SKIP`,`delux_claim_all`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let t=e==null?``:String(e).trim();return t?(w(`OUT`,`delux_claim_all`,{userCode:t}),new Promise(e=>{let n=!1,r=setTimeout(()=>{n||(n=!0,C.off(`ws_allClaim`,i),w(`ERR`,`delux_claim_all_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`}))},6e4);function i(t){n||(n=!0,clearTimeout(r),t&&t.str===`OK`?e({ok:!0,amount:Number(t.amount)||0,items:Array.isArray(t.items)?t.items:[]}):e({ok:!1,message:t?.message||t?.str||`ERR`}))}C.once(`ws_allClaim`,i),C.emit(`delux_claim_all`,{userCode:t})})):{ok:!1,error:`MISSING_FIELDS`}}async function Qt(e,t){if(!C?.connected)return w(`SKIP`,`delux_claim_ticket`,{ok:!1,error:`NOT_CONNECTED`}),{ok:!1,error:`NOT_CONNECTED`};let n=e==null?``:String(e).trim(),r=t==null?``:String(t).trim();return!n||!r?{ok:!1,error:`MISSING_FIELDS`}:(w(`OUT`,`delux_claim_ticket`,{userCode:n,barcode:r}),new Promise(e=>{function t(t){clearTimeout(i),e(t&&typeof t==`object`?t:{ok:!1})}let i=setTimeout(()=>{C.off(`delux_claim_ticket_response`,t),w(`ERR`,`delux_claim_ticket_timeout`,{error:`TIMEOUT`}),e({ok:!1,error:`TIMEOUT`})},3e4);C.once(`delux_claim_ticket_response`,t),C.emit(`delux_claim_ticket`,{userCode:n,barcode:r})}))}function T(){return{exists:!!C,connected:C?.connected||!1,id:C?.id||null}}var E=`Asia/Kolkata`,$t=[`JAN`,`FEB`,`MAR`,`APR`,`MAY`,`JUN`,`JUL`,`AUG`,`SEP`,`OCT`,`NOV`,`DEC`],en=null;function tn(e){return e&&e.utcMs!=null&&Number.isFinite(Number(e.utcMs))?(en=Number(e.utcMs),!0):!1}function nn(){return en}function D(){return en==null?null:new Date(en)}function rn(){let e=D();return e?new Date(e.getTime()):new Date(0)}function O(e,t){let n=new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(e),r={};for(let e of n)e.type!==`literal`&&(r[e.type]=e.value);return{year:Number(r.year),month:Number(r.month),day:Number(r.day),hour:Number(r.hour),minute:Number(r.minute),second:Number(r.second)}}function an(e,t,n,r,i,a){let o=e=>String(e).padStart(2,`0`);return new Date(`${e}-${o(t)}-${o(n)}T${o(r)}:${o(i)}:${o(a)}+05:30`)}function on(e){let t=O(e,E);return{date:`${$t[t.month-1]} ${t.day} ${t.year}`,time:`${String(t.hour).padStart(2,`0`)}:${String(t.minute).padStart(2,`0`)}:${String(t.second).padStart(2,`0`)}`}}function sn(e){if(!e||typeof e!=`string`)return``;let t=e.trim().split(`:`);if(t.length<2)return``;let n=Number(t[0]),r=Number(t[1]);if(!Number.isFinite(n)||!Number.isFinite(r))return``;let i=n>=12?`PM`:`AM`,a=(n+11)%12+1;return`${String(a).padStart(2,`0`)}:${String(r).padStart(2,`0`)} ${i}`}var cn=null;function ln(){cn&&=(clearInterval(cn),null)}function un({pin:e,password:t,loginError:n}){return`
    <div class="loginscreen_screen">
      <div class="loginscreen_marquee_outer" aria-hidden="true">
        <div class="loginscreen_marquee_inner">
          <span class="loginscreen_marquee_text">welcome.. to northen delux.</span>
        </div>
      </div>
      <div class="loginscreen_date_chip">
        <div class="loginscreen_date_chip_title" id="loginscreen_server_date">—</div>
        <div class="loginscreen_date_chip_time" id="loginscreen_server_time">—:—:—</div>
      </div>
      <div class="loginscreen_form">
        ${n?`<div class="loginscreen_error">contact admin for login</div>`:``}
        <div class="loginscreen_field_row">
          <label for="loginscreen_pin">Pin Number</label>
          <input id="loginscreen_pin" value="${e}" />
        </div>
        <div class="loginscreen_field_row">
          <label for="loginscreen_password">Password</label>
          <input id="loginscreen_password" type="password" value="${t}" />
        </div>
        <div class="loginscreen_form_actions">
          <button type="button" class="loginscreen_mini_btn" data-loginscreen-action="enter-dashboard">Enter</button>
          <button type="button" class="loginscreen_mini_btn" data-loginscreen-action="back-to-connect">Back</button>
        </div>
      </div>
    </div>
  `}function dn(e,{onAction:t,onPinInput:n,onPasswordInput:r}){let i=Ft(),a=e.querySelector(`#loginscreen_server_date`),o=e.querySelector(`#loginscreen_server_time`);async function s(){try{let e=await fetch(`${i}/api/time`,{cache:`no-store`});if(!e.ok)return;let t=await e.json();t.utcMs!=null&&tn(t),a&&t.date&&(a.textContent=t.date),o&&t.time&&(o.textContent=t.time)}catch{a&&(a.textContent=`—`),o&&(o.textContent=`—:—:—`)}}s(),cn=setInterval(s,1e3),e.querySelectorAll(`[data-loginscreen-action]`).forEach(e=>{e.addEventListener(`click`,()=>{t(e.dataset.loginscreenAction)})});let c=e.querySelector(`#loginscreen_pin`),l=e.querySelector(`#loginscreen_password`);c&&c.addEventListener(`input`,e=>{n(e.target.value)}),l&&l.addEventListener(`input`,e=>{r(e.target.value)})}var fn=class{constructor(e={}){this.options={onClose:()=>{},...e},this.element=null,this.isVisible=!1}create(e){let t=document.createElement(`div`);t.className=`popup_overlay`,t.innerHTML=`
      <div class="popup_container">
        <div class="popup_content">
          <div class="popup_body">
            ${e}
          </div>
        </div>
      </div>
    `,t.addEventListener(`click`,e=>{e.target===t&&this.hide()});let n=e=>{e.key===`Escape`&&this.isVisible&&this.hide()};return document.addEventListener(`keydown`,n),this.element=t,this.escapeHandler=n,t}show(){this.element&&(this.isVisible=!0,this.element.classList.add(`popup_overlay--visible`),document.body.style.overflow=`hidden`)}hide(){this.element&&(this.isVisible=!1,this.element.classList.remove(`popup_overlay--visible`),document.body.style.overflow=``,this.options.onClose())}mount(e){this.element&&e.appendChild(this.element)}destroy(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),document.removeEventListener(`keydown`,this.escapeHandler),this.element=null}};function k(e){return e==null?``:String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}var pn=[`Barcode`,`Game ID`,`Start Point`,`Play`,`Win`,`End Point`,`Claim`,`Result`,`Draw Time`,`Ticket Time`],mn=[{label:`AllClaim`,action:`allclaim`},{label:`Claim`,action:`claim`},{label:`Cancel`,action:`cancel`},{label:`Details`,action:`details`},{label:`Close`,action:`close`},{label:`Reprint`,action:`reprint`}];function hn({onAction:e}){return`
    <div class="sh_wrapper">
      <div class="sh_table_section">
        <table class="sh_table">
          <thead class="sh_table_head">
            <tr>${pn.map(e=>`<th class="sh_table_header">${e}</th>`).join(``)}</tr>
          </thead>
          <tbody class="sh_table_body sh_tickets_tbody"></tbody>
        </table>
      </div>
      <div class="sh_sidebar">
        <div class="sh_buttons">
          ${mn.map(e=>`<button type="button" class="sh_sidebar_btn" data-action="${e.action}">${e.label}</button>`).join(``)}
        </div>
        <div class="sh_filters">
          <label class="sh_checkbox_label">
            <input type="checkbox" class="sh_checkbox" id="sh_show_all" />
            <span>Show All Tickets</span>
          </label>
          <label class="sh_checkbox_label">
            <input type="checkbox" class="sh_checkbox" id="sh_winning_only" />
            <span>Show Winning Tickets Only</span>
          </label>
        </div>
        <button type="button" class="sh_result_btn" data-action="result">Result</button>
      </div>
    </div>
  `}function gn(e,{onAction:t,isBetLocked:n}){e.querySelectorAll(`[data-action]`).forEach(e=>{e.addEventListener(`click`,()=>{let n=e.dataset.action;t&&t(n)})});let r=e.querySelector(`tbody.sh_tickets_tbody`);r&&t&&!r.dataset.shRowBound&&(r.dataset.shRowBound=`1`,r.addEventListener(`click`,e=>{let i=e.target.closest(`tr.sh_table_row`);if(!i||typeof n==`function`&&n())return;let a=i.getAttribute(`data-ticket-id`)||``,o=i.getAttribute(`data-barcode`)||``;r.querySelectorAll(`tr.sh_table_row`).forEach(e=>e.classList.remove(`sh_table_row--selected`)),i.classList.add(`sh_table_row--selected`),t(`select`,{ticketId:a,barcode:o})}));let i=e.querySelector(`#sh_show_all`),a=e.querySelector(`#sh_winning_only`);i&&!i.dataset.shFilterBound&&(i.dataset.shFilterBound=`1`,i.addEventListener(`change`,e=>{t&&t(`filter`,{showAll:e.target.checked,winningOnly:a?.checked})})),a&&!a.dataset.shFilterBound&&(a.dataset.shFilterBound=`1`,a.addEventListener(`change`,e=>{t&&t(`filter`,{showAll:i?.checked,winningOnly:e.target.checked})}))}function _n(e,t){let n=e.querySelector(`tbody.sh_tickets_tbody`);if(n){if(!t){n.innerHTML=``;return}n.innerHTML=`<tr class="sh_placeholder_row"><td class="sh_table_cell sh_placeholder_cell" colspan="10">${k(t)}</td></tr>`}}function vn(e,t){let n=e.querySelector(`tbody.sh_tickets_tbody`);n&&(n.innerHTML=(Array.isArray(t)?t:[]).map(e=>`
    <tr class="sh_table_row" data-ticket-id="${k(e.ticketId)}" data-barcode="${k(e.barcode)}">
      <td class="sh_table_cell">${k(e.barcode)}</td>
      <td class="sh_table_cell">${k(e.gameId)}</td>
      <td class="sh_table_cell">${k(e.startPoint)}</td>
      <td class="sh_table_cell">${k(e.play)}</td>
      <td class="sh_table_cell">${k(e.win)}</td>
      <td class="sh_table_cell">${k(e.endPoint)}</td>
      <td class="sh_table_cell">${k(e.claim)}</td>
      <td class="sh_table_cell">${k(e.result)}</td>
      <td class="sh_table_cell sh_table_cell--draw">${e.drawTimeHtml==null?k(e.drawTime):e.drawTimeHtml}</td>
      <td class="sh_table_cell">${k(e.ticketTime)}</td>
    </tr>
  `).join(``))}var yn=class{constructor(){let e=rn();this.currentDate=new Date(e.getTime()),this.selectedDate=new Date(e.getTime()),this.isVisible=!1,this.targetInput=null,this.calendarElement=null}show(e){this.targetInput=e,this.selectedDate=this.parseInputDate(e.value)||rn(),this.currentDate=new Date(this.selectedDate.getTime()),this.calendarElement||this.createCalendar(),this.updateCalendar(),this.positionCalendar(e),this.calendarElement.style.display=`block`,this.isVisible=!0}hide(){this.calendarElement&&(this.calendarElement.style.display=`none`),this.isVisible=!1,this.targetInput=null}parseInputDate(e){if(!e)return null;let t=e.split(`/`);if(t.length===3){let e=parseInt(t[0],10),n=parseInt(t[1],10)-1,r=parseInt(t[2],10);return new Date(r,n,e)}return null}formatDate(e){return`${String(e.getDate()).padStart(2,`0`)}/${String(e.getMonth()+1).padStart(2,`0`)}/${e.getFullYear()}`}createCalendar(){this.calendarElement=document.createElement(`div`),this.calendarElement.className=`rf_calendar`,this.calendarElement.innerHTML=`
      <div class="rf_calendar_header">
        <button type="button" class="rf_calendar_nav" data-nav="prev-month">◀</button>
        <span class="rf_calendar_month"></span>
        <button type="button" class="rf_calendar_nav" data-nav="next-month">▶</button>
      </div>
      <div class="rf_calendar_weekdays">
        <div class="rf_calendar_weekday">S</div>
        <div class="rf_calendar_weekday">M</div>
        <div class="rf_calendar_weekday">T</div>
        <div class="rf_calendar_weekday">W</div>
        <div class="rf_calendar_weekday">T</div>
        <div class="rf_calendar_weekday">F</div>
        <div class="rf_calendar_weekday">S</div>
      </div>
      <div class="rf_calendar_days"></div>
      <div class="rf_calendar_actions">
        <button type="button" class="rf_calendar_btn rf_calendar_btn--close">Close</button>
        <button type="button" class="rf_calendar_btn rf_calendar_btn--apply">Apply</button>
      </div>
    `,this.calendarElement.addEventListener(`click`,e=>{let t=e.target.dataset.nav;if(t===`prev-month`)this.currentDate.setMonth(this.currentDate.getMonth()-1),this.updateCalendar();else if(t===`next-month`)this.currentDate.setMonth(this.currentDate.getMonth()+1),this.updateCalendar();else if(e.target.classList.contains(`rf_calendar_day`)){let t=parseInt(e.target.textContent,10);isNaN(t)||(this.selectedDate=new Date(this.currentDate.getFullYear(),this.currentDate.getMonth(),t),this.selectDate())}else e.target.classList.contains(`rf_calendar_btn--apply`)?this.selectDate():e.target.classList.contains(`rf_calendar_btn--close`)&&this.hide()}),document.body.appendChild(this.calendarElement)}updateCalendar(){let e=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],t=this.calendarElement.querySelector(`.rf_calendar_month`);t.textContent=`${e[this.currentDate.getMonth()]} ${this.currentDate.getFullYear()}`;let n=this.calendarElement.querySelector(`.rf_calendar_days`);n.innerHTML=``;let r=new Date(this.currentDate.getFullYear(),this.currentDate.getMonth(),1);new Date(this.currentDate.getFullYear(),this.currentDate.getMonth()+1,0);let i=new Date(r);i.setDate(i.getDate()-r.getDay());for(let e=0;e<42;e++){let t=new Date(i);t.setDate(i.getDate()+e);let r=document.createElement(`div`);r.className=`rf_calendar_day`,r.textContent=t.getDate(),t.getMonth()!==this.currentDate.getMonth()&&r.classList.add(`rf_calendar_day--other-month`),this.selectedDate&&t.getDate()===this.selectedDate.getDate()&&t.getMonth()===this.selectedDate.getMonth()&&t.getFullYear()===this.selectedDate.getFullYear()&&r.classList.add(`rf_calendar_day--selected`);let a=D(),o=a?O(a,E):null;if(o){let e=O(t,E);e.year===o.year&&e.month===o.month&&e.day===o.day&&r.classList.add(`rf_calendar_day--today`)}n.appendChild(r)}}positionCalendar(e){let t=e.getBoundingClientRect();this.calendarElement.style.position=`absolute`,this.calendarElement.style.top=`${t.bottom+window.scrollY+5}px`,this.calendarElement.style.left=`${t.left+window.scrollX}px`,this.calendarElement.style.zIndex=`10000`}selectDate(){this.targetInput&&(this.targetInput.value=this.formatDate(this.selectedDate)),this.hide()}destroy(){this.calendarElement&&=(document.body.removeChild(this.calendarElement),null)}};function bn(e){return`${String(e.getDate()).padStart(2,`0`)}/${String(e.getMonth()+1).padStart(2,`0`)}/${e.getFullYear()}`}function xn(e){if(!e)return null;let t=String(e).trim().split(`/`);if(t.length!==3)return null;let n=parseInt(t[0],10),r=parseInt(t[1],10),i=parseInt(t[2],10);return!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||r<1||r>12||n<1||n>31?null:`${i}-${String(r).padStart(2,`0`)}-${String(n).padStart(2,`0`)}`}function Sn(e){if(!e)return``;let t=String(e).trim().split(`-`);if(t.length!==3)return String(e);let[n,r,i]=t;return!n||!r||!i?String(e):`${i.padStart(2,`0`)}/${r.padStart(2,`0`)}/${n}`}var A=null,Cn=[`From Date`,`To Date`,`Sale Point`,`Win Point`,`Cancel Point`,`Commission Point`,`NTP Point`,`Operator Point`];function wn(){return`
    <div class="rf_wrapper">
      <div class="rf_header">
        <div class="rf_date_section">
          <span class="rf_label">Report From</span>
          <div class="rf_date_input_container">
          <input type="text" class="rf_date_input" id="rf_from_date" value="" readonly />
          <button type="button" class="rf_calendar_btn" data-action="calendar-from">📅</button>
          </div>
          <span class="rf_label">To</span>
          <div class="rf_date_input_container">
          <input type="text" class="rf_date_input" id="rf_to_date" value="" readonly />
          <button type="button" class="rf_calendar_btn" data-action="calendar-to">📅</button>
          </div>
        </div>
        <div class="rf_actions">
          <button type="button" class="rf_action_btn" data-action="show">Show</button>
          <button type="button" class="rf_action_btn" data-action="print">Print</button>
          <button type="button" class="rf_action_btn" data-action="close">Close</button>
        </div>
      </div>
      <div class="rf_table_section">
        <table class="rf_table">
          <thead class="rf_table_head">
            <tr>${Cn.map(e=>`<th class="rf_table_header">${e}</th>`).join(``)}</tr>
          </thead>
          <tbody class="rf_table_body" id="rf_table_body">
            <!-- Table rows will be populated dynamically -->
          </tbody>
        </table>
      </div>
    </div>
  `}function Tn(e,{onAction:t}){A||=new yn,e.querySelectorAll(`[data-action]`).forEach(n=>{n.addEventListener(`click`,()=>{let r=n.dataset.action;if(r===`calendar-from`){let t=e.querySelector(`#rf_from_date`);t&&A.show(t)}else if(r===`calendar-to`){let t=e.querySelector(`#rf_to_date`);t&&A.show(t)}else t&&(r===`show`||r===`print`||r===`close`)&&t(r)})}),document.addEventListener(`click`,e=>{A&&A.isVisible&&!A.calendarElement.contains(e.target)&&!e.target.classList.contains(`rf_calendar_btn`)&&A.hide()})}function En(e){if(e==null||e===``)return``;let t=Number(e);return Number.isFinite(t)?t.toFixed(2):String(e)}function Dn(e){!e||e._rfPurchaseRowBound||(e._rfPurchaseRowBound=!0,e.addEventListener(`click`,t=>{let n=t.target.closest(`#rf_table_body tr.rf_table_row`);if(!n||!e.contains(n))return;let r=e.querySelector(`#rf_table_body`);if(!r)return;r.querySelectorAll(`tr.rf_table_row--selected`).forEach(e=>{e.classList.remove(`rf_table_row--selected`)}),n.classList.add(`rf_table_row--selected`);let i=Number(n.dataset.rfRow);e._rfSelectedPurchaseRowIndex=Number.isFinite(i)?i:null}))}function On(e,t){let n=e.querySelector(`#rf_table_body`);if(!n)return;Dn(e);let r=Array.isArray(t)?t:[];e._purchaseDetailRows=r.map(e=>({...e})),e._rfSelectedPurchaseRowIndex=null,n.innerHTML=r.map((e,t)=>`
    <tr class="rf_table_row${e.rowKind===`total`?` rf_table_row--total`:``}" data-rf-row="${t}" role="button" tabindex="0">
      <td class="rf_table_cell">${e.fromDate||``}</td>
      <td class="rf_table_cell">${e.toDate||``}</td>
      <td class="rf_table_cell">${En(e.salePoint)}</td>
      <td class="rf_table_cell">${En(e.winPoint)}</td>
      <td class="rf_table_cell">${En(e.cancelPoint)}</td>
      <td class="rf_table_cell">${En(e.commissionPoint)}</td>
      <td class="rf_table_cell">${En(e.ntpPoint)}</td>
      <td class="rf_table_cell">${En(e.operatorPoint)}</td>
    </tr>`).join(``)}function kn(){A&&=(A.destroy(),null)}var An=new URL(``+new URL(`btn2-TQ6WoDI6.wav`,import.meta.url).href,``+import.meta.url).href,jn=new URL(``+new URL(`numberspinner-CA5xOemr.mp3`,import.meta.url).href,``+import.meta.url).href,Mn=new URL(``+new URL(`nomorebetplease-C12XxtAo.wav`,import.meta.url).href,``+import.meta.url).href,Nn=null,Pn=!1;function Fn(){new Audio(An).play().catch(()=>{})}function In(e){e?(Nn||=new Audio(jn),Nn.loop=!0,Nn.currentTime=0,Nn.play().catch(()=>{})):Nn&&(Nn.pause(),Nn.currentTime=0)}function Ln(){new Audio(Mn).play().catch(()=>{})}function Rn(e){e===`BETTING_LOCKED`&&Ln()}function zn(){Pn||(Pn=!0,document.addEventListener(`click`,e=>{let t=e.target;t instanceof Element&&t.closest(`button`)&&Fn()},!0))}function Bn(e){if(!e||typeof e!=`string`)return`PR`;let t=e.replace(/\s*(AM|PM)\s*$/i,``).split(`:`);if(t.length>=2){let e=Number(t[1]);if(Number.isFinite(e))return e%2==0?`PR`:`NR`}return`PR`}function Vn(e){return`${Bn(e)} 00`}function Hn({onAction:e,data:t,reveal:n}){let r=t?.date||`—`,i=t?.time||`—`,a=t?.drawTime||i,o=t?.result||`NR 22`,s=t?.drawType||`MINOR NR`,c=!!n,l=c?`flex`:`none`,u=c?`none`:`block`,d=c?``:o;return`
    <div class="lp_container">
      <button type="button" class="lp_close_btn" data-action="close">&times;</button>
        <div class="lp_header">
          <h1 class="lp_title">Northern Deluxe</h1>
          <div class="lp_info">
          <span class="lp_date" id="lp_date">${r}</span>
          <span class="lp_time" id="lp_time">${i}</span>
        </div>
      </div>
      <div class="lp_content">
        <div class="lp_draw_info">
          <span class="lp_draw_type" id="lp_draw_type">${s}</span>
          <span class="lp_draw_time" id="lp_draw_time">${a}</span>
        </div>
        <div class="lp_result_box lp_result_box--reveal">
          <div class="lp_reveal_phase" id="lp_reveal_phase" style="display: ${l}">
            <div class="lp_spin_number" id="lp_spin_number">${c?Vn(a):``}</div>
          </div>
          <div class="lp_final_phase" id="lp_final_phase" style="display: ${u}">
            <span class="lp_result_text" id="lp_result_text">${d}</span>
          </div>
        </div>
      </div>
      <div class="lp_status_box" id="lp_status_box" aria-busy="false">
        <span class="lp_status_count" id="lp_status_count" aria-live="polite"></span>
      </div>
    </div>
  `}function Un(e){e&&e._lpWinningPollTimer!=null&&(window.clearInterval(e._lpWinningPollTimer),e._lpWinningPollTimer=null)}function Wn(e){if(!e)return;e._lpStatusCountInterval!=null&&(window.clearInterval(e._lpStatusCountInterval),e._lpStatusCountInterval=null);let t=e.querySelector(`#lp_status_box`),n=e.querySelector(`#lp_status_count`);n&&(n.textContent=``),t&&(t.classList.remove(`lp_status_box--spinning`,`lp_status_box--frozen`),t.setAttribute(`aria-busy`,`false`)),e._lpStatusDigitFrozen=!1}function Gn(e,t=`1`){let n=e&&e.querySelector?e.querySelector(`#lp_status_box`):null,r=e&&e.querySelector?e.querySelector(`#lp_status_count`):null;!n||!r||(e._lpStatusCountInterval!=null&&(window.clearInterval(e._lpStatusCountInterval),e._lpStatusCountInterval=null),r.textContent=t!=null&&String(t).trim()!==``?String(t).trim():`1`,n.classList.remove(`lp_status_box--spinning`),n.classList.add(`lp_status_box--frozen`),e._lpStatusDigitFrozen=!0,n.setAttribute(`aria-busy`,`false`))}function Kn(e,t){let n=e&&e.querySelector?e.querySelector(`#lp_status_box`):null,r=e&&e.querySelector?e.querySelector(`#lp_status_count`):null;if(!n||!r)return;let i=Number(t);if(Number.isFinite(i)&&i===1){if(e._lpStatusDigitFrozen){e._lpStatusCountInterval!=null&&(window.clearInterval(e._lpStatusCountInterval),e._lpStatusCountInterval=null),n.classList.remove(`lp_status_box--spinning`),n.classList.add(`lp_status_box--frozen`),n.setAttribute(`aria-busy`,`false`);return}if(e._lpStatusCountInterval!=null)return;n.classList.add(`lp_status_box--spinning`),n.classList.remove(`lp_status_box--frozen`),n.setAttribute(`aria-busy`,`true`);let t=()=>{r.textContent=String(Math.floor(Math.random()*10))};t(),e._lpStatusCountInterval=window.setInterval(t,85);return}if(e._lpStatusCountInterval!=null&&(window.clearInterval(e._lpStatusCountInterval),e._lpStatusCountInterval=null),n.classList.remove(`lp_status_box--spinning`),n.setAttribute(`aria-busy`,`false`),e._lpStatusDigitFrozen){n.classList.add(`lp_status_box--frozen`);return}r.textContent=``,n.classList.remove(`lp_status_box--frozen`)}function qn(e,t,n,r,i=null,a=`1`){if(!e)return;e._lpRevealInterval&&=(clearInterval(e._lpRevealInterval),null),e._lpRevealTimer&&=(clearTimeout(e._lpRevealTimer),null);let o=e.querySelector(`#lp_reveal_phase`),s=e.querySelector(`#lp_final_phase`),c=e.querySelector(`#lp_spin_number`),l=e.querySelector(`#lp_result_text`);if(!o||!s||!c||!l){typeof r==`function`&&r();return}o.style.display=`flex`,s.style.display=`none`,s.classList.remove(`lp_final_phase--show`);let u=Bn(i);In(!0),e._lpRevealInterval=setInterval(()=>{c.textContent=`${u} ${String(Math.floor(Math.random()*100)).padStart(2,`0`)}`},65),e._lpRevealTimer=setTimeout(()=>{e._lpRevealInterval&&=(clearInterval(e._lpRevealInterval),null),e._lpRevealTimer=null,In(!1),o.style.display=`none`,l.textContent=(e._lpFinalResultOverride!=null&&String(e._lpFinalResultOverride).length>0?String(e._lpFinalResultOverride):null)??(t!=null&&String(t).length>0?String(t):`—`),delete e._lpFinalResultOverride,s.style.display=`block`,s.classList.add(`lp_final_phase--show`),Gn(e,a!=null&&String(a).trim()!==``?String(a).trim():`1`),typeof r==`function`&&r()},n)}function Jn(e){e&&(Un(e),Wn(e),In(!1),e._lpRevealInterval&&=(clearInterval(e._lpRevealInterval),null),e._lpRevealTimer&&=(clearTimeout(e._lpRevealTimer),null))}function Yn(e,{onAction:t}){let n=e.querySelector(`[data-action="close"]`);n&&n.addEventListener(`click`,()=>{Jn(e),t&&t(`close`)});let r=n=>{n.key===`Escape`&&(Jn(e),t&&t(`close`),document.removeEventListener(`keydown`,r))};document.addEventListener(`keydown`,r)}function Xn(e){return e==null?``:String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}var j=null;function Zn(e,t,n,r){if(j){let e=j.element.querySelector(`.popup_body`);e&&(e.innerHTML=Qn(t,{onAction:(e,t)=>{console.log(`Upcoming draw action:`,e,t),e===`close`||e===`cancel`?j.hide():e===`confirm`?(console.log(`Selected times:`,t.selectedTimes),r&&typeof r==`function`&&r(t.selectedTimes),j.hide()):e===`select-all`?er(j.element,!0):e===`unselect-all`&&er(j.element,!1)}}),$n(e,{onAction:(e,t)=>{console.log(`Upcoming draw action:`,e,t),e===`close`||e===`cancel`?j.hide():e===`confirm`?(console.log(`Selected times:`,t.selectedTimes),r&&typeof r==`function`&&r(t.selectedTimes),j.hide()):e===`select-all`?er(j.element,!0):e===`unselect-all`&&er(j.element,!1)}}))}else{let e=Qn(t,{onAction:(e,t)=>{console.log(`Upcoming draw action:`,e,t),e===`close`||e===`cancel`?j.hide():e===`confirm`?(console.log(`Selected times:`,t.selectedTimes),r&&typeof r==`function`&&r(t.selectedTimes),j.hide()):e===`select-all`?er(j.element,!0):e===`unselect-all`&&er(j.element,!1)}});j=new fn({onClose:()=>{console.log(`Upcoming draw popup closed`)}}),j.create(e),$n(j.element.querySelector(`.popup_body`),{onAction:(e,t)=>{console.log(`Upcoming draw action:`,e,t),e===`close`||e===`cancel`?j.hide():e===`confirm`?(console.log(`Selected times:`,t.selectedTimes),r&&typeof r==`function`&&r(t.selectedTimes),j.hide()):e===`select-all`?er(j.element,!0):e===`unselect-all`&&er(j.element,!1)}}),document.body.appendChild(j.element)}j.show()}function Qn(e,{onAction:t}){return`
    <div class="upcoming_modal">
      <div class="upcoming_grid">
        ${e.map(e=>`<div class="upcoming_cell upcoming_cell--active" data-time="${Xn(e)}">
      <span class="upcoming_time">${Xn(e)}</span>
      <input type="checkbox" class="upcoming_checkbox" value="${Xn(e)}" />
    </div>`).join(``)}
      </div>
      <div class="upcoming_actions">
        <button type="button" class="upcoming_action_btn upcoming_action_btn--unselect" data-action="unselect-all">UnselectAll</button>
        <button type="button" class="upcoming_action_btn upcoming_action_btn--select" data-action="select-all">SelectAll</button>
        <button type="button" class="upcoming_action_btn upcoming_action_btn--confirm" data-action="confirm">Confirm</button>
        <button type="button" class="upcoming_action_btn upcoming_action_btn--cancel" data-action="cancel">Cancel</button>
      </div>
    </div>
  `}function $n(e,{onAction:t}){e&&(e.querySelectorAll(`.upcoming_cell`).forEach(e=>{e.addEventListener(`click`,t=>{if(t.target.type===`checkbox`)return;let n=e.querySelector(`.upcoming_checkbox`);n&&(n.checked=!n.checked)})}),e.querySelectorAll(`[data-action]`).forEach(n=>{n.addEventListener(`click`,()=>{let r=n.dataset.action;if(r===`confirm`){let n=Array.from(e.querySelectorAll(`.upcoming_checkbox:checked`)).map(e=>e.value);console.log(`Checkbox selection - found checked checkboxes:`,e.querySelectorAll(`.upcoming_checkbox:checked`).length),console.log(`Checkbox selection - selected times:`,n),t(r,{selectedTimes:n})}else t(r)})}))}function er(e,t){e&&e.querySelectorAll(`.upcoming_checkbox`).forEach(e=>{e.checked=t})}function tr(){if(j)try{j.hide()}catch{}}function nr(){j&&=(j.destroy(),null)}var M=null;function rr(e,t,n){if(M){M.style.display=`flex`,M.dataset.userCode=e||``,M.dataset.apiBaseUrl=t||``;return}M=document.createElement(`div`),M.className=`cp_overlay`,M.dataset.userCode=e||``,M.dataset.apiBaseUrl=t||``,M.innerHTML=`
    <div class="cp_modal">
      <div class="cp_header">
        <h3 class="cp_title">Change password</h3>
        <button type="button" class="cp_close_btn" data-action="close">&times;</button>
      </div>
      <div class="cp_body">
        <div class="cp_message" id="cp_message"></div>
        <div class="cp_field">
          <label class="cp_label">Current password</label>
          <input type="password" class="cp_input" id="cp_current_password" />
        </div>
        <div class="cp_field">
          <label class="cp_label">New password</label>
          <input type="password" class="cp_input" id="cp_new_password" />
        </div>
        <div class="cp_field">
          <label class="cp_label">Confirm password</label>
          <input type="password" class="cp_input" id="cp_confirm_password" />
        </div>
        <button type="button" class="cp_update_btn" data-action="update">Update password</button>
      </div>
    </div>
  `,cr(M,n),document.body.appendChild(M),M.style.display=`flex`}function ir(){M&&(M.style.display=`none`,M.querySelectorAll(`.cp_input`).forEach(e=>e.value=``))}function ar(){M&&=(document.body.removeChild(M),null)}function or(e,t,n=!1){let r=e.querySelector(`#cp_message`);r&&(r.textContent=t,r.className=`cp_message`+(n?` cp_message--error`:` cp_message--success`))}async function sr(e,t){let n=e.querySelector(`#cp_current_password`).value,r=e.querySelector(`#cp_new_password`).value,i=e.querySelector(`#cp_confirm_password`).value;if(!n||!r||!i){or(e,`Please fill all fields`,!0);return}if(r!==i){or(e,`New password and confirm password do not match`,!0);return}if(r.length<4){or(e,`Password must be at least 4 characters long`,!0);return}let a=e.dataset.userCode,o=e.dataset.apiBaseUrl;if(!a||!o){or(e,`Error: User not logged in properly`,!0);return}let s=e.querySelector(`.cp_update_btn`),c=s.textContent;s.textContent=`Updating...`,s.disabled=!0;try{let i=`${o}/api/change-password`,s=await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({userCode:a,currentPassword:n,newPassword:r})}),c=await s.json();s.ok?(or(e,`Password changed successfully!`),e.querySelectorAll(`.cp_input`).forEach(e=>e.value=``),t&&t(`success`,{message:`Password changed successfully`}),setTimeout(()=>{ir()},1500)):(or(e,c.message||`Failed to change password`,!0),t&&t(`error`,{message:c.message||`Failed to change password`}))}catch(n){console.error(`Password change error:`,n),or(e,`Network error. Please try again.`,!0),t&&t(`error`,{message:`Network error`})}finally{s.textContent=c,s.disabled=!1}}function cr(e,t){e.addEventListener(`click`,n=>{let r=n.target.dataset.action;r===`close`?(ir(),t&&t(`close`)):r===`update`&&sr(e,t)}),e.addEventListener(`click`,n=>{n.target===e&&(ir(),t&&t(`close`))});let n=e=>{e.key===`Escape`&&(ir(),t&&t(`close`),document.removeEventListener(`keydown`,n))};document.addEventListener(`keydown`,n)}var lr=null;function ur(e){return e==null?``:String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}function dr(e){if(e==null||e===``)return null;let t=Number(e);return!Number.isFinite(t)||t<=1?null:t}function fr(e){return e==null?``:Math.floor(e)===e?`${Math.floor(e)}X`:`${e}X`}function pr(e,t){let n=ur(e||``),r=dr(t);return r?`<div class="result_popup_result_cell"><span class="result_popup_mult_badge">${ur(fr(r))}</span><span class="result_popup_result_text">${n}</span></div>`:n}function mr(){return`
    <div class="result_popup_wrapper">
      <div class="result_popup_header">
        <div class="result_popup_field">
          <label class="result_popup_label">Select Date</label>
          <div class="result_popup_input_group">
            <input type="text" class="result_popup_date_input" id="result_date_input" value="${new Date().toLocaleDateString(`en-GB`,{day:`2-digit`,month:`2-digit`,year:`numeric`}).replace(/\//g,`/`)}" readonly />
            <button type="button" class="result_popup_calendar_btn" id="result_calendar_btn">
              <svg viewBox="0 0 24 24" width="18" height="18">
                <path fill="currentColor" d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11z"/>
              </svg>
            </button>
          </div>
        </div>
        <div class="result_popup_field">
          <label class="result_popup_label">Select Stone</label>
          <select class="result_popup_select" id="result_stone_select">
            <option value="PR">PR</option>
            <option value="NR">NR</option>
          </select>
        </div>
        <div class="result_popup_buttons">
          <button type="button" class="result_popup_btn result_popup_btn--show" id="result_show_btn">show</button>
          <button type="button" class="result_popup_btn result_popup_btn--close" id="result_close_btn">close</button>
        </div>
      </div>
      <div class="result_popup_table_container">
        <table class="result_popup_table">
          <thead class="result_popup_table_head">
            <tr>
              <th class="result_popup_table_header">DrawTime</th>
              <th class="result_popup_table_header">Result</th>
            </tr>
          </thead>
          <tbody class="result_popup_table_body" id="result_table_body">
          </tbody>
        </table>
      </div>
    </div>
  `}function hr(e,{onAction:t,onShow:n}){lr||=new yn;let r=e.querySelector(`#result_show_btn`);r&&r.addEventListener(`click`,()=>{if(n){let t=e.querySelector(`#result_date_input`),r=e.querySelector(`#result_stone_select`);n({date:t?t.value:``,stone:r?r.value:`PR`})}});let i=e.querySelector(`#result_close_btn`);i&&i.addEventListener(`click`,()=>{t&&t(`close`)});let a=e.querySelector(`#result_calendar_btn`),o=e.querySelector(`#result_date_input`);a&&o&&a.addEventListener(`click`,()=>{lr.show(o)}),document.addEventListener(`click`,e=>{lr&&lr.isVisible&&!lr.calendarElement.contains(e.target)&&!e.target.closest(`#result_calendar_btn`)&&lr.hide()})}function gr(e,t){let n=e.querySelector(`#result_table_body`);if(n){if(!t||t.length===0){n.innerHTML=`<tr><td colspan="2" class="result_popup_empty">No results found</td></tr>`;return}n.innerHTML=t.map(e=>`
    <tr class="result_popup_table_row">
      <td class="result_popup_table_cell">${ur(e.drawTime||``)}</td>
      <td class="result_popup_table_cell result_popup_table_cell--result">${pr(e.result,e.multiple)}</td>
    </tr>
  `).join(``)}}function _r(){let e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:null;return e&&typeof e.JsBarcode==`function`?e.JsBarcode:null}function N(e){return e==null?``:String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}function vr(e){let t=String(e??``).trim();if(!t)return``;let n=parseInt(t,10);return Number.isFinite(n)?String(n):t.replace(/^0+/,``)||`0`}function yr(e){let t=_r();if(!t)return``;let n=String(e??``).trim()||`0`,r=document.createElement(`canvas`);try{return t(r,n,{format:`CODE128`,height:40,displayValue:!1}),r.toDataURL(`image/png`)}catch{return``}}function br(e){if(e==null)return!1;let t=String(e).trim().toLowerCase();return t===`1`||t===`true`||t===`yes`}function xr(){return br(`false`)}function Sr(e){let t=window.open(``,`_blank`);return t?(t.document.open(),t.document.write(e),t.document.close(),setTimeout(()=>{try{t.focus(),t.print()}catch{}try{t.close()}catch{}},450),!0):!1}function Cr(e){if(xr())return Sr(e);let t=typeof window<`u`?window.electronAPI:null,n=t&&typeof t.send==`function`?t.send.bind(t):null;return n?(n(`print`,e),!0):!1}var wr=`
    body{font-family:monospace;width:50mm;max-width:50mm;margin:0;padding:0;font-weight:bold;text-align:center;box-sizing:border-box}
    .ticket{width:50mm;max-width:50mm;background:#fff;text-align:left;padding:4px 3px;box-sizing:border-box}
    .ticket,.ticket *{box-sizing:border-box}
    .ticket h2,.ticket h3,.ticket h4{text-align:left;margin:5px 0;font-size:11px}
    .ticket p{margin:3px 0;font-size:10px}
    .barcode-container{text-align:left;margin-top:6px;height:40px}
    .barcodeImage{height:40px;max-width:100%}
    .footer{font-weight:bold;margin-top:6px;font-size:9px;text-align:center}
    .items-table{width:100%;max-width:100%;table-layout:fixed;text-align:center;margin-top:5px;border-collapse:collapse;font-size:7px}
    .items-table th,.items-table td{padding:1px;border:1px solid #000;overflow:hidden;word-break:break-all;line-height:1.15}
    .items-table th:nth-child(1),.items-table td:nth-child(1){width:24%}
    .items-table th:nth-child(2),.items-table td:nth-child(2){width:26%}
    .items-table th:nth-child(3),.items-table td:nth-child(3){width:24%}
    .items-table th:nth-child(4),.items-table td:nth-child(4){width:26%}
    .items-table th{background:#ddd}
    .meta{font-size:9px}
    @media print{body{margin:0;padding:0;max-width:50mm}.ticket{width:50mm;max-width:50mm}}
`;function Tr(){let e=O(D()||new Date,E);return`${`${String(e.day).padStart(2,`0`)}/${String(e.month).padStart(2,`0`)}/${e.year}`} ${`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}:${String(e.second).padStart(2,`0`)}`}`}function Er(e){let t=Number(e);return Number.isFinite(t)?t.toFixed(2):String(e??``)}function Dr({title:e,amountLabel:t,username:n,barcode:r,drawTime:i,placeTime:a,timing:o,claimTime:s,amount:c,footer:l}){let u=N(e||``),d=N(n||``),f=N(r||``),p=N(i||``),m=N(a||``),h=N(o||``),g=N(s||``),_=Er(c),v=N(t||``),ee=N(l||``);return Cr(`<!DOCTYPE html><html><head><meta charset="utf-8"/><title>Claim</title><style>${wr}
    .claim-lines{font-size:10px;text-align:left;margin-top:8px;line-height:1.35}
    .claim-lines b{font-size:9px;display:block;margin-top:6px}
    </style></head><body><div class="ticket"><h3>${u}</h3>
    <div class="claim-lines">
      <b>Barcode</b>${f}
      <b>Draw time</b>${p}
      <b>Place time</b>${m}
      <b>Timing</b>${h}
      <b>Claim time</b>${g}
      <b>${v}</b>${N(_)}
      <b>Username</b>${d}
    </div>
    <p class="footer">${ee}</p></div></body></html>`)}function Or({username:e,barcode:t,drawTime:n,placeTime:r,timing:i,claimedAmount:a,claimTime:o}){return Dr({title:`CLAIM`,amountLabel:`Claimed`,username:e,barcode:t,drawTime:n,placeTime:r,timing:i,claimTime:o!=null&&String(o).trim()!==``?String(o).trim():Tr(),amount:a,footer:`Claim slip`})}function kr({username:e,barcode:t,drawTime:n,placeTime:r,winAmount:i}){let a=N(e||``),o=N(t||``),s=N(Er(i)),c=N(String(n||``).trim()||`—`);return Cr(`<!DOCTYPE html><html><head><meta charset="utf-8"/><title>Winning</title><style>${wr}
    .win-slip{font-size:10px;text-align:left;margin-top:8px;line-height:1.45}
    .win-line{margin-bottom:4px}
    .win-ba{margin-top:8px;font-size:11px;font-weight:bold;word-break:break-all}
    </style></head><body><div class="ticket"><h3>WINNING</h3>
    <div class="win-slip">
      <div class="win-line">username: ${a}</div>
      <div class="win-line">placetime: ${N(String(r||``).trim()||`—`)}</div>
      <div class="win-line">drawtime: ${c}</div>
      <div class="win-line">barcode win amount</div>
      <div class="win-ba">${`${o} ${s}`}</div>
    </div>
    <p class="footer">Winning slip</p></div></body></html>`)}function Ar({username:e,printedAt:t,items:n,claimTime:r}){let i=N(e||``),a=N(t||``),o=N(r!=null&&String(r).trim()!==``?String(r).trim():Tr()),s=Array.isArray(n)?n:[],c=s.map(e=>String(e&&e.lotTime!=null?e.lotTime:``).trim()).filter((e,t,n)=>e&&n.indexOf(e)===t).join(`, `),l=s.map(e=>`<div>${N(String(e.barcode??``))}</div>`).join(``),u=s.map(e=>`<div style="text-align:right">${N(Er(e.amount))}</div>`).join(``);return Cr(`<!DOCTYPE html><html><head><meta charset="utf-8"/><title>Claim all</title><style>${wr}
    .pair{display:flex;gap:8px;width:100%;font-size:9px;margin-top:8px;justify-content:space-between}
    .pair .col{flex:1;min-width:0;word-break:break-all}
    </style></head><body><div class="ticket"><h3>CLAIM ALL</h3>
    <p class="meta"><b>Username</b><br/>${i}</p>
    <p class="meta"><b>Timing</b><br/>${a}</p>
    <p class="meta"><b>Claim time</b><br/>${o}</p>
    <p class="meta"><b>Draw time</b><br/>${N(c||`—`)}</p>
    <div class="pair"><div class="col"><b>Barcode</b>${l?`<div style="margin-top:4px">${l}</div>`:``}</div>
    <div class="col"><b>Claimed</b>${u?`<div style="margin-top:4px">${u}</div>`:``}</div></div>
    <p class="footer">Claim all slip</p></div></body></html>`)}function jr(e){let t=[];for(let n of Array.isArray(e)?e:[]){let e=n.cellID??n.cellid,r=Number(n.cv);e==null||e===``||!Number.isFinite(r)||r<=0||t.push({cellID:String(e),cv:r})}return t.sort((e,t)=>String(e.cellID).localeCompare(String(t.cellID),void 0,{numeric:!0})),t}function Mr(e){let t=``;for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];t+=`<tr style="font-weight:bold">
      <td>${N(vr(r.cellID))}</td><td>${N(r.cv)}</td>
      <td>${i?N(vr(i.cellID)):``}</td><td>${i?N(i.cv):``}</td>
    </tr>`}return t}function Nr({terminal:e,barcode:t,lotdate:n,drawTimeHms:r,ticketTime:i,ticketStatus:a,lines:o,heading:s,footNote:c}){let l=jr(o);if(l.length===0)return;let u=String(t??``).trim(),d=u?yr(u):``,f=Array.isArray(o)&&o[0]?o[0]:{},p=f.ticketTot!=null&&f.ticketTot!==``?Number(f.ticketTot):l.reduce((e,t)=>e+t.cv,0),m=Number.isFinite(p)?String(p):`—`,h=n&&r?`${N(n)} ${N(r)}`:N(r||n||`—`),g=s?N(s):`BET RECEIPT`,_=c?`<div class="footer">${N(c)}</div>`:``;Cr(`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Delux</title><style>${wr}</style></head><body>
  <div class="ticket">
    <h3>For Amusement Only</h3>
    <h2>NORTHERN DELUX</h2>
    <p class="meta"><strong>${g}</strong></p>
    <p><strong>Terminal:</strong> ${N(e||`—`)}</p>
    <p><strong>Barcode:</strong> ${N(u||`—`)}</p>
    <p><strong>Draw:</strong> ${h}</p>
    <p><strong>Ticket time:</strong> ${N(i||`—`)}</p>
    <p><strong>Status:</strong> ${N(a==null?`—`:String(a))}</p>
    <p><strong>Total points:</strong> ${N(m)}</p>
    <table class="items-table"><thead><tr><th>#</th><th>Pt</th><th>#</th><th>Pt</th></tr></thead><tbody>${Mr(l)}</tbody></table>
    ${d?`<div class="barcode-container"><img class="barcodeImage" src="${d}" alt="" /></div>`:``}
    <div class="footer">**Ticket not for sale**</div>
    ${_}
  </div></body></html>`)}function Pr(e){Nr({...e,heading:e.heading||`ADVANCE BET`})}function Fr(){let e=O(D()||new Date,E);return`${`${String(e.day).padStart(2,`0`)}/${String(e.month).padStart(2,`0`)}/${e.year}`} ${`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}:${String(e.second).padStart(2,`0`)}`}`}function Ir(e){let t=[];for(let n of Array.isArray(e)?e:[]){let e=n.cellID??n.cellid,r=Number(n.cv);e==null||e===``||!Number.isFinite(r)||r<=0||t.push({cellID:String(e),cv:r})}return t.sort((e,t)=>String(e.cellID).localeCompare(String(t.cellID),void 0,{numeric:!0})),t}function Lr(e){let t=``;for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];t+=`<tr style="font-weight:bold">
      <td>${N(vr(r.cellID))}</td><td>${N(r.cv)}</td>
      <td>${i?N(vr(i.cellID)):``}</td><td>${i?N(i.cv):``}</td>
    </tr>`}return t}function Rr(e,t,n={}){if(!e||e.ok!==!0)return null;let r=n&&typeof n==`object`?n:{},i=r.hidePlacedBets===!0,a=Array.isArray(e.cells)?e.cells:[];if(a.length===0)return null;let o=Array.isArray(e.tickets)&&e.tickets.length?e.tickets[0]:null,s=o&&o.drawTime!=null?String(o.drawTime).trim():``,c=``,l=``,u=/^(\d{4}-\d{2}-\d{2})\s+(\d{1,2}:\d{2}(?::\d{2})?)/.exec(s);u&&(c=u[1],l=u[2].split(`:`).length===2?`${u[2]}:00`:u[2]);let d=o&&o.ticketTime!=null?String(o.ticketTime).trim():``,f=`Duplicate / reprint`;if(`footerLine2`in r){let e=r.footerLine2;f=e===!1||e===null||e===``?``:String(e)}let p=``;r.stampCancelTime===!0?p=Fr():r.cancelTime!=null&&String(r.cancelTime).trim()!==``&&(p=String(r.cancelTime).trim());let m=a[0]||{},h=null;if(m.ticketTot!=null&&m.ticketTot!==``){let e=Number(m.ticketTot);Number.isFinite(e)&&(h=e)}if(h==null){let e=a.reduce((e,t)=>{let n=Number(t.cv);return e+(Number.isFinite(n)&&n>0?n:0)},0);e>0&&(h=e)}let g=r.summaryTotalLabel!=null&&String(r.summaryTotalLabel).trim()!==``?String(r.summaryTotalLabel).trim():``,_=r.hideBarcode===!0,v=r.showTicketNotForSaleFooter!==!1;return{heading:r.heading==null?`STONE REPRINT`:String(r.heading),footerLine2:f,terminal:t||`—`,barcode:String(e.barcode??``).trim(),lotdate:c,lotTime:l,placedAt:d,ticketStatus:`ticketStatus`in r?r.ticketStatus:null,cells:i?[]:a,hidePlacedBets:i,totalAmount:h,operatorLabel:r.operatorLabel==null?``:String(r.operatorLabel).trim(),summaryTotalLabel:g,cancelTime:p,hideBarcode:_,showTicketNotForSaleFooter:v}}function zr({heading:e,footerLine2:t,terminal:n,barcode:r,lotdate:i,lotTime:a,placedAt:o,ticketStatus:s,cells:c,hidePlacedBets:l,totalAmount:u,operatorLabel:d,summaryTotalLabel:f,cancelTime:p,hideBarcode:m,showTicketNotForSaleFooter:h}){let g=l===!0,_=m===!0,v=g?[]:Ir(c);if(!g&&v.length===0)return;let ee=String(r??``).trim(),te=!_&&ee?yr(ee):``,ne=i==null?``:String(i),re=a==null?``:String(a),ie=o==null?``:String(o),ae=ne&&re?`${N(ne)} ${N(re)}`:N(re||ne||`—`),oe=N(n||`—`),se=N(e||`RECEIPT`),ce=N((d==null?``:String(d).trim())||`Terminal`),le=Array.isArray(c)&&c[0]?c[0]:{},ue;if(g){let e=u!=null&&u!==``?Number(u):NaN;ue=Number.isFinite(e)?e:NaN}else ue=le.ticketTot!=null&&le.ticketTot!==``?Number(le.ticketTot):v.reduce((e,t)=>e+t.cv,0);let de=Number.isFinite(ue)?String(ue):`—`,fe=s!=null&&String(s)!==``?`<p><strong>Status:</strong> ${N(String(s))}</p>`:``,y=t!=null&&String(t).trim()!==``?`<div class="footer">${N(String(t))}</div>`:``,pe=p==null?``:String(p).trim(),me=pe===``?``:`<p><strong>Cancel time:</strong> ${N(pe)}</p>`,b=g?`<p><strong>Draw time:</strong> ${ae}</p>${me}`:`<p><strong>Draw:</strong> ${ae}</p>
    <p><strong>Placed:</strong> ${N(ie||`—`)}</p>`,he=g&&f!=null&&String(f).trim()!==``?String(f).trim():g?`Total amount`:`Total points`,ge=g?``:`<table class="items-table"><thead><tr><th>#</th><th>Pt</th><th>#</th><th>Pt</th></tr></thead><tbody>${Lr(v)}</tbody></table>`,_e=_?``:`<p><strong>Barcode:</strong> ${N(ee||`—`)}</p>`,ve=h===!1?``:`<div class="footer">**Ticket not for sale**</div>`;Cr(`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Delux</title><style>${wr}</style></head><body>
  <div class="ticket">
    <h3>For Amusement Only</h3>
    <h2>NORTHERN DELUX</h2>
    <p class="meta"><strong>${se}</strong></p>
    <p><strong>${ce}:</strong> ${oe}</p>
    ${_e}
    ${b}
    ${fe}
    <p><strong>${he}:</strong> ${N(de)}</p>
    ${ge}
    ${te?`<div class="barcode-container"><img class="barcodeImage" src="${te}" alt="" /></div>`:``}
    ${ve}
    ${y}
  </div></body></html>`)}function Br(e,{terminal:t}={}){if(!e||e.ok!==!0||e.hasReceipt!==!0)return;let n=Array.isArray(e.cells)?e.cells:[];zr({heading:`LAST RECEIPT`,footerLine2:`Duplicate / reprint`,terminal:t||`—`,barcode:e.barcode,lotdate:e.lotdate==null?``:String(e.lotdate),lotTime:e.lotTime==null?``:String(e.lotTime),placedAt:e.placedAt==null?``:String(e.placedAt),ticketStatus:e.ticketStatus,cells:n})}function Vr(e){return e==null?``:String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}function Hr(e){if(e==null||e===``)return`—`;let t=Number(e);return Vr(Number.isFinite(t)?t.toFixed(2):String(e))}function P(e,t){return`<p><strong>${Vr(e)}:</strong> ${t}</p>`}function Ur(){let e=O(D()||new Date,E);return`${`${String(e.day).padStart(2,`0`)}/${String(e.month).padStart(2,`0`)}/${e.year}`} ${`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}:${String(e.second).padStart(2,`0`)}`}`}function Wr(e){return`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Delux</title><style>${wr}</style></head><body>
  <div class="ticket">
    <h3>For Amusement Only</h3>
    <h2>NORTHERN DELUX</h2>
    <p class="meta"><strong>PURCHASE DETAILS</strong></p>
    ${[P(`Report time`,Vr(Ur())),P(`From date`,Vr(e.fromDate)),P(`To date`,Vr(e.toDate)),P(`Sale point`,Hr(e.salePoint)),P(`Win point`,Hr(e.winPoint)),P(`Cancel point`,Hr(e.cancelPoint)),P(`Commission point`,Hr(e.commissionPoint)),P(`NTP point`,Hr(e.ntpPoint)),P(`Operator point`,Hr(e.operatorPoint))].join(``)}
    <div class="footer">Northern Delux — counter purchase line</div>
    <div class="footer">**Ticket not for sale**</div>
  </div></body></html>`}function Gr(e){if(!e)return!1;let t=Wr(e);if(Cr(t))return!0;let n=document.createElement(`iframe`);n.setAttribute(`title`,`purchase-details-print`),n.style.cssText=`position:fixed;right:0;bottom:0;width:0;height:0;border:0;opacity:0;pointer-events:none`,document.body.appendChild(n);let r=n.contentDocument||n.contentWindow.document;r.open(),r.write(t),r.close();let i=n.contentWindow,a=()=>{try{i.focus(),i.print()}finally{setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n)},2e3)}};return r.readyState===`complete`?setTimeout(a,50):i.addEventListener(`load`,()=>setTimeout(a,50)),!0}var Kr=t({default:()=>qr}),qr=``+new URL(`4161854560_c48b3bbcbe-iJHQIlrj.jpg`,import.meta.url).href,Jr=t({default:()=>Yr}),Yr=``+new URL(`Durga-Yantra-6x6-Front_1200_klein-CjkmTqLQ.jpg`,import.meta.url).href,Xr=t({default:()=>Zr}),Zr=``+new URL(`Ganesha_Yantra-CrRaf6Zg.jpg`,import.meta.url).href,Qr=t({default:()=>$r}),$r=``+new URL(`Tripura-bhairavi_yantra_color-DS4ciZRR.jpg`,import.meta.url).href,ei=t({default:()=>ti}),ti=``+new URL(`bagalamukhi-yantra-cOlD-yPl.jpg`,import.meta.url).href,ni=t({default:()=>ri}),ri=``+new URL(`il_fullxfull.1598885277_esyt-Cw0wiXt6.jpg`,import.meta.url).href,ii=t({default:()=>ai}),ai=``+new URL(`venkatesh-yantra-CBa8UIzd.png`,import.meta.url).href,oi=1e3,si=Object.assign({"../media/slideshow/4161854560_c48b3bbcbe.jpg":Kr,"../media/slideshow/Durga-Yantra-6x6-Front_1200_klein.jpg":Jr,"../media/slideshow/Ganesha_Yantra.jpg":Xr,"../media/slideshow/Tripura-bhairavi_yantra_color.jpg":Qr,"../media/slideshow/bagalamukhi-yantra.jpg":ei,"../media/slideshow/il_fullxfull.1598885277_esyt.jpg":ni,"../media/slideshow/venkatesh-yantra.png":ii});function ci(e){if(typeof e==`string`)return e;let t=e&&e.default;return typeof t==`function`?t():typeof t==`string`?t:e}function li(){return Object.keys(si).sort().map(e=>ci(si[e]))}function ui(e){if(!e)return()=>{};let t=li();e.textContent=``,e.classList.add(`gamescreen_slideshow`);let n=document.createElement(`img`),r=document.createElement(`img`);if(n.className=`gamescreen_slideshow_layer`,r.className=`gamescreen_slideshow_layer`,n.alt=``,r.alt=``,n.draggable=!1,r.draggable=!1,e.appendChild(n),e.appendChild(r),t.length===0)return()=>{e.textContent=``,e.classList.remove(`gamescreen_slideshow`)};let i=n,a=r,o=0;if(i.src=t[0],i.classList.add(`gamescreen_slideshow_layer--active`),t.length<2)return()=>{e.textContent=``,e.classList.remove(`gamescreen_slideshow`)};let s=null,c=async()=>{o=(o+1)%t.length,a.removeAttribute(`src`),a.src=t[o];try{await a.decode()}catch{await new Promise(e=>{let t=()=>e();a.onload=t,a.onerror=t})}a.classList.add(`gamescreen_slideshow_layer--active`),i.classList.remove(`gamescreen_slideshow_layer--active`);let e=i;i=a,a=e};return s=window.setInterval(()=>{c()},oi),()=>{s!=null&&(clearInterval(s),s=null),e.textContent=``,e.classList.remove(`gamescreen_slideshow`)}}function F(e){return e==null?``:String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}function di(e){if(!e||typeof e!=`object`)return``;let t=[e.userCode,e.username,e.userName,e.login,e.pin,e.id];for(let e of t){if(e==null)continue;let t=String(e).trim();if(t)return t}return``}function fi(e){let t=di(e);return t?`P.No.${t}`:`P.No.—`}var I={startHour:0,startMinute:5,endHour:23,endMinute:55,interval:5};function pi(e){let t=[],n=e.startHour*60+e.startMinute,r=e.endHour*60+e.endMinute;for(;n<=r;){let r=Math.floor(n/60),i=n%60;t.push(`${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`),n+=e.interval}return console.log(`Generated draw times (first 10):`,t.slice(0,10)),t}function mi(e,t){let n=O(t,E),r=n.hour*60+n.minute,i=I.startHour*60+I.startMinute,a=I.endHour*60+I.endMinute,o=I.interval,s;if(r<i)s=i;else if(r>a)return[...e];else{let t=r-i;if(s=i+(Math.floor(t/o)+1)*o,s>a)return[...e]}let c=e.filter(e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n>=s});return console.log(`Current time: ${n.hour}:${String(n.minute).padStart(2,`0`)} (${r} min)`),console.log(`Next draw starts at: ${Math.floor(s/60)}:${String(s%60).padStart(2,`0`)} (${s} min)`),console.log(`Upcoming times:`,c),c}function hi(){let e=pi(I),t=[];for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1]||``;t.push([r,``,i,``])}return t}var gi=hi();function L(e,t,n=3e3){let r=e&&e.querySelector&&e.querySelector(`.gamescreen_place_chips`);r&&(e._placeChipsMsgTimer&&=(clearTimeout(e._placeChipsMsgTimer),null),r.textContent=t,e._placeChipsMsgTimer=setTimeout(()=>{r.textContent=``,e._placeChipsMsgTimer=null},n))}var _i=2,vi=2200,yi=2400;function bi(e,t){!e||!e.querySelector||(e._advanceChipsMsgQueue||=[],e._advanceChipsMsgQueue.push(String(t)),!e._advanceChipsMsgDrainRunning&&(e._advanceChipsMsgDrainRunning=!0,(async()=>{for(;e._advanceChipsMsgQueue&&e._advanceChipsMsgQueue.length>0;)L(e,e._advanceChipsMsgQueue.shift(),vi),await new Promise(e=>setTimeout(e,yi));e._advanceChipsMsgDrainRunning=!1})()))}function xi(){let e=``;for(let t=0;t<10;t++){e+=`<div class="gamescreen_pr_row">`;for(let n=0;n<10;n++){let r=t*10+n,i=`PR${String(r).padStart(2,`0`)}`;e+=`<div class="gamescreen_pr_cell"><span class="gamescreen_pr_label">${i}</span><input type="text" class="gamescreen_pr_input" value="" /></div>`}e+=`<div class="gamescreen_all_cell"><span class="gamescreen_all_label">ALL A</span><input type="text" class="gamescreen_all_input" value="" /></div></div>`}return e}function Si(){return Array(10).fill(0).map(()=>`<div class="gamescreen_all_cell"><span class="gamescreen_all_label">ALL B</span><input type="text" class="gamescreen_all_input" value="" /></div>`).join(``)}function Ci(){return Array(10).fill(0).map(()=>`<div class="gamescreen_all_cell"><span class="gamescreen_all_label">ALL C</span><input type="text" class="gamescreen_all_input" value="" /></div>`).join(``)}function wi(){return gi.map(e=>`<div class="gamescreen_time_row">${e.map((t,n)=>t?`<div class="${n===0||n===2?`gamescreen_time_cell gamescreen_time_cell--time`:`gamescreen_time_cell gamescreen_time_cell--code`}">${F(t)}</div>`:`<div class="gamescreen_time_cell gamescreen_time_cell--code" data-lot-time="${F(n===1?e[0]:n===3?e[2]:``)}"></div>`).join(``)}
      </div>`).join(``)}function R(e){if(e==null||e===``)return``;if(typeof Buffer<`u`&&Buffer.isBuffer(e))return R(e.toString(`utf8`));if(typeof e==`object`&&e&&(typeof e.hours==`number`||typeof e.minutes==`number`)){let t=Number(e.hours)||0,n=Number(e.minutes)||0;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}let t=String(e).trim();if(!t)return``;let n=/^(\d{1,2}):(\d{2})(?::\d{2}(?:\.\d+)?)?/.exec(t);if(n){let e=Number(n[1]),t=Number(n[2]);if(Number.isFinite(e)&&Number.isFinite(t))return`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`}return t.length>=5?t.slice(0,5):t}function Ti(e){if(e==null||e===``)return null;let t=Number(e);return!Number.isFinite(t)||t<=1?null:t}function Ei(e){return e==null?``:Math.floor(e)===e?`${Math.floor(e)}X`:`${e}X`}function Di(e,t){let n=F(e||``),r=Ti(t);return(e=>`<span class="gamescreen_time_code_wrap">${e}</span>`)(r?`<span class="gamescreen_result_mult_badge">${F(Ei(r))}</span><span class="gamescreen_time_cell_code_text">${n}</span>`:`<span class="gamescreen_time_cell_code_text">${n}</span>`)}function Oi(e){let t=String(e||``).trim(),n=/^(\d{4}-\d{2}-\d{2})\s+(\d{1,2}:\d{2})(?::\d{2})?/.exec(t);return n?`${n[1]}|${R(`${n[2]}:00`)}`:null}function ki(e){let t=new Map,n=Array.isArray(e)?e:[];for(let e of n){let n=e.lotdate==null?``:String(e.lotdate).trim(),r=R(e.lotTime??e.lottime);n&&r&&t.set(`${n}|${r}`,e.multiple)}return t}function Ai(e){if(e==null)return``;let t=String(e).replace(/\D/g,``);return t?t.slice(-2).padStart(2,`0`):``}function ji(e){let t=R(e).split(`:`);if(t.length<2)return`PR`;let n=Number(t[0]),r=Number(t[1]);return!Number.isFinite(n)||!Number.isFinite(r)||r%2==0?`PR`:`NR`}function Mi(e){if(!e)return;let t=X?Hi(X):null,n=`PR`;if(t){let e=O(t,E);n=ji(`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}`)}e.querySelectorAll(`.gamescreen_pr_label`).forEach((e,t)=>{e.textContent=`${n}${String(t).padStart(2,`0`)}`})}function Ni(e){let t=R(e);return t?sn(`${t}:00`):``}async function Pi(e){if(!e)return;let t=await Ut(``);if(!t||!t.ok)return;let n=Array.isArray(t.results)?t.results:[];n[0],Mi(e);let r=X||D(),i=r?Hi(r):null,a=pi(I),o=1440;if(i){let e=O(i,E);o=e.hour*60+e.minute}console.log(`Next draw time:`,i?O(i,E):`none`),console.log(`Next draw minutes:`,o);let s=new Map;n.forEach(e=>{let t=R(e.lotTime??e.lottime),n=ji(t);s.set(t,{lotTime:t,cellID:`${n}${Ai(e.cellID)}`.trim(),multiple:e.multiple})});let c=e.querySelectorAll(`.gamescreen_time_row`),l=0,u=!1;c.forEach(e=>{let t=e.querySelectorAll(`.gamescreen_time_cell`),n=a[l++]||``,r=a[l++]||``,i=!1,c=!1;if(n){let[e,t]=n.split(`:`).map(Number);i=e*60+t<o}if(r){let[e,t]=r.split(`:`).map(Number);c=e*60+t<o}let d=n?s.get(n):null,f=r?s.get(r):null;t[0]&&(t[0].textContent=i?n:``),t[1]&&(i&&d?t[1].innerHTML=Di(d.cellID,d.multiple):t[1].textContent=``),t[2]&&(t[2].textContent=c?r:``),t[3]&&(c&&f?t[3].innerHTML=Di(f.cellID,f.multiple):t[3].textContent=``);let p=i||c;e.style.display=p?`grid`:`none`,p&&(u=!0)}),console.log(`Has any visible rows:`,u);let d=e.querySelector(`.gamescreen_time_table_wrap`);d&&setTimeout(()=>{d.scrollTop=d.scrollHeight},100)}function Fi({sessionUser:e}={}){return`
    <div class="gamescreen_wrap">
      <div class="gamescreen_scale">
      <div class="gamescreen_screen">
        <!-- TOP SECTION -->
        <div class="gamescreen_header">
          <div class="gamescreen_title">Northern Deluxe</div>
          <div class="gamescreen_cb_row">
            <label class="gamescreen_cb" for="gs_cb_print">
              <input id="gs_cb_print" type="checkbox" checked />
              <span>PRINT <br />TICKET</span>
            </label>
            <label class="gamescreen_cb" for="gs_cb_ac">
              <input id="gs_cb_ac" type="checkbox" />
              <span>AC</span>
            </label>
          </div>
          <div class="gamescreen_meta_stack">
            <div class="gamescreen_amount">0.00</div>
            <div class="gamescreen_date_box">08/04/2026</div>
            <div class="gamescreen_pno">${F(fi(e))}</div>
          </div>
          <div class="gamescreen_time_sections">
          <div class="gamescreen_clock">13:48:49</div>
          <div class="gamescreen_bulb" aria-hidden="true">
            <span class="gamescreen_bulb_glow"></span>
          </div>
          </div>
        </div>
        <!-- MIDDLE SECTION -->
        <div class="gamescreen_middle">
          <div class="gamescreen_left_panel">
            <div class="gamescreen_time_section">
              <div class="gamescreen_time_group">
                <div class="gamescreen_lbl_time">Next Draw</div>
                <div class="gamescreen_val_time">--:--</div>
              </div>
              <div class="gamescreen_time_group">
                <div class="gamescreen_lbl_timeleft">Time Left</div>
                <div class="gamescreen_val_timeleft">00:00:58</div>
              </div>
            </div>
            <div class="gamescreen_img_panel">
              <div class="gamescreen_slideshow_host"></div>
            </div>
            <div class="gamescreen_caption">
              <div>To Get Stones</div>
              <div>Choose Your Product Codes</div>
            </div>
            <div class="gamescreen_time_table_wrap">
              <div class="gamescreen_time_table">${wi()}</div>
            </div>
            <button type="button" class="gamescreen_fbtn gamescreen_fbtn--stone gamescreen_stone_left" data-gamescreen-action="stone-report">Stone</button>
          </div>
          <div class="gamescreen_right_panel">
            <div class="gamescreen_green">
              <div class="gamescreen_pr_block" id="gamescreen_pr_block">
                <div class="gamescreen_pr_main">${xi()}</div>
                <div class="gamescreen_allb_row">${Si()}</div>
                <div class="gamescreen_allc_row">${Ci()}</div>
              </div>
              <div class="gamescreen_draw_closed" id="gamescreen_draw_closed" style="display: none;">
                <div class="gamescreen_draw_closed_text">Draw Closed</div>
              </div>
            </div>
            <div class="gamescreen_right_bottom">
              <button type="button" class="gamescreen_heera">HEERA Stones<br />Product codes</button>
              <div class="gamescreen_place_chips"></div>
              <div class="gamescreen_lucky_container">
                <input type="text" class="gamescreen_lucky_input" maxlength="2" placeholder="1" />
                <button type="button" class="gamescreen_lucky" data-gamescreen-action="lucky-pick">L - Lucky Pick</button>
              </div>
            </div>
          </div>
        </div>
        <!-- BOTTOM SECTION -->
        <div class="gamescreen_bottom">
          <div class="gamescreen_mid">
            <div class="gamescreen_center_controls">
              <div class="gamescreen_toggles">
                <button type="button" class="gamescreen_toggle gamescreen_toggle--on" id="gs_toggle_current">Current</button>
                <button type="button" class="gamescreen_toggle" id="gs_toggle_upcoming">Upcoming</button>
              </div>
              <div class="gamescreen_stats">
                <div class="gamescreen_stat gamescreen_stat--w">0.00</div>
                <div class="gamescreen_stat gamescreen_stat--g">0</div>
              </div>
            </div>
            <div class="gamescreen_barcode_section">
              <span class="gamescreen_barcode_lbl">F8<br />Barcode</span>
              <input id="gs_barcode_inp" class="gamescreen_barcode_inp" type="text" maxlength="24" inputmode="numeric" autocomplete="off" value="" />
            </div>
          </div>
          <div class="gamescreen_footer">
            <div class="gamescreen_footer_center">
              <button type="button" class="gamescreen_fbtn gamescreen_fbtn--buy">F6-Buy</button>
              <button type="button" class="gamescreen_fbtn gamescreen_fbtn--cyan">F5-Clear</button>
              <button type="button" class="gamescreen_fbtn gamescreen_fbtn--cyan">F9-Can. Rec.</button>
              <button type="button" class="gamescreen_fbtn gamescreen_fbtn--cyan2" data-gamescreen-action="last-receipt">Last Receipt</button>
              <button type="button" class="gamescreen_fbtn gamescreen_fbtn--white" data-gamescreen-action="change-password">Change Password</button>
              <button type="button" class="gamescreen_fbtn gamescreen_fbtn--exit" data-gamescreen-action="exit-offline">Exit</button>
              <button type="button" class="gamescreen_fbtn gamescreen_fbtn--white" data-gamescreen-action="purchase-details">Purchase Details</button>
              ${xr()?`<button type="button" class="gamescreen_fbtn gamescreen_fbtn--white" data-gamescreen-action="test-lucky-modal">Test Result Modal</button>`:``}
            </div>
          </div>
        </div>
      </div>
      </div>
    </div>
  `}var Ii=null,Li=null,Ri=null;function zi(){Ii&&=(window.removeEventListener(`resize`,Ii),null)}function Bi(e){let t=e.querySelector(`.gamescreen_scale`),n=e.querySelector(`.gamescreen_screen`);if(!t||!n)return;let r=window.innerWidth/1366,i=window.innerHeight/768;t.style.width=`${window.innerWidth}px`,t.style.height=`${window.innerHeight}px`,n.style.transform=`scale(${r}, ${i})`}var z=null,Vi=null,B=null,V=null,H=null,U=null,W=null,G={timeLeftSeconds:0,isBettingAllowed:!0,isPopupShowing:!1,popupTimeoutId:null,currentDrawTime:null,winningRequestedForDrawTs:null,winningFetchPending:!1,prevCountdownSeconds:null,prevNextDrawTs:null,afterLuckyPickDismiss:null};function Hi(e){if(!e)return null;let t=O(e,E),n=t.hour*60+t.minute,r=I,i=r.startHour*60+r.startMinute,a=r.endHour*60+r.endMinute,o=r.interval,s=0,c;if(n<i)c=i;else if(n>a)s=1,c=i;else{let e=n-i;c=i+(Math.floor(e/o)+1)*o,c>a&&(s=1,c=i)}let l=an(t.year,t.month,t.day,0,0,0),u=O(new Date(l.getTime()+s*24*60*60*1e3),E),d=Math.floor(c/60),f=c%60;return an(u.year,u.month,u.day,d,f,0)}function Ui(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Wi(e){U||(U=document.createElement(`div`),U.className=`gs_spinner_overlay`,U.innerHTML=`<div class="gs_spinner" aria-hidden="true"></div>`,document.body.appendChild(U)),e?(In(!0),U.classList.remove(`gs_spinner_overlay--visible`),U.offsetHeight,requestAnimationFrame(()=>{U&&U.classList.add(`gs_spinner_overlay--visible`)})):(U.classList.remove(`gs_spinner_overlay--visible`),In(!1))}function Gi(e){let t=O(new Date(e),E);return`${String(t.hour).padStart(2,`0`)}:${String(t.minute).padStart(2,`0`)}:00`}function Ki(e){if(!Array.isArray(e))return 0;let t=0;for(let n of e){let e=parseFloat(String(n&&n.claimAmount!=null?n.claimAmount:``).replace(/[^0-9.-]/g,``));Number.isFinite(e)&&(t+=e)}return t}function qi(e){let t=[...new Set((Array.isArray(e)?e:[]).map(e=>e&&e.barcode!=null?String(e.barcode).trim():``).filter(Boolean))];return t.length===0?``:(t.length,t[0])}function Ji(e,t){let n=(t&&t[0]&&t[0].lotTime!=null?String(t[0].lotTime):``)||(e==null?``:Gi(e)),r=t&&t[0]&&t[0].lotdate!=null?String(t[0].lotdate):J.date||``;return r&&n?`${r} ${n}`:n||r||``}function Yi(){W&&(W.classList.remove(`gs_winning_modal_overlay--visible`),W._pendingOnOk=null)}function Xi(e,t={}){let n=typeof t.onOk==`function`?t.onOk:null;W||(W=document.createElement(`div`),W.className=`gs_winning_modal_overlay`,document.body.appendChild(W),W.addEventListener(`click`,e=>{if(e.target&&e.target.classList&&e.target.classList.contains(`gs_winning_modal_ok`)){let e=W._pendingOnOk;W._pendingOnOk=null,typeof e==`function`&&e(),Yi();return}e.target===W&&Yi()})),W._pendingOnOk=n,W.innerHTML=`<div class="gs_winning_modal_panel" role="dialog" aria-modal="true">
    <div class="gs_winning_modal_title">Winning</div>
    <div class="gs_winning_modal_amount">${F(e)}</div>
    <button type="button" class="gs_winning_modal_ok">OK</button>
  </div>`,W.classList.remove(`gs_winning_modal_overlay--visible`),W.offsetHeight,requestAnimationFrame(()=>{W&&W.classList.add(`gs_winning_modal_overlay--visible`)})}function Zi(){let e=G.afterLuckyPickDismiss;if(G.afterLuckyPickDismiss=null,typeof e==`function`)try{e()}catch{}}function Qi(e=3e3){G.popupTimeoutId&&clearTimeout(G.popupTimeoutId),G.popupTimeoutId=setTimeout(()=>{V&&(Jn(V),V.classList.remove(`lp_overlay--visible`),document.body.style.overflow=``),G.isPopupShowing=!1,G.popupTimeoutId=null,Zi()},e)}function $i(e){return!0}function ea(e){let t=parseFloat(e.value);return isNaN(t)?0:t}function ta(e,t){e.value=t>0?t:``}function na(e){let t=String(e).replace(/\D/g,``);return t.length>3&&(t=t.slice(0,3)),t}var K={baseValues:Array(100).fill(0),allA:Array(10).fill(0),allB:Array(10).fill(0),allC:Array(10).fill(0),editedCells:Array(100).fill(!1)};function ra(){K.baseValues.fill(0),K.allA.fill(0),K.allB.fill(0),K.allC.fill(0),K.editedCells.fill(!1)}function ia(){return{baseValues:K.baseValues.slice(),allA:K.allA.slice(),allB:K.allB.slice(),allC:K.allC.slice()}}function aa(e){K.baseValues.splice(0,e.baseValues.length,...e.baseValues),K.allA.splice(0,e.allA.length,...e.allA),K.allB.splice(0,e.allB.length,...e.allB),K.allC.splice(0,e.allC.length,...e.allC)}function oa(e){let t=parseFloat(String(e).replace(/[^0-9.-]/g,``));return Number.isFinite(t)?t:0}function sa(){if(z)try{z.hide()}catch{}if(B)try{B.hide()}catch{}if(H)try{H.hide()}catch{}tr(),ir(),V&&V.classList.contains(`lp_overlay--visible`)&&(Jn(V),V.classList.remove(`lp_overlay--visible`)),G.afterLuckyPickDismiss=null,$a(),Yi(),document.body.style.overflow=``}function ca(e,t){e&&e.querySelectorAll(`.gamescreen_pr_input, .gamescreen_all_input, .gamescreen_lucky_input`).forEach(e=>{e.readOnly=t})}function la(e){let t=e&&e.querySelector(`.gamescreen_amount`);if(!t)return;let n=ma(e);t.textContent=Math.max(0,wa-n).toFixed(2)}function q(e,t){return e*10+t}function ua(e,t,n){return(t-n+10)%10==9-e}function da(e,t){let n=0;for(let r=0;r<10;r++)ua(e,t,r)&&(n+=K.allC[r]||0);return n}function fa(e,t){let n=q(e,t),r=K.baseValues[n];if(K.editedCells[n])return r;let i=K.allA[e]||0,a=K.allB[t]||0,o=da(e,t);return r+i+a+o}function pa(e,t={}){let{skipFocusedInput:n=!0}=t,r=e.querySelectorAll(`.gamescreen_pr_row`),i=document.activeElement;r.forEach((e,t)=>{e.querySelectorAll(`.gamescreen_pr_input`).forEach((e,r)=>{n&&e===i||ta(e,fa(t,r))})}),ma(e),la(e)}function ma(e){let t=0;for(let e=0;e<10;e++)for(let n=0;n<10;n++)t+=fa(e,n);let n=e.querySelector(`.gamescreen_stat--w`);return n&&(n.textContent=t.toFixed(2)),t}function ha(e){ra(),e.querySelectorAll(`.gamescreen_pr_input`).forEach(e=>{e.value=``}),e.querySelectorAll(`.gamescreen_pr_row .gamescreen_all_input`).forEach(e=>{e.value=``});let t=e.querySelector(`.gamescreen_allb_row`);t&&t.querySelectorAll(`.gamescreen_all_input`).forEach(e=>{e.value=``});let n=e.querySelector(`.gamescreen_allc_row`);n&&n.querySelectorAll(`.gamescreen_all_input`).forEach(e=>{e.value=``});let r=e.querySelector(`.gamescreen_stat--w`);r&&(r.textContent=`0.00`);let i=e.querySelector(`#gs_barcode_inp`);i&&(i.value=``),la(e)}function ga(e){if(ka()){L(e,`Lucky pick is not available in advance bet mode.`);return}let t=Va();if(t){Rn(t),L(e,Ha(t));return}let n=Math.floor(Math.random()*100),r=e.querySelector(`.gamescreen_lucky_input`),i=1;if(r&&r.value.trim()){let t=parseInt(r.value.trim(),10);if(t>=0&&t<=99)i=t;else{L(e,`Enter value between 0-99`);return}}let a=q(Math.floor(n/10),n%10),o=ia();if(K.baseValues[a]=(K.baseValues[a]||0)+i,pa(e),ma(e)>wa+1e-9){aa(o),pa(e),L(e,`Insufficient balance to place this bet.`);return}L(e,`Lucky pick: ${String(n).padStart(2,`0`)} (+${i})`)}function _a(e,t){let n=e.querySelectorAll(`.gamescreen_pr_row`),r=e.querySelector(`.gamescreen_allb_row`),i=e.querySelector(`.gamescreen_allc_row`);for(let e=0;e<n.length;e++){let r=n[e].querySelectorAll(`.gamescreen_pr_input`);for(let n=0;n<r.length;n++)if(r[n]===t)return{type:`pr`,row:e,col:n};if(n[e].querySelector(`.gamescreen_all_input`)===t)return{type:`alla`,row:e,col:10}}if(r){let e=r.querySelectorAll(`.gamescreen_all_input`);for(let n=0;n<e.length;n++)if(e[n]===t)return{type:`allb`,row:10,col:n}}if(i){let e=i.querySelectorAll(`.gamescreen_all_input`);for(let n=0;n<e.length;n++)if(e[n]===t)return{type:`allc`,row:11,col:n}}return null}function va(e,t){let n=e.querySelectorAll(`.gamescreen_pr_row`),r=e.querySelector(`.gamescreen_allb_row`),i=e.querySelector(`.gamescreen_allc_row`),a=null;switch(t.type){case`pr`:if(t.row>=0&&t.row<10&&t.col>=0&&t.col<10){let e=n[t.row];e&&(a=e.querySelectorAll(`.gamescreen_pr_input`)[t.col])}break;case`alla`:if(t.row>=0&&t.row<10){let e=n[t.row];e&&(a=e.querySelector(`.gamescreen_all_input`))}break;case`allb`:r&&t.col>=0&&t.col<10&&(a=r.querySelectorAll(`.gamescreen_all_input`)[t.col]);break;case`allc`:i&&t.col>=0&&t.col<10&&(a=i.querySelectorAll(`.gamescreen_all_input`)[t.col]);break}a&&a.focus()}function ya(e,t,n){let r=_a(e,t);if(!r)return;let i=null;switch(r.type){case`pr`:i=ba(r,n);break;case`alla`:i=xa(r,n);break;case`allb`:i=Sa(r,n);break;case`allc`:i=Ca(r,n);break}i&&va(e,i)}function ba(e,t){switch(t){case`up`:if(e.row>0)return{type:`pr`,row:e.row-1,col:e.col};break;case`down`:if(e.row<9)return{type:`pr`,row:e.row+1,col:e.col};if(e.row===9)return{type:`allb`,row:10,col:e.col};break;case`left`:if(e.col>0)return{type:`pr`,row:e.row,col:e.col-1};if(e.col===0&&e.row>0)return{type:`pr`,row:e.row-1,col:9};break;case`right`:if(e.col<9)return{type:`pr`,row:e.row,col:e.col+1};if(e.col===9)return{type:`alla`,row:e.row,col:10};break}return null}function xa(e,t){switch(t){case`up`:if(e.row>0)return{type:`alla`,row:e.row-1,col:10};break;case`down`:if(e.row<9)return{type:`alla`,row:e.row+1,col:10};break;case`left`:return{type:`pr`,row:e.row,col:9};case`right`:break}return null}function Sa(e,t){switch(t){case`up`:return{type:`pr`,row:9,col:e.col};case`down`:return{type:`allc`,row:11,col:e.col};case`left`:if(e.col>0)return{type:`allb`,row:10,col:e.col-1};break;case`right`:if(e.col<9)return{type:`allb`,row:10,col:e.col+1};break}return null}function Ca(e,t){switch(t){case`up`:return{type:`allb`,row:10,col:e.col};case`down`:break;case`left`:if(e.col>0)return{type:`allc`,row:11,col:e.col-1};break;case`right`:if(e.col<9)return{type:`allc`,row:11,col:e.col+1};break}return null}var wa=0;async function Ta(e,t){if(t&&e.querySelector(`.gamescreen_amount`))try{let n=await Ht(t);n&&n.ok&&n.balance!==void 0&&(wa=parseFloat(n.balance)||0,la(e))}catch(e){console.error(`Error getting balance:`,e)}}function Ea(){let e=nn();return(e==null?String(Math.floor(Math.random()*1e8)).padStart(8,`0`):String(e).slice(-8))+Math.floor(Math.random()*1e4).toString().padStart(4,`0`)}function Da(){let e=nn();return`TXN${String(e??Math.floor(Math.random()*0xe8d4a51000))}${Math.floor(Math.random()*1e3).toString().padStart(3,`0`)}`}var J={date:``,time:``},Y=[],Oa=`current`;function ka(){return Oa===`advance`}function Aa(){return G.timeLeftSeconds>10}function ja(e,t){Oa=t===`advance`?`advance`:`current`;let n=e.querySelector(`#gs_toggle_current`),r=e.querySelector(`#gs_toggle_upcoming`);n&&r&&(ka()?(n.classList.remove(`gamescreen_toggle--on`),r.classList.add(`gamescreen_toggle--on`)):(n.classList.add(`gamescreen_toggle--on`),r.classList.remove(`gamescreen_toggle--on`),Y=[])),e&&X&&Pa(e)}function Ma(e){let t=R(e?.lotTime??e?.lottime),n=ji(t),r=Ai(e?.cellID),i=r?`${n} ${r}`:n,a=J.date||`—`,o=J.time||`—`,s=Number(e?.status),c=Number.isFinite(s)?s:1,l=Ti(e?.multiple),u=l==null?`1`:String(Math.floor(l)===l?Math.floor(l):l);return{date:a,time:o,drawTime:Ni(t)||o,result:i,drawType:`${n} ${t||``}`.trim(),resultStatus:c,displayMultiple:u}}async function Na(e,t,n){G.winningFetchPending=!1,Wi(!1);let r=t&&t.ok&&t.result?t.result:null,i=null,a=e._deluxUserCode;a&&n!=null&&(i=await Xt(a,Gi(n))),Pi(e),a&&await Ta(e,a);let o=i&&i.ok&&i.hasWinning?Ki(i.wins):0,s=o>0?()=>{let t=i&&Array.isArray(i.wins)?i.wins:[];Xi(o.toFixed(2),{onOk:()=>{let r=e.querySelector(`#gs_cb_ac`),i=e.querySelector(`#gs_cb_print`),s=r?r.checked:!1,c=i?i.checked:!0;if(!s||!c||t.length===0)return;let l=qi(t),u=t[0]&&t[0].dateAdded!=null?String(t[0].dateAdded):``,d=Ji(n,t),f=e._deluxSessionUser;kr({username:f?.name||f?.userName||a,barcode:l,drawTime:d,placeTime:u,winAmount:o})}})}:null;G.isPopupShowing=!0,xo(e,r?Ma(r):null,{reveal:!0,onAfterDismiss:s})}var X=null;function Pa(e){if(!X)return;let t=e.querySelector(`.gamescreen_val_timeleft`);if(!t)return;let n=e.querySelector(`.gamescreen_val_time`);if(!$i(X)){t.textContent=`Closed`,n&&(n.textContent=`--:--`),G.timeLeftSeconds=0,G.isBettingAllowed=!1,G.currentDrawTime=null,ka()?ca(e,!1):ca(e,!0);let r=e.querySelector(`.gamescreen_fbtn--buy`);r&&(r.disabled=!0);let i=e.querySelector(`#gs_toggle_upcoming`);i&&(i.disabled=!0);return}let r=Hi(X);if(!r){t.textContent=`Closed`,n&&(n.textContent=`--:--`),G.timeLeftSeconds=0,G.isBettingAllowed=!1,G.currentDrawTime=null,ka()?ca(e,!1):ca(e,!0);let r=e.querySelector(`.gamescreen_fbtn--buy`);r&&(r.disabled=!0);let i=e.querySelector(`#gs_toggle_upcoming`);i&&(i.disabled=!0);return}G.currentDrawTime=r;let i=r.getTime()-X.getTime(),a=Math.max(0,Math.ceil(i/1e3));if(t.textContent=Ui(a),n){let e=O(r,E);n.textContent=`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}`}G.timeLeftSeconds=a,G.isBettingAllowed=a>10,Mi(e);let o=r.getTime(),s=G.prevCountdownSeconds;s!=null&&s>10&&a<=10&&sa(),G.prevCountdownSeconds=a,a<=10&&ma(e)>0&&ha(e),ca(e,a<=10);let c=e.querySelector(`.gamescreen_fbtn--buy`);c&&(ka()?c.disabled=!0:c.disabled=a<=10);let l=e.querySelector(`#gs_toggle_upcoming`);l&&(l.disabled=a<=10),z?.isVisible&&uo();let u=G.prevNextDrawTs,d=u!=null&&u!==o,f=d?u:null;d&&f!=null&&f!==G.winningRequestedForDrawTs&&!G.winningFetchPending&&(G.winningRequestedForDrawTs=f,G.winningFetchPending=!0,Wi(!0),Wt().then(t=>Na(e,t,f)).catch(()=>Na(e,null,f))),G.prevNextDrawTs=o}function Fa(){G.popupTimeoutId&&(clearTimeout(G.popupTimeoutId),G.popupTimeoutId=null),G={timeLeftSeconds:0,isBettingAllowed:!0,isPopupShowing:!1,popupTimeoutId:null,currentDrawTime:null,winningRequestedForDrawTs:null,winningFetchPending:!1,prevCountdownSeconds:null,prevNextDrawTs:null,afterLuckyPickDismiss:null}}async function Ia(){try{let e=Ft(),t=await fetch(`${e}/api/time`,{cache:`no-store`});if(t.ok){let e=await t.json();if(e.utcMs!=null){tn(e);let t=e.date&&e.time?{date:e.date,time:e.time}:on(new Date(Number(e.utcMs)));return J.date=t.date,J.time=t.time,{...e,date:t.date,time:t.time}}}}catch(e){console.error(`Error fetching server time:`,e)}let e=D();if(e){let t=on(e);return J.date=t.date,J.time=t.time,{date:t.date,time:t.time,utcMs:nn()}}return{date:J.date,time:J.time,utcMs:nn()}}function La(){if(J.date&&J.time)return{date:J.date,time:J.time};let e=D();return e?on(e):{date:``,time:``}}function Ra(){let e=X?new Date(X.getTime()):D();if(!e)return La();let t=Hi(e);if(!t)return La();let n=O(t,E),r=n.year,i=String(n.month).padStart(2,`0`),a=String(n.day).padStart(2,`0`),o=String(n.hour).padStart(2,`0`),s=String(n.minute).padStart(2,`0`);return{date:`${r}-${i}-${a}`,time:`${o}:${s}:00`}}function za(e,t,n={}){let r=n.advanceOnly===!0,i=[],a=Ra(),o=Ea(),s=Da(),c=e&&e.querySelector?ma(e):0;function l(e,n,r){let l=r??c,u=n?Ba(e):a;for(let e=0;e<10;e++)for(let r=0;r<10;r++){let c=fa(e,r);if(c>0){let d=q(e,r),f={uID:t,point:0,cv:parseFloat(c),cellid:String(d).padStart(4,`0`),sernum:1e3,lotnum:0,lotdate:u.date,lottime:u.time,barcode:o,transId:s,isadvance:n,ticketTot:l,qtytot:0,printtime:a.time,printflag:0,dateAdded:a.date,dateModified:a.date,status:1,curAdvDraw:0};i.push(f)}}}if(r){let e=n.advanceDrawTime;return e==null||String(e).trim()===``||c<=0||l(String(e).trim(),!0,c),i}return l(null,!1,c),Y&&Y.length>0&&Y.forEach(e=>{l(e,!0,c)}),i}function Ba(e){let t=String(e||``).trim().split(`:`),n=Number(t[0]),r=Number(t[1]??0);if(!Number.isFinite(n)||!Number.isFinite(r))return{date:``,time:`00:00:00`};let i=X?new Date(X):D();if(!i)return{date:``,time:`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}:00`};let a=O(i,E),o=an(a.year,a.month,a.day,n,r,0);o.getTime()<=i.getTime()&&(o=new Date(o.getTime()+1440*60*1e3));let s=O(o,E);return{date:`${s.year}-${String(s.month).padStart(2,`0`)}-${String(s.day).padStart(2,`0`)}`,time:`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}:00`}}function Va(){return G.isBettingAllowed?null:G.currentDrawTime!=null&&G.timeLeftSeconds>=1&&G.timeLeftSeconds<=10?`BETTING_LOCKED`:`BETTING_CLOSED`}function Ha(e){return e===`BETTING_LOCKED`?`Bet locked.`:`Betting is closed.`}function Ua(e){switch(e){case`NO_BETS`:return`No bets to place. Please select numbers first.`;case`INSUFFICIENT_BALANCE`:return`Insufficient balance to place this bet.`;case`NO_USER_CODE`:return`User not logged in properly.`;case`NOT_CONNECTED`:return`Not connected to server. Please reconnect.`;case`TIMEOUT`:return`Request timed out. Please try again.`;case`NETWORK_ERROR`:return`Network error. Please try again.`;case`BETTING_LOCKED`:return`Bet locked.`;case`BETTING_CLOSED`:return`Betting is closed.`;case`NO_BETS_CREATED`:return`No bets could be created. Check your grid.`;case`MISSING_FIELDS`:return`Invalid bet data. Please try again.`;case`NO_ADVANCE_TIMES`:return`Select at least one draw time.`;default:return`Failed to place bet: ${e}`}}function Wa(e){let t=localStorage.getItem(`username`);return t!=null&&String(t).trim()!==``?String(t).trim():e||`—`}function Ga(e){if(e&&e.timestamp){let t=new Date(e.timestamp);if(!Number.isNaN(t.getTime()))return t.toLocaleString()}try{return new Date().toLocaleString()}catch{return``}}function Ka(e,t,n,r){if(!t?.ok||!Array.isArray(n)||n.length===0)return;let i=Wa(e),a=n[0]?.lotdate==null?``:String(n[0].lotdate),o=t.drawTime!=null&&String(t.drawTime).trim()!==``?String(t.drawTime).trim():n[0]?.lottime==null?``:String(n[0].lottime),s={terminal:i,barcode:t.barcode,lotdate:a,drawTimeHms:o,ticketTime:Ga(t),ticketStatus:t.ticketStatus,lines:n};r?Pr(s):Nr({...s,heading:`BET RECEIPT`})}async function qa(e,t,n={}){if(!t)return{ok:!1,error:`NO_USER_CODE`};let r=n.advanceOnly===!0,i=n.silentReceipt===!0;if(G.timeLeftSeconds<=10)return Rn(`BETTING_LOCKED`),{ok:!1,error:`BETTING_LOCKED`};if(r){if(!Y||Y.length===0)return{ok:!1,error:`NO_ADVANCE_TIMES`};let t=ma(e)*Y.length;if(t<=0)return{ok:!1,error:`NO_BETS`};if(t>wa)return{ok:!1,error:`INSUFFICIENT_BALANCE`}}else{let t=Va();if(t)return Rn(t),{ok:!1,error:t};let n=ma(e);if(n<=0)return{ok:!1,error:`NO_BETS`};if(n>wa)return{ok:!1,error:`INSUFFICIENT_BALANCE`}}try{let n=localStorage.getItem(`userID`)||t;if(r){let r=Y.slice();console.log(`Processing advance bets for time slots:`,r);let a=null;async function o(r){console.log(`Placing advance bet for slot:`,r);let a=za(e,n,{advanceOnly:!0,advanceDrawTime:r});if(console.log(`Created bet list for slot`,r,`with`,a.length,`bets`),a.length===0)return{ok:!1,errResponse:{ok:!1,error:`NO_BETS_CREATED`}};let o=Ba(r);console.log(`Parsed draw time for slot`,r,`:`,o);let s=await zt(t,o.time,a);if(console.log(`Place bet response for slot`,r,`:`,s),!s||!s.ok)return{ok:!1,errResponse:s||{ok:!1,error:`UNKNOWN_ERROR`}};let c=s.barcode!=null&&String(s.barcode).trim()!==``?String(s.barcode).trim():`—`;bi(e,`Draw ${String(r).trim()}: bet placed. Barcode ${c}`);let l=e.querySelector(`#gs_cb_print`),u=l?l.checked:!0;return console.log(`Print checkbox checked:`,u),!i&&u&&Ka(t,s,a,!0),{ok:!0,response:s}}for(let e=0;e<r.length;e+=_i){let t=r.slice(e,e+_i);console.log(`Processing chunk:`,t);let n=await Promise.all(t.map(e=>o(e)));for(let e of n){if(!e.ok)return console.log(`Failed result:`,e.errResponse),e.errResponse||{ok:!1,error:`UNKNOWN_ERROR`};a=e.response}}return ha(e),Y=[],a||{ok:!1,error:`UNKNOWN_ERROR`}}let a=za(e,n,{advanceOnly:!1});if(a.length===0)return{ok:!1,error:`NO_BETS_CREATED`};let o=Ra().time,s=await zt(t,o,a);if(s&&s.ok){let n=e.querySelector(`#gs_cb_print`),r=n?n.checked:!0;return console.log(`Regular bet - Print checkbox checked:`,r),!i&&r&&Ka(t,s,a,!1),ha(e),Y=[],s}return s||{ok:!1,error:`UNKNOWN_ERROR`}}catch(e){return console.error(`Error placing bet:`,e),{ok:!1,error:`NETWORK_ERROR`}}finally{try{await Ta(e,t)}catch{}}}function Ja(e){e.addEventListener(`focus`,()=>{e.style.backgroundColor=`#0066ff`,e.style.color=`#ffffff`}),e.addEventListener(`blur`,()=>{e.style.backgroundColor=``,e.style.color=``})}function Ya(e){if(zi(),e&&e._slideshowTeardown&&(e._slideshowTeardown(),e._slideshowTeardown=null),Li&&=(clearInterval(Li),null),Ri&&=(clearInterval(Ri),null),Fa(),X=null,Oa=`current`,Y=[],$a(),z&&=(z.destroy(),null),B&&=(B.destroy(),null),kn(),nr(),ar(),V&&=(Jn(V),document.body.removeChild(V),null),U&&=(In(!1),document.body.removeChild(U),null),W&&=(document.body.removeChild(W),null),e&&e._placeChipsMsgTimer&&(clearTimeout(e._placeChipsMsgTimer),e._placeChipsMsgTimer=null),e){e._advanceChipsMsgQueue=null,e._advanceChipsMsgDrainRunning=!1;let t=e.querySelector(`.gamescreen_place_chips`);t&&(t.textContent=``)}e&&e._f5Handler&&(document.removeEventListener(`keydown`,e._f5Handler),e._f5Handler=null),e&&e._f6Handler&&(document.removeEventListener(`keydown`,e._f6Handler),e._f6Handler=null),e&&e._f8Handler&&(document.removeEventListener(`keydown`,e._f8Handler),e._f8Handler=null),e&&e._upcomingDrawRefresh&&(e._upcomingDrawRefresh=null)}function Xa(){let e=O(rn(),E);return{ymd:`${e.year}-${String(e.month).padStart(2,`0`)}-${String(e.day).padStart(2,`0`)}`,ddMm:bn(new Date(e.year,e.month-1,e.day))}}async function Za(e,t,n,r,i,a={}){let o=a.showErrors!==!1;if(!T().connected)return On(e,[]),o&&t&&L(t,`Not connected to server.`),!1;let s=await Yt(n,r,i);if(!s||s.ok!==!0)return On(e,[]),o&&t&&L(t,s&&s.error===`TIMEOUT`?`Purchase details request timed out.`:`Could not load purchase details.`),!1;let c=s.summary,l=Array.isArray(s.data)?s.data:[],u=l.map(e=>{let t=Sn(e.lotdate);return{rowKind:`day`,fromDate:t,toDate:t,salePoint:e.play,winPoint:e.win,cancelPoint:e.cancelPoint==null?e.cancel:e.cancelPoint,commissionPoint:e.commissionPoint,ntpPoint:e.ntpPoint,operatorPoint:e.operatorPoint}});return c&&(l.length>1||l.length===0)&&u.push({rowKind:`total`,fromDate:Sn(c.fromDate),toDate:Sn(c.toDate),salePoint:c.salePoint,winPoint:c.winPoint,cancelPoint:c.cancelPoint,commissionPoint:c.commissionPoint,ntpPoint:c.ntpPoint,operatorPoint:c.operatorPoint}),On(e,u),!0}async function Qa(e,t){if(!G.isBettingAllowed)return;if(!B){let n=wn();B=new fn({onClose:()=>{}}),B.create(n);let r=B.element.querySelector(`.popup_body`);Tn(r,{onAction:async n=>{if(n===`close`){B.hide();return}if(n===`print`){let t=r._rfSelectedPurchaseRowIndex,n=r._purchaseDetailRows;if(t==null||!Array.isArray(n)||n[t]==null){L(e,`Select a row in the table, then click Print.`);return}Gr(n[t])||L(e,`Could not open print window. Check pop-up settings.`);return}if(n===`show`){let n=r.querySelector(`#rf_from_date`),i=r.querySelector(`#rf_to_date`),a=xn(n&&n.value),o=xn(i&&i.value);if(!a||!o){L(e,`Choose valid Report From and To dates.`);return}if(a>o){L(e,`Report From must be on or before To.`);return}await Za(r,e,t,a,o,{showErrors:!0})}}}),document.body.appendChild(B.element)}B.show();let n=B.element.querySelector(`.popup_body`);if(n){let{ymd:r,ddMm:i}=Xa(),a=n.querySelector(`#rf_from_date`),o=n.querySelector(`#rf_to_date`);a&&(a.value=i),o&&(o.value=i),await Za(n,e,t,r,r,{showErrors:!0})}}function $a(){Vi&&Vi.parentNode&&Vi.parentNode.removeChild(Vi),Vi=null}function eo(e){$a();let t=Array.isArray(e.cells)?e.cells:[],n=[];for(let e=0;e<t.length;e+=2){let r=t[e],i=t[e+1];n.push(`<tr>
      <td>${F(r?.cellID)}</td><td>${F(r?.cv)}</td>
      <td>${i?F(i.cellID):``}</td><td>${i?F(i.cv):``}</td>
    </tr>`)}let r=n.join(``),i=document.createElement(`div`);i.className=`td_overlay`,i.innerHTML=`
    <div class="td_panel">
      <div class="td_title">Ticket details</div>
      <table class="td_table">
        <thead><tr>
          <th>Cell</th><th>Value</th><th>Cell</th><th>Value</th>
        </tr></thead>
        <tbody>${r}</tbody>
      </table>
      <button type="button" class="td_close">Close</button>
    </div>`,i.addEventListener(`click`,e=>{e.target===i&&$a()});let a=i.querySelector(`.td_close`);a&&a.addEventListener(`click`,()=>$a()),document.body.appendChild(i),Vi=i}function to(e){if(!e||typeof e!=`string`)return null;let t=/^(\d{4})-(\d{2})-(\d{2})\s+(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(String(e).trim());return t?an(Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]),Number(t[5]),t[6]==null?0:Number(t[6])):null}function no(e,t){if(!e||!t)return!1;let n=to(e);if(!n)return!1;let r=O(n,E),i=O(t,E);return r.year===i.year&&r.month===i.month&&r.day===i.day&&r.hour===i.hour&&r.minute===i.minute}function ro(e,t){if(!e||!t)return!1;let n=to(e);return n?n.getTime()<t.getTime():!1}function io(e){if(!e)return!1;let t=e.winRaw;if(t!=null&&Number.isFinite(Number(t))&&Number(t)>0)return!0;let n=parseFloat(String(e.win==null?``:e.win).replace(/[^\d.-]/g,``));return!!(Number.isFinite(n)&&n>0)}function ao(e){if(!e)return!1;let t=String(e._result||``).trim().toLowerCase();if(t===`cancelled`||t===`loss`)return!1;let n=e.claimRaw;return n!=null&&Number.isFinite(Number(n))&&Number(n)>0?!1:!!(t===`win`||io(e))}function oo(e){let t=e.result==null?``:String(e.result),n=Number(e.claim),r=e.claim!=null&&e.claim!==``&&Number.isFinite(n)?n:null,i=Number(e.win),a=e.win!=null&&e.win!==``&&Number.isFinite(i)?i:null,o=e.ticketTot==null?NaN:Number(e.ticketTot),s=``;return Number.isFinite(o)?s=Math.abs(o-Math.round(o))<1e-9?String(Math.round(o)):String(o):e.play!=null&&e.play!==``&&(s=String(e.play)),{ticketId:e.ticketId==null?``:e.ticketId,barcode:e.barcode==null?``:String(e.barcode),gameId:e.gameId==null?``:e.gameId,startPoint:e.startPoint==null?``:e.startPoint,play:s,endPoint:``,drawTime:(()=>{let t=e.drawTime!=null&&String(e.drawTime).trim()!==``?String(e.drawTime).trim():``;if(t)return t;let n=e.lotdate??e.lotDate,r=e.lotTime??e.lottime;return n!=null&&r!=null?`${String(n).trim()} ${String(r).trim()}`:``})(),ticketTime:e.ticketTime==null?``:e.ticketTime,claimRaw:r,winRaw:a,_result:t}}function so(e){if(!Array.isArray(e))return[];let t=new Map;for(let n of e){let e=n.barcode==null?``:String(n.barcode).trim(),r=e===``?`t:${n.ticketId}`:`b:${e}`;if(!t.has(r)){t.set(r,{...n});continue}let i=t.get(r);if(n.claimRaw!=null&&Number.isFinite(Number(n.claimRaw))){let e=Number(n.claimRaw),t=i.claimRaw!=null&&Number.isFinite(Number(i.claimRaw))?Number(i.claimRaw):null;i.claimRaw=t==null?e:Math.max(t,e)}if(n.winRaw!=null&&Number.isFinite(Number(n.winRaw))){let e=Number(n.winRaw),t=i.winRaw!=null&&Number.isFinite(Number(i.winRaw))?Number(i.winRaw):null;i.winRaw=t==null?e:Math.max(t,e)}}return Array.from(t.values())}function co(e){let t=X?Hi(X):null,n=z?._drawMultipleByKey;return e.map(e=>{let r=e.claimRaw!=null&&Number.isFinite(Number(e.claimRaw))?Number(e.claimRaw):null,i=e.winRaw!=null&&Number.isFinite(Number(e.winRaw))?Number(e.winRaw):null,a=``;r!=null&&r>0?a=r.toFixed(2):i!=null&&i>0&&(a=String(i));let o=r!=null&&r>0?`true`:`false`,s=r!=null&&r>0,c=(String(e._result||``).trim().toLowerCase()===`win`||io(e))&&!s,l=``;l=e._result===`Cancelled`?`Cancelled`:c?`No claimed`:t&&e.drawTime?no(e.drawTime,t)?`Pending`:ro(e.drawTime,t)?`Completed`:`Pending`:e._result||`Pending`;let u=Oi(e.drawTime),d=Ti(u&&n instanceof Map?n.get(u):null),f=null;return d&&e.drawTime&&(f=`<div class="sh_draw_cell"><span class="gamescreen_result_mult_badge">${F(Ei(d))}</span><span class="sh_draw_text">${F(String(e.drawTime))}</span></div>`),{...e,win:a,claim:o,result:l,drawTimeHtml:f}})}function lo(){let e=fo();if(!e)return;let t=e.querySelector(`[data-action="cancel"]`);if(!t)return;if(!G.isBettingAllowed){t.disabled=!0;return}let n=z?._session?.selectedBarcode;if(!n){t.disabled=!0;return}let r=(z._allTickets||[]).find(e=>String(e.barcode)===String(n));if(!r){t.disabled=!0;return}let i=X?Hi(X):null;t.disabled=!(r._result!==`Cancelled`&&i!=null&&no(r.drawTime,i))}function uo(){let e=fo();if(!e)return;let t=!G.isBettingAllowed;e.querySelectorAll(`[data-action]`).forEach(e=>{let n=e.dataset.action;if(n===`close`)e.disabled=!1;else if(n===`reprint`)e.disabled=!z?._session?.selectedBarcode;else if(n===`claim`)e.disabled=!z?._session?.selectedBarcode;else if(n===`allclaim`){let t=z._allTickets||[];e.disabled=!Array.isArray(t)||t.length===0}else t?e.disabled=!0:e.disabled=!1});let n=e.querySelector(`#sh_show_all`),r=e.querySelector(`#sh_winning_only`);n&&(n.disabled=t),r&&(r.disabled=t),lo()}function fo(){return z?.element?z.element.querySelector(`.popup_body`)||z.element:null}function po(){if(!z)return;let e=fo();if(!e)return;let t=e.querySelector(`#sh_show_all`)?.checked??!1,n=e.querySelector(`#sh_winning_only`)?.checked??!1,r=z._allTickets||[];r=Array.isArray(r)?[...r]:[],n&&(r=r.filter(e=>String(e._result||``).trim().toLowerCase()===`win`));let i=X?Hi(X):null;!t&&i&&(r=r.filter(e=>no(e.drawTime,i)||ao(e))),vn(e,co(r)),uo()}async function mo(e,t,n,r){let i=await Qt(t,n);if(!i||!i.ok)return L(e,i?.message||i?.error||`Claim failed.`),!1;let a=i.amount==null?0:Number(i.amount);L(e,a>0?`Claimed ${a.toFixed(2)}.`:`Claimed.`);let o=e.querySelector(`#gs_cb_print`),s=o?o.checked:!0;if(s&&a>0){let t=i.lotdate&&i.lotTime?`${i.lotdate} ${i.lotTime}`:i.lotTime||i.lotdate||``;Or({username:r,barcode:i.barcode||n,drawTime:t,placeTime:``,timing:t,claimedAmount:a})||L(e,`Could not open print window. Check pop-up settings.`)}else !s&&a>0&&L(e,`Printing disabled - claim slip not printed.`);return await ho(),await Ta(e,t),!0}async function ho(){let e=fo();if(!z||!e||!z._session?.userCode)return;let t=z._session.userCode;if(_n(e,`Loading…`),!T().connected){z._allTickets=[],_n(e,`Not connected. Log in and wait for connection.`);return}let n=await Kt(t,{limit:5e3}),r=n&&n.ok&&Array.isArray(n.tickets)?n.tickets:[];if(n&&n.ok&&r.length===0){let e=typeof localStorage<`u`?localStorage.getItem(`userID`):null,t=e==null?``:String(e).trim();if(t&&/^\d+$/.test(t)){let e=await Kt(null,{regid:Number(t),limit:5e3});e&&e.ok&&Array.isArray(e.tickets)&&e.tickets.length>0&&(n=e,r=e.tickets)}}if(!n||!n.ok){z._allTickets=[],_n(e,n?.error===`TIMEOUT`?`Request timed out.`:n?.error===`MISSING_FIELDS`?`Missing user.`:`Could not load tickets.`);return}z._allTickets=so(r.map(oo)),z._session&&(z._session.selectedBarcode=``);let i=await Ut(``);z._drawMultipleByKey=i&&i.ok&&Array.isArray(i.results)?ki(i.results):new Map,_n(e,``),po()}function go(e,t){let n=z?._session?.root,r=z?._session?.userCode;if(z&&!(!(e===`close`||e===`reprint`||e===`claim`||e===`allclaim`||e===`select`||e===`filter`||e===`result`||e===`details`)&&!G.isBettingAllowed)){if(e===`close`){$a(),z.hide();return}if(e===`select`){z._session&&(z._session.selectedBarcode=t?.barcode||``),uo();return}if(e===`filter`){po();return}if(!(!n||!r)){if(e===`result`){$a(),vo();return}if(e===`claim`){(async()=>{if(!T().connected){L(n,`Not connected.`);return}let e=z._session?.selectedBarcode||``;if(!e){L(n,`Select a ticket row.`);return}await mo(n,r,e,z._session?.displayName||r)})();return}if(e===`allclaim`){(async()=>{if(!T().connected){L(n,`Not connected.`);return}let e=await Zt(r);if(!e||!e.ok){L(n,e?.message||e?.error||`Claim all failed.`);return}let t=Number(e.amount)||0,i=Array.isArray(e.items)?e.items:[];L(n,t>0?`Claimed all: ${t.toFixed(2)}.`:`No tickets to claim.`);let a=n.querySelector(`#gs_cb_print`),o=a?a.checked:!0;o&&t>0&&i.length>0?Ar({username:z._session?.displayName||r,printedAt:new Date().toLocaleString(),items:i})||L(n,`Could not open print window. Check pop-up settings.`):!o&&t>0&&i.length>0&&L(n,`Printing disabled - claim slip not printed.`),await ho(),await Ta(n,r)})();return}if(e===`reprint`){(async()=>{let e=z._session?.selectedBarcode||``;if(!e){L(n,`Select a ticket row.`);return}let t=await qt(r,e);if(!t||!t.ok){L(n,t?.error===`NOT_FOUND`?`Ticket not found.`:`Reprint could not load ticket.`);return}let i=Rr(t,Wa(r),{hidePlacedBets:!0,summaryTotalLabel:`Total points`});if(!i){L(n,`Nothing to print for this ticket.`);return}let a=n.querySelector(`#gs_cb_print`),o=a?a.checked:!0;console.log(`Reprint - Print checkbox checked:`,o),o?zr(i):L(n,`Printing disabled - reprint not printed.`)})();return}if(e===`details`){(async()=>{let e=z._session?.selectedBarcode||``;if(!e){L(n,`Select a ticket row.`);return}let t=await qt(r,e);if(!t||!t.ok){L(n,t?.error===`NOT_FOUND`?`Ticket not found.`:`Details request failed.`);return}eo(t)})();return}if(e===`cancel`){if(!G.isBettingAllowed||fo()?.querySelector(`[data-action="cancel"]`)?.disabled)return;(async()=>{let e=z._session?.selectedBarcode||``;if(!e){L(n,`Select a ticket row.`);return}let t=await qt(r,e);if(!t||!t.ok){L(n,t?.error===`NOT_FOUND`?`Ticket not found.`:`Could not load ticket for cancel.`);return}let i=await Jt(r,e);if(L(n,i?.str||(i?.ok?`Done.`:`Cancellation failed.`)),i&&i.ok){let e=Rr(t,Wa(r),{heading:`TICKET CANCELLED`,ticketStatus:`Cancelled`,footerLine2:``,hidePlacedBets:!0,operatorLabel:`Username`,stampCancelTime:!0,hideBarcode:!0,showTicketNotForSaleFooter:!1});if(e){let t=n.querySelector(`#gs_cb_print`),r=t?t.checked:!0;console.log(`Cancel receipt - Print checkbox checked:`,r),r?zr(e):L(n,`Printing disabled - cancel receipt not printed.`)}await ho(),await Ta(n,r)}})();return}}}}async function _o(e,t,n){if(!z){let e=hn({onAction:()=>{}});z=new fn({onClose:()=>{$a()}}),z.create(e),gn(z.element.querySelector(`.popup_body`),{onAction:(e,t)=>go(e,t),isBetLocked:()=>!1}),document.body.appendChild(z.element)}let r=di(n)||t;z._session={userCode:t,root:e,selectedBarcode:``,displayName:r},z.show(),await ho(),uo()}async function vo(){if(!H){let e=mr();H=new fn({onClose:()=>{console.log(`Result popup closed`);let e=document.querySelector(`.result_calendar_picker`);e&&e.remove()}}),H.create(e),hr(H.element.querySelector(`.popup_body`),{onAction:e=>{e===`close`&&H.hide()},onShow:async({date:e,stone:t})=>{await yo(e,t)}}),document.body.appendChild(H.element)}H.show(),await yo(``,`PR`)}async function yo(e,t){if(!H)return;let n=await Ut(``);if(!n||!n.ok){gr(H.element,[]);return}let r=(Array.isArray(n.results)?n.results:[]).filter(e=>ji(R(e.lotTime??e.lottime))===t).map(e=>{let t=R(e.lotTime??e.lottime);return{drawTime:t,result:`${ji(t)} ${Ai(e.cellID)}`.trim(),multiple:e.multiple}});gr(H.element,r)}function bo(e,t={}){if(!t.skipBettingCheck&&!G.isBettingAllowed)return;let n=t.userCode||e?._deluxUserCode||``,r=()=>{let e=pi(I);return X?mi(e,X):e};Zn(e,r(),X,t=>{let r=Array.isArray(t)?t:[];if(Y=r,console.log(`Selected future draw times:`,Y),r.length===0){L(e,`Select at least one draw time, then Confirm.`);return}(async()=>{let t=await qa(e,n,{advanceOnly:!0});if(!t||!t.ok){let n=t?.error||`UNKNOWN_ERROR`;n===`BETTING_LOCKED`&&Ln(),L(e,Ua(n))}else L(e,`Advance bet(s) placed.`)})()}),e._upcomingDrawRefresh=()=>{let t=r();upcomingDrawPopup&&upcomingDrawPopup.element&&Zn(e,t,X,t=>{let r=Array.isArray(t)?t:[];if(Y=r,r.length===0){L(e,`Select at least one draw time, then Confirm.`);return}(async()=>{let t=await qa(e,n,{advanceOnly:!0});if(!t||!t.ok){let n=t?.error||`UNKNOWN_ERROR`;n===`BETTING_LOCKED`&&Ln(),L(e,Ua(n))}else L(e,`Advance bet(s) placed.`)})()})}}function xo(e,t,n={}){let r=n.reveal===!0;if(!r&&!G.isBettingAllowed)return;G.popupTimeoutId&&(clearTimeout(G.popupTimeoutId),G.popupTimeoutId=null),G.afterLuckyPickDismiss=typeof n.onAfterDismiss==`function`?n.onAfterDismiss:null;let i=La(),a=t||{date:i.date||`—`,time:sn(i.time)||i.time||`—`,drawTime:sn(i.time)||i.time||`—`,result:`—`,drawType:`Result`,displayMultiple:`1`};V&&(Un(V),Jn(V));let o=Hn({data:a,reveal:r});V||(V=document.createElement(`div`),V.className=`lp_overlay`,document.body.appendChild(V)),V.innerHTML=o,delete V._lpFinalResultOverride,delete V._lpStatusDigitFrozen,Yn(V,{onAction:e=>{console.log(`Lucky pick action:`,e),e===`close`&&(Jn(V),G.popupTimeoutId&&(clearTimeout(G.popupTimeoutId),G.popupTimeoutId=null),V.classList.remove(`lp_overlay--visible`),document.body.style.overflow=``,G.isPopupShowing=!1,Zi())}}),V.classList.add(`lp_overlay--visible`),document.body.style.overflow=`hidden`;let s=a.resultStatus==null?2:Number(a.resultStatus),c=Number.isFinite(s)?s:2;if(Kn(V,c),c===1&&(Un(V),V._lpWinningPollTimer=window.setInterval(()=>{Wt().then(e=>{if(!V||!V.classList.contains(`lp_overlay--visible`))return;let t=e&&e.ok&&e.result?e.result:null,n=t?Number(t.status):1,r=Number.isFinite(n)?n:1;if(Kn(V,r),r!==1&&(Un(V),t)){let e=Ma(t);V._lpFinalResultOverride=e.result,Gn(V,e.displayMultiple);let n=V.querySelector(`#lp_result_text`),r=V.querySelector(`#lp_final_phase`);n&&r&&r.style.display===`block`&&(n.textContent=e.result||`—`)}})},2e3)),r){let e=a.result||`—`,t=a.drawTime||null,n=a.displayMultiple!=null&&String(a.displayMultiple).trim()!==``?String(a.displayMultiple).trim():`1`;qn(V,e,2800,()=>{Qi(3200)},t,n)}else Qi(3e3)}function So(e,{onAction:t,sessionUser:n,onSessionPatch:r}){zi(),Bi(e),Ii=()=>Bi(e),window.addEventListener(`resize`,Ii),ra(),Oa=`current`,Y=[];let i=n?.userCode||n?.id||`dev`;e._deluxUserCode=i,e._deluxSessionUser=n||null;let a=e.querySelector(`.gamescreen_pno`);a&&(a.textContent=fi(n)),Ta(e,i),Mi(e);let o=e.querySelector(`.gamescreen_slideshow_host`);o&&(e._slideshowTeardown&&=(e._slideshowTeardown(),null),e._slideshowTeardown=ui(o));let s=e.querySelector(`#gs_cb_print`),c=e.querySelector(`#gs_cb_ac`);s&&(s.disabled=!1,s.checked=!0),c&&(c.disabled=!0,c.checked=!1,(async()=>{let e=n?.ac;if((e==null||e===``)&&T().connected){let t=await Bt(i);t&&t.ok&&t.ac!=null&&(e=t.ac,r?.({ac:Number(t.ac)}))}c.checked=Number(e)===1,c.disabled=!1})(),c.addEventListener(`change`,async t=>{let n=t.target,a=n.checked,o=+!!a;if(!T().connected){n.checked=!a,L(e,`Not connected to server.`);return}let s=await Vt(i,o);if(!s||!s.ok){n.checked=!a,L(e,`Could not update AC.`);return}r?.({ac:o})}));async function l(){let t=await Ia(),n=e.querySelector(`.gamescreen_date_box`);n&&t.date&&(n.textContent=t.date);let r=e.querySelector(`.gamescreen_clock`);r&&t.time&&(r.textContent=t.time),t.utcMs!=null&&(X=new Date(Number(t.utcMs))),Pa(e);let i=T();if(i.connected!==e._histSocketOk)e._histSocketOk=i.connected,i.connected&&(e._histThrottleAt=0,Pi(e));else if(i.connected){let t=Date.now();t-(e._histThrottleAt||0)>=8e3&&(e._histThrottleAt=t,Pi(e))}}l(),Ri=setInterval(l,1e3);let u=e.querySelectorAll(`.gamescreen_pr_row`);u.forEach((t,n)=>{t.querySelectorAll(`.gamescreen_pr_input`).forEach((t,r)=>{Ja(t),t.addEventListener(`input`,t=>{if(!Aa())return;let i=na(t.target.value),a=oa(i),o=q(n,r);K.baseValues[o]=a,K.editedCells[o]=!0,t.target.value=i,ma(e),la(e)}),t.addEventListener(`keydown`,n=>{switch(n.key){case`ArrowUp`:n.preventDefault(),ya(e,t,`up`);break;case`ArrowDown`:n.preventDefault(),ya(e,t,`down`);break;case`ArrowLeft`:n.preventDefault(),ya(e,t,`left`);break;case`ArrowRight`:n.preventDefault(),ya(e,t,`right`);break}})})}),u.forEach((t,n)=>{let r=t.querySelector(`.gamescreen_all_input`);r&&(Ja(r),r.addEventListener(`input`,t=>{if(!Aa())return;let i=na(t.target.value);t.target.value=i;let a=ea(r),o=K.allA[n]||0;if(K.allA[n]=a,o>0&&a===0)for(let e=0;e<10;e++){let t=q(n,e);K.baseValues[t]=0,K.editedCells[t]=!1}if(a>0)for(let e=0;e<10;e++){let t=q(n,e);K.editedCells[t]=!1}pa(e)}),r.addEventListener(`keydown`,t=>{switch(t.key){case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:t.preventDefault(),ya(e,r,t.key.replace(`Arrow`,``).toLowerCase());break}}))});let d=e.querySelector(`.gamescreen_allb_row`);d&&d.querySelectorAll(`.gamescreen_all_input`).forEach((t,n)=>{Ja(t),t.addEventListener(`input`,r=>{if(!Aa())return;let i=na(r.target.value);r.target.value=i;let a=ea(t),o=K.allB[n]||0;if(K.allB[n]=a,o>0&&a===0)for(let e=0;e<10;e++){let t=q(e,n);K.baseValues[t]=0,K.editedCells[t]=!1}if(a>0)for(let e=0;e<10;e++){let t=q(e,n);K.editedCells[t]=!1}pa(e)}),t.addEventListener(`keydown`,n=>{switch(n.key){case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:n.preventDefault(),ya(e,t,n.key.replace(`Arrow`,``).toLowerCase());break}})});let f=e.querySelector(`.gamescreen_allc_row`);f&&f.querySelectorAll(`.gamescreen_all_input`).forEach((t,n)=>{Ja(t),t.addEventListener(`input`,r=>{if(!Aa())return;let i=na(r.target.value);r.target.value=i;let a=ea(t),o=K.allC[n]||0;if(K.allC[n]=a,o>0&&a===0){for(let e=0;e<10;e++)for(let t=0;t<10;t++)if(ua(e,t,n)){let n=q(e,t);K.baseValues[n]=0,K.editedCells[n]=!1}}if(a>0){for(let e=0;e<10;e++)for(let t=0;t<10;t++)if(ua(e,t,n)){let n=q(e,t);K.editedCells[n]=!1}}pa(e)}),t.addEventListener(`keydown`,n=>{switch(n.key){case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:n.preventDefault(),ya(e,t,n.key.replace(`Arrow`,``).toLowerCase());break}})});let p=e.querySelector(`.gamescreen_fbtn--cyan`);p&&p.textContent.includes(`F5-Clear`)&&p.addEventListener(`click`,()=>{ha(e)});let m=t=>{t.key===`F5`&&(t.preventDefault(),ha(e))};document.addEventListener(`keydown`,m),e._f5Handler=m;let h=e.querySelector(`#gs_barcode_inp`);h&&(Ja(h),h.addEventListener(`input`,()=>{let t=String(h.value||``).replace(/\D/g,``).slice(0,12);if(t!==h.value&&(h.value=t),t.length!==12||e._barcodeClaimPending)return;e._barcodeClaimPending=!0;let r=t,a=di(n)||i;(async()=>{try{if(!T().connected){L(e,`Not connected.`);return}await mo(e,i,r,a)}finally{h.value=``,e._barcodeClaimPending=!1}})()}));let g=t=>{if(t.key===`F8`){t.preventDefault();let n=e.querySelector(`#gs_barcode_inp`);n&&n.focus()}};document.addEventListener(`keydown`,g),e._f8Handler=g;let _=e.querySelector(`.gamescreen_lucky_input`);_&&(Ja(_),_.addEventListener(`input`,e=>{let t=e.target.value.replace(/\D/g,``);t.length>2&&(t=t.slice(0,2)),t!==``&&parseInt(t,10)>99&&(t=`99`),e.target.value=t}),_.addEventListener(`keypress`,e=>{!/\d/.test(e.key)&&![`Backspace`,`Delete`,`Tab`,`Enter`,`ArrowLeft`,`ArrowRight`].includes(e.key)&&e.preventDefault()}),_.addEventListener(`paste`,e=>{e.preventDefault();let t=(e.clipboardData||window.clipboardData).getData(`text`).replace(/\D/g,``).slice(0,2);e.target.value=t}));let v=e.querySelector(`.gamescreen_fbtn--buy`);v&&v.addEventListener(`click`,async()=>{if(ka()){L(e,`Upcoming bets: choose chips, tap Upcoming, pick draw times, then Confirm.`);return}let t=Va();if(t){Rn(t),L(e,Ha(t));return}let n=v.textContent;v.textContent=`Placing Bet...`,v.disabled=!0;try{let t=Y.length,n=await qa(e,i);if(n&&n.ok)L(e,t>0?`Bet placed successfully for current draw + ${t} future draw(s).`:`Bet placed successfully.`);else{let t=n?.error||`Unknown error`;t===`BETTING_LOCKED`&&Ln(),L(e,Ua(t))}}catch(t){console.error(`Error in bet placement:`,t),L(e,`An error occurred while placing the bet.`)}finally{v.textContent=n,v.disabled=ka()||!G.isBettingAllowed}});let ee=t=>{if(t.key===`F6`){if(t.preventDefault(),ka()){L(e,`Upcoming bets: choose chips, tap Upcoming, pick draw times, then Confirm.`);return}let n=Va();if(n){Rn(n),L(e,Ha(n));return}v&&v.click()}};document.addEventListener(`keydown`,ee),e._f6Handler=ee,e.querySelectorAll(`[data-gamescreen-action]`).forEach(r=>{r.addEventListener(`click`,()=>{let a=r.dataset.gamescreenAction;if(a===`purchase-details`)Qa(e,i);else if(a===`stone-report`)_o(e,i,n);else if(a===`lucky-pick`)ga(e);else if(a===`test-lucky-modal`){if(!xr())return;(async()=>{G.isPopupShowing=!0;let t=null;if(T().connected){let e=await Wt();e&&e.ok&&e.result&&(t=Ma(e.result))}if(!t){let e=La();t={date:J.date||e.date||`—`,time:sn(e.time)||J.time||e.time||`—`,drawTime:sn(e.time)||J.time||e.time||`—`,result:`PR 00`,drawType:`TEST`,resultStatus:1,displayMultiple:`1`}}xo(e,t,{reveal:!0})})()}else a===`change-password`?rr(i,Ft(),(t,n)=>{t===`success`?L(e,`Password changed successfully!`):t===`error`&&L(e,n?.message||`Failed to change password`)}):a===`last-receipt`?(async()=>{if(!T().connected){L(e,`Not connected to server.`);return}let t=await Gt(i);if(!t||t.ok!==!0){L(e,t?.error===`TIMEOUT`?`Last receipt request timed out.`:`Could not load last receipt.`);return}if(!t.hasReceipt){L(e,`No receipt to print.`);return}let n=e.querySelector(`#gs_cb_print`),r=n?n.checked:!0;console.log(`Last receipt - Print checkbox checked:`,r),r?Br(t,{terminal:Wa(i)}):L(e,`Printing disabled - receipt not printed.`)})():t(a)})});let te=e.querySelector(`#gs_toggle_current`),ne=e.querySelector(`#gs_toggle_upcoming`),re=e.querySelector(`#gamescreen_pr_block`),ie=e.querySelector(`#gamescreen_draw_closed`);te&&ne&&re&&ie&&(te.addEventListener(`click`,()=>{ja(e,`current`),re.style.display=`flex`,ie.style.display=`none`}),ne.addEventListener(`click`,()=>{ja(e,`advance`),re.style.display=`flex`,ie.style.display=`none`,bo(e,{skipBettingCheck:!0,userCode:i})}))}async function Co(){try{let e=typeof window<`u`?window.electronAPI:null;if(e&&typeof e.closeApp==`function`){await e.closeApp();return}}catch{}typeof window<`u`&&window.close()}var wo=document.querySelector(`#app`),To=``,Eo=``,Do=`deluxAuth`;function Oo(){try{let e=localStorage.getItem(Do);if(!e)return null;let t=JSON.parse(e);return t&&typeof t==`object`?t:null}catch{return null}}function ko(e,t,n){try{localStorage.setItem(Do,JSON.stringify({pin:e||``,password:t||``,sessionUser:n||null}))}catch{}}function Ao(){$=null,ko(Q,Mo,null);try{localStorage.removeItem(`userID`)}catch{}}var jo=Oo(),Z=`offline`,Q=jo?.pin||To,Mo=jo?.password||Eo,No=``,Po=``,$=null;function Fo(e){return{INVALID_CREDENTIALS:`Invalid user code or password.`,MISSING_FIELDS:`Enter user code and password.`,NOT_CONNECTED:`Not connected to server.`,TIMEOUT:`Login timed out.`,SERVER_ERROR:`Server error. Try again.`,DB_ACCESS_DENIED:`Database rejected the app login. Run the API on the database machine (localhost/socket) or allow remote MySQL for this app user.`,MISSING_DEVICE:`This device did not send a valid install ID. Reinstall the app or contact support.`,DEVICE_PENDING_APPROVAL:`This device is not approved yet. Ask an administrator to approve the new device for your account.`}[e]||`Login failed.`}function Io(e){return e&&e.message===`CONNECT_TIMEOUT`?`Connection timed out.`:`Could not reach server.`}function Lo(){ln();let e=wo.querySelector(`.app_shell`);e?.querySelector(`.gamescreen_wrap`)&&Ya(e),wo.innerHTML=`<div class="app_shell">${Z===`offline`?n({connectError:No}):Z===`online`?i():Z===`login`?un({pin:Q,password:Mo,loginError:Po}):Fi({sessionUser:$})}</div>`,Ro()}function Ro(){let e=wo.querySelector(`.app_shell`);e&&(Z!==`game`&&zi(),Z===`offline`&&r(e,{async onAction(e){if(e===`connect`){No=``,Lo();try{await It(),Z=`online`}catch{No=Io()}Lo()}e===`power-off`&&await Co()}}),Z===`online`&&a(e,{async onAction(e){e===`disconnect`&&(Lt(),Z=`offline`,Lo()),e===`login-screen`&&(Po=``,Z=`login`,Lo()),e===`power-off`&&await Co()}}),Z===`login`&&dn(e,{async onAction(e){if(e===`enter-dashboard`){Po=``;let e=await Rt(Q,Mo);e&&e.ok?($=e.user||null,$&&localStorage.setItem(`userID`,$.id||$.userCode||Q),ko(Q,Mo,$),Z=`game`):Po=Fo(e&&e.error),Lo()}e===`back-to-connect`&&(Po=``,Z=`online`,Lo())},onPinInput(e){Q=e,ko(Q,Mo,$)},onPasswordInput(e){Mo=e,ko(Q,Mo,$)}}),Z===`game`&&So(e,{sessionUser:$,onSessionPatch(e){$&&e&&typeof e==`object`&&($={...$,...e},ko(Q,Mo,$))},onAction(e){e===`exit-offline`&&(Ao(),Po=``,No=``,Lt(),Z=`offline`,Lo())}}))}async function zo(){zn(),Lo()}zo();