!function(){try{var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e=Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4c9414e5-9dca-4f75-9613-ee0628ab5b02",t._sentryDebugIdIdentifier="sentry-dbid-4c9414e5-9dca-4f75-9613-ee0628ab5b02")}catch(t){}}();var _sentryModuleMetadataGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};_sentryModuleMetadataGlobal._sentryModuleMetadata=_sentryModuleMetadataGlobal._sentryModuleMetadata||{},_sentryModuleMetadataGlobal._sentryModuleMetadata[Error().stack]=Object.assign({},_sentryModuleMetadataGlobal._sentryModuleMetadata[Error().stack],{"_sentryBundlerPluginAppKey:web":!0}),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4781],{63762:function(t,e,s){var i;i=t=>(()=>{"use strict";var e={7:t=>{var e,s="object"==typeof Reflect?Reflect:null,i=s&&"function"==typeof s.apply?s.apply:function(t,e,s){return Function.prototype.apply.call(t,e,s)};e=s&&"function"==typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=Number.isNaN||function(t){return t!=t};function r(){r.init.call(this)}t.exports=r,t.exports.once=function(t,e){return new Promise(function(s,i){function n(s){t.removeListener(e,r),i(s)}function r(){"function"==typeof t.removeListener&&t.removeListener("error",n),s([].slice.call(arguments))}m(t,e,r,{once:!0}),"error"!==e&&"function"==typeof t.on&&m(t,"error",n,{once:!0})})},r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var o=10;function a(t){if("function"!=typeof t)throw TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?r.defaultMaxListeners:t._maxListeners}function h(t,e,s,i){var n,r,o;if(a(s),void 0===(r=t._events)?(r=t._events=Object.create(null),t._eventsCount=0):(void 0!==r.newListener&&(t.emit("newListener",e,s.listener?s.listener:s),r=t._events),o=r[e]),void 0===o)o=r[e]=s,++t._eventsCount;else if("function"==typeof o?o=r[e]=i?[s,o]:[o,s]:i?o.unshift(s):o.push(s),(n=l(t))>0&&o.length>n&&!o.warned){o.warned=!0;var h=Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=o.length,console&&console.warn&&console.warn(h)}return t}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0==arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(t,e,s){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:s},n=c.bind(i);return n.listener=s,i.wrapFn=n,n}function p(t,e,s){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:"function"==typeof n?s?[n.listener||n]:[n]:s?function(t){for(var e=Array(t.length),s=0;s<e.length;++s)e[s]=t[s].listener||t[s];return e}(n):f(n,n.length)}function d(t){var e=this._events;if(void 0!==e){var s=e[t];if("function"==typeof s)return 1;if(void 0!==s)return s.length}return 0}function f(t,e){for(var s=Array(e),i=0;i<e;++i)s[i]=t[i];return s}function m(t,e,s,i){if("function"==typeof t.on)i.once?t.once(e,s):t.on(e,s);else{if("function"!=typeof t.addEventListener)throw TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function n(r){i.once&&t.removeEventListener(e,n),s(r)})}}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(t){if("number"!=typeof t||t<0||n(t))throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");o=t}}),r.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||n(t))throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},r.prototype.getMaxListeners=function(){return l(this)},r.prototype.emit=function(t){for(var e=[],s=1;s<arguments.length;s++)e.push(arguments[s]);var n="error"===t,r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var o,a=Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=r[t];if(void 0===l)return!1;if("function"==typeof l)i(l,this,e);else{var h=l.length,c=f(l,h);for(s=0;s<h;++s)i(c[s],this,e)}return!0},r.prototype.addListener=function(t,e){return h(this,t,e,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(t,e){return h(this,t,e,!0)},r.prototype.once=function(t,e){return a(e),this.on(t,u(this,t,e)),this},r.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,u(this,t,e)),this},r.prototype.removeListener=function(t,e){var s,i,n,r,o;if(a(e),void 0===(i=this._events)||void 0===(s=i[t]))return this;if(s===e||s.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,s.listener||e));else if("function"!=typeof s){for(n=-1,r=s.length-1;r>=0;r--)if(s[r]===e||s[r].listener===e){o=s[r].listener,n=r;break}if(n<0)return this;0===n?s.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(s,n),1===s.length&&(i[t]=s[0]),void 0!==i.removeListener&&this.emit("removeListener",t,o||e)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(t){var e,s,i;if(void 0===(s=this._events))return this;if(void 0===s.removeListener)return 0==arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==s[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete s[t]),this;if(0==arguments.length){var n,r=Object.keys(s);for(i=0;i<r.length;++i)"removeListener"!==(n=r[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=s[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this},r.prototype.listeners=function(t){return p(this,t,!0)},r.prototype.rawListeners=function(t){return p(this,t,!1)},r.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},r.prototype.listenerCount=d,r.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},101:(t,e,s)=>{e.TypedEmitter=s(7).EventEmitter},155:e=>{e.exports=t}},s={};function i(t){var n=s[t];if(void 0!==n)return n.exports;var r=s[t]={exports:{}};return e[t](r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{ClaimContainer:()=>I,ClaimNotificationClient:()=>d,FaucetApi:()=>e,FaucetSession:()=>s,FaucetTime:()=>t,PoWClient:()=>S,PoWHashAlgo:()=>l,PoWMiner:()=>g,PoWMinerStatusContainer:()=>R,PoWSession:()=>f,PoWWorker:()=>b,PromiseDfd:()=>p,base64ToHex:()=>y,getPoWParamsStr:()=>m,renderDate:()=>k,renderTime:()=>T,renderTimespan:()=>E,toDecimalUnit:()=>C,toQuery:()=>N,toReadableAmount:()=>v});class t{offset;constructor(){this.offset=0}syncTimeOffset(t){let e=Math.floor((new Date).getTime()/1e3);this.offset=e-t}getLocalDate(){return new Date}getLocalTime(){return Math.floor(this.getLocalDate().getTime()/1e3)}getSyncedDate(){return new Date((new Date).getTime()-1e3*this.offset)}getSyncedTime(){return Math.floor(this.getSyncedDate().getTime()/1e3)}}class e{faucetTime;apiBaseUrl;constructor(e){this.faucetTime=new t,e.match(/\/$/)&&(e=e.substring(0,e.length-1)),this.apiBaseUrl=e}getFaucetTime(){return this.faucetTime}getApiUrl(t,e){t?t.match(/^\//)||(t="/"+t):t="";let s=this.apiBaseUrl+t;return e&&s.match(/^\//)&&(s=location.protocol+"//"+location.host+s),s}async apiGet(t,e){t.match(/^\//)||(t="/"+t);let s=this.prepareArgs(e),i=await fetch(this.apiBaseUrl+t+s);return await i.json()}async apiPost(t,e,s){t.match(/^\//)||(t="/"+t);let i=this.prepareArgs(e),n=await fetch(this.apiBaseUrl+t+i,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return await n.json()}async getFaucetConfig(){let t=await this.apiGet("/getFaucetConfig",{cliver:2});return this.faucetTime.syncTimeOffset(t.time),t}getSession(t){return this.apiGet("/getSession",{session:t})}getSessionStatus(t,e){return this.apiGet("/getSessionStatus",{session:t,details:e?1:void 0})}startSession(t){return this.apiPost("/startSession",{},t)}claimReward(t){return this.apiPost("/claimReward",{},t)}getQueueStatus(){return this.apiGet("/getQueueStatus")}getFaucetStatus(){return this.apiGet("/getFaucetStatus")}getPassportInfo(t){return this.apiGet("/getPassportInfo",{session:t})}refreshPassport(t){return this.apiGet("/refreshPassport",{session:t})}refreshPassportJson(t,e){return this.apiPost("/refreshPassport",{session:t},e)}prepareArgs(t){let e="";if(t){let s=[];Object.keys(t).forEach(e=>{t[e]&&s.push(e+"="+encodeURIComponent(t[e].toString()))}),s.length>0&&(e="?"+s.join("&"))}return e}}(a=l||(l={})).SCRYPT="scrypt",a.CRYPTONIGHT="cryptonight",a.ARGON2="argon2";class s{static persistSessionInfo(t){t?localStorage.setItem("powSessionStatus",JSON.stringify({v:2,id:t.getSessionId(),time:t.getStartTime(),addr:t.getTargetAddr(),value:t.getDropAmount().toString()})):localStorage.removeItem("powSessionStatus")}static recoverSessionInfo(){let t=localStorage.getItem("powSessionStatus");if(!t)return null;let e=JSON.parse(t);return e&&2===e.v?e:null}faucetApi;sessionId;sessionInfo;sessionInfoPromise;constructor(t,e,s){this.faucetApi=t,this.sessionId=e,this.sessionInfo=s}loadSessionInfo(){return this.sessionInfo?Promise.resolve(this.sessionInfo):this.refreshSessionInfo()}refreshSessionInfo(){return this.sessionInfoPromise?this.sessionInfoPromise:this.sessionInfoPromise=this.faucetApi.getSession(this.sessionId).then(t=>{if(t.error)throw t;return this.sessionInfo=t,this.sessionInfoPromise=null,t})}setSessionInfo(t){this.sessionInfo=t}getSessionId(){return this.sessionId}getModuleState(t){return this.sessionInfo?.modules?this.sessionInfo?.modules[t]:void 0}setModuleState(t,e){this.sessionInfo.modules[t]=e}getStatus(){return this.sessionInfo?.status}setStatus(t){this.sessionInfo&&(this.sessionInfo.status=t)}getTargetAddr(){return this.sessionInfo?.target}getDropAmount(){return BigInt(this.sessionInfo?.balance||"0")}getStartTime(){return this.sessionInfo?.start}}var r,o,a,l,h,c,u=i(101);class p{promise;resolve;reject;constructor(){let t;this.promise=new Promise((e,s)=>{t={resolve:e,reject:s}}),this.resolve=t.resolve,this.reject=t.reject}}(r=h||(h={}))[r.CLOSED_IDLE=0]="CLOSED_IDLE",r[r.CLOSED_RECONNECT=1]="CLOSED_RECONNECT",r[r.CONNECTING=2]="CONNECTING",r[r.READY=3]="READY";class d extends u.TypedEmitter{options;clientSocket=null;clientStatus;readyDfd=null;reconnectTimer=null;disconnectTimer=null;constructor(t){super(),this.options=t,this.clientStatus=h.CLOSED_IDLE}start(){this.clientStatus=h.CLOSED_RECONNECT,this.startClient()}stop(){this.clientSocket&&(this.clientSocket.close(),this.clientSocket=null),this.clientStatus=h.CLOSED_IDLE}isReady(){return this.clientStatus===h.READY}getReadyPromise(){return this.clientStatus===h.READY?Promise.resolve():(this.readyDfd||(this.readyDfd=new p),this.readyDfd.promise)}startClient(){this.clientStatus=h.CONNECTING,this.clientSocket=new WebSocket(this.options.claimWsUrl+"?session="+this.options.sessionId),this.clientSocket.addEventListener("open",t=>{this.clientStatus=h.READY,this.onClientReady()}),this.clientSocket.addEventListener("close",t=>{this.onClientClose()}),this.clientSocket.addEventListener("error",t=>{this.onClientClose()}),this.clientSocket.addEventListener("message",t=>this.onClientMessage(t))}reconnectClient(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.clientStatus===h.CLOSED_RECONNECT&&this.startClient()},5e3+5e3*Math.random()))}onClientClose(){this.clientSocket=null,this.clientStatus!==h.CLOSED_IDLE&&(this.clientStatus=h.CLOSED_RECONNECT),this.disconnectTimer&&(clearTimeout(this.disconnectTimer),this.disconnectTimer=null),this.emit("close"),this.clientStatus===h.CLOSED_RECONNECT&&this.reconnectClient()}onClientMessage(t){var e;try{e=JSON.parse(t.data)}catch(t){return}"error"!==e.action&&this.emit(e.action,e)}onClientReady(){this.readyDfd&&(this.readyDfd.resolve(),this.readyDfd=null),this.disconnectTimer||(this.disconnectTimer=setTimeout(()=>{this.disconnectTimer=null,this.clientSocket&&this.clientSocket.close(1e3,"24h reconnect")},864e5)),this.emit("open")}}class f extends u.TypedEmitter{balance;options;miner;preImage="";lastNonce=0;shareCount=0;shareQueue;shareQueueProcessing;verifyResultQueue;constructor(t){super(),this.options=t}resumeSession(){this.shareQueue=[],this.verifyResultQueue=[];let t=this.options.session.getModuleState("pow");this.preImage=t.preImage,this.lastNonce=t.lastNonce+1,this.shareCount=t.shareCount,this.balance=this.options.session.getDropAmount(),this.options.client.on("open",()=>{this.processShareQueue(),this.processVerifyQueue()}),this.options.client.on("verify",t=>this.processVerification(t.data)),this.options.client.on("updateBalance",t=>this.updateBalance(t.data)),this.options.client.on("error",t=>{"CLIENT_KILLED"===t.data.code?this.options.client.stop():this.options.showNotification("error","WS Error: ["+t.data.code+"] "+t.data.message,!0,2e4)}),this.emit("resume")}setMiner(t){this.miner=t}closeSession(){return this.options.client.sendRequest("closeSession").then(t=>{this.emit("close",t)})}submitShare(t){this.options.client.isReady()&&0===this.shareQueue?.length?this._submitShare(t):this.shareQueue?.push(t),this.shareCount++}submitVerifyResult(t){this.options.client.isReady()&&0===this.verifyResultQueue?.length?this._submitVerifyResult(t):this.verifyResultQueue?.push(t)}getBalance(){return this.balance??BigInt(0)}updateBalance(t){this.balance=BigInt(t.balance),this.emit("balanceUpdate",t)}getNonceRange(t){let e=this.lastNonce;return this.lastNonce+=t,e}getLastNonce(){return this.lastNonce}getShareCount(){return this.shareCount}getPreImage(){return this.preImage}getTargetAddr(){return this.options.session.getTargetAddr()}getStartTime(){return this.options.session.getStartTime()}processShareQueue(){if(this.shareQueueProcessing)return;this.shareQueueProcessing=!0;let t=()=>{let e=this.shareQueue?.length??0;this.options.client.isReady()||(e=0),e>0&&(this._submitShare(this.shareQueue?.shift()),e--),e>0?setTimeout(()=>t(),2e3):this.shareQueueProcessing=!1};t()}_submitShare(t){this.options.client.sendRequest("foundShare",t).catch(t=>{this.options.showNotification("error","Submission error: ["+t.code+"] "+t.message,!0,2e4)})}processVerification(t){this.miner?.processVerification(t)}processVerifyQueue(){this.verifyResultQueue?.forEach(t=>this._submitVerifyResult(t))}_submitVerifyResult(t){this.options.client.sendRequest("verifyResult",t).catch(t=>{this.options.showNotification("error","Verification error: ["+t.code+"] "+t.message,!0,2e4)})}}function m(t,e){switch(t.a){case l.SCRYPT:return t.a+"|"+t.n+"|"+t.r+"|"+t.p+"|"+t.l+"|"+e;case l.CRYPTONIGHT:return t.a+"|"+t.c+"|"+t.v+"|"+t.h+"|"+e;case l.ARGON2:return t.a+"|"+t.t+"|"+t.v+"|"+t.i+"|"+t.m+"|"+t.p+"|"+t.l+"|"+e}}class g extends u.TypedEmitter{options;settings;workers;verifyWorker;powParamsStr;nonceQueue;lastSaveNonce;updateStatsTimer;totalShares;lastShareTime;targetNoncePrefill;latestStats;constructor(t){super(),this.options=t,this.workers=[],this.powParamsStr=m(t.powParams,t.difficulty),this.totalShares=0,this.lastShareTime=null,this.nonceQueue=[],this.lastSaveNonce=null,this.targetNoncePrefill=200,this.latestStats=null,this.loadSettings(),this.options.session.setMiner(this)}startMiner(){this.startStopWorkers()}stopMiner(){this.stopAllWorker(),this.verifyWorker&&(this.verifyWorker.worker.terminate(),this.verifyWorker=null)}setPoWParams(t,e,s){this.options.nonceCount=s;let i=m(t,e);if(this.powParamsStr===i)return;let n=this.options.powParams.a!==t.a;this.powParamsStr=i,this.options.powParams=t,this.nonceQueue=[],n?(this.stopAllWorker(),this.startStopWorkers()):(this.verifyWorker&&this.verifyWorker.worker.postMessage({action:"setParams",data:{params:t,difficulty:e}}),this.workers.forEach(s=>{s.ready&&s.worker.postMessage({action:"setParams",data:{params:t,difficulty:e}})}))}setWorkerCount(t){this.settings.workerCount=t,this.saveSettings(),this.startStopWorkers()}getTargetWorkerCount(){return this.settings.workerCount}loadSettings(){this.settings={workerCount:navigator.hardwareConcurrency||4};let t=localStorage.getItem("powMinerSettings");if(t)try{let e=JSON.parse(t);Object.assign(this.settings,e)}catch(t){}}saveSettings(){localStorage.setItem("powMinerSettings",JSON.stringify(this.settings))}startStopWorkers(){for(;this.workers.length>this.settings.workerCount;)this.stopWorker();for(;this.workers.length<this.settings.workerCount;)this.workers.push(this.startWorker());this.verifyWorker||(this.verifyWorker=this.startWorker(),this.verifyWorker.id=-1,this.verifyWorker.verifyWorker=!0)}startWorker(){let t=this.options.workerSrc[this.options.powParams.a];if(!t)throw"No worker src for '"+this.options.powParams.a+"' algorithm";let e={id:this.workers.length,worker:new Worker(t),ready:!1,stats:[],lastNonce:0,verifyWorker:!1};return e.worker.addEventListener("message",t=>this.onWorkerMessage(e,t)),e}stopWorker(){this.workers.length<=0||this.workers.pop().worker.terminate()}stopAllWorker(){for(;this.workers.length>0;)this.stopWorker()}onWorkerMessage(t,e){let s=e.data;if(s&&"object"==typeof s)switch(s.action){case"init":this.onWorkerInit(t);break;case"nonce":this.onWorkerNonce(t,s.data);break;case"stats":this.onWorkerStats(t,s.data);break;case"verifyResult":this.onWorkerVerifyResult(t,s.data)}}onWorkerInit(t){if(t.ready=!0,t.verifyWorker)t.worker.postMessage({action:"setParams",data:{params:this.options.powParams,difficulty:this.options.difficulty}});else{let e=this.getLimitedNonceRefillCount(this.targetNoncePrefill);0===e&&(e=1);let s=this.options.session.getNonceRange(e);t.lastNonce=s,t.worker.postMessage({action:"setWork",data:{workerid:t.id,preimage:this.options.session.getPreImage(),params:this.options.powParams,difficulty:this.options.difficulty,nonceStart:s,nonceCount:e}})}}onWorkerNonce(t,e){if(e.params!==this.powParamsStr)return;t.lastNonce=e.nonce;let s=0,i=this.nonceQueue.length;for(;s<i&&e.nonce>this.nonceQueue[s];)s++;this.nonceQueue.splice(s,0,e.nonce),this.processNonceQueue()}processNonceQueue(){let t=null;if(this.workers.forEach(e=>{e.ready&&(null===t||e.lastNonce<t)&&(t=e.lastNonce)}),null===t||this.lastSaveNonce===t)return;this.lastSaveNonce=t;let e=0,s=this.nonceQueue.length;if(!(s<this.options.nonceCount)){for(let i=0;i<s&&!(this.nonceQueue[i]>t);i++)e++;for(;e>=this.options.nonceCount;){let t={nonces:this.nonceQueue.splice(0,this.options.nonceCount),params:this.powParamsStr,hashrate:this.latestStats?this.latestStats.hashRate:0};this.totalShares++,this.lastShareTime=this.options.time.getSyncedDate(),e-=this.options.nonceCount,this.options.session.submitShare(t)}}}getLimitedNonceRefillCount(t){if(this.options.hashrateLimit<=0)return t;let e=this.options.time.getSyncedTime()-this.options.session.getStartTime();if(e<=1)return t;let s=(e+=4)*this.options.hashrateLimit-this.options.session.getLastNonce();return s<=0?t=t>0?1:0:t>s&&(t=s),t}onWorkerStats(t,e){if(t.stats.push({shares:e.shares,time:e.time}),t.stats.length>30&&t.stats.splice(0,1),t.lastNonce=e.last,e.nonces<this.targetNoncePrefill){let s=this.getLimitedNonceRefillCount(this.targetNoncePrefill-e.nonces);s>0&&t.worker.postMessage({action:"addRange",data:{start:this.options.session.getNonceRange(s),count:s}})}this.processNonceQueue(),this.updateStatsTimer||(this.updateStatsTimer=setTimeout(()=>{this.updateStatsTimer=null,this.generateMinerStats()},1e3))}generateMinerStats(){let t=0,e=0;this.workers.forEach(s=>{if(!s.ready)return;t++;let i=0,n=0;s.stats.forEach(t=>{i+=t.shares,n+=t.time}),n>0&&(e+=i/(n/1e3))}),e>0&&(this.targetNoncePrefill=Math.ceil(4*e/this.workers.length),this.targetNoncePrefill<20&&(this.targetNoncePrefill=20));let s=this.latestStats={workerCount:t,hashRate:e,totalShares:this.totalShares,lastShareTime:this.lastShareTime};this.emit("stats",s)}processVerification(t){let e=this.verifyWorker;!e&&this.workers.length>0&&(e=this.workers[0]),e&&e.worker.postMessage({action:"verify",data:t})}onWorkerVerifyResult(t,e){this.options.session.submitVerifyResult(e)}}(o=c||(c={}))[o.CLOSED_IDLE=0]="CLOSED_IDLE",o[o.CLOSED_RECONNECT=1]="CLOSED_RECONNECT",o[o.CONNECTING=2]="CONNECTING",o[o.READY=3]="READY";class S extends u.TypedEmitter{options;clientSocket;clientStatus;readyDfd;requestCounter=1;reconnectTimer;disconnectTimer;requestQueue={};constructor(t){super(),this.options=t,this.clientStatus=c.CLOSED_IDLE}start(){this.clientStatus=c.CLOSED_RECONNECT,this.startClient()}stop(){this.clientSocket&&(this.clientSocket.close(),this.clientSocket=null),this.clientStatus=c.CLOSED_IDLE}isReady(){return this.clientStatus===c.READY}getReadyPromise(){return this.clientStatus===c.READY?Promise.resolve():(this.readyDfd||(this.readyDfd=new p),this.readyDfd.promise)}startClient(){this.clientStatus=c.CONNECTING,this.clientSocket=new WebSocket(this.options.powApiUrl+"?session="+this.options.sessionId),this.clientSocket.addEventListener("open",t=>{console.log("[PoWClient] faucet websocket opened"),this.clientStatus=c.READY,this.onClientReady()}),this.clientSocket.addEventListener("close",t=>{console.log("[PoWClient] faucet websocket closed"),this.onClientClose()}),this.clientSocket.addEventListener("error",t=>{console.log("[PoWClient] faucet websocket error",t),this.onClientClose()}),this.clientSocket.addEventListener("message",t=>this.onClientMessage(t))}reconnectClient(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.clientStatus===c.CLOSED_RECONNECT&&this.startClient()},5e3+5e3*Math.random()))}onClientClose(){this.clientSocket=null,this.clientStatus!==c.CLOSED_IDLE&&(this.clientStatus=c.CLOSED_RECONNECT),this.disconnectTimer&&(clearTimeout(this.disconnectTimer),this.disconnectTimer=null),this.emit("close"),this.clientStatus===c.CLOSED_RECONNECT&&this.reconnectClient()}sendRequest(t,e){return this.clientStatus===c.CLOSED_IDLE?Promise.reject("Internal Error (sendRequest called without active client). Please report this issue on github."):this.clientStatus===c.CLOSED_RECONNECT?Promise.reject("Not connected to faucet server. Please check your internet connection and try again in a few seconds."):(this.clientStatus!==c.READY?this.getReadyPromise():Promise.resolve()).then(()=>this._sendRequest(t,e))}_sendRequest(t,e){var s=this.requestCounter++,i=this.requestQueue[s]=new p,n={id:s,action:t};return void 0!==e&&(n.data=e),this.clientSocket.send(JSON.stringify(n)),i.promise}sendMessage(t,e){var s={action:t};void 0!==e&&(s.data=e),this.clientSocket.send(JSON.stringify(s))}onClientMessage(t){var e;try{e=JSON.parse(t.data)}catch(t){return void console.error(t)}if(e.hasOwnProperty("rsp")){var s=e.rsp,i="error"!==e.action;this.requestQueue.hasOwnProperty(s)&&(i?this.requestQueue[s].resolve(e.data):this.requestQueue[s].reject(e.data),delete this.requestQueue[s])}else e.action&&this.emit(e.action,e)}onClientReady(){this.readyDfd&&(this.readyDfd.resolve(),this.readyDfd=null),this.disconnectTimer||(this.disconnectTimer=setTimeout(()=>{this.disconnectTimer=null,this.clientSocket&&this.clientSocket.close(1e3,"24h reconnect")},864e5)),this.emit("open")}}function y(t){let e=atob(t),s="";for(let t=0;t<e.length;t++){let i=e.charCodeAt(t).toString(16);s+=2===i.length?i:"0"+i}return s}function C(t,e){return t/Math.pow(10,e||18)}function v(t,e,s,i){if(e||(e=18),i||(i=3),!t)return"0"+(s?" "+s:"");"bigint"==typeof t&&(t=Number(t));let n=C(t,e),r=Math.pow(10,i);return(Math.round(n*r)/r).toString()+(s?" "+s:"")}function w(t,e,s){for(t=t.toString();t.length<e;)t=s+t;return t}let k=(t,e,s)=>t.getFullYear()+"-"+w(t.getMonth()+1,2,"0")+"-"+w(t.getDate(),2,"0")+(e?" "+w(t.getHours(),2,"0")+":"+w(t.getMinutes(),2,"0")+(s?":"+w(t.getSeconds(),2,"0"):""):""),T=(t,e)=>w(t.getHours(),2,"0")+":"+w(t.getMinutes(),2,"0")+(e?":"+w(t.getSeconds(),2,"0"):""),E=(t,e)=>{let s,i=[];if(e||(e=2),t>=(s=86400)){let e=Math.floor(t/s);t-=e*s,i.push(e+"d")}if(t>=(s=3600)){let e=Math.floor(t/s);t-=e*s,i.push(e+"h")}if(t>=(s=60)){let e=Math.floor(t/s);t-=e*s,i.push(e+"min")}if(t>=(s=1)){let e=Math.floor(t/s);t-=e*s,i.push(e+"sec")}return i.length>e&&(i=i.slice(0,e)),i.join(" ")};function N(t,e="&"){let s=Object.keys(t);return s.reduce((i,n,r)=>{let o=`${i}${n}=${t[n]}`;return r<s.length-1&&(o+=e),o},"")}class b{options;workerId;powParams;powDifficulty;powPreImage;working=!1;workNonce;nonceRanges;statsCount;statsPoll;constructor(t){this.options=t,addEventListener("message",t=>this.onControlMessage(t)),postMessage({action:"init"})}onControlMessage(t){let e=t.data;if(e&&"object"==typeof e)switch(e.action){case"setWork":this.onCtrlSetWork(e.data);break;case"addRange":this.onCtrlAddRange(e.data);break;case"setParams":this.onCtrlSetParams(e.data);break;case"verify":this.onCtrlVerify(e.data)}}onCtrlSetWork(t){this.workerId=t.workerid,this.powParams=this.getWorkerParams(t.params,t.difficulty),this.powPreImage=y(t.preimage),this.nonceRanges=[{first:t.nonceStart,last:t.nonceStart+t.nonceCount-1,count:t.nonceCount}],this.workNonce=t.nonceStart,this.startWorkLoop()}onCtrlAddRange(t){this.nonceRanges.push({first:t.start,last:t.start+t.count-1,count:t.count}),1===this.nonceRanges.length&&(this.workNonce=t.start)}onCtrlSetParams(t){this.powParams=this.getWorkerParams(t.params,t.difficulty)}onCtrlVerify(t){let e=y(t.preimage),s=t.nonces.length>0;for(var i=0;i<t.nonces.length&&s;i++)if(!this.checkHash(t.nonces[i],e)){s=!1;break}postMessage({action:"verifyResult",data:{shareId:t.shareId,isValid:s}})}getWorkerParams(t,e){return{params:t,difficulty:e,dmask:this.getDifficultyMask(e),pstr:m(t,e)}}getDifficultyMask(t){let e=Math.floor(t/8)+1,s=Math.pow(2,8-(t-8*(e-1))).toString(16);for(;s.length<2*e;)s="0"+s;return s}startWorkLoop(){this.working||(this.statsCount=0,this.statsPoll=(new Date).getTime(),setInterval(()=>this.collectStats(),2e3),this.working=!0,this.workLoop())}collectStats(){let t=(new Date).getTime(),e=0;if(this.nonceRanges.length>0){e+=this.nonceRanges[0].last-this.workNonce;for(let t=1;t<this.nonceRanges.length;t++)e+=this.nonceRanges[t].count}postMessage({action:"stats",data:{shares:this.statsCount,time:t-this.statsPoll,last:this.workNonce,nonces:e}}),this.statsCount=0,this.statsPoll=t}workLoop(){if(this.working){for(var t=0;t<8;t++)this.work();setTimeout(()=>this.workLoop(),0===this.nonceRanges.length?20:0)}}work(){let t=this.nonceRanges.length;if(0===t)return;let e=this.workNonce++;e>=this.nonceRanges[0].last&&(this.nonceRanges.splice(0,1),1!==t&&(this.workNonce=this.nonceRanges[0].first)),this.checkHash(e,this.powPreImage)&&postMessage({action:"nonce",data:{nonce:e,params:this.powParams.pstr}})}checkHash(t,e){let s=t.toString(16);s.length<16&&(s="0000000000000000".substring(0,16-s.length)+s),this.statsCount++;let i=this.options.hashFn(s,e,this.powParams.params);return i.substring(0,this.powParams.dmask.length)<=this.powParams.dmask?i:null}}var L=i(155),P=i.n(L);class R extends P().PureComponent{powMinerStatsListener=null;powSessionUpdateListener=null;updateTimer=null;stoppedMiner=!1;constructor(t,e){super(t),this.state={refreshIndex:0,hashRate:0,totalShares:this.props.powSession.getShareCount(),startTime:this.props.powSession.getStartTime(),lastShareTime:0}}componentDidMount(){this.powMinerStatsListener||(this.powMinerStatsListener=t=>{let e={hashRate:t.hashRate,totalShares:this.props.powSession.getShareCount(),lastShareTime:t.lastShareTime?Math.floor(t.lastShareTime.getTime()/1e3):0};this.setState(e)},this.props.powMiner.on("stats",this.powMinerStatsListener)),this.powSessionUpdateListener||(this.powSessionUpdateListener=()=>{this.props.updateBalance()},this.props.powSession.on("balanceUpdate",this.powSessionUpdateListener)),this.updateTimer||this.setUpdateTimer(),this.props.powSession.once("resume",()=>{this.props.updateBalance()})}componentWillUnmount(){this.powMinerStatsListener&&(this.props.powMiner.off("stats",this.powMinerStatsListener),this.powMinerStatsListener=null),this.powSessionUpdateListener&&(this.props.powSession.off("balanceUpdate",this.powSessionUpdateListener),this.powSessionUpdateListener=null),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}render(){let t=this.props.time.getSyncedTime(),e=0;if(this.state.startTime){let s=this.props.faucetConfig?.modules?.pow?.powTimeout??0;(e=this.state.startTime+s-t)<5&&!this.stoppedMiner&&(this.stoppedMiner=!0,this.props.powSession.closeSession())}this.props.balance>=this.props.faucetConfig.maxClaim&&!this.stoppedMiner&&(this.stoppedMiner=!0,setTimeout(()=>{this.stoppedMiner=!0,this.props.powSession.closeSession()},100));let s=this.props.PowMinerStatusView;return this.props.powIsMining?P().createElement(s,{miningSpeed:Math.round(100*this.state.hashRate)/100+" H/s",time:E(e),balance:this.props.balance}):P().createElement(s,{miningSpeed:"-",time:"-",balance:this.props.balance})}setUpdateTimer(){let t=1e3-(new Date).getTime()%1e3+2;this.updateTimer=setTimeout(()=>{this.updateTimer=null,this.setState({refreshIndex:this.state.refreshIndex+1}),this.setUpdateTimer()},t)}}class I extends P().PureComponent{updateTimer=null;loadingStatus=!1;isTimedOut=!1;notificationClient;notificationClientActive=!1;lastStatusPoll=0;constructor(t){super(t),this.notificationClient=new d({claimWsUrl:this.props.wsEndpoint,sessionId:this.props.sessionId}),this.notificationClient.on("update",t=>{this.setState({claimNotification:t.data})}),this.notificationClient.on("open",()=>{this.setState({claimNotificationConnected:!0})}),this.notificationClient.on("close",()=>{this.setState({claimNotificationConnected:!1})}),this.state={sessionStatus:null,sessionDetails:null,loadingStatus:!1,loadingError:!1,isTimedOut:!1,claimProcessing:!1,refreshIndex:0,claimNotification:null,claimNotificationConnected:!1}}componentDidMount(){this.refreshSessionStatus()}componentWillUnmount(){this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null),this.notificationClientActive&&(this.notificationClientActive=!1,this.notificationClient.stop())}render(){let t=(new Date).getTime(),e=this.props.faucetApi.getFaucetTime().getSyncedTime();return this.state.sessionStatus&&(this.state.sessionStatus.start+this.props.faucetConfig.sessionTimeout-e<0&&"claimable"===this.state.sessionStatus.status&&!this.isTimedOut&&(this.isTimedOut=!0,this.setState({isTimedOut:!0}),this.props.showErrorNotification("Claim expired. Sorry, your reward has not been claimed in time."),this.props.onClose()),"claiming"===this.state.sessionStatus.status?(this.notificationClientActive||(this.notificationClientActive=!0,this.notificationClient.start()),(t-this.lastStatusPoll>3e4||(this.state.sessionStatus.claimIdx??0)<=(this.state.claimNotification?.confirmedIdx||0))&&(this.lastStatusPoll=t,this.refreshSessionStatus())):this.notificationClientActive&&(this.notificationClientActive=!1,this.notificationClient.stop())),this.renderClaim()}async refreshSessionStatus(){if(!this.loadingStatus){this.loadingStatus=!0,this.setState({loadingStatus:!0});try{let t=await this.props.faucetApi.getSessionStatus(this.props.sessionId,!this.state.sessionDetails);t.details&&this.setState({sessionDetails:t.details}),this.setState({loadingStatus:!1,sessionStatus:t},()=>{this.setUpdateTimer()})}catch(t){this.setState({loadingStatus:!1,loadingError:t.error?.toString()||t.toString()||!0})}this.loadingStatus=!1}}setUpdateTimer(){this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null);let t=1e3-(new Date).getTime()%1e3+2;this.updateTimer=setTimeout(()=>{this.updateTimer=null,this.setState({refreshIndex:this.state.refreshIndex+1}),this.setUpdateTimer()},t)}renderClaim(){let t=this.props.ErrorTextComponent;if(this.state.loadingError)return P().createElement(t,null,"No claimable reward found:"," ","string"==typeof this.state.loadingError?this.state.loadingError:"");if(!this.state.sessionStatus){let t=this.props.LoaderComponent;return P().createElement(t,null)}return this.state.isTimedOut?P().createElement(t,null,"Sorry, your reward has not been claimed in time."):P().createElement("div",null,"claimable"===this.state.sessionStatus.status?this.renderClaimForm():null,"claiming"===this.state.sessionStatus.status?this.renderClaimStatus():null,"failed"===this.state.sessionStatus.status?this.renderSessionFailed():null,"finished"===this.state.sessionStatus.status?this.renderClaimSuccess():null)}renderClaimForm(){let t=this.props.ClaimFormComponent;return P().createElement(t,{onSubmit:()=>this.submitClaim({}),isLoading:"claiming"===this.state.sessionStatus?.status})}renderClaimStatus(){let t=this.props.ClaimStatusComponent;return P().createElement(t,null)}renderClaimSuccess(){let t=this.props.ClaimSuccessComponent;return P().createElement(t,{hash:this.state.sessionStatus?.claimHash})}renderSessionFailed(){let t=this.props.ErrorTextComponent;return P().createElement(t,null,"Claim failed:"," ",this.state.sessionStatus?.failedReason||this.state.sessionStatus?.claimMessage," ",this.state.sessionStatus?.failedCode?" ["+this.state.sessionStatus?.failedCode+"]":"")}async submitClaim(t){try{t=Object.assign({session:this.props.sessionId},t||{});let e=await this.props.faucetApi.claimReward(t);if("failed"===e.status)throw e;this.lastStatusPoll=(new Date).getTime(),this.setState({sessionStatus:e}),s.persistSessionInfo(null)}catch(e){let t;throw t=e&&e.failedCode?"["+e.failedCode+"] "+e.failedReason:e.toString(),this.props.showErrorNotification("Claim failed. "+t),t}}}})(),n})(),t.exports=i(s(67294))},12185:function(t,e,s){"use strict";s.d(e,{h:function(){return r}});var i=s(67294);let n={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function r(){let[t,{width:e,height:s}]=function(){let t=(0,i.useRef)(0),e=(0,i.useRef)(null),[s,r]=(0,i.useState)(n),o=(0,i.useMemo)(()=>"undefined"!=typeof window?new ResizeObserver(s=>{let i=s[0];i&&(cancelAnimationFrame(t.current),t.current=requestAnimationFrame(()=>{e.current&&r(i.contentRect)}))}):null,[]);return(0,i.useEffect)(()=>(e.current&&o.observe(e.current),()=>{o.disconnect(),t.current&&cancelAnimationFrame(t.current)}),[e.current]),[e,s]}();return{ref:t,width:e,height:s}}},61001:function(t,e,s){"use strict";s.d(e,{Z:function(){return i}});var i=(0,s(4934).Z)("brand-discord-filled","IconBrandDiscordFilled",[["path",{d:"M14.983 3l.123 .006c2.014 .214 3.527 .672 4.966 1.673a1 1 0 0 1 .371 .488c1.876 5.315 2.373 9.987 1.451 12.28c-1.003 2.005 -2.606 3.553 -4.394 3.553c-.732 0 -1.693 -.968 -2.328 -2.045a21.512 21.512 0 0 0 2.103 -.493a1 1 0 1 0 -.55 -1.924c-3.32 .95 -6.13 .95 -9.45 0a1 1 0 0 0 -.55 1.924c.717 .204 1.416 .37 2.103 .494c-.635 1.075 -1.596 2.044 -2.328 2.044c-1.788 0 -3.391 -1.548 -4.428 -3.629c-.888 -2.217 -.39 -6.89 1.485 -12.204a1 1 0 0 1 .371 -.488c1.439 -1.001 2.952 -1.459 4.966 -1.673a1 1 0 0 1 .935 .435l.063 .107l.651 1.285l.137 -.016a12.97 12.97 0 0 1 2.643 0l.134 .016l.65 -1.284a1 1 0 0 1 .754 -.54l.122 -.009zm-5.983 7a2 2 0 0 0 -1.977 1.697l-.018 .154l-.005 .149l.005 .15a2 2 0 1 0 1.995 -2.15zm6 0a2 2 0 0 0 -1.977 1.697l-.018 .154l-.005 .149l.005 .15a2 2 0 1 0 1.995 -2.15z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]])},20585:function(t,e,s){"use strict";s.d(e,{Z:function(){return i}});var i=(0,s(4934).Z)("brand-twitter-filled","IconBrandTwitterFilled",[["path",{d:"M14.058 3.41c-1.807 .767 -2.995 2.453 -3.056 4.38l-.002 .182l-.243 -.023c-2.392 -.269 -4.498 -1.512 -5.944 -3.531a1 1 0 0 0 -1.685 .092l-.097 .186l-.049 .099c-.719 1.485 -1.19 3.29 -1.017 5.203l.03 .273c.283 2.263 1.5 4.215 3.779 5.679l.173 .107l-.081 .043c-1.315 .663 -2.518 .952 -3.827 .9c-1.056 -.04 -1.446 1.372 -.518 1.878c3.598 1.961 7.461 2.566 10.792 1.6c4.06 -1.18 7.152 -4.223 8.335 -8.433l.127 -.495c.238 -.993 .372 -2.006 .401 -3.024l.003 -.332l.393 -.779l.44 -.862l.214 -.434l.118 -.247c.265 -.565 .456 -1.033 .574 -1.43l.014 -.056l.008 -.018c.22 -.593 -.166 -1.358 -.941 -1.358l-.122 .007a.997 .997 0 0 0 -.231 .057l-.086 .038a7.46 7.46 0 0 1 -.88 .36l-.356 .115l-.271 .08l-.772 .214c-1.336 -1.118 -3.144 -1.254 -5.012 -.554l-.211 .084z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]])},1195:function(t,e,s){"use strict";s.d(e,{Z:function(){return i}});var i=(0,s(4934).Z)("circle-check-filled","IconCircleCheckFilled",[["path",{d:"M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]])},99324:function(t,e,s){"use strict";s.d(e,{Z:function(){return i}});var i=(0,s(4934).Z)("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]])},10028:function(t,e,s){"use strict";s.d(e,{Z:function(){return i}});var i=(0,s(84460).Z)("outline","check","IconCheck",[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]])}}]);