@tachybase/plugin-print-template 1.3.24 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/externalVersion.js +2 -2
- package/dist/node_modules/bullmq/dist/cjs/classes/queue.js +4 -2
- package/dist/node_modules/bullmq/dist/cjs/classes/scripts.js +3 -3
- package/dist/node_modules/bullmq/dist/cjs/classes/worker.js +8 -9
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveJobToWait.lua +15 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-9.lua +5 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-8.lua +3 -11
- package/dist/node_modules/bullmq/dist/cjs/commands/{moveToWaitingChildren-8.lua → moveToWaitingChildren-7.lua} +29 -40
- package/dist/node_modules/bullmq/dist/cjs/enums/error-code.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/index.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/scripts/index.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveJobFromActiveToWait-9.js +5 -1
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-8.js +12 -8
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-7.js +107 -0
- package/dist/node_modules/bullmq/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/node_modules/bullmq/dist/cjs/version.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/queue.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/queue.js +4 -2
- package/dist/node_modules/bullmq/dist/esm/classes/scripts.js +3 -3
- package/dist/node_modules/bullmq/dist/esm/classes/worker.js +8 -9
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveJobToWait.lua +15 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-9.lua +5 -1
- package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-8.lua +3 -11
- package/dist/node_modules/bullmq/dist/esm/commands/{moveToWaitingChildren-8.lua → moveToWaitingChildren-7.lua} +29 -40
- package/dist/node_modules/bullmq/dist/esm/enums/error-code.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/enums/error-code.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/index.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/index.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/moveJobFromActiveToWait-9.js +5 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-8.js +12 -8
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-7.js +104 -0
- package/dist/node_modules/bullmq/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/node_modules/bullmq/dist/esm/version.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/version.js +1 -1
- package/dist/node_modules/bullmq/package.json +1 -1
- package/dist/node_modules/docxtemplater/package.json +1 -1
- package/dist/node_modules/pizzip/package.json +1 -1
- package/package.json +6 -6
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-8.js +0 -529
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-8.js +0 -526
- /package/dist/node_modules/bullmq/dist/esm/scripts/{moveToWaitingChildren-8.d.ts → moveToWaitingChildren-7.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){var __webpack_modules__={4458:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getKeyIndexes=t.hasFlag=t.exists=t.list=void 0;const i=r(n(8148));t.list=Object.keys(i.default);const a={};t.list.forEach((e=>{a[e]=i.default[e].flags.reduce((function(e,t){e[t]=true;return e}),{})}));function exists(e){return Boolean(i.default[e])}t.exists=exists;function hasFlag(e,t){if(!a[e]){throw new Error("Unknown command "+e)}return Boolean(a[e][t])}t.hasFlag=hasFlag;function getKeyIndexes(e,t,n){const r=i.default[e];if(!r){throw new Error("Unknown command "+e)}if(!Array.isArray(t)){throw new Error("Expect args to be an array")}const a=[];const s=Boolean(n&&n.parseExternalKey);const takeDynamicKeys=(e,t)=>{const n=[];const r=Number(e[t]);for(let e=0;e<r;e++){n.push(e+t+1)}return n};const takeKeyAfterToken=(e,t,n)=>{for(let r=t;r<e.length-1;r+=1){if(String(e[r]).toLowerCase()===n.toLowerCase()){return r+1}}return null};switch(e){case"zunionstore":case"zinterstore":case"zdiffstore":a.push(0,...takeDynamicKeys(t,1));break;case"eval":case"evalsha":case"eval_ro":case"evalsha_ro":case"fcall":case"fcall_ro":case"blmpop":case"bzmpop":a.push(...takeDynamicKeys(t,1));break;case"sintercard":case"lmpop":case"zunion":case"zinter":case"zmpop":case"zintercard":case"zdiff":{a.push(...takeDynamicKeys(t,0));break}case"georadius":{a.push(0);const e=takeKeyAfterToken(t,5,"STORE");if(e)a.push(e);const n=takeKeyAfterToken(t,5,"STOREDIST");if(n)a.push(n);break}case"georadiusbymember":{a.push(0);const e=takeKeyAfterToken(t,4,"STORE");if(e)a.push(e);const n=takeKeyAfterToken(t,4,"STOREDIST");if(n)a.push(n);break}case"sort":case"sort_ro":a.push(0);for(let e=1;e<t.length-1;e++){let n=t[e];if(typeof n!=="string"){continue}const r=n.toUpperCase();if(r==="GET"){e+=1;n=t[e];if(n!=="#"){if(s){a.push([e,getExternalKeyNameLength(n)])}else{a.push(e)}}}else if(r==="BY"){e+=1;if(s){a.push([e,getExternalKeyNameLength(t[e])])}else{a.push(e)}}else if(r==="STORE"){e+=1;a.push(e)}}break;case"migrate":if(t[2]===""){for(let e=5;e<t.length-1;e++){const n=t[e];if(typeof n==="string"&&n.toUpperCase()==="KEYS"){for(let n=e+1;n<t.length;n++){a.push(n)}break}}}else{a.push(2)}break;case"xreadgroup":case"xread":for(let n=e==="xread"?0:3;n<t.length-1;n++){if(String(t[n]).toUpperCase()==="STREAMS"){for(let e=n+1;e<=n+(t.length-1-n)/2;e++){a.push(e)}break}}break;default:if(r.step>0){const e=r.keyStart-1;const n=r.keyStop>0?r.keyStop:t.length+r.keyStop+1;for(let t=e;t<n;t+=r.step){a.push(t)}}break}return a}t.getKeyIndexes=getKeyIndexes;function getExternalKeyNameLength(e){if(typeof e!=="string"){e=String(e)}const t=e.indexOf("->");return t===-1?e.length:t}},8158:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.AsyncFifoQueue=void 0;class Node{constructor(e){this.value=undefined;this.next=null;this.value=e}}class LinkedList{constructor(){this.length=0;this.head=null;this.tail=null}push(e){const t=new Node(e);if(!this.length){this.head=t}else{this.tail.next=t}this.tail=t;this.length+=1;return t}shift(){if(!this.length){return null}else{const e=this.head;this.head=this.head.next;this.length-=1;return e}}}class AsyncFifoQueue{constructor(e=false){this.ignoreErrors=e;this.queue=new LinkedList;this.pending=new Set;this.newPromise()}add(e){this.pending.add(e);e.then((t=>{this.pending.delete(e);if(this.queue.length===0){this.resolvePromise(t)}this.queue.push(t)})).catch((t=>{if(this.ignoreErrors){this.queue.push(undefined)}this.pending.delete(e);this.rejectPromise(t)}))}async waitAll(){await Promise.all(this.pending)}numTotal(){return this.pending.size+this.queue.length}numPending(){return this.pending.size}numQueued(){return this.queue.length}resolvePromise(e){this.resolve(e);this.newPromise()}rejectPromise(e){this.reject(e);this.newPromise()}newPromise(){this.nextPromise=new Promise(((e,t)=>{this.resolve=e;this.reject=t}))}async wait(){return this.nextPromise}async fetch(){var e;if(this.pending.size===0&&this.queue.length===0){return}while(this.queue.length===0){try{await this.wait()}catch(e){if(!this.ignoreErrors){console.error("Unexpected Error in AsyncFifoQueue",e)}}}return(e=this.queue.shift())===null||e===void 0?void 0:e.value}}t.AsyncFifoQueue=AsyncFifoQueue},5740:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Backoffs=void 0;class Backoffs{static normalize(e){if(Number.isFinite(e)){return{type:"fixed",delay:e}}else if(e){return e}}static calculate(e,t,n,r,i){if(e){const a=lookupStrategy(e,i);return a(t,e.type,n,r)}}}t.Backoffs=Backoffs;Backoffs.builtinStrategies={fixed:function(e,t=0){return function(){if(t>0){const n=e*(1-t);return Math.floor(Math.random()*e*t+n)}else{return e}}},exponential:function(e,t=0){return function(n){if(t>0){const r=Math.round(Math.pow(2,n-1)*e);const i=r*(1-t);return Math.floor(Math.random()*r*t+i)}else{return Math.round(Math.pow(2,n-1)*e)}}}};function lookupStrategy(e,t){if(e.type in Backoffs.builtinStrategies){return Backoffs.builtinStrategies[e.type](e.delay,e.jitter)}else if(t){return t}else{throw new Error(`Unknown backoff strategy ${e.type}.\n If a custom backoff strategy is used, specify it when the queue is created.`)}}},2622:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ChildPool=void 0;const r=n(6928);const i=n(5079);const a=3e4;class ChildPool{constructor({mainFile:e=r.join(process.cwd(),"dist/cjs/classes/main.js"),useWorkerThreads:t,workerForkOptions:n,workerThreadsOptions:i}){this.retained={};this.free={};this.opts={mainFile:e,useWorkerThreads:t,workerForkOptions:n,workerThreadsOptions:i}}async retain(e){let t=this.getFree(e).pop();if(t){this.retained[t.pid]=t;return t}t=new i.Child(this.opts.mainFile,e,{useWorkerThreads:this.opts.useWorkerThreads,workerForkOptions:this.opts.workerForkOptions,workerThreadsOptions:this.opts.workerThreadsOptions});t.on("exit",this.remove.bind(this,t));try{await t.init();if(t.exitCode!==null||t.signalCode!==null){throw new Error("Child exited before it could be retained")}this.retained[t.pid]=t;return t}catch(e){console.error(e);this.release(t);throw e}}release(e){delete this.retained[e.pid];this.getFree(e.processFile).push(e)}remove(e){delete this.retained[e.pid];const t=this.getFree(e.processFile);const n=t.indexOf(e);if(n>-1){t.splice(n,1)}}async kill(e,t="SIGKILL"){this.remove(e);return e.kill(t,a)}async clean(){const e=Object.values(this.retained).concat(this.getAllFree());this.retained={};this.free={};await Promise.all(e.map((e=>this.kill(e,"SIGTERM"))))}getFree(e){return this.free[e]=this.free[e]||[]}getAllFree(){return Object.values(this.free).reduce(((e,t)=>e.concat(t)),[])}}t.ChildPool=ChildPool},3434:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ChildProcessor=void 0;const r=n(6991);const i=n(8547);var a;(function(e){e[e["Idle"]=0]="Idle";e[e["Started"]=1]="Started";e[e["Terminating"]=2]="Terminating";e[e["Errored"]=3]="Errored"})(a||(a={}));const s=process.env.NODE_ENV==="test"?500:5e3;class ChildProcessor{constructor(e,t){this.send=e;this.receiver=t}async init(e){let t;try{const{default:r}=await n(5918)(e);t=r;if(t.default){t=t.default}if(typeof t!=="function"){throw new Error("No function is exported in processor file")}}catch(e){this.status=a.Errored;return this.send({cmd:r.ParentCommand.InitFailed,err:(0,i.errorToJSON)(e)})}const s=t;t=function(e,t){try{return Promise.resolve(s(e,t))}catch(e){return Promise.reject(e)}};this.processor=t;this.status=a.Idle;await this.send({cmd:r.ParentCommand.InitCompleted})}async start(e,t){if(this.status!==a.Idle){return this.send({cmd:r.ParentCommand.Error,err:(0,i.errorToJSON)(new Error("cannot start a not idling child process"))})}this.status=a.Started;this.currentJobPromise=(async()=>{try{const n=this.wrapJob(e,this.send);const i=await this.processor(n,t);await this.send({cmd:r.ParentCommand.Completed,value:typeof i==="undefined"?null:i})}catch(e){await this.send({cmd:r.ParentCommand.Failed,value:(0,i.errorToJSON)(!e.message?new Error(e):e)})}finally{this.status=a.Idle;this.currentJobPromise=undefined}})()}async stop(){}async waitForCurrentJobAndExit(){this.status=a.Terminating;try{await this.currentJobPromise}finally{process.exit(process.exitCode||0)}}wrapJob(e,t){const n=Object.assign(Object.assign({},e),{data:JSON.parse(e.data||"{}"),opts:e.opts,returnValue:JSON.parse(e.returnvalue||"{}"),async updateProgress(e){this.progress=e;await t({cmd:r.ParentCommand.Progress,value:e})},log:async e=>{await t({cmd:r.ParentCommand.Log,value:e})},moveToDelayed:async(e,n)=>{await t({cmd:r.ParentCommand.MoveToDelayed,value:{timestamp:e,token:n}})},moveToWait:async e=>{await t({cmd:r.ParentCommand.MoveToWait,value:{token:e}})},updateData:async e=>{await t({cmd:r.ParentCommand.Update,value:e});n.data=e},getChildrenValues:async()=>{const e=Math.random().toString(36).substring(2,15);await t({requestId:e,cmd:r.ParentCommand.GetChildrenValues});return waitResponse(e,this.receiver,s,"getChildrenValues")},getIgnoredChildrenFailures:async()=>{const e=Math.random().toString(36).substring(2,15);await t({requestId:e,cmd:r.ParentCommand.GetIgnoredChildrenFailures});return waitResponse(e,this.receiver,s,"getIgnoredChildrenFailures")}});return n}}t.ChildProcessor=ChildProcessor;const waitResponse=async(e,t,n,r)=>new Promise(((i,a)=>{const listener=n=>{if(n.requestId===e){i(n.value);t.off("message",listener)}};t.on("message",listener);setTimeout((()=>{t.off("message",listener);a(new Error(`TimeoutError: ${r} timed out in (${n}ms)`))}),n)}))},5079:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Child=void 0;const r=n(5317);const i=n(9278);const a=n(8167);const s=n(6991);const o=n(4434);const l={1:"Uncaught Fatal Exception",2:"Unused",3:"Internal JavaScript Parse Error",4:"Internal JavaScript Evaluation Failure",5:"Fatal Error",6:"Non-function Internal Exception Handler",7:"Internal Exception Handler Run-Time Failure",8:"Unused",9:"Invalid Argument",10:"Internal JavaScript Run-Time Failure",12:"Invalid Debug Argument",13:"Unfinished Top-Level Await"};class Child extends o.EventEmitter{constructor(e,t,n={useWorkerThreads:false}){super();this.mainFile=e;this.processFile=t;this.opts=n;this._exitCode=null;this._signalCode=null;this._killed=false}get pid(){if(this.childProcess){return this.childProcess.pid}else if(this.worker){return Math.abs(this.worker.threadId)}else{throw new Error("No child process or worker thread")}}get exitCode(){return this._exitCode}get signalCode(){return this._signalCode}get killed(){if(this.childProcess){return this.childProcess.killed}return this._killed}async init(){const e=await convertExecArgv(process.execArgv);let t;if(this.opts.useWorkerThreads){this.worker=t=new a.Worker(this.mainFile,Object.assign({execArgv:e,stdin:true,stdout:true,stderr:true},this.opts.workerThreadsOptions?this.opts.workerThreadsOptions:{}))}else{this.childProcess=t=(0,r.fork)(this.mainFile,[],Object.assign({execArgv:e,stdio:"pipe"},this.opts.workerForkOptions?this.opts.workerForkOptions:{}))}t.on("exit",((e,n)=>{this._exitCode=e;n=typeof n==="undefined"?null:n;this._signalCode=n;this._killed=true;this.emit("exit",e,n);t.removeAllListeners();this.removeAllListeners()}));t.on("error",((...e)=>this.emit("error",...e)));t.on("message",((...e)=>this.emit("message",...e)));t.on("close",((...e)=>this.emit("close",...e)));t.stdout.pipe(process.stdout);t.stderr.pipe(process.stderr);await this.initChild()}async send(e){return new Promise(((t,n)=>{if(this.childProcess){this.childProcess.send(e,(e=>{if(e){n(e)}else{t()}}))}else if(this.worker){t(this.worker.postMessage(e))}else{t()}}))}killProcess(e="SIGKILL"){if(this.childProcess){this.childProcess.kill(e)}else if(this.worker){this.worker.terminate()}}async kill(e="SIGKILL",t){if(this.hasProcessExited()){return}const n=onExitOnce(this.childProcess||this.worker);this.killProcess(e);if(t!==undefined&&(t===0||isFinite(t))){const e=setTimeout((()=>{if(!this.hasProcessExited()){this.killProcess("SIGKILL")}}),t);await n;clearTimeout(e)}await n}async initChild(){const e=new Promise(((e,t)=>{const onMessageHandler=n=>{if(n.cmd===s.ParentCommand.InitCompleted){e()}else if(n.cmd===s.ParentCommand.InitFailed){const e=new Error;e.stack=n.err.stack;e.message=n.err.message;t(e)}this.off("message",onMessageHandler);this.off("close",onCloseHandler)};const onCloseHandler=(e,n)=>{if(e>128){e-=128}const r=l[e]||`Unknown exit code ${e}`;t(new Error(`Error initializing child: ${r} and signal ${n}`));this.off("message",onMessageHandler);this.off("close",onCloseHandler)};this.on("message",onMessageHandler);this.on("close",onCloseHandler)}));await this.send({cmd:s.ChildCommand.Init,value:this.processFile});await e}hasProcessExited(){return!!(this.exitCode!==null||this.signalCode)}}t.Child=Child;function onExitOnce(e){return new Promise((t=>{e.once("exit",(()=>t()))}))}const getFreePort=async()=>new Promise((e=>{const t=(0,i.createServer)();t.listen(0,(()=>{const{port:n}=t.address();t.close((()=>e(n)))}))}));const convertExecArgv=async e=>{const t=[];const n=[];for(let r=0;r<e.length;r++){const i=e[r];if(i.indexOf("--inspect")===-1){t.push(i)}else{const e=i.split("=")[0];const t=await getFreePort();n.push(`${e}=${t}`)}}return t.concat(n)}},4684:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.DelayedError=t.DELAYED_ERROR=void 0;t.DELAYED_ERROR="bullmq:movedToDelayed";class DelayedError extends Error{constructor(e=t.DELAYED_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.DelayedError=DelayedError},2877:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(4684),t);r.__exportStar(n(9806),t);r.__exportStar(n(5431),t);r.__exportStar(n(47),t);r.__exportStar(n(97),t)},9806:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.RateLimitError=t.RATE_LIMIT_ERROR=void 0;t.RATE_LIMIT_ERROR="bullmq:rateLimitExceeded";class RateLimitError extends Error{constructor(e=t.RATE_LIMIT_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.RateLimitError=RateLimitError},5431:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.UnrecoverableError=t.UNRECOVERABLE_ERROR=void 0;t.UNRECOVERABLE_ERROR="bullmq:unrecoverable";class UnrecoverableError extends Error{constructor(e=t.UNRECOVERABLE_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.UnrecoverableError=UnrecoverableError},47:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.WaitingChildrenError=t.WAITING_CHILDREN_ERROR=void 0;t.WAITING_CHILDREN_ERROR="bullmq:movedToWaitingChildren";class WaitingChildrenError extends Error{constructor(e=t.WAITING_CHILDREN_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.WaitingChildrenError=WaitingChildrenError},97:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.WaitingError=t.WAITING_ERROR=void 0;t.WAITING_ERROR="bullmq:movedToWait";class WaitingError extends Error{constructor(e=t.WAITING_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.WaitingError=WaitingError},2424:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.FlowProducer=void 0;const r=n(4434);const i=n(9935);const a=n(8547);const s=n(4078);const o=n(4795);const l=n(6595);const c=n(6991);class FlowProducer extends r.EventEmitter{constructor(e={connection:{}},t=l.RedisConnection){super();this.opts=e;this.opts=Object.assign({prefix:"bull"},e);this.connection=new t(e.connection,{shared:(0,a.isRedisInstance)(e.connection),blocking:false,skipVersionCheck:e.skipVersionCheck,skipWaitingForReady:e.skipWaitingForReady});this.connection.on("error",(e=>this.emit("error",e)));this.connection.on("close",(()=>{if(!this.closing){this.emit("ioredis:close")}}));this.queueKeys=new o.QueueKeys(e.prefix);if(e===null||e===void 0?void 0:e.telemetry){this.telemetry=e.telemetry}}emit(e,...t){return super.emit(e,...t)}off(e,t){super.off(e,t);return this}on(e,t){super.on(e,t);return this}once(e,t){super.once(e,t);return this}get client(){return this.connection.client}get Job(){return s.Job}waitUntilReady(){return this.client}async add(e,t){var n;if(this.closing){return}const r=await this.connection.client;const i=r.multi();const s=(n=e===null||e===void 0?void 0:e.opts)===null||n===void 0?void 0:n.parent;const o=(0,a.getParentKey)(s);const l=o?`${o}:dependencies`:undefined;return(0,a.trace)(this.telemetry,c.SpanKind.PRODUCER,e.queueName,"addFlow",e.queueName,(async n=>{n===null||n===void 0?void 0:n.setAttributes({[c.TelemetryAttributes.FlowName]:e.name});const r=await this.addNode({multi:i,node:e,queuesOpts:t===null||t===void 0?void 0:t.queuesOptions,parent:{parentOpts:s,parentDependenciesKey:l}});await i.exec();return r}))}async getFlow(e){if(this.closing){return}const t=await this.connection.client;const n=Object.assign({depth:10,maxChildren:20,prefix:this.opts.prefix},e);const r=this.getNode(t,n);return r}async addBulk(e){if(this.closing){return}const t=await this.connection.client;const n=t.multi();return(0,a.trace)(this.telemetry,c.SpanKind.PRODUCER,"","addBulkFlows","",(async t=>{t===null||t===void 0?void 0:t.setAttributes({[c.TelemetryAttributes.BulkCount]:e.length,[c.TelemetryAttributes.BulkNames]:e.map((e=>e.name)).join(",")});const r=await this.addNodes(n,e);await n.exec();return r}))}async addNode({multi:e,node:t,parent:n,queuesOpts:r}){var s,l;const d=t.prefix||this.opts.prefix;const u=this.queueFromNode(t,new o.QueueKeys(d),d);const p=r&&r[t.queueName];const f=(s=p===null||p===void 0?void 0:p.defaultJobOptions)!==null&&s!==void 0?s:{};const h=((l=t.opts)===null||l===void 0?void 0:l.jobId)||(0,i.v4)();return(0,a.trace)(this.telemetry,c.SpanKind.PRODUCER,t.queueName,"addNode",t.queueName,(async(i,s)=>{var l,d;i===null||i===void 0?void 0:i.setAttributes({[c.TelemetryAttributes.JobName]:t.name,[c.TelemetryAttributes.JobId]:h});const p=t.opts;let y=p===null||p===void 0?void 0:p.telemetry;if(s&&p){const e=(l=p.telemetry)===null||l===void 0?void 0:l.omitContext;const t=((d=p.telemetry)===null||d===void 0?void 0:d.metadata)||!e&&s;if(t||e){y={metadata:t,omitContext:e}}}const m=new this.Job(u,t.name,t.data,Object.assign(Object.assign(Object.assign({},f),p),{parent:n===null||n===void 0?void 0:n.parentOpts,telemetry:y}),h);const b=(0,a.getParentKey)(n===null||n===void 0?void 0:n.parentOpts);if(t.children&&t.children.length>0){const i=h;const a=new o.QueueKeys(t.prefix||this.opts.prefix);const s=a.toKey(t.queueName,"waiting-children");await m.addJob(e,{parentDependenciesKey:n===null||n===void 0?void 0:n.parentDependenciesKey,waitChildrenKey:s,parentKey:b});const l=`${a.toKey(t.queueName,i)}:dependencies`;const c=await this.addChildren({multi:e,nodes:t.children,parent:{parentOpts:{id:i,queue:a.getQueueQualifiedName(t.queueName)},parentDependenciesKey:l},queuesOpts:r});return{job:m,children:c}}else{await m.addJob(e,{parentDependenciesKey:n===null||n===void 0?void 0:n.parentDependenciesKey,parentKey:b});return{job:m}}}))}addNodes(e,t){return Promise.all(t.map((t=>{var n;const r=(n=t===null||t===void 0?void 0:t.opts)===null||n===void 0?void 0:n.parent;const i=(0,a.getParentKey)(r);const s=i?`${i}:dependencies`:undefined;return this.addNode({multi:e,node:t,parent:{parentOpts:r,parentDependenciesKey:s}})})))}async getNode(e,t){const n=this.queueFromNode(t,new o.QueueKeys(t.prefix),t.prefix);const r=await this.Job.fromId(n,t.id);if(r){const{processed:n={},unprocessed:i=[],failed:a=[],ignored:s={}}=await r.getDependencies({failed:{count:t.maxChildren},processed:{count:t.maxChildren},unprocessed:{count:t.maxChildren},ignored:{count:t.maxChildren}});const o=Object.keys(n);const l=Object.keys(s);const c=o.length+i.length+l.length+a.length;const d=t.depth-1;if(c>0&&d){const n=await this.getChildren(e,[...o,...i,...a,...l],d,t.maxChildren);return{job:r,children:n}}else{return{job:r}}}}addChildren({multi:e,nodes:t,parent:n,queuesOpts:r}){return Promise.all(t.map((t=>this.addNode({multi:e,node:t,parent:n,queuesOpts:r}))))}getChildren(e,t,n,r){const getChild=t=>{const[i,a,s]=t.split(":");return this.getNode(e,{id:s,queueName:a,prefix:i,depth:n,maxChildren:r})};return Promise.all([...t.map(getChild)])}queueFromNode(e,t,n){return{client:this.connection.client,name:e.queueName,keys:t.getKeys(e.queueName),toKey:n=>t.toKey(e.queueName,n),opts:{prefix:n,connection:{}},qualifiedName:t.getQueueQualifiedName(e.queueName),closing:this.closing,waitUntilReady:async()=>this.connection.client,removeListener:this.removeListener.bind(this),emit:this.emit.bind(this),on:this.on.bind(this),redisVersion:this.connection.redisVersion,trace:async()=>{}}}async close(){if(!this.closing){this.closing=this.connection.close()}await this.closing}disconnect(){return this.connection.disconnect()}}t.FlowProducer=FlowProducer},4601:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(8158),t);r.__exportStar(n(5740),t);r.__exportStar(n(5079),t);r.__exportStar(n(2622),t);r.__exportStar(n(3434),t);r.__exportStar(n(2877),t);r.__exportStar(n(2424),t);r.__exportStar(n(4078),t);r.__exportStar(n(6830),t);r.__exportStar(n(4982),t);r.__exportStar(n(6058),t);r.__exportStar(n(1017),t);r.__exportStar(n(6451),t);r.__exportStar(n(4795),t);r.__exportStar(n(6838),t);r.__exportStar(n(6595),t);r.__exportStar(n(9454),t);r.__exportStar(n(1558),t);r.__exportStar(n(5249),t);r.__exportStar(n(7923),t)},6830:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.defaultRepeatStrategy=t.JobScheduler=void 0;const r=n(1577);const i=n(9912);const a=n(4078);const s=n(4982);const o=n(6991);const l=n(8547);class JobScheduler extends s.QueueBase{constructor(e,n,r){super(e,n,r);this.repeatStrategy=n.settings&&n.settings.repeatStrategy||t.defaultRepeatStrategy}async upsertJobScheduler(e,t,n,i,s,{override:l,producerId:c}){const{every:d,limit:u,pattern:p,offset:f}=t;if(p&&d){throw new Error("Both .pattern and .every options are defined for this repeatable job")}if(!p&&!d){throw new Error("Either .pattern or .every options must be defined for this repeatable job")}if(t.immediately&&t.startDate){throw new Error("Both .immediately and .startDate options are defined for this repeatable job")}if(t.immediately&&t.every){console.warn("Using option immediately with every does not affect the job's schedule. Job will run immediately anyway.")}const h=t.count?t.count+1:1;if(typeof t.limit!=="undefined"&&h>t.limit){return}let y=Date.now();const{endDate:m}=t;if(m&&y>new Date(m).getTime()){return}const b=s.prevMillis||0;y=b<y?y:b;const{startDate:g,immediately:v}=t,K=r.__rest(t,["startDate","immediately"]);let S=(y>b?y:b)+(f||0);if(g){S=new Date(g).getTime();S=S>y?S:y}let E;let k=null;if(d){const e=Math.floor((S-(f||0))/d)*d;k=typeof f==="number"?f:S-e;const t=e+d;if(b||f){E=t}else{E=e}}else if(p){E=await this.repeatStrategy(y,t,n);if(E<y){E=y}}if(E){return this.trace(o.SpanKind.PRODUCER,"add",`${this.name}.${n}`,(async(r,f)=>{var y,b;let g=s.telemetry;if(f){const e=(y=s.telemetry)===null||y===void 0?void 0:y.omitContext;const t=((b=s.telemetry)===null||b===void 0?void 0:b.metadata)||!e&&f;if(t||e){g={metadata:t,omitContext:e}}}const v=this.getNextJobOpts(E,e,Object.assign(Object.assign({},s),{repeat:K,telemetry:g}),h,k);if(l){const l=await this.scripts.addJobScheduler(e,E,JSON.stringify(typeof i==="undefined"?{}:i),a.Job.optsAsJSON(s),{name:n,endDate:m?new Date(m).getTime():undefined,tz:t.tz,pattern:p,every:d,limit:u,offset:k},a.Job.optsAsJSON(v),c);const f=new this.Job(this,n,i,v,l);f.id=l;r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.JobSchedulerId]:e,[o.TelemetryAttributes.JobId]:f.id});return f}else{const t=await this.scripts.updateJobSchedulerNextMillis(e,E,JSON.stringify(typeof i==="undefined"?{}:i),a.Job.optsAsJSON(v),c);if(t){const a=new this.Job(this,n,i,v,t);a.id=t;r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.JobSchedulerId]:e,[o.TelemetryAttributes.JobId]:a.id});return a}}}))}}getNextJobOpts(e,t,n,r,i){var a;const s=this.getSchedulerNextJobId({jobSchedulerId:t,nextMillis:e});const o=Date.now();const l=e+i-o;const c=Object.assign(Object.assign({},n),{jobId:s,delay:l<0?0:l,timestamp:o,prevMillis:e,repeatJobKey:t});c.repeat=Object.assign(Object.assign({},n.repeat),{offset:i,count:r,endDate:((a=n.repeat)===null||a===void 0?void 0:a.endDate)?new Date(n.repeat.endDate).getTime():undefined});return c}async removeJobScheduler(e){return this.scripts.removeJobScheduler(e)}async getSchedulerData(e,t,n){const r=await e.hgetall(this.toKey("repeat:"+t));return this.transformSchedulerData(t,r,n)}transformSchedulerData(e,t,n){if(t){const r={key:e,name:t.name,next:n};if(t.ic){r.iterationCount=parseInt(t.ic)}if(t.limit){r.limit=parseInt(t.limit)}if(t.endDate){r.endDate=parseInt(t.endDate)}if(t.tz){r.tz=t.tz}if(t.pattern){r.pattern=t.pattern}if(t.every){r.every=parseInt(t.every)}if(t.offset){r.offset=parseInt(t.offset)}if(t.data||t.opts){r.template=this.getTemplateFromJSON(t.data,t.opts)}return r}if(e.includes(":")){return this.keyToData(e,n)}}keyToData(e,t){const n=e.split(":");const r=n.slice(4).join(":")||null;return{key:e,name:n[0],id:n[1]||null,endDate:parseInt(n[2])||null,tz:n[3]||null,pattern:r,next:t}}async getScheduler(e){const[t,n]=await this.scripts.getJobScheduler(e);return this.transformSchedulerData(e,t?(0,l.array2obj)(t):null,n?parseInt(n):null)}getTemplateFromJSON(e,t){const n={};if(e){n.data=JSON.parse(e)}if(t){n.opts=a.Job.optsFromJSON(t)}return n}async getJobSchedulers(e=0,t=-1,n=false){const r=await this.client;const i=this.keys.repeat;const a=n?await r.zrange(i,e,t,"WITHSCORES"):await r.zrevrange(i,e,t,"WITHSCORES");const s=[];for(let e=0;e<a.length;e+=2){s.push(this.getSchedulerData(r,a[e],parseInt(a[e+1])))}return Promise.all(s)}async getSchedulersCount(){const e=this.keys.repeat;const t=await this.client;return t.zcard(e)}getSchedulerNextJobId({nextMillis:e,jobSchedulerId:t}){return`repeat:${t}:${e}`}}t.JobScheduler=JobScheduler;const defaultRepeatStrategy=(e,t)=>{const{pattern:n}=t;const r=new Date(e);const a=(0,i.parseExpression)(n,Object.assign(Object.assign({},t),{currentDate:r}));try{if(t.immediately){return(new Date).getTime()}else{return a.next().getTime()}}catch(e){}};t.defaultRepeatStrategy=defaultRepeatStrategy},4078:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Job=t.PRIORITY_LIMIT=void 0;const r=n(1577);const i=n(9023);const a=n(8547);const s=n(5740);const o=n(5431);const l=n(6991);const c=(0,i.debuglog)("bull");t.PRIORITY_LIMIT=2**21;class Job{constructor(e,t,n,i={},o){this.queue=e;this.name=t;this.data=n;this.opts=i;this.id=o;this.progress=0;this.returnvalue=null;this.stacktrace=null;this.delay=0;this.priority=0;this.attemptsStarted=0;this.attemptsMade=0;this.stalledCounter=0;const l=this.opts,{repeatJobKey:c}=l,d=r.__rest(l,["repeatJobKey"]);this.opts=Object.assign({attempts:0},d);this.delay=this.opts.delay;this.priority=this.opts.priority||0;this.repeatJobKey=c;this.timestamp=i.timestamp?i.timestamp:Date.now();this.opts.backoff=s.Backoffs.normalize(i.backoff);this.parentKey=(0,a.getParentKey)(i.parent);if(i.parent){this.parent={id:i.parent.id,queueKey:i.parent.queue};if(i.failParentOnFailure){this.parent.fpof=true}if(i.removeDependencyOnFailure){this.parent.rdof=true}if(i.ignoreDependencyOnFailure){this.parent.idof=true}if(i.continueParentOnFailure){this.parent.cpof=true}}this.debounceId=i.debounce?i.debounce.id:undefined;this.deduplicationId=i.deduplication?i.deduplication.id:this.debounceId;this.toKey=e.toKey.bind(e);this.createScripts();this.queueQualifiedName=e.qualifiedName}static async create(e,t,n,r){const i=await e.client;const a=new this(e,t,n,r,r&&r.jobId);a.id=await a.addJob(i,{parentKey:a.parentKey,parentDependenciesKey:a.parentKey?`${a.parentKey}:dependencies`:""});return a}static async createBulk(e,t){const n=await e.client;const r=t.map((t=>{var n;return new this(e,t.name,t.data,t.opts,(n=t.opts)===null||n===void 0?void 0:n.jobId)}));const i=n.pipeline();for(const e of r){e.addJob(i,{parentKey:e.parentKey,parentDependenciesKey:e.parentKey?`${e.parentKey}:dependencies`:""})}const a=await i.exec();for(let e=0;e<a.length;++e){const[t,n]=a[e];if(t){throw t}r[e].id=n}return r}static fromJSON(e,t,n){const r=JSON.parse(t.data||"{}");const i=Job.optsFromJSON(t.opts);const a=new this(e,t.name,r,i,t.id||n);a.progress=JSON.parse(t.progress||"0");a.delay=parseInt(t.delay);a.priority=parseInt(t.priority);a.timestamp=parseInt(t.timestamp);if(t.finishedOn){a.finishedOn=parseInt(t.finishedOn)}if(t.processedOn){a.processedOn=parseInt(t.processedOn)}if(t.rjk){a.repeatJobKey=t.rjk}if(t.deid){a.debounceId=t.deid;a.deduplicationId=t.deid}if(t.failedReason){a.failedReason=t.failedReason}a.attemptsStarted=parseInt(t.ats||"0");a.attemptsMade=parseInt(t.attemptsMade||t.atm||"0");a.stalledCounter=parseInt(t.stc||"0");if(t.defa){a.deferredFailure=t.defa}a.stacktrace=getTraces(t.stacktrace);if(typeof t.returnvalue==="string"){a.returnvalue=getReturnValue(t.returnvalue)}if(t.parentKey){a.parentKey=t.parentKey}if(t.parent){a.parent=JSON.parse(t.parent)}if(t.pb){a.processedBy=t.pb}if(t.nrjid){a.nextRepeatableJobId=t.nrjid}return a}createScripts(){this.scripts=(0,a.createScripts)(this.queue)}static optsFromJSON(e,t=a.optsDecodeMap){const n=JSON.parse(e||"{}");const r=Object.entries(n);const i={};for(const e of r){const[n,r]=e;if(t[n]){i[t[n]]=r}else{if(n==="tm"){i.telemetry=Object.assign(Object.assign({},i.telemetry),{metadata:r})}else if(n==="omc"){i.telemetry=Object.assign(Object.assign({},i.telemetry),{omitContext:r})}else{i[n]=r}}}return i}static async fromId(e,t){if(t){const n=await e.client;const r=await n.hgetall(e.toKey(t));return(0,a.isEmpty)(r)?undefined:this.fromJSON(e,r,t)}}static addJobLog(e,t,n,r){const i=e.scripts;return i.addLog(t,n,r)}toJSON(){const e=this,{queue:t,scripts:n}=e,i=r.__rest(e,["queue","scripts"]);return i}asJSON(){return(0,a.removeUndefinedFields)({id:this.id,name:this.name,data:JSON.stringify(typeof this.data==="undefined"?{}:this.data),opts:Job.optsAsJSON(this.opts),parent:this.parent?Object.assign({},this.parent):undefined,parentKey:this.parentKey,progress:this.progress,attemptsMade:this.attemptsMade,attemptsStarted:this.attemptsStarted,stalledCounter:this.stalledCounter,finishedOn:this.finishedOn,processedOn:this.processedOn,timestamp:this.timestamp,failedReason:JSON.stringify(this.failedReason),stacktrace:JSON.stringify(this.stacktrace),debounceId:this.debounceId,deduplicationId:this.deduplicationId,repeatJobKey:this.repeatJobKey,returnvalue:JSON.stringify(this.returnvalue),nrjid:this.nextRepeatableJobId})}static optsAsJSON(e={},t=a.optsEncodeMap){const n=Object.entries(e);const r={};for(const[e,i]of n){if(typeof i==="undefined"){continue}if(e in t){const n=e;const a=t[n];r[a]=i}else{if(e==="telemetry"){r.tm=i.metadata;r.omc=i.omitContext}else{r[e]=i}}}return r}asJSONSandbox(){return Object.assign(Object.assign({},this.asJSON()),{queueName:this.queueName,prefix:this.prefix})}updateData(e){this.data=e;return this.scripts.updateData(this,e)}async updateProgress(e){this.progress=e;await this.scripts.updateProgress(this.id,e);this.queue.emit("progress",this,e)}async log(e){return Job.addJobLog(this.queue,this.id,e,this.opts.keepLogs)}async removeChildDependency(){const e=await this.scripts.removeChildDependency(this.id,this.parentKey);if(e){this.parent=undefined;this.parentKey=undefined;return true}return false}async clearLogs(e){const t=await this.queue.client;const n=this.toKey(this.id)+":logs";if(e){await t.ltrim(n,-e,-1)}else{await t.del(n)}}async remove({removeChildren:e=true}={}){await this.queue.waitUntilReady();const t=this.queue;const n=this;const r=await this.scripts.remove(n.id,e);if(r){t.emit("removed",n)}else{throw new Error(`Job ${this.id} could not be removed because it is locked by another worker`)}}async removeUnprocessedChildren(){const e=this.id;await this.scripts.removeUnprocessedChildren(e)}extendLock(e,t){return this.scripts.extendLock(this.id,e,t)}async moveToCompleted(e,t,n=true){return this.queue.trace(l.SpanKind.INTERNAL,"complete",this.queue.name,(async(r,i)=>{var s,o;let l;if(!((o=(s=this.opts)===null||s===void 0?void 0:s.telemetry)===null||o===void 0?void 0:o.omitContext)&&i){l=i}await this.queue.waitUntilReady();this.returnvalue=e||void 0;const c=(0,a.tryCatch)(JSON.stringify,JSON,[e]);if(c===a.errorObject){throw a.errorObject.value}const d=this.scripts.moveToCompletedArgs(this,c,this.opts.removeOnComplete,t,n);const u=await this.scripts.moveToFinished(this.id,d);this.finishedOn=d[this.scripts.moveToFinishedKeys.length+1];this.attemptsMade+=1;return u}))}moveToWait(e){return this.scripts.moveJobFromActiveToWait(this.id,e)}async shouldRetryJob(e){if(this.attemptsMade+1<this.opts.attempts&&!this.discarded&&!(e instanceof o.UnrecoverableError||e.name=="UnrecoverableError")){const t=this.queue.opts;const n=await s.Backoffs.calculate(this.opts.backoff,this.attemptsMade+1,e,this,t.settings&&t.settings.backoffStrategy);return[n==-1?false:true,n==-1?0:n]}else{return[false,0]}}async moveToFailed(e,t,n=false){this.failedReason=e===null||e===void 0?void 0:e.message;const[r,i]=await this.shouldRetryJob(e);return this.queue.trace(l.SpanKind.INTERNAL,this.getSpanOperation(r,i),this.queue.name,(async(a,s)=>{var o,l;let c;if(!((l=(o=this.opts)===null||o===void 0?void 0:o.telemetry)===null||l===void 0?void 0:l.omitContext)&&s){c=s}let d;this.updateStacktrace(e);const u={failedReason:this.failedReason,stacktrace:JSON.stringify(this.stacktrace),tm:c};let p;if(r){if(i){d=await this.scripts.moveToDelayed(this.id,Date.now(),i,t,{fieldsToUpdate:u})}else{d=await this.scripts.retryJob(this.id,this.opts.lifo,t,{fieldsToUpdate:u})}}else{const e=this.scripts.moveToFailedArgs(this,this.failedReason,this.opts.removeOnFail,t,n,u);d=await this.scripts.moveToFinished(this.id,e);p=e[this.scripts.moveToFinishedKeys.length+1]}if(p&&typeof p==="number"){this.finishedOn=p}if(i&&typeof i==="number"){this.delay=i}this.attemptsMade+=1;return d}))}getSpanOperation(e,t){if(e){if(t){return"delay"}return"retry"}return"fail"}isCompleted(){return this.isInZSet("completed")}isFailed(){return this.isInZSet("failed")}isDelayed(){return this.isInZSet("delayed")}isWaitingChildren(){return this.isInZSet("waiting-children")}isActive(){return this.isInList("active")}async isWaiting(){return await this.isInList("wait")||await this.isInList("paused")}get queueName(){return this.queue.name}get prefix(){return this.queue.opts.prefix}getState(){return this.scripts.getState(this.id)}async changeDelay(e){await this.scripts.changeDelay(this.id,e);this.delay=e}async changePriority(e){await this.scripts.changePriority(this.id,e.priority,e.lifo);this.priority=e.priority||0}async getChildrenValues(){const e=await this.queue.client;const t=await e.hgetall(this.toKey(`${this.id}:processed`));if(t){return(0,a.parseObjectValues)(t)}}async getIgnoredChildrenFailures(){const e=await this.queue.client;return e.hgetall(this.toKey(`${this.id}:failed`))}async getFailedChildrenValues(){const e=await this.queue.client;return e.hgetall(this.toKey(`${this.id}:failed`))}async getDependencies(e={}){const t=await this.queue.client;const n=t.multi();if(!e.processed&&!e.unprocessed&&!e.ignored&&!e.failed){n.hgetall(this.toKey(`${this.id}:processed`));n.smembers(this.toKey(`${this.id}:dependencies`));n.hgetall(this.toKey(`${this.id}:failed`));n.zrange(this.toKey(`${this.id}:unsuccessful`),0,-1);const[[e,t],[r,i],[s,o],[l,c]]=await n.exec();return{processed:(0,a.parseObjectValues)(t),unprocessed:i,failed:c,ignored:o}}else{const t={cursor:0,count:20};const r=[];if(e.processed){r.push("processed");const i=Object.assign(Object.assign({},t),e.processed);n.hscan(this.toKey(`${this.id}:processed`),i.cursor,"COUNT",i.count)}if(e.unprocessed){r.push("unprocessed");const i=Object.assign(Object.assign({},t),e.unprocessed);n.sscan(this.toKey(`${this.id}:dependencies`),i.cursor,"COUNT",i.count)}if(e.ignored){r.push("ignored");const i=Object.assign(Object.assign({},t),e.ignored);n.hscan(this.toKey(`${this.id}:failed`),i.cursor,"COUNT",i.count)}let i;if(e.failed){r.push("failed");const a=Object.assign(Object.assign({},t),e.failed);i=a.cursor+a.count;n.zrange(this.toKey(`${this.id}:unsuccessful`),a.cursor,a.count-1)}const a=await n.exec();let s,o,l,c,d,u,p;r.forEach(((e,t)=>{switch(e){case"processed":{s=a[t][1][0];const e=a[t][1][1];const n={};for(let t=0;t<e.length;++t){if(t%2){n[e[t-1]]=JSON.parse(e[t])}}o=n;break}case"failed":{d=a[t][1];break}case"ignored":{u=a[t][1][0];const e=a[t][1][1];const n={};for(let t=0;t<e.length;++t){if(t%2){n[e[t-1]]=e[t]}}p=n;break}case"unprocessed":{l=a[t][1][0];c=a[t][1][1];break}}}));return Object.assign(Object.assign(Object.assign(Object.assign({},s?{processed:o,nextProcessedCursor:Number(s)}:{}),u?{ignored:p,nextIgnoredCursor:Number(u)}:{}),i?{failed:d,nextFailedCursor:i}:{}),l?{unprocessed:c,nextUnprocessedCursor:Number(l)}:{})}}async getDependenciesCount(e={}){const t=[];Object.entries(e).forEach((([e,n])=>{if(n){t.push(e)}}));const n=t.length?t:["processed","unprocessed","ignored","failed"];const r=await this.scripts.getDependencyCounts(this.id,n);const i={};r.forEach(((e,t)=>{i[`${n[t]}`]=e||0}));return i}async waitUntilFinished(e,t){await this.queue.waitUntilReady();const n=this.id;return new Promise((async(r,i)=>{let a;if(t){a=setTimeout((()=>onFailed(`Job wait ${this.name} timed out before finishing, no finish notification arrived after ${t}ms (id=${n})`)),t)}function onCompleted(e){removeListeners();r(e.returnvalue)}function onFailed(e){removeListeners();i(new Error(e.failedReason||e))}const s=`completed:${n}`;const o=`failed:${n}`;e.on(s,onCompleted);e.on(o,onFailed);this.queue.on("closing",onFailed);const removeListeners=()=>{clearInterval(a);e.removeListener(s,onCompleted);e.removeListener(o,onFailed);this.queue.removeListener("closing",onFailed)};await e.waitUntilReady();const[l,c]=await this.scripts.isFinished(n,true);const d=l!=0;if(d){if(l==-1||l==2){onFailed({failedReason:c})}else{onCompleted({returnvalue:getReturnValue(c)})}}}))}async moveToDelayed(e,t){const n=Date.now();const r=e-n;const i=r>0?r:0;const a=await this.scripts.moveToDelayed(this.id,n,i,t,{skipAttempt:true});this.delay=i;return a}async moveToWaitingChildren(e,t={}){const n=await this.scripts.moveToWaitingChildren(this.id,e,t);return n}async promote(){const e=this.id;await this.scripts.promote(e);this.delay=0}retry(e="failed"){this.failedReason=null;this.finishedOn=null;this.processedOn=null;this.returnvalue=null;return this.scripts.reprocessJob(this,e)}discard(){this.discarded=true}async isInZSet(e){const t=await this.queue.client;const n=await t.zscore(this.queue.toKey(e),this.id);return n!==null}async isInList(e){return this.scripts.isJobInList(this.queue.toKey(e),this.id)}addJob(e,t){const n=this.asJSON();this.validateOptions(n);return this.scripts.addJob(e,n,n.opts,this.id,t)}validateOptions(e){var n;const r=["removeDependencyOnFailure","failParentOnFailure","continueParentOnFailure","ignoreDependencyOnFailure"];const i=this.opts.sizeLimit&&(0,a.lengthInUtf8Bytes)(e.data)>this.opts.sizeLimit;if(i){throw new Error(`The size of job ${this.name} exceeds the limit ${this.opts.sizeLimit} bytes`)}if(this.opts.delay&&this.opts.repeat&&!((n=this.opts.repeat)===null||n===void 0?void 0:n.count)){throw new Error(`Delay and repeat options could not be used together`)}const s=r.filter((e=>this.opts[e]));if(s.length>1){const e=s.join(", ");throw new Error(`The following options cannot be used together: ${e}`)}if(`${parseInt(this.id,10)}`===this.id){throw new Error("Custom Ids cannot be integers")}if(this.opts.priority){if(Math.trunc(this.opts.priority)!==this.opts.priority){throw new Error(`Priority should not be float`)}if(this.opts.priority>t.PRIORITY_LIMIT){throw new Error(`Priority should be between 0 and ${t.PRIORITY_LIMIT}`)}}if(typeof this.opts.backoff==="object"&&typeof this.opts.backoff.jitter==="number"){if(this.opts.backoff.jitter<0||this.opts.backoff.jitter>1){throw new Error(`Jitter should be between 0 and 1`)}}}updateStacktrace(e){this.stacktrace=this.stacktrace||[];if(e===null||e===void 0?void 0:e.stack){this.stacktrace.push(e.stack);if(this.opts.stackTraceLimit===0){this.stacktrace=[]}else if(this.opts.stackTraceLimit){this.stacktrace=this.stacktrace.slice(-this.opts.stackTraceLimit)}}}}t.Job=Job;function getTraces(e){const t=(0,a.tryCatch)(JSON.parse,JSON,[e]);if(t===a.errorObject||!(t instanceof Array)){return[]}else{return t}}function getReturnValue(e){const t=(0,a.tryCatch)(JSON.parse,JSON,[e]);if(t!==a.errorObject){return t}else{c("corrupted returnvalue: "+e,t)}}},4982:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueBase=void 0;const r=n(4434);const i=n(8547);const a=n(6595);const s=n(4078);const o=n(4795);class QueueBase extends r.EventEmitter{constructor(e,t={connection:{}},n=a.RedisConnection,r=false){super();this.name=e;this.opts=t;this.closed=false;this.hasBlockingConnection=false;this.hasBlockingConnection=r;this.opts=Object.assign({prefix:"bull"},t);if(!e){throw new Error("Queue name must be provided")}if(e.includes(":")){throw new Error("Queue name cannot contain :")}this.connection=new n(t.connection,{shared:(0,i.isRedisInstance)(t.connection),blocking:r,skipVersionCheck:t.skipVersionCheck,skipWaitingForReady:t.skipWaitingForReady});this.connection.on("error",(e=>this.emit("error",e)));this.connection.on("close",(()=>{if(!this.closing){this.emit("ioredis:close")}}));const s=new o.QueueKeys(t.prefix);this.qualifiedName=s.getQueueQualifiedName(e);this.keys=s.getKeys(e);this.toKey=t=>s.toKey(e,t);this.createScripts()}get client(){return this.connection.client}createScripts(){this.scripts=(0,i.createScripts)(this)}get redisVersion(){return this.connection.redisVersion}get Job(){return s.Job}emit(e,...t){try{return super.emit(e,...t)}catch(e){try{return super.emit("error",e)}catch(e){console.error(e);return false}}}waitUntilReady(){return this.client}base64Name(){return Buffer.from(this.name).toString("base64")}clientName(e=""){const t=this.base64Name();return`${this.opts.prefix}:${t}${e}`}async close(){if(!this.closing){this.closing=this.connection.close()}await this.closing;this.closed=true}disconnect(){return this.connection.disconnect()}async checkConnectionError(e,t=i.DELAY_TIME_5){try{return await e()}catch(e){if((0,i.isNotConnectionError)(e)){this.emit("error",e)}if(!this.closing&&t){await(0,i.delay)(t)}else{return}}}trace(e,t,n,r,a){return(0,i.trace)(this.opts.telemetry,e,this.name,t,n,r,a)}}t.QueueBase=QueueBase},1017:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueEventsProducer=void 0;const r=n(1577);const i=n(4982);class QueueEventsProducer extends i.QueueBase{constructor(e,t={connection:{}},n){super(e,Object.assign({blockingConnection:false},t),n);this.opts=t}async publishEvent(e,t=1e3){const n=await this.client;const i=this.keys.events;const{eventName:a}=e,s=r.__rest(e,["eventName"]);const o=["MAXLEN","~",t,"*","event",a];for(const[e,t]of Object.entries(s)){o.push(e,t)}await n.xadd(i,...o)}async close(){if(!this.closing){this.closing=this.connection.close()}await this.closing}}t.QueueEventsProducer=QueueEventsProducer},6058:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueEvents=void 0;const r=n(1577);const i=n(8547);const a=n(4982);class QueueEvents extends a.QueueBase{constructor(e,t={connection:{}},n){var{connection:a,autorun:s=true}=t,o=r.__rest(t,["connection","autorun"]);super(e,Object.assign(Object.assign({},o),{connection:(0,i.isRedisInstance)(a)?a.duplicate():a}),n,true);this.running=false;this.opts=Object.assign({blockingTimeout:1e4},this.opts);if(s){this.run().catch((e=>this.emit("error",e)))}}emit(e,...t){return super.emit(e,...t)}off(e,t){super.off(e,t);return this}on(e,t){super.on(e,t);return this}once(e,t){super.once(e,t);return this}async run(){if(!this.running){try{this.running=true;const e=await this.client;try{await e.client("SETNAME",this.clientName(i.QUEUE_EVENT_SUFFIX))}catch(e){if(!i.clientCommandMessageReg.test(e.message)){throw e}}await this.consumeEvents(e)}catch(e){this.running=false;throw e}}else{throw new Error("Queue Events is already running.")}}async consumeEvents(e){const t=this.opts;const n=this.keys.events;let a=t.lastEventId||"$";while(!this.closing){const s=await this.checkConnectionError((()=>e.xread("BLOCK",t.blockingTimeout,"STREAMS",n,a)));if(s){const e=s[0];const t=e[1];for(let e=0;e<t.length;e++){a=t[e][0];const n=(0,i.array2obj)(t[e][1]);switch(n.event){case"progress":n.data=JSON.parse(n.data);break;case"completed":n.returnvalue=JSON.parse(n.returnvalue);break}const{event:s}=n,o=r.__rest(n,["event"]);if(s==="drained"){this.emit(s,a)}else{this.emit(s,o,a);if(o.jobId){this.emit(`${s}:${o.jobId}`,o,a)}}}}}}close(){if(!this.closing){this.closing=this.disconnect()}return this.closing}}t.QueueEvents=QueueEvents},6451:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueGetters=void 0;const r=n(4982);const i=n(8547);class QueueGetters extends r.QueueBase{getJob(e){return this.Job.fromId(this,e)}commandByType(e,t,n){return e.map((e=>{e=e==="waiting"?"wait":e;const r=this.toKey(e);switch(e){case"completed":case"failed":case"delayed":case"prioritized":case"repeat":case"waiting-children":return n(r,t?"zcard":"zrange");case"active":case"wait":case"paused":return n(r,t?"llen":"lrange")}}))}sanitizeJobTypes(e){const t=typeof e==="string"?[e]:e;if(Array.isArray(t)&&t.length>0){const e=[...t];if(e.indexOf("waiting")!==-1){e.push("paused")}return[...new Set(e)]}return["active","completed","delayed","failed","paused","prioritized","waiting","waiting-children"]}async count(){const e=await this.getJobCountByTypes("waiting","paused","delayed","prioritized","waiting-children");return e}async getRateLimitTtl(e){return this.scripts.getRateLimitTtl(e)}async getDebounceJobId(e){const t=await this.client;return t.get(`${this.keys.de}:${e}`)}async getDeduplicationJobId(e){const t=await this.client;return t.get(`${this.keys.de}:${e}`)}async getJobCountByTypes(...e){const t=await this.getJobCounts(...e);return Object.values(t).reduce(((e,t)=>e+t),0)}async getJobCounts(...e){const t=this.sanitizeJobTypes(e);const n=await this.scripts.getCounts(t);const r={};n.forEach(((e,n)=>{r[t[n]]=e||0}));return r}getJobState(e){return this.scripts.getState(e)}getCompletedCount(){return this.getJobCountByTypes("completed")}getFailedCount(){return this.getJobCountByTypes("failed")}getDelayedCount(){return this.getJobCountByTypes("delayed")}getActiveCount(){return this.getJobCountByTypes("active")}getPrioritizedCount(){return this.getJobCountByTypes("prioritized")}async getCountsPerPriority(e){const t=[...new Set(e)];const n=await this.scripts.getCountsPerPriority(t);const r={};n.forEach(((e,n)=>{r[`${t[n]}`]=e||0}));return r}getWaitingCount(){return this.getJobCountByTypes("waiting")}getWaitingChildrenCount(){return this.getJobCountByTypes("waiting-children")}getWaiting(e=0,t=-1){return this.getJobs(["waiting"],e,t,true)}getWaitingChildren(e=0,t=-1){return this.getJobs(["waiting-children"],e,t,true)}getActive(e=0,t=-1){return this.getJobs(["active"],e,t,true)}getDelayed(e=0,t=-1){return this.getJobs(["delayed"],e,t,true)}getPrioritized(e=0,t=-1){return this.getJobs(["prioritized"],e,t,true)}getCompleted(e=0,t=-1){return this.getJobs(["completed"],e,t,false)}getFailed(e=0,t=-1){return this.getJobs(["failed"],e,t,false)}async getDependencies(e,t,n,r){const i=this.toKey(t=="processed"?`${e}:processed`:`${e}:dependencies`);const{items:a,total:s,jobs:o}=await this.scripts.paginate(i,{start:n,end:r,fetchJobs:true});return{items:a,jobs:o,total:s}}async getRanges(e,t=0,n=1,r=false){const i=[];this.commandByType(e,false,((e,t)=>{switch(t){case"lrange":i.push("lrange");break;case"zrange":i.push("zrange");break}}));const a=await this.scripts.getRanges(e,t,n,r);let s=[];a.forEach(((e,t)=>{const n=e||[];if(r&&i[t]==="lrange"){s=s.concat(n.reverse())}else{s=s.concat(n)}}));return[...new Set(s)]}async getJobs(e,t=0,n=-1,r=false){const i=this.sanitizeJobTypes(e);const a=await this.getRanges(i,t,n,r);return Promise.all(a.map((e=>this.Job.fromId(this,e))))}async getJobLogs(e,t=0,n=-1,r=true){const i=await this.client;const a=i.multi();const s=this.toKey(e+":logs");if(r){a.lrange(s,t,n)}else{a.lrange(s,-(n+1),-(t+1))}a.llen(s);const o=await a.exec();if(!r){o[0][1].reverse()}return{logs:o[0][1],count:o[1][1]}}async baseGetClients(e){const t=await this.client;try{const n=await t.client("LIST");const r=this.parseClientList(n,e);return r}catch(e){if(!i.clientCommandMessageReg.test(e.message)){throw e}return[{name:"GCP does not support client list"}]}}getWorkers(){const e=`${this.clientName()}`;const t=`${this.clientName()}:w:`;const matcher=n=>n&&(n===e||n.startsWith(t));return this.baseGetClients(matcher)}async getWorkersCount(){const e=await this.getWorkers();return e.length}async getQueueEvents(){const e=`${this.clientName()}${i.QUEUE_EVENT_SUFFIX}`;return this.baseGetClients((t=>t===e))}async getMetrics(e,t=0,n=-1){const r=await this.client;const i=this.toKey(`metrics:${e}`);const a=`${i}:data`;const s=r.multi();s.hmget(i,"count","prevTS","prevCount");s.lrange(a,t,n);s.llen(a);const[o,l,c]=await s.exec();const[d,[u,p,f]]=o;const[h,y]=l;const[m,b]=c;if(d||h){throw d||h||m}return{meta:{count:parseInt(u||"0",10),prevTS:parseInt(p||"0",10),prevCount:parseInt(f||"0",10)},data:y,count:b}}parseClientList(e,t){const n=e.split(/\r?\n/);const r=[];n.forEach((e=>{const n={};const i=e.split(" ");i.forEach((function(e){const t=e.indexOf("=");const r=e.substring(0,t);const i=e.substring(t+1);n[r]=i}));const a=n["name"];if(t(a)){n["name"]=this.name;n["rawname"]=a;r.push(n)}}));return r}async exportPrometheusMetrics(e){const t=await this.getJobCounts();const n=[];n.push("# HELP bullmq_job_count Number of jobs in the queue by state");n.push("# TYPE bullmq_job_count gauge");const r=!e?"":Object.keys(e).reduce(((t,n)=>`${t}, ${n}="${e[n]}"`),"");for(const[e,i]of Object.entries(t)){n.push(`bullmq_job_count{queue="${this.name}", state="${e}"${r}} ${i}`)}return n.join("\n")}}t.QueueGetters=QueueGetters},4795:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueKeys=void 0;class QueueKeys{constructor(e="bull"){this.prefix=e}getKeys(e){const t={};["","active","wait","waiting-children","paused","id","delayed","prioritized","stalled-check","completed","failed","stalled","repeat","limiter","meta","events","pc","marker","de"].forEach((n=>{t[n]=this.toKey(e,n)}));return t}toKey(e,t){return`${this.getQueueQualifiedName(e)}:${t}`}getQueueQualifiedName(e){return`${this.prefix}:${e}`}}t.QueueKeys=QueueKeys},6838:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Queue=void 0;const r=n(9935);const i=n(4078);const a=n(6451);const s=n(9454);const o=n(6991);const l=n(6830);const c=n(6614);class Queue extends a.QueueGetters{constructor(e,t,n){var i;super(e,Object.assign({},t),n);this.token=(0,r.v4)();this.libName="bullmq";this.jobsOpts=(i=t===null||t===void 0?void 0:t.defaultJobOptions)!==null&&i!==void 0?i:{};this.waitUntilReady().then((e=>{if(!this.closing&&!(t===null||t===void 0?void 0:t.skipMetasUpdate)){return e.hmset(this.keys.meta,this.metaValues)}})).catch((e=>{}))}emit(e,...t){return super.emit(e,...t)}off(e,t){super.off(e,t);return this}on(e,t){super.on(e,t);return this}once(e,t){super.once(e,t);return this}get defaultJobOptions(){return Object.assign({},this.jobsOpts)}get metaValues(){var e,t,n,r;return{"opts.maxLenEvents":(r=(n=(t=(e=this.opts)===null||e===void 0?void 0:e.streams)===null||t===void 0?void 0:t.events)===null||n===void 0?void 0:n.maxLen)!==null&&r!==void 0?r:1e4,version:`${this.libName}:${c.version}`}}async getVersion(){const e=await this.client;return await e.hget(this.keys.meta,"version")}get repeat(){return new Promise((async e=>{if(!this._repeat){this._repeat=new s.Repeat(this.name,Object.assign(Object.assign({},this.opts),{connection:await this.client}));this._repeat.on("error",(e=>this.emit.bind(this,e)))}e(this._repeat)}))}get jobScheduler(){return new Promise((async e=>{if(!this._jobScheduler){this._jobScheduler=new l.JobScheduler(this.name,Object.assign(Object.assign({},this.opts),{connection:await this.client}));this._jobScheduler.on("error",(e=>this.emit.bind(this,e)))}e(this._jobScheduler)}))}async getGlobalConcurrency(){const e=await this.client;const t=await e.hget(this.keys.meta,"concurrency");if(t){return Number(t)}return null}async setGlobalConcurrency(e){const t=await this.client;return t.hset(this.keys.meta,"concurrency",e)}async removeGlobalConcurrency(){const e=await this.client;return e.hdel(this.keys.meta,"concurrency")}async add(e,t,n){return this.trace(o.SpanKind.PRODUCER,"add",`${this.name}.${e}`,(async(r,i)=>{var a;if(i&&!((a=n===null||n===void 0?void 0:n.telemetry)===null||a===void 0?void 0:a.omitContext)){const e={metadata:i};n=Object.assign(Object.assign({},n),{telemetry:e})}const s=await this.addJob(e,t,n);r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.JobName]:e,[o.TelemetryAttributes.JobId]:s.id});return s}))}async addJob(e,t,n){if(n&&n.repeat){if(n.repeat.endDate){if(+new Date(n.repeat.endDate)<Date.now()){throw new Error("End date must be greater than current timestamp")}}return(await this.repeat).updateRepeatableJob(e,t,Object.assign(Object.assign({},this.jobsOpts),n),{override:true})}else{const r=n===null||n===void 0?void 0:n.jobId;if(r=="0"||(r===null||r===void 0?void 0:r.startsWith("0:"))){throw new Error("JobId cannot be '0' or start with 0:")}const i=await this.Job.create(this,e,t,Object.assign(Object.assign(Object.assign({},this.jobsOpts),n),{jobId:r}));this.emit("waiting",i);return i}}async addBulk(e){return this.trace(o.SpanKind.PRODUCER,"addBulk",this.name,(async(t,n)=>{if(t){t.setAttributes({[o.TelemetryAttributes.BulkNames]:e.map((e=>e.name)),[o.TelemetryAttributes.BulkCount]:e.length})}return await this.Job.createBulk(this,e.map((e=>{var t,r,i,a,s,o;let l=(t=e.opts)===null||t===void 0?void 0:t.telemetry;if(n){const t=(i=(r=e.opts)===null||r===void 0?void 0:r.telemetry)===null||i===void 0?void 0:i.omitContext;const o=((s=(a=e.opts)===null||a===void 0?void 0:a.telemetry)===null||s===void 0?void 0:s.metadata)||!t&&n;if(o||t){l={metadata:o,omitContext:t}}}return{name:e.name,data:e.data,opts:Object.assign(Object.assign(Object.assign({},this.jobsOpts),e.opts),{jobId:(o=e.opts)===null||o===void 0?void 0:o.jobId,telemetry:l})}})))}))}async upsertJobScheduler(e,t,n){var r,i;if(t.endDate){if(+new Date(t.endDate)<Date.now()){throw new Error("End date must be greater than current timestamp")}}return(await this.jobScheduler).upsertJobScheduler(e,t,(r=n===null||n===void 0?void 0:n.name)!==null&&r!==void 0?r:e,(i=n===null||n===void 0?void 0:n.data)!==null&&i!==void 0?i:{},Object.assign(Object.assign({},this.jobsOpts),n===null||n===void 0?void 0:n.opts),{override:true})}async pause(){await this.trace(o.SpanKind.INTERNAL,"pause",this.name,(async()=>{await this.scripts.pause(true);this.emit("paused")}))}async close(){await this.trace(o.SpanKind.INTERNAL,"close",this.name,(async()=>{if(!this.closing){if(this._repeat){await this._repeat.close()}}await super.close()}))}async rateLimit(e){await this.trace(o.SpanKind.INTERNAL,"rateLimit",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueRateLimit]:e});await this.client.then((t=>t.set(this.keys.limiter,Number.MAX_SAFE_INTEGER,"PX",e)))}))}async resume(){await this.trace(o.SpanKind.INTERNAL,"resume",this.name,(async()=>{await this.scripts.pause(false);this.emit("resumed")}))}async isPaused(){const e=await this.client;const t=await e.hexists(this.keys.meta,"paused");return t===1}isMaxed(){return this.scripts.isMaxed()}async getRepeatableJobs(e,t,n){return(await this.repeat).getRepeatableJobs(e,t,n)}async getJobScheduler(e){return(await this.jobScheduler).getScheduler(e)}async getJobSchedulers(e,t,n){return(await this.jobScheduler).getJobSchedulers(e,t,n)}async getJobSchedulersCount(){return(await this.jobScheduler).getSchedulersCount()}async removeRepeatable(e,t,n){return this.trace(o.SpanKind.INTERNAL,"removeRepeatable",`${this.name}.${e}`,(async r=>{r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.JobName]:e,[o.TelemetryAttributes.JobId]:n});const i=await this.repeat;const a=await i.removeRepeatable(e,t,n);return!a}))}async removeJobScheduler(e){const t=await this.jobScheduler;const n=await t.removeJobScheduler(e);return!n}async removeDebounceKey(e){return this.trace(o.SpanKind.INTERNAL,"removeDebounceKey",`${this.name}`,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.JobKey]:e});const n=await this.client;return await n.del(`${this.keys.de}:${e}`)}))}async removeDeduplicationKey(e){return this.trace(o.SpanKind.INTERNAL,"removeDeduplicationKey",`${this.name}`,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.DeduplicationKey]:e});const n=await this.client;return n.del(`${this.keys.de}:${e}`)}))}async removeRateLimitKey(){const e=await this.client;return e.del(this.keys.limiter)}async removeRepeatableByKey(e){return this.trace(o.SpanKind.INTERNAL,"removeRepeatableByKey",`${this.name}`,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.JobKey]:e});const n=await this.repeat;const r=await n.removeRepeatableByKey(e);return!r}))}async remove(e,{removeChildren:t=true}={}){return this.trace(o.SpanKind.INTERNAL,"remove",this.name,(async n=>{n===null||n===void 0?void 0:n.setAttributes({[o.TelemetryAttributes.JobId]:e,[o.TelemetryAttributes.JobOptions]:JSON.stringify({removeChildren:t})});return await this.scripts.remove(e,t)}))}async updateJobProgress(e,t){await this.trace(o.SpanKind.INTERNAL,"updateJobProgress",this.name,(async n=>{n===null||n===void 0?void 0:n.setAttributes({[o.TelemetryAttributes.JobId]:e,[o.TelemetryAttributes.JobProgress]:JSON.stringify(t)});await this.scripts.updateProgress(e,t)}))}async addJobLog(e,t,n){return i.Job.addJobLog(this,e,t,n)}async drain(e=false){await this.trace(o.SpanKind.INTERNAL,"drain",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueDrainDelay]:e});await this.scripts.drain(e)}))}async clean(e,t,n="completed"){return this.trace(o.SpanKind.INTERNAL,"clean",this.name,(async r=>{const i=t||Infinity;const a=Math.min(1e4,i);const s=Date.now()-e;let l=0;const c=[];while(l<i){const e=await this.scripts.cleanJobsInSet(n,s,a);this.emit("cleaned",e,n);l+=e.length;c.push(...e);if(e.length<a){break}}r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.QueueGrace]:e,[o.TelemetryAttributes.JobType]:n,[o.TelemetryAttributes.QueueCleanLimit]:i,[o.TelemetryAttributes.JobIds]:c});return c}))}async obliterate(e){await this.trace(o.SpanKind.INTERNAL,"obliterate",this.name,(async()=>{await this.pause();let t=0;do{t=await this.scripts.obliterate(Object.assign({force:false,count:1e3},e))}while(t)}))}async retryJobs(e={}){await this.trace(o.SpanKind.PRODUCER,"retryJobs",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueOptions]:JSON.stringify(e)});let n=0;do{n=await this.scripts.retryJobs(e.state,e.count,e.timestamp)}while(n)}))}async promoteJobs(e={}){await this.trace(o.SpanKind.INTERNAL,"promoteJobs",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueOptions]:JSON.stringify(e)});let n=0;do{n=await this.scripts.promoteJobs(e.count)}while(n)}))}async trimEvents(e){return this.trace(o.SpanKind.INTERNAL,"trimEvents",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueEventMaxLength]:e});const n=await this.client;return await n.xtrim(this.keys.events,"MAXLEN","~",e)}))}async removeDeprecatedPriorityKey(){const e=await this.client;return e.del(this.toKey("priority"))}}t.Queue=Queue},6595:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.RedisConnection=void 0;const r=n(1577);const i=n(4434);const a=n(8721);const s=n(387);const o=n(8547);const l=n(6614);const c=n(9589);const d=["BullMQ: WARNING! Your redis options maxRetriesPerRequest must be null","and will be overridden by BullMQ."].join(" ");const u="BullMQ: Your redis options maxRetriesPerRequest must be null.";class RedisConnection extends i.EventEmitter{constructor(e,t){super();this.extraOptions=t;this.capabilities={canDoubleTimeout:false,canBlockFor1Ms:true};this.status="initializing";this.packageVersion=l.version;this.extraOptions=Object.assign({shared:false,blocking:true,skipVersionCheck:false,skipWaitingForReady:false},t);if(!(0,o.isRedisInstance)(e)){this.checkBlockingOptions(d,e);this.opts=Object.assign({port:6379,host:"127.0.0.1",retryStrategy:function(e){return Math.max(Math.min(Math.exp(e),2e4),1e3)}},e);if(this.extraOptions.blocking){this.opts.maxRetriesPerRequest=null}}else{this._client=e;if(this._client.options.keyPrefix){throw new Error("BullMQ: ioredis does not support ioredis prefixes, use the prefix option instead.")}if((0,o.isRedisCluster)(this._client)){this.opts=this._client.options.redisOptions}else{this.opts=this._client.options}this.checkBlockingOptions(u,this.opts,true)}this.skipVersionCheck=(t===null||t===void 0?void 0:t.skipVersionCheck)||!!(this.opts&&this.opts.skipVersionCheck);this.handleClientError=e=>{this.emit("error",e)};this.handleClientClose=()=>{this.emit("close")};this.handleClientReady=()=>{this.emit("ready")};this.initializing=this.init();this.initializing.catch((e=>this.emit("error",e)))}checkBlockingOptions(e,t,n=false){if(this.extraOptions.blocking&&t&&t.maxRetriesPerRequest){if(n){throw new Error(e)}else{console.error(e)}}}static async waitUntilReady(e){if(e.status==="ready"){return}if(e.status==="wait"){return e.connect()}if(e.status==="end"){throw new Error(s.CONNECTION_CLOSED_ERROR_MSG)}let t;let n;let r;try{await new Promise(((i,a)=>{let l;r=e=>{l=e};t=()=>{i()};n=()=>{if(e.status!=="end"){a(l||new Error(s.CONNECTION_CLOSED_ERROR_MSG))}else{if(l){a(l)}else{i()}}};(0,o.increaseMaxListeners)(e,3);e.once("ready",t);e.on("end",n);e.once("error",r)}))}finally{e.removeListener("end",n);e.removeListener("error",r);e.removeListener("ready",t);(0,o.decreaseMaxListeners)(e,3)}}get client(){return this.initializing}loadCommands(e,t){const n=t||c;for(const t in n){const r=`${n[t].name}:${e}`;if(!this._client[r]){this._client.defineCommand(r,{numberOfKeys:n[t].keys,lua:n[t].content})}}}async init(){if(!this._client){const e=this.opts,{url:t}=e,n=r.__rest(e,["url"]);this._client=t?new a.default(t,n):new a.default(n)}(0,o.increaseMaxListeners)(this._client,3);this._client.on("error",this.handleClientError);this._client.on("close",this.handleClientClose);this._client.on("ready",this.handleClientReady);if(!this.extraOptions.skipWaitingForReady){await RedisConnection.waitUntilReady(this._client)}this.loadCommands(this.packageVersion);if(this._client["status"]!=="end"){this.version=await this.getRedisVersion();if(this.skipVersionCheck!==true&&!this.closing){if((0,o.isRedisVersionLowerThan)(this.version,RedisConnection.minimumVersion)){throw new Error(`Redis version needs to be greater or equal than ${RedisConnection.minimumVersion} `+`Current: ${this.version}`)}if((0,o.isRedisVersionLowerThan)(this.version,RedisConnection.recommendedMinimumVersion)){console.warn(`It is highly recommended to use a minimum Redis version of ${RedisConnection.recommendedMinimumVersion}\n Current: ${this.version}`)}}this.capabilities={canDoubleTimeout:!(0,o.isRedisVersionLowerThan)(this.version,"6.0.0"),canBlockFor1Ms:!(0,o.isRedisVersionLowerThan)(this.version,"7.0.8")};this.status="ready"}return this._client}async disconnect(e=true){const t=await this.client;if(t.status!=="end"){let n,r;if(!e){return t.disconnect()}const i=new Promise(((e,i)=>{(0,o.increaseMaxListeners)(t,2);t.once("end",e);t.once("error",i);n=e;r=i}));t.disconnect();try{await i}finally{(0,o.decreaseMaxListeners)(t,2);t.removeListener("end",n);t.removeListener("error",r)}}}async reconnect(){const e=await this.client;return e.connect()}async close(e=false){if(!this.closing){const t=this.status;this.status="closing";this.closing=true;try{if(t==="ready"){await this.initializing}if(!this.extraOptions.shared){if(t=="initializing"||e){this._client.disconnect()}else{await this._client.quit()}this._client["status"]="end"}}catch(e){if((0,o.isNotConnectionError)(e)){throw e}}finally{this._client.off("error",this.handleClientError);this._client.off("close",this.handleClientClose);this._client.off("ready",this.handleClientReady);(0,o.decreaseMaxListeners)(this._client,3);this.removeAllListeners();this.status="closed"}}}async getRedisVersion(){if(this.skipVersionCheck){return RedisConnection.minimumVersion}const e=await this._client.info();const t="redis_version:";const n="maxmemory_policy:";const r=e.split(/\r?\n/);let i;for(let e=0;e<r.length;e++){if(r[e].indexOf(n)===0){const t=r[e].substr(n.length);if(t!=="noeviction"){console.warn(`IMPORTANT! Eviction policy is ${t}. It should be "noeviction"`)}}if(r[e].indexOf(t)===0){i=r[e].substr(t.length)}}return i}get redisVersion(){return this.version}}t.RedisConnection=RedisConnection;RedisConnection.minimumVersion="5.0.0";RedisConnection.recommendedMinimumVersion="6.2.0"},9454:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getNextMillis=t.Repeat=void 0;const r=n(1577);const i=n(9912);const a=n(6982);const s=n(4982);class Repeat extends s.QueueBase{constructor(e,n,r){super(e,n,r);this.repeatStrategy=n.settings&&n.settings.repeatStrategy||t.getNextMillis;this.repeatKeyHashAlgorithm=n.settings&&n.settings.repeatKeyHashAlgorithm||"md5"}async updateRepeatableJob(e,t,n,{override:i}){var a,s;const o=Object.assign({},n.repeat);(a=o.pattern)!==null&&a!==void 0?a:o.pattern=o.cron;delete o.cron;const l=o.count?o.count+1:1;if(typeof o.limit!=="undefined"&&l>o.limit){return}let c=Date.now();const{endDate:d}=o;if(d&&c>new Date(d).getTime()){return}const u=n.prevMillis||0;c=u<c?c:u;const p=await this.repeatStrategy(c,o,e);const{every:f,pattern:h}=o;const y=Boolean((f||h)&&o.immediately);const m=y&&f?c-p:undefined;if(p){if(!u&&n.jobId){o.jobId=n.jobId}const a=getRepeatConcatOptions(e,o);const c=(s=n.repeat.key)!==null&&s!==void 0?s:this.hash(a);let b;if(i){b=await this.scripts.addRepeatableJob(c,p,{name:e,endDate:d?new Date(d).getTime():undefined,tz:o.tz,pattern:h,every:f},a)}else{const e=await this.client;b=await this.scripts.updateRepeatableJobMillis(e,c,p,a)}const{immediately:g}=o,v=r.__rest(o,["immediately"]);return this.createNextJob(e,p,b,Object.assign(Object.assign({},n),{repeat:Object.assign({offset:m},v)}),t,l,y)}}async createNextJob(e,t,n,r,i,a,s){const o=this.getRepeatJobKey(e,t,n,i);const l=Date.now();const c=t+(r.repeat.offset?r.repeat.offset:0)-l;const d=Object.assign(Object.assign({},r),{jobId:o,delay:c<0||s?0:c,timestamp:l,prevMillis:t,repeatJobKey:n});d.repeat=Object.assign(Object.assign({},r.repeat),{count:a});return this.Job.create(this,e,i,d)}getRepeatJobKey(e,t,n,r){if(n.split(":").length>2){return this.getRepeatJobId({name:e,nextMillis:t,namespace:this.hash(n),jobId:r===null||r===void 0?void 0:r.id})}return this.getRepeatDelayedJobId({customKey:n,nextMillis:t})}async removeRepeatable(e,t,n){var r;const i=getRepeatConcatOptions(e,Object.assign(Object.assign({},t),{jobId:n}));const a=(r=t.key)!==null&&r!==void 0?r:this.hash(i);const s=this.getRepeatJobId({name:e,nextMillis:"",namespace:this.hash(i),jobId:n!==null&&n!==void 0?n:t.jobId,key:t.key});return this.scripts.removeRepeatable(s,i,a)}async removeRepeatableByKey(e){const t=this.keyToData(e);const n=this.getRepeatJobId({name:t.name,nextMillis:"",namespace:this.hash(e),jobId:t.id});return this.scripts.removeRepeatable(n,"",e)}async getRepeatableData(e,t,n){const r=await e.hgetall(this.toKey("repeat:"+t));if(r){return{key:t,name:r.name,endDate:parseInt(r.endDate)||null,tz:r.tz||null,pattern:r.pattern||null,every:r.every||null,next:n}}return this.keyToData(t,n)}keyToData(e,t){const n=e.split(":");const r=n.slice(4).join(":")||null;return{key:e,name:n[0],id:n[1]||null,endDate:parseInt(n[2])||null,tz:n[3]||null,pattern:r,next:t}}async getRepeatableJobs(e=0,t=-1,n=false){const r=await this.client;const i=this.keys.repeat;const a=n?await r.zrange(i,e,t,"WITHSCORES"):await r.zrevrange(i,e,t,"WITHSCORES");const s=[];for(let e=0;e<a.length;e+=2){s.push(this.getRepeatableData(r,a[e],parseInt(a[e+1])))}return Promise.all(s)}async getRepeatableCount(){const e=await this.client;return e.zcard(this.toKey("repeat"))}hash(e){return(0,a.createHash)(this.repeatKeyHashAlgorithm).update(e).digest("hex")}getRepeatDelayedJobId({nextMillis:e,customKey:t}){return`repeat:${t}:${e}`}getRepeatJobId({name:e,nextMillis:t,namespace:n,jobId:r,key:i}){const a=i!==null&&i!==void 0?i:this.hash(`${e}${r||""}${n}`);return`repeat:${a}:${t}`}}t.Repeat=Repeat;function getRepeatConcatOptions(e,t){const n=t.endDate?new Date(t.endDate).getTime():"";const r=t.tz||"";const i=t.pattern;const a=(i?i:String(t.every))||"";const s=t.jobId?t.jobId:"";return`${e}:${s}:${n}:${r}:${a}`}const getNextMillis=(e,t)=>{const n=t.pattern;if(n&&t.every){throw new Error("Both .pattern and .every options are defined for this repeatable job")}if(t.every){return Math.floor(e/t.every)*t.every+(t.immediately?0:t.every)}const r=t.startDate&&new Date(t.startDate)>new Date(e)?new Date(t.startDate):new Date(e);const a=(0,i.parseExpression)(n,Object.assign(Object.assign({},t),{currentDate:r}));try{if(t.immediately){return(new Date).getTime()}else{return a.next().getTime()}}catch(e){}};t.getNextMillis=getNextMillis},1558:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(6991);const sandbox=(e,t)=>async function process(n,i){let a;let s;let o;try{const l=new Promise(((l,c)=>{const initChild=async()=>{try{o=(e,t)=>{c(new Error("Unexpected exit code: "+e+" signal: "+t))};a=await t.retain(e);a.on("exit",o);s=async e=>{var t,i,s;try{switch(e.cmd){case r.ParentCommand.Completed:l(e.value);break;case r.ParentCommand.Failed:case r.ParentCommand.Error:{const t=new Error;Object.assign(t,e.value);c(t);break}case r.ParentCommand.Progress:await n.updateProgress(e.value);break;case r.ParentCommand.Log:await n.log(e.value);break;case r.ParentCommand.MoveToDelayed:await n.moveToDelayed((t=e.value)===null||t===void 0?void 0:t.timestamp,(i=e.value)===null||i===void 0?void 0:i.token);break;case r.ParentCommand.MoveToWait:await n.moveToWait((s=e.value)===null||s===void 0?void 0:s.token);break;case r.ParentCommand.Update:await n.updateData(e.value);break;case r.ParentCommand.GetChildrenValues:{const t=await n.getChildrenValues();a.send({requestId:e.requestId,cmd:r.ChildCommand.GetChildrenValuesResponse,value:t})}break;case r.ParentCommand.GetIgnoredChildrenFailures:{const t=await n.getIgnoredChildrenFailures();a.send({requestId:e.requestId,cmd:r.ChildCommand.GetIgnoredChildrenFailuresResponse,value:t})}break}}catch(e){c(e)}};a.on("message",s);a.send({cmd:r.ChildCommand.Start,job:n.asJSONSandbox(),token:i})}catch(e){c(e)}};initChild()}));await l;return l}finally{if(a){a.off("message",s);a.off("exit",o);if(a.exitCode===null&&a.signalCode===null){t.release(a)}}}};t["default"]=sandbox},5249:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.raw2NextJobData=t.Scripts=void 0;const r=n(7687);const i=new r.Packr({useRecords:false,encodeUndefinedAsNil:true});const a=i.pack;const s=n(6991);const o=n(8547);const l=n(6614);class Scripts{constructor(e){this.queue=e;this.version=l.version;const t=this.queue.keys;this.moveToFinishedKeys=[t.wait,t.active,t.prioritized,t.events,t.stalled,t.limiter,t.delayed,t.paused,t.meta,t.pc,undefined,undefined,undefined,undefined]}execCommand(e,t,n){const r=`${t}:${this.version}`;return e[r](n)}async isJobInList(e,t){const n=await this.queue.client;let r;if((0,o.isRedisVersionLowerThan)(this.queue.redisVersion,"6.0.6")){r=await this.execCommand(n,"isJobInList",[e,t])}else{r=await n.lpos(e,t)}return Number.isInteger(r)}addDelayedJobArgs(e,t,n){const r=this.queue.keys;const i=[r.marker,r.meta,r.id,r.delayed,r.completed,r.events];i.push(a(n),e.data,t);return i}addDelayedJob(e,t,n,r){const i=this.addDelayedJobArgs(t,n,r);return this.execCommand(e,"addDelayedJob",i)}addPrioritizedJobArgs(e,t,n){const r=this.queue.keys;const i=[r.marker,r.meta,r.id,r.prioritized,r.delayed,r.completed,r.active,r.events,r.pc];i.push(a(n),e.data,t);return i}addPrioritizedJob(e,t,n,r){const i=this.addPrioritizedJobArgs(t,n,r);return this.execCommand(e,"addPrioritizedJob",i)}addParentJobArgs(e,t,n){const r=this.queue.keys;const i=[r.meta,r.id,r.delayed,r.completed,r.events];i.push(a(n),e.data,t);return i}addParentJob(e,t,n,r){const i=this.addParentJobArgs(t,n,r);return this.execCommand(e,"addParentJob",i)}addStandardJobArgs(e,t,n){const r=this.queue.keys;const i=[r.wait,r.paused,r.meta,r.id,r.completed,r.delayed,r.active,r.events,r.marker];i.push(a(n),e.data,t);return i}addStandardJob(e,t,n,r){const i=this.addStandardJobArgs(t,n,r);return this.execCommand(e,"addStandardJob",i)}async addJob(e,t,n,r,i={}){const s=this.queue.keys;const o=t.parent;const l=[s[""],typeof r!=="undefined"?r:"",t.name,t.timestamp,t.parentKey||null,i.waitChildrenKey||null,i.parentDependenciesKey||null,o,t.repeatJobKey,t.deduplicationId?`${s.de}:${t.deduplicationId}`:null];let c;if(n.repeat){const e=Object.assign({},n.repeat);if(e.startDate){e.startDate=+new Date(e.startDate)}if(e.endDate){e.endDate=+new Date(e.endDate)}c=a(Object.assign(Object.assign({},n),{repeat:e}))}else{c=a(n)}let d;if(i.waitChildrenKey){d=await this.addParentJob(e,t,c,l)}else if(typeof n.delay=="number"&&n.delay>0){d=await this.addDelayedJob(e,t,c,l)}else if(n.priority){d=await this.addPrioritizedJob(e,t,c,l)}else{d=await this.addStandardJob(e,t,c,l)}if(d<0){throw this.finishedErrors({code:d,parentKey:i.parentKey,command:"addJob"})}return d}pauseArgs(e){let t="wait",n="paused";if(!e){t="paused";n="wait"}const r=[t,n,"meta","prioritized"].map((e=>this.queue.toKey(e)));r.push(this.queue.keys.events,this.queue.keys.delayed,this.queue.keys.marker);const i=[e?"paused":"resumed"];return r.concat(i)}async pause(e){const t=await this.queue.client;const n=this.pauseArgs(e);return this.execCommand(t,"pause",n)}addRepeatableJobArgs(e,t,n,r){const i=this.queue.keys;const s=[i.repeat,i.delayed];const o=[t,a(n),r,e,i[""]];return s.concat(o)}async addRepeatableJob(e,t,n,r){const i=await this.queue.client;const a=this.addRepeatableJobArgs(e,t,n,r);return this.execCommand(i,"addRepeatableJob",a)}async addJobScheduler(e,t,n,r,i,s,o){const l=await this.queue.client;const c=this.queue.keys;const d=[c.repeat,c.delayed,c.wait,c.paused,c.meta,c.prioritized,c.marker,c.id,c.events,c.pc,c.active];const u=[t,a(i),e,n,a(r),a(s),Date.now(),c[""],o?this.queue.toKey(o):""];return this.execCommand(l,"addJobScheduler",d.concat(u))}async updateRepeatableJobMillis(e,t,n,r){const i=[this.queue.keys.repeat,n,t,r];return this.execCommand(e,"updateRepeatableJobMillis",i)}async updateJobSchedulerNextMillis(e,t,n,r,i){const s=await this.queue.client;const o=this.queue.keys;const l=[o.repeat,o.delayed,o.wait,o.paused,o.meta,o.prioritized,o.marker,o.id,o.events,o.pc,i?this.queue.toKey(i):"",o.active];const c=[t,e,n,a(r),Date.now(),o[""],i];return this.execCommand(s,"updateJobScheduler",l.concat(c))}removeRepeatableArgs(e,t,n){const r=this.queue.keys;const i=[r.repeat,r.delayed,r.events];const a=[e,this.getRepeatConcatOptions(t,n),n,r[""]];return i.concat(a)}getRepeatConcatOptions(e,t){if(t&&t.split(":").length>2){return t}return e}async removeRepeatable(e,t,n){const r=await this.queue.client;const i=this.removeRepeatableArgs(e,t,n);return this.execCommand(r,"removeRepeatable",i)}async removeJobScheduler(e){const t=await this.queue.client;const n=this.queue.keys;const r=[n.repeat,n.delayed,n.events];const i=[e,n[""]];return this.execCommand(t,"removeJobScheduler",r.concat(i))}removeArgs(e,t){const n=[e,"repeat"].map((e=>this.queue.toKey(e)));const r=[e,t?1:0,this.queue.toKey("")];return n.concat(r)}async remove(e,t){const n=await this.queue.client;const r=this.removeArgs(e,t);const i=await this.execCommand(n,"removeJob",r);if(i<0){throw this.finishedErrors({code:i,jobId:e,command:"removeJob"})}return i}async removeUnprocessedChildren(e){const t=await this.queue.client;const n=[this.queue.toKey(e),this.queue.keys.meta,this.queue.toKey(""),e];await this.execCommand(t,"removeUnprocessedChildren",n)}async extendLock(e,t,n,r){r=r||await this.queue.client;const i=[this.queue.toKey(e)+":lock",this.queue.keys.stalled,t,n,e];return this.execCommand(r,"extendLock",i)}async extendLocks(e,t,n){const r=await this.queue.client;const i=[this.queue.keys.stalled,this.queue.toKey(""),a(t),a(e),n];return this.execCommand(r,"extendLocks",i)}async updateData(e,t){const n=await this.queue.client;const r=[this.queue.toKey(e.id)];const i=JSON.stringify(t);const a=await this.execCommand(n,"updateData",r.concat([i]));if(a<0){throw this.finishedErrors({code:a,jobId:e.id,command:"updateData"})}}async updateProgress(e,t){const n=await this.queue.client;const r=[this.queue.toKey(e),this.queue.keys.events,this.queue.keys.meta];const i=JSON.stringify(t);const a=await this.execCommand(n,"updateProgress",r.concat([e,i]));if(a<0){throw this.finishedErrors({code:a,jobId:e,command:"updateProgress"})}}async addLog(e,t,n){const r=await this.queue.client;const i=[this.queue.toKey(e),this.queue.toKey(e)+":logs"];const a=await this.execCommand(r,"addLog",i.concat([e,t,n?n:""]));if(a<0){throw this.finishedErrors({code:a,jobId:e,command:"addLog"})}return a}moveToFinishedArgs(e,t,n,r,i,s,l,c=true,d){var u,p,f,h,y,m,b;const g=this.queue.keys;const v=this.queue.opts;const K=i==="completed"?v.removeOnComplete:v.removeOnFail;const S=this.queue.toKey(`metrics:${i}`);const E=this.moveToFinishedKeys;E[10]=g[i];E[11]=this.queue.toKey((u=e.id)!==null&&u!==void 0?u:"");E[12]=S;E[13]=this.queue.keys.marker;const k=this.getKeepJobs(r,K);const I=[e.id,l,n,typeof t==="undefined"?"null":t,i,!c||this.queue.closing?0:1,g[""],a({token:s,name:v.name,keepJobs:k,limiter:v.limiter,lockDuration:v.lockDuration,attempts:e.opts.attempts,maxMetricsSize:((p=v.metrics)===null||p===void 0?void 0:p.maxDataPoints)?(f=v.metrics)===null||f===void 0?void 0:f.maxDataPoints:"",fpof:!!((h=e.opts)===null||h===void 0?void 0:h.failParentOnFailure),cpof:!!((y=e.opts)===null||y===void 0?void 0:y.continueParentOnFailure),idof:!!((m=e.opts)===null||m===void 0?void 0:m.ignoreDependencyOnFailure),rdof:!!((b=e.opts)===null||b===void 0?void 0:b.removeDependencyOnFailure)}),d?a((0,o.objectToFlatArray)(d)):void 0];return E.concat(I)}getKeepJobs(e,t){if(typeof e==="undefined"){return t||{count:e?0:-1}}return typeof e==="object"?e:typeof e==="number"?{count:e}:{count:e?0:-1}}async moveToFinished(e,t){const n=await this.queue.client;const r=await this.execCommand(n,"moveToFinished",t);if(r<0){throw this.finishedErrors({code:r,jobId:e,command:"moveToFinished",state:"active"})}else{if(typeof r!=="undefined"){return raw2NextJobData(r)}}}drainArgs(e){const t=this.queue.keys;const n=[t.wait,t.paused,t.delayed,t.prioritized,t.repeat];const r=[t[""],e?"1":"0"];return n.concat(r)}async drain(e){const t=await this.queue.client;const n=this.drainArgs(e);return this.execCommand(t,"drain",n)}removeChildDependencyArgs(e,t){const n=this.queue.keys;const r=[n[""]];const i=[this.queue.toKey(e),t];return r.concat(i)}async removeChildDependency(e,t){const n=await this.queue.client;const r=this.removeChildDependencyArgs(e,t);const i=await this.execCommand(n,"removeChildDependency",r);switch(i){case 0:return true;case 1:return false;default:throw this.finishedErrors({code:i,jobId:e,parentKey:t,command:"removeChildDependency"})}}getRangesArgs(e,t,n,r){const i=this.queue.keys;const a=e.map((e=>e==="waiting"?"wait":e));const s=[i[""]];const o=[t,n,r?"1":"0",...a];return s.concat(o)}async getRanges(e,t=0,n=1,r=false){const i=await this.queue.client;const a=this.getRangesArgs(e,t,n,r);return await this.execCommand(i,"getRanges",a)}getCountsArgs(e){const t=this.queue.keys;const n=e.map((e=>e==="waiting"?"wait":e));const r=[t[""]];const i=[...n];return r.concat(i)}async getCounts(e){const t=await this.queue.client;const n=this.getCountsArgs(e);return await this.execCommand(t,"getCounts",n)}getCountsPerPriorityArgs(e){const t=[this.queue.keys.wait,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.prioritized];const n=e;return t.concat(n)}async getCountsPerPriority(e){const t=await this.queue.client;const n=this.getCountsPerPriorityArgs(e);return await this.execCommand(t,"getCountsPerPriority",n)}getDependencyCountsArgs(e,t){const n=[`${e}:processed`,`${e}:dependencies`,`${e}:failed`,`${e}:unsuccessful`].map((e=>this.queue.toKey(e)));const r=t;return n.concat(r)}async getDependencyCounts(e,t){const n=await this.queue.client;const r=this.getDependencyCountsArgs(e,t);return await this.execCommand(n,"getDependencyCounts",r)}moveToCompletedArgs(e,t,n,r,i=false){const a=Date.now();return this.moveToFinishedArgs(e,t,"returnvalue",n,"completed",r,a,i)}moveToFailedArgs(e,t,n,r,i=false,a){const s=Date.now();return this.moveToFinishedArgs(e,t,"failedReason",n,"failed",r,s,i,a)}async isFinished(e,t=false){const n=await this.queue.client;const r=["completed","failed",e].map((e=>this.queue.toKey(e)));return this.execCommand(n,"isFinished",r.concat([e,t?"1":""]))}async getState(e){const t=await this.queue.client;const n=["completed","failed","delayed","active","wait","paused","waiting-children","prioritized"].map((e=>this.queue.toKey(e)));if((0,o.isRedisVersionLowerThan)(this.queue.redisVersion,"6.0.6")){return this.execCommand(t,"getState",n.concat([e]))}return this.execCommand(t,"getStateV2",n.concat([e]))}async changeDelay(e,t){const n=await this.queue.client;const r=this.changeDelayArgs(e,t);const i=await this.execCommand(n,"changeDelay",r);if(i<0){throw this.finishedErrors({code:i,jobId:e,command:"changeDelay",state:"delayed"})}}changeDelayArgs(e,t){const n=Date.now();const r=[this.queue.keys.delayed,this.queue.keys.meta,this.queue.keys.marker,this.queue.keys.events];return r.concat([t,JSON.stringify(n),e,this.queue.toKey(e)])}async changePriority(e,t=0,n=false){const r=await this.queue.client;const i=this.changePriorityArgs(e,t,n);const a=await this.execCommand(r,"changePriority",i);if(a<0){throw this.finishedErrors({code:a,jobId:e,command:"changePriority"})}}changePriorityArgs(e,t=0,n=false){const r=[this.queue.keys.wait,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.prioritized,this.queue.keys.active,this.queue.keys.pc,this.queue.keys.marker];return r.concat([t,this.queue.toKey(""),e,n?1:0])}moveToDelayedArgs(e,t,n,r,i={}){const s=this.queue.keys;const l=[s.marker,s.active,s.prioritized,s.delayed,this.queue.toKey(e),s.events,s.meta,s.stalled];return l.concat([this.queue.keys[""],t,e,n,r,i.skipAttempt?"1":"0",i.fieldsToUpdate?a((0,o.objectToFlatArray)(i.fieldsToUpdate)):void 0])}moveToWaitingChildrenArgs(e,t,n){const r=Date.now();const i=(0,o.getParentKey)(n.child);const a=["active","waiting-children",e,`${e}:dependencies`,`${e}:unsuccessful`,"stalled","failed","events"].map((e=>this.queue.toKey(e)));return a.concat([t,i!==null&&i!==void 0?i:"",JSON.stringify(r),e,this.queue.toKey("")])}isMaxedArgs(){const e=this.queue.keys;const t=[e.meta,e.active];return t}async isMaxed(){const e=await this.queue.client;const t=this.isMaxedArgs();return!!await this.execCommand(e,"isMaxed",t)}async moveToDelayed(e,t,n,r="0",i={}){const a=await this.queue.client;const s=this.moveToDelayedArgs(e,t,r,n,i);const o=await this.execCommand(a,"moveToDelayed",s);if(o<0){throw this.finishedErrors({code:o,jobId:e,command:"moveToDelayed",state:"active"})}}async moveToWaitingChildren(e,t,n={}){const r=await this.queue.client;const i=this.moveToWaitingChildrenArgs(e,t,n);const a=await this.execCommand(r,"moveToWaitingChildren",i);switch(a){case 0:return true;case 1:return false;default:throw this.finishedErrors({code:a,jobId:e,command:"moveToWaitingChildren",state:"active"})}}getRateLimitTtlArgs(e){const t=[this.queue.keys.limiter];return t.concat([e!==null&&e!==void 0?e:"0"])}async getRateLimitTtl(e){const t=await this.queue.client;const n=this.getRateLimitTtlArgs(e);return this.execCommand(t,"getRateLimitTtl",n)}async cleanJobsInSet(e,t,n=0){const r=await this.queue.client;return this.execCommand(r,"cleanJobsInSet",[this.queue.toKey(e),this.queue.toKey("events"),this.queue.toKey("repeat"),this.queue.toKey(""),t,n,e])}getJobSchedulerArgs(e){const t=[this.queue.keys.repeat];return t.concat([e])}async getJobScheduler(e){const t=await this.queue.client;const n=this.getJobSchedulerArgs(e);return this.execCommand(t,"getJobScheduler",n)}retryJobArgs(e,t,n,r={}){const i=[this.queue.keys.active,this.queue.keys.wait,this.queue.keys.paused,this.queue.toKey(e),this.queue.keys.meta,this.queue.keys.events,this.queue.keys.delayed,this.queue.keys.prioritized,this.queue.keys.pc,this.queue.keys.marker,this.queue.keys.stalled];const s=(t?"R":"L")+"PUSH";return i.concat([this.queue.toKey(""),Date.now(),s,e,n,r.fieldsToUpdate?a((0,o.objectToFlatArray)(r.fieldsToUpdate)):void 0])}async retryJob(e,t,n="0",r={}){const i=await this.queue.client;const a=this.retryJobArgs(e,t,n,r);const s=await this.execCommand(i,"retryJob",a);if(s<0){throw this.finishedErrors({code:s,jobId:e,command:"retryJob",state:"active"})}}moveJobsToWaitArgs(e,t,n){const r=[this.queue.toKey(""),this.queue.keys.events,this.queue.toKey(e),this.queue.toKey("wait"),this.queue.toKey("paused"),this.queue.keys.meta,this.queue.keys.active,this.queue.keys.marker];const i=[t,n,e];return r.concat(i)}async retryJobs(e="failed",t=1e3,n=(new Date).getTime()){const r=await this.queue.client;const i=this.moveJobsToWaitArgs(e,t,n);return this.execCommand(r,"moveJobsToWait",i)}async promoteJobs(e=1e3){const t=await this.queue.client;const n=this.moveJobsToWaitArgs("delayed",e,Number.MAX_VALUE);return this.execCommand(t,"moveJobsToWait",n)}async reprocessJob(e,t){const n=await this.queue.client;const r=[this.queue.toKey(e.id),this.queue.keys.events,this.queue.toKey(t),this.queue.keys.wait,this.queue.keys.meta,this.queue.keys.paused,this.queue.keys.active,this.queue.keys.marker];const i=[e.id,(e.opts.lifo?"R":"L")+"PUSH",t==="failed"?"failedReason":"returnvalue",t];const a=await this.execCommand(n,"reprocessJob",r.concat(i));switch(a){case 1:return;default:throw this.finishedErrors({code:a,jobId:e.id,command:"reprocessJob",state:t})}}async moveToActive(e,t,n){const r=this.queue.opts;const i=this.queue.keys;const s=[i.wait,i.active,i.prioritized,i.events,i.stalled,i.limiter,i.delayed,i.paused,i.meta,i.pc,i.marker];const o=[i[""],Date.now(),a({token:t,lockDuration:r.lockDuration,limiter:r.limiter,name:n})];const l=await this.execCommand(e,"moveToActive",s.concat(o));return raw2NextJobData(l)}async promote(e){const t=await this.queue.client;const n=[this.queue.keys.delayed,this.queue.keys.wait,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.prioritized,this.queue.keys.active,this.queue.keys.pc,this.queue.keys.events,this.queue.keys.marker];const r=[this.queue.toKey(""),e];const i=await this.execCommand(t,"promote",n.concat(r));if(i<0){throw this.finishedErrors({code:i,jobId:e,command:"promote",state:"delayed"})}}moveStalledJobsToWaitArgs(){const e=this.queue.opts;const t=[this.queue.keys.stalled,this.queue.keys.wait,this.queue.keys.active,this.queue.keys["stalled-check"],this.queue.keys.meta,this.queue.keys.paused,this.queue.keys.marker,this.queue.keys.events];const n=[e.maxStalledCount,this.queue.toKey(""),Date.now(),e.stalledInterval];return t.concat(n)}async moveStalledJobsToWait(){const e=await this.queue.client;const t=this.moveStalledJobsToWaitArgs();return this.execCommand(e,"moveStalledJobsToWait",t)}async moveJobFromActiveToWait(e,t="0"){const n=await this.queue.client;const r=[this.queue.keys.active,this.queue.keys.wait,this.queue.keys.stalled,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.limiter,this.queue.keys.prioritized,this.queue.keys.marker,this.queue.keys.events];const i=[e,t,this.queue.toKey(e)];const a=await this.execCommand(n,"moveJobFromActiveToWait",r.concat(i));if(a<0){throw this.finishedErrors({code:a,jobId:e,command:"moveJobFromActiveToWait",state:"active"})}return a}async obliterate(e){const t=await this.queue.client;const n=[this.queue.keys.meta,this.queue.toKey("")];const r=[e.count,e.force?"force":null];const i=await this.execCommand(t,"obliterate",n.concat(r));if(i<0){switch(i){case-1:throw new Error("Cannot obliterate non-paused queue");case-2:throw new Error("Cannot obliterate queue with active jobs")}}return i}async paginate(e,t){const n=await this.queue.client;const r=[e];const i=5;const a=t.end>=0?t.end-t.start+1:Infinity;let s="0",l=0,c,d,u,p=[],f=[];do{const e=[t.start+p.length,t.end,s,l,i];if(t.fetchJobs){e.push(1)}[s,l,c,d,u]=await this.execCommand(n,"paginate",r.concat(e));p=p.concat(c);if(u&&u.length){f=f.concat(u.map(o.array2obj))}}while(s!="0"&&p.length<a);if(p.length&&Array.isArray(p[0])){const e=[];for(let t=0;t<p.length;t++){const[n,r]=p[t];try{e.push({id:n,v:JSON.parse(r)})}catch(t){e.push({id:n,err:t.message})}}return{cursor:s,items:e,total:d,jobs:f}}else{return{cursor:s,items:p.map((e=>({id:e}))),total:d,jobs:f}}}finishedErrors({code:e,jobId:t,parentKey:n,command:r,state:i}){switch(e){case s.ErrorCode.JobNotExist:return new Error(`Missing key for job ${t}. ${r}`);case s.ErrorCode.JobLockNotExist:return new Error(`Missing lock for job ${t}. ${r}`);case s.ErrorCode.JobNotInState:return new Error(`Job ${t} is not in the ${i} state. ${r}`);case s.ErrorCode.JobPendingChildren:return new Error(`Job ${t} has pending dependencies. ${r}`);case s.ErrorCode.ParentJobNotExist:return new Error(`Missing key for parent job ${n}. ${r}`);case s.ErrorCode.JobLockMismatch:return new Error(`Lock mismatch for job ${t}. Cmd ${r} from ${i}`);case s.ErrorCode.ParentJobCannotBeReplaced:return new Error(`The parent job ${n} cannot be replaced. ${r}`);case s.ErrorCode.JobBelongsToJobScheduler:return new Error(`Job ${t} belongs to a job scheduler and cannot be removed directly. ${r}`);case s.ErrorCode.JobFailedChildren:return new Error(`Job ${t} has failed children. ${r}`);default:return new Error(`Unknown code ${e} error for ${t}. ${r}`)}}}t.Scripts=Scripts;function raw2NextJobData(e){if(e){const t=[null,e[1],e[2],e[3]];if(e[0]){t[0]=(0,o.array2obj)(e[0])}return t}return[]}t.raw2NextJobData=raw2NextJobData},7923:function(e,t,n){"use strict";e=n.nmd(e);Object.defineProperty(t,"__esModule",{value:true});t.Worker=void 0;const r=n(9896);const i=n(7016);const a=n(6928);const s=n(9935);const o=n(221);const l=n(8547);const c=n(4982);const d=n(9454);const u=n(2622);const p=n(6595);const f=n(1558);const h=n(8158);const y=n(2877);const m=n(6991);const b=n(6830);const g=10;const v=3e4;class Worker extends c.QueueBase{static RateLimitError(){return new y.RateLimitError}constructor(t,n,o,c){super(t,Object.assign(Object.assign({drainDelay:5,concurrency:1,lockDuration:3e4,maxStalledCount:1,stalledInterval:3e4,autorun:true,runRetryDelay:15e3},o),{blockingConnection:true}),c);this.abortDelayController=null;this.blockUntil=0;this.drained=false;this.extendLocksTimer=null;this.limitUntil=0;this.waiting=null;this.running=false;this.mainLoopRunning=null;if(!o||!o.connection){throw new Error("Worker requires a connection")}if(typeof this.opts.maxStalledCount!=="number"||this.opts.maxStalledCount<0){throw new Error("maxStalledCount must be greater or equal than 0")}if(typeof this.opts.stalledInterval!=="number"||this.opts.stalledInterval<=0){throw new Error("stalledInterval must be greater than 0")}if(typeof this.opts.drainDelay!=="number"||this.opts.drainDelay<=0){throw new Error("drainDelay must be greater than 0")}this.concurrency=this.opts.concurrency;this.opts.lockRenewTime=this.opts.lockRenewTime||this.opts.lockDuration/2;this.id=(0,s.v4)();if(n){if(typeof n==="function"){this.processFn=n}else{if(n instanceof i.URL){if(!r.existsSync(n)){throw new Error(`URL ${n} does not exist in the local file system`)}n=n.href}else{const e=[".js",".ts",".flow",".cjs"];const t=n+(e.includes(a.extname(n))?"":".js");if(!r.existsSync(t)){throw new Error(`File ${t} does not exist`)}}const t=a.dirname(e.filename||__filename);const s=a.join(t,"main-worker.js");const o=a.join(t,"main.js");let l=this.opts.useWorkerThreads?s:o;try{r.statSync(l)}catch(e){const t=this.opts.useWorkerThreads?"main-worker.js":"main.js";l=a.join(process.cwd(),`dist/cjs/classes/${t}`);r.statSync(l)}this.childPool=new u.ChildPool({mainFile:l,useWorkerThreads:this.opts.useWorkerThreads,workerForkOptions:this.opts.workerForkOptions,workerThreadsOptions:this.opts.workerThreadsOptions});this.processFn=(0,f.default)(n,this.childPool).bind(this)}if(this.opts.autorun){this.run().catch((e=>this.emit("error",e)))}}const d=this.clientName()+(this.opts.name?`:w:${this.opts.name}`:"");this.blockingConnection=new p.RedisConnection((0,l.isRedisInstance)(o.connection)?o.connection.duplicate({connectionName:d}):Object.assign(Object.assign({},o.connection),{connectionName:d}),{shared:false,blocking:true,skipVersionCheck:o.skipVersionCheck});this.blockingConnection.on("error",(e=>this.emit("error",e)));this.blockingConnection.on("ready",(()=>setTimeout((()=>this.emit("ready")),0)))}emit(e,...t){return super.emit(e,...t)}off(e,t){super.off(e,t);return this}on(e,t){super.on(e,t);return this}once(e,t){super.once(e,t);return this}callProcessJob(e,t){return this.processFn(e,t)}createJob(e,t){return this.Job.fromJSON(this,e,t)}async waitUntilReady(){await super.waitUntilReady();return this.blockingConnection.client}set concurrency(e){if(typeof e!=="number"||e<1||!isFinite(e)){throw new Error("concurrency must be a finite number greater than 0")}this._concurrency=e}get concurrency(){return this._concurrency}get repeat(){return new Promise((async e=>{if(!this._repeat){const e=await this.client;this._repeat=new d.Repeat(this.name,Object.assign(Object.assign({},this.opts),{connection:e}));this._repeat.on("error",(e=>this.emit.bind(this,e)))}e(this._repeat)}))}get jobScheduler(){return new Promise((async e=>{if(!this._jobScheduler){const e=await this.client;this._jobScheduler=new b.JobScheduler(this.name,Object.assign(Object.assign({},this.opts),{connection:e}));this._jobScheduler.on("error",(e=>this.emit.bind(this,e)))}e(this._jobScheduler)}))}async run(){if(!this.processFn){throw new Error("No process function is defined.")}if(this.running){throw new Error("Worker is already running.")}try{this.running=true;if(this.closing||this.paused){return}await this.startStalledCheckTimer();const e=await this.client;const t=await this.blockingConnection.client;this.mainLoopRunning=this.mainLoop(e,t);await this.mainLoopRunning}finally{this.running=false}}async waitForRateLimit(){var e;const t=this.limitUntil;if(t>Date.now()){(e=this.abortDelayController)===null||e===void 0?void 0:e.abort();this.abortDelayController=new o.AbortController;const n=this.getRateLimitDelay(t-Date.now());await this.delay(n,this.abortDelayController)}}async mainLoop(e,t){const n=new h.AsyncFifoQueue;const r=new Set;this.startLockExtenderTimer(r);let i=0;while(!this.closing&&!this.paused){let a=n.numTotal();while(!this.closing&&!this.paused&&!this.waiting&&a<this._concurrency&&!this.isRateLimited()){const r=`${this.id}:${i++}`;const s=this.retryIfFailed((()=>this._getNextJob(e,t,r,{block:true})),this.opts.runRetryDelay);n.add(s);a=n.numTotal();if(this.waiting&&a>1){break}const o=await s;if(!o&&a>1){break}if(this.blockUntil){break}}let s;do{s=await n.fetch()}while(!s&&n.numQueued()>0);if(s){const e=s.token;n.add(this.retryIfFailed((()=>this.processJob(s,e,(()=>n.numTotal()<=this._concurrency),r)),this.opts.runRetryDelay))}else if(n.numQueued()===0){await this.waitForRateLimit()}}return n.waitAll()}async getNextJob(e,{block:t=true}={}){var n,r;const i=await this._getNextJob(await this.client,await this.blockingConnection.client,e,{block:t});return this.trace(m.SpanKind.INTERNAL,"getNextJob",this.name,(async e=>{e===null||e===void 0?void 0:e.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.QueueName]:this.name,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerOptions]:JSON.stringify({block:t}),[m.TelemetryAttributes.JobId]:i===null||i===void 0?void 0:i.id});return i}),(r=(n=i===null||i===void 0?void 0:i.opts)===null||n===void 0?void 0:n.telemetry)===null||r===void 0?void 0:r.metadata)}async _getNextJob(e,t,n,{block:r=true}={}){if(this.paused){return}if(this.closing){return}if(this.drained&&r&&!this.limitUntil&&!this.waiting){this.waiting=this.waitForJob(t,this.blockUntil);try{this.blockUntil=await this.waiting;if(this.blockUntil<=0||this.blockUntil-Date.now()<1){return await this.moveToActive(e,n,this.opts.name)}}catch(e){if(!(this.paused||this.closing)&&(0,l.isNotConnectionError)(e)){throw e}}finally{this.waiting=null}}else{if(!this.isRateLimited()){return this.moveToActive(e,n,this.opts.name)}}}async rateLimit(e){await this.trace(m.SpanKind.INTERNAL,"rateLimit",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerRateLimit]:e});await this.client.then((t=>t.set(this.keys.limiter,Number.MAX_SAFE_INTEGER,"PX",e)))}))}get minimumBlockTimeout(){return this.blockingConnection.capabilities.canBlockFor1Ms?.001:.002}isRateLimited(){return this.limitUntil>Date.now()}async moveToActive(e,t,n){const[r,i,a,s]=await this.scripts.moveToActive(e,t,n);this.updateDelays(a,s);return this.nextJobFromJobData(r,i,t)}async waitForJob(e,t){if(this.paused){return Infinity}let n;try{if(!this.closing&&!this.isRateLimited()){let r=this.getBlockTimeout(t);if(r>0){r=this.blockingConnection.capabilities.canDoubleTimeout?r:Math.ceil(r);n=setTimeout((async()=>{e.disconnect(!this.closing)}),r*1e3+1e3);this.updateDelays();const i=await e.bzpopmin(this.keys.marker,r);if(i){const[e,n,r]=i;if(n){const e=parseInt(r);if(t&&e>t){return t}return e}}}return 0}}catch(e){if((0,l.isNotConnectionError)(e)){this.emit("error",e)}if(!this.closing){await this.delay()}}finally{clearTimeout(n)}return Infinity}getBlockTimeout(e){const t=this.opts;if(e){const t=e-Date.now();if(t<=0){return t}else if(t<this.minimumBlockTimeout*1e3){return this.minimumBlockTimeout}else{return Math.min(t/1e3,g)}}else{return Math.max(t.drainDelay,this.minimumBlockTimeout)}}getRateLimitDelay(e){return Math.min(e,v)}async delay(e,t){await(0,l.delay)(e||l.DELAY_TIME_1,t)}updateDelays(e=0,t=0){const n=Math.max(e,0);if(n>0){this.limitUntil=Date.now()+n}else{this.limitUntil=0}this.blockUntil=Math.max(t,0)||0}async nextJobFromJobData(e,t,n){if(!e){if(!this.drained){this.emit("drained");this.drained=true}}else{this.drained=false;const r=this.createJob(e,t);r.token=n;if(r.opts.repeat&&!r.nextRepeatableJobId){if(r.repeatJobKey){const e=await this.jobScheduler;await e.upsertJobScheduler(r.repeatJobKey,r.opts.repeat,r.name,r.data,r.opts,{override:false,producerId:r.id})}else{const e=await this.repeat;await e.updateRepeatableJob(r.name,r.data,r.opts,{override:false})}}return r}}async processJob(e,t,n=()=>true,r){var i,a;const s=(a=(i=e.opts)===null||i===void 0?void 0:i.telemetry)===null||a===void 0?void 0:a.metadata;return this.trace(m.SpanKind.CONSUMER,"process",this.name,(async i=>{i===null||i===void 0?void 0:i.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.JobId]:e.id});this.emit("active",e,"waiting");const a=Date.now();const s={job:e,ts:a};try{if(e.deferredFailure){const a=await this.handleFailed(new y.UnrecoverableError(e.deferredFailure),e,t,n,r,s,i);return a}r.add(s);const a=await this.callProcessJob(e,t);return await this.handleCompleted(a,e,t,n,r,s,i)}catch(a){const o=await this.handleFailed(a,e,t,n,r,s,i);return o}finally{i===null||i===void 0?void 0:i.setAttributes({[m.TelemetryAttributes.JobFinishedTimestamp]:Date.now(),[m.TelemetryAttributes.JobProcessedTimestamp]:a})}}),s)}async handleCompleted(e,t,n,r=()=>true,i,a,s){i.delete(a);if(!this.connection.closing){const i=await t.moveToCompleted(e,n,r()&&!(this.closing||this.paused));this.emit("completed",t,e,"active");s===null||s===void 0?void 0:s.addEvent("job completed",{[m.TelemetryAttributes.JobResult]:JSON.stringify(e)});const[a,o,l,c]=i||[];this.updateDelays(l,c);return this.nextJobFromJobData(a,o,n)}}async handleFailed(e,t,n,r=()=>true,i,a,s){i.delete(a);if(!this.connection.closing){try{if(e.message==y.RATE_LIMIT_ERROR){const e=await this.moveLimitedBackToWait(t,n);this.limitUntil=e>0?Date.now()+e:0;return}if(e instanceof y.DelayedError||e.name=="DelayedError"||e instanceof y.WaitingError||e.name=="WaitingError"||e instanceof y.WaitingChildrenError||e.name=="WaitingChildrenError"){return}const i=await t.moveToFailed(e,n,r()&&!(this.closing||this.paused));this.emit("failed",t,e,"active");s===null||s===void 0?void 0:s.addEvent("job failed",{[m.TelemetryAttributes.JobFailedReason]:e.message});if(i){const[e,t,r,a]=i;this.updateDelays(r,a);return this.nextJobFromJobData(e,t,n)}}catch(e){this.emit("error",e);s===null||s===void 0?void 0:s.recordException(e.message)}}}async pause(e){await this.trace(m.SpanKind.INTERNAL,"pause",this.name,(async t=>{var n;t===null||t===void 0?void 0:t.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerDoNotWaitActive]:e});if(!this.paused){this.paused=true;await(!e&&this.whenCurrentJobsFinished());(n=this.stalledCheckStopper)===null||n===void 0?void 0:n.call(this);this.emit("paused")}}))}resume(){if(!this.running){this.trace(m.SpanKind.INTERNAL,"resume",this.name,(e=>{e===null||e===void 0?void 0:e.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name});this.paused=false;if(this.processFn){this.run()}this.emit("resumed")}))}}isPaused(){return!!this.paused}isRunning(){return this.running}async close(e=false){if(this.closing){return this.closing}this.closing=(async()=>{await this.trace(m.SpanKind.INTERNAL,"close",this.name,(async t=>{var n,r;t===null||t===void 0?void 0:t.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerForceClose]:e});this.emit("closing","closing queue");(n=this.abortDelayController)===null||n===void 0?void 0:n.abort();const i=[()=>e||this.whenCurrentJobsFinished(false),()=>{var e;return(e=this.childPool)===null||e===void 0?void 0:e.clean()},()=>this.blockingConnection.close(e),()=>this.connection.close(e)];for(const e of i){try{await e()}catch(e){this.emit("error",e)}}clearTimeout(this.extendLocksTimer);(r=this.stalledCheckStopper)===null||r===void 0?void 0:r.call(this);this.closed=true;this.emit("closed")}))})();return await this.closing}async startStalledCheckTimer(){if(!this.opts.skipStalledCheck){if(!this.closing){await this.trace(m.SpanKind.INTERNAL,"startStalledCheckTimer",this.name,(async e=>{e===null||e===void 0?void 0:e.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name});this.stalledChecker().catch((e=>{this.emit("error",e)}))}))}}}async stalledChecker(){while(!(this.closing||this.paused)){try{await this.checkConnectionError((()=>this.moveStalledJobsToWait()))}catch(e){this.emit("error",e)}await new Promise((e=>{const t=setTimeout(e,this.opts.stalledInterval);this.stalledCheckStopper=()=>{clearTimeout(t);e()}}))}}startLockExtenderTimer(e){if(!this.opts.skipLockRenewal){clearTimeout(this.extendLocksTimer);if(!this.closed){this.extendLocksTimer=setTimeout((async()=>{const t=Date.now();const n=[];for(const r of e){const{job:e,ts:i}=r;if(!i){r.ts=t;continue}if(i+this.opts.lockRenewTime/2<t){r.ts=t;n.push(e)}}try{if(n.length){await this.extendLocks(n)}}catch(e){this.emit("error",e)}this.startLockExtenderTimer(e)}),this.opts.lockRenewTime/2)}}}async whenCurrentJobsFinished(e=true){if(this.waiting){await this.blockingConnection.disconnect(e)}else{e=false}if(this.mainLoopRunning){await this.mainLoopRunning}e&&await this.blockingConnection.reconnect()}async retryIfFailed(e,t){const n=1;do{try{return await e()}catch(e){this.emit("error",e);if(t){await this.delay(t)}else{return}}}while(n)}async extendLocks(e){await this.trace(m.SpanKind.INTERNAL,"extendLocks",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerJobsToExtendLocks]:e.map((e=>e.id))});try{const t=await this.scripts.extendLocks(e.map((e=>e.id)),e.map((e=>e.token)),this.opts.lockDuration);for(const e of t){this.emit("error",new Error(`could not renew lock for job ${e}`))}}catch(e){this.emit("error",e)}}))}async moveStalledJobsToWait(){await this.trace(m.SpanKind.INTERNAL,"moveStalledJobsToWait",this.name,(async e=>{const t=await this.scripts.moveStalledJobsToWait();e===null||e===void 0?void 0:e.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerStalledJobs]:t});t.forEach((t=>{e===null||e===void 0?void 0:e.addEvent("job stalled",{[m.TelemetryAttributes.JobId]:t});this.emit("stalled",t,"active")}))}))}moveLimitedBackToWait(e,t){return e.moveToWait(t)}}t.Worker=Worker},6901:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ChildCommand=void 0;var n;(function(e){e[e["Init"]=0]="Init";e[e["Start"]=1]="Start";e[e["Stop"]=2]="Stop";e[e["GetChildrenValuesResponse"]=3]="GetChildrenValuesResponse";e[e["GetIgnoredChildrenFailuresResponse"]=4]="GetIgnoredChildrenFailuresResponse"})(n=t.ChildCommand||(t.ChildCommand={}))},1139:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ErrorCode=void 0;var n;(function(e){e[e["JobNotExist"]=-1]="JobNotExist";e[e["JobLockNotExist"]=-2]="JobLockNotExist";e[e["JobNotInState"]=-3]="JobNotInState";e[e["JobPendingChildren"]=-4]="JobPendingChildren";e[e["ParentJobNotExist"]=-5]="ParentJobNotExist";e[e["JobLockMismatch"]=-6]="JobLockMismatch";e[e["ParentJobCannotBeReplaced"]=-7]="ParentJobCannotBeReplaced";e[e["JobBelongsToJobScheduler"]=-8]="JobBelongsToJobScheduler";e[e["JobFailedChildren"]=-9]="JobFailedChildren"})(n=t.ErrorCode||(t.ErrorCode={}))},6991:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(6901),t);r.__exportStar(n(1139),t);r.__exportStar(n(6231),t);r.__exportStar(n(214),t);r.__exportStar(n(2900),t)},214:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.MetricsTime=void 0;var n;(function(e){e[e["ONE_MINUTE"]=1]="ONE_MINUTE";e[e["FIVE_MINUTES"]=5]="FIVE_MINUTES";e[e["FIFTEEN_MINUTES"]=15]="FIFTEEN_MINUTES";e[e["THIRTY_MINUTES"]=30]="THIRTY_MINUTES";e[e["ONE_HOUR"]=60]="ONE_HOUR";e[e["ONE_WEEK"]=10080]="ONE_WEEK";e[e["TWO_WEEKS"]=20160]="TWO_WEEKS";e[e["ONE_MONTH"]=80640]="ONE_MONTH"})(n=t.MetricsTime||(t.MetricsTime={}))},6231:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ParentCommand=void 0;var n;(function(e){e[e["Completed"]=0]="Completed";e[e["Error"]=1]="Error";e[e["Failed"]=2]="Failed";e[e["InitFailed"]=3]="InitFailed";e[e["InitCompleted"]=4]="InitCompleted";e[e["Log"]=5]="Log";e[e["MoveToDelayed"]=6]="MoveToDelayed";e[e["MoveToWait"]=7]="MoveToWait";e[e["Progress"]=8]="Progress";e[e["Update"]=9]="Update";e[e["GetChildrenValues"]=10]="GetChildrenValues";e[e["GetIgnoredChildrenFailures"]=11]="GetIgnoredChildrenFailures"})(n=t.ParentCommand||(t.ParentCommand={}))},2900:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.SpanKind=t.TelemetryAttributes=void 0;var n;(function(e){e["QueueName"]="bullmq.queue.name";e["QueueOperation"]="bullmq.queue.operation";e["BulkCount"]="bullmq.job.bulk.count";e["BulkNames"]="bullmq.job.bulk.names";e["JobName"]="bullmq.job.name";e["JobId"]="bullmq.job.id";e["JobKey"]="bullmq.job.key";e["JobIds"]="bullmq.job.ids";e["DeduplicationKey"]="bullmq.job.deduplication.key";e["JobOptions"]="bullmq.job.options";e["JobProgress"]="bullmq.job.progress";e["QueueDrainDelay"]="bullmq.queue.drain.delay";e["QueueGrace"]="bullmq.queue.grace";e["QueueCleanLimit"]="bullmq.queue.clean.limit";e["QueueRateLimit"]="bullmq.queue.rate.limit";e["JobType"]="bullmq.job.type";e["QueueOptions"]="bullmq.queue.options";e["QueueEventMaxLength"]="bullmq.queue.event.max.length";e["WorkerOptions"]="bullmq.worker.options";e["WorkerName"]="bullmq.worker.name";e["WorkerId"]="bullmq.worker.id";e["WorkerRateLimit"]="bullmq.worker.rate.limit";e["WorkerDoNotWaitActive"]="bullmq.worker.do.not.wait.active";e["WorkerForceClose"]="bullmq.worker.force.close";e["WorkerStalledJobs"]="bullmq.worker.stalled.jobs";e["WorkerFailedJobs"]="bullmq.worker.failed.jobs";e["WorkerJobsToExtendLocks"]="bullmq.worker.jobs.to.extend.locks";e["JobFinishedTimestamp"]="bullmq.job.finished.timestamp";e["JobProcessedTimestamp"]="bullmq.job.processed.timestamp";e["JobResult"]="bullmq.job.result";e["JobFailedReason"]="bullmq.job.failed.reason";e["FlowName"]="bullmq.flow.name";e["JobSchedulerId"]="bullmq.job.scheduler.id"})(n=t.TelemetryAttributes||(t.TelemetryAttributes={}));var r;(function(e){e[e["INTERNAL"]=0]="INTERNAL";e[e["SERVER"]=1]="SERVER";e[e["CLIENT"]=2]="CLIENT";e[e["PRODUCER"]=3]="PRODUCER";e[e["CONSUMER"]=4]="CONSUMER"})(r=t.SpanKind||(t.SpanKind={}))},8610:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(4601),t);r.__exportStar(n(6991),t);r.__exportStar(n(7111),t);r.__exportStar(n(9560),t);r.__exportStar(n(8547),t)},8034:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8388:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2135:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},6251:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},171:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8677:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7111:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(8034),t);r.__exportStar(n(8388),t);r.__exportStar(n(2135),t);r.__exportStar(n(6251),t);r.__exportStar(n(171),t);r.__exportStar(n(8677),t);r.__exportStar(n(3324),t);r.__exportStar(n(7711),t);r.__exportStar(n(7307),t);r.__exportStar(n(7831),t);r.__exportStar(n(8981),t);r.__exportStar(n(1258),t);r.__exportStar(n(7114),t);r.__exportStar(n(53),t);r.__exportStar(n(7875),t);r.__exportStar(n(8396),t);r.__exportStar(n(4171),t);r.__exportStar(n(2327),t);r.__exportStar(n(4055),t);r.__exportStar(n(6068),t);r.__exportStar(n(2794),t);r.__exportStar(n(3959),t);r.__exportStar(n(2731),t);r.__exportStar(n(9686),t);r.__exportStar(n(3667),t);r.__exportStar(n(7038),t);r.__exportStar(n(1342),t);r.__exportStar(n(112),t);r.__exportStar(n(1538),t)},3324:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7711:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7307:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7831:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8981:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},1258:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7114:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},53:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8396:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7875:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},4171:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ClientType=void 0;var n;(function(e){e["blocking"]="blocking";e["normal"]="normal"})(n=t.ClientType||(t.ClientType={}))},2327:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},1538:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},4055:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},6068:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2731:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2794:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},3959:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9686:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},3667:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7038:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},112:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},1342:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8856:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addDelayedJob=void 0;const n=`--[[\n Adds a delayed job to the queue by doing the following:\n - Increases the job counter if needed.\n - Creates a new job key with the job data.\n - computes timestamp.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n Input:\n KEYS[1] 'marker',\n KEYS[2] 'meta'\n KEYS[3] 'id'\n KEYS[4] 'delayed'\n KEYS[5] 'completed'\n KEYS[6] events stream key\n ARGV[1] msgpacked arguments array\n [1] key prefix,\n [2] custom id (use custom instead of one generated automatically)\n [3] name\n [4] timestamp\n [5] parentKey?\n x [6] waitChildrenKey key.\n [7] parent dependencies key.\n [8] parent? {id, queueKey}\n [9] repeat job key\n [10] deduplication key\n ARGV[2] Json stringified job data\n ARGV[3] msgpacked options\n Output:\n jobId - OK\n -5 - Missing parent key\n]]\nlocal metaKey = KEYS[2]\nlocal idKey = KEYS[3]\nlocal delayedKey = KEYS[4]\nlocal completedKey = KEYS[5]\nlocal eventsKey = KEYS[6]\nlocal jobId\nlocal jobIdKey\nlocal rcall = redis.call\nlocal args = cmsgpack.unpack(ARGV[1])\nlocal data = ARGV[2]\nlocal parentKey = args[5]\nlocal parent = args[8]\nlocal repeatJobKey = args[9]\nlocal deduplicationKey = args[10]\nlocal parentData\n-- Includes\n--[[\n Adds a delayed job to the queue by doing the following:\n - Creates a new job key with the job data.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\nlocal function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,\n maxEvents, markerKey, delay)\n local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay))\n rcall("ZADD", delayedKey, score, jobId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- mark that a delayed job is available\n addDelayMarkerIfNeeded(markerKey, delayedKey)\nend\n--[[\n Function to debounce a job.\n]]\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,\n prefix)\n local deduplicationId = deduplicationOpts and deduplicationOpts['id']\n if deduplicationId then\n local ttl = deduplicationOpts['ttl']\n if deduplicationOpts['replace'] and ttl and ttl > 0 then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n if rcall("ZREM", delayedKey, currentDebounceJobId) > 0 then\n removeJobKeys(prefix .. currentDebounceJobId)\n rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDebounceJobId,\n "prev", "delayed")\n if deduplicationOpts['extend'] then\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n else\n rcall('SET', deduplicationKey, jobId, 'KEEPTTL')\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)\n return\n else\n return currentDebounceJobId\n end\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n local ttl = deduplicationOpts['ttl']\n local deduplicationKeyExists\n if ttl then\n if deduplicationOpts['extend'] then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n rcall('SET', deduplicationKey, currentDebounceJobId, 'PX', ttl)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced",\n "jobId", currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')\n end\n if deduplicationKeyExists then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",\n currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n end\n end\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to handle the case when job is duplicated.\n]]\n-- Includes\n--[[\n This function is used to update the parent's dependencies if the job\n is already completed and about to be ignored. The parent must get its\n dependencies updated to avoid the parent job being stuck forever in \n the waiting-children state.\n]]\n-- Includes\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\nlocal function updateExistingJobsParent(parentKey, parent, parentData,\n parentDependenciesKey, completedKey,\n jobIdKey, jobId, timestamp)\n if parentKey ~= nil then\n if rcall("ZSCORE", completedKey, jobId) then\n local returnvalue = rcall("HGET", jobIdKey, "returnvalue")\n updateParentDepsIfNeeded(parentKey, parent['queueKey'],\n parentDependenciesKey, parent['id'],\n jobIdKey, returnvalue, timestamp)\n else\n if parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\n end\n end\n rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)\n end\nend\nlocal function handleDuplicatedJob(jobKey, jobId, currentParentKey, currentParent,\n parentData, parentDependenciesKey, completedKey, eventsKey, maxEvents, timestamp)\n local existedParentKey = rcall("HGET", jobKey, "parentKey")\n if not existedParentKey or existedParentKey == currentParentKey then\n updateExistingJobsParent(currentParentKey, currentParent, parentData,\n parentDependenciesKey, completedKey, jobKey,\n jobId, timestamp)\n else\n if currentParentKey ~= nil and currentParentKey ~= existedParentKey\n and (rcall("EXISTS", existedParentKey) == 1) then\n return -7\n end\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", jobId)\n return jobId .. "" -- convert to string\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\nif parentKey ~= nil then\n if rcall("EXISTS", parentKey) ~= 1 then return -5 end\n parentData = cjson.encode(parent)\nend\nlocal jobCounter = rcall("INCR", idKey)\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal opts = cmsgpack.unpack(ARGV[3])\nlocal parentDependenciesKey = args[7]\nlocal timestamp = args[4]\nif args[2] == "" then\n jobId = jobCounter\n jobIdKey = args[1] .. jobId\nelse\n jobId = args[2]\n jobIdKey = args[1] .. jobId\n if rcall("EXISTS", jobIdKey) == 1 then\n return handleDuplicatedJob(jobIdKey, jobId, parentKey, parent,\n parentData, parentDependenciesKey, completedKey, eventsKey,\n maxEvents, timestamp)\n end\nend\nlocal deduplicationJobId = deduplicateJob(opts['de'], jobId, delayedKey, deduplicationKey,\n eventsKey, maxEvents, args[1])\nif deduplicationJobId then\n return deduplicationJobId\nend\nlocal delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],\n opts, timestamp, parentKey, parentData, repeatJobKey)\naddDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, KEYS[1], delay)\n-- Check if this job is a child of another job, if so add it to the parents dependencies\nif parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\nend\nreturn jobId .. "" -- convert to string\n`;t.addDelayedJob={name:"addDelayedJob",content:n,keys:6}},3189:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addJobScheduler=void 0;const n=`--[[\n Adds a job scheduler, i.e. a job factory that creates jobs based on a given schedule (repeat options).\n Input:\n KEYS[1] 'repeat' key\n KEYS[2] 'delayed' key\n KEYS[3] 'wait' key\n KEYS[4] 'paused' key\n KEYS[5] 'meta' key\n KEYS[6] 'prioritized' key\n KEYS[7] 'marker' key\n KEYS[8] 'id' key\n KEYS[9] 'events' key\n KEYS[10] 'pc' priority counter\n KEYS[11] 'active' key\n ARGV[1] next milliseconds\n ARGV[2] msgpacked options\n [1] name\n [2] tz?\n [3] patten?\n [4] endDate?\n [5] every?\n ARGV[3] jobs scheduler id\n ARGV[4] Json stringified template data\n ARGV[5] mspacked template opts\n ARGV[6] msgpacked delayed opts\n ARGV[7] timestamp\n ARGV[8] prefix key\n ARGV[9] producer key\n Output:\n repeatableKey - OK\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[1]\nlocal delayedKey = KEYS[2]\nlocal waitKey = KEYS[3]\nlocal pausedKey = KEYS[4]\nlocal metaKey = KEYS[5]\nlocal prioritizedKey = KEYS[6]\nlocal eventsKey = KEYS[9]\nlocal nextMillis = ARGV[1]\nlocal jobSchedulerId = ARGV[3]\nlocal templateOpts = cmsgpack.unpack(ARGV[5])\nlocal prefixKey = ARGV[8]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Adds a delayed job to the queue by doing the following:\n - Creates a new job key with the job data.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\nlocal function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,\n maxEvents, markerKey, delay)\n local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay))\n rcall("ZADD", delayedKey, score, jobId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- mark that a delayed job is available\n addDelayMarkerIfNeeded(markerKey, delayedKey)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePaused(queueMetaKey)\n return rcall("HEXISTS", queueMetaKey, "paused") == 1\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\nlocal function addJobFromScheduler(jobKey, jobId, rawOpts, waitKey, pausedKey, activeKey, metaKey, \n prioritizedKey, priorityCounter, delayedKey, markerKey, eventsKey, name, maxEvents, timestamp,\n data, jobSchedulerId)\n local opts = cmsgpack.unpack(rawOpts)\n local delay, priority = storeJob(eventsKey, jobKey, jobId, name, data,\n opts, timestamp, nil, nil, jobSchedulerId)\n if delay ~= 0 then\n addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, markerKey, delay)\n else\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)\n -- Standard or priority add\n if priority == 0 then\n local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'\n addJobInTargetList(target, markerKey, pushCmd, isPausedOrMaxed, jobId)\n else\n -- Priority add\n addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounter, isPausedOrMaxed)\n end\n -- Emit waiting event\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting", "jobId", jobId)\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\n--[[\n Function to store a job scheduler\n]]\nlocal function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMillis, opts,\n templateData, templateOpts)\n rcall("ZADD", repeatKey, nextMillis, schedulerId)\n local optionalValues = {}\n if opts['tz'] then\n table.insert(optionalValues, "tz")\n table.insert(optionalValues, opts['tz'])\n end\n if opts['limit'] then\n table.insert(optionalValues, "limit")\n table.insert(optionalValues, opts['limit'])\n end\n if opts['pattern'] then\n table.insert(optionalValues, "pattern")\n table.insert(optionalValues, opts['pattern'])\n end\n if opts['endDate'] then\n table.insert(optionalValues, "endDate")\n table.insert(optionalValues, opts['endDate'])\n end\n if opts['every'] then\n table.insert(optionalValues, "every")\n table.insert(optionalValues, opts['every'])\n end\n if opts['offset'] then\n table.insert(optionalValues, "offset")\n table.insert(optionalValues, opts['offset'])\n end\n local jsonTemplateOpts = cjson.encode(templateOpts)\n if jsonTemplateOpts and jsonTemplateOpts ~= '{}' then\n table.insert(optionalValues, "opts")\n table.insert(optionalValues, jsonTemplateOpts)\n end\n if templateData and templateData ~= '{}' then\n table.insert(optionalValues, "data")\n table.insert(optionalValues, templateData)\n end\n rcall("DEL", schedulerKey) -- remove all attributes and then re-insert new ones\n rcall("HMSET", schedulerKey, "name", opts['name'], "ic", 1, unpack(optionalValues))\nend\n-- If we are overriding a repeatable job we must delete the delayed job for\n-- the next iteration.\nlocal schedulerKey = repeatKey .. ":" .. jobSchedulerId\nlocal nextDelayedJobKey = schedulerKey .. ":" .. nextMillis\nlocal nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId,\n metaKey, eventsKey)\n if rcall("ZSCORE", delayedKey, jobId) then\n removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )\n rcall("ZREM", delayedKey, jobId)\n return true\n elseif rcall("ZSCORE", prioritizedKey, jobId) then\n removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )\n rcall("ZREM", prioritizedKey, jobId)\n return true\n else\n local pausedOrWaitKey = waitKey\n if isQueuePaused(metaKey) then\n pausedOrWaitKey = pausedKey\n end\n if rcall("LREM", pausedOrWaitKey, 1, jobId) > 0 then\n removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )\n return true\n end\n end\n return false\nend\nif rcall("EXISTS", nextDelayedJobKey) == 1 then\n if not removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,\n nextDelayedJobId, metaKey, eventsKey) then\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", nextDelayedJobId)\n return nextDelayedJobId .. "" -- convert to string\n end\nend\nlocal prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)\nif prevMillis then \n local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis\n local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis\n if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then\n removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,\n currentJobId, metaKey, eventsKey)\n end\nend\nlocal schedulerOpts = cmsgpack.unpack(ARGV[2])\nstoreJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)\nrcall("INCR", KEYS[8])\naddJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,\n KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,\n schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)\nif ARGV[9] ~= "" then\n rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)\nend\nreturn nextDelayedJobId .. "" -- convert to string\n`;t.addJobScheduler={name:"addJobScheduler",content:n,keys:11}},6061:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addLog=void 0;const n=`--[[\n Add job log\n Input:\n KEYS[1] job id key\n KEYS[2] job logs key\n ARGV[1] id\n ARGV[2] log\n ARGV[3] keepLogs\n Output:\n -1 - Missing job.\n]]\nlocal rcall = redis.call\nif rcall("EXISTS", KEYS[1]) == 1 then -- // Make sure job exists\n local logCount = rcall("RPUSH", KEYS[2], ARGV[2])\n if ARGV[3] ~= '' then\n local keepLogs = tonumber(ARGV[3])\n rcall("LTRIM", KEYS[2], -keepLogs, -1)\n return math.min(keepLogs, logCount)\n end\n return logCount\nelse\n return -1\nend\n`;t.addLog={name:"addLog",content:n,keys:2}},4997:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addParentJob=void 0;const n=`--[[\n Adds a parent job to the queue by doing the following:\n - Increases the job counter if needed.\n - Creates a new job key with the job data.\n - adds the job to the waiting-children zset\n Input:\n KEYS[1] 'meta'\n KEYS[2] 'id'\n KEYS[3] 'delayed'\n KEYS[4] 'completed'\n KEYS[5] events stream key\n ARGV[1] msgpacked arguments array\n [1] key prefix,\n [2] custom id (will not generate one automatically)\n [3] name\n [4] timestamp\n [5] parentKey?\n [6] waitChildrenKey key.\n [7] parent dependencies key.\n [8] parent? {id, queueKey}\n [9] repeat job key\n [10] deduplication key\n ARGV[2] Json stringified job data\n ARGV[3] msgpacked options\n Output:\n jobId - OK\n -5 - Missing parent key\n]]\nlocal metaKey = KEYS[1]\nlocal idKey = KEYS[2]\nlocal completedKey = KEYS[4]\nlocal eventsKey = KEYS[5]\nlocal jobId\nlocal jobIdKey\nlocal rcall = redis.call\nlocal args = cmsgpack.unpack(ARGV[1])\nlocal data = ARGV[2]\nlocal opts = cmsgpack.unpack(ARGV[3])\nlocal parentKey = args[5]\nlocal parent = args[8]\nlocal repeatJobKey = args[9]\nlocal deduplicationKey = args[10]\nlocal parentData\n-- Includes\n--[[\n Function to debounce a job.\n]]\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,\n prefix)\n local deduplicationId = deduplicationOpts and deduplicationOpts['id']\n if deduplicationId then\n local ttl = deduplicationOpts['ttl']\n if deduplicationOpts['replace'] and ttl and ttl > 0 then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n if rcall("ZREM", delayedKey, currentDebounceJobId) > 0 then\n removeJobKeys(prefix .. currentDebounceJobId)\n rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDebounceJobId,\n "prev", "delayed")\n if deduplicationOpts['extend'] then\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n else\n rcall('SET', deduplicationKey, jobId, 'KEEPTTL')\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)\n return\n else\n return currentDebounceJobId\n end\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n local ttl = deduplicationOpts['ttl']\n local deduplicationKeyExists\n if ttl then\n if deduplicationOpts['extend'] then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n rcall('SET', deduplicationKey, currentDebounceJobId, 'PX', ttl)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced",\n "jobId", currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')\n end\n if deduplicationKeyExists then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",\n currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n end\n end\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to handle the case when job is duplicated.\n]]\n-- Includes\n--[[\n This function is used to update the parent's dependencies if the job\n is already completed and about to be ignored. The parent must get its\n dependencies updated to avoid the parent job being stuck forever in \n the waiting-children state.\n]]\n-- Includes\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\nlocal function updateExistingJobsParent(parentKey, parent, parentData,\n parentDependenciesKey, completedKey,\n jobIdKey, jobId, timestamp)\n if parentKey ~= nil then\n if rcall("ZSCORE", completedKey, jobId) then\n local returnvalue = rcall("HGET", jobIdKey, "returnvalue")\n updateParentDepsIfNeeded(parentKey, parent['queueKey'],\n parentDependenciesKey, parent['id'],\n jobIdKey, returnvalue, timestamp)\n else\n if parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\n end\n end\n rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)\n end\nend\nlocal function handleDuplicatedJob(jobKey, jobId, currentParentKey, currentParent,\n parentData, parentDependenciesKey, completedKey, eventsKey, maxEvents, timestamp)\n local existedParentKey = rcall("HGET", jobKey, "parentKey")\n if not existedParentKey or existedParentKey == currentParentKey then\n updateExistingJobsParent(currentParentKey, currentParent, parentData,\n parentDependenciesKey, completedKey, jobKey,\n jobId, timestamp)\n else\n if currentParentKey ~= nil and currentParentKey ~= existedParentKey\n and (rcall("EXISTS", existedParentKey) == 1) then\n return -7\n end\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", jobId)\n return jobId .. "" -- convert to string\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\nif parentKey ~= nil then\n if rcall("EXISTS", parentKey) ~= 1 then return -5 end\n parentData = cjson.encode(parent)\nend\nlocal jobCounter = rcall("INCR", idKey)\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal parentDependenciesKey = args[7]\nlocal timestamp = args[4]\nif args[2] == "" then\n jobId = jobCounter\n jobIdKey = args[1] .. jobId\nelse\n jobId = args[2]\n jobIdKey = args[1] .. jobId\n if rcall("EXISTS", jobIdKey) == 1 then\n return handleDuplicatedJob(jobIdKey, jobId, parentKey, parent,\n parentData, parentDependenciesKey, completedKey, eventsKey,\n maxEvents, timestamp)\n end\nend\nlocal deduplicationJobId = deduplicateJob(opts['de'], jobId, KEYS[3],\n deduplicationKey, eventsKey, maxEvents, args[1])\nif deduplicationJobId then\n return deduplicationJobId\nend\n-- Store the job.\nstoreJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,\n parentKey, parentData, repeatJobKey)\nlocal waitChildrenKey = args[6]\nrcall("ZADD", waitChildrenKey, timestamp, jobId)\nrcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "waiting-children", "jobId", jobId)\n-- Check if this job is a child of another job, if so add it to the parents dependencies\nif parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\nend\nreturn jobId .. "" -- convert to string\n`;t.addParentJob={name:"addParentJob",content:n,keys:5}},2962:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addPrioritizedJob=void 0;const n=`--[[\n Adds a priotitized job to the queue by doing the following:\n - Increases the job counter if needed.\n - Creates a new job key with the job data.\n - Adds the job to the "added" list so that workers gets notified.\n Input:\n KEYS[1] 'marker',\n KEYS[2] 'meta'\n KEYS[3] 'id'\n KEYS[4] 'prioritized'\n KEYS[5] 'delayed'\n KEYS[6] 'completed'\n KEYS[7] 'active'\n KEYS[8] events stream key\n KEYS[9] 'pc' priority counter\n ARGV[1] msgpacked arguments array\n [1] key prefix,\n [2] custom id (will not generate one automatically)\n [3] name\n [4] timestamp\n [5] parentKey?\n [6] waitChildrenKey key.\n [7] parent dependencies key.\n [8] parent? {id, queueKey}\n [9] repeat job key\n [10] deduplication key\n ARGV[2] Json stringified job data\n ARGV[3] msgpacked options\n Output:\n jobId - OK\n -5 - Missing parent key\n]] \nlocal metaKey = KEYS[2]\nlocal idKey = KEYS[3]\nlocal priorityKey = KEYS[4]\nlocal completedKey = KEYS[6]\nlocal activeKey = KEYS[7]\nlocal eventsKey = KEYS[8]\nlocal priorityCounterKey = KEYS[9]\nlocal jobId\nlocal jobIdKey\nlocal rcall = redis.call\nlocal args = cmsgpack.unpack(ARGV[1])\nlocal data = ARGV[2]\nlocal opts = cmsgpack.unpack(ARGV[3])\nlocal parentKey = args[5]\nlocal parent = args[8]\nlocal repeatJobKey = args[9]\nlocal deduplicationKey = args[10]\nlocal parentData\n-- Includes\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to debounce a job.\n]]\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,\n prefix)\n local deduplicationId = deduplicationOpts and deduplicationOpts['id']\n if deduplicationId then\n local ttl = deduplicationOpts['ttl']\n if deduplicationOpts['replace'] and ttl and ttl > 0 then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n if rcall("ZREM", delayedKey, currentDebounceJobId) > 0 then\n removeJobKeys(prefix .. currentDebounceJobId)\n rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDebounceJobId,\n "prev", "delayed")\n if deduplicationOpts['extend'] then\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n else\n rcall('SET', deduplicationKey, jobId, 'KEEPTTL')\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)\n return\n else\n return currentDebounceJobId\n end\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n local ttl = deduplicationOpts['ttl']\n local deduplicationKeyExists\n if ttl then\n if deduplicationOpts['extend'] then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n rcall('SET', deduplicationKey, currentDebounceJobId, 'PX', ttl)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced",\n "jobId", currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')\n end\n if deduplicationKeyExists then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",\n currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n end\n end\n end\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to handle the case when job is duplicated.\n]]\n-- Includes\n--[[\n This function is used to update the parent's dependencies if the job\n is already completed and about to be ignored. The parent must get its\n dependencies updated to avoid the parent job being stuck forever in \n the waiting-children state.\n]]\n-- Includes\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\nlocal function updateExistingJobsParent(parentKey, parent, parentData,\n parentDependenciesKey, completedKey,\n jobIdKey, jobId, timestamp)\n if parentKey ~= nil then\n if rcall("ZSCORE", completedKey, jobId) then\n local returnvalue = rcall("HGET", jobIdKey, "returnvalue")\n updateParentDepsIfNeeded(parentKey, parent['queueKey'],\n parentDependenciesKey, parent['id'],\n jobIdKey, returnvalue, timestamp)\n else\n if parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\n end\n end\n rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)\n end\nend\nlocal function handleDuplicatedJob(jobKey, jobId, currentParentKey, currentParent,\n parentData, parentDependenciesKey, completedKey, eventsKey, maxEvents, timestamp)\n local existedParentKey = rcall("HGET", jobKey, "parentKey")\n if not existedParentKey or existedParentKey == currentParentKey then\n updateExistingJobsParent(currentParentKey, currentParent, parentData,\n parentDependenciesKey, completedKey, jobKey,\n jobId, timestamp)\n else\n if currentParentKey ~= nil and currentParentKey ~= existedParentKey\n and (rcall("EXISTS", existedParentKey) == 1) then\n return -7\n end\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", jobId)\n return jobId .. "" -- convert to string\nend\nif parentKey ~= nil then\n if rcall("EXISTS", parentKey) ~= 1 then return -5 end\n parentData = cjson.encode(parent)\nend\nlocal jobCounter = rcall("INCR", idKey)\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal parentDependenciesKey = args[7]\nlocal timestamp = args[4]\nif args[2] == "" then\n jobId = jobCounter\n jobIdKey = args[1] .. jobId\nelse\n jobId = args[2]\n jobIdKey = args[1] .. jobId\n if rcall("EXISTS", jobIdKey) == 1 then\n return handleDuplicatedJob(jobIdKey, jobId, parentKey, parent,\n parentData, parentDependenciesKey, completedKey, eventsKey,\n maxEvents, timestamp)\n end\nend\nlocal deduplicationJobId = deduplicateJob(opts['de'], jobId, KEYS[5],\n deduplicationKey, eventsKey, maxEvents, args[1])\nif deduplicationJobId then\n return deduplicationJobId\nend\n-- Store the job.\nlocal delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],\n opts, timestamp, parentKey, parentData,\n repeatJobKey)\n-- Add the job to the prioritized set\nlocal isPausedOrMaxed = isQueuePausedOrMaxed(metaKey, activeKey)\naddJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPausedOrMaxed)\n-- Emit waiting event\nrcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", jobId)\n-- Check if this job is a child of another job, if so add it to the parents dependencies\nif parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\nend\nreturn jobId .. "" -- convert to string\n`;t.addPrioritizedJob={name:"addPrioritizedJob",content:n,keys:9}},8069:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addRepeatableJob=void 0;const n=`--[[\n Adds a repeatable job\n Input:\n KEYS[1] 'repeat' key\n KEYS[2] 'delayed' key\n ARGV[1] next milliseconds\n ARGV[2] msgpacked options\n [1] name\n [2] tz?\n [3] patten?\n [4] endDate?\n [5] every?\n ARGV[3] legacy custom key TODO: remove this logic in next breaking change\n ARGV[4] custom key\n ARGV[5] prefix key\n Output:\n repeatableKey - OK\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[1]\nlocal delayedKey = KEYS[2]\nlocal nextMillis = ARGV[1]\nlocal legacyCustomKey = ARGV[3]\nlocal customKey = ARGV[4]\nlocal prefixKey = ARGV[5]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\nlocal function storeRepeatableJob(repeatKey, customKey, nextMillis, rawOpts)\n rcall("ZADD", repeatKey, nextMillis, customKey)\n local opts = cmsgpack.unpack(rawOpts)\n local optionalValues = {}\n if opts['tz'] then\n table.insert(optionalValues, "tz")\n table.insert(optionalValues, opts['tz'])\n end\n if opts['pattern'] then\n table.insert(optionalValues, "pattern")\n table.insert(optionalValues, opts['pattern'])\n end\n if opts['endDate'] then\n table.insert(optionalValues, "endDate")\n table.insert(optionalValues, opts['endDate'])\n end\n if opts['every'] then\n table.insert(optionalValues, "every")\n table.insert(optionalValues, opts['every'])\n end\n rcall("HMSET", repeatKey .. ":" .. customKey, "name", opts['name'],\n unpack(optionalValues))\n return customKey\nend\n-- If we are overriding a repeatable job we must delete the delayed job for\n-- the next iteration.\nlocal prevMillis = rcall("ZSCORE", repeatKey, customKey)\nif prevMillis then\n local delayedJobId = "repeat:" .. customKey .. ":" .. prevMillis\n local nextDelayedJobId = repeatKey .. ":" .. customKey .. ":" .. nextMillis\n if rcall("ZSCORE", delayedKey, delayedJobId)\n and rcall("EXISTS", nextDelayedJobId) ~= 1 then\n removeJob(delayedJobId, true, prefixKey, true --[[remove debounce key]])\n rcall("ZREM", delayedKey, delayedJobId)\n end\nend\n-- Keep backwards compatibility with old repeatable jobs (<= 3.0.0)\nif rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then\n return storeRepeatableJob(repeatKey, legacyCustomKey, nextMillis, ARGV[2])\nend\nreturn storeRepeatableJob(repeatKey, customKey, nextMillis, ARGV[2])\n`;t.addRepeatableJob={name:"addRepeatableJob",content:n,keys:2}},8962:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addStandardJob=void 0;const n=`--[[\n Adds a job to the queue by doing the following:\n - Increases the job counter if needed.\n - Creates a new job key with the job data.\n - if delayed:\n - computes timestamp.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n - if not delayed\n - Adds the jobId to the wait/paused list in one of three ways:\n - LIFO\n - FIFO\n - prioritized.\n - Adds the job to the "added" list so that workers gets notified.\n Input:\n KEYS[1] 'wait',\n KEYS[2] 'paused'\n KEYS[3] 'meta'\n KEYS[4] 'id'\n KEYS[5] 'completed'\n KEYS[6] 'delayed'\n KEYS[7] 'active'\n KEYS[8] events stream key\n KEYS[9] marker key\n ARGV[1] msgpacked arguments array\n [1] key prefix,\n [2] custom id (will not generate one automatically)\n [3] name\n [4] timestamp\n [5] parentKey?\n [6] waitChildrenKey key.\n [7] parent dependencies key.\n [8] parent? {id, queueKey}\n [9] repeat job key\n [10] deduplication key\n ARGV[2] Json stringified job data\n ARGV[3] msgpacked options\n Output:\n jobId - OK\n -5 - Missing parent key\n]]\nlocal eventsKey = KEYS[8]\nlocal jobId\nlocal jobIdKey\nlocal rcall = redis.call\nlocal args = cmsgpack.unpack(ARGV[1])\nlocal data = ARGV[2]\nlocal opts = cmsgpack.unpack(ARGV[3])\nlocal parentKey = args[5]\nlocal parent = args[8]\nlocal repeatJobKey = args[9]\nlocal deduplicationKey = args[10]\nlocal parentData\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to debounce a job.\n]]\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,\n prefix)\n local deduplicationId = deduplicationOpts and deduplicationOpts['id']\n if deduplicationId then\n local ttl = deduplicationOpts['ttl']\n if deduplicationOpts['replace'] and ttl and ttl > 0 then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n if rcall("ZREM", delayedKey, currentDebounceJobId) > 0 then\n removeJobKeys(prefix .. currentDebounceJobId)\n rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDebounceJobId,\n "prev", "delayed")\n if deduplicationOpts['extend'] then\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n else\n rcall('SET', deduplicationKey, jobId, 'KEEPTTL')\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)\n return\n else\n return currentDebounceJobId\n end\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n local ttl = deduplicationOpts['ttl']\n local deduplicationKeyExists\n if ttl then\n if deduplicationOpts['extend'] then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n rcall('SET', deduplicationKey, currentDebounceJobId, 'PX', ttl)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced",\n "jobId", currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')\n end\n if deduplicationKeyExists then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",\n currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n end\n end\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to handle the case when job is duplicated.\n]]\n-- Includes\n--[[\n This function is used to update the parent's dependencies if the job\n is already completed and about to be ignored. The parent must get its\n dependencies updated to avoid the parent job being stuck forever in \n the waiting-children state.\n]]\n-- Includes\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\nlocal function updateExistingJobsParent(parentKey, parent, parentData,\n parentDependenciesKey, completedKey,\n jobIdKey, jobId, timestamp)\n if parentKey ~= nil then\n if rcall("ZSCORE", completedKey, jobId) then\n local returnvalue = rcall("HGET", jobIdKey, "returnvalue")\n updateParentDepsIfNeeded(parentKey, parent['queueKey'],\n parentDependenciesKey, parent['id'],\n jobIdKey, returnvalue, timestamp)\n else\n if parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\n end\n end\n rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)\n end\nend\nlocal function handleDuplicatedJob(jobKey, jobId, currentParentKey, currentParent,\n parentData, parentDependenciesKey, completedKey, eventsKey, maxEvents, timestamp)\n local existedParentKey = rcall("HGET", jobKey, "parentKey")\n if not existedParentKey or existedParentKey == currentParentKey then\n updateExistingJobsParent(currentParentKey, currentParent, parentData,\n parentDependenciesKey, completedKey, jobKey,\n jobId, timestamp)\n else\n if currentParentKey ~= nil and currentParentKey ~= existedParentKey\n and (rcall("EXISTS", existedParentKey) == 1) then\n return -7\n end\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", jobId)\n return jobId .. "" -- convert to string\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\nif parentKey ~= nil then\n if rcall("EXISTS", parentKey) ~= 1 then return -5 end\n parentData = cjson.encode(parent)\nend\nlocal jobCounter = rcall("INCR", KEYS[4])\nlocal metaKey = KEYS[3]\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal parentDependenciesKey = args[7]\nlocal timestamp = args[4]\nif args[2] == "" then\n jobId = jobCounter\n jobIdKey = args[1] .. jobId\nelse\n jobId = args[2]\n jobIdKey = args[1] .. jobId\n if rcall("EXISTS", jobIdKey) == 1 then\n return handleDuplicatedJob(jobIdKey, jobId, parentKey, parent,\n parentData, parentDependenciesKey, KEYS[5], eventsKey,\n maxEvents, timestamp)\n end\nend\nlocal deduplicationJobId = deduplicateJob(opts['de'], jobId, KEYS[6],\n deduplicationKey, eventsKey, maxEvents, args[1])\nif deduplicationJobId then\n return deduplicationJobId\nend\n-- Store the job.\nstoreJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,\n parentKey, parentData, repeatJobKey)\nlocal target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[1], KEYS[2])\n-- LIFO or FIFO\nlocal pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'\naddJobInTargetList(target, KEYS[9], pushCmd, isPausedOrMaxed, jobId)\n-- Emit waiting event\nrcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", jobId)\n-- Check if this job is a child of another job, if so add it to the parents dependencies\nif parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\nend\nreturn jobId .. "" -- convert to string\n`;t.addStandardJob={name:"addStandardJob",content:n,keys:9}},443:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.changeDelay=void 0;const n=`--[[\n Change job delay when it is in delayed set.\n Input:\n KEYS[1] delayed key\n KEYS[2] meta key\n KEYS[3] marker key\n KEYS[4] events stream\n ARGV[1] delay\n ARGV[2] timestamp\n ARGV[3] the id of the job\n ARGV[4] job key\n Output:\n 0 - OK\n -1 - Missing job.\n -3 - Job not in delayed set.\n Events:\n - delayed key.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nif rcall("EXISTS", ARGV[4]) == 1 then\n local jobId = ARGV[3]\n local delay = tonumber(ARGV[1])\n local score, delayedTimestamp = getDelayedScore(KEYS[1], ARGV[2], delay)\n local numRemovedElements = rcall("ZREM", KEYS[1], jobId)\n if numRemovedElements < 1 then\n return -3\n end\n rcall("HSET", ARGV[4], "delay", delay)\n rcall("ZADD", KEYS[1], score, jobId)\n local maxEvents = getOrSetMaxEvents(KEYS[2])\n rcall("XADD", KEYS[4], "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- mark that a delayed job is available\n addDelayMarkerIfNeeded(KEYS[3], KEYS[1])\n return 0\nelse\n return -1\nend`;t.changeDelay={name:"changeDelay",content:n,keys:4}},4805:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.changePriority=void 0;const n=`--[[\n Change job priority\n Input:\n KEYS[1] 'wait',\n KEYS[2] 'paused'\n KEYS[3] 'meta'\n KEYS[4] 'prioritized'\n KEYS[5] 'active'\n KEYS[6] 'pc' priority counter\n KEYS[7] 'marker'\n ARGV[1] priority value\n ARGV[2] prefix key\n ARGV[3] job id\n ARGV[4] lifo\n Output:\n 0 - OK\n -1 - Missing job\n]]\nlocal jobId = ARGV[3]\nlocal jobKey = ARGV[2] .. jobId\nlocal priority = tonumber(ARGV[1])\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to push back job considering priority in front of same prioritized jobs.\n]]\nlocal function pushBackJobWithPriority(prioritizedKey, priority, jobId)\n -- in order to put it at front of same prioritized jobs\n -- we consider prioritized counter as 0\n local score = priority * 0x100000000\n rcall("ZADD", prioritizedKey, score, jobId)\nend\nlocal function reAddJobWithNewPriority( prioritizedKey, markerKey, targetKey,\n priorityCounter, lifo, priority, jobId, isPausedOrMaxed)\n if priority == 0 then\n local pushCmd = lifo and 'RPUSH' or 'LPUSH'\n addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n else\n if lifo then\n pushBackJobWithPriority(prioritizedKey, priority, jobId)\n else\n addJobWithPriority(markerKey, prioritizedKey, priority, jobId,\n priorityCounter, isPausedOrMaxed)\n end\n end\nend\nif rcall("EXISTS", jobKey) == 1 then\n local metaKey = KEYS[3]\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[5], KEYS[1], KEYS[2])\n local prioritizedKey = KEYS[4]\n local priorityCounterKey = KEYS[6]\n local markerKey = KEYS[7]\n -- Re-add with the new priority\n if rcall("ZREM", prioritizedKey, jobId) > 0 then\n reAddJobWithNewPriority( prioritizedKey, markerKey, target,\n priorityCounterKey, ARGV[4] == '1', priority, jobId, isPausedOrMaxed)\n elseif rcall("LREM", target, -1, jobId) > 0 then\n reAddJobWithNewPriority( prioritizedKey, markerKey, target,\n priorityCounterKey, ARGV[4] == '1', priority, jobId, isPausedOrMaxed)\n end\n rcall("HSET", jobKey, "priority", priority)\n return 0\nelse\n return -1\nend\n`;t.changePriority={name:"changePriority",content:n,keys:7}},8531:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.cleanJobsInSet=void 0;const n=`--[[\n Remove jobs from the specific set.\n Input:\n KEYS[1] set key,\n KEYS[2] events stream key\n KEYS[3] repeat key\n ARGV[1] jobKey prefix\n ARGV[2] timestamp\n ARGV[3] limit the number of jobs to be removed. 0 is unlimited\n ARGV[4] set name, can be any of 'wait', 'active', 'paused', 'delayed', 'completed', or 'failed'\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[3]\nlocal rangeStart = 0\nlocal rangeEnd = -1\nlocal limit = tonumber(ARGV[3])\n-- If we're only deleting _n_ items, avoid retrieving all items\n-- for faster performance\n--\n-- Start from the tail of the list, since that's where oldest elements\n-- are generally added for FIFO lists\nif limit > 0 then\n rangeStart = -1 - limit + 1\n rangeEnd = -1\nend\n-- Includes\n--[[\n Function to clean job list.\n Returns jobIds and deleted count number.\n]]\n-- Includes\n--[[\n Function to get the latest saved timestamp.\n]]\nlocal function getTimestamp(jobKey, attributes)\n if #attributes == 1 then\n return rcall("HGET", jobKey, attributes[1])\n end\n local jobTs\n for _, ts in ipairs(rcall("HMGET", jobKey, unpack(attributes))) do\n if (ts) then\n jobTs = ts\n break\n end\n end\n return jobTs\nend\n--[[\n Function to check if the job belongs to a job scheduler and\n current delayed job matches with jobId\n]]\nlocal function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)\n local repeatJobKey = rcall("HGET", jobKey, "rjk")\n if repeatJobKey then\n local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)\n if prevMillis then\n local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis\n return jobId == currentDelayedJobId\n end\n end\n return false\nend\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\nlocal function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,\n timestamp, isWaiting, jobSchedulersKey)\n local jobs = rcall("LRANGE", listKey, rangeStart, rangeEnd)\n local deleted = {}\n local deletedCount = 0\n local jobTS\n local deletionMarker = ''\n local jobIdsLen = #jobs\n for i, job in ipairs(jobs) do\n if limit > 0 and deletedCount >= limit then\n break\n end\n local jobKey = jobKeyPrefix .. job\n if (isWaiting or rcall("EXISTS", jobKey .. ":lock") == 0) and\n not isJobSchedulerJob(job, jobKey, jobSchedulersKey) then\n -- Find the right timestamp of the job to compare to maxTimestamp:\n -- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed\n -- * processedOn represents when the job was last attempted, but it doesn't get populated until\n -- the job is first tried\n -- * timestamp is the original job submission time\n -- Fetch all three of these (in that order) and use the first one that is set so that we'll leave jobs\n -- that have been active within the grace period:\n jobTS = getTimestamp(jobKey, {"finishedOn", "processedOn", "timestamp"})\n if (not jobTS or jobTS <= timestamp) then\n -- replace the entry with a deletion marker; the actual deletion will\n -- occur at the end of the script\n rcall("LSET", listKey, rangeEnd - jobIdsLen + i, deletionMarker)\n removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]])\n deletedCount = deletedCount + 1\n table.insert(deleted, job)\n end\n end\n end\n rcall("LREM", listKey, 0, deletionMarker)\n return {deleted, deletedCount}\nend\n--[[\n Function to clean job set.\n Returns jobIds and deleted count number.\n]] \n-- Includes\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n We use ZRANGEBYSCORE to make the case where we're deleting a limited number\n of items in a sorted set only run a single iteration. If we simply used\n ZRANGE, we may take a long time traversing through jobs that are within the\n grace period.\n]]\nlocal function getJobsInZset(zsetKey, rangeEnd, limit)\n if limit > 0 then\n return rcall("ZRANGEBYSCORE", zsetKey, 0, rangeEnd, "LIMIT", 0, limit)\n else\n return rcall("ZRANGEBYSCORE", zsetKey, 0, rangeEnd)\n end\nend\nlocal function cleanSet(\n setKey,\n jobKeyPrefix,\n rangeEnd,\n timestamp,\n limit,\n attributes,\n isFinished,\n jobSchedulersKey)\n local jobs = getJobsInZset(setKey, rangeEnd, limit)\n local deleted = {}\n local deletedCount = 0\n local jobTS\n for i, job in ipairs(jobs) do\n if limit > 0 and deletedCount >= limit then\n break\n end\n local jobKey = jobKeyPrefix .. job\n -- Extract a Job Scheduler Id from jobId ("repeat:job-scheduler-id:millis") \n -- and check if it is in the scheduled jobs\n if not (jobSchedulersKey and isJobSchedulerJob(job, jobKey, jobSchedulersKey)) then\n if isFinished then\n removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]] )\n deletedCount = deletedCount + 1\n table.insert(deleted, job)\n else\n -- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed\n jobTS = getTimestamp(jobKey, attributes)\n if (not jobTS or jobTS <= timestamp) then\n removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]] )\n deletedCount = deletedCount + 1\n table.insert(deleted, job)\n end\n end\n end\n end\n if (#deleted > 0) then\n for from, to in batches(#deleted, 7000) do\n rcall("ZREM", setKey, unpack(deleted, from, to))\n end\n end\n return {deleted, deletedCount}\nend\nlocal result\nif ARGV[4] == "active" then\n result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], false --[[ hasFinished ]],\n repeatKey)\nelseif ARGV[4] == "delayed" then\n rangeEnd = "+inf"\n result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,\n {"processedOn", "timestamp"}, false --[[ hasFinished ]], repeatKey)\nelseif ARGV[4] == "prioritized" then\n rangeEnd = "+inf"\n result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,\n {"timestamp"}, false --[[ hasFinished ]], repeatKey)\nelseif ARGV[4] == "wait" or ARGV[4] == "paused" then\n result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], true --[[ hasFinished ]],\n repeatKey)\nelse\n rangeEnd = ARGV[2]\n -- No need to pass repeat key as in that moment job won't be related to a job scheduler\n result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,\n {"finishedOn"}, true --[[ hasFinished ]])\nend\nrcall("XADD", KEYS[2], "*", "event", "cleaned", "count", result[2])\nreturn result[1]\n`;t.cleanJobsInSet={name:"cleanJobsInSet",content:n,keys:3}},917:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.drain=void 0;const n=`--[[\n Drains the queue, removes all jobs that are waiting\n or delayed, but not active, completed or failed\n Input:\n KEYS[1] 'wait',\n KEYS[2] 'paused'\n KEYS[3] 'delayed'\n KEYS[4] 'prioritized'\n KEYS[5] 'jobschedulers' (repeat)\n ARGV[1] queue key prefix\n ARGV[2] should clean delayed jobs\n]]\nlocal rcall = redis.call\nlocal queueBaseKey = ARGV[1]\n--[[\n Functions to remove jobs.\n]]\n-- Includes\n--[[\n Function to filter out jobs to ignore from a table.\n]]\nlocal function filterOutJobsToIgnore(jobs, jobsToIgnore)\n local filteredJobs = {}\n for i = 1, #jobs do\n if not jobsToIgnore[jobs[i]] then\n table.insert(filteredJobs, jobs[i])\n end\n end\n return filteredJobs\nend\n--[[\n Functions to remove jobs.\n]]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\nlocal function removeJobs(keys, hard, baseKey, max)\n for i, key in ipairs(keys) do\n removeJob(key, hard, baseKey, true --[[remove debounce key]])\n end\n return max - #keys\nend\nlocal function getListItems(keyName, max)\n return rcall('LRANGE', keyName, 0, max - 1)\nend\nlocal function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)\n local jobs = getListItems(keyName, max)\n if jobsToIgnore then\n jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)\n end\n local count = removeJobs(jobs, hard, baseKey, max)\n rcall("LTRIM", keyName, #jobs, -1)\n return count\nend\n-- Includes\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n Function to get ZSet items.\n]]\nlocal function getZSetItems(keyName, max)\n return rcall('ZRANGE', keyName, 0, max - 1)\nend\nlocal function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)\n local jobs = getZSetItems(keyName, max)\n if jobsToIgnore then\n jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)\n end\n local count = removeJobs(jobs, hard, baseKey, max)\n if(#jobs > 0) then\n for from, to in batches(#jobs, 7000) do\n rcall("ZREM", keyName, unpack(jobs, from, to))\n end\n end\n return count\nend\n-- We must not remove delayed jobs if they are associated to a job scheduler.\nlocal scheduledJobs = {}\nlocal jobSchedulers = rcall("ZRANGE", KEYS[5], 0, -1, "WITHSCORES")\n-- For every job scheduler, get the current delayed job id.\nfor i = 1, #jobSchedulers, 2 do\n local jobSchedulerId = jobSchedulers[i]\n local jobSchedulerMillis = jobSchedulers[i + 1]\n local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. jobSchedulerMillis\n scheduledJobs[delayedJobId] = true\nend\nremoveListJobs(KEYS[1], true, queueBaseKey, 0, scheduledJobs) -- wait\nremoveListJobs(KEYS[2], true, queueBaseKey, 0, scheduledJobs) -- paused\nif ARGV[2] == "1" then\n removeZSetJobs(KEYS[3], true, queueBaseKey, 0, scheduledJobs) -- delayed\nend\nremoveZSetJobs(KEYS[4], true, queueBaseKey, 0, scheduledJobs) -- prioritized\n`;t.drain={name:"drain",content:n,keys:5}},7137:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.extendLock=void 0;const n=`--[[\n Extend lock and removes the job from the stalled set.\n Input:\n KEYS[1] 'lock',\n KEYS[2] 'stalled'\n ARGV[1] token\n ARGV[2] lock duration in milliseconds\n ARGV[3] jobid\n Output:\n "1" if lock extented succesfully.\n]]\nlocal rcall = redis.call\nif rcall("GET", KEYS[1]) == ARGV[1] then\n -- if rcall("SET", KEYS[1], ARGV[1], "PX", ARGV[2], "XX") then\n if rcall("SET", KEYS[1], ARGV[1], "PX", ARGV[2]) then\n rcall("SREM", KEYS[2], ARGV[3])\n return 1\n end\nend\nreturn 0\n`;t.extendLock={name:"extendLock",content:n,keys:2}},5723:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.extendLocks=void 0;const n=`--[[\n Extend locks for multiple jobs and remove them from the stalled set if successful.\n Return the list of job IDs for which the operation failed.\n KEYS[1] = stalledKey\n ARGV[1] = baseKey\n ARGV[2] = tokens\n ARGV[3] = jobIds\n ARGV[4] = lockDuration (ms)\n Output:\n An array of failed job IDs. If empty, all succeeded.\n]]\nlocal rcall = redis.call\nlocal stalledKey = KEYS[1]\nlocal baseKey = ARGV[1]\nlocal tokens = cmsgpack.unpack(ARGV[2])\nlocal jobIds = cmsgpack.unpack(ARGV[3])\nlocal lockDuration = ARGV[4]\nlocal jobCount = #jobIds\nlocal failedJobs = {}\nfor i = 1, jobCount, 1 do\n local lockKey = baseKey .. jobIds[i] .. ':lock'\n local jobId = jobIds[i]\n local token = tokens[i]\n local currentToken = rcall("GET", lockKey)\n if currentToken == token then\n local setResult = rcall("SET", lockKey, token, "PX", lockDuration)\n if setResult then\n rcall("SREM", stalledKey, jobId)\n else\n table.insert(failedJobs, jobId)\n end\n else\n table.insert(failedJobs, jobId)\n end\nend\nreturn failedJobs\n`;t.extendLocks={name:"extendLocks",content:n,keys:1}},3943:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getCounts=void 0;const n=`--[[\n Get counts per provided states\n Input:\n KEYS[1] 'prefix'\n ARGV[1...] types\n]]\nlocal rcall = redis.call;\nlocal prefix = KEYS[1]\nlocal results = {}\nfor i = 1, #ARGV do\n local stateKey = prefix .. ARGV[i]\n if ARGV[i] == "wait" or ARGV[i] == "paused" then\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n local marker = rcall("LINDEX", stateKey, -1)\n if marker and string.sub(marker, 1, 2) == "0:" then\n local count = rcall("LLEN", stateKey)\n if count > 1 then\n rcall("RPOP", stateKey)\n results[#results+1] = count-1\n else\n results[#results+1] = 0\n end\n else\n results[#results+1] = rcall("LLEN", stateKey)\n end\n elseif ARGV[i] == "active" then\n results[#results+1] = rcall("LLEN", stateKey)\n else\n results[#results+1] = rcall("ZCARD", stateKey)\n end\nend\nreturn results\n`;t.getCounts={name:"getCounts",content:n,keys:1}},5959:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getCountsPerPriority=void 0;const n=`--[[\n Get counts per provided states\n Input:\n KEYS[1] wait key\n KEYS[2] paused key\n KEYS[3] meta key\n KEYS[4] prioritized key\n ARGV[1...] priorities\n]]\nlocal rcall = redis.call\nlocal results = {}\nlocal waitKey = KEYS[1]\nlocal pausedKey = KEYS[2]\nlocal prioritizedKey = KEYS[4]\n-- Includes\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePaused(queueMetaKey)\n return rcall("HEXISTS", queueMetaKey, "paused") == 1\nend\nfor i = 1, #ARGV do\n local priority = tonumber(ARGV[i])\n if priority == 0 then\n if isQueuePaused(KEYS[3]) then\n results[#results+1] = rcall("LLEN", pausedKey)\n else\n results[#results+1] = rcall("LLEN", waitKey)\n end\n else\n results[#results+1] = rcall("ZCOUNT", prioritizedKey,\n priority * 0x100000000, (priority + 1) * 0x100000000 - 1)\n end\nend\nreturn results\n`;t.getCountsPerPriority={name:"getCountsPerPriority",content:n,keys:4}},5577:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getDependencyCounts=void 0;const n=`--[[\n Get counts per child states\n Input:\n KEYS[1] processed key\n KEYS[2] unprocessed key\n KEYS[3] ignored key\n KEYS[4] failed key\n ARGV[1...] types\n]]\nlocal rcall = redis.call;\nlocal processedKey = KEYS[1]\nlocal unprocessedKey = KEYS[2]\nlocal ignoredKey = KEYS[3]\nlocal failedKey = KEYS[4]\nlocal results = {}\nfor i = 1, #ARGV do\n if ARGV[i] == "processed" then\n results[#results+1] = rcall("HLEN", processedKey)\n elseif ARGV[i] == "unprocessed" then\n results[#results+1] = rcall("SCARD", unprocessedKey)\n elseif ARGV[i] == "ignored" then\n results[#results+1] = rcall("HLEN", ignoredKey)\n else\n results[#results+1] = rcall("ZCARD", failedKey)\n end\nend\nreturn results\n`;t.getDependencyCounts={name:"getDependencyCounts",content:n,keys:4}},3811:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getJobScheduler=void 0;const n=`--[[\n Get job scheduler record.\n Input:\n KEYS[1] 'repeat' key\n ARGV[1] id\n]]\nlocal rcall = redis.call\nlocal jobSchedulerKey = KEYS[1] .. ":" .. ARGV[1]\nlocal score = rcall("ZSCORE", KEYS[1], ARGV[1])\nif score then\n return {rcall("HGETALL", jobSchedulerKey), score} -- get job data\nend\nreturn {nil, nil}\n`;t.getJobScheduler={name:"getJobScheduler",content:n,keys:1}},7521:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getRanges=void 0;const n=`--[[\n Get job ids per provided states\n Input:\n KEYS[1] 'prefix'\n ARGV[1] start\n ARGV[2] end\n ARGV[3] asc\n ARGV[4...] types\n]]\nlocal rcall = redis.call\nlocal prefix = KEYS[1]\nlocal rangeStart = tonumber(ARGV[1])\nlocal rangeEnd = tonumber(ARGV[2])\nlocal asc = ARGV[3]\nlocal results = {}\nlocal function getRangeInList(listKey, asc, rangeStart, rangeEnd, results)\n if asc == "1" then\n local modifiedRangeStart\n local modifiedRangeEnd\n if rangeStart == -1 then\n modifiedRangeStart = 0\n else\n modifiedRangeStart = -(rangeStart + 1)\n end\n if rangeEnd == -1 then\n modifiedRangeEnd = 0\n else\n modifiedRangeEnd = -(rangeEnd + 1)\n end\n results[#results+1] = rcall("LRANGE", listKey,\n modifiedRangeEnd,\n modifiedRangeStart)\n else\n results[#results+1] = rcall("LRANGE", listKey, rangeStart, rangeEnd)\n end\nend\nfor i = 4, #ARGV do\n local stateKey = prefix .. ARGV[i]\n if ARGV[i] == "wait" or ARGV[i] == "paused" then\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n local marker = rcall("LINDEX", stateKey, -1)\n if marker and string.sub(marker, 1, 2) == "0:" then\n local count = rcall("LLEN", stateKey)\n if count > 1 then\n rcall("RPOP", stateKey)\n getRangeInList(stateKey, asc, rangeStart, rangeEnd, results)\n else\n results[#results+1] = {}\n end\n else\n getRangeInList(stateKey, asc, rangeStart, rangeEnd, results)\n end\n elseif ARGV[i] == "active" then\n getRangeInList(stateKey, asc, rangeStart, rangeEnd, results)\n else\n if asc == "1" then\n results[#results+1] = rcall("ZRANGE", stateKey, rangeStart, rangeEnd)\n else\n results[#results+1] = rcall("ZREVRANGE", stateKey, rangeStart, rangeEnd)\n end\n end\nend\nreturn results\n`;t.getRanges={name:"getRanges",content:n,keys:1}},1928:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getRateLimitTtl=void 0;const n=`--[[\n Get rate limit ttl\n Input:\n KEYS[1] 'limiter'\n ARGV[1] maxJobs\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to get current rate limit ttl.\n]]\nlocal function getRateLimitTTL(maxJobs, rateLimiterKey)\n if maxJobs and maxJobs <= tonumber(rcall("GET", rateLimiterKey) or 0) then\n local pttl = rcall("PTTL", rateLimiterKey)\n if pttl == 0 then\n rcall("DEL", rateLimiterKey)\n end\n if pttl > 0 then\n return pttl\n end\n end\n return 0\nend\nlocal rateLimiterKey = KEYS[1]\nif ARGV[1] ~= "0" then\n return getRateLimitTTL(tonumber(ARGV[1]), rateLimiterKey)\nelse\n return rcall("PTTL", rateLimiterKey)\nend\n`;t.getRateLimitTtl={name:"getRateLimitTtl",content:n,keys:1}},7698:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getState=void 0;const n=`--[[\n Get a job state\n Input: \n KEYS[1] 'completed' key,\n KEYS[2] 'failed' key\n KEYS[3] 'delayed' key\n KEYS[4] 'active' key\n KEYS[5] 'wait' key\n KEYS[6] 'paused' key\n KEYS[7] 'waiting-children' key\n KEYS[8] 'prioritized' key\n ARGV[1] job id\n Output:\n 'completed'\n 'failed'\n 'delayed'\n 'active'\n 'prioritized'\n 'waiting'\n 'waiting-children'\n 'unknown'\n]]\nlocal rcall = redis.call\nif rcall("ZSCORE", KEYS[1], ARGV[1]) then\n return "completed"\nend\nif rcall("ZSCORE", KEYS[2], ARGV[1]) then\n return "failed"\nend\nif rcall("ZSCORE", KEYS[3], ARGV[1]) then\n return "delayed"\nend\nif rcall("ZSCORE", KEYS[8], ARGV[1]) then\n return "prioritized"\nend\n-- Includes\n--[[\n Functions to check if a item belongs to a list.\n]]\nlocal function checkItemInList(list, item)\n for _, v in pairs(list) do\n if v == item then\n return 1\n end\n end\n return nil\nend\nlocal active_items = rcall("LRANGE", KEYS[4] , 0, -1)\nif checkItemInList(active_items, ARGV[1]) ~= nil then\n return "active"\nend\nlocal wait_items = rcall("LRANGE", KEYS[5] , 0, -1)\nif checkItemInList(wait_items, ARGV[1]) ~= nil then\n return "waiting"\nend\nlocal paused_items = rcall("LRANGE", KEYS[6] , 0, -1)\nif checkItemInList(paused_items, ARGV[1]) ~= nil then\n return "waiting"\nend\nif rcall("ZSCORE", KEYS[7], ARGV[1]) then\n return "waiting-children"\nend\nreturn "unknown"\n`;t.getState={name:"getState",content:n,keys:8}},4777:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getStateV2=void 0;const n=`--[[\n Get a job state\n Input: \n KEYS[1] 'completed' key,\n KEYS[2] 'failed' key\n KEYS[3] 'delayed' key\n KEYS[4] 'active' key\n KEYS[5] 'wait' key\n KEYS[6] 'paused' key\n KEYS[7] 'waiting-children' key\n KEYS[8] 'prioritized' key\n ARGV[1] job id\n Output:\n 'completed'\n 'failed'\n 'delayed'\n 'active'\n 'waiting'\n 'waiting-children'\n 'unknown'\n]]\nlocal rcall = redis.call\nif rcall("ZSCORE", KEYS[1], ARGV[1]) then\n return "completed"\nend\nif rcall("ZSCORE", KEYS[2], ARGV[1]) then\n return "failed"\nend\nif rcall("ZSCORE", KEYS[3], ARGV[1]) then\n return "delayed"\nend\nif rcall("ZSCORE", KEYS[8], ARGV[1]) then\n return "prioritized"\nend\nif rcall("LPOS", KEYS[4] , ARGV[1]) then\n return "active"\nend\nif rcall("LPOS", KEYS[5] , ARGV[1]) then\n return "waiting"\nend\nif rcall("LPOS", KEYS[6] , ARGV[1]) then\n return "waiting"\nend\nif rcall("ZSCORE", KEYS[7] , ARGV[1]) then\n return "waiting-children"\nend\nreturn "unknown"\n`;t.getStateV2={name:"getStateV2",content:n,keys:8}},9589:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(8856),t);r.__exportStar(n(3189),t);r.__exportStar(n(6061),t);r.__exportStar(n(4997),t);r.__exportStar(n(2962),t);r.__exportStar(n(8069),t);r.__exportStar(n(8962),t);r.__exportStar(n(443),t);r.__exportStar(n(4805),t);r.__exportStar(n(8531),t);r.__exportStar(n(917),t);r.__exportStar(n(7137),t);r.__exportStar(n(5723),t);r.__exportStar(n(3943),t);r.__exportStar(n(5959),t);r.__exportStar(n(5577),t);r.__exportStar(n(3811),t);r.__exportStar(n(7521),t);r.__exportStar(n(1928),t);r.__exportStar(n(7698),t);r.__exportStar(n(4777),t);r.__exportStar(n(3551),t);r.__exportStar(n(8211),t);r.__exportStar(n(5681),t);r.__exportStar(n(2630),t);r.__exportStar(n(2625),t);r.__exportStar(n(2236),t);r.__exportStar(n(9258),t);r.__exportStar(n(4358),t);r.__exportStar(n(3141),t);r.__exportStar(n(772),t);r.__exportStar(n(8345),t);r.__exportStar(n(7441),t);r.__exportStar(n(5759),t);r.__exportStar(n(2347),t);r.__exportStar(n(7461),t);r.__exportStar(n(6732),t);r.__exportStar(n(9825),t);r.__exportStar(n(7645),t);r.__exportStar(n(3938),t);r.__exportStar(n(3940),t);r.__exportStar(n(1409),t);r.__exportStar(n(2800),t);r.__exportStar(n(8447),t);r.__exportStar(n(5726),t);r.__exportStar(n(6538),t);r.__exportStar(n(4331),t);r.__exportStar(n(2391),t)},3551:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.isFinished=void 0;const n=`--[[\n Checks if a job is finished (.i.e. is in the completed or failed set)\n Input: \n KEYS[1] completed key\n KEYS[2] failed key\n KEYS[3] job key\n ARGV[1] job id\n ARGV[2] return value?\n Output:\n 0 - Not finished.\n 1 - Completed.\n 2 - Failed.\n -1 - Missing job. \n]]\nlocal rcall = redis.call\nif rcall("EXISTS", KEYS[3]) ~= 1 then\n if ARGV[2] == "1" then\n return {-1,"Missing key for job " .. KEYS[3] .. ". isFinished"}\n end \n return -1\nend\nif rcall("ZSCORE", KEYS[1], ARGV[1]) then\n if ARGV[2] == "1" then\n local returnValue = rcall("HGET", KEYS[3], "returnvalue")\n return {1,returnValue}\n end\n return 1\nend\nif rcall("ZSCORE", KEYS[2], ARGV[1]) then\n if ARGV[2] == "1" then\n local failedReason = rcall("HGET", KEYS[3], "failedReason")\n return {2,failedReason}\n end\n return 2\nend\nif ARGV[2] == "1" then\n return {0}\nend\nreturn 0\n`;t.isFinished={name:"isFinished",content:n,keys:3}},8211:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.isJobInList=void 0;const n=`--[[\n Checks if job is in a given list.\n Input:\n KEYS[1]\n ARGV[1]\n Output:\n 1 if element found in the list.\n]]\n-- Includes\n--[[\n Functions to check if a item belongs to a list.\n]]\nlocal function checkItemInList(list, item)\n for _, v in pairs(list) do\n if v == item then\n return 1\n end\n end\n return nil\nend\nlocal items = redis.call("LRANGE", KEYS[1] , 0, -1)\nreturn checkItemInList(items, ARGV[1])\n`;t.isJobInList={name:"isJobInList",content:n,keys:1}},5681:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.isMaxed=void 0;const n=`--[[\n Checks if queue is maxed.\n Input:\n KEYS[1] meta key\n KEYS[2] active key\n Output:\n 1 if element found in the list.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to check if queue is maxed or not.\n]]\nlocal function isQueueMaxed(queueMetaKey, activeKey)\n local maxConcurrency = rcall("HGET", queueMetaKey, "concurrency")\n if maxConcurrency then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(maxConcurrency) then\n return true\n end\n end\n return false\nend\nreturn isQueueMaxed(KEYS[1], KEYS[2])\n`;t.isMaxed={name:"isMaxed",content:n,keys:2}},2630:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveJobFromActiveToWait=void 0;const n=`--[[\n Function to move job from active state to wait.\n Input:\n KEYS[1] active key\n KEYS[2] wait key\n KEYS[3] stalled key\n KEYS[4] paused key\n KEYS[5] meta key\n KEYS[6] limiter key\n KEYS[7] prioritized key\n KEYS[8] marker key\n KEYS[9] event key\n ARGV[1] job id\n ARGV[2] lock token\n ARGV[3] job id key\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to push back job considering priority in front of same prioritized jobs.\n]]\nlocal function pushBackJobWithPriority(prioritizedKey, priority, jobId)\n -- in order to put it at front of same prioritized jobs\n -- we consider prioritized counter as 0\n local score = priority * 0x100000000\n rcall("ZADD", prioritizedKey, score, jobId)\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\nlocal jobId = ARGV[1]\nlocal token = ARGV[2]\nlocal jobKey = ARGV[3]\nlocal errorCode = removeLock(jobKey, KEYS[3], token, jobId)\nif errorCode < 0 then\n return errorCode\nend\nlocal metaKey = KEYS[5]\nlocal removed = rcall("LREM", KEYS[1], 1, jobId)\nif removed > 0 then\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[1], KEYS[2], KEYS[4])\n local priority = tonumber(rcall("HGET", ARGV[3], "priority")) or 0\n if priority > 0 then\n pushBackJobWithPriority(KEYS[7], priority, jobId)\n else\n addJobInTargetList(target, KEYS[8], "RPUSH", isPausedOrMaxed, jobId)\n end\n local maxEvents = getOrSetMaxEvents(metaKey)\n -- Emit waiting event\n rcall("XADD", KEYS[9], "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", jobId, "prev", "active")\nend\nlocal pttl = rcall("PTTL", KEYS[6])\nif pttl > 0 then\n return pttl\nelse\n return 0\nend`;t.moveJobFromActiveToWait={name:"moveJobFromActiveToWait",content:n,keys:9}},2625:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveJobsToWait=void 0;const n=`--[[\n Move completed, failed or delayed jobs to wait.\n Note: Does not support jobs with priorities.\n Input:\n KEYS[1] base key\n KEYS[2] events stream\n KEYS[3] state key (failed, completed, delayed)\n KEYS[4] 'wait'\n KEYS[5] 'paused'\n KEYS[6] 'meta'\n KEYS[7] 'active'\n KEYS[8] 'marker'\n ARGV[1] count\n ARGV[2] timestamp\n ARGV[3] prev state\n Output:\n 1 means the operation is not completed\n 0 means the operation is completed\n]]\nlocal maxCount = tonumber(ARGV[1])\nlocal timestamp = tonumber(ARGV[2])\nlocal rcall = redis.call;\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal metaKey = KEYS[6]\nlocal target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[4], KEYS[5])\nlocal jobs = rcall('ZRANGEBYSCORE', KEYS[3], 0, timestamp, 'LIMIT', 0, maxCount)\nif (#jobs > 0) then\n if ARGV[3] == "failed" then\n for i, key in ipairs(jobs) do\n local jobKey = KEYS[1] .. key\n rcall("HDEL", jobKey, "finishedOn", "processedOn", "failedReason")\n end\n elseif ARGV[3] == "completed" then\n for i, key in ipairs(jobs) do\n local jobKey = KEYS[1] .. key\n rcall("HDEL", jobKey, "finishedOn", "processedOn", "returnvalue")\n end\n end\n local maxEvents = getOrSetMaxEvents(metaKey)\n for i, key in ipairs(jobs) do\n -- Emit waiting event\n rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event",\n "waiting", "jobId", key, "prev", ARGV[3]);\n end\n for from, to in batches(#jobs, 7000) do\n rcall("ZREM", KEYS[3], unpack(jobs, from, to))\n rcall("LPUSH", target, unpack(jobs, from, to))\n end\n addBaseMarkerIfNeeded(KEYS[8], isPausedOrMaxed)\nend\nmaxCount = maxCount - #jobs\nif (maxCount <= 0) then return 1 end\nreturn 0\n`;t.moveJobsToWait={name:"moveJobsToWait",content:n,keys:8}},2236:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveStalledJobsToWait=void 0;const n=`--[[\n Move stalled jobs to wait.\n Input:\n KEYS[1] 'stalled' (SET)\n KEYS[2] 'wait', (LIST)\n KEYS[3] 'active', (LIST)\n KEYS[4] 'stalled-check', (KEY)\n KEYS[5] 'meta', (KEY)\n KEYS[6] 'paused', (LIST)\n KEYS[7] 'marker'\n KEYS[8] 'event stream' (STREAM)\n ARGV[1] Max stalled job count\n ARGV[2] queue.toKey('')\n ARGV[3] timestamp\n ARGV[4] max check time\n Events:\n 'stalled' with stalled job id.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to trim events, default 10000.\n]]\n-- Includes\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nlocal function trimEvents(metaKey, eventStreamKey)\n local maxEvents = getOrSetMaxEvents(metaKey)\n if maxEvents then\n rcall("XTRIM", eventStreamKey, "MAXLEN", "~", maxEvents)\n else\n rcall("XTRIM", eventStreamKey, "MAXLEN", "~", 10000)\n end\nend\nlocal stalledKey = KEYS[1]\nlocal waitKey = KEYS[2]\nlocal activeKey = KEYS[3]\nlocal stalledCheckKey = KEYS[4]\nlocal metaKey = KEYS[5]\nlocal pausedKey = KEYS[6]\nlocal markerKey = KEYS[7]\nlocal eventStreamKey = KEYS[8]\nlocal maxStalledJobCount = tonumber(ARGV[1])\nlocal queueKeyPrefix = ARGV[2]\nlocal timestamp = ARGV[3]\nlocal maxCheckTime = ARGV[4]\nif rcall("EXISTS", stalledCheckKey) == 1 then\n return {}\nend\nrcall("SET", stalledCheckKey, timestamp, "PX", maxCheckTime)\n-- Trim events before emiting them to avoid trimming events emitted in this script\ntrimEvents(metaKey, eventStreamKey)\n-- Move all stalled jobs to wait\nlocal stalling = rcall('SMEMBERS', stalledKey)\nlocal stalled = {}\nif (#stalling > 0) then\n rcall('DEL', stalledKey)\n -- Remove from active list\n for i, jobId in ipairs(stalling) do\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n if string.sub(jobId, 1, 2) == "0:" then\n -- If the jobId is a delay marker ID we just remove it.\n rcall("LREM", activeKey, 1, jobId)\n else\n local jobKey = queueKeyPrefix .. jobId\n -- Check that the lock is also missing, then we can handle this job as really stalled.\n if (rcall("EXISTS", jobKey .. ":lock") == 0) then\n -- Remove from the active queue.\n local removed = rcall("LREM", activeKey, 1, jobId)\n if (removed > 0) then\n -- If this job has been stalled too many times, such as if it crashes the worker, then fail it.\n local stalledCount = rcall("HINCRBY", jobKey, "stc", 1)\n if stalledCount > maxStalledJobCount then\n local jobAttributes = rcall("HMGET", jobKey, "opts", "parent")\n local rawOpts = jobAttributes[1]\n local rawParentData = jobAttributes[2]\n local opts = cjson.decode(rawOpts)\n local failedReason = "job stalled more than allowable limit"\n rcall("HSET", jobKey, "defa", failedReason)\n end\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)\n -- Move the job back to the wait queue, to immediately be picked up by a waiting worker.\n addJobInTargetList(target, markerKey, "RPUSH", isPausedOrMaxed, jobId)\n rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId", jobId, 'prev', 'active')\n -- Emit the stalled event\n rcall("XADD", eventStreamKey, "*", "event", "stalled", "jobId", jobId)\n table.insert(stalled, jobId)\n end\n end\n end\n end\nend\n-- Mark potentially stalled jobs\nlocal active = rcall('LRANGE', activeKey, 0, -1)\nif (#active > 0) then\n for from, to in batches(#active, 7000) do\n rcall('SADD', stalledKey, unpack(active, from, to))\n end\nend\nreturn stalled\n`;t.moveStalledJobsToWait={name:"moveStalledJobsToWait",content:n,keys:8}},9258:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveToActive=void 0;const n=`--[[\n Move next job to be processed to active, lock it and fetch its data. The job\n may be delayed, in that case we need to move it to the delayed set instead.\n This operation guarantees that the worker owns the job during the lock\n expiration time. The worker is responsible of keeping the lock fresh\n so that no other worker picks this job again.\n Input:\n KEYS[1] wait key\n KEYS[2] active key\n KEYS[3] prioritized key\n KEYS[4] stream events key\n KEYS[5] stalled key\n -- Rate limiting\n KEYS[6] rate limiter key\n KEYS[7] delayed key\n -- Delayed jobs\n KEYS[8] paused key\n KEYS[9] meta key\n KEYS[10] pc priority counter\n -- Marker\n KEYS[11] marker key\n -- Arguments\n ARGV[1] key prefix\n ARGV[2] timestamp\n ARGV[3] opts\n opts - token - lock token\n opts - lockDuration\n opts - limiter\n opts - name - worker name\n]]\nlocal rcall = redis.call\nlocal waitKey = KEYS[1]\nlocal activeKey = KEYS[2]\nlocal eventStreamKey = KEYS[4]\nlocal rateLimiterKey = KEYS[6]\nlocal delayedKey = KEYS[7]\nlocal opts = cmsgpack.unpack(ARGV[3])\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\n--[[\n Function to get current rate limit ttl.\n]]\nlocal function getRateLimitTTL(maxJobs, rateLimiterKey)\n if maxJobs and maxJobs <= tonumber(rcall("GET", rateLimiterKey) or 0) then\n local pttl = rcall("PTTL", rateLimiterKey)\n if pttl == 0 then\n rcall("DEL", rateLimiterKey)\n end\n if pttl > 0 then\n return pttl\n end\n end\n return 0\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to move job from prioritized state to active.\n]]\nlocal function moveJobFromPrioritizedToActive(priorityKey, activeKey, priorityCounterKey)\n local prioritizedJob = rcall("ZPOPMIN", priorityKey)\n if #prioritizedJob > 0 then\n rcall("LPUSH", activeKey, prioritizedJob[1])\n return prioritizedJob[1]\n else\n rcall("DEL", priorityCounterKey)\n end\nend\n--[[\n Function to move job from wait state to active.\n Input:\n opts - token - lock token\n opts - lockDuration\n opts - limiter\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function prepareJobForProcessing(keyPrefix, rateLimiterKey, eventStreamKey,\n jobId, processedOn, maxJobs, markerKey, opts)\n local jobKey = keyPrefix .. jobId\n -- Check if we need to perform rate limiting.\n if maxJobs then\n local jobCounter = tonumber(rcall("INCR", rateLimiterKey))\n if jobCounter == 1 then\n local limiterDuration = opts['limiter'] and opts['limiter']['duration']\n local integerDuration = math.floor(math.abs(limiterDuration))\n rcall("PEXPIRE", rateLimiterKey, integerDuration)\n end\n end\n local lockKey = jobKey .. ':lock'\n -- get a lock\n if opts['token'] ~= "0" then\n rcall("SET", lockKey, opts['token'], "PX", opts['lockDuration'])\n end\n local optionalValues = {}\n if opts['name'] then\n -- Set "processedBy" field to the worker name\n table.insert(optionalValues, "pb")\n table.insert(optionalValues, opts['name'])\n end\n rcall("XADD", eventStreamKey, "*", "event", "active", "jobId", jobId, "prev", "waiting")\n rcall("HMSET", jobKey, "processedOn", processedOn, unpack(optionalValues))\n rcall("HINCRBY", jobKey, "ats", 1)\n addBaseMarkerIfNeeded(markerKey, false)\n -- rate limit delay must be 0 in this case to prevent adding more delay\n -- when job that is moved to active needs to be processed\n return {rcall("HGETALL", jobKey), jobId, 0, 0} -- get job data\nend\n--[[\n Updates the delay set, by moving delayed jobs that should\n be processed now to "wait".\n Events:\n 'waiting'\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n-- Try to get as much as 1000 jobs at once\nlocal function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,\n eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)\n local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)\n if (#jobs > 0) then\n rcall("ZREM", delayedKey, unpack(jobs))\n for _, jobId in ipairs(jobs) do\n local jobKey = prefix .. jobId\n local priority =\n tonumber(rcall("HGET", jobKey, "priority")) or 0\n if priority == 0 then\n -- LIFO or FIFO\n rcall("LPUSH", targetKey, jobId)\n else\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n end\n -- Emit waiting event\n rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",\n jobId, "prev", "delayed")\n rcall("HSET", jobKey, "delay", 0)\n end\n addBaseMarkerIfNeeded(markerKey, isPaused)\n end\nend\nlocal target, isPausedOrMaxed = getTargetQueueList(KEYS[9], activeKey, waitKey, KEYS[8])\n-- Check if there are delayed jobs that we can move to wait.\nlocal markerKey = KEYS[11]\npromoteDelayedJobs(delayedKey, markerKey, target, KEYS[3], eventStreamKey, ARGV[1],\n ARGV[2], KEYS[10], isPausedOrMaxed)\nlocal maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])\nlocal expireTime = getRateLimitTTL(maxJobs, rateLimiterKey)\n-- Check if we are rate limited first.\nif expireTime > 0 then return {0, 0, expireTime, 0} end\n-- paused or maxed queue\nif isPausedOrMaxed then return {0, 0, 0, 0} end\n-- no job ID, try non-blocking move from wait to active\nlocal jobId = rcall("RPOPLPUSH", waitKey, activeKey)\n-- Markers in waitlist DEPRECATED in v5: Will be completely removed in v6.\nif jobId and string.sub(jobId, 1, 2) == "0:" then\n rcall("LREM", activeKey, 1, jobId)\n jobId = rcall("RPOPLPUSH", waitKey, activeKey)\nend\nif jobId then\n return prepareJobForProcessing(ARGV[1], rateLimiterKey, eventStreamKey, jobId, ARGV[2],\n maxJobs, markerKey, opts)\nelse\n jobId = moveJobFromPrioritizedToActive(KEYS[3], activeKey, KEYS[10])\n if jobId then\n return prepareJobForProcessing(ARGV[1], rateLimiterKey, eventStreamKey, jobId, ARGV[2],\n maxJobs, markerKey, opts)\n end\nend\n-- Return the timestamp for the next delayed job if any.\nlocal nextTimestamp = getNextDelayedTimestamp(delayedKey)\nif nextTimestamp ~= nil then return {0, 0, 0, nextTimestamp} end\nreturn {0, 0, 0, 0}\n`;t.moveToActive={name:"moveToActive",content:n,keys:11}},4358:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveToDelayed=void 0;const n=`--[[\n Moves job from active to delayed set.\n Input:\n KEYS[1] marker key\n KEYS[2] active key\n KEYS[3] prioritized key\n KEYS[4] delayed key\n KEYS[5] job key\n KEYS[6] events stream\n KEYS[7] meta key\n KEYS[8] stalled key\n ARGV[1] key prefix\n ARGV[2] timestamp\n ARGV[3] the id of the job\n ARGV[4] queue token\n ARGV[5] delay value\n ARGV[6] skip attempt\n ARGV[7] optional job fields to update\n Output:\n 0 - OK\n -1 - Missing job.\n -3 - Job not in active set.\n Events:\n - delayed key.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\n--[[\n Function to update a bunch of fields in a job.\n]]\nlocal function updateJobFields(jobKey, msgpackedFields)\n if msgpackedFields and #msgpackedFields > 0 then\n local fieldsToUpdate = cmsgpack.unpack(msgpackedFields)\n if fieldsToUpdate then\n rcall("HMSET", jobKey, unpack(fieldsToUpdate))\n end\n end\nend\nlocal jobKey = KEYS[5]\nlocal metaKey = KEYS[7]\nlocal token = ARGV[4] \nif rcall("EXISTS", jobKey) == 1 then\n local errorCode = removeLock(jobKey, KEYS[8], token, ARGV[3])\n if errorCode < 0 then\n return errorCode\n end\n updateJobFields(jobKey, ARGV[7])\n local delayedKey = KEYS[4]\n local jobId = ARGV[3]\n local delay = tonumber(ARGV[5])\n local score, delayedTimestamp = getDelayedScore(delayedKey, ARGV[2], delay)\n local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)\n if numRemovedElements < 1 then return -3 end\n if ARGV[6] == "0" then\n rcall("HINCRBY", jobKey, "atm", 1)\n end\n rcall("HSET", jobKey, "delay", ARGV[5])\n local maxEvents = getOrSetMaxEvents(metaKey)\n rcall("ZADD", delayedKey, score, jobId)\n rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- Check if we need to push a marker job to wake up sleeping workers.\n local markerKey = KEYS[1]\n addDelayMarkerIfNeeded(markerKey, delayedKey)\n return 0\nelse\n return -1\nend\n`;t.moveToDelayed={name:"moveToDelayed",content:n,keys:8}},3141:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveToFinished=void 0;const n=`--[[\n Move job from active to a finished status (completed o failed)\n A job can only be moved to completed if it was active.\n The job must be locked before it can be moved to a finished status,\n and the lock must be released in this script.\n Input:\n KEYS[1] wait key\n KEYS[2] active key\n KEYS[3] prioritized key\n KEYS[4] event stream key\n KEYS[5] stalled key\n -- Rate limiting\n KEYS[6] rate limiter key\n KEYS[7] delayed key\n KEYS[8] paused key\n KEYS[9] meta key\n KEYS[10] pc priority counter\n KEYS[11] completed/failed key\n KEYS[12] jobId key\n KEYS[13] metrics key\n KEYS[14] marker key\n ARGV[1] jobId\n ARGV[2] timestamp\n ARGV[3] msg property returnvalue / failedReason\n ARGV[4] return value / failed reason\n ARGV[5] target (completed/failed)\n ARGV[6] fetch next?\n ARGV[7] keys prefix\n ARGV[8] opts\n ARGV[9] job fields to update\n opts - token - lock token\n opts - keepJobs\n opts - lockDuration - lock duration in milliseconds\n opts - attempts max attempts\n opts - maxMetricsSize\n opts - fpof - fail parent on fail\n opts - cpof - continue parent on fail\n opts - idof - ignore dependency on fail\n opts - rdof - remove dependency on fail\n opts - name - worker name\n Output:\n 0 OK\n -1 Missing key.\n -2 Missing lock.\n -3 Job not in active set\n -4 Job has pending children\n -6 Lock is not owned by this client\n -9 Job has failed children\n Events:\n 'completed/failed'\n]]\nlocal rcall = redis.call\n--- Includes\n--[[\n Functions to collect metrics based on a current and previous count of jobs.\n Granualarity is fixed at 1 minute.\n]]\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\nlocal function collectMetrics(metaKey, dataPointsList, maxDataPoints,\n timestamp)\n -- Increment current count\n local count = rcall("HINCRBY", metaKey, "count", 1) - 1\n -- Compute how many data points we need to add to the list, N.\n local prevTS = rcall("HGET", metaKey, "prevTS")\n if not prevTS then\n -- If prevTS is nil, set it to the current timestamp\n rcall("HSET", metaKey, "prevTS", timestamp, "prevCount", 0)\n return\n end\n local N = math.min(math.floor(timestamp / 60000) - math.floor(prevTS / 60000), tonumber(maxDataPoints))\n if N > 0 then\n local delta = count - rcall("HGET", metaKey, "prevCount")\n -- If N > 1, add N-1 zeros to the list\n if N > 1 then\n local points = {}\n points[1] = delta\n for i = 2, N do\n points[i] = 0\n end\n for from, to in batches(#points, 7000) do\n rcall("LPUSH", dataPointsList, unpack(points, from, to))\n end\n else\n -- LPUSH delta to the list\n rcall("LPUSH", dataPointsList, delta)\n end\n -- LTRIM to keep list to its max size\n rcall("LTRIM", dataPointsList, 0, maxDataPoints - 1)\n -- update prev count with current count\n rcall("HSET", metaKey, "prevCount", count, "prevTS", timestamp)\n end\nend\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\n--[[\n Function to get current rate limit ttl.\n]]\nlocal function getRateLimitTTL(maxJobs, rateLimiterKey)\n if maxJobs and maxJobs <= tonumber(rcall("GET", rateLimiterKey) or 0) then\n local pttl = rcall("PTTL", rateLimiterKey)\n if pttl == 0 then\n rcall("DEL", rateLimiterKey)\n end\n if pttl > 0 then\n return pttl\n end\n end\n return 0\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to move job from prioritized state to active.\n]]\nlocal function moveJobFromPrioritizedToActive(priorityKey, activeKey, priorityCounterKey)\n local prioritizedJob = rcall("ZPOPMIN", priorityKey)\n if #prioritizedJob > 0 then\n rcall("LPUSH", activeKey, prioritizedJob[1])\n return prioritizedJob[1]\n else\n rcall("DEL", priorityCounterKey)\n end\nend\n--[[\n Function to recursively move from waitingChildren to failed.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\n--[[\n Functions to remove jobs when removeOnFail option is provided.\n]]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\n--[[\n Functions to remove jobs by max age.\n]]\n-- Includes\nlocal function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,\n shouldRemoveDebounceKey)\n local start = timestamp - maxAge * 1000\n local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")\n for i, jobId in ipairs(jobIds) do\n removeJob(jobId, false, prefix, false --[[remove debounce key]])\n end\n rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)\nend\n--[[\n Functions to remove jobs by max count.\n]]\n-- Includes\nlocal function removeJobsByMaxCount(maxCount, targetSet, prefix)\n local start = maxCount\n local jobIds = rcall("ZREVRANGE", targetSet, start, -1)\n for i, jobId in ipairs(jobIds) do\n removeJob(jobId, false, prefix, false --[[remove debounce key]])\n end\n rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))\nend\nlocal function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestamp)\n local removeOnFailType = type(opts["removeOnFail"])\n if removeOnFailType == "number" then\n removeJobsByMaxCount(opts["removeOnFail"],\n failedKey, queueKeyPrefix)\n elseif removeOnFailType == "boolean" then\n if opts["removeOnFail"] then\n removeJob(jobId, false, queueKeyPrefix,\n false --[[remove debounce key]])\n rcall("ZREM", failedKey, jobId)\n end\n elseif removeOnFailType ~= "nil" then\n local maxAge = opts["removeOnFail"]["age"]\n local maxCount = opts["removeOnFail"]["count"]\n if maxAge ~= nil then\n removeJobsByMaxAge(timestamp, maxAge,\n failedKey, queueKeyPrefix)\n end\n if maxCount ~= nil and maxCount > 0 then\n removeJobsByMaxCount(maxCount, failedKey,\n queueKeyPrefix)\n end\n end \nend\nlocal moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobIdKey, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n local parentDelayedKey = parentQueueKey .. ":delayed"\n local parentPrioritizedKey = parentQueueKey .. ":prioritized"\n local parentWaitingChildrenOrDelayedKey\n local prevState\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then\n parentWaitingChildrenOrDelayedKey = parentWaitingChildrenKey\n prevState = "waiting-children"\n elseif rcall("ZSCORE", parentDelayedKey, parentId) then\n parentWaitingChildrenOrDelayedKey = parentDelayedKey\n prevState = "delayed"\n rcall("HSET", parentKey, "delay", 0)\n end\n if parentWaitingChildrenOrDelayedKey then\n rcall("ZREM", parentWaitingChildrenOrDelayedKey, parentId)\n local parentQueuePrefix = parentQueueKey .. ":"\n local parentFailedKey = parentQueueKey .. ":failed"\n local deferredFailure = "child " .. jobIdKey .. " failed"\n rcall("HSET", parentKey, "defa", deferredFailure)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n else\n if not rcall("ZSCORE", parentQueueKey .. ":failed", parentId) then\n local deferredFailure = "child " .. jobIdKey .. " failed"\n rcall("HSET", parentKey, "defa", deferredFailure)\n end\n end\n end\nend\nlocal moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedReason, timestamp)\n if rawParentData then\n local parentData = cjson.decode(rawParentData)\n local parentKey = parentData['queueKey'] .. ':' .. parentData['id']\n local parentDependenciesChildrenKey = parentKey .. ":dependencies"\n if parentData['fpof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n local parentUnsuccesssfulChildrenKey = parentKey .. ":unsuccessful"\n rcall("ZADD", parentUnsuccesssfulChildrenKey, timestamp, childKey)\n moveParentToFailedIfNeeded(\n parentData['queueKey'],\n parentKey,\n parentData['id'],\n childKey,\n timestamp\n )\n end\n elseif parentData['cpof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n local parentFailedChildrenKey = parentKey .. ":failed"\n rcall("HSET", parentFailedChildrenKey, childKey, failedReason)\n moveParentToWaitIfNeeded(parentData['queueKey'], parentKey, parentData['id'], timestamp)\n end\n elseif parentData['idof'] or parentData['rdof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n moveParentToWaitIfNoPendingDependencies(parentData['queueKey'], parentDependenciesChildrenKey,\n parentKey, parentData['id'], timestamp)\n if parentData['idof'] then\n local parentFailedChildrenKey = parentKey .. ":failed"\n rcall("HSET", parentFailedChildrenKey, childKey, failedReason)\n end\n end\n end\n end\nend\n--[[\n Function to move job from wait state to active.\n Input:\n opts - token - lock token\n opts - lockDuration\n opts - limiter\n]]\n-- Includes\nlocal function prepareJobForProcessing(keyPrefix, rateLimiterKey, eventStreamKey,\n jobId, processedOn, maxJobs, markerKey, opts)\n local jobKey = keyPrefix .. jobId\n -- Check if we need to perform rate limiting.\n if maxJobs then\n local jobCounter = tonumber(rcall("INCR", rateLimiterKey))\n if jobCounter == 1 then\n local limiterDuration = opts['limiter'] and opts['limiter']['duration']\n local integerDuration = math.floor(math.abs(limiterDuration))\n rcall("PEXPIRE", rateLimiterKey, integerDuration)\n end\n end\n local lockKey = jobKey .. ':lock'\n -- get a lock\n if opts['token'] ~= "0" then\n rcall("SET", lockKey, opts['token'], "PX", opts['lockDuration'])\n end\n local optionalValues = {}\n if opts['name'] then\n -- Set "processedBy" field to the worker name\n table.insert(optionalValues, "pb")\n table.insert(optionalValues, opts['name'])\n end\n rcall("XADD", eventStreamKey, "*", "event", "active", "jobId", jobId, "prev", "waiting")\n rcall("HMSET", jobKey, "processedOn", processedOn, unpack(optionalValues))\n rcall("HINCRBY", jobKey, "ats", 1)\n addBaseMarkerIfNeeded(markerKey, false)\n -- rate limit delay must be 0 in this case to prevent adding more delay\n -- when job that is moved to active needs to be processed\n return {rcall("HGETALL", jobKey), jobId, 0, 0} -- get job data\nend\n--[[\n Updates the delay set, by moving delayed jobs that should\n be processed now to "wait".\n Events:\n 'waiting'\n]]\n-- Includes\n-- Try to get as much as 1000 jobs at once\nlocal function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,\n eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)\n local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)\n if (#jobs > 0) then\n rcall("ZREM", delayedKey, unpack(jobs))\n for _, jobId in ipairs(jobs) do\n local jobKey = prefix .. jobId\n local priority =\n tonumber(rcall("HGET", jobKey, "priority")) or 0\n if priority == 0 then\n -- LIFO or FIFO\n rcall("LPUSH", targetKey, jobId)\n else\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n end\n -- Emit waiting event\n rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",\n jobId, "prev", "delayed")\n rcall("HSET", jobKey, "delay", 0)\n end\n addBaseMarkerIfNeeded(markerKey, isPaused)\n end\nend\n--[[\n Function to remove deduplication key if needed\n when a job is moved to completed or failed states.\n]]\nlocal function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,\n deduplicationId, jobId)\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local pttl = rcall("PTTL", deduplicationKey)\n if pttl == 0 then\n return rcall("DEL", deduplicationKey)\n end\n if pttl == -1 then\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\n end\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\n--[[\n Function to trim events, default 10000.\n]]\n-- Includes\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nlocal function trimEvents(metaKey, eventStreamKey)\n local maxEvents = getOrSetMaxEvents(metaKey)\n if maxEvents then\n rcall("XTRIM", eventStreamKey, "MAXLEN", "~", maxEvents)\n else\n rcall("XTRIM", eventStreamKey, "MAXLEN", "~", 10000)\n end\nend\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\n--[[\n Function to update a bunch of fields in a job.\n]]\nlocal function updateJobFields(jobKey, msgpackedFields)\n if msgpackedFields and #msgpackedFields > 0 then\n local fieldsToUpdate = cmsgpack.unpack(msgpackedFields)\n if fieldsToUpdate then\n rcall("HMSET", jobKey, unpack(fieldsToUpdate))\n end\n end\nend\nlocal jobIdKey = KEYS[12]\nif rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists\n -- Make sure it does not have pending dependencies\n -- It must happen before removing lock\n if ARGV[5] == "completed" then\n if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then\n return -4\n end\n if rcall("ZCARD", jobIdKey .. ":unsuccessful") ~= 0 then\n return -9\n end\n end\n local opts = cmsgpack.unpack(ARGV[8])\n local token = opts['token']\n local errorCode = removeLock(jobIdKey, KEYS[5], token, ARGV[1])\n if errorCode < 0 then\n return errorCode\n end\n updateJobFields(jobIdKey, ARGV[9]);\n local attempts = opts['attempts']\n local maxMetricsSize = opts['maxMetricsSize']\n local maxCount = opts['keepJobs']['count']\n local maxAge = opts['keepJobs']['age']\n local jobAttributes = rcall("HMGET", jobIdKey, "parentKey", "parent", "deid")\n local parentKey = jobAttributes[1] or ""\n local parentId = ""\n local parentQueueKey = ""\n if jobAttributes[2] then -- TODO: need to revisit this logic if it's still needed\n local jsonDecodedParent = cjson.decode(jobAttributes[2])\n parentId = jsonDecodedParent['id']\n parentQueueKey = jsonDecodedParent['queueKey']\n end\n local jobId = ARGV[1]\n local timestamp = ARGV[2]\n -- Remove from active list (if not active we shall return error)\n local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)\n if (numRemovedElements < 1) then\n return -3\n end\n local eventStreamKey = KEYS[4]\n local metaKey = KEYS[9]\n -- Trim events before emiting them to avoid trimming events emitted in this script\n trimEvents(metaKey, eventStreamKey)\n local prefix = ARGV[7]\n removeDeduplicationKeyIfNeededOnFinalization(prefix, jobAttributes[3], jobId)\n -- If job has a parent we need to\n -- 1) remove this job id from parents dependencies\n -- 2) move the job Id to parent "processed" set\n -- 3) push the results into parent "results" list\n -- 4) if parent's dependencies is empty, then move parent to "wait/paused". Note it may be a different queue!.\n if parentId == "" and parentKey ~= "" then\n parentId = getJobIdFromKey(parentKey)\n parentQueueKey = getJobKeyPrefix(parentKey, ":" .. parentId)\n end\n if parentId ~= "" then\n if ARGV[5] == "completed" then\n local dependenciesSet = parentKey .. ":dependencies"\n if rcall("SREM", dependenciesSet, jobIdKey) == 1 then\n updateParentDepsIfNeeded(parentKey, parentQueueKey, dependenciesSet, parentId, jobIdKey, ARGV[4],\n timestamp)\n end\n else\n moveChildFromDependenciesIfNeeded(jobAttributes[2], jobIdKey, ARGV[4], timestamp)\n end\n end\n local attemptsMade = rcall("HINCRBY", jobIdKey, "atm", 1)\n -- Remove job?\n if maxCount ~= 0 then\n local targetSet = KEYS[11]\n -- Add to complete/failed set\n rcall("ZADD", targetSet, timestamp, jobId)\n rcall("HSET", jobIdKey, ARGV[3], ARGV[4], "finishedOn", timestamp)\n -- "returnvalue" / "failedReason" and "finishedOn"\n if ARGV[5] == "failed" then\n rcall("HDEL", jobIdKey, "defa")\n end\n -- Remove old jobs?\n if maxAge ~= nil then\n removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)\n end\n if maxCount ~= nil and maxCount > 0 then\n removeJobsByMaxCount(maxCount, targetSet, prefix)\n end\n else\n removeJobKeys(jobIdKey)\n if parentKey ~= "" then\n -- TODO: when a child is removed when finished, result or failure in parent\n -- must not be deleted, those value references should be deleted when the parent\n -- is deleted\n removeParentDependencyKey(jobIdKey, false, parentKey, jobAttributes[3])\n end\n end\n rcall("XADD", eventStreamKey, "*", "event", ARGV[5], "jobId", jobId, ARGV[3], ARGV[4], "prev", "active")\n if ARGV[5] == "failed" then\n if tonumber(attemptsMade) >= tonumber(attempts) then\n rcall("XADD", eventStreamKey, "*", "event", "retries-exhausted", "jobId", jobId, "attemptsMade",\n attemptsMade)\n end\n end\n -- Collect metrics\n if maxMetricsSize ~= "" then\n collectMetrics(KEYS[13], KEYS[13] .. ':data', maxMetricsSize, timestamp)\n end\n -- Try to get next job to avoid an extra roundtrip if the queue is not closing,\n -- and not rate limited.\n if (ARGV[6] == "1") then\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2], KEYS[1], KEYS[8])\n local markerKey = KEYS[14]\n -- Check if there are delayed jobs that can be promoted\n promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[3], eventStreamKey, prefix, timestamp, KEYS[10],\n isPausedOrMaxed)\n local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])\n -- Check if we are rate limited first.\n local expireTime = getRateLimitTTL(maxJobs, KEYS[6])\n if expireTime > 0 then\n return {0, 0, expireTime, 0}\n end\n -- paused or maxed queue\n if isPausedOrMaxed then\n return {0, 0, 0, 0}\n end\n jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])\n if jobId then\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n if string.sub(jobId, 1, 2) == "0:" then\n rcall("LREM", KEYS[2], 1, jobId)\n -- If jobId is special ID 0:delay (delay greater than 0), then there is no job to process\n -- but if ID is 0:0, then there is at least 1 prioritized job to process\n if jobId == "0:0" then\n jobId = moveJobFromPrioritizedToActive(KEYS[3], KEYS[2], KEYS[10])\n return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,\n markerKey, opts)\n end\n else\n return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs, markerKey,\n opts)\n end\n else\n jobId = moveJobFromPrioritizedToActive(KEYS[3], KEYS[2], KEYS[10])\n if jobId then\n return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs, markerKey,\n opts)\n end\n end\n -- Return the timestamp for the next delayed job if any.\n local nextTimestamp = getNextDelayedTimestamp(KEYS[7])\n if nextTimestamp ~= nil then\n -- The result is guaranteed to be positive, since the\n -- ZRANGEBYSCORE command would have return a job otherwise.\n return {0, 0, 0, nextTimestamp}\n end\n end\n local waitLen = rcall("LLEN", KEYS[1])\n if waitLen == 0 then\n local activeLen = rcall("LLEN", KEYS[2])\n if activeLen == 0 then\n local prioritizedLen = rcall("ZCARD", KEYS[3])\n if prioritizedLen == 0 then\n rcall("XADD", eventStreamKey, "*", "event", "drained")\n end\n end\n end\n return 0\nelse\n return -1\nend\n`;t.moveToFinished={name:"moveToFinished",content:n,keys:14}},772:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveToWaitingChildren=void 0;const n=`--[[\n Moves job from active to waiting children set.\n Input:\n KEYS[1] active key\n KEYS[2] wait-children key\n KEYS[3] job key\n KEYS[4] job dependencies key\n KEYS[5] job unsuccessful key\n KEYS[6] stalled key\n KEYS[7] failed key\n KEYS[8] events key\n ARGV[1] token\n ARGV[2] child key\n ARGV[3] timestamp\n ARGV[4] jobId\n ARGV[5] prefix\n Output:\n 0 - OK\n 1 - There are not pending dependencies.\n -1 - Missing job.\n -2 - Missing lock\n -3 - Job not in active set\n]]\nlocal rcall = redis.call\nlocal activeKey = KEYS[1]\nlocal waitingChildrenKey = KEYS[2]\nlocal jobKey = KEYS[3]\nlocal jobDependenciesKey = KEYS[4]\nlocal jobUnsuccessfulKey = KEYS[5]\nlocal stalledKey = KEYS[6]\nlocal failedKey = KEYS[7]\nlocal timestamp = ARGV[3]\nlocal jobId = ARGV[4]\n--- Includes\n--[[\n Function to recursively move from waitingChildren to failed.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\n--[[\n Functions to remove jobs when removeOnFail option is provided.\n]]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\n--[[\n Functions to remove jobs by max age.\n]]\n-- Includes\nlocal function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,\n shouldRemoveDebounceKey)\n local start = timestamp - maxAge * 1000\n local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")\n for i, jobId in ipairs(jobIds) do\n removeJob(jobId, false, prefix, false --[[remove debounce key]])\n end\n rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)\nend\n--[[\n Functions to remove jobs by max count.\n]]\n-- Includes\nlocal function removeJobsByMaxCount(maxCount, targetSet, prefix)\n local start = maxCount\n local jobIds = rcall("ZREVRANGE", targetSet, start, -1)\n for i, jobId in ipairs(jobIds) do\n removeJob(jobId, false, prefix, false --[[remove debounce key]])\n end\n rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))\nend\nlocal function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestamp)\n local removeOnFailType = type(opts["removeOnFail"])\n if removeOnFailType == "number" then\n removeJobsByMaxCount(opts["removeOnFail"],\n failedKey, queueKeyPrefix)\n elseif removeOnFailType == "boolean" then\n if opts["removeOnFail"] then\n removeJob(jobId, false, queueKeyPrefix,\n false --[[remove debounce key]])\n rcall("ZREM", failedKey, jobId)\n end\n elseif removeOnFailType ~= "nil" then\n local maxAge = opts["removeOnFail"]["age"]\n local maxCount = opts["removeOnFail"]["count"]\n if maxAge ~= nil then\n removeJobsByMaxAge(timestamp, maxAge,\n failedKey, queueKeyPrefix)\n end\n if maxCount ~= nil and maxCount > 0 then\n removeJobsByMaxCount(maxCount, failedKey,\n queueKeyPrefix)\n end\n end \nend\nlocal moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobIdKey, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n local parentDelayedKey = parentQueueKey .. ":delayed"\n local parentPrioritizedKey = parentQueueKey .. ":prioritized"\n local parentWaitingChildrenOrDelayedKey\n local prevState\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then\n parentWaitingChildrenOrDelayedKey = parentWaitingChildrenKey\n prevState = "waiting-children"\n elseif rcall("ZSCORE", parentDelayedKey, parentId) then\n parentWaitingChildrenOrDelayedKey = parentDelayedKey\n prevState = "delayed"\n rcall("HSET", parentKey, "delay", 0)\n end\n if parentWaitingChildrenOrDelayedKey then\n rcall("ZREM", parentWaitingChildrenOrDelayedKey, parentId)\n local parentQueuePrefix = parentQueueKey .. ":"\n local parentFailedKey = parentQueueKey .. ":failed"\n local deferredFailure = "child " .. jobIdKey .. " failed"\n rcall("HSET", parentKey, "defa", deferredFailure)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n else\n if not rcall("ZSCORE", parentQueueKey .. ":failed", parentId) then\n local deferredFailure = "child " .. jobIdKey .. " failed"\n rcall("HSET", parentKey, "defa", deferredFailure)\n end\n end\n end\nend\nlocal moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedReason, timestamp)\n if rawParentData then\n local parentData = cjson.decode(rawParentData)\n local parentKey = parentData['queueKey'] .. ':' .. parentData['id']\n local parentDependenciesChildrenKey = parentKey .. ":dependencies"\n if parentData['fpof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n local parentUnsuccesssfulChildrenKey = parentKey .. ":unsuccessful"\n rcall("ZADD", parentUnsuccesssfulChildrenKey, timestamp, childKey)\n moveParentToFailedIfNeeded(\n parentData['queueKey'],\n parentKey,\n parentData['id'],\n childKey,\n timestamp\n )\n end\n elseif parentData['cpof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n local parentFailedChildrenKey = parentKey .. ":failed"\n rcall("HSET", parentFailedChildrenKey, childKey, failedReason)\n moveParentToWaitIfNeeded(parentData['queueKey'], parentKey, parentData['id'], timestamp)\n end\n elseif parentData['idof'] or parentData['rdof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n moveParentToWaitIfNoPendingDependencies(parentData['queueKey'], parentDependenciesChildrenKey,\n parentKey, parentData['id'], timestamp)\n if parentData['idof'] then\n local parentFailedChildrenKey = parentKey .. ":failed"\n rcall("HSET", parentFailedChildrenKey, childKey, failedReason)\n end\n end\n end\n end\nend\n--[[\n Function to remove deduplication key if needed\n when a job is moved to completed or failed states.\n]]\nlocal function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,\n deduplicationId, jobId)\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local pttl = rcall("PTTL", deduplicationKey)\n if pttl == 0 then\n return rcall("DEL", deduplicationKey)\n end\n if pttl == -1 then\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\n end\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\nlocal function moveToWaitingChildren(activeKey, waitingChildrenKey, jobId,\n timestamp)\n local score = tonumber(timestamp)\n local numRemovedElements = rcall("LREM", activeKey, -1, jobId)\n if(numRemovedElements < 1) then\n return -3\n end\n rcall("ZADD", waitingChildrenKey, score, jobId)\n return 0\nend\nif rcall("EXISTS", jobKey) == 1 then\n if rcall("ZCARD", jobUnsuccessfulKey) ~= 0 then\n -- TODO: refactor this logic in an include later\n local jobAttributes = rcall("HMGET", jobKey, "parent", "deid", "opts")\n removeDeduplicationKeyIfNeededOnFinalization(ARGV[5], jobAttributes[2], jobId)\n local failedReason = "children are failed"\n rcall("ZADD", failedKey, timestamp, jobId)\n rcall("HSET", jobKey, "finishedOn", timestamp)\n rcall("XADD", KEYS[8], "*", "event", "failed", "jobId", jobId, "failedReason",\n failedReason, "prev", "active")\n local rawParentData = jobAttributes[1]\n local rawOpts = jobAttributes[3]\n local opts = cjson.decode(rawOpts)\n moveChildFromDependenciesIfNeeded(rawParentData, jobKey, failedReason, timestamp)\n removeJobsOnFail(ARGV[5], failedKey, jobId, opts, timestamp)\n return 0\n else\n if ARGV[2] ~= "" then\n if rcall("SISMEMBER", jobDependenciesKey, ARGV[2]) ~= 0 then\n local errorCode = removeLock(jobKey, stalledKey, ARGV[1], jobId)\n if errorCode < 0 then\n return errorCode\n end\n return moveToWaitingChildren(activeKey, waitingChildrenKey, jobId, timestamp)\n end\n return 1\n else\n if rcall("SCARD", jobDependenciesKey) ~= 0 then \n local errorCode = removeLock(jobKey, stalledKey, ARGV[1], jobId)\n if errorCode < 0 then\n return errorCode\n end\n return moveToWaitingChildren(activeKey, waitingChildrenKey, jobId, timestamp)\n end\n return 1\n end \n end\nend\nreturn -1\n`;t.moveToWaitingChildren={name:"moveToWaitingChildren",content:n,keys:8}},8345:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.obliterate=void 0;const n=`--[[\n Completely obliterates a queue and all of its contents\n This command completely destroys a queue including all of its jobs, current or past \n leaving no trace of its existence. Since this script needs to iterate to find all the job\n keys, consider that this call may be slow for very large queues.\n The queue needs to be "paused" or it will return an error\n If the queue has currently active jobs then the script by default will return error,\n however this behaviour can be overrided using the 'force' option.\n Input:\n KEYS[1] meta\n KEYS[2] base\n ARGV[1] count\n ARGV[2] force\n]]\nlocal maxCount = tonumber(ARGV[1])\nlocal baseKey = KEYS[2]\nlocal rcall = redis.call\n-- Includes\n--[[\n Functions to remove jobs.\n]]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\nlocal function removeJobs(keys, hard, baseKey, max)\n for i, key in ipairs(keys) do\n removeJob(key, hard, baseKey, true --[[remove debounce key]])\n end\n return max - #keys\nend\n--[[\n Functions to remove jobs.\n]]\n-- Includes\n--[[\n Function to filter out jobs to ignore from a table.\n]]\nlocal function filterOutJobsToIgnore(jobs, jobsToIgnore)\n local filteredJobs = {}\n for i = 1, #jobs do\n if not jobsToIgnore[jobs[i]] then\n table.insert(filteredJobs, jobs[i])\n end\n end\n return filteredJobs\nend\nlocal function getListItems(keyName, max)\n return rcall('LRANGE', keyName, 0, max - 1)\nend\nlocal function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)\n local jobs = getListItems(keyName, max)\n if jobsToIgnore then\n jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)\n end\n local count = removeJobs(jobs, hard, baseKey, max)\n rcall("LTRIM", keyName, #jobs, -1)\n return count\nend\n-- Includes\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n Function to get ZSet items.\n]]\nlocal function getZSetItems(keyName, max)\n return rcall('ZRANGE', keyName, 0, max - 1)\nend\nlocal function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)\n local jobs = getZSetItems(keyName, max)\n if jobsToIgnore then\n jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)\n end\n local count = removeJobs(jobs, hard, baseKey, max)\n if(#jobs > 0) then\n for from, to in batches(#jobs, 7000) do\n rcall("ZREM", keyName, unpack(jobs, from, to))\n end\n end\n return count\nend\nlocal function removeLockKeys(keys)\n for i, key in ipairs(keys) do\n rcall("DEL", baseKey .. key .. ':lock')\n end\nend\n-- 1) Check if paused, if not return with error.\nif rcall("HEXISTS", KEYS[1], "paused") ~= 1 then\n return -1 -- Error, NotPaused\nend\n-- 2) Check if there are active jobs, if there are and not "force" return error.\nlocal activeKey = baseKey .. 'active'\nlocal activeJobs = getListItems(activeKey, maxCount)\nif (#activeJobs > 0) then\n if(ARGV[2] == "") then \n return -2 -- Error, ExistActiveJobs\n end\nend\nremoveLockKeys(activeJobs)\nmaxCount = removeJobs(activeJobs, true, baseKey, maxCount)\nrcall("LTRIM", activeKey, #activeJobs, -1)\nif(maxCount <= 0) then\n return 1\nend\nlocal delayedKey = baseKey .. 'delayed'\nmaxCount = removeZSetJobs(delayedKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nlocal repeatKey = baseKey .. 'repeat'\nlocal repeatJobsIds = getZSetItems(repeatKey, maxCount)\nfor i, key in ipairs(repeatJobsIds) do\n local jobKey = repeatKey .. ":" .. key\n rcall("DEL", jobKey)\nend\nif(#repeatJobsIds > 0) then\n for from, to in batches(#repeatJobsIds, 7000) do\n rcall("ZREM", repeatKey, unpack(repeatJobsIds, from, to))\n end\nend\nmaxCount = maxCount - #repeatJobsIds\nif(maxCount <= 0) then\n return 1\nend\nlocal completedKey = baseKey .. 'completed'\nmaxCount = removeZSetJobs(completedKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nlocal waitKey = baseKey .. 'paused'\nmaxCount = removeListJobs(waitKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nlocal prioritizedKey = baseKey .. 'prioritized'\nmaxCount = removeZSetJobs(prioritizedKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nlocal failedKey = baseKey .. 'failed'\nmaxCount = removeZSetJobs(failedKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nif(maxCount > 0) then\n rcall("DEL",\n baseKey .. 'events',\n baseKey .. 'delay', \n baseKey .. 'stalled-check',\n baseKey .. 'stalled',\n baseKey .. 'id',\n baseKey .. 'pc',\n baseKey .. 'meta',\n baseKey .. 'metrics:completed',\n baseKey .. 'metrics:completed:data',\n baseKey .. 'metrics:failed',\n baseKey .. 'metrics:failed:data')\n return 0\nelse\n return 1\nend\n`;t.obliterate={name:"obliterate",content:n,keys:2}},7441:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.paginate=void 0;const n=`--[[\n Paginate a set or hash\n Input:\n KEYS[1] key pointing to the set or hash to be paginated.\n ARGV[1] page start offset\n ARGV[2] page end offset (-1 for all the elements)\n ARGV[3] cursor\n ARGV[4] offset\n ARGV[5] max iterations\n ARGV[6] fetch jobs?\n Output:\n [cursor, offset, items, numItems]\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to achieve pagination for a set or hash.\n This function simulates pagination in the most efficient way possible\n for a set using sscan or hscan.\n The main limitation is that sets are not order preserving, so the\n pagination is not stable. This means that if the set is modified\n between pages, the same element may appear in different pages.\n]] -- Maximum number of elements to be returned by sscan per iteration.\nlocal maxCount = 100\n-- Finds the cursor, and returns the first elements available for the requested page.\nlocal function findPage(key, command, pageStart, pageSize, cursor, offset,\n maxIterations, fetchJobs)\n local items = {}\n local jobs = {}\n local iterations = 0\n repeat\n -- Iterate over the set using sscan/hscan.\n local result = rcall(command, key, cursor, "COUNT", maxCount)\n cursor = result[1]\n local members = result[2]\n local step = 1\n if command == "HSCAN" then\n step = 2\n end\n if #members == 0 then\n -- If the result is empty, we can return the result.\n return cursor, offset, items, jobs\n end\n local chunkStart = offset\n local chunkEnd = offset + #members / step\n local pageEnd = pageStart + pageSize\n if chunkEnd < pageStart then\n -- If the chunk is before the page, we can skip it.\n offset = chunkEnd\n elseif chunkStart > pageEnd then\n -- If the chunk is after the page, we can return the result.\n return cursor, offset, items, jobs\n else\n -- If the chunk is overlapping the page, we need to add the elements to the result.\n for i = 1, #members, step do\n if offset >= pageEnd then\n return cursor, offset, items, jobs\n end\n if offset >= pageStart then\n local index = #items + 1\n if fetchJobs ~= nil then\n jobs[#jobs+1] = rcall("HGETALL", members[i])\n end\n if step == 2 then\n items[index] = {members[i], members[i + 1]}\n else\n items[index] = members[i]\n end\n end\n offset = offset + 1\n end\n end\n iterations = iterations + 1\n until cursor == "0" or iterations >= maxIterations\n return cursor, offset, items, jobs\nend\nlocal key = KEYS[1]\nlocal scanCommand = "SSCAN"\nlocal countCommand = "SCARD"\nlocal type = rcall("TYPE", key)["ok"]\nif type == "none" then\n return {0, 0, {}, 0}\nelseif type == "hash" then\n scanCommand = "HSCAN"\n countCommand = "HLEN"\nelseif type ~= "set" then\n return\n redis.error_reply("Pagination is only supported for sets and hashes.")\nend\nlocal numItems = rcall(countCommand, key)\nlocal startOffset = tonumber(ARGV[1])\nlocal endOffset = tonumber(ARGV[2])\nif endOffset == -1 then \n endOffset = numItems\nend\nlocal pageSize = (endOffset - startOffset) + 1\nlocal cursor, offset, items, jobs = findPage(key, scanCommand, startOffset,\n pageSize, ARGV[3], tonumber(ARGV[4]),\n tonumber(ARGV[5]), ARGV[6])\nreturn {cursor, offset, items, numItems, jobs}\n`;t.paginate={name:"paginate",content:n,keys:1}},5759:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.pause=void 0;const n=`--[[\n Pauses or resumes a queue globably.\n Input:\n KEYS[1] 'wait' or 'paused''\n KEYS[2] 'paused' or 'wait'\n KEYS[3] 'meta'\n KEYS[4] 'prioritized'\n KEYS[5] events stream key\n KEYS[6] 'delayed'\n KEYS|7] 'marker'\n ARGV[1] 'paused' or 'resumed'\n Event:\n publish paused or resumed event.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\nlocal markerKey = KEYS[7]\nlocal hasJobs = rcall("EXISTS", KEYS[1]) == 1\n--TODO: check this logic to be reused when changing a delay\nif hasJobs then rcall("RENAME", KEYS[1], KEYS[2]) end\nif ARGV[1] == "paused" then\n rcall("HSET", KEYS[3], "paused", 1)\n rcall("DEL", markerKey)\nelse\n rcall("HDEL", KEYS[3], "paused")\n if hasJobs or rcall("ZCARD", KEYS[4]) > 0 then\n -- Add marker if there are waiting or priority jobs\n rcall("ZADD", markerKey, 0, "0")\n else\n addDelayMarkerIfNeeded(markerKey, KEYS[6])\n end\nend\nrcall("XADD", KEYS[5], "*", "event", ARGV[1]);\n`;t.pause={name:"pause",content:n,keys:7}},2347:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.promote=void 0;const n=`--[[\n Promotes a job that is currently "delayed" to the "waiting" state\n Input:\n KEYS[1] 'delayed'\n KEYS[2] 'wait'\n KEYS[3] 'paused'\n KEYS[4] 'meta'\n KEYS[5] 'prioritized'\n KEYS[6] 'active'\n KEYS[7] 'pc' priority counter\n KEYS[8] 'event stream'\n KEYS[9] 'marker'\n ARGV[1] queue.toKey('')\n ARGV[2] jobId\n Output:\n 0 - OK\n -3 - Job not in delayed zset.\n Events:\n 'waiting'\n]]\nlocal rcall = redis.call\nlocal jobId = ARGV[2]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nif rcall("ZREM", KEYS[1], jobId) == 1 then\n local jobKey = ARGV[1] .. jobId\n local priority = tonumber(rcall("HGET", jobKey, "priority")) or 0\n local metaKey = KEYS[4]\n local markerKey = KEYS[9]\n -- Remove delayed "marker" from the wait list if there is any.\n -- Since we are adding a job we do not need the marker anymore.\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[6], KEYS[2], KEYS[3])\n local marker = rcall("LINDEX", target, 0)\n if marker and string.sub(marker, 1, 2) == "0:" then rcall("LPOP", target) end\n if priority == 0 then\n -- LIFO or FIFO\n addJobInTargetList(target, markerKey, "LPUSH", isPausedOrMaxed, jobId)\n else\n addJobWithPriority(markerKey, KEYS[5], priority, jobId, KEYS[7], isPausedOrMaxed)\n end\n -- Emit waiting event (wait..ing@token)\n rcall("XADD", KEYS[8], "*", "event", "waiting", "jobId", jobId, "prev",\n "delayed");\n rcall("HSET", jobKey, "delay", 0)\n return 0\nelse\n return -3\nend\n`;t.promote={name:"promote",content:n,keys:9}},7461:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.releaseLock=void 0;const n=`--[[\n Release lock\n Input:\n KEYS[1] 'lock',\n ARGV[1] token\n ARGV[2] lock duration in milliseconds\n Output:\n "OK" if lock extented succesfully.\n]]\nlocal rcall = redis.call\nif rcall("GET", KEYS[1]) == ARGV[1] then\n return rcall("DEL", KEYS[1])\nelse\n return 0\nend\n`;t.releaseLock={name:"releaseLock",content:n,keys:1}},6732:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeChildDependency=void 0;const n=`--[[\n Break parent-child dependency by removing\n child reference from parent\n Input:\n KEYS[1] 'key' prefix,\n ARGV[1] job key\n ARGV[2] parent key\n Output:\n 0 - OK\n 1 - There is not relationship.\n -1 - Missing job key\n -5 - Missing parent key\n]]\nlocal rcall = redis.call\nlocal jobKey = ARGV[1]\nlocal parentKey = ARGV[2]\n-- Includes\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nif rcall("EXISTS", jobKey) ~= 1 then return -1 end\nif rcall("EXISTS", parentKey) ~= 1 then return -5 end\nif removeParentDependencyKey(jobKey, false, parentKey, KEYS[1], nil) then\n rcall("HDEL", jobKey, "parentKey", "parent")\n return 0\nelse\n return 1\nend`;t.removeChildDependency={name:"removeChildDependency",content:n,keys:1}},9825:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeJob=void 0;const n=`--[[\n Remove a job from all the statuses it may be in as well as all its data.\n In order to be able to remove a job, it cannot be active.\n Input:\n KEYS[1] jobKey\n KEYS[2] repeat key\n ARGV[1] jobId\n ARGV[2] remove children\n ARGV[3] queue prefix\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to check if the job belongs to a job scheduler and\n current delayed job matches with jobId\n]]\nlocal function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)\n local repeatJobKey = rcall("HGET", jobKey, "rjk")\n if repeatJobKey then\n local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)\n if prevMillis then\n local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis\n return jobId == currentDelayedJobId\n end\n end\n return false\nend\n--[[\n Function to recursively check if there are no locks\n on the jobs to be removed.\n returns:\n boolean\n]]\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\nlocal function isLocked( prefix, jobId, removeChildren)\n local jobKey = prefix .. jobId;\n -- Check if this job is locked\n local lockKey = jobKey .. ':lock'\n local lock = rcall("GET", lockKey)\n if not lock then\n if removeChildren == "1" then\n local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")\n if (#dependencies > 0) then\n for i, childJobKey in ipairs(dependencies) do\n -- We need to get the jobId for this job.\n local childJobId = getJobIdFromKey(childJobKey)\n local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)\n local result = isLocked( childJobPrefix, childJobId, removeChildren )\n if result then\n return true\n end\n end\n end\n end\n return false\n end\n return true\nend\n--[[\n Remove a job from all the statuses it may be in as well as all its data,\n including its children. Active children can be ignored.\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove from any state.\n returns:\n prev state\n]]\nlocal function removeJobFromAnyState( prefix, jobId)\n -- We start with the ZSCORE checks, since they have O(1) complexity\n if rcall("ZSCORE", prefix .. "completed", jobId) then\n rcall("ZREM", prefix .. "completed", jobId)\n return "completed"\n elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then\n rcall("ZREM", prefix .. "waiting-children", jobId)\n return "waiting-children"\n elseif rcall("ZSCORE", prefix .. "delayed", jobId) then\n rcall("ZREM", prefix .. "delayed", jobId)\n return "delayed"\n elseif rcall("ZSCORE", prefix .. "failed", jobId) then\n rcall("ZREM", prefix .. "failed", jobId)\n return "failed"\n elseif rcall("ZSCORE", prefix .. "prioritized", jobId) then\n rcall("ZREM", prefix .. "prioritized", jobId)\n return "prioritized"\n -- We remove only 1 element from the list, since we assume they are not added multiple times\n elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then\n return "wait"\n elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then\n return "paused"\n elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then\n return "active"\n end\n return "unknown"\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal removeJobChildren\nlocal removeJobWithChildren\nremoveJobChildren = function(prefix, jobKey, options)\n -- Check if this job has children\n -- If so, we are going to try to remove the children recursively in a depth-first way\n -- because if some job is locked, we must exit with an error.\n if not options.ignoreProcessed then\n local processed = rcall("HGETALL", jobKey .. ":processed")\n if #processed > 0 then\n for i = 1, #processed, 2 do\n local childJobId = getJobIdFromKey(processed[i])\n local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n local failed = rcall("HGETALL", jobKey .. ":failed")\n if #failed > 0 then\n for i = 1, #failed, 2 do\n local childJobId = getJobIdFromKey(failed[i])\n local childJobPrefix = getJobKeyPrefix(failed[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n local unsuccessful = rcall("ZRANGE", jobKey .. ":unsuccessful", 0, -1)\n if #unsuccessful > 0 then\n for i = 1, #unsuccessful, 1 do\n local childJobId = getJobIdFromKey(unsuccessful[i])\n local childJobPrefix = getJobKeyPrefix(unsuccessful[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n end\n local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")\n if #dependencies > 0 then\n for i, childJobKey in ipairs(dependencies) do\n local childJobId = getJobIdFromKey(childJobKey)\n local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\nend\nremoveJobWithChildren = function(prefix, jobId, parentKey, options)\n local jobKey = prefix .. jobId\n if options.ignoreLocked then\n if isLocked(prefix, jobId) then\n return\n end\n end\n -- Check if job is in the failed zset\n local failedSet = prefix .. "failed"\n if not (options.ignoreProcessed and rcall("ZSCORE", failedSet, jobId)) then\n removeParentDependencyKey(jobKey, false, parentKey, nil)\n if options.removeChildren then\n removeJobChildren(prefix, jobKey, options)\n end\n local prev = removeJobFromAnyState(prefix, jobId)\n removeDeduplicationKeyIfNeededOnRemoval(prefix, jobKey, jobId)\n if removeJobKeys(jobKey) > 0 then\n local metaKey = prefix .. "meta"\n local maxEvents = getOrSetMaxEvents(metaKey)\n rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",\n "jobId", jobId, "prev", prev)\n end\n end\nend\nlocal jobId = ARGV[1]\nlocal shouldRemoveChildren = ARGV[2]\nlocal prefix = ARGV[3]\nlocal jobKey = KEYS[1]\nlocal repeatKey = KEYS[2]\nif isJobSchedulerJob(jobId, jobKey, repeatKey) then\n return -8\nend\nif not isLocked(prefix, jobId, shouldRemoveChildren) then\n local options = {\n removeChildren = shouldRemoveChildren == "1",\n ignoreProcessed = false,\n ignoreLocked = false\n }\n removeJobWithChildren(prefix, jobId, nil, options)\n return 1\nend\nreturn 0\n`;t.removeJob={name:"removeJob",content:n,keys:2}},7645:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeJobScheduler=void 0;const n=`--[[\n Removes a job scheduler and its next scheduled job.\n Input:\n KEYS[1] job schedulers key\n KEYS[2] delayed jobs key\n KEYS[3] events key\n ARGV[1] job scheduler id\n ARGV[2] prefix key\n Output:\n 0 - OK\n 1 - Missing repeat job\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal jobSchedulerId = ARGV[1]\nlocal prefix = ARGV[2]\nlocal millis = rcall("ZSCORE", KEYS[1], jobSchedulerId)\nif millis then\n -- Delete next programmed job.\n local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. millis\n if(rcall("ZREM", KEYS[2], delayedJobId) == 1) then\n removeJobKeys(prefix .. delayedJobId)\n rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", delayedJobId, "prev", "delayed")\n end\nend\nif(rcall("ZREM", KEYS[1], jobSchedulerId) == 1) then\n rcall("DEL", KEYS[1] .. ":" .. jobSchedulerId)\n return 0\nend\nreturn 1\n`;t.removeJobScheduler={name:"removeJobScheduler",content:n,keys:3}},3938:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeRepeatable=void 0;const n=`--[[\n Removes a repeatable job\n Input:\n KEYS[1] repeat jobs key\n KEYS[2] delayed jobs key\n KEYS[3] events key\n ARGV[1] old repeat job id\n ARGV[2] options concat\n ARGV[3] repeat job key\n ARGV[4] prefix key\n Output:\n 0 - OK\n 1 - Missing repeat job\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\nlocal millis = rcall("ZSCORE", KEYS[1], ARGV[2])\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n-- legacy removal TODO: remove in next breaking change\nif millis then\n -- Delete next programmed job.\n local repeatJobId = ARGV[1] .. millis\n if(rcall("ZREM", KEYS[2], repeatJobId) == 1) then\n removeJobKeys(ARGV[4] .. repeatJobId)\n rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed");\n end\nend\nif(rcall("ZREM", KEYS[1], ARGV[2]) == 1) then\n return 0\nend\n-- new removal\nmillis = rcall("ZSCORE", KEYS[1], ARGV[3])\nif millis then\n -- Delete next programmed job.\n local repeatJobId = "repeat:" .. ARGV[3] .. ":" .. millis\n if(rcall("ZREM", KEYS[2], repeatJobId) == 1) then\n removeJobKeys(ARGV[4] .. repeatJobId)\n rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed")\n end\nend\nif(rcall("ZREM", KEYS[1], ARGV[3]) == 1) then\n rcall("DEL", KEYS[1] .. ":" .. ARGV[3])\n return 0\nend\nreturn 1\n`;t.removeRepeatable={name:"removeRepeatable",content:n,keys:3}},3940:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeUnprocessedChildren=void 0;const n=`--[[\n Remove a job from all the statuses it may be in as well as all its data.\n In order to be able to remove a job, it cannot be active.\n Input:\n KEYS[1] jobKey\n KEYS[2] meta key\n ARGV[1] prefix\n ARGV[2] jobId\n Events:\n 'removed' for every children removed\n]]\n-- Includes\n--[[\n Remove a job from all the statuses it may be in as well as all its data,\n including its children. Active children can be ignored.\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check if the job belongs to a job scheduler and\n current delayed job matches with jobId\n]]\nlocal function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)\n local repeatJobKey = rcall("HGET", jobKey, "rjk")\n if repeatJobKey then\n local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)\n if prevMillis then\n local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis\n return jobId == currentDelayedJobId\n end\n end\n return false\nend\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove from any state.\n returns:\n prev state\n]]\nlocal function removeJobFromAnyState( prefix, jobId)\n -- We start with the ZSCORE checks, since they have O(1) complexity\n if rcall("ZSCORE", prefix .. "completed", jobId) then\n rcall("ZREM", prefix .. "completed", jobId)\n return "completed"\n elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then\n rcall("ZREM", prefix .. "waiting-children", jobId)\n return "waiting-children"\n elseif rcall("ZSCORE", prefix .. "delayed", jobId) then\n rcall("ZREM", prefix .. "delayed", jobId)\n return "delayed"\n elseif rcall("ZSCORE", prefix .. "failed", jobId) then\n rcall("ZREM", prefix .. "failed", jobId)\n return "failed"\n elseif rcall("ZSCORE", prefix .. "prioritized", jobId) then\n rcall("ZREM", prefix .. "prioritized", jobId)\n return "prioritized"\n -- We remove only 1 element from the list, since we assume they are not added multiple times\n elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then\n return "wait"\n elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then\n return "paused"\n elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then\n return "active"\n end\n return "unknown"\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\n--[[\n Function to recursively check if there are no locks\n on the jobs to be removed.\n returns:\n boolean\n]]\nlocal function isLocked( prefix, jobId, removeChildren)\n local jobKey = prefix .. jobId;\n -- Check if this job is locked\n local lockKey = jobKey .. ':lock'\n local lock = rcall("GET", lockKey)\n if not lock then\n if removeChildren == "1" then\n local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")\n if (#dependencies > 0) then\n for i, childJobKey in ipairs(dependencies) do\n -- We need to get the jobId for this job.\n local childJobId = getJobIdFromKey(childJobKey)\n local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)\n local result = isLocked( childJobPrefix, childJobId, removeChildren )\n if result then\n return true\n end\n end\n end\n end\n return false\n end\n return true\nend\nlocal removeJobChildren\nlocal removeJobWithChildren\nremoveJobChildren = function(prefix, jobKey, options)\n -- Check if this job has children\n -- If so, we are going to try to remove the children recursively in a depth-first way\n -- because if some job is locked, we must exit with an error.\n if not options.ignoreProcessed then\n local processed = rcall("HGETALL", jobKey .. ":processed")\n if #processed > 0 then\n for i = 1, #processed, 2 do\n local childJobId = getJobIdFromKey(processed[i])\n local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n local failed = rcall("HGETALL", jobKey .. ":failed")\n if #failed > 0 then\n for i = 1, #failed, 2 do\n local childJobId = getJobIdFromKey(failed[i])\n local childJobPrefix = getJobKeyPrefix(failed[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n local unsuccessful = rcall("ZRANGE", jobKey .. ":unsuccessful", 0, -1)\n if #unsuccessful > 0 then\n for i = 1, #unsuccessful, 1 do\n local childJobId = getJobIdFromKey(unsuccessful[i])\n local childJobPrefix = getJobKeyPrefix(unsuccessful[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n end\n local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")\n if #dependencies > 0 then\n for i, childJobKey in ipairs(dependencies) do\n local childJobId = getJobIdFromKey(childJobKey)\n local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\nend\nremoveJobWithChildren = function(prefix, jobId, parentKey, options)\n local jobKey = prefix .. jobId\n if options.ignoreLocked then\n if isLocked(prefix, jobId) then\n return\n end\n end\n -- Check if job is in the failed zset\n local failedSet = prefix .. "failed"\n if not (options.ignoreProcessed and rcall("ZSCORE", failedSet, jobId)) then\n removeParentDependencyKey(jobKey, false, parentKey, nil)\n if options.removeChildren then\n removeJobChildren(prefix, jobKey, options)\n end\n local prev = removeJobFromAnyState(prefix, jobId)\n removeDeduplicationKeyIfNeededOnRemoval(prefix, jobKey, jobId)\n if removeJobKeys(jobKey) > 0 then\n local metaKey = prefix .. "meta"\n local maxEvents = getOrSetMaxEvents(metaKey)\n rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",\n "jobId", jobId, "prev", prev)\n end\n end\nend\nlocal prefix = ARGV[1]\nlocal jobId = ARGV[2]\nlocal jobKey = KEYS[1]\nlocal metaKey = KEYS[2]\nlocal options = {\n removeChildren = "1",\n ignoreProcessed = true,\n ignoreLocked = true\n}\nremoveJobChildren(prefix, jobKey, options) \n`;t.removeUnprocessedChildren={name:"removeUnprocessedChildren",content:n,keys:2}},1409:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.reprocessJob=void 0;const n=`--[[\n Attempts to reprocess a job\n Input:\n KEYS[1] job key\n KEYS[2] events stream\n KEYS[3] job state\n KEYS[4] wait key\n KEYS[5] meta\n KEYS[6] paused key\n KEYS[7] active key\n KEYS[8] marker key\n ARGV[1] job.id\n ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'\n ARGV[3] propVal - failedReason/returnvalue\n ARGV[4] prev state - failed/completed\n Output:\n 1 means the operation was a success\n -1 means the job does not exist\n -3 means the job was not found in the expected set.\n]]\nlocal rcall = redis.call;\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nif rcall("EXISTS", KEYS[1]) == 1 then\n local jobId = ARGV[1]\n if (rcall("ZREM", KEYS[3], jobId) == 1) then\n rcall("HDEL", KEYS[1], "finishedOn", "processedOn", ARGV[3])\n local target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[7], KEYS[4], KEYS[6])\n addJobInTargetList(target, KEYS[8], ARGV[2], isPausedOrMaxed, jobId)\n local maxEvents = getOrSetMaxEvents(KEYS[5])\n -- Emit waiting event\n rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", jobId, "prev", ARGV[4]);\n return 1\n else\n return -3\n end\nelse\n return -1\nend\n`;t.reprocessJob={name:"reprocessJob",content:n,keys:8}},2800:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.retryJob=void 0;const n=`--[[\n Retries a failed job by moving it back to the wait queue.\n Input:\n KEYS[1] 'active',\n KEYS[2] 'wait'\n KEYS[3] 'paused'\n KEYS[4] job key\n KEYS[5] 'meta'\n KEYS[6] events stream\n KEYS[7] delayed key\n KEYS[8] prioritized key\n KEYS[9] 'pc' priority counter\n KEYS[10] 'marker'\n KEYS[11] 'stalled'\n ARGV[1] key prefix\n ARGV[2] timestamp\n ARGV[3] pushCmd\n ARGV[4] jobId\n ARGV[5] token\n ARGV[6] optional job fields to update\n Events:\n 'waiting'\n Output:\n 0 - OK\n -1 - Missing key\n -2 - Missing lock\n -3 - Job not in active set\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Updates the delay set, by moving delayed jobs that should\n be processed now to "wait".\n Events:\n 'waiting'\n]]\n-- Includes\n-- Try to get as much as 1000 jobs at once\nlocal function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,\n eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)\n local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)\n if (#jobs > 0) then\n rcall("ZREM", delayedKey, unpack(jobs))\n for _, jobId in ipairs(jobs) do\n local jobKey = prefix .. jobId\n local priority =\n tonumber(rcall("HGET", jobKey, "priority")) or 0\n if priority == 0 then\n -- LIFO or FIFO\n rcall("LPUSH", targetKey, jobId)\n else\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n end\n -- Emit waiting event\n rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",\n jobId, "prev", "delayed")\n rcall("HSET", jobKey, "delay", 0)\n end\n addBaseMarkerIfNeeded(markerKey, isPaused)\n end\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\n--[[\n Function to update a bunch of fields in a job.\n]]\nlocal function updateJobFields(jobKey, msgpackedFields)\n if msgpackedFields and #msgpackedFields > 0 then\n local fieldsToUpdate = cmsgpack.unpack(msgpackedFields)\n if fieldsToUpdate then\n rcall("HMSET", jobKey, unpack(fieldsToUpdate))\n end\n end\nend\nlocal target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[1], KEYS[2], KEYS[3])\nlocal markerKey = KEYS[10]\n-- Check if there are delayed jobs that we can move to wait.\n-- test example: when there are delayed jobs between retries\npromoteDelayedJobs(KEYS[7], markerKey, target, KEYS[8], KEYS[6], ARGV[1], ARGV[2], KEYS[9], isPausedOrMaxed)\nlocal jobKey = KEYS[4]\nif rcall("EXISTS", jobKey) == 1 then\n local errorCode = removeLock(jobKey, KEYS[11], ARGV[5], ARGV[4]) \n if errorCode < 0 then\n return errorCode\n end\n updateJobFields(jobKey, ARGV[6])\n local numRemovedElements = rcall("LREM", KEYS[1], -1, ARGV[4])\n if (numRemovedElements < 1) then return -3 end\n local priority = tonumber(rcall("HGET", jobKey, "priority")) or 0\n --need to re-evaluate after removing job from active\n isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[1])\n -- Standard or priority add\n if priority == 0 then\n addJobInTargetList(target, markerKey, ARGV[3], isPausedOrMaxed, ARGV[4])\n else\n addJobWithPriority(markerKey, KEYS[8], priority, ARGV[4], KEYS[9], isPausedOrMaxed)\n end\n rcall("HINCRBY", jobKey, "atm", 1)\n local maxEvents = getOrSetMaxEvents(KEYS[5])\n -- Emit waiting event\n rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", ARGV[4], "prev", "failed")\n return 0\nelse\n return -1\nend\n`;t.retryJob={name:"retryJob",content:n,keys:11}},8447:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.saveStacktrace=void 0;const n=`--[[\n Save stacktrace and failedReason.\n Input:\n KEYS[1] job key\n ARGV[1] stacktrace\n ARGV[2] failedReason\n Output:\n 0 - OK\n -1 - Missing key\n]]\nlocal rcall = redis.call\nif rcall("EXISTS", KEYS[1]) == 1 then\n rcall("HMSET", KEYS[1], "stacktrace", ARGV[1], "failedReason", ARGV[2])\n return 0\nelse\n return -1\nend\n`;t.saveStacktrace={name:"saveStacktrace",content:n,keys:1}},5726:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.updateData=void 0;const n=`--[[\n Update job data\n Input:\n KEYS[1] Job id key\n ARGV[1] data\n Output:\n 0 - OK\n -1 - Missing job.\n]]\nlocal rcall = redis.call\nif rcall("EXISTS",KEYS[1]) == 1 then -- // Make sure job exists\n rcall("HSET", KEYS[1], "data", ARGV[1])\n return 0\nelse\n return -1\nend\n`;t.updateData={name:"updateData",content:n,keys:1}},6538:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.updateJobScheduler=void 0;const n=`--[[\n Updates a job scheduler and adds next delayed job\n Input:\n KEYS[1] 'repeat' key\n KEYS[2] 'delayed'\n KEYS[3] 'wait' key\n KEYS[4] 'paused' key\n KEYS[5] 'meta'\n KEYS[6] 'prioritized' key\n KEYS[7] 'marker',\n KEYS[8] 'id'\n KEYS[9] events stream key\n KEYS[10] 'pc' priority counter\n KEYS[11] producer key\n KEYS[12] 'active' key\n ARGV[1] next milliseconds\n ARGV[2] jobs scheduler id\n ARGV[3] Json stringified delayed data\n ARGV[4] msgpacked delayed opts\n ARGV[5] timestamp\n ARGV[6] prefix key\n ARGV[7] producer id\n Output:\n next delayed job id - OK\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[1]\nlocal delayedKey = KEYS[2]\nlocal waitKey = KEYS[3]\nlocal pausedKey = KEYS[4]\nlocal metaKey = KEYS[5]\nlocal prioritizedKey = KEYS[6]\nlocal nextMillis = ARGV[1]\nlocal jobSchedulerId = ARGV[2]\nlocal timestamp = ARGV[5]\nlocal prefixKey = ARGV[6]\nlocal producerId = ARGV[7]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Adds a delayed job to the queue by doing the following:\n - Creates a new job key with the job data.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\nlocal function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,\n maxEvents, markerKey, delay)\n local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay))\n rcall("ZADD", delayedKey, score, jobId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- mark that a delayed job is available\n addDelayMarkerIfNeeded(markerKey, delayedKey)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePaused(queueMetaKey)\n return rcall("HEXISTS", queueMetaKey, "paused") == 1\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\nlocal function addJobFromScheduler(jobKey, jobId, rawOpts, waitKey, pausedKey, activeKey, metaKey, \n prioritizedKey, priorityCounter, delayedKey, markerKey, eventsKey, name, maxEvents, timestamp,\n data, jobSchedulerId)\n local opts = cmsgpack.unpack(rawOpts)\n local delay, priority = storeJob(eventsKey, jobKey, jobId, name, data,\n opts, timestamp, nil, nil, jobSchedulerId)\n if delay ~= 0 then\n addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, markerKey, delay)\n else\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)\n -- Standard or priority add\n if priority == 0 then\n local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'\n addJobInTargetList(target, markerKey, pushCmd, isPausedOrMaxed, jobId)\n else\n -- Priority add\n addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounter, isPausedOrMaxed)\n end\n -- Emit waiting event\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting", "jobId", jobId)\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nlocal schedulerKey = repeatKey .. ":" .. jobSchedulerId\nlocal nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis\nlocal nextDelayedJobKey = schedulerKey .. ":" .. nextMillis\n-- Validate that scheduler exists.\nlocal prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)\nif prevMillis then\n local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis\n if producerId == currentDelayedJobId then\n local eventsKey = KEYS[9]\n local maxEvents = getOrSetMaxEvents(metaKey)\n if rcall("EXISTS", nextDelayedJobKey) ~= 1 then\n local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")\n rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)\n rcall("HINCRBY", schedulerKey, "ic", 1)\n rcall("INCR", KEYS[8])\n -- TODO: remove this workaround in next breaking change,\n -- all job-schedulers must save job data\n local templateData = schedulerAttributes[2] or ARGV[3]\n if templateData and templateData ~= '{}' then\n rcall("HSET", schedulerKey, "data", templateData)\n end\n addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey, \n KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey, \n schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)\n -- TODO: remove this workaround in next breaking change\n if KEYS[11] ~= "" then\n rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)\n end\n return nextDelayedJobId .. "" -- convert to string\n else\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", nextDelayedJobId)\n end\n end\nend\n`;t.updateJobScheduler={name:"updateJobScheduler",content:n,keys:12}},4331:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.updateProgress=void 0;const n=`--[[\n Update job progress\n Input:\n KEYS[1] Job id key\n KEYS[2] event stream key\n KEYS[3] meta key\n ARGV[1] id\n ARGV[2] progress\n Output:\n 0 - OK\n -1 - Missing job.\n Event:\n progress(jobId, progress)\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nif rcall("EXISTS", KEYS[1]) == 1 then -- // Make sure job exists\n local maxEvents = getOrSetMaxEvents(KEYS[3])\n rcall("HSET", KEYS[1], "progress", ARGV[2])\n rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event", "progress",\n "jobId", ARGV[1], "data", ARGV[2]);\n return 0\nelse\n return -1\nend\n`;t.updateProgress={name:"updateProgress",content:n,keys:3}},2391:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.updateRepeatableJobMillis=void 0;const n=`--[[\n Adds a repeatable job\n Input:\n KEYS[1] 'repeat' key\n ARGV[1] next milliseconds\n ARGV[2] custom key\n ARGV[3] legacy custom key TODO: remove this logic in next breaking change\n Output:\n repeatableKey - OK\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[1]\nlocal nextMillis = ARGV[1]\nlocal customKey = ARGV[2]\nlocal legacyCustomKey = ARGV[3]\nif rcall("ZSCORE", repeatKey, customKey) then\n rcall("ZADD", repeatKey, nextMillis, customKey)\n return customKey\nelseif rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then\n rcall("ZADD", repeatKey, nextMillis, legacyCustomKey)\n return legacyCustomKey\nend\nreturn ''\n`;t.updateRepeatableJobMillis={name:"updateRepeatableJobMillis",content:n,keys:1}},1812:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7638:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},3819:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9560:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(1812),t);r.__exportStar(n(7638),t);r.__exportStar(n(3819),t);r.__exportStar(n(5137),t);r.__exportStar(n(7520),t);r.__exportStar(n(4036),t);r.__exportStar(n(3721),t);r.__exportStar(n(456),t);r.__exportStar(n(3755),t);r.__exportStar(n(6227),t);r.__exportStar(n(7977),t)},7520:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},4036:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},6227:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},3721:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},456:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},5137:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},3755:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},7977:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8547:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.trace=t.removeUndefinedFields=t.QUEUE_EVENT_SUFFIX=t.toString=t.errorToJSON=t.parseObjectValues=t.isRedisVersionLowerThan=t.createScripts=t.childSend=t.asyncSend=t.isNotConnectionError=t.DELAY_TIME_1=t.DELAY_TIME_5=t.clientCommandMessageReg=t.getParentKey=t.removeAllQueueData=t.decreaseMaxListeners=t.isRedisCluster=t.isRedisInstance=t.optsEncodeMap=t.optsDecodeMap=t.invertObject=t.increaseMaxListeners=t.delay=t.objectToFlatArray=t.array2obj=t.isEmpty=t.lengthInUtf8Bytes=t.tryCatch=t.errorObject=void 0;const r=n(8721);const i=n(387);const a=n(5249);const s=n(2348);const o=n(6991);t.errorObject={value:null};function tryCatch(e,n,r){try{return e.apply(n,r)}catch(e){t.errorObject.value=e;return t.errorObject}}t.tryCatch=tryCatch;function lengthInUtf8Bytes(e){return Buffer.byteLength(e,"utf8")}t.lengthInUtf8Bytes=lengthInUtf8Bytes;function isEmpty(e){for(const t in e){if(Object.prototype.hasOwnProperty.call(e,t)){return false}}return true}t.isEmpty=isEmpty;function array2obj(e){const t={};for(let n=0;n<e.length;n+=2){t[e[n]]=e[n+1]}return t}t.array2obj=array2obj;function objectToFlatArray(e){const t=[];for(const n in e){if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==undefined){t[t.length]=n;t[t.length]=e[n]}}return t}t.objectToFlatArray=objectToFlatArray;function delay(e,t){return new Promise((n=>{let r;const callback=()=>{t===null||t===void 0?void 0:t.signal.removeEventListener("abort",callback);clearTimeout(r);n()};r=setTimeout(callback,e);t===null||t===void 0?void 0:t.signal.addEventListener("abort",callback)}))}t.delay=delay;function increaseMaxListeners(e,t){const n=e.getMaxListeners();e.setMaxListeners(n+t)}t.increaseMaxListeners=increaseMaxListeners;function invertObject(e){return Object.entries(e).reduce(((e,[t,n])=>{e[n]=t;return e}),{})}t.invertObject=invertObject;t.optsDecodeMap={de:"deduplication",fpof:"failParentOnFailure",cpof:"continueParentOnFailure",idof:"ignoreDependencyOnFailure",kl:"keepLogs",rdof:"removeDependencyOnFailure"};t.optsEncodeMap=Object.assign(Object.assign({},invertObject(t.optsDecodeMap)),{debounce:"de"});function isRedisInstance(e){if(!e){return false}const t=["connect","disconnect","duplicate"];return t.every((t=>typeof e[t]==="function"))}t.isRedisInstance=isRedisInstance;function isRedisCluster(e){return isRedisInstance(e)&&e.isCluster}t.isRedisCluster=isRedisCluster;function decreaseMaxListeners(e,t){increaseMaxListeners(e,-t)}t.decreaseMaxListeners=decreaseMaxListeners;async function removeAllQueueData(e,t,n=process.env.BULLMQ_TEST_PREFIX||"bull"){if(e instanceof r.Cluster){return Promise.resolve(false)}const i=`${n}:${t}:*`;const a=await new Promise(((t,n)=>{const r=e.scanStream({match:i});r.on("data",(t=>{if(t.length){const r=e.pipeline();t.forEach((e=>{r.del(e)}));r.exec().catch((e=>{n(e)}))}}));r.on("end",(()=>t()));r.on("error",(e=>n(e)))}));await a;await e.quit()}t.removeAllQueueData=removeAllQueueData;function getParentKey(e){if(e){return`${e.queue}:${e.id}`}}t.getParentKey=getParentKey;t.clientCommandMessageReg=/ERR unknown command ['`]\s*client\s*['`]/;t.DELAY_TIME_5=5e3;t.DELAY_TIME_1=100;function isNotConnectionError(e){const t=`${e.message}`;return t!==i.CONNECTION_CLOSED_ERROR_MSG&&!t.includes("ECONNREFUSED")}t.isNotConnectionError=isNotConnectionError;const asyncSend=(e,t)=>new Promise(((n,r)=>{if(typeof e.send==="function"){e.send(t,(e=>{if(e){r(e)}else{n()}}))}else if(typeof e.postMessage==="function"){n(e.postMessage(t))}else{n()}}));t.asyncSend=asyncSend;const childSend=(e,n)=>(0,t.asyncSend)(e,n);t.childSend=childSend;const createScripts=e=>new a.Scripts({keys:e.keys,client:e.client,get redisVersion(){return e.redisVersion},toKey:e.toKey,opts:e.opts,closing:e.closing});t.createScripts=createScripts;const isRedisVersionLowerThan=(e,t)=>{const n=s.valid(s.coerce(e));return s.lt(n,t)};t.isRedisVersionLowerThan=isRedisVersionLowerThan;const parseObjectValues=e=>{const t={};for(const n of Object.entries(e)){t[n[0]]=JSON.parse(n[1])}return t};t.parseObjectValues=parseObjectValues;const getCircularReplacer=e=>{const t=new WeakSet;t.add(e);return(e,n)=>{if(typeof n==="object"&&n!==null){if(t.has(n)){return"[Circular]"}t.add(n)}return n}};const errorToJSON=e=>{const t={};Object.getOwnPropertyNames(e).forEach((function(n){t[n]=e[n]}));return JSON.parse(JSON.stringify(t,getCircularReplacer(e)))};t.errorToJSON=errorToJSON;const l=1/0;const toString=e=>{if(e==null){return""}if(typeof e==="string"){return e}if(Array.isArray(e)){return`${e.map((e=>e==null?e:(0,t.toString)(e)))}`}if(typeof e=="symbol"||Object.prototype.toString.call(e)=="[object Symbol]"){return e.toString()}const n=`${e}`;return n==="0"&&1/e===-l?"-0":n};t.toString=toString;t.QUEUE_EVENT_SUFFIX=":qe";function removeUndefinedFields(e){const t={};for(const n in e){if(e[n]!==undefined){t[n]=e[n]}}return t}t.removeUndefinedFields=removeUndefinedFields;async function trace(e,t,n,r,i,a,s){if(!e){return a()}else{const{tracer:l,contextManager:c}=e;const d=c.active();let u;if(s){u=c.fromMetadata(d,s)}const p=i?`${r} ${i}`:r;const f=l.startSpan(p,{kind:t},u);try{f.setAttributes({[o.TelemetryAttributes.QueueName]:n,[o.TelemetryAttributes.QueueOperation]:r});let e;let i;if(t===o.SpanKind.CONSUMER&&u){e=f.setSpanOnContext(u)}else{e=f.setSpanOnContext(d)}if(a.length==2){i=c.getMetadata(e)}return await c.with(e,(()=>a(f,i)))}catch(e){f.recordException(e);throw e}finally{f.end()}}}t.trace=trace},6614:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.version=void 0;t.version="5.56.4"},3288:function(e){var t=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];var n=function toUTF8Array(e){var t;var n=0;var r=0;var i=[];var a=e.length;for(;n<a;n++){t=e.charCodeAt(n);if(t<128){i[r++]=t}else if(t<2048){i[r++]=t>>6|192;i[r++]=t&63|128}else if((t&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320){t=65536+((t&1023)<<10)+(e.charCodeAt(++n)&1023);i[r++]=t>>18|240;i[r++]=t>>12&63|128;i[r++]=t>>6&63|128;i[r++]=t&63|128}else{i[r++]=t>>12|224;i[r++]=t>>6&63|128;i[r++]=t&63|128}}return i};var r=e.exports=function generate(e){var r;var i=0;var a=-1;var s=0;var o=0;var l=typeof e==="string"?n(e):e;var c=l.length;while(i<c){r=l[i++];if(a===-1){if(r===123){a=i}}else if(r!==125){o=t[(r^o>>8)&255]^o<<8}else if(i-1!==a){return o&16383}s=t[(r^s>>8)&255]^s<<8}return s&16383};e.exports.generateMulti=function generateMulti(e){var t=1;var n=e.length;var i=r(e[0]);while(t<n){if(r(e[t++])!==i)return-1}return i}},2799:function(e,t,n){"use strict";var r=n(8588);CronDate.prototype.addYear=function(){this._date=this._date.plus({years:1})};CronDate.prototype.addMonth=function(){this._date=this._date.plus({months:1}).startOf("month")};CronDate.prototype.addDay=function(){this._date=this._date.plus({days:1}).startOf("day")};CronDate.prototype.addHour=function(){var e=this._date;this._date=this._date.plus({hours:1}).startOf("hour");if(this._date<=e){this._date=this._date.plus({hours:1})}};CronDate.prototype.addMinute=function(){var e=this._date;this._date=this._date.plus({minutes:1}).startOf("minute");if(this._date<e){this._date=this._date.plus({hours:1})}};CronDate.prototype.addSecond=function(){var e=this._date;this._date=this._date.plus({seconds:1}).startOf("second");if(this._date<e){this._date=this._date.plus({hours:1})}};CronDate.prototype.subtractYear=function(){this._date=this._date.minus({years:1})};CronDate.prototype.subtractMonth=function(){this._date=this._date.minus({months:1}).endOf("month").startOf("second")};CronDate.prototype.subtractDay=function(){this._date=this._date.minus({days:1}).endOf("day").startOf("second")};CronDate.prototype.subtractHour=function(){var e=this._date;this._date=this._date.minus({hours:1}).endOf("hour").startOf("second");if(this._date>=e){this._date=this._date.minus({hours:1})}};CronDate.prototype.subtractMinute=function(){var e=this._date;this._date=this._date.minus({minutes:1}).endOf("minute").startOf("second");if(this._date>e){this._date=this._date.minus({hours:1})}};CronDate.prototype.subtractSecond=function(){var e=this._date;this._date=this._date.minus({seconds:1}).startOf("second");if(this._date>e){this._date=this._date.minus({hours:1})}};CronDate.prototype.getDate=function(){return this._date.day};CronDate.prototype.getFullYear=function(){return this._date.year};CronDate.prototype.getDay=function(){var e=this._date.weekday;return e==7?0:e};CronDate.prototype.getMonth=function(){return this._date.month-1};CronDate.prototype.getHours=function(){return this._date.hour};CronDate.prototype.getMinutes=function(){return this._date.minute};CronDate.prototype.getSeconds=function(){return this._date.second};CronDate.prototype.getMilliseconds=function(){return this._date.millisecond};CronDate.prototype.getTime=function(){return this._date.valueOf()};CronDate.prototype.getUTCDate=function(){return this._getUTC().day};CronDate.prototype.getUTCFullYear=function(){return this._getUTC().year};CronDate.prototype.getUTCDay=function(){var e=this._getUTC().weekday;return e==7?0:e};CronDate.prototype.getUTCMonth=function(){return this._getUTC().month-1};CronDate.prototype.getUTCHours=function(){return this._getUTC().hour};CronDate.prototype.getUTCMinutes=function(){return this._getUTC().minute};CronDate.prototype.getUTCSeconds=function(){return this._getUTC().second};CronDate.prototype.toISOString=function(){return this._date.toUTC().toISO()};CronDate.prototype.toJSON=function(){return this._date.toJSON()};CronDate.prototype.setDate=function(e){this._date=this._date.set({day:e})};CronDate.prototype.setFullYear=function(e){this._date=this._date.set({year:e})};CronDate.prototype.setDay=function(e){this._date=this._date.set({weekday:e})};CronDate.prototype.setMonth=function(e){this._date=this._date.set({month:e+1})};CronDate.prototype.setHours=function(e){this._date=this._date.set({hour:e})};CronDate.prototype.setMinutes=function(e){this._date=this._date.set({minute:e})};CronDate.prototype.setSeconds=function(e){this._date=this._date.set({second:e})};CronDate.prototype.setMilliseconds=function(e){this._date=this._date.set({millisecond:e})};CronDate.prototype._getUTC=function(){return this._date.toUTC()};CronDate.prototype.toString=function(){return this.toDate().toString()};CronDate.prototype.toDate=function(){return this._date.toJSDate()};CronDate.prototype.isLastDayOfMonth=function(){var e=this._date.plus({days:1}).startOf("day");return this._date.month!==e.month};CronDate.prototype.isLastWeekdayOfMonth=function(){var e=this._date.plus({days:7}).startOf("day");return this._date.month!==e.month};function CronDate(e,t){var n={zone:t};if(!e){this._date=r.DateTime.local()}else if(e instanceof CronDate){this._date=e._date}else if(e instanceof Date){this._date=r.DateTime.fromJSDate(e,n)}else if(typeof e==="number"){this._date=r.DateTime.fromMillis(e,n)}else if(typeof e==="string"){this._date=r.DateTime.fromISO(e,n);this._date.isValid||(this._date=r.DateTime.fromRFC2822(e,n));this._date.isValid||(this._date=r.DateTime.fromSQL(e,n));this._date.isValid||(this._date=r.DateTime.fromFormat(e,"EEE, d MMM yyyy HH:mm:ss",n))}if(!this._date||!this._date.isValid){throw new Error("CronDate: unhandled timestamp: "+JSON.stringify(e))}if(t&&t!==this._date.zoneName){this._date=this._date.setZone(t)}}e.exports=CronDate},8937:function(e,t,n){"use strict";var r=n(2799);var i=n(4173);var a=1e4;function CronExpression(e,t){this._options=t;this._utc=t.utc||false;this._tz=this._utc?"UTC":t.tz;this._currentDate=new r(t.currentDate,this._tz);this._startDate=t.startDate?new r(t.startDate,this._tz):null;this._endDate=t.endDate?new r(t.endDate,this._tz):null;this._isIterator=t.iterator||false;this._hasIterated=false;this._nthDayOfWeek=t.nthDayOfWeek||0;this.fields=CronExpression._freezeFields(e)}CronExpression.map=["second","minute","hour","dayOfMonth","month","dayOfWeek"];CronExpression.predefined={"@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *"};CronExpression.constraints=[{min:0,max:59,chars:[]},{min:0,max:59,chars:[]},{min:0,max:23,chars:[]},{min:1,max:31,chars:["L"]},{min:1,max:12,chars:[]},{min:0,max:7,chars:["L"]}];CronExpression.daysInMonth=[31,29,31,30,31,30,31,31,30,31,30,31];CronExpression.aliases={month:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},dayOfWeek:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}};CronExpression.parseDefaults=["0","*","*","*","*","*"];CronExpression.standardValidCharacters=/^[,*\d/-]+$/;CronExpression.dayOfWeekValidCharacters=/^[?,*\dL#/-]+$/;CronExpression.dayOfMonthValidCharacters=/^[?,*\dL/-]+$/;CronExpression.validCharacters={second:CronExpression.standardValidCharacters,minute:CronExpression.standardValidCharacters,hour:CronExpression.standardValidCharacters,dayOfMonth:CronExpression.dayOfMonthValidCharacters,month:CronExpression.standardValidCharacters,dayOfWeek:CronExpression.dayOfWeekValidCharacters};CronExpression._isValidConstraintChar=function _isValidConstraintChar(e,t){if(typeof t!=="string"){return false}return e.chars.some((function(e){return t.indexOf(e)>-1}))};CronExpression._parseField=function _parseField(e,t,n){switch(e){case"month":case"dayOfWeek":var r=CronExpression.aliases[e];t=t.replace(/[a-z]{3}/gi,(function(e){e=e.toLowerCase();if(typeof r[e]!=="undefined"){return r[e]}else{throw new Error('Validation error, cannot resolve alias "'+e+'"')}}));break}if(!CronExpression.validCharacters[e].test(t)){throw new Error("Invalid characters, got value: "+t)}if(t.indexOf("*")!==-1){t=t.replace(/\*/g,n.min+"-"+n.max)}else if(t.indexOf("?")!==-1){t=t.replace(/\?/g,n.min+"-"+n.max)}function parseSequence(t){var r=[];function handleResult(t){if(t instanceof Array){for(var i=0,a=t.length;i<a;i++){var s=t[i];if(CronExpression._isValidConstraintChar(n,s)){r.push(s);continue}if(typeof s!=="number"||Number.isNaN(s)||s<n.min||s>n.max){throw new Error("Constraint error, got value "+s+" expected range "+n.min+"-"+n.max)}r.push(s)}}else{if(CronExpression._isValidConstraintChar(n,t)){r.push(t);return}var o=+t;if(Number.isNaN(o)||o<n.min||o>n.max){throw new Error("Constraint error, got value "+t+" expected range "+n.min+"-"+n.max)}if(e==="dayOfWeek"){o=o%7}r.push(o)}}var i=t.split(",");if(!i.every((function(e){return e.length>0}))){throw new Error("Invalid list value format")}if(i.length>1){for(var a=0,s=i.length;a<s;a++){handleResult(parseRepeat(i[a]))}}else{handleResult(parseRepeat(t))}r.sort(CronExpression._sortCompareFn);return r}function parseRepeat(e){var t=1;var r=e.split("/");if(r.length>2){throw new Error("Invalid repeat: "+e)}if(r.length>1){if(r[0]==+r[0]){r=[r[0]+"-"+n.max,r[1]]}return parseRange(r[0],r[r.length-1])}return parseRange(e,t)}function parseRange(t,r){var i=[];var a=t.split("-");if(a.length>1){if(a.length<2){return+t}if(!a[0].length){if(!a[1].length){throw new Error("Invalid range: "+t)}return+t}var s=+a[0];var o=+a[1];if(Number.isNaN(s)||Number.isNaN(o)||s<n.min||o>n.max){throw new Error("Constraint error, got range "+s+"-"+o+" expected range "+n.min+"-"+n.max)}else if(s>o){throw new Error("Invalid range: "+t)}var l=+r;if(Number.isNaN(l)||l<=0){throw new Error("Constraint error, cannot repeat at every "+l+" time.")}if(e==="dayOfWeek"&&o%7===0){i.push(0)}for(var c=s,d=o;c<=d;c++){var u=i.indexOf(c)!==-1;if(!u&&l>0&&l%r===0){l=1;i.push(c)}else{l++}}return i}return Number.isNaN(+t)?t:+t}return parseSequence(t)};CronExpression._sortCompareFn=function(e,t){var n=typeof e==="number";var r=typeof t==="number";if(n&&r){return e-t}if(!n&&r){return 1}if(n&&!r){return-1}return e.localeCompare(t)};CronExpression._handleMaxDaysInMonth=function(e){if(e.month.length===1){var t=CronExpression.daysInMonth[e.month[0]-1];if(e.dayOfMonth[0]>t){throw new Error("Invalid explicit day of month definition")}return e.dayOfMonth.filter((function(e){return e==="L"?true:e<=t})).sort(CronExpression._sortCompareFn)}};CronExpression._freezeFields=function(e){for(var t=0,n=CronExpression.map.length;t<n;++t){var r=CronExpression.map[t];var i=e[r];e[r]=Object.freeze(i)}return Object.freeze(e)};CronExpression.prototype._applyTimezoneShift=function(e,t,n){if(n==="Month"||n==="Day"){var r=e.getTime();e[t+n]();var i=e.getTime();if(r===i){if(e.getMinutes()===0&&e.getSeconds()===0){e.addHour()}else if(e.getMinutes()===59&&e.getSeconds()===59){e.subtractHour()}}}else{var a=e.getHours();e[t+n]();var s=e.getHours();var o=s-a;if(o===2){if(this.fields.hour.length!==24){this._dstStart=s}}else if(o===0&&e.getMinutes()===0&&e.getSeconds()===0){if(this.fields.hour.length!==24){this._dstEnd=s}}}};CronExpression.prototype._findSchedule=function _findSchedule(e){function matchSchedule(e,t){for(var n=0,r=t.length;n<r;n++){if(t[n]>=e){return t[n]===e}}return t[0]===e}function isNthDayMatch(e,t){if(t<6){if(e.getDate()<8&&t===1){return true}var n=e.getDate()%7?1:0;var r=e.getDate()-e.getDate()%7;var i=Math.floor(r/7)+n;return i===t}return false}function isLInExpressions(e){return e.length>0&&e.some((function(e){return typeof e==="string"&&e.indexOf("L")>=0}))}e=e||false;var t=e?"subtract":"add";var n=new r(this._currentDate,this._tz);var i=this._startDate;var s=this._endDate;var o=n.getTime();var l=0;function isLastWeekdayOfMonthMatch(e){return e.some((function(e){if(!isLInExpressions([e])){return false}var t=Number.parseInt(e[0])%7;if(Number.isNaN(t)){throw new Error("Invalid last weekday of the month expression: "+e)}return n.getDay()===t&&n.isLastWeekdayOfMonth()}))}while(l<a){l++;if(e){if(i&&n.getTime()-i.getTime()<0){throw new Error("Out of the timespan range")}}else{if(s&&s.getTime()-n.getTime()<0){throw new Error("Out of the timespan range")}}var c=matchSchedule(n.getDate(),this.fields.dayOfMonth);if(isLInExpressions(this.fields.dayOfMonth)){c=c||n.isLastDayOfMonth()}var d=matchSchedule(n.getDay(),this.fields.dayOfWeek);if(isLInExpressions(this.fields.dayOfWeek)){d=d||isLastWeekdayOfMonthMatch(this.fields.dayOfWeek)}var u=this.fields.dayOfMonth.length>=CronExpression.daysInMonth[n.getMonth()];var p=this.fields.dayOfWeek.length===CronExpression.constraints[5].max-CronExpression.constraints[5].min+1;var f=n.getHours();if(!c&&(!d||p)){this._applyTimezoneShift(n,t,"Day");continue}if(!u&&p&&!c){this._applyTimezoneShift(n,t,"Day");continue}if(u&&!p&&!d){this._applyTimezoneShift(n,t,"Day");continue}if(this._nthDayOfWeek>0&&!isNthDayMatch(n,this._nthDayOfWeek)){this._applyTimezoneShift(n,t,"Day");continue}if(!matchSchedule(n.getMonth()+1,this.fields.month)){this._applyTimezoneShift(n,t,"Month");continue}if(!matchSchedule(f,this.fields.hour)){if(this._dstStart!==f){this._dstStart=null;this._applyTimezoneShift(n,t,"Hour");continue}else if(!matchSchedule(f-1,this.fields.hour)){n[t+"Hour"]();continue}}else if(this._dstEnd===f){if(!e){this._dstEnd=null;this._applyTimezoneShift(n,"add","Hour");continue}}if(!matchSchedule(n.getMinutes(),this.fields.minute)){this._applyTimezoneShift(n,t,"Minute");continue}if(!matchSchedule(n.getSeconds(),this.fields.second)){this._applyTimezoneShift(n,t,"Second");continue}if(o===n.getTime()){if(t==="add"||n.getMilliseconds()===0){this._applyTimezoneShift(n,t,"Second")}else{n.setMilliseconds(0)}continue}break}if(l>=a){throw new Error("Invalid expression, loop limit exceeded")}this._currentDate=new r(n,this._tz);this._hasIterated=true;return n};CronExpression.prototype.next=function next(){var e=this._findSchedule();if(this._isIterator){return{value:e,done:!this.hasNext()}}return e};CronExpression.prototype.prev=function prev(){var e=this._findSchedule(true);if(this._isIterator){return{value:e,done:!this.hasPrev()}}return e};CronExpression.prototype.hasNext=function(){var e=this._currentDate;var t=this._hasIterated;try{this._findSchedule();return true}catch(e){return false}finally{this._currentDate=e;this._hasIterated=t}};CronExpression.prototype.hasPrev=function(){var e=this._currentDate;var t=this._hasIterated;try{this._findSchedule(true);return true}catch(e){return false}finally{this._currentDate=e;this._hasIterated=t}};CronExpression.prototype.iterate=function iterate(e,t){var n=[];if(e>=0){for(var r=0,i=e;r<i;r++){try{var a=this.next();n.push(a);if(t){t(a,r)}}catch(e){break}}}else{for(var r=0,i=e;r>i;r--){try{var a=this.prev();n.push(a);if(t){t(a,r)}}catch(e){break}}}return n};CronExpression.prototype.reset=function reset(e){this._currentDate=new r(e||this._options.currentDate)};CronExpression.prototype.stringify=function stringify(e){var t=[];for(var n=e?0:1,r=CronExpression.map.length;n<r;++n){var a=CronExpression.map[n];var s=this.fields[a];var o=CronExpression.constraints[n];if(a==="dayOfMonth"&&this.fields.month.length===1){o={min:1,max:CronExpression.daysInMonth[this.fields.month[0]-1]}}else if(a==="dayOfWeek"){o={min:0,max:6};s=s[s.length-1]===7?s.slice(0,-1):s}t.push(i(s,o.min,o.max))}return t.join(" ")};CronExpression.parse=function parse(e,t){var n=this;if(typeof t==="function"){t={}}function parse(e,t){if(!t){t={}}if(typeof t.currentDate==="undefined"){t.currentDate=new r(undefined,n._tz)}if(CronExpression.predefined[e]){e=CronExpression.predefined[e]}var i=[];var a=(e+"").trim().split(/\s+/);if(a.length>6){throw new Error("Invalid cron expression")}var s=CronExpression.map.length-a.length;for(var o=0,l=CronExpression.map.length;o<l;++o){var c=CronExpression.map[o];var d=a[a.length>l?o:o-s];if(o<s||!d){i.push(CronExpression._parseField(c,CronExpression.parseDefaults[o],CronExpression.constraints[o]))}else{var u=c==="dayOfWeek"?parseNthDay(d):d;i.push(CronExpression._parseField(c,u,CronExpression.constraints[o]))}}var p={};for(var o=0,l=CronExpression.map.length;o<l;o++){var f=CronExpression.map[o];p[f]=i[o]}var h=CronExpression._handleMaxDaysInMonth(p);p.dayOfMonth=h||p.dayOfMonth;return new CronExpression(p,t);function parseNthDay(e){var n=e.split("#");if(n.length>1){var r=+n[n.length-1];if(/,/.test(e)){throw new Error("Constraint error, invalid dayOfWeek `#` and `,` "+"special characters are incompatible")}if(/\//.test(e)){throw new Error("Constraint error, invalid dayOfWeek `#` and `/` "+"special characters are incompatible")}if(/-/.test(e)){throw new Error("Constraint error, invalid dayOfWeek `#` and `-` "+"special characters are incompatible")}if(n.length>2||Number.isNaN(r)||(r<1||r>5)){throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)")}t.nthDayOfWeek=r;return n[0]}return e}}return parse(e,t)};CronExpression.fieldsToExpression=function fieldsToExpression(e,t){function validateConstraints(e,t,n){if(!t){throw new Error("Validation error, Field "+e+" is missing")}if(t.length===0){throw new Error("Validation error, Field "+e+" contains no values")}for(var r=0,i=t.length;r<i;r++){var a=t[r];if(CronExpression._isValidConstraintChar(n,a)){continue}if(typeof a!=="number"||Number.isNaN(a)||a<n.min||a>n.max){throw new Error("Constraint error, got value "+a+" expected range "+n.min+"-"+n.max)}}}var n={};for(var r=0,i=CronExpression.map.length;r<i;++r){var a=CronExpression.map[r];var s=e[a];validateConstraints(a,s,CronExpression.constraints[r]);var o=[];var l=-1;while(++l<s.length){o[l]=s[l]}s=o.sort(CronExpression._sortCompareFn).filter((function(e,t,n){return!t||e!==n[t-1]}));if(s.length!==o.length){throw new Error("Validation error, Field "+a+" contains duplicate values")}n[a]=s}var c=CronExpression._handleMaxDaysInMonth(n);n.dayOfMonth=c||n.dayOfMonth;return new CronExpression(n,t||{})};e.exports=CronExpression},8936:function(e){"use strict";function buildRange(e){return{start:e,count:1}}function completeRangeWithItem(e,t){e.end=t;e.step=t-e.start;e.count=2}function finalizeCurrentRange(e,t,n){if(t){if(t.count===2){e.push(buildRange(t.start));e.push(buildRange(t.end))}else{e.push(t)}}if(n){e.push(n)}}function compactField(e){var t=[];var n=undefined;for(var r=0;r<e.length;r++){var i=e[r];if(typeof i!=="number"){finalizeCurrentRange(t,n,buildRange(i));n=undefined}else if(!n){n=buildRange(i)}else if(n.count===1){completeRangeWithItem(n,i)}else{if(n.step===i-n.end){n.count++;n.end=i}else if(n.count===2){t.push(buildRange(n.start));n=buildRange(n.end);completeRangeWithItem(n,i)}else{finalizeCurrentRange(t,n);n=buildRange(i)}}}finalizeCurrentRange(t,n);return t}e.exports=compactField},4173:function(e,t,n){"use strict";var r=n(8936);function stringifyField(e,t,n){var i=r(e);if(i.length===1){var a=i[0];var s=a.step;if(s===1&&a.start===t&&a.end===n){return"*"}if(s!==1&&a.start===t&&a.end===n-s+1){return"*/"+s}}var o=[];for(var l=0,c=i.length;l<c;++l){var d=i[l];if(d.count===1){o.push(d.start);continue}var s=d.step;if(d.step===1){o.push(d.start+"-"+d.end);continue}var u=d.start==0?d.count-1:d.count;if(d.step*u>d.end){o=o.concat(Array.from({length:d.end-d.start+1}).map((function(e,t){var n=d.start+t;if((n-d.start)%d.step===0){return n}return null})).filter((function(e){return e!=null})))}else if(d.end===n-d.step+1){o.push(d.start+"/"+d.step)}else{o.push(d.start+"-"+d.end+"/"+d.step)}}return o.join(",")}e.exports=stringifyField},9912:function(e,t,n){"use strict";var r=n(8937);function CronParser(){}CronParser._parseEntry=function _parseEntry(e){var t=e.split(" ");if(t.length===6){return{interval:r.parse(e)}}else if(t.length>6){return{interval:r.parse(t.slice(0,6).join(" ")),command:t.slice(6,t.length)}}else{throw new Error("Invalid entry: "+e)}};CronParser.parseExpression=function parseExpression(e,t){return r.parse(e,t)};CronParser.fieldsToExpression=function fieldsToExpression(e,t){return r.fieldsToExpression(e,t)};CronParser.parseString=function parseString(e){var t=e.split("\n");var n={variables:{},expressions:[],errors:{}};for(var r=0,i=t.length;r<i;r++){var a=t[r];var s=null;var o=a.trim();if(o.length>0){if(o.match(/^#/)){continue}else if(s=o.match(/^(.*)=(.*)$/)){n.variables[s[1]]=s[2]}else{var l=null;try{l=CronParser._parseEntry("0 "+o);n.expressions.push(l.interval)}catch(e){n.errors[o]=e}}}}return n};CronParser.parseFile=function parseFile(e,t){n(9896).readFile(e,(function(e,n){if(e){t(e);return}return t(null,CronParser.parseString(n.toString()))}))};e.exports=CronParser},5313:function(e,t,n){t.formatArgs=formatArgs;t.save=save;t.load=load;t.useColors=useColors;t.storage=localstorage();t.destroy=(()=>{let e=false;return()=>{if(!e){e=true;console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}}})();t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function useColors(){if(typeof window!=="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)){return true}if(typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)){return false}let e;return typeof document!=="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!=="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!=="undefined"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function formatArgs(t){t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff);if(!this.useColors){return}const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0;let i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{if(e==="%%"){return}r++;if(e==="%c"){i=r}}));t.splice(i,0,n)}t.log=console.debug||console.log||(()=>{});function save(e){try{if(e){t.storage.setItem("debug",e)}else{t.storage.removeItem("debug")}}catch(e){}}function load(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}if(!e&&typeof process!=="undefined"&&"env"in process){e=process.env.DEBUG}return e}function localstorage(){try{return localStorage}catch(e){}}e.exports=n(5384)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},5384:function(e,t,n){function setup(e){createDebug.debug=createDebug;createDebug.default=createDebug;createDebug.coerce=coerce;createDebug.disable=disable;createDebug.enable=enable;createDebug.enabled=enabled;createDebug.humanize=n(2134);createDebug.destroy=destroy;Object.keys(e).forEach((t=>{createDebug[t]=e[t]}));createDebug.names=[];createDebug.skips=[];createDebug.formatters={};function selectColor(e){let t=0;for(let n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n);t|=0}return createDebug.colors[Math.abs(t)%createDebug.colors.length]}createDebug.selectColor=selectColor;function createDebug(e){let t;let n=null;let r;let i;function debug(...e){if(!debug.enabled){return}const n=debug;const r=Number(new Date);const i=r-(t||r);n.diff=i;n.prev=t;n.curr=r;t=r;e[0]=createDebug.coerce(e[0]);if(typeof e[0]!=="string"){e.unshift("%O")}let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,r)=>{if(t==="%%"){return"%"}a++;const i=createDebug.formatters[r];if(typeof i==="function"){const r=e[a];t=i.call(n,r);e.splice(a,1);a--}return t}));createDebug.formatArgs.call(n,e);const s=n.log||createDebug.log;s.apply(n,e)}debug.namespace=e;debug.useColors=createDebug.useColors();debug.color=createDebug.selectColor(e);debug.extend=extend;debug.destroy=createDebug.destroy;Object.defineProperty(debug,"enabled",{enumerable:true,configurable:false,get:()=>{if(n!==null){return n}if(r!==createDebug.namespaces){r=createDebug.namespaces;i=createDebug.enabled(e)}return i},set:e=>{n=e}});if(typeof createDebug.init==="function"){createDebug.init(debug)}return debug}function extend(e,t){const n=createDebug(this.namespace+(typeof t==="undefined"?":":t)+e);n.log=this.log;return n}function enable(e){createDebug.save(e);createDebug.namespaces=e;createDebug.names=[];createDebug.skips=[];const t=(typeof e==="string"?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of t){if(e[0]==="-"){createDebug.skips.push(e.slice(1))}else{createDebug.names.push(e)}}}function matchesTemplate(e,t){let n=0;let r=0;let i=-1;let a=0;while(n<e.length){if(r<t.length&&(t[r]===e[n]||t[r]==="*")){if(t[r]==="*"){i=r;a=n;r++}else{n++;r++}}else if(i!==-1){r=i+1;a++;n=a}else{return false}}while(r<t.length&&t[r]==="*"){r++}return r===t.length}function disable(){const e=[...createDebug.names,...createDebug.skips.map((e=>"-"+e))].join(",");createDebug.enable("");return e}function enabled(e){for(const t of createDebug.skips){if(matchesTemplate(e,t)){return false}}for(const t of createDebug.names){if(matchesTemplate(e,t)){return true}}return false}function coerce(e){if(e instanceof Error){return e.stack||e.message}return e}function destroy(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}createDebug.enable(createDebug.load());return createDebug}e.exports=setup},6449:function(e,t,n){if(typeof process==="undefined"||process.type==="renderer"||process.browser===true||process.__nwjs){e.exports=n(5313)}else{e.exports=n(249)}},249:function(e,t,n){const r=n(2018);const i=n(9023);t.init=init;t.log=log;t.formatArgs=formatArgs;t.save=save;t.load=load;t.useColors=useColors;t.destroy=i.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");t.colors=[6,2,3,4,5,1];try{const e=n(5414);if(e&&(e.stderr||e).level>=2){t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let r=process.env[t];if(/^(yes|on|true|enabled)$/i.test(r)){r=true}else if(/^(no|off|false|disabled)$/i.test(r)){r=false}else if(r==="null"){r=null}else{r=Number(r)}e[n]=r;return e}),{});function useColors(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):r.isatty(process.stderr.fd)}function formatArgs(t){const{namespace:n,useColors:r}=this;if(r){const r=this.color;const i="[3"+(r<8?r:"8;5;"+r);const a=` ${i};1m${n} [0m`;t[0]=a+t[0].split("\n").join("\n"+a);t.push(i+"m+"+e.exports.humanize(this.diff)+"[0m")}else{t[0]=getDate()+n+" "+t[0]}}function getDate(){if(t.inspectOpts.hideDate){return""}return(new Date).toISOString()+" "}function log(...e){return process.stderr.write(i.formatWithOptions(t.inspectOpts,...e)+"\n")}function save(e){if(e){process.env.DEBUG=e}else{delete process.env.DEBUG}}function load(){return process.env.DEBUG}function init(e){e.inspectOpts={};const n=Object.keys(t.inspectOpts);for(let r=0;r<n.length;r++){e.inspectOpts[n[r]]=t.inspectOpts[n[r]]}}e.exports=n(5384)(t);const{formatters:a}=e.exports;a.o=function(e){this.inspectOpts.colors=this.useColors;return i.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")};a.O=function(e){this.inspectOpts.colors=this.useColors;return i.inspect(e,this.inspectOpts)}},9611:function(e){"use strict";function Denque(e,t){var t=t||{};this._capacity=t.capacity;this._head=0;this._tail=0;if(Array.isArray(e)){this._fromArray(e)}else{this._capacityMask=3;this._list=new Array(4)}}Denque.prototype.peekAt=function peekAt(e){var t=e;if(t!==(t|0)){return void 0}var n=this.size();if(t>=n||t<-n)return undefined;if(t<0)t+=n;t=this._head+t&this._capacityMask;return this._list[t]};Denque.prototype.get=function get(e){return this.peekAt(e)};Denque.prototype.peek=function peek(){if(this._head===this._tail)return undefined;return this._list[this._head]};Denque.prototype.peekFront=function peekFront(){return this.peek()};Denque.prototype.peekBack=function peekBack(){return this.peekAt(-1)};Object.defineProperty(Denque.prototype,"length",{get:function length(){return this.size()}});Denque.prototype.size=function size(){if(this._head===this._tail)return 0;if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};Denque.prototype.unshift=function unshift(e){if(arguments.length===0)return this.size();var t=this._list.length;this._head=this._head-1+t&this._capacityMask;this._list[this._head]=e;if(this._tail===this._head)this._growArray();if(this._capacity&&this.size()>this._capacity)this.pop();if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};Denque.prototype.shift=function shift(){var e=this._head;if(e===this._tail)return undefined;var t=this._list[e];this._list[e]=undefined;this._head=e+1&this._capacityMask;if(e<2&&this._tail>1e4&&this._tail<=this._list.length>>>2)this._shrinkArray();return t};Denque.prototype.push=function push(e){if(arguments.length===0)return this.size();var t=this._tail;this._list[t]=e;this._tail=t+1&this._capacityMask;if(this._tail===this._head){this._growArray()}if(this._capacity&&this.size()>this._capacity){this.shift()}if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};Denque.prototype.pop=function pop(){var e=this._tail;if(e===this._head)return undefined;var t=this._list.length;this._tail=e-1+t&this._capacityMask;var n=this._list[this._tail];this._list[this._tail]=undefined;if(this._head<2&&e>1e4&&e<=t>>>2)this._shrinkArray();return n};Denque.prototype.removeOne=function removeOne(e){var t=e;if(t!==(t|0)){return void 0}if(this._head===this._tail)return void 0;var n=this.size();var r=this._list.length;if(t>=n||t<-n)return void 0;if(t<0)t+=n;t=this._head+t&this._capacityMask;var i=this._list[t];var a;if(e<n/2){for(a=e;a>0;a--){this._list[t]=this._list[t=t-1+r&this._capacityMask]}this._list[t]=void 0;this._head=this._head+1+r&this._capacityMask}else{for(a=n-1-e;a>0;a--){this._list[t]=this._list[t=t+1+r&this._capacityMask]}this._list[t]=void 0;this._tail=this._tail-1+r&this._capacityMask}return i};Denque.prototype.remove=function remove(e,t){var n=e;var r;var i=t;if(n!==(n|0)){return void 0}if(this._head===this._tail)return void 0;var a=this.size();var s=this._list.length;if(n>=a||n<-a||t<1)return void 0;if(n<0)n+=a;if(t===1||!t){r=new Array(1);r[0]=this.removeOne(n);return r}if(n===0&&n+t>=a){r=this.toArray();this.clear();return r}if(n+t>a)t=a-n;var o;r=new Array(t);for(o=0;o<t;o++){r[o]=this._list[this._head+n+o&this._capacityMask]}n=this._head+n&this._capacityMask;if(e+t===a){this._tail=this._tail-t+s&this._capacityMask;for(o=t;o>0;o--){this._list[n=n+1+s&this._capacityMask]=void 0}return r}if(e===0){this._head=this._head+t+s&this._capacityMask;for(o=t-1;o>0;o--){this._list[n=n+1+s&this._capacityMask]=void 0}return r}if(n<a/2){this._head=this._head+e+t+s&this._capacityMask;for(o=e;o>0;o--){this.unshift(this._list[n=n-1+s&this._capacityMask])}n=this._head-1+s&this._capacityMask;while(i>0){this._list[n=n-1+s&this._capacityMask]=void 0;i--}if(e<0)this._tail=n}else{this._tail=n;n=n+t+s&this._capacityMask;for(o=a-(t+e);o>0;o--){this.push(this._list[n++])}n=this._tail;while(i>0){this._list[n=n+1+s&this._capacityMask]=void 0;i--}}if(this._head<2&&this._tail>1e4&&this._tail<=s>>>2)this._shrinkArray();return r};Denque.prototype.splice=function splice(e,t){var n=e;if(n!==(n|0)){return void 0}var r=this.size();if(n<0)n+=r;if(n>r)return void 0;if(arguments.length>2){var i;var a;var s;var o=arguments.length;var l=this._list.length;var c=2;if(!r||n<r/2){a=new Array(n);for(i=0;i<n;i++){a[i]=this._list[this._head+i&this._capacityMask]}if(t===0){s=[];if(n>0){this._head=this._head+n+l&this._capacityMask}}else{s=this.remove(n,t);this._head=this._head+n+l&this._capacityMask}while(o>c){this.unshift(arguments[--o])}for(i=n;i>0;i--){this.unshift(a[i-1])}}else{a=new Array(r-(n+t));var d=a.length;for(i=0;i<d;i++){a[i]=this._list[this._head+n+t+i&this._capacityMask]}if(t===0){s=[];if(n!=r){this._tail=this._head+n+l&this._capacityMask}}else{s=this.remove(n,t);this._tail=this._tail-d+l&this._capacityMask}while(c<o){this.push(arguments[c++])}for(i=0;i<d;i++){this.push(a[i])}}return s}else{return this.remove(n,t)}};Denque.prototype.clear=function clear(){this._list=new Array(this._list.length);this._head=0;this._tail=0};Denque.prototype.isEmpty=function isEmpty(){return this._head===this._tail};Denque.prototype.toArray=function toArray(){return this._copyArray(false)};Denque.prototype._fromArray=function _fromArray(e){var t=e.length;var n=this._nextPowerOf2(t);this._list=new Array(n);this._capacityMask=n-1;this._tail=t;for(var r=0;r<t;r++)this._list[r]=e[r]};Denque.prototype._copyArray=function _copyArray(e,t){var n=this._list;var r=n.length;var i=this.length;t=t|i;if(t==i&&this._head<this._tail){return this._list.slice(this._head,this._tail)}var a=new Array(t);var s=0;var o;if(e||this._head>this._tail){for(o=this._head;o<r;o++)a[s++]=n[o];for(o=0;o<this._tail;o++)a[s++]=n[o]}else{for(o=this._head;o<this._tail;o++)a[s++]=n[o]}return a};Denque.prototype._growArray=function _growArray(){if(this._head!=0){var e=this._copyArray(true,this._list.length<<1);this._tail=this._list.length;this._head=0;this._list=e}else{this._tail=this._list.length;this._list.length<<=1}this._capacityMask=this._capacityMask<<1|1};Denque.prototype._shrinkArray=function _shrinkArray(){this._list.length>>>=1;this._capacityMask>>>=1};Denque.prototype._nextPowerOf2=function _nextPowerOf2(e){var t=Math.log(e)/Math.log(2);var n=1<<t+1;return Math.max(n,4)};e.exports=Denque},9054:function(e,t,n){"use strict";const r=n(5317);const{isLinux:i,getReport:a}=n(7613);const{LDD_PATH:s,readFile:o,readFileSync:l}=n(5941);let c;let d;const u="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true";let p="";const safeCommand=()=>{if(!p){return new Promise((e=>{r.exec(u,((t,n)=>{p=t?" ":n;e(p)}))}))}return p};const safeCommandSync=()=>{if(!p){try{p=r.execSync(u,{encoding:"utf8"})}catch(e){p=" "}}return p};const f="glibc";const h=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;const y="musl";const isFileMusl=e=>e.includes("libc.musl-")||e.includes("ld-musl-");const familyFromReport=()=>{const e=a();if(e.header&&e.header.glibcVersionRuntime){return f}if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(isFileMusl)){return y}}return null};const familyFromCommand=e=>{const[t,n]=e.split(/[\r\n]+/);if(t&&t.includes(f)){return f}if(n&&n.includes(y)){return y}return null};const getFamilyFromLddContent=e=>{if(e.includes("musl")){return y}if(e.includes("GNU C Library")){return f}return null};const familyFromFilesystem=async()=>{if(c!==undefined){return c}c=null;try{const e=await o(s);c=getFamilyFromLddContent(e)}catch(e){}return c};const familyFromFilesystemSync=()=>{if(c!==undefined){return c}c=null;try{const e=l(s);c=getFamilyFromLddContent(e)}catch(e){}return c};const family=async()=>{let e=null;if(i()){e=await familyFromFilesystem();if(!e){e=familyFromReport()}if(!e){const t=await safeCommand();e=familyFromCommand(t)}}return e};const familySync=()=>{let e=null;if(i()){e=familyFromFilesystemSync();if(!e){e=familyFromReport()}if(!e){const t=safeCommandSync();e=familyFromCommand(t)}}return e};const isNonGlibcLinux=async()=>i()&&await family()!==f;const isNonGlibcLinuxSync=()=>i()&&familySync()!==f;const versionFromFilesystem=async()=>{if(d!==undefined){return d}d=null;try{const e=await o(s);const t=e.match(h);if(t){d=t[1]}}catch(e){}return d};const versionFromFilesystemSync=()=>{if(d!==undefined){return d}d=null;try{const e=l(s);const t=e.match(h);if(t){d=t[1]}}catch(e){}return d};const versionFromReport=()=>{const e=a();if(e.header&&e.header.glibcVersionRuntime){return e.header.glibcVersionRuntime}return null};const versionSuffix=e=>e.trim().split(/\s+/)[1];const versionFromCommand=e=>{const[t,n,r]=e.split(/[\r\n]+/);if(t&&t.includes(f)){return versionSuffix(t)}if(n&&r&&n.includes(y)){return versionSuffix(r)}return null};const version=async()=>{let e=null;if(i()){e=await versionFromFilesystem();if(!e){e=versionFromReport()}if(!e){const t=await safeCommand();e=versionFromCommand(t)}}return e};const versionSync=()=>{let e=null;if(i()){e=versionFromFilesystemSync();if(!e){e=versionFromReport()}if(!e){const t=safeCommandSync();e=versionFromCommand(t)}}return e};e.exports={GLIBC:f,MUSL:y,family:family,familySync:familySync,isNonGlibcLinux:isNonGlibcLinux,isNonGlibcLinuxSync:isNonGlibcLinuxSync,version:version,versionSync:versionSync}},5941:function(e,t,n){"use strict";const r=n(9896);const i="/usr/bin/ldd";const readFileSync=e=>r.readFileSync(e,"utf-8");const readFile=e=>new Promise(((t,n)=>{r.readFile(e,"utf-8",((e,r)=>{if(e){n(e)}else{t(r)}}))}));e.exports={LDD_PATH:i,readFileSync:readFileSync,readFile:readFile}},7613:function(e){"use strict";const isLinux=()=>process.platform==="linux";let t=null;const getReport=()=>{if(!t){if(isLinux()&&process.report){const e=process.report.excludeNetwork;process.report.excludeNetwork=true;t=process.report.getReport();process.report.excludeNetwork=e}else{t={}}}return t};e.exports={isLinux:isLinux,getReport:getReport}},2871:function(e){"use strict";e.exports=(e,t)=>{t=t||process.argv;const n=e.startsWith("-")?"":e.length===1?"-":"--";const r=t.indexOf(n+e);const i=t.indexOf("--");return r!==-1&&(i===-1?true:r<i)}},7544:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(4458);const i=n(3288);const a=n(2460);const s=n(387);class Command{constructor(e,t=[],n={},r){this.name=e;this.inTransaction=false;this.isResolved=false;this.transformed=false;this.replyEncoding=n.replyEncoding;this.errorStack=n.errorStack;this.args=t.flat();this.callback=r;this.initPromise();if(n.keyPrefix){const e=n.keyPrefix instanceof Buffer;let t=e?n.keyPrefix:null;this._iterateKeys((r=>{if(r instanceof Buffer){if(t===null){t=Buffer.from(n.keyPrefix)}return Buffer.concat([t,r])}else if(e){return Buffer.concat([n.keyPrefix,Buffer.from(String(r))])}return n.keyPrefix+r}))}if(n.readOnly){this.isReadOnly=true}}static checkFlag(e,t){return!!this.getFlagMap()[e][t]}static setArgumentTransformer(e,t){this._transformer.argument[e]=t}static setReplyTransformer(e,t){this._transformer.reply[e]=t}static getFlagMap(){if(!this.flagMap){this.flagMap=Object.keys(Command.FLAGS).reduce(((e,t)=>{e[t]={};Command.FLAGS[t].forEach((n=>{e[t][n]=true}));return e}),{})}return this.flagMap}getSlot(){if(typeof this.slot==="undefined"){const e=this.getKeys()[0];this.slot=e==null?null:i(e)}return this.slot}getKeys(){return this._iterateKeys()}toWritable(e){let t;const n="*"+(this.args.length+1)+"\r\n$"+Buffer.byteLength(this.name)+"\r\n"+this.name+"\r\n";if(this.bufferMode){const e=new MixedBuffers;e.push(n);for(let t=0;t<this.args.length;++t){const n=this.args[t];if(n instanceof Buffer){if(n.length===0){e.push("$0\r\n\r\n")}else{e.push("$"+n.length+"\r\n");e.push(n);e.push("\r\n")}}else{e.push("$"+Buffer.byteLength(n)+"\r\n"+n+"\r\n")}}t=e.toBuffer()}else{t=n;for(let e=0;e<this.args.length;++e){const n=this.args[e];t+="$"+Buffer.byteLength(n)+"\r\n"+n+"\r\n"}}return t}stringifyArguments(){for(let e=0;e<this.args.length;++e){const t=this.args[e];if(typeof t==="string"){}else if(t instanceof Buffer){this.bufferMode=true}else{this.args[e]=(0,s.toArg)(t)}}}transformReply(e){if(this.replyEncoding){e=(0,s.convertBufferToString)(e,this.replyEncoding)}const t=Command._transformer.reply[this.name];if(t){e=t(e)}return e}setTimeout(e){if(!this._commandTimeoutTimer){this._commandTimeoutTimer=setTimeout((()=>{if(!this.isResolved){this.reject(new Error("Command timed out"))}}),e)}}initPromise(){const e=new Promise(((e,t)=>{if(!this.transformed){this.transformed=true;const e=Command._transformer.argument[this.name];if(e){this.args=e(this.args)}this.stringifyArguments()}this.resolve=this._convertValue(e);if(this.errorStack){this.reject=e=>{t((0,s.optimizeErrorStack)(e,this.errorStack.stack,__dirname))}}else{this.reject=t}}));this.promise=(0,a.default)(e,this.callback)}_iterateKeys(e=e=>e){if(typeof this.keys==="undefined"){this.keys=[];if((0,r.exists)(this.name)){const t=(0,r.getKeyIndexes)(this.name,this.args);for(const n of t){this.args[n]=e(this.args[n]);this.keys.push(this.args[n])}}}return this.keys}_convertValue(e){return t=>{try{const n=this._commandTimeoutTimer;if(n){clearTimeout(n);delete this._commandTimeoutTimer}e(this.transformReply(t));this.isResolved=true}catch(e){this.reject(e)}return this.promise}}}t["default"]=Command;Command.FLAGS={VALID_IN_SUBSCRIBER_MODE:["subscribe","psubscribe","unsubscribe","punsubscribe","ssubscribe","sunsubscribe","ping","quit"],VALID_IN_MONITOR_MODE:["monitor","auth"],ENTER_SUBSCRIBER_MODE:["subscribe","psubscribe","ssubscribe"],EXIT_SUBSCRIBER_MODE:["unsubscribe","punsubscribe","sunsubscribe"],WILL_DISCONNECT:["quit"]};Command._transformer={argument:{},reply:{}};const msetArgumentTransformer=function(e){if(e.length===1){if(e[0]instanceof Map){return(0,s.convertMapToArray)(e[0])}if(typeof e[0]==="object"&&e[0]!==null){return(0,s.convertObjectToArray)(e[0])}}return e};const hsetArgumentTransformer=function(e){if(e.length===2){if(e[1]instanceof Map){return[e[0]].concat((0,s.convertMapToArray)(e[1]))}if(typeof e[1]==="object"&&e[1]!==null){return[e[0]].concat((0,s.convertObjectToArray)(e[1]))}}return e};Command.setArgumentTransformer("mset",msetArgumentTransformer);Command.setArgumentTransformer("msetnx",msetArgumentTransformer);Command.setArgumentTransformer("hset",hsetArgumentTransformer);Command.setArgumentTransformer("hmset",hsetArgumentTransformer);Command.setReplyTransformer("hgetall",(function(e){if(Array.isArray(e)){const t={};for(let n=0;n<e.length;n+=2){const r=e[n];const i=e[n+1];if(r in t){Object.defineProperty(t,r,{value:i,configurable:true,enumerable:true,writable:true})}else{t[r]=i}}return t}return e}));class MixedBuffers{constructor(){this.length=0;this.items=[]}push(e){this.length+=Buffer.byteLength(e);this.items.push(e)}toBuffer(){const e=Buffer.allocUnsafe(this.length);let t=0;for(const n of this.items){const r=Buffer.byteLength(n);Buffer.isBuffer(n)?n.copy(e,t):e.write(n,t,r);t+=r}return e}}},4021:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(7544);const i=n(387);const a=n(9751);const s=n(7286);const o=(0,i.Debug)("dataHandler");class DataHandler{constructor(e,t){this.redis=e;const n=new a({stringNumbers:t.stringNumbers,returnBuffers:true,returnError:e=>{this.returnError(e)},returnFatalError:e=>{this.returnFatalError(e)},returnReply:e=>{this.returnReply(e)}});e.stream.prependListener("data",(e=>{n.execute(e)}));e.stream.resume()}returnFatalError(e){e.message+=". Please report this.";this.redis.recoverFromFatalError(e,e,{offlineQueue:false})}returnError(e){const t=this.shiftCommand(e);if(!t){return}e.command={name:t.command.name,args:t.command.args};this.redis.handleReconnection(e,t)}returnReply(e){if(this.handleMonitorReply(e)){return}if(this.handleSubscriberReply(e)){return}const t=this.shiftCommand(e);if(!t){return}if(r.default.checkFlag("ENTER_SUBSCRIBER_MODE",t.command.name)){this.redis.condition.subscriber=new s.default;this.redis.condition.subscriber.add(t.command.name,e[1].toString());if(!fillSubCommand(t.command,e[2])){this.redis.commandQueue.unshift(t)}}else if(r.default.checkFlag("EXIT_SUBSCRIBER_MODE",t.command.name)){if(!fillUnsubCommand(t.command,e[2])){this.redis.commandQueue.unshift(t)}}else{t.command.resolve(e)}}handleSubscriberReply(e){if(!this.redis.condition.subscriber){return false}const t=Array.isArray(e)?e[0].toString():null;o('receive reply "%s" in subscriber mode',t);switch(t){case"message":if(this.redis.listeners("message").length>0){this.redis.emit("message",e[1].toString(),e[2]?e[2].toString():"")}this.redis.emit("messageBuffer",e[1],e[2]);break;case"pmessage":{const t=e[1].toString();if(this.redis.listeners("pmessage").length>0){this.redis.emit("pmessage",t,e[2].toString(),e[3].toString())}this.redis.emit("pmessageBuffer",t,e[2],e[3]);break}case"smessage":{if(this.redis.listeners("smessage").length>0){this.redis.emit("smessage",e[1].toString(),e[2]?e[2].toString():"")}this.redis.emit("smessageBuffer",e[1],e[2]);break}case"ssubscribe":case"subscribe":case"psubscribe":{const n=e[1].toString();this.redis.condition.subscriber.add(t,n);const r=this.shiftCommand(e);if(!r){return}if(!fillSubCommand(r.command,e[2])){this.redis.commandQueue.unshift(r)}break}case"sunsubscribe":case"unsubscribe":case"punsubscribe":{const n=e[1]?e[1].toString():null;if(n){this.redis.condition.subscriber.del(t,n)}const r=e[2];if(Number(r)===0){this.redis.condition.subscriber=false}const i=this.shiftCommand(e);if(!i){return}if(!fillUnsubCommand(i.command,r)){this.redis.commandQueue.unshift(i)}break}default:{const t=this.shiftCommand(e);if(!t){return}t.command.resolve(e)}}return true}handleMonitorReply(e){if(this.redis.status!=="monitoring"){return false}const t=e.toString();if(t==="OK"){return false}const n=t.indexOf(" ");const r=t.slice(0,n);const i=t.indexOf('"');const a=t.slice(i+1,-1).split('" "').map((e=>e.replace(/\\"/g,'"')));const s=t.slice(n+2,i-2).split(" ");this.redis.emit("monitor",r,a,s[1],s[0]);return true}shiftCommand(e){const t=this.redis.commandQueue.shift();if(!t){const t="Command queue state error. If you can reproduce this, please report it.";const n=new Error(t+(e instanceof Error?` Last error: ${e.message}`:` Last reply: ${e.toString()}`));this.redis.emit("error",n);return null}return t}}t["default"]=DataHandler;const l=new WeakMap;function fillSubCommand(e,t){let n=l.has(e)?l.get(e):e.args.length;n-=1;if(n<=0){e.resolve(t);l.delete(e);return true}l.set(e,n);return false}function fillUnsubCommand(e,t){let n=l.has(e)?l.get(e):e.args.length;if(n===0){if(Number(t)===0){l.delete(e);e.resolve(t);return true}return false}n-=1;if(n<=0){e.resolve(t);return true}l.set(e,n);return false}},2499:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(3288);const i=n(4458);const a=n(2460);const s=n(9023);const o=n(7544);const l=n(387);const c=n(1325);function generateMultiWithNodes(e,t){const n=r(t[0]);const i=e._groupsBySlot[n];for(let n=1;n<t.length;n++){if(e._groupsBySlot[r(t[n])]!==i){return-1}}return n}class Pipeline extends c.default{constructor(e){super();this.redis=e;this.isPipeline=true;this.replyPending=0;this._queue=[];this._result=[];this._transactions=0;this._shaToScript={};this.isCluster=this.redis.constructor.name==="Cluster"||this.redis.isCluster;this.options=e.options;Object.keys(e.scriptsSet).forEach((t=>{const n=e.scriptsSet[t];this._shaToScript[n.sha]=n;this[t]=e[t];this[t+"Buffer"]=e[t+"Buffer"]}));e.addedBuiltinSet.forEach((t=>{this[t]=e[t];this[t+"Buffer"]=e[t+"Buffer"]}));this.promise=new Promise(((e,t)=>{this.resolve=e;this.reject=t}));const t=this;Object.defineProperty(this,"length",{get:function(){return t._queue.length}})}fillResult(e,t){if(this._queue[t].name==="exec"&&Array.isArray(e[1])){const n=e[1].length;for(let r=0;r<n;r++){if(e[1][r]instanceof Error){continue}const i=this._queue[t-(n-r)];try{e[1][r]=i.transformReply(e[1][r])}catch(t){e[1][r]=t}}}this._result[t]=e;if(--this.replyPending){return}if(this.isCluster){let e=true;let t;for(let n=0;n<this._result.length;++n){const r=this._result[n][0];const a=this._queue[n];if(r){if(a.name==="exec"&&r.message==="EXECABORT Transaction discarded because of previous errors."){continue}if(!t){t={name:r.name,message:r.message}}else if(t.name!==r.name||t.message!==r.message){e=false;break}}else if(!a.inTransaction){const t=(0,i.exists)(a.name)&&(0,i.hasFlag)(a.name,"readonly");if(!t){e=false;break}}}if(t&&e){const e=this;const n=t.message.split(" ");const r=this._queue;let i=false;this._queue=[];for(let e=0;e<r.length;++e){if(n[0]==="ASK"&&!i&&r[e].name!=="asking"&&(!r[e-1]||r[e-1].name!=="asking")){const e=new o.default("asking");e.ignore=true;this.sendCommand(e)}r[e].initPromise();this.sendCommand(r[e]);i=r[e].inTransaction}let a=true;if(typeof this.leftRedirections==="undefined"){this.leftRedirections={}}const exec=function(){e.exec()};const s=this.redis;s.handleError(t,this.leftRedirections,{moved:function(t,r){e.preferKey=r;s.slots[n[1]]=[r];s._groupsBySlot[n[1]]=s._groupsIds[s.slots[n[1]].join(";")];s.refreshSlotsCache();e.exec()},ask:function(t,n){e.preferKey=n;e.exec()},tryagain:exec,clusterDown:exec,connectionClosed:exec,maxRedirections:()=>{a=false},defaults:()=>{a=false}});if(a){return}}}let n=0;for(let e=0;e<this._queue.length-n;++e){if(this._queue[e+n].ignore){n+=1}this._result[e]=this._result[e+n]}this.resolve(this._result.slice(0,this._result.length-n))}sendCommand(e){if(this._transactions>0){e.inTransaction=true}const t=this._queue.length;e.pipelineIndex=t;e.promise.then((e=>{this.fillResult([null,e],t)})).catch((e=>{this.fillResult([e],t)}));this._queue.push(e);return this}addBatch(e){let t,n,r;for(let i=0;i<e.length;++i){t=e[i];n=t[0];r=t.slice(1);this[n].apply(this,r)}return this}}t["default"]=Pipeline;const d=Pipeline.prototype.multi;Pipeline.prototype.multi=function(){this._transactions+=1;return d.apply(this,arguments)};const u=Pipeline.prototype.execBuffer;Pipeline.prototype.execBuffer=(0,s.deprecate)((function(){if(this._transactions>0){this._transactions-=1}return u.apply(this,arguments)}),"Pipeline#execBuffer: Use Pipeline#exec instead");Pipeline.prototype.exec=function(e){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(l.noop);if(e&&!this.nodeifiedPromise){this.nodeifiedPromise=true;(0,a.default)(this.promise,e)}this.redis.delayUntilReady((t=>{if(t){this.reject(t);return}this.exec(e)}));return this.promise}if(this._transactions>0){this._transactions-=1;return u.apply(this,arguments)}if(!this.nodeifiedPromise){this.nodeifiedPromise=true;(0,a.default)(this.promise,e)}if(!this._queue.length){this.resolve([])}let t;if(this.isCluster){const e=[];for(let t=0;t<this._queue.length;t++){const n=this._queue[t].getKeys();if(n.length){e.push(n[0])}if(n.length&&r.generateMulti(n)<0){this.reject(new Error("All the keys in a pipeline command should belong to the same slot"));return this.promise}}if(e.length){t=generateMultiWithNodes(this.redis,e);if(t<0){this.reject(new Error("All keys in the pipeline should belong to the same slots allocation group"));return this.promise}}else{t=Math.random()*16384|0}}const n=this;execPipeline();return this.promise;function execPipeline(){let e=n.replyPending=n._queue.length;let r;if(n.isCluster){r={slot:t,redis:n.redis.connectionPool.nodes.all[n.preferKey]}}let i="";let a;const s={isPipeline:true,destination:n.isCluster?r:{redis:n.redis},write(t){if(typeof t!=="string"){if(!a){a=[]}if(i){a.push(Buffer.from(i,"utf8"));i=""}a.push(t)}else{i+=t}if(! --e){if(a){if(i){a.push(Buffer.from(i,"utf8"))}s.destination.redis.stream.write(Buffer.concat(a))}else{s.destination.redis.stream.write(i)}e=n._queue.length;i="";a=undefined}}};for(let e=0;e<n._queue.length;++e){n.redis.sendCommand(n._queue[e],s,r)}return n.promise}}},3810:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(4458);const i=n(4434);const a=n(2460);const s=n(8524);const o=n(7544);const l=n(8886);const c=n(1082);const d=n(430);const u=n(7746);const p=n(2196);const f=n(7785);const h=n(387);const y=n(4190);const m=n(1325);const b=n(3146);const g=n(9611);const v=(0,h.Debug)("redis");class Redis extends m.default{constructor(e,t,n){super();this.status="wait";this.isCluster=false;this.reconnectTimeout=null;this.connectionEpoch=0;this.retryAttempts=0;this.manuallyClosing=false;this._autoPipelines=new Map;this._runningAutoPipelines=new Set;this.parseOptions(e,t,n);i.EventEmitter.call(this);this.resetCommandQueue();this.resetOfflineQueue();if(this.options.Connector){this.connector=new this.options.Connector(this.options)}else if(this.options.sentinels){const e=new c.default(this.options);e.emitter=this;this.connector=e}else{this.connector=new l.StandaloneConnector(this.options)}if(this.options.scripts){Object.entries(this.options.scripts).forEach((([e,t])=>{this.defineCommand(e,t)}))}if(this.options.lazyConnect){this.setStatus("wait")}else{this.connect().catch(b.noop)}}static createClient(...e){return new Redis(...e)}get autoPipelineQueueSize(){let e=0;for(const t of this._autoPipelines.values()){e+=t.length}return e}connect(e){const t=new Promise(((e,t)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){t(new Error("Redis is already connecting/connected"));return}this.connectionEpoch+=1;this.setStatus("connecting");const{options:n}=this;this.condition={select:n.db,auth:n.username?[n.username,n.password]:n.password,subscriber:false};const r=this;(0,a.default)(this.connector.connect((function(e,t){r.silentEmit(e,t)})),(function(i,a){if(i){r.flushQueue(i);r.silentEmit("error",i);t(i);r.setStatus("end");return}let s=n.tls?"secureConnect":"connect";if("sentinels"in n&&n.sentinels&&!n.enableTLSForSentinelMode){s="connect"}r.stream=a;if(n.noDelay){a.setNoDelay(true)}if(typeof n.keepAlive==="number"){if(a.connecting){a.once(s,(()=>{a.setKeepAlive(true,n.keepAlive)}))}else{a.setKeepAlive(true,n.keepAlive)}}if(a.connecting){a.once(s,d.connectHandler(r));if(n.connectTimeout){let e=false;a.setTimeout(n.connectTimeout,(function(){if(e){return}a.setTimeout(0);a.destroy();const t=new Error("connect ETIMEDOUT");t.errorno="ETIMEDOUT";t.code="ETIMEDOUT";t.syscall="connect";d.errorHandler(r)(t)}));a.once(s,(function(){e=true;a.setTimeout(0)}))}}else if(a.destroyed){const e=r.connector.firstError;if(e){process.nextTick((()=>{d.errorHandler(r)(e)}))}process.nextTick(d.closeHandler(r))}else{process.nextTick(d.connectHandler(r))}if(!a.destroyed){a.once("error",d.errorHandler(r));a.once("close",d.closeHandler(r))}const connectionReadyHandler=function(){r.removeListener("close",connectionCloseHandler);e()};var connectionCloseHandler=function(){r.removeListener("ready",connectionReadyHandler);t(new Error(h.CONNECTION_CLOSED_ERROR_MSG))};r.once("ready",connectionReadyHandler);r.once("close",connectionCloseHandler)}))}));return(0,a.default)(t,e)}disconnect(e=false){if(!e){this.manuallyClosing=true}if(this.reconnectTimeout&&!e){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=null}if(this.status==="wait"){d.closeHandler(this)()}else{this.connector.disconnect()}}end(){this.disconnect()}duplicate(e){return new Redis({...this.options,...e})}get mode(){var e;return this.options.monitor?"monitor":((e=this.condition)===null||e===void 0?void 0:e.subscriber)?"subscriber":"normal"}monitor(e){const t=this.duplicate({monitor:true,lazyConnect:false});return(0,a.default)(new Promise((function(e,n){t.once("error",n);t.once("monitoring",(function(){e(t)}))})),e)}sendCommand(e,t){var n,i;if(this.status==="wait"){this.connect().catch(b.noop)}if(this.status==="end"){e.reject(new Error(h.CONNECTION_CLOSED_ERROR_MSG));return e.promise}if(((n=this.condition)===null||n===void 0?void 0:n.subscriber)&&!o.default.checkFlag("VALID_IN_SUBSCRIBER_MODE",e.name)){e.reject(new Error("Connection in subscriber mode, only subscriber commands may be used"));return e.promise}if(typeof this.options.commandTimeout==="number"){e.setTimeout(this.options.commandTimeout)}let a=this.status==="ready"||!t&&this.status==="connect"&&(0,r.exists)(e.name)&&(0,r.hasFlag)(e.name,"loading");if(!this.stream){a=false}else if(!this.stream.writable){a=false}else if(this.stream._writableState&&this.stream._writableState.ended){a=false}if(!a){if(!this.options.enableOfflineQueue){e.reject(new Error("Stream isn't writeable and enableOfflineQueue options is false"));return e.promise}if(e.name==="quit"&&this.offlineQueue.length===0){this.disconnect();e.resolve(Buffer.from("OK"));return e.promise}if(v.enabled){v("queue command[%s]: %d -> %s(%o)",this._getDescription(),this.condition.select,e.name,e.args)}this.offlineQueue.push({command:e,stream:t,select:this.condition.select})}else{if(v.enabled){v("write command[%s]: %d -> %s(%o)",this._getDescription(),(i=this.condition)===null||i===void 0?void 0:i.select,e.name,e.args)}if(t){if("isPipeline"in t&&t.isPipeline){t.write(e.toWritable(t.destination.redis.stream))}else{t.write(e.toWritable(t))}}else{this.stream.write(e.toWritable(this.stream))}this.commandQueue.push({command:e,stream:t,select:this.condition.select});if(o.default.checkFlag("WILL_DISCONNECT",e.name)){this.manuallyClosing=true}if(this.options.socketTimeout!==undefined&&this.socketTimeoutTimer===undefined){this.setSocketTimeout()}}if(e.name==="select"&&(0,h.isInt)(e.args[0])){const t=parseInt(e.args[0],10);if(this.condition.select!==t){this.condition.select=t;this.emit("select",t);v("switch to db [%d]",this.condition.select)}}return e.promise}setSocketTimeout(){this.socketTimeoutTimer=setTimeout((()=>{this.stream.destroy(new Error(`Socket timeout. Expecting data, but didn't receive any in ${this.options.socketTimeout}ms.`));this.socketTimeoutTimer=undefined}),this.options.socketTimeout);this.stream.once("data",(()=>{clearTimeout(this.socketTimeoutTimer);this.socketTimeoutTimer=undefined;if(this.commandQueue.length===0)return;this.setSocketTimeout()}))}scanStream(e){return this.createScanStream("scan",{options:e})}scanBufferStream(e){return this.createScanStream("scanBuffer",{options:e})}sscanStream(e,t){return this.createScanStream("sscan",{key:e,options:t})}sscanBufferStream(e,t){return this.createScanStream("sscanBuffer",{key:e,options:t})}hscanStream(e,t){return this.createScanStream("hscan",{key:e,options:t})}hscanBufferStream(e,t){return this.createScanStream("hscanBuffer",{key:e,options:t})}zscanStream(e,t){return this.createScanStream("zscan",{key:e,options:t})}zscanBufferStream(e,t){return this.createScanStream("zscanBuffer",{key:e,options:t})}silentEmit(e,t){let n;if(e==="error"){n=t;if(this.status==="end"){return}if(this.manuallyClosing){if(n instanceof Error&&(n.message===h.CONNECTION_CLOSED_ERROR_MSG||n.syscall==="connect"||n.syscall==="read")){return}}}if(this.listeners(e).length>0){return this.emit.apply(this,arguments)}if(n&&n instanceof Error){console.error("[ioredis] Unhandled error event:",n.stack)}return false}recoverFromFatalError(e,t,n){this.flushQueue(t,n);this.silentEmit("error",t);this.disconnect(true)}handleReconnection(e,t){var n;let r=false;if(this.options.reconnectOnError){r=this.options.reconnectOnError(e)}switch(r){case 1:case true:if(this.status!=="reconnecting"){this.disconnect(true)}t.command.reject(e);break;case 2:if(this.status!=="reconnecting"){this.disconnect(true)}if(((n=this.condition)===null||n===void 0?void 0:n.select)!==t.select&&t.command.name!=="select"){this.select(t.select)}this.sendCommand(t.command);break;default:t.command.reject(e)}}_getDescription(){let e;if("path"in this.options&&this.options.path){e=this.options.path}else if(this.stream&&this.stream.remoteAddress&&this.stream.remotePort){e=this.stream.remoteAddress+":"+this.stream.remotePort}else if("host"in this.options&&this.options.host){e=this.options.host+":"+this.options.port}else{e=""}if(this.options.connectionName){e+=` (${this.options.connectionName})`}return e}resetCommandQueue(){this.commandQueue=new g}resetOfflineQueue(){this.offlineQueue=new g}parseOptions(...e){const t={};let n=false;for(let r=0;r<e.length;++r){const i=e[r];if(i===null||typeof i==="undefined"){continue}if(typeof i==="object"){(0,b.defaults)(t,i)}else if(typeof i==="string"){(0,b.defaults)(t,(0,h.parseURL)(i));if(i.startsWith("rediss://")){n=true}}else if(typeof i==="number"){t.port=i}else{throw new Error("Invalid argument "+i)}}if(n){(0,b.defaults)(t,{tls:true})}(0,b.defaults)(t,Redis.defaultOptions);if(typeof t.port==="string"){t.port=parseInt(t.port,10)}if(typeof t.db==="string"){t.db=parseInt(t.db,10)}this.options=(0,h.resolveTLSProfile)(t)}setStatus(e,t){if(v.enabled){v("status[%s]: %s -> %s",this._getDescription(),this.status||"[empty]",e)}this.status=e;process.nextTick(this.emit.bind(this,e,t))}createScanStream(e,{key:t,options:n={}}){return new p.default({objectMode:true,key:t,redis:this,command:e,...n})}flushQueue(e,t){t=(0,b.defaults)({},t,{offlineQueue:true,commandQueue:true});let n;if(t.offlineQueue){while(n=this.offlineQueue.shift()){n.command.reject(e)}}if(t.commandQueue){if(this.commandQueue.length>0){if(this.stream){this.stream.removeAllListeners("data")}while(n=this.commandQueue.shift()){n.command.reject(e)}}}}_readyCheck(e){const t=this;this.info((function(n,r){if(n){if(n.message&&n.message.includes("NOPERM")){console.warn(`Skipping the ready check because INFO command fails: "${n.message}". You can disable ready check with "enableReadyCheck". More: https://github.com/luin/ioredis/wiki/Disable-ready-check.`);return e(null,{})}return e(n)}if(typeof r!=="string"){return e(null,r)}const i={};const a=r.split("\r\n");for(let e=0;e<a.length;++e){const[t,...n]=a[e].split(":");const r=n.join(":");if(r){i[t]=r}}if(!i.loading||i.loading==="0"){e(null,i)}else{const n=(i.loading_eta_seconds||1)*1e3;const r=t.options.maxLoadingRetryTime&&t.options.maxLoadingRetryTime<n?t.options.maxLoadingRetryTime:n;v("Redis server still loading, trying again in "+r+"ms");setTimeout((function(){t._readyCheck(e)}),r)}})).catch(b.noop)}}Redis.Cluster=s.default;Redis.Command=o.default;Redis.defaultOptions=u.DEFAULT_REDIS_OPTIONS;(0,y.default)(Redis,i.EventEmitter);(0,f.addTransactionSupport)(Redis.prototype);t["default"]=Redis},2196:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(2203);class ScanStream extends r.Readable{constructor(e){super(e);this.opt=e;this._redisCursor="0";this._redisDrained=false}_read(){if(this._redisDrained){this.push(null);return}const e=[this._redisCursor];if(this.opt.key){e.unshift(this.opt.key)}if(this.opt.match){e.push("MATCH",this.opt.match)}if(this.opt.type){e.push("TYPE",this.opt.type)}if(this.opt.count){e.push("COUNT",String(this.opt.count))}if(this.opt.noValues){e.push("NOVALUES")}this.opt.redis[this.opt.command](e,((e,t)=>{if(e){this.emit("error",e);return}this._redisCursor=t[0]instanceof Buffer?t[0].toString():t[0];if(this._redisCursor==="0"){this._redisDrained=true}this.push(t[1])}))}close(){this._redisDrained=true}}t["default"]=ScanStream},7818:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(6982);const i=n(7544);const a=n(2460);class Script{constructor(e,t=null,n="",a=false){this.lua=e;this.numberOfKeys=t;this.keyPrefix=n;this.readOnly=a;this.sha=(0,r.createHash)("sha1").update(e).digest("hex");const s=this.sha;const o=new WeakSet;this.Command=class CustomScriptCommand extends i.default{toWritable(t){const n=this.reject;this.reject=e=>{if(e.message.indexOf("NOSCRIPT")!==-1){o.delete(t)}n.call(this,e)};if(!o.has(t)){o.add(t);this.name="eval";this.args[0]=e}else if(this.name==="eval"){this.name="evalsha";this.args[0]=s}return super.toWritable(t)}}}execute(e,t,n,r){if(typeof this.numberOfKeys==="number"){t.unshift(this.numberOfKeys)}if(this.keyPrefix){n.keyPrefix=this.keyPrefix}if(this.readOnly){n.readOnly=true}const i=new this.Command("evalsha",[this.sha,...t],n);i.promise=i.promise.catch((r=>{if(r.message.indexOf("NOSCRIPT")===-1){throw r}const i=new this.Command("evalsha",[this.sha,...t],n);const a=e.isPipeline?e.redis:e;return a.sendCommand(i)}));(0,a.default)(i.promise,r);return e.sendCommand(i)}}t["default"]=Script},7286:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});class SubscriptionSet{constructor(){this.set={subscribe:{},psubscribe:{},ssubscribe:{}}}add(e,t){this.set[mapSet(e)][t]=true}del(e,t){delete this.set[mapSet(e)][t]}channels(e){return Object.keys(this.set[mapSet(e)])}isEmpty(){return this.channels("subscribe").length===0&&this.channels("psubscribe").length===0&&this.channels("ssubscribe").length===0}}t["default"]=SubscriptionSet;function mapSet(e){if(e==="unsubscribe"){return"subscribe"}if(e==="punsubscribe"){return"psubscribe"}if(e==="sunsubscribe"){return"ssubscribe"}return e}},419:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.executeWithAutoPipelining=t.getFirstValueInFlattenedArray=t.shouldUseAutoPipelining=t.notAllowedAutoPipelineCommands=t.kCallbacks=t.kExec=void 0;const r=n(3146);const i=n(3288);const a=n(2460);t.kExec=Symbol("exec");t.kCallbacks=Symbol("callbacks");t.notAllowedAutoPipelineCommands=["auth","info","script","quit","cluster","pipeline","multi","subscribe","psubscribe","unsubscribe","unpsubscribe","select"];function executeAutoPipeline(e,n){if(e._runningAutoPipelines.has(n)){return}if(!e._autoPipelines.has(n)){return}e._runningAutoPipelines.add(n);const r=e._autoPipelines.get(n);e._autoPipelines.delete(n);const i=r[t.kCallbacks];r[t.kCallbacks]=null;r.exec((function(t,r){e._runningAutoPipelines.delete(n);if(t){for(let e=0;e<i.length;e++){process.nextTick(i[e],t)}}else{for(let e=0;e<i.length;e++){process.nextTick(i[e],...r[e])}}if(e._autoPipelines.has(n)){executeAutoPipeline(e,n)}}))}function shouldUseAutoPipelining(e,n,r){return n&&e.options.enableAutoPipelining&&!e.isPipeline&&!t.notAllowedAutoPipelineCommands.includes(r)&&!e.options.autoPipeliningIgnoredCommands.includes(r)}t.shouldUseAutoPipelining=shouldUseAutoPipelining;function getFirstValueInFlattenedArray(e){for(let t=0;t<e.length;t++){const n=e[t];if(typeof n==="string"){return n}else if(Array.isArray(n)||(0,r.isArguments)(n)){if(n.length===0){continue}return n[0]}const i=[n].flat();if(i.length>0){return i[0]}}return undefined}t.getFirstValueInFlattenedArray=getFirstValueInFlattenedArray;function executeWithAutoPipelining(e,n,s,o,l){if(e.isCluster&&!e.slots.length){if(e.status==="wait")e.connect().catch(r.noop);return(0,a.default)(new Promise((function(t,r){e.delayUntilReady((i=>{if(i){r(i);return}executeWithAutoPipelining(e,n,s,o,null).then(t,r)}))})),l)}const c=e.options.keyPrefix||"";const d=e.isCluster?e.slots[i(`${c}${getFirstValueInFlattenedArray(o)}`)].join(","):"main";if(!e._autoPipelines.has(d)){const n=e.pipeline();n[t.kExec]=false;n[t.kCallbacks]=[];e._autoPipelines.set(d,n)}const u=e._autoPipelines.get(d);if(!u[t.kExec]){u[t.kExec]=true;setImmediate(executeAutoPipeline,e,d)}const p=new Promise((function(e,r){u[t.kCallbacks].push((function(t,n){if(t){r(t);return}e(n)}));if(n==="call"){o.unshift(s)}u[n](...o)}));return(0,a.default)(p,l)}t.executeWithAutoPipelining=executeWithAutoPipelining},5322:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.DEFAULT_CLUSTER_OPTIONS=void 0;const r=n(2250);t.DEFAULT_CLUSTER_OPTIONS={clusterRetryStrategy:e=>Math.min(100+e*2,2e3),enableOfflineQueue:true,enableReadyCheck:true,scaleReads:"master",maxRedirections:16,retryDelayOnMoved:0,retryDelayOnFailover:100,retryDelayOnClusterDown:100,retryDelayOnTryAgain:100,slotsRefreshTimeout:1e3,useSRVRecords:false,resolveSrv:r.resolveSrv,dnsLookup:r.lookup,enableAutoPipelining:false,autoPipeliningIgnoredCommands:[],shardedSubscribers:false}},908:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(2174);const i=n(387);const a=n(3810);const s=(0,i.Debug)("cluster:subscriber");class ClusterSubscriber{constructor(e,t,n=false){this.connectionPool=e;this.emitter=t;this.isSharded=n;this.started=false;this.subscriber=null;this.slotRange=[];this.onSubscriberEnd=()=>{if(!this.started){s("subscriber has disconnected, but ClusterSubscriber is not started, so not reconnecting.");return}s("subscriber has disconnected, selecting a new one...");this.selectSubscriber()};this.connectionPool.on("-node",((e,t)=>{if(!this.started||!this.subscriber){return}if((0,r.getNodeKey)(this.subscriber.options)===t){s("subscriber has left, selecting a new one...");this.selectSubscriber()}}));this.connectionPool.on("+node",(()=>{if(!this.started||this.subscriber){return}s("a new node is discovered and there is no subscriber, selecting a new one...");this.selectSubscriber()}))}getInstance(){return this.subscriber}associateSlotRange(e){if(this.isSharded){this.slotRange=e}return this.slotRange}start(){this.started=true;this.selectSubscriber();s("started")}stop(){this.started=false;if(this.subscriber){this.subscriber.disconnect();this.subscriber=null}}isStarted(){return this.started}selectSubscriber(){const e=this.lastActiveSubscriber;if(e){e.off("end",this.onSubscriberEnd);e.disconnect()}if(this.subscriber){this.subscriber.off("end",this.onSubscriberEnd);this.subscriber.disconnect()}const t=(0,i.sample)(this.connectionPool.getNodes());if(!t){s("selecting subscriber failed since there is no node discovered in the cluster yet");this.subscriber=null;return}const{options:n}=t;s("selected a subscriber %s:%s",n.host,n.port);let o="subscriber";if(this.isSharded)o="ssubscriber";this.subscriber=new a.default({port:n.port,host:n.host,username:n.username,password:n.password,enableReadyCheck:true,connectionName:(0,r.getConnectionName)(o,n.connectionName),lazyConnect:true,tls:n.tls,retryStrategy:null});this.subscriber.on("error",i.noop);this.subscriber.once("end",this.onSubscriberEnd);const l={subscribe:[],psubscribe:[],ssubscribe:[]};if(e){const t=e.condition||e.prevCondition;if(t&&t.subscriber){l.subscribe=t.subscriber.channels("subscribe");l.psubscribe=t.subscriber.channels("psubscribe");l.ssubscribe=t.subscriber.channels("ssubscribe")}}if(l.subscribe.length||l.psubscribe.length||l.ssubscribe.length){let e=0;for(const t of["subscribe","psubscribe","ssubscribe"]){const n=l[t];if(n.length){e+=1;s("%s %d channels",t,n.length);this.subscriber[t](n).then((()=>{if(! --e){this.lastActiveSubscriber=this.subscriber}})).catch((()=>{s("failed to %s %d channels",t,n.length)}))}}}else{this.lastActiveSubscriber=this.subscriber}for(const e of["message","messageBuffer"]){this.subscriber.on(e,((t,n)=>{this.emitter.emit(e,t,n)}))}for(const e of["pmessage","pmessageBuffer"]){this.subscriber.on(e,((t,n,r)=>{this.emitter.emit(e,t,n,r)}))}if(this.isSharded==true){for(const e of["smessage","smessageBuffer"]){this.subscriber.on(e,((t,n)=>{this.emitter.emit(e,t,n)}))}}}}t["default"]=ClusterSubscriber},3409:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(387);const i=n(908);const a=n(9208);const s=n(2174);const o=n(3288);const l=(0,r.Debug)("cluster:subscriberGroup");class ClusterSubscriberGroup{constructor(e){this.cluster=e;this.shardedSubscribers=new Map;this.clusterSlots=[];this.subscriberToSlotsIndex=new Map;this.channels=new Map;e.on("+node",(e=>{this._addSubscriber(e)}));e.on("-node",(e=>{this._removeSubscriber(e)}));e.on("refresh",(()=>{this._refreshSlots(e)}))}getResponsibleSubscriber(e){const t=this.clusterSlots[e][0];return this.shardedSubscribers.get(t)}addChannels(e){const t=o(e[0]);e.forEach((e=>{if(o(e)!=t)return-1}));const n=this.channels.get(t);if(!n){this.channels.set(t,e)}else{this.channels.set(t,n.concat(e))}return[...this.channels.values()].flatMap((e=>e)).length}removeChannels(e){const t=o(e[0]);e.forEach((e=>{if(o(e)!=t)return-1}));const n=this.channels.get(t);if(n){const r=n.filter((t=>!e.includes(t)));this.channels.set(t,r)}return[...this.channels.values()].flatMap((e=>e)).length}stop(){for(const e of this.shardedSubscribers.values()){e.stop()}}start(){for(const e of this.shardedSubscribers.values()){if(!e.isStarted()){e.start()}}}_addSubscriber(e){const t=new a.default(e.options);if(t.addMasterNode(e)){const n=new i.default(t,this.cluster,true);const r=(0,s.getNodeKey)(e.options);this.shardedSubscribers.set(r,n);n.start();this._resubscribe();this.cluster.emit("+subscriber");return n}return null}_removeSubscriber(e){const t=(0,s.getNodeKey)(e.options);const n=this.shardedSubscribers.get(t);if(n){n.stop();this.shardedSubscribers.delete(t);this._resubscribe();this.cluster.emit("-subscriber")}return this.shardedSubscribers}_refreshSlots(e){if(this._slotsAreEqual(e.slots)){l("Nothing to refresh because the new cluster map is equal to the previous one.")}else{l("Refreshing the slots of the subscriber group.");this.subscriberToSlotsIndex=new Map;for(let t=0;t<e.slots.length;t++){const n=e.slots[t][0];if(!this.subscriberToSlotsIndex.has(n)){this.subscriberToSlotsIndex.set(n,[])}this.subscriberToSlotsIndex.get(n).push(Number(t))}this._resubscribe();this.clusterSlots=JSON.parse(JSON.stringify(e.slots));this.cluster.emit("subscribersReady");return true}return false}_resubscribe(){if(this.shardedSubscribers){this.shardedSubscribers.forEach(((e,t)=>{const n=this.subscriberToSlotsIndex.get(t);if(n){e.associateSlotRange(n);n.forEach((t=>{const n=e.getInstance();const r=this.channels.get(t);if(r&&r.length>0){if(n){n.ssubscribe(r);n.on("ready",(()=>{n.ssubscribe(r)}))}}}))}}))}}_slotsAreEqual(e){if(this.clusterSlots===undefined)return false;else return JSON.stringify(this.clusterSlots)===JSON.stringify(e)}}t["default"]=ClusterSubscriberGroup},9208:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(4434);const i=n(387);const a=n(2174);const s=n(3810);const o=(0,i.Debug)("cluster:connectionPool");class ConnectionPool extends r.EventEmitter{constructor(e){super();this.redisOptions=e;this.nodes={all:{},master:{},slave:{}};this.specifiedOptions={}}getNodes(e="all"){const t=this.nodes[e];return Object.keys(t).map((e=>t[e]))}getInstanceByKey(e){return this.nodes.all[e]}getSampleInstance(e){const t=Object.keys(this.nodes[e]);const n=(0,i.sample)(t);return this.nodes[e][n]}addMasterNode(e){const t=(0,a.getNodeKey)(e.options);const n=this.createRedisFromOptions(e,e.options.readOnly);if(!e.options.readOnly){this.nodes.all[t]=n;this.nodes.master[t]=n;return true}return false}createRedisFromOptions(e,t){const n=new s.default((0,i.defaults)({retryStrategy:null,enableOfflineQueue:true,readOnly:t},e,this.redisOptions,{lazyConnect:true}));return n}findOrCreate(e,t=false){const n=(0,a.getNodeKey)(e);t=Boolean(t);if(this.specifiedOptions[n]){Object.assign(e,this.specifiedOptions[n])}else{this.specifiedOptions[n]=e}let r;if(this.nodes.all[n]){r=this.nodes.all[n];if(r.options.readOnly!==t){r.options.readOnly=t;o("Change role of %s to %s",n,t?"slave":"master");r[t?"readonly":"readwrite"]().catch(i.noop);if(t){delete this.nodes.master[n];this.nodes.slave[n]=r}else{delete this.nodes.slave[n];this.nodes.master[n]=r}}}else{o("Connecting to %s as %s",n,t?"slave":"master");r=this.createRedisFromOptions(e,t);this.nodes.all[n]=r;this.nodes[t?"slave":"master"][n]=r;r.once("end",(()=>{this.removeNode(n);this.emit("-node",r,n);if(!Object.keys(this.nodes.all).length){this.emit("drain")}}));this.emit("+node",r,n);r.on("error",(function(e){this.emit("nodeError",e,n)}))}return r}reset(e){o("Reset with %O",e);const t={};e.forEach((e=>{const n=(0,a.getNodeKey)(e);if(!(e.readOnly&&t[n])){t[n]=e}}));Object.keys(this.nodes.all).forEach((e=>{if(!t[e]){o("Disconnect %s because the node does not hold any slot",e);this.nodes.all[e].disconnect();this.removeNode(e)}}));Object.keys(t).forEach((e=>{const n=t[e];this.findOrCreate(n,n.readOnly)}))}removeNode(e){const{nodes:t}=this;if(t.all[e]){o("Remove %s from the pool",e);delete t.all[e]}delete t.master[e];delete t.slave[e]}}t["default"]=ConnectionPool},640:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(387);const i=n(9611);const a=(0,r.Debug)("delayqueue");class DelayQueue{constructor(){this.queues={};this.timeouts={}}push(e,t,n){const r=n.callback||process.nextTick;if(!this.queues[e]){this.queues[e]=new i}const a=this.queues[e];a.push(t);if(!this.timeouts[e]){this.timeouts[e]=setTimeout((()=>{r((()=>{this.timeouts[e]=null;this.execute(e)}))}),n.timeout)}}execute(e){const t=this.queues[e];if(!t){return}const{length:n}=t;if(!n){return}a("send %d commands in %s queue",n,e);this.queues[e]=null;while(t.length>0){t.shift()()}}}t["default"]=DelayQueue},8524:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(4458);const i=n(4434);const a=n(8287);const s=n(2460);const o=n(7544);const l=n(7591);const c=n(3810);const d=n(2196);const u=n(7785);const p=n(387);const f=n(4190);const h=n(1325);const y=n(5322);const m=n(908);const b=n(9208);const g=n(640);const v=n(2174);const K=n(9611);const S=n(3409);const E=(0,p.Debug)("cluster");const k=new WeakSet;class Cluster extends h.default{constructor(e,t={}){super();this.slots=[];this._groupsIds={};this._groupsBySlot=Array(16384);this.isCluster=true;this.retryAttempts=0;this.delayQueue=new g.default;this.offlineQueue=new K;this.isRefreshing=false;this._refreshSlotsCacheCallbacks=[];this._autoPipelines=new Map;this._runningAutoPipelines=new Set;this._readyDelayedCallbacks=[];this.connectionEpoch=0;i.EventEmitter.call(this);this.startupNodes=e;this.options=(0,p.defaults)({},t,y.DEFAULT_CLUSTER_OPTIONS,this.options);if(this.options.shardedSubscribers==true)this.shardedSubscribers=new S.default(this);if(this.options.redisOptions&&this.options.redisOptions.keyPrefix&&!this.options.keyPrefix){this.options.keyPrefix=this.options.redisOptions.keyPrefix}if(typeof this.options.scaleReads!=="function"&&["all","master","slave"].indexOf(this.options.scaleReads)===-1){throw new Error('Invalid option scaleReads "'+this.options.scaleReads+'". Expected "all", "master", "slave" or a custom function')}this.connectionPool=new b.default(this.options.redisOptions);this.connectionPool.on("-node",((e,t)=>{this.emit("-node",e)}));this.connectionPool.on("+node",(e=>{this.emit("+node",e)}));this.connectionPool.on("drain",(()=>{this.setStatus("close")}));this.connectionPool.on("nodeError",((e,t)=>{this.emit("node error",e,t)}));this.subscriber=new m.default(this.connectionPool,this);if(this.options.scripts){Object.entries(this.options.scripts).forEach((([e,t])=>{this.defineCommand(e,t)}))}if(this.options.lazyConnect){this.setStatus("wait")}else{this.connect().catch((e=>{E("connecting failed: %s",e)}))}}connect(){return new Promise(((e,t)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){t(new Error("Redis is already connecting/connected"));return}const n=++this.connectionEpoch;this.setStatus("connecting");this.resolveStartupNodeHostnames().then((r=>{if(this.connectionEpoch!==n){E("discard connecting after resolving startup nodes because epoch not match: %d != %d",n,this.connectionEpoch);t(new a.RedisError("Connection is discarded because a new connection is made"));return}if(this.status!=="connecting"){E("discard connecting after resolving startup nodes because the status changed to %s",this.status);t(new a.RedisError("Connection is aborted"));return}this.connectionPool.reset(r);const readyHandler=()=>{this.setStatus("ready");this.retryAttempts=0;this.executeOfflineCommands();this.resetNodesRefreshInterval();e()};let i=undefined;const refreshListener=()=>{this.invokeReadyDelayedCallbacks(undefined);this.removeListener("close",i);this.manuallyClosing=false;this.setStatus("connect");if(this.options.enableReadyCheck){this.readyCheck(((e,t)=>{if(e||t){E("Ready check failed (%s). Reconnecting...",e||t);if(this.status==="connect"){this.disconnect(true)}}else{readyHandler()}}))}else{readyHandler()}};i=()=>{const e=new Error("None of startup nodes is available");this.removeListener("refresh",refreshListener);this.invokeReadyDelayedCallbacks(e);t(e)};this.once("refresh",refreshListener);this.once("close",i);this.once("close",this.handleCloseEvent.bind(this));this.refreshSlotsCache((e=>{if(e&&e.message===l.default.defaultMessage){c.default.prototype.silentEmit.call(this,"error",e);this.connectionPool.reset([])}}));this.subscriber.start();if(this.options.shardedSubscribers){this.shardedSubscribers.start()}})).catch((e=>{this.setStatus("close");this.handleCloseEvent(e);this.invokeReadyDelayedCallbacks(e);t(e)}))}))}disconnect(e=false){const t=this.status;this.setStatus("disconnecting");if(!e){this.manuallyClosing=true}if(this.reconnectTimeout&&!e){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=null;E("Canceled reconnecting attempts")}this.clearNodesRefreshInterval();this.subscriber.stop();if(this.options.shardedSubscribers){this.shardedSubscribers.stop()}if(t==="wait"){this.setStatus("close");this.handleCloseEvent()}else{this.connectionPool.reset([])}}quit(e){const t=this.status;this.setStatus("disconnecting");this.manuallyClosing=true;if(this.reconnectTimeout){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=null}this.clearNodesRefreshInterval();this.subscriber.stop();if(this.options.shardedSubscribers){this.shardedSubscribers.stop()}if(t==="wait"){const t=(0,s.default)(Promise.resolve("OK"),e);setImmediate(function(){this.setStatus("close");this.handleCloseEvent()}.bind(this));return t}return(0,s.default)(Promise.all(this.nodes().map((e=>e.quit().catch((e=>{if(e.message===p.CONNECTION_CLOSED_ERROR_MSG){return"OK"}throw e}))))).then((()=>"OK")),e)}duplicate(e=[],t={}){const n=e.length>0?e:this.startupNodes.slice(0);const r=Object.assign({},this.options,t);return new Cluster(n,r)}nodes(e="all"){if(e!=="all"&&e!=="master"&&e!=="slave"){throw new Error('Invalid role "'+e+'". Expected "all", "master" or "slave"')}return this.connectionPool.getNodes(e)}delayUntilReady(e){this._readyDelayedCallbacks.push(e)}get autoPipelineQueueSize(){let e=0;for(const t of this._autoPipelines.values()){e+=t.length}return e}refreshSlotsCache(e){if(e){this._refreshSlotsCacheCallbacks.push(e)}if(this.isRefreshing){return}this.isRefreshing=true;const t=this;const wrapper=e=>{this.isRefreshing=false;for(const t of this._refreshSlotsCacheCallbacks){t(e)}this._refreshSlotsCacheCallbacks=[]};const n=(0,p.shuffle)(this.connectionPool.getNodes());let r=null;function tryNode(e){if(e===n.length){const e=new l.default(l.default.defaultMessage,r);return wrapper(e)}const i=n[e];const a=`${i.options.host}:${i.options.port}`;E("getting slot cache from %s",a);t.getInfoFromNode(i,(function(n){switch(t.status){case"close":case"end":return wrapper(new Error("Cluster is disconnected."));case"disconnecting":return wrapper(new Error("Cluster is disconnecting."))}if(n){t.emit("node error",n,a);r=n;tryNode(e+1)}else{t.emit("refresh");wrapper()}}))}tryNode(0)}sendCommand(e,t,n){if(this.status==="wait"){this.connect().catch(p.noop)}if(this.status==="end"){e.reject(new Error(p.CONNECTION_CLOSED_ERROR_MSG));return e.promise}let i=this.options.scaleReads;if(i!=="master"){const t=e.isReadOnly||(0,r.exists)(e.name)&&(0,r.hasFlag)(e.name,"readonly");if(!t){i="master"}}let s=n?n.slot:e.getSlot();const l={};const c=this;if(!n&&!k.has(e)){k.add(e);const t=e.reject;e.reject=function(n){const r=tryConnection.bind(null,true);c.handleError(n,l,{moved:function(t,n){E("command %s is moved to %s",e.name,n);s=Number(t);if(c.slots[t]){c.slots[t][0]=n}else{c.slots[t]=[n]}c._groupsBySlot[t]=c._groupsIds[c.slots[t].join(";")];c.connectionPool.findOrCreate(c.natMapper(n));tryConnection();E("refreshing slot caches... (triggered by MOVED error)");c.refreshSlotsCache()},ask:function(t,n){E("command %s is required to ask %s:%s",e.name,n);const r=c.natMapper(n);c.connectionPool.findOrCreate(r);tryConnection(false,`${r.host}:${r.port}`)},tryagain:r,clusterDown:r,connectionClosed:r,maxRedirections:function(n){t.call(e,n)},defaults:function(){t.call(e,n)}})}}tryConnection();function tryConnection(r,l){if(c.status==="end"){e.reject(new a.AbortError("Cluster is ended."));return}let d;if(c.status==="ready"||e.name==="cluster"){if(n&&n.redis){d=n.redis}else if(o.default.checkFlag("ENTER_SUBSCRIBER_MODE",e.name)||o.default.checkFlag("EXIT_SUBSCRIBER_MODE",e.name)){if(c.options.shardedSubscribers==true&&(e.name=="ssubscribe"||e.name=="sunsubscribe")){const t=c.shardedSubscribers.getResponsibleSubscriber(s);let n=-1;if(e.name=="ssubscribe")n=c.shardedSubscribers.addChannels(e.getKeys());if(e.name=="sunsubscribe")n=c.shardedSubscribers.removeChannels(e.getKeys());if(n!==-1){d=t.getInstance()}else{e.reject(new a.AbortError("Can't add or remove the given channels. Are they in the same slot?"))}}else{d=c.subscriber.getInstance()}if(!d){e.reject(new a.AbortError("No subscriber for the cluster"));return}}else{if(!r){if(typeof s==="number"&&c.slots[s]){const t=c.slots[s];if(typeof i==="function"){const n=t.map((function(e){return c.connectionPool.getInstanceByKey(e)}));d=i(n,e);if(Array.isArray(d)){d=(0,p.sample)(d)}if(!d){d=n[0]}}else{let e;if(i==="all"){e=(0,p.sample)(t)}else if(i==="slave"&&t.length>1){e=(0,p.sample)(t,1)}else{e=t[0]}d=c.connectionPool.getInstanceByKey(e)}}if(l){d=c.connectionPool.getInstanceByKey(l);d.asking()}}if(!d){d=(typeof i==="function"?null:c.connectionPool.getSampleInstance(i))||c.connectionPool.getSampleInstance("all")}}if(n&&!n.redis){n.redis=d}}if(d){d.sendCommand(e,t)}else if(c.options.enableOfflineQueue){c.offlineQueue.push({command:e,stream:t,node:n})}else{e.reject(new Error("Cluster isn't ready and enableOfflineQueue options is false"))}}return e.promise}sscanStream(e,t){return this.createScanStream("sscan",{key:e,options:t})}sscanBufferStream(e,t){return this.createScanStream("sscanBuffer",{key:e,options:t})}hscanStream(e,t){return this.createScanStream("hscan",{key:e,options:t})}hscanBufferStream(e,t){return this.createScanStream("hscanBuffer",{key:e,options:t})}zscanStream(e,t){return this.createScanStream("zscan",{key:e,options:t})}zscanBufferStream(e,t){return this.createScanStream("zscanBuffer",{key:e,options:t})}handleError(e,t,n){if(typeof t.value==="undefined"){t.value=this.options.maxRedirections}else{t.value-=1}if(t.value<=0){n.maxRedirections(new Error("Too many Cluster redirections. Last error: "+e));return}const r=e.message.split(" ");if(r[0]==="MOVED"){const e=this.options.retryDelayOnMoved;if(e&&typeof e==="number"){this.delayQueue.push("moved",n.moved.bind(null,r[1],r[2]),{timeout:e})}else{n.moved(r[1],r[2])}}else if(r[0]==="ASK"){n.ask(r[1],r[2])}else if(r[0]==="TRYAGAIN"){this.delayQueue.push("tryagain",n.tryagain,{timeout:this.options.retryDelayOnTryAgain})}else if(r[0]==="CLUSTERDOWN"&&this.options.retryDelayOnClusterDown>0){this.delayQueue.push("clusterdown",n.connectionClosed,{timeout:this.options.retryDelayOnClusterDown,callback:this.refreshSlotsCache.bind(this)})}else if(e.message===p.CONNECTION_CLOSED_ERROR_MSG&&this.options.retryDelayOnFailover>0&&this.status==="ready"){this.delayQueue.push("failover",n.connectionClosed,{timeout:this.options.retryDelayOnFailover,callback:this.refreshSlotsCache.bind(this)})}else{n.defaults()}}resetOfflineQueue(){this.offlineQueue=new K}clearNodesRefreshInterval(){if(this.slotsTimer){clearTimeout(this.slotsTimer);this.slotsTimer=null}}resetNodesRefreshInterval(){if(this.slotsTimer||!this.options.slotsRefreshInterval){return}const nextRound=()=>{this.slotsTimer=setTimeout((()=>{E('refreshing slot caches... (triggered by "slotsRefreshInterval" option)');this.refreshSlotsCache((()=>{nextRound()}))}),this.options.slotsRefreshInterval)};nextRound()}setStatus(e){E("status: %s -> %s",this.status||"[empty]",e);this.status=e;process.nextTick((()=>{this.emit(e)}))}handleCloseEvent(e){if(e){E("closed because %s",e)}let t;if(!this.manuallyClosing&&typeof this.options.clusterRetryStrategy==="function"){t=this.options.clusterRetryStrategy.call(this,++this.retryAttempts,e)}if(typeof t==="number"){this.setStatus("reconnecting");this.reconnectTimeout=setTimeout((()=>{this.reconnectTimeout=null;E("Cluster is disconnected. Retrying after %dms",t);this.connect().catch((function(e){E("Got error %s when reconnecting. Ignoring...",e)}))}),t)}else{this.setStatus("end");this.flushQueue(new Error("None of startup nodes is available"))}}flushQueue(e){let t;while(t=this.offlineQueue.shift()){t.command.reject(e)}}executeOfflineCommands(){if(this.offlineQueue.length){E("send %d commands in offline queue",this.offlineQueue.length);const e=this.offlineQueue;this.resetOfflineQueue();let t;while(t=e.shift()){this.sendCommand(t.command,t.stream,t.node)}}}natMapper(e){const t=typeof e==="string"?e:`${e.host}:${e.port}`;let n=null;if(this.options.natMap&&typeof this.options.natMap==="function"){n=this.options.natMap(t)}else if(this.options.natMap&&typeof this.options.natMap==="object"){n=this.options.natMap[t]}if(n){E("NAT mapping %s -> %O",t,n);return Object.assign({},n)}return typeof e==="string"?(0,v.nodeKeyToRedisOptions)(e):e}getInfoFromNode(e,t){if(!e){return t(new Error("Node is disconnected"))}const n=e.duplicate({enableOfflineQueue:true,enableReadyCheck:false,retryStrategy:null,connectionName:(0,v.getConnectionName)("refresher",this.options.redisOptions&&this.options.redisOptions.connectionName)});n.on("error",p.noop);n.cluster("SLOTS",(0,p.timeout)(((e,r)=>{n.disconnect();if(e){E("error encountered running CLUSTER.SLOTS: %s",e);return t(e)}if(this.status==="disconnecting"||this.status==="close"||this.status==="end"){E("ignore CLUSTER.SLOTS results (count: %d) since cluster status is %s",r.length,this.status);t();return}const i=[];E("cluster slots result count: %d",r.length);for(let e=0;e<r.length;++e){const t=r[e];const n=t[0];const a=t[1];const s=[];for(let e=2;e<t.length;e++){if(!t[e][0]){continue}const n=this.natMapper({host:t[e][0],port:t[e][1]});n.readOnly=e!==2;i.push(n);s.push(n.host+":"+n.port)}E("cluster slots result [%d]: slots %d~%d served by %s",e,n,a,s);for(let e=n;e<=a;e++){this.slots[e]=s}}this._groupsIds=Object.create(null);let a=0;for(let e=0;e<16384;e++){const t=(this.slots[e]||[]).join(";");if(!t.length){this._groupsBySlot[e]=undefined;continue}if(!this._groupsIds[t]){this._groupsIds[t]=++a}this._groupsBySlot[e]=this._groupsIds[t]}this.connectionPool.reset(i);t()}),this.options.slotsRefreshTimeout))}invokeReadyDelayedCallbacks(e){for(const t of this._readyDelayedCallbacks){process.nextTick(t,e)}this._readyDelayedCallbacks=[]}readyCheck(e){this.cluster("INFO",((t,n)=>{if(t){return e(t)}if(typeof n!=="string"){return e()}let r;const i=n.split("\r\n");for(let e=0;e<i.length;++e){const t=i[e].split(":");if(t[0]==="cluster_state"){r=t[1];break}}if(r==="fail"){E("cluster state not ok (%s)",r);e(null,r)}else{e()}}))}resolveSrv(e){return new Promise(((t,n)=>{this.options.resolveSrv(e,((e,r)=>{if(e){return n(e)}const i=this,a=(0,v.groupSrvRecords)(r),s=Object.keys(a).sort(((e,t)=>parseInt(e)-parseInt(t)));function tryFirstOne(e){if(!s.length){return n(e)}const r=s[0],o=a[r],l=(0,v.weightSrvRecords)(o);if(!o.records.length){s.shift()}i.dnsLookup(l.name).then((e=>t({host:e,port:l.port})),tryFirstOne)}tryFirstOne()}))}))}dnsLookup(e){return new Promise(((t,n)=>{this.options.dnsLookup(e,((r,i)=>{if(r){E("failed to resolve hostname %s to IP: %s",e,r.message);n(r)}else{E("resolved hostname %s to IP %s",e,i);t(i)}}))}))}async resolveStartupNodeHostnames(){if(!Array.isArray(this.startupNodes)||this.startupNodes.length===0){throw new Error("`startupNodes` should contain at least one node.")}const e=(0,v.normalizeNodeOptions)(this.startupNodes);const t=(0,v.getUniqueHostnamesFromOptions)(e);if(t.length===0){return e}const n=await Promise.all(t.map((this.options.useSRVRecords?this.resolveSrv:this.dnsLookup).bind(this)));const r=(0,p.zipMap)(t,n);return e.map((e=>{const t=r.get(e.host);if(!t){return e}if(this.options.useSRVRecords){return Object.assign({},e,t)}return Object.assign({},e,{host:t})}))}createScanStream(e,{key:t,options:n={}}){return new d.default({objectMode:true,key:t,redis:this,command:e,...n})}}(0,f.default)(Cluster,i.EventEmitter);(0,u.addTransactionSupport)(Cluster.prototype);t["default"]=Cluster},2174:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getConnectionName=t.weightSrvRecords=t.groupSrvRecords=t.getUniqueHostnamesFromOptions=t.normalizeNodeOptions=t.nodeKeyToRedisOptions=t.getNodeKey=void 0;const r=n(387);const i=n(9278);function getNodeKey(e){e.port=e.port||6379;e.host=e.host||"127.0.0.1";return e.host+":"+e.port}t.getNodeKey=getNodeKey;function nodeKeyToRedisOptions(e){const t=e.lastIndexOf(":");if(t===-1){throw new Error(`Invalid node key ${e}`)}return{host:e.slice(0,t),port:Number(e.slice(t+1))}}t.nodeKeyToRedisOptions=nodeKeyToRedisOptions;function normalizeNodeOptions(e){return e.map((e=>{const t={};if(typeof e==="object"){Object.assign(t,e)}else if(typeof e==="string"){Object.assign(t,(0,r.parseURL)(e))}else if(typeof e==="number"){t.port=e}else{throw new Error("Invalid argument "+e)}if(typeof t.port==="string"){t.port=parseInt(t.port,10)}delete t.db;if(!t.port){t.port=6379}if(!t.host){t.host="127.0.0.1"}return(0,r.resolveTLSProfile)(t)}))}t.normalizeNodeOptions=normalizeNodeOptions;function getUniqueHostnamesFromOptions(e){const t={};e.forEach((e=>{t[e.host]=true}));return Object.keys(t).filter((e=>!(0,i.isIP)(e)))}t.getUniqueHostnamesFromOptions=getUniqueHostnamesFromOptions;function groupSrvRecords(e){const t={};for(const n of e){if(!t.hasOwnProperty(n.priority)){t[n.priority]={totalWeight:n.weight,records:[n]}}else{t[n.priority].totalWeight+=n.weight;t[n.priority].records.push(n)}}return t}t.groupSrvRecords=groupSrvRecords;function weightSrvRecords(e){if(e.records.length===1){e.totalWeight=0;return e.records.shift()}const t=Math.floor(Math.random()*(e.totalWeight+e.records.length));let n=0;for(const[r,i]of e.records.entries()){n+=1+i.weight;if(n>t){e.totalWeight-=i.weight;e.records.splice(r,1);return i}}}t.weightSrvRecords=weightSrvRecords;function getConnectionName(e,t){const n=`ioredis-cluster(${e})`;return t?`${n}:${t}`:n}t.getConnectionName=getConnectionName},5031:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(387);const i=(0,r.Debug)("AbstractConnector");class AbstractConnector{constructor(e){this.connecting=false;this.disconnectTimeout=e}check(e){return true}disconnect(){this.connecting=false;if(this.stream){const e=this.stream;const t=setTimeout((()=>{i("stream %s:%s still open, destroying it",e.remoteAddress,e.remotePort);e.destroy()}),this.disconnectTimeout);e.on("close",(()=>clearTimeout(t)));e.end()}}}t["default"]=AbstractConnector},5468:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.FailoverDetector=void 0;const r=n(387);const i=(0,r.Debug)("FailoverDetector");const a="+switch-master";class FailoverDetector{constructor(e,t){this.isDisconnected=false;this.connector=e;this.sentinels=t}cleanup(){this.isDisconnected=true;for(const e of this.sentinels){e.client.disconnect()}}async subscribe(){i("Starting FailoverDetector");const e=[];for(const t of this.sentinels){const n=t.client.subscribe(a).catch((e=>{i("Failed to subscribe to failover messages on sentinel %s:%s (%s)",t.address.host||"127.0.0.1",t.address.port||26739,e.message)}));e.push(n);t.client.on("message",(e=>{if(!this.isDisconnected&&e===a){this.disconnect()}}))}await Promise.all(e)}disconnect(){this.isDisconnected=true;i("Failover detected, disconnecting");this.connector.disconnect()}}t.FailoverDetector=FailoverDetector},4694:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function isSentinelEql(e,t){return(e.host||"127.0.0.1")===(t.host||"127.0.0.1")&&(e.port||26379)===(t.port||26379)}class SentinelIterator{constructor(e){this.cursor=0;this.sentinels=e.slice(0)}next(){const e=this.cursor>=this.sentinels.length;return{done:e,value:e?undefined:this.sentinels[this.cursor++]}}reset(e){if(e&&this.sentinels.length>1&&this.cursor!==1){this.sentinels.unshift(...this.sentinels.splice(this.cursor-1))}this.cursor=0}add(e){for(let t=0;t<this.sentinels.length;t++){if(isSentinelEql(e,this.sentinels[t])){return false}}this.sentinels.push(e);return true}toString(){return`${JSON.stringify(this.sentinels)} @${this.cursor}`}}t["default"]=SentinelIterator},1082:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.SentinelIterator=void 0;const r=n(9278);const i=n(387);const a=n(4756);const s=n(4694);t.SentinelIterator=s.default;const o=n(5031);const l=n(3810);const c=n(5468);const d=(0,i.Debug)("SentinelConnector");class SentinelConnector extends o.default{constructor(e){super(e.disconnectTimeout);this.options=e;this.emitter=null;this.failoverDetector=null;if(!this.options.sentinels.length){throw new Error("Requires at least one sentinel to connect to.")}if(!this.options.name){throw new Error("Requires the name of master.")}this.sentinelIterator=new s.default(this.options.sentinels)}check(e){const t=!e.role||this.options.role===e.role;if(!t){d("role invalid, expected %s, but got %s",this.options.role,e.role);this.sentinelIterator.next();this.sentinelIterator.next();this.sentinelIterator.reset(true)}return t}disconnect(){super.disconnect();if(this.failoverDetector){this.failoverDetector.cleanup()}}connect(e){this.connecting=true;this.retryAttempts=0;let t;const connectToNext=async()=>{const n=this.sentinelIterator.next();if(n.done){this.sentinelIterator.reset(false);const n=typeof this.options.sentinelRetryStrategy==="function"?this.options.sentinelRetryStrategy(++this.retryAttempts):null;let r=typeof n!=="number"?"All sentinels are unreachable and retry is disabled.":`All sentinels are unreachable. Retrying from scratch after ${n}ms.`;if(t){r+=` Last error: ${t.message}`}d(r);const i=new Error(r);if(typeof n==="number"){e("error",i);await new Promise((e=>setTimeout(e,n)));return connectToNext()}else{throw i}}let s=null;let o=null;try{s=await this.resolve(n.value)}catch(e){o=e}if(!this.connecting){throw new Error(i.CONNECTION_CLOSED_ERROR_MSG)}const l=n.value.host+":"+n.value.port;if(s){d("resolved: %s:%s from sentinel %s",s.host,s.port,l);if(this.options.enableTLSForSentinelMode&&this.options.tls){Object.assign(s,this.options.tls);this.stream=(0,a.connect)(s);this.stream.once("secureConnect",this.initFailoverDetector.bind(this))}else{this.stream=(0,r.createConnection)(s);this.stream.once("connect",this.initFailoverDetector.bind(this))}this.stream.once("error",(e=>{this.firstError=e}));return this.stream}else{const n=o?"failed to connect to sentinel "+l+" because "+o.message:"connected to sentinel "+l+" successfully, but got an invalid reply: "+s;d(n);e("sentinelError",new Error(n));if(o){t=o}return connectToNext()}};return connectToNext()}async updateSentinels(e){if(!this.options.updateSentinels){return}const t=await e.sentinel("sentinels",this.options.name);if(!Array.isArray(t)){return}t.map(i.packObject).forEach((e=>{const t=e.flags?e.flags.split(","):[];if(t.indexOf("disconnected")===-1&&e.ip&&e.port){const t=this.sentinelNatResolve(addressResponseToAddress(e));if(this.sentinelIterator.add(t)){d("adding sentinel %s:%s",t.host,t.port)}}}));d("Updated internal sentinels: %s",this.sentinelIterator)}async resolveMaster(e){const t=await e.sentinel("get-master-addr-by-name",this.options.name);await this.updateSentinels(e);return this.sentinelNatResolve(Array.isArray(t)?{host:t[0],port:Number(t[1])}:null)}async resolveSlave(e){const t=await e.sentinel("slaves",this.options.name);if(!Array.isArray(t)){return null}const n=t.map(i.packObject).filter((e=>e.flags&&!e.flags.match(/(disconnected|s_down|o_down)/)));return this.sentinelNatResolve(selectPreferredSentinel(n,this.options.preferredSlaves))}sentinelNatResolve(e){if(!e||!this.options.natMap)return e;const t=`${e.host}:${e.port}`;let n=e;if(typeof this.options.natMap==="function"){n=this.options.natMap(t)||e}else if(typeof this.options.natMap==="object"){n=this.options.natMap[t]||e}return n}connectToSentinel(e,t){const n=new l.default({port:e.port||26379,host:e.host,username:this.options.sentinelUsername||null,password:this.options.sentinelPassword||null,family:e.family||("path"in this.options&&this.options.path?undefined:this.options.family),tls:this.options.sentinelTLS,retryStrategy:null,enableReadyCheck:false,connectTimeout:this.options.connectTimeout,commandTimeout:this.options.sentinelCommandTimeout,...t});return n}async resolve(e){const t=this.connectToSentinel(e);t.on("error",noop);try{if(this.options.role==="slave"){return await this.resolveSlave(t)}else{return await this.resolveMaster(t)}}finally{t.disconnect()}}async initFailoverDetector(){var e;if(!this.options.failoverDetector){return}this.sentinelIterator.reset(true);const t=[];while(t.length<this.options.sentinelMaxConnections){const{done:e,value:n}=this.sentinelIterator.next();if(e){break}const r=this.connectToSentinel(n,{lazyConnect:true,retryStrategy:this.options.sentinelReconnectStrategy});r.on("reconnecting",(()=>{var e;(e=this.emitter)===null||e===void 0?void 0:e.emit("sentinelReconnecting")}));t.push({address:n,client:r})}this.sentinelIterator.reset(false);if(this.failoverDetector){this.failoverDetector.cleanup()}this.failoverDetector=new c.FailoverDetector(this,t);await this.failoverDetector.subscribe();(e=this.emitter)===null||e===void 0?void 0:e.emit("failoverSubscribed")}}t["default"]=SentinelConnector;function selectPreferredSentinel(e,t){if(e.length===0){return null}let n;if(typeof t==="function"){n=t(e)}else if(t!==null&&typeof t==="object"){const r=Array.isArray(t)?t:[t];r.sort(((e,t)=>{if(!e.prio){e.prio=1}if(!t.prio){t.prio=1}if(e.prio<t.prio){return-1}if(e.prio>t.prio){return 1}return 0}));for(let t=0;t<r.length;t++){for(let i=0;i<e.length;i++){const a=e[i];if(a.ip===r[t].ip){if(a.port===r[t].port){n=a;break}}}if(n){break}}}if(!n){n=(0,i.sample)(e)}return addressResponseToAddress(n)}function addressResponseToAddress(e){return{host:e.ip,port:Number(e.port)}}function noop(){}},2768:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(9278);const i=n(4756);const a=n(387);const s=n(5031);class StandaloneConnector extends s.default{constructor(e){super(e.disconnectTimeout);this.options=e}connect(e){const{options:t}=this;this.connecting=true;let n;if("path"in t&&t.path){n={path:t.path}}else{n={};if("port"in t&&t.port!=null){n.port=t.port}if("host"in t&&t.host!=null){n.host=t.host}if("family"in t&&t.family!=null){n.family=t.family}}if(t.tls){Object.assign(n,t.tls)}return new Promise(((e,s)=>{process.nextTick((()=>{if(!this.connecting){s(new Error(a.CONNECTION_CLOSED_ERROR_MSG));return}try{if(t.tls){this.stream=(0,i.connect)(n)}else{this.stream=(0,r.createConnection)(n)}}catch(e){s(e);return}this.stream.once("error",(e=>{this.firstError=e}));e(this.stream)}))}))}}t["default"]=StandaloneConnector},8886:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.SentinelConnector=t.StandaloneConnector=void 0;const r=n(2768);t.StandaloneConnector=r.default;const i=n(1082);t.SentinelConnector=i.default},5260:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});const n=`-----BEGIN CERTIFICATE-----\nMIIDTzCCAjegAwIBAgIJAKSVpiDswLcwMA0GCSqGSIb3DQEBBQUAMD4xFjAUBgNV\nBAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1\ndGhvcml0eTAeFw0xMzEwMDExMjE0NTVaFw0yMzA5MjkxMjE0NTVaMD4xFjAUBgNV\nBAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1\ndGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALZqkh/DczWP\nJnxnHLQ7QL0T4B4CDKWBKCcisriGbA6ZePWVNo4hfKQC6JrzfR+081NeD6VcWUiz\nrmd+jtPhIY4c+WVQYm5PKaN6DT1imYdxQw7aqO5j2KUCEh/cznpLxeSHoTxlR34E\nQwF28Wl3eg2vc5ct8LjU3eozWVk3gb7alx9mSA2SgmuX5lEQawl++rSjsBStemY2\nBDwOpAMXIrdEyP/cVn8mkvi/BDs5M5G+09j0gfhyCzRWMQ7Hn71u1eolRxwVxgi3\nTMn+/vTaFSqxKjgck6zuAYjBRPaHe7qLxHNr1So/Mc9nPy+3wHebFwbIcnUojwbp\n4nctkWbjb2cCAwEAAaNQME4wHQYDVR0OBBYEFP1whtcrydmW3ZJeuSoKZIKjze3w\nMB8GA1UdIwQYMBaAFP1whtcrydmW3ZJeuSoKZIKjze3wMAwGA1UdEwQFMAMBAf8w\nDQYJKoZIhvcNAQEFBQADggEBAG2erXhwRAa7+ZOBs0B6X57Hwyd1R4kfmXcs0rta\nlbPpvgULSiB+TCbf3EbhJnHGyvdCY1tvlffLjdA7HJ0PCOn+YYLBA0pTU/dyvrN6\nSu8NuS5yubnt9mb13nDGYo1rnt0YRfxN+8DM3fXIVr038A30UlPX2Ou1ExFJT0MZ\nuFKY6ZvLdI6/1cbgmguMlAhM+DhKyV6Sr5699LM3zqeI816pZmlREETYkGr91q7k\nBpXJu/dtHaGxg1ZGu6w/PCsYGUcECWENYD4VQPd8N32JjOfu6vEgoEAwfPP+3oGp\nZ4m3ewACcWOAenqflb+cQYC4PsF7qbXDmRaWrbKntOlZ3n0=\n-----END CERTIFICATE-----\n-----BEGIN CERTIFICATE-----\nMIIGMTCCBBmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwajELMAkGA1UEBhMCVVMx\nCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJzMS0w\nKwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcN\nMTgwMjI1MTUzNzM3WhcNMjgwMjIzMTUzNzM3WjBfMQswCQYDVQQGEwJVUzELMAkG\nA1UECAwCQ0ExEjAQBgNVBAoMCVJlZGlzTGFiczEvMC0GA1UEAwwmUkNQIEludGVy\nbWVkaWF0ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA\nA4ICDwAwggIKAoICAQDf9dqbxc8Bq7Ctq9rWcxrGNKKHivqLAFpPq02yLPx6fsOv\nTq7GsDChAYBBc4v7Y2Ap9RD5Vs3dIhEANcnolf27QwrG9RMnnvzk8pCvp1o6zSU4\nVuOE1W66/O1/7e2rVxyrnTcP7UgK43zNIXu7+tiAqWsO92uSnuMoGPGpeaUm1jym\nhjWKtkAwDFSqvHY+XL5qDVBEjeUe+WHkYUg40cAXjusAqgm2hZt29c2wnVrxW25W\nP0meNlzHGFdA2AC5z54iRiqj57dTfBTkHoBczQxcyw6hhzxZQ4e5I5zOKjXXEhZN\nr0tA3YC14CTabKRus/JmZieyZzRgEy2oti64tmLYTqSlAD78pRL40VNoaSYetXLw\nhhNsXCHgWaY6d5bLOc/aIQMAV5oLvZQKvuXAF1IDmhPA+bZbpWipp0zagf1P1H3s\nUzsMdn2KM0ejzgotbtNlj5TcrVwpmvE3ktvUAuA+hi3FkVx1US+2Gsp5x4YOzJ7u\nP1WPk6ShF0JgnJH2ILdj6kttTWwFzH17keSFICWDfH/+kM+k7Y1v3EXMQXE7y0T9\nMjvJskz6d/nv+sQhY04xt64xFMGTnZjlJMzfQNi7zWFLTZnDD0lPowq7l3YiPoTT\nt5Xky83lu0KZsZBo0WlWaDG00gLVdtRgVbcuSWxpi5BdLb1kRab66JptWjxwXQID\nAQABo4HrMIHoMDoGA1UdHwQzMDEwL6AtoCuGKWh0dHBzOi8vcmwtY2Etc2VydmVy\nLnJlZGlzbGFicy5jb20vdjEvY3JsMEYGCCsGAQUFBwEBBDowODA2BggrBgEFBQcw\nAYYqaHR0cHM6Ly9ybC1jYS1zZXJ2ZXIucmVkaXNsYWJzLmNvbS92MS9vY3NwMB0G\nA1UdDgQWBBQHar5OKvQUpP2qWt6mckzToeCOHDAfBgNVHSMEGDAWgBQi42wH6hM4\nL2sujEvLM0/u8lRXTzASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIB\nhjANBgkqhkiG9w0BAQsFAAOCAgEAirEn/iTsAKyhd+pu2W3Z5NjCko4NPU0EYUbr\nAP7+POK2rzjIrJO3nFYQ/LLuC7KCXG+2qwan2SAOGmqWst13Y+WHp44Kae0kaChW\nvcYLXXSoGQGC8QuFSNUdaeg3RbMDYFT04dOkqufeWVccoHVxyTSg9eD8LZuHn5jw\n7QDLiEECBmIJHk5Eeo2TAZrx4Yx6ufSUX5HeVjlAzqwtAqdt99uCJ/EL8bgpWbe+\nXoSpvUv0SEC1I1dCAhCKAvRlIOA6VBcmzg5Am12KzkqTul12/VEFIgzqu0Zy2Jbc\nAUPrYVu/+tOGXQaijy7YgwH8P8n3s7ZeUa1VABJHcxrxYduDDJBLZi+MjheUDaZ1\njQRHYevI2tlqeSBqdPKG4zBY5lS0GiAlmuze5oENt0P3XboHoZPHiqcK3VECgTVh\n/BkJcuudETSJcZDmQ8YfoKfBzRQNg2sv/hwvUv73Ss51Sco8GEt2lD8uEdib1Q6z\nzDT5lXJowSzOD5ZA9OGDjnSRL+2riNtKWKEqvtEG3VBJoBzu9GoxbAc7wIZLxmli\niF5a/Zf5X+UXD3s4TMmy6C4QZJpAA2egsSQCnraWO2ULhh7iXMysSkF/nzVfZn43\niqpaB8++9a37hWq14ZmOv0TJIDz//b2+KC4VFXWQ5W5QC6whsjT+OlG4p5ZYG0jo\n616pxqo=\n-----END CERTIFICATE-----\n-----BEGIN CERTIFICATE-----\nMIIFujCCA6KgAwIBAgIJAJ1aTT1lu2ScMA0GCSqGSIb3DQEBCwUAMGoxCzAJBgNV\nBAYTAlVTMQswCQYDVQQIDAJDQTELMAkGA1UEBwwCQ0ExEjAQBgNVBAoMCVJlZGlz\nTGFiczEtMCsGA1UEAwwkUmVkaXNMYWJzIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9y\naXR5MB4XDTE4MDIyNTE1MjA0MloXDTM4MDIyMDE1MjA0MlowajELMAkGA1UEBhMC\nVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJz\nMS0wKwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw\nggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDLEjXy7YrbN5Waau5cd6g1\nG5C2tMmeTpZ0duFAPxNU4oE3RHS5gGiok346fUXuUxbZ6QkuzeN2/2Z+RmRcJhQY\nDm0ZgdG4x59An1TJfnzKKoWj8ISmoHS/TGNBdFzXV7FYNLBuqZouqePI6ReC6Qhl\npp45huV32Q3a6IDrrvx7Wo5ZczEQeFNbCeCOQYNDdTmCyEkHqc2AGo8eoIlSTutT\nULOC7R5gzJVTS0e1hesQ7jmqHjbO+VQS1NAL4/5K6cuTEqUl+XhVhPdLWBXJQ5ag\n54qhX4v+ojLzeU1R/Vc6NjMvVtptWY6JihpgplprN0Yh2556ewcXMeturcKgXfGJ\nxeYzsjzXerEjrVocX5V8BNrg64NlifzTMKNOOv4fVZszq1SIHR8F9ROrqiOdh8iC\nJpUbLpXH9hWCSEO6VRMB2xJoKu3cgl63kF30s77x7wLFMEHiwsQRKxooE1UhgS9K\n2sO4TlQ1eWUvFvHSTVDQDlGQ6zu4qjbOpb3Q8bQwoK+ai2alkXVR4Ltxe9QlgYK3\nStsnPhruzZGA0wbXdpw0bnM+YdlEm5ffSTpNIfgHeaa7Dtb801FtA71ZlH7A6TaI\nSIQuUST9EKmv7xrJyx0W1pGoPOLw5T029aTjnICSLdtV9bLwysrLhIYG5bnPq78B\ncS+jZHFGzD7PUVGQD01nOQIDAQABo2MwYTAdBgNVHQ4EFgQUIuNsB+oTOC9rLoxL\nyzNP7vJUV08wHwYDVR0jBBgwFoAUIuNsB+oTOC9rLoxLyzNP7vJUV08wDwYDVR0T\nAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAHfg\nz5pMNUAKdMzK1aS1EDdK9yKz4qicILz5czSLj1mC7HKDRy8cVADUxEICis++CsCu\nrYOvyCVergHQLREcxPq4rc5Nq1uj6J6649NEeh4WazOOjL4ZfQ1jVznMbGy+fJm3\n3Hoelv6jWRG9iqeJZja7/1s6YC6bWymI/OY1e4wUKeNHAo+Vger7MlHV+RuabaX+\nhSJ8bJAM59NCM7AgMTQpJCncrcdLeceYniGy5Q/qt2b5mJkQVkIdy4TPGGB+AXDJ\nD0q3I/JDRkDUFNFdeW0js7fHdsvCR7O3tJy5zIgEV/o/BCkmJVtuwPYOrw/yOlKj\nTY/U7ATAx9VFF6/vYEOMYSmrZlFX+98L6nJtwDqfLB5VTltqZ4H/KBxGE3IRSt9l\nFXy40U+LnXzhhW+7VBAvyYX8GEXhHkKU8Gqk1xitrqfBXY74xKgyUSTolFSfFVgj\nmcM/X4K45bka+qpkj7Kfv/8D4j6aZekwhN2ly6hhC1SmQ8qjMjpG/mrWOSSHZFmf\nybu9iD2AYHeIOkshIl6xYIa++Q/00/vs46IzAbQyriOi0XxlSMMVtPx0Q3isp+ji\nn8Mq9eOuxYOEQ4of8twUkUDd528iwGtEdwf0Q01UyT84S62N8AySl1ZBKXJz6W4F\nUhWfa/HQYOAPDdEjNgnVwLI23b8t0TozyCWw7q8h\n-----END CERTIFICATE-----\n\n-----BEGIN CERTIFICATE-----\nMIIEjzCCA3egAwIBAgIQe55B/ALCKJDZtdNT8kD6hTANBgkqhkiG9w0BAQsFADBM\nMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xv\nYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjAeFw0yMjAxMjYxMjAwMDBaFw0y\nNTAxMjYwMDAwMDBaMFgxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWdu\nIG52LXNhMS4wLAYDVQQDEyVHbG9iYWxTaWduIEF0bGFzIFIzIE9WIFRMUyBDQSAy\nMDIyIFEyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmGmg1LW9b7Lf\n8zDD83yBDTEkt+FOxKJZqF4veWc5KZsQj9HfnUS2e5nj/E+JImlGPsQuoiosLuXD\nBVBNAMcUFa11buFMGMeEMwiTmCXoXRrXQmH0qjpOfKgYc5gHG3BsRGaRrf7VR4eg\nofNMG9wUBw4/g/TT7+bQJdA4NfE7Y4d5gEryZiBGB/swaX6Jp/8MF4TgUmOWmalK\ndZCKyb4sPGQFRTtElk67F7vU+wdGcrcOx1tDcIB0ncjLPMnaFicagl+daWGsKqTh\ncounQb6QJtYHa91KvCfKWocMxQ7OIbB5UARLPmC4CJ1/f8YFm35ebfzAeULYdGXu\njE9CLor0OwIDAQABo4IBXzCCAVswDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQG\nCCsGAQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQW\nBBSH5Zq7a7B/t95GfJWkDBpA8HHqdjAfBgNVHSMEGDAWgBSP8Et/qC5FJK5NUPpj\nmove4t0bvDB7BggrBgEFBQcBAQRvMG0wLgYIKwYBBQUHMAGGImh0dHA6Ly9vY3Nw\nMi5nbG9iYWxzaWduLmNvbS9yb290cjMwOwYIKwYBBQUHMAKGL2h0dHA6Ly9zZWN1\ncmUuZ2xvYmFsc2lnbi5jb20vY2FjZXJ0L3Jvb3QtcjMuY3J0MDYGA1UdHwQvMC0w\nK6ApoCeGJWh0dHA6Ly9jcmwuZ2xvYmFsc2lnbi5jb20vcm9vdC1yMy5jcmwwIQYD\nVR0gBBowGDAIBgZngQwBAgIwDAYKKwYBBAGgMgoBAjANBgkqhkiG9w0BAQsFAAOC\nAQEAKRic9/f+nmhQU/wz04APZLjgG5OgsuUOyUEZjKVhNGDwxGTvKhyXGGAMW2B/\n3bRi+aElpXwoxu3pL6fkElbX3B0BeS5LoDtxkyiVEBMZ8m+sXbocwlPyxrPbX6mY\n0rVIvnuUeBH8X0L5IwfpNVvKnBIilTbcebfHyXkPezGwz7E1yhUULjJFm2bt0SdX\ny+4X/WeiiYIv+fTVgZZgl+/2MKIsu/qdBJc3f3TvJ8nz+Eax1zgZmww+RSQWeOj3\n15Iw6Z5FX+NwzY/Ab+9PosR5UosSeq+9HhtaxZttXG1nVh+avYPGYddWmiMT90J5\nZgKnO/Fx2hBgTxhOTMYaD312kg==\n-----END CERTIFICATE-----\n\n-----BEGIN CERTIFICATE-----\nMIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G\nA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp\nZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4\nMTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG\nA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\nhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8\nRgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT\ngHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm\nKPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd\nQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ\nXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw\nDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o\nLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU\nRUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp\njjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK\n6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\nmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\nMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\nWD9f\n-----END CERTIFICATE-----`;const r={RedisCloudFixed:{ca:n},RedisCloudFlexible:{ca:n}};t["default"]=r},7591:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(8287);class ClusterAllFailedError extends r.RedisError{constructor(e,t){super(e);this.lastNodeError=t;Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}t["default"]=ClusterAllFailedError;ClusterAllFailedError.defaultMessage="Failed to refresh slots cache."},4655:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(8287);class MaxRetriesPerRequestError extends r.AbortError{constructor(e){const t=`Reached the max retries per request limit (which is ${e}). Refer to "maxRetriesPerRequest" option for details.`;super(t);Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}t["default"]=MaxRetriesPerRequestError},4613:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.MaxRetriesPerRequestError=void 0;const r=n(4655);t.MaxRetriesPerRequestError=r.default},8721:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.print=t.ReplyError=t.SentinelIterator=t.SentinelConnector=t.AbstractConnector=t.Pipeline=t.ScanStream=t.Command=t.Cluster=t.Redis=t["default"]=void 0;t=e.exports=n(3810)["default"];var r=n(3810);Object.defineProperty(t,"default",{enumerable:true,get:function(){return r.default}});var i=n(3810);Object.defineProperty(t,"Redis",{enumerable:true,get:function(){return i.default}});var a=n(8524);Object.defineProperty(t,"Cluster",{enumerable:true,get:function(){return a.default}});var s=n(7544);Object.defineProperty(t,"Command",{enumerable:true,get:function(){return s.default}});var o=n(2196);Object.defineProperty(t,"ScanStream",{enumerable:true,get:function(){return o.default}});var l=n(2499);Object.defineProperty(t,"Pipeline",{enumerable:true,get:function(){return l.default}});var c=n(5031);Object.defineProperty(t,"AbstractConnector",{enumerable:true,get:function(){return c.default}});var d=n(1082);Object.defineProperty(t,"SentinelConnector",{enumerable:true,get:function(){return d.default}});Object.defineProperty(t,"SentinelIterator",{enumerable:true,get:function(){return d.SentinelIterator}});t.ReplyError=n(8287).ReplyError;Object.defineProperty(t,"Promise",{get(){console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.");return Promise},set(e){console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.")}});function print(e,t){if(e){console.log("Error: "+e)}else{console.log("Reply: "+t)}}t.print=print},7746:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.DEFAULT_REDIS_OPTIONS=void 0;t.DEFAULT_REDIS_OPTIONS={port:6379,host:"localhost",family:4,connectTimeout:1e4,disconnectTimeout:2e3,retryStrategy:function(e){return Math.min(e*50,2e3)},keepAlive:0,noDelay:true,connectionName:null,sentinels:null,name:null,role:"master",sentinelRetryStrategy:function(e){return Math.min(e*10,1e3)},sentinelReconnectStrategy:function(){return 6e4},natMap:null,enableTLSForSentinelMode:false,updateSentinels:true,failoverDetector:false,username:null,password:null,db:0,enableOfflineQueue:true,enableReadyCheck:true,autoResubscribe:true,autoResendUnfulfilledCommands:true,lazyConnect:false,keyPrefix:"",reconnectOnError:null,readOnly:false,stringNumbers:false,maxRetriesPerRequest:20,maxLoadingRetryTime:1e4,enableAutoPipelining:false,autoPipeliningIgnoredCommands:[],sentinelMaxConnections:10}},430:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.readyHandler=t.errorHandler=t.closeHandler=t.connectHandler=void 0;const r=n(8287);const i=n(7544);const a=n(4613);const s=n(387);const o=n(4021);const l=(0,s.Debug)("connection");function connectHandler(e){return function(){e.setStatus("connect");e.resetCommandQueue();let n=false;const{connectionEpoch:r}=e;if(e.condition.auth){e.auth(e.condition.auth,(function(t){if(r!==e.connectionEpoch){return}if(t){if(t.message.indexOf("no password is set")!==-1){console.warn("[WARN] Redis server does not require a password, but a password was supplied.")}else if(t.message.indexOf("without any password configured for the default user")!==-1){console.warn("[WARN] This Redis server's `default` user does not require a password, but a password was supplied")}else if(t.message.indexOf("wrong number of arguments for 'auth' command")!==-1){console.warn(`[ERROR] The server returned "wrong number of arguments for 'auth' command". You are probably passing both username and password to Redis version 5 or below. You should only pass the 'password' option for Redis version 5 and under.`)}else{n=true;e.recoverFromFatalError(t,t)}}}))}if(e.condition.select){e.select(e.condition.select).catch((t=>{e.silentEmit("error",t)}))}if(!e.options.enableReadyCheck){t.readyHandler(e)()}new o.default(e,{stringNumbers:e.options.stringNumbers});if(e.options.enableReadyCheck){e._readyCheck((function(i,a){if(r!==e.connectionEpoch){return}if(i){if(!n){e.recoverFromFatalError(new Error("Ready check failed: "+i.message),i)}}else{if(e.connector.check(a)){t.readyHandler(e)()}else{e.disconnect(true)}}}))}}}t.connectHandler=connectHandler;function abortError(e){const t=new r.AbortError("Command aborted due to connection close");t.command={name:e.name,args:e.args};return t}function abortIncompletePipelines(e){var t;let n=0;for(let r=0;r<e.length;){const i=(t=e.peekAt(r))===null||t===void 0?void 0:t.command;const a=i.pipelineIndex;if(a===undefined||a===0){n=0}if(a!==undefined&&a!==n++){e.remove(r,1);i.reject(abortError(i));continue}r++}}function abortTransactionFragments(e){var t;for(let n=0;n<e.length;){const r=(t=e.peekAt(n))===null||t===void 0?void 0:t.command;if(r.name==="multi"){break}if(r.name==="exec"){e.remove(n,1);r.reject(abortError(r));break}if(r.inTransaction){e.remove(n,1);r.reject(abortError(r))}else{n++}}}function closeHandler(e){return function(){const t=e.status;e.setStatus("close");if(e.commandQueue.length){abortIncompletePipelines(e.commandQueue)}if(e.offlineQueue.length){abortTransactionFragments(e.offlineQueue)}if(t==="ready"){if(!e.prevCondition){e.prevCondition=e.condition}if(e.commandQueue.length){e.prevCommandQueue=e.commandQueue}}if(e.manuallyClosing){e.manuallyClosing=false;l("skip reconnecting since the connection is manually closed.");return close()}if(typeof e.options.retryStrategy!=="function"){l("skip reconnecting because `retryStrategy` is not a function");return close()}const n=e.options.retryStrategy(++e.retryAttempts);if(typeof n!=="number"){l("skip reconnecting because `retryStrategy` doesn't return a number");return close()}l("reconnect in %sms",n);e.setStatus("reconnecting",n);e.reconnectTimeout=setTimeout((function(){e.reconnectTimeout=null;e.connect().catch(s.noop)}),n);const{maxRetriesPerRequest:r}=e.options;if(typeof r==="number"){if(r<0){l("maxRetriesPerRequest is negative, ignoring...")}else{const t=e.retryAttempts%(r+1);if(t===0){l("reach maxRetriesPerRequest limitation, flushing command queue...");e.flushQueue(new a.MaxRetriesPerRequestError(r))}}}};function close(){e.setStatus("end");e.flushQueue(new Error(s.CONNECTION_CLOSED_ERROR_MSG))}}t.closeHandler=closeHandler;function errorHandler(e){return function(t){l("error: %s",t);e.silentEmit("error",t)}}t.errorHandler=errorHandler;function readyHandler(e){return function(){e.setStatus("ready");e.retryAttempts=0;if(e.options.monitor){e.call("monitor").then((()=>e.setStatus("monitoring")),(t=>e.emit("error",t)));const{sendCommand:t}=e;e.sendCommand=function(n){if(i.default.checkFlag("VALID_IN_MONITOR_MODE",n.name)){return t.call(e,n)}n.reject(new Error("Connection is in monitoring mode, can't process commands."));return n.promise};e.once("close",(function(){delete e.sendCommand}));return}const t=e.prevCondition?e.prevCondition.select:e.condition.select;if(e.options.connectionName){l("set the connection name [%s]",e.options.connectionName);e.client("setname",e.options.connectionName).catch(s.noop)}if(e.options.readOnly){l("set the connection to readonly mode");e.readonly().catch(s.noop)}if(e.prevCondition){const n=e.prevCondition;e.prevCondition=null;if(n.subscriber&&e.options.autoResubscribe){if(e.condition.select!==t){l("connect to db [%d]",t);e.select(t)}const r=n.subscriber.channels("subscribe");if(r.length){l("subscribe %d channels",r.length);e.subscribe(r)}const i=n.subscriber.channels("psubscribe");if(i.length){l("psubscribe %d channels",i.length);e.psubscribe(i)}const a=n.subscriber.channels("ssubscribe");if(a.length){l("ssubscribe %d channels",a.length);e.ssubscribe(a)}}}if(e.prevCommandQueue){if(e.options.autoResendUnfulfilledCommands){l("resend %d unfulfilled commands",e.prevCommandQueue.length);while(e.prevCommandQueue.length>0){const t=e.prevCommandQueue.shift();if(t.select!==e.condition.select&&t.command.name!=="select"){e.select(t.select)}e.sendCommand(t.command,t.stream)}}else{e.prevCommandQueue=null}}if(e.offlineQueue.length){l("send %d commands in offline queue",e.offlineQueue.length);const t=e.offlineQueue;e.resetOfflineQueue();while(t.length>0){const n=t.shift();if(n.select!==e.condition.select&&n.command.name!=="select"){e.select(n.select)}e.sendCommand(n.command,n.stream)}}if(e.condition.select!==t){l("connect to db [%d]",t);e.select(t)}}}t.readyHandler=readyHandler},7785:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addTransactionSupport=void 0;const r=n(387);const i=n(2460);const a=n(2499);function addTransactionSupport(e){e.pipeline=function(e){const t=new a.default(this);if(Array.isArray(e)){t.addBatch(e)}return t};const{multi:t}=e;e.multi=function(e,n){if(typeof n==="undefined"&&!Array.isArray(e)){n=e;e=null}if(n&&n.pipeline===false){return t.call(this)}const s=new a.default(this);s.multi();if(Array.isArray(e)){s.addBatch(e)}const o=s.exec;s.exec=function(e){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(r.noop);return(0,i.default)(new Promise(((e,t)=>{this.redis.delayUntilReady((n=>{if(n){t(n);return}this.exec(s).then(e,t)}))})),e)}if(this._transactions>0){o.call(s)}if(this.nodeifiedPromise){return o.call(s)}const t=o.call(s);return(0,i.default)(t.then((function(e){const t=e[e.length-1];if(typeof t==="undefined"){throw new Error("Pipeline cannot be used to send any commands when the `exec()` has been called on it.")}if(t[0]){t[0].previousErrors=[];for(let n=0;n<e.length-1;++n){if(e[n][0]){t[0].previousErrors.push(e[n][0])}}throw t[0]}return(0,r.wrapMultiResult)(t[1])})),e)};const{execBuffer:l}=s;s.execBuffer=function(e){if(this._transactions>0){l.call(s)}return s.exec(e)};return s};const{exec:n}=e;e.exec=function(e){return(0,i.default)(n.call(this).then((function(e){if(Array.isArray(e)){e=(0,r.wrapMultiResult)(e)}return e})),e)}}t.addTransactionSupport=addTransactionSupport},1325:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(4458);const i=n(419);const a=n(7544);const s=n(7818);class Commander{constructor(){this.options={};this.scriptsSet={};this.addedBuiltinSet=new Set}getBuiltinCommands(){return o.slice(0)}createBuiltinCommand(e){return{string:generateFunction(null,e,"utf8"),buffer:generateFunction(null,e,null)}}addBuiltinCommand(e){this.addedBuiltinSet.add(e);this[e]=generateFunction(e,e,"utf8");this[e+"Buffer"]=generateFunction(e+"Buffer",e,null)}defineCommand(e,t){const n=new s.default(t.lua,t.numberOfKeys,this.options.keyPrefix,t.readOnly);this.scriptsSet[e]=n;this[e]=generateScriptingFunction(e,e,n,"utf8");this[e+"Buffer"]=generateScriptingFunction(e+"Buffer",e,n,null)}sendCommand(e,t,n){throw new Error('"sendCommand" is not implemented')}}const o=r.list.filter((e=>e!=="monitor"));o.push("sentinel");o.forEach((function(e){Commander.prototype[e]=generateFunction(e,e,"utf8");Commander.prototype[e+"Buffer"]=generateFunction(e+"Buffer",e,null)}));Commander.prototype.call=generateFunction("call","utf8");Commander.prototype.callBuffer=generateFunction("callBuffer",null);Commander.prototype.send_command=Commander.prototype.call;function generateFunction(e,t,n){if(typeof n==="undefined"){n=t;t=null}return function(...r){const s=t||r.shift();let o=r[r.length-1];if(typeof o==="function"){r.pop()}else{o=undefined}const l={errorStack:this.options.showFriendlyErrorStack?new Error:undefined,keyPrefix:this.options.keyPrefix,replyEncoding:n};if(!(0,i.shouldUseAutoPipelining)(this,e,s)){return this.sendCommand(new a.default(s,r,l,o))}return(0,i.executeWithAutoPipelining)(this,e,s,r,o)}}function generateScriptingFunction(e,t,n,r){return function(...a){const s=typeof a[a.length-1]==="function"?a.pop():undefined;const o={replyEncoding:r};if(this.options.showFriendlyErrorStack){o.errorStack=new Error}if(!(0,i.shouldUseAutoPipelining)(this,e,t)){return n.execute(this,a,o,s)}return(0,i.executeWithAutoPipelining)(this,e,t,a,s)}}t["default"]=Commander},4190:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function applyMixin(e,t){Object.getOwnPropertyNames(t.prototype).forEach((n=>{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))}))}t["default"]=applyMixin},828:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.genRedactedString=t.getStringValue=t.MAX_ARGUMENT_LENGTH=void 0;const r=n(6449);const i=200;t.MAX_ARGUMENT_LENGTH=i;const a="ioredis";function getStringValue(e){if(e===null){return}switch(typeof e){case"boolean":return;case"number":return;case"object":if(Buffer.isBuffer(e)){return e.toString("hex")}if(Array.isArray(e)){return e.join(",")}try{return JSON.stringify(e)}catch(e){return}case"string":return e}}t.getStringValue=getStringValue;function genRedactedString(e,t){const{length:n}=e;return n<=t?e:e.slice(0,t)+' ... <REDACTED full-length="'+n+'">'}t.genRedactedString=genRedactedString;function genDebugFunction(e){const t=(0,r.default)(`${a}:${e}`);function wrappedDebug(...e){if(!t.enabled){return}for(let t=1;t<e.length;t++){const n=getStringValue(e[t]);if(typeof n==="string"&&n.length>i){e[t]=genRedactedString(n,i)}}return t.apply(null,e)}Object.defineProperties(wrappedDebug,{namespace:{get(){return t.namespace}},enabled:{get(){return t.enabled}},destroy:{get(){return t.destroy}},log:{get(){return t.log},set(e){t.log=e}}});return wrappedDebug}t["default"]=genDebugFunction},387:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.noop=t.defaults=t.Debug=t.zipMap=t.CONNECTION_CLOSED_ERROR_MSG=t.shuffle=t.sample=t.resolveTLSProfile=t.parseURL=t.optimizeErrorStack=t.toArg=t.convertMapToArray=t.convertObjectToArray=t.timeout=t.packObject=t.isInt=t.wrapMultiResult=t.convertBufferToString=void 0;const r=n(7016);const i=n(3146);Object.defineProperty(t,"defaults",{enumerable:true,get:function(){return i.defaults}});Object.defineProperty(t,"noop",{enumerable:true,get:function(){return i.noop}});const a=n(828);t.Debug=a.default;const s=n(5260);function convertBufferToString(e,t){if(e instanceof Buffer){return e.toString(t)}if(Array.isArray(e)){const n=e.length;const r=Array(n);for(let i=0;i<n;++i){r[i]=e[i]instanceof Buffer&&t==="utf8"?e[i].toString():convertBufferToString(e[i],t)}return r}return e}t.convertBufferToString=convertBufferToString;function wrapMultiResult(e){if(!e){return null}const t=[];const n=e.length;for(let r=0;r<n;++r){const n=e[r];if(n instanceof Error){t.push([n])}else{t.push([null,n])}}return t}t.wrapMultiResult=wrapMultiResult;function isInt(e){const t=parseFloat(e);return!isNaN(e)&&(t|0)===t}t.isInt=isInt;function packObject(e){const t={};const n=e.length;for(let r=1;r<n;r+=2){t[e[r-1]]=e[r]}return t}t.packObject=packObject;function timeout(e,t){let n=null;const run=function(){if(n){clearTimeout(n);n=null;e.apply(this,arguments)}};n=setTimeout(run,t,new Error("timeout"));return run}t.timeout=timeout;function convertObjectToArray(e){const t=[];const n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){t.push(n[r],e[n[r]])}return t}t.convertObjectToArray=convertObjectToArray;function convertMapToArray(e){const t=[];let n=0;e.forEach((function(e,r){t[n]=r;t[n+1]=e;n+=2}));return t}t.convertMapToArray=convertMapToArray;function toArg(e){if(e===null||typeof e==="undefined"){return""}return String(e)}t.toArg=toArg;function optimizeErrorStack(e,t,n){const r=t.split("\n");let i="";let a;for(a=1;a<r.length;++a){if(r[a].indexOf(n)===-1){break}}for(let e=a;e<r.length;++e){i+="\n"+r[e]}if(e.stack){const t=e.stack.indexOf("\n");e.stack=e.stack.slice(0,t)+i}return e}t.optimizeErrorStack=optimizeErrorStack;function parseURL(e){if(isInt(e)){return{port:e}}let t=(0,r.parse)(e,true,true);if(!t.slashes&&e[0]!=="/"){e="//"+e;t=(0,r.parse)(e,true,true)}const n=t.query||{};const a={};if(t.auth){const e=t.auth.indexOf(":");a.username=e===-1?t.auth:t.auth.slice(0,e);a.password=e===-1?"":t.auth.slice(e+1)}if(t.pathname){if(t.protocol==="redis:"||t.protocol==="rediss:"){if(t.pathname.length>1){a.db=t.pathname.slice(1)}}else{a.path=t.pathname}}if(t.host){a.host=t.hostname}if(t.port){a.port=t.port}if(typeof n.family==="string"){const e=Number.parseInt(n.family,10);if(!Number.isNaN(e)){a.family=e}}(0,i.defaults)(a,n);return a}t.parseURL=parseURL;function resolveTLSProfile(e){let t=e===null||e===void 0?void 0:e.tls;if(typeof t==="string")t={profile:t};const n=s.default[t===null||t===void 0?void 0:t.profile];if(n){t=Object.assign({},n,t);delete t.profile;e=Object.assign({},e,{tls:t})}return e}t.resolveTLSProfile=resolveTLSProfile;function sample(e,t=0){const n=e.length;if(t>=n){return null}return e[t+Math.floor(Math.random()*(n-t))]}t.sample=sample;function shuffle(e){let t=e.length;while(t>0){const n=Math.floor(Math.random()*t);t--;[e[t],e[n]]=[e[n],e[t]]}return e}t.shuffle=shuffle;t.CONNECTION_CLOSED_ERROR_MSG="Connection is closed.";function zipMap(e,t){const n=new Map;e.forEach(((e,r)=>{n.set(e,t[r])}));return n}t.zipMap=zipMap},3146:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.isArguments=t.defaults=t.noop=void 0;const r=n(4242);t.defaults=r;const i=n(8952);t.isArguments=i;function noop(){}t.noop=noop},4242:function(e){var t=9007199254740991;var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]";var a=/^(?:0|[1-9]\d*)$/;function apply(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function baseTimes(e,t){var n=-1,r=Array(e);while(++n<e){r[n]=t(n)}return r}var s=Object.prototype;var o=s.hasOwnProperty;var l=s.toString;var c=s.propertyIsEnumerable;var d=Math.max;function arrayLikeKeys(e,t){var n=u(e)||isArguments(e)?baseTimes(e.length,String):[];var r=n.length,i=!!r;for(var a in e){if((t||o.call(e,a))&&!(i&&(a=="length"||isIndex(a,r)))){n.push(a)}}return n}function assignInDefaults(e,t,n,r){if(e===undefined||eq(e,s[n])&&!o.call(r,n)){return t}return e}function assignValue(e,t,n){var r=e[t];if(!(o.call(e,t)&&eq(r,n))||n===undefined&&!(t in e)){e[t]=n}}function baseKeysIn(e){if(!isObject(e)){return nativeKeysIn(e)}var t=isPrototype(e),n=[];for(var r in e){if(!(r=="constructor"&&(t||!o.call(e,r)))){n.push(r)}}return n}function baseRest(e,t){t=d(t===undefined?e.length-1:t,0);return function(){var n=arguments,r=-1,i=d(n.length-t,0),a=Array(i);while(++r<i){a[r]=n[t+r]}r=-1;var s=Array(t+1);while(++r<t){s[r]=n[r]}s[t]=a;return apply(e,this,s)}}function copyObject(e,t,n,r){n||(n={});var i=-1,a=t.length;while(++i<a){var s=t[i];var o=r?r(n[s],e[s],s,n,e):undefined;assignValue(n,s,o===undefined?e[s]:o)}return n}function createAssigner(e){return baseRest((function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:undefined,s=i>2?n[2]:undefined;a=e.length>3&&typeof a=="function"?(i--,a):undefined;if(s&&isIterateeCall(n[0],n[1],s)){a=i<3?undefined:a;i=1}t=Object(t);while(++r<i){var o=n[r];if(o){e(t,o,r,a)}}return t}))}function isIndex(e,n){n=n==null?t:n;return!!n&&(typeof e=="number"||a.test(e))&&(e>-1&&e%1==0&&e<n)}function isIterateeCall(e,t,n){if(!isObject(n)){return false}var r=typeof t;if(r=="number"?isArrayLike(n)&&isIndex(t,n.length):r=="string"&&t in n){return eq(n[t],e)}return false}function isPrototype(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||s;return e===n}function nativeKeysIn(e){var t=[];if(e!=null){for(var n in Object(e)){t.push(n)}}return t}function eq(e,t){return e===t||e!==e&&t!==t}function isArguments(e){return isArrayLikeObject(e)&&o.call(e,"callee")&&(!c.call(e,"callee")||l.call(e)==n)}var u=Array.isArray;function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function isFunction(e){var t=isObject(e)?l.call(e):"";return t==r||t==i}function isLength(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=t}function isObject(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function isObjectLike(e){return!!e&&typeof e=="object"}var p=createAssigner((function(e,t,n,r){copyObject(t,keysIn(t),e,r)}));var f=baseRest((function(e){e.push(undefined,assignInDefaults);return apply(p,undefined,e)}));function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,true):baseKeysIn(e)}e.exports=f},8952:function(e){var t=9007199254740991;var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]";var a=Object.prototype;var s=a.hasOwnProperty;var o=a.toString;var l=a.propertyIsEnumerable;function isArguments(e){return isArrayLikeObject(e)&&s.call(e,"callee")&&(!l.call(e,"callee")||o.call(e)==n)}function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function isFunction(e){var t=isObject(e)?o.call(e):"";return t==r||t==i}function isLength(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=t}function isObject(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function isObjectLike(e){return!!e&&typeof e=="object"}e.exports=isArguments},8588:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});class LuxonError extends Error{}class InvalidDateTimeError extends LuxonError{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class InvalidIntervalError extends LuxonError{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class InvalidDurationError extends LuxonError{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class ConflictingSpecificationError extends LuxonError{}class InvalidUnitError extends LuxonError{constructor(e){super(`Invalid unit ${e}`)}}class InvalidArgumentError extends LuxonError{}class ZoneIsAbstractError extends LuxonError{constructor(){super("Zone is an abstract class")}}const n="numeric",r="short",i="long";const a={year:n,month:n,day:n};const s={year:n,month:r,day:n};const o={year:n,month:r,day:n,weekday:r};const l={year:n,month:i,day:n};const c={year:n,month:i,day:n,weekday:i};const d={hour:n,minute:n};const u={hour:n,minute:n,second:n};const p={hour:n,minute:n,second:n,timeZoneName:r};const f={hour:n,minute:n,second:n,timeZoneName:i};const h={hour:n,minute:n,hourCycle:"h23"};const y={hour:n,minute:n,second:n,hourCycle:"h23"};const m={hour:n,minute:n,second:n,hourCycle:"h23",timeZoneName:r};const b={hour:n,minute:n,second:n,hourCycle:"h23",timeZoneName:i};const g={year:n,month:n,day:n,hour:n,minute:n};const v={year:n,month:n,day:n,hour:n,minute:n,second:n};const K={year:n,month:r,day:n,hour:n,minute:n};const S={year:n,month:r,day:n,hour:n,minute:n,second:n};const E={year:n,month:r,day:n,weekday:r,hour:n,minute:n};const k={year:n,month:i,day:n,hour:n,minute:n,timeZoneName:r};const I={year:n,month:i,day:n,hour:n,minute:n,second:n,timeZoneName:r};const w={year:n,month:i,day:n,weekday:i,hour:n,minute:n,timeZoneName:i};const j={year:n,month:i,day:n,weekday:i,hour:n,minute:n,second:n,timeZoneName:i};class Zone{get type(){throw new ZoneIsAbstractError}get name(){throw new ZoneIsAbstractError}get ianaName(){return this.name}get isUniversal(){throw new ZoneIsAbstractError}offsetName(e,t){throw new ZoneIsAbstractError}formatOffset(e,t){throw new ZoneIsAbstractError}offset(e){throw new ZoneIsAbstractError}equals(e){throw new ZoneIsAbstractError}get isValid(){throw new ZoneIsAbstractError}}let x=null;class SystemZone extends Zone{static get instance(){if(x===null){x=new SystemZone}return x}get type(){return"system"}get name(){return(new Intl.DateTimeFormat).resolvedOptions().timeZone}get isUniversal(){return false}offsetName(e,{format:t,locale:n}){return parseZoneInfo(e,t,n)}formatOffset(e,t){return formatOffset(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return true}}let T={};function makeDTF(e){if(!T[e]){T[e]=new Intl.DateTimeFormat("en-US",{hour12:false,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"})}return T[e]}const D={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function hackyOffset(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,i,a,s,o,l,c,d]=r;return[s,i,a,o,l,c,d]}function partsOffset(e,t){const n=e.formatToParts(t);const r=[];for(let e=0;e<n.length;e++){const{type:t,value:i}=n[e];const a=D[t];if(t==="era"){r[a]=i}else if(!isUndefined(a)){r[a]=parseInt(i,10)}}return r}let O={};class IANAZone extends Zone{static create(e){if(!O[e]){O[e]=new IANAZone(e)}return O[e]}static resetCache(){O={};T={}}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e){return false}try{new Intl.DateTimeFormat("en-US",{timeZone:e}).format();return true}catch(e){return false}}constructor(e){super();this.zoneName=e;this.valid=IANAZone.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return false}offsetName(e,{format:t,locale:n}){return parseZoneInfo(e,t,n,this.name)}formatOffset(e,t){return formatOffset(this.offset(e),t)}offset(e){const t=new Date(e);if(isNaN(t))return NaN;const n=makeDTF(this.name);let[r,i,a,s,o,l,c]=n.formatToParts?partsOffset(n,t):hackyOffset(n,t);if(s==="BC"){r=-Math.abs(r)+1}const d=o===24?0:o;const u=objToLocalTS({year:r,month:i,day:a,hour:d,minute:l,second:c,millisecond:0});let p=+t;const f=p%1e3;p-=f>=0?f:1e3+f;return(u-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let C={};function getCachedLF(e,t={}){const n=JSON.stringify([e,t]);let r=C[n];if(!r){r=new Intl.ListFormat(e,t);C[n]=r}return r}let A={};function getCachedDTF(e,t={}){const n=JSON.stringify([e,t]);let r=A[n];if(!r){r=new Intl.DateTimeFormat(e,t);A[n]=r}return r}let R={};function getCachedINF(e,t={}){const n=JSON.stringify([e,t]);let r=R[n];if(!r){r=new Intl.NumberFormat(e,t);R[n]=r}return r}let P={};function getCachedRTF(e,t={}){const{base:n,...r}=t;const i=JSON.stringify([e,r]);let a=P[i];if(!a){a=new Intl.RelativeTimeFormat(e,t);P[i]=a}return a}let M=null;function systemLocale(){if(M){return M}else{M=(new Intl.DateTimeFormat).resolvedOptions().locale;return M}}let _={};function getCachedWeekInfo(e){let t=_[e];if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo;_[e]=t}return t}function parseLocaleString(e){const t=e.indexOf("-x-");if(t!==-1){e=e.substring(0,t)}const n=e.indexOf("-u-");if(n===-1){return[e]}else{let t;let r;try{t=getCachedDTF(e).resolvedOptions();r=e}catch(i){const a=e.substring(0,n);t=getCachedDTF(a).resolvedOptions();r=a}const{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function intlConfigString(e,t,n){if(n||t){if(!e.includes("-u-")){e+="-u"}if(n){e+=`-ca-${n}`}if(t){e+=`-nu-${t}`}return e}else{return e}}function mapMonths(e){const t=[];for(let n=1;n<=12;n++){const r=DateTime.utc(2009,n,1);t.push(e(r))}return t}function mapWeekdays(e){const t=[];for(let n=1;n<=7;n++){const r=DateTime.utc(2016,11,13+n);t.push(e(r))}return t}function listStuff(e,t,n,r){const i=e.listingMode();if(i==="error"){return null}else if(i==="en"){return n(t)}else{return r(t)}}function supportsFastNumbers(e){if(e.numberingSystem&&e.numberingSystem!=="latn"){return false}else{return e.numberingSystem==="latn"||!e.locale||e.locale.startsWith("en")||new Intl.DateTimeFormat(e.intl).resolvedOptions().numberingSystem==="latn"}}class PolyNumberFormatter{constructor(e,t,n){this.padTo=n.padTo||0;this.floor=n.floor||false;const{padTo:r,floor:i,...a}=n;if(!t||Object.keys(a).length>0){const t={useGrouping:false,...n};if(n.padTo>0)t.minimumIntegerDigits=n.padTo;this.inf=getCachedINF(e,t)}}format(e){if(this.inf){const t=this.floor?Math.floor(e):e;return this.inf.format(t)}else{const t=this.floor?Math.floor(e):roundTo(e,3);return padStart(t,this.padTo)}}}class PolyDateFormatter{constructor(e,t,n){this.opts=n;this.originalZone=undefined;let r=undefined;if(this.opts.timeZone){this.dt=e}else if(e.zone.type==="fixed"){const t=-1*(e.offset/60);const n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;if(e.offset!==0&&IANAZone.create(n).valid){r=n;this.dt=e}else{r="UTC";this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset});this.originalZone=e.zone}}else if(e.zone.type==="system"){this.dt=e}else if(e.zone.type==="iana"){this.dt=e;r=e.zone.name}else{r="UTC";this.dt=e.setZone("UTC").plus({minutes:e.offset});this.originalZone=e.zone}const i={...this.opts};i.timeZone=i.timeZone||r;this.dtf=getCachedDTF(t,i)}format(){if(this.originalZone){return this.formatToParts().map((({value:e})=>e)).join("")}return this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());if(this.originalZone){return e.map((e=>{if(e.type==="timeZoneName"){const t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}else{return e}}))}return e}resolvedOptions(){return this.dtf.resolvedOptions()}}class PolyRelFormatter{constructor(e,t,n){this.opts={style:"long",...n};if(!t&&hasRelative()){this.rtf=getCachedRTF(e,n)}}format(e,t){if(this.rtf){return this.rtf.format(e,t)}else{return formatRelativeTime(t,e,this.opts.numeric,this.opts.style!=="long")}}formatToParts(e,t){if(this.rtf){return this.rtf.formatToParts(e,t)}else{return[]}}}const N={firstDay:1,minimalDays:4,weekend:[6,7]};class Locale{static fromOpts(e){return Locale.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,t,n,r,i=false){const a=e||Settings.defaultLocale;const s=a||(i?"en-US":systemLocale());const o=t||Settings.defaultNumberingSystem;const l=n||Settings.defaultOutputCalendar;const c=validateWeekSettings(r)||Settings.defaultWeekSettings;return new Locale(s,o,l,c,a)}static resetCache(){M=null;A={};R={};P={}}static fromObject({locale:e,numberingSystem:t,outputCalendar:n,weekSettings:r}={}){return Locale.create(e,t,n,r)}constructor(e,t,n,r,i){const[a,s,o]=parseLocaleString(e);this.locale=a;this.numberingSystem=t||s||null;this.outputCalendar=n||o||null;this.weekSettings=r;this.intl=intlConfigString(this.locale,this.numberingSystem,this.outputCalendar);this.weekdaysCache={format:{},standalone:{}};this.monthsCache={format:{},standalone:{}};this.meridiemCache=null;this.eraCache={};this.specifiedLocale=i;this.fastNumbersCached=null}get fastNumbers(){if(this.fastNumbersCached==null){this.fastNumbersCached=supportsFastNumbers(this)}return this.fastNumbersCached}listingMode(){const e=this.isEnglish();const t=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&t?"en":"intl"}clone(e){if(!e||Object.getOwnPropertyNames(e).length===0){return this}else{return Locale.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,validateWeekSettings(e.weekSettings)||this.weekSettings,e.defaultToEN||false)}}redefaultToEN(e={}){return this.clone({...e,defaultToEN:true})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:false})}months(e,t=false){return listStuff(this,e,months,(()=>{const n=t?{month:e,day:"numeric"}:{month:e},r=t?"format":"standalone";if(!this.monthsCache[r][e]){this.monthsCache[r][e]=mapMonths((e=>this.extract(e,n,"month")))}return this.monthsCache[r][e]}))}weekdays(e,t=false){return listStuff(this,e,weekdays,(()=>{const n=t?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=t?"format":"standalone";if(!this.weekdaysCache[r][e]){this.weekdaysCache[r][e]=mapWeekdays((e=>this.extract(e,n,"weekday")))}return this.weekdaysCache[r][e]}))}meridiems(){return listStuff(this,undefined,(()=>ie),(()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[DateTime.utc(2016,11,13,9),DateTime.utc(2016,11,13,19)].map((t=>this.extract(t,e,"dayperiod")))}return this.meridiemCache}))}eras(e){return listStuff(this,e,eras,(()=>{const t={era:e};if(!this.eraCache[e]){this.eraCache[e]=[DateTime.utc(-40,1,1),DateTime.utc(2017,1,1)].map((e=>this.extract(e,t,"era")))}return this.eraCache[e]}))}extract(e,t,n){const r=this.dtFormatter(e,t),i=r.formatToParts(),a=i.find((e=>e.type.toLowerCase()===n));return a?a.value:null}numberFormatter(e={}){return new PolyNumberFormatter(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new PolyDateFormatter(e,this.intl,t)}relFormatter(e={}){return new PolyRelFormatter(this.intl,this.isEnglish(),e)}listFormatter(e={}){return getCachedLF(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us")}getWeekSettings(){if(this.weekSettings){return this.weekSettings}else if(!hasLocaleWeekInfo()){return N}else{return getCachedWeekInfo(this.locale)}}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let L=null;class FixedOffsetZone extends Zone{static get utcInstance(){if(L===null){L=new FixedOffsetZone(0)}return L}static instance(e){return e===0?FixedOffsetZone.utcInstance:new FixedOffsetZone(e)}static parseSpecifier(e){if(e){const t=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(t){return new FixedOffsetZone(signedOffset(t[1],t[2]))}}return null}constructor(e){super();this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${formatOffset(this.fixed,"narrow")}`}get ianaName(){if(this.fixed===0){return"Etc/UTC"}else{return`Etc/GMT${formatOffset(-this.fixed,"narrow")}`}}offsetName(){return this.name}formatOffset(e,t){return formatOffset(this.fixed,t)}get isUniversal(){return true}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return true}}class InvalidZone extends Zone{constructor(e){super();this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return false}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return false}get isValid(){return false}}function normalizeZone(e,t){if(isUndefined(e)||e===null){return t}else if(e instanceof Zone){return e}else if(isString(e)){const n=e.toLowerCase();if(n==="default")return t;else if(n==="local"||n==="system")return SystemZone.instance;else if(n==="utc"||n==="gmt")return FixedOffsetZone.utcInstance;else return FixedOffsetZone.parseSpecifier(n)||IANAZone.create(e)}else if(isNumber(e)){return FixedOffsetZone.instance(e)}else if(typeof e==="object"&&"offset"in e&&typeof e.offset==="function"){return e}else{return new InvalidZone(e)}}const J={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"};const F={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]};const V=J.hanidec.replace(/[\[|\]]/g,"").split("");function parseDigits(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(e[n].search(J.hanidec)!==-1){t+=V.indexOf(e[n])}else{for(const e in F){const[n,i]=F[e];if(r>=n&&r<=i){t+=r-n}}}}return parseInt(t,10)}else{return t}}let q={};function resetDigitRegexCache(){q={}}function digitRegex({numberingSystem:e},t=""){const n=e||"latn";if(!q[n]){q[n]={}}if(!q[n][t]){q[n][t]=new RegExp(`${J[n]}${t}`)}return q[n][t]}let now=()=>Date.now(),G="system",Y=null,B=null,U=null,W=60,z,Q=null;class Settings{static get now(){return now}static set now(e){now=e}static set defaultZone(e){G=e}static get defaultZone(){return normalizeZone(G,SystemZone.instance)}static get defaultLocale(){return Y}static set defaultLocale(e){Y=e}static get defaultNumberingSystem(){return B}static set defaultNumberingSystem(e){B=e}static get defaultOutputCalendar(){return U}static set defaultOutputCalendar(e){U=e}static get defaultWeekSettings(){return Q}static set defaultWeekSettings(e){Q=validateWeekSettings(e)}static get twoDigitCutoffYear(){return W}static set twoDigitCutoffYear(e){W=e%100}static get throwOnInvalid(){return z}static set throwOnInvalid(e){z=e}static resetCaches(){Locale.resetCache();IANAZone.resetCache();DateTime.resetCache();resetDigitRegexCache()}}class Invalid{constructor(e,t){this.reason=e;this.explanation=t}toMessage(){if(this.explanation){return`${this.reason}: ${this.explanation}`}else{return this.reason}}}const Z=[0,31,59,90,120,151,181,212,243,273,304,334],$=[0,31,60,91,121,152,182,213,244,274,305,335];function unitOutOfRange(e,t){return new Invalid("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function dayOfWeek(e,t,n){const r=new Date(Date.UTC(e,t-1,n));if(e<100&&e>=0){r.setUTCFullYear(r.getUTCFullYear()-1900)}const i=r.getUTCDay();return i===0?7:i}function computeOrdinal(e,t,n){return n+(isLeapYear(e)?$:Z)[t-1]}function uncomputeOrdinal(e,t){const n=isLeapYear(e)?$:Z,r=n.findIndex((e=>e<t)),i=t-n[r];return{month:r+1,day:i}}function isoWeekdayToLocal(e,t){return(e-t+7)%7+1}function gregorianToWeek(e,t=4,n=1){const{year:r,month:i,day:a}=e,s=computeOrdinal(r,i,a),o=isoWeekdayToLocal(dayOfWeek(r,i,a),n);let l=Math.floor((s-o+14-t)/7),c;if(l<1){c=r-1;l=weeksInWeekYear(c,t,n)}else if(l>weeksInWeekYear(r,t,n)){c=r+1;l=1}else{c=r}return{weekYear:c,weekNumber:l,weekday:o,...timeObject(e)}}function weekToGregorian(e,t=4,n=1){const{weekYear:r,weekNumber:i,weekday:a}=e,s=isoWeekdayToLocal(dayOfWeek(r,1,t),n),o=daysInYear(r);let l=i*7+a-s-7+t,c;if(l<1){c=r-1;l+=daysInYear(c)}else if(l>o){c=r+1;l-=daysInYear(r)}else{c=r}const{month:d,day:u}=uncomputeOrdinal(c,l);return{year:c,month:d,day:u,...timeObject(e)}}function gregorianToOrdinal(e){const{year:t,month:n,day:r}=e;const i=computeOrdinal(t,n,r);return{year:t,ordinal:i,...timeObject(e)}}function ordinalToGregorian(e){const{year:t,ordinal:n}=e;const{month:r,day:i}=uncomputeOrdinal(t,n);return{year:t,month:r,day:i,...timeObject(e)}}function usesLocalWeekValues(e,t){const n=!isUndefined(e.localWeekday)||!isUndefined(e.localWeekNumber)||!isUndefined(e.localWeekYear);if(n){const n=!isUndefined(e.weekday)||!isUndefined(e.weekNumber)||!isUndefined(e.weekYear);if(n){throw new ConflictingSpecificationError("Cannot mix locale-based week fields with ISO-based week fields")}if(!isUndefined(e.localWeekday))e.weekday=e.localWeekday;if(!isUndefined(e.localWeekNumber))e.weekNumber=e.localWeekNumber;if(!isUndefined(e.localWeekYear))e.weekYear=e.localWeekYear;delete e.localWeekday;delete e.localWeekNumber;delete e.localWeekYear;return{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else{return{minDaysInFirstWeek:4,startOfWeek:1}}}function hasInvalidWeekData(e,t=4,n=1){const r=isInteger(e.weekYear),i=integerBetween(e.weekNumber,1,weeksInWeekYear(e.weekYear,t,n)),a=integerBetween(e.weekday,1,7);if(!r){return unitOutOfRange("weekYear",e.weekYear)}else if(!i){return unitOutOfRange("week",e.weekNumber)}else if(!a){return unitOutOfRange("weekday",e.weekday)}else return false}function hasInvalidOrdinalData(e){const t=isInteger(e.year),n=integerBetween(e.ordinal,1,daysInYear(e.year));if(!t){return unitOutOfRange("year",e.year)}else if(!n){return unitOutOfRange("ordinal",e.ordinal)}else return false}function hasInvalidGregorianData(e){const t=isInteger(e.year),n=integerBetween(e.month,1,12),r=integerBetween(e.day,1,daysInMonth(e.year,e.month));if(!t){return unitOutOfRange("year",e.year)}else if(!n){return unitOutOfRange("month",e.month)}else if(!r){return unitOutOfRange("day",e.day)}else return false}function hasInvalidTimeData(e){const{hour:t,minute:n,second:r,millisecond:i}=e;const a=integerBetween(t,0,23)||t===24&&n===0&&r===0&&i===0,s=integerBetween(n,0,59),o=integerBetween(r,0,59),l=integerBetween(i,0,999);if(!a){return unitOutOfRange("hour",t)}else if(!s){return unitOutOfRange("minute",n)}else if(!o){return unitOutOfRange("second",r)}else if(!l){return unitOutOfRange("millisecond",i)}else return false}function isUndefined(e){return typeof e==="undefined"}function isNumber(e){return typeof e==="number"}function isInteger(e){return typeof e==="number"&&e%1===0}function isString(e){return typeof e==="string"}function isDate(e){return Object.prototype.toString.call(e)==="[object Date]"}function hasRelative(){try{return typeof Intl!=="undefined"&&!!Intl.RelativeTimeFormat}catch(e){return false}}function hasLocaleWeekInfo(){try{return typeof Intl!=="undefined"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch(e){return false}}function maybeArray(e){return Array.isArray(e)?e:[e]}function bestBy(e,t,n){if(e.length===0){return undefined}return e.reduce(((e,r)=>{const i=[t(r),r];if(!e){return i}else if(n(e[0],i[0])===e[0]){return e}else{return i}}),null)[1]}function pick(e,t){return t.reduce(((t,n)=>{t[n]=e[n];return t}),{})}function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function validateWeekSettings(e){if(e==null){return null}else if(typeof e!=="object"){throw new InvalidArgumentError("Week settings must be an object")}else{if(!integerBetween(e.firstDay,1,7)||!integerBetween(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some((e=>!integerBetween(e,1,7)))){throw new InvalidArgumentError("Invalid week settings")}return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}}function integerBetween(e,t,n){return isInteger(e)&&e>=t&&e<=n}function floorMod(e,t){return e-t*Math.floor(e/t)}function padStart(e,t=2){const n=e<0;let r;if(n){r="-"+(""+-e).padStart(t,"0")}else{r=(""+e).padStart(t,"0")}return r}function parseInteger(e){if(isUndefined(e)||e===null||e===""){return undefined}else{return parseInt(e,10)}}function parseFloating(e){if(isUndefined(e)||e===null||e===""){return undefined}else{return parseFloat(e)}}function parseMillis(e){if(isUndefined(e)||e===null||e===""){return undefined}else{const t=parseFloat("0."+e)*1e3;return Math.floor(t)}}function roundTo(e,t,n=false){const r=10**t,i=n?Math.trunc:Math.round;return i(e*r)/r}function isLeapYear(e){return e%4===0&&(e%100!==0||e%400===0)}function daysInYear(e){return isLeapYear(e)?366:365}function daysInMonth(e,t){const n=floorMod(t-1,12)+1,r=e+(t-n)/12;if(n===2){return isLeapYear(r)?29:28}else{return[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}}function objToLocalTS(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);if(e.year<100&&e.year>=0){t=new Date(t);t.setUTCFullYear(e.year,e.month-1,e.day)}return+t}function firstWeekOffset(e,t,n){const r=isoWeekdayToLocal(dayOfWeek(e,1,t),n);return-r+t-1}function weeksInWeekYear(e,t=4,n=1){const r=firstWeekOffset(e,t,n);const i=firstWeekOffset(e+1,t,n);return(daysInYear(e)-r+i)/7}function untruncateYear(e){if(e>99){return e}else return e>Settings.twoDigitCutoffYear?1900+e:2e3+e}function parseZoneInfo(e,t,n,r=null){const i=new Date(e),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};if(r){a.timeZone=r}const s={timeZoneName:t,...a};const o=new Intl.DateTimeFormat(n,s).formatToParts(i).find((e=>e.type.toLowerCase()==="timezonename"));return o?o.value:null}function signedOffset(e,t){let n=parseInt(e,10);if(Number.isNaN(n)){n=0}const r=parseInt(t,10)||0,i=n<0||Object.is(n,-0)?-r:r;return n*60+i}function asNumber(e){const t=Number(e);if(typeof e==="boolean"||e===""||Number.isNaN(t))throw new InvalidArgumentError(`Invalid unit value ${e}`);return t}function normalizeObject(e,t){const n={};for(const r in e){if(hasOwnProperty(e,r)){const i=e[r];if(i===undefined||i===null)continue;n[t(r)]=asNumber(i)}}return n}function formatOffset(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?"+":"-";switch(t){case"short":return`${i}${padStart(n,2)}:${padStart(r,2)}`;case"narrow":return`${i}${n}${r>0?`:${r}`:""}`;case"techie":return`${i}${padStart(n,2)}${padStart(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function timeObject(e){return pick(e,["hour","minute","second","millisecond"])}const H=["January","February","March","April","May","June","July","August","September","October","November","December"];const X=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];const ee=["J","F","M","A","M","J","J","A","S","O","N","D"];function months(e){switch(e){case"narrow":return[...ee];case"short":return[...X];case"long":return[...H];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const te=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];const ne=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];const re=["M","T","W","T","F","S","S"];function weekdays(e){switch(e){case"narrow":return[...re];case"short":return[...ne];case"long":return[...te];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const ie=["AM","PM"];const ae=["Before Christ","Anno Domini"];const se=["BC","AD"];const oe=["B","A"];function eras(e){switch(e){case"narrow":return[...oe];case"short":return[...se];case"long":return[...ae];default:return null}}function meridiemForDateTime(e){return ie[e.hour<12?0:1]}function weekdayForDateTime(e,t){return weekdays(t)[e.weekday-1]}function monthForDateTime(e,t){return months(t)[e.month-1]}function eraForDateTime(e,t){return eras(t)[e.year<0?0:1]}function formatRelativeTime(e,t,n="always",r=false){const i={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]};const a=["hours","minutes","seconds"].indexOf(e)===-1;if(n==="auto"&&a){const n=e==="days";switch(t){case 1:return n?"tomorrow":`next ${i[e][0]}`;case-1:return n?"yesterday":`last ${i[e][0]}`;case 0:return n?"today":`this ${i[e][0]}`}}const s=Object.is(t,-0)||t<0,o=Math.abs(t),l=o===1,c=i[e],d=r?l?c[1]:c[2]||c[1]:l?i[e][0]:e;return s?`${o} ${d} ago`:`in ${o} ${d}`}function stringifyTokens(e,t){let n="";for(const r of e){if(r.literal){n+=r.val}else{n+=t(r.val)}}return n}const le={D:a,DD:s,DDD:l,DDDD:c,t:d,tt:u,ttt:p,tttt:f,T:h,TT:y,TTT:m,TTTT:b,f:g,ff:K,fff:k,ffff:w,F:v,FF:S,FFF:I,FFFF:j};class Formatter{static create(e,t={}){return new Formatter(e,t)}static parseFormat(e){let t=null,n="",r=false;const i=[];for(let a=0;a<e.length;a++){const s=e.charAt(a);if(s==="'"){if(n.length>0){i.push({literal:r||/^\s+$/.test(n),val:n})}t=null;n="";r=!r}else if(r){n+=s}else if(s===t){n+=s}else{if(n.length>0){i.push({literal:/^\s+$/.test(n),val:n})}n=s;t=s}}if(n.length>0){i.push({literal:r||/^\s+$/.test(n),val:n})}return i}static macroTokenToFormatOpts(e){return le[e]}constructor(e,t){this.opts=t;this.loc=e;this.systemLoc=null}formatWithSystemDefault(e,t){if(this.systemLoc===null){this.systemLoc=this.loc.redefaultToSystem()}const n=this.systemLoc.dtFormatter(e,{...this.opts,...t});return n.format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){const n=this.dtFormatter(e.start,t);return n.dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0){if(this.opts.forceSimple){return padStart(e,t)}const n={...this.opts};if(t>0){n.padTo=t}return this.loc.numberFormatter(n).format(e)}formatDateTimeFromString(e,t){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",string=(t,n)=>this.loc.extract(e,t,n),formatOffset=t=>{if(e.isOffsetFixed&&e.offset===0&&t.allowZ){return"Z"}return e.isValid?e.zone.formatOffset(e.ts,t.format):""},meridiem=()=>n?meridiemForDateTime(e):string({hour:"numeric",hourCycle:"h12"},"dayperiod"),month=(t,r)=>n?monthForDateTime(e,t):string(r?{month:t}:{month:t,day:"numeric"},"month"),weekday=(t,r)=>n?weekdayForDateTime(e,t):string(r?{weekday:t}:{weekday:t,month:"long",day:"numeric"},"weekday"),maybeMacro=t=>{const n=Formatter.macroTokenToFormatOpts(t);if(n){return this.formatWithSystemDefault(e,n)}else{return t}},era=t=>n?eraForDateTime(e,t):string({era:t},"era"),tokenToString=t=>{switch(t){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return formatOffset({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return formatOffset({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return formatOffset({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return meridiem();case"d":return r?string({day:"numeric"},"day"):this.num(e.day);case"dd":return r?string({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return weekday("short",true);case"cccc":return weekday("long",true);case"ccccc":return weekday("narrow",true);case"E":return this.num(e.weekday);case"EEE":return weekday("short",false);case"EEEE":return weekday("long",false);case"EEEEE":return weekday("narrow",false);case"L":return r?string({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?string({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return month("short",true);case"LLLL":return month("long",true);case"LLLLL":return month("narrow",true);case"M":return r?string({month:"numeric"},"month"):this.num(e.month);case"MM":return r?string({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return month("short",false);case"MMMM":return month("long",false);case"MMMMM":return month("narrow",false);case"y":return r?string({year:"numeric"},"year"):this.num(e.year);case"yy":return r?string({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?string({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?string({year:"numeric"},"year"):this.num(e.year,6);case"G":return era("short");case"GG":return era("long");case"GGGGG":return era("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return maybeMacro(t)}};return stringifyTokens(Formatter.parseFormat(t),tokenToString)}formatDurationFromString(e,t){const tokenToField=e=>{switch(e[0]){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":return"hour";case"d":return"day";case"w":return"week";case"M":return"month";case"y":return"year";default:return null}},tokenToString=e=>t=>{const n=tokenToField(t);if(n){return this.num(e.get(n),t.length)}else{return t}},n=Formatter.parseFormat(t),r=n.reduce(((e,{literal:t,val:n})=>t?e:e.concat(n)),[]),i=e.shiftTo(...r.map(tokenToField).filter((e=>e)));return stringifyTokens(n,tokenToString(i))}}const ce=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function combineRegexes(...e){const t=e.reduce(((e,t)=>e+t.source),"");return RegExp(`^${t}$`)}function combineExtractors(...e){return t=>e.reduce((([e,n,r],i)=>{const[a,s,o]=i(t,r);return[{...e,...a},s||n,o]}),[{},null,1]).slice(0,2)}function parse(e,...t){if(e==null){return[null,null]}for(const[n,r]of t){const t=n.exec(e);if(t){return r(t)}}return[null,null]}function simpleParse(...e){return(t,n)=>{const r={};let i;for(i=0;i<e.length;i++){r[e[i]]=parseInteger(t[n+i])}return[r,null,n+i]}}const de=/(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/;const ue=`(?:${de.source}?(?:\\[(${ce.source})\\])?)?`;const pe=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/;const fe=RegExp(`${pe.source}${ue}`);const he=RegExp(`(?:T${fe.source})?`);const ye=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/;const me=/(\d{4})-?W(\d\d)(?:-?(\d))?/;const be=/(\d{4})-?(\d{3})/;const ge=simpleParse("weekYear","weekNumber","weekDay");const ve=simpleParse("year","ordinal");const Ke=/(\d{4})-(\d\d)-(\d\d)/;const Se=RegExp(`${pe.source} ?(?:${de.source}|(${ce.source}))?`);const Ee=RegExp(`(?: ${Se.source})?`);function int(e,t,n){const r=e[t];return isUndefined(r)?n:parseInteger(r)}function extractISOYmd(e,t){const n={year:int(e,t),month:int(e,t+1,1),day:int(e,t+2,1)};return[n,null,t+3]}function extractISOTime(e,t){const n={hours:int(e,t,0),minutes:int(e,t+1,0),seconds:int(e,t+2,0),milliseconds:parseMillis(e[t+3])};return[n,null,t+4]}function extractISOOffset(e,t){const n=!e[t]&&!e[t+1],r=signedOffset(e[t+1],e[t+2]),i=n?null:FixedOffsetZone.instance(r);return[{},i,t+3]}function extractIANAZone(e,t){const n=e[t]?IANAZone.create(e[t]):null;return[{},n,t+1]}const ke=RegExp(`^T?${pe.source}$`);const Ie=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function extractISODuration(e){const[t,n,r,i,a,s,o,l,c]=e;const d=t[0]==="-";const u=l&&l[0]==="-";const maybeNegate=(e,t=false)=>e!==undefined&&(t||e&&d)?-e:e;return[{years:maybeNegate(parseFloating(n)),months:maybeNegate(parseFloating(r)),weeks:maybeNegate(parseFloating(i)),days:maybeNegate(parseFloating(a)),hours:maybeNegate(parseFloating(s)),minutes:maybeNegate(parseFloating(o)),seconds:maybeNegate(parseFloating(l),l==="-0"),milliseconds:maybeNegate(parseMillis(c),u)}]}const we={GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function fromStrings(e,t,n,r,i,a,s){const o={year:t.length===2?untruncateYear(parseInteger(t)):parseInteger(t),month:X.indexOf(n)+1,day:parseInteger(r),hour:parseInteger(i),minute:parseInteger(a)};if(s)o.second=parseInteger(s);if(e){o.weekday=e.length>3?te.indexOf(e)+1:ne.indexOf(e)+1}return o}const je=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function extractRFC2822(e){const[,t,n,r,i,a,s,o,l,c,d,u]=e,p=fromStrings(t,i,r,n,a,s,o);let f;if(l){f=we[l]}else if(c){f=0}else{f=signedOffset(d,u)}return[p,new FixedOffsetZone(f)]}function preprocessRFC2822(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const xe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Te=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,De=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function extractRFC1123Or850(e){const[,t,n,r,i,a,s,o]=e,l=fromStrings(t,i,r,n,a,s,o);return[l,FixedOffsetZone.utcInstance]}function extractASCII(e){const[,t,n,r,i,a,s,o]=e,l=fromStrings(t,o,n,r,i,a,s);return[l,FixedOffsetZone.utcInstance]}const Oe=combineRegexes(ye,he);const Ce=combineRegexes(me,he);const Ae=combineRegexes(be,he);const Re=combineRegexes(fe);const Pe=combineExtractors(extractISOYmd,extractISOTime,extractISOOffset,extractIANAZone);const Me=combineExtractors(ge,extractISOTime,extractISOOffset,extractIANAZone);const _e=combineExtractors(ve,extractISOTime,extractISOOffset,extractIANAZone);const Ne=combineExtractors(extractISOTime,extractISOOffset,extractIANAZone);function parseISODate(e){return parse(e,[Oe,Pe],[Ce,Me],[Ae,_e],[Re,Ne])}function parseRFC2822Date(e){return parse(preprocessRFC2822(e),[je,extractRFC2822])}function parseHTTPDate(e){return parse(e,[xe,extractRFC1123Or850],[Te,extractRFC1123Or850],[De,extractASCII])}function parseISODuration(e){return parse(e,[Ie,extractISODuration])}const Le=combineExtractors(extractISOTime);function parseISOTimeOnly(e){return parse(e,[ke,Le])}const Je=combineRegexes(Ke,Ee);const Fe=combineRegexes(Se);const Ve=combineExtractors(extractISOTime,extractISOOffset,extractIANAZone);function parseSQL(e){return parse(e,[Je,Pe],[Fe,Ve])}const qe="Invalid Duration";const Ge={weeks:{days:7,hours:7*24,minutes:7*24*60,seconds:7*24*60*60,milliseconds:7*24*60*60*1e3},days:{hours:24,minutes:24*60,seconds:24*60*60,milliseconds:24*60*60*1e3},hours:{minutes:60,seconds:60*60,milliseconds:60*60*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Ye={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:91*24,minutes:91*24*60,seconds:91*24*60*60,milliseconds:91*24*60*60*1e3},months:{weeks:4,days:30,hours:30*24,minutes:30*24*60,seconds:30*24*60*60,milliseconds:30*24*60*60*1e3},...Ge},Be=146097/400,Ue=146097/4800,We={years:{quarters:4,months:12,weeks:Be/7,days:Be,hours:Be*24,minutes:Be*24*60,seconds:Be*24*60*60,milliseconds:Be*24*60*60*1e3},quarters:{months:3,weeks:Be/28,days:Be/4,hours:Be*24/4,minutes:Be*24*60/4,seconds:Be*24*60*60/4,milliseconds:Be*24*60*60*1e3/4},months:{weeks:Ue/7,days:Ue,hours:Ue*24,minutes:Ue*24*60,seconds:Ue*24*60*60,milliseconds:Ue*24*60*60*1e3},...Ge};const ze=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"];const Qe=ze.slice(0).reverse();function clone$1(e,t,n=false){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new Duration(r)}function durationToMillis(e,t){var n;let r=(n=t.milliseconds)!=null?n:0;for(const n of Qe.slice(1)){if(t[n]){r+=t[n]*e[n]["milliseconds"]}}return r}function normalizeValues(e,t){const n=durationToMillis(e,t)<0?-1:1;ze.reduceRight(((r,i)=>{if(!isUndefined(t[i])){if(r){const a=t[r]*n;const s=e[i][r];const o=Math.floor(a/s);t[i]+=o*n;t[r]-=o*s*n}return i}else{return r}}),null);ze.reduce(((n,r)=>{if(!isUndefined(t[r])){if(n){const i=t[n]%1;t[n]-=i;t[r]+=i*e[n][r]}return r}else{return n}}),null)}function removeZeroes(e){const t={};for(const[n,r]of Object.entries(e)){if(r!==0){t[n]=r}}return t}class Duration{constructor(e){const t=e.conversionAccuracy==="longterm"||false;let n=t?We:Ye;if(e.matrix){n=e.matrix}this.values=e.values;this.loc=e.loc||Locale.create();this.conversionAccuracy=t?"longterm":"casual";this.invalid=e.invalid||null;this.matrix=n;this.isLuxonDuration=true}static fromMillis(e,t){return Duration.fromObject({milliseconds:e},t)}static fromObject(e,t={}){if(e==null||typeof e!=="object"){throw new InvalidArgumentError(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`)}return new Duration({values:normalizeObject(e,Duration.normalizeUnit),loc:Locale.fromObject(t),conversionAccuracy:t.conversionAccuracy,matrix:t.matrix})}static fromDurationLike(e){if(isNumber(e)){return Duration.fromMillis(e)}else if(Duration.isDuration(e)){return e}else if(typeof e==="object"){return Duration.fromObject(e)}else{throw new InvalidArgumentError(`Unknown duration argument ${e} of type ${typeof e}`)}}static fromISO(e,t){const[n]=parseISODuration(e);if(n){return Duration.fromObject(n,t)}else{return Duration.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}}static fromISOTime(e,t){const[n]=parseISOTimeOnly(e);if(n){return Duration.fromObject(n,t)}else{return Duration.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}}static invalid(e,t=null){if(!e){throw new InvalidArgumentError("need to specify a reason the Duration is invalid")}const n=e instanceof Invalid?e:new Invalid(e,t);if(Settings.throwOnInvalid){throw new InvalidDurationError(n)}else{return new Duration({invalid:n})}}static normalizeUnit(e){const t={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e?e.toLowerCase():e];if(!t)throw new InvalidUnitError(e);return t}static isDuration(e){return e&&e.isLuxonDuration||false}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){const n={...t,floor:t.round!==false&&t.floor!==false};return this.isValid?Formatter.create(this.loc,n).formatDurationFromString(this,e):qe}toHuman(e={}){if(!this.isValid)return qe;const t=ze.map((t=>{const n=this.values[t];if(isUndefined(n)){return null}return this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:t.slice(0,-1)}).format(n)})).filter((e=>e));return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(t)}toObject(){if(!this.isValid)return{};return{...this.values}}toISO(){if(!this.isValid)return null;let e="P";if(this.years!==0)e+=this.years+"Y";if(this.months!==0||this.quarters!==0)e+=this.months+this.quarters*3+"M";if(this.weeks!==0)e+=this.weeks+"W";if(this.days!==0)e+=this.days+"D";if(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)e+="T";if(this.hours!==0)e+=this.hours+"H";if(this.minutes!==0)e+=this.minutes+"M";if(this.seconds!==0||this.milliseconds!==0)e+=roundTo(this.seconds+this.milliseconds/1e3,3)+"S";if(e==="P")e+="T0S";return e}toISOTime(e={}){if(!this.isValid)return null;const t=this.toMillis();if(t<0||t>=864e5)return null;e={suppressMilliseconds:false,suppressSeconds:false,includePrefix:false,format:"extended",...e,includeOffset:false};const n=DateTime.fromMillis(t,{zone:"UTC"});return n.toISOTime(e)}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid){return`Duration { values: ${JSON.stringify(this.values)} }`}else{return`Duration { Invalid, reason: ${this.invalidReason} }`}}toMillis(){if(!this.isValid)return NaN;return durationToMillis(this.matrix,this.values)}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const t=Duration.fromDurationLike(e),n={};for(const e of ze){if(hasOwnProperty(t.values,e)||hasOwnProperty(this.values,e)){n[e]=t.get(e)+this.get(e)}}return clone$1(this,{values:n},true)}minus(e){if(!this.isValid)return this;const t=Duration.fromDurationLike(e);return this.plus(t.negate())}mapUnits(e){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values)){t[n]=asNumber(e(this.values[n],n))}return clone$1(this,{values:t},true)}get(e){return this[Duration.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const t={...this.values,...normalizeObject(e,Duration.normalizeUnit)};return clone$1(this,{values:t})}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){const i=this.loc.clone({locale:e,numberingSystem:t});const a={loc:i,matrix:r,conversionAccuracy:n};return clone$1(this,a)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();normalizeValues(this.matrix,e);return clone$1(this,{values:e},true)}rescale(){if(!this.isValid)return this;const e=removeZeroes(this.normalize().shiftToAll().toObject());return clone$1(this,{values:e},true)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0){return this}e=e.map((e=>Duration.normalizeUnit(e)));const t={},n={},r=this.toObject();let i;for(const a of ze){if(e.indexOf(a)>=0){i=a;let e=0;for(const t in n){e+=this.matrix[t][a]*n[t];n[t]=0}if(isNumber(r[a])){e+=r[a]}const s=Math.trunc(e);t[a]=s;n[a]=(e*1e3-s*1e3)/1e3}else if(isNumber(r[a])){n[a]=r[a]}}for(const e in n){if(n[e]!==0){t[i]+=e===i?n[e]:n[e]/this.matrix[i][e]}}normalizeValues(this.matrix,t);return clone$1(this,{values:t},true)}shiftToAll(){if(!this.isValid)return this;return this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds")}negate(){if(!this.isValid)return this;const e={};for(const t of Object.keys(this.values)){e[t]=this.values[t]===0?0:-this.values[t]}return clone$1(this,{values:e},true)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid){return false}if(!this.loc.equals(e.loc)){return false}function eq(e,t){if(e===undefined||e===0)return t===undefined||t===0;return e===t}for(const t of ze){if(!eq(this.values[t],e.values[t])){return false}}return true}}const Ze="Invalid Interval";function validateStartEnd(e,t){if(!e||!e.isValid){return Interval.invalid("missing or invalid start")}else if(!t||!t.isValid){return Interval.invalid("missing or invalid end")}else if(t<e){return Interval.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`)}else{return null}}class Interval{constructor(e){this.s=e.start;this.e=e.end;this.invalid=e.invalid||null;this.isLuxonInterval=true}static invalid(e,t=null){if(!e){throw new InvalidArgumentError("need to specify a reason the Interval is invalid")}const n=e instanceof Invalid?e:new Invalid(e,t);if(Settings.throwOnInvalid){throw new InvalidIntervalError(n)}else{return new Interval({invalid:n})}}static fromDateTimes(e,t){const n=friendlyDateTime(e),r=friendlyDateTime(t);const i=validateStartEnd(n,r);if(i==null){return new Interval({start:n,end:r})}else{return i}}static after(e,t){const n=Duration.fromDurationLike(t),r=friendlyDateTime(e);return Interval.fromDateTimes(r,r.plus(n))}static before(e,t){const n=Duration.fromDurationLike(t),r=friendlyDateTime(e);return Interval.fromDateTimes(r.minus(n),r)}static fromISO(e,t){const[n,r]=(e||"").split("/",2);if(n&&r){let e,i;try{e=DateTime.fromISO(n,t);i=e.isValid}catch(r){i=false}let a,s;try{a=DateTime.fromISO(r,t);s=a.isValid}catch(r){s=false}if(i&&s){return Interval.fromDateTimes(e,a)}if(i){const n=Duration.fromISO(r,t);if(n.isValid){return Interval.after(e,n)}}else if(s){const e=Duration.fromISO(n,t);if(e.isValid){return Interval.before(a,e)}}}return Interval.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||false}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(...[e]).get(e):NaN}count(e="milliseconds",t){if(!this.isValid)return NaN;const n=this.start.startOf(e,t);let r;if(t!=null&&t.useLocaleWeeks){r=this.end.reconfigure({locale:n.locale})}else{r=this.end}r=r.startOf(e,t);return Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):false}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){if(!this.isValid)return false;return this.s>e}isBefore(e){if(!this.isValid)return false;return this.e<=e}contains(e){if(!this.isValid)return false;return this.s<=e&&this.e>e}set({start:e,end:t}={}){if(!this.isValid)return this;return Interval.fromDateTimes(e||this.s,t||this.e)}splitAt(...e){if(!this.isValid)return[];const t=e.map(friendlyDateTime).filter((e=>this.contains(e))).sort(((e,t)=>e.toMillis()-t.toMillis())),n=[];let{s:r}=this,i=0;while(r<this.e){const e=t[i]||this.e,a=+e>+this.e?this.e:e;n.push(Interval.fromDateTimes(r,a));r=a;i+=1}return n}splitBy(e){const t=Duration.fromDurationLike(e);if(!this.isValid||!t.isValid||t.as("milliseconds")===0){return[]}let{s:n}=this,r=1,i;const a=[];while(n<this.e){const e=this.start.plus(t.mapUnits((e=>e*r)));i=+e>+this.e?this.e:e;a.push(Interval.fromDateTimes(n,i));n=i;r+=1}return a}divideEqually(e){if(!this.isValid)return[];return this.splitBy(this.length()/e).slice(0,e)}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){if(!this.isValid)return false;return+this.e===+e.s}abutsEnd(e){if(!this.isValid)return false;return+e.e===+this.s}engulfs(e){if(!this.isValid)return false;return this.s<=e.s&&this.e>=e.e}equals(e){if(!this.isValid||!e.isValid){return false}return this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const t=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;if(t>=n){return null}else{return Interval.fromDateTimes(t,n)}}union(e){if(!this.isValid)return this;const t=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return Interval.fromDateTimes(t,n)}static merge(e){const[t,n]=e.sort(((e,t)=>e.s-t.s)).reduce((([e,t],n)=>{if(!t){return[e,n]}else if(t.overlaps(n)||t.abutsStart(n)){return[e,t.union(n)]}else{return[e.concat([t]),n]}}),[[],null]);if(n){t.push(n)}return t}static xor(e){let t=null,n=0;const r=[],i=e.map((e=>[{time:e.s,type:"s"},{time:e.e,type:"e"}])),a=Array.prototype.concat(...i),s=a.sort(((e,t)=>e.time-t.time));for(const e of s){n+=e.type==="s"?1:-1;if(n===1){t=e.time}else{if(t&&+t!==+e.time){r.push(Interval.fromDateTimes(t,e.time))}t=null}}return Interval.merge(r)}difference(...e){return Interval.xor([this].concat(e)).map((e=>this.intersection(e))).filter((e=>e&&!e.isEmpty()))}toString(){if(!this.isValid)return Ze;return`[${this.s.toISO()} – ${this.e.toISO()})`}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid){return`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`}else{return`Interval { Invalid, reason: ${this.invalidReason} }`}}toLocaleString(e=a,t={}){return this.isValid?Formatter.create(this.s.loc.clone(t),e).formatInterval(this):Ze}toISO(e){if(!this.isValid)return Ze;return`${this.s.toISO(e)}/${this.e.toISO(e)}`}toISODate(){if(!this.isValid)return Ze;return`${this.s.toISODate()}/${this.e.toISODate()}`}toISOTime(e){if(!this.isValid)return Ze;return`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`}toFormat(e,{separator:t=" – "}={}){if(!this.isValid)return Ze;return`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`}toDuration(e,t){if(!this.isValid){return Duration.invalid(this.invalidReason)}return this.e.diff(this.s,e,t)}mapEndpoints(e){return Interval.fromDateTimes(e(this.s),e(this.e))}}class Info{static hasDST(e=Settings.defaultZone){const t=DateTime.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return IANAZone.isValidZone(e)}static normalizeZone(e){return normalizeZone(e,Settings.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||Locale.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||Locale.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||Locale.create(e)).getWeekendDays().slice()}static months(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Locale.create(t,n,i)).months(e)}static monthsFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Locale.create(t,n,i)).months(e,true)}static weekdays(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Locale.create(t,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Locale.create(t,n,null)).weekdays(e,true)}static meridiems({locale:e=null}={}){return Locale.create(e).meridiems()}static eras(e="short",{locale:t=null}={}){return Locale.create(t,null,"gregory").eras(e)}static features(){return{relative:hasRelative(),localeWeek:hasLocaleWeekInfo()}}}function dayDiff(e,t){const utcDayStart=e=>e.toUTC(0,{keepLocalTime:true}).startOf("day").valueOf(),n=utcDayStart(t)-utcDayStart(e);return Math.floor(Duration.fromMillis(n).as("days"))}function highOrderDiffs(e,t,n){const r=[["years",(e,t)=>t.year-e.year],["quarters",(e,t)=>t.quarter-e.quarter+(t.year-e.year)*4],["months",(e,t)=>t.month-e.month+(t.year-e.year)*12],["weeks",(e,t)=>{const n=dayDiff(e,t);return(n-n%7)/7}],["days",dayDiff]];const i={};const a=e;let s,o;for(const[l,c]of r){if(n.indexOf(l)>=0){s=l;i[l]=c(e,t);o=a.plus(i);if(o>t){i[l]--;e=a.plus(i);if(e>t){o=e;i[l]--;e=a.plus(i)}}else{e=o}}}return[e,i,o,s]}function diff(e,t,n,r){let[i,a,s,o]=highOrderDiffs(e,t,n);const l=t-i;const c=n.filter((e=>["hours","minutes","seconds","milliseconds"].indexOf(e)>=0));if(c.length===0){if(s<t){s=i.plus({[o]:1})}if(s!==i){a[o]=(a[o]||0)+l/(s-i)}}const d=Duration.fromObject(a,r);if(c.length>0){return Duration.fromMillis(l,r).shiftTo(...c).plus(d)}else{return d}}const $e="missing Intl.DateTimeFormat.formatToParts support";function intUnit(e,t=e=>e){return{regex:e,deser:([e])=>t(parseDigits(e))}}const He=String.fromCharCode(160);const Xe=`[ ${He}]`;const et=new RegExp(Xe,"g");function fixListRegex(e){return e.replace(/\./g,"\\.?").replace(et,Xe)}function stripInsensitivities(e){return e.replace(/\./g,"").replace(et," ").toLowerCase()}function oneOf(e,t){if(e===null){return null}else{return{regex:RegExp(e.map(fixListRegex).join("|")),deser:([n])=>e.findIndex((e=>stripInsensitivities(n)===stripInsensitivities(e)))+t}}}function offset(e,t){return{regex:e,deser:([,e,t])=>signedOffset(e,t),groups:t}}function simple(e){return{regex:e,deser:([e])=>e}}function escapeToken(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function unitForToken(e,t){const n=digitRegex(t),r=digitRegex(t,"{2}"),i=digitRegex(t,"{3}"),a=digitRegex(t,"{4}"),s=digitRegex(t,"{6}"),o=digitRegex(t,"{1,2}"),l=digitRegex(t,"{1,3}"),c=digitRegex(t,"{1,6}"),d=digitRegex(t,"{1,9}"),u=digitRegex(t,"{2,4}"),p=digitRegex(t,"{4,6}"),literal=e=>({regex:RegExp(escapeToken(e.val)),deser:([e])=>e,literal:true}),unitate=f=>{if(e.literal){return literal(f)}switch(f.val){case"G":return oneOf(t.eras("short"),0);case"GG":return oneOf(t.eras("long"),0);case"y":return intUnit(c);case"yy":return intUnit(u,untruncateYear);case"yyyy":return intUnit(a);case"yyyyy":return intUnit(p);case"yyyyyy":return intUnit(s);case"M":return intUnit(o);case"MM":return intUnit(r);case"MMM":return oneOf(t.months("short",true),1);case"MMMM":return oneOf(t.months("long",true),1);case"L":return intUnit(o);case"LL":return intUnit(r);case"LLL":return oneOf(t.months("short",false),1);case"LLLL":return oneOf(t.months("long",false),1);case"d":return intUnit(o);case"dd":return intUnit(r);case"o":return intUnit(l);case"ooo":return intUnit(i);case"HH":return intUnit(r);case"H":return intUnit(o);case"hh":return intUnit(r);case"h":return intUnit(o);case"mm":return intUnit(r);case"m":return intUnit(o);case"q":return intUnit(o);case"qq":return intUnit(r);case"s":return intUnit(o);case"ss":return intUnit(r);case"S":return intUnit(l);case"SSS":return intUnit(i);case"u":return simple(d);case"uu":return simple(o);case"uuu":return intUnit(n);case"a":return oneOf(t.meridiems(),0);case"kkkk":return intUnit(a);case"kk":return intUnit(u,untruncateYear);case"W":return intUnit(o);case"WW":return intUnit(r);case"E":case"c":return intUnit(n);case"EEE":return oneOf(t.weekdays("short",false),1);case"EEEE":return oneOf(t.weekdays("long",false),1);case"ccc":return oneOf(t.weekdays("short",true),1);case"cccc":return oneOf(t.weekdays("long",true),1);case"Z":case"ZZ":return offset(new RegExp(`([+-]${o.source})(?::(${r.source}))?`),2);case"ZZZ":return offset(new RegExp(`([+-]${o.source})(${r.source})?`),2);case"z":return simple(/[a-z_+-/]{1,256}?/i);case" ":return simple(/[^\S\n\r]/);default:return literal(f)}};const f=unitate(e)||{invalidReason:$e};f.token=e;return f}const tt={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function tokenForPart(e,t,n){const{type:r,value:i}=e;if(r==="literal"){const e=/^\s+$/.test(i);return{literal:!e,val:e?" ":i}}const a=t[r];let s=r;if(r==="hour"){if(t.hour12!=null){s=t.hour12?"hour12":"hour24"}else if(t.hourCycle!=null){if(t.hourCycle==="h11"||t.hourCycle==="h12"){s="hour12"}else{s="hour24"}}else{s=n.hour12?"hour12":"hour24"}}let o=tt[s];if(typeof o==="object"){o=o[a]}if(o){return{literal:false,val:o}}return undefined}function buildRegex(e){const t=e.map((e=>e.regex)).reduce(((e,t)=>`${e}(${t.source})`),"");return[`^${t}$`,e]}function match(e,t,n){const r=e.match(t);if(r){const e={};let t=1;for(const i in n){if(hasOwnProperty(n,i)){const a=n[i],s=a.groups?a.groups+1:1;if(!a.literal&&a.token){e[a.token.val[0]]=a.deser(r.slice(t,t+s))}t+=s}}return[r,e]}else{return[r,{}]}}function dateTimeFromMatches(e){const toField=e=>{switch(e){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let t=null;let n;if(!isUndefined(e.z)){t=IANAZone.create(e.z)}if(!isUndefined(e.Z)){if(!t){t=new FixedOffsetZone(e.Z)}n=e.Z}if(!isUndefined(e.q)){e.M=(e.q-1)*3+1}if(!isUndefined(e.h)){if(e.h<12&&e.a===1){e.h+=12}else if(e.h===12&&e.a===0){e.h=0}}if(e.G===0&&e.y){e.y=-e.y}if(!isUndefined(e.u)){e.S=parseMillis(e.u)}const r=Object.keys(e).reduce(((t,n)=>{const r=toField(n);if(r){t[r]=e[n]}return t}),{});return[r,t,n]}let nt=null;function getDummyDateTime(){if(!nt){nt=DateTime.fromMillis(1555555555555)}return nt}function maybeExpandMacroToken(e,t){if(e.literal){return e}const n=Formatter.macroTokenToFormatOpts(e.val);const r=formatOptsToTokens(n,t);if(r==null||r.includes(undefined)){return e}return r}function expandMacroTokens(e,t){return Array.prototype.concat(...e.map((e=>maybeExpandMacroToken(e,t))))}class TokenParser{constructor(e,t){this.locale=e;this.format=t;this.tokens=expandMacroTokens(Formatter.parseFormat(t),e);this.units=this.tokens.map((t=>unitForToken(t,e)));this.disqualifyingUnit=this.units.find((e=>e.invalidReason));if(!this.disqualifyingUnit){const[e,t]=buildRegex(this.units);this.regex=RegExp(e,"i");this.handlers=t}}explainFromTokens(e){if(!this.isValid){return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}else{const[t,n]=match(e,this.regex,this.handlers),[r,i,a]=n?dateTimeFromMatches(n):[null,null,undefined];if(hasOwnProperty(n,"a")&&hasOwnProperty(n,"H")){throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format")}return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:a}}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function explainFromTokens(e,t,n){const r=new TokenParser(e,n);return r.explainFromTokens(t)}function parseFromTokens(e,t,n){const{result:r,zone:i,specificOffset:a,invalidReason:s}=explainFromTokens(e,t,n);return[r,i,a,s]}function formatOptsToTokens(e,t){if(!e){return null}const n=Formatter.create(t,e);const r=n.dtFormatter(getDummyDateTime());const i=r.formatToParts();const a=r.resolvedOptions();return i.map((t=>tokenForPart(t,e,a)))}const rt="Invalid DateTime";const it=864e13;function unsupportedZone(e){return new Invalid("unsupported zone",`the zone "${e.name}" is not supported`)}function possiblyCachedWeekData(e){if(e.weekData===null){e.weekData=gregorianToWeek(e.c)}return e.weekData}function possiblyCachedLocalWeekData(e){if(e.localWeekData===null){e.localWeekData=gregorianToWeek(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())}return e.localWeekData}function clone(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new DateTime({...n,...t,old:n})}function fixOffset(e,t,n){let r=e-t*60*1e3;const i=n.offset(r);if(t===i){return[r,t]}r-=(i-t)*60*1e3;const a=n.offset(r);if(i===a){return[r,i]}return[e-Math.min(i,a)*60*1e3,Math.max(i,a)]}function tsToObj(e,t){e+=t*60*1e3;const n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function objToTS(e,t,n){return fixOffset(objToLocalTS(e),t,n)}function adjustTime(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,a={...e.c,year:r,month:i,day:Math.min(e.c.day,daysInMonth(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},s=Duration.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),o=objToLocalTS(a);let[l,c]=fixOffset(o,n,e.zone);if(s!==0){l+=s;c=e.zone.offset(l)}return{ts:l,o:c}}function parseDataToDateTime(e,t,n,r,i,a){const{setZone:s,zone:o}=n;if(e&&Object.keys(e).length!==0||t){const r=t||o,i=DateTime.fromObject(e,{...n,zone:r,specificOffset:a});return s?i:i.setZone(o)}else{return DateTime.invalid(new Invalid("unparsable",`the input "${i}" can't be parsed as ${r}`))}}function toTechFormat(e,t,n=true){return e.isValid?Formatter.create(Locale.create("en-US"),{allowZ:n,forceSimple:true}).formatDateTimeFromString(e,t):null}function toISODate(e,t){const n=e.c.year>9999||e.c.year<0;let r="";if(n&&e.c.year>=0)r+="+";r+=padStart(e.c.year,n?6:4);if(t){r+="-";r+=padStart(e.c.month);r+="-";r+=padStart(e.c.day)}else{r+=padStart(e.c.month);r+=padStart(e.c.day)}return r}function toISOTime(e,t,n,r,i,a){let s=padStart(e.c.hour);if(t){s+=":";s+=padStart(e.c.minute);if(e.c.millisecond!==0||e.c.second!==0||!n){s+=":"}}else{s+=padStart(e.c.minute)}if(e.c.millisecond!==0||e.c.second!==0||!n){s+=padStart(e.c.second);if(e.c.millisecond!==0||!r){s+=".";s+=padStart(e.c.millisecond,3)}}if(i){if(e.isOffsetFixed&&e.offset===0&&!a){s+="Z"}else if(e.o<0){s+="-";s+=padStart(Math.trunc(-e.o/60));s+=":";s+=padStart(Math.trunc(-e.o%60))}else{s+="+";s+=padStart(Math.trunc(e.o/60));s+=":";s+=padStart(Math.trunc(e.o%60))}}if(a){s+="["+e.zone.ianaName+"]"}return s}const at={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},st={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},ot={ordinal:1,hour:0,minute:0,second:0,millisecond:0};const ct=["year","month","day","hour","minute","second","millisecond"],dt=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],ut=["year","ordinal","hour","minute","second","millisecond"];function normalizeUnit(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new InvalidUnitError(e);return t}function normalizeUnitWithLocalWeeks(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return normalizeUnit(e)}}function guessOffsetForZone(e){if(!ft[e]){if(pt===undefined){pt=Settings.now()}ft[e]=e.offset(pt)}return ft[e]}function quickDT(e,t){const n=normalizeZone(t.zone,Settings.defaultZone);if(!n.isValid){return DateTime.invalid(unsupportedZone(n))}const r=Locale.fromObject(t);let i,a;if(!isUndefined(e.year)){for(const t of ct){if(isUndefined(e[t])){e[t]=at[t]}}const t=hasInvalidGregorianData(e)||hasInvalidTimeData(e);if(t){return DateTime.invalid(t)}const r=guessOffsetForZone(n);[i,a]=objToTS(e,r,n)}else{i=Settings.now()}return new DateTime({ts:i,zone:n,loc:r,o:a})}function diffRelative(e,t,n){const r=isUndefined(n.round)?true:n.round,format=(e,i)=>{e=roundTo(e,r||n.calendary?0:2,true);const a=t.loc.clone(n).relFormatter(n);return a.format(e,i)},differ=r=>{if(n.calendary){if(!t.hasSame(e,r)){return t.startOf(r).diff(e.startOf(r),r).get(r)}else return 0}else{return t.diff(e,r).get(r)}};if(n.unit){return format(differ(n.unit),n.unit)}for(const e of n.units){const t=differ(e);if(Math.abs(t)>=1){return format(t,e)}}return format(e>t?-0:0,n.units[n.units.length-1])}function lastOpts(e){let t={},n;if(e.length>0&&typeof e[e.length-1]==="object"){t=e[e.length-1];n=Array.from(e).slice(0,e.length-1)}else{n=Array.from(e)}return[t,n]}let pt;let ft={};class DateTime{constructor(e){const t=e.zone||Settings.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Invalid("invalid input"):null)||(!t.isValid?unsupportedZone(t):null);this.ts=isUndefined(e.ts)?Settings.now():e.ts;let r=null,i=null;if(!n){const a=e.old&&e.old.ts===this.ts&&e.old.zone.equals(t);if(a){[r,i]=[e.old.c,e.old.o]}else{const a=isNumber(e.o)&&!e.old?e.o:t.offset(this.ts);r=tsToObj(this.ts,a);n=Number.isNaN(r.year)?new Invalid("invalid input"):null;r=n?null:r;i=n?null:a}}this._zone=t;this.loc=e.loc||Locale.create();this.invalid=n;this.weekData=null;this.localWeekData=null;this.c=r;this.o=i;this.isLuxonDateTime=true}static now(){return new DateTime({})}static local(){const[e,t]=lastOpts(arguments),[n,r,i,a,s,o,l]=t;return quickDT({year:n,month:r,day:i,hour:a,minute:s,second:o,millisecond:l},e)}static utc(){const[e,t]=lastOpts(arguments),[n,r,i,a,s,o,l]=t;e.zone=FixedOffsetZone.utcInstance;return quickDT({year:n,month:r,day:i,hour:a,minute:s,second:o,millisecond:l},e)}static fromJSDate(e,t={}){const n=isDate(e)?e.valueOf():NaN;if(Number.isNaN(n)){return DateTime.invalid("invalid input")}const r=normalizeZone(t.zone,Settings.defaultZone);if(!r.isValid){return DateTime.invalid(unsupportedZone(r))}return new DateTime({ts:n,zone:r,loc:Locale.fromObject(t)})}static fromMillis(e,t={}){if(!isNumber(e)){throw new InvalidArgumentError(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}else if(e<-it||e>it){return DateTime.invalid("Timestamp out of range")}else{return new DateTime({ts:e,zone:normalizeZone(t.zone,Settings.defaultZone),loc:Locale.fromObject(t)})}}static fromSeconds(e,t={}){if(!isNumber(e)){throw new InvalidArgumentError("fromSeconds requires a numerical input")}else{return new DateTime({ts:e*1e3,zone:normalizeZone(t.zone,Settings.defaultZone),loc:Locale.fromObject(t)})}}static fromObject(e,t={}){e=e||{};const n=normalizeZone(t.zone,Settings.defaultZone);if(!n.isValid){return DateTime.invalid(unsupportedZone(n))}const r=Locale.fromObject(t);const i=normalizeObject(e,normalizeUnitWithLocalWeeks);const{minDaysInFirstWeek:a,startOfWeek:s}=usesLocalWeekValues(i,r);const o=Settings.now(),l=!isUndefined(t.specificOffset)?t.specificOffset:n.offset(o),c=!isUndefined(i.ordinal),d=!isUndefined(i.year),u=!isUndefined(i.month)||!isUndefined(i.day),p=d||u,f=i.weekYear||i.weekNumber;if((p||c)&&f){throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals")}if(u&&c){throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day")}const h=f||i.weekday&&!p;let y,m,b=tsToObj(o,l);if(h){y=dt;m=st;b=gregorianToWeek(b,a,s)}else if(c){y=ut;m=ot;b=gregorianToOrdinal(b)}else{y=ct;m=at}let g=false;for(const e of y){const t=i[e];if(!isUndefined(t)){g=true}else if(g){i[e]=m[e]}else{i[e]=b[e]}}const v=h?hasInvalidWeekData(i,a,s):c?hasInvalidOrdinalData(i):hasInvalidGregorianData(i),K=v||hasInvalidTimeData(i);if(K){return DateTime.invalid(K)}const S=h?weekToGregorian(i,a,s):c?ordinalToGregorian(i):i,[E,k]=objToTS(S,l,n),I=new DateTime({ts:E,zone:n,o:k,loc:r});if(i.weekday&&p&&e.weekday!==I.weekday){return DateTime.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${I.toISO()}`)}if(!I.isValid){return DateTime.invalid(I.invalid)}return I}static fromISO(e,t={}){const[n,r]=parseISODate(e);return parseDataToDateTime(n,r,t,"ISO 8601",e)}static fromRFC2822(e,t={}){const[n,r]=parseRFC2822Date(e);return parseDataToDateTime(n,r,t,"RFC 2822",e)}static fromHTTP(e,t={}){const[n,r]=parseHTTPDate(e);return parseDataToDateTime(n,r,t,"HTTP",t)}static fromFormat(e,t,n={}){if(isUndefined(e)||isUndefined(t)){throw new InvalidArgumentError("fromFormat requires an input string and a format")}const{locale:r=null,numberingSystem:i=null}=n,a=Locale.fromOpts({locale:r,numberingSystem:i,defaultToEN:true}),[s,o,l,c]=parseFromTokens(a,e,t);if(c){return DateTime.invalid(c)}else{return parseDataToDateTime(s,o,n,`format ${t}`,e,l)}}static fromString(e,t,n={}){return DateTime.fromFormat(e,t,n)}static fromSQL(e,t={}){const[n,r]=parseSQL(e);return parseDataToDateTime(n,r,t,"SQL",e)}static invalid(e,t=null){if(!e){throw new InvalidArgumentError("need to specify a reason the DateTime is invalid")}const n=e instanceof Invalid?e:new Invalid(e,t);if(Settings.throwOnInvalid){throw new InvalidDateTimeError(n)}else{return new DateTime({invalid:n})}}static isDateTime(e){return e&&e.isLuxonDateTime||false}static parseFormatForOpts(e,t={}){const n=formatOptsToTokens(e,Locale.fromObject(t));return!n?null:n.map((e=>e?e.val:null)).join("")}static expandFormat(e,t={}){const n=expandMacroTokens(Formatter.parseFormat(e),Locale.fromObject(t));return n.map((e=>e.val)).join("")}static resetCache(){pt=undefined;ft={}}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?possiblyCachedWeekData(this).weekYear:NaN}get weekNumber(){return this.isValid?possiblyCachedWeekData(this).weekNumber:NaN}get weekday(){return this.isValid?possiblyCachedWeekData(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?possiblyCachedLocalWeekData(this).weekday:NaN}get localWeekNumber(){return this.isValid?possiblyCachedLocalWeekData(this).weekNumber:NaN}get localWeekYear(){return this.isValid?possiblyCachedLocalWeekData(this).weekYear:NaN}get ordinal(){return this.isValid?gregorianToOrdinal(this.c).ordinal:NaN}get monthShort(){return this.isValid?Info.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Info.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Info.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Info.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){if(this.isValid){return this.zone.offsetName(this.ts,{format:"short",locale:this.locale})}else{return null}}get offsetNameLong(){if(this.isValid){return this.zone.offsetName(this.ts,{format:"long",locale:this.locale})}else{return null}}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){if(this.isOffsetFixed){return false}else{return this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed){return[this]}const e=864e5;const t=6e4;const n=objToLocalTS(this.c);const r=this.zone.offset(n-e);const i=this.zone.offset(n+e);const a=this.zone.offset(n-r*t);const s=this.zone.offset(n-i*t);if(a===s){return[this]}const o=n-a*t;const l=n-s*t;const c=tsToObj(o,a);const d=tsToObj(l,s);if(c.hour===d.hour&&c.minute===d.minute&&c.second===d.second&&c.millisecond===d.millisecond){return[clone(this,{ts:o}),clone(this,{ts:l})]}return[this]}get isInLeapYear(){return isLeapYear(this.year)}get daysInMonth(){return daysInMonth(this.year,this.month)}get daysInYear(){return this.isValid?daysInYear(this.year):NaN}get weeksInWeekYear(){return this.isValid?weeksInWeekYear(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?weeksInWeekYear(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:t,numberingSystem:n,calendar:r}=Formatter.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(FixedOffsetZone.instance(e),t)}toLocal(){return this.setZone(Settings.defaultZone)}setZone(e,{keepLocalTime:t=false,keepCalendarTime:n=false}={}){e=normalizeZone(e,Settings.defaultZone);if(e.equals(this.zone)){return this}else if(!e.isValid){return DateTime.invalid(unsupportedZone(e))}else{let r=this.ts;if(t||n){const t=e.offset(this.ts);const n=this.toObject();[r]=objToTS(n,t,e)}return clone(this,{ts:r,zone:e})}}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return clone(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const t=normalizeObject(e,normalizeUnitWithLocalWeeks);const{minDaysInFirstWeek:n,startOfWeek:r}=usesLocalWeekValues(t,this.loc);const i=!isUndefined(t.weekYear)||!isUndefined(t.weekNumber)||!isUndefined(t.weekday),a=!isUndefined(t.ordinal),s=!isUndefined(t.year),o=!isUndefined(t.month)||!isUndefined(t.day),l=s||o,c=t.weekYear||t.weekNumber;if((l||a)&&c){throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals")}if(o&&a){throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day")}let d;if(i){d=weekToGregorian({...gregorianToWeek(this.c,n,r),...t},n,r)}else if(!isUndefined(t.ordinal)){d=ordinalToGregorian({...gregorianToOrdinal(this.c),...t})}else{d={...this.toObject(),...t};if(isUndefined(t.day)){d.day=Math.min(daysInMonth(d.year,d.month),d.day)}}const[u,p]=objToTS(d,this.o,this.zone);return clone(this,{ts:u,o:p})}plus(e){if(!this.isValid)return this;const t=Duration.fromDurationLike(e);return clone(this,adjustTime(this,t))}minus(e){if(!this.isValid)return this;const t=Duration.fromDurationLike(e).negate();return clone(this,adjustTime(this,t))}startOf(e,{useLocaleWeeks:t=false}={}){if(!this.isValid)return this;const n={},r=Duration.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks"){if(t){const e=this.loc.getStartOfWeek();const{weekday:t}=this;if(t<e){n.weekNumber=this.weekNumber-1}n.weekday=e}else{n.weekday=1}}if(r==="quarters"){const e=Math.ceil(this.month/3);n.month=(e-1)*3+1}return this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?Formatter.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):rt}toLocaleString(e=a,t={}){return this.isValid?Formatter.create(this.loc.clone(t),e).formatDateTime(this):rt}toLocaleParts(e={}){return this.isValid?Formatter.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:t=false,suppressMilliseconds:n=false,includeOffset:r=true,extendedZone:i=false}={}){if(!this.isValid){return null}const a=e==="extended";let s=toISODate(this,a);s+="T";s+=toISOTime(this,a,t,n,r,i);return s}toISODate({format:e="extended"}={}){if(!this.isValid){return null}return toISODate(this,e==="extended")}toISOWeekDate(){return toTechFormat(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=false,suppressSeconds:t=false,includeOffset:n=true,includePrefix:r=false,extendedZone:i=false,format:a="extended"}={}){if(!this.isValid){return null}let s=r?"T":"";return s+toISOTime(this,a==="extended",t,e,n,i)}toRFC2822(){return toTechFormat(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",false)}toHTTP(){return toTechFormat(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){if(!this.isValid){return null}return toISODate(this,true)}toSQLTime({includeOffset:e=true,includeZone:t=false,includeOffsetSpace:n=true}={}){let r="HH:mm:ss.SSS";if(t||e){if(n){r+=" "}if(t){r+="z"}else if(e){r+="ZZ"}}return toTechFormat(this,r,true)}toSQL(e={}){if(!this.isValid){return null}return`${this.toSQLDate()} ${this.toSQLTime(e)}`}toString(){return this.isValid?this.toISO():rt}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid){return`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`}else{return`DateTime { Invalid, reason: ${this.invalidReason} }`}}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const t={...this.c};if(e.includeConfig){t.outputCalendar=this.outputCalendar;t.numberingSystem=this.loc.numberingSystem;t.locale=this.loc.locale}return t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t="milliseconds",n={}){if(!this.isValid||!e.isValid){return Duration.invalid("created by diffing an invalid DateTime")}const r={locale:this.locale,numberingSystem:this.numberingSystem,...n};const i=maybeArray(t).map(Duration.normalizeUnit),a=e.valueOf()>this.valueOf(),s=a?this:e,o=a?e:this,l=diff(s,o,i,r);return a?l.negate():l}diffNow(e="milliseconds",t={}){return this.diff(DateTime.now(),e,t)}until(e){return this.isValid?Interval.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return false;const r=e.valueOf();const i=this.setZone(e.zone,{keepLocalTime:true});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const t=e.base||DateTime.fromObject({},{zone:this.zone}),n=e.padding?this<t?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"];let i=e.unit;if(Array.isArray(e.unit)){r=e.unit;i=undefined}return diffRelative(t,this.plus(n),{...e,numeric:"always",units:r,unit:i})}toRelativeCalendar(e={}){if(!this.isValid)return null;return diffRelative(e.base||DateTime.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:true})}static min(...e){if(!e.every(DateTime.isDateTime)){throw new InvalidArgumentError("min requires all arguments be DateTimes")}return bestBy(e,(e=>e.valueOf()),Math.min)}static max(...e){if(!e.every(DateTime.isDateTime)){throw new InvalidArgumentError("max requires all arguments be DateTimes")}return bestBy(e,(e=>e.valueOf()),Math.max)}static fromFormatExplain(e,t,n={}){const{locale:r=null,numberingSystem:i=null}=n,a=Locale.fromOpts({locale:r,numberingSystem:i,defaultToEN:true});return explainFromTokens(a,e,t)}static fromStringExplain(e,t,n={}){return DateTime.fromFormatExplain(e,t,n)}static buildFormatParser(e,t={}){const{locale:n=null,numberingSystem:r=null}=t,i=Locale.fromOpts({locale:n,numberingSystem:r,defaultToEN:true});return new TokenParser(i,e)}static fromFormatParser(e,t,n={}){if(isUndefined(e)||isUndefined(t)){throw new InvalidArgumentError("fromFormatParser requires an input string and a format parser")}const{locale:r=null,numberingSystem:i=null}=n,a=Locale.fromOpts({locale:r,numberingSystem:i,defaultToEN:true});if(!a.equals(t.locale)){throw new InvalidArgumentError(`fromFormatParser called with a locale of ${a}, `+`but the format parser was created for ${t.locale}`)}const{result:s,zone:o,specificOffset:l,invalidReason:c}=t.explainFromTokens(e);if(c){return DateTime.invalid(c)}else{return parseDataToDateTime(s,o,n,`format ${t.format}`,e,l)}}static get DATE_SHORT(){return a}static get DATE_MED(){return s}static get DATE_MED_WITH_WEEKDAY(){return o}static get DATE_FULL(){return l}static get DATE_HUGE(){return c}static get TIME_SIMPLE(){return d}static get TIME_WITH_SECONDS(){return u}static get TIME_WITH_SHORT_OFFSET(){return p}static get TIME_WITH_LONG_OFFSET(){return f}static get TIME_24_SIMPLE(){return h}static get TIME_24_WITH_SECONDS(){return y}static get TIME_24_WITH_SHORT_OFFSET(){return m}static get TIME_24_WITH_LONG_OFFSET(){return b}static get DATETIME_SHORT(){return g}static get DATETIME_SHORT_WITH_SECONDS(){return v}static get DATETIME_MED(){return K}static get DATETIME_MED_WITH_SECONDS(){return S}static get DATETIME_MED_WITH_WEEKDAY(){return E}static get DATETIME_FULL(){return k}static get DATETIME_FULL_WITH_SECONDS(){return I}static get DATETIME_HUGE(){return w}static get DATETIME_HUGE_WITH_SECONDS(){return j}}function friendlyDateTime(e){if(DateTime.isDateTime(e)){return e}else if(e&&e.valueOf&&isNumber(e.valueOf())){return DateTime.fromJSDate(e)}else if(e&&typeof e==="object"){return DateTime.fromObject(e)}else{throw new InvalidArgumentError(`Unknown datetime argument: ${e}, of type ${typeof e}`)}}const ht="3.5.0";t.DateTime=DateTime;t.Duration=Duration;t.FixedOffsetZone=FixedOffsetZone;t.IANAZone=IANAZone;t.Info=Info;t.Interval=Interval;t.InvalidZone=InvalidZone;t.Settings=Settings;t.SystemZone=SystemZone;t.VERSION=ht;t.Zone=Zone},2134:function(e){var t=1e3;var n=t*60;var r=n*60;var i=r*24;var a=i*7;var s=i*365.25;e.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0){return parse(e)}else if(n==="number"&&isFinite(e)){return t.long?fmtLong(e):fmtShort(e)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse(e){e=String(e);if(e.length>100){return}var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!o){return}var l=parseFloat(o[1]);var c=(o[2]||"ms").toLowerCase();switch(c){case"years":case"year":case"yrs":case"yr":case"y":return l*s;case"weeks":case"week":case"w":return l*a;case"days":case"day":case"d":return l*i;case"hours":case"hour":case"hrs":case"hr":case"h":return l*r;case"minutes":case"minute":case"mins":case"min":case"m":return l*n;case"seconds":case"second":case"secs":case"sec":case"s":return l*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return undefined}}function fmtShort(e){var a=Math.abs(e);if(a>=i){return Math.round(e/i)+"d"}if(a>=r){return Math.round(e/r)+"h"}if(a>=n){return Math.round(e/n)+"m"}if(a>=t){return Math.round(e/t)+"s"}return e+"ms"}function fmtLong(e){var a=Math.abs(e);if(a>=i){return plural(e,a,i,"day")}if(a>=r){return plural(e,a,r,"hour")}if(a>=n){return plural(e,a,n,"minute")}if(a>=t){return plural(e,a,t,"second")}return e+" ms"}function plural(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+" "+r+(i?"s":"")}},86:function(e,t,n){e.exports=n(8869)(__dirname)},221:function(e,t,n){const{EventEmitter:r}=n(4434);class AbortSignal{constructor(){this.eventEmitter=new r;this.onabort=null;this.aborted=false;this.reason=undefined}toString(){return"[object AbortSignal]"}get[Symbol.toStringTag](){return"AbortSignal"}removeEventListener(e,t){this.eventEmitter.removeListener(e,t)}addEventListener(e,t){this.eventEmitter.on(e,t)}dispatchEvent(e){const t={type:e,target:this};const n=`on${e}`;if(typeof this[n]==="function")this[n](t);this.eventEmitter.emit(e,t)}throwIfAborted(){if(this.aborted){throw this.reason}}static abort(e){const t=new AbortController;t.abort();return t.signal}static timeout(e){const t=new AbortController;setTimeout((()=>t.abort(new Error("TimeoutError"))),e);return t.signal}}class AbortController{constructor(){this.signal=new AbortSignal}abort(e){if(this.signal.aborted)return;this.signal.aborted=true;if(e)this.signal.reason=e;else this.signal.reason=new Error("AbortError");this.signal.dispatchEvent("abort")}toString(){return"[object AbortController]"}get[Symbol.toStringTag](){return"AbortController"}}e.exports={AbortController:AbortController,AbortSignal:AbortSignal}},8869:function(module,__unused_webpack_exports,__nccwpck_require__){const runtimeRequire=true?eval("require"):0;if(typeof runtimeRequire.addon==="function"){module.exports=runtimeRequire.addon.bind(runtimeRequire)}else{module.exports=__nccwpck_require__(4769)}},4769:function(module,__unused_webpack_exports,__nccwpck_require__){var fs=__nccwpck_require__(9896);var path=__nccwpck_require__(6928);var url=__nccwpck_require__(7016);var os=__nccwpck_require__(857);var runtimeRequire=true?eval("require"):0;var vars=process.config&&process.config.variables||{};var prebuildsOnly=!!process.env.PREBUILDS_ONLY;var versions=process.versions;var abi=versions.modules;if(versions.deno||process.isBun){abi="unsupported"}var runtime=isElectron()?"electron":isNwjs()?"node-webkit":"node";var arch=process.env.npm_config_arch||os.arch();var platform=process.env.npm_config_platform||os.platform();var libc=process.env.LIBC||(isMusl(platform)?"musl":"glibc");var armv=process.env.ARM_VERSION||(arch==="arm64"?"8":vars.arm_version)||"";var uv=(versions.uv||"").split(".")[0];module.exports=load;function load(e){return runtimeRequire(load.resolve(e))}load.resolve=load.path=function(e){e=path.resolve(e||".");var t="";var n;try{t=runtimeRequire(path.join(e,"package.json")).name;var r=t.toUpperCase().replace(/-/g,"_");if(process.env[r+"_PREBUILD"])e=process.env[r+"_PREBUILD"]}catch(e){n=e}if(!prebuildsOnly){var i=getFirst(path.join(e,"build/Release"),matchBuild);if(i)return i;var a=getFirst(path.join(e,"build/Debug"),matchBuild);if(a)return a}var s=resolve(e);if(s)return s;var o=resolve(path.dirname(process.execPath));if(o)return o;var l=(t[0]=="@"?"":"@"+t+"/")+t+"-"+platform+"-"+arch;var c;try{var d=path.dirname(__nccwpck_require__(3339).createRequire(url.pathToFileURL(path.join(e,"package.json"))).resolve(l));return resolveFile(d)}catch(e){c=e}var u=["platform="+platform,"arch="+arch,"runtime="+runtime,"abi="+abi,"uv="+uv,armv?"armv="+armv:"","libc="+libc,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",true?"webpack=true":0].filter(Boolean).join(" ");let p="No native build was found for "+u+"\n attempted loading from: "+e+" and package:"+" "+l+"\n";if(n){p+="Error finding package.json: "+n.message+"\n"}if(c){p+="Error resolving package: "+c.message+"\n"}throw new Error(p);function resolve(e){var t=readdirSync(path.join(e,"prebuilds")).map(parseTuple);var n=t.filter(matchTuple(platform,arch)).sort(compareTuples)[0];if(!n)return;return resolveFile(path.join(e,"prebuilds",n.name))}function resolveFile(e){var t=readdirSync(e).map(parseTags);var n=t.filter(matchTags(runtime,abi));var r=n.sort(compareTags(runtime))[0];if(r)return path.join(e,r.file)}};function readdirSync(e){try{return fs.readdirSync(e)}catch(e){return[]}}function getFirst(e,t){var n=readdirSync(e).filter(t);return n[0]&&path.join(e,n[0])}function matchBuild(e){return/\.node$/.test(e)}function parseTuple(e){var t=e.split("-");if(t.length!==2)return;var n=t[0];var r=t[1].split("+");if(!n)return;if(!r.length)return;if(!r.every(Boolean))return;return{name:e,platform:n,architectures:r}}function matchTuple(e,t){return function(n){if(n==null)return false;if(n.platform!==e)return false;return n.architectures.includes(t)}}function compareTuples(e,t){return e.architectures.length-t.architectures.length}function parseTags(e){var t=e.split(".");var n=t.pop();var r={file:e,specificity:0};if(n!=="node")return;for(var i=0;i<t.length;i++){var a=t[i];if(a==="node"||a==="electron"||a==="node-webkit"){r.runtime=a}else if(a==="napi"){r.napi=true}else if(a.slice(0,3)==="abi"){r.abi=a.slice(3)}else if(a.slice(0,2)==="uv"){r.uv=a.slice(2)}else if(a.slice(0,4)==="armv"){r.armv=a.slice(4)}else if(a==="glibc"||a==="musl"){r.libc=a}else{continue}r.specificity++}return r}function matchTags(e,t){return function(n){if(n==null)return false;if(n.runtime!==e&&!runtimeAgnostic(n))return false;if(n.abi!==t&&!n.napi)return false;if(n.uv&&n.uv!==uv)return false;if(n.armv&&n.armv!==armv)return false;if(n.libc&&n.libc!==libc)return false;return true}}function runtimeAgnostic(e){return e.runtime==="node"&&e.napi}function compareTags(e){return function(t,n){if(t.runtime!==n.runtime){return t.runtime===e?-1:1}else if(t.abi!==n.abi){return t.abi?-1:1}else if(t.specificity!==n.specificity){return t.specificity>n.specificity?-1:1}else{return 0}}}function isNwjs(){return!!(process.versions&&process.versions.nw)}function isElectron(){if(process.versions&&process.versions.electron)return true;if(process.env.ELECTRON_RUN_AS_NODE)return true;return typeof window!=="undefined"&&window.process&&window.process.type==="renderer"}function isMusl(e){if(e!=="linux")return false;const{familySync:t,MUSL:n}=__nccwpck_require__(9054);return t()===n}load.parseTags=parseTags;load.matchTags=matchTags;load.compareTags=compareTags;load.parseTuple=parseTuple;load.matchTuple=matchTuple;load.compareTuples=compareTuples},8287:function(e,t,n){"use strict";const r=process.version.charCodeAt(1)<55&&process.version.charCodeAt(2)===46?n(3554):n(4144);e.exports=r},4144:function(e,t,n){"use strict";const r=n(2613);class RedisError extends Error{get name(){return this.constructor.name}}class ParserError extends RedisError{constructor(e,t,n){r(t);r.strictEqual(typeof n,"number");const i=Error.stackTraceLimit;Error.stackTraceLimit=2;super(e);Error.stackTraceLimit=i;this.offset=n;this.buffer=t}get name(){return this.constructor.name}}class ReplyError extends RedisError{constructor(e){const t=Error.stackTraceLimit;Error.stackTraceLimit=2;super(e);Error.stackTraceLimit=t}get name(){return this.constructor.name}}class AbortError extends RedisError{get name(){return this.constructor.name}}class InterruptError extends AbortError{get name(){return this.constructor.name}}e.exports={RedisError:RedisError,ParserError:ParserError,ReplyError:ReplyError,AbortError:AbortError,InterruptError:InterruptError}},3554:function(e,t,n){"use strict";const r=n(2613);const i=n(9023);function RedisError(e){Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});Error.captureStackTrace(this,this.constructor)}i.inherits(RedisError,Error);Object.defineProperty(RedisError.prototype,"name",{value:"RedisError",configurable:true,writable:true});function ParserError(e,t,n){r(t);r.strictEqual(typeof n,"number");Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});const i=Error.stackTraceLimit;Error.stackTraceLimit=2;Error.captureStackTrace(this,this.constructor);Error.stackTraceLimit=i;this.offset=n;this.buffer=t}i.inherits(ParserError,RedisError);Object.defineProperty(ParserError.prototype,"name",{value:"ParserError",configurable:true,writable:true});function ReplyError(e){Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});const t=Error.stackTraceLimit;Error.stackTraceLimit=2;Error.captureStackTrace(this,this.constructor);Error.stackTraceLimit=t}i.inherits(ReplyError,RedisError);Object.defineProperty(ReplyError.prototype,"name",{value:"ReplyError",configurable:true,writable:true});function AbortError(e){Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});Error.captureStackTrace(this,this.constructor)}i.inherits(AbortError,RedisError);Object.defineProperty(AbortError.prototype,"name",{value:"AbortError",configurable:true,writable:true});function InterruptError(e){Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});Error.captureStackTrace(this,this.constructor)}i.inherits(InterruptError,AbortError);Object.defineProperty(InterruptError.prototype,"name",{value:"InterruptError",configurable:true,writable:true});e.exports={RedisError:RedisError,ParserError:ParserError,ReplyError:ReplyError,AbortError:AbortError,InterruptError:InterruptError}},9751:function(e,t,n){"use strict";e.exports=n(4072)},4072:function(e,t,n){"use strict";const r=n(181).Buffer;const i=n(3193).StringDecoder;const a=new i;const s=n(8287);const o=s.ReplyError;const l=s.ParserError;var c=r.allocUnsafe(32*1024);var d=0;var u=null;var p=0;var f=0;function parseSimpleNumbers(e){const t=e.buffer.length-1;var n=e.offset;var r=0;var i=1;if(e.buffer[n]===45){i=-1;n++}while(n<t){const t=e.buffer[n++];if(t===13){e.offset=n+1;return i*r}r=r*10+(t-48)}}function parseStringNumbers(e){const t=e.buffer.length-1;var n=e.offset;var r=0;var i="";if(e.buffer[n]===45){i+="-";n++}while(n<t){var a=e.buffer[n++];if(a===13){e.offset=n+1;if(r!==0){i+=r}return i}else if(r>429496728){i+=r*10+(a-48);r=0}else if(a===48&&r===0){i+=0}else{r=r*10+(a-48)}}}function parseSimpleString(e){const t=e.offset;const n=e.buffer;const r=n.length-1;var i=t;while(i<r){if(n[i++]===13){e.offset=i+1;if(e.optionReturnBuffers===true){return e.buffer.slice(t,i-1)}return e.buffer.toString("utf8",t,i-1)}}}function parseLength(e){const t=e.buffer.length-1;var n=e.offset;var r=0;while(n<t){const t=e.buffer[n++];if(t===13){e.offset=n+1;return r}r=r*10+(t-48)}}function parseInteger(e){if(e.optionStringNumbers===true){return parseStringNumbers(e)}return parseSimpleNumbers(e)}function parseBulkString(e){const t=parseLength(e);if(t===undefined){return}if(t<0){return null}const n=e.offset+t;if(n+2>e.buffer.length){e.bigStrSize=n+2;e.totalChunkSize=e.buffer.length;e.bufferCache.push(e.buffer);return}const r=e.offset;e.offset=n+2;if(e.optionReturnBuffers===true){return e.buffer.slice(r,n)}return e.buffer.toString("utf8",r,n)}function parseError(e){var t=parseSimpleString(e);if(t!==undefined){if(e.optionReturnBuffers===true){t=t.toString()}return new o(t)}}function handleError(e,t){const n=new l("Protocol error, got "+JSON.stringify(String.fromCharCode(t))+" as reply type byte",JSON.stringify(e.buffer),e.offset);e.buffer=null;e.returnFatalError(n)}function parseArray(e){const t=parseLength(e);if(t===undefined){return}if(t<0){return null}const n=new Array(t);return parseArrayElements(e,n,0)}function pushArrayCache(e,t,n){e.arrayCache.push(t);e.arrayPos.push(n)}function parseArrayChunks(e){const t=e.arrayCache.pop();var n=e.arrayPos.pop();if(e.arrayCache.length){const r=parseArrayChunks(e);if(r===undefined){pushArrayCache(e,t,n);return}t[n++]=r}return parseArrayElements(e,t,n)}function parseArrayElements(e,t,n){const r=e.buffer.length;while(n<t.length){const i=e.offset;if(e.offset>=r){pushArrayCache(e,t,n);return}const a=parseType(e,e.buffer[e.offset++]);if(a===undefined){if(!(e.arrayCache.length||e.bufferCache.length)){e.offset=i}pushArrayCache(e,t,n);return}t[n]=a;n++}return t}function parseType(e,t){switch(t){case 36:return parseBulkString(e);case 43:return parseSimpleString(e);case 42:return parseArray(e);case 58:return parseInteger(e);case 45:return parseError(e);default:return handleError(e,t)}}function decreaseBufferPool(){if(c.length>50*1024){if(p===1||f>p*2){const e=Math.floor(c.length/10);const t=e<d?d:e;d=0;c=c.slice(t,c.length)}else{f++;p--}}else{clearInterval(u);p=0;f=0;u=null}}function resizeBuffer(e){if(c.length<e+d){const t=e>1024*1024*75?2:3;if(d>1024*1024*111){d=1024*1024*50}c=r.allocUnsafe(e*t+d);d=0;p++;if(u===null){u=setInterval(decreaseBufferPool,50)}}}function concatBulkString(e){const t=e.bufferCache;const n=e.offset;var r=t.length;var i=e.bigStrSize-e.totalChunkSize;e.offset=i;if(i<=2){if(r===2){return t[0].toString("utf8",n,t[0].length+i-2)}r--;i=t[t.length-2].length+i}var s=a.write(t[0].slice(n));for(var o=1;o<r-1;o++){s+=a.write(t[o])}s+=a.end(t[o].slice(0,i-2));return s}function concatBulkBuffer(e){const t=e.bufferCache;const n=e.offset;const r=e.bigStrSize-n-2;var i=t.length;var a=e.bigStrSize-e.totalChunkSize;e.offset=a;if(a<=2){if(i===2){return t[0].slice(n,t[0].length+a-2)}i--;a=t[t.length-2].length+a}resizeBuffer(r);const s=d;t[0].copy(c,s,n,t[0].length);d+=t[0].length-n;for(var o=1;o<i-1;o++){t[o].copy(c,d);d+=t[o].length}t[o].copy(c,d,0,a-2);d+=a-2;return c.slice(s,d)}class JavascriptRedisParser{constructor(e){if(!e){throw new TypeError("Options are mandatory.")}if(typeof e.returnError!=="function"||typeof e.returnReply!=="function"){throw new TypeError("The returnReply and returnError options have to be functions.")}this.setReturnBuffers(!!e.returnBuffers);this.setStringNumbers(!!e.stringNumbers);this.returnError=e.returnError;this.returnFatalError=e.returnFatalError||e.returnError;this.returnReply=e.returnReply;this.reset()}reset(){this.offset=0;this.buffer=null;this.bigStrSize=0;this.totalChunkSize=0;this.bufferCache=[];this.arrayCache=[];this.arrayPos=[]}setReturnBuffers(e){if(typeof e!=="boolean"){throw new TypeError("The returnBuffers argument has to be a boolean")}this.optionReturnBuffers=e}setStringNumbers(e){if(typeof e!=="boolean"){throw new TypeError("The stringNumbers argument has to be a boolean")}this.optionStringNumbers=e}execute(e){if(this.buffer===null){this.buffer=e;this.offset=0}else if(this.bigStrSize===0){const t=this.buffer.length;const n=t-this.offset;const i=r.allocUnsafe(n+e.length);this.buffer.copy(i,0,this.offset,t);e.copy(i,n,0,e.length);this.buffer=i;this.offset=0;if(this.arrayCache.length){const e=parseArrayChunks(this);if(e===undefined){return}this.returnReply(e)}}else if(this.totalChunkSize+e.length>=this.bigStrSize){this.bufferCache.push(e);var t=this.optionReturnBuffers?concatBulkBuffer(this):concatBulkString(this);this.bigStrSize=0;this.bufferCache=[];this.buffer=e;if(this.arrayCache.length){this.arrayCache[0][this.arrayPos[0]++]=t;t=parseArrayChunks(this);if(t===undefined){return}}this.returnReply(t)}else{this.bufferCache.push(e);this.totalChunkSize+=e.length;return}while(this.offset<this.buffer.length){const e=this.offset;const t=this.buffer[this.offset++];const n=parseType(this,t);if(n===undefined){if(!(this.arrayCache.length||this.bufferCache.length)){this.offset=e}return}if(t===45){this.returnError(n)}else{this.returnReply(n)}}this.buffer=null}}e.exports=JavascriptRedisParser},863:function(e,t,n){"use strict";const r=Symbol("SemVer ANY");class Comparator{static get ANY(){return r}constructor(e,t){t=i(t);if(e instanceof Comparator){if(e.loose===!!t.loose){return e}else{e=e.value}}e=e.trim().split(/\s+/).join(" ");l("comparator",e,t);this.options=t;this.loose=!!t.loose;this.parse(e);if(this.semver===r){this.value=""}else{this.value=this.operator+this.semver.version}l("comp",this)}parse(e){const t=this.options.loose?a[s.COMPARATORLOOSE]:a[s.COMPARATOR];const n=e.match(t);if(!n){throw new TypeError(`Invalid comparator: ${e}`)}this.operator=n[1]!==undefined?n[1]:"";if(this.operator==="="){this.operator=""}if(!n[2]){this.semver=r}else{this.semver=new c(n[2],this.options.loose)}}toString(){return this.value}test(e){l("Comparator.test",e,this.options.loose);if(this.semver===r||e===r){return true}if(typeof e==="string"){try{e=new c(e,this.options)}catch(e){return false}}return o(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof Comparator)){throw new TypeError("a Comparator is required")}if(this.operator===""){if(this.value===""){return true}return new d(e.value,t).test(this.value)}else if(e.operator===""){if(e.value===""){return true}return new d(this.value,t).test(e.semver)}t=i(t);if(t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")){return false}if(!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))){return false}if(this.operator.startsWith(">")&&e.operator.startsWith(">")){return true}if(this.operator.startsWith("<")&&e.operator.startsWith("<")){return true}if(this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")){return true}if(o(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<")){return true}if(o(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")){return true}return false}}e.exports=Comparator;const i=n(2600);const{safeRe:a,t:s}=n(6211);const o=n(5618);const l=n(7611);const c=n(4839);const d=n(8474)},8474:function(e,t,n){"use strict";const r=/\s+/g;class Range{constructor(e,t){t=s(t);if(e instanceof Range){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease){return e}else{return new Range(e.raw,t)}}if(e instanceof o){this.raw=e.value;this.set=[[e]];this.formatted=undefined;return this}this.options=t;this.loose=!!t.loose;this.includePrerelease=!!t.includePrerelease;this.raw=e.trim().replace(r," ");this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length));if(!this.set.length){throw new TypeError(`Invalid SemVer Range: ${this.raw}`)}if(this.set.length>1){const e=this.set[0];this.set=this.set.filter((e=>!isNullSet(e[0])));if(this.set.length===0){this.set=[e]}else if(this.set.length>1){for(const e of this.set){if(e.length===1&&isAny(e[0])){this.set=[e];break}}}}this.formatted=undefined}get range(){if(this.formatted===undefined){this.formatted="";for(let e=0;e<this.set.length;e++){if(e>0){this.formatted+="||"}const t=this.set[e];for(let e=0;e<t.length;e++){if(e>0){this.formatted+=" "}this.formatted+=t[e].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=(this.options.includePrerelease&&y)|(this.options.loose&&m);const n=t+":"+e;const r=a.get(n);if(r){return r}const i=this.options.loose;const s=i?d[u.HYPHENRANGELOOSE]:d[u.HYPHENRANGE];e=e.replace(s,hyphenReplace(this.options.includePrerelease));l("hyphen replace",e);e=e.replace(d[u.COMPARATORTRIM],p);l("comparator trim",e);e=e.replace(d[u.TILDETRIM],f);l("tilde trim",e);e=e.replace(d[u.CARETTRIM],h);l("caret trim",e);let c=e.split(" ").map((e=>parseComparator(e,this.options))).join(" ").split(/\s+/).map((e=>replaceGTE0(e,this.options)));if(i){c=c.filter((e=>{l("loose invalid filter",e,this.options);return!!e.match(d[u.COMPARATORLOOSE])}))}l("range list",c);const b=new Map;const g=c.map((e=>new o(e,this.options)));for(const e of g){if(isNullSet(e)){return[e]}b.set(e.value,e)}if(b.size>1&&b.has("")){b.delete("")}const v=[...b.values()];a.set(n,v);return v}intersects(e,t){if(!(e instanceof Range)){throw new TypeError("a Range is required")}return this.set.some((n=>isSatisfiable(n,t)&&e.set.some((e=>isSatisfiable(e,t)&&n.every((n=>e.every((e=>n.intersects(e,t)))))))))}test(e){if(!e){return false}if(typeof e==="string"){try{e=new c(e,this.options)}catch(e){return false}}for(let t=0;t<this.set.length;t++){if(testSet(this.set[t],e,this.options)){return true}}return false}}e.exports=Range;const i=n(2443);const a=new i;const s=n(2600);const o=n(863);const l=n(7611);const c=n(4839);const{safeRe:d,t:u,comparatorTrimReplace:p,tildeTrimReplace:f,caretTrimReplace:h}=n(6211);const{FLAG_INCLUDE_PRERELEASE:y,FLAG_LOOSE:m}=n(4329);const isNullSet=e=>e.value==="<0.0.0-0";const isAny=e=>e.value==="";const isSatisfiable=(e,t)=>{let n=true;const r=e.slice();let i=r.pop();while(n&&r.length){n=r.every((e=>i.intersects(e,t)));i=r.pop()}return n};const parseComparator=(e,t)=>{l("comp",e,t);e=replaceCarets(e,t);l("caret",e);e=replaceTildes(e,t);l("tildes",e);e=replaceXRanges(e,t);l("xrange",e);e=replaceStars(e,t);l("stars",e);return e};const isX=e=>!e||e.toLowerCase()==="x"||e==="*";const replaceTildes=(e,t)=>e.trim().split(/\s+/).map((e=>replaceTilde(e,t))).join(" ");const replaceTilde=(e,t)=>{const n=t.loose?d[u.TILDELOOSE]:d[u.TILDE];return e.replace(n,((t,n,r,i,a)=>{l("tilde",e,t,n,r,i,a);let s;if(isX(n)){s=""}else if(isX(r)){s=`>=${n}.0.0 <${+n+1}.0.0-0`}else if(isX(i)){s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`}else if(a){l("replaceTilde pr",a);s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`}else{s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`}l("tilde return",s);return s}))};const replaceCarets=(e,t)=>e.trim().split(/\s+/).map((e=>replaceCaret(e,t))).join(" ");const replaceCaret=(e,t)=>{l("caret",e,t);const n=t.loose?d[u.CARETLOOSE]:d[u.CARET];const r=t.includePrerelease?"-0":"";return e.replace(n,((t,n,i,a,s)=>{l("caret",e,t,n,i,a,s);let o;if(isX(n)){o=""}else if(isX(i)){o=`>=${n}.0.0${r} <${+n+1}.0.0-0`}else if(isX(a)){if(n==="0"){o=`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`}else{o=`>=${n}.${i}.0${r} <${+n+1}.0.0-0`}}else if(s){l("replaceCaret pr",s);if(n==="0"){if(i==="0"){o=`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`}else{o=`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`}}else{o=`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`}}else{l("no pr");if(n==="0"){if(i==="0"){o=`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`}else{o=`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`}}else{o=`>=${n}.${i}.${a} <${+n+1}.0.0-0`}}l("caret return",o);return o}))};const replaceXRanges=(e,t)=>{l("replaceXRanges",e,t);return e.split(/\s+/).map((e=>replaceXRange(e,t))).join(" ")};const replaceXRange=(e,t)=>{e=e.trim();const n=t.loose?d[u.XRANGELOOSE]:d[u.XRANGE];return e.replace(n,((n,r,i,a,s,o)=>{l("xRange",e,n,r,i,a,s,o);const c=isX(i);const d=c||isX(a);const u=d||isX(s);const p=u;if(r==="="&&p){r=""}o=t.includePrerelease?"-0":"";if(c){if(r===">"||r==="<"){n="<0.0.0-0"}else{n="*"}}else if(r&&p){if(d){a=0}s=0;if(r===">"){r=">=";if(d){i=+i+1;a=0;s=0}else{a=+a+1;s=0}}else if(r==="<="){r="<";if(d){i=+i+1}else{a=+a+1}}if(r==="<"){o="-0"}n=`${r+i}.${a}.${s}${o}`}else if(d){n=`>=${i}.0.0${o} <${+i+1}.0.0-0`}else if(u){n=`>=${i}.${a}.0${o} <${i}.${+a+1}.0-0`}l("xRange return",n);return n}))};const replaceStars=(e,t)=>{l("replaceStars",e,t);return e.trim().replace(d[u.STAR],"")};const replaceGTE0=(e,t)=>{l("replaceGTE0",e,t);return e.trim().replace(d[t.includePrerelease?u.GTE0PRE:u.GTE0],"")};const hyphenReplace=e=>(t,n,r,i,a,s,o,l,c,d,u,p)=>{if(isX(r)){n=""}else if(isX(i)){n=`>=${r}.0.0${e?"-0":""}`}else if(isX(a)){n=`>=${r}.${i}.0${e?"-0":""}`}else if(s){n=`>=${n}`}else{n=`>=${n}${e?"-0":""}`}if(isX(c)){l=""}else if(isX(d)){l=`<${+c+1}.0.0-0`}else if(isX(u)){l=`<${c}.${+d+1}.0-0`}else if(p){l=`<=${c}.${d}.${u}-${p}`}else if(e){l=`<${c}.${d}.${+u+1}-0`}else{l=`<=${l}`}return`${n} ${l}`.trim()};const testSet=(e,t,n)=>{for(let n=0;n<e.length;n++){if(!e[n].test(t)){return false}}if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++){l(e[n].semver);if(e[n].semver===o.ANY){continue}if(e[n].semver.prerelease.length>0){const r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch){return true}}}return false}return true}},4839:function(e,t,n){"use strict";const r=n(7611);const{MAX_LENGTH:i,MAX_SAFE_INTEGER:a}=n(4329);const{safeRe:s,t:o}=n(6211);const l=n(2600);const{compareIdentifiers:c}=n(6104);class SemVer{constructor(e,t){t=l(t);if(e instanceof SemVer){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease){return e}else{e=e.version}}else if(typeof e!=="string"){throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`)}if(e.length>i){throw new TypeError(`version is longer than ${i} characters`)}r("SemVer",e,t);this.options=t;this.loose=!!t.loose;this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?s[o.LOOSE]:s[o.FULL]);if(!n){throw new TypeError(`Invalid Version: ${e}`)}this.raw=e;this.major=+n[1];this.minor=+n[2];this.patch=+n[3];if(this.major>a||this.major<0){throw new TypeError("Invalid major version")}if(this.minor>a||this.minor<0){throw new TypeError("Invalid minor version")}if(this.patch>a||this.patch<0){throw new TypeError("Invalid patch version")}if(!n[4]){this.prerelease=[]}else{this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<a){return t}}return e}))}this.build=n[5]?n[5].split("."):[];this.format()}format(){this.version=`${this.major}.${this.minor}.${this.patch}`;if(this.prerelease.length){this.version+=`-${this.prerelease.join(".")}`}return this.version}toString(){return this.version}compare(e){r("SemVer.compare",this.version,this.options,e);if(!(e instanceof SemVer)){if(typeof e==="string"&&e===this.version){return 0}e=new SemVer(e,this.options)}if(e.version===this.version){return 0}return this.compareMain(e)||this.comparePre(e)}compareMain(e){if(!(e instanceof SemVer)){e=new SemVer(e,this.options)}return c(this.major,e.major)||c(this.minor,e.minor)||c(this.patch,e.patch)}comparePre(e){if(!(e instanceof SemVer)){e=new SemVer(e,this.options)}if(this.prerelease.length&&!e.prerelease.length){return-1}else if(!this.prerelease.length&&e.prerelease.length){return 1}else if(!this.prerelease.length&&!e.prerelease.length){return 0}let t=0;do{const n=this.prerelease[t];const i=e.prerelease[t];r("prerelease compare",t,n,i);if(n===undefined&&i===undefined){return 0}else if(i===undefined){return 1}else if(n===undefined){return-1}else if(n===i){continue}else{return c(n,i)}}while(++t)}compareBuild(e){if(!(e instanceof SemVer)){e=new SemVer(e,this.options)}let t=0;do{const n=this.build[t];const i=e.build[t];r("build compare",t,n,i);if(n===undefined&&i===undefined){return 0}else if(i===undefined){return 1}else if(n===undefined){return-1}else if(n===i){continue}else{return c(n,i)}}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&n===false){throw new Error("invalid increment argument: identifier is empty")}if(t){const e=`-${t}`.match(this.options.loose?s[o.PRERELEASELOOSE]:s[o.PRERELEASE]);if(!e||e[1]!==t){throw new Error(`invalid identifier: ${t}`)}}}switch(e){case"premajor":this.prerelease.length=0;this.patch=0;this.minor=0;this.major++;this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0;this.patch=0;this.minor++;this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0;this.inc("patch",t,n);this.inc("pre",t,n);break;case"prerelease":if(this.prerelease.length===0){this.inc("patch",t,n)}this.inc("pre",t,n);break;case"release":if(this.prerelease.length===0){throw new Error(`version ${this.raw} is not a prerelease`)}this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0){this.major++}this.minor=0;this.patch=0;this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0){this.minor++}this.patch=0;this.prerelease=[];break;case"patch":if(this.prerelease.length===0){this.patch++}this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(this.prerelease.length===0){this.prerelease=[e]}else{let r=this.prerelease.length;while(--r>=0){if(typeof this.prerelease[r]==="number"){this.prerelease[r]++;r=-2}}if(r===-1){if(t===this.prerelease.join(".")&&n===false){throw new Error("invalid increment argument: identifier already exists")}this.prerelease.push(e)}}if(t){let r=[t,e];if(n===false){r=[t]}if(c(this.prerelease[0],t)===0){if(isNaN(this.prerelease[1])){this.prerelease=r}}else{this.prerelease=r}}break}default:throw new Error(`invalid increment argument: ${e}`)}this.raw=this.format();if(this.build.length){this.raw+=`+${this.build.join(".")}`}return this}}e.exports=SemVer},2771:function(e,t,n){"use strict";const r=n(893);const clean=(e,t)=>{const n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null};e.exports=clean},5618:function(e,t,n){"use strict";const r=n(5630);const i=n(3282);const a=n(5283);const s=n(6064);const o=n(6108);const l=n(3353);const cmp=(e,t,n,c)=>{switch(t){case"===":if(typeof e==="object"){e=e.version}if(typeof n==="object"){n=n.version}return e===n;case"!==":if(typeof e==="object"){e=e.version}if(typeof n==="object"){n=n.version}return e!==n;case"":case"=":case"==":return r(e,n,c);case"!=":return i(e,n,c);case">":return a(e,n,c);case">=":return s(e,n,c);case"<":return o(e,n,c);case"<=":return l(e,n,c);default:throw new TypeError(`Invalid operator: ${t}`)}};e.exports=cmp},3597:function(e,t,n){"use strict";const r=n(4839);const i=n(893);const{safeRe:a,t:s}=n(6211);const coerce=(e,t)=>{if(e instanceof r){return e}if(typeof e==="number"){e=String(e)}if(typeof e!=="string"){return null}t=t||{};let n=null;if(!t.rtl){n=e.match(t.includePrerelease?a[s.COERCEFULL]:a[s.COERCE])}else{const r=t.includePrerelease?a[s.COERCERTLFULL]:a[s.COERCERTL];let i;while((i=r.exec(e))&&(!n||n.index+n[0].length!==e.length)){if(!n||i.index+i[0].length!==n.index+n[0].length){n=i}r.lastIndex=i.index+i[1].length+i[2].length}r.lastIndex=-1}if(n===null){return null}const o=n[2];const l=n[3]||"0";const c=n[4]||"0";const d=t.includePrerelease&&n[5]?`-${n[5]}`:"";const u=t.includePrerelease&&n[6]?`+${n[6]}`:"";return i(`${o}.${l}.${c}${d}${u}`,t)};e.exports=coerce},3932:function(e,t,n){"use strict";const r=n(4839);const compareBuild=(e,t,n)=>{const i=new r(e,n);const a=new r(t,n);return i.compare(a)||i.compareBuild(a)};e.exports=compareBuild},9822:function(e,t,n){"use strict";const r=n(6625);const compareLoose=(e,t)=>r(e,t,true);e.exports=compareLoose},6625:function(e,t,n){"use strict";const r=n(4839);const compare=(e,t,n)=>new r(e,n).compare(new r(t,n));e.exports=compare},1531:function(e,t,n){"use strict";const r=n(893);const diff=(e,t)=>{const n=r(e,null,true);const i=r(t,null,true);const a=n.compare(i);if(a===0){return null}const s=a>0;const o=s?n:i;const l=s?i:n;const c=!!o.prerelease.length;const d=!!l.prerelease.length;if(d&&!c){if(!l.patch&&!l.minor){return"major"}if(l.compareMain(o)===0){if(l.minor&&!l.patch){return"minor"}return"patch"}}const u=c?"pre":"";if(n.major!==i.major){return u+"major"}if(n.minor!==i.minor){return u+"minor"}if(n.patch!==i.patch){return u+"patch"}return"prerelease"};e.exports=diff},5630:function(e,t,n){"use strict";const r=n(6625);const eq=(e,t,n)=>r(e,t,n)===0;e.exports=eq},5283:function(e,t,n){"use strict";const r=n(6625);const gt=(e,t,n)=>r(e,t,n)>0;e.exports=gt},6064:function(e,t,n){"use strict";const r=n(6625);const gte=(e,t,n)=>r(e,t,n)>=0;e.exports=gte},2782:function(e,t,n){"use strict";const r=n(4839);const inc=(e,t,n,i,a)=>{if(typeof n==="string"){a=i;i=n;n=undefined}try{return new r(e instanceof r?e.version:e,n).inc(t,i,a).version}catch(e){return null}};e.exports=inc},6108:function(e,t,n){"use strict";const r=n(6625);const lt=(e,t,n)=>r(e,t,n)<0;e.exports=lt},3353:function(e,t,n){"use strict";const r=n(6625);const lte=(e,t,n)=>r(e,t,n)<=0;e.exports=lte},5251:function(e,t,n){"use strict";const r=n(4839);const major=(e,t)=>new r(e,t).major;e.exports=major},5479:function(e,t,n){"use strict";const r=n(4839);const minor=(e,t)=>new r(e,t).minor;e.exports=minor},3282:function(e,t,n){"use strict";const r=n(6625);const neq=(e,t,n)=>r(e,t,n)!==0;e.exports=neq},893:function(e,t,n){"use strict";const r=n(4839);const parse=(e,t,n=false)=>{if(e instanceof r){return e}try{return new r(e,t)}catch(e){if(!n){return null}throw e}};e.exports=parse},7056:function(e,t,n){"use strict";const r=n(4839);const patch=(e,t)=>new r(e,t).patch;e.exports=patch},390:function(e,t,n){"use strict";const r=n(893);const prerelease=(e,t)=>{const n=r(e,t);return n&&n.prerelease.length?n.prerelease:null};e.exports=prerelease},9729:function(e,t,n){"use strict";const r=n(6625);const rcompare=(e,t,n)=>r(t,e,n);e.exports=rcompare},8828:function(e,t,n){"use strict";const r=n(3932);const rsort=(e,t)=>e.sort(((e,n)=>r(n,e,t)));e.exports=rsort},2132:function(e,t,n){"use strict";const r=n(8474);const satisfies=(e,t,n)=>{try{t=new r(t,n)}catch(e){return false}return t.test(e)};e.exports=satisfies},6476:function(e,t,n){"use strict";const r=n(3932);const sort=(e,t)=>e.sort(((e,n)=>r(e,n,t)));e.exports=sort},5752:function(e,t,n){"use strict";const r=n(893);const valid=(e,t)=>{const n=r(e,t);return n?n.version:null};e.exports=valid},2348:function(e,t,n){"use strict";const r=n(6211);const i=n(4329);const a=n(4839);const s=n(6104);const o=n(893);const l=n(5752);const c=n(2771);const d=n(2782);const u=n(1531);const p=n(5251);const f=n(5479);const h=n(7056);const y=n(390);const m=n(6625);const b=n(9729);const g=n(9822);const v=n(3932);const K=n(6476);const S=n(8828);const E=n(5283);const k=n(6108);const I=n(5630);const w=n(3282);const j=n(6064);const x=n(3353);const T=n(5618);const D=n(3597);const O=n(863);const C=n(8474);const A=n(2132);const R=n(2258);const P=n(9269);const M=n(1367);const _=n(6950);const N=n(8733);const L=n(4772);const J=n(712);const F=n(5585);const V=n(1357);const q=n(7344);const G=n(4837);e.exports={parse:o,valid:l,clean:c,inc:d,diff:u,major:p,minor:f,patch:h,prerelease:y,compare:m,rcompare:b,compareLoose:g,compareBuild:v,sort:K,rsort:S,gt:E,lt:k,eq:I,neq:w,gte:j,lte:x,cmp:T,coerce:D,Comparator:O,Range:C,satisfies:A,toComparators:R,maxSatisfying:P,minSatisfying:M,minVersion:_,validRange:N,outside:L,gtr:J,ltr:F,intersects:V,simplifyRange:q,subset:G,SemVer:a,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers}},4329:function(e){"use strict";const t="2.0.0";const n=256;const r=Number.MAX_SAFE_INTEGER||9007199254740991;const i=16;const a=n-6;const s=["major","premajor","minor","preminor","patch","prepatch","prerelease"];e.exports={MAX_LENGTH:n,MAX_SAFE_COMPONENT_LENGTH:i,MAX_SAFE_BUILD_LENGTH:a,MAX_SAFE_INTEGER:r,RELEASE_TYPES:s,SEMVER_SPEC_VERSION:t,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},7611:function(e){"use strict";const t=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},6104:function(e){"use strict";const t=/^[0-9]+$/;const compareIdentifiers=(e,n)=>{const r=t.test(e);const i=t.test(n);if(r&&i){e=+e;n=+n}return e===n?0:r&&!i?-1:i&&!r?1:e<n?-1:1};const rcompareIdentifiers=(e,t)=>compareIdentifiers(t,e);e.exports={compareIdentifiers:compareIdentifiers,rcompareIdentifiers:rcompareIdentifiers}},2443:function(e){"use strict";class LRUCache{constructor(){this.max=1e3;this.map=new Map}get(e){const t=this.map.get(e);if(t===undefined){return undefined}else{this.map.delete(e);this.map.set(e,t);return t}}delete(e){return this.map.delete(e)}set(e,t){const n=this.delete(e);if(!n&&t!==undefined){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}e.exports=LRUCache},2600:function(e){"use strict";const t=Object.freeze({loose:true});const n=Object.freeze({});const parseOptions=e=>{if(!e){return n}if(typeof e!=="object"){return t}return e};e.exports=parseOptions},6211:function(e,t,n){"use strict";const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:a}=n(4329);const s=n(7611);t=e.exports={};const o=t.re=[];const l=t.safeRe=[];const c=t.src=[];const d=t.safeSrc=[];const u=t.t={};let p=0;const f="[a-zA-Z0-9-]";const h=[["\\s",1],["\\d",a],[f,i]];const makeSafeRegex=e=>{for(const[t,n]of h){e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`)}return e};const createToken=(e,t,n)=>{const r=makeSafeRegex(t);const i=p++;s(e,i,t);u[e]=i;c[i]=t;d[i]=r;o[i]=new RegExp(t,n?"g":undefined);l[i]=new RegExp(r,n?"g":undefined)};createToken("NUMERICIDENTIFIER","0|[1-9]\\d*");createToken("NUMERICIDENTIFIERLOOSE","\\d+");createToken("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`);createToken("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.`+`(${c[u.NUMERICIDENTIFIER]})\\.`+`(${c[u.NUMERICIDENTIFIER]})`);createToken("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.`+`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.`+`(${c[u.NUMERICIDENTIFIERLOOSE]})`);createToken("PRERELEASEIDENTIFIER",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`);createToken("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`);createToken("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`);createToken("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`);createToken("BUILDIDENTIFIER",`${f}+`);createToken("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`);createToken("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`);createToken("FULL",`^${c[u.FULLPLAIN]}$`);createToken("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`);createToken("LOOSE",`^${c[u.LOOSEPLAIN]}$`);createToken("GTLT","((?:<|>)?=?)");createToken("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);createToken("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`);createToken("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})`+`(?:\\.(${c[u.XRANGEIDENTIFIER]})`+`(?:\\.(${c[u.XRANGEIDENTIFIER]})`+`(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?`+`)?)?`);createToken("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})`+`(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})`+`(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})`+`(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?`+`)?)?`);createToken("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`);createToken("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`);createToken("COERCEPLAIN",`${"(^|[^\\d])"+"(\\d{1,"}${r}})`+`(?:\\.(\\d{1,${r}}))?`+`(?:\\.(\\d{1,${r}}))?`);createToken("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`);createToken("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?`+`(?:${c[u.BUILD]})?`+`(?:$|[^\\d])`);createToken("COERCERTL",c[u.COERCE],true);createToken("COERCERTLFULL",c[u.COERCEFULL],true);createToken("LONETILDE","(?:~>?)");createToken("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,true);t.tildeTrimReplace="$1~";createToken("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`);createToken("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`);createToken("LONECARET","(?:\\^)");createToken("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,true);t.caretTrimReplace="$1^";createToken("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`);createToken("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`);createToken("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`);createToken("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`);createToken("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,true);t.comparatorTrimReplace="$1$2$3";createToken("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})`+`\\s+-\\s+`+`(${c[u.XRANGEPLAIN]})`+`\\s*$`);createToken("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})`+`\\s+-\\s+`+`(${c[u.XRANGEPLAINLOOSE]})`+`\\s*$`);createToken("STAR","(<|>)?=?\\s*\\*");createToken("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");createToken("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},712:function(e,t,n){"use strict";const r=n(4772);const gtr=(e,t,n)=>r(e,t,">",n);e.exports=gtr},1357:function(e,t,n){"use strict";const r=n(8474);const intersects=(e,t,n)=>{e=new r(e,n);t=new r(t,n);return e.intersects(t,n)};e.exports=intersects},5585:function(e,t,n){"use strict";const r=n(4772);const ltr=(e,t,n)=>r(e,t,"<",n);e.exports=ltr},9269:function(e,t,n){"use strict";const r=n(4839);const i=n(8474);const maxSatisfying=(e,t,n)=>{let a=null;let s=null;let o=null;try{o=new i(t,n)}catch(e){return null}e.forEach((e=>{if(o.test(e)){if(!a||s.compare(e)===-1){a=e;s=new r(a,n)}}}));return a};e.exports=maxSatisfying},1367:function(e,t,n){"use strict";const r=n(4839);const i=n(8474);const minSatisfying=(e,t,n)=>{let a=null;let s=null;let o=null;try{o=new i(t,n)}catch(e){return null}e.forEach((e=>{if(o.test(e)){if(!a||s.compare(e)===1){a=e;s=new r(a,n)}}}));return a};e.exports=minSatisfying},6950:function(e,t,n){"use strict";const r=n(4839);const i=n(8474);const a=n(5283);const minVersion=(e,t)=>{e=new i(e,t);let n=new r("0.0.0");if(e.test(n)){return n}n=new r("0.0.0-0");if(e.test(n)){return n}n=null;for(let t=0;t<e.set.length;++t){const i=e.set[t];let s=null;i.forEach((e=>{const t=new r(e.semver.version);switch(e.operator){case">":if(t.prerelease.length===0){t.patch++}else{t.prerelease.push(0)}t.raw=t.format();case"":case">=":if(!s||a(t,s)){s=t}break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}}));if(s&&(!n||a(n,s))){n=s}}if(n&&e.test(n)){return n}return null};e.exports=minVersion},4772:function(e,t,n){"use strict";const r=n(4839);const i=n(863);const{ANY:a}=i;const s=n(8474);const o=n(2132);const l=n(5283);const c=n(6108);const d=n(3353);const u=n(6064);const outside=(e,t,n,p)=>{e=new r(e,p);t=new s(t,p);let f,h,y,m,b;switch(n){case">":f=l;h=d;y=c;m=">";b=">=";break;case"<":f=c;h=u;y=l;m="<";b="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(o(e,t,p)){return false}for(let n=0;n<t.set.length;++n){const r=t.set[n];let s=null;let o=null;r.forEach((e=>{if(e.semver===a){e=new i(">=0.0.0")}s=s||e;o=o||e;if(f(e.semver,s.semver,p)){s=e}else if(y(e.semver,o.semver,p)){o=e}}));if(s.operator===m||s.operator===b){return false}if((!o.operator||o.operator===m)&&h(e,o.semver)){return false}else if(o.operator===b&&y(e,o.semver)){return false}}return true};e.exports=outside},7344:function(e,t,n){"use strict";const r=n(2132);const i=n(6625);e.exports=(e,t,n)=>{const a=[];let s=null;let o=null;const l=e.sort(((e,t)=>i(e,t,n)));for(const e of l){const i=r(e,t,n);if(i){o=e;if(!s){s=e}}else{if(o){a.push([s,o])}o=null;s=null}}if(s){a.push([s,null])}const c=[];for(const[e,t]of a){if(e===t){c.push(e)}else if(!t&&e===l[0]){c.push("*")}else if(!t){c.push(`>=${e}`)}else if(e===l[0]){c.push(`<=${t}`)}else{c.push(`${e} - ${t}`)}}const d=c.join(" || ");const u=typeof t.raw==="string"?t.raw:String(t);return d.length<u.length?d:t}},4837:function(e,t,n){"use strict";const r=n(8474);const i=n(863);const{ANY:a}=i;const s=n(2132);const o=n(6625);const subset=(e,t,n={})=>{if(e===t){return true}e=new r(e,n);t=new r(t,n);let i=false;e:for(const r of e.set){for(const e of t.set){const t=simpleSubset(r,e,n);i=i||t!==null;if(t){continue e}}if(i){return false}}return true};const l=[new i(">=0.0.0-0")];const c=[new i(">=0.0.0")];const simpleSubset=(e,t,n)=>{if(e===t){return true}if(e.length===1&&e[0].semver===a){if(t.length===1&&t[0].semver===a){return true}else if(n.includePrerelease){e=l}else{e=c}}if(t.length===1&&t[0].semver===a){if(n.includePrerelease){return true}else{t=c}}const r=new Set;let i,d;for(const t of e){if(t.operator===">"||t.operator===">="){i=higherGT(i,t,n)}else if(t.operator==="<"||t.operator==="<="){d=lowerLT(d,t,n)}else{r.add(t.semver)}}if(r.size>1){return null}let u;if(i&&d){u=o(i.semver,d.semver,n);if(u>0){return null}else if(u===0&&(i.operator!==">="||d.operator!=="<=")){return null}}for(const e of r){if(i&&!s(e,String(i),n)){return null}if(d&&!s(e,String(d),n)){return null}for(const r of t){if(!s(e,String(r),n)){return false}}return true}let p,f;let h,y;let m=d&&!n.includePrerelease&&d.semver.prerelease.length?d.semver:false;let b=i&&!n.includePrerelease&&i.semver.prerelease.length?i.semver:false;if(m&&m.prerelease.length===1&&d.operator==="<"&&m.prerelease[0]===0){m=false}for(const e of t){y=y||e.operator===">"||e.operator===">=";h=h||e.operator==="<"||e.operator==="<=";if(i){if(b){if(e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch){b=false}}if(e.operator===">"||e.operator===">="){p=higherGT(i,e,n);if(p===e&&p!==i){return false}}else if(i.operator===">="&&!s(i.semver,String(e),n)){return false}}if(d){if(m){if(e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===m.major&&e.semver.minor===m.minor&&e.semver.patch===m.patch){m=false}}if(e.operator==="<"||e.operator==="<="){f=lowerLT(d,e,n);if(f===e&&f!==d){return false}}else if(d.operator==="<="&&!s(d.semver,String(e),n)){return false}}if(!e.operator&&(d||i)&&u!==0){return false}}if(i&&h&&!d&&u!==0){return false}if(d&&y&&!i&&u!==0){return false}if(b||m){return false}return true};const higherGT=(e,t,n)=>{if(!e){return t}const r=o(e.semver,t.semver,n);return r>0?e:r<0?t:t.operator===">"&&e.operator===">="?t:e};const lowerLT=(e,t,n)=>{if(!e){return t}const r=o(e.semver,t.semver,n);return r<0?e:r>0?t:t.operator==="<"&&e.operator==="<="?t:e};e.exports=subset},2258:function(e,t,n){"use strict";const r=n(8474);const toComparators=(e,t)=>new r(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")));e.exports=toComparators},8733:function(e,t,n){"use strict";const r=n(8474);const validRange=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}};e.exports=validRange},2460:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(549);function throwLater(e){setTimeout((function(){throw e}),0)}function asCallback(e,t,n){if(typeof t==="function"){e.then((e=>{let i;if(n!==undefined&&Object(n).spread&&Array.isArray(e)){i=r.tryCatch(t).apply(undefined,[null].concat(e))}else{i=e===undefined?r.tryCatch(t)(null):r.tryCatch(t)(null,e)}if(i===r.errorObj){throwLater(i.e)}}),(e=>{if(!e){const t=new Error(e+"");Object.assign(t,{cause:e});e=t}const n=r.tryCatch(t)(e);if(n===r.errorObj){throwLater(n.e)}}))}return e}t["default"]=asCallback},549:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.tryCatch=t.errorObj=void 0;t.errorObj={e:{}};let n;function tryCatcher(e,r){try{const e=n;n=null;return e.apply(this,arguments)}catch(e){t.errorObj.e=e;return t.errorObj}}function tryCatch(e){n=e;return tryCatcher}t.tryCatch=tryCatch},5414:function(e,t,n){"use strict";const r=n(857);const i=n(2871);const a=process.env;let s;if(i("no-color")||i("no-colors")||i("color=false")){s=false}else if(i("color")||i("colors")||i("color=true")||i("color=always")){s=true}if("FORCE_COLOR"in a){s=a.FORCE_COLOR.length===0||parseInt(a.FORCE_COLOR,10)!==0}function translateLevel(e){if(e===0){return false}return{level:e,hasBasic:true,has256:e>=2,has16m:e>=3}}function supportsColor(e){if(s===false){return 0}if(i("color=16m")||i("color=full")||i("color=truecolor")){return 3}if(i("color=256")){return 2}if(e&&!e.isTTY&&s!==true){return 0}const t=s?1:0;if(process.platform==="win32"){const e=r.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586){return Number(e[2])>=14931?3:2}return 1}if("CI"in a){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some((e=>e in a))||a.CI_NAME==="codeship"){return 1}return t}if("TEAMCITY_VERSION"in a){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0}if(a.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in a){const e=parseInt((a.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(a.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(a.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)){return 1}if("COLORTERM"in a){return 1}if(a.TERM==="dumb"){return t}return t}function getSupportLevel(e){const t=supportsColor(e);return translateLevel(t)}e.exports={supportsColor:getSupportLevel,stdout:getSupportLevel(process.stdout),stderr:getSupportLevel(process.stderr)}},1577:function(e){var t;var n;var r;var i;var a;var s;var o;var l;var c;var d;var u;var p;var f;var h;var y;var m;var b;var g;var v;var K;var S;var E;var k;var I;var w;var j;var x;var T;var D;var O;var C;var A;(function(t){var n=typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:{};if(typeof define==="function"&&define.amd){define("tslib",["exports"],(function(e){t(createExporter(n,createExporter(e)))}))}else if(true&&typeof e.exports==="object"){t(createExporter(n,createExporter(e.exports)))}else{t(createExporter(n))}function createExporter(e,t){if(e!==n){if(typeof Object.create==="function"){Object.defineProperty(e,"__esModule",{value:true})}else{e.__esModule=true}}return function(n,r){return e[n]=t?t(n,r):r}}})((function(e){var R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]};t=function(e,t){if(typeof t!=="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");R(e,t);function __(){this.constructor=e}e.prototype=t===null?Object.create(t):(__.prototype=t.prototype,new __)};n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))e[i]=t[i]}return e};r=function(e,t){var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0)n[r]=e[r];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++){if(t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i]))n[r[i]]=e[r[i]]}return n};i=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)if(s=e[o])a=(i<3?s(a):i>3?s(t,n,a):s(t,n))||a;return i>3&&a&&Object.defineProperty(t,n,a),a};a=function(e,t){return function(n,r){t(n,r,e)}};s=function(e,t,n,r,i,a){function accept(e){if(e!==void 0&&typeof e!=="function")throw new TypeError("Function expected");return e}var s=r.kind,o=s==="getter"?"get":s==="setter"?"set":"value";var l=!t&&e?r["static"]?e:e.prototype:null;var c=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{});var d,u=false;for(var p=n.length-1;p>=0;p--){var f={};for(var h in r)f[h]=h==="access"?{}:r[h];for(var h in r.access)f.access[h]=r.access[h];f.addInitializer=function(e){if(u)throw new TypeError("Cannot add initializers after decoration has completed");a.push(accept(e||null))};var y=(0,n[p])(s==="accessor"?{get:c.get,set:c.set}:c[o],f);if(s==="accessor"){if(y===void 0)continue;if(y===null||typeof y!=="object")throw new TypeError("Object expected");if(d=accept(y.get))c.get=d;if(d=accept(y.set))c.set=d;if(d=accept(y.init))i.unshift(d)}else if(d=accept(y)){if(s==="field")i.unshift(d);else c[o]=d}}if(l)Object.defineProperty(l,r.name,c);u=true};o=function(e,t,n){var r=arguments.length>2;for(var i=0;i<t.length;i++){n=r?t[i].call(e,n):t[i].call(e)}return r?n:void 0};l=function(e){return typeof e==="symbol"?e:"".concat(e)};c=function(e,t,n){if(typeof t==="symbol")t=t.description?"[".concat(t.description,"]"):"";return Object.defineProperty(e,"name",{configurable:true,value:n?"".concat(n," ",t):t})};d=function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};u=function(e,t,n,r){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))};p=function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=verb(0),s["throw"]=verb(1),s["return"]=verb(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function verb(e){return function(t){return step([e,t])}}function step(o){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,o[0]&&(n=0)),n)try{if(r=1,i&&(a=o[0]&2?i["return"]:o[0]?i["throw"]||((a=i["return"])&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;if(i=0,a)o=[o[0]&2,a.value];switch(o[0]){case 0:case 1:a=o;break;case 4:n.label++;return{value:o[1],done:false};case 5:n.label++;i=o[1];o=[0];continue;case 7:o=n.ops.pop();n.trys.pop();continue;default:if(!(a=n.trys,a=a.length>0&&a[a.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1];a=o;break}if(a&&n.label<a[2]){n.label=a[2];n.ops.push(o);break}if(a[2])n.ops.pop();n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e];i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};f=function(e,t){for(var n in e)if(n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n))D(t,e,n)};D=Object.create?function(e,t,n,r){if(r===undefined)r=n;var i=Object.getOwnPropertyDescriptor(t,n);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[n]}}}Object.defineProperty(e,r,i)}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]};h=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&r>=e.length)e=void 0;return{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};y=function(e,t){var n=typeof Symbol==="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],s;try{while((t===void 0||t-- >0)&&!(i=r.next()).done)a.push(i.value)}catch(e){s={error:e}}finally{try{if(i&&!i.done&&(n=r["return"]))n.call(r)}finally{if(s)throw s.error}}return a};m=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(y(arguments[t]));return e};b=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],s=0,o=a.length;s<o;s++,i++)r[i]=a[s];return r};g=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++){if(a||!(r in t)){if(!a)a=Array.prototype.slice.call(t,0,r);a[r]=t[r]}}return e.concat(a||Array.prototype.slice.call(t))};v=function(e){return this instanceof v?(this.v=e,this):new v(e)};K=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),verb("next"),verb("throw"),verb("return",awaitReturn),i[Symbol.asyncIterator]=function(){return this},i;function awaitReturn(e){return function(t){return Promise.resolve(t).then(e,reject)}}function verb(e,t){if(r[e]){i[e]=function(t){return new Promise((function(n,r){a.push([e,t,n,r])>1||resume(e,t)}))};if(t)i[e]=t(i[e])}}function resume(e,t){try{step(r[e](t))}catch(e){settle(a[0][3],e)}}function step(e){e.value instanceof v?Promise.resolve(e.value.v).then(fulfill,reject):settle(a[0][2],e)}function fulfill(e){resume("next",e)}function reject(e){resume("throw",e)}function settle(e,t){if(e(t),a.shift(),a.length)resume(a[0][0],a[0][1])}};S=function(e){var t,n;return t={},verb("next"),verb("throw",(function(e){throw e})),verb("return"),t[Symbol.iterator]=function(){return this},t;function verb(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:v(e[r](t)),done:false}:i?i(t):t}:i}};E=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof h==="function"?h(e):e[Symbol.iterator](),n={},verb("next"),verb("throw"),verb("return"),n[Symbol.asyncIterator]=function(){return this},n);function verb(t){n[t]=e[t]&&function(n){return new Promise((function(r,i){n=e[t](n),settle(r,i,n.done,n.value)}))}}function settle(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}};k=function(e,t){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:t})}else{e.raw=t}return e};var P=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t};var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n))t[t.length]=n;return t};return ownKeys(e)};I=function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=ownKeys(e),r=0;r<n.length;r++)if(n[r]!=="default")D(t,e,n[r]);P(t,e);return t};w=function(e){return e&&e.__esModule?e:{default:e}};j=function(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)};x=function(e,t,n,r,i){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(e,n):i?i.value=n:t.set(e,n),n};T=function(e,t){if(t===null||typeof t!=="object"&&typeof t!=="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e==="function"?t===e:e.has(t)};O=function(e,t,n){if(t!==null&&t!==void 0){if(typeof t!=="object"&&typeof t!=="function")throw new TypeError("Object expected.");var r,i;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose];if(n)i=r}if(typeof r!=="function")throw new TypeError("Object not disposable.");if(i)r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}};e.stack.push({value:t,dispose:r,async:n})}else if(n){e.stack.push({async:true})}return t};var M=typeof SuppressedError==="function"?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};C=function(e){function fail(t){e.error=e.hasError?new M(t,e.error,"An error was suppressed during disposal."):t;e.hasError=true}var t,n=0;function next(){while(t=e.stack.pop()){try{if(!t.async&&n===1)return n=0,e.stack.push(t),Promise.resolve().then(next);if(t.dispose){var r=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(r).then(next,(function(e){fail(e);return next()}))}else n|=1}catch(e){fail(e)}}if(n===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return next()};A=function(e,t){if(typeof e==="string"&&/^\.\.?\//.test(e)){return e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,(function(e,n,r,i,a){return n?t?".jsx":".js":r&&(!i||!a)?e:r+i+"."+a.toLowerCase()+"js"}))}return e};e("__extends",t);e("__assign",n);e("__rest",r);e("__decorate",i);e("__param",a);e("__esDecorate",s);e("__runInitializers",o);e("__propKey",l);e("__setFunctionName",c);e("__metadata",d);e("__awaiter",u);e("__generator",p);e("__exportStar",f);e("__createBinding",D);e("__values",h);e("__read",y);e("__spread",m);e("__spreadArrays",b);e("__spreadArray",g);e("__await",v);e("__asyncGenerator",K);e("__asyncDelegator",S);e("__asyncValues",E);e("__makeTemplateObject",k);e("__importStar",I);e("__importDefault",w);e("__classPrivateFieldGet",j);e("__classPrivateFieldSet",x);e("__classPrivateFieldIn",T);e("__addDisposableResource",O);e("__disposeResources",C);e("__rewriteRelativeImportExtension",A)}));0&&0},9935:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});Object.defineProperty(t,"NIL",{enumerable:true,get:function(){return o.default}});Object.defineProperty(t,"parse",{enumerable:true,get:function(){return u.default}});Object.defineProperty(t,"stringify",{enumerable:true,get:function(){return d.default}});Object.defineProperty(t,"v1",{enumerable:true,get:function(){return r.default}});Object.defineProperty(t,"v3",{enumerable:true,get:function(){return i.default}});Object.defineProperty(t,"v4",{enumerable:true,get:function(){return a.default}});Object.defineProperty(t,"v5",{enumerable:true,get:function(){return s.default}});Object.defineProperty(t,"validate",{enumerable:true,get:function(){return c.default}});Object.defineProperty(t,"version",{enumerable:true,get:function(){return l.default}});var r=_interopRequireDefault(n(494));var i=_interopRequireDefault(n(8564));var a=_interopRequireDefault(n(3633));var s=_interopRequireDefault(n(6002));var o=_interopRequireDefault(n(9032));var l=_interopRequireDefault(n(1247));var c=_interopRequireDefault(n(733));var d=_interopRequireDefault(n(5654));var u=_interopRequireDefault(n(9688));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}},1463:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(6982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function md5(e){if(Array.isArray(e)){e=Buffer.from(e)}else if(typeof e==="string"){e=Buffer.from(e,"utf8")}return r.default.createHash("md5").update(e).digest()}var i=md5;t["default"]=i},7788:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(6982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var i={randomUUID:r.default.randomUUID};t["default"]=i},9032:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n="00000000-0000-0000-0000-000000000000";t["default"]=n},9688:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(733));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function parse(e){if(!(0,r.default)(e)){throw TypeError("Invalid UUID")}let t;const n=new Uint8Array(16);n[0]=(t=parseInt(e.slice(0,8),16))>>>24;n[1]=t>>>16&255;n[2]=t>>>8&255;n[3]=t&255;n[4]=(t=parseInt(e.slice(9,13),16))>>>8;n[5]=t&255;n[6]=(t=parseInt(e.slice(14,18),16))>>>8;n[7]=t&255;n[8]=(t=parseInt(e.slice(19,23),16))>>>8;n[9]=t&255;n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255;n[11]=t/4294967296&255;n[12]=t>>>24&255;n[13]=t>>>16&255;n[14]=t>>>8&255;n[15]=t&255;return n}var i=parse;t["default"]=i},1784:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;t["default"]=n},298:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=rng;var r=_interopRequireDefault(n(6982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const i=new Uint8Array(256);let a=i.length;function rng(){if(a>i.length-16){r.default.randomFillSync(i);a=0}return i.slice(a,a+=16)}},8978:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(6982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function sha1(e){if(Array.isArray(e)){e=Buffer.from(e)}else if(typeof e==="string"){e=Buffer.from(e,"utf8")}return r.default.createHash("sha1").update(e).digest()}var i=sha1;t["default"]=i},5654:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;t.unsafeStringify=unsafeStringify;var r=_interopRequireDefault(n(733));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const i=[];for(let e=0;e<256;++e){i.push((e+256).toString(16).slice(1))}function unsafeStringify(e,t=0){return i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]}function stringify(e,t=0){const n=unsafeStringify(e,t);if(!(0,r.default)(n)){throw TypeError("Stringified UUID is invalid")}return n}var a=stringify;t["default"]=a},494:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(298));var i=n(5654);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let a;let s;let o=0;let l=0;function v1(e,t,n){let c=t&&n||0;const d=t||new Array(16);e=e||{};let u=e.node||a;let p=e.clockseq!==undefined?e.clockseq:s;if(u==null||p==null){const t=e.random||(e.rng||r.default)();if(u==null){u=a=[t[0]|1,t[1],t[2],t[3],t[4],t[5]]}if(p==null){p=s=(t[6]<<8|t[7])&16383}}let f=e.msecs!==undefined?e.msecs:Date.now();let h=e.nsecs!==undefined?e.nsecs:l+1;const y=f-o+(h-l)/1e4;if(y<0&&e.clockseq===undefined){p=p+1&16383}if((y<0||f>o)&&e.nsecs===undefined){h=0}if(h>=1e4){throw new Error("uuid.v1(): Can't create more than 10M uuids/sec")}o=f;l=h;s=p;f+=122192928e5;const m=((f&268435455)*1e4+h)%4294967296;d[c++]=m>>>24&255;d[c++]=m>>>16&255;d[c++]=m>>>8&255;d[c++]=m&255;const b=f/4294967296*1e4&268435455;d[c++]=b>>>8&255;d[c++]=b&255;d[c++]=b>>>24&15|16;d[c++]=b>>>16&255;d[c++]=p>>>8|128;d[c++]=p&255;for(let e=0;e<6;++e){d[c+e]=u[e]}return t||(0,i.unsafeStringify)(d)}var c=v1;t["default"]=c},8564:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(3537));var i=_interopRequireDefault(n(1463));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const a=(0,r.default)("v3",48,i.default);var s=a;t["default"]=s},3537:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.URL=t.DNS=void 0;t["default"]=v35;var r=n(5654);var i=_interopRequireDefault(n(9688));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function stringToBytes(e){e=unescape(encodeURIComponent(e));const t=[];for(let n=0;n<e.length;++n){t.push(e.charCodeAt(n))}return t}const a="6ba7b810-9dad-11d1-80b4-00c04fd430c8";t.DNS=a;const s="6ba7b811-9dad-11d1-80b4-00c04fd430c8";t.URL=s;function v35(e,t,n){function generateUUID(e,a,s,o){var l;if(typeof e==="string"){e=stringToBytes(e)}if(typeof a==="string"){a=(0,i.default)(a)}if(((l=a)===null||l===void 0?void 0:l.length)!==16){throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)")}let c=new Uint8Array(16+e.length);c.set(a);c.set(e,a.length);c=n(c);c[6]=c[6]&15|t;c[8]=c[8]&63|128;if(s){o=o||0;for(let e=0;e<16;++e){s[o+e]=c[e]}return s}return(0,r.unsafeStringify)(c)}try{generateUUID.name=e}catch(e){}generateUUID.DNS=a;generateUUID.URL=s;return generateUUID}},3633:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(7788));var i=_interopRequireDefault(n(298));var a=n(5654);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function v4(e,t,n){if(r.default.randomUUID&&!t&&!e){return r.default.randomUUID()}e=e||{};const s=e.random||(e.rng||i.default)();s[6]=s[6]&15|64;s[8]=s[8]&63|128;if(t){n=n||0;for(let e=0;e<16;++e){t[n+e]=s[e]}return t}return(0,a.unsafeStringify)(s)}var s=v4;t["default"]=s},6002:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(3537));var i=_interopRequireDefault(n(8978));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const a=(0,r.default)("v5",80,i.default);var s=a;t["default"]=s},733:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(1784));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function validate(e){return typeof e==="string"&&r.default.test(e)}var i=validate;t["default"]=i},1247:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(733));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function version(e){if(!(0,r.default)(e)){throw TypeError("Invalid UUID")}return parseInt(e.slice(14,15),16)}var i=version;t["default"]=i},5918:function(e){function webpackEmptyAsyncContext(e){return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");t.code="MODULE_NOT_FOUND";throw t}))}webpackEmptyAsyncContext.keys=function(){return[]};webpackEmptyAsyncContext.resolve=webpackEmptyAsyncContext;webpackEmptyAsyncContext.id=5918;e.exports=webpackEmptyAsyncContext},2613:function(e){"use strict";e.exports=require("assert")},181:function(e){"use strict";e.exports=require("buffer")},5317:function(e){"use strict";e.exports=require("child_process")},6982:function(e){"use strict";e.exports=require("crypto")},2250:function(e){"use strict";e.exports=require("dns")},4434:function(e){"use strict";e.exports=require("events")},9896:function(e){"use strict";e.exports=require("fs")},3339:function(e){"use strict";e.exports=require("module")},9278:function(e){"use strict";e.exports=require("net")},857:function(e){"use strict";e.exports=require("os")},6928:function(e){"use strict";e.exports=require("path")},2203:function(e){"use strict";e.exports=require("stream")},3193:function(e){"use strict";e.exports=require("string_decoder")},4756:function(e){"use strict";e.exports=require("tls")},2018:function(e){"use strict";e.exports=require("tty")},7016:function(e){"use strict";e.exports=require("url")},9023:function(e){"use strict";e.exports=require("util")},8167:function(e){"use strict";e.exports=require("worker_threads")},7687:function(e,t,n){"use strict";var r=n(2203);var i=n(3339);var a;try{a=new TextDecoder}catch(e){}var s;var o;var l=0;const c=[];var d=c;var u=0;var p={};var f;var h;var y=0;var m=0;var b;var g;var v=[];var K;var S={useRecords:false,mapsAsObjects:true};class C1Type{}const E=new C1Type;E.name="MessagePack 0xC1";var k=false;var I=2;var w,j,x;try{new Function("")}catch(e){I=Infinity}class Unpackr{constructor(e){if(e){if(e.useRecords===false&&e.mapsAsObjects===undefined)e.mapsAsObjects=true;if(e.sequential&&e.trusted!==false){e.trusted=true;if(!e.structures&&e.useRecords!=false){e.structures=[];if(!e.maxSharedStructures)e.maxSharedStructures=0}}if(e.structures)e.structures.sharedLength=e.structures.length;else if(e.getStructures){(e.structures=[]).uninitialized=true;e.structures.sharedLength=0}if(e.int64AsNumber){e.int64AsType="number"}}Object.assign(this,e)}unpack(e,t){if(s){return saveState$1((()=>{clearSource();return this?this.unpack(e,t):Unpackr.prototype.unpack.call(S,e,t)}))}if(!e.buffer&&e.constructor===ArrayBuffer)e=typeof Buffer!=="undefined"?Buffer.from(e):new Uint8Array(e);if(typeof t==="object"){o=t.end||e.length;l=t.start||0}else{l=0;o=t>-1?t:e.length}u=0;m=0;h=null;d=c;b=null;s=e;try{K=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(t){s=null;if(e instanceof Uint8Array)throw t;throw new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Unpackr){p=this;if(this.structures){f=this.structures;return checkedRead(t)}else if(!f||f.length>0){f=[]}}else{p=S;if(!f||f.length>0)f=[]}return checkedRead(t)}unpackMultiple(e,t){let n,r=0;try{k=true;let i=e.length;let a=this?this.unpack(e,i):V.unpack(e,i);if(t){if(t(a,r,l)===false)return;while(l<i){r=l;if(t(checkedRead(),r,l)===false){return}}}else{n=[a];while(l<i){r=l;n.push(checkedRead())}return n}}catch(e){e.lastPosition=r;e.values=n;throw e}finally{k=false;clearSource()}}_mergeStructures(e,t){if(j)e=j.call(this,e);e=e||[];if(Object.isFrozen(e))e=e.map((e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n){n.isShared=true;if(t>=32)n.highByte=t-32>>5}}e.sharedLength=e.length;for(let n in t||[]){if(n>=0){let r=e[n];let i=t[n];if(i){if(r)(e.restoreStructures||(e.restoreStructures=[]))[n]=r;e[n]=i}}}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function checkedRead(e){try{if(!p.trusted&&!k){let e=f.sharedLength||0;if(e<f.length)f.length=e}let t;if(p.randomAccessStructure&&s[l]<64&&s[l]>=32&&w){t=w(s,l,o,p);s=null;if(!(e&&e.lazy)&&t)t=t.toJSON();l=o}else t=read();if(b){l=b.postBundlePosition;b=null}if(k)f.restoreStructures=null;if(l==o){if(f&&f.restoreStructures)restoreStructures();f=null;s=null;if(g)g=null}else if(l>o){throw new Error("Unexpected end of MessagePack data")}else if(!k){let e;try{e=JSON.stringify(t,((e,t)=>typeof t==="bigint"?`${t}n`:t)).slice(0,100)}catch(t){e="(JSON view not available "+t+")"}throw new Error("Data read, but end of buffer not reached "+e)}return t}catch(e){if(f&&f.restoreStructures)restoreStructures();clearSource();if(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||l>o){e.incomplete=true}throw e}}function restoreStructures(){for(let e in f.restoreStructures){f[e]=f.restoreStructures[e]}f.restoreStructures=null}function read(){let e=s[l++];if(e<160){if(e<128){if(e<64)return e;else{let t=f[e&63]||p.getStructures&&loadStructures()[e&63];if(t){if(!t.read){t.read=createStructureReader(t,e&63)}return t.read()}else return e}}else if(e<144){e-=128;if(p.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=readKey();if(e==="__proto__")e="__proto_";t[e]=read()}return t}else{let t=new Map;for(let n=0;n<e;n++){t.set(read(),read())}return t}}else{e-=144;let t=new Array(e);for(let n=0;n<e;n++){t[n]=read()}if(p.freezeData)return Object.freeze(t);return t}}else if(e<192){let t=e-160;if(m>=l){return h.slice(l-y,(l+=t)-y)}if(m==0&&o<140){let e=t<16?shortStringInJS(t):longStringInJS(t);if(e!=null)return e}return D(t)}else{let t;switch(e){case 192:return null;case 193:if(b){t=read();if(t>0)return b[1].slice(b.position1,b.position1+=t);else return b[0].slice(b.position0,b.position0-=t)}return E;case 194:return false;case 195:return true;case 196:t=s[l++];if(t===undefined)throw new Error("Unexpected end of buffer");return readBin(t);case 197:t=K.getUint16(l);l+=2;return readBin(t);case 198:t=K.getUint32(l);l+=4;return readBin(t);case 199:return readExt(s[l++]);case 200:t=K.getUint16(l);l+=2;return readExt(t);case 201:t=K.getUint32(l);l+=4;return readExt(t);case 202:t=K.getFloat32(l);if(p.useFloat32>2){let e=J[(s[l]&127)<<1|s[l+1]>>7];l+=4;return(e*t+(t>0?.5:-.5)>>0)/e}l+=4;return t;case 203:t=K.getFloat64(l);l+=8;return t;case 204:return s[l++];case 205:t=K.getUint16(l);l+=2;return t;case 206:t=K.getUint32(l);l+=4;return t;case 207:if(p.int64AsType==="number"){t=K.getUint32(l)*4294967296;t+=K.getUint32(l+4)}else if(p.int64AsType==="string"){t=K.getBigUint64(l).toString()}else if(p.int64AsType==="auto"){t=K.getBigUint64(l);if(t<=BigInt(2)<<BigInt(52))t=Number(t)}else t=K.getBigUint64(l);l+=8;return t;case 208:return K.getInt8(l++);case 209:t=K.getInt16(l);l+=2;return t;case 210:t=K.getInt32(l);l+=4;return t;case 211:if(p.int64AsType==="number"){t=K.getInt32(l)*4294967296;t+=K.getUint32(l+4)}else if(p.int64AsType==="string"){t=K.getBigInt64(l).toString()}else if(p.int64AsType==="auto"){t=K.getBigInt64(l);if(t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52))t=Number(t)}else t=K.getBigInt64(l);l+=8;return t;case 212:t=s[l++];if(t==114){return recordDefinition(s[l++]&63)}else{let e=v[t];if(e){if(e.read){l++;return e.read(read())}else if(e.noBuffer){l++;return e()}else return e(s.subarray(l,++l))}else throw new Error("Unknown extension "+t)}case 213:t=s[l];if(t==114){l++;return recordDefinition(s[l++]&63,s[l++])}else return readExt(2);case 214:return readExt(4);case 215:return readExt(8);case 216:return readExt(16);case 217:t=s[l++];if(m>=l){return h.slice(l-y,(l+=t)-y)}return O(t);case 218:t=K.getUint16(l);l+=2;if(m>=l){return h.slice(l-y,(l+=t)-y)}return C(t);case 219:t=K.getUint32(l);l+=4;if(m>=l){return h.slice(l-y,(l+=t)-y)}return A(t);case 220:t=K.getUint16(l);l+=2;return readArray(t);case 221:t=K.getUint32(l);l+=4;return readArray(t);case 222:t=K.getUint16(l);l+=2;return readMap(t);case 223:t=K.getUint32(l);l+=4;return readMap(t);default:if(e>=224)return e-256;if(e===undefined){let e=new Error("Unexpected end of MessagePack data");e.incomplete=true;throw e}throw new Error("Unknown MessagePack token "+e)}}}const T=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function createStructureReader(e,t){function readObject(){if(readObject.count++>I){let n=e.read=new Function("r","return function(){return "+(p.freezeData?"Object.freeze":"")+"({"+e.map((e=>e==="__proto__"?"__proto_:r()":T.test(e)?e+":r()":"["+JSON.stringify(e)+"]:r()")).join(",")+"})}")(read);if(e.highByte===0)e.read=createSecondByteReader(t,e.read);return n()}let n={};for(let t=0,r=e.length;t<r;t++){let r=e[t];if(r==="__proto__")r="__proto_";n[r]=read()}if(p.freezeData)return Object.freeze(n);return n}readObject.count=0;if(e.highByte===0){return createSecondByteReader(t,readObject)}return readObject}const createSecondByteReader=(e,t)=>function(){let n=s[l++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5);let i=f[r]||loadStructures()[r];if(!i){throw new Error("Record id is not defined for "+r)}if(!i.read)i.read=createStructureReader(i,e);return i.read()};function loadStructures(){let e=saveState$1((()=>{s=null;return p.getStructures()}));return f=p._mergeStructures(e,f)}var D=readStringJS;var O=readStringJS;var C=readStringJS;var A=readStringJS;t.isNativeAccelerationEnabled=false;function setExtractor(e){t.isNativeAccelerationEnabled=true;D=readString(1);O=readString(2);C=readString(3);A=readString(5);function readString(t){return function readString(n){let r=d[u++];if(r==null){if(b)return readStringJS(n);let i=s.byteOffset;let a=e(l-t+i,o+i,s.buffer);if(typeof a=="string"){r=a;d=c}else{d=a;u=1;m=1;r=d[0];if(r===undefined)throw new Error("Unexpected end of buffer")}}let i=r.length;if(i<=n){l+=n;return r}h=r;y=l;m=l+i;l+=n;return r.slice(0,n)}}}function readStringJS(e){let t;if(e<16){if(t=shortStringInJS(e))return t}if(e>64&&a)return a.decode(s.subarray(l,l+=e));const n=l+e;const r=[];t="";while(l<n){const e=s[l++];if((e&128)===0){r.push(e)}else if((e&224)===192){const t=s[l++]&63;r.push((e&31)<<6|t)}else if((e&240)===224){const t=s[l++]&63;const n=s[l++]&63;r.push((e&31)<<12|t<<6|n)}else if((e&248)===240){const t=s[l++]&63;const n=s[l++]&63;const i=s[l++]&63;let a=(e&7)<<18|t<<12|n<<6|i;if(a>65535){a-=65536;r.push(a>>>10&1023|55296);a=56320|a&1023}r.push(a)}else{r.push(e)}if(r.length>=4096){t+=R.apply(String,r);r.length=0}}if(r.length>0){t+=R.apply(String,r)}return t}function readString(e,t,n){let r=s;s=e;l=t;try{return readStringJS(n)}finally{s=r}}function readArray(e){let t=new Array(e);for(let n=0;n<e;n++){t[n]=read()}if(p.freezeData)return Object.freeze(t);return t}function readMap(e){if(p.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=readKey();if(e==="__proto__")e="__proto_";t[e]=read()}return t}else{let t=new Map;for(let n=0;n<e;n++){t.set(read(),read())}return t}}var R=String.fromCharCode;function longStringInJS(e){let t=l;let n=new Array(e);for(let r=0;r<e;r++){const e=s[l++];if((e&128)>0){l=t;return}n[r]=e}return R.apply(String,n)}function shortStringInJS(e){if(e<4){if(e<2){if(e===0)return"";else{let e=s[l++];if((e&128)>1){l-=1;return}return R(e)}}else{let t=s[l++];let n=s[l++];if((t&128)>0||(n&128)>0){l-=2;return}if(e<3)return R(t,n);let r=s[l++];if((r&128)>0){l-=3;return}return R(t,n,r)}}else{let t=s[l++];let n=s[l++];let r=s[l++];let i=s[l++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){l-=4;return}if(e<6){if(e===4)return R(t,n,r,i);else{let e=s[l++];if((e&128)>0){l-=5;return}return R(t,n,r,i,e)}}else if(e<8){let a=s[l++];let o=s[l++];if((a&128)>0||(o&128)>0){l-=6;return}if(e<7)return R(t,n,r,i,a,o);let c=s[l++];if((c&128)>0){l-=7;return}return R(t,n,r,i,a,o,c)}else{let a=s[l++];let o=s[l++];let c=s[l++];let d=s[l++];if((a&128)>0||(o&128)>0||(c&128)>0||(d&128)>0){l-=8;return}if(e<10){if(e===8)return R(t,n,r,i,a,o,c,d);else{let e=s[l++];if((e&128)>0){l-=9;return}return R(t,n,r,i,a,o,c,d,e)}}else if(e<12){let u=s[l++];let p=s[l++];if((u&128)>0||(p&128)>0){l-=10;return}if(e<11)return R(t,n,r,i,a,o,c,d,u,p);let f=s[l++];if((f&128)>0){l-=11;return}return R(t,n,r,i,a,o,c,d,u,p,f)}else{let u=s[l++];let p=s[l++];let f=s[l++];let h=s[l++];if((u&128)>0||(p&128)>0||(f&128)>0||(h&128)>0){l-=12;return}if(e<14){if(e===12)return R(t,n,r,i,a,o,c,d,u,p,f,h);else{let e=s[l++];if((e&128)>0){l-=13;return}return R(t,n,r,i,a,o,c,d,u,p,f,h,e)}}else{let y=s[l++];let m=s[l++];if((y&128)>0||(m&128)>0){l-=14;return}if(e<15)return R(t,n,r,i,a,o,c,d,u,p,f,h,y,m);let b=s[l++];if((b&128)>0){l-=15;return}return R(t,n,r,i,a,o,c,d,u,p,f,h,y,m,b)}}}}}function readOnlyJSString(){let e=s[l++];let t;if(e<192){t=e-160}else{switch(e){case 217:t=s[l++];break;case 218:t=K.getUint16(l);l+=2;break;case 219:t=K.getUint32(l);l+=4;break;default:throw new Error("Expected string")}}return readStringJS(t)}function readBin(e){return p.copyBuffers?Uint8Array.prototype.slice.call(s,l,l+=e):s.subarray(l,l+=e)}function readExt(e){let t=s[l++];if(v[t]){let n;return v[t](s.subarray(l,n=l+=e),(e=>{l=e;try{return read()}finally{l=n}}))}else throw new Error("Unknown extension type "+t)}var P=new Array(4096);function readKey(){let e=s[l++];if(e>=160&&e<192){e=e-160;if(m>=l)return h.slice(l-y,(l+=e)-y);else if(!(m==0&&o<180))return D(e)}else{l--;return asSafeString(read())}let t=(e<<5^(e>1?K.getUint16(l):e>0?s[l]:0))&4095;let n=P[t];let r=l;let i=l+e-3;let a;let c=0;if(n&&n.bytes==e){while(r<i){a=K.getUint32(r);if(a!=n[c++]){r=1879048192;break}r+=4}i+=3;while(r<i){a=s[r++];if(a!=n[c++]){r=1879048192;break}}if(r===i){l=r;return n.string}i-=3;r=l}n=[];P[t]=n;n.bytes=e;while(r<i){a=K.getUint32(r);n.push(a);r+=4}i+=3;while(r<i){a=s[r++];n.push(a)}let d=e<16?shortStringInJS(e):longStringInJS(e);if(d!=null)return n.string=d;return n.string=D(e)}function asSafeString(e){if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"||typeof e==="bigint")return e.toString();if(e==null)return e+"";if(p.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every((e=>["string","number","boolean","bigint"].includes(typeof e)))){return e.flat().toString()}throw new Error(`Invalid property type for record: ${typeof e}`)}const recordDefinition=(e,t)=>{let n=read().map(asSafeString);let r=e;if(t!==undefined){e=e<32?-((t<<5)+e):(t<<5)+e;n.highByte=t}let i=f[e];if(i&&(i.isShared||k)){(f.restoreStructures||(f.restoreStructures=[]))[e]=i}f[e]=n;n.read=createStructureReader(n,r);return n.read()};v[0]=()=>{};v[0].noBuffer=true;v[66]=e=>{let t=e.length;let n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++){n<<=BigInt(8);n+=BigInt(e[r])}return n};let M={Error:Error,TypeError:TypeError,ReferenceError:ReferenceError};v[101]=()=>{let e=read();return(M[e[0]]||Error)(e[1],{cause:e[2]})};v[105]=e=>{if(p.structuredClone===false)throw new Error("Structured clone extension is disabled");let t=K.getUint32(l-4);if(!g)g=new Map;let n=s[l];let r;if(n>=144&&n<160||n==220||n==221)r=[];else if(n>=128&&n<144||n==222||n==223)r=new Map;else if((n>=199&&n<=201||n>=212&&n<=216)&&s[l+1]===115)r=new Set;else r={};let i={target:r};g.set(t,i);let a=read();if(!i.used){return i.target=a}else{Object.assign(r,a)}if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r};v[112]=e=>{if(p.structuredClone===false)throw new Error("Structured clone extension is disabled");let t=K.getUint32(l-4);let n=g.get(t);n.used=true;return n.target};v[115]=()=>new Set(read());const _=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((e=>e+"Array"));let N=typeof globalThis==="object"?globalThis:window;v[116]=e=>{let t=e[0];let n=Uint8Array.prototype.slice.call(e,1).buffer;let r=_[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw new Error("Could not find typed array for code "+t)}return new N[r](n)};v[120]=()=>{let e=read();return new RegExp(e[0],e[1])};const L=[];v[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3];let n=l;l+=t-e.length;b=L;b=[readOnlyJSString(),readOnlyJSString()];b.position0=0;b.position1=0;b.postBundlePosition=l;l=n;return read()};v[255]=e=>{if(e.length==4)return new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3);else if(e.length==8)return new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3);else if(e.length==12)return new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3);else return new Date("invalid")};function saveState$1(e){if(x)x();let t=o;let n=l;let r=u;let i=y;let a=m;let c=h;let v=d;let S=g;let E=b;let I=new Uint8Array(s.slice(0,o));let w=f;let j=f.slice(0,f.length);let T=p;let D=k;let O=e();o=t;l=n;u=r;y=i;m=a;h=c;d=v;g=S;b=E;s=I;k=D;f=w;f.splice(0,f.length,...j);p=T;K=new DataView(s.buffer,s.byteOffset,s.byteLength);return O}function clearSource(){s=null;g=null;f=null}function addExtension$1(e){if(e.unpack)v[e.type]=e.unpack;else v[e.type]=e}const J=new Array(147);for(let e=0;e<256;e++){J[e]=+("1e"+Math.floor(45.15-e*.30103))}const F=Unpackr;var V=new Unpackr({useRecords:false});const q=V.unpack;const G=V.unpackMultiple;const Y=V.unpack;const B={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let U=new Float32Array(1);let W=new Uint8Array(U.buffer,0,4);function roundFloat32(e){U[0]=e;let t=J[(W[3]&127)<<1|W[2]>>7];return(t*e+(e>0?.5:-.5)>>0)/t}function setReadStruct(e,t,n){w=e;j=t;x=n}let z;try{z=new TextEncoder}catch(e){}let Q,Z;const $=typeof Buffer!=="undefined";const H=$?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array;const X=$?Buffer:Uint8Array;const ee=$?4294967296:2144337920;let te,ne;let re;let ie=0;let ae;let se=null;let oe;const le=21760;const ce=/[\u0080-\uFFFF]/;const de=Symbol("record-id");class Packr extends Unpackr{constructor(e){super(e);this.offset=0;let t;let n;let r;let i;let a=X.prototype.utf8Write?function(e,t){return te.utf8Write(e,t,te.byteLength-t)}:z&&z.encodeInto?function(e,t){return z.encodeInto(e,te.subarray(t)).written}:false;let s=this;if(!e)e={};let o=e&&e.sequential;let l=e.structures||e.saveStructures;let c=e.maxSharedStructures;if(c==null)c=l?32:0;if(c>8160)throw new Error("Maximum maxSharedStructure is 8160");if(e.structuredClone&&e.moreTypes==undefined){this.moreTypes=true}let d=e.maxOwnStructures;if(d==null)d=l?32:64;if(!this.structures&&e.useRecords!=false)this.structures=[];let u=c>32||d+c>64;let p=c+64;let f=c+d+64;if(f>8256){throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192")}let h=[];let y=0;let m=0;this.pack=this.encode=function(e,a){if(!te){te=new H(8192);re=te.dataView||(te.dataView=new DataView(te.buffer,0,8192));ie=0}ae=te.length-10;if(ae-ie<2048){te=new H(te.length);re=te.dataView||(te.dataView=new DataView(te.buffer,0,te.length));ae=te.length-10;ie=0}else ie=ie+7&2147483640;t=ie;if(a&Se)ie+=a&255;i=s.structuredClone?new Map:null;if(s.bundleStrings&&typeof e!=="string"){se=[];se.size=Infinity}else se=null;r=s.structures;if(r){if(r.uninitialized)r=s._mergeStructures(s.getStructures());let e=r.sharedLength||0;if(e>c){throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength)}if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r];if(!n){n=i[r]=Object.create(null)}i=n}i[de]=t+64}this.lastNamedStructuresLength=e}if(!o){r.nextId=e+64}}if(n)n=false;let l;try{if(s.randomAccessStructure&&e&&e.constructor&&e.constructor===Object)writeStruct(e);else pack(e);let n=se;if(se)writeBundles(t,pack,0);if(i&&i.idsToInsert){let e=i.idsToInsert.sort(((e,t)=>e.offset>t.offset?1:-1));let r=e.length;let a=-1;while(n&&r>0){let i=e[--r].offset+t;if(i<n.stringsPosition+t&&a===-1)a=0;if(i>n.position+t){if(a>=0)a+=6}else{if(a>=0){re.setUint32(n.position+t,re.getUint32(n.position+t)+a);a=-1}n=n.previous;r++}}if(a>=0&&n){re.setUint32(n.position+t,re.getUint32(n.position+t)+a)}ie+=e.length*6;if(ie>ae)makeRoom(ie);s.offset=ie;let o=insertIds(te.subarray(t,ie),e);i=null;return o}s.offset=ie;if(a&ve){te.start=t;te.end=ie;return te}return te.subarray(t,ie)}catch(e){l=e;throw e}finally{if(r){resetStructures();if(n&&s.saveStructures){let n=r.sharedLength||0;let i=te.subarray(t,ie);let o=prepareStructures$1(r,s);if(!l){if(s.saveStructures(o,o.isCompatible)===false){return s.pack(e,a)}s.lastNamedStructuresLength=n;if(te.length>1073741824)te=null;return i}}}if(te.length>1073741824)te=null;if(a&Ke)ie=t}};const resetStructures=()=>{if(m<10)m++;let e=r.sharedLength||0;if(r.length>e&&!o)r.length=e;if(y>1e4){r.transitions=null;m=0;y=0;if(h.length>0)h=[]}else if(h.length>0&&!o){for(let e=0,t=h.length;e<t;e++){h[e][de]=0}h=[]}};const packArray=e=>{var t=e.length;if(t<16){te[ie++]=144|t}else if(t<65536){te[ie++]=220;te[ie++]=t>>8;te[ie++]=t&255}else{te[ie++]=221;re.setUint32(ie,t);ie+=4}for(let n=0;n<t;n++){pack(e[n])}};const pack=e=>{if(ie>ae)te=makeRoom(ie);var n=typeof e;var r;if(n==="string"){let n=e.length;if(se&&n>=4&&n<4096){if((se.size+=n)>le){let e;let n=(se[0]?se[0].length*3+se[1].length:0)+10;if(ie+n>ae)te=makeRoom(ie+n);let r;if(se.position){r=se;te[ie]=200;ie+=3;te[ie++]=98;e=ie-t;ie+=4;writeBundles(t,pack,0);re.setUint16(e+t-3,ie-t-e)}else{te[ie++]=214;te[ie++]=98;e=ie-t;ie+=4}se=["",""];se.previous=r;se.size=0;se.position=e}let r=ce.test(e);se[r?0:1]+=e;te[ie++]=193;pack(r?-n:n);return}let i;if(n<32){i=1}else if(n<256){i=2}else if(n<65536){i=3}else{i=5}let s=n*3;if(ie+s>ae)te=makeRoom(ie+s);if(n<64||!a){let t,a,s,o=ie+i;for(t=0;t<n;t++){a=e.charCodeAt(t);if(a<128){te[o++]=a}else if(a<2048){te[o++]=a>>6|192;te[o++]=a&63|128}else if((a&64512)===55296&&((s=e.charCodeAt(t+1))&64512)===56320){a=65536+((a&1023)<<10)+(s&1023);t++;te[o++]=a>>18|240;te[o++]=a>>12&63|128;te[o++]=a>>6&63|128;te[o++]=a&63|128}else{te[o++]=a>>12|224;te[o++]=a>>6&63|128;te[o++]=a&63|128}}r=o-ie-i}else{r=a(e,ie+i)}if(r<32){te[ie++]=160|r}else if(r<256){if(i<2){te.copyWithin(ie+2,ie+1,ie+1+r)}te[ie++]=217;te[ie++]=r}else if(r<65536){if(i<3){te.copyWithin(ie+3,ie+2,ie+2+r)}te[ie++]=218;te[ie++]=r>>8;te[ie++]=r&255}else{if(i<5){te.copyWithin(ie+5,ie+3,ie+3+r)}te[ie++]=219;re.setUint32(ie,r);ie+=4}ie+=r}else if(n==="number"){if(e>>>0===e){if(e<32||e<128&&this.useRecords===false||e<64&&!this.randomAccessStructure){te[ie++]=e}else if(e<256){te[ie++]=204;te[ie++]=e}else if(e<65536){te[ie++]=205;te[ie++]=e>>8;te[ie++]=e&255}else{te[ie++]=206;re.setUint32(ie,e);ie+=4}}else if(e>>0===e){if(e>=-32){te[ie++]=256+e}else if(e>=-128){te[ie++]=208;te[ie++]=e+256}else if(e>=-32768){te[ie++]=209;re.setInt16(ie,e);ie+=2}else{te[ie++]=210;re.setInt32(ie,e);ie+=4}}else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){te[ie++]=202;re.setFloat32(ie,e);let n;if(t<4||(n=e*J[(te[ie]&127)<<1|te[ie+1]>>7])>>0===n){ie+=4;return}else ie--}te[ie++]=203;re.setFloat64(ie,e);ie+=8}}else if(n==="object"||n==="function"){if(!e)te[ie++]=192;else{if(i){let n=i.get(e);if(n){if(!n.id){let e=i.idsToInsert||(i.idsToInsert=[]);n.id=e.push(n)}te[ie++]=214;te[ie++]=112;re.setUint32(ie,n.id);ie+=4;return}else i.set(e,{offset:ie-t})}let a=e.constructor;if(a===Object){K(e)}else if(a===Array){packArray(e)}else if(a===Map){if(this.mapAsEmptyObject)te[ie++]=128;else{r=e.size;if(r<16){te[ie++]=128|r}else if(r<65536){te[ie++]=222;te[ie++]=r>>8;te[ie++]=r&255}else{te[ie++]=223;re.setUint32(ie,r);ie+=4}for(let[t,n]of e){pack(t);pack(n)}}}else{for(let t=0,n=Q.length;t<n;t++){let n=Z[t];if(e instanceof n){let n=Q[t];if(n.write){if(n.type){te[ie++]=212;te[ie++]=n.type;te[ie++]=0}let t=n.write.call(this,e);if(t===e){if(Array.isArray(e)){packArray(e)}else{K(e)}}else{pack(t)}return}let r=te;let i=re;let a=ie;te=null;let s;try{s=n.pack.call(this,e,(e=>{te=r;r=null;ie+=e;if(ie>ae)makeRoom(ie);return{target:te,targetView:re,position:ie-e}}),pack)}finally{if(r){te=r;re=i;ie=a;ae=te.length-10}}if(s){if(s.length+ie>ae)makeRoom(s.length+ie);ie=writeExtensionData(s,te,ie,n.type)}return}}if(Array.isArray(e)){packArray(e)}else{if(e.toJSON){const t=e.toJSON();if(t!==e)return pack(t)}if(n==="function")return pack(this.writeFunction&&this.writeFunction(e));K(e)}}}}else if(n==="boolean"){te[ie++]=e?195:194}else if(n==="bigint"){if(e<0x8000000000000000&&e>=-0x8000000000000000){te[ie++]=211;re.setBigInt64(ie,e)}else if(e<0x10000000000000000&&e>0){te[ie++]=207;re.setBigUint64(ie,e)}else{if(this.largeBigIntToFloat){te[ie++]=203;re.setFloat64(ie,Number(e))}else if(this.largeBigIntToString){return pack(e.toString())}else if((this.useBigIntExtension||this.moreTypes)&&e<BigInt(2)**BigInt(1023)&&e>-(BigInt(2)**BigInt(1023))){te[ie++]=199;ie++;te[ie++]=66;let t=[];let n;do{let r=e&BigInt(255);n=(r&BigInt(128))===(e<BigInt(0)?BigInt(128):BigInt(0));t.push(r);e>>=BigInt(8)}while(!((e===BigInt(0)||e===BigInt(-1))&&n));te[ie-2]=t.length;for(let e=t.length;e>0;){te[ie++]=Number(t[--e])}return}else{throw new RangeError(e+" was too large to fit in MessagePack 64-bit integer format, use"+" useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set"+" largeBigIntToString to convert to string")}}ie+=8}else if(n==="undefined"){if(this.encodeUndefinedAsNil)te[ie++]=192;else{te[ie++]=212;te[ie++]=0;te[ie++]=0}}else{throw new Error("Unknown type: "+n)}};const b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e){if((typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n]))t.push(n)}}else{t=Object.keys(e)}let n=t.length;if(n<16){te[ie++]=128|n}else if(n<65536){te[ie++]=222;te[ie++]=n>>8;te[ie++]=n&255}else{te[ie++]=223;re.setUint32(ie,n);ie+=4}let r;if(this.coercibleKeyAsNumber){for(let i=0;i<n;i++){r=t[i];let n=Number(r);pack(isNaN(n)?r:n);pack(e[r])}}else{for(let i=0;i<n;i++){pack(r=t[i]);pack(e[r])}}}:e=>{te[ie++]=222;let n=ie-t;ie+=2;let r=0;for(let t in e){if(typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(t)){pack(t);pack(e[t]);r++}}if(r>65535){throw new Error("Object is too large to serialize with fast 16-bit map size,"+' use the "variableMapSize" option to serialize this object')}te[n+++t]=r>>8;te[n+t]=r&255};const g=this.useRecords===false?b:e.progressiveRecords&&!u?e=>{let n,i=r.transitions||(r.transitions=Object.create(null));let a=ie++-t;let s;for(let o in e){if(typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(o)){n=i[o];if(n)i=n;else{let l=Object.keys(e);let c=i;i=r.transitions;let d=0;for(let e=0,t=l.length;e<t;e++){let t=l[e];n=i[t];if(!n){n=i[t]=Object.create(null);d++}i=n}if(a+t+1==ie){ie--;newRecord(i,l,d)}else insertNewRecord(i,l,a,d);s=true;i=c[o]}pack(e[o])}}if(!s){let n=i[de];if(n)te[a+t]=n;else insertNewRecord(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null));let i=0;for(let r in e)if(typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(r)){t=n[r];if(!t){t=n[r]=Object.create(null);i++}n=t}let a=n[de];if(a){if(a>=96&&u){te[ie++]=((a-=96)&31)+96;te[ie++]=a>>5}else te[ie++]=a}else{newRecord(n,n.__keys__||Object.keys(e),i)}for(let t in e)if(typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(t)){pack(e[t])}};const v=typeof this.useRecords=="function"&&this.useRecords;const K=v?e=>{v(e)?g(e):b(e)}:g;const makeRoom=e=>{let n;if(e>16777216){if(e-t>ee)throw new Error("Packed buffer would be larger than maximum buffer size");n=Math.min(ee,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,te.length-1)>>12)+1<<12;let r=new H(n);re=r.dataView||(r.dataView=new DataView(r.buffer,0,n));e=Math.min(e,te.length);if(te.copy)te.copy(r,0,t,e);else r.set(te.slice(t,e));ie-=t;t=0;ae=r.length-10;return te=r};const newRecord=(e,t,i)=>{let a=r.nextId;if(!a)a=64;if(a<p&&this.shouldShareStructure&&!this.shouldShareStructure(t)){a=r.nextOwnId;if(!(a<f))a=p;r.nextOwnId=a+1}else{if(a>=f)a=p;r.nextId=a+1}let s=t.highByte=a>=96&&u?a-96>>5:-1;e[de]=a;e.__keys__=t;r[a-64]=t;if(a<p){t.isShared=true;r.sharedLength=a-63;n=true;if(s>=0){te[ie++]=(a&31)+96;te[ie++]=s}else{te[ie++]=a}}else{if(s>=0){te[ie++]=213;te[ie++]=114;te[ie++]=(a&31)+96;te[ie++]=s}else{te[ie++]=212;te[ie++]=114;te[ie++]=a}if(i)y+=m*i;if(h.length>=d)h.shift()[de]=0;h.push(e);pack(t)}};const insertNewRecord=(e,n,r,i)=>{let a=te;let s=ie;let o=ae;let l=t;te=ne;ie=0;t=0;if(!te)ne=te=new H(8192);ae=te.length-10;newRecord(e,n,i);ne=te;let c=ie;te=a;ie=s;ae=o;t=l;if(c>1){let e=ie+c-1;if(e>ae)makeRoom(e);let n=r+t;te.copyWithin(n+c,n+1,ie);te.set(ne.slice(0,c),n);ie=e}else{te[r+t]=ne[0]}};const writeStruct=e=>{let i=oe(e,te,t,ie,r,makeRoom,((e,t,r)=>{if(r)return n=true;ie=t;let i=te;pack(e);resetStructures();if(i!==te){return{position:ie,targetView:re,target:te}}return ie}),this);if(i===0)return K(e);ie=i}}useBuffer(e){te=e;te.dataView||(te.dataView=new DataView(te.buffer,te.byteOffset,te.byteLength));ie=0}set position(e){ie=e}get position(){return ie}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}Z=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,C1Type];Q=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214;e[i++]=255;n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215;n[a++]=255;i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0));i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate){t(0);return n(this.onInvalidDate())}let{target:e,targetView:r,position:i}=t(3);e[i++]=212;e[i++]=255;e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199;n[a++]=12;n[a++]=255;i.setUint32(a,e.getMilliseconds()*1e6);i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject){t(0);return n({})}let r=Array.from(e);let{target:i,position:a}=t(this.moreTypes?3:0);if(this.moreTypes){i[a++]=212;i[a++]=115;i[a++]=0}n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);if(this.moreTypes){r[i++]=212;r[i++]=101;r[i++]=0}n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);if(this.moreTypes){r[i++]=212;r[i++]=120;r[i++]=0}n([e.source,e.flags])}},{pack(e,t){if(this.moreTypes)writeExtBuffer(e,16,t);else writeBuffer($?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;if(n!==X&&this.moreTypes)writeExtBuffer(e,_.indexOf(n.name),t);else writeBuffer(e,t)}},{pack(e,t){if(this.moreTypes)writeExtBuffer(e,17,t);else writeBuffer($?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function writeExtBuffer(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:s}=n(4+i);a[s++]=199;a[s++]=i+1}else if(i+1<65536){var{target:a,position:s}=n(5+i);a[s++]=200;a[s++]=i+1>>8;a[s++]=i+1&255}else{var{target:a,position:s,targetView:o}=n(7+i);a[s++]=201;o.setUint32(s,i+1);s+=4}a[s++]=116;a[s++]=t;if(!e.buffer)e=new Uint8Array(e);a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s)}function writeBuffer(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196;r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197;r[i++]=n>>8;r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198;a.setUint32(i,n);i+=4}r.set(e,i)}function writeExtensionData(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:if(i<256){t[n++]=199;t[n++]=i}else if(i<65536){t[n++]=200;t[n++]=i>>8;t[n++]=i&255}else{t[n++]=201;t[n++]=i>>24;t[n++]=i>>16&255;t[n++]=i>>8&255;t[n++]=i&255}}t[n++]=r;t.set(e,n);n+=i;return n}function insertIds(e,t){let n;let r=t.length*6;let i=e.length-r;while(n=t.pop()){let t=n.offset;let a=n.id;e.copyWithin(t+r,t,i);r-=6;let s=t+r;e[s++]=214;e[s++]=105;e[s++]=a>>24;e[s++]=a>>16&255;e[s++]=a>>8&255;e[s++]=a&255;i=t}return e}function writeBundles(e,t,n){if(se.length>0){re.setUint32(se.position+e,ie+n-se.position-e);se.stringsPosition=ie-e;let r=se;se=null;t(r[0]);t(r[1])}}function addExtension(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");Z.unshift(e.Class);Q.unshift(e)}addExtension$1(e)}function prepareStructures$1(e,t){e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;if(!n)t._mergeStructures(e);return n};return e}function setWriteStructSlots(e,t){oe=e;prepareStructures$1=t}let ue=new Packr({useRecords:false});const pe=ue.pack;const fe=ue.pack;const he=Packr;const{NEVER:ye,ALWAYS:me,DECIMAL_ROUND:be,DECIMAL_FIT:ge}=B;const ve=512;const Ke=1024;const Se=2048;const Ee=3;const ke=0;const Ie=2;const we=1;const je=16;const xe=["num","object","string","ascii"];xe[je]="date";const Te=[false,true,true,false,false,true,true,false];let De;try{new Function("");De=true}catch(e){}let Oe;const Ce=typeof Buffer!=="undefined";let Ae,Re;try{Ae=new TextEncoder}catch(e){}const Pe=Ce?function(e,t,n){return e.utf8Write(t,n,e.byteLength-n)}:Ae&&Ae.encodeInto?function(e,t,n){return Ae.encodeInto(t,e.subarray(n)).written}:false;setWriteStructSlots(writeStruct,prepareStructures);function writeStruct(e,t,n,r,i,a,s,o){let l=o.typedStructs||(o.typedStructs=[]);let c=t.dataView;let d=(l.lastStringStart||100)+r;let u=t.length-10;let p=r;if(r>u){t=a(r);c=t.dataView;r-=n;p-=n;d-=n;n=0;u=t.length-10}let f,h=d;let y=l.transitions||(l.transitions=Object.create(null));let m=l.nextId||l.length;let b=m<15?1:m<240?2:m<61440?3:m<15728640?4:0;if(b===0)return 0;r+=b;let g=[];let v;let K=0;for(let i in e){let o=e[i];let b=y[i];if(!b){y[i]=b={key:i,parent:y,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null}}if(r>u){t=a(r);c=t.dataView;r-=n;p-=n;d-=n;h-=n;n=0;u=t.length-10}switch(typeof o){case"number":let e=o;if(m<200||!b.num64){if(e>>0===e&&e<536870912&&e>-520093696){if(e<246&&e>=0&&(b.num8&&!(m>200&&b.num32)||e<32&&!b.num32)){y=b.num8||createTypeTransition(b,ke,1);t[r++]=e}else{y=b.num32||createTypeTransition(b,ke,4);c.setUint32(r,e,true);r+=4}break}else if(e<4294967296&&e>=-2147483648){c.setFloat32(r,e,true);if(Te[t[r+3]>>>5]){let n;if((n=e*J[(t[r+3]&127)<<1|t[r+2]>>7])>>0===n){y=b.num32||createTypeTransition(b,ke,4);r+=4;break}}}}y=b.num64||createTypeTransition(b,ke,8);c.setFloat64(r,e,true);r+=8;break;case"string":let S=o.length;f=h-d;if((S<<2)+h>u){t=a((S<<2)+h);c=t.dataView;r-=n;p-=n;d-=n;h-=n;n=0;u=t.length-10}if(S>65280+f>>2){g.push(i,o,r-p);break}let E;let k=h;if(S<64){let e,n,r;for(e=0;e<S;e++){n=o.charCodeAt(e);if(n<128){t[h++]=n}else if(n<2048){E=true;t[h++]=n>>6|192;t[h++]=n&63|128}else if((n&64512)===55296&&((r=o.charCodeAt(e+1))&64512)===56320){E=true;n=65536+((n&1023)<<10)+(r&1023);e++;t[h++]=n>>18|240;t[h++]=n>>12&63|128;t[h++]=n>>6&63|128;t[h++]=n&63|128}else{E=true;t[h++]=n>>12|224;t[h++]=n>>6&63|128;t[h++]=n&63|128}}}else{h+=Pe(t,o,h);E=h-k>S}if(f<160||f<246&&(b.ascii8||b.string8)){if(E){if(!(y=b.string8)){if(l.length>10&&(y=b.ascii8)){y.__type=Ie;b.ascii8=null;b.string8=y;s(null,0,true)}else{y=createTypeTransition(b,Ie,1)}}}else if(f===0&&!v){v=true;y=b.ascii0||createTypeTransition(b,Ee,0);break}else if(!(y=b.ascii8)&&!(l.length>10&&(y=b.string8)))y=createTypeTransition(b,Ee,1);t[r++]=f}else{y=b.string16||createTypeTransition(b,Ie,2);c.setUint16(r,f,true);r+=2}break;case"object":if(o){if(o.constructor===Date){y=b.date64||createTypeTransition(b,je,8);c.setFloat64(r,o.getTime(),true);r+=8}else{g.push(i,o,K)}break}else{b=anyType(b,r,c,-10);if(b){y=b;r=Oe}else g.push(i,o,K)}break;case"boolean":y=b.num8||b.ascii8||createTypeTransition(b,ke,1);t[r++]=o?249:248;break;case"undefined":b=anyType(b,r,c,-9);if(b){y=b;r=Oe}else g.push(i,o,K);break;default:g.push(i,o,K)}K++}for(let e=0,i=g.length;e<i;){let i=g[e++];let a=g[e++];let o=g[e++];let l=y[i];if(!l){y[i]=l={key:i,parent:y,enumerationOffset:o-K,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null}}let u;if(a){let e;f=h-d;if(f<65280){y=l.object16;if(y)e=2;else if(y=l.object32)e=4;else{y=createTypeTransition(l,we,2);e=2}}else{y=l.object32||createTypeTransition(l,we,4);e=4}u=s(a,h);if(typeof u==="object"){h=u.position;c=u.targetView;t=u.target;d-=n;r-=n;p-=n;n=0}else h=u;if(e===2){c.setUint16(r,f,true);r+=2}else{c.setUint32(r,f,true);r+=4}}else{y=l.object16||createTypeTransition(l,we,2);c.setInt16(r,a===null?-10:-9,true);r+=2}K++}let S=y[de];if(S==null){S=o.typedStructs.length;let e=[];let t=y;let n,r;while((r=t.__type)!==undefined){let i=t.__size;t=t.__parent;n=t.key;let a=[r,i,n];if(t.enumerationOffset)a.push(t.enumerationOffset);e.push(a);t=t.parent}e.reverse();y[de]=S;o.typedStructs[S]=e;s(null,0,true)}switch(b){case 1:if(S>=16)return 0;t[p]=S+32;break;case 2:if(S>=256)return 0;t[p]=56;t[p+1]=S;break;case 3:if(S>=65536)return 0;t[p]=57;c.setUint16(p+1,S,true);break;case 4:if(S>=16777216)return 0;c.setUint32(p,(S<<8)+58,true);break}if(r<d){if(d===h)return r;t.copyWithin(r,d,h);h+=r-d;l.lastStringStart=r-p}else if(r>d){if(d===h)return r;l.lastStringStart=r-p;return writeStruct(e,t,n,p,i,a,s,o)}return h}function anyType(e,t,n,r){let i;if(i=e.ascii8||e.num8){n.setInt8(t,r,true);Oe=t+1;return i}if(i=e.string16||e.object16){n.setInt16(t,r,true);Oe=t+2;return i}if(i=e.num32){n.setUint32(t,3758096640+r,true);Oe=t+4;return i}if(i=e.num64){n.setFloat64(t,NaN,true);n.setInt8(t,r);Oe=t+8;return i}Oe=t;return}function createTypeTransition(e,t,n){let r=xe[t]+(n<<3);let i=e[r]||(e[r]=Object.create(null));i.__type=t;i.__size=n;i.__parent=e;return i}function onLoadedStructures(e){if(!(e instanceof Map))return e;let t=e.get("typed")||[];if(Object.isFrozen(t))t=t.map((e=>e.slice(0)));let n=e.get("named");let r=Object.create(null);for(let e=0,n=t.length;e<n;e++){let n=t[e];let i=r;for(let[e,t,r]of n){let n=i[r];if(!n){i[r]=n={key:r,parent:i,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null}}i=createTypeTransition(n,e,t)}i[de]=e}t.transitions=r;this.typedStructs=t;this.lastTypedStructuresLength=t.length;return n}var Me=Symbol.for("source");function readStruct(e,t,n,r){let i=e[t++]-32;if(i>=24){switch(i){case 24:i=e[t++];break;case 25:i=e[t++]+(e[t++]<<8);break;case 26:i=e[t++]+(e[t++]<<8)+(e[t++]<<16);break;case 27:i=e[t++]+(e[t++]<<8)+(e[t++]<<16)+(e[t++]<<24);break}}let a=r.typedStructs&&r.typedStructs[i];if(!a){e=Uint8Array.prototype.slice.call(e,t,n);n-=t;t=0;if(!r.getStructures)throw new Error(`Reference to shared structure ${i} without getStructures method`);r._mergeStructures(r.getStructures());if(!r.typedStructs)throw new Error("Could not find any shared typed structures");r.lastTypedStructuresLength=r.typedStructs.length;a=r.typedStructs[i];if(!a)throw new Error("Could not find typed structure "+i)}var s=a.construct;var o=a.fullConstruct;if(!s){s=a.construct=function LazyObject(){};o=a.fullConstruct=function LoadedObject(){};o.prototype=r.structPrototype??{};var l=s.prototype=r.structPrototype?Object.create(r.structPrototype):{};let e=[];let t=0;let n;for(let i=0,s=a.length;i<s;i++){let s=a[i];let[o,l,c,d]=s;if(c==="__proto__")c="__proto_";let u={key:c,offset:t};if(d)e.splice(i+d,0,u);else e.push(u);let p;switch(l){case 0:p=()=>0;break;case 1:p=(e,t)=>{let n=e.bytes[t+u.offset];return n>=246?toConstant(n):n};break;case 2:p=(e,t)=>{let n=e.bytes;let r=n.dataView||(n.dataView=new DataView(n.buffer,n.byteOffset,n.byteLength));let i=r.getUint16(t+u.offset,true);return i>=65280?toConstant(i&255):i};break;case 4:p=(e,t)=>{let n=e.bytes;let r=n.dataView||(n.dataView=new DataView(n.buffer,n.byteOffset,n.byteLength));let i=r.getUint32(t+u.offset,true);return i>=4294967040?toConstant(i&255):i};break}u.getRef=p;t+=l;let f;switch(o){case Ee:if(n&&!n.next)n.next=u;n=u;u.multiGetCount=0;f=function(e){let n=e.bytes;let r=e.position;let i=t+r;let a=p(e,r);if(typeof a!=="number")return a;let s,o=u.next;while(o){s=o.getRef(e,r);if(typeof s==="number")break;else s=null;o=o.next}if(s==null)s=e.bytesEnd-i;if(e.srcString){return e.srcString.slice(a,s)}return readString(n,a+i,s-a)};break;case Ie:case we:if(n&&!n.next)n.next=u;n=u;f=function(e){let n=e.position;let i=t+n;let a=p(e,n);if(typeof a!=="number")return a;let s=e.bytes;let l,c=u.next;while(c){l=c.getRef(e,n);if(typeof l==="number")break;else l=null;c=c.next}if(l==null)l=e.bytesEnd-i;if(o===Ie){return s.toString("utf8",a+i,l+i)}else{Re=e;try{return r.unpack(s,{start:a+i,end:l+i})}finally{Re=null}}};break;case ke:switch(l){case 4:f=function(e){let t=e.bytes;let n=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength));let r=e.position+u.offset;let i=n.getInt32(r,true);if(i<536870912){if(i>-520093696)return i;if(i>-536870912)return toConstant(i&255)}let a=n.getFloat32(r,true);let s=J[(t[r+3]&127)<<1|t[r+2]>>7];return(s*a+(a>0?.5:-.5)>>0)/s};break;case 8:f=function(e){let t=e.bytes;let n=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength));let r=n.getFloat64(e.position+u.offset,true);if(isNaN(r)){let n=t[e.position+u.offset];if(n>=246)return toConstant(n)}return r};break;case 1:f=function(e){let t=e.bytes;let n=t[e.position+u.offset];return n<246?n:toConstant(n)};break}break;case je:f=function(e){let t=e.bytes;let n=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength));return new Date(n.getFloat64(e.position+u.offset,true))};break}u.get=f}if(De){let t=[];let n=[];let i=0;let a;for(let s of e){if(r.alwaysLazyProperty&&r.alwaysLazyProperty(s.key)){a=true;continue}Object.defineProperty(l,s.key,{get:withSource(s.get),enumerable:true});let e="v"+i++;n.push(e);t.push("o["+JSON.stringify(s.key)+"]="+e+"(s)")}if(a){t.push("__proto__:this")}let s=new Function(...n,"var c=this;return function(s){var o=new c();"+t.join(";")+";return o;}").apply(o,e.map((e=>e.get)));Object.defineProperty(l,"toJSON",{value(e){return s.call(this,this[Me])}})}else{Object.defineProperty(l,"toJSON",{value(t){let n={};for(let t=0,r=e.length;t<r;t++){let r=e[t].key;n[r]=this[r]}return n}})}}var c=new s;c[Me]={bytes:e,position:t,srcString:"",bytesEnd:n};return c}function toConstant(e){switch(e){case 246:return null;case 247:return undefined;case 248:return false;case 249:return true}throw new Error("Unknown constant")}function withSource(e){return function(){return e(this[Me])}}function saveState(){if(Re){Re.bytes=Uint8Array.prototype.slice.call(Re.bytes,Re.position,Re.bytesEnd);Re.position=0;Re.bytesEnd=Re.bytes.length}}function prepareStructures(e,t){if(t.typedStructs){let n=new Map;n.set("named",e);n.set("typed",t.typedStructs);e=n}let n=t.lastTypedStructuresLength||0;e.isCompatible=e=>{let r=true;if(e instanceof Map){let i=e.get("named")||[];if(i.length!==(t.lastNamedStructuresLength||0))r=false;let a=e.get("typed")||[];if(a.length!==n)r=false}else if(e instanceof Array||Array.isArray(e)){if(e.length!==(t.lastNamedStructuresLength||0))r=false}if(!r)t._mergeStructures(e);return r};t.lastTypedStructuresLength=t.typedStructs&&t.typedStructs.length;return e}setReadStruct(readStruct,onLoadedStructures,saveState);class PackrStream extends r.Transform{constructor(e){if(!e)e={};e.writableObjectMode=true;super(e);e.sequential=true;this.packr=e.packr||new Packr(e)}_transform(e,t,n){this.push(this.packr.pack(e));n()}}class UnpackrStream extends r.Transform{constructor(e){if(!e)e={};e.objectMode=true;super(e);e.structures=[];this.unpackr=e.unpackr||new Unpackr(e)}_transform(e,t,n){if(this.incompleteBuffer){e=Buffer.concat([this.incompleteBuffer,e]);this.incompleteBuffer=null}let r;try{r=this.unpackr.unpackMultiple(e)}catch(t){if(t.incomplete){this.incompleteBuffer=e.slice(t.lastPosition);r=t.values}else throw t}finally{for(let e of r||[]){if(e===null)e=this.getNullValue();this.push(e)}}if(n)n()}getNullValue(){return Symbol.for(null)}}function packIter(e,t={}){if(!e||typeof e!=="object"){throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable")}else if(typeof e[Symbol.iterator]==="function"){return packIterSync(e,t)}else if(typeof e.then==="function"||typeof e[Symbol.asyncIterator]==="function"){return packIterAsync(e,t)}else{throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}}function*packIterSync(e,t){const n=new Packr(t);for(const t of e){yield n.pack(t)}}async function*packIterAsync(e,t){const n=new Packr(t);for await(const t of e){yield n.pack(t)}}function unpackIter(e,t={}){if(!e||typeof e!=="object"){throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise")}const n=new Unpackr(t);let r;const parser=e=>{let t;if(r){e=Buffer.concat([r,e]);r=undefined}try{t=n.unpackMultiple(e)}catch(n){if(n.incomplete){r=e.slice(n.lastPosition);t=n.values}else{throw n}}return t};if(typeof e[Symbol.iterator]==="function"){return function*iter(){for(const t of e){yield*parser(t)}}()}else if(typeof e[Symbol.asyncIterator]==="function"){return async function*iter(){for await(const t of e){yield*parser(t)}}()}}const _e=unpackIter;const Ne=packIter;const Le=false;const Je=true;const Fe=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==undefined&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!Fe){let e;try{if(true)e=n(86);else{}if(e)setExtractor(e.extractStrings)}catch(e){}}t.ALWAYS=me;t.C1=E;t.DECIMAL_FIT=ge;t.DECIMAL_ROUND=be;t.Decoder=F;t.DecoderStream=UnpackrStream;t.Encoder=he;t.EncoderStream=PackrStream;t.FLOAT32_OPTIONS=B;t.NEVER=ye;t.Packr=Packr;t.PackrStream=PackrStream;t.Unpackr=Unpackr;t.UnpackrStream=UnpackrStream;t.addExtension=addExtension;t.clearSource=clearSource;t.decode=Y;t.decodeIter=_e;t.encode=fe;t.encodeIter=Ne;t.mapsAsObjects=Je;t.pack=pe;t.roundFloat32=roundFloat32;t.unpack=q;t.unpackMultiple=G;t.useRecords=Le},8148:function(e){"use strict";e.exports=JSON.parse('{"acl":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"append":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"asking":{"arity":1,"flags":["fast"],"keyStart":0,"keyStop":0,"step":0},"auth":{"arity":-2,"flags":["noscript","loading","stale","fast","no_auth","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"bgrewriteaof":{"arity":1,"flags":["admin","noscript","no_async_loading"],"keyStart":0,"keyStop":0,"step":0},"bgsave":{"arity":-1,"flags":["admin","noscript","no_async_loading"],"keyStart":0,"keyStop":0,"step":0},"bitcount":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"bitfield":{"arity":-2,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"bitfield_ro":{"arity":-2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"bitop":{"arity":-4,"flags":["write","denyoom"],"keyStart":2,"keyStop":-1,"step":1},"bitpos":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"blmove":{"arity":6,"flags":["write","denyoom","noscript","blocking"],"keyStart":1,"keyStop":2,"step":1},"blmpop":{"arity":-5,"flags":["write","blocking","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"blpop":{"arity":-3,"flags":["write","noscript","blocking"],"keyStart":1,"keyStop":-2,"step":1},"brpop":{"arity":-3,"flags":["write","noscript","blocking"],"keyStart":1,"keyStop":-2,"step":1},"brpoplpush":{"arity":4,"flags":["write","denyoom","noscript","blocking"],"keyStart":1,"keyStop":2,"step":1},"bzmpop":{"arity":-5,"flags":["write","blocking","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"bzpopmax":{"arity":-3,"flags":["write","noscript","blocking","fast"],"keyStart":1,"keyStop":-2,"step":1},"bzpopmin":{"arity":-3,"flags":["write","noscript","blocking","fast"],"keyStart":1,"keyStop":-2,"step":1},"client":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"cluster":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"command":{"arity":-1,"flags":["loading","stale"],"keyStart":0,"keyStop":0,"step":0},"config":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"copy":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"dbsize":{"arity":1,"flags":["readonly","fast"],"keyStart":0,"keyStop":0,"step":0},"debug":{"arity":-2,"flags":["admin","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"decr":{"arity":2,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"decrby":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"del":{"arity":-2,"flags":["write"],"keyStart":1,"keyStop":-1,"step":1},"discard":{"arity":1,"flags":["noscript","loading","stale","fast","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"dump":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"echo":{"arity":2,"flags":["fast"],"keyStart":0,"keyStop":0,"step":0},"eval":{"arity":-3,"flags":["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"eval_ro":{"arity":-3,"flags":["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"evalsha":{"arity":-3,"flags":["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"evalsha_ro":{"arity":-3,"flags":["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"exec":{"arity":1,"flags":["noscript","loading","stale","skip_slowlog"],"keyStart":0,"keyStop":0,"step":0},"exists":{"arity":-2,"flags":["readonly","fast"],"keyStart":1,"keyStop":-1,"step":1},"expire":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"expireat":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"expiretime":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"failover":{"arity":-1,"flags":["admin","noscript","stale"],"keyStart":0,"keyStop":0,"step":0},"fcall":{"arity":-3,"flags":["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"fcall_ro":{"arity":-3,"flags":["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"flushall":{"arity":-1,"flags":["write"],"keyStart":0,"keyStop":0,"step":0},"flushdb":{"arity":-1,"flags":["write"],"keyStart":0,"keyStop":0,"step":0},"function":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"geoadd":{"arity":-5,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"geodist":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"geohash":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"geopos":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"georadius":{"arity":-6,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"georadius_ro":{"arity":-6,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"georadiusbymember":{"arity":-5,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"georadiusbymember_ro":{"arity":-5,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"geosearch":{"arity":-7,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"geosearchstore":{"arity":-8,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"get":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"getbit":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"getdel":{"arity":2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"getex":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"getrange":{"arity":4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"getset":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hdel":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"hello":{"arity":-1,"flags":["noscript","loading","stale","fast","no_auth","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"hexists":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hget":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hgetall":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"hincrby":{"arity":4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hincrbyfloat":{"arity":4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hkeys":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"hlen":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hmget":{"arity":-3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hmset":{"arity":-4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hrandfield":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"hscan":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"hset":{"arity":-4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hsetnx":{"arity":4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hstrlen":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hvals":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"incr":{"arity":2,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"incrby":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"incrbyfloat":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"info":{"arity":-1,"flags":["loading","stale"],"keyStart":0,"keyStop":0,"step":0},"keys":{"arity":2,"flags":["readonly"],"keyStart":0,"keyStop":0,"step":0},"lastsave":{"arity":1,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"latency":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"lcs":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":2,"step":1},"lindex":{"arity":3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"linsert":{"arity":5,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"llen":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"lmove":{"arity":5,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"lmpop":{"arity":-4,"flags":["write","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"lolwut":{"arity":-1,"flags":["readonly","fast"],"keyStart":0,"keyStop":0,"step":0},"lpop":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"lpos":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"lpush":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"lpushx":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"lrange":{"arity":4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"lrem":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"lset":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"ltrim":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"memory":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"mget":{"arity":-2,"flags":["readonly","fast"],"keyStart":1,"keyStop":-1,"step":1},"migrate":{"arity":-6,"flags":["write","movablekeys"],"keyStart":3,"keyStop":3,"step":1},"module":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"monitor":{"arity":1,"flags":["admin","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"move":{"arity":3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"mset":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":2},"msetnx":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":2},"multi":{"arity":1,"flags":["noscript","loading","stale","fast","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"object":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"persist":{"arity":2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"pexpire":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"pexpireat":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"pexpiretime":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"pfadd":{"arity":-2,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"pfcount":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":-1,"step":1},"pfdebug":{"arity":3,"flags":["write","denyoom","admin"],"keyStart":2,"keyStop":2,"step":1},"pfmerge":{"arity":-2,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":1},"pfselftest":{"arity":1,"flags":["admin"],"keyStart":0,"keyStop":0,"step":0},"ping":{"arity":-1,"flags":["fast"],"keyStart":0,"keyStop":0,"step":0},"psetex":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"psubscribe":{"arity":-2,"flags":["pubsub","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"psync":{"arity":-3,"flags":["admin","noscript","no_async_loading","no_multi"],"keyStart":0,"keyStop":0,"step":0},"pttl":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"publish":{"arity":3,"flags":["pubsub","loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"pubsub":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"punsubscribe":{"arity":-1,"flags":["pubsub","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"quit":{"arity":-1,"flags":["noscript","loading","stale","fast","no_auth","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"randomkey":{"arity":1,"flags":["readonly"],"keyStart":0,"keyStop":0,"step":0},"readonly":{"arity":1,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"readwrite":{"arity":1,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"rename":{"arity":3,"flags":["write"],"keyStart":1,"keyStop":2,"step":1},"renamenx":{"arity":3,"flags":["write","fast"],"keyStart":1,"keyStop":2,"step":1},"replconf":{"arity":-1,"flags":["admin","noscript","loading","stale","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"replicaof":{"arity":3,"flags":["admin","noscript","stale","no_async_loading"],"keyStart":0,"keyStop":0,"step":0},"reset":{"arity":1,"flags":["noscript","loading","stale","fast","no_auth","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"restore":{"arity":-4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"restore-asking":{"arity":-4,"flags":["write","denyoom","asking"],"keyStart":1,"keyStop":1,"step":1},"role":{"arity":1,"flags":["noscript","loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"rpop":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"rpoplpush":{"arity":3,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"rpush":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"rpushx":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"sadd":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"save":{"arity":1,"flags":["admin","noscript","no_async_loading","no_multi"],"keyStart":0,"keyStop":0,"step":0},"scan":{"arity":-2,"flags":["readonly"],"keyStart":0,"keyStop":0,"step":0},"scard":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"script":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"sdiff":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":-1,"step":1},"sdiffstore":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":1},"select":{"arity":2,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"set":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"setbit":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"setex":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"setnx":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"setrange":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"shutdown":{"arity":-1,"flags":["admin","noscript","loading","stale","no_multi","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"sinter":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":-1,"step":1},"sintercard":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"sinterstore":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":1},"sismember":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"slaveof":{"arity":3,"flags":["admin","noscript","stale","no_async_loading"],"keyStart":0,"keyStop":0,"step":0},"slowlog":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"smembers":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"smismember":{"arity":-3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"smove":{"arity":4,"flags":["write","fast"],"keyStart":1,"keyStop":2,"step":1},"sort":{"arity":-2,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"sort_ro":{"arity":-2,"flags":["readonly","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"spop":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"spublish":{"arity":3,"flags":["pubsub","loading","stale","fast"],"keyStart":1,"keyStop":1,"step":1},"srandmember":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"srem":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"sscan":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"ssubscribe":{"arity":-2,"flags":["pubsub","noscript","loading","stale"],"keyStart":1,"keyStop":-1,"step":1},"strlen":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"subscribe":{"arity":-2,"flags":["pubsub","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"substr":{"arity":4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"sunion":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":-1,"step":1},"sunionstore":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":1},"sunsubscribe":{"arity":-1,"flags":["pubsub","noscript","loading","stale"],"keyStart":1,"keyStop":-1,"step":1},"swapdb":{"arity":3,"flags":["write","fast"],"keyStart":0,"keyStop":0,"step":0},"sync":{"arity":1,"flags":["admin","noscript","no_async_loading","no_multi"],"keyStart":0,"keyStop":0,"step":0},"time":{"arity":1,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"touch":{"arity":-2,"flags":["readonly","fast"],"keyStart":1,"keyStop":-1,"step":1},"ttl":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"type":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"unlink":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":-1,"step":1},"unsubscribe":{"arity":-1,"flags":["pubsub","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"unwatch":{"arity":1,"flags":["noscript","loading","stale","fast","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"wait":{"arity":3,"flags":["noscript"],"keyStart":0,"keyStop":0,"step":0},"watch":{"arity":-2,"flags":["noscript","loading","stale","fast","allow_busy"],"keyStart":1,"keyStop":-1,"step":1},"xack":{"arity":-4,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"xadd":{"arity":-5,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"xautoclaim":{"arity":-6,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"xclaim":{"arity":-6,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"xdel":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"xgroup":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"xinfo":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"xlen":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"xpending":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"xrange":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"xread":{"arity":-4,"flags":["readonly","blocking","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"xreadgroup":{"arity":-7,"flags":["write","blocking","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"xrevrange":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"xsetid":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"xtrim":{"arity":-4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"zadd":{"arity":-4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"zcard":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zcount":{"arity":4,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zdiff":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zdiffstore":{"arity":-4,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"zincrby":{"arity":4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"zinter":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zintercard":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zinterstore":{"arity":-4,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"zlexcount":{"arity":4,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zmpop":{"arity":-4,"flags":["write","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zmscore":{"arity":-3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zpopmax":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"zpopmin":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"zrandmember":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrange":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrangebylex":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrangebyscore":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrangestore":{"arity":-5,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"zrank":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zrem":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"zremrangebylex":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"zremrangebyrank":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"zremrangebyscore":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"zrevrange":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrevrangebylex":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrevrangebyscore":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrevrank":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zscan":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zscore":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zunion":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zunionstore":{"arity":-4,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1}}')}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var n=__webpack_module_cache__[e]={id:e,loaded:false,exports:{}};var r=true;try{__webpack_modules__[e].call(n.exports,n,n.exports,__nccwpck_require__);r=false}finally{if(r)delete __webpack_module_cache__[e]}n.loaded=true;return n.exports}!function(){__nccwpck_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}();!function(){__nccwpck_require__.nmd=function(e){e.paths=[];if(!e.children)e.children=[];return e}}();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(8610);module.exports=__webpack_exports__})();
|
|
1
|
+
(function(){var __webpack_modules__={3175:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getKeyIndexes=t.hasFlag=t.exists=t.list=void 0;const i=r(n(435));t.list=Object.keys(i.default);const s={};t.list.forEach((e=>{s[e]=i.default[e].flags.reduce((function(e,t){e[t]=true;return e}),{})}));function exists(e){return Boolean(i.default[e])}t.exists=exists;function hasFlag(e,t){if(!s[e]){throw new Error("Unknown command "+e)}return Boolean(s[e][t])}t.hasFlag=hasFlag;function getKeyIndexes(e,t,n){const r=i.default[e];if(!r){throw new Error("Unknown command "+e)}if(!Array.isArray(t)){throw new Error("Expect args to be an array")}const s=[];const a=Boolean(n&&n.parseExternalKey);const takeDynamicKeys=(e,t)=>{const n=[];const r=Number(e[t]);for(let e=0;e<r;e++){n.push(e+t+1)}return n};const takeKeyAfterToken=(e,t,n)=>{for(let r=t;r<e.length-1;r+=1){if(String(e[r]).toLowerCase()===n.toLowerCase()){return r+1}}return null};switch(e){case"zunionstore":case"zinterstore":case"zdiffstore":s.push(0,...takeDynamicKeys(t,1));break;case"eval":case"evalsha":case"eval_ro":case"evalsha_ro":case"fcall":case"fcall_ro":case"blmpop":case"bzmpop":s.push(...takeDynamicKeys(t,1));break;case"sintercard":case"lmpop":case"zunion":case"zinter":case"zmpop":case"zintercard":case"zdiff":{s.push(...takeDynamicKeys(t,0));break}case"georadius":{s.push(0);const e=takeKeyAfterToken(t,5,"STORE");if(e)s.push(e);const n=takeKeyAfterToken(t,5,"STOREDIST");if(n)s.push(n);break}case"georadiusbymember":{s.push(0);const e=takeKeyAfterToken(t,4,"STORE");if(e)s.push(e);const n=takeKeyAfterToken(t,4,"STOREDIST");if(n)s.push(n);break}case"sort":case"sort_ro":s.push(0);for(let e=1;e<t.length-1;e++){let n=t[e];if(typeof n!=="string"){continue}const r=n.toUpperCase();if(r==="GET"){e+=1;n=t[e];if(n!=="#"){if(a){s.push([e,getExternalKeyNameLength(n)])}else{s.push(e)}}}else if(r==="BY"){e+=1;if(a){s.push([e,getExternalKeyNameLength(t[e])])}else{s.push(e)}}else if(r==="STORE"){e+=1;s.push(e)}}break;case"migrate":if(t[2]===""){for(let e=5;e<t.length-1;e++){const n=t[e];if(typeof n==="string"&&n.toUpperCase()==="KEYS"){for(let n=e+1;n<t.length;n++){s.push(n)}break}}}else{s.push(2)}break;case"xreadgroup":case"xread":for(let n=e==="xread"?0:3;n<t.length-1;n++){if(String(t[n]).toUpperCase()==="STREAMS"){for(let e=n+1;e<=n+(t.length-1-n)/2;e++){s.push(e)}break}}break;default:if(r.step>0){const e=r.keyStart-1;const n=r.keyStop>0?r.keyStop:t.length+r.keyStop+1;for(let t=e;t<n;t+=r.step){s.push(t)}}break}return s}t.getKeyIndexes=getKeyIndexes;function getExternalKeyNameLength(e){if(typeof e!=="string"){e=String(e)}const t=e.indexOf("->");return t===-1?e.length:t}},3581:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.AsyncFifoQueue=void 0;class Node{constructor(e){this.value=undefined;this.next=null;this.value=e}}class LinkedList{constructor(){this.length=0;this.head=null;this.tail=null}push(e){const t=new Node(e);if(!this.length){this.head=t}else{this.tail.next=t}this.tail=t;this.length+=1;return t}shift(){if(!this.length){return null}else{const e=this.head;this.head=this.head.next;this.length-=1;return e}}}class AsyncFifoQueue{constructor(e=false){this.ignoreErrors=e;this.queue=new LinkedList;this.pending=new Set;this.newPromise()}add(e){this.pending.add(e);e.then((t=>{this.pending.delete(e);if(this.queue.length===0){this.resolvePromise(t)}this.queue.push(t)})).catch((t=>{if(this.ignoreErrors){this.queue.push(undefined)}this.pending.delete(e);this.rejectPromise(t)}))}async waitAll(){await Promise.all(this.pending)}numTotal(){return this.pending.size+this.queue.length}numPending(){return this.pending.size}numQueued(){return this.queue.length}resolvePromise(e){this.resolve(e);this.newPromise()}rejectPromise(e){this.reject(e);this.newPromise()}newPromise(){this.nextPromise=new Promise(((e,t)=>{this.resolve=e;this.reject=t}))}async wait(){return this.nextPromise}async fetch(){var e;if(this.pending.size===0&&this.queue.length===0){return}while(this.queue.length===0){try{await this.wait()}catch(e){if(!this.ignoreErrors){console.error("Unexpected Error in AsyncFifoQueue",e)}}}return(e=this.queue.shift())===null||e===void 0?void 0:e.value}}t.AsyncFifoQueue=AsyncFifoQueue},5303:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Backoffs=void 0;class Backoffs{static normalize(e){if(Number.isFinite(e)){return{type:"fixed",delay:e}}else if(e){return e}}static calculate(e,t,n,r,i){if(e){const s=lookupStrategy(e,i);return s(t,e.type,n,r)}}}t.Backoffs=Backoffs;Backoffs.builtinStrategies={fixed:function(e,t=0){return function(){if(t>0){const n=e*(1-t);return Math.floor(Math.random()*e*t+n)}else{return e}}},exponential:function(e,t=0){return function(n){if(t>0){const r=Math.round(Math.pow(2,n-1)*e);const i=r*(1-t);return Math.floor(Math.random()*r*t+i)}else{return Math.round(Math.pow(2,n-1)*e)}}}};function lookupStrategy(e,t){if(e.type in Backoffs.builtinStrategies){return Backoffs.builtinStrategies[e.type](e.delay,e.jitter)}else if(t){return t}else{throw new Error(`Unknown backoff strategy ${e.type}.\n If a custom backoff strategy is used, specify it when the queue is created.`)}}},8853:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ChildPool=void 0;const r=n(6928);const i=n(9882);const s=3e4;class ChildPool{constructor({mainFile:e=r.join(process.cwd(),"dist/cjs/classes/main.js"),useWorkerThreads:t,workerForkOptions:n,workerThreadsOptions:i}){this.retained={};this.free={};this.opts={mainFile:e,useWorkerThreads:t,workerForkOptions:n,workerThreadsOptions:i}}async retain(e){let t=this.getFree(e).pop();if(t){this.retained[t.pid]=t;return t}t=new i.Child(this.opts.mainFile,e,{useWorkerThreads:this.opts.useWorkerThreads,workerForkOptions:this.opts.workerForkOptions,workerThreadsOptions:this.opts.workerThreadsOptions});t.on("exit",this.remove.bind(this,t));try{await t.init();if(t.exitCode!==null||t.signalCode!==null){throw new Error("Child exited before it could be retained")}this.retained[t.pid]=t;return t}catch(e){console.error(e);this.release(t);throw e}}release(e){delete this.retained[e.pid];this.getFree(e.processFile).push(e)}remove(e){delete this.retained[e.pid];const t=this.getFree(e.processFile);const n=t.indexOf(e);if(n>-1){t.splice(n,1)}}async kill(e,t="SIGKILL"){this.remove(e);return e.kill(t,s)}async clean(){const e=Object.values(this.retained).concat(this.getAllFree());this.retained={};this.free={};await Promise.all(e.map((e=>this.kill(e,"SIGTERM"))))}getFree(e){return this.free[e]=this.free[e]||[]}getAllFree(){return Object.values(this.free).reduce(((e,t)=>e.concat(t)),[])}}t.ChildPool=ChildPool},415:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ChildProcessor=void 0;const r=n(6694);const i=n(2646);var s;(function(e){e[e["Idle"]=0]="Idle";e[e["Started"]=1]="Started";e[e["Terminating"]=2]="Terminating";e[e["Errored"]=3]="Errored"})(s||(s={}));const a=process.env.NODE_ENV==="test"?500:5e3;class ChildProcessor{constructor(e,t){this.send=e;this.receiver=t}async init(e){let t;try{const{default:r}=await n(9761)(e);t=r;if(t.default){t=t.default}if(typeof t!=="function"){throw new Error("No function is exported in processor file")}}catch(e){this.status=s.Errored;return this.send({cmd:r.ParentCommand.InitFailed,err:(0,i.errorToJSON)(e)})}const a=t;t=function(e,t){try{return Promise.resolve(a(e,t))}catch(e){return Promise.reject(e)}};this.processor=t;this.status=s.Idle;await this.send({cmd:r.ParentCommand.InitCompleted})}async start(e,t){if(this.status!==s.Idle){return this.send({cmd:r.ParentCommand.Error,err:(0,i.errorToJSON)(new Error("cannot start a not idling child process"))})}this.status=s.Started;this.currentJobPromise=(async()=>{try{const n=this.wrapJob(e,this.send);const i=await this.processor(n,t);await this.send({cmd:r.ParentCommand.Completed,value:typeof i==="undefined"?null:i})}catch(e){await this.send({cmd:r.ParentCommand.Failed,value:(0,i.errorToJSON)(!e.message?new Error(e):e)})}finally{this.status=s.Idle;this.currentJobPromise=undefined}})()}async stop(){}async waitForCurrentJobAndExit(){this.status=s.Terminating;try{await this.currentJobPromise}finally{process.exit(process.exitCode||0)}}wrapJob(e,t){const n=Object.assign(Object.assign({},e),{data:JSON.parse(e.data||"{}"),opts:e.opts,returnValue:JSON.parse(e.returnvalue||"{}"),async updateProgress(e){this.progress=e;await t({cmd:r.ParentCommand.Progress,value:e})},log:async e=>{await t({cmd:r.ParentCommand.Log,value:e})},moveToDelayed:async(e,n)=>{await t({cmd:r.ParentCommand.MoveToDelayed,value:{timestamp:e,token:n}})},moveToWait:async e=>{await t({cmd:r.ParentCommand.MoveToWait,value:{token:e}})},updateData:async e=>{await t({cmd:r.ParentCommand.Update,value:e});n.data=e},getChildrenValues:async()=>{const e=Math.random().toString(36).substring(2,15);await t({requestId:e,cmd:r.ParentCommand.GetChildrenValues});return waitResponse(e,this.receiver,a,"getChildrenValues")},getIgnoredChildrenFailures:async()=>{const e=Math.random().toString(36).substring(2,15);await t({requestId:e,cmd:r.ParentCommand.GetIgnoredChildrenFailures});return waitResponse(e,this.receiver,a,"getIgnoredChildrenFailures")}});return n}}t.ChildProcessor=ChildProcessor;const waitResponse=async(e,t,n,r)=>new Promise(((i,s)=>{const listener=n=>{if(n.requestId===e){i(n.value);t.off("message",listener)}};t.on("message",listener);setTimeout((()=>{t.off("message",listener);s(new Error(`TimeoutError: ${r} timed out in (${n}ms)`))}),n)}))},9882:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Child=void 0;const r=n(5317);const i=n(9278);const s=n(8167);const a=n(6694);const o=n(4434);const l={1:"Uncaught Fatal Exception",2:"Unused",3:"Internal JavaScript Parse Error",4:"Internal JavaScript Evaluation Failure",5:"Fatal Error",6:"Non-function Internal Exception Handler",7:"Internal Exception Handler Run-Time Failure",8:"Unused",9:"Invalid Argument",10:"Internal JavaScript Run-Time Failure",12:"Invalid Debug Argument",13:"Unfinished Top-Level Await"};class Child extends o.EventEmitter{constructor(e,t,n={useWorkerThreads:false}){super();this.mainFile=e;this.processFile=t;this.opts=n;this._exitCode=null;this._signalCode=null;this._killed=false}get pid(){if(this.childProcess){return this.childProcess.pid}else if(this.worker){return Math.abs(this.worker.threadId)}else{throw new Error("No child process or worker thread")}}get exitCode(){return this._exitCode}get signalCode(){return this._signalCode}get killed(){if(this.childProcess){return this.childProcess.killed}return this._killed}async init(){const e=await convertExecArgv(process.execArgv);let t;if(this.opts.useWorkerThreads){this.worker=t=new s.Worker(this.mainFile,Object.assign({execArgv:e,stdin:true,stdout:true,stderr:true},this.opts.workerThreadsOptions?this.opts.workerThreadsOptions:{}))}else{this.childProcess=t=(0,r.fork)(this.mainFile,[],Object.assign({execArgv:e,stdio:"pipe"},this.opts.workerForkOptions?this.opts.workerForkOptions:{}))}t.on("exit",((e,n)=>{this._exitCode=e;n=typeof n==="undefined"?null:n;this._signalCode=n;this._killed=true;this.emit("exit",e,n);t.removeAllListeners();this.removeAllListeners()}));t.on("error",((...e)=>this.emit("error",...e)));t.on("message",((...e)=>this.emit("message",...e)));t.on("close",((...e)=>this.emit("close",...e)));t.stdout.pipe(process.stdout);t.stderr.pipe(process.stderr);await this.initChild()}async send(e){return new Promise(((t,n)=>{if(this.childProcess){this.childProcess.send(e,(e=>{if(e){n(e)}else{t()}}))}else if(this.worker){t(this.worker.postMessage(e))}else{t()}}))}killProcess(e="SIGKILL"){if(this.childProcess){this.childProcess.kill(e)}else if(this.worker){this.worker.terminate()}}async kill(e="SIGKILL",t){if(this.hasProcessExited()){return}const n=onExitOnce(this.childProcess||this.worker);this.killProcess(e);if(t!==undefined&&(t===0||isFinite(t))){const e=setTimeout((()=>{if(!this.hasProcessExited()){this.killProcess("SIGKILL")}}),t);await n;clearTimeout(e)}await n}async initChild(){const e=new Promise(((e,t)=>{const onMessageHandler=n=>{if(n.cmd===a.ParentCommand.InitCompleted){e()}else if(n.cmd===a.ParentCommand.InitFailed){const e=new Error;e.stack=n.err.stack;e.message=n.err.message;t(e)}this.off("message",onMessageHandler);this.off("close",onCloseHandler)};const onCloseHandler=(e,n)=>{if(e>128){e-=128}const r=l[e]||`Unknown exit code ${e}`;t(new Error(`Error initializing child: ${r} and signal ${n}`));this.off("message",onMessageHandler);this.off("close",onCloseHandler)};this.on("message",onMessageHandler);this.on("close",onCloseHandler)}));await this.send({cmd:a.ChildCommand.Init,value:this.processFile});await e}hasProcessExited(){return!!(this.exitCode!==null||this.signalCode)}}t.Child=Child;function onExitOnce(e){return new Promise((t=>{e.once("exit",(()=>t()))}))}const getFreePort=async()=>new Promise((e=>{const t=(0,i.createServer)();t.listen(0,(()=>{const{port:n}=t.address();t.close((()=>e(n)))}))}));const convertExecArgv=async e=>{const t=[];const n=[];for(let r=0;r<e.length;r++){const i=e[r];if(i.indexOf("--inspect")===-1){t.push(i)}else{const e=i.split("=")[0];const t=await getFreePort();n.push(`${e}=${t}`)}}return t.concat(n)}},4583:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.DelayedError=t.DELAYED_ERROR=void 0;t.DELAYED_ERROR="bullmq:movedToDelayed";class DelayedError extends Error{constructor(e=t.DELAYED_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.DelayedError=DelayedError},6342:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(4583),t);r.__exportStar(n(9443),t);r.__exportStar(n(7200),t);r.__exportStar(n(9602),t);r.__exportStar(n(5066),t)},9443:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.RateLimitError=t.RATE_LIMIT_ERROR=void 0;t.RATE_LIMIT_ERROR="bullmq:rateLimitExceeded";class RateLimitError extends Error{constructor(e=t.RATE_LIMIT_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.RateLimitError=RateLimitError},7200:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.UnrecoverableError=t.UNRECOVERABLE_ERROR=void 0;t.UNRECOVERABLE_ERROR="bullmq:unrecoverable";class UnrecoverableError extends Error{constructor(e=t.UNRECOVERABLE_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.UnrecoverableError=UnrecoverableError},9602:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.WaitingChildrenError=t.WAITING_CHILDREN_ERROR=void 0;t.WAITING_CHILDREN_ERROR="bullmq:movedToWaitingChildren";class WaitingChildrenError extends Error{constructor(e=t.WAITING_CHILDREN_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.WaitingChildrenError=WaitingChildrenError},5066:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.WaitingError=t.WAITING_ERROR=void 0;t.WAITING_ERROR="bullmq:movedToWait";class WaitingError extends Error{constructor(e=t.WAITING_ERROR){super(e);this.name=this.constructor.name;Object.setPrototypeOf(this,new.target.prototype)}}t.WaitingError=WaitingError},5249:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.FlowProducer=void 0;const r=n(4434);const i=n(9935);const s=n(2646);const a=n(5183);const o=n(4920);const l=n(3420);const c=n(6694);class FlowProducer extends r.EventEmitter{constructor(e={connection:{}},t=l.RedisConnection){super();this.opts=e;this.opts=Object.assign({prefix:"bull"},e);this.connection=new t(e.connection,{shared:(0,s.isRedisInstance)(e.connection),blocking:false,skipVersionCheck:e.skipVersionCheck,skipWaitingForReady:e.skipWaitingForReady});this.connection.on("error",(e=>this.emit("error",e)));this.connection.on("close",(()=>{if(!this.closing){this.emit("ioredis:close")}}));this.queueKeys=new o.QueueKeys(e.prefix);if(e===null||e===void 0?void 0:e.telemetry){this.telemetry=e.telemetry}}emit(e,...t){return super.emit(e,...t)}off(e,t){super.off(e,t);return this}on(e,t){super.on(e,t);return this}once(e,t){super.once(e,t);return this}get client(){return this.connection.client}get Job(){return a.Job}waitUntilReady(){return this.client}async add(e,t){var n;if(this.closing){return}const r=await this.connection.client;const i=r.multi();const a=(n=e===null||e===void 0?void 0:e.opts)===null||n===void 0?void 0:n.parent;const o=(0,s.getParentKey)(a);const l=o?`${o}:dependencies`:undefined;return(0,s.trace)(this.telemetry,c.SpanKind.PRODUCER,e.queueName,"addFlow",e.queueName,(async n=>{n===null||n===void 0?void 0:n.setAttributes({[c.TelemetryAttributes.FlowName]:e.name});const r=await this.addNode({multi:i,node:e,queuesOpts:t===null||t===void 0?void 0:t.queuesOptions,parent:{parentOpts:a,parentDependenciesKey:l}});await i.exec();return r}))}async getFlow(e){if(this.closing){return}const t=await this.connection.client;const n=Object.assign({depth:10,maxChildren:20,prefix:this.opts.prefix},e);const r=this.getNode(t,n);return r}async addBulk(e){if(this.closing){return}const t=await this.connection.client;const n=t.multi();return(0,s.trace)(this.telemetry,c.SpanKind.PRODUCER,"","addBulkFlows","",(async t=>{t===null||t===void 0?void 0:t.setAttributes({[c.TelemetryAttributes.BulkCount]:e.length,[c.TelemetryAttributes.BulkNames]:e.map((e=>e.name)).join(",")});const r=await this.addNodes(n,e);await n.exec();return r}))}async addNode({multi:e,node:t,parent:n,queuesOpts:r}){var a,l;const u=t.prefix||this.opts.prefix;const d=this.queueFromNode(t,new o.QueueKeys(u),u);const f=r&&r[t.queueName];const p=(a=f===null||f===void 0?void 0:f.defaultJobOptions)!==null&&a!==void 0?a:{};const h=((l=t.opts)===null||l===void 0?void 0:l.jobId)||(0,i.v4)();return(0,s.trace)(this.telemetry,c.SpanKind.PRODUCER,t.queueName,"addNode",t.queueName,(async(i,a)=>{var l,u;i===null||i===void 0?void 0:i.setAttributes({[c.TelemetryAttributes.JobName]:t.name,[c.TelemetryAttributes.JobId]:h});const f=t.opts;let y=f===null||f===void 0?void 0:f.telemetry;if(a&&f){const e=(l=f.telemetry)===null||l===void 0?void 0:l.omitContext;const t=((u=f.telemetry)===null||u===void 0?void 0:u.metadata)||!e&&a;if(t||e){y={metadata:t,omitContext:e}}}const m=new this.Job(d,t.name,t.data,Object.assign(Object.assign(Object.assign({},p),f),{parent:n===null||n===void 0?void 0:n.parentOpts,telemetry:y}),h);const b=(0,s.getParentKey)(n===null||n===void 0?void 0:n.parentOpts);if(t.children&&t.children.length>0){const i=h;const s=new o.QueueKeys(t.prefix||this.opts.prefix);const a=s.toKey(t.queueName,"waiting-children");await m.addJob(e,{parentDependenciesKey:n===null||n===void 0?void 0:n.parentDependenciesKey,waitChildrenKey:a,parentKey:b});const l=`${s.toKey(t.queueName,i)}:dependencies`;const c=await this.addChildren({multi:e,nodes:t.children,parent:{parentOpts:{id:i,queue:s.getQueueQualifiedName(t.queueName)},parentDependenciesKey:l},queuesOpts:r});return{job:m,children:c}}else{await m.addJob(e,{parentDependenciesKey:n===null||n===void 0?void 0:n.parentDependenciesKey,parentKey:b});return{job:m}}}))}addNodes(e,t){return Promise.all(t.map((t=>{var n;const r=(n=t===null||t===void 0?void 0:t.opts)===null||n===void 0?void 0:n.parent;const i=(0,s.getParentKey)(r);const a=i?`${i}:dependencies`:undefined;return this.addNode({multi:e,node:t,parent:{parentOpts:r,parentDependenciesKey:a}})})))}async getNode(e,t){const n=this.queueFromNode(t,new o.QueueKeys(t.prefix),t.prefix);const r=await this.Job.fromId(n,t.id);if(r){const{processed:n={},unprocessed:i=[],failed:s=[],ignored:a={}}=await r.getDependencies({failed:{count:t.maxChildren},processed:{count:t.maxChildren},unprocessed:{count:t.maxChildren},ignored:{count:t.maxChildren}});const o=Object.keys(n);const l=Object.keys(a);const c=o.length+i.length+l.length+s.length;const u=t.depth-1;if(c>0&&u){const n=await this.getChildren(e,[...o,...i,...s,...l],u,t.maxChildren);return{job:r,children:n}}else{return{job:r}}}}addChildren({multi:e,nodes:t,parent:n,queuesOpts:r}){return Promise.all(t.map((t=>this.addNode({multi:e,node:t,parent:n,queuesOpts:r}))))}getChildren(e,t,n,r){const getChild=t=>{const[i,s,a]=t.split(":");return this.getNode(e,{id:a,queueName:s,prefix:i,depth:n,maxChildren:r})};return Promise.all([...t.map(getChild)])}queueFromNode(e,t,n){return{client:this.connection.client,name:e.queueName,keys:t.getKeys(e.queueName),toKey:n=>t.toKey(e.queueName,n),opts:{prefix:n,connection:{}},qualifiedName:t.getQueueQualifiedName(e.queueName),closing:this.closing,waitUntilReady:async()=>this.connection.client,removeListener:this.removeListener.bind(this),emit:this.emit.bind(this),on:this.on.bind(this),redisVersion:this.connection.redisVersion,trace:async()=>{}}}async close(){if(!this.closing){this.closing=this.connection.close()}await this.closing}disconnect(){return this.connection.disconnect()}}t.FlowProducer=FlowProducer},9404:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(3581),t);r.__exportStar(n(5303),t);r.__exportStar(n(9882),t);r.__exportStar(n(8853),t);r.__exportStar(n(415),t);r.__exportStar(n(6342),t);r.__exportStar(n(5249),t);r.__exportStar(n(5183),t);r.__exportStar(n(355),t);r.__exportStar(n(977),t);r.__exportStar(n(3449),t);r.__exportStar(n(6592),t);r.__exportStar(n(6586),t);r.__exportStar(n(4920),t);r.__exportStar(n(9011),t);r.__exportStar(n(3420),t);r.__exportStar(n(9126),t);r.__exportStar(n(8999),t);r.__exportStar(n(9916),t);r.__exportStar(n(8544),t)},355:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.defaultRepeatStrategy=t.JobScheduler=void 0;const r=n(1577);const i=n(9912);const s=n(5183);const a=n(977);const o=n(6694);const l=n(2646);class JobScheduler extends a.QueueBase{constructor(e,n,r){super(e,n,r);this.repeatStrategy=n.settings&&n.settings.repeatStrategy||t.defaultRepeatStrategy}async upsertJobScheduler(e,t,n,i,a,{override:l,producerId:c}){const{every:u,limit:d,pattern:f,offset:p}=t;if(f&&u){throw new Error("Both .pattern and .every options are defined for this repeatable job")}if(!f&&!u){throw new Error("Either .pattern or .every options must be defined for this repeatable job")}if(t.immediately&&t.startDate){throw new Error("Both .immediately and .startDate options are defined for this repeatable job")}if(t.immediately&&t.every){console.warn("Using option immediately with every does not affect the job's schedule. Job will run immediately anyway.")}const h=t.count?t.count+1:1;if(typeof t.limit!=="undefined"&&h>t.limit){return}let y=Date.now();const{endDate:m}=t;if(m&&y>new Date(m).getTime()){return}const b=a.prevMillis||0;y=b<y?y:b;const{startDate:g,immediately:v}=t,K=r.__rest(t,["startDate","immediately"]);let S=(y>b?y:b)+(p||0);if(g){S=new Date(g).getTime();S=S>y?S:y}let E;let k=null;if(u){const e=Math.floor((S-(p||0))/u)*u;k=typeof p==="number"?p:S-e;const t=e+u;if(b||p){E=t}else{E=e}}else if(f){E=await this.repeatStrategy(y,t,n);if(E<y){E=y}}if(E){return this.trace(o.SpanKind.PRODUCER,"add",`${this.name}.${n}`,(async(r,p)=>{var y,b;let g=a.telemetry;if(p){const e=(y=a.telemetry)===null||y===void 0?void 0:y.omitContext;const t=((b=a.telemetry)===null||b===void 0?void 0:b.metadata)||!e&&p;if(t||e){g={metadata:t,omitContext:e}}}const v=this.getNextJobOpts(E,e,Object.assign(Object.assign({},a),{repeat:K,telemetry:g}),h,k);if(l){const l=await this.scripts.addJobScheduler(e,E,JSON.stringify(typeof i==="undefined"?{}:i),s.Job.optsAsJSON(a),{name:n,endDate:m?new Date(m).getTime():undefined,tz:t.tz,pattern:f,every:u,limit:d,offset:k},s.Job.optsAsJSON(v),c);const p=new this.Job(this,n,i,v,l);p.id=l;r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.JobSchedulerId]:e,[o.TelemetryAttributes.JobId]:p.id});return p}else{const t=await this.scripts.updateJobSchedulerNextMillis(e,E,JSON.stringify(typeof i==="undefined"?{}:i),s.Job.optsAsJSON(v),c);if(t){const s=new this.Job(this,n,i,v,t);s.id=t;r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.JobSchedulerId]:e,[o.TelemetryAttributes.JobId]:s.id});return s}}}))}}getNextJobOpts(e,t,n,r,i){var s;const a=this.getSchedulerNextJobId({jobSchedulerId:t,nextMillis:e});const o=Date.now();const l=e+i-o;const c=Object.assign(Object.assign({},n),{jobId:a,delay:l<0?0:l,timestamp:o,prevMillis:e,repeatJobKey:t});c.repeat=Object.assign(Object.assign({},n.repeat),{offset:i,count:r,endDate:((s=n.repeat)===null||s===void 0?void 0:s.endDate)?new Date(n.repeat.endDate).getTime():undefined});return c}async removeJobScheduler(e){return this.scripts.removeJobScheduler(e)}async getSchedulerData(e,t,n){const r=await e.hgetall(this.toKey("repeat:"+t));return this.transformSchedulerData(t,r,n)}transformSchedulerData(e,t,n){if(t){const r={key:e,name:t.name,next:n};if(t.ic){r.iterationCount=parseInt(t.ic)}if(t.limit){r.limit=parseInt(t.limit)}if(t.endDate){r.endDate=parseInt(t.endDate)}if(t.tz){r.tz=t.tz}if(t.pattern){r.pattern=t.pattern}if(t.every){r.every=parseInt(t.every)}if(t.offset){r.offset=parseInt(t.offset)}if(t.data||t.opts){r.template=this.getTemplateFromJSON(t.data,t.opts)}return r}if(e.includes(":")){return this.keyToData(e,n)}}keyToData(e,t){const n=e.split(":");const r=n.slice(4).join(":")||null;return{key:e,name:n[0],id:n[1]||null,endDate:parseInt(n[2])||null,tz:n[3]||null,pattern:r,next:t}}async getScheduler(e){const[t,n]=await this.scripts.getJobScheduler(e);return this.transformSchedulerData(e,t?(0,l.array2obj)(t):null,n?parseInt(n):null)}getTemplateFromJSON(e,t){const n={};if(e){n.data=JSON.parse(e)}if(t){n.opts=s.Job.optsFromJSON(t)}return n}async getJobSchedulers(e=0,t=-1,n=false){const r=await this.client;const i=this.keys.repeat;const s=n?await r.zrange(i,e,t,"WITHSCORES"):await r.zrevrange(i,e,t,"WITHSCORES");const a=[];for(let e=0;e<s.length;e+=2){a.push(this.getSchedulerData(r,s[e],parseInt(s[e+1])))}return Promise.all(a)}async getSchedulersCount(){const e=this.keys.repeat;const t=await this.client;return t.zcard(e)}getSchedulerNextJobId({nextMillis:e,jobSchedulerId:t}){return`repeat:${t}:${e}`}}t.JobScheduler=JobScheduler;const defaultRepeatStrategy=(e,t)=>{const{pattern:n}=t;const r=new Date(e);const s=(0,i.parseExpression)(n,Object.assign(Object.assign({},t),{currentDate:r}));try{if(t.immediately){return(new Date).getTime()}else{return s.next().getTime()}}catch(e){}};t.defaultRepeatStrategy=defaultRepeatStrategy},5183:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Job=t.PRIORITY_LIMIT=void 0;const r=n(1577);const i=n(9023);const s=n(2646);const a=n(5303);const o=n(7200);const l=n(6694);const c=(0,i.debuglog)("bull");t.PRIORITY_LIMIT=2**21;class Job{constructor(e,t,n,i={},o){this.queue=e;this.name=t;this.data=n;this.opts=i;this.id=o;this.progress=0;this.returnvalue=null;this.stacktrace=null;this.delay=0;this.priority=0;this.attemptsStarted=0;this.attemptsMade=0;this.stalledCounter=0;const l=this.opts,{repeatJobKey:c}=l,u=r.__rest(l,["repeatJobKey"]);this.opts=Object.assign({attempts:0},u);this.delay=this.opts.delay;this.priority=this.opts.priority||0;this.repeatJobKey=c;this.timestamp=i.timestamp?i.timestamp:Date.now();this.opts.backoff=a.Backoffs.normalize(i.backoff);this.parentKey=(0,s.getParentKey)(i.parent);if(i.parent){this.parent={id:i.parent.id,queueKey:i.parent.queue};if(i.failParentOnFailure){this.parent.fpof=true}if(i.removeDependencyOnFailure){this.parent.rdof=true}if(i.ignoreDependencyOnFailure){this.parent.idof=true}if(i.continueParentOnFailure){this.parent.cpof=true}}this.debounceId=i.debounce?i.debounce.id:undefined;this.deduplicationId=i.deduplication?i.deduplication.id:this.debounceId;this.toKey=e.toKey.bind(e);this.createScripts();this.queueQualifiedName=e.qualifiedName}static async create(e,t,n,r){const i=await e.client;const s=new this(e,t,n,r,r&&r.jobId);s.id=await s.addJob(i,{parentKey:s.parentKey,parentDependenciesKey:s.parentKey?`${s.parentKey}:dependencies`:""});return s}static async createBulk(e,t){const n=await e.client;const r=t.map((t=>{var n;return new this(e,t.name,t.data,t.opts,(n=t.opts)===null||n===void 0?void 0:n.jobId)}));const i=n.pipeline();for(const e of r){e.addJob(i,{parentKey:e.parentKey,parentDependenciesKey:e.parentKey?`${e.parentKey}:dependencies`:""})}const s=await i.exec();for(let e=0;e<s.length;++e){const[t,n]=s[e];if(t){throw t}r[e].id=n}return r}static fromJSON(e,t,n){const r=JSON.parse(t.data||"{}");const i=Job.optsFromJSON(t.opts);const s=new this(e,t.name,r,i,t.id||n);s.progress=JSON.parse(t.progress||"0");s.delay=parseInt(t.delay);s.priority=parseInt(t.priority);s.timestamp=parseInt(t.timestamp);if(t.finishedOn){s.finishedOn=parseInt(t.finishedOn)}if(t.processedOn){s.processedOn=parseInt(t.processedOn)}if(t.rjk){s.repeatJobKey=t.rjk}if(t.deid){s.debounceId=t.deid;s.deduplicationId=t.deid}if(t.failedReason){s.failedReason=t.failedReason}s.attemptsStarted=parseInt(t.ats||"0");s.attemptsMade=parseInt(t.attemptsMade||t.atm||"0");s.stalledCounter=parseInt(t.stc||"0");if(t.defa){s.deferredFailure=t.defa}s.stacktrace=getTraces(t.stacktrace);if(typeof t.returnvalue==="string"){s.returnvalue=getReturnValue(t.returnvalue)}if(t.parentKey){s.parentKey=t.parentKey}if(t.parent){s.parent=JSON.parse(t.parent)}if(t.pb){s.processedBy=t.pb}if(t.nrjid){s.nextRepeatableJobId=t.nrjid}return s}createScripts(){this.scripts=(0,s.createScripts)(this.queue)}static optsFromJSON(e,t=s.optsDecodeMap){const n=JSON.parse(e||"{}");const r=Object.entries(n);const i={};for(const e of r){const[n,r]=e;if(t[n]){i[t[n]]=r}else{if(n==="tm"){i.telemetry=Object.assign(Object.assign({},i.telemetry),{metadata:r})}else if(n==="omc"){i.telemetry=Object.assign(Object.assign({},i.telemetry),{omitContext:r})}else{i[n]=r}}}return i}static async fromId(e,t){if(t){const n=await e.client;const r=await n.hgetall(e.toKey(t));return(0,s.isEmpty)(r)?undefined:this.fromJSON(e,r,t)}}static addJobLog(e,t,n,r){const i=e.scripts;return i.addLog(t,n,r)}toJSON(){const e=this,{queue:t,scripts:n}=e,i=r.__rest(e,["queue","scripts"]);return i}asJSON(){return(0,s.removeUndefinedFields)({id:this.id,name:this.name,data:JSON.stringify(typeof this.data==="undefined"?{}:this.data),opts:Job.optsAsJSON(this.opts),parent:this.parent?Object.assign({},this.parent):undefined,parentKey:this.parentKey,progress:this.progress,attemptsMade:this.attemptsMade,attemptsStarted:this.attemptsStarted,stalledCounter:this.stalledCounter,finishedOn:this.finishedOn,processedOn:this.processedOn,timestamp:this.timestamp,failedReason:JSON.stringify(this.failedReason),stacktrace:JSON.stringify(this.stacktrace),debounceId:this.debounceId,deduplicationId:this.deduplicationId,repeatJobKey:this.repeatJobKey,returnvalue:JSON.stringify(this.returnvalue),nrjid:this.nextRepeatableJobId})}static optsAsJSON(e={},t=s.optsEncodeMap){const n=Object.entries(e);const r={};for(const[e,i]of n){if(typeof i==="undefined"){continue}if(e in t){const n=e;const s=t[n];r[s]=i}else{if(e==="telemetry"){r.tm=i.metadata;r.omc=i.omitContext}else{r[e]=i}}}return r}asJSONSandbox(){return Object.assign(Object.assign({},this.asJSON()),{queueName:this.queueName,prefix:this.prefix})}updateData(e){this.data=e;return this.scripts.updateData(this,e)}async updateProgress(e){this.progress=e;await this.scripts.updateProgress(this.id,e);this.queue.emit("progress",this,e)}async log(e){return Job.addJobLog(this.queue,this.id,e,this.opts.keepLogs)}async removeChildDependency(){const e=await this.scripts.removeChildDependency(this.id,this.parentKey);if(e){this.parent=undefined;this.parentKey=undefined;return true}return false}async clearLogs(e){const t=await this.queue.client;const n=this.toKey(this.id)+":logs";if(e){await t.ltrim(n,-e,-1)}else{await t.del(n)}}async remove({removeChildren:e=true}={}){await this.queue.waitUntilReady();const t=this.queue;const n=this;const r=await this.scripts.remove(n.id,e);if(r){t.emit("removed",n)}else{throw new Error(`Job ${this.id} could not be removed because it is locked by another worker`)}}async removeUnprocessedChildren(){const e=this.id;await this.scripts.removeUnprocessedChildren(e)}extendLock(e,t){return this.scripts.extendLock(this.id,e,t)}async moveToCompleted(e,t,n=true){return this.queue.trace(l.SpanKind.INTERNAL,"complete",this.queue.name,(async(r,i)=>{var a,o;let l;if(!((o=(a=this.opts)===null||a===void 0?void 0:a.telemetry)===null||o===void 0?void 0:o.omitContext)&&i){l=i}await this.queue.waitUntilReady();this.returnvalue=e||void 0;const c=(0,s.tryCatch)(JSON.stringify,JSON,[e]);if(c===s.errorObject){throw s.errorObject.value}const u=this.scripts.moveToCompletedArgs(this,c,this.opts.removeOnComplete,t,n);const d=await this.scripts.moveToFinished(this.id,u);this.finishedOn=u[this.scripts.moveToFinishedKeys.length+1];this.attemptsMade+=1;return d}))}moveToWait(e){return this.scripts.moveJobFromActiveToWait(this.id,e)}async shouldRetryJob(e){if(this.attemptsMade+1<this.opts.attempts&&!this.discarded&&!(e instanceof o.UnrecoverableError||e.name=="UnrecoverableError")){const t=this.queue.opts;const n=await a.Backoffs.calculate(this.opts.backoff,this.attemptsMade+1,e,this,t.settings&&t.settings.backoffStrategy);return[n==-1?false:true,n==-1?0:n]}else{return[false,0]}}async moveToFailed(e,t,n=false){this.failedReason=e===null||e===void 0?void 0:e.message;const[r,i]=await this.shouldRetryJob(e);return this.queue.trace(l.SpanKind.INTERNAL,this.getSpanOperation(r,i),this.queue.name,(async(s,a)=>{var o,l;let c;if(!((l=(o=this.opts)===null||o===void 0?void 0:o.telemetry)===null||l===void 0?void 0:l.omitContext)&&a){c=a}let u;this.updateStacktrace(e);const d={failedReason:this.failedReason,stacktrace:JSON.stringify(this.stacktrace),tm:c};let f;if(r){if(i){u=await this.scripts.moveToDelayed(this.id,Date.now(),i,t,{fieldsToUpdate:d})}else{u=await this.scripts.retryJob(this.id,this.opts.lifo,t,{fieldsToUpdate:d})}}else{const e=this.scripts.moveToFailedArgs(this,this.failedReason,this.opts.removeOnFail,t,n,d);u=await this.scripts.moveToFinished(this.id,e);f=e[this.scripts.moveToFinishedKeys.length+1]}if(f&&typeof f==="number"){this.finishedOn=f}if(i&&typeof i==="number"){this.delay=i}this.attemptsMade+=1;return u}))}getSpanOperation(e,t){if(e){if(t){return"delay"}return"retry"}return"fail"}isCompleted(){return this.isInZSet("completed")}isFailed(){return this.isInZSet("failed")}isDelayed(){return this.isInZSet("delayed")}isWaitingChildren(){return this.isInZSet("waiting-children")}isActive(){return this.isInList("active")}async isWaiting(){return await this.isInList("wait")||await this.isInList("paused")}get queueName(){return this.queue.name}get prefix(){return this.queue.opts.prefix}getState(){return this.scripts.getState(this.id)}async changeDelay(e){await this.scripts.changeDelay(this.id,e);this.delay=e}async changePriority(e){await this.scripts.changePriority(this.id,e.priority,e.lifo);this.priority=e.priority||0}async getChildrenValues(){const e=await this.queue.client;const t=await e.hgetall(this.toKey(`${this.id}:processed`));if(t){return(0,s.parseObjectValues)(t)}}async getIgnoredChildrenFailures(){const e=await this.queue.client;return e.hgetall(this.toKey(`${this.id}:failed`))}async getFailedChildrenValues(){const e=await this.queue.client;return e.hgetall(this.toKey(`${this.id}:failed`))}async getDependencies(e={}){const t=await this.queue.client;const n=t.multi();if(!e.processed&&!e.unprocessed&&!e.ignored&&!e.failed){n.hgetall(this.toKey(`${this.id}:processed`));n.smembers(this.toKey(`${this.id}:dependencies`));n.hgetall(this.toKey(`${this.id}:failed`));n.zrange(this.toKey(`${this.id}:unsuccessful`),0,-1);const[[e,t],[r,i],[a,o],[l,c]]=await n.exec();return{processed:(0,s.parseObjectValues)(t),unprocessed:i,failed:c,ignored:o}}else{const t={cursor:0,count:20};const r=[];if(e.processed){r.push("processed");const i=Object.assign(Object.assign({},t),e.processed);n.hscan(this.toKey(`${this.id}:processed`),i.cursor,"COUNT",i.count)}if(e.unprocessed){r.push("unprocessed");const i=Object.assign(Object.assign({},t),e.unprocessed);n.sscan(this.toKey(`${this.id}:dependencies`),i.cursor,"COUNT",i.count)}if(e.ignored){r.push("ignored");const i=Object.assign(Object.assign({},t),e.ignored);n.hscan(this.toKey(`${this.id}:failed`),i.cursor,"COUNT",i.count)}let i;if(e.failed){r.push("failed");const s=Object.assign(Object.assign({},t),e.failed);i=s.cursor+s.count;n.zrange(this.toKey(`${this.id}:unsuccessful`),s.cursor,s.count-1)}const s=await n.exec();let a,o,l,c,u,d,f;r.forEach(((e,t)=>{switch(e){case"processed":{a=s[t][1][0];const e=s[t][1][1];const n={};for(let t=0;t<e.length;++t){if(t%2){n[e[t-1]]=JSON.parse(e[t])}}o=n;break}case"failed":{u=s[t][1];break}case"ignored":{d=s[t][1][0];const e=s[t][1][1];const n={};for(let t=0;t<e.length;++t){if(t%2){n[e[t-1]]=e[t]}}f=n;break}case"unprocessed":{l=s[t][1][0];c=s[t][1][1];break}}}));return Object.assign(Object.assign(Object.assign(Object.assign({},a?{processed:o,nextProcessedCursor:Number(a)}:{}),d?{ignored:f,nextIgnoredCursor:Number(d)}:{}),i?{failed:u,nextFailedCursor:i}:{}),l?{unprocessed:c,nextUnprocessedCursor:Number(l)}:{})}}async getDependenciesCount(e={}){const t=[];Object.entries(e).forEach((([e,n])=>{if(n){t.push(e)}}));const n=t.length?t:["processed","unprocessed","ignored","failed"];const r=await this.scripts.getDependencyCounts(this.id,n);const i={};r.forEach(((e,t)=>{i[`${n[t]}`]=e||0}));return i}async waitUntilFinished(e,t){await this.queue.waitUntilReady();const n=this.id;return new Promise((async(r,i)=>{let s;if(t){s=setTimeout((()=>onFailed(`Job wait ${this.name} timed out before finishing, no finish notification arrived after ${t}ms (id=${n})`)),t)}function onCompleted(e){removeListeners();r(e.returnvalue)}function onFailed(e){removeListeners();i(new Error(e.failedReason||e))}const a=`completed:${n}`;const o=`failed:${n}`;e.on(a,onCompleted);e.on(o,onFailed);this.queue.on("closing",onFailed);const removeListeners=()=>{clearInterval(s);e.removeListener(a,onCompleted);e.removeListener(o,onFailed);this.queue.removeListener("closing",onFailed)};await e.waitUntilReady();const[l,c]=await this.scripts.isFinished(n,true);const u=l!=0;if(u){if(l==-1||l==2){onFailed({failedReason:c})}else{onCompleted({returnvalue:getReturnValue(c)})}}}))}async moveToDelayed(e,t){const n=Date.now();const r=e-n;const i=r>0?r:0;const s=await this.scripts.moveToDelayed(this.id,n,i,t,{skipAttempt:true});this.delay=i;return s}async moveToWaitingChildren(e,t={}){const n=await this.scripts.moveToWaitingChildren(this.id,e,t);return n}async promote(){const e=this.id;await this.scripts.promote(e);this.delay=0}retry(e="failed"){this.failedReason=null;this.finishedOn=null;this.processedOn=null;this.returnvalue=null;return this.scripts.reprocessJob(this,e)}discard(){this.discarded=true}async isInZSet(e){const t=await this.queue.client;const n=await t.zscore(this.queue.toKey(e),this.id);return n!==null}async isInList(e){return this.scripts.isJobInList(this.queue.toKey(e),this.id)}addJob(e,t){const n=this.asJSON();this.validateOptions(n);return this.scripts.addJob(e,n,n.opts,this.id,t)}validateOptions(e){var n;const r=["removeDependencyOnFailure","failParentOnFailure","continueParentOnFailure","ignoreDependencyOnFailure"];const i=this.opts.sizeLimit&&(0,s.lengthInUtf8Bytes)(e.data)>this.opts.sizeLimit;if(i){throw new Error(`The size of job ${this.name} exceeds the limit ${this.opts.sizeLimit} bytes`)}if(this.opts.delay&&this.opts.repeat&&!((n=this.opts.repeat)===null||n===void 0?void 0:n.count)){throw new Error(`Delay and repeat options could not be used together`)}const a=r.filter((e=>this.opts[e]));if(a.length>1){const e=a.join(", ");throw new Error(`The following options cannot be used together: ${e}`)}if(`${parseInt(this.id,10)}`===this.id){throw new Error("Custom Ids cannot be integers")}if(this.opts.priority){if(Math.trunc(this.opts.priority)!==this.opts.priority){throw new Error(`Priority should not be float`)}if(this.opts.priority>t.PRIORITY_LIMIT){throw new Error(`Priority should be between 0 and ${t.PRIORITY_LIMIT}`)}}if(typeof this.opts.backoff==="object"&&typeof this.opts.backoff.jitter==="number"){if(this.opts.backoff.jitter<0||this.opts.backoff.jitter>1){throw new Error(`Jitter should be between 0 and 1`)}}}updateStacktrace(e){this.stacktrace=this.stacktrace||[];if(e===null||e===void 0?void 0:e.stack){this.stacktrace.push(e.stack);if(this.opts.stackTraceLimit===0){this.stacktrace=[]}else if(this.opts.stackTraceLimit){this.stacktrace=this.stacktrace.slice(-this.opts.stackTraceLimit)}}}}t.Job=Job;function getTraces(e){const t=(0,s.tryCatch)(JSON.parse,JSON,[e]);if(t===s.errorObject||!(t instanceof Array)){return[]}else{return t}}function getReturnValue(e){const t=(0,s.tryCatch)(JSON.parse,JSON,[e]);if(t!==s.errorObject){return t}else{c("corrupted returnvalue: "+e,t)}}},977:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueBase=void 0;const r=n(4434);const i=n(2646);const s=n(3420);const a=n(5183);const o=n(4920);class QueueBase extends r.EventEmitter{constructor(e,t={connection:{}},n=s.RedisConnection,r=false){super();this.name=e;this.opts=t;this.closed=false;this.hasBlockingConnection=false;this.hasBlockingConnection=r;this.opts=Object.assign({prefix:"bull"},t);if(!e){throw new Error("Queue name must be provided")}if(e.includes(":")){throw new Error("Queue name cannot contain :")}this.connection=new n(t.connection,{shared:(0,i.isRedisInstance)(t.connection),blocking:r,skipVersionCheck:t.skipVersionCheck,skipWaitingForReady:t.skipWaitingForReady});this.connection.on("error",(e=>this.emit("error",e)));this.connection.on("close",(()=>{if(!this.closing){this.emit("ioredis:close")}}));const a=new o.QueueKeys(t.prefix);this.qualifiedName=a.getQueueQualifiedName(e);this.keys=a.getKeys(e);this.toKey=t=>a.toKey(e,t);this.createScripts()}get client(){return this.connection.client}createScripts(){this.scripts=(0,i.createScripts)(this)}get redisVersion(){return this.connection.redisVersion}get Job(){return a.Job}emit(e,...t){try{return super.emit(e,...t)}catch(e){try{return super.emit("error",e)}catch(e){console.error(e);return false}}}waitUntilReady(){return this.client}base64Name(){return Buffer.from(this.name).toString("base64")}clientName(e=""){const t=this.base64Name();return`${this.opts.prefix}:${t}${e}`}async close(){if(!this.closing){this.closing=this.connection.close()}await this.closing;this.closed=true}disconnect(){return this.connection.disconnect()}async checkConnectionError(e,t=i.DELAY_TIME_5){try{return await e()}catch(e){if((0,i.isNotConnectionError)(e)){this.emit("error",e)}if(!this.closing&&t){await(0,i.delay)(t)}else{return}}}trace(e,t,n,r,s){return(0,i.trace)(this.opts.telemetry,e,this.name,t,n,r,s)}}t.QueueBase=QueueBase},6592:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueEventsProducer=void 0;const r=n(1577);const i=n(977);class QueueEventsProducer extends i.QueueBase{constructor(e,t={connection:{}},n){super(e,Object.assign({blockingConnection:false},t),n);this.opts=t}async publishEvent(e,t=1e3){const n=await this.client;const i=this.keys.events;const{eventName:s}=e,a=r.__rest(e,["eventName"]);const o=["MAXLEN","~",t,"*","event",s];for(const[e,t]of Object.entries(a)){o.push(e,t)}await n.xadd(i,...o)}async close(){if(!this.closing){this.closing=this.connection.close()}await this.closing}}t.QueueEventsProducer=QueueEventsProducer},3449:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueEvents=void 0;const r=n(1577);const i=n(2646);const s=n(977);class QueueEvents extends s.QueueBase{constructor(e,t={connection:{}},n){var{connection:s,autorun:a=true}=t,o=r.__rest(t,["connection","autorun"]);super(e,Object.assign(Object.assign({},o),{connection:(0,i.isRedisInstance)(s)?s.duplicate():s}),n,true);this.running=false;this.opts=Object.assign({blockingTimeout:1e4},this.opts);if(a){this.run().catch((e=>this.emit("error",e)))}}emit(e,...t){return super.emit(e,...t)}off(e,t){super.off(e,t);return this}on(e,t){super.on(e,t);return this}once(e,t){super.once(e,t);return this}async run(){if(!this.running){try{this.running=true;const e=await this.client;try{await e.client("SETNAME",this.clientName(i.QUEUE_EVENT_SUFFIX))}catch(e){if(!i.clientCommandMessageReg.test(e.message)){throw e}}await this.consumeEvents(e)}catch(e){this.running=false;throw e}}else{throw new Error("Queue Events is already running.")}}async consumeEvents(e){const t=this.opts;const n=this.keys.events;let s=t.lastEventId||"$";while(!this.closing){const a=await this.checkConnectionError((()=>e.xread("BLOCK",t.blockingTimeout,"STREAMS",n,s)));if(a){const e=a[0];const t=e[1];for(let e=0;e<t.length;e++){s=t[e][0];const n=(0,i.array2obj)(t[e][1]);switch(n.event){case"progress":n.data=JSON.parse(n.data);break;case"completed":n.returnvalue=JSON.parse(n.returnvalue);break}const{event:a}=n,o=r.__rest(n,["event"]);if(a==="drained"){this.emit(a,s)}else{this.emit(a,o,s);if(o.jobId){this.emit(`${a}:${o.jobId}`,o,s)}}}}}}close(){if(!this.closing){this.closing=this.disconnect()}return this.closing}}t.QueueEvents=QueueEvents},6586:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueGetters=void 0;const r=n(977);const i=n(2646);class QueueGetters extends r.QueueBase{getJob(e){return this.Job.fromId(this,e)}commandByType(e,t,n){return e.map((e=>{e=e==="waiting"?"wait":e;const r=this.toKey(e);switch(e){case"completed":case"failed":case"delayed":case"prioritized":case"repeat":case"waiting-children":return n(r,t?"zcard":"zrange");case"active":case"wait":case"paused":return n(r,t?"llen":"lrange")}}))}sanitizeJobTypes(e){const t=typeof e==="string"?[e]:e;if(Array.isArray(t)&&t.length>0){const e=[...t];if(e.indexOf("waiting")!==-1){e.push("paused")}return[...new Set(e)]}return["active","completed","delayed","failed","paused","prioritized","waiting","waiting-children"]}async count(){const e=await this.getJobCountByTypes("waiting","paused","delayed","prioritized","waiting-children");return e}async getRateLimitTtl(e){return this.scripts.getRateLimitTtl(e)}async getDebounceJobId(e){const t=await this.client;return t.get(`${this.keys.de}:${e}`)}async getDeduplicationJobId(e){const t=await this.client;return t.get(`${this.keys.de}:${e}`)}async getJobCountByTypes(...e){const t=await this.getJobCounts(...e);return Object.values(t).reduce(((e,t)=>e+t),0)}async getJobCounts(...e){const t=this.sanitizeJobTypes(e);const n=await this.scripts.getCounts(t);const r={};n.forEach(((e,n)=>{r[t[n]]=e||0}));return r}getJobState(e){return this.scripts.getState(e)}getCompletedCount(){return this.getJobCountByTypes("completed")}getFailedCount(){return this.getJobCountByTypes("failed")}getDelayedCount(){return this.getJobCountByTypes("delayed")}getActiveCount(){return this.getJobCountByTypes("active")}getPrioritizedCount(){return this.getJobCountByTypes("prioritized")}async getCountsPerPriority(e){const t=[...new Set(e)];const n=await this.scripts.getCountsPerPriority(t);const r={};n.forEach(((e,n)=>{r[`${t[n]}`]=e||0}));return r}getWaitingCount(){return this.getJobCountByTypes("waiting")}getWaitingChildrenCount(){return this.getJobCountByTypes("waiting-children")}getWaiting(e=0,t=-1){return this.getJobs(["waiting"],e,t,true)}getWaitingChildren(e=0,t=-1){return this.getJobs(["waiting-children"],e,t,true)}getActive(e=0,t=-1){return this.getJobs(["active"],e,t,true)}getDelayed(e=0,t=-1){return this.getJobs(["delayed"],e,t,true)}getPrioritized(e=0,t=-1){return this.getJobs(["prioritized"],e,t,true)}getCompleted(e=0,t=-1){return this.getJobs(["completed"],e,t,false)}getFailed(e=0,t=-1){return this.getJobs(["failed"],e,t,false)}async getDependencies(e,t,n,r){const i=this.toKey(t=="processed"?`${e}:processed`:`${e}:dependencies`);const{items:s,total:a,jobs:o}=await this.scripts.paginate(i,{start:n,end:r,fetchJobs:true});return{items:s,jobs:o,total:a}}async getRanges(e,t=0,n=1,r=false){const i=[];this.commandByType(e,false,((e,t)=>{switch(t){case"lrange":i.push("lrange");break;case"zrange":i.push("zrange");break}}));const s=await this.scripts.getRanges(e,t,n,r);let a=[];s.forEach(((e,t)=>{const n=e||[];if(r&&i[t]==="lrange"){a=a.concat(n.reverse())}else{a=a.concat(n)}}));return[...new Set(a)]}async getJobs(e,t=0,n=-1,r=false){const i=this.sanitizeJobTypes(e);const s=await this.getRanges(i,t,n,r);return Promise.all(s.map((e=>this.Job.fromId(this,e))))}async getJobLogs(e,t=0,n=-1,r=true){const i=await this.client;const s=i.multi();const a=this.toKey(e+":logs");if(r){s.lrange(a,t,n)}else{s.lrange(a,-(n+1),-(t+1))}s.llen(a);const o=await s.exec();if(!r){o[0][1].reverse()}return{logs:o[0][1],count:o[1][1]}}async baseGetClients(e){const t=await this.client;try{const n=await t.client("LIST");const r=this.parseClientList(n,e);return r}catch(e){if(!i.clientCommandMessageReg.test(e.message)){throw e}return[{name:"GCP does not support client list"}]}}getWorkers(){const e=`${this.clientName()}`;const t=`${this.clientName()}:w:`;const matcher=n=>n&&(n===e||n.startsWith(t));return this.baseGetClients(matcher)}async getWorkersCount(){const e=await this.getWorkers();return e.length}async getQueueEvents(){const e=`${this.clientName()}${i.QUEUE_EVENT_SUFFIX}`;return this.baseGetClients((t=>t===e))}async getMetrics(e,t=0,n=-1){const r=await this.client;const i=this.toKey(`metrics:${e}`);const s=`${i}:data`;const a=r.multi();a.hmget(i,"count","prevTS","prevCount");a.lrange(s,t,n);a.llen(s);const[o,l,c]=await a.exec();const[u,[d,f,p]]=o;const[h,y]=l;const[m,b]=c;if(u||h){throw u||h||m}return{meta:{count:parseInt(d||"0",10),prevTS:parseInt(f||"0",10),prevCount:parseInt(p||"0",10)},data:y,count:b}}parseClientList(e,t){const n=e.split(/\r?\n/);const r=[];n.forEach((e=>{const n={};const i=e.split(" ");i.forEach((function(e){const t=e.indexOf("=");const r=e.substring(0,t);const i=e.substring(t+1);n[r]=i}));const s=n["name"];if(t(s)){n["name"]=this.name;n["rawname"]=s;r.push(n)}}));return r}async exportPrometheusMetrics(e){const t=await this.getJobCounts();const n=[];n.push("# HELP bullmq_job_count Number of jobs in the queue by state");n.push("# TYPE bullmq_job_count gauge");const r=!e?"":Object.keys(e).reduce(((t,n)=>`${t}, ${n}="${e[n]}"`),"");for(const[e,i]of Object.entries(t)){n.push(`bullmq_job_count{queue="${this.name}", state="${e}"${r}} ${i}`)}return n.join("\n")}}t.QueueGetters=QueueGetters},4920:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.QueueKeys=void 0;class QueueKeys{constructor(e="bull"){this.prefix=e}getKeys(e){const t={};["","active","wait","waiting-children","paused","id","delayed","prioritized","stalled-check","completed","failed","stalled","repeat","limiter","meta","events","pc","marker","de"].forEach((n=>{t[n]=this.toKey(e,n)}));return t}toKey(e,t){return`${this.getQueueQualifiedName(e)}:${t}`}getQueueQualifiedName(e){return`${this.prefix}:${e}`}}t.QueueKeys=QueueKeys},9011:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Queue=void 0;const r=n(9935);const i=n(5183);const s=n(6586);const a=n(9126);const o=n(6694);const l=n(355);const c=n(3267);class Queue extends s.QueueGetters{constructor(e,t,n){var i;super(e,Object.assign({},t),n);this.token=(0,r.v4)();this.libName="bullmq";this.jobsOpts=(i=t===null||t===void 0?void 0:t.defaultJobOptions)!==null&&i!==void 0?i:{};this.waitUntilReady().then((e=>{if(!this.closing&&!(t===null||t===void 0?void 0:t.skipMetasUpdate)){return e.hmset(this.keys.meta,this.metaValues)}})).catch((e=>{}))}emit(e,...t){return super.emit(e,...t)}off(e,t){super.off(e,t);return this}on(e,t){super.on(e,t);return this}once(e,t){super.once(e,t);return this}get defaultJobOptions(){return Object.assign({},this.jobsOpts)}get metaValues(){var e,t,n,r;return{"opts.maxLenEvents":(r=(n=(t=(e=this.opts)===null||e===void 0?void 0:e.streams)===null||t===void 0?void 0:t.events)===null||n===void 0?void 0:n.maxLen)!==null&&r!==void 0?r:1e4,version:`${this.libName}:${c.version}`}}async getVersion(){const e=await this.client;return await e.hget(this.keys.meta,"version")}get repeat(){return new Promise((async e=>{if(!this._repeat){this._repeat=new a.Repeat(this.name,Object.assign(Object.assign({},this.opts),{connection:await this.client}));this._repeat.on("error",(e=>this.emit.bind(this,e)))}e(this._repeat)}))}get jobScheduler(){return new Promise((async e=>{if(!this._jobScheduler){this._jobScheduler=new l.JobScheduler(this.name,Object.assign(Object.assign({},this.opts),{connection:await this.client}));this._jobScheduler.on("error",(e=>this.emit.bind(this,e)))}e(this._jobScheduler)}))}async getGlobalConcurrency(){const e=await this.client;const t=await e.hget(this.keys.meta,"concurrency");if(t){return Number(t)}return null}async setGlobalConcurrency(e){const t=await this.client;return t.hset(this.keys.meta,"concurrency",e)}async removeGlobalConcurrency(){const e=await this.client;return e.hdel(this.keys.meta,"concurrency")}async add(e,t,n){return this.trace(o.SpanKind.PRODUCER,"add",`${this.name}.${e}`,(async(r,i)=>{var s;if(i&&!((s=n===null||n===void 0?void 0:n.telemetry)===null||s===void 0?void 0:s.omitContext)){const e={metadata:i};n=Object.assign(Object.assign({},n),{telemetry:e})}const a=await this.addJob(e,t,n);r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.JobName]:e,[o.TelemetryAttributes.JobId]:a.id});return a}))}async addJob(e,t,n){if(n&&n.repeat){if(n.repeat.endDate){if(+new Date(n.repeat.endDate)<Date.now()){throw new Error("End date must be greater than current timestamp")}}return(await this.repeat).updateRepeatableJob(e,t,Object.assign(Object.assign({},this.jobsOpts),n),{override:true})}else{const r=n===null||n===void 0?void 0:n.jobId;if(r=="0"||(r===null||r===void 0?void 0:r.startsWith("0:"))){throw new Error("JobId cannot be '0' or start with 0:")}const i=await this.Job.create(this,e,t,Object.assign(Object.assign(Object.assign({},this.jobsOpts),n),{jobId:r}));this.emit("waiting",i);return i}}async addBulk(e){return this.trace(o.SpanKind.PRODUCER,"addBulk",this.name,(async(t,n)=>{if(t){t.setAttributes({[o.TelemetryAttributes.BulkNames]:e.map((e=>e.name)),[o.TelemetryAttributes.BulkCount]:e.length})}return await this.Job.createBulk(this,e.map((e=>{var t,r,i,s,a,o;let l=(t=e.opts)===null||t===void 0?void 0:t.telemetry;if(n){const t=(i=(r=e.opts)===null||r===void 0?void 0:r.telemetry)===null||i===void 0?void 0:i.omitContext;const o=((a=(s=e.opts)===null||s===void 0?void 0:s.telemetry)===null||a===void 0?void 0:a.metadata)||!t&&n;if(o||t){l={metadata:o,omitContext:t}}}return{name:e.name,data:e.data,opts:Object.assign(Object.assign(Object.assign({},this.jobsOpts),e.opts),{jobId:(o=e.opts)===null||o===void 0?void 0:o.jobId,telemetry:l})}})))}))}async upsertJobScheduler(e,t,n){var r,i;if(t.endDate){if(+new Date(t.endDate)<Date.now()){throw new Error("End date must be greater than current timestamp")}}return(await this.jobScheduler).upsertJobScheduler(e,t,(r=n===null||n===void 0?void 0:n.name)!==null&&r!==void 0?r:e,(i=n===null||n===void 0?void 0:n.data)!==null&&i!==void 0?i:{},Object.assign(Object.assign({},this.jobsOpts),n===null||n===void 0?void 0:n.opts),{override:true})}async pause(){await this.trace(o.SpanKind.INTERNAL,"pause",this.name,(async()=>{await this.scripts.pause(true);this.emit("paused")}))}async close(){await this.trace(o.SpanKind.INTERNAL,"close",this.name,(async()=>{if(!this.closing){if(this._repeat){await this._repeat.close()}}await super.close()}))}async rateLimit(e){await this.trace(o.SpanKind.INTERNAL,"rateLimit",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueRateLimit]:e});await this.client.then((t=>t.set(this.keys.limiter,Number.MAX_SAFE_INTEGER,"PX",e)))}))}async resume(){await this.trace(o.SpanKind.INTERNAL,"resume",this.name,(async()=>{await this.scripts.pause(false);this.emit("resumed")}))}async isPaused(){const e=await this.client;const t=await e.hexists(this.keys.meta,"paused");return t===1}isMaxed(){return this.scripts.isMaxed()}async getRepeatableJobs(e,t,n){return(await this.repeat).getRepeatableJobs(e,t,n)}async getJobScheduler(e){return(await this.jobScheduler).getScheduler(e)}async getJobSchedulers(e,t,n){return(await this.jobScheduler).getJobSchedulers(e,t,n)}async getJobSchedulersCount(){return(await this.jobScheduler).getSchedulersCount()}async removeRepeatable(e,t,n){return this.trace(o.SpanKind.INTERNAL,"removeRepeatable",`${this.name}.${e}`,(async r=>{r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.JobName]:e,[o.TelemetryAttributes.JobId]:n});const i=await this.repeat;const s=await i.removeRepeatable(e,t,n);return!s}))}async removeJobScheduler(e){const t=await this.jobScheduler;const n=await t.removeJobScheduler(e);return!n}async removeDebounceKey(e){return this.trace(o.SpanKind.INTERNAL,"removeDebounceKey",`${this.name}`,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.JobKey]:e});const n=await this.client;return await n.del(`${this.keys.de}:${e}`)}))}async removeDeduplicationKey(e){return this.trace(o.SpanKind.INTERNAL,"removeDeduplicationKey",`${this.name}`,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.DeduplicationKey]:e});const n=await this.client;return n.del(`${this.keys.de}:${e}`)}))}async removeRateLimitKey(){const e=await this.client;return e.del(this.keys.limiter)}async removeRepeatableByKey(e){return this.trace(o.SpanKind.INTERNAL,"removeRepeatableByKey",`${this.name}`,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.JobKey]:e});const n=await this.repeat;const r=await n.removeRepeatableByKey(e);return!r}))}async remove(e,{removeChildren:t=true}={}){return this.trace(o.SpanKind.INTERNAL,"remove",this.name,(async n=>{n===null||n===void 0?void 0:n.setAttributes({[o.TelemetryAttributes.JobId]:e,[o.TelemetryAttributes.JobOptions]:JSON.stringify({removeChildren:t})});return await this.scripts.remove(e,t)}))}async updateJobProgress(e,t){await this.trace(o.SpanKind.INTERNAL,"updateJobProgress",this.name,(async n=>{n===null||n===void 0?void 0:n.setAttributes({[o.TelemetryAttributes.JobId]:e,[o.TelemetryAttributes.JobProgress]:JSON.stringify(t)});await this.scripts.updateProgress(e,t)}))}async addJobLog(e,t,n){return i.Job.addJobLog(this,e,t,n)}async drain(e=false){await this.trace(o.SpanKind.INTERNAL,"drain",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueDrainDelay]:e});await this.scripts.drain(e)}))}async clean(e,t,n="completed"){return this.trace(o.SpanKind.INTERNAL,"clean",this.name,(async r=>{const i=t||Infinity;const s=Math.min(1e4,i);const a=Date.now()-e;let l=0;const c=[];const u=n==="waiting"?"wait":n;while(l<i){const e=await this.scripts.cleanJobsInSet(u,a,s);this.emit("cleaned",e,u);l+=e.length;c.push(...e);if(e.length<s){break}}r===null||r===void 0?void 0:r.setAttributes({[o.TelemetryAttributes.QueueGrace]:e,[o.TelemetryAttributes.JobType]:n,[o.TelemetryAttributes.QueueCleanLimit]:i,[o.TelemetryAttributes.JobIds]:c});return c}))}async obliterate(e){await this.trace(o.SpanKind.INTERNAL,"obliterate",this.name,(async()=>{await this.pause();let t=0;do{t=await this.scripts.obliterate(Object.assign({force:false,count:1e3},e))}while(t)}))}async retryJobs(e={}){await this.trace(o.SpanKind.PRODUCER,"retryJobs",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueOptions]:JSON.stringify(e)});let n=0;do{n=await this.scripts.retryJobs(e.state,e.count,e.timestamp)}while(n)}))}async promoteJobs(e={}){await this.trace(o.SpanKind.INTERNAL,"promoteJobs",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueOptions]:JSON.stringify(e)});let n=0;do{n=await this.scripts.promoteJobs(e.count)}while(n)}))}async trimEvents(e){return this.trace(o.SpanKind.INTERNAL,"trimEvents",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[o.TelemetryAttributes.QueueEventMaxLength]:e});const n=await this.client;return await n.xtrim(this.keys.events,"MAXLEN","~",e)}))}async removeDeprecatedPriorityKey(){const e=await this.client;return e.del(this.toKey("priority"))}}t.Queue=Queue},3420:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.RedisConnection=void 0;const r=n(1577);const i=n(4434);const s=n(405);const a=n(9335);const o=n(2646);const l=n(3267);const c=n(3760);const u=["BullMQ: WARNING! Your redis options maxRetriesPerRequest must be null","and will be overridden by BullMQ."].join(" ");const d="BullMQ: Your redis options maxRetriesPerRequest must be null.";class RedisConnection extends i.EventEmitter{constructor(e,t){super();this.extraOptions=t;this.capabilities={canDoubleTimeout:false,canBlockFor1Ms:true};this.status="initializing";this.packageVersion=l.version;this.extraOptions=Object.assign({shared:false,blocking:true,skipVersionCheck:false,skipWaitingForReady:false},t);if(!(0,o.isRedisInstance)(e)){this.checkBlockingOptions(u,e);this.opts=Object.assign({port:6379,host:"127.0.0.1",retryStrategy:function(e){return Math.max(Math.min(Math.exp(e),2e4),1e3)}},e);if(this.extraOptions.blocking){this.opts.maxRetriesPerRequest=null}}else{this._client=e;if(this._client.options.keyPrefix){throw new Error("BullMQ: ioredis does not support ioredis prefixes, use the prefix option instead.")}if((0,o.isRedisCluster)(this._client)){this.opts=this._client.options.redisOptions}else{this.opts=this._client.options}this.checkBlockingOptions(d,this.opts,true)}this.skipVersionCheck=(t===null||t===void 0?void 0:t.skipVersionCheck)||!!(this.opts&&this.opts.skipVersionCheck);this.handleClientError=e=>{this.emit("error",e)};this.handleClientClose=()=>{this.emit("close")};this.handleClientReady=()=>{this.emit("ready")};this.initializing=this.init();this.initializing.catch((e=>this.emit("error",e)))}checkBlockingOptions(e,t,n=false){if(this.extraOptions.blocking&&t&&t.maxRetriesPerRequest){if(n){throw new Error(e)}else{console.error(e)}}}static async waitUntilReady(e){if(e.status==="ready"){return}if(e.status==="wait"){return e.connect()}if(e.status==="end"){throw new Error(a.CONNECTION_CLOSED_ERROR_MSG)}let t;let n;let r;try{await new Promise(((i,s)=>{let l;r=e=>{l=e};t=()=>{i()};n=()=>{if(e.status!=="end"){s(l||new Error(a.CONNECTION_CLOSED_ERROR_MSG))}else{if(l){s(l)}else{i()}}};(0,o.increaseMaxListeners)(e,3);e.once("ready",t);e.on("end",n);e.once("error",r)}))}finally{e.removeListener("end",n);e.removeListener("error",r);e.removeListener("ready",t);(0,o.decreaseMaxListeners)(e,3)}}get client(){return this.initializing}loadCommands(e,t){const n=t||c;for(const t in n){const r=`${n[t].name}:${e}`;if(!this._client[r]){this._client.defineCommand(r,{numberOfKeys:n[t].keys,lua:n[t].content})}}}async init(){if(!this._client){const e=this.opts,{url:t}=e,n=r.__rest(e,["url"]);this._client=t?new s.default(t,n):new s.default(n)}(0,o.increaseMaxListeners)(this._client,3);this._client.on("error",this.handleClientError);this._client.on("close",this.handleClientClose);this._client.on("ready",this.handleClientReady);if(!this.extraOptions.skipWaitingForReady){await RedisConnection.waitUntilReady(this._client)}this.loadCommands(this.packageVersion);if(this._client["status"]!=="end"){this.version=await this.getRedisVersion();if(this.skipVersionCheck!==true&&!this.closing){if((0,o.isRedisVersionLowerThan)(this.version,RedisConnection.minimumVersion)){throw new Error(`Redis version needs to be greater or equal than ${RedisConnection.minimumVersion} `+`Current: ${this.version}`)}if((0,o.isRedisVersionLowerThan)(this.version,RedisConnection.recommendedMinimumVersion)){console.warn(`It is highly recommended to use a minimum Redis version of ${RedisConnection.recommendedMinimumVersion}\n Current: ${this.version}`)}}this.capabilities={canDoubleTimeout:!(0,o.isRedisVersionLowerThan)(this.version,"6.0.0"),canBlockFor1Ms:!(0,o.isRedisVersionLowerThan)(this.version,"7.0.8")};this.status="ready"}return this._client}async disconnect(e=true){const t=await this.client;if(t.status!=="end"){let n,r;if(!e){return t.disconnect()}const i=new Promise(((e,i)=>{(0,o.increaseMaxListeners)(t,2);t.once("end",e);t.once("error",i);n=e;r=i}));t.disconnect();try{await i}finally{(0,o.decreaseMaxListeners)(t,2);t.removeListener("end",n);t.removeListener("error",r)}}}async reconnect(){const e=await this.client;return e.connect()}async close(e=false){if(!this.closing){const t=this.status;this.status="closing";this.closing=true;try{if(t==="ready"){await this.initializing}if(!this.extraOptions.shared){if(t=="initializing"||e){this._client.disconnect()}else{await this._client.quit()}this._client["status"]="end"}}catch(e){if((0,o.isNotConnectionError)(e)){throw e}}finally{this._client.off("error",this.handleClientError);this._client.off("close",this.handleClientClose);this._client.off("ready",this.handleClientReady);(0,o.decreaseMaxListeners)(this._client,3);this.removeAllListeners();this.status="closed"}}}async getRedisVersion(){if(this.skipVersionCheck){return RedisConnection.minimumVersion}const e=await this._client.info();const t="redis_version:";const n="maxmemory_policy:";const r=e.split(/\r?\n/);let i;for(let e=0;e<r.length;e++){if(r[e].indexOf(n)===0){const t=r[e].substr(n.length);if(t!=="noeviction"){console.warn(`IMPORTANT! Eviction policy is ${t}. It should be "noeviction"`)}}if(r[e].indexOf(t)===0){i=r[e].substr(t.length)}}return i}get redisVersion(){return this.version}}t.RedisConnection=RedisConnection;RedisConnection.minimumVersion="5.0.0";RedisConnection.recommendedMinimumVersion="6.2.0"},9126:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getNextMillis=t.Repeat=void 0;const r=n(1577);const i=n(9912);const s=n(6982);const a=n(977);class Repeat extends a.QueueBase{constructor(e,n,r){super(e,n,r);this.repeatStrategy=n.settings&&n.settings.repeatStrategy||t.getNextMillis;this.repeatKeyHashAlgorithm=n.settings&&n.settings.repeatKeyHashAlgorithm||"md5"}async updateRepeatableJob(e,t,n,{override:i}){var s,a;const o=Object.assign({},n.repeat);(s=o.pattern)!==null&&s!==void 0?s:o.pattern=o.cron;delete o.cron;const l=o.count?o.count+1:1;if(typeof o.limit!=="undefined"&&l>o.limit){return}let c=Date.now();const{endDate:u}=o;if(u&&c>new Date(u).getTime()){return}const d=n.prevMillis||0;c=d<c?c:d;const f=await this.repeatStrategy(c,o,e);const{every:p,pattern:h}=o;const y=Boolean((p||h)&&o.immediately);const m=y&&p?c-f:undefined;if(f){if(!d&&n.jobId){o.jobId=n.jobId}const s=getRepeatConcatOptions(e,o);const c=(a=n.repeat.key)!==null&&a!==void 0?a:this.hash(s);let b;if(i){b=await this.scripts.addRepeatableJob(c,f,{name:e,endDate:u?new Date(u).getTime():undefined,tz:o.tz,pattern:h,every:p},s)}else{const e=await this.client;b=await this.scripts.updateRepeatableJobMillis(e,c,f,s)}const{immediately:g}=o,v=r.__rest(o,["immediately"]);return this.createNextJob(e,f,b,Object.assign(Object.assign({},n),{repeat:Object.assign({offset:m},v)}),t,l,y)}}async createNextJob(e,t,n,r,i,s,a){const o=this.getRepeatJobKey(e,t,n,i);const l=Date.now();const c=t+(r.repeat.offset?r.repeat.offset:0)-l;const u=Object.assign(Object.assign({},r),{jobId:o,delay:c<0||a?0:c,timestamp:l,prevMillis:t,repeatJobKey:n});u.repeat=Object.assign(Object.assign({},r.repeat),{count:s});return this.Job.create(this,e,i,u)}getRepeatJobKey(e,t,n,r){if(n.split(":").length>2){return this.getRepeatJobId({name:e,nextMillis:t,namespace:this.hash(n),jobId:r===null||r===void 0?void 0:r.id})}return this.getRepeatDelayedJobId({customKey:n,nextMillis:t})}async removeRepeatable(e,t,n){var r;const i=getRepeatConcatOptions(e,Object.assign(Object.assign({},t),{jobId:n}));const s=(r=t.key)!==null&&r!==void 0?r:this.hash(i);const a=this.getRepeatJobId({name:e,nextMillis:"",namespace:this.hash(i),jobId:n!==null&&n!==void 0?n:t.jobId,key:t.key});return this.scripts.removeRepeatable(a,i,s)}async removeRepeatableByKey(e){const t=this.keyToData(e);const n=this.getRepeatJobId({name:t.name,nextMillis:"",namespace:this.hash(e),jobId:t.id});return this.scripts.removeRepeatable(n,"",e)}async getRepeatableData(e,t,n){const r=await e.hgetall(this.toKey("repeat:"+t));if(r){return{key:t,name:r.name,endDate:parseInt(r.endDate)||null,tz:r.tz||null,pattern:r.pattern||null,every:r.every||null,next:n}}return this.keyToData(t,n)}keyToData(e,t){const n=e.split(":");const r=n.slice(4).join(":")||null;return{key:e,name:n[0],id:n[1]||null,endDate:parseInt(n[2])||null,tz:n[3]||null,pattern:r,next:t}}async getRepeatableJobs(e=0,t=-1,n=false){const r=await this.client;const i=this.keys.repeat;const s=n?await r.zrange(i,e,t,"WITHSCORES"):await r.zrevrange(i,e,t,"WITHSCORES");const a=[];for(let e=0;e<s.length;e+=2){a.push(this.getRepeatableData(r,s[e],parseInt(s[e+1])))}return Promise.all(a)}async getRepeatableCount(){const e=await this.client;return e.zcard(this.toKey("repeat"))}hash(e){return(0,s.createHash)(this.repeatKeyHashAlgorithm).update(e).digest("hex")}getRepeatDelayedJobId({nextMillis:e,customKey:t}){return`repeat:${t}:${e}`}getRepeatJobId({name:e,nextMillis:t,namespace:n,jobId:r,key:i}){const s=i!==null&&i!==void 0?i:this.hash(`${e}${r||""}${n}`);return`repeat:${s}:${t}`}}t.Repeat=Repeat;function getRepeatConcatOptions(e,t){const n=t.endDate?new Date(t.endDate).getTime():"";const r=t.tz||"";const i=t.pattern;const s=(i?i:String(t.every))||"";const a=t.jobId?t.jobId:"";return`${e}:${a}:${n}:${r}:${s}`}const getNextMillis=(e,t)=>{const n=t.pattern;if(n&&t.every){throw new Error("Both .pattern and .every options are defined for this repeatable job")}if(t.every){return Math.floor(e/t.every)*t.every+(t.immediately?0:t.every)}const r=t.startDate&&new Date(t.startDate)>new Date(e)?new Date(t.startDate):new Date(e);const s=(0,i.parseExpression)(n,Object.assign(Object.assign({},t),{currentDate:r}));try{if(t.immediately){return(new Date).getTime()}else{return s.next().getTime()}}catch(e){}};t.getNextMillis=getNextMillis},8999:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(6694);const sandbox=(e,t)=>async function process(n,i){let s;let a;let o;try{const l=new Promise(((l,c)=>{const initChild=async()=>{try{o=(e,t)=>{c(new Error("Unexpected exit code: "+e+" signal: "+t))};s=await t.retain(e);s.on("exit",o);a=async e=>{var t,i,a;try{switch(e.cmd){case r.ParentCommand.Completed:l(e.value);break;case r.ParentCommand.Failed:case r.ParentCommand.Error:{const t=new Error;Object.assign(t,e.value);c(t);break}case r.ParentCommand.Progress:await n.updateProgress(e.value);break;case r.ParentCommand.Log:await n.log(e.value);break;case r.ParentCommand.MoveToDelayed:await n.moveToDelayed((t=e.value)===null||t===void 0?void 0:t.timestamp,(i=e.value)===null||i===void 0?void 0:i.token);break;case r.ParentCommand.MoveToWait:await n.moveToWait((a=e.value)===null||a===void 0?void 0:a.token);break;case r.ParentCommand.Update:await n.updateData(e.value);break;case r.ParentCommand.GetChildrenValues:{const t=await n.getChildrenValues();s.send({requestId:e.requestId,cmd:r.ChildCommand.GetChildrenValuesResponse,value:t})}break;case r.ParentCommand.GetIgnoredChildrenFailures:{const t=await n.getIgnoredChildrenFailures();s.send({requestId:e.requestId,cmd:r.ChildCommand.GetIgnoredChildrenFailuresResponse,value:t})}break}}catch(e){c(e)}};s.on("message",a);s.send({cmd:r.ChildCommand.Start,job:n.asJSONSandbox(),token:i})}catch(e){c(e)}};initChild()}));await l;return l}finally{if(s){s.off("message",a);s.off("exit",o);if(s.exitCode===null&&s.signalCode===null){t.release(s)}}}};t["default"]=sandbox},9916:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.raw2NextJobData=t.Scripts=void 0;const r=n(2766);const i=new r.Packr({useRecords:false,encodeUndefinedAsNil:true});const s=i.pack;const a=n(6694);const o=n(2646);const l=n(3267);const c=n(6342);class Scripts{constructor(e){this.queue=e;this.version=l.version;const t=this.queue.keys;this.moveToFinishedKeys=[t.wait,t.active,t.prioritized,t.events,t.stalled,t.limiter,t.delayed,t.paused,t.meta,t.pc,undefined,undefined,undefined,undefined]}execCommand(e,t,n){const r=`${t}:${this.version}`;return e[r](n)}async isJobInList(e,t){const n=await this.queue.client;let r;if((0,o.isRedisVersionLowerThan)(this.queue.redisVersion,"6.0.6")){r=await this.execCommand(n,"isJobInList",[e,t])}else{r=await n.lpos(e,t)}return Number.isInteger(r)}addDelayedJobArgs(e,t,n){const r=this.queue.keys;const i=[r.marker,r.meta,r.id,r.delayed,r.completed,r.events];i.push(s(n),e.data,t);return i}addDelayedJob(e,t,n,r){const i=this.addDelayedJobArgs(t,n,r);return this.execCommand(e,"addDelayedJob",i)}addPrioritizedJobArgs(e,t,n){const r=this.queue.keys;const i=[r.marker,r.meta,r.id,r.prioritized,r.delayed,r.completed,r.active,r.events,r.pc];i.push(s(n),e.data,t);return i}addPrioritizedJob(e,t,n,r){const i=this.addPrioritizedJobArgs(t,n,r);return this.execCommand(e,"addPrioritizedJob",i)}addParentJobArgs(e,t,n){const r=this.queue.keys;const i=[r.meta,r.id,r.delayed,r.completed,r.events];i.push(s(n),e.data,t);return i}addParentJob(e,t,n,r){const i=this.addParentJobArgs(t,n,r);return this.execCommand(e,"addParentJob",i)}addStandardJobArgs(e,t,n){const r=this.queue.keys;const i=[r.wait,r.paused,r.meta,r.id,r.completed,r.delayed,r.active,r.events,r.marker];i.push(s(n),e.data,t);return i}addStandardJob(e,t,n,r){const i=this.addStandardJobArgs(t,n,r);return this.execCommand(e,"addStandardJob",i)}async addJob(e,t,n,r,i={}){const a=this.queue.keys;const o=t.parent;const l=[a[""],typeof r!=="undefined"?r:"",t.name,t.timestamp,t.parentKey||null,i.waitChildrenKey||null,i.parentDependenciesKey||null,o,t.repeatJobKey,t.deduplicationId?`${a.de}:${t.deduplicationId}`:null];let c;if(n.repeat){const e=Object.assign({},n.repeat);if(e.startDate){e.startDate=+new Date(e.startDate)}if(e.endDate){e.endDate=+new Date(e.endDate)}c=s(Object.assign(Object.assign({},n),{repeat:e}))}else{c=s(n)}let u;if(i.waitChildrenKey){u=await this.addParentJob(e,t,c,l)}else if(typeof n.delay=="number"&&n.delay>0){u=await this.addDelayedJob(e,t,c,l)}else if(n.priority){u=await this.addPrioritizedJob(e,t,c,l)}else{u=await this.addStandardJob(e,t,c,l)}if(u<0){throw this.finishedErrors({code:u,parentKey:i.parentKey,command:"addJob"})}return u}pauseArgs(e){let t="wait",n="paused";if(!e){t="paused";n="wait"}const r=[t,n,"meta","prioritized"].map((e=>this.queue.toKey(e)));r.push(this.queue.keys.events,this.queue.keys.delayed,this.queue.keys.marker);const i=[e?"paused":"resumed"];return r.concat(i)}async pause(e){const t=await this.queue.client;const n=this.pauseArgs(e);return this.execCommand(t,"pause",n)}addRepeatableJobArgs(e,t,n,r){const i=this.queue.keys;const a=[i.repeat,i.delayed];const o=[t,s(n),r,e,i[""]];return a.concat(o)}async addRepeatableJob(e,t,n,r){const i=await this.queue.client;const s=this.addRepeatableJobArgs(e,t,n,r);return this.execCommand(i,"addRepeatableJob",s)}async addJobScheduler(e,t,n,r,i,a,o){const l=await this.queue.client;const c=this.queue.keys;const u=[c.repeat,c.delayed,c.wait,c.paused,c.meta,c.prioritized,c.marker,c.id,c.events,c.pc,c.active];const d=[t,s(i),e,n,s(r),s(a),Date.now(),c[""],o?this.queue.toKey(o):""];return this.execCommand(l,"addJobScheduler",u.concat(d))}async updateRepeatableJobMillis(e,t,n,r){const i=[this.queue.keys.repeat,n,t,r];return this.execCommand(e,"updateRepeatableJobMillis",i)}async updateJobSchedulerNextMillis(e,t,n,r,i){const a=await this.queue.client;const o=this.queue.keys;const l=[o.repeat,o.delayed,o.wait,o.paused,o.meta,o.prioritized,o.marker,o.id,o.events,o.pc,i?this.queue.toKey(i):"",o.active];const c=[t,e,n,s(r),Date.now(),o[""],i];return this.execCommand(a,"updateJobScheduler",l.concat(c))}removeRepeatableArgs(e,t,n){const r=this.queue.keys;const i=[r.repeat,r.delayed,r.events];const s=[e,this.getRepeatConcatOptions(t,n),n,r[""]];return i.concat(s)}getRepeatConcatOptions(e,t){if(t&&t.split(":").length>2){return t}return e}async removeRepeatable(e,t,n){const r=await this.queue.client;const i=this.removeRepeatableArgs(e,t,n);return this.execCommand(r,"removeRepeatable",i)}async removeJobScheduler(e){const t=await this.queue.client;const n=this.queue.keys;const r=[n.repeat,n.delayed,n.events];const i=[e,n[""]];return this.execCommand(t,"removeJobScheduler",r.concat(i))}removeArgs(e,t){const n=[e,"repeat"].map((e=>this.queue.toKey(e)));const r=[e,t?1:0,this.queue.toKey("")];return n.concat(r)}async remove(e,t){const n=await this.queue.client;const r=this.removeArgs(e,t);const i=await this.execCommand(n,"removeJob",r);if(i<0){throw this.finishedErrors({code:i,jobId:e,command:"removeJob"})}return i}async removeUnprocessedChildren(e){const t=await this.queue.client;const n=[this.queue.toKey(e),this.queue.keys.meta,this.queue.toKey(""),e];await this.execCommand(t,"removeUnprocessedChildren",n)}async extendLock(e,t,n,r){r=r||await this.queue.client;const i=[this.queue.toKey(e)+":lock",this.queue.keys.stalled,t,n,e];return this.execCommand(r,"extendLock",i)}async extendLocks(e,t,n){const r=await this.queue.client;const i=[this.queue.keys.stalled,this.queue.toKey(""),s(t),s(e),n];return this.execCommand(r,"extendLocks",i)}async updateData(e,t){const n=await this.queue.client;const r=[this.queue.toKey(e.id)];const i=JSON.stringify(t);const s=await this.execCommand(n,"updateData",r.concat([i]));if(s<0){throw this.finishedErrors({code:s,jobId:e.id,command:"updateData"})}}async updateProgress(e,t){const n=await this.queue.client;const r=[this.queue.toKey(e),this.queue.keys.events,this.queue.keys.meta];const i=JSON.stringify(t);const s=await this.execCommand(n,"updateProgress",r.concat([e,i]));if(s<0){throw this.finishedErrors({code:s,jobId:e,command:"updateProgress"})}}async addLog(e,t,n){const r=await this.queue.client;const i=[this.queue.toKey(e),this.queue.toKey(e)+":logs"];const s=await this.execCommand(r,"addLog",i.concat([e,t,n?n:""]));if(s<0){throw this.finishedErrors({code:s,jobId:e,command:"addLog"})}return s}moveToFinishedArgs(e,t,n,r,i,a,l,c=true,u){var d,f,p,h,y,m,b;const g=this.queue.keys;const v=this.queue.opts;const K=i==="completed"?v.removeOnComplete:v.removeOnFail;const S=this.queue.toKey(`metrics:${i}`);const E=this.moveToFinishedKeys;E[10]=g[i];E[11]=this.queue.toKey((d=e.id)!==null&&d!==void 0?d:"");E[12]=S;E[13]=this.queue.keys.marker;const k=this.getKeepJobs(r,K);const I=[e.id,l,n,typeof t==="undefined"?"null":t,i,!c||this.queue.closing?0:1,g[""],s({token:a,name:v.name,keepJobs:k,limiter:v.limiter,lockDuration:v.lockDuration,attempts:e.opts.attempts,maxMetricsSize:((f=v.metrics)===null||f===void 0?void 0:f.maxDataPoints)?(p=v.metrics)===null||p===void 0?void 0:p.maxDataPoints:"",fpof:!!((h=e.opts)===null||h===void 0?void 0:h.failParentOnFailure),cpof:!!((y=e.opts)===null||y===void 0?void 0:y.continueParentOnFailure),idof:!!((m=e.opts)===null||m===void 0?void 0:m.ignoreDependencyOnFailure),rdof:!!((b=e.opts)===null||b===void 0?void 0:b.removeDependencyOnFailure)}),u?s((0,o.objectToFlatArray)(u)):void 0];return E.concat(I)}getKeepJobs(e,t){if(typeof e==="undefined"){return t||{count:e?0:-1}}return typeof e==="object"?e:typeof e==="number"?{count:e}:{count:e?0:-1}}async moveToFinished(e,t){const n=await this.queue.client;const r=await this.execCommand(n,"moveToFinished",t);if(r<0){throw this.finishedErrors({code:r,jobId:e,command:"moveToFinished",state:"active"})}else{if(typeof r!=="undefined"){return raw2NextJobData(r)}}}drainArgs(e){const t=this.queue.keys;const n=[t.wait,t.paused,t.delayed,t.prioritized,t.repeat];const r=[t[""],e?"1":"0"];return n.concat(r)}async drain(e){const t=await this.queue.client;const n=this.drainArgs(e);return this.execCommand(t,"drain",n)}removeChildDependencyArgs(e,t){const n=this.queue.keys;const r=[n[""]];const i=[this.queue.toKey(e),t];return r.concat(i)}async removeChildDependency(e,t){const n=await this.queue.client;const r=this.removeChildDependencyArgs(e,t);const i=await this.execCommand(n,"removeChildDependency",r);switch(i){case 0:return true;case 1:return false;default:throw this.finishedErrors({code:i,jobId:e,parentKey:t,command:"removeChildDependency"})}}getRangesArgs(e,t,n,r){const i=this.queue.keys;const s=e.map((e=>e==="waiting"?"wait":e));const a=[i[""]];const o=[t,n,r?"1":"0",...s];return a.concat(o)}async getRanges(e,t=0,n=1,r=false){const i=await this.queue.client;const s=this.getRangesArgs(e,t,n,r);return await this.execCommand(i,"getRanges",s)}getCountsArgs(e){const t=this.queue.keys;const n=e.map((e=>e==="waiting"?"wait":e));const r=[t[""]];const i=[...n];return r.concat(i)}async getCounts(e){const t=await this.queue.client;const n=this.getCountsArgs(e);return await this.execCommand(t,"getCounts",n)}getCountsPerPriorityArgs(e){const t=[this.queue.keys.wait,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.prioritized];const n=e;return t.concat(n)}async getCountsPerPriority(e){const t=await this.queue.client;const n=this.getCountsPerPriorityArgs(e);return await this.execCommand(t,"getCountsPerPriority",n)}getDependencyCountsArgs(e,t){const n=[`${e}:processed`,`${e}:dependencies`,`${e}:failed`,`${e}:unsuccessful`].map((e=>this.queue.toKey(e)));const r=t;return n.concat(r)}async getDependencyCounts(e,t){const n=await this.queue.client;const r=this.getDependencyCountsArgs(e,t);return await this.execCommand(n,"getDependencyCounts",r)}moveToCompletedArgs(e,t,n,r,i=false){const s=Date.now();return this.moveToFinishedArgs(e,t,"returnvalue",n,"completed",r,s,i)}moveToFailedArgs(e,t,n,r,i=false,s){const a=Date.now();return this.moveToFinishedArgs(e,t,"failedReason",n,"failed",r,a,i,s)}async isFinished(e,t=false){const n=await this.queue.client;const r=["completed","failed",e].map((e=>this.queue.toKey(e)));return this.execCommand(n,"isFinished",r.concat([e,t?"1":""]))}async getState(e){const t=await this.queue.client;const n=["completed","failed","delayed","active","wait","paused","waiting-children","prioritized"].map((e=>this.queue.toKey(e)));if((0,o.isRedisVersionLowerThan)(this.queue.redisVersion,"6.0.6")){return this.execCommand(t,"getState",n.concat([e]))}return this.execCommand(t,"getStateV2",n.concat([e]))}async changeDelay(e,t){const n=await this.queue.client;const r=this.changeDelayArgs(e,t);const i=await this.execCommand(n,"changeDelay",r);if(i<0){throw this.finishedErrors({code:i,jobId:e,command:"changeDelay",state:"delayed"})}}changeDelayArgs(e,t){const n=Date.now();const r=[this.queue.keys.delayed,this.queue.keys.meta,this.queue.keys.marker,this.queue.keys.events];return r.concat([t,JSON.stringify(n),e,this.queue.toKey(e)])}async changePriority(e,t=0,n=false){const r=await this.queue.client;const i=this.changePriorityArgs(e,t,n);const s=await this.execCommand(r,"changePriority",i);if(s<0){throw this.finishedErrors({code:s,jobId:e,command:"changePriority"})}}changePriorityArgs(e,t=0,n=false){const r=[this.queue.keys.wait,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.prioritized,this.queue.keys.active,this.queue.keys.pc,this.queue.keys.marker];return r.concat([t,this.queue.toKey(""),e,n?1:0])}moveToDelayedArgs(e,t,n,r,i={}){const a=this.queue.keys;const l=[a.marker,a.active,a.prioritized,a.delayed,this.queue.toKey(e),a.events,a.meta,a.stalled];return l.concat([this.queue.keys[""],t,e,n,r,i.skipAttempt?"1":"0",i.fieldsToUpdate?s((0,o.objectToFlatArray)(i.fieldsToUpdate)):void 0])}moveToWaitingChildrenArgs(e,t,n){const r=Date.now();const i=(0,o.getParentKey)(n.child);const s=["active","waiting-children",e,`${e}:dependencies`,`${e}:unsuccessful`,"stalled","events"].map((e=>this.queue.toKey(e)));return s.concat([t,i!==null&&i!==void 0?i:"",JSON.stringify(r),e,this.queue.toKey("")])}isMaxedArgs(){const e=this.queue.keys;const t=[e.meta,e.active];return t}async isMaxed(){const e=await this.queue.client;const t=this.isMaxedArgs();return!!await this.execCommand(e,"isMaxed",t)}async moveToDelayed(e,t,n,r="0",i={}){const s=await this.queue.client;const a=this.moveToDelayedArgs(e,t,r,n,i);const o=await this.execCommand(s,"moveToDelayed",a);if(o<0){throw this.finishedErrors({code:o,jobId:e,command:"moveToDelayed",state:"active"})}}async moveToWaitingChildren(e,t,n={}){const r=await this.queue.client;const i=this.moveToWaitingChildrenArgs(e,t,n);const s=await this.execCommand(r,"moveToWaitingChildren",i);switch(s){case 0:return true;case 1:return false;default:throw this.finishedErrors({code:s,jobId:e,command:"moveToWaitingChildren",state:"active"})}}getRateLimitTtlArgs(e){const t=[this.queue.keys.limiter];return t.concat([e!==null&&e!==void 0?e:"0"])}async getRateLimitTtl(e){const t=await this.queue.client;const n=this.getRateLimitTtlArgs(e);return this.execCommand(t,"getRateLimitTtl",n)}async cleanJobsInSet(e,t,n=0){const r=await this.queue.client;return this.execCommand(r,"cleanJobsInSet",[this.queue.toKey(e),this.queue.toKey("events"),this.queue.toKey("repeat"),this.queue.toKey(""),t,n,e])}getJobSchedulerArgs(e){const t=[this.queue.keys.repeat];return t.concat([e])}async getJobScheduler(e){const t=await this.queue.client;const n=this.getJobSchedulerArgs(e);return this.execCommand(t,"getJobScheduler",n)}retryJobArgs(e,t,n,r={}){const i=[this.queue.keys.active,this.queue.keys.wait,this.queue.keys.paused,this.queue.toKey(e),this.queue.keys.meta,this.queue.keys.events,this.queue.keys.delayed,this.queue.keys.prioritized,this.queue.keys.pc,this.queue.keys.marker,this.queue.keys.stalled];const a=(t?"R":"L")+"PUSH";return i.concat([this.queue.toKey(""),Date.now(),a,e,n,r.fieldsToUpdate?s((0,o.objectToFlatArray)(r.fieldsToUpdate)):void 0])}async retryJob(e,t,n="0",r={}){const i=await this.queue.client;const s=this.retryJobArgs(e,t,n,r);const a=await this.execCommand(i,"retryJob",s);if(a<0){throw this.finishedErrors({code:a,jobId:e,command:"retryJob",state:"active"})}}moveJobsToWaitArgs(e,t,n){const r=[this.queue.toKey(""),this.queue.keys.events,this.queue.toKey(e),this.queue.toKey("wait"),this.queue.toKey("paused"),this.queue.keys.meta,this.queue.keys.active,this.queue.keys.marker];const i=[t,n,e];return r.concat(i)}async retryJobs(e="failed",t=1e3,n=(new Date).getTime()){const r=await this.queue.client;const i=this.moveJobsToWaitArgs(e,t,n);return this.execCommand(r,"moveJobsToWait",i)}async promoteJobs(e=1e3){const t=await this.queue.client;const n=this.moveJobsToWaitArgs("delayed",e,Number.MAX_VALUE);return this.execCommand(t,"moveJobsToWait",n)}async reprocessJob(e,t){const n=await this.queue.client;const r=[this.queue.toKey(e.id),this.queue.keys.events,this.queue.toKey(t),this.queue.keys.wait,this.queue.keys.meta,this.queue.keys.paused,this.queue.keys.active,this.queue.keys.marker];const i=[e.id,(e.opts.lifo?"R":"L")+"PUSH",t==="failed"?"failedReason":"returnvalue",t];const s=await this.execCommand(n,"reprocessJob",r.concat(i));switch(s){case 1:return;default:throw this.finishedErrors({code:s,jobId:e.id,command:"reprocessJob",state:t})}}async moveToActive(e,t,n){const r=this.queue.opts;const i=this.queue.keys;const a=[i.wait,i.active,i.prioritized,i.events,i.stalled,i.limiter,i.delayed,i.paused,i.meta,i.pc,i.marker];const o=[i[""],Date.now(),s({token:t,lockDuration:r.lockDuration,limiter:r.limiter,name:n})];const l=await this.execCommand(e,"moveToActive",a.concat(o));return raw2NextJobData(l)}async promote(e){const t=await this.queue.client;const n=[this.queue.keys.delayed,this.queue.keys.wait,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.prioritized,this.queue.keys.active,this.queue.keys.pc,this.queue.keys.events,this.queue.keys.marker];const r=[this.queue.toKey(""),e];const i=await this.execCommand(t,"promote",n.concat(r));if(i<0){throw this.finishedErrors({code:i,jobId:e,command:"promote",state:"delayed"})}}moveStalledJobsToWaitArgs(){const e=this.queue.opts;const t=[this.queue.keys.stalled,this.queue.keys.wait,this.queue.keys.active,this.queue.keys["stalled-check"],this.queue.keys.meta,this.queue.keys.paused,this.queue.keys.marker,this.queue.keys.events];const n=[e.maxStalledCount,this.queue.toKey(""),Date.now(),e.stalledInterval];return t.concat(n)}async moveStalledJobsToWait(){const e=await this.queue.client;const t=this.moveStalledJobsToWaitArgs();return this.execCommand(e,"moveStalledJobsToWait",t)}async moveJobFromActiveToWait(e,t="0"){const n=await this.queue.client;const r=[this.queue.keys.active,this.queue.keys.wait,this.queue.keys.stalled,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.limiter,this.queue.keys.prioritized,this.queue.keys.marker,this.queue.keys.events];const i=[e,t,this.queue.toKey(e)];const s=await this.execCommand(n,"moveJobFromActiveToWait",r.concat(i));if(s<0){throw this.finishedErrors({code:s,jobId:e,command:"moveJobFromActiveToWait",state:"active"})}return s}async obliterate(e){const t=await this.queue.client;const n=[this.queue.keys.meta,this.queue.toKey("")];const r=[e.count,e.force?"force":null];const i=await this.execCommand(t,"obliterate",n.concat(r));if(i<0){switch(i){case-1:throw new Error("Cannot obliterate non-paused queue");case-2:throw new Error("Cannot obliterate queue with active jobs")}}return i}async paginate(e,t){const n=await this.queue.client;const r=[e];const i=5;const s=t.end>=0?t.end-t.start+1:Infinity;let a="0",l=0,c,u,d,f=[],p=[];do{const e=[t.start+f.length,t.end,a,l,i];if(t.fetchJobs){e.push(1)}[a,l,c,u,d]=await this.execCommand(n,"paginate",r.concat(e));f=f.concat(c);if(d&&d.length){p=p.concat(d.map(o.array2obj))}}while(a!="0"&&f.length<s);if(f.length&&Array.isArray(f[0])){const e=[];for(let t=0;t<f.length;t++){const[n,r]=f[t];try{e.push({id:n,v:JSON.parse(r)})}catch(t){e.push({id:n,err:t.message})}}return{cursor:a,items:e,total:u,jobs:p}}else{return{cursor:a,items:f.map((e=>({id:e}))),total:u,jobs:p}}}finishedErrors({code:e,jobId:t,parentKey:n,command:r,state:i}){switch(e){case a.ErrorCode.JobNotExist:return new Error(`Missing key for job ${t}. ${r}`);case a.ErrorCode.JobLockNotExist:return new Error(`Missing lock for job ${t}. ${r}`);case a.ErrorCode.JobNotInState:return new Error(`Job ${t} is not in the ${i} state. ${r}`);case a.ErrorCode.JobPendingChildren:return new Error(`Job ${t} has pending dependencies. ${r}`);case a.ErrorCode.ParentJobNotExist:return new Error(`Missing key for parent job ${n}. ${r}`);case a.ErrorCode.JobLockMismatch:return new Error(`Lock mismatch for job ${t}. Cmd ${r} from ${i}`);case a.ErrorCode.ParentJobCannotBeReplaced:return new Error(`The parent job ${n} cannot be replaced. ${r}`);case a.ErrorCode.JobBelongsToJobScheduler:return new Error(`Job ${t} belongs to a job scheduler and cannot be removed directly. ${r}`);case a.ErrorCode.JobHasFailedChildren:return new c.UnrecoverableError(`Cannot complete job ${t} because it has at least one failed child. ${r}`);default:return new Error(`Unknown code ${e} error for ${t}. ${r}`)}}}t.Scripts=Scripts;function raw2NextJobData(e){if(e){const t=[null,e[1],e[2],e[3]];if(e[0]){t[0]=(0,o.array2obj)(e[0])}return t}return[]}t.raw2NextJobData=raw2NextJobData},8544:function(e,t,n){"use strict";e=n.nmd(e);Object.defineProperty(t,"__esModule",{value:true});t.Worker=void 0;const r=n(9896);const i=n(7016);const s=n(6928);const a=n(9935);const o=n(221);const l=n(2646);const c=n(977);const u=n(9126);const d=n(8853);const f=n(3420);const p=n(8999);const h=n(3581);const y=n(6342);const m=n(6694);const b=n(355);const g=10;const v=3e4;class Worker extends c.QueueBase{static RateLimitError(){return new y.RateLimitError}constructor(t,n,o,c){super(t,Object.assign(Object.assign({drainDelay:5,concurrency:1,lockDuration:3e4,maxStalledCount:1,stalledInterval:3e4,autorun:true,runRetryDelay:15e3},o),{blockingConnection:true}),c);this.abortDelayController=null;this.blockUntil=0;this.drained=false;this.extendLocksTimer=null;this.limitUntil=0;this.waiting=null;this.running=false;this.mainLoopRunning=null;if(!o||!o.connection){throw new Error("Worker requires a connection")}if(typeof this.opts.maxStalledCount!=="number"||this.opts.maxStalledCount<0){throw new Error("maxStalledCount must be greater or equal than 0")}if(typeof this.opts.stalledInterval!=="number"||this.opts.stalledInterval<=0){throw new Error("stalledInterval must be greater than 0")}if(typeof this.opts.drainDelay!=="number"||this.opts.drainDelay<=0){throw new Error("drainDelay must be greater than 0")}this.concurrency=this.opts.concurrency;this.opts.lockRenewTime=this.opts.lockRenewTime||this.opts.lockDuration/2;this.id=(0,a.v4)();if(n){if(typeof n==="function"){this.processFn=n}else{if(n instanceof i.URL){if(!r.existsSync(n)){throw new Error(`URL ${n} does not exist in the local file system`)}n=n.href}else{const e=[".js",".ts",".flow",".cjs"];const t=n+(e.includes(s.extname(n))?"":".js");if(!r.existsSync(t)){throw new Error(`File ${t} does not exist`)}}const t=s.dirname(e.filename||__filename);const a=s.join(t,"main-worker.js");const o=s.join(t,"main.js");let l=this.opts.useWorkerThreads?a:o;try{r.statSync(l)}catch(e){const t=this.opts.useWorkerThreads?"main-worker.js":"main.js";l=s.join(process.cwd(),`dist/cjs/classes/${t}`);r.statSync(l)}this.childPool=new d.ChildPool({mainFile:l,useWorkerThreads:this.opts.useWorkerThreads,workerForkOptions:this.opts.workerForkOptions,workerThreadsOptions:this.opts.workerThreadsOptions});this.processFn=(0,p.default)(n,this.childPool).bind(this)}if(this.opts.autorun){this.run().catch((e=>this.emit("error",e)))}}const u=this.clientName()+(this.opts.name?`:w:${this.opts.name}`:"");this.blockingConnection=new f.RedisConnection((0,l.isRedisInstance)(o.connection)?o.connection.duplicate({connectionName:u}):Object.assign(Object.assign({},o.connection),{connectionName:u}),{shared:false,blocking:true,skipVersionCheck:o.skipVersionCheck});this.blockingConnection.on("error",(e=>this.emit("error",e)));this.blockingConnection.on("ready",(()=>setTimeout((()=>this.emit("ready")),0)))}emit(e,...t){return super.emit(e,...t)}off(e,t){super.off(e,t);return this}on(e,t){super.on(e,t);return this}once(e,t){super.once(e,t);return this}callProcessJob(e,t){return this.processFn(e,t)}createJob(e,t){return this.Job.fromJSON(this,e,t)}async waitUntilReady(){await super.waitUntilReady();return this.blockingConnection.client}set concurrency(e){if(typeof e!=="number"||e<1||!isFinite(e)){throw new Error("concurrency must be a finite number greater than 0")}this._concurrency=e}get concurrency(){return this._concurrency}get repeat(){return new Promise((async e=>{if(!this._repeat){const e=await this.client;this._repeat=new u.Repeat(this.name,Object.assign(Object.assign({},this.opts),{connection:e}));this._repeat.on("error",(e=>this.emit.bind(this,e)))}e(this._repeat)}))}get jobScheduler(){return new Promise((async e=>{if(!this._jobScheduler){const e=await this.client;this._jobScheduler=new b.JobScheduler(this.name,Object.assign(Object.assign({},this.opts),{connection:e}));this._jobScheduler.on("error",(e=>this.emit.bind(this,e)))}e(this._jobScheduler)}))}async run(){if(!this.processFn){throw new Error("No process function is defined.")}if(this.running){throw new Error("Worker is already running.")}try{this.running=true;if(this.closing||this.paused){return}await this.startStalledCheckTimer();const e=await this.client;const t=await this.blockingConnection.client;this.mainLoopRunning=this.mainLoop(e,t);await this.mainLoopRunning}finally{this.running=false}}async waitForRateLimit(){var e;const t=this.limitUntil;if(t>Date.now()){(e=this.abortDelayController)===null||e===void 0?void 0:e.abort();this.abortDelayController=new o.AbortController;const n=this.getRateLimitDelay(t-Date.now());await this.delay(n,this.abortDelayController)}}async mainLoop(e,t){const n=new h.AsyncFifoQueue;const r=new Set;this.startLockExtenderTimer(r);let i=0;while(!this.closing&&!this.paused||n.numTotal()>0){while(!this.closing&&!this.paused&&!this.waiting&&n.numTotal()<this._concurrency&&!this.isRateLimited()){const r=`${this.id}:${i++}`;const s=this.retryIfFailed((()=>this._getNextJob(e,t,r,{block:true})),this.opts.runRetryDelay);n.add(s);if(this.waiting&&n.numTotal()>1){break}const a=await s;if(!a&&n.numTotal()>1){break}if(this.blockUntil){break}}let s;do{s=await n.fetch()}while(!s&&n.numQueued()>0);if(s){const e=s.token;n.add(this.retryIfFailed((()=>this.processJob(s,e,(()=>n.numTotal()<=this._concurrency),r)),this.opts.runRetryDelay))}else if(n.numQueued()===0){await this.waitForRateLimit()}}}async getNextJob(e,{block:t=true}={}){var n,r;const i=await this._getNextJob(await this.client,await this.blockingConnection.client,e,{block:t});return this.trace(m.SpanKind.INTERNAL,"getNextJob",this.name,(async e=>{e===null||e===void 0?void 0:e.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.QueueName]:this.name,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerOptions]:JSON.stringify({block:t}),[m.TelemetryAttributes.JobId]:i===null||i===void 0?void 0:i.id});return i}),(r=(n=i===null||i===void 0?void 0:i.opts)===null||n===void 0?void 0:n.telemetry)===null||r===void 0?void 0:r.metadata)}async _getNextJob(e,t,n,{block:r=true}={}){if(this.paused){return}if(this.closing){return}if(this.drained&&r&&!this.limitUntil&&!this.waiting){this.waiting=this.waitForJob(t,this.blockUntil);try{this.blockUntil=await this.waiting;if(this.blockUntil<=0||this.blockUntil-Date.now()<1){return await this.moveToActive(e,n,this.opts.name)}}catch(e){if(!(this.paused||this.closing)&&(0,l.isNotConnectionError)(e)){throw e}}finally{this.waiting=null}}else{if(!this.isRateLimited()){return this.moveToActive(e,n,this.opts.name)}}}async rateLimit(e){await this.trace(m.SpanKind.INTERNAL,"rateLimit",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerRateLimit]:e});await this.client.then((t=>t.set(this.keys.limiter,Number.MAX_SAFE_INTEGER,"PX",e)))}))}get minimumBlockTimeout(){return this.blockingConnection.capabilities.canBlockFor1Ms?.001:.002}isRateLimited(){return this.limitUntil>Date.now()}async moveToActive(e,t,n){const[r,i,s,a]=await this.scripts.moveToActive(e,t,n);this.updateDelays(s,a);return this.nextJobFromJobData(r,i,t)}async waitForJob(e,t){if(this.paused){return Infinity}let n;try{if(!this.closing&&!this.isRateLimited()){let r=this.getBlockTimeout(t);if(r>0){r=this.blockingConnection.capabilities.canDoubleTimeout?r:Math.ceil(r);n=setTimeout((async()=>{e.disconnect(!this.closing)}),r*1e3+1e3);this.updateDelays();const i=await e.bzpopmin(this.keys.marker,r);if(i){const[e,n,r]=i;if(n){const e=parseInt(r);if(t&&e>t){return t}return e}}}return 0}}catch(e){if((0,l.isNotConnectionError)(e)){this.emit("error",e)}if(!this.closing){await this.delay()}}finally{clearTimeout(n)}return Infinity}getBlockTimeout(e){const t=this.opts;if(e){const t=e-Date.now();if(t<=0){return t}else if(t<this.minimumBlockTimeout*1e3){return this.minimumBlockTimeout}else{return Math.min(t/1e3,g)}}else{return Math.max(t.drainDelay,this.minimumBlockTimeout)}}getRateLimitDelay(e){return Math.min(e,v)}async delay(e,t){await(0,l.delay)(e||l.DELAY_TIME_1,t)}updateDelays(e=0,t=0){const n=Math.max(e,0);if(n>0){this.limitUntil=Date.now()+n}else{this.limitUntil=0}this.blockUntil=Math.max(t,0)||0}async nextJobFromJobData(e,t,n){if(!e){if(!this.drained){this.emit("drained");this.drained=true}}else{this.drained=false;const r=this.createJob(e,t);r.token=n;if(r.opts.repeat&&!r.nextRepeatableJobId){if(r.repeatJobKey&&r.repeatJobKey.split(":").length<5){const e=await this.jobScheduler;await e.upsertJobScheduler(r.repeatJobKey,r.opts.repeat,r.name,r.data,r.opts,{override:false,producerId:r.id})}else{const e=await this.repeat;await e.updateRepeatableJob(r.name,r.data,r.opts,{override:false})}}return r}}async processJob(e,t,n=()=>true,r){var i,s;const a=(s=(i=e.opts)===null||i===void 0?void 0:i.telemetry)===null||s===void 0?void 0:s.metadata;return this.trace(m.SpanKind.CONSUMER,"process",this.name,(async i=>{i===null||i===void 0?void 0:i.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.JobId]:e.id});this.emit("active",e,"waiting");const s=Date.now();const a={job:e,ts:s};try{if(e.deferredFailure){const s=await this.handleFailed(new y.UnrecoverableError(e.deferredFailure),e,t,n,r,a,i);return s}r.add(a);const s=await this.callProcessJob(e,t);return await this.handleCompleted(s,e,t,n,r,a,i)}catch(s){const o=await this.handleFailed(s,e,t,n,r,a,i);return o}finally{i===null||i===void 0?void 0:i.setAttributes({[m.TelemetryAttributes.JobFinishedTimestamp]:Date.now(),[m.TelemetryAttributes.JobProcessedTimestamp]:s})}}),a)}async handleCompleted(e,t,n,r=()=>true,i,s,a){i.delete(s);if(!this.connection.closing){const i=await t.moveToCompleted(e,n,r()&&!(this.closing||this.paused));this.emit("completed",t,e,"active");a===null||a===void 0?void 0:a.addEvent("job completed",{[m.TelemetryAttributes.JobResult]:JSON.stringify(e)});const[s,o,l,c]=i||[];this.updateDelays(l,c);return this.nextJobFromJobData(s,o,n)}}async handleFailed(e,t,n,r=()=>true,i,s,a){i.delete(s);if(!this.connection.closing){try{if(e.message==y.RATE_LIMIT_ERROR){const e=await this.moveLimitedBackToWait(t,n);this.limitUntil=e>0?Date.now()+e:0;return}if(e instanceof y.DelayedError||e.name=="DelayedError"||e instanceof y.WaitingError||e.name=="WaitingError"||e instanceof y.WaitingChildrenError||e.name=="WaitingChildrenError"){return}const i=await t.moveToFailed(e,n,r()&&!(this.closing||this.paused));this.emit("failed",t,e,"active");a===null||a===void 0?void 0:a.addEvent("job failed",{[m.TelemetryAttributes.JobFailedReason]:e.message});if(i){const[e,t,r,s]=i;this.updateDelays(r,s);return this.nextJobFromJobData(e,t,n)}}catch(e){this.emit("error",e);a===null||a===void 0?void 0:a.recordException(e.message)}}}async pause(e){await this.trace(m.SpanKind.INTERNAL,"pause",this.name,(async t=>{var n;t===null||t===void 0?void 0:t.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerDoNotWaitActive]:e});if(!this.paused){this.paused=true;if(!e){await this.whenCurrentJobsFinished()}(n=this.stalledCheckStopper)===null||n===void 0?void 0:n.call(this);this.emit("paused")}}))}resume(){if(!this.running){this.trace(m.SpanKind.INTERNAL,"resume",this.name,(e=>{e===null||e===void 0?void 0:e.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name});this.paused=false;if(this.processFn){this.run()}this.emit("resumed")}))}}isPaused(){return!!this.paused}isRunning(){return this.running}async close(e=false){if(this.closing){return this.closing}this.closing=(async()=>{await this.trace(m.SpanKind.INTERNAL,"close",this.name,(async t=>{var n,r;t===null||t===void 0?void 0:t.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerForceClose]:e});this.emit("closing","closing queue");(n=this.abortDelayController)===null||n===void 0?void 0:n.abort();const i=[()=>e||this.whenCurrentJobsFinished(false),()=>{var e;return(e=this.childPool)===null||e===void 0?void 0:e.clean()},()=>this.blockingConnection.close(e),()=>this.connection.close(e)];for(const e of i){try{await e()}catch(e){this.emit("error",e)}}clearTimeout(this.extendLocksTimer);(r=this.stalledCheckStopper)===null||r===void 0?void 0:r.call(this);this.closed=true;this.emit("closed")}))})();return await this.closing}async startStalledCheckTimer(){if(!this.opts.skipStalledCheck){if(!this.closing){await this.trace(m.SpanKind.INTERNAL,"startStalledCheckTimer",this.name,(async e=>{e===null||e===void 0?void 0:e.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name});this.stalledChecker().catch((e=>{this.emit("error",e)}))}))}}}async stalledChecker(){while(!(this.closing||this.paused)){try{await this.checkConnectionError((()=>this.moveStalledJobsToWait()))}catch(e){this.emit("error",e)}await new Promise((e=>{const t=setTimeout(e,this.opts.stalledInterval);this.stalledCheckStopper=()=>{clearTimeout(t);e()}}))}}startLockExtenderTimer(e){if(!this.opts.skipLockRenewal){clearTimeout(this.extendLocksTimer);if(!this.closed){this.extendLocksTimer=setTimeout((async()=>{const t=Date.now();const n=[];for(const r of e){const{job:e,ts:i}=r;if(!i){r.ts=t;continue}if(i+this.opts.lockRenewTime/2<t){r.ts=t;n.push(e)}}try{if(n.length){await this.extendLocks(n)}}catch(e){this.emit("error",e)}this.startLockExtenderTimer(e)}),this.opts.lockRenewTime/2)}}}async whenCurrentJobsFinished(e=true){if(this.waiting){await this.blockingConnection.disconnect(e)}else{e=false}if(this.mainLoopRunning){await this.mainLoopRunning}e&&await this.blockingConnection.reconnect()}async retryIfFailed(e,t){const n=1;do{try{return await e()}catch(e){this.emit("error",e);if(t){await this.delay(t)}else{return}}}while(n)}async extendLocks(e){await this.trace(m.SpanKind.INTERNAL,"extendLocks",this.name,(async t=>{t===null||t===void 0?void 0:t.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerJobsToExtendLocks]:e.map((e=>e.id))});try{const t=await this.scripts.extendLocks(e.map((e=>e.id)),e.map((e=>e.token)),this.opts.lockDuration);for(const e of t){this.emit("error",new Error(`could not renew lock for job ${e}`))}}catch(e){this.emit("error",e)}}))}async moveStalledJobsToWait(){await this.trace(m.SpanKind.INTERNAL,"moveStalledJobsToWait",this.name,(async e=>{const t=await this.scripts.moveStalledJobsToWait();e===null||e===void 0?void 0:e.setAttributes({[m.TelemetryAttributes.WorkerId]:this.id,[m.TelemetryAttributes.WorkerName]:this.opts.name,[m.TelemetryAttributes.WorkerStalledJobs]:t});t.forEach((t=>{e===null||e===void 0?void 0:e.addEvent("job stalled",{[m.TelemetryAttributes.JobId]:t});this.emit("stalled",t,"active")}))}))}moveLimitedBackToWait(e,t){return e.moveToWait(t)}}t.Worker=Worker},9052:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ChildCommand=void 0;var n;(function(e){e[e["Init"]=0]="Init";e[e["Start"]=1]="Start";e[e["Stop"]=2]="Stop";e[e["GetChildrenValuesResponse"]=3]="GetChildrenValuesResponse";e[e["GetIgnoredChildrenFailuresResponse"]=4]="GetIgnoredChildrenFailuresResponse"})(n=t.ChildCommand||(t.ChildCommand={}))},6320:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ErrorCode=void 0;var n;(function(e){e[e["JobNotExist"]=-1]="JobNotExist";e[e["JobLockNotExist"]=-2]="JobLockNotExist";e[e["JobNotInState"]=-3]="JobNotInState";e[e["JobPendingChildren"]=-4]="JobPendingChildren";e[e["ParentJobNotExist"]=-5]="ParentJobNotExist";e[e["JobLockMismatch"]=-6]="JobLockMismatch";e[e["ParentJobCannotBeReplaced"]=-7]="ParentJobCannotBeReplaced";e[e["JobBelongsToJobScheduler"]=-8]="JobBelongsToJobScheduler";e[e["JobHasFailedChildren"]=-9]="JobHasFailedChildren"})(n=t.ErrorCode||(t.ErrorCode={}))},6694:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(9052),t);r.__exportStar(n(6320),t);r.__exportStar(n(9532),t);r.__exportStar(n(4569),t);r.__exportStar(n(75),t)},4569:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.MetricsTime=void 0;var n;(function(e){e[e["ONE_MINUTE"]=1]="ONE_MINUTE";e[e["FIVE_MINUTES"]=5]="FIVE_MINUTES";e[e["FIFTEEN_MINUTES"]=15]="FIFTEEN_MINUTES";e[e["THIRTY_MINUTES"]=30]="THIRTY_MINUTES";e[e["ONE_HOUR"]=60]="ONE_HOUR";e[e["ONE_WEEK"]=10080]="ONE_WEEK";e[e["TWO_WEEKS"]=20160]="TWO_WEEKS";e[e["ONE_MONTH"]=80640]="ONE_MONTH"})(n=t.MetricsTime||(t.MetricsTime={}))},9532:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ParentCommand=void 0;var n;(function(e){e[e["Completed"]=0]="Completed";e[e["Error"]=1]="Error";e[e["Failed"]=2]="Failed";e[e["InitFailed"]=3]="InitFailed";e[e["InitCompleted"]=4]="InitCompleted";e[e["Log"]=5]="Log";e[e["MoveToDelayed"]=6]="MoveToDelayed";e[e["MoveToWait"]=7]="MoveToWait";e[e["Progress"]=8]="Progress";e[e["Update"]=9]="Update";e[e["GetChildrenValues"]=10]="GetChildrenValues";e[e["GetIgnoredChildrenFailures"]=11]="GetIgnoredChildrenFailures"})(n=t.ParentCommand||(t.ParentCommand={}))},75:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.SpanKind=t.TelemetryAttributes=void 0;var n;(function(e){e["QueueName"]="bullmq.queue.name";e["QueueOperation"]="bullmq.queue.operation";e["BulkCount"]="bullmq.job.bulk.count";e["BulkNames"]="bullmq.job.bulk.names";e["JobName"]="bullmq.job.name";e["JobId"]="bullmq.job.id";e["JobKey"]="bullmq.job.key";e["JobIds"]="bullmq.job.ids";e["DeduplicationKey"]="bullmq.job.deduplication.key";e["JobOptions"]="bullmq.job.options";e["JobProgress"]="bullmq.job.progress";e["QueueDrainDelay"]="bullmq.queue.drain.delay";e["QueueGrace"]="bullmq.queue.grace";e["QueueCleanLimit"]="bullmq.queue.clean.limit";e["QueueRateLimit"]="bullmq.queue.rate.limit";e["JobType"]="bullmq.job.type";e["QueueOptions"]="bullmq.queue.options";e["QueueEventMaxLength"]="bullmq.queue.event.max.length";e["WorkerOptions"]="bullmq.worker.options";e["WorkerName"]="bullmq.worker.name";e["WorkerId"]="bullmq.worker.id";e["WorkerRateLimit"]="bullmq.worker.rate.limit";e["WorkerDoNotWaitActive"]="bullmq.worker.do.not.wait.active";e["WorkerForceClose"]="bullmq.worker.force.close";e["WorkerStalledJobs"]="bullmq.worker.stalled.jobs";e["WorkerFailedJobs"]="bullmq.worker.failed.jobs";e["WorkerJobsToExtendLocks"]="bullmq.worker.jobs.to.extend.locks";e["JobFinishedTimestamp"]="bullmq.job.finished.timestamp";e["JobProcessedTimestamp"]="bullmq.job.processed.timestamp";e["JobResult"]="bullmq.job.result";e["JobFailedReason"]="bullmq.job.failed.reason";e["FlowName"]="bullmq.flow.name";e["JobSchedulerId"]="bullmq.job.scheduler.id"})(n=t.TelemetryAttributes||(t.TelemetryAttributes={}));var r;(function(e){e[e["INTERNAL"]=0]="INTERNAL";e[e["SERVER"]=1]="SERVER";e[e["CLIENT"]=2]="CLIENT";e[e["PRODUCER"]=3]="PRODUCER";e[e["CONSUMER"]=4]="CONSUMER"})(r=t.SpanKind||(t.SpanKind={}))},9595:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(9404),t);r.__exportStar(n(6694),t);r.__exportStar(n(9128),t);r.__exportStar(n(2953),t);r.__exportStar(n(2646),t)},8507:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9799:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},6938:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},1484:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},642:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9512:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9128:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(8507),t);r.__exportStar(n(9799),t);r.__exportStar(n(6938),t);r.__exportStar(n(1484),t);r.__exportStar(n(642),t);r.__exportStar(n(9512),t);r.__exportStar(n(1549),t);r.__exportStar(n(1218),t);r.__exportStar(n(4150),t);r.__exportStar(n(4780),t);r.__exportStar(n(5938),t);r.__exportStar(n(8633),t);r.__exportStar(n(3945),t);r.__exportStar(n(3548),t);r.__exportStar(n(9758),t);r.__exportStar(n(5553),t);r.__exportStar(n(5880),t);r.__exportStar(n(6146),t);r.__exportStar(n(1844),t);r.__exportStar(n(2847),t);r.__exportStar(n(6063),t);r.__exportStar(n(8786),t);r.__exportStar(n(5054),t);r.__exportStar(n(9785),t);r.__exportStar(n(536),t);r.__exportStar(n(5761),t);r.__exportStar(n(2631),t);r.__exportStar(n(5207),t);r.__exportStar(n(1716),t)},1549:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},1218:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},4150:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},4780:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},5938:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8633:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},3945:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},3548:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},5553:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9758:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},5880:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ClientType=void 0;var n;(function(e){e["blocking"]="blocking";e["normal"]="normal"})(n=t.ClientType||(t.ClientType={}))},6146:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},1716:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},1844:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2847:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},5054:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},6063:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8786:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9785:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},536:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},5761:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},5207:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2631:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},3653:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addDelayedJob=void 0;const n=`--[[\n Adds a delayed job to the queue by doing the following:\n - Increases the job counter if needed.\n - Creates a new job key with the job data.\n - computes timestamp.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n Input:\n KEYS[1] 'marker',\n KEYS[2] 'meta'\n KEYS[3] 'id'\n KEYS[4] 'delayed'\n KEYS[5] 'completed'\n KEYS[6] events stream key\n ARGV[1] msgpacked arguments array\n [1] key prefix,\n [2] custom id (use custom instead of one generated automatically)\n [3] name\n [4] timestamp\n [5] parentKey?\n x [6] waitChildrenKey key.\n [7] parent dependencies key.\n [8] parent? {id, queueKey}\n [9] repeat job key\n [10] deduplication key\n ARGV[2] Json stringified job data\n ARGV[3] msgpacked options\n Output:\n jobId - OK\n -5 - Missing parent key\n]]\nlocal metaKey = KEYS[2]\nlocal idKey = KEYS[3]\nlocal delayedKey = KEYS[4]\nlocal completedKey = KEYS[5]\nlocal eventsKey = KEYS[6]\nlocal jobId\nlocal jobIdKey\nlocal rcall = redis.call\nlocal args = cmsgpack.unpack(ARGV[1])\nlocal data = ARGV[2]\nlocal parentKey = args[5]\nlocal parent = args[8]\nlocal repeatJobKey = args[9]\nlocal deduplicationKey = args[10]\nlocal parentData\n-- Includes\n--[[\n Adds a delayed job to the queue by doing the following:\n - Creates a new job key with the job data.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\nlocal function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,\n maxEvents, markerKey, delay)\n local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay))\n rcall("ZADD", delayedKey, score, jobId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- mark that a delayed job is available\n addDelayMarkerIfNeeded(markerKey, delayedKey)\nend\n--[[\n Function to debounce a job.\n]]\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,\n prefix)\n local deduplicationId = deduplicationOpts and deduplicationOpts['id']\n if deduplicationId then\n local ttl = deduplicationOpts['ttl']\n if deduplicationOpts['replace'] and ttl and ttl > 0 then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n if rcall("ZREM", delayedKey, currentDebounceJobId) > 0 then\n removeJobKeys(prefix .. currentDebounceJobId)\n rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDebounceJobId,\n "prev", "delayed")\n if deduplicationOpts['extend'] then\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n else\n rcall('SET', deduplicationKey, jobId, 'KEEPTTL')\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)\n return\n else\n return currentDebounceJobId\n end\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n local ttl = deduplicationOpts['ttl']\n local deduplicationKeyExists\n if ttl then\n if deduplicationOpts['extend'] then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n rcall('SET', deduplicationKey, currentDebounceJobId, 'PX', ttl)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced",\n "jobId", currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')\n end\n if deduplicationKeyExists then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",\n currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n end\n end\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to handle the case when job is duplicated.\n]]\n-- Includes\n--[[\n This function is used to update the parent's dependencies if the job\n is already completed and about to be ignored. The parent must get its\n dependencies updated to avoid the parent job being stuck forever in \n the waiting-children state.\n]]\n-- Includes\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\nlocal function updateExistingJobsParent(parentKey, parent, parentData,\n parentDependenciesKey, completedKey,\n jobIdKey, jobId, timestamp)\n if parentKey ~= nil then\n if rcall("ZSCORE", completedKey, jobId) then\n local returnvalue = rcall("HGET", jobIdKey, "returnvalue")\n updateParentDepsIfNeeded(parentKey, parent['queueKey'],\n parentDependenciesKey, parent['id'],\n jobIdKey, returnvalue, timestamp)\n else\n if parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\n end\n end\n rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)\n end\nend\nlocal function handleDuplicatedJob(jobKey, jobId, currentParentKey, currentParent,\n parentData, parentDependenciesKey, completedKey, eventsKey, maxEvents, timestamp)\n local existedParentKey = rcall("HGET", jobKey, "parentKey")\n if not existedParentKey or existedParentKey == currentParentKey then\n updateExistingJobsParent(currentParentKey, currentParent, parentData,\n parentDependenciesKey, completedKey, jobKey,\n jobId, timestamp)\n else\n if currentParentKey ~= nil and currentParentKey ~= existedParentKey\n and (rcall("EXISTS", existedParentKey) == 1) then\n return -7\n end\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", jobId)\n return jobId .. "" -- convert to string\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\nif parentKey ~= nil then\n if rcall("EXISTS", parentKey) ~= 1 then return -5 end\n parentData = cjson.encode(parent)\nend\nlocal jobCounter = rcall("INCR", idKey)\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal opts = cmsgpack.unpack(ARGV[3])\nlocal parentDependenciesKey = args[7]\nlocal timestamp = args[4]\nif args[2] == "" then\n jobId = jobCounter\n jobIdKey = args[1] .. jobId\nelse\n jobId = args[2]\n jobIdKey = args[1] .. jobId\n if rcall("EXISTS", jobIdKey) == 1 then\n return handleDuplicatedJob(jobIdKey, jobId, parentKey, parent,\n parentData, parentDependenciesKey, completedKey, eventsKey,\n maxEvents, timestamp)\n end\nend\nlocal deduplicationJobId = deduplicateJob(opts['de'], jobId, delayedKey, deduplicationKey,\n eventsKey, maxEvents, args[1])\nif deduplicationJobId then\n return deduplicationJobId\nend\nlocal delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],\n opts, timestamp, parentKey, parentData, repeatJobKey)\naddDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, KEYS[1], delay)\n-- Check if this job is a child of another job, if so add it to the parents dependencies\nif parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\nend\nreturn jobId .. "" -- convert to string\n`;t.addDelayedJob={name:"addDelayedJob",content:n,keys:6}},6494:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addJobScheduler=void 0;const n=`--[[\n Adds a job scheduler, i.e. a job factory that creates jobs based on a given schedule (repeat options).\n Input:\n KEYS[1] 'repeat' key\n KEYS[2] 'delayed' key\n KEYS[3] 'wait' key\n KEYS[4] 'paused' key\n KEYS[5] 'meta' key\n KEYS[6] 'prioritized' key\n KEYS[7] 'marker' key\n KEYS[8] 'id' key\n KEYS[9] 'events' key\n KEYS[10] 'pc' priority counter\n KEYS[11] 'active' key\n ARGV[1] next milliseconds\n ARGV[2] msgpacked options\n [1] name\n [2] tz?\n [3] patten?\n [4] endDate?\n [5] every?\n ARGV[3] jobs scheduler id\n ARGV[4] Json stringified template data\n ARGV[5] mspacked template opts\n ARGV[6] msgpacked delayed opts\n ARGV[7] timestamp\n ARGV[8] prefix key\n ARGV[9] producer key\n Output:\n repeatableKey - OK\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[1]\nlocal delayedKey = KEYS[2]\nlocal waitKey = KEYS[3]\nlocal pausedKey = KEYS[4]\nlocal metaKey = KEYS[5]\nlocal prioritizedKey = KEYS[6]\nlocal eventsKey = KEYS[9]\nlocal nextMillis = ARGV[1]\nlocal jobSchedulerId = ARGV[3]\nlocal templateOpts = cmsgpack.unpack(ARGV[5])\nlocal prefixKey = ARGV[8]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Adds a delayed job to the queue by doing the following:\n - Creates a new job key with the job data.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\nlocal function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,\n maxEvents, markerKey, delay)\n local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay))\n rcall("ZADD", delayedKey, score, jobId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- mark that a delayed job is available\n addDelayMarkerIfNeeded(markerKey, delayedKey)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePaused(queueMetaKey)\n return rcall("HEXISTS", queueMetaKey, "paused") == 1\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\nlocal function addJobFromScheduler(jobKey, jobId, rawOpts, waitKey, pausedKey, activeKey, metaKey, \n prioritizedKey, priorityCounter, delayedKey, markerKey, eventsKey, name, maxEvents, timestamp,\n data, jobSchedulerId)\n local opts = cmsgpack.unpack(rawOpts)\n local delay, priority = storeJob(eventsKey, jobKey, jobId, name, data,\n opts, timestamp, nil, nil, jobSchedulerId)\n if delay ~= 0 then\n addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, markerKey, delay)\n else\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)\n -- Standard or priority add\n if priority == 0 then\n local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'\n addJobInTargetList(target, markerKey, pushCmd, isPausedOrMaxed, jobId)\n else\n -- Priority add\n addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounter, isPausedOrMaxed)\n end\n -- Emit waiting event\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting", "jobId", jobId)\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\n--[[\n Function to store a job scheduler\n]]\nlocal function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMillis, opts,\n templateData, templateOpts)\n rcall("ZADD", repeatKey, nextMillis, schedulerId)\n local optionalValues = {}\n if opts['tz'] then\n table.insert(optionalValues, "tz")\n table.insert(optionalValues, opts['tz'])\n end\n if opts['limit'] then\n table.insert(optionalValues, "limit")\n table.insert(optionalValues, opts['limit'])\n end\n if opts['pattern'] then\n table.insert(optionalValues, "pattern")\n table.insert(optionalValues, opts['pattern'])\n end\n if opts['endDate'] then\n table.insert(optionalValues, "endDate")\n table.insert(optionalValues, opts['endDate'])\n end\n if opts['every'] then\n table.insert(optionalValues, "every")\n table.insert(optionalValues, opts['every'])\n end\n if opts['offset'] then\n table.insert(optionalValues, "offset")\n table.insert(optionalValues, opts['offset'])\n end\n local jsonTemplateOpts = cjson.encode(templateOpts)\n if jsonTemplateOpts and jsonTemplateOpts ~= '{}' then\n table.insert(optionalValues, "opts")\n table.insert(optionalValues, jsonTemplateOpts)\n end\n if templateData and templateData ~= '{}' then\n table.insert(optionalValues, "data")\n table.insert(optionalValues, templateData)\n end\n rcall("DEL", schedulerKey) -- remove all attributes and then re-insert new ones\n rcall("HMSET", schedulerKey, "name", opts['name'], "ic", 1, unpack(optionalValues))\nend\n-- If we are overriding a repeatable job we must delete the delayed job for\n-- the next iteration.\nlocal schedulerKey = repeatKey .. ":" .. jobSchedulerId\nlocal nextDelayedJobKey = schedulerKey .. ":" .. nextMillis\nlocal nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId,\n metaKey, eventsKey)\n if rcall("ZSCORE", delayedKey, jobId) then\n removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )\n rcall("ZREM", delayedKey, jobId)\n return true\n elseif rcall("ZSCORE", prioritizedKey, jobId) then\n removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )\n rcall("ZREM", prioritizedKey, jobId)\n return true\n else\n local pausedOrWaitKey = waitKey\n if isQueuePaused(metaKey) then\n pausedOrWaitKey = pausedKey\n end\n if rcall("LREM", pausedOrWaitKey, 1, jobId) > 0 then\n removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )\n return true\n end\n end\n return false\nend\nif rcall("EXISTS", nextDelayedJobKey) == 1 then\n if not removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,\n nextDelayedJobId, metaKey, eventsKey) then\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", nextDelayedJobId)\n return nextDelayedJobId .. "" -- convert to string\n end\nend\nlocal prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)\nif prevMillis then \n local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis\n local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis\n if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then\n removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,\n currentJobId, metaKey, eventsKey)\n end\nend\nlocal schedulerOpts = cmsgpack.unpack(ARGV[2])\nstoreJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)\nrcall("INCR", KEYS[8])\naddJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,\n KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,\n schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)\nif ARGV[9] ~= "" then\n rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)\nend\nreturn nextDelayedJobId .. "" -- convert to string\n`;t.addJobScheduler={name:"addJobScheduler",content:n,keys:11}},9637:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addLog=void 0;const n=`--[[\n Add job log\n Input:\n KEYS[1] job id key\n KEYS[2] job logs key\n ARGV[1] id\n ARGV[2] log\n ARGV[3] keepLogs\n Output:\n -1 - Missing job.\n]]\nlocal rcall = redis.call\nif rcall("EXISTS", KEYS[1]) == 1 then -- // Make sure job exists\n local logCount = rcall("RPUSH", KEYS[2], ARGV[2])\n if ARGV[3] ~= '' then\n local keepLogs = tonumber(ARGV[3])\n rcall("LTRIM", KEYS[2], -keepLogs, -1)\n return math.min(keepLogs, logCount)\n end\n return logCount\nelse\n return -1\nend\n`;t.addLog={name:"addLog",content:n,keys:2}},9026:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addParentJob=void 0;const n=`--[[\n Adds a parent job to the queue by doing the following:\n - Increases the job counter if needed.\n - Creates a new job key with the job data.\n - adds the job to the waiting-children zset\n Input:\n KEYS[1] 'meta'\n KEYS[2] 'id'\n KEYS[3] 'delayed'\n KEYS[4] 'completed'\n KEYS[5] events stream key\n ARGV[1] msgpacked arguments array\n [1] key prefix,\n [2] custom id (will not generate one automatically)\n [3] name\n [4] timestamp\n [5] parentKey?\n [6] waitChildrenKey key.\n [7] parent dependencies key.\n [8] parent? {id, queueKey}\n [9] repeat job key\n [10] deduplication key\n ARGV[2] Json stringified job data\n ARGV[3] msgpacked options\n Output:\n jobId - OK\n -5 - Missing parent key\n]]\nlocal metaKey = KEYS[1]\nlocal idKey = KEYS[2]\nlocal completedKey = KEYS[4]\nlocal eventsKey = KEYS[5]\nlocal jobId\nlocal jobIdKey\nlocal rcall = redis.call\nlocal args = cmsgpack.unpack(ARGV[1])\nlocal data = ARGV[2]\nlocal opts = cmsgpack.unpack(ARGV[3])\nlocal parentKey = args[5]\nlocal parent = args[8]\nlocal repeatJobKey = args[9]\nlocal deduplicationKey = args[10]\nlocal parentData\n-- Includes\n--[[\n Function to debounce a job.\n]]\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,\n prefix)\n local deduplicationId = deduplicationOpts and deduplicationOpts['id']\n if deduplicationId then\n local ttl = deduplicationOpts['ttl']\n if deduplicationOpts['replace'] and ttl and ttl > 0 then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n if rcall("ZREM", delayedKey, currentDebounceJobId) > 0 then\n removeJobKeys(prefix .. currentDebounceJobId)\n rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDebounceJobId,\n "prev", "delayed")\n if deduplicationOpts['extend'] then\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n else\n rcall('SET', deduplicationKey, jobId, 'KEEPTTL')\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)\n return\n else\n return currentDebounceJobId\n end\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n local ttl = deduplicationOpts['ttl']\n local deduplicationKeyExists\n if ttl then\n if deduplicationOpts['extend'] then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n rcall('SET', deduplicationKey, currentDebounceJobId, 'PX', ttl)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced",\n "jobId", currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')\n end\n if deduplicationKeyExists then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",\n currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n end\n end\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to handle the case when job is duplicated.\n]]\n-- Includes\n--[[\n This function is used to update the parent's dependencies if the job\n is already completed and about to be ignored. The parent must get its\n dependencies updated to avoid the parent job being stuck forever in \n the waiting-children state.\n]]\n-- Includes\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\nlocal function updateExistingJobsParent(parentKey, parent, parentData,\n parentDependenciesKey, completedKey,\n jobIdKey, jobId, timestamp)\n if parentKey ~= nil then\n if rcall("ZSCORE", completedKey, jobId) then\n local returnvalue = rcall("HGET", jobIdKey, "returnvalue")\n updateParentDepsIfNeeded(parentKey, parent['queueKey'],\n parentDependenciesKey, parent['id'],\n jobIdKey, returnvalue, timestamp)\n else\n if parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\n end\n end\n rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)\n end\nend\nlocal function handleDuplicatedJob(jobKey, jobId, currentParentKey, currentParent,\n parentData, parentDependenciesKey, completedKey, eventsKey, maxEvents, timestamp)\n local existedParentKey = rcall("HGET", jobKey, "parentKey")\n if not existedParentKey or existedParentKey == currentParentKey then\n updateExistingJobsParent(currentParentKey, currentParent, parentData,\n parentDependenciesKey, completedKey, jobKey,\n jobId, timestamp)\n else\n if currentParentKey ~= nil and currentParentKey ~= existedParentKey\n and (rcall("EXISTS", existedParentKey) == 1) then\n return -7\n end\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", jobId)\n return jobId .. "" -- convert to string\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\nif parentKey ~= nil then\n if rcall("EXISTS", parentKey) ~= 1 then return -5 end\n parentData = cjson.encode(parent)\nend\nlocal jobCounter = rcall("INCR", idKey)\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal parentDependenciesKey = args[7]\nlocal timestamp = args[4]\nif args[2] == "" then\n jobId = jobCounter\n jobIdKey = args[1] .. jobId\nelse\n jobId = args[2]\n jobIdKey = args[1] .. jobId\n if rcall("EXISTS", jobIdKey) == 1 then\n return handleDuplicatedJob(jobIdKey, jobId, parentKey, parent,\n parentData, parentDependenciesKey, completedKey, eventsKey,\n maxEvents, timestamp)\n end\nend\nlocal deduplicationJobId = deduplicateJob(opts['de'], jobId, KEYS[3],\n deduplicationKey, eventsKey, maxEvents, args[1])\nif deduplicationJobId then\n return deduplicationJobId\nend\n-- Store the job.\nstoreJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,\n parentKey, parentData, repeatJobKey)\nlocal waitChildrenKey = args[6]\nrcall("ZADD", waitChildrenKey, timestamp, jobId)\nrcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "waiting-children", "jobId", jobId)\n-- Check if this job is a child of another job, if so add it to the parents dependencies\nif parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\nend\nreturn jobId .. "" -- convert to string\n`;t.addParentJob={name:"addParentJob",content:n,keys:5}},5699:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addPrioritizedJob=void 0;const n=`--[[\n Adds a priotitized job to the queue by doing the following:\n - Increases the job counter if needed.\n - Creates a new job key with the job data.\n - Adds the job to the "added" list so that workers gets notified.\n Input:\n KEYS[1] 'marker',\n KEYS[2] 'meta'\n KEYS[3] 'id'\n KEYS[4] 'prioritized'\n KEYS[5] 'delayed'\n KEYS[6] 'completed'\n KEYS[7] 'active'\n KEYS[8] events stream key\n KEYS[9] 'pc' priority counter\n ARGV[1] msgpacked arguments array\n [1] key prefix,\n [2] custom id (will not generate one automatically)\n [3] name\n [4] timestamp\n [5] parentKey?\n [6] waitChildrenKey key.\n [7] parent dependencies key.\n [8] parent? {id, queueKey}\n [9] repeat job key\n [10] deduplication key\n ARGV[2] Json stringified job data\n ARGV[3] msgpacked options\n Output:\n jobId - OK\n -5 - Missing parent key\n]] \nlocal metaKey = KEYS[2]\nlocal idKey = KEYS[3]\nlocal priorityKey = KEYS[4]\nlocal completedKey = KEYS[6]\nlocal activeKey = KEYS[7]\nlocal eventsKey = KEYS[8]\nlocal priorityCounterKey = KEYS[9]\nlocal jobId\nlocal jobIdKey\nlocal rcall = redis.call\nlocal args = cmsgpack.unpack(ARGV[1])\nlocal data = ARGV[2]\nlocal opts = cmsgpack.unpack(ARGV[3])\nlocal parentKey = args[5]\nlocal parent = args[8]\nlocal repeatJobKey = args[9]\nlocal deduplicationKey = args[10]\nlocal parentData\n-- Includes\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to debounce a job.\n]]\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,\n prefix)\n local deduplicationId = deduplicationOpts and deduplicationOpts['id']\n if deduplicationId then\n local ttl = deduplicationOpts['ttl']\n if deduplicationOpts['replace'] and ttl and ttl > 0 then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n if rcall("ZREM", delayedKey, currentDebounceJobId) > 0 then\n removeJobKeys(prefix .. currentDebounceJobId)\n rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDebounceJobId,\n "prev", "delayed")\n if deduplicationOpts['extend'] then\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n else\n rcall('SET', deduplicationKey, jobId, 'KEEPTTL')\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)\n return\n else\n return currentDebounceJobId\n end\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n local ttl = deduplicationOpts['ttl']\n local deduplicationKeyExists\n if ttl then\n if deduplicationOpts['extend'] then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n rcall('SET', deduplicationKey, currentDebounceJobId, 'PX', ttl)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced",\n "jobId", currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')\n end\n if deduplicationKeyExists then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",\n currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n end\n end\n end\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to handle the case when job is duplicated.\n]]\n-- Includes\n--[[\n This function is used to update the parent's dependencies if the job\n is already completed and about to be ignored. The parent must get its\n dependencies updated to avoid the parent job being stuck forever in \n the waiting-children state.\n]]\n-- Includes\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\nlocal function updateExistingJobsParent(parentKey, parent, parentData,\n parentDependenciesKey, completedKey,\n jobIdKey, jobId, timestamp)\n if parentKey ~= nil then\n if rcall("ZSCORE", completedKey, jobId) then\n local returnvalue = rcall("HGET", jobIdKey, "returnvalue")\n updateParentDepsIfNeeded(parentKey, parent['queueKey'],\n parentDependenciesKey, parent['id'],\n jobIdKey, returnvalue, timestamp)\n else\n if parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\n end\n end\n rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)\n end\nend\nlocal function handleDuplicatedJob(jobKey, jobId, currentParentKey, currentParent,\n parentData, parentDependenciesKey, completedKey, eventsKey, maxEvents, timestamp)\n local existedParentKey = rcall("HGET", jobKey, "parentKey")\n if not existedParentKey or existedParentKey == currentParentKey then\n updateExistingJobsParent(currentParentKey, currentParent, parentData,\n parentDependenciesKey, completedKey, jobKey,\n jobId, timestamp)\n else\n if currentParentKey ~= nil and currentParentKey ~= existedParentKey\n and (rcall("EXISTS", existedParentKey) == 1) then\n return -7\n end\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", jobId)\n return jobId .. "" -- convert to string\nend\nif parentKey ~= nil then\n if rcall("EXISTS", parentKey) ~= 1 then return -5 end\n parentData = cjson.encode(parent)\nend\nlocal jobCounter = rcall("INCR", idKey)\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal parentDependenciesKey = args[7]\nlocal timestamp = args[4]\nif args[2] == "" then\n jobId = jobCounter\n jobIdKey = args[1] .. jobId\nelse\n jobId = args[2]\n jobIdKey = args[1] .. jobId\n if rcall("EXISTS", jobIdKey) == 1 then\n return handleDuplicatedJob(jobIdKey, jobId, parentKey, parent,\n parentData, parentDependenciesKey, completedKey, eventsKey,\n maxEvents, timestamp)\n end\nend\nlocal deduplicationJobId = deduplicateJob(opts['de'], jobId, KEYS[5],\n deduplicationKey, eventsKey, maxEvents, args[1])\nif deduplicationJobId then\n return deduplicationJobId\nend\n-- Store the job.\nlocal delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],\n opts, timestamp, parentKey, parentData,\n repeatJobKey)\n-- Add the job to the prioritized set\nlocal isPausedOrMaxed = isQueuePausedOrMaxed(metaKey, activeKey)\naddJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPausedOrMaxed)\n-- Emit waiting event\nrcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", jobId)\n-- Check if this job is a child of another job, if so add it to the parents dependencies\nif parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\nend\nreturn jobId .. "" -- convert to string\n`;t.addPrioritizedJob={name:"addPrioritizedJob",content:n,keys:9}},4882:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addRepeatableJob=void 0;const n=`--[[\n Adds a repeatable job\n Input:\n KEYS[1] 'repeat' key\n KEYS[2] 'delayed' key\n ARGV[1] next milliseconds\n ARGV[2] msgpacked options\n [1] name\n [2] tz?\n [3] patten?\n [4] endDate?\n [5] every?\n ARGV[3] legacy custom key TODO: remove this logic in next breaking change\n ARGV[4] custom key\n ARGV[5] prefix key\n Output:\n repeatableKey - OK\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[1]\nlocal delayedKey = KEYS[2]\nlocal nextMillis = ARGV[1]\nlocal legacyCustomKey = ARGV[3]\nlocal customKey = ARGV[4]\nlocal prefixKey = ARGV[5]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\nlocal function storeRepeatableJob(repeatKey, customKey, nextMillis, rawOpts)\n rcall("ZADD", repeatKey, nextMillis, customKey)\n local opts = cmsgpack.unpack(rawOpts)\n local optionalValues = {}\n if opts['tz'] then\n table.insert(optionalValues, "tz")\n table.insert(optionalValues, opts['tz'])\n end\n if opts['pattern'] then\n table.insert(optionalValues, "pattern")\n table.insert(optionalValues, opts['pattern'])\n end\n if opts['endDate'] then\n table.insert(optionalValues, "endDate")\n table.insert(optionalValues, opts['endDate'])\n end\n if opts['every'] then\n table.insert(optionalValues, "every")\n table.insert(optionalValues, opts['every'])\n end\n rcall("HMSET", repeatKey .. ":" .. customKey, "name", opts['name'],\n unpack(optionalValues))\n return customKey\nend\n-- If we are overriding a repeatable job we must delete the delayed job for\n-- the next iteration.\nlocal prevMillis = rcall("ZSCORE", repeatKey, customKey)\nif prevMillis then\n local delayedJobId = "repeat:" .. customKey .. ":" .. prevMillis\n local nextDelayedJobId = repeatKey .. ":" .. customKey .. ":" .. nextMillis\n if rcall("ZSCORE", delayedKey, delayedJobId)\n and rcall("EXISTS", nextDelayedJobId) ~= 1 then\n removeJob(delayedJobId, true, prefixKey, true --[[remove debounce key]])\n rcall("ZREM", delayedKey, delayedJobId)\n end\nend\n-- Keep backwards compatibility with old repeatable jobs (<= 3.0.0)\nif rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then\n return storeRepeatableJob(repeatKey, legacyCustomKey, nextMillis, ARGV[2])\nend\nreturn storeRepeatableJob(repeatKey, customKey, nextMillis, ARGV[2])\n`;t.addRepeatableJob={name:"addRepeatableJob",content:n,keys:2}},1501:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addStandardJob=void 0;const n=`--[[\n Adds a job to the queue by doing the following:\n - Increases the job counter if needed.\n - Creates a new job key with the job data.\n - if delayed:\n - computes timestamp.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n - if not delayed\n - Adds the jobId to the wait/paused list in one of three ways:\n - LIFO\n - FIFO\n - prioritized.\n - Adds the job to the "added" list so that workers gets notified.\n Input:\n KEYS[1] 'wait',\n KEYS[2] 'paused'\n KEYS[3] 'meta'\n KEYS[4] 'id'\n KEYS[5] 'completed'\n KEYS[6] 'delayed'\n KEYS[7] 'active'\n KEYS[8] events stream key\n KEYS[9] marker key\n ARGV[1] msgpacked arguments array\n [1] key prefix,\n [2] custom id (will not generate one automatically)\n [3] name\n [4] timestamp\n [5] parentKey?\n [6] waitChildrenKey key.\n [7] parent dependencies key.\n [8] parent? {id, queueKey}\n [9] repeat job key\n [10] deduplication key\n ARGV[2] Json stringified job data\n ARGV[3] msgpacked options\n Output:\n jobId - OK\n -5 - Missing parent key\n]]\nlocal eventsKey = KEYS[8]\nlocal jobId\nlocal jobIdKey\nlocal rcall = redis.call\nlocal args = cmsgpack.unpack(ARGV[1])\nlocal data = ARGV[2]\nlocal opts = cmsgpack.unpack(ARGV[3])\nlocal parentKey = args[5]\nlocal parent = args[8]\nlocal repeatJobKey = args[9]\nlocal deduplicationKey = args[10]\nlocal parentData\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to debounce a job.\n]]\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,\n prefix)\n local deduplicationId = deduplicationOpts and deduplicationOpts['id']\n if deduplicationId then\n local ttl = deduplicationOpts['ttl']\n if deduplicationOpts['replace'] and ttl and ttl > 0 then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n if rcall("ZREM", delayedKey, currentDebounceJobId) > 0 then\n removeJobKeys(prefix .. currentDebounceJobId)\n rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDebounceJobId,\n "prev", "delayed")\n if deduplicationOpts['extend'] then\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n else\n rcall('SET', deduplicationKey, jobId, 'KEEPTTL')\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)\n return\n else\n return currentDebounceJobId\n end\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n local ttl = deduplicationOpts['ttl']\n local deduplicationKeyExists\n if ttl then\n if deduplicationOpts['extend'] then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n if currentDebounceJobId then\n rcall('SET', deduplicationKey, currentDebounceJobId, 'PX', ttl)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced",\n "jobId", currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n else\n rcall('SET', deduplicationKey, jobId, 'PX', ttl)\n return\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')\n end\n else\n deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')\n end\n if deduplicationKeyExists then\n local currentDebounceJobId = rcall('GET', deduplicationKey)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",\n currentDebounceJobId, "debounceId", deduplicationId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",\n currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)\n return currentDebounceJobId\n end\n end\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to handle the case when job is duplicated.\n]]\n-- Includes\n--[[\n This function is used to update the parent's dependencies if the job\n is already completed and about to be ignored. The parent must get its\n dependencies updated to avoid the parent job being stuck forever in \n the waiting-children state.\n]]\n-- Includes\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\nlocal function updateExistingJobsParent(parentKey, parent, parentData,\n parentDependenciesKey, completedKey,\n jobIdKey, jobId, timestamp)\n if parentKey ~= nil then\n if rcall("ZSCORE", completedKey, jobId) then\n local returnvalue = rcall("HGET", jobIdKey, "returnvalue")\n updateParentDepsIfNeeded(parentKey, parent['queueKey'],\n parentDependenciesKey, parent['id'],\n jobIdKey, returnvalue, timestamp)\n else\n if parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\n end\n end\n rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)\n end\nend\nlocal function handleDuplicatedJob(jobKey, jobId, currentParentKey, currentParent,\n parentData, parentDependenciesKey, completedKey, eventsKey, maxEvents, timestamp)\n local existedParentKey = rcall("HGET", jobKey, "parentKey")\n if not existedParentKey or existedParentKey == currentParentKey then\n updateExistingJobsParent(currentParentKey, currentParent, parentData,\n parentDependenciesKey, completedKey, jobKey,\n jobId, timestamp)\n else\n if currentParentKey ~= nil and currentParentKey ~= existedParentKey\n and (rcall("EXISTS", existedParentKey) == 1) then\n return -7\n end\n end\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", jobId)\n return jobId .. "" -- convert to string\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\nif parentKey ~= nil then\n if rcall("EXISTS", parentKey) ~= 1 then return -5 end\n parentData = cjson.encode(parent)\nend\nlocal jobCounter = rcall("INCR", KEYS[4])\nlocal metaKey = KEYS[3]\nlocal maxEvents = getOrSetMaxEvents(metaKey)\nlocal parentDependenciesKey = args[7]\nlocal timestamp = args[4]\nif args[2] == "" then\n jobId = jobCounter\n jobIdKey = args[1] .. jobId\nelse\n jobId = args[2]\n jobIdKey = args[1] .. jobId\n if rcall("EXISTS", jobIdKey) == 1 then\n return handleDuplicatedJob(jobIdKey, jobId, parentKey, parent,\n parentData, parentDependenciesKey, KEYS[5], eventsKey,\n maxEvents, timestamp)\n end\nend\nlocal deduplicationJobId = deduplicateJob(opts['de'], jobId, KEYS[6],\n deduplicationKey, eventsKey, maxEvents, args[1])\nif deduplicationJobId then\n return deduplicationJobId\nend\n-- Store the job.\nstoreJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,\n parentKey, parentData, repeatJobKey)\nlocal target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[1], KEYS[2])\n-- LIFO or FIFO\nlocal pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'\naddJobInTargetList(target, KEYS[9], pushCmd, isPausedOrMaxed, jobId)\n-- Emit waiting event\nrcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", jobId)\n-- Check if this job is a child of another job, if so add it to the parents dependencies\nif parentDependenciesKey ~= nil then\n rcall("SADD", parentDependenciesKey, jobIdKey)\nend\nreturn jobId .. "" -- convert to string\n`;t.addStandardJob={name:"addStandardJob",content:n,keys:9}},2570:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.changeDelay=void 0;const n=`--[[\n Change job delay when it is in delayed set.\n Input:\n KEYS[1] delayed key\n KEYS[2] meta key\n KEYS[3] marker key\n KEYS[4] events stream\n ARGV[1] delay\n ARGV[2] timestamp\n ARGV[3] the id of the job\n ARGV[4] job key\n Output:\n 0 - OK\n -1 - Missing job.\n -3 - Job not in delayed set.\n Events:\n - delayed key.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nif rcall("EXISTS", ARGV[4]) == 1 then\n local jobId = ARGV[3]\n local delay = tonumber(ARGV[1])\n local score, delayedTimestamp = getDelayedScore(KEYS[1], ARGV[2], delay)\n local numRemovedElements = rcall("ZREM", KEYS[1], jobId)\n if numRemovedElements < 1 then\n return -3\n end\n rcall("HSET", ARGV[4], "delay", delay)\n rcall("ZADD", KEYS[1], score, jobId)\n local maxEvents = getOrSetMaxEvents(KEYS[2])\n rcall("XADD", KEYS[4], "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- mark that a delayed job is available\n addDelayMarkerIfNeeded(KEYS[3], KEYS[1])\n return 0\nelse\n return -1\nend`;t.changeDelay={name:"changeDelay",content:n,keys:4}},7914:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.changePriority=void 0;const n=`--[[\n Change job priority\n Input:\n KEYS[1] 'wait',\n KEYS[2] 'paused'\n KEYS[3] 'meta'\n KEYS[4] 'prioritized'\n KEYS[5] 'active'\n KEYS[6] 'pc' priority counter\n KEYS[7] 'marker'\n ARGV[1] priority value\n ARGV[2] prefix key\n ARGV[3] job id\n ARGV[4] lifo\n Output:\n 0 - OK\n -1 - Missing job\n]]\nlocal jobId = ARGV[3]\nlocal jobKey = ARGV[2] .. jobId\nlocal priority = tonumber(ARGV[1])\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to push back job considering priority in front of same prioritized jobs.\n]]\nlocal function pushBackJobWithPriority(prioritizedKey, priority, jobId)\n -- in order to put it at front of same prioritized jobs\n -- we consider prioritized counter as 0\n local score = priority * 0x100000000\n rcall("ZADD", prioritizedKey, score, jobId)\nend\nlocal function reAddJobWithNewPriority( prioritizedKey, markerKey, targetKey,\n priorityCounter, lifo, priority, jobId, isPausedOrMaxed)\n if priority == 0 then\n local pushCmd = lifo and 'RPUSH' or 'LPUSH'\n addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n else\n if lifo then\n pushBackJobWithPriority(prioritizedKey, priority, jobId)\n else\n addJobWithPriority(markerKey, prioritizedKey, priority, jobId,\n priorityCounter, isPausedOrMaxed)\n end\n end\nend\nif rcall("EXISTS", jobKey) == 1 then\n local metaKey = KEYS[3]\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[5], KEYS[1], KEYS[2])\n local prioritizedKey = KEYS[4]\n local priorityCounterKey = KEYS[6]\n local markerKey = KEYS[7]\n -- Re-add with the new priority\n if rcall("ZREM", prioritizedKey, jobId) > 0 then\n reAddJobWithNewPriority( prioritizedKey, markerKey, target,\n priorityCounterKey, ARGV[4] == '1', priority, jobId, isPausedOrMaxed)\n elseif rcall("LREM", target, -1, jobId) > 0 then\n reAddJobWithNewPriority( prioritizedKey, markerKey, target,\n priorityCounterKey, ARGV[4] == '1', priority, jobId, isPausedOrMaxed)\n end\n rcall("HSET", jobKey, "priority", priority)\n return 0\nelse\n return -1\nend\n`;t.changePriority={name:"changePriority",content:n,keys:7}},6204:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.cleanJobsInSet=void 0;const n=`--[[\n Remove jobs from the specific set.\n Input:\n KEYS[1] set key,\n KEYS[2] events stream key\n KEYS[3] repeat key\n ARGV[1] jobKey prefix\n ARGV[2] timestamp\n ARGV[3] limit the number of jobs to be removed. 0 is unlimited\n ARGV[4] set name, can be any of 'wait', 'active', 'paused', 'delayed', 'completed', or 'failed'\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[3]\nlocal rangeStart = 0\nlocal rangeEnd = -1\nlocal limit = tonumber(ARGV[3])\n-- If we're only deleting _n_ items, avoid retrieving all items\n-- for faster performance\n--\n-- Start from the tail of the list, since that's where oldest elements\n-- are generally added for FIFO lists\nif limit > 0 then\n rangeStart = -1 - limit + 1\n rangeEnd = -1\nend\n-- Includes\n--[[\n Function to clean job list.\n Returns jobIds and deleted count number.\n]]\n-- Includes\n--[[\n Function to get the latest saved timestamp.\n]]\nlocal function getTimestamp(jobKey, attributes)\n if #attributes == 1 then\n return rcall("HGET", jobKey, attributes[1])\n end\n local jobTs\n for _, ts in ipairs(rcall("HMGET", jobKey, unpack(attributes))) do\n if (ts) then\n jobTs = ts\n break\n end\n end\n return jobTs\nend\n--[[\n Function to check if the job belongs to a job scheduler and\n current delayed job matches with jobId\n]]\nlocal function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)\n local repeatJobKey = rcall("HGET", jobKey, "rjk")\n if repeatJobKey then\n local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)\n if prevMillis then\n local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis\n return jobId == currentDelayedJobId\n end\n end\n return false\nend\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\nlocal function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,\n timestamp, isWaiting, jobSchedulersKey)\n local jobs = rcall("LRANGE", listKey, rangeStart, rangeEnd)\n local deleted = {}\n local deletedCount = 0\n local jobTS\n local deletionMarker = ''\n local jobIdsLen = #jobs\n for i, job in ipairs(jobs) do\n if limit > 0 and deletedCount >= limit then\n break\n end\n local jobKey = jobKeyPrefix .. job\n if (isWaiting or rcall("EXISTS", jobKey .. ":lock") == 0) and\n not isJobSchedulerJob(job, jobKey, jobSchedulersKey) then\n -- Find the right timestamp of the job to compare to maxTimestamp:\n -- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed\n -- * processedOn represents when the job was last attempted, but it doesn't get populated until\n -- the job is first tried\n -- * timestamp is the original job submission time\n -- Fetch all three of these (in that order) and use the first one that is set so that we'll leave jobs\n -- that have been active within the grace period:\n jobTS = getTimestamp(jobKey, {"finishedOn", "processedOn", "timestamp"})\n if (not jobTS or jobTS <= timestamp) then\n -- replace the entry with a deletion marker; the actual deletion will\n -- occur at the end of the script\n rcall("LSET", listKey, rangeEnd - jobIdsLen + i, deletionMarker)\n removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]])\n deletedCount = deletedCount + 1\n table.insert(deleted, job)\n end\n end\n end\n rcall("LREM", listKey, 0, deletionMarker)\n return {deleted, deletedCount}\nend\n--[[\n Function to clean job set.\n Returns jobIds and deleted count number.\n]] \n-- Includes\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n We use ZRANGEBYSCORE to make the case where we're deleting a limited number\n of items in a sorted set only run a single iteration. If we simply used\n ZRANGE, we may take a long time traversing through jobs that are within the\n grace period.\n]]\nlocal function getJobsInZset(zsetKey, rangeEnd, limit)\n if limit > 0 then\n return rcall("ZRANGEBYSCORE", zsetKey, 0, rangeEnd, "LIMIT", 0, limit)\n else\n return rcall("ZRANGEBYSCORE", zsetKey, 0, rangeEnd)\n end\nend\nlocal function cleanSet(\n setKey,\n jobKeyPrefix,\n rangeEnd,\n timestamp,\n limit,\n attributes,\n isFinished,\n jobSchedulersKey)\n local jobs = getJobsInZset(setKey, rangeEnd, limit)\n local deleted = {}\n local deletedCount = 0\n local jobTS\n for i, job in ipairs(jobs) do\n if limit > 0 and deletedCount >= limit then\n break\n end\n local jobKey = jobKeyPrefix .. job\n -- Extract a Job Scheduler Id from jobId ("repeat:job-scheduler-id:millis") \n -- and check if it is in the scheduled jobs\n if not (jobSchedulersKey and isJobSchedulerJob(job, jobKey, jobSchedulersKey)) then\n if isFinished then\n removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]] )\n deletedCount = deletedCount + 1\n table.insert(deleted, job)\n else\n -- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed\n jobTS = getTimestamp(jobKey, attributes)\n if (not jobTS or jobTS <= timestamp) then\n removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]] )\n deletedCount = deletedCount + 1\n table.insert(deleted, job)\n end\n end\n end\n end\n if (#deleted > 0) then\n for from, to in batches(#deleted, 7000) do\n rcall("ZREM", setKey, unpack(deleted, from, to))\n end\n end\n return {deleted, deletedCount}\nend\nlocal result\nif ARGV[4] == "active" then\n result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], false --[[ hasFinished ]],\n repeatKey)\nelseif ARGV[4] == "delayed" then\n rangeEnd = "+inf"\n result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,\n {"processedOn", "timestamp"}, false --[[ hasFinished ]], repeatKey)\nelseif ARGV[4] == "prioritized" then\n rangeEnd = "+inf"\n result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,\n {"timestamp"}, false --[[ hasFinished ]], repeatKey)\nelseif ARGV[4] == "wait" or ARGV[4] == "paused" then\n result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], true --[[ hasFinished ]],\n repeatKey)\nelse\n rangeEnd = ARGV[2]\n -- No need to pass repeat key as in that moment job won't be related to a job scheduler\n result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,\n {"finishedOn"}, true --[[ hasFinished ]])\nend\nrcall("XADD", KEYS[2], "*", "event", "cleaned", "count", result[2])\nreturn result[1]\n`;t.cleanJobsInSet={name:"cleanJobsInSet",content:n,keys:3}},6296:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.drain=void 0;const n=`--[[\n Drains the queue, removes all jobs that are waiting\n or delayed, but not active, completed or failed\n Input:\n KEYS[1] 'wait',\n KEYS[2] 'paused'\n KEYS[3] 'delayed'\n KEYS[4] 'prioritized'\n KEYS[5] 'jobschedulers' (repeat)\n ARGV[1] queue key prefix\n ARGV[2] should clean delayed jobs\n]]\nlocal rcall = redis.call\nlocal queueBaseKey = ARGV[1]\n--[[\n Functions to remove jobs.\n]]\n-- Includes\n--[[\n Function to filter out jobs to ignore from a table.\n]]\nlocal function filterOutJobsToIgnore(jobs, jobsToIgnore)\n local filteredJobs = {}\n for i = 1, #jobs do\n if not jobsToIgnore[jobs[i]] then\n table.insert(filteredJobs, jobs[i])\n end\n end\n return filteredJobs\nend\n--[[\n Functions to remove jobs.\n]]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\nlocal function removeJobs(keys, hard, baseKey, max)\n for i, key in ipairs(keys) do\n removeJob(key, hard, baseKey, true --[[remove debounce key]])\n end\n return max - #keys\nend\nlocal function getListItems(keyName, max)\n return rcall('LRANGE', keyName, 0, max - 1)\nend\nlocal function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)\n local jobs = getListItems(keyName, max)\n if jobsToIgnore then\n jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)\n end\n local count = removeJobs(jobs, hard, baseKey, max)\n rcall("LTRIM", keyName, #jobs, -1)\n return count\nend\n-- Includes\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n Function to get ZSet items.\n]]\nlocal function getZSetItems(keyName, max)\n return rcall('ZRANGE', keyName, 0, max - 1)\nend\nlocal function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)\n local jobs = getZSetItems(keyName, max)\n if jobsToIgnore then\n jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)\n end\n local count = removeJobs(jobs, hard, baseKey, max)\n if(#jobs > 0) then\n for from, to in batches(#jobs, 7000) do\n rcall("ZREM", keyName, unpack(jobs, from, to))\n end\n end\n return count\nend\n-- We must not remove delayed jobs if they are associated to a job scheduler.\nlocal scheduledJobs = {}\nlocal jobSchedulers = rcall("ZRANGE", KEYS[5], 0, -1, "WITHSCORES")\n-- For every job scheduler, get the current delayed job id.\nfor i = 1, #jobSchedulers, 2 do\n local jobSchedulerId = jobSchedulers[i]\n local jobSchedulerMillis = jobSchedulers[i + 1]\n local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. jobSchedulerMillis\n scheduledJobs[delayedJobId] = true\nend\nremoveListJobs(KEYS[1], true, queueBaseKey, 0, scheduledJobs) -- wait\nremoveListJobs(KEYS[2], true, queueBaseKey, 0, scheduledJobs) -- paused\nif ARGV[2] == "1" then\n removeZSetJobs(KEYS[3], true, queueBaseKey, 0, scheduledJobs) -- delayed\nend\nremoveZSetJobs(KEYS[4], true, queueBaseKey, 0, scheduledJobs) -- prioritized\n`;t.drain={name:"drain",content:n,keys:5}},4706:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.extendLock=void 0;const n=`--[[\n Extend lock and removes the job from the stalled set.\n Input:\n KEYS[1] 'lock',\n KEYS[2] 'stalled'\n ARGV[1] token\n ARGV[2] lock duration in milliseconds\n ARGV[3] jobid\n Output:\n "1" if lock extented succesfully.\n]]\nlocal rcall = redis.call\nif rcall("GET", KEYS[1]) == ARGV[1] then\n -- if rcall("SET", KEYS[1], ARGV[1], "PX", ARGV[2], "XX") then\n if rcall("SET", KEYS[1], ARGV[1], "PX", ARGV[2]) then\n rcall("SREM", KEYS[2], ARGV[3])\n return 1\n end\nend\nreturn 0\n`;t.extendLock={name:"extendLock",content:n,keys:2}},4750:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.extendLocks=void 0;const n=`--[[\n Extend locks for multiple jobs and remove them from the stalled set if successful.\n Return the list of job IDs for which the operation failed.\n KEYS[1] = stalledKey\n ARGV[1] = baseKey\n ARGV[2] = tokens\n ARGV[3] = jobIds\n ARGV[4] = lockDuration (ms)\n Output:\n An array of failed job IDs. If empty, all succeeded.\n]]\nlocal rcall = redis.call\nlocal stalledKey = KEYS[1]\nlocal baseKey = ARGV[1]\nlocal tokens = cmsgpack.unpack(ARGV[2])\nlocal jobIds = cmsgpack.unpack(ARGV[3])\nlocal lockDuration = ARGV[4]\nlocal jobCount = #jobIds\nlocal failedJobs = {}\nfor i = 1, jobCount, 1 do\n local lockKey = baseKey .. jobIds[i] .. ':lock'\n local jobId = jobIds[i]\n local token = tokens[i]\n local currentToken = rcall("GET", lockKey)\n if currentToken == token then\n local setResult = rcall("SET", lockKey, token, "PX", lockDuration)\n if setResult then\n rcall("SREM", stalledKey, jobId)\n else\n table.insert(failedJobs, jobId)\n end\n else\n table.insert(failedJobs, jobId)\n end\nend\nreturn failedJobs\n`;t.extendLocks={name:"extendLocks",content:n,keys:1}},7574:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getCounts=void 0;const n=`--[[\n Get counts per provided states\n Input:\n KEYS[1] 'prefix'\n ARGV[1...] types\n]]\nlocal rcall = redis.call;\nlocal prefix = KEYS[1]\nlocal results = {}\nfor i = 1, #ARGV do\n local stateKey = prefix .. ARGV[i]\n if ARGV[i] == "wait" or ARGV[i] == "paused" then\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n local marker = rcall("LINDEX", stateKey, -1)\n if marker and string.sub(marker, 1, 2) == "0:" then\n local count = rcall("LLEN", stateKey)\n if count > 1 then\n rcall("RPOP", stateKey)\n results[#results+1] = count-1\n else\n results[#results+1] = 0\n end\n else\n results[#results+1] = rcall("LLEN", stateKey)\n end\n elseif ARGV[i] == "active" then\n results[#results+1] = rcall("LLEN", stateKey)\n else\n results[#results+1] = rcall("ZCARD", stateKey)\n end\nend\nreturn results\n`;t.getCounts={name:"getCounts",content:n,keys:1}},5419:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getCountsPerPriority=void 0;const n=`--[[\n Get counts per provided states\n Input:\n KEYS[1] wait key\n KEYS[2] paused key\n KEYS[3] meta key\n KEYS[4] prioritized key\n ARGV[1...] priorities\n]]\nlocal rcall = redis.call\nlocal results = {}\nlocal waitKey = KEYS[1]\nlocal pausedKey = KEYS[2]\nlocal prioritizedKey = KEYS[4]\n-- Includes\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePaused(queueMetaKey)\n return rcall("HEXISTS", queueMetaKey, "paused") == 1\nend\nfor i = 1, #ARGV do\n local priority = tonumber(ARGV[i])\n if priority == 0 then\n if isQueuePaused(KEYS[3]) then\n results[#results+1] = rcall("LLEN", pausedKey)\n else\n results[#results+1] = rcall("LLEN", waitKey)\n end\n else\n results[#results+1] = rcall("ZCOUNT", prioritizedKey,\n priority * 0x100000000, (priority + 1) * 0x100000000 - 1)\n end\nend\nreturn results\n`;t.getCountsPerPriority={name:"getCountsPerPriority",content:n,keys:4}},4076:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getDependencyCounts=void 0;const n=`--[[\n Get counts per child states\n Input:\n KEYS[1] processed key\n KEYS[2] unprocessed key\n KEYS[3] ignored key\n KEYS[4] failed key\n ARGV[1...] types\n]]\nlocal rcall = redis.call;\nlocal processedKey = KEYS[1]\nlocal unprocessedKey = KEYS[2]\nlocal ignoredKey = KEYS[3]\nlocal failedKey = KEYS[4]\nlocal results = {}\nfor i = 1, #ARGV do\n if ARGV[i] == "processed" then\n results[#results+1] = rcall("HLEN", processedKey)\n elseif ARGV[i] == "unprocessed" then\n results[#results+1] = rcall("SCARD", unprocessedKey)\n elseif ARGV[i] == "ignored" then\n results[#results+1] = rcall("HLEN", ignoredKey)\n else\n results[#results+1] = rcall("ZCARD", failedKey)\n end\nend\nreturn results\n`;t.getDependencyCounts={name:"getDependencyCounts",content:n,keys:4}},5802:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getJobScheduler=void 0;const n=`--[[\n Get job scheduler record.\n Input:\n KEYS[1] 'repeat' key\n ARGV[1] id\n]]\nlocal rcall = redis.call\nlocal jobSchedulerKey = KEYS[1] .. ":" .. ARGV[1]\nlocal score = rcall("ZSCORE", KEYS[1], ARGV[1])\nif score then\n return {rcall("HGETALL", jobSchedulerKey), score} -- get job data\nend\nreturn {nil, nil}\n`;t.getJobScheduler={name:"getJobScheduler",content:n,keys:1}},6264:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getRanges=void 0;const n=`--[[\n Get job ids per provided states\n Input:\n KEYS[1] 'prefix'\n ARGV[1] start\n ARGV[2] end\n ARGV[3] asc\n ARGV[4...] types\n]]\nlocal rcall = redis.call\nlocal prefix = KEYS[1]\nlocal rangeStart = tonumber(ARGV[1])\nlocal rangeEnd = tonumber(ARGV[2])\nlocal asc = ARGV[3]\nlocal results = {}\nlocal function getRangeInList(listKey, asc, rangeStart, rangeEnd, results)\n if asc == "1" then\n local modifiedRangeStart\n local modifiedRangeEnd\n if rangeStart == -1 then\n modifiedRangeStart = 0\n else\n modifiedRangeStart = -(rangeStart + 1)\n end\n if rangeEnd == -1 then\n modifiedRangeEnd = 0\n else\n modifiedRangeEnd = -(rangeEnd + 1)\n end\n results[#results+1] = rcall("LRANGE", listKey,\n modifiedRangeEnd,\n modifiedRangeStart)\n else\n results[#results+1] = rcall("LRANGE", listKey, rangeStart, rangeEnd)\n end\nend\nfor i = 4, #ARGV do\n local stateKey = prefix .. ARGV[i]\n if ARGV[i] == "wait" or ARGV[i] == "paused" then\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n local marker = rcall("LINDEX", stateKey, -1)\n if marker and string.sub(marker, 1, 2) == "0:" then\n local count = rcall("LLEN", stateKey)\n if count > 1 then\n rcall("RPOP", stateKey)\n getRangeInList(stateKey, asc, rangeStart, rangeEnd, results)\n else\n results[#results+1] = {}\n end\n else\n getRangeInList(stateKey, asc, rangeStart, rangeEnd, results)\n end\n elseif ARGV[i] == "active" then\n getRangeInList(stateKey, asc, rangeStart, rangeEnd, results)\n else\n if asc == "1" then\n results[#results+1] = rcall("ZRANGE", stateKey, rangeStart, rangeEnd)\n else\n results[#results+1] = rcall("ZREVRANGE", stateKey, rangeStart, rangeEnd)\n end\n end\nend\nreturn results\n`;t.getRanges={name:"getRanges",content:n,keys:1}},8901:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getRateLimitTtl=void 0;const n=`--[[\n Get rate limit ttl\n Input:\n KEYS[1] 'limiter'\n ARGV[1] maxJobs\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to get current rate limit ttl.\n]]\nlocal function getRateLimitTTL(maxJobs, rateLimiterKey)\n if maxJobs and maxJobs <= tonumber(rcall("GET", rateLimiterKey) or 0) then\n local pttl = rcall("PTTL", rateLimiterKey)\n if pttl == 0 then\n rcall("DEL", rateLimiterKey)\n end\n if pttl > 0 then\n return pttl\n end\n end\n return 0\nend\nlocal rateLimiterKey = KEYS[1]\nif ARGV[1] ~= "0" then\n return getRateLimitTTL(tonumber(ARGV[1]), rateLimiterKey)\nelse\n return rcall("PTTL", rateLimiterKey)\nend\n`;t.getRateLimitTtl={name:"getRateLimitTtl",content:n,keys:1}},7662:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getState=void 0;const n=`--[[\n Get a job state\n Input: \n KEYS[1] 'completed' key,\n KEYS[2] 'failed' key\n KEYS[3] 'delayed' key\n KEYS[4] 'active' key\n KEYS[5] 'wait' key\n KEYS[6] 'paused' key\n KEYS[7] 'waiting-children' key\n KEYS[8] 'prioritized' key\n ARGV[1] job id\n Output:\n 'completed'\n 'failed'\n 'delayed'\n 'active'\n 'prioritized'\n 'waiting'\n 'waiting-children'\n 'unknown'\n]]\nlocal rcall = redis.call\nif rcall("ZSCORE", KEYS[1], ARGV[1]) then\n return "completed"\nend\nif rcall("ZSCORE", KEYS[2], ARGV[1]) then\n return "failed"\nend\nif rcall("ZSCORE", KEYS[3], ARGV[1]) then\n return "delayed"\nend\nif rcall("ZSCORE", KEYS[8], ARGV[1]) then\n return "prioritized"\nend\n-- Includes\n--[[\n Functions to check if a item belongs to a list.\n]]\nlocal function checkItemInList(list, item)\n for _, v in pairs(list) do\n if v == item then\n return 1\n end\n end\n return nil\nend\nlocal active_items = rcall("LRANGE", KEYS[4] , 0, -1)\nif checkItemInList(active_items, ARGV[1]) ~= nil then\n return "active"\nend\nlocal wait_items = rcall("LRANGE", KEYS[5] , 0, -1)\nif checkItemInList(wait_items, ARGV[1]) ~= nil then\n return "waiting"\nend\nlocal paused_items = rcall("LRANGE", KEYS[6] , 0, -1)\nif checkItemInList(paused_items, ARGV[1]) ~= nil then\n return "waiting"\nend\nif rcall("ZSCORE", KEYS[7], ARGV[1]) then\n return "waiting-children"\nend\nreturn "unknown"\n`;t.getState={name:"getState",content:n,keys:8}},6806:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getStateV2=void 0;const n=`--[[\n Get a job state\n Input: \n KEYS[1] 'completed' key,\n KEYS[2] 'failed' key\n KEYS[3] 'delayed' key\n KEYS[4] 'active' key\n KEYS[5] 'wait' key\n KEYS[6] 'paused' key\n KEYS[7] 'waiting-children' key\n KEYS[8] 'prioritized' key\n ARGV[1] job id\n Output:\n 'completed'\n 'failed'\n 'delayed'\n 'active'\n 'waiting'\n 'waiting-children'\n 'unknown'\n]]\nlocal rcall = redis.call\nif rcall("ZSCORE", KEYS[1], ARGV[1]) then\n return "completed"\nend\nif rcall("ZSCORE", KEYS[2], ARGV[1]) then\n return "failed"\nend\nif rcall("ZSCORE", KEYS[3], ARGV[1]) then\n return "delayed"\nend\nif rcall("ZSCORE", KEYS[8], ARGV[1]) then\n return "prioritized"\nend\nif rcall("LPOS", KEYS[4] , ARGV[1]) then\n return "active"\nend\nif rcall("LPOS", KEYS[5] , ARGV[1]) then\n return "waiting"\nend\nif rcall("LPOS", KEYS[6] , ARGV[1]) then\n return "waiting"\nend\nif rcall("ZSCORE", KEYS[7] , ARGV[1]) then\n return "waiting-children"\nend\nreturn "unknown"\n`;t.getStateV2={name:"getStateV2",content:n,keys:8}},3760:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(3653),t);r.__exportStar(n(6494),t);r.__exportStar(n(9637),t);r.__exportStar(n(9026),t);r.__exportStar(n(5699),t);r.__exportStar(n(4882),t);r.__exportStar(n(1501),t);r.__exportStar(n(2570),t);r.__exportStar(n(7914),t);r.__exportStar(n(6204),t);r.__exportStar(n(6296),t);r.__exportStar(n(4706),t);r.__exportStar(n(4750),t);r.__exportStar(n(7574),t);r.__exportStar(n(5419),t);r.__exportStar(n(4076),t);r.__exportStar(n(5802),t);r.__exportStar(n(6264),t);r.__exportStar(n(8901),t);r.__exportStar(n(7662),t);r.__exportStar(n(6806),t);r.__exportStar(n(4872),t);r.__exportStar(n(1173),t);r.__exportStar(n(3556),t);r.__exportStar(n(5952),t);r.__exportStar(n(510),t);r.__exportStar(n(8709),t);r.__exportStar(n(1411),t);r.__exportStar(n(6451),t);r.__exportStar(n(5612),t);r.__exportStar(n(1584),t);r.__exportStar(n(2982),t);r.__exportStar(n(1377),t);r.__exportStar(n(6926),t);r.__exportStar(n(6770),t);r.__exportStar(n(516),t);r.__exportStar(n(5705),t);r.__exportStar(n(9472),t);r.__exportStar(n(6758),t);r.__exportStar(n(6745),t);r.__exportStar(n(5909),t);r.__exportStar(n(6106),t);r.__exportStar(n(9722),t);r.__exportStar(n(7044),t);r.__exportStar(n(6953),t);r.__exportStar(n(6003),t);r.__exportStar(n(8780),t);r.__exportStar(n(8333),t)},4872:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.isFinished=void 0;const n=`--[[\n Checks if a job is finished (.i.e. is in the completed or failed set)\n Input: \n KEYS[1] completed key\n KEYS[2] failed key\n KEYS[3] job key\n ARGV[1] job id\n ARGV[2] return value?\n Output:\n 0 - Not finished.\n 1 - Completed.\n 2 - Failed.\n -1 - Missing job. \n]]\nlocal rcall = redis.call\nif rcall("EXISTS", KEYS[3]) ~= 1 then\n if ARGV[2] == "1" then\n return {-1,"Missing key for job " .. KEYS[3] .. ". isFinished"}\n end \n return -1\nend\nif rcall("ZSCORE", KEYS[1], ARGV[1]) then\n if ARGV[2] == "1" then\n local returnValue = rcall("HGET", KEYS[3], "returnvalue")\n return {1,returnValue}\n end\n return 1\nend\nif rcall("ZSCORE", KEYS[2], ARGV[1]) then\n if ARGV[2] == "1" then\n local failedReason = rcall("HGET", KEYS[3], "failedReason")\n return {2,failedReason}\n end\n return 2\nend\nif ARGV[2] == "1" then\n return {0}\nend\nreturn 0\n`;t.isFinished={name:"isFinished",content:n,keys:3}},1173:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.isJobInList=void 0;const n=`--[[\n Checks if job is in a given list.\n Input:\n KEYS[1]\n ARGV[1]\n Output:\n 1 if element found in the list.\n]]\n-- Includes\n--[[\n Functions to check if a item belongs to a list.\n]]\nlocal function checkItemInList(list, item)\n for _, v in pairs(list) do\n if v == item then\n return 1\n end\n end\n return nil\nend\nlocal items = redis.call("LRANGE", KEYS[1] , 0, -1)\nreturn checkItemInList(items, ARGV[1])\n`;t.isJobInList={name:"isJobInList",content:n,keys:1}},3556:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.isMaxed=void 0;const n=`--[[\n Checks if queue is maxed.\n Input:\n KEYS[1] meta key\n KEYS[2] active key\n Output:\n 1 if element found in the list.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to check if queue is maxed or not.\n]]\nlocal function isQueueMaxed(queueMetaKey, activeKey)\n local maxConcurrency = rcall("HGET", queueMetaKey, "concurrency")\n if maxConcurrency then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(maxConcurrency) then\n return true\n end\n end\n return false\nend\nreturn isQueueMaxed(KEYS[1], KEYS[2])\n`;t.isMaxed={name:"isMaxed",content:n,keys:2}},5952:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveJobFromActiveToWait=void 0;const n=`--[[\n Function to move job from active state to wait.\n Input:\n KEYS[1] active key\n KEYS[2] wait key\n KEYS[3] stalled key\n KEYS[4] paused key\n KEYS[5] meta key\n KEYS[6] limiter key\n KEYS[7] prioritized key\n KEYS[8] marker key\n KEYS[9] event key\n ARGV[1] job id\n ARGV[2] lock token\n ARGV[3] job id key\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to push back job considering priority in front of same prioritized jobs.\n]]\nlocal function pushBackJobWithPriority(prioritizedKey, priority, jobId)\n -- in order to put it at front of same prioritized jobs\n -- we consider prioritized counter as 0\n local score = priority * 0x100000000\n rcall("ZADD", prioritizedKey, score, jobId)\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\nlocal jobId = ARGV[1]\nlocal token = ARGV[2]\nlocal jobKey = ARGV[3]\nif rcall("EXISTS", jobKey) == 0 then\n return -1\nend\nlocal errorCode = removeLock(jobKey, KEYS[3], token, jobId)\nif errorCode < 0 then\n return errorCode\nend\nlocal metaKey = KEYS[5]\nlocal removed = rcall("LREM", KEYS[1], 1, jobId)\nif removed > 0 then\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[1], KEYS[2], KEYS[4])\n local priority = tonumber(rcall("HGET", ARGV[3], "priority")) or 0\n if priority > 0 then\n pushBackJobWithPriority(KEYS[7], priority, jobId)\n else\n addJobInTargetList(target, KEYS[8], "RPUSH", isPausedOrMaxed, jobId)\n end\n local maxEvents = getOrSetMaxEvents(metaKey)\n -- Emit waiting event\n rcall("XADD", KEYS[9], "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", jobId, "prev", "active")\nend\nlocal pttl = rcall("PTTL", KEYS[6])\nif pttl > 0 then\n return pttl\nelse\n return 0\nend\n`;t.moveJobFromActiveToWait={name:"moveJobFromActiveToWait",content:n,keys:9}},510:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveJobsToWait=void 0;const n=`--[[\n Move completed, failed or delayed jobs to wait.\n Note: Does not support jobs with priorities.\n Input:\n KEYS[1] base key\n KEYS[2] events stream\n KEYS[3] state key (failed, completed, delayed)\n KEYS[4] 'wait'\n KEYS[5] 'paused'\n KEYS[6] 'meta'\n KEYS[7] 'active'\n KEYS[8] 'marker'\n ARGV[1] count\n ARGV[2] timestamp\n ARGV[3] prev state\n Output:\n 1 means the operation is not completed\n 0 means the operation is completed\n]]\nlocal maxCount = tonumber(ARGV[1])\nlocal timestamp = tonumber(ARGV[2])\nlocal rcall = redis.call;\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal metaKey = KEYS[6]\nlocal target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[4], KEYS[5])\nlocal jobs = rcall('ZRANGEBYSCORE', KEYS[3], 0, timestamp, 'LIMIT', 0, maxCount)\nif (#jobs > 0) then\n if ARGV[3] == "failed" then\n for i, key in ipairs(jobs) do\n local jobKey = KEYS[1] .. key\n rcall("HDEL", jobKey, "finishedOn", "processedOn", "failedReason")\n end\n elseif ARGV[3] == "completed" then\n for i, key in ipairs(jobs) do\n local jobKey = KEYS[1] .. key\n rcall("HDEL", jobKey, "finishedOn", "processedOn", "returnvalue")\n end\n end\n local maxEvents = getOrSetMaxEvents(metaKey)\n for i, key in ipairs(jobs) do\n -- Emit waiting event\n rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event",\n "waiting", "jobId", key, "prev", ARGV[3]);\n end\n for from, to in batches(#jobs, 7000) do\n rcall("ZREM", KEYS[3], unpack(jobs, from, to))\n rcall("LPUSH", target, unpack(jobs, from, to))\n end\n addBaseMarkerIfNeeded(KEYS[8], isPausedOrMaxed)\nend\nmaxCount = maxCount - #jobs\nif (maxCount <= 0) then return 1 end\nreturn 0\n`;t.moveJobsToWait={name:"moveJobsToWait",content:n,keys:8}},8709:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveStalledJobsToWait=void 0;const n=`--[[\n Move stalled jobs to wait.\n Input:\n KEYS[1] 'stalled' (SET)\n KEYS[2] 'wait', (LIST)\n KEYS[3] 'active', (LIST)\n KEYS[4] 'stalled-check', (KEY)\n KEYS[5] 'meta', (KEY)\n KEYS[6] 'paused', (LIST)\n KEYS[7] 'marker'\n KEYS[8] 'event stream' (STREAM)\n ARGV[1] Max stalled job count\n ARGV[2] queue.toKey('')\n ARGV[3] timestamp\n ARGV[4] max check time\n Events:\n 'stalled' with stalled job id.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to move job to wait to be picked up by a waiting worker.\n]]\n-- Includes\nlocal function moveJobToWait(metaKey, activeKey, waitKey, pausedKey, markerKey, eventStreamKey,\n jobId, pushCmd)\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)\n addJobInTargetList(target, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId", jobId, 'prev', 'active')\nend\n--[[\n Function to trim events, default 10000.\n]]\n-- Includes\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nlocal function trimEvents(metaKey, eventStreamKey)\n local maxEvents = getOrSetMaxEvents(metaKey)\n if maxEvents then\n rcall("XTRIM", eventStreamKey, "MAXLEN", "~", maxEvents)\n else\n rcall("XTRIM", eventStreamKey, "MAXLEN", "~", 10000)\n end\nend\nlocal stalledKey = KEYS[1]\nlocal waitKey = KEYS[2]\nlocal activeKey = KEYS[3]\nlocal stalledCheckKey = KEYS[4]\nlocal metaKey = KEYS[5]\nlocal pausedKey = KEYS[6]\nlocal markerKey = KEYS[7]\nlocal eventStreamKey = KEYS[8]\nlocal maxStalledJobCount = tonumber(ARGV[1])\nlocal queueKeyPrefix = ARGV[2]\nlocal timestamp = ARGV[3]\nlocal maxCheckTime = ARGV[4]\nif rcall("EXISTS", stalledCheckKey) == 1 then\n return {}\nend\nrcall("SET", stalledCheckKey, timestamp, "PX", maxCheckTime)\n-- Trim events before emiting them to avoid trimming events emitted in this script\ntrimEvents(metaKey, eventStreamKey)\n-- Move all stalled jobs to wait\nlocal stalling = rcall('SMEMBERS', stalledKey)\nlocal stalled = {}\nif (#stalling > 0) then\n rcall('DEL', stalledKey)\n -- Remove from active list\n for i, jobId in ipairs(stalling) do\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n if string.sub(jobId, 1, 2) == "0:" then\n -- If the jobId is a delay marker ID we just remove it.\n rcall("LREM", activeKey, 1, jobId)\n else\n local jobKey = queueKeyPrefix .. jobId\n -- Check that the lock is also missing, then we can handle this job as really stalled.\n if (rcall("EXISTS", jobKey .. ":lock") == 0) then\n -- Remove from the active queue.\n local removed = rcall("LREM", activeKey, 1, jobId)\n if (removed > 0) then\n -- If this job has been stalled too many times, such as if it crashes the worker, then fail it.\n local stalledCount = rcall("HINCRBY", jobKey, "stc", 1)\n if stalledCount > maxStalledJobCount then\n local failedReason = "job stalled more than allowable limit"\n rcall("HSET", jobKey, "defa", failedReason)\n end\n moveJobToWait(metaKey, activeKey, waitKey, pausedKey, markerKey, eventStreamKey, jobId,\n "RPUSH")\n -- Emit the stalled event\n rcall("XADD", eventStreamKey, "*", "event", "stalled", "jobId", jobId)\n table.insert(stalled, jobId)\n end\n end\n end\n end\nend\n-- Mark potentially stalled jobs\nlocal active = rcall('LRANGE', activeKey, 0, -1)\nif (#active > 0) then\n for from, to in batches(#active, 7000) do\n rcall('SADD', stalledKey, unpack(active, from, to))\n end\nend\nreturn stalled\n`;t.moveStalledJobsToWait={name:"moveStalledJobsToWait",content:n,keys:8}},1411:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveToActive=void 0;const n=`--[[\n Move next job to be processed to active, lock it and fetch its data. The job\n may be delayed, in that case we need to move it to the delayed set instead.\n This operation guarantees that the worker owns the job during the lock\n expiration time. The worker is responsible of keeping the lock fresh\n so that no other worker picks this job again.\n Input:\n KEYS[1] wait key\n KEYS[2] active key\n KEYS[3] prioritized key\n KEYS[4] stream events key\n KEYS[5] stalled key\n -- Rate limiting\n KEYS[6] rate limiter key\n KEYS[7] delayed key\n -- Delayed jobs\n KEYS[8] paused key\n KEYS[9] meta key\n KEYS[10] pc priority counter\n -- Marker\n KEYS[11] marker key\n -- Arguments\n ARGV[1] key prefix\n ARGV[2] timestamp\n ARGV[3] opts\n opts - token - lock token\n opts - lockDuration\n opts - limiter\n opts - name - worker name\n]]\nlocal rcall = redis.call\nlocal waitKey = KEYS[1]\nlocal activeKey = KEYS[2]\nlocal eventStreamKey = KEYS[4]\nlocal rateLimiterKey = KEYS[6]\nlocal delayedKey = KEYS[7]\nlocal opts = cmsgpack.unpack(ARGV[3])\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\n--[[\n Function to get current rate limit ttl.\n]]\nlocal function getRateLimitTTL(maxJobs, rateLimiterKey)\n if maxJobs and maxJobs <= tonumber(rcall("GET", rateLimiterKey) or 0) then\n local pttl = rcall("PTTL", rateLimiterKey)\n if pttl == 0 then\n rcall("DEL", rateLimiterKey)\n end\n if pttl > 0 then\n return pttl\n end\n end\n return 0\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to move job from prioritized state to active.\n]]\nlocal function moveJobFromPrioritizedToActive(priorityKey, activeKey, priorityCounterKey)\n local prioritizedJob = rcall("ZPOPMIN", priorityKey)\n if #prioritizedJob > 0 then\n rcall("LPUSH", activeKey, prioritizedJob[1])\n return prioritizedJob[1]\n else\n rcall("DEL", priorityCounterKey)\n end\nend\n--[[\n Function to move job from wait state to active.\n Input:\n opts - token - lock token\n opts - lockDuration\n opts - limiter\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function prepareJobForProcessing(keyPrefix, rateLimiterKey, eventStreamKey,\n jobId, processedOn, maxJobs, markerKey, opts)\n local jobKey = keyPrefix .. jobId\n -- Check if we need to perform rate limiting.\n if maxJobs then\n local jobCounter = tonumber(rcall("INCR", rateLimiterKey))\n if jobCounter == 1 then\n local limiterDuration = opts['limiter'] and opts['limiter']['duration']\n local integerDuration = math.floor(math.abs(limiterDuration))\n rcall("PEXPIRE", rateLimiterKey, integerDuration)\n end\n end\n local lockKey = jobKey .. ':lock'\n -- get a lock\n if opts['token'] ~= "0" then\n rcall("SET", lockKey, opts['token'], "PX", opts['lockDuration'])\n end\n local optionalValues = {}\n if opts['name'] then\n -- Set "processedBy" field to the worker name\n table.insert(optionalValues, "pb")\n table.insert(optionalValues, opts['name'])\n end\n rcall("XADD", eventStreamKey, "*", "event", "active", "jobId", jobId, "prev", "waiting")\n rcall("HMSET", jobKey, "processedOn", processedOn, unpack(optionalValues))\n rcall("HINCRBY", jobKey, "ats", 1)\n addBaseMarkerIfNeeded(markerKey, false)\n -- rate limit delay must be 0 in this case to prevent adding more delay\n -- when job that is moved to active needs to be processed\n return {rcall("HGETALL", jobKey), jobId, 0, 0} -- get job data\nend\n--[[\n Updates the delay set, by moving delayed jobs that should\n be processed now to "wait".\n Events:\n 'waiting'\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n-- Try to get as much as 1000 jobs at once\nlocal function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,\n eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)\n local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)\n if (#jobs > 0) then\n rcall("ZREM", delayedKey, unpack(jobs))\n for _, jobId in ipairs(jobs) do\n local jobKey = prefix .. jobId\n local priority =\n tonumber(rcall("HGET", jobKey, "priority")) or 0\n if priority == 0 then\n -- LIFO or FIFO\n rcall("LPUSH", targetKey, jobId)\n else\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n end\n -- Emit waiting event\n rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",\n jobId, "prev", "delayed")\n rcall("HSET", jobKey, "delay", 0)\n end\n addBaseMarkerIfNeeded(markerKey, isPaused)\n end\nend\nlocal target, isPausedOrMaxed = getTargetQueueList(KEYS[9], activeKey, waitKey, KEYS[8])\n-- Check if there are delayed jobs that we can move to wait.\nlocal markerKey = KEYS[11]\npromoteDelayedJobs(delayedKey, markerKey, target, KEYS[3], eventStreamKey, ARGV[1],\n ARGV[2], KEYS[10], isPausedOrMaxed)\nlocal maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])\nlocal expireTime = getRateLimitTTL(maxJobs, rateLimiterKey)\n-- Check if we are rate limited first.\nif expireTime > 0 then return {0, 0, expireTime, 0} end\n-- paused or maxed queue\nif isPausedOrMaxed then return {0, 0, 0, 0} end\n-- no job ID, try non-blocking move from wait to active\nlocal jobId = rcall("RPOPLPUSH", waitKey, activeKey)\n-- Markers in waitlist DEPRECATED in v5: Will be completely removed in v6.\nif jobId and string.sub(jobId, 1, 2) == "0:" then\n rcall("LREM", activeKey, 1, jobId)\n jobId = rcall("RPOPLPUSH", waitKey, activeKey)\nend\nif jobId then\n return prepareJobForProcessing(ARGV[1], rateLimiterKey, eventStreamKey, jobId, ARGV[2],\n maxJobs, markerKey, opts)\nelse\n jobId = moveJobFromPrioritizedToActive(KEYS[3], activeKey, KEYS[10])\n if jobId then\n return prepareJobForProcessing(ARGV[1], rateLimiterKey, eventStreamKey, jobId, ARGV[2],\n maxJobs, markerKey, opts)\n end\nend\n-- Return the timestamp for the next delayed job if any.\nlocal nextTimestamp = getNextDelayedTimestamp(delayedKey)\nif nextTimestamp ~= nil then return {0, 0, 0, nextTimestamp} end\nreturn {0, 0, 0, 0}\n`;t.moveToActive={name:"moveToActive",content:n,keys:11}},6451:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveToDelayed=void 0;const n=`--[[\n Moves job from active to delayed set.\n Input:\n KEYS[1] marker key\n KEYS[2] active key\n KEYS[3] prioritized key\n KEYS[4] delayed key\n KEYS[5] job key\n KEYS[6] events stream\n KEYS[7] meta key\n KEYS[8] stalled key\n ARGV[1] key prefix\n ARGV[2] timestamp\n ARGV[3] the id of the job\n ARGV[4] queue token\n ARGV[5] delay value\n ARGV[6] skip attempt\n ARGV[7] optional job fields to update\n Output:\n 0 - OK\n -1 - Missing job.\n -3 - Job not in active set.\n Events:\n - delayed key.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\n--[[\n Function to update a bunch of fields in a job.\n]]\nlocal function updateJobFields(jobKey, msgpackedFields)\n if msgpackedFields and #msgpackedFields > 0 then\n local fieldsToUpdate = cmsgpack.unpack(msgpackedFields)\n if fieldsToUpdate then\n rcall("HMSET", jobKey, unpack(fieldsToUpdate))\n end\n end\nend\nlocal jobKey = KEYS[5]\nlocal metaKey = KEYS[7]\nlocal token = ARGV[4] \nif rcall("EXISTS", jobKey) == 1 then\n local errorCode = removeLock(jobKey, KEYS[8], token, ARGV[3])\n if errorCode < 0 then\n return errorCode\n end\n updateJobFields(jobKey, ARGV[7])\n local delayedKey = KEYS[4]\n local jobId = ARGV[3]\n local delay = tonumber(ARGV[5])\n local score, delayedTimestamp = getDelayedScore(delayedKey, ARGV[2], delay)\n local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)\n if numRemovedElements < 1 then return -3 end\n if ARGV[6] == "0" then\n rcall("HINCRBY", jobKey, "atm", 1)\n end\n rcall("HSET", jobKey, "delay", ARGV[5])\n local maxEvents = getOrSetMaxEvents(metaKey)\n rcall("ZADD", delayedKey, score, jobId)\n rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- Check if we need to push a marker job to wake up sleeping workers.\n local markerKey = KEYS[1]\n addDelayMarkerIfNeeded(markerKey, delayedKey)\n return 0\nelse\n return -1\nend\n`;t.moveToDelayed={name:"moveToDelayed",content:n,keys:8}},5612:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveToFinished=void 0;const n=`--[[\n Move job from active to a finished status (completed o failed)\n A job can only be moved to completed if it was active.\n The job must be locked before it can be moved to a finished status,\n and the lock must be released in this script.\n Input:\n KEYS[1] wait key\n KEYS[2] active key\n KEYS[3] prioritized key\n KEYS[4] event stream key\n KEYS[5] stalled key\n -- Rate limiting\n KEYS[6] rate limiter key\n KEYS[7] delayed key\n KEYS[8] paused key\n KEYS[9] meta key\n KEYS[10] pc priority counter\n KEYS[11] completed/failed key\n KEYS[12] jobId key\n KEYS[13] metrics key\n KEYS[14] marker key\n ARGV[1] jobId\n ARGV[2] timestamp\n ARGV[3] msg property returnvalue / failedReason\n ARGV[4] return value / failed reason\n ARGV[5] target (completed/failed)\n ARGV[6] fetch next?\n ARGV[7] keys prefix\n ARGV[8] opts\n ARGV[9] job fields to update\n opts - token - lock token\n opts - keepJobs\n opts - lockDuration - lock duration in milliseconds\n opts - attempts max attempts\n opts - maxMetricsSize\n opts - fpof - fail parent on fail\n opts - cpof - continue parent on fail\n opts - idof - ignore dependency on fail\n opts - rdof - remove dependency on fail\n opts - name - worker name\n Output:\n 0 OK\n -1 Missing key.\n -2 Missing lock.\n -3 Job not in active set\n -4 Job has pending children\n -6 Lock is not owned by this client\n -9 Job has failed children\n Events:\n 'completed/failed'\n]]\nlocal rcall = redis.call\n--- Includes\n--[[\n Functions to collect metrics based on a current and previous count of jobs.\n Granualarity is fixed at 1 minute.\n]]\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\nlocal function collectMetrics(metaKey, dataPointsList, maxDataPoints,\n timestamp)\n -- Increment current count\n local count = rcall("HINCRBY", metaKey, "count", 1) - 1\n -- Compute how many data points we need to add to the list, N.\n local prevTS = rcall("HGET", metaKey, "prevTS")\n if not prevTS then\n -- If prevTS is nil, set it to the current timestamp\n rcall("HSET", metaKey, "prevTS", timestamp, "prevCount", 0)\n return\n end\n local N = math.min(math.floor(timestamp / 60000) - math.floor(prevTS / 60000), tonumber(maxDataPoints))\n if N > 0 then\n local delta = count - rcall("HGET", metaKey, "prevCount")\n -- If N > 1, add N-1 zeros to the list\n if N > 1 then\n local points = {}\n points[1] = delta\n for i = 2, N do\n points[i] = 0\n end\n for from, to in batches(#points, 7000) do\n rcall("LPUSH", dataPointsList, unpack(points, from, to))\n end\n else\n -- LPUSH delta to the list\n rcall("LPUSH", dataPointsList, delta)\n end\n -- LTRIM to keep list to its max size\n rcall("LTRIM", dataPointsList, 0, maxDataPoints - 1)\n -- update prev count with current count\n rcall("HSET", metaKey, "prevCount", count, "prevTS", timestamp)\n end\nend\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\n--[[\n Function to get current rate limit ttl.\n]]\nlocal function getRateLimitTTL(maxJobs, rateLimiterKey)\n if maxJobs and maxJobs <= tonumber(rcall("GET", rateLimiterKey) or 0) then\n local pttl = rcall("PTTL", rateLimiterKey)\n if pttl == 0 then\n rcall("DEL", rateLimiterKey)\n end\n if pttl > 0 then\n return pttl\n end\n end\n return 0\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to move job from prioritized state to active.\n]]\nlocal function moveJobFromPrioritizedToActive(priorityKey, activeKey, priorityCounterKey)\n local prioritizedJob = rcall("ZPOPMIN", priorityKey)\n if #prioritizedJob > 0 then\n rcall("LPUSH", activeKey, prioritizedJob[1])\n return prioritizedJob[1]\n else\n rcall("DEL", priorityCounterKey)\n end\nend\n--[[\n Function to recursively move from waitingChildren to failed.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized)\n if no pending dependencies.\n]]\n-- Includes\n--[[\n Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.\n]]\n-- Includes\n--[[\n Move parent to a wait status (wait, prioritized or delayed)\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\nlocal function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n local parentWaitKey = parentQueueKey .. ":wait"\n local parentPausedKey = parentQueueKey .. ":paused"\n local parentActiveKey = parentQueueKey .. ":active"\n local parentMetaKey = parentQueueKey .. ":meta"\n local parentMarkerKey = parentQueueKey .. ":marker"\n local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")\n local priority = tonumber(jobAttributes[1]) or 0\n local delay = tonumber(jobAttributes[2]) or 0\n if delay > 0 then\n local delayedTimestamp = tonumber(timestamp) + delay\n local score = delayedTimestamp * 0x1000\n local parentDelayedKey = parentQueueKey .. ":delayed"\n rcall("ZADD", parentDelayedKey, score, parentId)\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",\n delayedTimestamp)\n addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)\n else\n if priority == 0 then\n local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,\n parentWaitKey, parentPausedKey)\n addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)\n else\n local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)\n addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,\n parentQueueKey .. ":pc", isPausedOrMaxed)\n end\n rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",\n "waiting-children")\n end\nend\nlocal function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then \n rcall("ZREM", parentWaitingChildrenKey, parentId)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n end\n end\nend\nlocal function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,\n parentId, timestamp)\n local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0\n if doNotHavePendingDependencies then\n moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)\n end\nend\n--[[\n Functions to remove jobs when removeOnFail option is provided.\n]]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\n--[[\n Functions to remove jobs by max age.\n]]\n-- Includes\nlocal function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,\n shouldRemoveDebounceKey)\n local start = timestamp - maxAge * 1000\n local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")\n for i, jobId in ipairs(jobIds) do\n removeJob(jobId, false, prefix, false --[[remove debounce key]])\n end\n rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)\nend\n--[[\n Functions to remove jobs by max count.\n]]\n-- Includes\nlocal function removeJobsByMaxCount(maxCount, targetSet, prefix)\n local start = maxCount\n local jobIds = rcall("ZREVRANGE", targetSet, start, -1)\n for i, jobId in ipairs(jobIds) do\n removeJob(jobId, false, prefix, false --[[remove debounce key]])\n end\n rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))\nend\nlocal function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestamp)\n local removeOnFailType = type(opts["removeOnFail"])\n if removeOnFailType == "number" then\n removeJobsByMaxCount(opts["removeOnFail"],\n failedKey, queueKeyPrefix)\n elseif removeOnFailType == "boolean" then\n if opts["removeOnFail"] then\n removeJob(jobId, false, queueKeyPrefix,\n false --[[remove debounce key]])\n rcall("ZREM", failedKey, jobId)\n end\n elseif removeOnFailType ~= "nil" then\n local maxAge = opts["removeOnFail"]["age"]\n local maxCount = opts["removeOnFail"]["count"]\n if maxAge ~= nil then\n removeJobsByMaxAge(timestamp, maxAge,\n failedKey, queueKeyPrefix)\n end\n if maxCount ~= nil and maxCount > 0 then\n removeJobsByMaxCount(maxCount, failedKey,\n queueKeyPrefix)\n end\n end \nend\nlocal moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobIdKey, timestamp)\n if rcall("EXISTS", parentKey) == 1 then\n local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"\n local parentDelayedKey = parentQueueKey .. ":delayed"\n local parentPrioritizedKey = parentQueueKey .. ":prioritized"\n local parentWaitingChildrenOrDelayedKey\n local prevState\n if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then\n parentWaitingChildrenOrDelayedKey = parentWaitingChildrenKey\n prevState = "waiting-children"\n elseif rcall("ZSCORE", parentDelayedKey, parentId) then\n parentWaitingChildrenOrDelayedKey = parentDelayedKey\n prevState = "delayed"\n rcall("HSET", parentKey, "delay", 0)\n end\n if parentWaitingChildrenOrDelayedKey then\n rcall("ZREM", parentWaitingChildrenOrDelayedKey, parentId)\n local parentQueuePrefix = parentQueueKey .. ":"\n local parentFailedKey = parentQueueKey .. ":failed"\n local deferredFailure = "child " .. jobIdKey .. " failed"\n rcall("HSET", parentKey, "defa", deferredFailure)\n moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)\n else\n if not rcall("ZSCORE", parentQueueKey .. ":failed", parentId) then\n local deferredFailure = "child " .. jobIdKey .. " failed"\n rcall("HSET", parentKey, "defa", deferredFailure)\n end\n end\n end\nend\nlocal moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedReason, timestamp)\n if rawParentData then\n local parentData = cjson.decode(rawParentData)\n local parentKey = parentData['queueKey'] .. ':' .. parentData['id']\n local parentDependenciesChildrenKey = parentKey .. ":dependencies"\n if parentData['fpof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n local parentUnsuccesssfulChildrenKey = parentKey .. ":unsuccessful"\n rcall("ZADD", parentUnsuccesssfulChildrenKey, timestamp, childKey)\n moveParentToFailedIfNeeded(\n parentData['queueKey'],\n parentKey,\n parentData['id'],\n childKey,\n timestamp\n )\n end\n elseif parentData['cpof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n local parentFailedChildrenKey = parentKey .. ":failed"\n rcall("HSET", parentFailedChildrenKey, childKey, failedReason)\n moveParentToWaitIfNeeded(parentData['queueKey'], parentKey, parentData['id'], timestamp)\n end\n elseif parentData['idof'] or parentData['rdof'] then\n if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then\n moveParentToWaitIfNoPendingDependencies(parentData['queueKey'], parentDependenciesChildrenKey,\n parentKey, parentData['id'], timestamp)\n if parentData['idof'] then\n local parentFailedChildrenKey = parentKey .. ":failed"\n rcall("HSET", parentFailedChildrenKey, childKey, failedReason)\n end\n end\n end\n end\nend\n--[[\n Function to move job from wait state to active.\n Input:\n opts - token - lock token\n opts - lockDuration\n opts - limiter\n]]\n-- Includes\nlocal function prepareJobForProcessing(keyPrefix, rateLimiterKey, eventStreamKey,\n jobId, processedOn, maxJobs, markerKey, opts)\n local jobKey = keyPrefix .. jobId\n -- Check if we need to perform rate limiting.\n if maxJobs then\n local jobCounter = tonumber(rcall("INCR", rateLimiterKey))\n if jobCounter == 1 then\n local limiterDuration = opts['limiter'] and opts['limiter']['duration']\n local integerDuration = math.floor(math.abs(limiterDuration))\n rcall("PEXPIRE", rateLimiterKey, integerDuration)\n end\n end\n local lockKey = jobKey .. ':lock'\n -- get a lock\n if opts['token'] ~= "0" then\n rcall("SET", lockKey, opts['token'], "PX", opts['lockDuration'])\n end\n local optionalValues = {}\n if opts['name'] then\n -- Set "processedBy" field to the worker name\n table.insert(optionalValues, "pb")\n table.insert(optionalValues, opts['name'])\n end\n rcall("XADD", eventStreamKey, "*", "event", "active", "jobId", jobId, "prev", "waiting")\n rcall("HMSET", jobKey, "processedOn", processedOn, unpack(optionalValues))\n rcall("HINCRBY", jobKey, "ats", 1)\n addBaseMarkerIfNeeded(markerKey, false)\n -- rate limit delay must be 0 in this case to prevent adding more delay\n -- when job that is moved to active needs to be processed\n return {rcall("HGETALL", jobKey), jobId, 0, 0} -- get job data\nend\n--[[\n Updates the delay set, by moving delayed jobs that should\n be processed now to "wait".\n Events:\n 'waiting'\n]]\n-- Includes\n-- Try to get as much as 1000 jobs at once\nlocal function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,\n eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)\n local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)\n if (#jobs > 0) then\n rcall("ZREM", delayedKey, unpack(jobs))\n for _, jobId in ipairs(jobs) do\n local jobKey = prefix .. jobId\n local priority =\n tonumber(rcall("HGET", jobKey, "priority")) or 0\n if priority == 0 then\n -- LIFO or FIFO\n rcall("LPUSH", targetKey, jobId)\n else\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n end\n -- Emit waiting event\n rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",\n jobId, "prev", "delayed")\n rcall("HSET", jobKey, "delay", 0)\n end\n addBaseMarkerIfNeeded(markerKey, isPaused)\n end\nend\n--[[\n Function to remove deduplication key if needed\n when a job is moved to completed or failed states.\n]]\nlocal function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,\n deduplicationId, jobId)\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local pttl = rcall("PTTL", deduplicationKey)\n if pttl == 0 then\n return rcall("DEL", deduplicationKey)\n end\n if pttl == -1 then\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\n end\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\n--[[\n Function to trim events, default 10000.\n]]\n-- Includes\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nlocal function trimEvents(metaKey, eventStreamKey)\n local maxEvents = getOrSetMaxEvents(metaKey)\n if maxEvents then\n rcall("XTRIM", eventStreamKey, "MAXLEN", "~", maxEvents)\n else\n rcall("XTRIM", eventStreamKey, "MAXLEN", "~", 10000)\n end\nend\n--[[\n Validate and move or add dependencies to parent.\n]]\n-- Includes\nlocal function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,\n parentId, jobIdKey, returnvalue, timestamp )\n local processedSet = parentKey .. ":processed"\n rcall("HSET", processedSet, jobIdKey, returnvalue)\n moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)\nend\n--[[\n Function to update a bunch of fields in a job.\n]]\nlocal function updateJobFields(jobKey, msgpackedFields)\n if msgpackedFields and #msgpackedFields > 0 then\n local fieldsToUpdate = cmsgpack.unpack(msgpackedFields)\n if fieldsToUpdate then\n rcall("HMSET", jobKey, unpack(fieldsToUpdate))\n end\n end\nend\nlocal jobIdKey = KEYS[12]\nif rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists\n -- Make sure it does not have pending dependencies\n -- It must happen before removing lock\n if ARGV[5] == "completed" then\n if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then\n return -4\n end\n if rcall("ZCARD", jobIdKey .. ":unsuccessful") ~= 0 then\n return -9\n end\n end\n local opts = cmsgpack.unpack(ARGV[8])\n local token = opts['token']\n local errorCode = removeLock(jobIdKey, KEYS[5], token, ARGV[1])\n if errorCode < 0 then\n return errorCode\n end\n updateJobFields(jobIdKey, ARGV[9]);\n local attempts = opts['attempts']\n local maxMetricsSize = opts['maxMetricsSize']\n local maxCount = opts['keepJobs']['count']\n local maxAge = opts['keepJobs']['age']\n local jobAttributes = rcall("HMGET", jobIdKey, "parentKey", "parent", "deid")\n local parentKey = jobAttributes[1] or ""\n local parentId = ""\n local parentQueueKey = ""\n if jobAttributes[2] then -- TODO: need to revisit this logic if it's still needed\n local jsonDecodedParent = cjson.decode(jobAttributes[2])\n parentId = jsonDecodedParent['id']\n parentQueueKey = jsonDecodedParent['queueKey']\n end\n local jobId = ARGV[1]\n local timestamp = ARGV[2]\n -- Remove from active list (if not active we shall return error)\n local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)\n if (numRemovedElements < 1) then\n return -3\n end\n local eventStreamKey = KEYS[4]\n local metaKey = KEYS[9]\n -- Trim events before emiting them to avoid trimming events emitted in this script\n trimEvents(metaKey, eventStreamKey)\n local prefix = ARGV[7]\n removeDeduplicationKeyIfNeededOnFinalization(prefix, jobAttributes[3], jobId)\n -- If job has a parent we need to\n -- 1) remove this job id from parents dependencies\n -- 2) move the job Id to parent "processed" set\n -- 3) push the results into parent "results" list\n -- 4) if parent's dependencies is empty, then move parent to "wait/paused". Note it may be a different queue!.\n if parentId == "" and parentKey ~= "" then\n parentId = getJobIdFromKey(parentKey)\n parentQueueKey = getJobKeyPrefix(parentKey, ":" .. parentId)\n end\n if parentId ~= "" then\n if ARGV[5] == "completed" then\n local dependenciesSet = parentKey .. ":dependencies"\n if rcall("SREM", dependenciesSet, jobIdKey) == 1 then\n updateParentDepsIfNeeded(parentKey, parentQueueKey, dependenciesSet, parentId, jobIdKey, ARGV[4],\n timestamp)\n end\n else\n moveChildFromDependenciesIfNeeded(jobAttributes[2], jobIdKey, ARGV[4], timestamp)\n end\n end\n local attemptsMade = rcall("HINCRBY", jobIdKey, "atm", 1)\n -- Remove job?\n if maxCount ~= 0 then\n local targetSet = KEYS[11]\n -- Add to complete/failed set\n rcall("ZADD", targetSet, timestamp, jobId)\n rcall("HSET", jobIdKey, ARGV[3], ARGV[4], "finishedOn", timestamp)\n -- "returnvalue" / "failedReason" and "finishedOn"\n if ARGV[5] == "failed" then\n rcall("HDEL", jobIdKey, "defa")\n end\n -- Remove old jobs?\n if maxAge ~= nil then\n removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)\n end\n if maxCount ~= nil and maxCount > 0 then\n removeJobsByMaxCount(maxCount, targetSet, prefix)\n end\n else\n removeJobKeys(jobIdKey)\n if parentKey ~= "" then\n -- TODO: when a child is removed when finished, result or failure in parent\n -- must not be deleted, those value references should be deleted when the parent\n -- is deleted\n removeParentDependencyKey(jobIdKey, false, parentKey, jobAttributes[3])\n end\n end\n rcall("XADD", eventStreamKey, "*", "event", ARGV[5], "jobId", jobId, ARGV[3], ARGV[4], "prev", "active")\n if ARGV[5] == "failed" then\n if tonumber(attemptsMade) >= tonumber(attempts) then\n rcall("XADD", eventStreamKey, "*", "event", "retries-exhausted", "jobId", jobId, "attemptsMade",\n attemptsMade)\n end\n end\n -- Collect metrics\n if maxMetricsSize ~= "" then\n collectMetrics(KEYS[13], KEYS[13] .. ':data', maxMetricsSize, timestamp)\n end\n -- Try to get next job to avoid an extra roundtrip if the queue is not closing,\n -- and not rate limited.\n if (ARGV[6] == "1") then\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2], KEYS[1], KEYS[8])\n local markerKey = KEYS[14]\n -- Check if there are delayed jobs that can be promoted\n promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[3], eventStreamKey, prefix, timestamp, KEYS[10],\n isPausedOrMaxed)\n local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])\n -- Check if we are rate limited first.\n local expireTime = getRateLimitTTL(maxJobs, KEYS[6])\n if expireTime > 0 then\n return {0, 0, expireTime, 0}\n end\n -- paused or maxed queue\n if isPausedOrMaxed then\n return {0, 0, 0, 0}\n end\n jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])\n if jobId then\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n if string.sub(jobId, 1, 2) == "0:" then\n rcall("LREM", KEYS[2], 1, jobId)\n -- If jobId is special ID 0:delay (delay greater than 0), then there is no job to process\n -- but if ID is 0:0, then there is at least 1 prioritized job to process\n if jobId == "0:0" then\n jobId = moveJobFromPrioritizedToActive(KEYS[3], KEYS[2], KEYS[10])\n return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,\n markerKey, opts)\n end\n else\n return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs, markerKey,\n opts)\n end\n else\n jobId = moveJobFromPrioritizedToActive(KEYS[3], KEYS[2], KEYS[10])\n if jobId then\n return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs, markerKey,\n opts)\n end\n end\n -- Return the timestamp for the next delayed job if any.\n local nextTimestamp = getNextDelayedTimestamp(KEYS[7])\n if nextTimestamp ~= nil then\n -- The result is guaranteed to be positive, since the\n -- ZRANGEBYSCORE command would have return a job otherwise.\n return {0, 0, 0, nextTimestamp}\n end\n end\n local waitLen = rcall("LLEN", KEYS[1])\n if waitLen == 0 then\n local activeLen = rcall("LLEN", KEYS[2])\n if activeLen == 0 then\n local prioritizedLen = rcall("ZCARD", KEYS[3])\n if prioritizedLen == 0 then\n rcall("XADD", eventStreamKey, "*", "event", "drained")\n end\n end\n end\n return 0\nelse\n return -1\nend\n`;t.moveToFinished={name:"moveToFinished",content:n,keys:14}},1584:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.moveToWaitingChildren=void 0;const n=`--[[\n Moves job from active to waiting children set.\n Input:\n KEYS[1] active key\n KEYS[2] wait-children key\n KEYS[3] job key\n KEYS[4] job dependencies key\n KEYS[5] job unsuccessful key\n KEYS[6] stalled key\n KEYS[7] events key\n ARGV[1] token\n ARGV[2] child key\n ARGV[3] timestamp\n ARGV[4] jobId\n ARGV[5] prefix\n Output:\n 0 - OK\n 1 - There are not pending dependencies.\n -1 - Missing job.\n -2 - Missing lock\n -3 - Job not in active set\n -9 - Job has failed children\n]]\nlocal rcall = redis.call\nlocal activeKey = KEYS[1]\nlocal waitingChildrenKey = KEYS[2]\nlocal jobKey = KEYS[3]\nlocal jobDependenciesKey = KEYS[4]\nlocal jobUnsuccessfulKey = KEYS[5]\nlocal stalledKey = KEYS[6]\nlocal eventStreamKey = KEYS[7]\nlocal token = ARGV[1]\nlocal timestamp = ARGV[3]\nlocal jobId = ARGV[4]\n--- Includes\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\nlocal function removeJobFromActive(activeKey, stalledKey, jobKey, jobId,\n token)\n local errorCode = removeLock(jobKey, stalledKey, token, jobId)\n if errorCode < 0 then\n return errorCode\n end\n local numRemovedElements = rcall("LREM", activeKey, -1, jobId)\n if numRemovedElements < 1 then\n return -3\n end\n return 0\nend\nlocal function moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, eventStreamKey,\n jobKey, jobId, timestamp, token)\n local errorCode = removeJobFromActive(activeKey, stalledKey, jobKey, jobId, token)\n if errorCode < 0 then\n return errorCode\n end\n local score = tonumber(timestamp)\n rcall("ZADD", waitingChildrenKey, score, jobId)\n rcall("XADD", eventStreamKey, "*", "event", "waiting-children", "jobId", jobId, 'prev', 'active')\n return 0\nend\nif rcall("EXISTS", jobKey) == 1 then\n if rcall("ZCARD", jobUnsuccessfulKey) ~= 0 then\n return -9\n else\n if ARGV[2] ~= "" then\n if rcall("SISMEMBER", jobDependenciesKey, ARGV[2]) ~= 0 then\n return moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, eventStreamKey,\n jobKey, jobId, timestamp, token)\n end\n return 1\n else\n if rcall("SCARD", jobDependenciesKey) ~= 0 then \n return moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, eventStreamKey,\n jobKey, jobId, timestamp, token)\n end\n return 1\n end \n end\nend\nreturn -1\n`;t.moveToWaitingChildren={name:"moveToWaitingChildren",content:n,keys:7}},2982:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.obliterate=void 0;const n=`--[[\n Completely obliterates a queue and all of its contents\n This command completely destroys a queue including all of its jobs, current or past \n leaving no trace of its existence. Since this script needs to iterate to find all the job\n keys, consider that this call may be slow for very large queues.\n The queue needs to be "paused" or it will return an error\n If the queue has currently active jobs then the script by default will return error,\n however this behaviour can be overrided using the 'force' option.\n Input:\n KEYS[1] meta\n KEYS[2] base\n ARGV[1] count\n ARGV[2] force\n]]\nlocal maxCount = tonumber(ARGV[1])\nlocal baseKey = KEYS[2]\nlocal rcall = redis.call\n-- Includes\n--[[\n Functions to remove jobs.\n]]\n-- Includes\n--[[\n Function to remove job.\n]]\n-- Includes\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)\n local jobKey = baseKey .. jobId\n removeParentDependencyKey(jobKey, hard, nil, baseKey)\n if shouldRemoveDeduplicationKey then\n removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)\n end\n removeJobKeys(jobKey)\nend\nlocal function removeJobs(keys, hard, baseKey, max)\n for i, key in ipairs(keys) do\n removeJob(key, hard, baseKey, true --[[remove debounce key]])\n end\n return max - #keys\nend\n--[[\n Functions to remove jobs.\n]]\n-- Includes\n--[[\n Function to filter out jobs to ignore from a table.\n]]\nlocal function filterOutJobsToIgnore(jobs, jobsToIgnore)\n local filteredJobs = {}\n for i = 1, #jobs do\n if not jobsToIgnore[jobs[i]] then\n table.insert(filteredJobs, jobs[i])\n end\n end\n return filteredJobs\nend\nlocal function getListItems(keyName, max)\n return rcall('LRANGE', keyName, 0, max - 1)\nend\nlocal function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)\n local jobs = getListItems(keyName, max)\n if jobsToIgnore then\n jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)\n end\n local count = removeJobs(jobs, hard, baseKey, max)\n rcall("LTRIM", keyName, #jobs, -1)\n return count\nend\n-- Includes\n--[[\n Function to loop in batches.\n Just a bit of warning, some commands as ZREM\n could receive a maximum of 7000 parameters per call.\n]]\nlocal function batches(n, batchSize)\n local i = 0\n return function()\n local from = i * batchSize + 1\n i = i + 1\n if (from <= n) then\n local to = math.min(from + batchSize - 1, n)\n return from, to\n end\n end\nend\n--[[\n Function to get ZSet items.\n]]\nlocal function getZSetItems(keyName, max)\n return rcall('ZRANGE', keyName, 0, max - 1)\nend\nlocal function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)\n local jobs = getZSetItems(keyName, max)\n if jobsToIgnore then\n jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)\n end\n local count = removeJobs(jobs, hard, baseKey, max)\n if(#jobs > 0) then\n for from, to in batches(#jobs, 7000) do\n rcall("ZREM", keyName, unpack(jobs, from, to))\n end\n end\n return count\nend\nlocal function removeLockKeys(keys)\n for i, key in ipairs(keys) do\n rcall("DEL", baseKey .. key .. ':lock')\n end\nend\n-- 1) Check if paused, if not return with error.\nif rcall("HEXISTS", KEYS[1], "paused") ~= 1 then\n return -1 -- Error, NotPaused\nend\n-- 2) Check if there are active jobs, if there are and not "force" return error.\nlocal activeKey = baseKey .. 'active'\nlocal activeJobs = getListItems(activeKey, maxCount)\nif (#activeJobs > 0) then\n if(ARGV[2] == "") then \n return -2 -- Error, ExistActiveJobs\n end\nend\nremoveLockKeys(activeJobs)\nmaxCount = removeJobs(activeJobs, true, baseKey, maxCount)\nrcall("LTRIM", activeKey, #activeJobs, -1)\nif(maxCount <= 0) then\n return 1\nend\nlocal delayedKey = baseKey .. 'delayed'\nmaxCount = removeZSetJobs(delayedKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nlocal repeatKey = baseKey .. 'repeat'\nlocal repeatJobsIds = getZSetItems(repeatKey, maxCount)\nfor i, key in ipairs(repeatJobsIds) do\n local jobKey = repeatKey .. ":" .. key\n rcall("DEL", jobKey)\nend\nif(#repeatJobsIds > 0) then\n for from, to in batches(#repeatJobsIds, 7000) do\n rcall("ZREM", repeatKey, unpack(repeatJobsIds, from, to))\n end\nend\nmaxCount = maxCount - #repeatJobsIds\nif(maxCount <= 0) then\n return 1\nend\nlocal completedKey = baseKey .. 'completed'\nmaxCount = removeZSetJobs(completedKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nlocal waitKey = baseKey .. 'paused'\nmaxCount = removeListJobs(waitKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nlocal prioritizedKey = baseKey .. 'prioritized'\nmaxCount = removeZSetJobs(prioritizedKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nlocal failedKey = baseKey .. 'failed'\nmaxCount = removeZSetJobs(failedKey, true, baseKey, maxCount)\nif(maxCount <= 0) then\n return 1\nend\nif(maxCount > 0) then\n rcall("DEL",\n baseKey .. 'events',\n baseKey .. 'delay', \n baseKey .. 'stalled-check',\n baseKey .. 'stalled',\n baseKey .. 'id',\n baseKey .. 'pc',\n baseKey .. 'meta',\n baseKey .. 'metrics:completed',\n baseKey .. 'metrics:completed:data',\n baseKey .. 'metrics:failed',\n baseKey .. 'metrics:failed:data')\n return 0\nelse\n return 1\nend\n`;t.obliterate={name:"obliterate",content:n,keys:2}},1377:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.paginate=void 0;const n=`--[[\n Paginate a set or hash\n Input:\n KEYS[1] key pointing to the set or hash to be paginated.\n ARGV[1] page start offset\n ARGV[2] page end offset (-1 for all the elements)\n ARGV[3] cursor\n ARGV[4] offset\n ARGV[5] max iterations\n ARGV[6] fetch jobs?\n Output:\n [cursor, offset, items, numItems]\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to achieve pagination for a set or hash.\n This function simulates pagination in the most efficient way possible\n for a set using sscan or hscan.\n The main limitation is that sets are not order preserving, so the\n pagination is not stable. This means that if the set is modified\n between pages, the same element may appear in different pages.\n]] -- Maximum number of elements to be returned by sscan per iteration.\nlocal maxCount = 100\n-- Finds the cursor, and returns the first elements available for the requested page.\nlocal function findPage(key, command, pageStart, pageSize, cursor, offset,\n maxIterations, fetchJobs)\n local items = {}\n local jobs = {}\n local iterations = 0\n repeat\n -- Iterate over the set using sscan/hscan.\n local result = rcall(command, key, cursor, "COUNT", maxCount)\n cursor = result[1]\n local members = result[2]\n local step = 1\n if command == "HSCAN" then\n step = 2\n end\n if #members == 0 then\n -- If the result is empty, we can return the result.\n return cursor, offset, items, jobs\n end\n local chunkStart = offset\n local chunkEnd = offset + #members / step\n local pageEnd = pageStart + pageSize\n if chunkEnd < pageStart then\n -- If the chunk is before the page, we can skip it.\n offset = chunkEnd\n elseif chunkStart > pageEnd then\n -- If the chunk is after the page, we can return the result.\n return cursor, offset, items, jobs\n else\n -- If the chunk is overlapping the page, we need to add the elements to the result.\n for i = 1, #members, step do\n if offset >= pageEnd then\n return cursor, offset, items, jobs\n end\n if offset >= pageStart then\n local index = #items + 1\n if fetchJobs ~= nil then\n jobs[#jobs+1] = rcall("HGETALL", members[i])\n end\n if step == 2 then\n items[index] = {members[i], members[i + 1]}\n else\n items[index] = members[i]\n end\n end\n offset = offset + 1\n end\n end\n iterations = iterations + 1\n until cursor == "0" or iterations >= maxIterations\n return cursor, offset, items, jobs\nend\nlocal key = KEYS[1]\nlocal scanCommand = "SSCAN"\nlocal countCommand = "SCARD"\nlocal type = rcall("TYPE", key)["ok"]\nif type == "none" then\n return {0, 0, {}, 0}\nelseif type == "hash" then\n scanCommand = "HSCAN"\n countCommand = "HLEN"\nelseif type ~= "set" then\n return\n redis.error_reply("Pagination is only supported for sets and hashes.")\nend\nlocal numItems = rcall(countCommand, key)\nlocal startOffset = tonumber(ARGV[1])\nlocal endOffset = tonumber(ARGV[2])\nif endOffset == -1 then \n endOffset = numItems\nend\nlocal pageSize = (endOffset - startOffset) + 1\nlocal cursor, offset, items, jobs = findPage(key, scanCommand, startOffset,\n pageSize, ARGV[3], tonumber(ARGV[4]),\n tonumber(ARGV[5]), ARGV[6])\nreturn {cursor, offset, items, numItems, jobs}\n`;t.paginate={name:"paginate",content:n,keys:1}},6926:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.pause=void 0;const n=`--[[\n Pauses or resumes a queue globably.\n Input:\n KEYS[1] 'wait' or 'paused''\n KEYS[2] 'paused' or 'wait'\n KEYS[3] 'meta'\n KEYS[4] 'prioritized'\n KEYS[5] events stream key\n KEYS[6] 'delayed'\n KEYS|7] 'marker'\n ARGV[1] 'paused' or 'resumed'\n Event:\n publish paused or resumed event.\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\nlocal markerKey = KEYS[7]\nlocal hasJobs = rcall("EXISTS", KEYS[1]) == 1\n--TODO: check this logic to be reused when changing a delay\nif hasJobs then rcall("RENAME", KEYS[1], KEYS[2]) end\nif ARGV[1] == "paused" then\n rcall("HSET", KEYS[3], "paused", 1)\n rcall("DEL", markerKey)\nelse\n rcall("HDEL", KEYS[3], "paused")\n if hasJobs or rcall("ZCARD", KEYS[4]) > 0 then\n -- Add marker if there are waiting or priority jobs\n rcall("ZADD", markerKey, 0, "0")\n else\n addDelayMarkerIfNeeded(markerKey, KEYS[6])\n end\nend\nrcall("XADD", KEYS[5], "*", "event", ARGV[1]);\n`;t.pause={name:"pause",content:n,keys:7}},6770:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.promote=void 0;const n=`--[[\n Promotes a job that is currently "delayed" to the "waiting" state\n Input:\n KEYS[1] 'delayed'\n KEYS[2] 'wait'\n KEYS[3] 'paused'\n KEYS[4] 'meta'\n KEYS[5] 'prioritized'\n KEYS[6] 'active'\n KEYS[7] 'pc' priority counter\n KEYS[8] 'event stream'\n KEYS[9] 'marker'\n ARGV[1] queue.toKey('')\n ARGV[2] jobId\n Output:\n 0 - OK\n -3 - Job not in delayed zset.\n Events:\n 'waiting'\n]]\nlocal rcall = redis.call\nlocal jobId = ARGV[2]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nif rcall("ZREM", KEYS[1], jobId) == 1 then\n local jobKey = ARGV[1] .. jobId\n local priority = tonumber(rcall("HGET", jobKey, "priority")) or 0\n local metaKey = KEYS[4]\n local markerKey = KEYS[9]\n -- Remove delayed "marker" from the wait list if there is any.\n -- Since we are adding a job we do not need the marker anymore.\n -- Markers in waitlist DEPRECATED in v5: Remove in v6.\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[6], KEYS[2], KEYS[3])\n local marker = rcall("LINDEX", target, 0)\n if marker and string.sub(marker, 1, 2) == "0:" then rcall("LPOP", target) end\n if priority == 0 then\n -- LIFO or FIFO\n addJobInTargetList(target, markerKey, "LPUSH", isPausedOrMaxed, jobId)\n else\n addJobWithPriority(markerKey, KEYS[5], priority, jobId, KEYS[7], isPausedOrMaxed)\n end\n -- Emit waiting event (wait..ing@token)\n rcall("XADD", KEYS[8], "*", "event", "waiting", "jobId", jobId, "prev",\n "delayed");\n rcall("HSET", jobKey, "delay", 0)\n return 0\nelse\n return -3\nend\n`;t.promote={name:"promote",content:n,keys:9}},516:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.releaseLock=void 0;const n=`--[[\n Release lock\n Input:\n KEYS[1] 'lock',\n ARGV[1] token\n ARGV[2] lock duration in milliseconds\n Output:\n "OK" if lock extented succesfully.\n]]\nlocal rcall = redis.call\nif rcall("GET", KEYS[1]) == ARGV[1] then\n return rcall("DEL", KEYS[1])\nelse\n return 0\nend\n`;t.releaseLock={name:"releaseLock",content:n,keys:1}},5705:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeChildDependency=void 0;const n=`--[[\n Break parent-child dependency by removing\n child reference from parent\n Input:\n KEYS[1] 'key' prefix,\n ARGV[1] job key\n ARGV[2] parent key\n Output:\n 0 - OK\n 1 - There is not relationship.\n -1 - Missing job key\n -5 - Missing parent key\n]]\nlocal rcall = redis.call\nlocal jobKey = ARGV[1]\nlocal parentKey = ARGV[2]\n-- Includes\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nif rcall("EXISTS", jobKey) ~= 1 then return -1 end\nif rcall("EXISTS", parentKey) ~= 1 then return -5 end\nif removeParentDependencyKey(jobKey, false, parentKey, KEYS[1], nil) then\n rcall("HDEL", jobKey, "parentKey", "parent")\n return 0\nelse\n return 1\nend`;t.removeChildDependency={name:"removeChildDependency",content:n,keys:1}},9472:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeJob=void 0;const n=`--[[\n Remove a job from all the statuses it may be in as well as all its data.\n In order to be able to remove a job, it cannot be active.\n Input:\n KEYS[1] jobKey\n KEYS[2] repeat key\n ARGV[1] jobId\n ARGV[2] remove children\n ARGV[3] queue prefix\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to check if the job belongs to a job scheduler and\n current delayed job matches with jobId\n]]\nlocal function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)\n local repeatJobKey = rcall("HGET", jobKey, "rjk")\n if repeatJobKey then\n local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)\n if prevMillis then\n local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis\n return jobId == currentDelayedJobId\n end\n end\n return false\nend\n--[[\n Function to recursively check if there are no locks\n on the jobs to be removed.\n returns:\n boolean\n]]\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\nlocal function isLocked( prefix, jobId, removeChildren)\n local jobKey = prefix .. jobId;\n -- Check if this job is locked\n local lockKey = jobKey .. ':lock'\n local lock = rcall("GET", lockKey)\n if not lock then\n if removeChildren == "1" then\n local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")\n if (#dependencies > 0) then\n for i, childJobKey in ipairs(dependencies) do\n -- We need to get the jobId for this job.\n local childJobId = getJobIdFromKey(childJobKey)\n local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)\n local result = isLocked( childJobPrefix, childJobId, removeChildren )\n if result then\n return true\n end\n end\n end\n end\n return false\n end\n return true\nend\n--[[\n Remove a job from all the statuses it may be in as well as all its data,\n including its children. Active children can be ignored.\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove from any state.\n returns:\n prev state\n]]\nlocal function removeJobFromAnyState( prefix, jobId)\n -- We start with the ZSCORE checks, since they have O(1) complexity\n if rcall("ZSCORE", prefix .. "completed", jobId) then\n rcall("ZREM", prefix .. "completed", jobId)\n return "completed"\n elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then\n rcall("ZREM", prefix .. "waiting-children", jobId)\n return "waiting-children"\n elseif rcall("ZSCORE", prefix .. "delayed", jobId) then\n rcall("ZREM", prefix .. "delayed", jobId)\n return "delayed"\n elseif rcall("ZSCORE", prefix .. "failed", jobId) then\n rcall("ZREM", prefix .. "failed", jobId)\n return "failed"\n elseif rcall("ZSCORE", prefix .. "prioritized", jobId) then\n rcall("ZREM", prefix .. "prioritized", jobId)\n return "prioritized"\n -- We remove only 1 element from the list, since we assume they are not added multiple times\n elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then\n return "wait"\n elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then\n return "paused"\n elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then\n return "active"\n end\n return "unknown"\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\nlocal removeJobChildren\nlocal removeJobWithChildren\nremoveJobChildren = function(prefix, jobKey, options)\n -- Check if this job has children\n -- If so, we are going to try to remove the children recursively in a depth-first way\n -- because if some job is locked, we must exit with an error.\n if not options.ignoreProcessed then\n local processed = rcall("HGETALL", jobKey .. ":processed")\n if #processed > 0 then\n for i = 1, #processed, 2 do\n local childJobId = getJobIdFromKey(processed[i])\n local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n local failed = rcall("HGETALL", jobKey .. ":failed")\n if #failed > 0 then\n for i = 1, #failed, 2 do\n local childJobId = getJobIdFromKey(failed[i])\n local childJobPrefix = getJobKeyPrefix(failed[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n local unsuccessful = rcall("ZRANGE", jobKey .. ":unsuccessful", 0, -1)\n if #unsuccessful > 0 then\n for i = 1, #unsuccessful, 1 do\n local childJobId = getJobIdFromKey(unsuccessful[i])\n local childJobPrefix = getJobKeyPrefix(unsuccessful[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n end\n local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")\n if #dependencies > 0 then\n for i, childJobKey in ipairs(dependencies) do\n local childJobId = getJobIdFromKey(childJobKey)\n local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\nend\nremoveJobWithChildren = function(prefix, jobId, parentKey, options)\n local jobKey = prefix .. jobId\n if options.ignoreLocked then\n if isLocked(prefix, jobId) then\n return\n end\n end\n -- Check if job is in the failed zset\n local failedSet = prefix .. "failed"\n if not (options.ignoreProcessed and rcall("ZSCORE", failedSet, jobId)) then\n removeParentDependencyKey(jobKey, false, parentKey, nil)\n if options.removeChildren then\n removeJobChildren(prefix, jobKey, options)\n end\n local prev = removeJobFromAnyState(prefix, jobId)\n removeDeduplicationKeyIfNeededOnRemoval(prefix, jobKey, jobId)\n if removeJobKeys(jobKey) > 0 then\n local metaKey = prefix .. "meta"\n local maxEvents = getOrSetMaxEvents(metaKey)\n rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",\n "jobId", jobId, "prev", prev)\n end\n end\nend\nlocal jobId = ARGV[1]\nlocal shouldRemoveChildren = ARGV[2]\nlocal prefix = ARGV[3]\nlocal jobKey = KEYS[1]\nlocal repeatKey = KEYS[2]\nif isJobSchedulerJob(jobId, jobKey, repeatKey) then\n return -8\nend\nif not isLocked(prefix, jobId, shouldRemoveChildren) then\n local options = {\n removeChildren = shouldRemoveChildren == "1",\n ignoreProcessed = false,\n ignoreLocked = false\n }\n removeJobWithChildren(prefix, jobId, nil, options)\n return 1\nend\nreturn 0\n`;t.removeJob={name:"removeJob",content:n,keys:2}},6758:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeJobScheduler=void 0;const n=`--[[\n Removes a job scheduler and its next scheduled job.\n Input:\n KEYS[1] job schedulers key\n KEYS[2] delayed jobs key\n KEYS[3] events key\n ARGV[1] job scheduler id\n ARGV[2] prefix key\n Output:\n 0 - OK\n 1 - Missing repeat job\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\nlocal jobSchedulerId = ARGV[1]\nlocal prefix = ARGV[2]\nlocal millis = rcall("ZSCORE", KEYS[1], jobSchedulerId)\nif millis then\n -- Delete next programmed job.\n local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. millis\n if(rcall("ZREM", KEYS[2], delayedJobId) == 1) then\n removeJobKeys(prefix .. delayedJobId)\n rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", delayedJobId, "prev", "delayed")\n end\nend\nif(rcall("ZREM", KEYS[1], jobSchedulerId) == 1) then\n rcall("DEL", KEYS[1] .. ":" .. jobSchedulerId)\n return 0\nend\nreturn 1\n`;t.removeJobScheduler={name:"removeJobScheduler",content:n,keys:3}},6745:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeRepeatable=void 0;const n=`--[[\n Removes a repeatable job\n Input:\n KEYS[1] repeat jobs key\n KEYS[2] delayed jobs key\n KEYS[3] events key\n ARGV[1] old repeat job id\n ARGV[2] options concat\n ARGV[3] repeat job key\n ARGV[4] prefix key\n Output:\n 0 - OK\n 1 - Missing repeat job\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\nlocal millis = rcall("ZSCORE", KEYS[1], ARGV[2])\n-- Includes\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n-- legacy removal TODO: remove in next breaking change\nif millis then\n -- Delete next programmed job.\n local repeatJobId = ARGV[1] .. millis\n if(rcall("ZREM", KEYS[2], repeatJobId) == 1) then\n removeJobKeys(ARGV[4] .. repeatJobId)\n rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed");\n end\nend\nif(rcall("ZREM", KEYS[1], ARGV[2]) == 1) then\n return 0\nend\n-- new removal\nmillis = rcall("ZSCORE", KEYS[1], ARGV[3])\nif millis then\n -- Delete next programmed job.\n local repeatJobId = "repeat:" .. ARGV[3] .. ":" .. millis\n if(rcall("ZREM", KEYS[2], repeatJobId) == 1) then\n removeJobKeys(ARGV[4] .. repeatJobId)\n rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed")\n end\nend\nif(rcall("ZREM", KEYS[1], ARGV[3]) == 1) then\n rcall("DEL", KEYS[1] .. ":" .. ARGV[3])\n return 0\nend\nreturn 1\n`;t.removeRepeatable={name:"removeRepeatable",content:n,keys:3}},5909:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeUnprocessedChildren=void 0;const n=`--[[\n Remove a job from all the statuses it may be in as well as all its data.\n In order to be able to remove a job, it cannot be active.\n Input:\n KEYS[1] jobKey\n KEYS[2] meta key\n ARGV[1] prefix\n ARGV[2] jobId\n Events:\n 'removed' for every children removed\n]]\n-- Includes\n--[[\n Remove a job from all the statuses it may be in as well as all its data,\n including its children. Active children can be ignored.\n Events:\n 'removed'\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Functions to destructure job key.\n Just a bit of warning, these functions may be a bit slow and affect performance significantly.\n]]\nlocal getJobIdFromKey = function (jobKey)\n return string.match(jobKey, ".*:(.*)")\nend\nlocal getJobKeyPrefix = function (jobKey, jobId)\n return string.sub(jobKey, 0, #jobKey - #jobId)\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check if the job belongs to a job scheduler and\n current delayed job matches with jobId\n]]\nlocal function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)\n local repeatJobKey = rcall("HGET", jobKey, "rjk")\n if repeatJobKey then\n local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)\n if prevMillis then\n local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis\n return jobId == currentDelayedJobId\n end\n end\n return false\nend\n--[[\n Function to remove deduplication key if needed\n when a job is being removed.\n]]\nlocal function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,\n jobKey, jobId)\n local deduplicationId = rcall("HGET", jobKey, "deid")\n if deduplicationId then\n local deduplicationKey = prefixKey .. "de:" .. deduplicationId\n local currentJobId = rcall('GET', deduplicationKey)\n if currentJobId and currentJobId == jobId then\n return rcall("DEL", deduplicationKey)\n end\n end\nend\n--[[\n Function to remove from any state.\n returns:\n prev state\n]]\nlocal function removeJobFromAnyState( prefix, jobId)\n -- We start with the ZSCORE checks, since they have O(1) complexity\n if rcall("ZSCORE", prefix .. "completed", jobId) then\n rcall("ZREM", prefix .. "completed", jobId)\n return "completed"\n elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then\n rcall("ZREM", prefix .. "waiting-children", jobId)\n return "waiting-children"\n elseif rcall("ZSCORE", prefix .. "delayed", jobId) then\n rcall("ZREM", prefix .. "delayed", jobId)\n return "delayed"\n elseif rcall("ZSCORE", prefix .. "failed", jobId) then\n rcall("ZREM", prefix .. "failed", jobId)\n return "failed"\n elseif rcall("ZSCORE", prefix .. "prioritized", jobId) then\n rcall("ZREM", prefix .. "prioritized", jobId)\n return "prioritized"\n -- We remove only 1 element from the list, since we assume they are not added multiple times\n elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then\n return "wait"\n elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then\n return "paused"\n elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then\n return "active"\n end\n return "unknown"\nend\n--[[\n Function to remove job keys.\n]]\nlocal function removeJobKeys(jobKey)\n return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',\n jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')\nend\n--[[\n Check if this job has a parent. If so we will just remove it from\n the parent child list, but if it is the last child we should move the parent to "wait/paused"\n which requires code from "moveToFinished"\n]]\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nlocal function _moveParentToWait(parentPrefix, parentId, emitEvent)\n local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",\n parentPrefix .. "wait", parentPrefix .. "paused")\n addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)\n if emitEvent then\n local parentEventStream = parentPrefix .. "events"\n rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")\n end\nend\nlocal function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)\n if parentKey then\n local parentDependenciesKey = parentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(parentKey)\n local parentPrefix = getJobKeyPrefix(parentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then -- remove parent in same queue\n if parentPrefix == baseKey then\n removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)\n removeJobKeys(parentKey)\n if debounceId then\n rcall("DEL", parentPrefix .. "de:" .. debounceId)\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n else\n local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")\n local missedParentKey = parentAttributes[1]\n if( (type(missedParentKey) == "string") and missedParentKey ~= ""\n and (rcall("EXISTS", missedParentKey) == 1)) then\n local parentDependenciesKey = missedParentKey .. ":dependencies"\n local result = rcall("SREM", parentDependenciesKey, jobKey)\n if result > 0 then\n local pendingDependencies = rcall("SCARD", parentDependenciesKey)\n if pendingDependencies == 0 then\n local parentId = getJobIdFromKey(missedParentKey)\n local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)\n local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)\n if numRemovedElements == 1 then\n if hard then\n if parentPrefix == baseKey then\n removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)\n removeJobKeys(missedParentKey)\n if parentAttributes[2] then\n rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])\n end\n else\n _moveParentToWait(parentPrefix, parentId)\n end\n else\n _moveParentToWait(parentPrefix, parentId, true)\n end\n end\n end\n return true\n end\n end\n end\n return false\nend\n--[[\n Function to recursively check if there are no locks\n on the jobs to be removed.\n returns:\n boolean\n]]\nlocal function isLocked( prefix, jobId, removeChildren)\n local jobKey = prefix .. jobId;\n -- Check if this job is locked\n local lockKey = jobKey .. ':lock'\n local lock = rcall("GET", lockKey)\n if not lock then\n if removeChildren == "1" then\n local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")\n if (#dependencies > 0) then\n for i, childJobKey in ipairs(dependencies) do\n -- We need to get the jobId for this job.\n local childJobId = getJobIdFromKey(childJobKey)\n local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)\n local result = isLocked( childJobPrefix, childJobId, removeChildren )\n if result then\n return true\n end\n end\n end\n end\n return false\n end\n return true\nend\nlocal removeJobChildren\nlocal removeJobWithChildren\nremoveJobChildren = function(prefix, jobKey, options)\n -- Check if this job has children\n -- If so, we are going to try to remove the children recursively in a depth-first way\n -- because if some job is locked, we must exit with an error.\n if not options.ignoreProcessed then\n local processed = rcall("HGETALL", jobKey .. ":processed")\n if #processed > 0 then\n for i = 1, #processed, 2 do\n local childJobId = getJobIdFromKey(processed[i])\n local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n local failed = rcall("HGETALL", jobKey .. ":failed")\n if #failed > 0 then\n for i = 1, #failed, 2 do\n local childJobId = getJobIdFromKey(failed[i])\n local childJobPrefix = getJobKeyPrefix(failed[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n local unsuccessful = rcall("ZRANGE", jobKey .. ":unsuccessful", 0, -1)\n if #unsuccessful > 0 then\n for i = 1, #unsuccessful, 1 do\n local childJobId = getJobIdFromKey(unsuccessful[i])\n local childJobPrefix = getJobKeyPrefix(unsuccessful[i], childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\n end\n local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")\n if #dependencies > 0 then\n for i, childJobKey in ipairs(dependencies) do\n local childJobId = getJobIdFromKey(childJobKey)\n local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)\n removeJobWithChildren(childJobPrefix, childJobId, jobKey, options)\n end\n end\nend\nremoveJobWithChildren = function(prefix, jobId, parentKey, options)\n local jobKey = prefix .. jobId\n if options.ignoreLocked then\n if isLocked(prefix, jobId) then\n return\n end\n end\n -- Check if job is in the failed zset\n local failedSet = prefix .. "failed"\n if not (options.ignoreProcessed and rcall("ZSCORE", failedSet, jobId)) then\n removeParentDependencyKey(jobKey, false, parentKey, nil)\n if options.removeChildren then\n removeJobChildren(prefix, jobKey, options)\n end\n local prev = removeJobFromAnyState(prefix, jobId)\n removeDeduplicationKeyIfNeededOnRemoval(prefix, jobKey, jobId)\n if removeJobKeys(jobKey) > 0 then\n local metaKey = prefix .. "meta"\n local maxEvents = getOrSetMaxEvents(metaKey)\n rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",\n "jobId", jobId, "prev", prev)\n end\n end\nend\nlocal prefix = ARGV[1]\nlocal jobId = ARGV[2]\nlocal jobKey = KEYS[1]\nlocal metaKey = KEYS[2]\nlocal options = {\n removeChildren = "1",\n ignoreProcessed = true,\n ignoreLocked = true\n}\nremoveJobChildren(prefix, jobKey, options) \n`;t.removeUnprocessedChildren={name:"removeUnprocessedChildren",content:n,keys:2}},6106:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.reprocessJob=void 0;const n=`--[[\n Attempts to reprocess a job\n Input:\n KEYS[1] job key\n KEYS[2] events stream\n KEYS[3] job state\n KEYS[4] wait key\n KEYS[5] meta\n KEYS[6] paused key\n KEYS[7] active key\n KEYS[8] marker key\n ARGV[1] job.id\n ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'\n ARGV[3] propVal - failedReason/returnvalue\n ARGV[4] prev state - failed/completed\n Output:\n 1 means the operation was a success\n -1 means the job does not exist\n -3 means the job was not found in the expected set.\n]]\nlocal rcall = redis.call;\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\nif rcall("EXISTS", KEYS[1]) == 1 then\n local jobId = ARGV[1]\n if (rcall("ZREM", KEYS[3], jobId) == 1) then\n rcall("HDEL", KEYS[1], "finishedOn", "processedOn", ARGV[3])\n local target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[7], KEYS[4], KEYS[6])\n addJobInTargetList(target, KEYS[8], ARGV[2], isPausedOrMaxed, jobId)\n local maxEvents = getOrSetMaxEvents(KEYS[5])\n -- Emit waiting event\n rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", jobId, "prev", ARGV[4]);\n return 1\n else\n return -3\n end\nelse\n return -1\nend\n`;t.reprocessJob={name:"reprocessJob",content:n,keys:8}},9722:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.retryJob=void 0;const n=`--[[\n Retries a failed job by moving it back to the wait queue.\n Input:\n KEYS[1] 'active',\n KEYS[2] 'wait'\n KEYS[3] 'paused'\n KEYS[4] job key\n KEYS[5] 'meta'\n KEYS[6] events stream\n KEYS[7] delayed key\n KEYS[8] prioritized key\n KEYS[9] 'pc' priority counter\n KEYS[10] 'marker'\n KEYS[11] 'stalled'\n ARGV[1] key prefix\n ARGV[2] timestamp\n ARGV[3] pushCmd\n ARGV[4] jobId\n ARGV[5] token\n ARGV[6] optional job fields to update\n Events:\n 'waiting'\n Output:\n 0 - OK\n -1 - Missing key\n -2 - Missing lock\n -3 - Job not in active set\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to check if queue is paused or maxed\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePausedOrMaxed(queueMetaKey, activeKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n return activeCount >= tonumber(queueAttributes[2])\n end\n end\n return false\nend\n--[[\n Updates the delay set, by moving delayed jobs that should\n be processed now to "wait".\n Events:\n 'waiting'\n]]\n-- Includes\n-- Try to get as much as 1000 jobs at once\nlocal function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,\n eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)\n local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)\n if (#jobs > 0) then\n rcall("ZREM", delayedKey, unpack(jobs))\n for _, jobId in ipairs(jobs) do\n local jobKey = prefix .. jobId\n local priority =\n tonumber(rcall("HGET", jobKey, "priority")) or 0\n if priority == 0 then\n -- LIFO or FIFO\n rcall("LPUSH", targetKey, jobId)\n else\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n end\n -- Emit waiting event\n rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",\n jobId, "prev", "delayed")\n rcall("HSET", jobKey, "delay", 0)\n end\n addBaseMarkerIfNeeded(markerKey, isPaused)\n end\nend\nlocal function removeLock(jobKey, stalledKey, token, jobId)\n if token ~= "0" then\n local lockKey = jobKey .. ':lock'\n local lockToken = rcall("GET", lockKey)\n if lockToken == token then\n rcall("DEL", lockKey)\n rcall("SREM", stalledKey, jobId)\n else\n if lockToken then\n -- Lock exists but token does not match\n return -6\n else\n -- Lock is missing completely\n return -2\n end\n end\n end\n return 0\nend\n--[[\n Function to update a bunch of fields in a job.\n]]\nlocal function updateJobFields(jobKey, msgpackedFields)\n if msgpackedFields and #msgpackedFields > 0 then\n local fieldsToUpdate = cmsgpack.unpack(msgpackedFields)\n if fieldsToUpdate then\n rcall("HMSET", jobKey, unpack(fieldsToUpdate))\n end\n end\nend\nlocal target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[1], KEYS[2], KEYS[3])\nlocal markerKey = KEYS[10]\n-- Check if there are delayed jobs that we can move to wait.\n-- test example: when there are delayed jobs between retries\npromoteDelayedJobs(KEYS[7], markerKey, target, KEYS[8], KEYS[6], ARGV[1], ARGV[2], KEYS[9], isPausedOrMaxed)\nlocal jobKey = KEYS[4]\nif rcall("EXISTS", jobKey) == 1 then\n local errorCode = removeLock(jobKey, KEYS[11], ARGV[5], ARGV[4]) \n if errorCode < 0 then\n return errorCode\n end\n updateJobFields(jobKey, ARGV[6])\n local numRemovedElements = rcall("LREM", KEYS[1], -1, ARGV[4])\n if (numRemovedElements < 1) then return -3 end\n local priority = tonumber(rcall("HGET", jobKey, "priority")) or 0\n --need to re-evaluate after removing job from active\n isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[1])\n -- Standard or priority add\n if priority == 0 then\n addJobInTargetList(target, markerKey, ARGV[3], isPausedOrMaxed, ARGV[4])\n else\n addJobWithPriority(markerKey, KEYS[8], priority, ARGV[4], KEYS[9], isPausedOrMaxed)\n end\n rcall("HINCRBY", jobKey, "atm", 1)\n local maxEvents = getOrSetMaxEvents(KEYS[5])\n -- Emit waiting event\n rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "waiting",\n "jobId", ARGV[4], "prev", "failed")\n return 0\nelse\n return -1\nend\n`;t.retryJob={name:"retryJob",content:n,keys:11}},7044:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.saveStacktrace=void 0;const n=`--[[\n Save stacktrace and failedReason.\n Input:\n KEYS[1] job key\n ARGV[1] stacktrace\n ARGV[2] failedReason\n Output:\n 0 - OK\n -1 - Missing key\n]]\nlocal rcall = redis.call\nif rcall("EXISTS", KEYS[1]) == 1 then\n rcall("HMSET", KEYS[1], "stacktrace", ARGV[1], "failedReason", ARGV[2])\n return 0\nelse\n return -1\nend\n`;t.saveStacktrace={name:"saveStacktrace",content:n,keys:1}},6953:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.updateData=void 0;const n=`--[[\n Update job data\n Input:\n KEYS[1] Job id key\n ARGV[1] data\n Output:\n 0 - OK\n -1 - Missing job.\n]]\nlocal rcall = redis.call\nif rcall("EXISTS",KEYS[1]) == 1 then -- // Make sure job exists\n rcall("HSET", KEYS[1], "data", ARGV[1])\n return 0\nelse\n return -1\nend\n`;t.updateData={name:"updateData",content:n,keys:1}},6003:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.updateJobScheduler=void 0;const n=`--[[\n Updates a job scheduler and adds next delayed job\n Input:\n KEYS[1] 'repeat' key\n KEYS[2] 'delayed'\n KEYS[3] 'wait' key\n KEYS[4] 'paused' key\n KEYS[5] 'meta'\n KEYS[6] 'prioritized' key\n KEYS[7] 'marker',\n KEYS[8] 'id'\n KEYS[9] events stream key\n KEYS[10] 'pc' priority counter\n KEYS[11] producer key\n KEYS[12] 'active' key\n ARGV[1] next milliseconds\n ARGV[2] jobs scheduler id\n ARGV[3] Json stringified delayed data\n ARGV[4] msgpacked delayed opts\n ARGV[5] timestamp\n ARGV[6] prefix key\n ARGV[7] producer id\n Output:\n next delayed job id - OK\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[1]\nlocal delayedKey = KEYS[2]\nlocal waitKey = KEYS[3]\nlocal pausedKey = KEYS[4]\nlocal metaKey = KEYS[5]\nlocal prioritizedKey = KEYS[6]\nlocal nextMillis = ARGV[1]\nlocal jobSchedulerId = ARGV[2]\nlocal timestamp = ARGV[5]\nlocal prefixKey = ARGV[6]\nlocal producerId = ARGV[7]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Adds a delayed job to the queue by doing the following:\n - Creates a new job key with the job data.\n - adds to delayed zset.\n - Emits a global event 'delayed' if the job is delayed.\n]]\n-- Includes\n--[[\n Add delay marker if needed.\n]]\n-- Includes\n--[[\n Function to return the next delayed job timestamp.\n]]\nlocal function getNextDelayedTimestamp(delayedKey)\n local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")\n if #result then\n local nextTimestamp = tonumber(result[2])\n if nextTimestamp ~= nil then\n return nextTimestamp / 0x1000\n end\n end\nend\nlocal function addDelayMarkerIfNeeded(markerKey, delayedKey)\n local nextTimestamp = getNextDelayedTimestamp(delayedKey)\n if nextTimestamp ~= nil then\n -- Replace the score of the marker with the newest known\n -- next timestamp.\n rcall("ZADD", markerKey, nextTimestamp, "1")\n end\nend\n--[[\n Bake in the job id first 12 bits into the timestamp\n to guarantee correct execution order of delayed jobs\n (up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)\n WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail\n]]\nlocal function getDelayedScore(delayedKey, timestamp, delay)\n local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)\n local minScore = delayedTimestamp * 0x1000\n local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1\n local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,\n minScore, "WITHSCORES","LIMIT", 0, 1)\n if #result then\n local currentMaxScore = tonumber(result[2])\n if currentMaxScore ~= nil then\n if currentMaxScore >= maxScore then\n return maxScore, delayedTimestamp\n else\n return currentMaxScore + 1, delayedTimestamp\n end\n end\n end\n return minScore, delayedTimestamp\nend\nlocal function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,\n maxEvents, markerKey, delay)\n local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay))\n rcall("ZADD", delayedKey, score, jobId)\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",\n "jobId", jobId, "delay", delayedTimestamp)\n -- mark that a delayed job is available\n addDelayMarkerIfNeeded(markerKey, delayedKey)\nend\n--[[\n Function to add job considering priority.\n]]\n-- Includes\n--[[\n Add marker if needed when a job is available.\n]]\nlocal function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\n if not isPausedOrMaxed then\n rcall("ZADD", markerKey, 0, "0")\n end \nend\n--[[\n Function to get priority score.\n]]\nlocal function getPriorityScore(priority, priorityCounterKey)\n local prioCounter = rcall("INCR", priorityCounterKey)\n return priority * 0x100000000 + prioCounter % 0x100000000\nend\nlocal function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,\n isPausedOrMaxed)\n local score = getPriorityScore(priority, priorityCounterKey)\n rcall("ZADD", prioritizedKey, score, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function isQueuePaused(queueMetaKey)\n return rcall("HEXISTS", queueMetaKey, "paused") == 1\nend\n--[[\n Function to store a job\n]]\nlocal function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,\n parentKey, parentData, repeatJobKey)\n local jsonOpts = cjson.encode(opts)\n local delay = opts['delay'] or 0\n local priority = opts['priority'] or 0\n local debounceId = opts['de'] and opts['de']['id']\n local optionalValues = {}\n if parentKey ~= nil then\n table.insert(optionalValues, "parentKey")\n table.insert(optionalValues, parentKey)\n table.insert(optionalValues, "parent")\n table.insert(optionalValues, parentData)\n end\n if repeatJobKey then\n table.insert(optionalValues, "rjk")\n table.insert(optionalValues, repeatJobKey)\n end\n if debounceId then\n table.insert(optionalValues, "deid")\n table.insert(optionalValues, debounceId)\n end\n rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,\n "timestamp", timestamp, "delay", delay, "priority", priority,\n unpack(optionalValues))\n rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)\n return delay, priority\nend\n--[[\n Function to check for the meta.paused key to decide if we are paused or not\n (since an empty list and !EXISTS are not really the same).\n]]\nlocal function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)\n local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")\n if queueAttributes[1] then\n return pausedKey, true\n else\n if queueAttributes[2] then\n local activeCount = rcall("LLEN", activeKey)\n if activeCount >= tonumber(queueAttributes[2]) then\n return waitKey, true\n else\n return waitKey, false\n end\n end\n end\n return waitKey, false\nend\n--[[\n Function to add job in target list and add marker if needed.\n]]\n-- Includes\nlocal function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)\n rcall(pushCmd, targetKey, jobId)\n addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)\nend\nlocal function addJobFromScheduler(jobKey, jobId, rawOpts, waitKey, pausedKey, activeKey, metaKey, \n prioritizedKey, priorityCounter, delayedKey, markerKey, eventsKey, name, maxEvents, timestamp,\n data, jobSchedulerId)\n local opts = cmsgpack.unpack(rawOpts)\n local delay, priority = storeJob(eventsKey, jobKey, jobId, name, data,\n opts, timestamp, nil, nil, jobSchedulerId)\n if delay ~= 0 then\n addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, markerKey, delay)\n else\n local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)\n -- Standard or priority add\n if priority == 0 then\n local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'\n addJobInTargetList(target, markerKey, pushCmd, isPausedOrMaxed, jobId)\n else\n -- Priority add\n addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounter, isPausedOrMaxed)\n end\n -- Emit waiting event\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting", "jobId", jobId)\n end\nend\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nlocal schedulerKey = repeatKey .. ":" .. jobSchedulerId\nlocal nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis\nlocal nextDelayedJobKey = schedulerKey .. ":" .. nextMillis\n-- Validate that scheduler exists.\nlocal prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)\nif prevMillis then\n local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis\n if producerId == currentDelayedJobId then\n local eventsKey = KEYS[9]\n local maxEvents = getOrSetMaxEvents(metaKey)\n if rcall("EXISTS", nextDelayedJobKey) ~= 1 then\n local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")\n rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)\n rcall("HINCRBY", schedulerKey, "ic", 1)\n rcall("INCR", KEYS[8])\n -- TODO: remove this workaround in next breaking change,\n -- all job-schedulers must save job data\n local templateData = schedulerAttributes[2] or ARGV[3]\n if templateData and templateData ~= '{}' then\n rcall("HSET", schedulerKey, "data", templateData)\n end\n addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey, \n KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey, \n schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)\n -- TODO: remove this workaround in next breaking change\n if KEYS[11] ~= "" then\n rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)\n end\n return nextDelayedJobId .. "" -- convert to string\n else\n rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",\n "duplicated", "jobId", nextDelayedJobId)\n end\n end\nend\n`;t.updateJobScheduler={name:"updateJobScheduler",content:n,keys:12}},8780:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.updateProgress=void 0;const n=`--[[\n Update job progress\n Input:\n KEYS[1] Job id key\n KEYS[2] event stream key\n KEYS[3] meta key\n ARGV[1] id\n ARGV[2] progress\n Output:\n 0 - OK\n -1 - Missing job.\n Event:\n progress(jobId, progress)\n]]\nlocal rcall = redis.call\n-- Includes\n--[[\n Function to get max events value or set by default 10000.\n]]\nlocal function getOrSetMaxEvents(metaKey)\n local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")\n if not maxEvents then\n maxEvents = 10000\n rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)\n end\n return maxEvents\nend\nif rcall("EXISTS", KEYS[1]) == 1 then -- // Make sure job exists\n local maxEvents = getOrSetMaxEvents(KEYS[3])\n rcall("HSET", KEYS[1], "progress", ARGV[2])\n rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event", "progress",\n "jobId", ARGV[1], "data", ARGV[2]);\n return 0\nelse\n return -1\nend\n`;t.updateProgress={name:"updateProgress",content:n,keys:3}},8333:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.updateRepeatableJobMillis=void 0;const n=`--[[\n Adds a repeatable job\n Input:\n KEYS[1] 'repeat' key\n ARGV[1] next milliseconds\n ARGV[2] custom key\n ARGV[3] legacy custom key TODO: remove this logic in next breaking change\n Output:\n repeatableKey - OK\n]]\nlocal rcall = redis.call\nlocal repeatKey = KEYS[1]\nlocal nextMillis = ARGV[1]\nlocal customKey = ARGV[2]\nlocal legacyCustomKey = ARGV[3]\nif rcall("ZSCORE", repeatKey, customKey) then\n rcall("ZADD", repeatKey, nextMillis, customKey)\n return customKey\nelseif rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then\n rcall("ZADD", repeatKey, nextMillis, legacyCustomKey)\n return legacyCustomKey\nend\nreturn ''\n`;t.updateRepeatableJobMillis={name:"updateRepeatableJobMillis",content:n,keys:1}},1191:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},1267:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},6110:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2953:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(1577);r.__exportStar(n(1191),t);r.__exportStar(n(1267),t);r.__exportStar(n(6110),t);r.__exportStar(n(4788),t);r.__exportStar(n(9331),t);r.__exportStar(n(9297),t);r.__exportStar(n(2366),t);r.__exportStar(n(9159),t);r.__exportStar(n(6326),t);r.__exportStar(n(2096),t);r.__exportStar(n(8110),t)},9331:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9297:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2096:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2366:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},9159:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},4788:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},6326:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},8110:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true})},2646:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.trace=t.removeUndefinedFields=t.QUEUE_EVENT_SUFFIX=t.toString=t.errorToJSON=t.parseObjectValues=t.isRedisVersionLowerThan=t.createScripts=t.childSend=t.asyncSend=t.isNotConnectionError=t.DELAY_TIME_1=t.DELAY_TIME_5=t.clientCommandMessageReg=t.getParentKey=t.removeAllQueueData=t.decreaseMaxListeners=t.isRedisCluster=t.isRedisInstance=t.optsEncodeMap=t.optsDecodeMap=t.invertObject=t.increaseMaxListeners=t.delay=t.objectToFlatArray=t.array2obj=t.isEmpty=t.lengthInUtf8Bytes=t.tryCatch=t.errorObject=void 0;const r=n(405);const i=n(9335);const s=n(9916);const a=n(2348);const o=n(6694);t.errorObject={value:null};function tryCatch(e,n,r){try{return e.apply(n,r)}catch(e){t.errorObject.value=e;return t.errorObject}}t.tryCatch=tryCatch;function lengthInUtf8Bytes(e){return Buffer.byteLength(e,"utf8")}t.lengthInUtf8Bytes=lengthInUtf8Bytes;function isEmpty(e){for(const t in e){if(Object.prototype.hasOwnProperty.call(e,t)){return false}}return true}t.isEmpty=isEmpty;function array2obj(e){const t={};for(let n=0;n<e.length;n+=2){t[e[n]]=e[n+1]}return t}t.array2obj=array2obj;function objectToFlatArray(e){const t=[];for(const n in e){if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==undefined){t[t.length]=n;t[t.length]=e[n]}}return t}t.objectToFlatArray=objectToFlatArray;function delay(e,t){return new Promise((n=>{let r;const callback=()=>{t===null||t===void 0?void 0:t.signal.removeEventListener("abort",callback);clearTimeout(r);n()};r=setTimeout(callback,e);t===null||t===void 0?void 0:t.signal.addEventListener("abort",callback)}))}t.delay=delay;function increaseMaxListeners(e,t){const n=e.getMaxListeners();e.setMaxListeners(n+t)}t.increaseMaxListeners=increaseMaxListeners;function invertObject(e){return Object.entries(e).reduce(((e,[t,n])=>{e[n]=t;return e}),{})}t.invertObject=invertObject;t.optsDecodeMap={de:"deduplication",fpof:"failParentOnFailure",cpof:"continueParentOnFailure",idof:"ignoreDependencyOnFailure",kl:"keepLogs",rdof:"removeDependencyOnFailure"};t.optsEncodeMap=Object.assign(Object.assign({},invertObject(t.optsDecodeMap)),{debounce:"de"});function isRedisInstance(e){if(!e){return false}const t=["connect","disconnect","duplicate"];return t.every((t=>typeof e[t]==="function"))}t.isRedisInstance=isRedisInstance;function isRedisCluster(e){return isRedisInstance(e)&&e.isCluster}t.isRedisCluster=isRedisCluster;function decreaseMaxListeners(e,t){increaseMaxListeners(e,-t)}t.decreaseMaxListeners=decreaseMaxListeners;async function removeAllQueueData(e,t,n=process.env.BULLMQ_TEST_PREFIX||"bull"){if(e instanceof r.Cluster){return Promise.resolve(false)}const i=`${n}:${t}:*`;const s=await new Promise(((t,n)=>{const r=e.scanStream({match:i});r.on("data",(t=>{if(t.length){const r=e.pipeline();t.forEach((e=>{r.del(e)}));r.exec().catch((e=>{n(e)}))}}));r.on("end",(()=>t()));r.on("error",(e=>n(e)))}));await s;await e.quit()}t.removeAllQueueData=removeAllQueueData;function getParentKey(e){if(e){return`${e.queue}:${e.id}`}}t.getParentKey=getParentKey;t.clientCommandMessageReg=/ERR unknown command ['`]\s*client\s*['`]/;t.DELAY_TIME_5=5e3;t.DELAY_TIME_1=100;function isNotConnectionError(e){const t=`${e.message}`;return t!==i.CONNECTION_CLOSED_ERROR_MSG&&!t.includes("ECONNREFUSED")}t.isNotConnectionError=isNotConnectionError;const asyncSend=(e,t)=>new Promise(((n,r)=>{if(typeof e.send==="function"){e.send(t,(e=>{if(e){r(e)}else{n()}}))}else if(typeof e.postMessage==="function"){n(e.postMessage(t))}else{n()}}));t.asyncSend=asyncSend;const childSend=(e,n)=>(0,t.asyncSend)(e,n);t.childSend=childSend;const createScripts=e=>new s.Scripts({keys:e.keys,client:e.client,get redisVersion(){return e.redisVersion},toKey:e.toKey,opts:e.opts,closing:e.closing});t.createScripts=createScripts;const isRedisVersionLowerThan=(e,t)=>{const n=a.valid(a.coerce(e));return a.lt(n,t)};t.isRedisVersionLowerThan=isRedisVersionLowerThan;const parseObjectValues=e=>{const t={};for(const n of Object.entries(e)){t[n[0]]=JSON.parse(n[1])}return t};t.parseObjectValues=parseObjectValues;const getCircularReplacer=e=>{const t=new WeakSet;t.add(e);return(e,n)=>{if(typeof n==="object"&&n!==null){if(t.has(n)){return"[Circular]"}t.add(n)}return n}};const errorToJSON=e=>{const t={};Object.getOwnPropertyNames(e).forEach((function(n){t[n]=e[n]}));return JSON.parse(JSON.stringify(t,getCircularReplacer(e)))};t.errorToJSON=errorToJSON;const l=1/0;const toString=e=>{if(e==null){return""}if(typeof e==="string"){return e}if(Array.isArray(e)){return`${e.map((e=>e==null?e:(0,t.toString)(e)))}`}if(typeof e=="symbol"||Object.prototype.toString.call(e)=="[object Symbol]"){return e.toString()}const n=`${e}`;return n==="0"&&1/e===-l?"-0":n};t.toString=toString;t.QUEUE_EVENT_SUFFIX=":qe";function removeUndefinedFields(e){const t={};for(const n in e){if(e[n]!==undefined){t[n]=e[n]}}return t}t.removeUndefinedFields=removeUndefinedFields;async function trace(e,t,n,r,i,s,a){if(!e){return s()}else{const{tracer:l,contextManager:c}=e;const u=c.active();let d;if(a){d=c.fromMetadata(u,a)}const f=i?`${r} ${i}`:r;const p=l.startSpan(f,{kind:t},d);try{p.setAttributes({[o.TelemetryAttributes.QueueName]:n,[o.TelemetryAttributes.QueueOperation]:r});let e;let i;if(t===o.SpanKind.CONSUMER&&d){e=p.setSpanOnContext(d)}else{e=p.setSpanOnContext(u)}if(s.length==2){i=c.getMetadata(e)}return await c.with(e,(()=>s(p,i)))}catch(e){p.recordException(e);throw e}finally{p.end()}}}t.trace=trace},3267:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.version=void 0;t.version="5.56.9"},3288:function(e){var t=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];var n=function toUTF8Array(e){var t;var n=0;var r=0;var i=[];var s=e.length;for(;n<s;n++){t=e.charCodeAt(n);if(t<128){i[r++]=t}else if(t<2048){i[r++]=t>>6|192;i[r++]=t&63|128}else if((t&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320){t=65536+((t&1023)<<10)+(e.charCodeAt(++n)&1023);i[r++]=t>>18|240;i[r++]=t>>12&63|128;i[r++]=t>>6&63|128;i[r++]=t&63|128}else{i[r++]=t>>12|224;i[r++]=t>>6&63|128;i[r++]=t&63|128}}return i};var r=e.exports=function generate(e){var r;var i=0;var s=-1;var a=0;var o=0;var l=typeof e==="string"?n(e):e;var c=l.length;while(i<c){r=l[i++];if(s===-1){if(r===123){s=i}}else if(r!==125){o=t[(r^o>>8)&255]^o<<8}else if(i-1!==s){return o&16383}a=t[(r^a>>8)&255]^a<<8}return a&16383};e.exports.generateMulti=function generateMulti(e){var t=1;var n=e.length;var i=r(e[0]);while(t<n){if(r(e[t++])!==i)return-1}return i}},2799:function(e,t,n){"use strict";var r=n(8588);CronDate.prototype.addYear=function(){this._date=this._date.plus({years:1})};CronDate.prototype.addMonth=function(){this._date=this._date.plus({months:1}).startOf("month")};CronDate.prototype.addDay=function(){this._date=this._date.plus({days:1}).startOf("day")};CronDate.prototype.addHour=function(){var e=this._date;this._date=this._date.plus({hours:1}).startOf("hour");if(this._date<=e){this._date=this._date.plus({hours:1})}};CronDate.prototype.addMinute=function(){var e=this._date;this._date=this._date.plus({minutes:1}).startOf("minute");if(this._date<e){this._date=this._date.plus({hours:1})}};CronDate.prototype.addSecond=function(){var e=this._date;this._date=this._date.plus({seconds:1}).startOf("second");if(this._date<e){this._date=this._date.plus({hours:1})}};CronDate.prototype.subtractYear=function(){this._date=this._date.minus({years:1})};CronDate.prototype.subtractMonth=function(){this._date=this._date.minus({months:1}).endOf("month").startOf("second")};CronDate.prototype.subtractDay=function(){this._date=this._date.minus({days:1}).endOf("day").startOf("second")};CronDate.prototype.subtractHour=function(){var e=this._date;this._date=this._date.minus({hours:1}).endOf("hour").startOf("second");if(this._date>=e){this._date=this._date.minus({hours:1})}};CronDate.prototype.subtractMinute=function(){var e=this._date;this._date=this._date.minus({minutes:1}).endOf("minute").startOf("second");if(this._date>e){this._date=this._date.minus({hours:1})}};CronDate.prototype.subtractSecond=function(){var e=this._date;this._date=this._date.minus({seconds:1}).startOf("second");if(this._date>e){this._date=this._date.minus({hours:1})}};CronDate.prototype.getDate=function(){return this._date.day};CronDate.prototype.getFullYear=function(){return this._date.year};CronDate.prototype.getDay=function(){var e=this._date.weekday;return e==7?0:e};CronDate.prototype.getMonth=function(){return this._date.month-1};CronDate.prototype.getHours=function(){return this._date.hour};CronDate.prototype.getMinutes=function(){return this._date.minute};CronDate.prototype.getSeconds=function(){return this._date.second};CronDate.prototype.getMilliseconds=function(){return this._date.millisecond};CronDate.prototype.getTime=function(){return this._date.valueOf()};CronDate.prototype.getUTCDate=function(){return this._getUTC().day};CronDate.prototype.getUTCFullYear=function(){return this._getUTC().year};CronDate.prototype.getUTCDay=function(){var e=this._getUTC().weekday;return e==7?0:e};CronDate.prototype.getUTCMonth=function(){return this._getUTC().month-1};CronDate.prototype.getUTCHours=function(){return this._getUTC().hour};CronDate.prototype.getUTCMinutes=function(){return this._getUTC().minute};CronDate.prototype.getUTCSeconds=function(){return this._getUTC().second};CronDate.prototype.toISOString=function(){return this._date.toUTC().toISO()};CronDate.prototype.toJSON=function(){return this._date.toJSON()};CronDate.prototype.setDate=function(e){this._date=this._date.set({day:e})};CronDate.prototype.setFullYear=function(e){this._date=this._date.set({year:e})};CronDate.prototype.setDay=function(e){this._date=this._date.set({weekday:e})};CronDate.prototype.setMonth=function(e){this._date=this._date.set({month:e+1})};CronDate.prototype.setHours=function(e){this._date=this._date.set({hour:e})};CronDate.prototype.setMinutes=function(e){this._date=this._date.set({minute:e})};CronDate.prototype.setSeconds=function(e){this._date=this._date.set({second:e})};CronDate.prototype.setMilliseconds=function(e){this._date=this._date.set({millisecond:e})};CronDate.prototype._getUTC=function(){return this._date.toUTC()};CronDate.prototype.toString=function(){return this.toDate().toString()};CronDate.prototype.toDate=function(){return this._date.toJSDate()};CronDate.prototype.isLastDayOfMonth=function(){var e=this._date.plus({days:1}).startOf("day");return this._date.month!==e.month};CronDate.prototype.isLastWeekdayOfMonth=function(){var e=this._date.plus({days:7}).startOf("day");return this._date.month!==e.month};function CronDate(e,t){var n={zone:t};if(!e){this._date=r.DateTime.local()}else if(e instanceof CronDate){this._date=e._date}else if(e instanceof Date){this._date=r.DateTime.fromJSDate(e,n)}else if(typeof e==="number"){this._date=r.DateTime.fromMillis(e,n)}else if(typeof e==="string"){this._date=r.DateTime.fromISO(e,n);this._date.isValid||(this._date=r.DateTime.fromRFC2822(e,n));this._date.isValid||(this._date=r.DateTime.fromSQL(e,n));this._date.isValid||(this._date=r.DateTime.fromFormat(e,"EEE, d MMM yyyy HH:mm:ss",n))}if(!this._date||!this._date.isValid){throw new Error("CronDate: unhandled timestamp: "+JSON.stringify(e))}if(t&&t!==this._date.zoneName){this._date=this._date.setZone(t)}}e.exports=CronDate},8937:function(e,t,n){"use strict";var r=n(2799);var i=n(4173);var s=1e4;function CronExpression(e,t){this._options=t;this._utc=t.utc||false;this._tz=this._utc?"UTC":t.tz;this._currentDate=new r(t.currentDate,this._tz);this._startDate=t.startDate?new r(t.startDate,this._tz):null;this._endDate=t.endDate?new r(t.endDate,this._tz):null;this._isIterator=t.iterator||false;this._hasIterated=false;this._nthDayOfWeek=t.nthDayOfWeek||0;this.fields=CronExpression._freezeFields(e)}CronExpression.map=["second","minute","hour","dayOfMonth","month","dayOfWeek"];CronExpression.predefined={"@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *"};CronExpression.constraints=[{min:0,max:59,chars:[]},{min:0,max:59,chars:[]},{min:0,max:23,chars:[]},{min:1,max:31,chars:["L"]},{min:1,max:12,chars:[]},{min:0,max:7,chars:["L"]}];CronExpression.daysInMonth=[31,29,31,30,31,30,31,31,30,31,30,31];CronExpression.aliases={month:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},dayOfWeek:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}};CronExpression.parseDefaults=["0","*","*","*","*","*"];CronExpression.standardValidCharacters=/^[,*\d/-]+$/;CronExpression.dayOfWeekValidCharacters=/^[?,*\dL#/-]+$/;CronExpression.dayOfMonthValidCharacters=/^[?,*\dL/-]+$/;CronExpression.validCharacters={second:CronExpression.standardValidCharacters,minute:CronExpression.standardValidCharacters,hour:CronExpression.standardValidCharacters,dayOfMonth:CronExpression.dayOfMonthValidCharacters,month:CronExpression.standardValidCharacters,dayOfWeek:CronExpression.dayOfWeekValidCharacters};CronExpression._isValidConstraintChar=function _isValidConstraintChar(e,t){if(typeof t!=="string"){return false}return e.chars.some((function(e){return t.indexOf(e)>-1}))};CronExpression._parseField=function _parseField(e,t,n){switch(e){case"month":case"dayOfWeek":var r=CronExpression.aliases[e];t=t.replace(/[a-z]{3}/gi,(function(e){e=e.toLowerCase();if(typeof r[e]!=="undefined"){return r[e]}else{throw new Error('Validation error, cannot resolve alias "'+e+'"')}}));break}if(!CronExpression.validCharacters[e].test(t)){throw new Error("Invalid characters, got value: "+t)}if(t.indexOf("*")!==-1){t=t.replace(/\*/g,n.min+"-"+n.max)}else if(t.indexOf("?")!==-1){t=t.replace(/\?/g,n.min+"-"+n.max)}function parseSequence(t){var r=[];function handleResult(t){if(t instanceof Array){for(var i=0,s=t.length;i<s;i++){var a=t[i];if(CronExpression._isValidConstraintChar(n,a)){r.push(a);continue}if(typeof a!=="number"||Number.isNaN(a)||a<n.min||a>n.max){throw new Error("Constraint error, got value "+a+" expected range "+n.min+"-"+n.max)}r.push(a)}}else{if(CronExpression._isValidConstraintChar(n,t)){r.push(t);return}var o=+t;if(Number.isNaN(o)||o<n.min||o>n.max){throw new Error("Constraint error, got value "+t+" expected range "+n.min+"-"+n.max)}if(e==="dayOfWeek"){o=o%7}r.push(o)}}var i=t.split(",");if(!i.every((function(e){return e.length>0}))){throw new Error("Invalid list value format")}if(i.length>1){for(var s=0,a=i.length;s<a;s++){handleResult(parseRepeat(i[s]))}}else{handleResult(parseRepeat(t))}r.sort(CronExpression._sortCompareFn);return r}function parseRepeat(e){var t=1;var r=e.split("/");if(r.length>2){throw new Error("Invalid repeat: "+e)}if(r.length>1){if(r[0]==+r[0]){r=[r[0]+"-"+n.max,r[1]]}return parseRange(r[0],r[r.length-1])}return parseRange(e,t)}function parseRange(t,r){var i=[];var s=t.split("-");if(s.length>1){if(s.length<2){return+t}if(!s[0].length){if(!s[1].length){throw new Error("Invalid range: "+t)}return+t}var a=+s[0];var o=+s[1];if(Number.isNaN(a)||Number.isNaN(o)||a<n.min||o>n.max){throw new Error("Constraint error, got range "+a+"-"+o+" expected range "+n.min+"-"+n.max)}else if(a>o){throw new Error("Invalid range: "+t)}var l=+r;if(Number.isNaN(l)||l<=0){throw new Error("Constraint error, cannot repeat at every "+l+" time.")}if(e==="dayOfWeek"&&o%7===0){i.push(0)}for(var c=a,u=o;c<=u;c++){var d=i.indexOf(c)!==-1;if(!d&&l>0&&l%r===0){l=1;i.push(c)}else{l++}}return i}return Number.isNaN(+t)?t:+t}return parseSequence(t)};CronExpression._sortCompareFn=function(e,t){var n=typeof e==="number";var r=typeof t==="number";if(n&&r){return e-t}if(!n&&r){return 1}if(n&&!r){return-1}return e.localeCompare(t)};CronExpression._handleMaxDaysInMonth=function(e){if(e.month.length===1){var t=CronExpression.daysInMonth[e.month[0]-1];if(e.dayOfMonth[0]>t){throw new Error("Invalid explicit day of month definition")}return e.dayOfMonth.filter((function(e){return e==="L"?true:e<=t})).sort(CronExpression._sortCompareFn)}};CronExpression._freezeFields=function(e){for(var t=0,n=CronExpression.map.length;t<n;++t){var r=CronExpression.map[t];var i=e[r];e[r]=Object.freeze(i)}return Object.freeze(e)};CronExpression.prototype._applyTimezoneShift=function(e,t,n){if(n==="Month"||n==="Day"){var r=e.getTime();e[t+n]();var i=e.getTime();if(r===i){if(e.getMinutes()===0&&e.getSeconds()===0){e.addHour()}else if(e.getMinutes()===59&&e.getSeconds()===59){e.subtractHour()}}}else{var s=e.getHours();e[t+n]();var a=e.getHours();var o=a-s;if(o===2){if(this.fields.hour.length!==24){this._dstStart=a}}else if(o===0&&e.getMinutes()===0&&e.getSeconds()===0){if(this.fields.hour.length!==24){this._dstEnd=a}}}};CronExpression.prototype._findSchedule=function _findSchedule(e){function matchSchedule(e,t){for(var n=0,r=t.length;n<r;n++){if(t[n]>=e){return t[n]===e}}return t[0]===e}function isNthDayMatch(e,t){if(t<6){if(e.getDate()<8&&t===1){return true}var n=e.getDate()%7?1:0;var r=e.getDate()-e.getDate()%7;var i=Math.floor(r/7)+n;return i===t}return false}function isLInExpressions(e){return e.length>0&&e.some((function(e){return typeof e==="string"&&e.indexOf("L")>=0}))}e=e||false;var t=e?"subtract":"add";var n=new r(this._currentDate,this._tz);var i=this._startDate;var a=this._endDate;var o=n.getTime();var l=0;function isLastWeekdayOfMonthMatch(e){return e.some((function(e){if(!isLInExpressions([e])){return false}var t=Number.parseInt(e[0])%7;if(Number.isNaN(t)){throw new Error("Invalid last weekday of the month expression: "+e)}return n.getDay()===t&&n.isLastWeekdayOfMonth()}))}while(l<s){l++;if(e){if(i&&n.getTime()-i.getTime()<0){throw new Error("Out of the timespan range")}}else{if(a&&a.getTime()-n.getTime()<0){throw new Error("Out of the timespan range")}}var c=matchSchedule(n.getDate(),this.fields.dayOfMonth);if(isLInExpressions(this.fields.dayOfMonth)){c=c||n.isLastDayOfMonth()}var u=matchSchedule(n.getDay(),this.fields.dayOfWeek);if(isLInExpressions(this.fields.dayOfWeek)){u=u||isLastWeekdayOfMonthMatch(this.fields.dayOfWeek)}var d=this.fields.dayOfMonth.length>=CronExpression.daysInMonth[n.getMonth()];var f=this.fields.dayOfWeek.length===CronExpression.constraints[5].max-CronExpression.constraints[5].min+1;var p=n.getHours();if(!c&&(!u||f)){this._applyTimezoneShift(n,t,"Day");continue}if(!d&&f&&!c){this._applyTimezoneShift(n,t,"Day");continue}if(d&&!f&&!u){this._applyTimezoneShift(n,t,"Day");continue}if(this._nthDayOfWeek>0&&!isNthDayMatch(n,this._nthDayOfWeek)){this._applyTimezoneShift(n,t,"Day");continue}if(!matchSchedule(n.getMonth()+1,this.fields.month)){this._applyTimezoneShift(n,t,"Month");continue}if(!matchSchedule(p,this.fields.hour)){if(this._dstStart!==p){this._dstStart=null;this._applyTimezoneShift(n,t,"Hour");continue}else if(!matchSchedule(p-1,this.fields.hour)){n[t+"Hour"]();continue}}else if(this._dstEnd===p){if(!e){this._dstEnd=null;this._applyTimezoneShift(n,"add","Hour");continue}}if(!matchSchedule(n.getMinutes(),this.fields.minute)){this._applyTimezoneShift(n,t,"Minute");continue}if(!matchSchedule(n.getSeconds(),this.fields.second)){this._applyTimezoneShift(n,t,"Second");continue}if(o===n.getTime()){if(t==="add"||n.getMilliseconds()===0){this._applyTimezoneShift(n,t,"Second")}else{n.setMilliseconds(0)}continue}break}if(l>=s){throw new Error("Invalid expression, loop limit exceeded")}this._currentDate=new r(n,this._tz);this._hasIterated=true;return n};CronExpression.prototype.next=function next(){var e=this._findSchedule();if(this._isIterator){return{value:e,done:!this.hasNext()}}return e};CronExpression.prototype.prev=function prev(){var e=this._findSchedule(true);if(this._isIterator){return{value:e,done:!this.hasPrev()}}return e};CronExpression.prototype.hasNext=function(){var e=this._currentDate;var t=this._hasIterated;try{this._findSchedule();return true}catch(e){return false}finally{this._currentDate=e;this._hasIterated=t}};CronExpression.prototype.hasPrev=function(){var e=this._currentDate;var t=this._hasIterated;try{this._findSchedule(true);return true}catch(e){return false}finally{this._currentDate=e;this._hasIterated=t}};CronExpression.prototype.iterate=function iterate(e,t){var n=[];if(e>=0){for(var r=0,i=e;r<i;r++){try{var s=this.next();n.push(s);if(t){t(s,r)}}catch(e){break}}}else{for(var r=0,i=e;r>i;r--){try{var s=this.prev();n.push(s);if(t){t(s,r)}}catch(e){break}}}return n};CronExpression.prototype.reset=function reset(e){this._currentDate=new r(e||this._options.currentDate)};CronExpression.prototype.stringify=function stringify(e){var t=[];for(var n=e?0:1,r=CronExpression.map.length;n<r;++n){var s=CronExpression.map[n];var a=this.fields[s];var o=CronExpression.constraints[n];if(s==="dayOfMonth"&&this.fields.month.length===1){o={min:1,max:CronExpression.daysInMonth[this.fields.month[0]-1]}}else if(s==="dayOfWeek"){o={min:0,max:6};a=a[a.length-1]===7?a.slice(0,-1):a}t.push(i(a,o.min,o.max))}return t.join(" ")};CronExpression.parse=function parse(e,t){var n=this;if(typeof t==="function"){t={}}function parse(e,t){if(!t){t={}}if(typeof t.currentDate==="undefined"){t.currentDate=new r(undefined,n._tz)}if(CronExpression.predefined[e]){e=CronExpression.predefined[e]}var i=[];var s=(e+"").trim().split(/\s+/);if(s.length>6){throw new Error("Invalid cron expression")}var a=CronExpression.map.length-s.length;for(var o=0,l=CronExpression.map.length;o<l;++o){var c=CronExpression.map[o];var u=s[s.length>l?o:o-a];if(o<a||!u){i.push(CronExpression._parseField(c,CronExpression.parseDefaults[o],CronExpression.constraints[o]))}else{var d=c==="dayOfWeek"?parseNthDay(u):u;i.push(CronExpression._parseField(c,d,CronExpression.constraints[o]))}}var f={};for(var o=0,l=CronExpression.map.length;o<l;o++){var p=CronExpression.map[o];f[p]=i[o]}var h=CronExpression._handleMaxDaysInMonth(f);f.dayOfMonth=h||f.dayOfMonth;return new CronExpression(f,t);function parseNthDay(e){var n=e.split("#");if(n.length>1){var r=+n[n.length-1];if(/,/.test(e)){throw new Error("Constraint error, invalid dayOfWeek `#` and `,` "+"special characters are incompatible")}if(/\//.test(e)){throw new Error("Constraint error, invalid dayOfWeek `#` and `/` "+"special characters are incompatible")}if(/-/.test(e)){throw new Error("Constraint error, invalid dayOfWeek `#` and `-` "+"special characters are incompatible")}if(n.length>2||Number.isNaN(r)||(r<1||r>5)){throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)")}t.nthDayOfWeek=r;return n[0]}return e}}return parse(e,t)};CronExpression.fieldsToExpression=function fieldsToExpression(e,t){function validateConstraints(e,t,n){if(!t){throw new Error("Validation error, Field "+e+" is missing")}if(t.length===0){throw new Error("Validation error, Field "+e+" contains no values")}for(var r=0,i=t.length;r<i;r++){var s=t[r];if(CronExpression._isValidConstraintChar(n,s)){continue}if(typeof s!=="number"||Number.isNaN(s)||s<n.min||s>n.max){throw new Error("Constraint error, got value "+s+" expected range "+n.min+"-"+n.max)}}}var n={};for(var r=0,i=CronExpression.map.length;r<i;++r){var s=CronExpression.map[r];var a=e[s];validateConstraints(s,a,CronExpression.constraints[r]);var o=[];var l=-1;while(++l<a.length){o[l]=a[l]}a=o.sort(CronExpression._sortCompareFn).filter((function(e,t,n){return!t||e!==n[t-1]}));if(a.length!==o.length){throw new Error("Validation error, Field "+s+" contains duplicate values")}n[s]=a}var c=CronExpression._handleMaxDaysInMonth(n);n.dayOfMonth=c||n.dayOfMonth;return new CronExpression(n,t||{})};e.exports=CronExpression},8936:function(e){"use strict";function buildRange(e){return{start:e,count:1}}function completeRangeWithItem(e,t){e.end=t;e.step=t-e.start;e.count=2}function finalizeCurrentRange(e,t,n){if(t){if(t.count===2){e.push(buildRange(t.start));e.push(buildRange(t.end))}else{e.push(t)}}if(n){e.push(n)}}function compactField(e){var t=[];var n=undefined;for(var r=0;r<e.length;r++){var i=e[r];if(typeof i!=="number"){finalizeCurrentRange(t,n,buildRange(i));n=undefined}else if(!n){n=buildRange(i)}else if(n.count===1){completeRangeWithItem(n,i)}else{if(n.step===i-n.end){n.count++;n.end=i}else if(n.count===2){t.push(buildRange(n.start));n=buildRange(n.end);completeRangeWithItem(n,i)}else{finalizeCurrentRange(t,n);n=buildRange(i)}}}finalizeCurrentRange(t,n);return t}e.exports=compactField},4173:function(e,t,n){"use strict";var r=n(8936);function stringifyField(e,t,n){var i=r(e);if(i.length===1){var s=i[0];var a=s.step;if(a===1&&s.start===t&&s.end===n){return"*"}if(a!==1&&s.start===t&&s.end===n-a+1){return"*/"+a}}var o=[];for(var l=0,c=i.length;l<c;++l){var u=i[l];if(u.count===1){o.push(u.start);continue}var a=u.step;if(u.step===1){o.push(u.start+"-"+u.end);continue}var d=u.start==0?u.count-1:u.count;if(u.step*d>u.end){o=o.concat(Array.from({length:u.end-u.start+1}).map((function(e,t){var n=u.start+t;if((n-u.start)%u.step===0){return n}return null})).filter((function(e){return e!=null})))}else if(u.end===n-u.step+1){o.push(u.start+"/"+u.step)}else{o.push(u.start+"-"+u.end+"/"+u.step)}}return o.join(",")}e.exports=stringifyField},9912:function(e,t,n){"use strict";var r=n(8937);function CronParser(){}CronParser._parseEntry=function _parseEntry(e){var t=e.split(" ");if(t.length===6){return{interval:r.parse(e)}}else if(t.length>6){return{interval:r.parse(t.slice(0,6).join(" ")),command:t.slice(6,t.length)}}else{throw new Error("Invalid entry: "+e)}};CronParser.parseExpression=function parseExpression(e,t){return r.parse(e,t)};CronParser.fieldsToExpression=function fieldsToExpression(e,t){return r.fieldsToExpression(e,t)};CronParser.parseString=function parseString(e){var t=e.split("\n");var n={variables:{},expressions:[],errors:{}};for(var r=0,i=t.length;r<i;r++){var s=t[r];var a=null;var o=s.trim();if(o.length>0){if(o.match(/^#/)){continue}else if(a=o.match(/^(.*)=(.*)$/)){n.variables[a[1]]=a[2]}else{var l=null;try{l=CronParser._parseEntry("0 "+o);n.expressions.push(l.interval)}catch(e){n.errors[o]=e}}}}return n};CronParser.parseFile=function parseFile(e,t){n(9896).readFile(e,(function(e,n){if(e){t(e);return}return t(null,CronParser.parseString(n.toString()))}))};e.exports=CronParser},5313:function(e,t,n){t.formatArgs=formatArgs;t.save=save;t.load=load;t.useColors=useColors;t.storage=localstorage();t.destroy=(()=>{let e=false;return()=>{if(!e){e=true;console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}}})();t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function useColors(){if(typeof window!=="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)){return true}if(typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)){return false}let e;return typeof document!=="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!=="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!=="undefined"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function formatArgs(t){t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff);if(!this.useColors){return}const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0;let i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{if(e==="%%"){return}r++;if(e==="%c"){i=r}}));t.splice(i,0,n)}t.log=console.debug||console.log||(()=>{});function save(e){try{if(e){t.storage.setItem("debug",e)}else{t.storage.removeItem("debug")}}catch(e){}}function load(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}if(!e&&typeof process!=="undefined"&&"env"in process){e=process.env.DEBUG}return e}function localstorage(){try{return localStorage}catch(e){}}e.exports=n(5384)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},5384:function(e,t,n){function setup(e){createDebug.debug=createDebug;createDebug.default=createDebug;createDebug.coerce=coerce;createDebug.disable=disable;createDebug.enable=enable;createDebug.enabled=enabled;createDebug.humanize=n(2134);createDebug.destroy=destroy;Object.keys(e).forEach((t=>{createDebug[t]=e[t]}));createDebug.names=[];createDebug.skips=[];createDebug.formatters={};function selectColor(e){let t=0;for(let n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n);t|=0}return createDebug.colors[Math.abs(t)%createDebug.colors.length]}createDebug.selectColor=selectColor;function createDebug(e){let t;let n=null;let r;let i;function debug(...e){if(!debug.enabled){return}const n=debug;const r=Number(new Date);const i=r-(t||r);n.diff=i;n.prev=t;n.curr=r;t=r;e[0]=createDebug.coerce(e[0]);if(typeof e[0]!=="string"){e.unshift("%O")}let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,r)=>{if(t==="%%"){return"%"}s++;const i=createDebug.formatters[r];if(typeof i==="function"){const r=e[s];t=i.call(n,r);e.splice(s,1);s--}return t}));createDebug.formatArgs.call(n,e);const a=n.log||createDebug.log;a.apply(n,e)}debug.namespace=e;debug.useColors=createDebug.useColors();debug.color=createDebug.selectColor(e);debug.extend=extend;debug.destroy=createDebug.destroy;Object.defineProperty(debug,"enabled",{enumerable:true,configurable:false,get:()=>{if(n!==null){return n}if(r!==createDebug.namespaces){r=createDebug.namespaces;i=createDebug.enabled(e)}return i},set:e=>{n=e}});if(typeof createDebug.init==="function"){createDebug.init(debug)}return debug}function extend(e,t){const n=createDebug(this.namespace+(typeof t==="undefined"?":":t)+e);n.log=this.log;return n}function enable(e){createDebug.save(e);createDebug.namespaces=e;createDebug.names=[];createDebug.skips=[];const t=(typeof e==="string"?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of t){if(e[0]==="-"){createDebug.skips.push(e.slice(1))}else{createDebug.names.push(e)}}}function matchesTemplate(e,t){let n=0;let r=0;let i=-1;let s=0;while(n<e.length){if(r<t.length&&(t[r]===e[n]||t[r]==="*")){if(t[r]==="*"){i=r;s=n;r++}else{n++;r++}}else if(i!==-1){r=i+1;s++;n=s}else{return false}}while(r<t.length&&t[r]==="*"){r++}return r===t.length}function disable(){const e=[...createDebug.names,...createDebug.skips.map((e=>"-"+e))].join(",");createDebug.enable("");return e}function enabled(e){for(const t of createDebug.skips){if(matchesTemplate(e,t)){return false}}for(const t of createDebug.names){if(matchesTemplate(e,t)){return true}}return false}function coerce(e){if(e instanceof Error){return e.stack||e.message}return e}function destroy(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}createDebug.enable(createDebug.load());return createDebug}e.exports=setup},6449:function(e,t,n){if(typeof process==="undefined"||process.type==="renderer"||process.browser===true||process.__nwjs){e.exports=n(5313)}else{e.exports=n(249)}},249:function(e,t,n){const r=n(2018);const i=n(9023);t.init=init;t.log=log;t.formatArgs=formatArgs;t.save=save;t.load=load;t.useColors=useColors;t.destroy=i.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");t.colors=[6,2,3,4,5,1];try{const e=n(5414);if(e&&(e.stderr||e).level>=2){t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let r=process.env[t];if(/^(yes|on|true|enabled)$/i.test(r)){r=true}else if(/^(no|off|false|disabled)$/i.test(r)){r=false}else if(r==="null"){r=null}else{r=Number(r)}e[n]=r;return e}),{});function useColors(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):r.isatty(process.stderr.fd)}function formatArgs(t){const{namespace:n,useColors:r}=this;if(r){const r=this.color;const i="[3"+(r<8?r:"8;5;"+r);const s=` ${i};1m${n} [0m`;t[0]=s+t[0].split("\n").join("\n"+s);t.push(i+"m+"+e.exports.humanize(this.diff)+"[0m")}else{t[0]=getDate()+n+" "+t[0]}}function getDate(){if(t.inspectOpts.hideDate){return""}return(new Date).toISOString()+" "}function log(...e){return process.stderr.write(i.formatWithOptions(t.inspectOpts,...e)+"\n")}function save(e){if(e){process.env.DEBUG=e}else{delete process.env.DEBUG}}function load(){return process.env.DEBUG}function init(e){e.inspectOpts={};const n=Object.keys(t.inspectOpts);for(let r=0;r<n.length;r++){e.inspectOpts[n[r]]=t.inspectOpts[n[r]]}}e.exports=n(5384)(t);const{formatters:s}=e.exports;s.o=function(e){this.inspectOpts.colors=this.useColors;return i.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")};s.O=function(e){this.inspectOpts.colors=this.useColors;return i.inspect(e,this.inspectOpts)}},9611:function(e){"use strict";function Denque(e,t){var t=t||{};this._capacity=t.capacity;this._head=0;this._tail=0;if(Array.isArray(e)){this._fromArray(e)}else{this._capacityMask=3;this._list=new Array(4)}}Denque.prototype.peekAt=function peekAt(e){var t=e;if(t!==(t|0)){return void 0}var n=this.size();if(t>=n||t<-n)return undefined;if(t<0)t+=n;t=this._head+t&this._capacityMask;return this._list[t]};Denque.prototype.get=function get(e){return this.peekAt(e)};Denque.prototype.peek=function peek(){if(this._head===this._tail)return undefined;return this._list[this._head]};Denque.prototype.peekFront=function peekFront(){return this.peek()};Denque.prototype.peekBack=function peekBack(){return this.peekAt(-1)};Object.defineProperty(Denque.prototype,"length",{get:function length(){return this.size()}});Denque.prototype.size=function size(){if(this._head===this._tail)return 0;if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};Denque.prototype.unshift=function unshift(e){if(arguments.length===0)return this.size();var t=this._list.length;this._head=this._head-1+t&this._capacityMask;this._list[this._head]=e;if(this._tail===this._head)this._growArray();if(this._capacity&&this.size()>this._capacity)this.pop();if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};Denque.prototype.shift=function shift(){var e=this._head;if(e===this._tail)return undefined;var t=this._list[e];this._list[e]=undefined;this._head=e+1&this._capacityMask;if(e<2&&this._tail>1e4&&this._tail<=this._list.length>>>2)this._shrinkArray();return t};Denque.prototype.push=function push(e){if(arguments.length===0)return this.size();var t=this._tail;this._list[t]=e;this._tail=t+1&this._capacityMask;if(this._tail===this._head){this._growArray()}if(this._capacity&&this.size()>this._capacity){this.shift()}if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};Denque.prototype.pop=function pop(){var e=this._tail;if(e===this._head)return undefined;var t=this._list.length;this._tail=e-1+t&this._capacityMask;var n=this._list[this._tail];this._list[this._tail]=undefined;if(this._head<2&&e>1e4&&e<=t>>>2)this._shrinkArray();return n};Denque.prototype.removeOne=function removeOne(e){var t=e;if(t!==(t|0)){return void 0}if(this._head===this._tail)return void 0;var n=this.size();var r=this._list.length;if(t>=n||t<-n)return void 0;if(t<0)t+=n;t=this._head+t&this._capacityMask;var i=this._list[t];var s;if(e<n/2){for(s=e;s>0;s--){this._list[t]=this._list[t=t-1+r&this._capacityMask]}this._list[t]=void 0;this._head=this._head+1+r&this._capacityMask}else{for(s=n-1-e;s>0;s--){this._list[t]=this._list[t=t+1+r&this._capacityMask]}this._list[t]=void 0;this._tail=this._tail-1+r&this._capacityMask}return i};Denque.prototype.remove=function remove(e,t){var n=e;var r;var i=t;if(n!==(n|0)){return void 0}if(this._head===this._tail)return void 0;var s=this.size();var a=this._list.length;if(n>=s||n<-s||t<1)return void 0;if(n<0)n+=s;if(t===1||!t){r=new Array(1);r[0]=this.removeOne(n);return r}if(n===0&&n+t>=s){r=this.toArray();this.clear();return r}if(n+t>s)t=s-n;var o;r=new Array(t);for(o=0;o<t;o++){r[o]=this._list[this._head+n+o&this._capacityMask]}n=this._head+n&this._capacityMask;if(e+t===s){this._tail=this._tail-t+a&this._capacityMask;for(o=t;o>0;o--){this._list[n=n+1+a&this._capacityMask]=void 0}return r}if(e===0){this._head=this._head+t+a&this._capacityMask;for(o=t-1;o>0;o--){this._list[n=n+1+a&this._capacityMask]=void 0}return r}if(n<s/2){this._head=this._head+e+t+a&this._capacityMask;for(o=e;o>0;o--){this.unshift(this._list[n=n-1+a&this._capacityMask])}n=this._head-1+a&this._capacityMask;while(i>0){this._list[n=n-1+a&this._capacityMask]=void 0;i--}if(e<0)this._tail=n}else{this._tail=n;n=n+t+a&this._capacityMask;for(o=s-(t+e);o>0;o--){this.push(this._list[n++])}n=this._tail;while(i>0){this._list[n=n+1+a&this._capacityMask]=void 0;i--}}if(this._head<2&&this._tail>1e4&&this._tail<=a>>>2)this._shrinkArray();return r};Denque.prototype.splice=function splice(e,t){var n=e;if(n!==(n|0)){return void 0}var r=this.size();if(n<0)n+=r;if(n>r)return void 0;if(arguments.length>2){var i;var s;var a;var o=arguments.length;var l=this._list.length;var c=2;if(!r||n<r/2){s=new Array(n);for(i=0;i<n;i++){s[i]=this._list[this._head+i&this._capacityMask]}if(t===0){a=[];if(n>0){this._head=this._head+n+l&this._capacityMask}}else{a=this.remove(n,t);this._head=this._head+n+l&this._capacityMask}while(o>c){this.unshift(arguments[--o])}for(i=n;i>0;i--){this.unshift(s[i-1])}}else{s=new Array(r-(n+t));var u=s.length;for(i=0;i<u;i++){s[i]=this._list[this._head+n+t+i&this._capacityMask]}if(t===0){a=[];if(n!=r){this._tail=this._head+n+l&this._capacityMask}}else{a=this.remove(n,t);this._tail=this._tail-u+l&this._capacityMask}while(c<o){this.push(arguments[c++])}for(i=0;i<u;i++){this.push(s[i])}}return a}else{return this.remove(n,t)}};Denque.prototype.clear=function clear(){this._list=new Array(this._list.length);this._head=0;this._tail=0};Denque.prototype.isEmpty=function isEmpty(){return this._head===this._tail};Denque.prototype.toArray=function toArray(){return this._copyArray(false)};Denque.prototype._fromArray=function _fromArray(e){var t=e.length;var n=this._nextPowerOf2(t);this._list=new Array(n);this._capacityMask=n-1;this._tail=t;for(var r=0;r<t;r++)this._list[r]=e[r]};Denque.prototype._copyArray=function _copyArray(e,t){var n=this._list;var r=n.length;var i=this.length;t=t|i;if(t==i&&this._head<this._tail){return this._list.slice(this._head,this._tail)}var s=new Array(t);var a=0;var o;if(e||this._head>this._tail){for(o=this._head;o<r;o++)s[a++]=n[o];for(o=0;o<this._tail;o++)s[a++]=n[o]}else{for(o=this._head;o<this._tail;o++)s[a++]=n[o]}return s};Denque.prototype._growArray=function _growArray(){if(this._head!=0){var e=this._copyArray(true,this._list.length<<1);this._tail=this._list.length;this._head=0;this._list=e}else{this._tail=this._list.length;this._list.length<<=1}this._capacityMask=this._capacityMask<<1|1};Denque.prototype._shrinkArray=function _shrinkArray(){this._list.length>>>=1;this._capacityMask>>>=1};Denque.prototype._nextPowerOf2=function _nextPowerOf2(e){var t=Math.log(e)/Math.log(2);var n=1<<t+1;return Math.max(n,4)};e.exports=Denque},9054:function(e,t,n){"use strict";const r=n(5317);const{isLinux:i,getReport:s}=n(7613);const{LDD_PATH:a,readFile:o,readFileSync:l}=n(5941);let c;let u;const d="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true";let f="";const safeCommand=()=>{if(!f){return new Promise((e=>{r.exec(d,((t,n)=>{f=t?" ":n;e(f)}))}))}return f};const safeCommandSync=()=>{if(!f){try{f=r.execSync(d,{encoding:"utf8"})}catch(e){f=" "}}return f};const p="glibc";const h=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;const y="musl";const isFileMusl=e=>e.includes("libc.musl-")||e.includes("ld-musl-");const familyFromReport=()=>{const e=s();if(e.header&&e.header.glibcVersionRuntime){return p}if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(isFileMusl)){return y}}return null};const familyFromCommand=e=>{const[t,n]=e.split(/[\r\n]+/);if(t&&t.includes(p)){return p}if(n&&n.includes(y)){return y}return null};const getFamilyFromLddContent=e=>{if(e.includes("musl")){return y}if(e.includes("GNU C Library")){return p}return null};const familyFromFilesystem=async()=>{if(c!==undefined){return c}c=null;try{const e=await o(a);c=getFamilyFromLddContent(e)}catch(e){}return c};const familyFromFilesystemSync=()=>{if(c!==undefined){return c}c=null;try{const e=l(a);c=getFamilyFromLddContent(e)}catch(e){}return c};const family=async()=>{let e=null;if(i()){e=await familyFromFilesystem();if(!e){e=familyFromReport()}if(!e){const t=await safeCommand();e=familyFromCommand(t)}}return e};const familySync=()=>{let e=null;if(i()){e=familyFromFilesystemSync();if(!e){e=familyFromReport()}if(!e){const t=safeCommandSync();e=familyFromCommand(t)}}return e};const isNonGlibcLinux=async()=>i()&&await family()!==p;const isNonGlibcLinuxSync=()=>i()&&familySync()!==p;const versionFromFilesystem=async()=>{if(u!==undefined){return u}u=null;try{const e=await o(a);const t=e.match(h);if(t){u=t[1]}}catch(e){}return u};const versionFromFilesystemSync=()=>{if(u!==undefined){return u}u=null;try{const e=l(a);const t=e.match(h);if(t){u=t[1]}}catch(e){}return u};const versionFromReport=()=>{const e=s();if(e.header&&e.header.glibcVersionRuntime){return e.header.glibcVersionRuntime}return null};const versionSuffix=e=>e.trim().split(/\s+/)[1];const versionFromCommand=e=>{const[t,n,r]=e.split(/[\r\n]+/);if(t&&t.includes(p)){return versionSuffix(t)}if(n&&r&&n.includes(y)){return versionSuffix(r)}return null};const version=async()=>{let e=null;if(i()){e=await versionFromFilesystem();if(!e){e=versionFromReport()}if(!e){const t=await safeCommand();e=versionFromCommand(t)}}return e};const versionSync=()=>{let e=null;if(i()){e=versionFromFilesystemSync();if(!e){e=versionFromReport()}if(!e){const t=safeCommandSync();e=versionFromCommand(t)}}return e};e.exports={GLIBC:p,MUSL:y,family:family,familySync:familySync,isNonGlibcLinux:isNonGlibcLinux,isNonGlibcLinuxSync:isNonGlibcLinuxSync,version:version,versionSync:versionSync}},5941:function(e,t,n){"use strict";const r=n(9896);const i="/usr/bin/ldd";const readFileSync=e=>r.readFileSync(e,"utf-8");const readFile=e=>new Promise(((t,n)=>{r.readFile(e,"utf-8",((e,r)=>{if(e){n(e)}else{t(r)}}))}));e.exports={LDD_PATH:i,readFileSync:readFileSync,readFile:readFile}},7613:function(e){"use strict";const isLinux=()=>process.platform==="linux";let t=null;const getReport=()=>{if(!t){if(isLinux()&&process.report){const e=process.report.excludeNetwork;process.report.excludeNetwork=true;t=process.report.getReport();process.report.excludeNetwork=e}else{t={}}}return t};e.exports={isLinux:isLinux,getReport:getReport}},2871:function(e){"use strict";e.exports=(e,t)=>{t=t||process.argv;const n=e.startsWith("-")?"":e.length===1?"-":"--";const r=t.indexOf(n+e);const i=t.indexOf("--");return r!==-1&&(i===-1?true:r<i)}},5372:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(3175);const i=n(3288);const s=n(2460);const a=n(9335);class Command{constructor(e,t=[],n={},r){this.name=e;this.inTransaction=false;this.isResolved=false;this.transformed=false;this.replyEncoding=n.replyEncoding;this.errorStack=n.errorStack;this.args=t.flat();this.callback=r;this.initPromise();if(n.keyPrefix){const e=n.keyPrefix instanceof Buffer;let t=e?n.keyPrefix:null;this._iterateKeys((r=>{if(r instanceof Buffer){if(t===null){t=Buffer.from(n.keyPrefix)}return Buffer.concat([t,r])}else if(e){return Buffer.concat([n.keyPrefix,Buffer.from(String(r))])}return n.keyPrefix+r}))}if(n.readOnly){this.isReadOnly=true}}static checkFlag(e,t){return!!this.getFlagMap()[e][t]}static setArgumentTransformer(e,t){this._transformer.argument[e]=t}static setReplyTransformer(e,t){this._transformer.reply[e]=t}static getFlagMap(){if(!this.flagMap){this.flagMap=Object.keys(Command.FLAGS).reduce(((e,t)=>{e[t]={};Command.FLAGS[t].forEach((n=>{e[t][n]=true}));return e}),{})}return this.flagMap}getSlot(){if(typeof this.slot==="undefined"){const e=this.getKeys()[0];this.slot=e==null?null:i(e)}return this.slot}getKeys(){return this._iterateKeys()}toWritable(e){let t;const n="*"+(this.args.length+1)+"\r\n$"+Buffer.byteLength(this.name)+"\r\n"+this.name+"\r\n";if(this.bufferMode){const e=new MixedBuffers;e.push(n);for(let t=0;t<this.args.length;++t){const n=this.args[t];if(n instanceof Buffer){if(n.length===0){e.push("$0\r\n\r\n")}else{e.push("$"+n.length+"\r\n");e.push(n);e.push("\r\n")}}else{e.push("$"+Buffer.byteLength(n)+"\r\n"+n+"\r\n")}}t=e.toBuffer()}else{t=n;for(let e=0;e<this.args.length;++e){const n=this.args[e];t+="$"+Buffer.byteLength(n)+"\r\n"+n+"\r\n"}}return t}stringifyArguments(){for(let e=0;e<this.args.length;++e){const t=this.args[e];if(typeof t==="string"){}else if(t instanceof Buffer){this.bufferMode=true}else{this.args[e]=(0,a.toArg)(t)}}}transformReply(e){if(this.replyEncoding){e=(0,a.convertBufferToString)(e,this.replyEncoding)}const t=Command._transformer.reply[this.name];if(t){e=t(e)}return e}setTimeout(e){if(!this._commandTimeoutTimer){this._commandTimeoutTimer=setTimeout((()=>{if(!this.isResolved){this.reject(new Error("Command timed out"))}}),e)}}initPromise(){const e=new Promise(((e,t)=>{if(!this.transformed){this.transformed=true;const e=Command._transformer.argument[this.name];if(e){this.args=e(this.args)}this.stringifyArguments()}this.resolve=this._convertValue(e);if(this.errorStack){this.reject=e=>{t((0,a.optimizeErrorStack)(e,this.errorStack.stack,__dirname))}}else{this.reject=t}}));this.promise=(0,s.default)(e,this.callback)}_iterateKeys(e=e=>e){if(typeof this.keys==="undefined"){this.keys=[];if((0,r.exists)(this.name)){const t=(0,r.getKeyIndexes)(this.name,this.args);for(const n of t){this.args[n]=e(this.args[n]);this.keys.push(this.args[n])}}}return this.keys}_convertValue(e){return t=>{try{const n=this._commandTimeoutTimer;if(n){clearTimeout(n);delete this._commandTimeoutTimer}e(this.transformReply(t));this.isResolved=true}catch(e){this.reject(e)}return this.promise}}}t["default"]=Command;Command.FLAGS={VALID_IN_SUBSCRIBER_MODE:["subscribe","psubscribe","unsubscribe","punsubscribe","ssubscribe","sunsubscribe","ping","quit"],VALID_IN_MONITOR_MODE:["monitor","auth"],ENTER_SUBSCRIBER_MODE:["subscribe","psubscribe","ssubscribe"],EXIT_SUBSCRIBER_MODE:["unsubscribe","punsubscribe","sunsubscribe"],WILL_DISCONNECT:["quit"]};Command._transformer={argument:{},reply:{}};const msetArgumentTransformer=function(e){if(e.length===1){if(e[0]instanceof Map){return(0,a.convertMapToArray)(e[0])}if(typeof e[0]==="object"&&e[0]!==null){return(0,a.convertObjectToArray)(e[0])}}return e};const hsetArgumentTransformer=function(e){if(e.length===2){if(e[1]instanceof Map){return[e[0]].concat((0,a.convertMapToArray)(e[1]))}if(typeof e[1]==="object"&&e[1]!==null){return[e[0]].concat((0,a.convertObjectToArray)(e[1]))}}return e};Command.setArgumentTransformer("mset",msetArgumentTransformer);Command.setArgumentTransformer("msetnx",msetArgumentTransformer);Command.setArgumentTransformer("hset",hsetArgumentTransformer);Command.setArgumentTransformer("hmset",hsetArgumentTransformer);Command.setReplyTransformer("hgetall",(function(e){if(Array.isArray(e)){const t={};for(let n=0;n<e.length;n+=2){const r=e[n];const i=e[n+1];if(r in t){Object.defineProperty(t,r,{value:i,configurable:true,enumerable:true,writable:true})}else{t[r]=i}}return t}return e}));class MixedBuffers{constructor(){this.length=0;this.items=[]}push(e){this.length+=Buffer.byteLength(e);this.items.push(e)}toBuffer(){const e=Buffer.allocUnsafe(this.length);let t=0;for(const n of this.items){const r=Buffer.byteLength(n);Buffer.isBuffer(n)?n.copy(e,t):e.write(n,t,r);t+=r}return e}}},2161:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(5372);const i=n(9335);const s=n(9751);const a=n(5954);const o=(0,i.Debug)("dataHandler");class DataHandler{constructor(e,t){this.redis=e;const n=new s({stringNumbers:t.stringNumbers,returnBuffers:true,returnError:e=>{this.returnError(e)},returnFatalError:e=>{this.returnFatalError(e)},returnReply:e=>{this.returnReply(e)}});e.stream.prependListener("data",(e=>{n.execute(e)}));e.stream.resume()}returnFatalError(e){e.message+=". Please report this.";this.redis.recoverFromFatalError(e,e,{offlineQueue:false})}returnError(e){const t=this.shiftCommand(e);if(!t){return}e.command={name:t.command.name,args:t.command.args};this.redis.handleReconnection(e,t)}returnReply(e){if(this.handleMonitorReply(e)){return}if(this.handleSubscriberReply(e)){return}const t=this.shiftCommand(e);if(!t){return}if(r.default.checkFlag("ENTER_SUBSCRIBER_MODE",t.command.name)){this.redis.condition.subscriber=new a.default;this.redis.condition.subscriber.add(t.command.name,e[1].toString());if(!fillSubCommand(t.command,e[2])){this.redis.commandQueue.unshift(t)}}else if(r.default.checkFlag("EXIT_SUBSCRIBER_MODE",t.command.name)){if(!fillUnsubCommand(t.command,e[2])){this.redis.commandQueue.unshift(t)}}else{t.command.resolve(e)}}handleSubscriberReply(e){if(!this.redis.condition.subscriber){return false}const t=Array.isArray(e)?e[0].toString():null;o('receive reply "%s" in subscriber mode',t);switch(t){case"message":if(this.redis.listeners("message").length>0){this.redis.emit("message",e[1].toString(),e[2]?e[2].toString():"")}this.redis.emit("messageBuffer",e[1],e[2]);break;case"pmessage":{const t=e[1].toString();if(this.redis.listeners("pmessage").length>0){this.redis.emit("pmessage",t,e[2].toString(),e[3].toString())}this.redis.emit("pmessageBuffer",t,e[2],e[3]);break}case"smessage":{if(this.redis.listeners("smessage").length>0){this.redis.emit("smessage",e[1].toString(),e[2]?e[2].toString():"")}this.redis.emit("smessageBuffer",e[1],e[2]);break}case"ssubscribe":case"subscribe":case"psubscribe":{const n=e[1].toString();this.redis.condition.subscriber.add(t,n);const r=this.shiftCommand(e);if(!r){return}if(!fillSubCommand(r.command,e[2])){this.redis.commandQueue.unshift(r)}break}case"sunsubscribe":case"unsubscribe":case"punsubscribe":{const n=e[1]?e[1].toString():null;if(n){this.redis.condition.subscriber.del(t,n)}const r=e[2];if(Number(r)===0){this.redis.condition.subscriber=false}const i=this.shiftCommand(e);if(!i){return}if(!fillUnsubCommand(i.command,r)){this.redis.commandQueue.unshift(i)}break}default:{const t=this.shiftCommand(e);if(!t){return}t.command.resolve(e)}}return true}handleMonitorReply(e){if(this.redis.status!=="monitoring"){return false}const t=e.toString();if(t==="OK"){return false}const n=t.indexOf(" ");const r=t.slice(0,n);const i=t.indexOf('"');const s=t.slice(i+1,-1).split('" "').map((e=>e.replace(/\\"/g,'"')));const a=t.slice(n+2,i-2).split(" ");this.redis.emit("monitor",r,s,a[1],a[0]);return true}shiftCommand(e){const t=this.redis.commandQueue.shift();if(!t){const t="Command queue state error. If you can reproduce this, please report it.";const n=new Error(t+(e instanceof Error?` Last error: ${e.message}`:` Last reply: ${e.toString()}`));this.redis.emit("error",n);return null}return t}}t["default"]=DataHandler;const l=new WeakMap;function fillSubCommand(e,t){let n=l.has(e)?l.get(e):e.args.length;n-=1;if(n<=0){e.resolve(t);l.delete(e);return true}l.set(e,n);return false}function fillUnsubCommand(e,t){let n=l.has(e)?l.get(e):e.args.length;if(n===0){if(Number(t)===0){l.delete(e);e.resolve(t);return true}return false}n-=1;if(n<=0){e.resolve(t);return true}l.set(e,n);return false}},8823:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(3288);const i=n(3175);const s=n(2460);const a=n(9023);const o=n(5372);const l=n(9335);const c=n(4489);function generateMultiWithNodes(e,t){const n=r(t[0]);const i=e._groupsBySlot[n];for(let n=1;n<t.length;n++){if(e._groupsBySlot[r(t[n])]!==i){return-1}}return n}class Pipeline extends c.default{constructor(e){super();this.redis=e;this.isPipeline=true;this.replyPending=0;this._queue=[];this._result=[];this._transactions=0;this._shaToScript={};this.isCluster=this.redis.constructor.name==="Cluster"||this.redis.isCluster;this.options=e.options;Object.keys(e.scriptsSet).forEach((t=>{const n=e.scriptsSet[t];this._shaToScript[n.sha]=n;this[t]=e[t];this[t+"Buffer"]=e[t+"Buffer"]}));e.addedBuiltinSet.forEach((t=>{this[t]=e[t];this[t+"Buffer"]=e[t+"Buffer"]}));this.promise=new Promise(((e,t)=>{this.resolve=e;this.reject=t}));const t=this;Object.defineProperty(this,"length",{get:function(){return t._queue.length}})}fillResult(e,t){if(this._queue[t].name==="exec"&&Array.isArray(e[1])){const n=e[1].length;for(let r=0;r<n;r++){if(e[1][r]instanceof Error){continue}const i=this._queue[t-(n-r)];try{e[1][r]=i.transformReply(e[1][r])}catch(t){e[1][r]=t}}}this._result[t]=e;if(--this.replyPending){return}if(this.isCluster){let e=true;let t;for(let n=0;n<this._result.length;++n){const r=this._result[n][0];const s=this._queue[n];if(r){if(s.name==="exec"&&r.message==="EXECABORT Transaction discarded because of previous errors."){continue}if(!t){t={name:r.name,message:r.message}}else if(t.name!==r.name||t.message!==r.message){e=false;break}}else if(!s.inTransaction){const t=(0,i.exists)(s.name)&&(0,i.hasFlag)(s.name,"readonly");if(!t){e=false;break}}}if(t&&e){const e=this;const n=t.message.split(" ");const r=this._queue;let i=false;this._queue=[];for(let e=0;e<r.length;++e){if(n[0]==="ASK"&&!i&&r[e].name!=="asking"&&(!r[e-1]||r[e-1].name!=="asking")){const e=new o.default("asking");e.ignore=true;this.sendCommand(e)}r[e].initPromise();this.sendCommand(r[e]);i=r[e].inTransaction}let s=true;if(typeof this.leftRedirections==="undefined"){this.leftRedirections={}}const exec=function(){e.exec()};const a=this.redis;a.handleError(t,this.leftRedirections,{moved:function(t,r){e.preferKey=r;a.slots[n[1]]=[r];a._groupsBySlot[n[1]]=a._groupsIds[a.slots[n[1]].join(";")];a.refreshSlotsCache();e.exec()},ask:function(t,n){e.preferKey=n;e.exec()},tryagain:exec,clusterDown:exec,connectionClosed:exec,maxRedirections:()=>{s=false},defaults:()=>{s=false}});if(s){return}}}let n=0;for(let e=0;e<this._queue.length-n;++e){if(this._queue[e+n].ignore){n+=1}this._result[e]=this._result[e+n]}this.resolve(this._result.slice(0,this._result.length-n))}sendCommand(e){if(this._transactions>0){e.inTransaction=true}const t=this._queue.length;e.pipelineIndex=t;e.promise.then((e=>{this.fillResult([null,e],t)})).catch((e=>{this.fillResult([e],t)}));this._queue.push(e);return this}addBatch(e){let t,n,r;for(let i=0;i<e.length;++i){t=e[i];n=t[0];r=t.slice(1);this[n].apply(this,r)}return this}}t["default"]=Pipeline;const u=Pipeline.prototype.multi;Pipeline.prototype.multi=function(){this._transactions+=1;return u.apply(this,arguments)};const d=Pipeline.prototype.execBuffer;Pipeline.prototype.execBuffer=(0,a.deprecate)((function(){if(this._transactions>0){this._transactions-=1}return d.apply(this,arguments)}),"Pipeline#execBuffer: Use Pipeline#exec instead");Pipeline.prototype.exec=function(e){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(l.noop);if(e&&!this.nodeifiedPromise){this.nodeifiedPromise=true;(0,s.default)(this.promise,e)}this.redis.delayUntilReady((t=>{if(t){this.reject(t);return}this.exec(e)}));return this.promise}if(this._transactions>0){this._transactions-=1;return d.apply(this,arguments)}if(!this.nodeifiedPromise){this.nodeifiedPromise=true;(0,s.default)(this.promise,e)}if(!this._queue.length){this.resolve([])}let t;if(this.isCluster){const e=[];for(let t=0;t<this._queue.length;t++){const n=this._queue[t].getKeys();if(n.length){e.push(n[0])}if(n.length&&r.generateMulti(n)<0){this.reject(new Error("All the keys in a pipeline command should belong to the same slot"));return this.promise}}if(e.length){t=generateMultiWithNodes(this.redis,e);if(t<0){this.reject(new Error("All keys in the pipeline should belong to the same slots allocation group"));return this.promise}}else{t=Math.random()*16384|0}}const n=this;execPipeline();return this.promise;function execPipeline(){let e=n.replyPending=n._queue.length;let r;if(n.isCluster){r={slot:t,redis:n.redis.connectionPool.nodes.all[n.preferKey]}}let i="";let s;const a={isPipeline:true,destination:n.isCluster?r:{redis:n.redis},write(t){if(typeof t!=="string"){if(!s){s=[]}if(i){s.push(Buffer.from(i,"utf8"));i=""}s.push(t)}else{i+=t}if(! --e){if(s){if(i){s.push(Buffer.from(i,"utf8"))}a.destination.redis.stream.write(Buffer.concat(s))}else{a.destination.redis.stream.write(i)}e=n._queue.length;i="";s=undefined}}};for(let e=0;e<n._queue.length;++e){n.redis.sendCommand(n._queue[e],a,r)}return n.promise}}},6942:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(3175);const i=n(4434);const s=n(2460);const a=n(1352);const o=n(5372);const l=n(5850);const c=n(1766);const u=n(7778);const d=n(4542);const f=n(1432);const p=n(1101);const h=n(9335);const y=n(9066);const m=n(4489);const b=n(150);const g=n(9611);const v=(0,h.Debug)("redis");class Redis extends m.default{constructor(e,t,n){super();this.status="wait";this.isCluster=false;this.reconnectTimeout=null;this.connectionEpoch=0;this.retryAttempts=0;this.manuallyClosing=false;this._autoPipelines=new Map;this._runningAutoPipelines=new Set;this.parseOptions(e,t,n);i.EventEmitter.call(this);this.resetCommandQueue();this.resetOfflineQueue();if(this.options.Connector){this.connector=new this.options.Connector(this.options)}else if(this.options.sentinels){const e=new c.default(this.options);e.emitter=this;this.connector=e}else{this.connector=new l.StandaloneConnector(this.options)}if(this.options.scripts){Object.entries(this.options.scripts).forEach((([e,t])=>{this.defineCommand(e,t)}))}if(this.options.lazyConnect){this.setStatus("wait")}else{this.connect().catch(b.noop)}}static createClient(...e){return new Redis(...e)}get autoPipelineQueueSize(){let e=0;for(const t of this._autoPipelines.values()){e+=t.length}return e}connect(e){const t=new Promise(((e,t)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){t(new Error("Redis is already connecting/connected"));return}this.connectionEpoch+=1;this.setStatus("connecting");const{options:n}=this;this.condition={select:n.db,auth:n.username?[n.username,n.password]:n.password,subscriber:false};const r=this;(0,s.default)(this.connector.connect((function(e,t){r.silentEmit(e,t)})),(function(i,s){if(i){r.flushQueue(i);r.silentEmit("error",i);t(i);r.setStatus("end");return}let a=n.tls?"secureConnect":"connect";if("sentinels"in n&&n.sentinels&&!n.enableTLSForSentinelMode){a="connect"}r.stream=s;if(n.noDelay){s.setNoDelay(true)}if(typeof n.keepAlive==="number"){if(s.connecting){s.once(a,(()=>{s.setKeepAlive(true,n.keepAlive)}))}else{s.setKeepAlive(true,n.keepAlive)}}if(s.connecting){s.once(a,u.connectHandler(r));if(n.connectTimeout){let e=false;s.setTimeout(n.connectTimeout,(function(){if(e){return}s.setTimeout(0);s.destroy();const t=new Error("connect ETIMEDOUT");t.errorno="ETIMEDOUT";t.code="ETIMEDOUT";t.syscall="connect";u.errorHandler(r)(t)}));s.once(a,(function(){e=true;s.setTimeout(0)}))}}else if(s.destroyed){const e=r.connector.firstError;if(e){process.nextTick((()=>{u.errorHandler(r)(e)}))}process.nextTick(u.closeHandler(r))}else{process.nextTick(u.connectHandler(r))}if(!s.destroyed){s.once("error",u.errorHandler(r));s.once("close",u.closeHandler(r))}const connectionReadyHandler=function(){r.removeListener("close",connectionCloseHandler);e()};var connectionCloseHandler=function(){r.removeListener("ready",connectionReadyHandler);t(new Error(h.CONNECTION_CLOSED_ERROR_MSG))};r.once("ready",connectionReadyHandler);r.once("close",connectionCloseHandler)}))}));return(0,s.default)(t,e)}disconnect(e=false){if(!e){this.manuallyClosing=true}if(this.reconnectTimeout&&!e){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=null}if(this.status==="wait"){u.closeHandler(this)()}else{this.connector.disconnect()}}end(){this.disconnect()}duplicate(e){return new Redis({...this.options,...e})}get mode(){var e;return this.options.monitor?"monitor":((e=this.condition)===null||e===void 0?void 0:e.subscriber)?"subscriber":"normal"}monitor(e){const t=this.duplicate({monitor:true,lazyConnect:false});return(0,s.default)(new Promise((function(e,n){t.once("error",n);t.once("monitoring",(function(){e(t)}))})),e)}sendCommand(e,t){var n,i;if(this.status==="wait"){this.connect().catch(b.noop)}if(this.status==="end"){e.reject(new Error(h.CONNECTION_CLOSED_ERROR_MSG));return e.promise}if(((n=this.condition)===null||n===void 0?void 0:n.subscriber)&&!o.default.checkFlag("VALID_IN_SUBSCRIBER_MODE",e.name)){e.reject(new Error("Connection in subscriber mode, only subscriber commands may be used"));return e.promise}if(typeof this.options.commandTimeout==="number"){e.setTimeout(this.options.commandTimeout)}let s=this.status==="ready"||!t&&this.status==="connect"&&(0,r.exists)(e.name)&&(0,r.hasFlag)(e.name,"loading");if(!this.stream){s=false}else if(!this.stream.writable){s=false}else if(this.stream._writableState&&this.stream._writableState.ended){s=false}if(!s){if(!this.options.enableOfflineQueue){e.reject(new Error("Stream isn't writeable and enableOfflineQueue options is false"));return e.promise}if(e.name==="quit"&&this.offlineQueue.length===0){this.disconnect();e.resolve(Buffer.from("OK"));return e.promise}if(v.enabled){v("queue command[%s]: %d -> %s(%o)",this._getDescription(),this.condition.select,e.name,e.args)}this.offlineQueue.push({command:e,stream:t,select:this.condition.select})}else{if(v.enabled){v("write command[%s]: %d -> %s(%o)",this._getDescription(),(i=this.condition)===null||i===void 0?void 0:i.select,e.name,e.args)}if(t){if("isPipeline"in t&&t.isPipeline){t.write(e.toWritable(t.destination.redis.stream))}else{t.write(e.toWritable(t))}}else{this.stream.write(e.toWritable(this.stream))}this.commandQueue.push({command:e,stream:t,select:this.condition.select});if(o.default.checkFlag("WILL_DISCONNECT",e.name)){this.manuallyClosing=true}if(this.options.socketTimeout!==undefined&&this.socketTimeoutTimer===undefined){this.setSocketTimeout()}}if(e.name==="select"&&(0,h.isInt)(e.args[0])){const t=parseInt(e.args[0],10);if(this.condition.select!==t){this.condition.select=t;this.emit("select",t);v("switch to db [%d]",this.condition.select)}}return e.promise}setSocketTimeout(){this.socketTimeoutTimer=setTimeout((()=>{this.stream.destroy(new Error(`Socket timeout. Expecting data, but didn't receive any in ${this.options.socketTimeout}ms.`));this.socketTimeoutTimer=undefined}),this.options.socketTimeout);this.stream.once("data",(()=>{clearTimeout(this.socketTimeoutTimer);this.socketTimeoutTimer=undefined;if(this.commandQueue.length===0)return;this.setSocketTimeout()}))}scanStream(e){return this.createScanStream("scan",{options:e})}scanBufferStream(e){return this.createScanStream("scanBuffer",{options:e})}sscanStream(e,t){return this.createScanStream("sscan",{key:e,options:t})}sscanBufferStream(e,t){return this.createScanStream("sscanBuffer",{key:e,options:t})}hscanStream(e,t){return this.createScanStream("hscan",{key:e,options:t})}hscanBufferStream(e,t){return this.createScanStream("hscanBuffer",{key:e,options:t})}zscanStream(e,t){return this.createScanStream("zscan",{key:e,options:t})}zscanBufferStream(e,t){return this.createScanStream("zscanBuffer",{key:e,options:t})}silentEmit(e,t){let n;if(e==="error"){n=t;if(this.status==="end"){return}if(this.manuallyClosing){if(n instanceof Error&&(n.message===h.CONNECTION_CLOSED_ERROR_MSG||n.syscall==="connect"||n.syscall==="read")){return}}}if(this.listeners(e).length>0){return this.emit.apply(this,arguments)}if(n&&n instanceof Error){console.error("[ioredis] Unhandled error event:",n.stack)}return false}recoverFromFatalError(e,t,n){this.flushQueue(t,n);this.silentEmit("error",t);this.disconnect(true)}handleReconnection(e,t){var n;let r=false;if(this.options.reconnectOnError){r=this.options.reconnectOnError(e)}switch(r){case 1:case true:if(this.status!=="reconnecting"){this.disconnect(true)}t.command.reject(e);break;case 2:if(this.status!=="reconnecting"){this.disconnect(true)}if(((n=this.condition)===null||n===void 0?void 0:n.select)!==t.select&&t.command.name!=="select"){this.select(t.select)}this.sendCommand(t.command);break;default:t.command.reject(e)}}_getDescription(){let e;if("path"in this.options&&this.options.path){e=this.options.path}else if(this.stream&&this.stream.remoteAddress&&this.stream.remotePort){e=this.stream.remoteAddress+":"+this.stream.remotePort}else if("host"in this.options&&this.options.host){e=this.options.host+":"+this.options.port}else{e=""}if(this.options.connectionName){e+=` (${this.options.connectionName})`}return e}resetCommandQueue(){this.commandQueue=new g}resetOfflineQueue(){this.offlineQueue=new g}parseOptions(...e){const t={};let n=false;for(let r=0;r<e.length;++r){const i=e[r];if(i===null||typeof i==="undefined"){continue}if(typeof i==="object"){(0,b.defaults)(t,i)}else if(typeof i==="string"){(0,b.defaults)(t,(0,h.parseURL)(i));if(i.startsWith("rediss://")){n=true}}else if(typeof i==="number"){t.port=i}else{throw new Error("Invalid argument "+i)}}if(n){(0,b.defaults)(t,{tls:true})}(0,b.defaults)(t,Redis.defaultOptions);if(typeof t.port==="string"){t.port=parseInt(t.port,10)}if(typeof t.db==="string"){t.db=parseInt(t.db,10)}this.options=(0,h.resolveTLSProfile)(t)}setStatus(e,t){if(v.enabled){v("status[%s]: %s -> %s",this._getDescription(),this.status||"[empty]",e)}this.status=e;process.nextTick(this.emit.bind(this,e,t))}createScanStream(e,{key:t,options:n={}}){return new f.default({objectMode:true,key:t,redis:this,command:e,...n})}flushQueue(e,t){t=(0,b.defaults)({},t,{offlineQueue:true,commandQueue:true});let n;if(t.offlineQueue){while(n=this.offlineQueue.shift()){n.command.reject(e)}}if(t.commandQueue){if(this.commandQueue.length>0){if(this.stream){this.stream.removeAllListeners("data")}while(n=this.commandQueue.shift()){n.command.reject(e)}}}}_readyCheck(e){const t=this;this.info((function(n,r){if(n){if(n.message&&n.message.includes("NOPERM")){console.warn(`Skipping the ready check because INFO command fails: "${n.message}". You can disable ready check with "enableReadyCheck". More: https://github.com/luin/ioredis/wiki/Disable-ready-check.`);return e(null,{})}return e(n)}if(typeof r!=="string"){return e(null,r)}const i={};const s=r.split("\r\n");for(let e=0;e<s.length;++e){const[t,...n]=s[e].split(":");const r=n.join(":");if(r){i[t]=r}}if(!i.loading||i.loading==="0"){e(null,i)}else{const n=(i.loading_eta_seconds||1)*1e3;const r=t.options.maxLoadingRetryTime&&t.options.maxLoadingRetryTime<n?t.options.maxLoadingRetryTime:n;v("Redis server still loading, trying again in "+r+"ms");setTimeout((function(){t._readyCheck(e)}),r)}})).catch(b.noop)}}Redis.Cluster=a.default;Redis.Command=o.default;Redis.defaultOptions=d.DEFAULT_REDIS_OPTIONS;(0,y.default)(Redis,i.EventEmitter);(0,p.addTransactionSupport)(Redis.prototype);t["default"]=Redis},1432:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(2203);class ScanStream extends r.Readable{constructor(e){super(e);this.opt=e;this._redisCursor="0";this._redisDrained=false}_read(){if(this._redisDrained){this.push(null);return}const e=[this._redisCursor];if(this.opt.key){e.unshift(this.opt.key)}if(this.opt.match){e.push("MATCH",this.opt.match)}if(this.opt.type){e.push("TYPE",this.opt.type)}if(this.opt.count){e.push("COUNT",String(this.opt.count))}if(this.opt.noValues){e.push("NOVALUES")}this.opt.redis[this.opt.command](e,((e,t)=>{if(e){this.emit("error",e);return}this._redisCursor=t[0]instanceof Buffer?t[0].toString():t[0];if(this._redisCursor==="0"){this._redisDrained=true}this.push(t[1])}))}close(){this._redisDrained=true}}t["default"]=ScanStream},7334:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(6982);const i=n(5372);const s=n(2460);class Script{constructor(e,t=null,n="",s=false){this.lua=e;this.numberOfKeys=t;this.keyPrefix=n;this.readOnly=s;this.sha=(0,r.createHash)("sha1").update(e).digest("hex");const a=this.sha;const o=new WeakSet;this.Command=class CustomScriptCommand extends i.default{toWritable(t){const n=this.reject;this.reject=e=>{if(e.message.indexOf("NOSCRIPT")!==-1){o.delete(t)}n.call(this,e)};if(!o.has(t)){o.add(t);this.name="eval";this.args[0]=e}else if(this.name==="eval"){this.name="evalsha";this.args[0]=a}return super.toWritable(t)}}}execute(e,t,n,r){if(typeof this.numberOfKeys==="number"){t.unshift(this.numberOfKeys)}if(this.keyPrefix){n.keyPrefix=this.keyPrefix}if(this.readOnly){n.readOnly=true}const i=new this.Command("evalsha",[this.sha,...t],n);i.promise=i.promise.catch((r=>{if(r.message.indexOf("NOSCRIPT")===-1){throw r}const i=new this.Command("evalsha",[this.sha,...t],n);const s=e.isPipeline?e.redis:e;return s.sendCommand(i)}));(0,s.default)(i.promise,r);return e.sendCommand(i)}}t["default"]=Script},5954:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});class SubscriptionSet{constructor(){this.set={subscribe:{},psubscribe:{},ssubscribe:{}}}add(e,t){this.set[mapSet(e)][t]=true}del(e,t){delete this.set[mapSet(e)][t]}channels(e){return Object.keys(this.set[mapSet(e)])}isEmpty(){return this.channels("subscribe").length===0&&this.channels("psubscribe").length===0&&this.channels("ssubscribe").length===0}}t["default"]=SubscriptionSet;function mapSet(e){if(e==="unsubscribe"){return"subscribe"}if(e==="punsubscribe"){return"psubscribe"}if(e==="sunsubscribe"){return"ssubscribe"}return e}},407:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.executeWithAutoPipelining=t.getFirstValueInFlattenedArray=t.shouldUseAutoPipelining=t.notAllowedAutoPipelineCommands=t.kCallbacks=t.kExec=void 0;const r=n(150);const i=n(3288);const s=n(2460);t.kExec=Symbol("exec");t.kCallbacks=Symbol("callbacks");t.notAllowedAutoPipelineCommands=["auth","info","script","quit","cluster","pipeline","multi","subscribe","psubscribe","unsubscribe","unpsubscribe","select"];function executeAutoPipeline(e,n){if(e._runningAutoPipelines.has(n)){return}if(!e._autoPipelines.has(n)){return}e._runningAutoPipelines.add(n);const r=e._autoPipelines.get(n);e._autoPipelines.delete(n);const i=r[t.kCallbacks];r[t.kCallbacks]=null;r.exec((function(t,r){e._runningAutoPipelines.delete(n);if(t){for(let e=0;e<i.length;e++){process.nextTick(i[e],t)}}else{for(let e=0;e<i.length;e++){process.nextTick(i[e],...r[e])}}if(e._autoPipelines.has(n)){executeAutoPipeline(e,n)}}))}function shouldUseAutoPipelining(e,n,r){return n&&e.options.enableAutoPipelining&&!e.isPipeline&&!t.notAllowedAutoPipelineCommands.includes(r)&&!e.options.autoPipeliningIgnoredCommands.includes(r)}t.shouldUseAutoPipelining=shouldUseAutoPipelining;function getFirstValueInFlattenedArray(e){for(let t=0;t<e.length;t++){const n=e[t];if(typeof n==="string"){return n}else if(Array.isArray(n)||(0,r.isArguments)(n)){if(n.length===0){continue}return n[0]}const i=[n].flat();if(i.length>0){return i[0]}}return undefined}t.getFirstValueInFlattenedArray=getFirstValueInFlattenedArray;function executeWithAutoPipelining(e,n,a,o,l){if(e.isCluster&&!e.slots.length){if(e.status==="wait")e.connect().catch(r.noop);return(0,s.default)(new Promise((function(t,r){e.delayUntilReady((i=>{if(i){r(i);return}executeWithAutoPipelining(e,n,a,o,null).then(t,r)}))})),l)}const c=e.options.keyPrefix||"";const u=e.isCluster?e.slots[i(`${c}${getFirstValueInFlattenedArray(o)}`)].join(","):"main";if(!e._autoPipelines.has(u)){const n=e.pipeline();n[t.kExec]=false;n[t.kCallbacks]=[];e._autoPipelines.set(u,n)}const d=e._autoPipelines.get(u);if(!d[t.kExec]){d[t.kExec]=true;setImmediate(executeAutoPipeline,e,u)}const f=new Promise((function(e,r){d[t.kCallbacks].push((function(t,n){if(t){r(t);return}e(n)}));if(n==="call"){o.unshift(a)}d[n](...o)}));return(0,s.default)(f,l)}t.executeWithAutoPipelining=executeWithAutoPipelining},9670:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.DEFAULT_CLUSTER_OPTIONS=void 0;const r=n(2250);t.DEFAULT_CLUSTER_OPTIONS={clusterRetryStrategy:e=>Math.min(100+e*2,2e3),enableOfflineQueue:true,enableReadyCheck:true,scaleReads:"master",maxRedirections:16,retryDelayOnMoved:0,retryDelayOnFailover:100,retryDelayOnClusterDown:100,retryDelayOnTryAgain:100,slotsRefreshTimeout:1e3,useSRVRecords:false,resolveSrv:r.resolveSrv,dnsLookup:r.lookup,enableAutoPipelining:false,autoPipeliningIgnoredCommands:[],shardedSubscribers:false}},6272:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(722);const i=n(9335);const s=n(6942);const a=(0,i.Debug)("cluster:subscriber");class ClusterSubscriber{constructor(e,t,n=false){this.connectionPool=e;this.emitter=t;this.isSharded=n;this.started=false;this.subscriber=null;this.slotRange=[];this.onSubscriberEnd=()=>{if(!this.started){a("subscriber has disconnected, but ClusterSubscriber is not started, so not reconnecting.");return}a("subscriber has disconnected, selecting a new one...");this.selectSubscriber()};this.connectionPool.on("-node",((e,t)=>{if(!this.started||!this.subscriber){return}if((0,r.getNodeKey)(this.subscriber.options)===t){a("subscriber has left, selecting a new one...");this.selectSubscriber()}}));this.connectionPool.on("+node",(()=>{if(!this.started||this.subscriber){return}a("a new node is discovered and there is no subscriber, selecting a new one...");this.selectSubscriber()}))}getInstance(){return this.subscriber}associateSlotRange(e){if(this.isSharded){this.slotRange=e}return this.slotRange}start(){this.started=true;this.selectSubscriber();a("started")}stop(){this.started=false;if(this.subscriber){this.subscriber.disconnect();this.subscriber=null}}isStarted(){return this.started}selectSubscriber(){const e=this.lastActiveSubscriber;if(e){e.off("end",this.onSubscriberEnd);e.disconnect()}if(this.subscriber){this.subscriber.off("end",this.onSubscriberEnd);this.subscriber.disconnect()}const t=(0,i.sample)(this.connectionPool.getNodes());if(!t){a("selecting subscriber failed since there is no node discovered in the cluster yet");this.subscriber=null;return}const{options:n}=t;a("selected a subscriber %s:%s",n.host,n.port);let o="subscriber";if(this.isSharded)o="ssubscriber";this.subscriber=new s.default({port:n.port,host:n.host,username:n.username,password:n.password,enableReadyCheck:true,connectionName:(0,r.getConnectionName)(o,n.connectionName),lazyConnect:true,tls:n.tls,retryStrategy:null});this.subscriber.on("error",i.noop);this.subscriber.once("end",this.onSubscriberEnd);const l={subscribe:[],psubscribe:[],ssubscribe:[]};if(e){const t=e.condition||e.prevCondition;if(t&&t.subscriber){l.subscribe=t.subscriber.channels("subscribe");l.psubscribe=t.subscriber.channels("psubscribe");l.ssubscribe=t.subscriber.channels("ssubscribe")}}if(l.subscribe.length||l.psubscribe.length||l.ssubscribe.length){let e=0;for(const t of["subscribe","psubscribe","ssubscribe"]){const n=l[t];if(n.length){e+=1;a("%s %d channels",t,n.length);this.subscriber[t](n).then((()=>{if(! --e){this.lastActiveSubscriber=this.subscriber}})).catch((()=>{a("failed to %s %d channels",t,n.length)}))}}}else{this.lastActiveSubscriber=this.subscriber}for(const e of["message","messageBuffer"]){this.subscriber.on(e,((t,n)=>{this.emitter.emit(e,t,n)}))}for(const e of["pmessage","pmessageBuffer"]){this.subscriber.on(e,((t,n,r)=>{this.emitter.emit(e,t,n,r)}))}if(this.isSharded==true){for(const e of["smessage","smessageBuffer"]){this.subscriber.on(e,((t,n)=>{this.emitter.emit(e,t,n)}))}}}}t["default"]=ClusterSubscriber},9733:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(9335);const i=n(6272);const s=n(5860);const a=n(722);const o=n(3288);const l=(0,r.Debug)("cluster:subscriberGroup");class ClusterSubscriberGroup{constructor(e){this.cluster=e;this.shardedSubscribers=new Map;this.clusterSlots=[];this.subscriberToSlotsIndex=new Map;this.channels=new Map;e.on("+node",(e=>{this._addSubscriber(e)}));e.on("-node",(e=>{this._removeSubscriber(e)}));e.on("refresh",(()=>{this._refreshSlots(e)}))}getResponsibleSubscriber(e){const t=this.clusterSlots[e][0];return this.shardedSubscribers.get(t)}addChannels(e){const t=o(e[0]);e.forEach((e=>{if(o(e)!=t)return-1}));const n=this.channels.get(t);if(!n){this.channels.set(t,e)}else{this.channels.set(t,n.concat(e))}return[...this.channels.values()].flatMap((e=>e)).length}removeChannels(e){const t=o(e[0]);e.forEach((e=>{if(o(e)!=t)return-1}));const n=this.channels.get(t);if(n){const r=n.filter((t=>!e.includes(t)));this.channels.set(t,r)}return[...this.channels.values()].flatMap((e=>e)).length}stop(){for(const e of this.shardedSubscribers.values()){e.stop()}}start(){for(const e of this.shardedSubscribers.values()){if(!e.isStarted()){e.start()}}}_addSubscriber(e){const t=new s.default(e.options);if(t.addMasterNode(e)){const n=new i.default(t,this.cluster,true);const r=(0,a.getNodeKey)(e.options);this.shardedSubscribers.set(r,n);n.start();this._resubscribe();this.cluster.emit("+subscriber");return n}return null}_removeSubscriber(e){const t=(0,a.getNodeKey)(e.options);const n=this.shardedSubscribers.get(t);if(n){n.stop();this.shardedSubscribers.delete(t);this._resubscribe();this.cluster.emit("-subscriber")}return this.shardedSubscribers}_refreshSlots(e){if(this._slotsAreEqual(e.slots)){l("Nothing to refresh because the new cluster map is equal to the previous one.")}else{l("Refreshing the slots of the subscriber group.");this.subscriberToSlotsIndex=new Map;for(let t=0;t<e.slots.length;t++){const n=e.slots[t][0];if(!this.subscriberToSlotsIndex.has(n)){this.subscriberToSlotsIndex.set(n,[])}this.subscriberToSlotsIndex.get(n).push(Number(t))}this._resubscribe();this.clusterSlots=JSON.parse(JSON.stringify(e.slots));this.cluster.emit("subscribersReady");return true}return false}_resubscribe(){if(this.shardedSubscribers){this.shardedSubscribers.forEach(((e,t)=>{const n=this.subscriberToSlotsIndex.get(t);if(n){e.associateSlotRange(n);n.forEach((t=>{const n=e.getInstance();const r=this.channels.get(t);if(r&&r.length>0){if(n){n.ssubscribe(r);n.on("ready",(()=>{n.ssubscribe(r)}))}}}))}}))}}_slotsAreEqual(e){if(this.clusterSlots===undefined)return false;else return JSON.stringify(this.clusterSlots)===JSON.stringify(e)}}t["default"]=ClusterSubscriberGroup},5860:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(4434);const i=n(9335);const s=n(722);const a=n(6942);const o=(0,i.Debug)("cluster:connectionPool");class ConnectionPool extends r.EventEmitter{constructor(e){super();this.redisOptions=e;this.nodes={all:{},master:{},slave:{}};this.specifiedOptions={}}getNodes(e="all"){const t=this.nodes[e];return Object.keys(t).map((e=>t[e]))}getInstanceByKey(e){return this.nodes.all[e]}getSampleInstance(e){const t=Object.keys(this.nodes[e]);const n=(0,i.sample)(t);return this.nodes[e][n]}addMasterNode(e){const t=(0,s.getNodeKey)(e.options);const n=this.createRedisFromOptions(e,e.options.readOnly);if(!e.options.readOnly){this.nodes.all[t]=n;this.nodes.master[t]=n;return true}return false}createRedisFromOptions(e,t){const n=new a.default((0,i.defaults)({retryStrategy:null,enableOfflineQueue:true,readOnly:t},e,this.redisOptions,{lazyConnect:true}));return n}findOrCreate(e,t=false){const n=(0,s.getNodeKey)(e);t=Boolean(t);if(this.specifiedOptions[n]){Object.assign(e,this.specifiedOptions[n])}else{this.specifiedOptions[n]=e}let r;if(this.nodes.all[n]){r=this.nodes.all[n];if(r.options.readOnly!==t){r.options.readOnly=t;o("Change role of %s to %s",n,t?"slave":"master");r[t?"readonly":"readwrite"]().catch(i.noop);if(t){delete this.nodes.master[n];this.nodes.slave[n]=r}else{delete this.nodes.slave[n];this.nodes.master[n]=r}}}else{o("Connecting to %s as %s",n,t?"slave":"master");r=this.createRedisFromOptions(e,t);this.nodes.all[n]=r;this.nodes[t?"slave":"master"][n]=r;r.once("end",(()=>{this.removeNode(n);this.emit("-node",r,n);if(!Object.keys(this.nodes.all).length){this.emit("drain")}}));this.emit("+node",r,n);r.on("error",(function(e){this.emit("nodeError",e,n)}))}return r}reset(e){o("Reset with %O",e);const t={};e.forEach((e=>{const n=(0,s.getNodeKey)(e);if(!(e.readOnly&&t[n])){t[n]=e}}));Object.keys(this.nodes.all).forEach((e=>{if(!t[e]){o("Disconnect %s because the node does not hold any slot",e);this.nodes.all[e].disconnect();this.removeNode(e)}}));Object.keys(t).forEach((e=>{const n=t[e];this.findOrCreate(n,n.readOnly)}))}removeNode(e){const{nodes:t}=this;if(t.all[e]){o("Remove %s from the pool",e);delete t.all[e]}delete t.master[e];delete t.slave[e]}}t["default"]=ConnectionPool},468:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(9335);const i=n(9611);const s=(0,r.Debug)("delayqueue");class DelayQueue{constructor(){this.queues={};this.timeouts={}}push(e,t,n){const r=n.callback||process.nextTick;if(!this.queues[e]){this.queues[e]=new i}const s=this.queues[e];s.push(t);if(!this.timeouts[e]){this.timeouts[e]=setTimeout((()=>{r((()=>{this.timeouts[e]=null;this.execute(e)}))}),n.timeout)}}execute(e){const t=this.queues[e];if(!t){return}const{length:n}=t;if(!n){return}s("send %d commands in %s queue",n,e);this.queues[e]=null;while(t.length>0){t.shift()()}}}t["default"]=DelayQueue},1352:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(3175);const i=n(4434);const s=n(8287);const a=n(2460);const o=n(5372);const l=n(4819);const c=n(6942);const u=n(1432);const d=n(1101);const f=n(9335);const p=n(9066);const h=n(4489);const y=n(9670);const m=n(6272);const b=n(5860);const g=n(468);const v=n(722);const K=n(9611);const S=n(9733);const E=(0,f.Debug)("cluster");const k=new WeakSet;class Cluster extends h.default{constructor(e,t={}){super();this.slots=[];this._groupsIds={};this._groupsBySlot=Array(16384);this.isCluster=true;this.retryAttempts=0;this.delayQueue=new g.default;this.offlineQueue=new K;this.isRefreshing=false;this._refreshSlotsCacheCallbacks=[];this._autoPipelines=new Map;this._runningAutoPipelines=new Set;this._readyDelayedCallbacks=[];this.connectionEpoch=0;i.EventEmitter.call(this);this.startupNodes=e;this.options=(0,f.defaults)({},t,y.DEFAULT_CLUSTER_OPTIONS,this.options);if(this.options.shardedSubscribers==true)this.shardedSubscribers=new S.default(this);if(this.options.redisOptions&&this.options.redisOptions.keyPrefix&&!this.options.keyPrefix){this.options.keyPrefix=this.options.redisOptions.keyPrefix}if(typeof this.options.scaleReads!=="function"&&["all","master","slave"].indexOf(this.options.scaleReads)===-1){throw new Error('Invalid option scaleReads "'+this.options.scaleReads+'". Expected "all", "master", "slave" or a custom function')}this.connectionPool=new b.default(this.options.redisOptions);this.connectionPool.on("-node",((e,t)=>{this.emit("-node",e)}));this.connectionPool.on("+node",(e=>{this.emit("+node",e)}));this.connectionPool.on("drain",(()=>{this.setStatus("close")}));this.connectionPool.on("nodeError",((e,t)=>{this.emit("node error",e,t)}));this.subscriber=new m.default(this.connectionPool,this);if(this.options.scripts){Object.entries(this.options.scripts).forEach((([e,t])=>{this.defineCommand(e,t)}))}if(this.options.lazyConnect){this.setStatus("wait")}else{this.connect().catch((e=>{E("connecting failed: %s",e)}))}}connect(){return new Promise(((e,t)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){t(new Error("Redis is already connecting/connected"));return}const n=++this.connectionEpoch;this.setStatus("connecting");this.resolveStartupNodeHostnames().then((r=>{if(this.connectionEpoch!==n){E("discard connecting after resolving startup nodes because epoch not match: %d != %d",n,this.connectionEpoch);t(new s.RedisError("Connection is discarded because a new connection is made"));return}if(this.status!=="connecting"){E("discard connecting after resolving startup nodes because the status changed to %s",this.status);t(new s.RedisError("Connection is aborted"));return}this.connectionPool.reset(r);const readyHandler=()=>{this.setStatus("ready");this.retryAttempts=0;this.executeOfflineCommands();this.resetNodesRefreshInterval();e()};let i=undefined;const refreshListener=()=>{this.invokeReadyDelayedCallbacks(undefined);this.removeListener("close",i);this.manuallyClosing=false;this.setStatus("connect");if(this.options.enableReadyCheck){this.readyCheck(((e,t)=>{if(e||t){E("Ready check failed (%s). Reconnecting...",e||t);if(this.status==="connect"){this.disconnect(true)}}else{readyHandler()}}))}else{readyHandler()}};i=()=>{const e=new Error("None of startup nodes is available");this.removeListener("refresh",refreshListener);this.invokeReadyDelayedCallbacks(e);t(e)};this.once("refresh",refreshListener);this.once("close",i);this.once("close",this.handleCloseEvent.bind(this));this.refreshSlotsCache((e=>{if(e&&e.message===l.default.defaultMessage){c.default.prototype.silentEmit.call(this,"error",e);this.connectionPool.reset([])}}));this.subscriber.start();if(this.options.shardedSubscribers){this.shardedSubscribers.start()}})).catch((e=>{this.setStatus("close");this.handleCloseEvent(e);this.invokeReadyDelayedCallbacks(e);t(e)}))}))}disconnect(e=false){const t=this.status;this.setStatus("disconnecting");if(!e){this.manuallyClosing=true}if(this.reconnectTimeout&&!e){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=null;E("Canceled reconnecting attempts")}this.clearNodesRefreshInterval();this.subscriber.stop();if(this.options.shardedSubscribers){this.shardedSubscribers.stop()}if(t==="wait"){this.setStatus("close");this.handleCloseEvent()}else{this.connectionPool.reset([])}}quit(e){const t=this.status;this.setStatus("disconnecting");this.manuallyClosing=true;if(this.reconnectTimeout){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=null}this.clearNodesRefreshInterval();this.subscriber.stop();if(this.options.shardedSubscribers){this.shardedSubscribers.stop()}if(t==="wait"){const t=(0,a.default)(Promise.resolve("OK"),e);setImmediate(function(){this.setStatus("close");this.handleCloseEvent()}.bind(this));return t}return(0,a.default)(Promise.all(this.nodes().map((e=>e.quit().catch((e=>{if(e.message===f.CONNECTION_CLOSED_ERROR_MSG){return"OK"}throw e}))))).then((()=>"OK")),e)}duplicate(e=[],t={}){const n=e.length>0?e:this.startupNodes.slice(0);const r=Object.assign({},this.options,t);return new Cluster(n,r)}nodes(e="all"){if(e!=="all"&&e!=="master"&&e!=="slave"){throw new Error('Invalid role "'+e+'". Expected "all", "master" or "slave"')}return this.connectionPool.getNodes(e)}delayUntilReady(e){this._readyDelayedCallbacks.push(e)}get autoPipelineQueueSize(){let e=0;for(const t of this._autoPipelines.values()){e+=t.length}return e}refreshSlotsCache(e){if(e){this._refreshSlotsCacheCallbacks.push(e)}if(this.isRefreshing){return}this.isRefreshing=true;const t=this;const wrapper=e=>{this.isRefreshing=false;for(const t of this._refreshSlotsCacheCallbacks){t(e)}this._refreshSlotsCacheCallbacks=[]};const n=(0,f.shuffle)(this.connectionPool.getNodes());let r=null;function tryNode(e){if(e===n.length){const e=new l.default(l.default.defaultMessage,r);return wrapper(e)}const i=n[e];const s=`${i.options.host}:${i.options.port}`;E("getting slot cache from %s",s);t.getInfoFromNode(i,(function(n){switch(t.status){case"close":case"end":return wrapper(new Error("Cluster is disconnected."));case"disconnecting":return wrapper(new Error("Cluster is disconnecting."))}if(n){t.emit("node error",n,s);r=n;tryNode(e+1)}else{t.emit("refresh");wrapper()}}))}tryNode(0)}sendCommand(e,t,n){if(this.status==="wait"){this.connect().catch(f.noop)}if(this.status==="end"){e.reject(new Error(f.CONNECTION_CLOSED_ERROR_MSG));return e.promise}let i=this.options.scaleReads;if(i!=="master"){const t=e.isReadOnly||(0,r.exists)(e.name)&&(0,r.hasFlag)(e.name,"readonly");if(!t){i="master"}}let a=n?n.slot:e.getSlot();const l={};const c=this;if(!n&&!k.has(e)){k.add(e);const t=e.reject;e.reject=function(n){const r=tryConnection.bind(null,true);c.handleError(n,l,{moved:function(t,n){E("command %s is moved to %s",e.name,n);a=Number(t);if(c.slots[t]){c.slots[t][0]=n}else{c.slots[t]=[n]}c._groupsBySlot[t]=c._groupsIds[c.slots[t].join(";")];c.connectionPool.findOrCreate(c.natMapper(n));tryConnection();E("refreshing slot caches... (triggered by MOVED error)");c.refreshSlotsCache()},ask:function(t,n){E("command %s is required to ask %s:%s",e.name,n);const r=c.natMapper(n);c.connectionPool.findOrCreate(r);tryConnection(false,`${r.host}:${r.port}`)},tryagain:r,clusterDown:r,connectionClosed:r,maxRedirections:function(n){t.call(e,n)},defaults:function(){t.call(e,n)}})}}tryConnection();function tryConnection(r,l){if(c.status==="end"){e.reject(new s.AbortError("Cluster is ended."));return}let u;if(c.status==="ready"||e.name==="cluster"){if(n&&n.redis){u=n.redis}else if(o.default.checkFlag("ENTER_SUBSCRIBER_MODE",e.name)||o.default.checkFlag("EXIT_SUBSCRIBER_MODE",e.name)){if(c.options.shardedSubscribers==true&&(e.name=="ssubscribe"||e.name=="sunsubscribe")){const t=c.shardedSubscribers.getResponsibleSubscriber(a);let n=-1;if(e.name=="ssubscribe")n=c.shardedSubscribers.addChannels(e.getKeys());if(e.name=="sunsubscribe")n=c.shardedSubscribers.removeChannels(e.getKeys());if(n!==-1){u=t.getInstance()}else{e.reject(new s.AbortError("Can't add or remove the given channels. Are they in the same slot?"))}}else{u=c.subscriber.getInstance()}if(!u){e.reject(new s.AbortError("No subscriber for the cluster"));return}}else{if(!r){if(typeof a==="number"&&c.slots[a]){const t=c.slots[a];if(typeof i==="function"){const n=t.map((function(e){return c.connectionPool.getInstanceByKey(e)}));u=i(n,e);if(Array.isArray(u)){u=(0,f.sample)(u)}if(!u){u=n[0]}}else{let e;if(i==="all"){e=(0,f.sample)(t)}else if(i==="slave"&&t.length>1){e=(0,f.sample)(t,1)}else{e=t[0]}u=c.connectionPool.getInstanceByKey(e)}}if(l){u=c.connectionPool.getInstanceByKey(l);u.asking()}}if(!u){u=(typeof i==="function"?null:c.connectionPool.getSampleInstance(i))||c.connectionPool.getSampleInstance("all")}}if(n&&!n.redis){n.redis=u}}if(u){u.sendCommand(e,t)}else if(c.options.enableOfflineQueue){c.offlineQueue.push({command:e,stream:t,node:n})}else{e.reject(new Error("Cluster isn't ready and enableOfflineQueue options is false"))}}return e.promise}sscanStream(e,t){return this.createScanStream("sscan",{key:e,options:t})}sscanBufferStream(e,t){return this.createScanStream("sscanBuffer",{key:e,options:t})}hscanStream(e,t){return this.createScanStream("hscan",{key:e,options:t})}hscanBufferStream(e,t){return this.createScanStream("hscanBuffer",{key:e,options:t})}zscanStream(e,t){return this.createScanStream("zscan",{key:e,options:t})}zscanBufferStream(e,t){return this.createScanStream("zscanBuffer",{key:e,options:t})}handleError(e,t,n){if(typeof t.value==="undefined"){t.value=this.options.maxRedirections}else{t.value-=1}if(t.value<=0){n.maxRedirections(new Error("Too many Cluster redirections. Last error: "+e));return}const r=e.message.split(" ");if(r[0]==="MOVED"){const e=this.options.retryDelayOnMoved;if(e&&typeof e==="number"){this.delayQueue.push("moved",n.moved.bind(null,r[1],r[2]),{timeout:e})}else{n.moved(r[1],r[2])}}else if(r[0]==="ASK"){n.ask(r[1],r[2])}else if(r[0]==="TRYAGAIN"){this.delayQueue.push("tryagain",n.tryagain,{timeout:this.options.retryDelayOnTryAgain})}else if(r[0]==="CLUSTERDOWN"&&this.options.retryDelayOnClusterDown>0){this.delayQueue.push("clusterdown",n.connectionClosed,{timeout:this.options.retryDelayOnClusterDown,callback:this.refreshSlotsCache.bind(this)})}else if(e.message===f.CONNECTION_CLOSED_ERROR_MSG&&this.options.retryDelayOnFailover>0&&this.status==="ready"){this.delayQueue.push("failover",n.connectionClosed,{timeout:this.options.retryDelayOnFailover,callback:this.refreshSlotsCache.bind(this)})}else{n.defaults()}}resetOfflineQueue(){this.offlineQueue=new K}clearNodesRefreshInterval(){if(this.slotsTimer){clearTimeout(this.slotsTimer);this.slotsTimer=null}}resetNodesRefreshInterval(){if(this.slotsTimer||!this.options.slotsRefreshInterval){return}const nextRound=()=>{this.slotsTimer=setTimeout((()=>{E('refreshing slot caches... (triggered by "slotsRefreshInterval" option)');this.refreshSlotsCache((()=>{nextRound()}))}),this.options.slotsRefreshInterval)};nextRound()}setStatus(e){E("status: %s -> %s",this.status||"[empty]",e);this.status=e;process.nextTick((()=>{this.emit(e)}))}handleCloseEvent(e){if(e){E("closed because %s",e)}let t;if(!this.manuallyClosing&&typeof this.options.clusterRetryStrategy==="function"){t=this.options.clusterRetryStrategy.call(this,++this.retryAttempts,e)}if(typeof t==="number"){this.setStatus("reconnecting");this.reconnectTimeout=setTimeout((()=>{this.reconnectTimeout=null;E("Cluster is disconnected. Retrying after %dms",t);this.connect().catch((function(e){E("Got error %s when reconnecting. Ignoring...",e)}))}),t)}else{this.setStatus("end");this.flushQueue(new Error("None of startup nodes is available"))}}flushQueue(e){let t;while(t=this.offlineQueue.shift()){t.command.reject(e)}}executeOfflineCommands(){if(this.offlineQueue.length){E("send %d commands in offline queue",this.offlineQueue.length);const e=this.offlineQueue;this.resetOfflineQueue();let t;while(t=e.shift()){this.sendCommand(t.command,t.stream,t.node)}}}natMapper(e){const t=typeof e==="string"?e:`${e.host}:${e.port}`;let n=null;if(this.options.natMap&&typeof this.options.natMap==="function"){n=this.options.natMap(t)}else if(this.options.natMap&&typeof this.options.natMap==="object"){n=this.options.natMap[t]}if(n){E("NAT mapping %s -> %O",t,n);return Object.assign({},n)}return typeof e==="string"?(0,v.nodeKeyToRedisOptions)(e):e}getInfoFromNode(e,t){if(!e){return t(new Error("Node is disconnected"))}const n=e.duplicate({enableOfflineQueue:true,enableReadyCheck:false,retryStrategy:null,connectionName:(0,v.getConnectionName)("refresher",this.options.redisOptions&&this.options.redisOptions.connectionName)});n.on("error",f.noop);n.cluster("SLOTS",(0,f.timeout)(((e,r)=>{n.disconnect();if(e){E("error encountered running CLUSTER.SLOTS: %s",e);return t(e)}if(this.status==="disconnecting"||this.status==="close"||this.status==="end"){E("ignore CLUSTER.SLOTS results (count: %d) since cluster status is %s",r.length,this.status);t();return}const i=[];E("cluster slots result count: %d",r.length);for(let e=0;e<r.length;++e){const t=r[e];const n=t[0];const s=t[1];const a=[];for(let e=2;e<t.length;e++){if(!t[e][0]){continue}const n=this.natMapper({host:t[e][0],port:t[e][1]});n.readOnly=e!==2;i.push(n);a.push(n.host+":"+n.port)}E("cluster slots result [%d]: slots %d~%d served by %s",e,n,s,a);for(let e=n;e<=s;e++){this.slots[e]=a}}this._groupsIds=Object.create(null);let s=0;for(let e=0;e<16384;e++){const t=(this.slots[e]||[]).join(";");if(!t.length){this._groupsBySlot[e]=undefined;continue}if(!this._groupsIds[t]){this._groupsIds[t]=++s}this._groupsBySlot[e]=this._groupsIds[t]}this.connectionPool.reset(i);t()}),this.options.slotsRefreshTimeout))}invokeReadyDelayedCallbacks(e){for(const t of this._readyDelayedCallbacks){process.nextTick(t,e)}this._readyDelayedCallbacks=[]}readyCheck(e){this.cluster("INFO",((t,n)=>{if(t){return e(t)}if(typeof n!=="string"){return e()}let r;const i=n.split("\r\n");for(let e=0;e<i.length;++e){const t=i[e].split(":");if(t[0]==="cluster_state"){r=t[1];break}}if(r==="fail"){E("cluster state not ok (%s)",r);e(null,r)}else{e()}}))}resolveSrv(e){return new Promise(((t,n)=>{this.options.resolveSrv(e,((e,r)=>{if(e){return n(e)}const i=this,s=(0,v.groupSrvRecords)(r),a=Object.keys(s).sort(((e,t)=>parseInt(e)-parseInt(t)));function tryFirstOne(e){if(!a.length){return n(e)}const r=a[0],o=s[r],l=(0,v.weightSrvRecords)(o);if(!o.records.length){a.shift()}i.dnsLookup(l.name).then((e=>t({host:e,port:l.port})),tryFirstOne)}tryFirstOne()}))}))}dnsLookup(e){return new Promise(((t,n)=>{this.options.dnsLookup(e,((r,i)=>{if(r){E("failed to resolve hostname %s to IP: %s",e,r.message);n(r)}else{E("resolved hostname %s to IP %s",e,i);t(i)}}))}))}async resolveStartupNodeHostnames(){if(!Array.isArray(this.startupNodes)||this.startupNodes.length===0){throw new Error("`startupNodes` should contain at least one node.")}const e=(0,v.normalizeNodeOptions)(this.startupNodes);const t=(0,v.getUniqueHostnamesFromOptions)(e);if(t.length===0){return e}const n=await Promise.all(t.map((this.options.useSRVRecords?this.resolveSrv:this.dnsLookup).bind(this)));const r=(0,f.zipMap)(t,n);return e.map((e=>{const t=r.get(e.host);if(!t){return e}if(this.options.useSRVRecords){return Object.assign({},e,t)}return Object.assign({},e,{host:t})}))}createScanStream(e,{key:t,options:n={}}){return new u.default({objectMode:true,key:t,redis:this,command:e,...n})}}(0,p.default)(Cluster,i.EventEmitter);(0,d.addTransactionSupport)(Cluster.prototype);t["default"]=Cluster},722:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getConnectionName=t.weightSrvRecords=t.groupSrvRecords=t.getUniqueHostnamesFromOptions=t.normalizeNodeOptions=t.nodeKeyToRedisOptions=t.getNodeKey=void 0;const r=n(9335);const i=n(9278);function getNodeKey(e){e.port=e.port||6379;e.host=e.host||"127.0.0.1";return e.host+":"+e.port}t.getNodeKey=getNodeKey;function nodeKeyToRedisOptions(e){const t=e.lastIndexOf(":");if(t===-1){throw new Error(`Invalid node key ${e}`)}return{host:e.slice(0,t),port:Number(e.slice(t+1))}}t.nodeKeyToRedisOptions=nodeKeyToRedisOptions;function normalizeNodeOptions(e){return e.map((e=>{const t={};if(typeof e==="object"){Object.assign(t,e)}else if(typeof e==="string"){Object.assign(t,(0,r.parseURL)(e))}else if(typeof e==="number"){t.port=e}else{throw new Error("Invalid argument "+e)}if(typeof t.port==="string"){t.port=parseInt(t.port,10)}delete t.db;if(!t.port){t.port=6379}if(!t.host){t.host="127.0.0.1"}return(0,r.resolveTLSProfile)(t)}))}t.normalizeNodeOptions=normalizeNodeOptions;function getUniqueHostnamesFromOptions(e){const t={};e.forEach((e=>{t[e.host]=true}));return Object.keys(t).filter((e=>!(0,i.isIP)(e)))}t.getUniqueHostnamesFromOptions=getUniqueHostnamesFromOptions;function groupSrvRecords(e){const t={};for(const n of e){if(!t.hasOwnProperty(n.priority)){t[n.priority]={totalWeight:n.weight,records:[n]}}else{t[n.priority].totalWeight+=n.weight;t[n.priority].records.push(n)}}return t}t.groupSrvRecords=groupSrvRecords;function weightSrvRecords(e){if(e.records.length===1){e.totalWeight=0;return e.records.shift()}const t=Math.floor(Math.random()*(e.totalWeight+e.records.length));let n=0;for(const[r,i]of e.records.entries()){n+=1+i.weight;if(n>t){e.totalWeight-=i.weight;e.records.splice(r,1);return i}}}t.weightSrvRecords=weightSrvRecords;function getConnectionName(e,t){const n=`ioredis-cluster(${e})`;return t?`${n}:${t}`:n}t.getConnectionName=getConnectionName},4931:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(9335);const i=(0,r.Debug)("AbstractConnector");class AbstractConnector{constructor(e){this.connecting=false;this.disconnectTimeout=e}check(e){return true}disconnect(){this.connecting=false;if(this.stream){const e=this.stream;const t=setTimeout((()=>{i("stream %s:%s still open, destroying it",e.remoteAddress,e.remotePort);e.destroy()}),this.disconnectTimeout);e.on("close",(()=>clearTimeout(t)));e.end()}}}t["default"]=AbstractConnector},3744:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.FailoverDetector=void 0;const r=n(9335);const i=(0,r.Debug)("FailoverDetector");const s="+switch-master";class FailoverDetector{constructor(e,t){this.isDisconnected=false;this.connector=e;this.sentinels=t}cleanup(){this.isDisconnected=true;for(const e of this.sentinels){e.client.disconnect()}}async subscribe(){i("Starting FailoverDetector");const e=[];for(const t of this.sentinels){const n=t.client.subscribe(s).catch((e=>{i("Failed to subscribe to failover messages on sentinel %s:%s (%s)",t.address.host||"127.0.0.1",t.address.port||26739,e.message)}));e.push(n);t.client.on("message",(e=>{if(!this.isDisconnected&&e===s){this.disconnect()}}))}await Promise.all(e)}disconnect(){this.isDisconnected=true;i("Failover detected, disconnecting");this.connector.disconnect()}}t.FailoverDetector=FailoverDetector},7154:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function isSentinelEql(e,t){return(e.host||"127.0.0.1")===(t.host||"127.0.0.1")&&(e.port||26379)===(t.port||26379)}class SentinelIterator{constructor(e){this.cursor=0;this.sentinels=e.slice(0)}next(){const e=this.cursor>=this.sentinels.length;return{done:e,value:e?undefined:this.sentinels[this.cursor++]}}reset(e){if(e&&this.sentinels.length>1&&this.cursor!==1){this.sentinels.unshift(...this.sentinels.splice(this.cursor-1))}this.cursor=0}add(e){for(let t=0;t<this.sentinels.length;t++){if(isSentinelEql(e,this.sentinels[t])){return false}}this.sentinels.push(e);return true}toString(){return`${JSON.stringify(this.sentinels)} @${this.cursor}`}}t["default"]=SentinelIterator},1766:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.SentinelIterator=void 0;const r=n(9278);const i=n(9335);const s=n(4756);const a=n(7154);t.SentinelIterator=a.default;const o=n(4931);const l=n(6942);const c=n(3744);const u=(0,i.Debug)("SentinelConnector");class SentinelConnector extends o.default{constructor(e){super(e.disconnectTimeout);this.options=e;this.emitter=null;this.failoverDetector=null;if(!this.options.sentinels.length){throw new Error("Requires at least one sentinel to connect to.")}if(!this.options.name){throw new Error("Requires the name of master.")}this.sentinelIterator=new a.default(this.options.sentinels)}check(e){const t=!e.role||this.options.role===e.role;if(!t){u("role invalid, expected %s, but got %s",this.options.role,e.role);this.sentinelIterator.next();this.sentinelIterator.next();this.sentinelIterator.reset(true)}return t}disconnect(){super.disconnect();if(this.failoverDetector){this.failoverDetector.cleanup()}}connect(e){this.connecting=true;this.retryAttempts=0;let t;const connectToNext=async()=>{const n=this.sentinelIterator.next();if(n.done){this.sentinelIterator.reset(false);const n=typeof this.options.sentinelRetryStrategy==="function"?this.options.sentinelRetryStrategy(++this.retryAttempts):null;let r=typeof n!=="number"?"All sentinels are unreachable and retry is disabled.":`All sentinels are unreachable. Retrying from scratch after ${n}ms.`;if(t){r+=` Last error: ${t.message}`}u(r);const i=new Error(r);if(typeof n==="number"){e("error",i);await new Promise((e=>setTimeout(e,n)));return connectToNext()}else{throw i}}let a=null;let o=null;try{a=await this.resolve(n.value)}catch(e){o=e}if(!this.connecting){throw new Error(i.CONNECTION_CLOSED_ERROR_MSG)}const l=n.value.host+":"+n.value.port;if(a){u("resolved: %s:%s from sentinel %s",a.host,a.port,l);if(this.options.enableTLSForSentinelMode&&this.options.tls){Object.assign(a,this.options.tls);this.stream=(0,s.connect)(a);this.stream.once("secureConnect",this.initFailoverDetector.bind(this))}else{this.stream=(0,r.createConnection)(a);this.stream.once("connect",this.initFailoverDetector.bind(this))}this.stream.once("error",(e=>{this.firstError=e}));return this.stream}else{const n=o?"failed to connect to sentinel "+l+" because "+o.message:"connected to sentinel "+l+" successfully, but got an invalid reply: "+a;u(n);e("sentinelError",new Error(n));if(o){t=o}return connectToNext()}};return connectToNext()}async updateSentinels(e){if(!this.options.updateSentinels){return}const t=await e.sentinel("sentinels",this.options.name);if(!Array.isArray(t)){return}t.map(i.packObject).forEach((e=>{const t=e.flags?e.flags.split(","):[];if(t.indexOf("disconnected")===-1&&e.ip&&e.port){const t=this.sentinelNatResolve(addressResponseToAddress(e));if(this.sentinelIterator.add(t)){u("adding sentinel %s:%s",t.host,t.port)}}}));u("Updated internal sentinels: %s",this.sentinelIterator)}async resolveMaster(e){const t=await e.sentinel("get-master-addr-by-name",this.options.name);await this.updateSentinels(e);return this.sentinelNatResolve(Array.isArray(t)?{host:t[0],port:Number(t[1])}:null)}async resolveSlave(e){const t=await e.sentinel("slaves",this.options.name);if(!Array.isArray(t)){return null}const n=t.map(i.packObject).filter((e=>e.flags&&!e.flags.match(/(disconnected|s_down|o_down)/)));return this.sentinelNatResolve(selectPreferredSentinel(n,this.options.preferredSlaves))}sentinelNatResolve(e){if(!e||!this.options.natMap)return e;const t=`${e.host}:${e.port}`;let n=e;if(typeof this.options.natMap==="function"){n=this.options.natMap(t)||e}else if(typeof this.options.natMap==="object"){n=this.options.natMap[t]||e}return n}connectToSentinel(e,t){const n=new l.default({port:e.port||26379,host:e.host,username:this.options.sentinelUsername||null,password:this.options.sentinelPassword||null,family:e.family||("path"in this.options&&this.options.path?undefined:this.options.family),tls:this.options.sentinelTLS,retryStrategy:null,enableReadyCheck:false,connectTimeout:this.options.connectTimeout,commandTimeout:this.options.sentinelCommandTimeout,...t});return n}async resolve(e){const t=this.connectToSentinel(e);t.on("error",noop);try{if(this.options.role==="slave"){return await this.resolveSlave(t)}else{return await this.resolveMaster(t)}}finally{t.disconnect()}}async initFailoverDetector(){var e;if(!this.options.failoverDetector){return}this.sentinelIterator.reset(true);const t=[];while(t.length<this.options.sentinelMaxConnections){const{done:e,value:n}=this.sentinelIterator.next();if(e){break}const r=this.connectToSentinel(n,{lazyConnect:true,retryStrategy:this.options.sentinelReconnectStrategy});r.on("reconnecting",(()=>{var e;(e=this.emitter)===null||e===void 0?void 0:e.emit("sentinelReconnecting")}));t.push({address:n,client:r})}this.sentinelIterator.reset(false);if(this.failoverDetector){this.failoverDetector.cleanup()}this.failoverDetector=new c.FailoverDetector(this,t);await this.failoverDetector.subscribe();(e=this.emitter)===null||e===void 0?void 0:e.emit("failoverSubscribed")}}t["default"]=SentinelConnector;function selectPreferredSentinel(e,t){if(e.length===0){return null}let n;if(typeof t==="function"){n=t(e)}else if(t!==null&&typeof t==="object"){const r=Array.isArray(t)?t:[t];r.sort(((e,t)=>{if(!e.prio){e.prio=1}if(!t.prio){t.prio=1}if(e.prio<t.prio){return-1}if(e.prio>t.prio){return 1}return 0}));for(let t=0;t<r.length;t++){for(let i=0;i<e.length;i++){const s=e[i];if(s.ip===r[t].ip){if(s.port===r[t].port){n=s;break}}}if(n){break}}}if(!n){n=(0,i.sample)(e)}return addressResponseToAddress(n)}function addressResponseToAddress(e){return{host:e.ip,port:Number(e.port)}}function noop(){}},6036:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(9278);const i=n(4756);const s=n(9335);const a=n(4931);class StandaloneConnector extends a.default{constructor(e){super(e.disconnectTimeout);this.options=e}connect(e){const{options:t}=this;this.connecting=true;let n;if("path"in t&&t.path){n={path:t.path}}else{n={};if("port"in t&&t.port!=null){n.port=t.port}if("host"in t&&t.host!=null){n.host=t.host}if("family"in t&&t.family!=null){n.family=t.family}}if(t.tls){Object.assign(n,t.tls)}return new Promise(((e,a)=>{process.nextTick((()=>{if(!this.connecting){a(new Error(s.CONNECTION_CLOSED_ERROR_MSG));return}try{if(t.tls){this.stream=(0,i.connect)(n)}else{this.stream=(0,r.createConnection)(n)}}catch(e){a(e);return}this.stream.once("error",(e=>{this.firstError=e}));e(this.stream)}))}))}}t["default"]=StandaloneConnector},5850:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.SentinelConnector=t.StandaloneConnector=void 0;const r=n(6036);t.StandaloneConnector=r.default;const i=n(1766);t.SentinelConnector=i.default},424:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});const n=`-----BEGIN CERTIFICATE-----\nMIIDTzCCAjegAwIBAgIJAKSVpiDswLcwMA0GCSqGSIb3DQEBBQUAMD4xFjAUBgNV\nBAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1\ndGhvcml0eTAeFw0xMzEwMDExMjE0NTVaFw0yMzA5MjkxMjE0NTVaMD4xFjAUBgNV\nBAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1\ndGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALZqkh/DczWP\nJnxnHLQ7QL0T4B4CDKWBKCcisriGbA6ZePWVNo4hfKQC6JrzfR+081NeD6VcWUiz\nrmd+jtPhIY4c+WVQYm5PKaN6DT1imYdxQw7aqO5j2KUCEh/cznpLxeSHoTxlR34E\nQwF28Wl3eg2vc5ct8LjU3eozWVk3gb7alx9mSA2SgmuX5lEQawl++rSjsBStemY2\nBDwOpAMXIrdEyP/cVn8mkvi/BDs5M5G+09j0gfhyCzRWMQ7Hn71u1eolRxwVxgi3\nTMn+/vTaFSqxKjgck6zuAYjBRPaHe7qLxHNr1So/Mc9nPy+3wHebFwbIcnUojwbp\n4nctkWbjb2cCAwEAAaNQME4wHQYDVR0OBBYEFP1whtcrydmW3ZJeuSoKZIKjze3w\nMB8GA1UdIwQYMBaAFP1whtcrydmW3ZJeuSoKZIKjze3wMAwGA1UdEwQFMAMBAf8w\nDQYJKoZIhvcNAQEFBQADggEBAG2erXhwRAa7+ZOBs0B6X57Hwyd1R4kfmXcs0rta\nlbPpvgULSiB+TCbf3EbhJnHGyvdCY1tvlffLjdA7HJ0PCOn+YYLBA0pTU/dyvrN6\nSu8NuS5yubnt9mb13nDGYo1rnt0YRfxN+8DM3fXIVr038A30UlPX2Ou1ExFJT0MZ\nuFKY6ZvLdI6/1cbgmguMlAhM+DhKyV6Sr5699LM3zqeI816pZmlREETYkGr91q7k\nBpXJu/dtHaGxg1ZGu6w/PCsYGUcECWENYD4VQPd8N32JjOfu6vEgoEAwfPP+3oGp\nZ4m3ewACcWOAenqflb+cQYC4PsF7qbXDmRaWrbKntOlZ3n0=\n-----END CERTIFICATE-----\n-----BEGIN CERTIFICATE-----\nMIIGMTCCBBmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwajELMAkGA1UEBhMCVVMx\nCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJzMS0w\nKwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcN\nMTgwMjI1MTUzNzM3WhcNMjgwMjIzMTUzNzM3WjBfMQswCQYDVQQGEwJVUzELMAkG\nA1UECAwCQ0ExEjAQBgNVBAoMCVJlZGlzTGFiczEvMC0GA1UEAwwmUkNQIEludGVy\nbWVkaWF0ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA\nA4ICDwAwggIKAoICAQDf9dqbxc8Bq7Ctq9rWcxrGNKKHivqLAFpPq02yLPx6fsOv\nTq7GsDChAYBBc4v7Y2Ap9RD5Vs3dIhEANcnolf27QwrG9RMnnvzk8pCvp1o6zSU4\nVuOE1W66/O1/7e2rVxyrnTcP7UgK43zNIXu7+tiAqWsO92uSnuMoGPGpeaUm1jym\nhjWKtkAwDFSqvHY+XL5qDVBEjeUe+WHkYUg40cAXjusAqgm2hZt29c2wnVrxW25W\nP0meNlzHGFdA2AC5z54iRiqj57dTfBTkHoBczQxcyw6hhzxZQ4e5I5zOKjXXEhZN\nr0tA3YC14CTabKRus/JmZieyZzRgEy2oti64tmLYTqSlAD78pRL40VNoaSYetXLw\nhhNsXCHgWaY6d5bLOc/aIQMAV5oLvZQKvuXAF1IDmhPA+bZbpWipp0zagf1P1H3s\nUzsMdn2KM0ejzgotbtNlj5TcrVwpmvE3ktvUAuA+hi3FkVx1US+2Gsp5x4YOzJ7u\nP1WPk6ShF0JgnJH2ILdj6kttTWwFzH17keSFICWDfH/+kM+k7Y1v3EXMQXE7y0T9\nMjvJskz6d/nv+sQhY04xt64xFMGTnZjlJMzfQNi7zWFLTZnDD0lPowq7l3YiPoTT\nt5Xky83lu0KZsZBo0WlWaDG00gLVdtRgVbcuSWxpi5BdLb1kRab66JptWjxwXQID\nAQABo4HrMIHoMDoGA1UdHwQzMDEwL6AtoCuGKWh0dHBzOi8vcmwtY2Etc2VydmVy\nLnJlZGlzbGFicy5jb20vdjEvY3JsMEYGCCsGAQUFBwEBBDowODA2BggrBgEFBQcw\nAYYqaHR0cHM6Ly9ybC1jYS1zZXJ2ZXIucmVkaXNsYWJzLmNvbS92MS9vY3NwMB0G\nA1UdDgQWBBQHar5OKvQUpP2qWt6mckzToeCOHDAfBgNVHSMEGDAWgBQi42wH6hM4\nL2sujEvLM0/u8lRXTzASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIB\nhjANBgkqhkiG9w0BAQsFAAOCAgEAirEn/iTsAKyhd+pu2W3Z5NjCko4NPU0EYUbr\nAP7+POK2rzjIrJO3nFYQ/LLuC7KCXG+2qwan2SAOGmqWst13Y+WHp44Kae0kaChW\nvcYLXXSoGQGC8QuFSNUdaeg3RbMDYFT04dOkqufeWVccoHVxyTSg9eD8LZuHn5jw\n7QDLiEECBmIJHk5Eeo2TAZrx4Yx6ufSUX5HeVjlAzqwtAqdt99uCJ/EL8bgpWbe+\nXoSpvUv0SEC1I1dCAhCKAvRlIOA6VBcmzg5Am12KzkqTul12/VEFIgzqu0Zy2Jbc\nAUPrYVu/+tOGXQaijy7YgwH8P8n3s7ZeUa1VABJHcxrxYduDDJBLZi+MjheUDaZ1\njQRHYevI2tlqeSBqdPKG4zBY5lS0GiAlmuze5oENt0P3XboHoZPHiqcK3VECgTVh\n/BkJcuudETSJcZDmQ8YfoKfBzRQNg2sv/hwvUv73Ss51Sco8GEt2lD8uEdib1Q6z\nzDT5lXJowSzOD5ZA9OGDjnSRL+2riNtKWKEqvtEG3VBJoBzu9GoxbAc7wIZLxmli\niF5a/Zf5X+UXD3s4TMmy6C4QZJpAA2egsSQCnraWO2ULhh7iXMysSkF/nzVfZn43\niqpaB8++9a37hWq14ZmOv0TJIDz//b2+KC4VFXWQ5W5QC6whsjT+OlG4p5ZYG0jo\n616pxqo=\n-----END CERTIFICATE-----\n-----BEGIN CERTIFICATE-----\nMIIFujCCA6KgAwIBAgIJAJ1aTT1lu2ScMA0GCSqGSIb3DQEBCwUAMGoxCzAJBgNV\nBAYTAlVTMQswCQYDVQQIDAJDQTELMAkGA1UEBwwCQ0ExEjAQBgNVBAoMCVJlZGlz\nTGFiczEtMCsGA1UEAwwkUmVkaXNMYWJzIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9y\naXR5MB4XDTE4MDIyNTE1MjA0MloXDTM4MDIyMDE1MjA0MlowajELMAkGA1UEBhMC\nVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJz\nMS0wKwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw\nggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDLEjXy7YrbN5Waau5cd6g1\nG5C2tMmeTpZ0duFAPxNU4oE3RHS5gGiok346fUXuUxbZ6QkuzeN2/2Z+RmRcJhQY\nDm0ZgdG4x59An1TJfnzKKoWj8ISmoHS/TGNBdFzXV7FYNLBuqZouqePI6ReC6Qhl\npp45huV32Q3a6IDrrvx7Wo5ZczEQeFNbCeCOQYNDdTmCyEkHqc2AGo8eoIlSTutT\nULOC7R5gzJVTS0e1hesQ7jmqHjbO+VQS1NAL4/5K6cuTEqUl+XhVhPdLWBXJQ5ag\n54qhX4v+ojLzeU1R/Vc6NjMvVtptWY6JihpgplprN0Yh2556ewcXMeturcKgXfGJ\nxeYzsjzXerEjrVocX5V8BNrg64NlifzTMKNOOv4fVZszq1SIHR8F9ROrqiOdh8iC\nJpUbLpXH9hWCSEO6VRMB2xJoKu3cgl63kF30s77x7wLFMEHiwsQRKxooE1UhgS9K\n2sO4TlQ1eWUvFvHSTVDQDlGQ6zu4qjbOpb3Q8bQwoK+ai2alkXVR4Ltxe9QlgYK3\nStsnPhruzZGA0wbXdpw0bnM+YdlEm5ffSTpNIfgHeaa7Dtb801FtA71ZlH7A6TaI\nSIQuUST9EKmv7xrJyx0W1pGoPOLw5T029aTjnICSLdtV9bLwysrLhIYG5bnPq78B\ncS+jZHFGzD7PUVGQD01nOQIDAQABo2MwYTAdBgNVHQ4EFgQUIuNsB+oTOC9rLoxL\nyzNP7vJUV08wHwYDVR0jBBgwFoAUIuNsB+oTOC9rLoxLyzNP7vJUV08wDwYDVR0T\nAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAHfg\nz5pMNUAKdMzK1aS1EDdK9yKz4qicILz5czSLj1mC7HKDRy8cVADUxEICis++CsCu\nrYOvyCVergHQLREcxPq4rc5Nq1uj6J6649NEeh4WazOOjL4ZfQ1jVznMbGy+fJm3\n3Hoelv6jWRG9iqeJZja7/1s6YC6bWymI/OY1e4wUKeNHAo+Vger7MlHV+RuabaX+\nhSJ8bJAM59NCM7AgMTQpJCncrcdLeceYniGy5Q/qt2b5mJkQVkIdy4TPGGB+AXDJ\nD0q3I/JDRkDUFNFdeW0js7fHdsvCR7O3tJy5zIgEV/o/BCkmJVtuwPYOrw/yOlKj\nTY/U7ATAx9VFF6/vYEOMYSmrZlFX+98L6nJtwDqfLB5VTltqZ4H/KBxGE3IRSt9l\nFXy40U+LnXzhhW+7VBAvyYX8GEXhHkKU8Gqk1xitrqfBXY74xKgyUSTolFSfFVgj\nmcM/X4K45bka+qpkj7Kfv/8D4j6aZekwhN2ly6hhC1SmQ8qjMjpG/mrWOSSHZFmf\nybu9iD2AYHeIOkshIl6xYIa++Q/00/vs46IzAbQyriOi0XxlSMMVtPx0Q3isp+ji\nn8Mq9eOuxYOEQ4of8twUkUDd528iwGtEdwf0Q01UyT84S62N8AySl1ZBKXJz6W4F\nUhWfa/HQYOAPDdEjNgnVwLI23b8t0TozyCWw7q8h\n-----END CERTIFICATE-----\n\n-----BEGIN CERTIFICATE-----\nMIIEjzCCA3egAwIBAgIQe55B/ALCKJDZtdNT8kD6hTANBgkqhkiG9w0BAQsFADBM\nMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xv\nYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjAeFw0yMjAxMjYxMjAwMDBaFw0y\nNTAxMjYwMDAwMDBaMFgxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWdu\nIG52LXNhMS4wLAYDVQQDEyVHbG9iYWxTaWduIEF0bGFzIFIzIE9WIFRMUyBDQSAy\nMDIyIFEyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmGmg1LW9b7Lf\n8zDD83yBDTEkt+FOxKJZqF4veWc5KZsQj9HfnUS2e5nj/E+JImlGPsQuoiosLuXD\nBVBNAMcUFa11buFMGMeEMwiTmCXoXRrXQmH0qjpOfKgYc5gHG3BsRGaRrf7VR4eg\nofNMG9wUBw4/g/TT7+bQJdA4NfE7Y4d5gEryZiBGB/swaX6Jp/8MF4TgUmOWmalK\ndZCKyb4sPGQFRTtElk67F7vU+wdGcrcOx1tDcIB0ncjLPMnaFicagl+daWGsKqTh\ncounQb6QJtYHa91KvCfKWocMxQ7OIbB5UARLPmC4CJ1/f8YFm35ebfzAeULYdGXu\njE9CLor0OwIDAQABo4IBXzCCAVswDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQG\nCCsGAQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQW\nBBSH5Zq7a7B/t95GfJWkDBpA8HHqdjAfBgNVHSMEGDAWgBSP8Et/qC5FJK5NUPpj\nmove4t0bvDB7BggrBgEFBQcBAQRvMG0wLgYIKwYBBQUHMAGGImh0dHA6Ly9vY3Nw\nMi5nbG9iYWxzaWduLmNvbS9yb290cjMwOwYIKwYBBQUHMAKGL2h0dHA6Ly9zZWN1\ncmUuZ2xvYmFsc2lnbi5jb20vY2FjZXJ0L3Jvb3QtcjMuY3J0MDYGA1UdHwQvMC0w\nK6ApoCeGJWh0dHA6Ly9jcmwuZ2xvYmFsc2lnbi5jb20vcm9vdC1yMy5jcmwwIQYD\nVR0gBBowGDAIBgZngQwBAgIwDAYKKwYBBAGgMgoBAjANBgkqhkiG9w0BAQsFAAOC\nAQEAKRic9/f+nmhQU/wz04APZLjgG5OgsuUOyUEZjKVhNGDwxGTvKhyXGGAMW2B/\n3bRi+aElpXwoxu3pL6fkElbX3B0BeS5LoDtxkyiVEBMZ8m+sXbocwlPyxrPbX6mY\n0rVIvnuUeBH8X0L5IwfpNVvKnBIilTbcebfHyXkPezGwz7E1yhUULjJFm2bt0SdX\ny+4X/WeiiYIv+fTVgZZgl+/2MKIsu/qdBJc3f3TvJ8nz+Eax1zgZmww+RSQWeOj3\n15Iw6Z5FX+NwzY/Ab+9PosR5UosSeq+9HhtaxZttXG1nVh+avYPGYddWmiMT90J5\nZgKnO/Fx2hBgTxhOTMYaD312kg==\n-----END CERTIFICATE-----\n\n-----BEGIN CERTIFICATE-----\nMIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G\nA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp\nZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4\nMTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG\nA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\nhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8\nRgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT\ngHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm\nKPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd\nQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ\nXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw\nDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o\nLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU\nRUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp\njjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK\n6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\nmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\nMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\nWD9f\n-----END CERTIFICATE-----`;const r={RedisCloudFixed:{ca:n},RedisCloudFlexible:{ca:n}};t["default"]=r},4819:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(8287);class ClusterAllFailedError extends r.RedisError{constructor(e,t){super(e);this.lastNodeError=t;Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}t["default"]=ClusterAllFailedError;ClusterAllFailedError.defaultMessage="Failed to refresh slots cache."},3203:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(8287);class MaxRetriesPerRequestError extends r.AbortError{constructor(e){const t=`Reached the max retries per request limit (which is ${e}). Refer to "maxRetriesPerRequest" option for details.`;super(t);Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}t["default"]=MaxRetriesPerRequestError},3417:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.MaxRetriesPerRequestError=void 0;const r=n(3203);t.MaxRetriesPerRequestError=r.default},405:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.print=t.ReplyError=t.SentinelIterator=t.SentinelConnector=t.AbstractConnector=t.Pipeline=t.ScanStream=t.Command=t.Cluster=t.Redis=t["default"]=void 0;t=e.exports=n(6942)["default"];var r=n(6942);Object.defineProperty(t,"default",{enumerable:true,get:function(){return r.default}});var i=n(6942);Object.defineProperty(t,"Redis",{enumerable:true,get:function(){return i.default}});var s=n(1352);Object.defineProperty(t,"Cluster",{enumerable:true,get:function(){return s.default}});var a=n(5372);Object.defineProperty(t,"Command",{enumerable:true,get:function(){return a.default}});var o=n(1432);Object.defineProperty(t,"ScanStream",{enumerable:true,get:function(){return o.default}});var l=n(8823);Object.defineProperty(t,"Pipeline",{enumerable:true,get:function(){return l.default}});var c=n(4931);Object.defineProperty(t,"AbstractConnector",{enumerable:true,get:function(){return c.default}});var u=n(1766);Object.defineProperty(t,"SentinelConnector",{enumerable:true,get:function(){return u.default}});Object.defineProperty(t,"SentinelIterator",{enumerable:true,get:function(){return u.SentinelIterator}});t.ReplyError=n(8287).ReplyError;Object.defineProperty(t,"Promise",{get(){console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.");return Promise},set(e){console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.")}});function print(e,t){if(e){console.log("Error: "+e)}else{console.log("Reply: "+t)}}t.print=print},4542:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.DEFAULT_REDIS_OPTIONS=void 0;t.DEFAULT_REDIS_OPTIONS={port:6379,host:"localhost",family:4,connectTimeout:1e4,disconnectTimeout:2e3,retryStrategy:function(e){return Math.min(e*50,2e3)},keepAlive:0,noDelay:true,connectionName:null,sentinels:null,name:null,role:"master",sentinelRetryStrategy:function(e){return Math.min(e*10,1e3)},sentinelReconnectStrategy:function(){return 6e4},natMap:null,enableTLSForSentinelMode:false,updateSentinels:true,failoverDetector:false,username:null,password:null,db:0,enableOfflineQueue:true,enableReadyCheck:true,autoResubscribe:true,autoResendUnfulfilledCommands:true,lazyConnect:false,keyPrefix:"",reconnectOnError:null,readOnly:false,stringNumbers:false,maxRetriesPerRequest:20,maxLoadingRetryTime:1e4,enableAutoPipelining:false,autoPipeliningIgnoredCommands:[],sentinelMaxConnections:10}},7778:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.readyHandler=t.errorHandler=t.closeHandler=t.connectHandler=void 0;const r=n(8287);const i=n(5372);const s=n(3417);const a=n(9335);const o=n(2161);const l=(0,a.Debug)("connection");function connectHandler(e){return function(){e.setStatus("connect");e.resetCommandQueue();let n=false;const{connectionEpoch:r}=e;if(e.condition.auth){e.auth(e.condition.auth,(function(t){if(r!==e.connectionEpoch){return}if(t){if(t.message.indexOf("no password is set")!==-1){console.warn("[WARN] Redis server does not require a password, but a password was supplied.")}else if(t.message.indexOf("without any password configured for the default user")!==-1){console.warn("[WARN] This Redis server's `default` user does not require a password, but a password was supplied")}else if(t.message.indexOf("wrong number of arguments for 'auth' command")!==-1){console.warn(`[ERROR] The server returned "wrong number of arguments for 'auth' command". You are probably passing both username and password to Redis version 5 or below. You should only pass the 'password' option for Redis version 5 and under.`)}else{n=true;e.recoverFromFatalError(t,t)}}}))}if(e.condition.select){e.select(e.condition.select).catch((t=>{e.silentEmit("error",t)}))}if(!e.options.enableReadyCheck){t.readyHandler(e)()}new o.default(e,{stringNumbers:e.options.stringNumbers});if(e.options.enableReadyCheck){e._readyCheck((function(i,s){if(r!==e.connectionEpoch){return}if(i){if(!n){e.recoverFromFatalError(new Error("Ready check failed: "+i.message),i)}}else{if(e.connector.check(s)){t.readyHandler(e)()}else{e.disconnect(true)}}}))}}}t.connectHandler=connectHandler;function abortError(e){const t=new r.AbortError("Command aborted due to connection close");t.command={name:e.name,args:e.args};return t}function abortIncompletePipelines(e){var t;let n=0;for(let r=0;r<e.length;){const i=(t=e.peekAt(r))===null||t===void 0?void 0:t.command;const s=i.pipelineIndex;if(s===undefined||s===0){n=0}if(s!==undefined&&s!==n++){e.remove(r,1);i.reject(abortError(i));continue}r++}}function abortTransactionFragments(e){var t;for(let n=0;n<e.length;){const r=(t=e.peekAt(n))===null||t===void 0?void 0:t.command;if(r.name==="multi"){break}if(r.name==="exec"){e.remove(n,1);r.reject(abortError(r));break}if(r.inTransaction){e.remove(n,1);r.reject(abortError(r))}else{n++}}}function closeHandler(e){return function(){const t=e.status;e.setStatus("close");if(e.commandQueue.length){abortIncompletePipelines(e.commandQueue)}if(e.offlineQueue.length){abortTransactionFragments(e.offlineQueue)}if(t==="ready"){if(!e.prevCondition){e.prevCondition=e.condition}if(e.commandQueue.length){e.prevCommandQueue=e.commandQueue}}if(e.manuallyClosing){e.manuallyClosing=false;l("skip reconnecting since the connection is manually closed.");return close()}if(typeof e.options.retryStrategy!=="function"){l("skip reconnecting because `retryStrategy` is not a function");return close()}const n=e.options.retryStrategy(++e.retryAttempts);if(typeof n!=="number"){l("skip reconnecting because `retryStrategy` doesn't return a number");return close()}l("reconnect in %sms",n);e.setStatus("reconnecting",n);e.reconnectTimeout=setTimeout((function(){e.reconnectTimeout=null;e.connect().catch(a.noop)}),n);const{maxRetriesPerRequest:r}=e.options;if(typeof r==="number"){if(r<0){l("maxRetriesPerRequest is negative, ignoring...")}else{const t=e.retryAttempts%(r+1);if(t===0){l("reach maxRetriesPerRequest limitation, flushing command queue...");e.flushQueue(new s.MaxRetriesPerRequestError(r))}}}};function close(){e.setStatus("end");e.flushQueue(new Error(a.CONNECTION_CLOSED_ERROR_MSG))}}t.closeHandler=closeHandler;function errorHandler(e){return function(t){l("error: %s",t);e.silentEmit("error",t)}}t.errorHandler=errorHandler;function readyHandler(e){return function(){e.setStatus("ready");e.retryAttempts=0;if(e.options.monitor){e.call("monitor").then((()=>e.setStatus("monitoring")),(t=>e.emit("error",t)));const{sendCommand:t}=e;e.sendCommand=function(n){if(i.default.checkFlag("VALID_IN_MONITOR_MODE",n.name)){return t.call(e,n)}n.reject(new Error("Connection is in monitoring mode, can't process commands."));return n.promise};e.once("close",(function(){delete e.sendCommand}));return}const t=e.prevCondition?e.prevCondition.select:e.condition.select;if(e.options.connectionName){l("set the connection name [%s]",e.options.connectionName);e.client("setname",e.options.connectionName).catch(a.noop)}if(e.options.readOnly){l("set the connection to readonly mode");e.readonly().catch(a.noop)}if(e.prevCondition){const n=e.prevCondition;e.prevCondition=null;if(n.subscriber&&e.options.autoResubscribe){if(e.condition.select!==t){l("connect to db [%d]",t);e.select(t)}const r=n.subscriber.channels("subscribe");if(r.length){l("subscribe %d channels",r.length);e.subscribe(r)}const i=n.subscriber.channels("psubscribe");if(i.length){l("psubscribe %d channels",i.length);e.psubscribe(i)}const s=n.subscriber.channels("ssubscribe");if(s.length){l("ssubscribe %d channels",s.length);e.ssubscribe(s)}}}if(e.prevCommandQueue){if(e.options.autoResendUnfulfilledCommands){l("resend %d unfulfilled commands",e.prevCommandQueue.length);while(e.prevCommandQueue.length>0){const t=e.prevCommandQueue.shift();if(t.select!==e.condition.select&&t.command.name!=="select"){e.select(t.select)}e.sendCommand(t.command,t.stream)}}else{e.prevCommandQueue=null}}if(e.offlineQueue.length){l("send %d commands in offline queue",e.offlineQueue.length);const t=e.offlineQueue;e.resetOfflineQueue();while(t.length>0){const n=t.shift();if(n.select!==e.condition.select&&n.command.name!=="select"){e.select(n.select)}e.sendCommand(n.command,n.stream)}}if(e.condition.select!==t){l("connect to db [%d]",t);e.select(t)}}}t.readyHandler=readyHandler},1101:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.addTransactionSupport=void 0;const r=n(9335);const i=n(2460);const s=n(8823);function addTransactionSupport(e){e.pipeline=function(e){const t=new s.default(this);if(Array.isArray(e)){t.addBatch(e)}return t};const{multi:t}=e;e.multi=function(e,n){if(typeof n==="undefined"&&!Array.isArray(e)){n=e;e=null}if(n&&n.pipeline===false){return t.call(this)}const a=new s.default(this);a.multi();if(Array.isArray(e)){a.addBatch(e)}const o=a.exec;a.exec=function(e){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(r.noop);return(0,i.default)(new Promise(((e,t)=>{this.redis.delayUntilReady((n=>{if(n){t(n);return}this.exec(a).then(e,t)}))})),e)}if(this._transactions>0){o.call(a)}if(this.nodeifiedPromise){return o.call(a)}const t=o.call(a);return(0,i.default)(t.then((function(e){const t=e[e.length-1];if(typeof t==="undefined"){throw new Error("Pipeline cannot be used to send any commands when the `exec()` has been called on it.")}if(t[0]){t[0].previousErrors=[];for(let n=0;n<e.length-1;++n){if(e[n][0]){t[0].previousErrors.push(e[n][0])}}throw t[0]}return(0,r.wrapMultiResult)(t[1])})),e)};const{execBuffer:l}=a;a.execBuffer=function(e){if(this._transactions>0){l.call(a)}return a.exec(e)};return a};const{exec:n}=e;e.exec=function(e){return(0,i.default)(n.call(this).then((function(e){if(Array.isArray(e)){e=(0,r.wrapMultiResult)(e)}return e})),e)}}t.addTransactionSupport=addTransactionSupport},4489:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(3175);const i=n(407);const s=n(5372);const a=n(7334);class Commander{constructor(){this.options={};this.scriptsSet={};this.addedBuiltinSet=new Set}getBuiltinCommands(){return o.slice(0)}createBuiltinCommand(e){return{string:generateFunction(null,e,"utf8"),buffer:generateFunction(null,e,null)}}addBuiltinCommand(e){this.addedBuiltinSet.add(e);this[e]=generateFunction(e,e,"utf8");this[e+"Buffer"]=generateFunction(e+"Buffer",e,null)}defineCommand(e,t){const n=new a.default(t.lua,t.numberOfKeys,this.options.keyPrefix,t.readOnly);this.scriptsSet[e]=n;this[e]=generateScriptingFunction(e,e,n,"utf8");this[e+"Buffer"]=generateScriptingFunction(e+"Buffer",e,n,null)}sendCommand(e,t,n){throw new Error('"sendCommand" is not implemented')}}const o=r.list.filter((e=>e!=="monitor"));o.push("sentinel");o.forEach((function(e){Commander.prototype[e]=generateFunction(e,e,"utf8");Commander.prototype[e+"Buffer"]=generateFunction(e+"Buffer",e,null)}));Commander.prototype.call=generateFunction("call","utf8");Commander.prototype.callBuffer=generateFunction("callBuffer",null);Commander.prototype.send_command=Commander.prototype.call;function generateFunction(e,t,n){if(typeof n==="undefined"){n=t;t=null}return function(...r){const a=t||r.shift();let o=r[r.length-1];if(typeof o==="function"){r.pop()}else{o=undefined}const l={errorStack:this.options.showFriendlyErrorStack?new Error:undefined,keyPrefix:this.options.keyPrefix,replyEncoding:n};if(!(0,i.shouldUseAutoPipelining)(this,e,a)){return this.sendCommand(new s.default(a,r,l,o))}return(0,i.executeWithAutoPipelining)(this,e,a,r,o)}}function generateScriptingFunction(e,t,n,r){return function(...s){const a=typeof s[s.length-1]==="function"?s.pop():undefined;const o={replyEncoding:r};if(this.options.showFriendlyErrorStack){o.errorStack=new Error}if(!(0,i.shouldUseAutoPipelining)(this,e,t)){return n.execute(this,s,o,a)}return(0,i.executeWithAutoPipelining)(this,e,t,s,a)}}t["default"]=Commander},9066:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function applyMixin(e,t){Object.getOwnPropertyNames(t.prototype).forEach((n=>{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))}))}t["default"]=applyMixin},7800:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.genRedactedString=t.getStringValue=t.MAX_ARGUMENT_LENGTH=void 0;const r=n(6449);const i=200;t.MAX_ARGUMENT_LENGTH=i;const s="ioredis";function getStringValue(e){if(e===null){return}switch(typeof e){case"boolean":return;case"number":return;case"object":if(Buffer.isBuffer(e)){return e.toString("hex")}if(Array.isArray(e)){return e.join(",")}try{return JSON.stringify(e)}catch(e){return}case"string":return e}}t.getStringValue=getStringValue;function genRedactedString(e,t){const{length:n}=e;return n<=t?e:e.slice(0,t)+' ... <REDACTED full-length="'+n+'">'}t.genRedactedString=genRedactedString;function genDebugFunction(e){const t=(0,r.default)(`${s}:${e}`);function wrappedDebug(...e){if(!t.enabled){return}for(let t=1;t<e.length;t++){const n=getStringValue(e[t]);if(typeof n==="string"&&n.length>i){e[t]=genRedactedString(n,i)}}return t.apply(null,e)}Object.defineProperties(wrappedDebug,{namespace:{get(){return t.namespace}},enabled:{get(){return t.enabled}},destroy:{get(){return t.destroy}},log:{get(){return t.log},set(e){t.log=e}}});return wrappedDebug}t["default"]=genDebugFunction},9335:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.noop=t.defaults=t.Debug=t.zipMap=t.CONNECTION_CLOSED_ERROR_MSG=t.shuffle=t.sample=t.resolveTLSProfile=t.parseURL=t.optimizeErrorStack=t.toArg=t.convertMapToArray=t.convertObjectToArray=t.timeout=t.packObject=t.isInt=t.wrapMultiResult=t.convertBufferToString=void 0;const r=n(7016);const i=n(150);Object.defineProperty(t,"defaults",{enumerable:true,get:function(){return i.defaults}});Object.defineProperty(t,"noop",{enumerable:true,get:function(){return i.noop}});const s=n(7800);t.Debug=s.default;const a=n(424);function convertBufferToString(e,t){if(e instanceof Buffer){return e.toString(t)}if(Array.isArray(e)){const n=e.length;const r=Array(n);for(let i=0;i<n;++i){r[i]=e[i]instanceof Buffer&&t==="utf8"?e[i].toString():convertBufferToString(e[i],t)}return r}return e}t.convertBufferToString=convertBufferToString;function wrapMultiResult(e){if(!e){return null}const t=[];const n=e.length;for(let r=0;r<n;++r){const n=e[r];if(n instanceof Error){t.push([n])}else{t.push([null,n])}}return t}t.wrapMultiResult=wrapMultiResult;function isInt(e){const t=parseFloat(e);return!isNaN(e)&&(t|0)===t}t.isInt=isInt;function packObject(e){const t={};const n=e.length;for(let r=1;r<n;r+=2){t[e[r-1]]=e[r]}return t}t.packObject=packObject;function timeout(e,t){let n=null;const run=function(){if(n){clearTimeout(n);n=null;e.apply(this,arguments)}};n=setTimeout(run,t,new Error("timeout"));return run}t.timeout=timeout;function convertObjectToArray(e){const t=[];const n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){t.push(n[r],e[n[r]])}return t}t.convertObjectToArray=convertObjectToArray;function convertMapToArray(e){const t=[];let n=0;e.forEach((function(e,r){t[n]=r;t[n+1]=e;n+=2}));return t}t.convertMapToArray=convertMapToArray;function toArg(e){if(e===null||typeof e==="undefined"){return""}return String(e)}t.toArg=toArg;function optimizeErrorStack(e,t,n){const r=t.split("\n");let i="";let s;for(s=1;s<r.length;++s){if(r[s].indexOf(n)===-1){break}}for(let e=s;e<r.length;++e){i+="\n"+r[e]}if(e.stack){const t=e.stack.indexOf("\n");e.stack=e.stack.slice(0,t)+i}return e}t.optimizeErrorStack=optimizeErrorStack;function parseURL(e){if(isInt(e)){return{port:e}}let t=(0,r.parse)(e,true,true);if(!t.slashes&&e[0]!=="/"){e="//"+e;t=(0,r.parse)(e,true,true)}const n=t.query||{};const s={};if(t.auth){const e=t.auth.indexOf(":");s.username=e===-1?t.auth:t.auth.slice(0,e);s.password=e===-1?"":t.auth.slice(e+1)}if(t.pathname){if(t.protocol==="redis:"||t.protocol==="rediss:"){if(t.pathname.length>1){s.db=t.pathname.slice(1)}}else{s.path=t.pathname}}if(t.host){s.host=t.hostname}if(t.port){s.port=t.port}if(typeof n.family==="string"){const e=Number.parseInt(n.family,10);if(!Number.isNaN(e)){s.family=e}}(0,i.defaults)(s,n);return s}t.parseURL=parseURL;function resolveTLSProfile(e){let t=e===null||e===void 0?void 0:e.tls;if(typeof t==="string")t={profile:t};const n=a.default[t===null||t===void 0?void 0:t.profile];if(n){t=Object.assign({},n,t);delete t.profile;e=Object.assign({},e,{tls:t})}return e}t.resolveTLSProfile=resolveTLSProfile;function sample(e,t=0){const n=e.length;if(t>=n){return null}return e[t+Math.floor(Math.random()*(n-t))]}t.sample=sample;function shuffle(e){let t=e.length;while(t>0){const n=Math.floor(Math.random()*t);t--;[e[t],e[n]]=[e[n],e[t]]}return e}t.shuffle=shuffle;t.CONNECTION_CLOSED_ERROR_MSG="Connection is closed.";function zipMap(e,t){const n=new Map;e.forEach(((e,r)=>{n.set(e,t[r])}));return n}t.zipMap=zipMap},150:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.isArguments=t.defaults=t.noop=void 0;const r=n(4242);t.defaults=r;const i=n(8952);t.isArguments=i;function noop(){}t.noop=noop},4242:function(e){var t=9007199254740991;var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]";var s=/^(?:0|[1-9]\d*)$/;function apply(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function baseTimes(e,t){var n=-1,r=Array(e);while(++n<e){r[n]=t(n)}return r}var a=Object.prototype;var o=a.hasOwnProperty;var l=a.toString;var c=a.propertyIsEnumerable;var u=Math.max;function arrayLikeKeys(e,t){var n=d(e)||isArguments(e)?baseTimes(e.length,String):[];var r=n.length,i=!!r;for(var s in e){if((t||o.call(e,s))&&!(i&&(s=="length"||isIndex(s,r)))){n.push(s)}}return n}function assignInDefaults(e,t,n,r){if(e===undefined||eq(e,a[n])&&!o.call(r,n)){return t}return e}function assignValue(e,t,n){var r=e[t];if(!(o.call(e,t)&&eq(r,n))||n===undefined&&!(t in e)){e[t]=n}}function baseKeysIn(e){if(!isObject(e)){return nativeKeysIn(e)}var t=isPrototype(e),n=[];for(var r in e){if(!(r=="constructor"&&(t||!o.call(e,r)))){n.push(r)}}return n}function baseRest(e,t){t=u(t===undefined?e.length-1:t,0);return function(){var n=arguments,r=-1,i=u(n.length-t,0),s=Array(i);while(++r<i){s[r]=n[t+r]}r=-1;var a=Array(t+1);while(++r<t){a[r]=n[r]}a[t]=s;return apply(e,this,a)}}function copyObject(e,t,n,r){n||(n={});var i=-1,s=t.length;while(++i<s){var a=t[i];var o=r?r(n[a],e[a],a,n,e):undefined;assignValue(n,a,o===undefined?e[a]:o)}return n}function createAssigner(e){return baseRest((function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:undefined,a=i>2?n[2]:undefined;s=e.length>3&&typeof s=="function"?(i--,s):undefined;if(a&&isIterateeCall(n[0],n[1],a)){s=i<3?undefined:s;i=1}t=Object(t);while(++r<i){var o=n[r];if(o){e(t,o,r,s)}}return t}))}function isIndex(e,n){n=n==null?t:n;return!!n&&(typeof e=="number"||s.test(e))&&(e>-1&&e%1==0&&e<n)}function isIterateeCall(e,t,n){if(!isObject(n)){return false}var r=typeof t;if(r=="number"?isArrayLike(n)&&isIndex(t,n.length):r=="string"&&t in n){return eq(n[t],e)}return false}function isPrototype(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||a;return e===n}function nativeKeysIn(e){var t=[];if(e!=null){for(var n in Object(e)){t.push(n)}}return t}function eq(e,t){return e===t||e!==e&&t!==t}function isArguments(e){return isArrayLikeObject(e)&&o.call(e,"callee")&&(!c.call(e,"callee")||l.call(e)==n)}var d=Array.isArray;function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function isFunction(e){var t=isObject(e)?l.call(e):"";return t==r||t==i}function isLength(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=t}function isObject(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function isObjectLike(e){return!!e&&typeof e=="object"}var f=createAssigner((function(e,t,n,r){copyObject(t,keysIn(t),e,r)}));var p=baseRest((function(e){e.push(undefined,assignInDefaults);return apply(f,undefined,e)}));function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,true):baseKeysIn(e)}e.exports=p},8952:function(e){var t=9007199254740991;var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]";var s=Object.prototype;var a=s.hasOwnProperty;var o=s.toString;var l=s.propertyIsEnumerable;function isArguments(e){return isArrayLikeObject(e)&&a.call(e,"callee")&&(!l.call(e,"callee")||o.call(e)==n)}function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function isFunction(e){var t=isObject(e)?o.call(e):"";return t==r||t==i}function isLength(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=t}function isObject(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function isObjectLike(e){return!!e&&typeof e=="object"}e.exports=isArguments},8588:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});class LuxonError extends Error{}class InvalidDateTimeError extends LuxonError{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class InvalidIntervalError extends LuxonError{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class InvalidDurationError extends LuxonError{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class ConflictingSpecificationError extends LuxonError{}class InvalidUnitError extends LuxonError{constructor(e){super(`Invalid unit ${e}`)}}class InvalidArgumentError extends LuxonError{}class ZoneIsAbstractError extends LuxonError{constructor(){super("Zone is an abstract class")}}const n="numeric",r="short",i="long";const s={year:n,month:n,day:n};const a={year:n,month:r,day:n};const o={year:n,month:r,day:n,weekday:r};const l={year:n,month:i,day:n};const c={year:n,month:i,day:n,weekday:i};const u={hour:n,minute:n};const d={hour:n,minute:n,second:n};const f={hour:n,minute:n,second:n,timeZoneName:r};const p={hour:n,minute:n,second:n,timeZoneName:i};const h={hour:n,minute:n,hourCycle:"h23"};const y={hour:n,minute:n,second:n,hourCycle:"h23"};const m={hour:n,minute:n,second:n,hourCycle:"h23",timeZoneName:r};const b={hour:n,minute:n,second:n,hourCycle:"h23",timeZoneName:i};const g={year:n,month:n,day:n,hour:n,minute:n};const v={year:n,month:n,day:n,hour:n,minute:n,second:n};const K={year:n,month:r,day:n,hour:n,minute:n};const S={year:n,month:r,day:n,hour:n,minute:n,second:n};const E={year:n,month:r,day:n,weekday:r,hour:n,minute:n};const k={year:n,month:i,day:n,hour:n,minute:n,timeZoneName:r};const I={year:n,month:i,day:n,hour:n,minute:n,second:n,timeZoneName:r};const w={year:n,month:i,day:n,weekday:i,hour:n,minute:n,timeZoneName:i};const j={year:n,month:i,day:n,weekday:i,hour:n,minute:n,second:n,timeZoneName:i};class Zone{get type(){throw new ZoneIsAbstractError}get name(){throw new ZoneIsAbstractError}get ianaName(){return this.name}get isUniversal(){throw new ZoneIsAbstractError}offsetName(e,t){throw new ZoneIsAbstractError}formatOffset(e,t){throw new ZoneIsAbstractError}offset(e){throw new ZoneIsAbstractError}equals(e){throw new ZoneIsAbstractError}get isValid(){throw new ZoneIsAbstractError}}let x=null;class SystemZone extends Zone{static get instance(){if(x===null){x=new SystemZone}return x}get type(){return"system"}get name(){return(new Intl.DateTimeFormat).resolvedOptions().timeZone}get isUniversal(){return false}offsetName(e,{format:t,locale:n}){return parseZoneInfo(e,t,n)}formatOffset(e,t){return formatOffset(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return true}}let T={};function makeDTF(e){if(!T[e]){T[e]=new Intl.DateTimeFormat("en-US",{hour12:false,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"})}return T[e]}const D={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function hackyOffset(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,i,s,a,o,l,c,u]=r;return[a,i,s,o,l,c,u]}function partsOffset(e,t){const n=e.formatToParts(t);const r=[];for(let e=0;e<n.length;e++){const{type:t,value:i}=n[e];const s=D[t];if(t==="era"){r[s]=i}else if(!isUndefined(s)){r[s]=parseInt(i,10)}}return r}let O={};class IANAZone extends Zone{static create(e){if(!O[e]){O[e]=new IANAZone(e)}return O[e]}static resetCache(){O={};T={}}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e){return false}try{new Intl.DateTimeFormat("en-US",{timeZone:e}).format();return true}catch(e){return false}}constructor(e){super();this.zoneName=e;this.valid=IANAZone.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return false}offsetName(e,{format:t,locale:n}){return parseZoneInfo(e,t,n,this.name)}formatOffset(e,t){return formatOffset(this.offset(e),t)}offset(e){const t=new Date(e);if(isNaN(t))return NaN;const n=makeDTF(this.name);let[r,i,s,a,o,l,c]=n.formatToParts?partsOffset(n,t):hackyOffset(n,t);if(a==="BC"){r=-Math.abs(r)+1}const u=o===24?0:o;const d=objToLocalTS({year:r,month:i,day:s,hour:u,minute:l,second:c,millisecond:0});let f=+t;const p=f%1e3;f-=p>=0?p:1e3+p;return(d-f)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let C={};function getCachedLF(e,t={}){const n=JSON.stringify([e,t]);let r=C[n];if(!r){r=new Intl.ListFormat(e,t);C[n]=r}return r}let A={};function getCachedDTF(e,t={}){const n=JSON.stringify([e,t]);let r=A[n];if(!r){r=new Intl.DateTimeFormat(e,t);A[n]=r}return r}let R={};function getCachedINF(e,t={}){const n=JSON.stringify([e,t]);let r=R[n];if(!r){r=new Intl.NumberFormat(e,t);R[n]=r}return r}let _={};function getCachedRTF(e,t={}){const{base:n,...r}=t;const i=JSON.stringify([e,r]);let s=_[i];if(!s){s=new Intl.RelativeTimeFormat(e,t);_[i]=s}return s}let M=null;function systemLocale(){if(M){return M}else{M=(new Intl.DateTimeFormat).resolvedOptions().locale;return M}}let P={};function getCachedWeekInfo(e){let t=P[e];if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo;P[e]=t}return t}function parseLocaleString(e){const t=e.indexOf("-x-");if(t!==-1){e=e.substring(0,t)}const n=e.indexOf("-u-");if(n===-1){return[e]}else{let t;let r;try{t=getCachedDTF(e).resolvedOptions();r=e}catch(i){const s=e.substring(0,n);t=getCachedDTF(s).resolvedOptions();r=s}const{numberingSystem:i,calendar:s}=t;return[r,i,s]}}function intlConfigString(e,t,n){if(n||t){if(!e.includes("-u-")){e+="-u"}if(n){e+=`-ca-${n}`}if(t){e+=`-nu-${t}`}return e}else{return e}}function mapMonths(e){const t=[];for(let n=1;n<=12;n++){const r=DateTime.utc(2009,n,1);t.push(e(r))}return t}function mapWeekdays(e){const t=[];for(let n=1;n<=7;n++){const r=DateTime.utc(2016,11,13+n);t.push(e(r))}return t}function listStuff(e,t,n,r){const i=e.listingMode();if(i==="error"){return null}else if(i==="en"){return n(t)}else{return r(t)}}function supportsFastNumbers(e){if(e.numberingSystem&&e.numberingSystem!=="latn"){return false}else{return e.numberingSystem==="latn"||!e.locale||e.locale.startsWith("en")||new Intl.DateTimeFormat(e.intl).resolvedOptions().numberingSystem==="latn"}}class PolyNumberFormatter{constructor(e,t,n){this.padTo=n.padTo||0;this.floor=n.floor||false;const{padTo:r,floor:i,...s}=n;if(!t||Object.keys(s).length>0){const t={useGrouping:false,...n};if(n.padTo>0)t.minimumIntegerDigits=n.padTo;this.inf=getCachedINF(e,t)}}format(e){if(this.inf){const t=this.floor?Math.floor(e):e;return this.inf.format(t)}else{const t=this.floor?Math.floor(e):roundTo(e,3);return padStart(t,this.padTo)}}}class PolyDateFormatter{constructor(e,t,n){this.opts=n;this.originalZone=undefined;let r=undefined;if(this.opts.timeZone){this.dt=e}else if(e.zone.type==="fixed"){const t=-1*(e.offset/60);const n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;if(e.offset!==0&&IANAZone.create(n).valid){r=n;this.dt=e}else{r="UTC";this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset});this.originalZone=e.zone}}else if(e.zone.type==="system"){this.dt=e}else if(e.zone.type==="iana"){this.dt=e;r=e.zone.name}else{r="UTC";this.dt=e.setZone("UTC").plus({minutes:e.offset});this.originalZone=e.zone}const i={...this.opts};i.timeZone=i.timeZone||r;this.dtf=getCachedDTF(t,i)}format(){if(this.originalZone){return this.formatToParts().map((({value:e})=>e)).join("")}return this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());if(this.originalZone){return e.map((e=>{if(e.type==="timeZoneName"){const t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}else{return e}}))}return e}resolvedOptions(){return this.dtf.resolvedOptions()}}class PolyRelFormatter{constructor(e,t,n){this.opts={style:"long",...n};if(!t&&hasRelative()){this.rtf=getCachedRTF(e,n)}}format(e,t){if(this.rtf){return this.rtf.format(e,t)}else{return formatRelativeTime(t,e,this.opts.numeric,this.opts.style!=="long")}}formatToParts(e,t){if(this.rtf){return this.rtf.formatToParts(e,t)}else{return[]}}}const N={firstDay:1,minimalDays:4,weekend:[6,7]};class Locale{static fromOpts(e){return Locale.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,t,n,r,i=false){const s=e||Settings.defaultLocale;const a=s||(i?"en-US":systemLocale());const o=t||Settings.defaultNumberingSystem;const l=n||Settings.defaultOutputCalendar;const c=validateWeekSettings(r)||Settings.defaultWeekSettings;return new Locale(a,o,l,c,s)}static resetCache(){M=null;A={};R={};_={}}static fromObject({locale:e,numberingSystem:t,outputCalendar:n,weekSettings:r}={}){return Locale.create(e,t,n,r)}constructor(e,t,n,r,i){const[s,a,o]=parseLocaleString(e);this.locale=s;this.numberingSystem=t||a||null;this.outputCalendar=n||o||null;this.weekSettings=r;this.intl=intlConfigString(this.locale,this.numberingSystem,this.outputCalendar);this.weekdaysCache={format:{},standalone:{}};this.monthsCache={format:{},standalone:{}};this.meridiemCache=null;this.eraCache={};this.specifiedLocale=i;this.fastNumbersCached=null}get fastNumbers(){if(this.fastNumbersCached==null){this.fastNumbersCached=supportsFastNumbers(this)}return this.fastNumbersCached}listingMode(){const e=this.isEnglish();const t=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&t?"en":"intl"}clone(e){if(!e||Object.getOwnPropertyNames(e).length===0){return this}else{return Locale.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,validateWeekSettings(e.weekSettings)||this.weekSettings,e.defaultToEN||false)}}redefaultToEN(e={}){return this.clone({...e,defaultToEN:true})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:false})}months(e,t=false){return listStuff(this,e,months,(()=>{const n=t?{month:e,day:"numeric"}:{month:e},r=t?"format":"standalone";if(!this.monthsCache[r][e]){this.monthsCache[r][e]=mapMonths((e=>this.extract(e,n,"month")))}return this.monthsCache[r][e]}))}weekdays(e,t=false){return listStuff(this,e,weekdays,(()=>{const n=t?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=t?"format":"standalone";if(!this.weekdaysCache[r][e]){this.weekdaysCache[r][e]=mapWeekdays((e=>this.extract(e,n,"weekday")))}return this.weekdaysCache[r][e]}))}meridiems(){return listStuff(this,undefined,(()=>ie),(()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[DateTime.utc(2016,11,13,9),DateTime.utc(2016,11,13,19)].map((t=>this.extract(t,e,"dayperiod")))}return this.meridiemCache}))}eras(e){return listStuff(this,e,eras,(()=>{const t={era:e};if(!this.eraCache[e]){this.eraCache[e]=[DateTime.utc(-40,1,1),DateTime.utc(2017,1,1)].map((e=>this.extract(e,t,"era")))}return this.eraCache[e]}))}extract(e,t,n){const r=this.dtFormatter(e,t),i=r.formatToParts(),s=i.find((e=>e.type.toLowerCase()===n));return s?s.value:null}numberFormatter(e={}){return new PolyNumberFormatter(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new PolyDateFormatter(e,this.intl,t)}relFormatter(e={}){return new PolyRelFormatter(this.intl,this.isEnglish(),e)}listFormatter(e={}){return getCachedLF(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us")}getWeekSettings(){if(this.weekSettings){return this.weekSettings}else if(!hasLocaleWeekInfo()){return N}else{return getCachedWeekInfo(this.locale)}}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let L=null;class FixedOffsetZone extends Zone{static get utcInstance(){if(L===null){L=new FixedOffsetZone(0)}return L}static instance(e){return e===0?FixedOffsetZone.utcInstance:new FixedOffsetZone(e)}static parseSpecifier(e){if(e){const t=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(t){return new FixedOffsetZone(signedOffset(t[1],t[2]))}}return null}constructor(e){super();this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${formatOffset(this.fixed,"narrow")}`}get ianaName(){if(this.fixed===0){return"Etc/UTC"}else{return`Etc/GMT${formatOffset(-this.fixed,"narrow")}`}}offsetName(){return this.name}formatOffset(e,t){return formatOffset(this.fixed,t)}get isUniversal(){return true}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return true}}class InvalidZone extends Zone{constructor(e){super();this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return false}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return false}get isValid(){return false}}function normalizeZone(e,t){if(isUndefined(e)||e===null){return t}else if(e instanceof Zone){return e}else if(isString(e)){const n=e.toLowerCase();if(n==="default")return t;else if(n==="local"||n==="system")return SystemZone.instance;else if(n==="utc"||n==="gmt")return FixedOffsetZone.utcInstance;else return FixedOffsetZone.parseSpecifier(n)||IANAZone.create(e)}else if(isNumber(e)){return FixedOffsetZone.instance(e)}else if(typeof e==="object"&&"offset"in e&&typeof e.offset==="function"){return e}else{return new InvalidZone(e)}}const J={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"};const F={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]};const V=J.hanidec.replace(/[\[|\]]/g,"").split("");function parseDigits(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(e[n].search(J.hanidec)!==-1){t+=V.indexOf(e[n])}else{for(const e in F){const[n,i]=F[e];if(r>=n&&r<=i){t+=r-n}}}}return parseInt(t,10)}else{return t}}let G={};function resetDigitRegexCache(){G={}}function digitRegex({numberingSystem:e},t=""){const n=e||"latn";if(!G[n]){G[n]={}}if(!G[n][t]){G[n][t]=new RegExp(`${J[n]}${t}`)}return G[n][t]}let now=()=>Date.now(),q="system",Y=null,U=null,B=null,W=60,z,Z=null;class Settings{static get now(){return now}static set now(e){now=e}static set defaultZone(e){q=e}static get defaultZone(){return normalizeZone(q,SystemZone.instance)}static get defaultLocale(){return Y}static set defaultLocale(e){Y=e}static get defaultNumberingSystem(){return U}static set defaultNumberingSystem(e){U=e}static get defaultOutputCalendar(){return B}static set defaultOutputCalendar(e){B=e}static get defaultWeekSettings(){return Z}static set defaultWeekSettings(e){Z=validateWeekSettings(e)}static get twoDigitCutoffYear(){return W}static set twoDigitCutoffYear(e){W=e%100}static get throwOnInvalid(){return z}static set throwOnInvalid(e){z=e}static resetCaches(){Locale.resetCache();IANAZone.resetCache();DateTime.resetCache();resetDigitRegexCache()}}class Invalid{constructor(e,t){this.reason=e;this.explanation=t}toMessage(){if(this.explanation){return`${this.reason}: ${this.explanation}`}else{return this.reason}}}const $=[0,31,59,90,120,151,181,212,243,273,304,334],Q=[0,31,60,91,121,152,182,213,244,274,305,335];function unitOutOfRange(e,t){return new Invalid("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function dayOfWeek(e,t,n){const r=new Date(Date.UTC(e,t-1,n));if(e<100&&e>=0){r.setUTCFullYear(r.getUTCFullYear()-1900)}const i=r.getUTCDay();return i===0?7:i}function computeOrdinal(e,t,n){return n+(isLeapYear(e)?Q:$)[t-1]}function uncomputeOrdinal(e,t){const n=isLeapYear(e)?Q:$,r=n.findIndex((e=>e<t)),i=t-n[r];return{month:r+1,day:i}}function isoWeekdayToLocal(e,t){return(e-t+7)%7+1}function gregorianToWeek(e,t=4,n=1){const{year:r,month:i,day:s}=e,a=computeOrdinal(r,i,s),o=isoWeekdayToLocal(dayOfWeek(r,i,s),n);let l=Math.floor((a-o+14-t)/7),c;if(l<1){c=r-1;l=weeksInWeekYear(c,t,n)}else if(l>weeksInWeekYear(r,t,n)){c=r+1;l=1}else{c=r}return{weekYear:c,weekNumber:l,weekday:o,...timeObject(e)}}function weekToGregorian(e,t=4,n=1){const{weekYear:r,weekNumber:i,weekday:s}=e,a=isoWeekdayToLocal(dayOfWeek(r,1,t),n),o=daysInYear(r);let l=i*7+s-a-7+t,c;if(l<1){c=r-1;l+=daysInYear(c)}else if(l>o){c=r+1;l-=daysInYear(r)}else{c=r}const{month:u,day:d}=uncomputeOrdinal(c,l);return{year:c,month:u,day:d,...timeObject(e)}}function gregorianToOrdinal(e){const{year:t,month:n,day:r}=e;const i=computeOrdinal(t,n,r);return{year:t,ordinal:i,...timeObject(e)}}function ordinalToGregorian(e){const{year:t,ordinal:n}=e;const{month:r,day:i}=uncomputeOrdinal(t,n);return{year:t,month:r,day:i,...timeObject(e)}}function usesLocalWeekValues(e,t){const n=!isUndefined(e.localWeekday)||!isUndefined(e.localWeekNumber)||!isUndefined(e.localWeekYear);if(n){const n=!isUndefined(e.weekday)||!isUndefined(e.weekNumber)||!isUndefined(e.weekYear);if(n){throw new ConflictingSpecificationError("Cannot mix locale-based week fields with ISO-based week fields")}if(!isUndefined(e.localWeekday))e.weekday=e.localWeekday;if(!isUndefined(e.localWeekNumber))e.weekNumber=e.localWeekNumber;if(!isUndefined(e.localWeekYear))e.weekYear=e.localWeekYear;delete e.localWeekday;delete e.localWeekNumber;delete e.localWeekYear;return{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else{return{minDaysInFirstWeek:4,startOfWeek:1}}}function hasInvalidWeekData(e,t=4,n=1){const r=isInteger(e.weekYear),i=integerBetween(e.weekNumber,1,weeksInWeekYear(e.weekYear,t,n)),s=integerBetween(e.weekday,1,7);if(!r){return unitOutOfRange("weekYear",e.weekYear)}else if(!i){return unitOutOfRange("week",e.weekNumber)}else if(!s){return unitOutOfRange("weekday",e.weekday)}else return false}function hasInvalidOrdinalData(e){const t=isInteger(e.year),n=integerBetween(e.ordinal,1,daysInYear(e.year));if(!t){return unitOutOfRange("year",e.year)}else if(!n){return unitOutOfRange("ordinal",e.ordinal)}else return false}function hasInvalidGregorianData(e){const t=isInteger(e.year),n=integerBetween(e.month,1,12),r=integerBetween(e.day,1,daysInMonth(e.year,e.month));if(!t){return unitOutOfRange("year",e.year)}else if(!n){return unitOutOfRange("month",e.month)}else if(!r){return unitOutOfRange("day",e.day)}else return false}function hasInvalidTimeData(e){const{hour:t,minute:n,second:r,millisecond:i}=e;const s=integerBetween(t,0,23)||t===24&&n===0&&r===0&&i===0,a=integerBetween(n,0,59),o=integerBetween(r,0,59),l=integerBetween(i,0,999);if(!s){return unitOutOfRange("hour",t)}else if(!a){return unitOutOfRange("minute",n)}else if(!o){return unitOutOfRange("second",r)}else if(!l){return unitOutOfRange("millisecond",i)}else return false}function isUndefined(e){return typeof e==="undefined"}function isNumber(e){return typeof e==="number"}function isInteger(e){return typeof e==="number"&&e%1===0}function isString(e){return typeof e==="string"}function isDate(e){return Object.prototype.toString.call(e)==="[object Date]"}function hasRelative(){try{return typeof Intl!=="undefined"&&!!Intl.RelativeTimeFormat}catch(e){return false}}function hasLocaleWeekInfo(){try{return typeof Intl!=="undefined"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch(e){return false}}function maybeArray(e){return Array.isArray(e)?e:[e]}function bestBy(e,t,n){if(e.length===0){return undefined}return e.reduce(((e,r)=>{const i=[t(r),r];if(!e){return i}else if(n(e[0],i[0])===e[0]){return e}else{return i}}),null)[1]}function pick(e,t){return t.reduce(((t,n)=>{t[n]=e[n];return t}),{})}function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function validateWeekSettings(e){if(e==null){return null}else if(typeof e!=="object"){throw new InvalidArgumentError("Week settings must be an object")}else{if(!integerBetween(e.firstDay,1,7)||!integerBetween(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some((e=>!integerBetween(e,1,7)))){throw new InvalidArgumentError("Invalid week settings")}return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}}function integerBetween(e,t,n){return isInteger(e)&&e>=t&&e<=n}function floorMod(e,t){return e-t*Math.floor(e/t)}function padStart(e,t=2){const n=e<0;let r;if(n){r="-"+(""+-e).padStart(t,"0")}else{r=(""+e).padStart(t,"0")}return r}function parseInteger(e){if(isUndefined(e)||e===null||e===""){return undefined}else{return parseInt(e,10)}}function parseFloating(e){if(isUndefined(e)||e===null||e===""){return undefined}else{return parseFloat(e)}}function parseMillis(e){if(isUndefined(e)||e===null||e===""){return undefined}else{const t=parseFloat("0."+e)*1e3;return Math.floor(t)}}function roundTo(e,t,n=false){const r=10**t,i=n?Math.trunc:Math.round;return i(e*r)/r}function isLeapYear(e){return e%4===0&&(e%100!==0||e%400===0)}function daysInYear(e){return isLeapYear(e)?366:365}function daysInMonth(e,t){const n=floorMod(t-1,12)+1,r=e+(t-n)/12;if(n===2){return isLeapYear(r)?29:28}else{return[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}}function objToLocalTS(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);if(e.year<100&&e.year>=0){t=new Date(t);t.setUTCFullYear(e.year,e.month-1,e.day)}return+t}function firstWeekOffset(e,t,n){const r=isoWeekdayToLocal(dayOfWeek(e,1,t),n);return-r+t-1}function weeksInWeekYear(e,t=4,n=1){const r=firstWeekOffset(e,t,n);const i=firstWeekOffset(e+1,t,n);return(daysInYear(e)-r+i)/7}function untruncateYear(e){if(e>99){return e}else return e>Settings.twoDigitCutoffYear?1900+e:2e3+e}function parseZoneInfo(e,t,n,r=null){const i=new Date(e),s={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};if(r){s.timeZone=r}const a={timeZoneName:t,...s};const o=new Intl.DateTimeFormat(n,a).formatToParts(i).find((e=>e.type.toLowerCase()==="timezonename"));return o?o.value:null}function signedOffset(e,t){let n=parseInt(e,10);if(Number.isNaN(n)){n=0}const r=parseInt(t,10)||0,i=n<0||Object.is(n,-0)?-r:r;return n*60+i}function asNumber(e){const t=Number(e);if(typeof e==="boolean"||e===""||Number.isNaN(t))throw new InvalidArgumentError(`Invalid unit value ${e}`);return t}function normalizeObject(e,t){const n={};for(const r in e){if(hasOwnProperty(e,r)){const i=e[r];if(i===undefined||i===null)continue;n[t(r)]=asNumber(i)}}return n}function formatOffset(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?"+":"-";switch(t){case"short":return`${i}${padStart(n,2)}:${padStart(r,2)}`;case"narrow":return`${i}${n}${r>0?`:${r}`:""}`;case"techie":return`${i}${padStart(n,2)}${padStart(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function timeObject(e){return pick(e,["hour","minute","second","millisecond"])}const H=["January","February","March","April","May","June","July","August","September","October","November","December"];const X=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];const ee=["J","F","M","A","M","J","J","A","S","O","N","D"];function months(e){switch(e){case"narrow":return[...ee];case"short":return[...X];case"long":return[...H];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const te=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];const ne=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];const re=["M","T","W","T","F","S","S"];function weekdays(e){switch(e){case"narrow":return[...re];case"short":return[...ne];case"long":return[...te];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const ie=["AM","PM"];const se=["Before Christ","Anno Domini"];const ae=["BC","AD"];const oe=["B","A"];function eras(e){switch(e){case"narrow":return[...oe];case"short":return[...ae];case"long":return[...se];default:return null}}function meridiemForDateTime(e){return ie[e.hour<12?0:1]}function weekdayForDateTime(e,t){return weekdays(t)[e.weekday-1]}function monthForDateTime(e,t){return months(t)[e.month-1]}function eraForDateTime(e,t){return eras(t)[e.year<0?0:1]}function formatRelativeTime(e,t,n="always",r=false){const i={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]};const s=["hours","minutes","seconds"].indexOf(e)===-1;if(n==="auto"&&s){const n=e==="days";switch(t){case 1:return n?"tomorrow":`next ${i[e][0]}`;case-1:return n?"yesterday":`last ${i[e][0]}`;case 0:return n?"today":`this ${i[e][0]}`}}const a=Object.is(t,-0)||t<0,o=Math.abs(t),l=o===1,c=i[e],u=r?l?c[1]:c[2]||c[1]:l?i[e][0]:e;return a?`${o} ${u} ago`:`in ${o} ${u}`}function stringifyTokens(e,t){let n="";for(const r of e){if(r.literal){n+=r.val}else{n+=t(r.val)}}return n}const le={D:s,DD:a,DDD:l,DDDD:c,t:u,tt:d,ttt:f,tttt:p,T:h,TT:y,TTT:m,TTTT:b,f:g,ff:K,fff:k,ffff:w,F:v,FF:S,FFF:I,FFFF:j};class Formatter{static create(e,t={}){return new Formatter(e,t)}static parseFormat(e){let t=null,n="",r=false;const i=[];for(let s=0;s<e.length;s++){const a=e.charAt(s);if(a==="'"){if(n.length>0){i.push({literal:r||/^\s+$/.test(n),val:n})}t=null;n="";r=!r}else if(r){n+=a}else if(a===t){n+=a}else{if(n.length>0){i.push({literal:/^\s+$/.test(n),val:n})}n=a;t=a}}if(n.length>0){i.push({literal:r||/^\s+$/.test(n),val:n})}return i}static macroTokenToFormatOpts(e){return le[e]}constructor(e,t){this.opts=t;this.loc=e;this.systemLoc=null}formatWithSystemDefault(e,t){if(this.systemLoc===null){this.systemLoc=this.loc.redefaultToSystem()}const n=this.systemLoc.dtFormatter(e,{...this.opts,...t});return n.format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){const n=this.dtFormatter(e.start,t);return n.dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0){if(this.opts.forceSimple){return padStart(e,t)}const n={...this.opts};if(t>0){n.padTo=t}return this.loc.numberFormatter(n).format(e)}formatDateTimeFromString(e,t){const n=this.loc.listingMode()==="en",r=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",string=(t,n)=>this.loc.extract(e,t,n),formatOffset=t=>{if(e.isOffsetFixed&&e.offset===0&&t.allowZ){return"Z"}return e.isValid?e.zone.formatOffset(e.ts,t.format):""},meridiem=()=>n?meridiemForDateTime(e):string({hour:"numeric",hourCycle:"h12"},"dayperiod"),month=(t,r)=>n?monthForDateTime(e,t):string(r?{month:t}:{month:t,day:"numeric"},"month"),weekday=(t,r)=>n?weekdayForDateTime(e,t):string(r?{weekday:t}:{weekday:t,month:"long",day:"numeric"},"weekday"),maybeMacro=t=>{const n=Formatter.macroTokenToFormatOpts(t);if(n){return this.formatWithSystemDefault(e,n)}else{return t}},era=t=>n?eraForDateTime(e,t):string({era:t},"era"),tokenToString=t=>{switch(t){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return formatOffset({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return formatOffset({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return formatOffset({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return meridiem();case"d":return r?string({day:"numeric"},"day"):this.num(e.day);case"dd":return r?string({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return weekday("short",true);case"cccc":return weekday("long",true);case"ccccc":return weekday("narrow",true);case"E":return this.num(e.weekday);case"EEE":return weekday("short",false);case"EEEE":return weekday("long",false);case"EEEEE":return weekday("narrow",false);case"L":return r?string({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?string({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return month("short",true);case"LLLL":return month("long",true);case"LLLLL":return month("narrow",true);case"M":return r?string({month:"numeric"},"month"):this.num(e.month);case"MM":return r?string({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return month("short",false);case"MMMM":return month("long",false);case"MMMMM":return month("narrow",false);case"y":return r?string({year:"numeric"},"year"):this.num(e.year);case"yy":return r?string({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?string({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?string({year:"numeric"},"year"):this.num(e.year,6);case"G":return era("short");case"GG":return era("long");case"GGGGG":return era("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return maybeMacro(t)}};return stringifyTokens(Formatter.parseFormat(t),tokenToString)}formatDurationFromString(e,t){const tokenToField=e=>{switch(e[0]){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":return"hour";case"d":return"day";case"w":return"week";case"M":return"month";case"y":return"year";default:return null}},tokenToString=e=>t=>{const n=tokenToField(t);if(n){return this.num(e.get(n),t.length)}else{return t}},n=Formatter.parseFormat(t),r=n.reduce(((e,{literal:t,val:n})=>t?e:e.concat(n)),[]),i=e.shiftTo(...r.map(tokenToField).filter((e=>e)));return stringifyTokens(n,tokenToString(i))}}const ce=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function combineRegexes(...e){const t=e.reduce(((e,t)=>e+t.source),"");return RegExp(`^${t}$`)}function combineExtractors(...e){return t=>e.reduce((([e,n,r],i)=>{const[s,a,o]=i(t,r);return[{...e,...s},a||n,o]}),[{},null,1]).slice(0,2)}function parse(e,...t){if(e==null){return[null,null]}for(const[n,r]of t){const t=n.exec(e);if(t){return r(t)}}return[null,null]}function simpleParse(...e){return(t,n)=>{const r={};let i;for(i=0;i<e.length;i++){r[e[i]]=parseInteger(t[n+i])}return[r,null,n+i]}}const ue=/(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/;const de=`(?:${ue.source}?(?:\\[(${ce.source})\\])?)?`;const fe=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/;const pe=RegExp(`${fe.source}${de}`);const he=RegExp(`(?:T${pe.source})?`);const ye=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/;const me=/(\d{4})-?W(\d\d)(?:-?(\d))?/;const be=/(\d{4})-?(\d{3})/;const ge=simpleParse("weekYear","weekNumber","weekDay");const ve=simpleParse("year","ordinal");const Ke=/(\d{4})-(\d\d)-(\d\d)/;const Se=RegExp(`${fe.source} ?(?:${ue.source}|(${ce.source}))?`);const Ee=RegExp(`(?: ${Se.source})?`);function int(e,t,n){const r=e[t];return isUndefined(r)?n:parseInteger(r)}function extractISOYmd(e,t){const n={year:int(e,t),month:int(e,t+1,1),day:int(e,t+2,1)};return[n,null,t+3]}function extractISOTime(e,t){const n={hours:int(e,t,0),minutes:int(e,t+1,0),seconds:int(e,t+2,0),milliseconds:parseMillis(e[t+3])};return[n,null,t+4]}function extractISOOffset(e,t){const n=!e[t]&&!e[t+1],r=signedOffset(e[t+1],e[t+2]),i=n?null:FixedOffsetZone.instance(r);return[{},i,t+3]}function extractIANAZone(e,t){const n=e[t]?IANAZone.create(e[t]):null;return[{},n,t+1]}const ke=RegExp(`^T?${fe.source}$`);const Ie=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function extractISODuration(e){const[t,n,r,i,s,a,o,l,c]=e;const u=t[0]==="-";const d=l&&l[0]==="-";const maybeNegate=(e,t=false)=>e!==undefined&&(t||e&&u)?-e:e;return[{years:maybeNegate(parseFloating(n)),months:maybeNegate(parseFloating(r)),weeks:maybeNegate(parseFloating(i)),days:maybeNegate(parseFloating(s)),hours:maybeNegate(parseFloating(a)),minutes:maybeNegate(parseFloating(o)),seconds:maybeNegate(parseFloating(l),l==="-0"),milliseconds:maybeNegate(parseMillis(c),d)}]}const we={GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function fromStrings(e,t,n,r,i,s,a){const o={year:t.length===2?untruncateYear(parseInteger(t)):parseInteger(t),month:X.indexOf(n)+1,day:parseInteger(r),hour:parseInteger(i),minute:parseInteger(s)};if(a)o.second=parseInteger(a);if(e){o.weekday=e.length>3?te.indexOf(e)+1:ne.indexOf(e)+1}return o}const je=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function extractRFC2822(e){const[,t,n,r,i,s,a,o,l,c,u,d]=e,f=fromStrings(t,i,r,n,s,a,o);let p;if(l){p=we[l]}else if(c){p=0}else{p=signedOffset(u,d)}return[f,new FixedOffsetZone(p)]}function preprocessRFC2822(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const xe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Te=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,De=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function extractRFC1123Or850(e){const[,t,n,r,i,s,a,o]=e,l=fromStrings(t,i,r,n,s,a,o);return[l,FixedOffsetZone.utcInstance]}function extractASCII(e){const[,t,n,r,i,s,a,o]=e,l=fromStrings(t,o,n,r,i,s,a);return[l,FixedOffsetZone.utcInstance]}const Oe=combineRegexes(ye,he);const Ce=combineRegexes(me,he);const Ae=combineRegexes(be,he);const Re=combineRegexes(pe);const _e=combineExtractors(extractISOYmd,extractISOTime,extractISOOffset,extractIANAZone);const Me=combineExtractors(ge,extractISOTime,extractISOOffset,extractIANAZone);const Pe=combineExtractors(ve,extractISOTime,extractISOOffset,extractIANAZone);const Ne=combineExtractors(extractISOTime,extractISOOffset,extractIANAZone);function parseISODate(e){return parse(e,[Oe,_e],[Ce,Me],[Ae,Pe],[Re,Ne])}function parseRFC2822Date(e){return parse(preprocessRFC2822(e),[je,extractRFC2822])}function parseHTTPDate(e){return parse(e,[xe,extractRFC1123Or850],[Te,extractRFC1123Or850],[De,extractASCII])}function parseISODuration(e){return parse(e,[Ie,extractISODuration])}const Le=combineExtractors(extractISOTime);function parseISOTimeOnly(e){return parse(e,[ke,Le])}const Je=combineRegexes(Ke,Ee);const Fe=combineRegexes(Se);const Ve=combineExtractors(extractISOTime,extractISOOffset,extractIANAZone);function parseSQL(e){return parse(e,[Je,_e],[Fe,Ve])}const Ge="Invalid Duration";const qe={weeks:{days:7,hours:7*24,minutes:7*24*60,seconds:7*24*60*60,milliseconds:7*24*60*60*1e3},days:{hours:24,minutes:24*60,seconds:24*60*60,milliseconds:24*60*60*1e3},hours:{minutes:60,seconds:60*60,milliseconds:60*60*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Ye={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:91*24,minutes:91*24*60,seconds:91*24*60*60,milliseconds:91*24*60*60*1e3},months:{weeks:4,days:30,hours:30*24,minutes:30*24*60,seconds:30*24*60*60,milliseconds:30*24*60*60*1e3},...qe},Ue=146097/400,Be=146097/4800,We={years:{quarters:4,months:12,weeks:Ue/7,days:Ue,hours:Ue*24,minutes:Ue*24*60,seconds:Ue*24*60*60,milliseconds:Ue*24*60*60*1e3},quarters:{months:3,weeks:Ue/28,days:Ue/4,hours:Ue*24/4,minutes:Ue*24*60/4,seconds:Ue*24*60*60/4,milliseconds:Ue*24*60*60*1e3/4},months:{weeks:Be/7,days:Be,hours:Be*24,minutes:Be*24*60,seconds:Be*24*60*60,milliseconds:Be*24*60*60*1e3},...qe};const ze=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"];const Ze=ze.slice(0).reverse();function clone$1(e,t,n=false){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new Duration(r)}function durationToMillis(e,t){var n;let r=(n=t.milliseconds)!=null?n:0;for(const n of Ze.slice(1)){if(t[n]){r+=t[n]*e[n]["milliseconds"]}}return r}function normalizeValues(e,t){const n=durationToMillis(e,t)<0?-1:1;ze.reduceRight(((r,i)=>{if(!isUndefined(t[i])){if(r){const s=t[r]*n;const a=e[i][r];const o=Math.floor(s/a);t[i]+=o*n;t[r]-=o*a*n}return i}else{return r}}),null);ze.reduce(((n,r)=>{if(!isUndefined(t[r])){if(n){const i=t[n]%1;t[n]-=i;t[r]+=i*e[n][r]}return r}else{return n}}),null)}function removeZeroes(e){const t={};for(const[n,r]of Object.entries(e)){if(r!==0){t[n]=r}}return t}class Duration{constructor(e){const t=e.conversionAccuracy==="longterm"||false;let n=t?We:Ye;if(e.matrix){n=e.matrix}this.values=e.values;this.loc=e.loc||Locale.create();this.conversionAccuracy=t?"longterm":"casual";this.invalid=e.invalid||null;this.matrix=n;this.isLuxonDuration=true}static fromMillis(e,t){return Duration.fromObject({milliseconds:e},t)}static fromObject(e,t={}){if(e==null||typeof e!=="object"){throw new InvalidArgumentError(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`)}return new Duration({values:normalizeObject(e,Duration.normalizeUnit),loc:Locale.fromObject(t),conversionAccuracy:t.conversionAccuracy,matrix:t.matrix})}static fromDurationLike(e){if(isNumber(e)){return Duration.fromMillis(e)}else if(Duration.isDuration(e)){return e}else if(typeof e==="object"){return Duration.fromObject(e)}else{throw new InvalidArgumentError(`Unknown duration argument ${e} of type ${typeof e}`)}}static fromISO(e,t){const[n]=parseISODuration(e);if(n){return Duration.fromObject(n,t)}else{return Duration.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}}static fromISOTime(e,t){const[n]=parseISOTimeOnly(e);if(n){return Duration.fromObject(n,t)}else{return Duration.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}}static invalid(e,t=null){if(!e){throw new InvalidArgumentError("need to specify a reason the Duration is invalid")}const n=e instanceof Invalid?e:new Invalid(e,t);if(Settings.throwOnInvalid){throw new InvalidDurationError(n)}else{return new Duration({invalid:n})}}static normalizeUnit(e){const t={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e?e.toLowerCase():e];if(!t)throw new InvalidUnitError(e);return t}static isDuration(e){return e&&e.isLuxonDuration||false}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){const n={...t,floor:t.round!==false&&t.floor!==false};return this.isValid?Formatter.create(this.loc,n).formatDurationFromString(this,e):Ge}toHuman(e={}){if(!this.isValid)return Ge;const t=ze.map((t=>{const n=this.values[t];if(isUndefined(n)){return null}return this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:t.slice(0,-1)}).format(n)})).filter((e=>e));return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(t)}toObject(){if(!this.isValid)return{};return{...this.values}}toISO(){if(!this.isValid)return null;let e="P";if(this.years!==0)e+=this.years+"Y";if(this.months!==0||this.quarters!==0)e+=this.months+this.quarters*3+"M";if(this.weeks!==0)e+=this.weeks+"W";if(this.days!==0)e+=this.days+"D";if(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)e+="T";if(this.hours!==0)e+=this.hours+"H";if(this.minutes!==0)e+=this.minutes+"M";if(this.seconds!==0||this.milliseconds!==0)e+=roundTo(this.seconds+this.milliseconds/1e3,3)+"S";if(e==="P")e+="T0S";return e}toISOTime(e={}){if(!this.isValid)return null;const t=this.toMillis();if(t<0||t>=864e5)return null;e={suppressMilliseconds:false,suppressSeconds:false,includePrefix:false,format:"extended",...e,includeOffset:false};const n=DateTime.fromMillis(t,{zone:"UTC"});return n.toISOTime(e)}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid){return`Duration { values: ${JSON.stringify(this.values)} }`}else{return`Duration { Invalid, reason: ${this.invalidReason} }`}}toMillis(){if(!this.isValid)return NaN;return durationToMillis(this.matrix,this.values)}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const t=Duration.fromDurationLike(e),n={};for(const e of ze){if(hasOwnProperty(t.values,e)||hasOwnProperty(this.values,e)){n[e]=t.get(e)+this.get(e)}}return clone$1(this,{values:n},true)}minus(e){if(!this.isValid)return this;const t=Duration.fromDurationLike(e);return this.plus(t.negate())}mapUnits(e){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values)){t[n]=asNumber(e(this.values[n],n))}return clone$1(this,{values:t},true)}get(e){return this[Duration.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const t={...this.values,...normalizeObject(e,Duration.normalizeUnit)};return clone$1(this,{values:t})}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){const i=this.loc.clone({locale:e,numberingSystem:t});const s={loc:i,matrix:r,conversionAccuracy:n};return clone$1(this,s)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();normalizeValues(this.matrix,e);return clone$1(this,{values:e},true)}rescale(){if(!this.isValid)return this;const e=removeZeroes(this.normalize().shiftToAll().toObject());return clone$1(this,{values:e},true)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0){return this}e=e.map((e=>Duration.normalizeUnit(e)));const t={},n={},r=this.toObject();let i;for(const s of ze){if(e.indexOf(s)>=0){i=s;let e=0;for(const t in n){e+=this.matrix[t][s]*n[t];n[t]=0}if(isNumber(r[s])){e+=r[s]}const a=Math.trunc(e);t[s]=a;n[s]=(e*1e3-a*1e3)/1e3}else if(isNumber(r[s])){n[s]=r[s]}}for(const e in n){if(n[e]!==0){t[i]+=e===i?n[e]:n[e]/this.matrix[i][e]}}normalizeValues(this.matrix,t);return clone$1(this,{values:t},true)}shiftToAll(){if(!this.isValid)return this;return this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds")}negate(){if(!this.isValid)return this;const e={};for(const t of Object.keys(this.values)){e[t]=this.values[t]===0?0:-this.values[t]}return clone$1(this,{values:e},true)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid){return false}if(!this.loc.equals(e.loc)){return false}function eq(e,t){if(e===undefined||e===0)return t===undefined||t===0;return e===t}for(const t of ze){if(!eq(this.values[t],e.values[t])){return false}}return true}}const $e="Invalid Interval";function validateStartEnd(e,t){if(!e||!e.isValid){return Interval.invalid("missing or invalid start")}else if(!t||!t.isValid){return Interval.invalid("missing or invalid end")}else if(t<e){return Interval.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`)}else{return null}}class Interval{constructor(e){this.s=e.start;this.e=e.end;this.invalid=e.invalid||null;this.isLuxonInterval=true}static invalid(e,t=null){if(!e){throw new InvalidArgumentError("need to specify a reason the Interval is invalid")}const n=e instanceof Invalid?e:new Invalid(e,t);if(Settings.throwOnInvalid){throw new InvalidIntervalError(n)}else{return new Interval({invalid:n})}}static fromDateTimes(e,t){const n=friendlyDateTime(e),r=friendlyDateTime(t);const i=validateStartEnd(n,r);if(i==null){return new Interval({start:n,end:r})}else{return i}}static after(e,t){const n=Duration.fromDurationLike(t),r=friendlyDateTime(e);return Interval.fromDateTimes(r,r.plus(n))}static before(e,t){const n=Duration.fromDurationLike(t),r=friendlyDateTime(e);return Interval.fromDateTimes(r.minus(n),r)}static fromISO(e,t){const[n,r]=(e||"").split("/",2);if(n&&r){let e,i;try{e=DateTime.fromISO(n,t);i=e.isValid}catch(r){i=false}let s,a;try{s=DateTime.fromISO(r,t);a=s.isValid}catch(r){a=false}if(i&&a){return Interval.fromDateTimes(e,s)}if(i){const n=Duration.fromISO(r,t);if(n.isValid){return Interval.after(e,n)}}else if(a){const e=Duration.fromISO(n,t);if(e.isValid){return Interval.before(s,e)}}}return Interval.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||false}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(...[e]).get(e):NaN}count(e="milliseconds",t){if(!this.isValid)return NaN;const n=this.start.startOf(e,t);let r;if(t!=null&&t.useLocaleWeeks){r=this.end.reconfigure({locale:n.locale})}else{r=this.end}r=r.startOf(e,t);return Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):false}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){if(!this.isValid)return false;return this.s>e}isBefore(e){if(!this.isValid)return false;return this.e<=e}contains(e){if(!this.isValid)return false;return this.s<=e&&this.e>e}set({start:e,end:t}={}){if(!this.isValid)return this;return Interval.fromDateTimes(e||this.s,t||this.e)}splitAt(...e){if(!this.isValid)return[];const t=e.map(friendlyDateTime).filter((e=>this.contains(e))).sort(((e,t)=>e.toMillis()-t.toMillis())),n=[];let{s:r}=this,i=0;while(r<this.e){const e=t[i]||this.e,s=+e>+this.e?this.e:e;n.push(Interval.fromDateTimes(r,s));r=s;i+=1}return n}splitBy(e){const t=Duration.fromDurationLike(e);if(!this.isValid||!t.isValid||t.as("milliseconds")===0){return[]}let{s:n}=this,r=1,i;const s=[];while(n<this.e){const e=this.start.plus(t.mapUnits((e=>e*r)));i=+e>+this.e?this.e:e;s.push(Interval.fromDateTimes(n,i));n=i;r+=1}return s}divideEqually(e){if(!this.isValid)return[];return this.splitBy(this.length()/e).slice(0,e)}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){if(!this.isValid)return false;return+this.e===+e.s}abutsEnd(e){if(!this.isValid)return false;return+e.e===+this.s}engulfs(e){if(!this.isValid)return false;return this.s<=e.s&&this.e>=e.e}equals(e){if(!this.isValid||!e.isValid){return false}return this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const t=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;if(t>=n){return null}else{return Interval.fromDateTimes(t,n)}}union(e){if(!this.isValid)return this;const t=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return Interval.fromDateTimes(t,n)}static merge(e){const[t,n]=e.sort(((e,t)=>e.s-t.s)).reduce((([e,t],n)=>{if(!t){return[e,n]}else if(t.overlaps(n)||t.abutsStart(n)){return[e,t.union(n)]}else{return[e.concat([t]),n]}}),[[],null]);if(n){t.push(n)}return t}static xor(e){let t=null,n=0;const r=[],i=e.map((e=>[{time:e.s,type:"s"},{time:e.e,type:"e"}])),s=Array.prototype.concat(...i),a=s.sort(((e,t)=>e.time-t.time));for(const e of a){n+=e.type==="s"?1:-1;if(n===1){t=e.time}else{if(t&&+t!==+e.time){r.push(Interval.fromDateTimes(t,e.time))}t=null}}return Interval.merge(r)}difference(...e){return Interval.xor([this].concat(e)).map((e=>this.intersection(e))).filter((e=>e&&!e.isEmpty()))}toString(){if(!this.isValid)return $e;return`[${this.s.toISO()} – ${this.e.toISO()})`}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid){return`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`}else{return`Interval { Invalid, reason: ${this.invalidReason} }`}}toLocaleString(e=s,t={}){return this.isValid?Formatter.create(this.s.loc.clone(t),e).formatInterval(this):$e}toISO(e){if(!this.isValid)return $e;return`${this.s.toISO(e)}/${this.e.toISO(e)}`}toISODate(){if(!this.isValid)return $e;return`${this.s.toISODate()}/${this.e.toISODate()}`}toISOTime(e){if(!this.isValid)return $e;return`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`}toFormat(e,{separator:t=" – "}={}){if(!this.isValid)return $e;return`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`}toDuration(e,t){if(!this.isValid){return Duration.invalid(this.invalidReason)}return this.e.diff(this.s,e,t)}mapEndpoints(e){return Interval.fromDateTimes(e(this.s),e(this.e))}}class Info{static hasDST(e=Settings.defaultZone){const t=DateTime.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return IANAZone.isValidZone(e)}static normalizeZone(e){return normalizeZone(e,Settings.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||Locale.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||Locale.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||Locale.create(e)).getWeekendDays().slice()}static months(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Locale.create(t,n,i)).months(e)}static monthsFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||Locale.create(t,n,i)).months(e,true)}static weekdays(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Locale.create(t,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Locale.create(t,n,null)).weekdays(e,true)}static meridiems({locale:e=null}={}){return Locale.create(e).meridiems()}static eras(e="short",{locale:t=null}={}){return Locale.create(t,null,"gregory").eras(e)}static features(){return{relative:hasRelative(),localeWeek:hasLocaleWeekInfo()}}}function dayDiff(e,t){const utcDayStart=e=>e.toUTC(0,{keepLocalTime:true}).startOf("day").valueOf(),n=utcDayStart(t)-utcDayStart(e);return Math.floor(Duration.fromMillis(n).as("days"))}function highOrderDiffs(e,t,n){const r=[["years",(e,t)=>t.year-e.year],["quarters",(e,t)=>t.quarter-e.quarter+(t.year-e.year)*4],["months",(e,t)=>t.month-e.month+(t.year-e.year)*12],["weeks",(e,t)=>{const n=dayDiff(e,t);return(n-n%7)/7}],["days",dayDiff]];const i={};const s=e;let a,o;for(const[l,c]of r){if(n.indexOf(l)>=0){a=l;i[l]=c(e,t);o=s.plus(i);if(o>t){i[l]--;e=s.plus(i);if(e>t){o=e;i[l]--;e=s.plus(i)}}else{e=o}}}return[e,i,o,a]}function diff(e,t,n,r){let[i,s,a,o]=highOrderDiffs(e,t,n);const l=t-i;const c=n.filter((e=>["hours","minutes","seconds","milliseconds"].indexOf(e)>=0));if(c.length===0){if(a<t){a=i.plus({[o]:1})}if(a!==i){s[o]=(s[o]||0)+l/(a-i)}}const u=Duration.fromObject(s,r);if(c.length>0){return Duration.fromMillis(l,r).shiftTo(...c).plus(u)}else{return u}}const Qe="missing Intl.DateTimeFormat.formatToParts support";function intUnit(e,t=e=>e){return{regex:e,deser:([e])=>t(parseDigits(e))}}const He=String.fromCharCode(160);const Xe=`[ ${He}]`;const et=new RegExp(Xe,"g");function fixListRegex(e){return e.replace(/\./g,"\\.?").replace(et,Xe)}function stripInsensitivities(e){return e.replace(/\./g,"").replace(et," ").toLowerCase()}function oneOf(e,t){if(e===null){return null}else{return{regex:RegExp(e.map(fixListRegex).join("|")),deser:([n])=>e.findIndex((e=>stripInsensitivities(n)===stripInsensitivities(e)))+t}}}function offset(e,t){return{regex:e,deser:([,e,t])=>signedOffset(e,t),groups:t}}function simple(e){return{regex:e,deser:([e])=>e}}function escapeToken(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function unitForToken(e,t){const n=digitRegex(t),r=digitRegex(t,"{2}"),i=digitRegex(t,"{3}"),s=digitRegex(t,"{4}"),a=digitRegex(t,"{6}"),o=digitRegex(t,"{1,2}"),l=digitRegex(t,"{1,3}"),c=digitRegex(t,"{1,6}"),u=digitRegex(t,"{1,9}"),d=digitRegex(t,"{2,4}"),f=digitRegex(t,"{4,6}"),literal=e=>({regex:RegExp(escapeToken(e.val)),deser:([e])=>e,literal:true}),unitate=p=>{if(e.literal){return literal(p)}switch(p.val){case"G":return oneOf(t.eras("short"),0);case"GG":return oneOf(t.eras("long"),0);case"y":return intUnit(c);case"yy":return intUnit(d,untruncateYear);case"yyyy":return intUnit(s);case"yyyyy":return intUnit(f);case"yyyyyy":return intUnit(a);case"M":return intUnit(o);case"MM":return intUnit(r);case"MMM":return oneOf(t.months("short",true),1);case"MMMM":return oneOf(t.months("long",true),1);case"L":return intUnit(o);case"LL":return intUnit(r);case"LLL":return oneOf(t.months("short",false),1);case"LLLL":return oneOf(t.months("long",false),1);case"d":return intUnit(o);case"dd":return intUnit(r);case"o":return intUnit(l);case"ooo":return intUnit(i);case"HH":return intUnit(r);case"H":return intUnit(o);case"hh":return intUnit(r);case"h":return intUnit(o);case"mm":return intUnit(r);case"m":return intUnit(o);case"q":return intUnit(o);case"qq":return intUnit(r);case"s":return intUnit(o);case"ss":return intUnit(r);case"S":return intUnit(l);case"SSS":return intUnit(i);case"u":return simple(u);case"uu":return simple(o);case"uuu":return intUnit(n);case"a":return oneOf(t.meridiems(),0);case"kkkk":return intUnit(s);case"kk":return intUnit(d,untruncateYear);case"W":return intUnit(o);case"WW":return intUnit(r);case"E":case"c":return intUnit(n);case"EEE":return oneOf(t.weekdays("short",false),1);case"EEEE":return oneOf(t.weekdays("long",false),1);case"ccc":return oneOf(t.weekdays("short",true),1);case"cccc":return oneOf(t.weekdays("long",true),1);case"Z":case"ZZ":return offset(new RegExp(`([+-]${o.source})(?::(${r.source}))?`),2);case"ZZZ":return offset(new RegExp(`([+-]${o.source})(${r.source})?`),2);case"z":return simple(/[a-z_+-/]{1,256}?/i);case" ":return simple(/[^\S\n\r]/);default:return literal(p)}};const p=unitate(e)||{invalidReason:Qe};p.token=e;return p}const tt={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function tokenForPart(e,t,n){const{type:r,value:i}=e;if(r==="literal"){const e=/^\s+$/.test(i);return{literal:!e,val:e?" ":i}}const s=t[r];let a=r;if(r==="hour"){if(t.hour12!=null){a=t.hour12?"hour12":"hour24"}else if(t.hourCycle!=null){if(t.hourCycle==="h11"||t.hourCycle==="h12"){a="hour12"}else{a="hour24"}}else{a=n.hour12?"hour12":"hour24"}}let o=tt[a];if(typeof o==="object"){o=o[s]}if(o){return{literal:false,val:o}}return undefined}function buildRegex(e){const t=e.map((e=>e.regex)).reduce(((e,t)=>`${e}(${t.source})`),"");return[`^${t}$`,e]}function match(e,t,n){const r=e.match(t);if(r){const e={};let t=1;for(const i in n){if(hasOwnProperty(n,i)){const s=n[i],a=s.groups?s.groups+1:1;if(!s.literal&&s.token){e[s.token.val[0]]=s.deser(r.slice(t,t+a))}t+=a}}return[r,e]}else{return[r,{}]}}function dateTimeFromMatches(e){const toField=e=>{switch(e){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let t=null;let n;if(!isUndefined(e.z)){t=IANAZone.create(e.z)}if(!isUndefined(e.Z)){if(!t){t=new FixedOffsetZone(e.Z)}n=e.Z}if(!isUndefined(e.q)){e.M=(e.q-1)*3+1}if(!isUndefined(e.h)){if(e.h<12&&e.a===1){e.h+=12}else if(e.h===12&&e.a===0){e.h=0}}if(e.G===0&&e.y){e.y=-e.y}if(!isUndefined(e.u)){e.S=parseMillis(e.u)}const r=Object.keys(e).reduce(((t,n)=>{const r=toField(n);if(r){t[r]=e[n]}return t}),{});return[r,t,n]}let nt=null;function getDummyDateTime(){if(!nt){nt=DateTime.fromMillis(1555555555555)}return nt}function maybeExpandMacroToken(e,t){if(e.literal){return e}const n=Formatter.macroTokenToFormatOpts(e.val);const r=formatOptsToTokens(n,t);if(r==null||r.includes(undefined)){return e}return r}function expandMacroTokens(e,t){return Array.prototype.concat(...e.map((e=>maybeExpandMacroToken(e,t))))}class TokenParser{constructor(e,t){this.locale=e;this.format=t;this.tokens=expandMacroTokens(Formatter.parseFormat(t),e);this.units=this.tokens.map((t=>unitForToken(t,e)));this.disqualifyingUnit=this.units.find((e=>e.invalidReason));if(!this.disqualifyingUnit){const[e,t]=buildRegex(this.units);this.regex=RegExp(e,"i");this.handlers=t}}explainFromTokens(e){if(!this.isValid){return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}else{const[t,n]=match(e,this.regex,this.handlers),[r,i,s]=n?dateTimeFromMatches(n):[null,null,undefined];if(hasOwnProperty(n,"a")&&hasOwnProperty(n,"H")){throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format")}return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:s}}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function explainFromTokens(e,t,n){const r=new TokenParser(e,n);return r.explainFromTokens(t)}function parseFromTokens(e,t,n){const{result:r,zone:i,specificOffset:s,invalidReason:a}=explainFromTokens(e,t,n);return[r,i,s,a]}function formatOptsToTokens(e,t){if(!e){return null}const n=Formatter.create(t,e);const r=n.dtFormatter(getDummyDateTime());const i=r.formatToParts();const s=r.resolvedOptions();return i.map((t=>tokenForPart(t,e,s)))}const rt="Invalid DateTime";const it=864e13;function unsupportedZone(e){return new Invalid("unsupported zone",`the zone "${e.name}" is not supported`)}function possiblyCachedWeekData(e){if(e.weekData===null){e.weekData=gregorianToWeek(e.c)}return e.weekData}function possiblyCachedLocalWeekData(e){if(e.localWeekData===null){e.localWeekData=gregorianToWeek(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())}return e.localWeekData}function clone(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new DateTime({...n,...t,old:n})}function fixOffset(e,t,n){let r=e-t*60*1e3;const i=n.offset(r);if(t===i){return[r,t]}r-=(i-t)*60*1e3;const s=n.offset(r);if(i===s){return[r,i]}return[e-Math.min(i,s)*60*1e3,Math.max(i,s)]}function tsToObj(e,t){e+=t*60*1e3;const n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function objToTS(e,t,n){return fixOffset(objToLocalTS(e),t,n)}function adjustTime(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,s={...e.c,year:r,month:i,day:Math.min(e.c.day,daysInMonth(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},a=Duration.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),o=objToLocalTS(s);let[l,c]=fixOffset(o,n,e.zone);if(a!==0){l+=a;c=e.zone.offset(l)}return{ts:l,o:c}}function parseDataToDateTime(e,t,n,r,i,s){const{setZone:a,zone:o}=n;if(e&&Object.keys(e).length!==0||t){const r=t||o,i=DateTime.fromObject(e,{...n,zone:r,specificOffset:s});return a?i:i.setZone(o)}else{return DateTime.invalid(new Invalid("unparsable",`the input "${i}" can't be parsed as ${r}`))}}function toTechFormat(e,t,n=true){return e.isValid?Formatter.create(Locale.create("en-US"),{allowZ:n,forceSimple:true}).formatDateTimeFromString(e,t):null}function toISODate(e,t){const n=e.c.year>9999||e.c.year<0;let r="";if(n&&e.c.year>=0)r+="+";r+=padStart(e.c.year,n?6:4);if(t){r+="-";r+=padStart(e.c.month);r+="-";r+=padStart(e.c.day)}else{r+=padStart(e.c.month);r+=padStart(e.c.day)}return r}function toISOTime(e,t,n,r,i,s){let a=padStart(e.c.hour);if(t){a+=":";a+=padStart(e.c.minute);if(e.c.millisecond!==0||e.c.second!==0||!n){a+=":"}}else{a+=padStart(e.c.minute)}if(e.c.millisecond!==0||e.c.second!==0||!n){a+=padStart(e.c.second);if(e.c.millisecond!==0||!r){a+=".";a+=padStart(e.c.millisecond,3)}}if(i){if(e.isOffsetFixed&&e.offset===0&&!s){a+="Z"}else if(e.o<0){a+="-";a+=padStart(Math.trunc(-e.o/60));a+=":";a+=padStart(Math.trunc(-e.o%60))}else{a+="+";a+=padStart(Math.trunc(e.o/60));a+=":";a+=padStart(Math.trunc(e.o%60))}}if(s){a+="["+e.zone.ianaName+"]"}return a}const st={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},at={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},ot={ordinal:1,hour:0,minute:0,second:0,millisecond:0};const ct=["year","month","day","hour","minute","second","millisecond"],ut=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],dt=["year","ordinal","hour","minute","second","millisecond"];function normalizeUnit(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new InvalidUnitError(e);return t}function normalizeUnitWithLocalWeeks(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return normalizeUnit(e)}}function guessOffsetForZone(e){if(!pt[e]){if(ft===undefined){ft=Settings.now()}pt[e]=e.offset(ft)}return pt[e]}function quickDT(e,t){const n=normalizeZone(t.zone,Settings.defaultZone);if(!n.isValid){return DateTime.invalid(unsupportedZone(n))}const r=Locale.fromObject(t);let i,s;if(!isUndefined(e.year)){for(const t of ct){if(isUndefined(e[t])){e[t]=st[t]}}const t=hasInvalidGregorianData(e)||hasInvalidTimeData(e);if(t){return DateTime.invalid(t)}const r=guessOffsetForZone(n);[i,s]=objToTS(e,r,n)}else{i=Settings.now()}return new DateTime({ts:i,zone:n,loc:r,o:s})}function diffRelative(e,t,n){const r=isUndefined(n.round)?true:n.round,format=(e,i)=>{e=roundTo(e,r||n.calendary?0:2,true);const s=t.loc.clone(n).relFormatter(n);return s.format(e,i)},differ=r=>{if(n.calendary){if(!t.hasSame(e,r)){return t.startOf(r).diff(e.startOf(r),r).get(r)}else return 0}else{return t.diff(e,r).get(r)}};if(n.unit){return format(differ(n.unit),n.unit)}for(const e of n.units){const t=differ(e);if(Math.abs(t)>=1){return format(t,e)}}return format(e>t?-0:0,n.units[n.units.length-1])}function lastOpts(e){let t={},n;if(e.length>0&&typeof e[e.length-1]==="object"){t=e[e.length-1];n=Array.from(e).slice(0,e.length-1)}else{n=Array.from(e)}return[t,n]}let ft;let pt={};class DateTime{constructor(e){const t=e.zone||Settings.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Invalid("invalid input"):null)||(!t.isValid?unsupportedZone(t):null);this.ts=isUndefined(e.ts)?Settings.now():e.ts;let r=null,i=null;if(!n){const s=e.old&&e.old.ts===this.ts&&e.old.zone.equals(t);if(s){[r,i]=[e.old.c,e.old.o]}else{const s=isNumber(e.o)&&!e.old?e.o:t.offset(this.ts);r=tsToObj(this.ts,s);n=Number.isNaN(r.year)?new Invalid("invalid input"):null;r=n?null:r;i=n?null:s}}this._zone=t;this.loc=e.loc||Locale.create();this.invalid=n;this.weekData=null;this.localWeekData=null;this.c=r;this.o=i;this.isLuxonDateTime=true}static now(){return new DateTime({})}static local(){const[e,t]=lastOpts(arguments),[n,r,i,s,a,o,l]=t;return quickDT({year:n,month:r,day:i,hour:s,minute:a,second:o,millisecond:l},e)}static utc(){const[e,t]=lastOpts(arguments),[n,r,i,s,a,o,l]=t;e.zone=FixedOffsetZone.utcInstance;return quickDT({year:n,month:r,day:i,hour:s,minute:a,second:o,millisecond:l},e)}static fromJSDate(e,t={}){const n=isDate(e)?e.valueOf():NaN;if(Number.isNaN(n)){return DateTime.invalid("invalid input")}const r=normalizeZone(t.zone,Settings.defaultZone);if(!r.isValid){return DateTime.invalid(unsupportedZone(r))}return new DateTime({ts:n,zone:r,loc:Locale.fromObject(t)})}static fromMillis(e,t={}){if(!isNumber(e)){throw new InvalidArgumentError(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}else if(e<-it||e>it){return DateTime.invalid("Timestamp out of range")}else{return new DateTime({ts:e,zone:normalizeZone(t.zone,Settings.defaultZone),loc:Locale.fromObject(t)})}}static fromSeconds(e,t={}){if(!isNumber(e)){throw new InvalidArgumentError("fromSeconds requires a numerical input")}else{return new DateTime({ts:e*1e3,zone:normalizeZone(t.zone,Settings.defaultZone),loc:Locale.fromObject(t)})}}static fromObject(e,t={}){e=e||{};const n=normalizeZone(t.zone,Settings.defaultZone);if(!n.isValid){return DateTime.invalid(unsupportedZone(n))}const r=Locale.fromObject(t);const i=normalizeObject(e,normalizeUnitWithLocalWeeks);const{minDaysInFirstWeek:s,startOfWeek:a}=usesLocalWeekValues(i,r);const o=Settings.now(),l=!isUndefined(t.specificOffset)?t.specificOffset:n.offset(o),c=!isUndefined(i.ordinal),u=!isUndefined(i.year),d=!isUndefined(i.month)||!isUndefined(i.day),f=u||d,p=i.weekYear||i.weekNumber;if((f||c)&&p){throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals")}if(d&&c){throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day")}const h=p||i.weekday&&!f;let y,m,b=tsToObj(o,l);if(h){y=ut;m=at;b=gregorianToWeek(b,s,a)}else if(c){y=dt;m=ot;b=gregorianToOrdinal(b)}else{y=ct;m=st}let g=false;for(const e of y){const t=i[e];if(!isUndefined(t)){g=true}else if(g){i[e]=m[e]}else{i[e]=b[e]}}const v=h?hasInvalidWeekData(i,s,a):c?hasInvalidOrdinalData(i):hasInvalidGregorianData(i),K=v||hasInvalidTimeData(i);if(K){return DateTime.invalid(K)}const S=h?weekToGregorian(i,s,a):c?ordinalToGregorian(i):i,[E,k]=objToTS(S,l,n),I=new DateTime({ts:E,zone:n,o:k,loc:r});if(i.weekday&&f&&e.weekday!==I.weekday){return DateTime.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${I.toISO()}`)}if(!I.isValid){return DateTime.invalid(I.invalid)}return I}static fromISO(e,t={}){const[n,r]=parseISODate(e);return parseDataToDateTime(n,r,t,"ISO 8601",e)}static fromRFC2822(e,t={}){const[n,r]=parseRFC2822Date(e);return parseDataToDateTime(n,r,t,"RFC 2822",e)}static fromHTTP(e,t={}){const[n,r]=parseHTTPDate(e);return parseDataToDateTime(n,r,t,"HTTP",t)}static fromFormat(e,t,n={}){if(isUndefined(e)||isUndefined(t)){throw new InvalidArgumentError("fromFormat requires an input string and a format")}const{locale:r=null,numberingSystem:i=null}=n,s=Locale.fromOpts({locale:r,numberingSystem:i,defaultToEN:true}),[a,o,l,c]=parseFromTokens(s,e,t);if(c){return DateTime.invalid(c)}else{return parseDataToDateTime(a,o,n,`format ${t}`,e,l)}}static fromString(e,t,n={}){return DateTime.fromFormat(e,t,n)}static fromSQL(e,t={}){const[n,r]=parseSQL(e);return parseDataToDateTime(n,r,t,"SQL",e)}static invalid(e,t=null){if(!e){throw new InvalidArgumentError("need to specify a reason the DateTime is invalid")}const n=e instanceof Invalid?e:new Invalid(e,t);if(Settings.throwOnInvalid){throw new InvalidDateTimeError(n)}else{return new DateTime({invalid:n})}}static isDateTime(e){return e&&e.isLuxonDateTime||false}static parseFormatForOpts(e,t={}){const n=formatOptsToTokens(e,Locale.fromObject(t));return!n?null:n.map((e=>e?e.val:null)).join("")}static expandFormat(e,t={}){const n=expandMacroTokens(Formatter.parseFormat(e),Locale.fromObject(t));return n.map((e=>e.val)).join("")}static resetCache(){ft=undefined;pt={}}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?possiblyCachedWeekData(this).weekYear:NaN}get weekNumber(){return this.isValid?possiblyCachedWeekData(this).weekNumber:NaN}get weekday(){return this.isValid?possiblyCachedWeekData(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?possiblyCachedLocalWeekData(this).weekday:NaN}get localWeekNumber(){return this.isValid?possiblyCachedLocalWeekData(this).weekNumber:NaN}get localWeekYear(){return this.isValid?possiblyCachedLocalWeekData(this).weekYear:NaN}get ordinal(){return this.isValid?gregorianToOrdinal(this.c).ordinal:NaN}get monthShort(){return this.isValid?Info.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Info.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Info.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Info.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){if(this.isValid){return this.zone.offsetName(this.ts,{format:"short",locale:this.locale})}else{return null}}get offsetNameLong(){if(this.isValid){return this.zone.offsetName(this.ts,{format:"long",locale:this.locale})}else{return null}}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){if(this.isOffsetFixed){return false}else{return this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed){return[this]}const e=864e5;const t=6e4;const n=objToLocalTS(this.c);const r=this.zone.offset(n-e);const i=this.zone.offset(n+e);const s=this.zone.offset(n-r*t);const a=this.zone.offset(n-i*t);if(s===a){return[this]}const o=n-s*t;const l=n-a*t;const c=tsToObj(o,s);const u=tsToObj(l,a);if(c.hour===u.hour&&c.minute===u.minute&&c.second===u.second&&c.millisecond===u.millisecond){return[clone(this,{ts:o}),clone(this,{ts:l})]}return[this]}get isInLeapYear(){return isLeapYear(this.year)}get daysInMonth(){return daysInMonth(this.year,this.month)}get daysInYear(){return this.isValid?daysInYear(this.year):NaN}get weeksInWeekYear(){return this.isValid?weeksInWeekYear(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?weeksInWeekYear(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:t,numberingSystem:n,calendar:r}=Formatter.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(FixedOffsetZone.instance(e),t)}toLocal(){return this.setZone(Settings.defaultZone)}setZone(e,{keepLocalTime:t=false,keepCalendarTime:n=false}={}){e=normalizeZone(e,Settings.defaultZone);if(e.equals(this.zone)){return this}else if(!e.isValid){return DateTime.invalid(unsupportedZone(e))}else{let r=this.ts;if(t||n){const t=e.offset(this.ts);const n=this.toObject();[r]=objToTS(n,t,e)}return clone(this,{ts:r,zone:e})}}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){const r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return clone(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const t=normalizeObject(e,normalizeUnitWithLocalWeeks);const{minDaysInFirstWeek:n,startOfWeek:r}=usesLocalWeekValues(t,this.loc);const i=!isUndefined(t.weekYear)||!isUndefined(t.weekNumber)||!isUndefined(t.weekday),s=!isUndefined(t.ordinal),a=!isUndefined(t.year),o=!isUndefined(t.month)||!isUndefined(t.day),l=a||o,c=t.weekYear||t.weekNumber;if((l||s)&&c){throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals")}if(o&&s){throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day")}let u;if(i){u=weekToGregorian({...gregorianToWeek(this.c,n,r),...t},n,r)}else if(!isUndefined(t.ordinal)){u=ordinalToGregorian({...gregorianToOrdinal(this.c),...t})}else{u={...this.toObject(),...t};if(isUndefined(t.day)){u.day=Math.min(daysInMonth(u.year,u.month),u.day)}}const[d,f]=objToTS(u,this.o,this.zone);return clone(this,{ts:d,o:f})}plus(e){if(!this.isValid)return this;const t=Duration.fromDurationLike(e);return clone(this,adjustTime(this,t))}minus(e){if(!this.isValid)return this;const t=Duration.fromDurationLike(e).negate();return clone(this,adjustTime(this,t))}startOf(e,{useLocaleWeeks:t=false}={}){if(!this.isValid)return this;const n={},r=Duration.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks"){if(t){const e=this.loc.getStartOfWeek();const{weekday:t}=this;if(t<e){n.weekNumber=this.weekNumber-1}n.weekday=e}else{n.weekday=1}}if(r==="quarters"){const e=Math.ceil(this.month/3);n.month=(e-1)*3+1}return this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?Formatter.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):rt}toLocaleString(e=s,t={}){return this.isValid?Formatter.create(this.loc.clone(t),e).formatDateTime(this):rt}toLocaleParts(e={}){return this.isValid?Formatter.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:t=false,suppressMilliseconds:n=false,includeOffset:r=true,extendedZone:i=false}={}){if(!this.isValid){return null}const s=e==="extended";let a=toISODate(this,s);a+="T";a+=toISOTime(this,s,t,n,r,i);return a}toISODate({format:e="extended"}={}){if(!this.isValid){return null}return toISODate(this,e==="extended")}toISOWeekDate(){return toTechFormat(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=false,suppressSeconds:t=false,includeOffset:n=true,includePrefix:r=false,extendedZone:i=false,format:s="extended"}={}){if(!this.isValid){return null}let a=r?"T":"";return a+toISOTime(this,s==="extended",t,e,n,i)}toRFC2822(){return toTechFormat(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",false)}toHTTP(){return toTechFormat(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){if(!this.isValid){return null}return toISODate(this,true)}toSQLTime({includeOffset:e=true,includeZone:t=false,includeOffsetSpace:n=true}={}){let r="HH:mm:ss.SSS";if(t||e){if(n){r+=" "}if(t){r+="z"}else if(e){r+="ZZ"}}return toTechFormat(this,r,true)}toSQL(e={}){if(!this.isValid){return null}return`${this.toSQLDate()} ${this.toSQLTime(e)}`}toString(){return this.isValid?this.toISO():rt}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid){return`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`}else{return`DateTime { Invalid, reason: ${this.invalidReason} }`}}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const t={...this.c};if(e.includeConfig){t.outputCalendar=this.outputCalendar;t.numberingSystem=this.loc.numberingSystem;t.locale=this.loc.locale}return t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t="milliseconds",n={}){if(!this.isValid||!e.isValid){return Duration.invalid("created by diffing an invalid DateTime")}const r={locale:this.locale,numberingSystem:this.numberingSystem,...n};const i=maybeArray(t).map(Duration.normalizeUnit),s=e.valueOf()>this.valueOf(),a=s?this:e,o=s?e:this,l=diff(a,o,i,r);return s?l.negate():l}diffNow(e="milliseconds",t={}){return this.diff(DateTime.now(),e,t)}until(e){return this.isValid?Interval.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return false;const r=e.valueOf();const i=this.setZone(e.zone,{keepLocalTime:true});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const t=e.base||DateTime.fromObject({},{zone:this.zone}),n=e.padding?this<t?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"];let i=e.unit;if(Array.isArray(e.unit)){r=e.unit;i=undefined}return diffRelative(t,this.plus(n),{...e,numeric:"always",units:r,unit:i})}toRelativeCalendar(e={}){if(!this.isValid)return null;return diffRelative(e.base||DateTime.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:true})}static min(...e){if(!e.every(DateTime.isDateTime)){throw new InvalidArgumentError("min requires all arguments be DateTimes")}return bestBy(e,(e=>e.valueOf()),Math.min)}static max(...e){if(!e.every(DateTime.isDateTime)){throw new InvalidArgumentError("max requires all arguments be DateTimes")}return bestBy(e,(e=>e.valueOf()),Math.max)}static fromFormatExplain(e,t,n={}){const{locale:r=null,numberingSystem:i=null}=n,s=Locale.fromOpts({locale:r,numberingSystem:i,defaultToEN:true});return explainFromTokens(s,e,t)}static fromStringExplain(e,t,n={}){return DateTime.fromFormatExplain(e,t,n)}static buildFormatParser(e,t={}){const{locale:n=null,numberingSystem:r=null}=t,i=Locale.fromOpts({locale:n,numberingSystem:r,defaultToEN:true});return new TokenParser(i,e)}static fromFormatParser(e,t,n={}){if(isUndefined(e)||isUndefined(t)){throw new InvalidArgumentError("fromFormatParser requires an input string and a format parser")}const{locale:r=null,numberingSystem:i=null}=n,s=Locale.fromOpts({locale:r,numberingSystem:i,defaultToEN:true});if(!s.equals(t.locale)){throw new InvalidArgumentError(`fromFormatParser called with a locale of ${s}, `+`but the format parser was created for ${t.locale}`)}const{result:a,zone:o,specificOffset:l,invalidReason:c}=t.explainFromTokens(e);if(c){return DateTime.invalid(c)}else{return parseDataToDateTime(a,o,n,`format ${t.format}`,e,l)}}static get DATE_SHORT(){return s}static get DATE_MED(){return a}static get DATE_MED_WITH_WEEKDAY(){return o}static get DATE_FULL(){return l}static get DATE_HUGE(){return c}static get TIME_SIMPLE(){return u}static get TIME_WITH_SECONDS(){return d}static get TIME_WITH_SHORT_OFFSET(){return f}static get TIME_WITH_LONG_OFFSET(){return p}static get TIME_24_SIMPLE(){return h}static get TIME_24_WITH_SECONDS(){return y}static get TIME_24_WITH_SHORT_OFFSET(){return m}static get TIME_24_WITH_LONG_OFFSET(){return b}static get DATETIME_SHORT(){return g}static get DATETIME_SHORT_WITH_SECONDS(){return v}static get DATETIME_MED(){return K}static get DATETIME_MED_WITH_SECONDS(){return S}static get DATETIME_MED_WITH_WEEKDAY(){return E}static get DATETIME_FULL(){return k}static get DATETIME_FULL_WITH_SECONDS(){return I}static get DATETIME_HUGE(){return w}static get DATETIME_HUGE_WITH_SECONDS(){return j}}function friendlyDateTime(e){if(DateTime.isDateTime(e)){return e}else if(e&&e.valueOf&&isNumber(e.valueOf())){return DateTime.fromJSDate(e)}else if(e&&typeof e==="object"){return DateTime.fromObject(e)}else{throw new InvalidArgumentError(`Unknown datetime argument: ${e}, of type ${typeof e}`)}}const ht="3.5.0";t.DateTime=DateTime;t.Duration=Duration;t.FixedOffsetZone=FixedOffsetZone;t.IANAZone=IANAZone;t.Info=Info;t.Interval=Interval;t.InvalidZone=InvalidZone;t.Settings=Settings;t.SystemZone=SystemZone;t.VERSION=ht;t.Zone=Zone},2134:function(e){var t=1e3;var n=t*60;var r=n*60;var i=r*24;var s=i*7;var a=i*365.25;e.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0){return parse(e)}else if(n==="number"&&isFinite(e)){return t.long?fmtLong(e):fmtShort(e)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse(e){e=String(e);if(e.length>100){return}var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!o){return}var l=parseFloat(o[1]);var c=(o[2]||"ms").toLowerCase();switch(c){case"years":case"year":case"yrs":case"yr":case"y":return l*a;case"weeks":case"week":case"w":return l*s;case"days":case"day":case"d":return l*i;case"hours":case"hour":case"hrs":case"hr":case"h":return l*r;case"minutes":case"minute":case"mins":case"min":case"m":return l*n;case"seconds":case"second":case"secs":case"sec":case"s":return l*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return undefined}}function fmtShort(e){var s=Math.abs(e);if(s>=i){return Math.round(e/i)+"d"}if(s>=r){return Math.round(e/r)+"h"}if(s>=n){return Math.round(e/n)+"m"}if(s>=t){return Math.round(e/t)+"s"}return e+"ms"}function fmtLong(e){var s=Math.abs(e);if(s>=i){return plural(e,s,i,"day")}if(s>=r){return plural(e,s,r,"hour")}if(s>=n){return plural(e,s,n,"minute")}if(s>=t){return plural(e,s,t,"second")}return e+" ms"}function plural(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+" "+r+(i?"s":"")}},86:function(e,t,n){e.exports=n(8869)(__dirname)},221:function(e,t,n){const{EventEmitter:r}=n(4434);class AbortSignal{constructor(){this.eventEmitter=new r;this.onabort=null;this.aborted=false;this.reason=undefined}toString(){return"[object AbortSignal]"}get[Symbol.toStringTag](){return"AbortSignal"}removeEventListener(e,t){this.eventEmitter.removeListener(e,t)}addEventListener(e,t){this.eventEmitter.on(e,t)}dispatchEvent(e){const t={type:e,target:this};const n=`on${e}`;if(typeof this[n]==="function")this[n](t);this.eventEmitter.emit(e,t)}throwIfAborted(){if(this.aborted){throw this.reason}}static abort(e){const t=new AbortController;t.abort();return t.signal}static timeout(e){const t=new AbortController;setTimeout((()=>t.abort(new Error("TimeoutError"))),e);return t.signal}}class AbortController{constructor(){this.signal=new AbortSignal}abort(e){if(this.signal.aborted)return;this.signal.aborted=true;if(e)this.signal.reason=e;else this.signal.reason=new Error("AbortError");this.signal.dispatchEvent("abort")}toString(){return"[object AbortController]"}get[Symbol.toStringTag](){return"AbortController"}}e.exports={AbortController:AbortController,AbortSignal:AbortSignal}},8869:function(module,__unused_webpack_exports,__nccwpck_require__){const runtimeRequire=true?eval("require"):0;if(typeof runtimeRequire.addon==="function"){module.exports=runtimeRequire.addon.bind(runtimeRequire)}else{module.exports=__nccwpck_require__(4769)}},4769:function(module,__unused_webpack_exports,__nccwpck_require__){var fs=__nccwpck_require__(9896);var path=__nccwpck_require__(6928);var url=__nccwpck_require__(7016);var os=__nccwpck_require__(857);var runtimeRequire=true?eval("require"):0;var vars=process.config&&process.config.variables||{};var prebuildsOnly=!!process.env.PREBUILDS_ONLY;var versions=process.versions;var abi=versions.modules;if(versions.deno||process.isBun){abi="unsupported"}var runtime=isElectron()?"electron":isNwjs()?"node-webkit":"node";var arch=process.env.npm_config_arch||os.arch();var platform=process.env.npm_config_platform||os.platform();var libc=process.env.LIBC||(isMusl(platform)?"musl":"glibc");var armv=process.env.ARM_VERSION||(arch==="arm64"?"8":vars.arm_version)||"";var uv=(versions.uv||"").split(".")[0];module.exports=load;function load(e){return runtimeRequire(load.resolve(e))}load.resolve=load.path=function(e){e=path.resolve(e||".");var t="";var n;try{t=runtimeRequire(path.join(e,"package.json")).name;var r=t.toUpperCase().replace(/-/g,"_");if(process.env[r+"_PREBUILD"])e=process.env[r+"_PREBUILD"]}catch(e){n=e}if(!prebuildsOnly){var i=getFirst(path.join(e,"build/Release"),matchBuild);if(i)return i;var s=getFirst(path.join(e,"build/Debug"),matchBuild);if(s)return s}var a=resolve(e);if(a)return a;var o=resolve(path.dirname(process.execPath));if(o)return o;var l=(t[0]=="@"?"":"@"+t+"/")+t+"-"+platform+"-"+arch;var c;try{var u=path.dirname(__nccwpck_require__(3339).createRequire(url.pathToFileURL(path.join(e,"package.json"))).resolve(l));return resolveFile(u)}catch(e){c=e}var d=["platform="+platform,"arch="+arch,"runtime="+runtime,"abi="+abi,"uv="+uv,armv?"armv="+armv:"","libc="+libc,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",true?"webpack=true":0].filter(Boolean).join(" ");let f="No native build was found for "+d+"\n attempted loading from: "+e+" and package:"+" "+l+"\n";if(n){f+="Error finding package.json: "+n.message+"\n"}if(c){f+="Error resolving package: "+c.message+"\n"}throw new Error(f);function resolve(e){var t=readdirSync(path.join(e,"prebuilds")).map(parseTuple);var n=t.filter(matchTuple(platform,arch)).sort(compareTuples)[0];if(!n)return;return resolveFile(path.join(e,"prebuilds",n.name))}function resolveFile(e){var t=readdirSync(e).map(parseTags);var n=t.filter(matchTags(runtime,abi));var r=n.sort(compareTags(runtime))[0];if(r)return path.join(e,r.file)}};function readdirSync(e){try{return fs.readdirSync(e)}catch(e){return[]}}function getFirst(e,t){var n=readdirSync(e).filter(t);return n[0]&&path.join(e,n[0])}function matchBuild(e){return/\.node$/.test(e)}function parseTuple(e){var t=e.split("-");if(t.length!==2)return;var n=t[0];var r=t[1].split("+");if(!n)return;if(!r.length)return;if(!r.every(Boolean))return;return{name:e,platform:n,architectures:r}}function matchTuple(e,t){return function(n){if(n==null)return false;if(n.platform!==e)return false;return n.architectures.includes(t)}}function compareTuples(e,t){return e.architectures.length-t.architectures.length}function parseTags(e){var t=e.split(".");var n=t.pop();var r={file:e,specificity:0};if(n!=="node")return;for(var i=0;i<t.length;i++){var s=t[i];if(s==="node"||s==="electron"||s==="node-webkit"){r.runtime=s}else if(s==="napi"){r.napi=true}else if(s.slice(0,3)==="abi"){r.abi=s.slice(3)}else if(s.slice(0,2)==="uv"){r.uv=s.slice(2)}else if(s.slice(0,4)==="armv"){r.armv=s.slice(4)}else if(s==="glibc"||s==="musl"){r.libc=s}else{continue}r.specificity++}return r}function matchTags(e,t){return function(n){if(n==null)return false;if(n.runtime!==e&&!runtimeAgnostic(n))return false;if(n.abi!==t&&!n.napi)return false;if(n.uv&&n.uv!==uv)return false;if(n.armv&&n.armv!==armv)return false;if(n.libc&&n.libc!==libc)return false;return true}}function runtimeAgnostic(e){return e.runtime==="node"&&e.napi}function compareTags(e){return function(t,n){if(t.runtime!==n.runtime){return t.runtime===e?-1:1}else if(t.abi!==n.abi){return t.abi?-1:1}else if(t.specificity!==n.specificity){return t.specificity>n.specificity?-1:1}else{return 0}}}function isNwjs(){return!!(process.versions&&process.versions.nw)}function isElectron(){if(process.versions&&process.versions.electron)return true;if(process.env.ELECTRON_RUN_AS_NODE)return true;return typeof window!=="undefined"&&window.process&&window.process.type==="renderer"}function isMusl(e){if(e!=="linux")return false;const{familySync:t,MUSL:n}=__nccwpck_require__(9054);return t()===n}load.parseTags=parseTags;load.matchTags=matchTags;load.compareTags=compareTags;load.parseTuple=parseTuple;load.matchTuple=matchTuple;load.compareTuples=compareTuples},8287:function(e,t,n){"use strict";const r=process.version.charCodeAt(1)<55&&process.version.charCodeAt(2)===46?n(3554):n(4144);e.exports=r},4144:function(e,t,n){"use strict";const r=n(2613);class RedisError extends Error{get name(){return this.constructor.name}}class ParserError extends RedisError{constructor(e,t,n){r(t);r.strictEqual(typeof n,"number");const i=Error.stackTraceLimit;Error.stackTraceLimit=2;super(e);Error.stackTraceLimit=i;this.offset=n;this.buffer=t}get name(){return this.constructor.name}}class ReplyError extends RedisError{constructor(e){const t=Error.stackTraceLimit;Error.stackTraceLimit=2;super(e);Error.stackTraceLimit=t}get name(){return this.constructor.name}}class AbortError extends RedisError{get name(){return this.constructor.name}}class InterruptError extends AbortError{get name(){return this.constructor.name}}e.exports={RedisError:RedisError,ParserError:ParserError,ReplyError:ReplyError,AbortError:AbortError,InterruptError:InterruptError}},3554:function(e,t,n){"use strict";const r=n(2613);const i=n(9023);function RedisError(e){Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});Error.captureStackTrace(this,this.constructor)}i.inherits(RedisError,Error);Object.defineProperty(RedisError.prototype,"name",{value:"RedisError",configurable:true,writable:true});function ParserError(e,t,n){r(t);r.strictEqual(typeof n,"number");Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});const i=Error.stackTraceLimit;Error.stackTraceLimit=2;Error.captureStackTrace(this,this.constructor);Error.stackTraceLimit=i;this.offset=n;this.buffer=t}i.inherits(ParserError,RedisError);Object.defineProperty(ParserError.prototype,"name",{value:"ParserError",configurable:true,writable:true});function ReplyError(e){Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});const t=Error.stackTraceLimit;Error.stackTraceLimit=2;Error.captureStackTrace(this,this.constructor);Error.stackTraceLimit=t}i.inherits(ReplyError,RedisError);Object.defineProperty(ReplyError.prototype,"name",{value:"ReplyError",configurable:true,writable:true});function AbortError(e){Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});Error.captureStackTrace(this,this.constructor)}i.inherits(AbortError,RedisError);Object.defineProperty(AbortError.prototype,"name",{value:"AbortError",configurable:true,writable:true});function InterruptError(e){Object.defineProperty(this,"message",{value:e||"",configurable:true,writable:true});Error.captureStackTrace(this,this.constructor)}i.inherits(InterruptError,AbortError);Object.defineProperty(InterruptError.prototype,"name",{value:"InterruptError",configurable:true,writable:true});e.exports={RedisError:RedisError,ParserError:ParserError,ReplyError:ReplyError,AbortError:AbortError,InterruptError:InterruptError}},9751:function(e,t,n){"use strict";e.exports=n(4072)},4072:function(e,t,n){"use strict";const r=n(181).Buffer;const i=n(3193).StringDecoder;const s=new i;const a=n(8287);const o=a.ReplyError;const l=a.ParserError;var c=r.allocUnsafe(32*1024);var u=0;var d=null;var f=0;var p=0;function parseSimpleNumbers(e){const t=e.buffer.length-1;var n=e.offset;var r=0;var i=1;if(e.buffer[n]===45){i=-1;n++}while(n<t){const t=e.buffer[n++];if(t===13){e.offset=n+1;return i*r}r=r*10+(t-48)}}function parseStringNumbers(e){const t=e.buffer.length-1;var n=e.offset;var r=0;var i="";if(e.buffer[n]===45){i+="-";n++}while(n<t){var s=e.buffer[n++];if(s===13){e.offset=n+1;if(r!==0){i+=r}return i}else if(r>429496728){i+=r*10+(s-48);r=0}else if(s===48&&r===0){i+=0}else{r=r*10+(s-48)}}}function parseSimpleString(e){const t=e.offset;const n=e.buffer;const r=n.length-1;var i=t;while(i<r){if(n[i++]===13){e.offset=i+1;if(e.optionReturnBuffers===true){return e.buffer.slice(t,i-1)}return e.buffer.toString("utf8",t,i-1)}}}function parseLength(e){const t=e.buffer.length-1;var n=e.offset;var r=0;while(n<t){const t=e.buffer[n++];if(t===13){e.offset=n+1;return r}r=r*10+(t-48)}}function parseInteger(e){if(e.optionStringNumbers===true){return parseStringNumbers(e)}return parseSimpleNumbers(e)}function parseBulkString(e){const t=parseLength(e);if(t===undefined){return}if(t<0){return null}const n=e.offset+t;if(n+2>e.buffer.length){e.bigStrSize=n+2;e.totalChunkSize=e.buffer.length;e.bufferCache.push(e.buffer);return}const r=e.offset;e.offset=n+2;if(e.optionReturnBuffers===true){return e.buffer.slice(r,n)}return e.buffer.toString("utf8",r,n)}function parseError(e){var t=parseSimpleString(e);if(t!==undefined){if(e.optionReturnBuffers===true){t=t.toString()}return new o(t)}}function handleError(e,t){const n=new l("Protocol error, got "+JSON.stringify(String.fromCharCode(t))+" as reply type byte",JSON.stringify(e.buffer),e.offset);e.buffer=null;e.returnFatalError(n)}function parseArray(e){const t=parseLength(e);if(t===undefined){return}if(t<0){return null}const n=new Array(t);return parseArrayElements(e,n,0)}function pushArrayCache(e,t,n){e.arrayCache.push(t);e.arrayPos.push(n)}function parseArrayChunks(e){const t=e.arrayCache.pop();var n=e.arrayPos.pop();if(e.arrayCache.length){const r=parseArrayChunks(e);if(r===undefined){pushArrayCache(e,t,n);return}t[n++]=r}return parseArrayElements(e,t,n)}function parseArrayElements(e,t,n){const r=e.buffer.length;while(n<t.length){const i=e.offset;if(e.offset>=r){pushArrayCache(e,t,n);return}const s=parseType(e,e.buffer[e.offset++]);if(s===undefined){if(!(e.arrayCache.length||e.bufferCache.length)){e.offset=i}pushArrayCache(e,t,n);return}t[n]=s;n++}return t}function parseType(e,t){switch(t){case 36:return parseBulkString(e);case 43:return parseSimpleString(e);case 42:return parseArray(e);case 58:return parseInteger(e);case 45:return parseError(e);default:return handleError(e,t)}}function decreaseBufferPool(){if(c.length>50*1024){if(f===1||p>f*2){const e=Math.floor(c.length/10);const t=e<u?u:e;u=0;c=c.slice(t,c.length)}else{p++;f--}}else{clearInterval(d);f=0;p=0;d=null}}function resizeBuffer(e){if(c.length<e+u){const t=e>1024*1024*75?2:3;if(u>1024*1024*111){u=1024*1024*50}c=r.allocUnsafe(e*t+u);u=0;f++;if(d===null){d=setInterval(decreaseBufferPool,50)}}}function concatBulkString(e){const t=e.bufferCache;const n=e.offset;var r=t.length;var i=e.bigStrSize-e.totalChunkSize;e.offset=i;if(i<=2){if(r===2){return t[0].toString("utf8",n,t[0].length+i-2)}r--;i=t[t.length-2].length+i}var a=s.write(t[0].slice(n));for(var o=1;o<r-1;o++){a+=s.write(t[o])}a+=s.end(t[o].slice(0,i-2));return a}function concatBulkBuffer(e){const t=e.bufferCache;const n=e.offset;const r=e.bigStrSize-n-2;var i=t.length;var s=e.bigStrSize-e.totalChunkSize;e.offset=s;if(s<=2){if(i===2){return t[0].slice(n,t[0].length+s-2)}i--;s=t[t.length-2].length+s}resizeBuffer(r);const a=u;t[0].copy(c,a,n,t[0].length);u+=t[0].length-n;for(var o=1;o<i-1;o++){t[o].copy(c,u);u+=t[o].length}t[o].copy(c,u,0,s-2);u+=s-2;return c.slice(a,u)}class JavascriptRedisParser{constructor(e){if(!e){throw new TypeError("Options are mandatory.")}if(typeof e.returnError!=="function"||typeof e.returnReply!=="function"){throw new TypeError("The returnReply and returnError options have to be functions.")}this.setReturnBuffers(!!e.returnBuffers);this.setStringNumbers(!!e.stringNumbers);this.returnError=e.returnError;this.returnFatalError=e.returnFatalError||e.returnError;this.returnReply=e.returnReply;this.reset()}reset(){this.offset=0;this.buffer=null;this.bigStrSize=0;this.totalChunkSize=0;this.bufferCache=[];this.arrayCache=[];this.arrayPos=[]}setReturnBuffers(e){if(typeof e!=="boolean"){throw new TypeError("The returnBuffers argument has to be a boolean")}this.optionReturnBuffers=e}setStringNumbers(e){if(typeof e!=="boolean"){throw new TypeError("The stringNumbers argument has to be a boolean")}this.optionStringNumbers=e}execute(e){if(this.buffer===null){this.buffer=e;this.offset=0}else if(this.bigStrSize===0){const t=this.buffer.length;const n=t-this.offset;const i=r.allocUnsafe(n+e.length);this.buffer.copy(i,0,this.offset,t);e.copy(i,n,0,e.length);this.buffer=i;this.offset=0;if(this.arrayCache.length){const e=parseArrayChunks(this);if(e===undefined){return}this.returnReply(e)}}else if(this.totalChunkSize+e.length>=this.bigStrSize){this.bufferCache.push(e);var t=this.optionReturnBuffers?concatBulkBuffer(this):concatBulkString(this);this.bigStrSize=0;this.bufferCache=[];this.buffer=e;if(this.arrayCache.length){this.arrayCache[0][this.arrayPos[0]++]=t;t=parseArrayChunks(this);if(t===undefined){return}}this.returnReply(t)}else{this.bufferCache.push(e);this.totalChunkSize+=e.length;return}while(this.offset<this.buffer.length){const e=this.offset;const t=this.buffer[this.offset++];const n=parseType(this,t);if(n===undefined){if(!(this.arrayCache.length||this.bufferCache.length)){this.offset=e}return}if(t===45){this.returnError(n)}else{this.returnReply(n)}}this.buffer=null}}e.exports=JavascriptRedisParser},863:function(e,t,n){"use strict";const r=Symbol("SemVer ANY");class Comparator{static get ANY(){return r}constructor(e,t){t=i(t);if(e instanceof Comparator){if(e.loose===!!t.loose){return e}else{e=e.value}}e=e.trim().split(/\s+/).join(" ");l("comparator",e,t);this.options=t;this.loose=!!t.loose;this.parse(e);if(this.semver===r){this.value=""}else{this.value=this.operator+this.semver.version}l("comp",this)}parse(e){const t=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR];const n=e.match(t);if(!n){throw new TypeError(`Invalid comparator: ${e}`)}this.operator=n[1]!==undefined?n[1]:"";if(this.operator==="="){this.operator=""}if(!n[2]){this.semver=r}else{this.semver=new c(n[2],this.options.loose)}}toString(){return this.value}test(e){l("Comparator.test",e,this.options.loose);if(this.semver===r||e===r){return true}if(typeof e==="string"){try{e=new c(e,this.options)}catch(e){return false}}return o(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof Comparator)){throw new TypeError("a Comparator is required")}if(this.operator===""){if(this.value===""){return true}return new u(e.value,t).test(this.value)}else if(e.operator===""){if(e.value===""){return true}return new u(this.value,t).test(e.semver)}t=i(t);if(t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")){return false}if(!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))){return false}if(this.operator.startsWith(">")&&e.operator.startsWith(">")){return true}if(this.operator.startsWith("<")&&e.operator.startsWith("<")){return true}if(this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")){return true}if(o(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<")){return true}if(o(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")){return true}return false}}e.exports=Comparator;const i=n(2600);const{safeRe:s,t:a}=n(6211);const o=n(5618);const l=n(7611);const c=n(4839);const u=n(8474)},8474:function(e,t,n){"use strict";const r=/\s+/g;class Range{constructor(e,t){t=a(t);if(e instanceof Range){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease){return e}else{return new Range(e.raw,t)}}if(e instanceof o){this.raw=e.value;this.set=[[e]];this.formatted=undefined;return this}this.options=t;this.loose=!!t.loose;this.includePrerelease=!!t.includePrerelease;this.raw=e.trim().replace(r," ");this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length));if(!this.set.length){throw new TypeError(`Invalid SemVer Range: ${this.raw}`)}if(this.set.length>1){const e=this.set[0];this.set=this.set.filter((e=>!isNullSet(e[0])));if(this.set.length===0){this.set=[e]}else if(this.set.length>1){for(const e of this.set){if(e.length===1&&isAny(e[0])){this.set=[e];break}}}}this.formatted=undefined}get range(){if(this.formatted===undefined){this.formatted="";for(let e=0;e<this.set.length;e++){if(e>0){this.formatted+="||"}const t=this.set[e];for(let e=0;e<t.length;e++){if(e>0){this.formatted+=" "}this.formatted+=t[e].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=(this.options.includePrerelease&&y)|(this.options.loose&&m);const n=t+":"+e;const r=s.get(n);if(r){return r}const i=this.options.loose;const a=i?u[d.HYPHENRANGELOOSE]:u[d.HYPHENRANGE];e=e.replace(a,hyphenReplace(this.options.includePrerelease));l("hyphen replace",e);e=e.replace(u[d.COMPARATORTRIM],f);l("comparator trim",e);e=e.replace(u[d.TILDETRIM],p);l("tilde trim",e);e=e.replace(u[d.CARETTRIM],h);l("caret trim",e);let c=e.split(" ").map((e=>parseComparator(e,this.options))).join(" ").split(/\s+/).map((e=>replaceGTE0(e,this.options)));if(i){c=c.filter((e=>{l("loose invalid filter",e,this.options);return!!e.match(u[d.COMPARATORLOOSE])}))}l("range list",c);const b=new Map;const g=c.map((e=>new o(e,this.options)));for(const e of g){if(isNullSet(e)){return[e]}b.set(e.value,e)}if(b.size>1&&b.has("")){b.delete("")}const v=[...b.values()];s.set(n,v);return v}intersects(e,t){if(!(e instanceof Range)){throw new TypeError("a Range is required")}return this.set.some((n=>isSatisfiable(n,t)&&e.set.some((e=>isSatisfiable(e,t)&&n.every((n=>e.every((e=>n.intersects(e,t)))))))))}test(e){if(!e){return false}if(typeof e==="string"){try{e=new c(e,this.options)}catch(e){return false}}for(let t=0;t<this.set.length;t++){if(testSet(this.set[t],e,this.options)){return true}}return false}}e.exports=Range;const i=n(2443);const s=new i;const a=n(2600);const o=n(863);const l=n(7611);const c=n(4839);const{safeRe:u,t:d,comparatorTrimReplace:f,tildeTrimReplace:p,caretTrimReplace:h}=n(6211);const{FLAG_INCLUDE_PRERELEASE:y,FLAG_LOOSE:m}=n(4329);const isNullSet=e=>e.value==="<0.0.0-0";const isAny=e=>e.value==="";const isSatisfiable=(e,t)=>{let n=true;const r=e.slice();let i=r.pop();while(n&&r.length){n=r.every((e=>i.intersects(e,t)));i=r.pop()}return n};const parseComparator=(e,t)=>{l("comp",e,t);e=replaceCarets(e,t);l("caret",e);e=replaceTildes(e,t);l("tildes",e);e=replaceXRanges(e,t);l("xrange",e);e=replaceStars(e,t);l("stars",e);return e};const isX=e=>!e||e.toLowerCase()==="x"||e==="*";const replaceTildes=(e,t)=>e.trim().split(/\s+/).map((e=>replaceTilde(e,t))).join(" ");const replaceTilde=(e,t)=>{const n=t.loose?u[d.TILDELOOSE]:u[d.TILDE];return e.replace(n,((t,n,r,i,s)=>{l("tilde",e,t,n,r,i,s);let a;if(isX(n)){a=""}else if(isX(r)){a=`>=${n}.0.0 <${+n+1}.0.0-0`}else if(isX(i)){a=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`}else if(s){l("replaceTilde pr",s);a=`>=${n}.${r}.${i}-${s} <${n}.${+r+1}.0-0`}else{a=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`}l("tilde return",a);return a}))};const replaceCarets=(e,t)=>e.trim().split(/\s+/).map((e=>replaceCaret(e,t))).join(" ");const replaceCaret=(e,t)=>{l("caret",e,t);const n=t.loose?u[d.CARETLOOSE]:u[d.CARET];const r=t.includePrerelease?"-0":"";return e.replace(n,((t,n,i,s,a)=>{l("caret",e,t,n,i,s,a);let o;if(isX(n)){o=""}else if(isX(i)){o=`>=${n}.0.0${r} <${+n+1}.0.0-0`}else if(isX(s)){if(n==="0"){o=`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`}else{o=`>=${n}.${i}.0${r} <${+n+1}.0.0-0`}}else if(a){l("replaceCaret pr",a);if(n==="0"){if(i==="0"){o=`>=${n}.${i}.${s}-${a} <${n}.${i}.${+s+1}-0`}else{o=`>=${n}.${i}.${s}-${a} <${n}.${+i+1}.0-0`}}else{o=`>=${n}.${i}.${s}-${a} <${+n+1}.0.0-0`}}else{l("no pr");if(n==="0"){if(i==="0"){o=`>=${n}.${i}.${s}${r} <${n}.${i}.${+s+1}-0`}else{o=`>=${n}.${i}.${s}${r} <${n}.${+i+1}.0-0`}}else{o=`>=${n}.${i}.${s} <${+n+1}.0.0-0`}}l("caret return",o);return o}))};const replaceXRanges=(e,t)=>{l("replaceXRanges",e,t);return e.split(/\s+/).map((e=>replaceXRange(e,t))).join(" ")};const replaceXRange=(e,t)=>{e=e.trim();const n=t.loose?u[d.XRANGELOOSE]:u[d.XRANGE];return e.replace(n,((n,r,i,s,a,o)=>{l("xRange",e,n,r,i,s,a,o);const c=isX(i);const u=c||isX(s);const d=u||isX(a);const f=d;if(r==="="&&f){r=""}o=t.includePrerelease?"-0":"";if(c){if(r===">"||r==="<"){n="<0.0.0-0"}else{n="*"}}else if(r&&f){if(u){s=0}a=0;if(r===">"){r=">=";if(u){i=+i+1;s=0;a=0}else{s=+s+1;a=0}}else if(r==="<="){r="<";if(u){i=+i+1}else{s=+s+1}}if(r==="<"){o="-0"}n=`${r+i}.${s}.${a}${o}`}else if(u){n=`>=${i}.0.0${o} <${+i+1}.0.0-0`}else if(d){n=`>=${i}.${s}.0${o} <${i}.${+s+1}.0-0`}l("xRange return",n);return n}))};const replaceStars=(e,t)=>{l("replaceStars",e,t);return e.trim().replace(u[d.STAR],"")};const replaceGTE0=(e,t)=>{l("replaceGTE0",e,t);return e.trim().replace(u[t.includePrerelease?d.GTE0PRE:d.GTE0],"")};const hyphenReplace=e=>(t,n,r,i,s,a,o,l,c,u,d,f)=>{if(isX(r)){n=""}else if(isX(i)){n=`>=${r}.0.0${e?"-0":""}`}else if(isX(s)){n=`>=${r}.${i}.0${e?"-0":""}`}else if(a){n=`>=${n}`}else{n=`>=${n}${e?"-0":""}`}if(isX(c)){l=""}else if(isX(u)){l=`<${+c+1}.0.0-0`}else if(isX(d)){l=`<${c}.${+u+1}.0-0`}else if(f){l=`<=${c}.${u}.${d}-${f}`}else if(e){l=`<${c}.${u}.${+d+1}-0`}else{l=`<=${l}`}return`${n} ${l}`.trim()};const testSet=(e,t,n)=>{for(let n=0;n<e.length;n++){if(!e[n].test(t)){return false}}if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++){l(e[n].semver);if(e[n].semver===o.ANY){continue}if(e[n].semver.prerelease.length>0){const r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch){return true}}}return false}return true}},4839:function(e,t,n){"use strict";const r=n(7611);const{MAX_LENGTH:i,MAX_SAFE_INTEGER:s}=n(4329);const{safeRe:a,t:o}=n(6211);const l=n(2600);const{compareIdentifiers:c}=n(6104);class SemVer{constructor(e,t){t=l(t);if(e instanceof SemVer){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease){return e}else{e=e.version}}else if(typeof e!=="string"){throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`)}if(e.length>i){throw new TypeError(`version is longer than ${i} characters`)}r("SemVer",e,t);this.options=t;this.loose=!!t.loose;this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?a[o.LOOSE]:a[o.FULL]);if(!n){throw new TypeError(`Invalid Version: ${e}`)}this.raw=e;this.major=+n[1];this.minor=+n[2];this.patch=+n[3];if(this.major>s||this.major<0){throw new TypeError("Invalid major version")}if(this.minor>s||this.minor<0){throw new TypeError("Invalid minor version")}if(this.patch>s||this.patch<0){throw new TypeError("Invalid patch version")}if(!n[4]){this.prerelease=[]}else{this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<s){return t}}return e}))}this.build=n[5]?n[5].split("."):[];this.format()}format(){this.version=`${this.major}.${this.minor}.${this.patch}`;if(this.prerelease.length){this.version+=`-${this.prerelease.join(".")}`}return this.version}toString(){return this.version}compare(e){r("SemVer.compare",this.version,this.options,e);if(!(e instanceof SemVer)){if(typeof e==="string"&&e===this.version){return 0}e=new SemVer(e,this.options)}if(e.version===this.version){return 0}return this.compareMain(e)||this.comparePre(e)}compareMain(e){if(!(e instanceof SemVer)){e=new SemVer(e,this.options)}return c(this.major,e.major)||c(this.minor,e.minor)||c(this.patch,e.patch)}comparePre(e){if(!(e instanceof SemVer)){e=new SemVer(e,this.options)}if(this.prerelease.length&&!e.prerelease.length){return-1}else if(!this.prerelease.length&&e.prerelease.length){return 1}else if(!this.prerelease.length&&!e.prerelease.length){return 0}let t=0;do{const n=this.prerelease[t];const i=e.prerelease[t];r("prerelease compare",t,n,i);if(n===undefined&&i===undefined){return 0}else if(i===undefined){return 1}else if(n===undefined){return-1}else if(n===i){continue}else{return c(n,i)}}while(++t)}compareBuild(e){if(!(e instanceof SemVer)){e=new SemVer(e,this.options)}let t=0;do{const n=this.build[t];const i=e.build[t];r("build compare",t,n,i);if(n===undefined&&i===undefined){return 0}else if(i===undefined){return 1}else if(n===undefined){return-1}else if(n===i){continue}else{return c(n,i)}}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&n===false){throw new Error("invalid increment argument: identifier is empty")}if(t){const e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t){throw new Error(`invalid identifier: ${t}`)}}}switch(e){case"premajor":this.prerelease.length=0;this.patch=0;this.minor=0;this.major++;this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0;this.patch=0;this.minor++;this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0;this.inc("patch",t,n);this.inc("pre",t,n);break;case"prerelease":if(this.prerelease.length===0){this.inc("patch",t,n)}this.inc("pre",t,n);break;case"release":if(this.prerelease.length===0){throw new Error(`version ${this.raw} is not a prerelease`)}this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0){this.major++}this.minor=0;this.patch=0;this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0){this.minor++}this.patch=0;this.prerelease=[];break;case"patch":if(this.prerelease.length===0){this.patch++}this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(this.prerelease.length===0){this.prerelease=[e]}else{let r=this.prerelease.length;while(--r>=0){if(typeof this.prerelease[r]==="number"){this.prerelease[r]++;r=-2}}if(r===-1){if(t===this.prerelease.join(".")&&n===false){throw new Error("invalid increment argument: identifier already exists")}this.prerelease.push(e)}}if(t){let r=[t,e];if(n===false){r=[t]}if(c(this.prerelease[0],t)===0){if(isNaN(this.prerelease[1])){this.prerelease=r}}else{this.prerelease=r}}break}default:throw new Error(`invalid increment argument: ${e}`)}this.raw=this.format();if(this.build.length){this.raw+=`+${this.build.join(".")}`}return this}}e.exports=SemVer},2771:function(e,t,n){"use strict";const r=n(893);const clean=(e,t)=>{const n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null};e.exports=clean},5618:function(e,t,n){"use strict";const r=n(5630);const i=n(3282);const s=n(5283);const a=n(6064);const o=n(6108);const l=n(3353);const cmp=(e,t,n,c)=>{switch(t){case"===":if(typeof e==="object"){e=e.version}if(typeof n==="object"){n=n.version}return e===n;case"!==":if(typeof e==="object"){e=e.version}if(typeof n==="object"){n=n.version}return e!==n;case"":case"=":case"==":return r(e,n,c);case"!=":return i(e,n,c);case">":return s(e,n,c);case">=":return a(e,n,c);case"<":return o(e,n,c);case"<=":return l(e,n,c);default:throw new TypeError(`Invalid operator: ${t}`)}};e.exports=cmp},3597:function(e,t,n){"use strict";const r=n(4839);const i=n(893);const{safeRe:s,t:a}=n(6211);const coerce=(e,t)=>{if(e instanceof r){return e}if(typeof e==="number"){e=String(e)}if(typeof e!=="string"){return null}t=t||{};let n=null;if(!t.rtl){n=e.match(t.includePrerelease?s[a.COERCEFULL]:s[a.COERCE])}else{const r=t.includePrerelease?s[a.COERCERTLFULL]:s[a.COERCERTL];let i;while((i=r.exec(e))&&(!n||n.index+n[0].length!==e.length)){if(!n||i.index+i[0].length!==n.index+n[0].length){n=i}r.lastIndex=i.index+i[1].length+i[2].length}r.lastIndex=-1}if(n===null){return null}const o=n[2];const l=n[3]||"0";const c=n[4]||"0";const u=t.includePrerelease&&n[5]?`-${n[5]}`:"";const d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return i(`${o}.${l}.${c}${u}${d}`,t)};e.exports=coerce},3932:function(e,t,n){"use strict";const r=n(4839);const compareBuild=(e,t,n)=>{const i=new r(e,n);const s=new r(t,n);return i.compare(s)||i.compareBuild(s)};e.exports=compareBuild},9822:function(e,t,n){"use strict";const r=n(6625);const compareLoose=(e,t)=>r(e,t,true);e.exports=compareLoose},6625:function(e,t,n){"use strict";const r=n(4839);const compare=(e,t,n)=>new r(e,n).compare(new r(t,n));e.exports=compare},1531:function(e,t,n){"use strict";const r=n(893);const diff=(e,t)=>{const n=r(e,null,true);const i=r(t,null,true);const s=n.compare(i);if(s===0){return null}const a=s>0;const o=a?n:i;const l=a?i:n;const c=!!o.prerelease.length;const u=!!l.prerelease.length;if(u&&!c){if(!l.patch&&!l.minor){return"major"}if(l.compareMain(o)===0){if(l.minor&&!l.patch){return"minor"}return"patch"}}const d=c?"pre":"";if(n.major!==i.major){return d+"major"}if(n.minor!==i.minor){return d+"minor"}if(n.patch!==i.patch){return d+"patch"}return"prerelease"};e.exports=diff},5630:function(e,t,n){"use strict";const r=n(6625);const eq=(e,t,n)=>r(e,t,n)===0;e.exports=eq},5283:function(e,t,n){"use strict";const r=n(6625);const gt=(e,t,n)=>r(e,t,n)>0;e.exports=gt},6064:function(e,t,n){"use strict";const r=n(6625);const gte=(e,t,n)=>r(e,t,n)>=0;e.exports=gte},2782:function(e,t,n){"use strict";const r=n(4839);const inc=(e,t,n,i,s)=>{if(typeof n==="string"){s=i;i=n;n=undefined}try{return new r(e instanceof r?e.version:e,n).inc(t,i,s).version}catch(e){return null}};e.exports=inc},6108:function(e,t,n){"use strict";const r=n(6625);const lt=(e,t,n)=>r(e,t,n)<0;e.exports=lt},3353:function(e,t,n){"use strict";const r=n(6625);const lte=(e,t,n)=>r(e,t,n)<=0;e.exports=lte},5251:function(e,t,n){"use strict";const r=n(4839);const major=(e,t)=>new r(e,t).major;e.exports=major},5479:function(e,t,n){"use strict";const r=n(4839);const minor=(e,t)=>new r(e,t).minor;e.exports=minor},3282:function(e,t,n){"use strict";const r=n(6625);const neq=(e,t,n)=>r(e,t,n)!==0;e.exports=neq},893:function(e,t,n){"use strict";const r=n(4839);const parse=(e,t,n=false)=>{if(e instanceof r){return e}try{return new r(e,t)}catch(e){if(!n){return null}throw e}};e.exports=parse},7056:function(e,t,n){"use strict";const r=n(4839);const patch=(e,t)=>new r(e,t).patch;e.exports=patch},390:function(e,t,n){"use strict";const r=n(893);const prerelease=(e,t)=>{const n=r(e,t);return n&&n.prerelease.length?n.prerelease:null};e.exports=prerelease},9729:function(e,t,n){"use strict";const r=n(6625);const rcompare=(e,t,n)=>r(t,e,n);e.exports=rcompare},8828:function(e,t,n){"use strict";const r=n(3932);const rsort=(e,t)=>e.sort(((e,n)=>r(n,e,t)));e.exports=rsort},2132:function(e,t,n){"use strict";const r=n(8474);const satisfies=(e,t,n)=>{try{t=new r(t,n)}catch(e){return false}return t.test(e)};e.exports=satisfies},6476:function(e,t,n){"use strict";const r=n(3932);const sort=(e,t)=>e.sort(((e,n)=>r(e,n,t)));e.exports=sort},5752:function(e,t,n){"use strict";const r=n(893);const valid=(e,t)=>{const n=r(e,t);return n?n.version:null};e.exports=valid},2348:function(e,t,n){"use strict";const r=n(6211);const i=n(4329);const s=n(4839);const a=n(6104);const o=n(893);const l=n(5752);const c=n(2771);const u=n(2782);const d=n(1531);const f=n(5251);const p=n(5479);const h=n(7056);const y=n(390);const m=n(6625);const b=n(9729);const g=n(9822);const v=n(3932);const K=n(6476);const S=n(8828);const E=n(5283);const k=n(6108);const I=n(5630);const w=n(3282);const j=n(6064);const x=n(3353);const T=n(5618);const D=n(3597);const O=n(863);const C=n(8474);const A=n(2132);const R=n(2258);const _=n(9269);const M=n(1367);const P=n(6950);const N=n(8733);const L=n(4772);const J=n(712);const F=n(5585);const V=n(1357);const G=n(7344);const q=n(4837);e.exports={parse:o,valid:l,clean:c,inc:u,diff:d,major:f,minor:p,patch:h,prerelease:y,compare:m,rcompare:b,compareLoose:g,compareBuild:v,sort:K,rsort:S,gt:E,lt:k,eq:I,neq:w,gte:j,lte:x,cmp:T,coerce:D,Comparator:O,Range:C,satisfies:A,toComparators:R,maxSatisfying:_,minSatisfying:M,minVersion:P,validRange:N,outside:L,gtr:J,ltr:F,intersects:V,simplifyRange:G,subset:q,SemVer:s,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}},4329:function(e){"use strict";const t="2.0.0";const n=256;const r=Number.MAX_SAFE_INTEGER||9007199254740991;const i=16;const s=n-6;const a=["major","premajor","minor","preminor","patch","prepatch","prerelease"];e.exports={MAX_LENGTH:n,MAX_SAFE_COMPONENT_LENGTH:i,MAX_SAFE_BUILD_LENGTH:s,MAX_SAFE_INTEGER:r,RELEASE_TYPES:a,SEMVER_SPEC_VERSION:t,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},7611:function(e){"use strict";const t=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},6104:function(e){"use strict";const t=/^[0-9]+$/;const compareIdentifiers=(e,n)=>{const r=t.test(e);const i=t.test(n);if(r&&i){e=+e;n=+n}return e===n?0:r&&!i?-1:i&&!r?1:e<n?-1:1};const rcompareIdentifiers=(e,t)=>compareIdentifiers(t,e);e.exports={compareIdentifiers:compareIdentifiers,rcompareIdentifiers:rcompareIdentifiers}},2443:function(e){"use strict";class LRUCache{constructor(){this.max=1e3;this.map=new Map}get(e){const t=this.map.get(e);if(t===undefined){return undefined}else{this.map.delete(e);this.map.set(e,t);return t}}delete(e){return this.map.delete(e)}set(e,t){const n=this.delete(e);if(!n&&t!==undefined){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}e.exports=LRUCache},2600:function(e){"use strict";const t=Object.freeze({loose:true});const n=Object.freeze({});const parseOptions=e=>{if(!e){return n}if(typeof e!=="object"){return t}return e};e.exports=parseOptions},6211:function(e,t,n){"use strict";const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:s}=n(4329);const a=n(7611);t=e.exports={};const o=t.re=[];const l=t.safeRe=[];const c=t.src=[];const u=t.safeSrc=[];const d=t.t={};let f=0;const p="[a-zA-Z0-9-]";const h=[["\\s",1],["\\d",s],[p,i]];const makeSafeRegex=e=>{for(const[t,n]of h){e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`)}return e};const createToken=(e,t,n)=>{const r=makeSafeRegex(t);const i=f++;a(e,i,t);d[e]=i;c[i]=t;u[i]=r;o[i]=new RegExp(t,n?"g":undefined);l[i]=new RegExp(r,n?"g":undefined)};createToken("NUMERICIDENTIFIER","0|[1-9]\\d*");createToken("NUMERICIDENTIFIERLOOSE","\\d+");createToken("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`);createToken("MAINVERSION",`(${c[d.NUMERICIDENTIFIER]})\\.`+`(${c[d.NUMERICIDENTIFIER]})\\.`+`(${c[d.NUMERICIDENTIFIER]})`);createToken("MAINVERSIONLOOSE",`(${c[d.NUMERICIDENTIFIERLOOSE]})\\.`+`(${c[d.NUMERICIDENTIFIERLOOSE]})\\.`+`(${c[d.NUMERICIDENTIFIERLOOSE]})`);createToken("PRERELEASEIDENTIFIER",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIER]})`);createToken("PRERELEASEIDENTIFIERLOOSE",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIERLOOSE]})`);createToken("PRERELEASE",`(?:-(${c[d.PRERELEASEIDENTIFIER]}(?:\\.${c[d.PRERELEASEIDENTIFIER]})*))`);createToken("PRERELEASELOOSE",`(?:-?(${c[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[d.PRERELEASEIDENTIFIERLOOSE]})*))`);createToken("BUILDIDENTIFIER",`${p}+`);createToken("BUILD",`(?:\\+(${c[d.BUILDIDENTIFIER]}(?:\\.${c[d.BUILDIDENTIFIER]})*))`);createToken("FULLPLAIN",`v?${c[d.MAINVERSION]}${c[d.PRERELEASE]}?${c[d.BUILD]}?`);createToken("FULL",`^${c[d.FULLPLAIN]}$`);createToken("LOOSEPLAIN",`[v=\\s]*${c[d.MAINVERSIONLOOSE]}${c[d.PRERELEASELOOSE]}?${c[d.BUILD]}?`);createToken("LOOSE",`^${c[d.LOOSEPLAIN]}$`);createToken("GTLT","((?:<|>)?=?)");createToken("XRANGEIDENTIFIERLOOSE",`${c[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);createToken("XRANGEIDENTIFIER",`${c[d.NUMERICIDENTIFIER]}|x|X|\\*`);createToken("XRANGEPLAIN",`[v=\\s]*(${c[d.XRANGEIDENTIFIER]})`+`(?:\\.(${c[d.XRANGEIDENTIFIER]})`+`(?:\\.(${c[d.XRANGEIDENTIFIER]})`+`(?:${c[d.PRERELEASE]})?${c[d.BUILD]}?`+`)?)?`);createToken("XRANGEPLAINLOOSE",`[v=\\s]*(${c[d.XRANGEIDENTIFIERLOOSE]})`+`(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})`+`(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})`+`(?:${c[d.PRERELEASELOOSE]})?${c[d.BUILD]}?`+`)?)?`);createToken("XRANGE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAIN]}$`);createToken("XRANGELOOSE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAINLOOSE]}$`);createToken("COERCEPLAIN",`${"(^|[^\\d])"+"(\\d{1,"}${r}})`+`(?:\\.(\\d{1,${r}}))?`+`(?:\\.(\\d{1,${r}}))?`);createToken("COERCE",`${c[d.COERCEPLAIN]}(?:$|[^\\d])`);createToken("COERCEFULL",c[d.COERCEPLAIN]+`(?:${c[d.PRERELEASE]})?`+`(?:${c[d.BUILD]})?`+`(?:$|[^\\d])`);createToken("COERCERTL",c[d.COERCE],true);createToken("COERCERTLFULL",c[d.COERCEFULL],true);createToken("LONETILDE","(?:~>?)");createToken("TILDETRIM",`(\\s*)${c[d.LONETILDE]}\\s+`,true);t.tildeTrimReplace="$1~";createToken("TILDE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAIN]}$`);createToken("TILDELOOSE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAINLOOSE]}$`);createToken("LONECARET","(?:\\^)");createToken("CARETTRIM",`(\\s*)${c[d.LONECARET]}\\s+`,true);t.caretTrimReplace="$1^";createToken("CARET",`^${c[d.LONECARET]}${c[d.XRANGEPLAIN]}$`);createToken("CARETLOOSE",`^${c[d.LONECARET]}${c[d.XRANGEPLAINLOOSE]}$`);createToken("COMPARATORLOOSE",`^${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]})$|^$`);createToken("COMPARATOR",`^${c[d.GTLT]}\\s*(${c[d.FULLPLAIN]})$|^$`);createToken("COMPARATORTRIM",`(\\s*)${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]}|${c[d.XRANGEPLAIN]})`,true);t.comparatorTrimReplace="$1$2$3";createToken("HYPHENRANGE",`^\\s*(${c[d.XRANGEPLAIN]})`+`\\s+-\\s+`+`(${c[d.XRANGEPLAIN]})`+`\\s*$`);createToken("HYPHENRANGELOOSE",`^\\s*(${c[d.XRANGEPLAINLOOSE]})`+`\\s+-\\s+`+`(${c[d.XRANGEPLAINLOOSE]})`+`\\s*$`);createToken("STAR","(<|>)?=?\\s*\\*");createToken("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");createToken("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},712:function(e,t,n){"use strict";const r=n(4772);const gtr=(e,t,n)=>r(e,t,">",n);e.exports=gtr},1357:function(e,t,n){"use strict";const r=n(8474);const intersects=(e,t,n)=>{e=new r(e,n);t=new r(t,n);return e.intersects(t,n)};e.exports=intersects},5585:function(e,t,n){"use strict";const r=n(4772);const ltr=(e,t,n)=>r(e,t,"<",n);e.exports=ltr},9269:function(e,t,n){"use strict";const r=n(4839);const i=n(8474);const maxSatisfying=(e,t,n)=>{let s=null;let a=null;let o=null;try{o=new i(t,n)}catch(e){return null}e.forEach((e=>{if(o.test(e)){if(!s||a.compare(e)===-1){s=e;a=new r(s,n)}}}));return s};e.exports=maxSatisfying},1367:function(e,t,n){"use strict";const r=n(4839);const i=n(8474);const minSatisfying=(e,t,n)=>{let s=null;let a=null;let o=null;try{o=new i(t,n)}catch(e){return null}e.forEach((e=>{if(o.test(e)){if(!s||a.compare(e)===1){s=e;a=new r(s,n)}}}));return s};e.exports=minSatisfying},6950:function(e,t,n){"use strict";const r=n(4839);const i=n(8474);const s=n(5283);const minVersion=(e,t)=>{e=new i(e,t);let n=new r("0.0.0");if(e.test(n)){return n}n=new r("0.0.0-0");if(e.test(n)){return n}n=null;for(let t=0;t<e.set.length;++t){const i=e.set[t];let a=null;i.forEach((e=>{const t=new r(e.semver.version);switch(e.operator){case">":if(t.prerelease.length===0){t.patch++}else{t.prerelease.push(0)}t.raw=t.format();case"":case">=":if(!a||s(t,a)){a=t}break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}}));if(a&&(!n||s(n,a))){n=a}}if(n&&e.test(n)){return n}return null};e.exports=minVersion},4772:function(e,t,n){"use strict";const r=n(4839);const i=n(863);const{ANY:s}=i;const a=n(8474);const o=n(2132);const l=n(5283);const c=n(6108);const u=n(3353);const d=n(6064);const outside=(e,t,n,f)=>{e=new r(e,f);t=new a(t,f);let p,h,y,m,b;switch(n){case">":p=l;h=u;y=c;m=">";b=">=";break;case"<":p=c;h=d;y=l;m="<";b="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(o(e,t,f)){return false}for(let n=0;n<t.set.length;++n){const r=t.set[n];let a=null;let o=null;r.forEach((e=>{if(e.semver===s){e=new i(">=0.0.0")}a=a||e;o=o||e;if(p(e.semver,a.semver,f)){a=e}else if(y(e.semver,o.semver,f)){o=e}}));if(a.operator===m||a.operator===b){return false}if((!o.operator||o.operator===m)&&h(e,o.semver)){return false}else if(o.operator===b&&y(e,o.semver)){return false}}return true};e.exports=outside},7344:function(e,t,n){"use strict";const r=n(2132);const i=n(6625);e.exports=(e,t,n)=>{const s=[];let a=null;let o=null;const l=e.sort(((e,t)=>i(e,t,n)));for(const e of l){const i=r(e,t,n);if(i){o=e;if(!a){a=e}}else{if(o){s.push([a,o])}o=null;a=null}}if(a){s.push([a,null])}const c=[];for(const[e,t]of s){if(e===t){c.push(e)}else if(!t&&e===l[0]){c.push("*")}else if(!t){c.push(`>=${e}`)}else if(e===l[0]){c.push(`<=${t}`)}else{c.push(`${e} - ${t}`)}}const u=c.join(" || ");const d=typeof t.raw==="string"?t.raw:String(t);return u.length<d.length?u:t}},4837:function(e,t,n){"use strict";const r=n(8474);const i=n(863);const{ANY:s}=i;const a=n(2132);const o=n(6625);const subset=(e,t,n={})=>{if(e===t){return true}e=new r(e,n);t=new r(t,n);let i=false;e:for(const r of e.set){for(const e of t.set){const t=simpleSubset(r,e,n);i=i||t!==null;if(t){continue e}}if(i){return false}}return true};const l=[new i(">=0.0.0-0")];const c=[new i(">=0.0.0")];const simpleSubset=(e,t,n)=>{if(e===t){return true}if(e.length===1&&e[0].semver===s){if(t.length===1&&t[0].semver===s){return true}else if(n.includePrerelease){e=l}else{e=c}}if(t.length===1&&t[0].semver===s){if(n.includePrerelease){return true}else{t=c}}const r=new Set;let i,u;for(const t of e){if(t.operator===">"||t.operator===">="){i=higherGT(i,t,n)}else if(t.operator==="<"||t.operator==="<="){u=lowerLT(u,t,n)}else{r.add(t.semver)}}if(r.size>1){return null}let d;if(i&&u){d=o(i.semver,u.semver,n);if(d>0){return null}else if(d===0&&(i.operator!==">="||u.operator!=="<=")){return null}}for(const e of r){if(i&&!a(e,String(i),n)){return null}if(u&&!a(e,String(u),n)){return null}for(const r of t){if(!a(e,String(r),n)){return false}}return true}let f,p;let h,y;let m=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:false;let b=i&&!n.includePrerelease&&i.semver.prerelease.length?i.semver:false;if(m&&m.prerelease.length===1&&u.operator==="<"&&m.prerelease[0]===0){m=false}for(const e of t){y=y||e.operator===">"||e.operator===">=";h=h||e.operator==="<"||e.operator==="<=";if(i){if(b){if(e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch){b=false}}if(e.operator===">"||e.operator===">="){f=higherGT(i,e,n);if(f===e&&f!==i){return false}}else if(i.operator===">="&&!a(i.semver,String(e),n)){return false}}if(u){if(m){if(e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===m.major&&e.semver.minor===m.minor&&e.semver.patch===m.patch){m=false}}if(e.operator==="<"||e.operator==="<="){p=lowerLT(u,e,n);if(p===e&&p!==u){return false}}else if(u.operator==="<="&&!a(u.semver,String(e),n)){return false}}if(!e.operator&&(u||i)&&d!==0){return false}}if(i&&h&&!u&&d!==0){return false}if(u&&y&&!i&&d!==0){return false}if(b||m){return false}return true};const higherGT=(e,t,n)=>{if(!e){return t}const r=o(e.semver,t.semver,n);return r>0?e:r<0?t:t.operator===">"&&e.operator===">="?t:e};const lowerLT=(e,t,n)=>{if(!e){return t}const r=o(e.semver,t.semver,n);return r<0?e:r>0?t:t.operator==="<"&&e.operator==="<="?t:e};e.exports=subset},2258:function(e,t,n){"use strict";const r=n(8474);const toComparators=(e,t)=>new r(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")));e.exports=toComparators},8733:function(e,t,n){"use strict";const r=n(8474);const validRange=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}};e.exports=validRange},2460:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(549);function throwLater(e){setTimeout((function(){throw e}),0)}function asCallback(e,t,n){if(typeof t==="function"){e.then((e=>{let i;if(n!==undefined&&Object(n).spread&&Array.isArray(e)){i=r.tryCatch(t).apply(undefined,[null].concat(e))}else{i=e===undefined?r.tryCatch(t)(null):r.tryCatch(t)(null,e)}if(i===r.errorObj){throwLater(i.e)}}),(e=>{if(!e){const t=new Error(e+"");Object.assign(t,{cause:e});e=t}const n=r.tryCatch(t)(e);if(n===r.errorObj){throwLater(n.e)}}))}return e}t["default"]=asCallback},549:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.tryCatch=t.errorObj=void 0;t.errorObj={e:{}};let n;function tryCatcher(e,r){try{const e=n;n=null;return e.apply(this,arguments)}catch(e){t.errorObj.e=e;return t.errorObj}}function tryCatch(e){n=e;return tryCatcher}t.tryCatch=tryCatch},5414:function(e,t,n){"use strict";const r=n(857);const i=n(2871);const s=process.env;let a;if(i("no-color")||i("no-colors")||i("color=false")){a=false}else if(i("color")||i("colors")||i("color=true")||i("color=always")){a=true}if("FORCE_COLOR"in s){a=s.FORCE_COLOR.length===0||parseInt(s.FORCE_COLOR,10)!==0}function translateLevel(e){if(e===0){return false}return{level:e,hasBasic:true,has256:e>=2,has16m:e>=3}}function supportsColor(e){if(a===false){return 0}if(i("color=16m")||i("color=full")||i("color=truecolor")){return 3}if(i("color=256")){return 2}if(e&&!e.isTTY&&a!==true){return 0}const t=a?1:0;if(process.platform==="win32"){const e=r.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586){return Number(e[2])>=14931?3:2}return 1}if("CI"in s){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some((e=>e in s))||s.CI_NAME==="codeship"){return 1}return t}if("TEAMCITY_VERSION"in s){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(s.TEAMCITY_VERSION)?1:0}if(s.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in s){const e=parseInt((s.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(s.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(s.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(s.TERM)){return 1}if("COLORTERM"in s){return 1}if(s.TERM==="dumb"){return t}return t}function getSupportLevel(e){const t=supportsColor(e);return translateLevel(t)}e.exports={supportsColor:getSupportLevel,stdout:getSupportLevel(process.stdout),stderr:getSupportLevel(process.stderr)}},1577:function(e){var t;var n;var r;var i;var s;var a;var o;var l;var c;var u;var d;var f;var p;var h;var y;var m;var b;var g;var v;var K;var S;var E;var k;var I;var w;var j;var x;var T;var D;var O;var C;var A;(function(t){var n=typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:{};if(typeof define==="function"&&define.amd){define("tslib",["exports"],(function(e){t(createExporter(n,createExporter(e)))}))}else if(true&&typeof e.exports==="object"){t(createExporter(n,createExporter(e.exports)))}else{t(createExporter(n))}function createExporter(e,t){if(e!==n){if(typeof Object.create==="function"){Object.defineProperty(e,"__esModule",{value:true})}else{e.__esModule=true}}return function(n,r){return e[n]=t?t(n,r):r}}})((function(e){var R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]};t=function(e,t){if(typeof t!=="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");R(e,t);function __(){this.constructor=e}e.prototype=t===null?Object.create(t):(__.prototype=t.prototype,new __)};n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))e[i]=t[i]}return e};r=function(e,t){var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0)n[r]=e[r];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++){if(t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i]))n[r[i]]=e[r[i]]}return n};i=function(e,t,n,r){var i=arguments.length,s=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)if(a=e[o])s=(i<3?a(s):i>3?a(t,n,s):a(t,n))||s;return i>3&&s&&Object.defineProperty(t,n,s),s};s=function(e,t){return function(n,r){t(n,r,e)}};a=function(e,t,n,r,i,s){function accept(e){if(e!==void 0&&typeof e!=="function")throw new TypeError("Function expected");return e}var a=r.kind,o=a==="getter"?"get":a==="setter"?"set":"value";var l=!t&&e?r["static"]?e:e.prototype:null;var c=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{});var u,d=false;for(var f=n.length-1;f>=0;f--){var p={};for(var h in r)p[h]=h==="access"?{}:r[h];for(var h in r.access)p.access[h]=r.access[h];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");s.push(accept(e||null))};var y=(0,n[f])(a==="accessor"?{get:c.get,set:c.set}:c[o],p);if(a==="accessor"){if(y===void 0)continue;if(y===null||typeof y!=="object")throw new TypeError("Object expected");if(u=accept(y.get))c.get=u;if(u=accept(y.set))c.set=u;if(u=accept(y.init))i.unshift(u)}else if(u=accept(y)){if(a==="field")i.unshift(u);else c[o]=u}}if(l)Object.defineProperty(l,r.name,c);d=true};o=function(e,t,n){var r=arguments.length>2;for(var i=0;i<t.length;i++){n=r?t[i].call(e,n):t[i].call(e)}return r?n:void 0};l=function(e){return typeof e==="symbol"?e:"".concat(e)};c=function(e,t,n){if(typeof t==="symbol")t=t.description?"[".concat(t.description,"]"):"";return Object.defineProperty(e,"name",{configurable:true,value:n?"".concat(n," ",t):t})};u=function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};d=function(e,t,n,r){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))};f=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=verb(0),a["throw"]=verb(1),a["return"]=verb(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function verb(e){return function(t){return step([e,t])}}function step(o){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,o[0]&&(n=0)),n)try{if(r=1,i&&(s=o[0]&2?i["return"]:o[0]?i["throw"]||((s=i["return"])&&s.call(i),0):i.next)&&!(s=s.call(i,o[1])).done)return s;if(i=0,s)o=[o[0]&2,s.value];switch(o[0]){case 0:case 1:s=o;break;case 4:n.label++;return{value:o[1],done:false};case 5:n.label++;i=o[1];o=[0];continue;case 7:o=n.ops.pop();n.trys.pop();continue;default:if(!(s=n.trys,s=s.length>0&&s[s.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!s||o[1]>s[0]&&o[1]<s[3])){n.label=o[1];break}if(o[0]===6&&n.label<s[1]){n.label=s[1];s=o;break}if(s&&n.label<s[2]){n.label=s[2];n.ops.push(o);break}if(s[2])n.ops.pop();n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e];i=0}finally{r=s=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};p=function(e,t){for(var n in e)if(n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n))D(t,e,n)};D=Object.create?function(e,t,n,r){if(r===undefined)r=n;var i=Object.getOwnPropertyDescriptor(t,n);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[n]}}}Object.defineProperty(e,r,i)}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]};h=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&r>=e.length)e=void 0;return{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};y=function(e,t){var n=typeof Symbol==="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],a;try{while((t===void 0||t-- >0)&&!(i=r.next()).done)s.push(i.value)}catch(e){a={error:e}}finally{try{if(i&&!i.done&&(n=r["return"]))n.call(r)}finally{if(a)throw a.error}}return s};m=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(y(arguments[t]));return e};b=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var s=arguments[t],a=0,o=s.length;a<o;a++,i++)r[i]=s[a];return r};g=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++){if(s||!(r in t)){if(!s)s=Array.prototype.slice.call(t,0,r);s[r]=t[r]}}return e.concat(s||Array.prototype.slice.call(t))};v=function(e){return this instanceof v?(this.v=e,this):new v(e)};K=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),verb("next"),verb("throw"),verb("return",awaitReturn),i[Symbol.asyncIterator]=function(){return this},i;function awaitReturn(e){return function(t){return Promise.resolve(t).then(e,reject)}}function verb(e,t){if(r[e]){i[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||resume(e,t)}))};if(t)i[e]=t(i[e])}}function resume(e,t){try{step(r[e](t))}catch(e){settle(s[0][3],e)}}function step(e){e.value instanceof v?Promise.resolve(e.value.v).then(fulfill,reject):settle(s[0][2],e)}function fulfill(e){resume("next",e)}function reject(e){resume("throw",e)}function settle(e,t){if(e(t),s.shift(),s.length)resume(s[0][0],s[0][1])}};S=function(e){var t,n;return t={},verb("next"),verb("throw",(function(e){throw e})),verb("return"),t[Symbol.iterator]=function(){return this},t;function verb(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:v(e[r](t)),done:false}:i?i(t):t}:i}};E=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof h==="function"?h(e):e[Symbol.iterator](),n={},verb("next"),verb("throw"),verb("return"),n[Symbol.asyncIterator]=function(){return this},n);function verb(t){n[t]=e[t]&&function(n){return new Promise((function(r,i){n=e[t](n),settle(r,i,n.done,n.value)}))}}function settle(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}};k=function(e,t){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:t})}else{e.raw=t}return e};var _=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t};var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n))t[t.length]=n;return t};return ownKeys(e)};I=function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=ownKeys(e),r=0;r<n.length;r++)if(n[r]!=="default")D(t,e,n[r]);_(t,e);return t};w=function(e){return e&&e.__esModule?e:{default:e}};j=function(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)};x=function(e,t,n,r,i){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(e,n):i?i.value=n:t.set(e,n),n};T=function(e,t){if(t===null||typeof t!=="object"&&typeof t!=="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e==="function"?t===e:e.has(t)};O=function(e,t,n){if(t!==null&&t!==void 0){if(typeof t!=="object"&&typeof t!=="function")throw new TypeError("Object expected.");var r,i;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose];if(n)i=r}if(typeof r!=="function")throw new TypeError("Object not disposable.");if(i)r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}};e.stack.push({value:t,dispose:r,async:n})}else if(n){e.stack.push({async:true})}return t};var M=typeof SuppressedError==="function"?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};C=function(e){function fail(t){e.error=e.hasError?new M(t,e.error,"An error was suppressed during disposal."):t;e.hasError=true}var t,n=0;function next(){while(t=e.stack.pop()){try{if(!t.async&&n===1)return n=0,e.stack.push(t),Promise.resolve().then(next);if(t.dispose){var r=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(r).then(next,(function(e){fail(e);return next()}))}else n|=1}catch(e){fail(e)}}if(n===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return next()};A=function(e,t){if(typeof e==="string"&&/^\.\.?\//.test(e)){return e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,(function(e,n,r,i,s){return n?t?".jsx":".js":r&&(!i||!s)?e:r+i+"."+s.toLowerCase()+"js"}))}return e};e("__extends",t);e("__assign",n);e("__rest",r);e("__decorate",i);e("__param",s);e("__esDecorate",a);e("__runInitializers",o);e("__propKey",l);e("__setFunctionName",c);e("__metadata",u);e("__awaiter",d);e("__generator",f);e("__exportStar",p);e("__createBinding",D);e("__values",h);e("__read",y);e("__spread",m);e("__spreadArrays",b);e("__spreadArray",g);e("__await",v);e("__asyncGenerator",K);e("__asyncDelegator",S);e("__asyncValues",E);e("__makeTemplateObject",k);e("__importStar",I);e("__importDefault",w);e("__classPrivateFieldGet",j);e("__classPrivateFieldSet",x);e("__classPrivateFieldIn",T);e("__addDisposableResource",O);e("__disposeResources",C);e("__rewriteRelativeImportExtension",A)}));0&&0},9935:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});Object.defineProperty(t,"NIL",{enumerable:true,get:function(){return o.default}});Object.defineProperty(t,"parse",{enumerable:true,get:function(){return d.default}});Object.defineProperty(t,"stringify",{enumerable:true,get:function(){return u.default}});Object.defineProperty(t,"v1",{enumerable:true,get:function(){return r.default}});Object.defineProperty(t,"v3",{enumerable:true,get:function(){return i.default}});Object.defineProperty(t,"v4",{enumerable:true,get:function(){return s.default}});Object.defineProperty(t,"v5",{enumerable:true,get:function(){return a.default}});Object.defineProperty(t,"validate",{enumerable:true,get:function(){return c.default}});Object.defineProperty(t,"version",{enumerable:true,get:function(){return l.default}});var r=_interopRequireDefault(n(494));var i=_interopRequireDefault(n(8564));var s=_interopRequireDefault(n(3633));var a=_interopRequireDefault(n(6002));var o=_interopRequireDefault(n(9032));var l=_interopRequireDefault(n(1247));var c=_interopRequireDefault(n(733));var u=_interopRequireDefault(n(5654));var d=_interopRequireDefault(n(9688));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}},1463:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(6982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function md5(e){if(Array.isArray(e)){e=Buffer.from(e)}else if(typeof e==="string"){e=Buffer.from(e,"utf8")}return r.default.createHash("md5").update(e).digest()}var i=md5;t["default"]=i},7788:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(6982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var i={randomUUID:r.default.randomUUID};t["default"]=i},9032:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n="00000000-0000-0000-0000-000000000000";t["default"]=n},9688:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(733));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function parse(e){if(!(0,r.default)(e)){throw TypeError("Invalid UUID")}let t;const n=new Uint8Array(16);n[0]=(t=parseInt(e.slice(0,8),16))>>>24;n[1]=t>>>16&255;n[2]=t>>>8&255;n[3]=t&255;n[4]=(t=parseInt(e.slice(9,13),16))>>>8;n[5]=t&255;n[6]=(t=parseInt(e.slice(14,18),16))>>>8;n[7]=t&255;n[8]=(t=parseInt(e.slice(19,23),16))>>>8;n[9]=t&255;n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255;n[11]=t/4294967296&255;n[12]=t>>>24&255;n[13]=t>>>16&255;n[14]=t>>>8&255;n[15]=t&255;return n}var i=parse;t["default"]=i},1784:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;t["default"]=n},298:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=rng;var r=_interopRequireDefault(n(6982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const i=new Uint8Array(256);let s=i.length;function rng(){if(s>i.length-16){r.default.randomFillSync(i);s=0}return i.slice(s,s+=16)}},8978:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(6982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function sha1(e){if(Array.isArray(e)){e=Buffer.from(e)}else if(typeof e==="string"){e=Buffer.from(e,"utf8")}return r.default.createHash("sha1").update(e).digest()}var i=sha1;t["default"]=i},5654:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;t.unsafeStringify=unsafeStringify;var r=_interopRequireDefault(n(733));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const i=[];for(let e=0;e<256;++e){i.push((e+256).toString(16).slice(1))}function unsafeStringify(e,t=0){return i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]}function stringify(e,t=0){const n=unsafeStringify(e,t);if(!(0,r.default)(n)){throw TypeError("Stringified UUID is invalid")}return n}var s=stringify;t["default"]=s},494:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(298));var i=n(5654);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let s;let a;let o=0;let l=0;function v1(e,t,n){let c=t&&n||0;const u=t||new Array(16);e=e||{};let d=e.node||s;let f=e.clockseq!==undefined?e.clockseq:a;if(d==null||f==null){const t=e.random||(e.rng||r.default)();if(d==null){d=s=[t[0]|1,t[1],t[2],t[3],t[4],t[5]]}if(f==null){f=a=(t[6]<<8|t[7])&16383}}let p=e.msecs!==undefined?e.msecs:Date.now();let h=e.nsecs!==undefined?e.nsecs:l+1;const y=p-o+(h-l)/1e4;if(y<0&&e.clockseq===undefined){f=f+1&16383}if((y<0||p>o)&&e.nsecs===undefined){h=0}if(h>=1e4){throw new Error("uuid.v1(): Can't create more than 10M uuids/sec")}o=p;l=h;a=f;p+=122192928e5;const m=((p&268435455)*1e4+h)%4294967296;u[c++]=m>>>24&255;u[c++]=m>>>16&255;u[c++]=m>>>8&255;u[c++]=m&255;const b=p/4294967296*1e4&268435455;u[c++]=b>>>8&255;u[c++]=b&255;u[c++]=b>>>24&15|16;u[c++]=b>>>16&255;u[c++]=f>>>8|128;u[c++]=f&255;for(let e=0;e<6;++e){u[c+e]=d[e]}return t||(0,i.unsafeStringify)(u)}var c=v1;t["default"]=c},8564:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(3537));var i=_interopRequireDefault(n(1463));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const s=(0,r.default)("v3",48,i.default);var a=s;t["default"]=a},3537:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.URL=t.DNS=void 0;t["default"]=v35;var r=n(5654);var i=_interopRequireDefault(n(9688));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function stringToBytes(e){e=unescape(encodeURIComponent(e));const t=[];for(let n=0;n<e.length;++n){t.push(e.charCodeAt(n))}return t}const s="6ba7b810-9dad-11d1-80b4-00c04fd430c8";t.DNS=s;const a="6ba7b811-9dad-11d1-80b4-00c04fd430c8";t.URL=a;function v35(e,t,n){function generateUUID(e,s,a,o){var l;if(typeof e==="string"){e=stringToBytes(e)}if(typeof s==="string"){s=(0,i.default)(s)}if(((l=s)===null||l===void 0?void 0:l.length)!==16){throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)")}let c=new Uint8Array(16+e.length);c.set(s);c.set(e,s.length);c=n(c);c[6]=c[6]&15|t;c[8]=c[8]&63|128;if(a){o=o||0;for(let e=0;e<16;++e){a[o+e]=c[e]}return a}return(0,r.unsafeStringify)(c)}try{generateUUID.name=e}catch(e){}generateUUID.DNS=s;generateUUID.URL=a;return generateUUID}},3633:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(7788));var i=_interopRequireDefault(n(298));var s=n(5654);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function v4(e,t,n){if(r.default.randomUUID&&!t&&!e){return r.default.randomUUID()}e=e||{};const a=e.random||(e.rng||i.default)();a[6]=a[6]&15|64;a[8]=a[8]&63|128;if(t){n=n||0;for(let e=0;e<16;++e){t[n+e]=a[e]}return t}return(0,s.unsafeStringify)(a)}var a=v4;t["default"]=a},6002:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(3537));var i=_interopRequireDefault(n(8978));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const s=(0,r.default)("v5",80,i.default);var a=s;t["default"]=a},733:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(1784));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function validate(e){return typeof e==="string"&&r.default.test(e)}var i=validate;t["default"]=i},1247:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=_interopRequireDefault(n(733));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function version(e){if(!(0,r.default)(e)){throw TypeError("Invalid UUID")}return parseInt(e.slice(14,15),16)}var i=version;t["default"]=i},9761:function(e){function webpackEmptyAsyncContext(e){return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");t.code="MODULE_NOT_FOUND";throw t}))}webpackEmptyAsyncContext.keys=function(){return[]};webpackEmptyAsyncContext.resolve=webpackEmptyAsyncContext;webpackEmptyAsyncContext.id=9761;e.exports=webpackEmptyAsyncContext},2613:function(e){"use strict";e.exports=require("assert")},181:function(e){"use strict";e.exports=require("buffer")},5317:function(e){"use strict";e.exports=require("child_process")},6982:function(e){"use strict";e.exports=require("crypto")},2250:function(e){"use strict";e.exports=require("dns")},4434:function(e){"use strict";e.exports=require("events")},9896:function(e){"use strict";e.exports=require("fs")},3339:function(e){"use strict";e.exports=require("module")},9278:function(e){"use strict";e.exports=require("net")},857:function(e){"use strict";e.exports=require("os")},6928:function(e){"use strict";e.exports=require("path")},2203:function(e){"use strict";e.exports=require("stream")},3193:function(e){"use strict";e.exports=require("string_decoder")},4756:function(e){"use strict";e.exports=require("tls")},2018:function(e){"use strict";e.exports=require("tty")},7016:function(e){"use strict";e.exports=require("url")},9023:function(e){"use strict";e.exports=require("util")},8167:function(e){"use strict";e.exports=require("worker_threads")},2766:function(e,t,n){"use strict";var r=n(2203);var i=n(3339);var s;try{s=new TextDecoder}catch(e){}var a;var o;var l=0;const c=[];var u=c;var d=0;var f={};var p;var h;var y=0;var m=0;var b;var g;var v=[];var K;var S={useRecords:false,mapsAsObjects:true};class C1Type{}const E=new C1Type;E.name="MessagePack 0xC1";var k=false;var I=2;var w,j,x;try{new Function("")}catch(e){I=Infinity}class Unpackr{constructor(e){if(e){if(e.useRecords===false&&e.mapsAsObjects===undefined)e.mapsAsObjects=true;if(e.sequential&&e.trusted!==false){e.trusted=true;if(!e.structures&&e.useRecords!=false){e.structures=[];if(!e.maxSharedStructures)e.maxSharedStructures=0}}if(e.structures)e.structures.sharedLength=e.structures.length;else if(e.getStructures){(e.structures=[]).uninitialized=true;e.structures.sharedLength=0}if(e.int64AsNumber){e.int64AsType="number"}}Object.assign(this,e)}unpack(e,t){if(a){return saveState$1((()=>{clearSource();return this?this.unpack(e,t):Unpackr.prototype.unpack.call(S,e,t)}))}if(!e.buffer&&e.constructor===ArrayBuffer)e=typeof Buffer!=="undefined"?Buffer.from(e):new Uint8Array(e);if(typeof t==="object"){o=t.end||e.length;l=t.start||0}else{l=0;o=t>-1?t:e.length}d=0;m=0;h=null;u=c;b=null;a=e;try{K=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(t){a=null;if(e instanceof Uint8Array)throw t;throw new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Unpackr){f=this;if(this.structures){p=this.structures;return checkedRead(t)}else if(!p||p.length>0){p=[]}}else{f=S;if(!p||p.length>0)p=[]}return checkedRead(t)}unpackMultiple(e,t){let n,r=0;try{k=true;let i=e.length;let s=this?this.unpack(e,i):V.unpack(e,i);if(t){if(t(s,r,l)===false)return;while(l<i){r=l;if(t(checkedRead(),r,l)===false){return}}}else{n=[s];while(l<i){r=l;n.push(checkedRead())}return n}}catch(e){e.lastPosition=r;e.values=n;throw e}finally{k=false;clearSource()}}_mergeStructures(e,t){if(j)e=j.call(this,e);e=e||[];if(Object.isFrozen(e))e=e.map((e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n){n.isShared=true;if(t>=32)n.highByte=t-32>>5}}e.sharedLength=e.length;for(let n in t||[]){if(n>=0){let r=e[n];let i=t[n];if(i){if(r)(e.restoreStructures||(e.restoreStructures=[]))[n]=r;e[n]=i}}}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function checkedRead(e){try{if(!f.trusted&&!k){let e=p.sharedLength||0;if(e<p.length)p.length=e}let t;if(f.randomAccessStructure&&a[l]<64&&a[l]>=32&&w){t=w(a,l,o,f);a=null;if(!(e&&e.lazy)&&t)t=t.toJSON();l=o}else t=read();if(b){l=b.postBundlePosition;b=null}if(k)p.restoreStructures=null;if(l==o){if(p&&p.restoreStructures)restoreStructures();p=null;a=null;if(g)g=null}else if(l>o){throw new Error("Unexpected end of MessagePack data")}else if(!k){let e;try{e=JSON.stringify(t,((e,t)=>typeof t==="bigint"?`${t}n`:t)).slice(0,100)}catch(t){e="(JSON view not available "+t+")"}throw new Error("Data read, but end of buffer not reached "+e)}return t}catch(e){if(p&&p.restoreStructures)restoreStructures();clearSource();if(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||l>o){e.incomplete=true}throw e}}function restoreStructures(){for(let e in p.restoreStructures){p[e]=p.restoreStructures[e]}p.restoreStructures=null}function read(){let e=a[l++];if(e<160){if(e<128){if(e<64)return e;else{let t=p[e&63]||f.getStructures&&loadStructures()[e&63];if(t){if(!t.read){t.read=createStructureReader(t,e&63)}return t.read()}else return e}}else if(e<144){e-=128;if(f.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=readKey();if(e==="__proto__")e="__proto_";t[e]=read()}return t}else{let t=new Map;for(let n=0;n<e;n++){t.set(read(),read())}return t}}else{e-=144;let t=new Array(e);for(let n=0;n<e;n++){t[n]=read()}if(f.freezeData)return Object.freeze(t);return t}}else if(e<192){let t=e-160;if(m>=l){return h.slice(l-y,(l+=t)-y)}if(m==0&&o<140){let e=t<16?shortStringInJS(t):longStringInJS(t);if(e!=null)return e}return D(t)}else{let t;switch(e){case 192:return null;case 193:if(b){t=read();if(t>0)return b[1].slice(b.position1,b.position1+=t);else return b[0].slice(b.position0,b.position0-=t)}return E;case 194:return false;case 195:return true;case 196:t=a[l++];if(t===undefined)throw new Error("Unexpected end of buffer");return readBin(t);case 197:t=K.getUint16(l);l+=2;return readBin(t);case 198:t=K.getUint32(l);l+=4;return readBin(t);case 199:return readExt(a[l++]);case 200:t=K.getUint16(l);l+=2;return readExt(t);case 201:t=K.getUint32(l);l+=4;return readExt(t);case 202:t=K.getFloat32(l);if(f.useFloat32>2){let e=J[(a[l]&127)<<1|a[l+1]>>7];l+=4;return(e*t+(t>0?.5:-.5)>>0)/e}l+=4;return t;case 203:t=K.getFloat64(l);l+=8;return t;case 204:return a[l++];case 205:t=K.getUint16(l);l+=2;return t;case 206:t=K.getUint32(l);l+=4;return t;case 207:if(f.int64AsType==="number"){t=K.getUint32(l)*4294967296;t+=K.getUint32(l+4)}else if(f.int64AsType==="string"){t=K.getBigUint64(l).toString()}else if(f.int64AsType==="auto"){t=K.getBigUint64(l);if(t<=BigInt(2)<<BigInt(52))t=Number(t)}else t=K.getBigUint64(l);l+=8;return t;case 208:return K.getInt8(l++);case 209:t=K.getInt16(l);l+=2;return t;case 210:t=K.getInt32(l);l+=4;return t;case 211:if(f.int64AsType==="number"){t=K.getInt32(l)*4294967296;t+=K.getUint32(l+4)}else if(f.int64AsType==="string"){t=K.getBigInt64(l).toString()}else if(f.int64AsType==="auto"){t=K.getBigInt64(l);if(t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52))t=Number(t)}else t=K.getBigInt64(l);l+=8;return t;case 212:t=a[l++];if(t==114){return recordDefinition(a[l++]&63)}else{let e=v[t];if(e){if(e.read){l++;return e.read(read())}else if(e.noBuffer){l++;return e()}else return e(a.subarray(l,++l))}else throw new Error("Unknown extension "+t)}case 213:t=a[l];if(t==114){l++;return recordDefinition(a[l++]&63,a[l++])}else return readExt(2);case 214:return readExt(4);case 215:return readExt(8);case 216:return readExt(16);case 217:t=a[l++];if(m>=l){return h.slice(l-y,(l+=t)-y)}return O(t);case 218:t=K.getUint16(l);l+=2;if(m>=l){return h.slice(l-y,(l+=t)-y)}return C(t);case 219:t=K.getUint32(l);l+=4;if(m>=l){return h.slice(l-y,(l+=t)-y)}return A(t);case 220:t=K.getUint16(l);l+=2;return readArray(t);case 221:t=K.getUint32(l);l+=4;return readArray(t);case 222:t=K.getUint16(l);l+=2;return readMap(t);case 223:t=K.getUint32(l);l+=4;return readMap(t);default:if(e>=224)return e-256;if(e===undefined){let e=new Error("Unexpected end of MessagePack data");e.incomplete=true;throw e}throw new Error("Unknown MessagePack token "+e)}}}const T=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function createStructureReader(e,t){function readObject(){if(readObject.count++>I){let n=e.read=new Function("r","return function(){return "+(f.freezeData?"Object.freeze":"")+"({"+e.map((e=>e==="__proto__"?"__proto_:r()":T.test(e)?e+":r()":"["+JSON.stringify(e)+"]:r()")).join(",")+"})}")(read);if(e.highByte===0)e.read=createSecondByteReader(t,e.read);return n()}let n={};for(let t=0,r=e.length;t<r;t++){let r=e[t];if(r==="__proto__")r="__proto_";n[r]=read()}if(f.freezeData)return Object.freeze(n);return n}readObject.count=0;if(e.highByte===0){return createSecondByteReader(t,readObject)}return readObject}const createSecondByteReader=(e,t)=>function(){let n=a[l++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5);let i=p[r]||loadStructures()[r];if(!i){throw new Error("Record id is not defined for "+r)}if(!i.read)i.read=createStructureReader(i,e);return i.read()};function loadStructures(){let e=saveState$1((()=>{a=null;return f.getStructures()}));return p=f._mergeStructures(e,p)}var D=readStringJS;var O=readStringJS;var C=readStringJS;var A=readStringJS;t.isNativeAccelerationEnabled=false;function setExtractor(e){t.isNativeAccelerationEnabled=true;D=readString(1);O=readString(2);C=readString(3);A=readString(5);function readString(t){return function readString(n){let r=u[d++];if(r==null){if(b)return readStringJS(n);let i=a.byteOffset;let s=e(l-t+i,o+i,a.buffer);if(typeof s=="string"){r=s;u=c}else{u=s;d=1;m=1;r=u[0];if(r===undefined)throw new Error("Unexpected end of buffer")}}let i=r.length;if(i<=n){l+=n;return r}h=r;y=l;m=l+i;l+=n;return r.slice(0,n)}}}function readStringJS(e){let t;if(e<16){if(t=shortStringInJS(e))return t}if(e>64&&s)return s.decode(a.subarray(l,l+=e));const n=l+e;const r=[];t="";while(l<n){const e=a[l++];if((e&128)===0){r.push(e)}else if((e&224)===192){const t=a[l++]&63;r.push((e&31)<<6|t)}else if((e&240)===224){const t=a[l++]&63;const n=a[l++]&63;r.push((e&31)<<12|t<<6|n)}else if((e&248)===240){const t=a[l++]&63;const n=a[l++]&63;const i=a[l++]&63;let s=(e&7)<<18|t<<12|n<<6|i;if(s>65535){s-=65536;r.push(s>>>10&1023|55296);s=56320|s&1023}r.push(s)}else{r.push(e)}if(r.length>=4096){t+=R.apply(String,r);r.length=0}}if(r.length>0){t+=R.apply(String,r)}return t}function readString(e,t,n){let r=a;a=e;l=t;try{return readStringJS(n)}finally{a=r}}function readArray(e){let t=new Array(e);for(let n=0;n<e;n++){t[n]=read()}if(f.freezeData)return Object.freeze(t);return t}function readMap(e){if(f.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=readKey();if(e==="__proto__")e="__proto_";t[e]=read()}return t}else{let t=new Map;for(let n=0;n<e;n++){t.set(read(),read())}return t}}var R=String.fromCharCode;function longStringInJS(e){let t=l;let n=new Array(e);for(let r=0;r<e;r++){const e=a[l++];if((e&128)>0){l=t;return}n[r]=e}return R.apply(String,n)}function shortStringInJS(e){if(e<4){if(e<2){if(e===0)return"";else{let e=a[l++];if((e&128)>1){l-=1;return}return R(e)}}else{let t=a[l++];let n=a[l++];if((t&128)>0||(n&128)>0){l-=2;return}if(e<3)return R(t,n);let r=a[l++];if((r&128)>0){l-=3;return}return R(t,n,r)}}else{let t=a[l++];let n=a[l++];let r=a[l++];let i=a[l++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){l-=4;return}if(e<6){if(e===4)return R(t,n,r,i);else{let e=a[l++];if((e&128)>0){l-=5;return}return R(t,n,r,i,e)}}else if(e<8){let s=a[l++];let o=a[l++];if((s&128)>0||(o&128)>0){l-=6;return}if(e<7)return R(t,n,r,i,s,o);let c=a[l++];if((c&128)>0){l-=7;return}return R(t,n,r,i,s,o,c)}else{let s=a[l++];let o=a[l++];let c=a[l++];let u=a[l++];if((s&128)>0||(o&128)>0||(c&128)>0||(u&128)>0){l-=8;return}if(e<10){if(e===8)return R(t,n,r,i,s,o,c,u);else{let e=a[l++];if((e&128)>0){l-=9;return}return R(t,n,r,i,s,o,c,u,e)}}else if(e<12){let d=a[l++];let f=a[l++];if((d&128)>0||(f&128)>0){l-=10;return}if(e<11)return R(t,n,r,i,s,o,c,u,d,f);let p=a[l++];if((p&128)>0){l-=11;return}return R(t,n,r,i,s,o,c,u,d,f,p)}else{let d=a[l++];let f=a[l++];let p=a[l++];let h=a[l++];if((d&128)>0||(f&128)>0||(p&128)>0||(h&128)>0){l-=12;return}if(e<14){if(e===12)return R(t,n,r,i,s,o,c,u,d,f,p,h);else{let e=a[l++];if((e&128)>0){l-=13;return}return R(t,n,r,i,s,o,c,u,d,f,p,h,e)}}else{let y=a[l++];let m=a[l++];if((y&128)>0||(m&128)>0){l-=14;return}if(e<15)return R(t,n,r,i,s,o,c,u,d,f,p,h,y,m);let b=a[l++];if((b&128)>0){l-=15;return}return R(t,n,r,i,s,o,c,u,d,f,p,h,y,m,b)}}}}}function readOnlyJSString(){let e=a[l++];let t;if(e<192){t=e-160}else{switch(e){case 217:t=a[l++];break;case 218:t=K.getUint16(l);l+=2;break;case 219:t=K.getUint32(l);l+=4;break;default:throw new Error("Expected string")}}return readStringJS(t)}function readBin(e){return f.copyBuffers?Uint8Array.prototype.slice.call(a,l,l+=e):a.subarray(l,l+=e)}function readExt(e){let t=a[l++];if(v[t]){let n;return v[t](a.subarray(l,n=l+=e),(e=>{l=e;try{return read()}finally{l=n}}))}else throw new Error("Unknown extension type "+t)}var _=new Array(4096);function readKey(){let e=a[l++];if(e>=160&&e<192){e=e-160;if(m>=l)return h.slice(l-y,(l+=e)-y);else if(!(m==0&&o<180))return D(e)}else{l--;return asSafeString(read())}let t=(e<<5^(e>1?K.getUint16(l):e>0?a[l]:0))&4095;let n=_[t];let r=l;let i=l+e-3;let s;let c=0;if(n&&n.bytes==e){while(r<i){s=K.getUint32(r);if(s!=n[c++]){r=1879048192;break}r+=4}i+=3;while(r<i){s=a[r++];if(s!=n[c++]){r=1879048192;break}}if(r===i){l=r;return n.string}i-=3;r=l}n=[];_[t]=n;n.bytes=e;while(r<i){s=K.getUint32(r);n.push(s);r+=4}i+=3;while(r<i){s=a[r++];n.push(s)}let u=e<16?shortStringInJS(e):longStringInJS(e);if(u!=null)return n.string=u;return n.string=D(e)}function asSafeString(e){if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"||typeof e==="bigint")return e.toString();if(e==null)return e+"";if(f.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every((e=>["string","number","boolean","bigint"].includes(typeof e)))){return e.flat().toString()}throw new Error(`Invalid property type for record: ${typeof e}`)}const recordDefinition=(e,t)=>{let n=read().map(asSafeString);let r=e;if(t!==undefined){e=e<32?-((t<<5)+e):(t<<5)+e;n.highByte=t}let i=p[e];if(i&&(i.isShared||k)){(p.restoreStructures||(p.restoreStructures=[]))[e]=i}p[e]=n;n.read=createStructureReader(n,r);return n.read()};v[0]=()=>{};v[0].noBuffer=true;v[66]=e=>{let t=e.byteLength%8||8;let n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++){n<<=BigInt(8);n+=BigInt(e[r])}if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength);let decode=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8){n<<=BigInt(64n);n|=r.getBigUint64(i)}return n}let i=e+(n>>4<<3);let s=decode(e,i);let a=decode(i,t);return s<<BigInt((t-i)*8)|a};n=n<<BigInt((r.byteLength-t)*8)|decode(t,r.byteLength)}return n};let M={Error:Error,EvalError:EvalError,RangeError:RangeError,ReferenceError:ReferenceError,SyntaxError:SyntaxError,TypeError:TypeError,URIError:URIError,AggregateError:typeof AggregateError==="function"?AggregateError:null};v[101]=()=>{let e=read();if(!M[e[0]]){let t=Error(e[1],{cause:e[2]});t.name=e[0];return t}return M[e[0]](e[1],{cause:e[2]})};v[105]=e=>{if(f.structuredClone===false)throw new Error("Structured clone extension is disabled");let t=K.getUint32(l-4);if(!g)g=new Map;let n=a[l];let r;if(n>=144&&n<160||n==220||n==221)r=[];else if(n>=128&&n<144||n==222||n==223)r=new Map;else if((n>=199&&n<=201||n>=212&&n<=216)&&a[l+1]===115)r=new Set;else r={};let i={target:r};g.set(t,i);let s=read();if(!i.used){return i.target=s}else{Object.assign(r,s)}if(r instanceof Map)for(let[e,t]of s.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(s))r.add(e);return r};v[112]=e=>{if(f.structuredClone===false)throw new Error("Structured clone extension is disabled");let t=K.getUint32(l-4);let n=g.get(t);n.used=true;return n.target};v[115]=()=>new Set(read());const P=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((e=>e+"Array"));let N=typeof globalThis==="object"?globalThis:window;v[116]=e=>{let t=e[0];let n=Uint8Array.prototype.slice.call(e,1).buffer;let r=P[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw new Error("Could not find typed array for code "+t)}return new N[r](n)};v[120]=()=>{let e=read();return new RegExp(e[0],e[1])};const L=[];v[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3];let n=l;l+=t-e.length;b=L;b=[readOnlyJSString(),readOnlyJSString()];b.position0=0;b.position1=0;b.postBundlePosition=l;l=n;return read()};v[255]=e=>{if(e.length==4)return new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3);else if(e.length==8)return new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3);else if(e.length==12)return new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3);else return new Date("invalid")};function saveState$1(e){if(x)x();let t=o;let n=l;let r=d;let i=y;let s=m;let c=h;let v=u;let S=g;let E=b;let I=new Uint8Array(a.slice(0,o));let w=p;let j=p.slice(0,p.length);let T=f;let D=k;let O=e();o=t;l=n;d=r;y=i;m=s;h=c;u=v;g=S;b=E;a=I;k=D;p=w;p.splice(0,p.length,...j);f=T;K=new DataView(a.buffer,a.byteOffset,a.byteLength);return O}function clearSource(){a=null;g=null;p=null}function addExtension$1(e){if(e.unpack)v[e.type]=e.unpack;else v[e.type]=e}const J=new Array(147);for(let e=0;e<256;e++){J[e]=+("1e"+Math.floor(45.15-e*.30103))}const F=Unpackr;var V=new Unpackr({useRecords:false});const G=V.unpack;const q=V.unpackMultiple;const Y=V.unpack;const U={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let B=new Float32Array(1);let W=new Uint8Array(B.buffer,0,4);function roundFloat32(e){B[0]=e;let t=J[(W[3]&127)<<1|W[2]>>7];return(t*e+(e>0?.5:-.5)>>0)/t}function setReadStruct(e,t,n){w=e;j=t;x=n}let z;try{z=new TextEncoder}catch(e){}let Z,$;const Q=typeof Buffer!=="undefined";const H=Q?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array;const X=Q?Buffer:Uint8Array;const ee=Q?4294967296:2144337920;let te,ne;let re;let ie=0;let se;let ae=null;let oe;const le=21760;const ce=/[\u0080-\uFFFF]/;const ue=Symbol("record-id");class Packr extends Unpackr{constructor(e){super(e);this.offset=0;let t;let n;let r;let i;let s=X.prototype.utf8Write?function(e,t){return te.utf8Write(e,t,te.byteLength-t)}:z&&z.encodeInto?function(e,t){return z.encodeInto(e,te.subarray(t)).written}:false;let a=this;if(!e)e={};let o=e&&e.sequential;let l=e.structures||e.saveStructures;let c=e.maxSharedStructures;if(c==null)c=l?32:0;if(c>8160)throw new Error("Maximum maxSharedStructure is 8160");if(e.structuredClone&&e.moreTypes==undefined){this.moreTypes=true}let u=e.maxOwnStructures;if(u==null)u=l?32:64;if(!this.structures&&e.useRecords!=false)this.structures=[];let d=c>32||u+c>64;let f=c+64;let p=c+u+64;if(p>8256){throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192")}let h=[];let y=0;let m=0;this.pack=this.encode=function(e,s){if(!te){te=new H(8192);re=te.dataView||(te.dataView=new DataView(te.buffer,0,8192));ie=0}se=te.length-10;if(se-ie<2048){te=new H(te.length);re=te.dataView||(te.dataView=new DataView(te.buffer,0,te.length));se=te.length-10;ie=0}else ie=ie+7&2147483640;t=ie;if(s&Se)ie+=s&255;i=a.structuredClone?new Map:null;if(a.bundleStrings&&typeof e!=="string"){ae=[];ae.size=Infinity}else ae=null;r=a.structures;if(r){if(r.uninitialized)r=a._mergeStructures(a.getStructures());let e=r.sharedLength||0;if(e>c){throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength)}if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r];if(!n){n=i[r]=Object.create(null)}i=n}i[ue]=t+64}this.lastNamedStructuresLength=e}if(!o){r.nextId=e+64}}if(n)n=false;let l;try{if(a.randomAccessStructure&&e&&e.constructor&&e.constructor===Object)writeStruct(e);else pack(e);let n=ae;if(ae)writeBundles(t,pack,0);if(i&&i.idsToInsert){let e=i.idsToInsert.sort(((e,t)=>e.offset>t.offset?1:-1));let r=e.length;let s=-1;while(n&&r>0){let i=e[--r].offset+t;if(i<n.stringsPosition+t&&s===-1)s=0;if(i>n.position+t){if(s>=0)s+=6}else{if(s>=0){re.setUint32(n.position+t,re.getUint32(n.position+t)+s);s=-1}n=n.previous;r++}}if(s>=0&&n){re.setUint32(n.position+t,re.getUint32(n.position+t)+s)}ie+=e.length*6;if(ie>se)makeRoom(ie);a.offset=ie;let o=insertIds(te.subarray(t,ie),e);i=null;return o}a.offset=ie;if(s&ve){te.start=t;te.end=ie;return te}return te.subarray(t,ie)}catch(e){l=e;throw e}finally{if(r){resetStructures();if(n&&a.saveStructures){let n=r.sharedLength||0;let i=te.subarray(t,ie);let o=prepareStructures$1(r,a);if(!l){if(a.saveStructures(o,o.isCompatible)===false){return a.pack(e,s)}a.lastNamedStructuresLength=n;if(te.length>1073741824)te=null;return i}}}if(te.length>1073741824)te=null;if(s&Ke)ie=t}};const resetStructures=()=>{if(m<10)m++;let e=r.sharedLength||0;if(r.length>e&&!o)r.length=e;if(y>1e4){r.transitions=null;m=0;y=0;if(h.length>0)h=[]}else if(h.length>0&&!o){for(let e=0,t=h.length;e<t;e++){h[e][ue]=0}h=[]}};const packArray=e=>{var t=e.length;if(t<16){te[ie++]=144|t}else if(t<65536){te[ie++]=220;te[ie++]=t>>8;te[ie++]=t&255}else{te[ie++]=221;re.setUint32(ie,t);ie+=4}for(let n=0;n<t;n++){pack(e[n])}};const pack=e=>{if(ie>se)te=makeRoom(ie);var n=typeof e;var r;if(n==="string"){let n=e.length;if(ae&&n>=4&&n<4096){if((ae.size+=n)>le){let e;let n=(ae[0]?ae[0].length*3+ae[1].length:0)+10;if(ie+n>se)te=makeRoom(ie+n);let r;if(ae.position){r=ae;te[ie]=200;ie+=3;te[ie++]=98;e=ie-t;ie+=4;writeBundles(t,pack,0);re.setUint16(e+t-3,ie-t-e)}else{te[ie++]=214;te[ie++]=98;e=ie-t;ie+=4}ae=["",""];ae.previous=r;ae.size=0;ae.position=e}let r=ce.test(e);ae[r?0:1]+=e;te[ie++]=193;pack(r?-n:n);return}let i;if(n<32){i=1}else if(n<256){i=2}else if(n<65536){i=3}else{i=5}let a=n*3;if(ie+a>se)te=makeRoom(ie+a);if(n<64||!s){let t,s,a,o=ie+i;for(t=0;t<n;t++){s=e.charCodeAt(t);if(s<128){te[o++]=s}else if(s<2048){te[o++]=s>>6|192;te[o++]=s&63|128}else if((s&64512)===55296&&((a=e.charCodeAt(t+1))&64512)===56320){s=65536+((s&1023)<<10)+(a&1023);t++;te[o++]=s>>18|240;te[o++]=s>>12&63|128;te[o++]=s>>6&63|128;te[o++]=s&63|128}else{te[o++]=s>>12|224;te[o++]=s>>6&63|128;te[o++]=s&63|128}}r=o-ie-i}else{r=s(e,ie+i)}if(r<32){te[ie++]=160|r}else if(r<256){if(i<2){te.copyWithin(ie+2,ie+1,ie+1+r)}te[ie++]=217;te[ie++]=r}else if(r<65536){if(i<3){te.copyWithin(ie+3,ie+2,ie+2+r)}te[ie++]=218;te[ie++]=r>>8;te[ie++]=r&255}else{if(i<5){te.copyWithin(ie+5,ie+3,ie+3+r)}te[ie++]=219;re.setUint32(ie,r);ie+=4}ie+=r}else if(n==="number"){if(e>>>0===e){if(e<32||e<128&&this.useRecords===false||e<64&&!this.randomAccessStructure){te[ie++]=e}else if(e<256){te[ie++]=204;te[ie++]=e}else if(e<65536){te[ie++]=205;te[ie++]=e>>8;te[ie++]=e&255}else{te[ie++]=206;re.setUint32(ie,e);ie+=4}}else if(e>>0===e){if(e>=-32){te[ie++]=256+e}else if(e>=-128){te[ie++]=208;te[ie++]=e+256}else if(e>=-32768){te[ie++]=209;re.setInt16(ie,e);ie+=2}else{te[ie++]=210;re.setInt32(ie,e);ie+=4}}else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){te[ie++]=202;re.setFloat32(ie,e);let n;if(t<4||(n=e*J[(te[ie]&127)<<1|te[ie+1]>>7])>>0===n){ie+=4;return}else ie--}te[ie++]=203;re.setFloat64(ie,e);ie+=8}}else if(n==="object"||n==="function"){if(!e)te[ie++]=192;else{if(i){let n=i.get(e);if(n){if(!n.id){let e=i.idsToInsert||(i.idsToInsert=[]);n.id=e.push(n)}te[ie++]=214;te[ie++]=112;re.setUint32(ie,n.id);ie+=4;return}else i.set(e,{offset:ie-t})}let s=e.constructor;if(s===Object){K(e)}else if(s===Array){packArray(e)}else if(s===Map){if(this.mapAsEmptyObject)te[ie++]=128;else{r=e.size;if(r<16){te[ie++]=128|r}else if(r<65536){te[ie++]=222;te[ie++]=r>>8;te[ie++]=r&255}else{te[ie++]=223;re.setUint32(ie,r);ie+=4}for(let[t,n]of e){pack(t);pack(n)}}}else{for(let t=0,n=Z.length;t<n;t++){let n=$[t];if(e instanceof n){let n=Z[t];if(n.write){if(n.type){te[ie++]=212;te[ie++]=n.type;te[ie++]=0}let t=n.write.call(this,e);if(t===e){if(Array.isArray(e)){packArray(e)}else{K(e)}}else{pack(t)}return}let r=te;let i=re;let s=ie;te=null;let a;try{a=n.pack.call(this,e,(e=>{te=r;r=null;ie+=e;if(ie>se)makeRoom(ie);return{target:te,targetView:re,position:ie-e}}),pack)}finally{if(r){te=r;re=i;ie=s;se=te.length-10}}if(a){if(a.length+ie>se)makeRoom(a.length+ie);ie=writeExtensionData(a,te,ie,n.type)}return}}if(Array.isArray(e)){packArray(e)}else{if(e.toJSON){const t=e.toJSON();if(t!==e)return pack(t)}if(n==="function")return pack(this.writeFunction&&this.writeFunction(e));K(e)}}}}else if(n==="boolean"){te[ie++]=e?195:194}else if(n==="bigint"){if(e<0x8000000000000000&&e>=-0x8000000000000000){te[ie++]=211;re.setBigInt64(ie,e)}else if(e<0x10000000000000000&&e>0){te[ie++]=207;re.setBigUint64(ie,e)}else{if(this.largeBigIntToFloat){te[ie++]=203;re.setFloat64(ie,Number(e))}else if(this.largeBigIntToString){return pack(e.toString())}else if(this.useBigIntExtension||this.moreTypes){let t=e<0?BigInt(-1):BigInt(0);let n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1);let i=[];while(true){i.push(e&r);if(e>>BigInt(63)===t)break;e>>=BigInt(64)}n=new Uint8Array(new BigUint64Array(i).buffer);n.reverse()}else{let t=e<0;let r=(t?~e:e).toString(16);if(r.length%2){r="0"+r}else if(parseInt(r.charAt(0),16)>=8){r="00"+r}if(Q){n=Buffer.from(r,"hex")}else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++){n[e]=parseInt(r.slice(e*2,e*2+2),16)}}if(t){for(let e=0;e<n.length;e++)n[e]=~n[e]}}if(n.length+ie>se)makeRoom(n.length+ie);ie=writeExtensionData(n,te,ie,66);return}else{throw new RangeError(e+" was too large to fit in MessagePack 64-bit integer format, use"+" useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set"+" largeBigIntToString to convert to string")}}ie+=8}else if(n==="undefined"){if(this.encodeUndefinedAsNil)te[ie++]=192;else{te[ie++]=212;te[ie++]=0;te[ie++]=0}}else{throw new Error("Unknown type: "+n)}};const b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e){if((typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n]))t.push(n)}}else{t=Object.keys(e)}let n=t.length;if(n<16){te[ie++]=128|n}else if(n<65536){te[ie++]=222;te[ie++]=n>>8;te[ie++]=n&255}else{te[ie++]=223;re.setUint32(ie,n);ie+=4}let r;if(this.coercibleKeyAsNumber){for(let i=0;i<n;i++){r=t[i];let n=Number(r);pack(isNaN(n)?r:n);pack(e[r])}}else{for(let i=0;i<n;i++){pack(r=t[i]);pack(e[r])}}}:e=>{te[ie++]=222;let n=ie-t;ie+=2;let r=0;for(let t in e){if(typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(t)){pack(t);pack(e[t]);r++}}if(r>65535){throw new Error("Object is too large to serialize with fast 16-bit map size,"+' use the "variableMapSize" option to serialize this object')}te[n+++t]=r>>8;te[n+t]=r&255};const g=this.useRecords===false?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||(r.transitions=Object.create(null));let s=ie++-t;let a;for(let o in e){if(typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(o)){n=i[o];if(n)i=n;else{let l=Object.keys(e);let c=i;i=r.transitions;let u=0;for(let e=0,t=l.length;e<t;e++){let t=l[e];n=i[t];if(!n){n=i[t]=Object.create(null);u++}i=n}if(s+t+1==ie){ie--;newRecord(i,l,u)}else insertNewRecord(i,l,s,u);a=true;i=c[o]}pack(e[o])}}if(!a){let n=i[ue];if(n)te[s+t]=n;else insertNewRecord(i,Object.keys(e),s,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null));let i=0;for(let r in e)if(typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(r)){t=n[r];if(!t){t=n[r]=Object.create(null);i++}n=t}let s=n[ue];if(s){if(s>=96&&d){te[ie++]=((s-=96)&31)+96;te[ie++]=s>>5}else te[ie++]=s}else{newRecord(n,n.__keys__||Object.keys(e),i)}for(let t in e)if(typeof e.hasOwnProperty!=="function"||e.hasOwnProperty(t)){pack(e[t])}};const v=typeof this.useRecords=="function"&&this.useRecords;const K=v?e=>{v(e)?g(e):b(e)}:g;const makeRoom=e=>{let n;if(e>16777216){if(e-t>ee)throw new Error("Packed buffer would be larger than maximum buffer size");n=Math.min(ee,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,te.length-1)>>12)+1<<12;let r=new H(n);re=r.dataView||(r.dataView=new DataView(r.buffer,0,n));e=Math.min(e,te.length);if(te.copy)te.copy(r,0,t,e);else r.set(te.slice(t,e));ie-=t;t=0;se=r.length-10;return te=r};const newRecord=(e,t,i)=>{let s=r.nextId;if(!s)s=64;if(s<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)){s=r.nextOwnId;if(!(s<p))s=f;r.nextOwnId=s+1}else{if(s>=p)s=f;r.nextId=s+1}let a=t.highByte=s>=96&&d?s-96>>5:-1;e[ue]=s;e.__keys__=t;r[s-64]=t;if(s<f){t.isShared=true;r.sharedLength=s-63;n=true;if(a>=0){te[ie++]=(s&31)+96;te[ie++]=a}else{te[ie++]=s}}else{if(a>=0){te[ie++]=213;te[ie++]=114;te[ie++]=(s&31)+96;te[ie++]=a}else{te[ie++]=212;te[ie++]=114;te[ie++]=s}if(i)y+=m*i;if(h.length>=u)h.shift()[ue]=0;h.push(e);pack(t)}};const insertNewRecord=(e,n,r,i)=>{let s=te;let a=ie;let o=se;let l=t;te=ne;ie=0;t=0;if(!te)ne=te=new H(8192);se=te.length-10;newRecord(e,n,i);ne=te;let c=ie;te=s;ie=a;se=o;t=l;if(c>1){let e=ie+c-1;if(e>se)makeRoom(e);let n=r+t;te.copyWithin(n+c,n+1,ie);te.set(ne.slice(0,c),n);ie=e}else{te[r+t]=ne[0]}};const writeStruct=e=>{let i=oe(e,te,t,ie,r,makeRoom,((e,t,r)=>{if(r)return n=true;ie=t;let i=te;pack(e);resetStructures();if(i!==te){return{position:ie,targetView:re,target:te}}return ie}),this);if(i===0)return K(e);ie=i}}useBuffer(e){te=e;te.dataView||(te.dataView=new DataView(te.buffer,te.byteOffset,te.byteLength));re=te.dataView;ie=0}set position(e){ie=e}get position(){return ie}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}$=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,C1Type];Z=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214;e[i++]=255;n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:s}=t(10);n[s++]=215;n[s++]=255;i.setUint32(s,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0));i.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate){t(0);return n(this.onInvalidDate())}let{target:e,targetView:r,position:i}=t(3);e[i++]=212;e[i++]=255;e[i++]=255}else{let{target:n,targetView:i,position:s}=t(15);n[s++]=199;n[s++]=12;n[s++]=255;i.setUint32(s,e.getMilliseconds()*1e6);i.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject){t(0);return n({})}let r=Array.from(e);let{target:i,position:s}=t(this.moreTypes?3:0);if(this.moreTypes){i[s++]=212;i[s++]=115;i[s++]=0}n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);if(this.moreTypes){r[i++]=212;r[i++]=101;r[i++]=0}n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);if(this.moreTypes){r[i++]=212;r[i++]=120;r[i++]=0}n([e.source,e.flags])}},{pack(e,t){if(this.moreTypes)writeExtBuffer(e,16,t);else writeBuffer(Q?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;if(n!==X&&this.moreTypes)writeExtBuffer(e,P.indexOf(n.name),t);else writeBuffer(e,t)}},{pack(e,t){if(this.moreTypes)writeExtBuffer(e,17,t);else writeBuffer(Q?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function writeExtBuffer(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:s,position:a}=n(4+i);s[a++]=199;s[a++]=i+1}else if(i+1<65536){var{target:s,position:a}=n(5+i);s[a++]=200;s[a++]=i+1>>8;s[a++]=i+1&255}else{var{target:s,position:a,targetView:o}=n(7+i);s[a++]=201;o.setUint32(a,i+1);a+=4}s[a++]=116;s[a++]=t;if(!e.buffer)e=new Uint8Array(e);s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a)}function writeBuffer(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196;r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197;r[i++]=n>>8;r[i++]=n&255}else{var{target:r,position:i,targetView:s}=t(n+5);r[i++]=198;s.setUint32(i,n);i+=4}r.set(e,i)}function writeExtensionData(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:if(i<256){t[n++]=199;t[n++]=i}else if(i<65536){t[n++]=200;t[n++]=i>>8;t[n++]=i&255}else{t[n++]=201;t[n++]=i>>24;t[n++]=i>>16&255;t[n++]=i>>8&255;t[n++]=i&255}}t[n++]=r;t.set(e,n);n+=i;return n}function insertIds(e,t){let n;let r=t.length*6;let i=e.length-r;while(n=t.pop()){let t=n.offset;let s=n.id;e.copyWithin(t+r,t,i);r-=6;let a=t+r;e[a++]=214;e[a++]=105;e[a++]=s>>24;e[a++]=s>>16&255;e[a++]=s>>8&255;e[a++]=s&255;i=t}return e}function writeBundles(e,t,n){if(ae.length>0){re.setUint32(ae.position+e,ie+n-ae.position-e);ae.stringsPosition=ie-e;let r=ae;ae=null;t(r[0]);t(r[1])}}function addExtension(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");$.unshift(e.Class);Z.unshift(e)}addExtension$1(e)}function prepareStructures$1(e,t){e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;if(!n)t._mergeStructures(e);return n};return e}function setWriteStructSlots(e,t){oe=e;prepareStructures$1=t}let de=new Packr({useRecords:false});const fe=de.pack;const pe=de.pack;const he=Packr;const{NEVER:ye,ALWAYS:me,DECIMAL_ROUND:be,DECIMAL_FIT:ge}=U;const ve=512;const Ke=1024;const Se=2048;const Ee=3;const ke=0;const Ie=2;const we=1;const je=16;const xe=["num","object","string","ascii"];xe[je]="date";const Te=[false,true,true,false,false,true,true,false];let De;try{new Function("");De=true}catch(e){}let Oe;const Ce=typeof Buffer!=="undefined";let Ae,Re;try{Ae=new TextEncoder}catch(e){}const _e=Ce?function(e,t,n){return e.utf8Write(t,n,e.byteLength-n)}:Ae&&Ae.encodeInto?function(e,t,n){return Ae.encodeInto(t,e.subarray(n)).written}:false;setWriteStructSlots(writeStruct,prepareStructures);function writeStruct(e,t,n,r,i,s,a,o){let l=o.typedStructs||(o.typedStructs=[]);let c=t.dataView;let u=(l.lastStringStart||100)+r;let d=t.length-10;let f=r;if(r>d){t=s(r);c=t.dataView;r-=n;f-=n;u-=n;n=0;d=t.length-10}let p,h=u;let y=l.transitions||(l.transitions=Object.create(null));let m=l.nextId||l.length;let b=m<15?1:m<240?2:m<61440?3:m<15728640?4:0;if(b===0)return 0;r+=b;let g=[];let v;let K=0;for(let i in e){let o=e[i];let b=y[i];if(!b){y[i]=b={key:i,parent:y,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null}}if(r>d){t=s(r);c=t.dataView;r-=n;f-=n;u-=n;h-=n;n=0;d=t.length-10}switch(typeof o){case"number":let e=o;if(m<200||!b.num64){if(e>>0===e&&e<536870912&&e>-520093696){if(e<246&&e>=0&&(b.num8&&!(m>200&&b.num32)||e<32&&!b.num32)){y=b.num8||createTypeTransition(b,ke,1);t[r++]=e}else{y=b.num32||createTypeTransition(b,ke,4);c.setUint32(r,e,true);r+=4}break}else if(e<4294967296&&e>=-2147483648){c.setFloat32(r,e,true);if(Te[t[r+3]>>>5]){let n;if((n=e*J[(t[r+3]&127)<<1|t[r+2]>>7])>>0===n){y=b.num32||createTypeTransition(b,ke,4);r+=4;break}}}}y=b.num64||createTypeTransition(b,ke,8);c.setFloat64(r,e,true);r+=8;break;case"string":let S=o.length;p=h-u;if((S<<2)+h>d){t=s((S<<2)+h);c=t.dataView;r-=n;f-=n;u-=n;h-=n;n=0;d=t.length-10}if(S>65280+p>>2){g.push(i,o,r-f);break}let E;let k=h;if(S<64){let e,n,r;for(e=0;e<S;e++){n=o.charCodeAt(e);if(n<128){t[h++]=n}else if(n<2048){E=true;t[h++]=n>>6|192;t[h++]=n&63|128}else if((n&64512)===55296&&((r=o.charCodeAt(e+1))&64512)===56320){E=true;n=65536+((n&1023)<<10)+(r&1023);e++;t[h++]=n>>18|240;t[h++]=n>>12&63|128;t[h++]=n>>6&63|128;t[h++]=n&63|128}else{E=true;t[h++]=n>>12|224;t[h++]=n>>6&63|128;t[h++]=n&63|128}}}else{h+=_e(t,o,h);E=h-k>S}if(p<160||p<246&&(b.ascii8||b.string8)){if(E){if(!(y=b.string8)){if(l.length>10&&(y=b.ascii8)){y.__type=Ie;b.ascii8=null;b.string8=y;a(null,0,true)}else{y=createTypeTransition(b,Ie,1)}}}else if(p===0&&!v){v=true;y=b.ascii0||createTypeTransition(b,Ee,0);break}else if(!(y=b.ascii8)&&!(l.length>10&&(y=b.string8)))y=createTypeTransition(b,Ee,1);t[r++]=p}else{y=b.string16||createTypeTransition(b,Ie,2);c.setUint16(r,p,true);r+=2}break;case"object":if(o){if(o.constructor===Date){y=b.date64||createTypeTransition(b,je,8);c.setFloat64(r,o.getTime(),true);r+=8}else{g.push(i,o,K)}break}else{b=anyType(b,r,c,-10);if(b){y=b;r=Oe}else g.push(i,o,K)}break;case"boolean":y=b.num8||b.ascii8||createTypeTransition(b,ke,1);t[r++]=o?249:248;break;case"undefined":b=anyType(b,r,c,-9);if(b){y=b;r=Oe}else g.push(i,o,K);break;default:g.push(i,o,K)}K++}for(let e=0,i=g.length;e<i;){let i=g[e++];let s=g[e++];let o=g[e++];let l=y[i];if(!l){y[i]=l={key:i,parent:y,enumerationOffset:o-K,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null}}let d;if(s){let e;p=h-u;if(p<65280){y=l.object16;if(y)e=2;else if(y=l.object32)e=4;else{y=createTypeTransition(l,we,2);e=2}}else{y=l.object32||createTypeTransition(l,we,4);e=4}d=a(s,h);if(typeof d==="object"){h=d.position;c=d.targetView;t=d.target;u-=n;r-=n;f-=n;n=0}else h=d;if(e===2){c.setUint16(r,p,true);r+=2}else{c.setUint32(r,p,true);r+=4}}else{y=l.object16||createTypeTransition(l,we,2);c.setInt16(r,s===null?-10:-9,true);r+=2}K++}let S=y[ue];if(S==null){S=o.typedStructs.length;let e=[];let t=y;let n,r;while((r=t.__type)!==undefined){let i=t.__size;t=t.__parent;n=t.key;let s=[r,i,n];if(t.enumerationOffset)s.push(t.enumerationOffset);e.push(s);t=t.parent}e.reverse();y[ue]=S;o.typedStructs[S]=e;a(null,0,true)}switch(b){case 1:if(S>=16)return 0;t[f]=S+32;break;case 2:if(S>=256)return 0;t[f]=56;t[f+1]=S;break;case 3:if(S>=65536)return 0;t[f]=57;c.setUint16(f+1,S,true);break;case 4:if(S>=16777216)return 0;c.setUint32(f,(S<<8)+58,true);break}if(r<u){if(u===h)return r;t.copyWithin(r,u,h);h+=r-u;l.lastStringStart=r-f}else if(r>u){if(u===h)return r;l.lastStringStart=r-f;return writeStruct(e,t,n,f,i,s,a,o)}return h}function anyType(e,t,n,r){let i;if(i=e.ascii8||e.num8){n.setInt8(t,r,true);Oe=t+1;return i}if(i=e.string16||e.object16){n.setInt16(t,r,true);Oe=t+2;return i}if(i=e.num32){n.setUint32(t,3758096640+r,true);Oe=t+4;return i}if(i=e.num64){n.setFloat64(t,NaN,true);n.setInt8(t,r);Oe=t+8;return i}Oe=t;return}function createTypeTransition(e,t,n){let r=xe[t]+(n<<3);let i=e[r]||(e[r]=Object.create(null));i.__type=t;i.__size=n;i.__parent=e;return i}function onLoadedStructures(e){if(!(e instanceof Map))return e;let t=e.get("typed")||[];if(Object.isFrozen(t))t=t.map((e=>e.slice(0)));let n=e.get("named");let r=Object.create(null);for(let e=0,n=t.length;e<n;e++){let n=t[e];let i=r;for(let[e,t,r]of n){let n=i[r];if(!n){i[r]=n={key:r,parent:i,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null}}i=createTypeTransition(n,e,t)}i[ue]=e}t.transitions=r;this.typedStructs=t;this.lastTypedStructuresLength=t.length;return n}var Me=Symbol.for("source");function readStruct(e,t,n,r){let i=e[t++]-32;if(i>=24){switch(i){case 24:i=e[t++];break;case 25:i=e[t++]+(e[t++]<<8);break;case 26:i=e[t++]+(e[t++]<<8)+(e[t++]<<16);break;case 27:i=e[t++]+(e[t++]<<8)+(e[t++]<<16)+(e[t++]<<24);break}}let s=r.typedStructs&&r.typedStructs[i];if(!s){e=Uint8Array.prototype.slice.call(e,t,n);n-=t;t=0;if(!r.getStructures)throw new Error(`Reference to shared structure ${i} without getStructures method`);r._mergeStructures(r.getStructures());if(!r.typedStructs)throw new Error("Could not find any shared typed structures");r.lastTypedStructuresLength=r.typedStructs.length;s=r.typedStructs[i];if(!s)throw new Error("Could not find typed structure "+i)}var a=s.construct;var o=s.fullConstruct;if(!a){a=s.construct=function LazyObject(){};o=s.fullConstruct=function LoadedObject(){};o.prototype=r.structPrototype||{};var l=a.prototype=r.structPrototype?Object.create(r.structPrototype):{};let e=[];let t=0;let n;for(let i=0,a=s.length;i<a;i++){let a=s[i];let[o,l,c,u]=a;if(c==="__proto__")c="__proto_";let d={key:c,offset:t};if(u)e.splice(i+u,0,d);else e.push(d);let f;switch(l){case 0:f=()=>0;break;case 1:f=(e,t)=>{let n=e.bytes[t+d.offset];return n>=246?toConstant(n):n};break;case 2:f=(e,t)=>{let n=e.bytes;let r=n.dataView||(n.dataView=new DataView(n.buffer,n.byteOffset,n.byteLength));let i=r.getUint16(t+d.offset,true);return i>=65280?toConstant(i&255):i};break;case 4:f=(e,t)=>{let n=e.bytes;let r=n.dataView||(n.dataView=new DataView(n.buffer,n.byteOffset,n.byteLength));let i=r.getUint32(t+d.offset,true);return i>=4294967040?toConstant(i&255):i};break}d.getRef=f;t+=l;let p;switch(o){case Ee:if(n&&!n.next)n.next=d;n=d;d.multiGetCount=0;p=function(e){let n=e.bytes;let r=e.position;let i=t+r;let s=f(e,r);if(typeof s!=="number")return s;let a,o=d.next;while(o){a=o.getRef(e,r);if(typeof a==="number")break;else a=null;o=o.next}if(a==null)a=e.bytesEnd-i;if(e.srcString){return e.srcString.slice(s,a)}return readString(n,s+i,a-s)};break;case Ie:case we:if(n&&!n.next)n.next=d;n=d;p=function(e){let n=e.position;let i=t+n;let s=f(e,n);if(typeof s!=="number")return s;let a=e.bytes;let l,c=d.next;while(c){l=c.getRef(e,n);if(typeof l==="number")break;else l=null;c=c.next}if(l==null)l=e.bytesEnd-i;if(o===Ie){return a.toString("utf8",s+i,l+i)}else{Re=e;try{return r.unpack(a,{start:s+i,end:l+i})}finally{Re=null}}};break;case ke:switch(l){case 4:p=function(e){let t=e.bytes;let n=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength));let r=e.position+d.offset;let i=n.getInt32(r,true);if(i<536870912){if(i>-520093696)return i;if(i>-536870912)return toConstant(i&255)}let s=n.getFloat32(r,true);let a=J[(t[r+3]&127)<<1|t[r+2]>>7];return(a*s+(s>0?.5:-.5)>>0)/a};break;case 8:p=function(e){let t=e.bytes;let n=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength));let r=n.getFloat64(e.position+d.offset,true);if(isNaN(r)){let n=t[e.position+d.offset];if(n>=246)return toConstant(n)}return r};break;case 1:p=function(e){let t=e.bytes;let n=t[e.position+d.offset];return n<246?n:toConstant(n)};break}break;case je:p=function(e){let t=e.bytes;let n=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength));return new Date(n.getFloat64(e.position+d.offset,true))};break}d.get=p}if(De){let t=[];let n=[];let i=0;let s;for(let a of e){if(r.alwaysLazyProperty&&r.alwaysLazyProperty(a.key)){s=true;continue}Object.defineProperty(l,a.key,{get:withSource(a.get),enumerable:true});let e="v"+i++;n.push(e);t.push("o["+JSON.stringify(a.key)+"]="+e+"(s)")}if(s){t.push("__proto__:this")}let a=new Function(...n,"var c=this;return function(s){var o=new c();"+t.join(";")+";return o;}").apply(o,e.map((e=>e.get)));Object.defineProperty(l,"toJSON",{value(e){return a.call(this,this[Me])}})}else{Object.defineProperty(l,"toJSON",{value(t){let n={};for(let t=0,r=e.length;t<r;t++){let r=e[t].key;n[r]=this[r]}return n}})}}var c=new a;c[Me]={bytes:e,position:t,srcString:"",bytesEnd:n};return c}function toConstant(e){switch(e){case 246:return null;case 247:return undefined;case 248:return false;case 249:return true}throw new Error("Unknown constant")}function withSource(e){return function(){return e(this[Me])}}function saveState(){if(Re){Re.bytes=Uint8Array.prototype.slice.call(Re.bytes,Re.position,Re.bytesEnd);Re.position=0;Re.bytesEnd=Re.bytes.length}}function prepareStructures(e,t){if(t.typedStructs){let n=new Map;n.set("named",e);n.set("typed",t.typedStructs);e=n}let n=t.lastTypedStructuresLength||0;e.isCompatible=e=>{let r=true;if(e instanceof Map){let i=e.get("named")||[];if(i.length!==(t.lastNamedStructuresLength||0))r=false;let s=e.get("typed")||[];if(s.length!==n)r=false}else if(e instanceof Array||Array.isArray(e)){if(e.length!==(t.lastNamedStructuresLength||0))r=false}if(!r)t._mergeStructures(e);return r};t.lastTypedStructuresLength=t.typedStructs&&t.typedStructs.length;return e}setReadStruct(readStruct,onLoadedStructures,saveState);class PackrStream extends r.Transform{constructor(e){if(!e)e={};e.writableObjectMode=true;super(e);e.sequential=true;this.packr=e.packr||new Packr(e)}_transform(e,t,n){this.push(this.packr.pack(e));n()}}class UnpackrStream extends r.Transform{constructor(e){if(!e)e={};e.objectMode=true;super(e);e.structures=[];this.unpackr=e.unpackr||new Unpackr(e)}_transform(e,t,n){if(this.incompleteBuffer){e=Buffer.concat([this.incompleteBuffer,e]);this.incompleteBuffer=null}let r;try{r=this.unpackr.unpackMultiple(e)}catch(t){if(t.incomplete){this.incompleteBuffer=e.slice(t.lastPosition);r=t.values}else throw t}finally{for(let e of r||[]){if(e===null)e=this.getNullValue();this.push(e)}}if(n)n()}getNullValue(){return Symbol.for(null)}}function packIter(e,t={}){if(!e||typeof e!=="object"){throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable")}else if(typeof e[Symbol.iterator]==="function"){return packIterSync(e,t)}else if(typeof e.then==="function"||typeof e[Symbol.asyncIterator]==="function"){return packIterAsync(e,t)}else{throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}}function*packIterSync(e,t){const n=new Packr(t);for(const t of e){yield n.pack(t)}}async function*packIterAsync(e,t){const n=new Packr(t);for await(const t of e){yield n.pack(t)}}function unpackIter(e,t={}){if(!e||typeof e!=="object"){throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise")}const n=new Unpackr(t);let r;const parser=e=>{let t;if(r){e=Buffer.concat([r,e]);r=undefined}try{t=n.unpackMultiple(e)}catch(n){if(n.incomplete){r=e.slice(n.lastPosition);t=n.values}else{throw n}}return t};if(typeof e[Symbol.iterator]==="function"){return function*iter(){for(const t of e){yield*parser(t)}}()}else if(typeof e[Symbol.asyncIterator]==="function"){return async function*iter(){for await(const t of e){yield*parser(t)}}()}}const Pe=unpackIter;const Ne=packIter;const Le=false;const Je=true;const Fe=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==undefined&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!Fe){let e;try{if(true)e=n(86);else{}if(e)setExtractor(e.extractStrings)}catch(e){}}t.ALWAYS=me;t.C1=E;t.DECIMAL_FIT=ge;t.DECIMAL_ROUND=be;t.Decoder=F;t.DecoderStream=UnpackrStream;t.Encoder=he;t.EncoderStream=PackrStream;t.FLOAT32_OPTIONS=U;t.NEVER=ye;t.Packr=Packr;t.PackrStream=PackrStream;t.Unpackr=Unpackr;t.UnpackrStream=UnpackrStream;t.addExtension=addExtension;t.clearSource=clearSource;t.decode=Y;t.decodeIter=Pe;t.encode=pe;t.encodeIter=Ne;t.mapsAsObjects=Je;t.pack=fe;t.roundFloat32=roundFloat32;t.unpack=G;t.unpackMultiple=q;t.useRecords=Le},435:function(e){"use strict";e.exports=JSON.parse('{"acl":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"append":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"asking":{"arity":1,"flags":["fast"],"keyStart":0,"keyStop":0,"step":0},"auth":{"arity":-2,"flags":["noscript","loading","stale","fast","no_auth","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"bgrewriteaof":{"arity":1,"flags":["admin","noscript","no_async_loading"],"keyStart":0,"keyStop":0,"step":0},"bgsave":{"arity":-1,"flags":["admin","noscript","no_async_loading"],"keyStart":0,"keyStop":0,"step":0},"bitcount":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"bitfield":{"arity":-2,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"bitfield_ro":{"arity":-2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"bitop":{"arity":-4,"flags":["write","denyoom"],"keyStart":2,"keyStop":-1,"step":1},"bitpos":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"blmove":{"arity":6,"flags":["write","denyoom","noscript","blocking"],"keyStart":1,"keyStop":2,"step":1},"blmpop":{"arity":-5,"flags":["write","blocking","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"blpop":{"arity":-3,"flags":["write","noscript","blocking"],"keyStart":1,"keyStop":-2,"step":1},"brpop":{"arity":-3,"flags":["write","noscript","blocking"],"keyStart":1,"keyStop":-2,"step":1},"brpoplpush":{"arity":4,"flags":["write","denyoom","noscript","blocking"],"keyStart":1,"keyStop":2,"step":1},"bzmpop":{"arity":-5,"flags":["write","blocking","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"bzpopmax":{"arity":-3,"flags":["write","noscript","blocking","fast"],"keyStart":1,"keyStop":-2,"step":1},"bzpopmin":{"arity":-3,"flags":["write","noscript","blocking","fast"],"keyStart":1,"keyStop":-2,"step":1},"client":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"cluster":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"command":{"arity":-1,"flags":["loading","stale"],"keyStart":0,"keyStop":0,"step":0},"config":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"copy":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"dbsize":{"arity":1,"flags":["readonly","fast"],"keyStart":0,"keyStop":0,"step":0},"debug":{"arity":-2,"flags":["admin","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"decr":{"arity":2,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"decrby":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"del":{"arity":-2,"flags":["write"],"keyStart":1,"keyStop":-1,"step":1},"discard":{"arity":1,"flags":["noscript","loading","stale","fast","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"dump":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"echo":{"arity":2,"flags":["fast"],"keyStart":0,"keyStop":0,"step":0},"eval":{"arity":-3,"flags":["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"eval_ro":{"arity":-3,"flags":["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"evalsha":{"arity":-3,"flags":["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"evalsha_ro":{"arity":-3,"flags":["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"exec":{"arity":1,"flags":["noscript","loading","stale","skip_slowlog"],"keyStart":0,"keyStop":0,"step":0},"exists":{"arity":-2,"flags":["readonly","fast"],"keyStart":1,"keyStop":-1,"step":1},"expire":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"expireat":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"expiretime":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"failover":{"arity":-1,"flags":["admin","noscript","stale"],"keyStart":0,"keyStop":0,"step":0},"fcall":{"arity":-3,"flags":["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"fcall_ro":{"arity":-3,"flags":["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"flushall":{"arity":-1,"flags":["write"],"keyStart":0,"keyStop":0,"step":0},"flushdb":{"arity":-1,"flags":["write"],"keyStart":0,"keyStop":0,"step":0},"function":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"geoadd":{"arity":-5,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"geodist":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"geohash":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"geopos":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"georadius":{"arity":-6,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"georadius_ro":{"arity":-6,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"georadiusbymember":{"arity":-5,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"georadiusbymember_ro":{"arity":-5,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"geosearch":{"arity":-7,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"geosearchstore":{"arity":-8,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"get":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"getbit":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"getdel":{"arity":2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"getex":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"getrange":{"arity":4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"getset":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hdel":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"hello":{"arity":-1,"flags":["noscript","loading","stale","fast","no_auth","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"hexists":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hexpire":{"arity":-6,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"hget":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hgetall":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"hincrby":{"arity":4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hincrbyfloat":{"arity":4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hkeys":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"hlen":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hmget":{"arity":-3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hmset":{"arity":-4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hrandfield":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"hscan":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"hset":{"arity":-4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hsetnx":{"arity":4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"hstrlen":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"hvals":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"incr":{"arity":2,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"incrby":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"incrbyfloat":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"info":{"arity":-1,"flags":["loading","stale"],"keyStart":0,"keyStop":0,"step":0},"keys":{"arity":2,"flags":["readonly"],"keyStart":0,"keyStop":0,"step":0},"lastsave":{"arity":1,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"latency":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"lcs":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":2,"step":1},"lindex":{"arity":3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"linsert":{"arity":5,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"llen":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"lmove":{"arity":5,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"lmpop":{"arity":-4,"flags":["write","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"lolwut":{"arity":-1,"flags":["readonly","fast"],"keyStart":0,"keyStop":0,"step":0},"lpop":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"lpos":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"lpush":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"lpushx":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"lrange":{"arity":4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"lrem":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"lset":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"ltrim":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"memory":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"mget":{"arity":-2,"flags":["readonly","fast"],"keyStart":1,"keyStop":-1,"step":1},"migrate":{"arity":-6,"flags":["write","movablekeys"],"keyStart":3,"keyStop":3,"step":1},"module":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"monitor":{"arity":1,"flags":["admin","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"move":{"arity":3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"mset":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":2},"msetnx":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":2},"multi":{"arity":1,"flags":["noscript","loading","stale","fast","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"object":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"persist":{"arity":2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"pexpire":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"pexpireat":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"pexpiretime":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"pfadd":{"arity":-2,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"pfcount":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":-1,"step":1},"pfdebug":{"arity":3,"flags":["write","denyoom","admin"],"keyStart":2,"keyStop":2,"step":1},"pfmerge":{"arity":-2,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":1},"pfselftest":{"arity":1,"flags":["admin"],"keyStart":0,"keyStop":0,"step":0},"ping":{"arity":-1,"flags":["fast"],"keyStart":0,"keyStop":0,"step":0},"psetex":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"psubscribe":{"arity":-2,"flags":["pubsub","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"psync":{"arity":-3,"flags":["admin","noscript","no_async_loading","no_multi"],"keyStart":0,"keyStop":0,"step":0},"pttl":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"publish":{"arity":3,"flags":["pubsub","loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"pubsub":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"punsubscribe":{"arity":-1,"flags":["pubsub","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"quit":{"arity":-1,"flags":["noscript","loading","stale","fast","no_auth","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"randomkey":{"arity":1,"flags":["readonly"],"keyStart":0,"keyStop":0,"step":0},"readonly":{"arity":1,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"readwrite":{"arity":1,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"rename":{"arity":3,"flags":["write"],"keyStart":1,"keyStop":2,"step":1},"renamenx":{"arity":3,"flags":["write","fast"],"keyStart":1,"keyStop":2,"step":1},"replconf":{"arity":-1,"flags":["admin","noscript","loading","stale","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"replicaof":{"arity":3,"flags":["admin","noscript","stale","no_async_loading"],"keyStart":0,"keyStop":0,"step":0},"reset":{"arity":1,"flags":["noscript","loading","stale","fast","no_auth","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"restore":{"arity":-4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"restore-asking":{"arity":-4,"flags":["write","denyoom","asking"],"keyStart":1,"keyStop":1,"step":1},"role":{"arity":1,"flags":["noscript","loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"rpop":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"rpoplpush":{"arity":3,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"rpush":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"rpushx":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"sadd":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"save":{"arity":1,"flags":["admin","noscript","no_async_loading","no_multi"],"keyStart":0,"keyStop":0,"step":0},"scan":{"arity":-2,"flags":["readonly"],"keyStart":0,"keyStop":0,"step":0},"scard":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"script":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"sdiff":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":-1,"step":1},"sdiffstore":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":1},"select":{"arity":2,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"set":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"setbit":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"setex":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"setnx":{"arity":3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"setrange":{"arity":4,"flags":["write","denyoom"],"keyStart":1,"keyStop":1,"step":1},"shutdown":{"arity":-1,"flags":["admin","noscript","loading","stale","no_multi","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"sinter":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":-1,"step":1},"sintercard":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"sinterstore":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":1},"sismember":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"slaveof":{"arity":3,"flags":["admin","noscript","stale","no_async_loading"],"keyStart":0,"keyStop":0,"step":0},"slowlog":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"smembers":{"arity":2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"smismember":{"arity":-3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"smove":{"arity":4,"flags":["write","fast"],"keyStart":1,"keyStop":2,"step":1},"sort":{"arity":-2,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"sort_ro":{"arity":-2,"flags":["readonly","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"spop":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"spublish":{"arity":3,"flags":["pubsub","loading","stale","fast"],"keyStart":1,"keyStop":1,"step":1},"srandmember":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"srem":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"sscan":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"ssubscribe":{"arity":-2,"flags":["pubsub","noscript","loading","stale"],"keyStart":1,"keyStop":-1,"step":1},"strlen":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"subscribe":{"arity":-2,"flags":["pubsub","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"substr":{"arity":4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"sunion":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":-1,"step":1},"sunionstore":{"arity":-3,"flags":["write","denyoom"],"keyStart":1,"keyStop":-1,"step":1},"sunsubscribe":{"arity":-1,"flags":["pubsub","noscript","loading","stale"],"keyStart":1,"keyStop":-1,"step":1},"swapdb":{"arity":3,"flags":["write","fast"],"keyStart":0,"keyStop":0,"step":0},"sync":{"arity":1,"flags":["admin","noscript","no_async_loading","no_multi"],"keyStart":0,"keyStop":0,"step":0},"time":{"arity":1,"flags":["loading","stale","fast"],"keyStart":0,"keyStop":0,"step":0},"touch":{"arity":-2,"flags":["readonly","fast"],"keyStart":1,"keyStop":-1,"step":1},"ttl":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"type":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"unlink":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":-1,"step":1},"unsubscribe":{"arity":-1,"flags":["pubsub","noscript","loading","stale"],"keyStart":0,"keyStop":0,"step":0},"unwatch":{"arity":1,"flags":["noscript","loading","stale","fast","allow_busy"],"keyStart":0,"keyStop":0,"step":0},"wait":{"arity":3,"flags":["noscript"],"keyStart":0,"keyStop":0,"step":0},"watch":{"arity":-2,"flags":["noscript","loading","stale","fast","allow_busy"],"keyStart":1,"keyStop":-1,"step":1},"xack":{"arity":-4,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"xadd":{"arity":-5,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"xautoclaim":{"arity":-6,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"xclaim":{"arity":-6,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"xdel":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"xgroup":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"xinfo":{"arity":-2,"flags":[],"keyStart":0,"keyStop":0,"step":0},"xlen":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"xpending":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"xrange":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"xread":{"arity":-4,"flags":["readonly","blocking","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"xreadgroup":{"arity":-7,"flags":["write","blocking","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"xrevrange":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"xsetid":{"arity":-3,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"xtrim":{"arity":-4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"zadd":{"arity":-4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"zcard":{"arity":2,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zcount":{"arity":4,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zdiff":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zdiffstore":{"arity":-4,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"zincrby":{"arity":4,"flags":["write","denyoom","fast"],"keyStart":1,"keyStop":1,"step":1},"zinter":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zintercard":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zinterstore":{"arity":-4,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1},"zlexcount":{"arity":4,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zmpop":{"arity":-4,"flags":["write","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zmscore":{"arity":-3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zpopmax":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"zpopmin":{"arity":-2,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"zrandmember":{"arity":-2,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrange":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrangebylex":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrangebyscore":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrangestore":{"arity":-5,"flags":["write","denyoom"],"keyStart":1,"keyStop":2,"step":1},"zrank":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zrem":{"arity":-3,"flags":["write","fast"],"keyStart":1,"keyStop":1,"step":1},"zremrangebylex":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"zremrangebyrank":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"zremrangebyscore":{"arity":4,"flags":["write"],"keyStart":1,"keyStop":1,"step":1},"zrevrange":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrevrangebylex":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrevrangebyscore":{"arity":-4,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zrevrank":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zscan":{"arity":-3,"flags":["readonly"],"keyStart":1,"keyStop":1,"step":1},"zscore":{"arity":3,"flags":["readonly","fast"],"keyStart":1,"keyStop":1,"step":1},"zunion":{"arity":-3,"flags":["readonly","movablekeys"],"keyStart":0,"keyStop":0,"step":0},"zunionstore":{"arity":-4,"flags":["write","denyoom","movablekeys"],"keyStart":1,"keyStop":1,"step":1}}')}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var n=__webpack_module_cache__[e]={id:e,loaded:false,exports:{}};var r=true;try{__webpack_modules__[e].call(n.exports,n,n.exports,__nccwpck_require__);r=false}finally{if(r)delete __webpack_module_cache__[e]}n.loaded=true;return n.exports}!function(){__nccwpck_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}();!function(){__nccwpck_require__.nmd=function(e){e.paths=[];if(!e.children)e.children=[];return e}}();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(9595);module.exports=__webpack_exports__})();
|