claude-mem 13.12.2 → 13.12.4

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.
@@ -98,10 +98,10 @@ ${o.stack}`:` ${o.message}`;else if(this.getLevel()===0&&typeof o=="object")try{
98
98
  ${m.stack??""}
99
99
  `)}else Os(f+`
100
100
  `)}debug(e,r,i,n){this.log(0,e,r,i,n)}info(e,r,i,n){this.log(1,e,r,i,n)}warn(e,r,i,n){this.log(2,e,r,i,n)}setErrorSink(e){Tb=e}error(e,r,i,n){this.log(3,e,r,i,n),this.routeErrorToSink(r,i,n)}routeErrorToSink(e,r,i){try{if(!Tb||!(i instanceof Error))return;Tb(i)}catch{}}dataIn(e,r,i,n){this.info(e,`\u2192 ${r}`,i,n)}dataOut(e,r,i,n){this.info(e,`\u2190 ${r}`,i,n)}success(e,r,i,n){this.info(e,`\u2713 ${r}`,i,n)}failure(e,r,i,n){this.error(e,`\u2717 ${r}`,i,n)}},I=new Ob});import{join as hA}from"path";import{mkdirSync as HW,writeFileSync as YW}from"fs";import{randomUUID as XW}from"crypto";function QW(t){let e=t.DO_NOT_TRACK;return e===void 0||e===""?!1:e!=="0"&&e!=="false"}function Ab(t,e){if(QW(t))return{enabled:!1,source:"DO_NOT_TRACK"};let r=t.CLAUDE_MEM_TELEMETRY?.toLowerCase();return r==="0"||r==="false"||r==="off"?{enabled:!1,source:"env"}:r==="1"||r==="true"||r==="on"?{enabled:!0,source:"env"}:e?.enabled===!0?{enabled:!0,source:"config"}:e?.enabled===!1?{enabled:!1,source:"config"}:{enabled:!0,source:"default"}}function gA(t,e){return Ab(t,e).enabled}function Jl(){return hA(Cn(),yA)}function Ci(){let t;try{t=Ft(Jl(),null)}catch(e){let r=e instanceof Error?e:new Error(String(e));return I.warn("SYSTEM","Telemetry: corrupt telemetry.json; treating as no recorded consent",void 0,r),null}return!t||typeof t!="object"||typeof t.installId!="string"||t.enabled!==void 0&&typeof t.enabled!="boolean"?null:{enabled:t.enabled,installId:t.installId,decidedAt:typeof t.decidedAt=="string"?t.decidedAt:""}}function Ms(t){let e=Cn();HW(e,{recursive:!0}),YW(hA(e,yA),JSON.stringify(t,null,2)+`
101
- `)}function Od(){let t=Ci();if(t?.installId)return t.installId;let e=XW();return Ms({installId:e,decidedAt:""}),e}var yA,Ad=S(()=>{"use strict";nt();wo();Me();yA="telemetry.json"});function t3(t,e){if(!(!t||typeof t!="object"))for(let r of Object.keys(t)){if(!e3.has(r))continue;let i=t[r];typeof i=="string"?e[r]=i.length>bA?i.slice(0,bA):i:(typeof i=="number"&&Number.isFinite(i)||typeof i=="boolean")&&(e[r]=i)}}function vA(t){let e={};try{t3(t,e)}catch{}return e}var e3,bA,SA=S(()=>{"use strict";e3=new Set(["version","os","os_version","is_wsl","arch","runtime","runtime_version","node_version","duration_ms","outcome","error_category","locale","is_ci","endpoint","ide","provider","runtime_mode","trigger","count","has_summary","is_update","install_method","interactive","bun_version","uv_version","claude_code_version","observation_count","session_count","timeline_depth_days","has_session_summary","obs_type_bugfix","obs_type_discovery","obs_type_decision","obs_type_refactor","obs_type_other","tokens_injected","tokens_saved_vs_naive","mode","search_strategy","observation_type","hook","compression_ms","tokens_input","tokens_output","compression_ratio","model","cost_usd","endpoint_class","db_observation_count","db_session_count","db_summary_count","db_project_count","db_size_mb","install_age_days","obs_count_7d","obs_count_30d","days_since_last_obs","result_count","chroma_available","fallback_reason","invalid_output_class","consecutive_invalid_outputs","respawn_triggered","abort_reason","previous_shutdown","previous_uptime_seconds","uptime_seconds","shutdown_reason","process_rss_mb","heap_used_mb","hook_type","error_mode","consecutive_failures","threshold_tripped","discovery_tokens","read_tokens","summary_count","prompt_count","project_count","backfilled","first_active_date","session_completed_count","session_failed_count","sessions_claude_count","sessions_codex_count","sessions_gemini_count","sessions_other_platform_count","subagent_obs_count","total_tokens_input","total_tokens_output","total_cost_usd","avg_duration_ms","avg_compression_ms","outcomes_ok","outcomes_error","outcomes_aborted","outcomes_invalid_output","top_model","window_start_ts","rollup_reason","window_seq","total_tokens","avg_tokens","observations_created","total_observations_injected","total_tokens_saved_vs_naive"]),bA=200});import EA from"os";function wA(){return process.env.CLAUDE_MEM_TELEMETRY_KEY||n3}function xA(){return process.env.CLAUDE_MEM_TELEMETRY_HOST||i3}function IA(t){let e={};for(let r of o3)t[r]!==void 0&&(e[r]=t[r]);return e}function s3(){if(process.platform!=="linux")return!1;try{return!!process.env.WSL_DISTRO_NAME||EA.release().toLowerCase().includes("microsoft")}catch(t){let e=t instanceof Error?t:new Error(String(t));return I.warn("SYSTEM","Telemetry: WSL detection failed; reporting is_wsl=false",void 0,e),!1}}function kA(){return{version:r3,os:process.platform,os_version:EA.release(),is_wsl:s3(),arch:process.arch,runtime:process.versions.bun?"bun":"node",runtime_version:process.versions.bun??process.versions.node,node_version:process.versions.node,is_ci:!!process.env.CI,locale:Intl.DateTimeFormat().resolvedOptions().locale}}var r3,n3,i3,o3,_A=S(()=>{"use strict";Me();r3="13.12.2",n3="phc_BKJAeNbpj932N9qEiU6qhutZEiu6LLfRpXfTbLM9MLaG",i3="https://us.i.posthog.com";o3=["version","os","os_version","is_wsl","arch","runtime","locale","ide","provider","runtime_mode","install_method","claude_code_version","first_active_date","db_observation_count","db_session_count","db_summary_count","db_project_count","db_size_mb","install_age_days","obs_count_7d","obs_count_30d","days_since_last_obs"]});async function Ns(t,e,r){try{if(!gA(process.env,Ci()))return;let i=vA({...kA(),...e??{}});if(r?.person?i.$set=IA(i):i.$process_person_profile=!1,process.env.CLAUDE_MEM_TELEMETRY_DEBUG==="1"){process.stderr.write("[telemetry] "+JSON.stringify({event:t,properties:i})+`
101
+ `)}function Od(){let t=Ci();if(t?.installId)return t.installId;let e=XW();return Ms({installId:e,decidedAt:""}),e}var yA,Ad=S(()=>{"use strict";nt();wo();Me();yA="telemetry.json"});function t3(t,e){if(!(!t||typeof t!="object"))for(let r of Object.keys(t)){if(!e3.has(r))continue;let i=t[r];typeof i=="string"?e[r]=i.length>bA?i.slice(0,bA):i:(typeof i=="number"&&Number.isFinite(i)||typeof i=="boolean")&&(e[r]=i)}}function vA(t){let e={};try{t3(t,e)}catch{}return e}var e3,bA,SA=S(()=>{"use strict";e3=new Set(["version","os","os_version","is_wsl","arch","runtime","runtime_version","node_version","duration_ms","outcome","error_category","locale","is_ci","endpoint","ide","provider","runtime_mode","trigger","count","has_summary","is_update","install_method","interactive","bun_version","uv_version","claude_code_version","observation_count","session_count","timeline_depth_days","has_session_summary","obs_type_bugfix","obs_type_discovery","obs_type_decision","obs_type_refactor","obs_type_other","tokens_injected","tokens_saved_vs_naive","mode","search_strategy","observation_type","hook","compression_ms","tokens_input","tokens_output","compression_ratio","model","cost_usd","endpoint_class","db_observation_count","db_session_count","db_summary_count","db_project_count","db_size_mb","install_age_days","obs_count_7d","obs_count_30d","days_since_last_obs","result_count","chroma_available","fallback_reason","invalid_output_class","consecutive_invalid_outputs","respawn_triggered","abort_reason","previous_shutdown","previous_uptime_seconds","uptime_seconds","shutdown_reason","process_rss_mb","heap_used_mb","hook_type","error_mode","consecutive_failures","threshold_tripped","discovery_tokens","read_tokens","summary_count","prompt_count","project_count","backfilled","first_active_date","session_completed_count","session_failed_count","sessions_claude_count","sessions_codex_count","sessions_gemini_count","sessions_other_platform_count","subagent_obs_count","total_tokens_input","total_tokens_output","total_cost_usd","avg_duration_ms","avg_compression_ms","outcomes_ok","outcomes_error","outcomes_aborted","outcomes_invalid_output","top_model","window_start_ts","rollup_reason","window_seq","total_tokens","avg_tokens","observations_created","total_observations_injected","total_tokens_saved_vs_naive"]),bA=200});import EA from"os";function wA(){return process.env.CLAUDE_MEM_TELEMETRY_KEY||n3}function xA(){return process.env.CLAUDE_MEM_TELEMETRY_HOST||i3}function IA(t){let e={};for(let r of o3)t[r]!==void 0&&(e[r]=t[r]);return e}function s3(){if(process.platform!=="linux")return!1;try{return!!process.env.WSL_DISTRO_NAME||EA.release().toLowerCase().includes("microsoft")}catch(t){let e=t instanceof Error?t:new Error(String(t));return I.warn("SYSTEM","Telemetry: WSL detection failed; reporting is_wsl=false",void 0,e),!1}}function kA(){return{version:r3,os:process.platform,os_version:EA.release(),is_wsl:s3(),arch:process.arch,runtime:process.versions.bun?"bun":"node",runtime_version:process.versions.bun??process.versions.node,node_version:process.versions.node,is_ci:!!process.env.CI,locale:Intl.DateTimeFormat().resolvedOptions().locale}}var r3,n3,i3,o3,_A=S(()=>{"use strict";Me();r3="13.12.4",n3="phc_BKJAeNbpj932N9qEiU6qhutZEiu6LLfRpXfTbLM9MLaG",i3="https://us.i.posthog.com";o3=["version","os","os_version","is_wsl","arch","runtime","locale","ide","provider","runtime_mode","install_method","claude_code_version","first_active_date","db_observation_count","db_session_count","db_summary_count","db_project_count","db_size_mb","install_age_days","obs_count_7d","obs_count_30d","days_since_last_obs"]});async function Ns(t,e,r){try{if(!gA(process.env,Ci()))return;let i=vA({...kA(),...e??{}});if(r?.person?i.$set=IA(i):i.$process_person_profile=!1,process.env.CLAUDE_MEM_TELEMETRY_DEBUG==="1"){process.stderr.write("[telemetry] "+JSON.stringify({event:t,properties:i})+`
102
102
  `);return}let n=wA(),o=new AbortController,s=setTimeout(()=>o.abort(),a3);try{await l3(n,t,i,o.signal)}finally{clearTimeout(s)}}catch{}}async function l3(t,e,r,i){await fetch(`${xA()}/capture/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:t,event:e,distinct_id:Od(),properties:r}),signal:i})}var a3,Kd=S(()=>{"use strict";Ad();SA();_A();a3=2e3});import{spawn as c3,spawnSync as u3}from"node:child_process";import{extname as Kb}from"node:path";function Oi(t,e,r){return c3(t,e??[],{windowsHide:!0,...r})}function p3(t){return`"${t.replace(/"/g,'""')}"`}function Rd(t){if(process.platform!=="win32")return null;try{let e=u3("where",[t],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],windowsHide:!0});if(e.status!==0||!e.stdout.trim())return null;let r=e.stdout.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);return r.find(i=>CA.has(Kb(i).toLowerCase()))??r.find(i=>d3.has(Kb(i).toLowerCase()))??r[0]??null}catch{return null}}function Ls(t,e,r,i=process.platform){let n={...i==="win32"?{windowsHide:!0}:{},...r};if(i==="win32"&&TA.has(Kb(t).toLowerCase())){let o=[t,...e].map(p3).join(" ");return{command:process.env.ComSpec??"cmd.exe",args:["/d","/s","/c",`"${o}"`],options:{...n,windowsVerbatimArguments:!0}}}return{command:t,args:[...e],options:n}}var TA,CA,d3,Ai=S(()=>{"use strict";TA=new Set([".cmd",".bat"]),CA=new Set([".exe",".com"]),d3=new Set([...CA,...TA])});function Us(t){return process.platform==="win32"?Math.round(t*nr.WINDOWS_MULTIPLIER):t}var nr,Fl=S(()=>{"use strict";nr={HEALTH_CHECK:3e3,API_REQUEST:3e4,HOOK_READINESS_WAIT:1e4,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5}});var KA={};Ce(KA,{SettingsDefaultsManager:()=>Fe});import{readFileSync as f3,existsSync as m3}from"fs";import{join as OA}from"path";import{homedir as AA,hostname as h3}from"os";var Fe,Vr=S(()=>{"use strict";Fl();un();Fe=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5-20251001",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_API_TIMEOUT_MS:String(Us(nr.API_REQUEST)),CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"subscription",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-flash-latest",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_BASE_URL:"",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_DATA_DIR:OA(AA(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_WELCOME_HINT_ENABLED:"true",CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED:"false",CLAUDE_MEM_FOLDER_USE_LOCAL_MD:"false",CLAUDE_MEM_TRANSCRIPTS_ENABLED:"true",CLAUDE_MEM_TRANSCRIPTS_CONFIG_PATH:OA(AA(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_CHROMA_PREWARM_TIMEOUT_MS:"120000",CLAUDE_MEM_CLOUD_SYNC_TOKEN:"",CLAUDE_MEM_CLOUD_SYNC_USER_ID:"",CLAUDE_MEM_CLOUD_SYNC_HUB_URL:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_ID:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_NAME:h3(),CLAUDE_MEM_CLOUD_SYNC_WS:"true",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_QUEUE_ENGINE:"sqlite",CLAUDE_MEM_REDIS_URL:"",CLAUDE_MEM_REDIS_HOST:"127.0.0.1",CLAUDE_MEM_REDIS_PORT:"6379",CLAUDE_MEM_REDIS_MODE:"external",CLAUDE_MEM_QUEUE_REDIS_PREFIX:`claude_mem_${process.env.CLAUDE_MEM_WORKER_PORT??String(37700+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_AUTH_MODE:"api-key",CLAUDE_MEM_RUNTIME:"worker",CLAUDE_MEM_SERVER_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_API_KEY:"",CLAUDE_MEM_SERVER_PROJECT_ID:"",CLAUDE_MEM_SERVER_BETA_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_BETA_API_KEY:"",CLAUDE_MEM_SERVER_BETA_PROJECT_ID:""};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return process.env[e]??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static applyEnvOverrides(e){let r={...e};for(let i of Object.keys(this.DEFAULTS))process.env[i]!==void 0&&(r[i]=process.env[i]);return r}static loadFromFile(e,r=!0){try{if(!m3(e)){let a=this.getAllDefaults();try{wt(e,a),console.warn("[SETTINGS] Created settings file with defaults:",e)}catch(l){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,l instanceof Error?l.message:String(l))}return r?this.applyEnvOverrides(a):a}let i=f3(e,"utf-8"),n=er(i),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{wt(e,o),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,a instanceof Error?a.message:String(a))}}let s={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))o[a]!==void 0&&(s[a]=o[a]);return r?this.applyEnvOverrides(s):s}catch(i){console.warn("[SETTINGS] Failed to load settings, using defaults:",e,i instanceof Error?i.message:String(i));let n=this.getAllDefaults();return r?this.applyEnvOverrides(n):n}}}});import{execFile as y3}from"child_process";import{promisify as g3}from"util";import{existsSync as cge,readFileSync as uge,writeFileSync as dge,mkdirSync as pge,unlinkSync as fge}from"fs";import{userInfo as hge}from"os";import{join as gge}from"path";var Sge,RA=S(()=>{"use strict";nt();Me();Sge=g3(y3)});import{existsSync as Rb,readFileSync as jA,writeFileSync as b3,mkdirSync as v3,chmodSync as DA}from"fs";import{parseEnv as S3}from"util";function PA(){return process.env.CLAUDE_MEM_ENV_FILE??yt.envFile()}function NA(t){return S3(t)}function E3(t){let e=["# claude-mem credentials","# This file stores keys and gateway settings for the claude-mem memory agent","# Edit this file or use claude-mem settings to configure",""];for(let[r,i]of Object.entries(t))if(i){let n=/[\s#=]/.test(i);e.push(`${r}=${n?`"${i}"`:i}`)}return e.join(`
103
103
  `)+`
104
- `}function ql(){let t=PA();if(!Rb(t))return{};try{let e=jA(t,"utf-8"),r=NA(e),i={};for(let n of MA)r[n]&&(i[n]=r[n]);return i}catch(e){return I.warn("ENV","Failed to load .env file",{path:t},e instanceof Error?e:new Error(String(e))),{}}}function zl(t){let e=PA(),r={};try{Rb(yt.dataDir())||v3(yt.dataDir(),{recursive:!0,mode:448}),DA(yt.dataDir(),448),r=Rb(e)?NA(jA(e,"utf-8")):{}}catch(n){let o=n instanceof Error?n:new Error(String(n));throw I.error("ENV","Failed to set up env directory or read existing env",{},o),o}let i={...r};for(let n of MA){let o=t[n];o!==void 0&&(o?i[n]=o:delete i[n])}try{b3(e,E3(i),{encoding:"utf-8",mode:384}),DA(e,384)}catch(n){throw I.error("ENV","Failed to save .env file",{path:e},n instanceof Error?n:new Error(String(n))),n}}var MA,LA=S(()=>{"use strict";Me();nt();RA();MA=["ANTHROPIC_API_KEY","ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN","GEMINI_API_KEY","OPENROUTER_API_KEY"]});function To(t=process.env){let e={};for(let[r,i]of Object.entries(t))if(i!==void 0){if(k3.has(r)){e[r]=i;continue}x3.has(r)||w3.some(n=>r.startsWith(n))||(e[r]=i)}return e}var w3,x3,I3,k3,Dd=S(()=>{"use strict";w3=["CLAUDECODE_","CLAUDE_CODE_"],x3=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),I3=new Set(["HTTP_PROXY","HTTPS_PROXY","ALL_PROXY","NO_PROXY","http_proxy","https_proxy","all_proxy","no_proxy","npm_config_proxy","npm_config_https_proxy","npm_config_noproxy"]),k3=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_USE_FOUNDRY","CLAUDE_CODE_SKIP_BEDROCK_AUTH","CLAUDE_CODE_SKIP_VERTEX_AUTH","CLAUDE_CODE_SKIP_FOUNDRY_AUTH","ANTHROPIC_BEDROCK_BASE_URL","AWS_REGION","AWS_PROFILE","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","ANTHROPIC_VERTEX_PROJECT_ID","CLOUD_ML_REGION","GOOGLE_APPLICATION_CREDENTIALS",...I3])});import{spawnSync as FA}from"child_process";import{existsSync as _3,mkdirSync as UA,readFileSync as qA,writeFileSync as T3}from"fs";import $A from"path";function Br(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(I.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return I.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}async function jd(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.every(i=>!Br(i.pid)))return;await new Promise(i=>setTimeout(i,100))}}function R3(t){let e=FA("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${t}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...To(process.env),LC_ALL:"C",LANG:"C"}});if(e.status===0){let r=e.stdout.trim();return r.length>0?r:null}return null}function D3(t){let e=JA.get(t);if(e&&Date.now()-e.capturedAtMs<K3)return e.token;let r=null;try{r=R3(t)}catch(i){I.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:t,error:i instanceof Error?i.message:String(i)}),r=null}return JA.set(t,{token:r,capturedAtMs:Date.now()}),r}function zA(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=qA(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let n=e.slice(r+2).split(" ")[19];return n&&/^\d+$/.test(n)?n:null}catch(e){return I.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return D3(t);try{let e=FA("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...To(process.env),LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return I.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function Mb(t){if(!t||!Br(t.pid))return!1;if(!t.startToken)return!0;let e=zA(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||I.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}function Pd(){return Db||(Db=new Pb),Db}function jb(){let t=j3.shift();t&&t()}var C3,O3,A3,K3,JA,Pb,Db,j3,$s=S(()=>{"use strict";Ai();Me();Dd();nt();C3=5e3,O3=1e3,A3=yt.supervisorRegistry();K3=5e3,JA=new Map;Pb=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=A3){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,UA($A.dirname(this.registryPath),{recursive:!0}),!_3(this.registryPath)){this.persist();return}try{let i=JSON.parse(qA(this.registryPath,"utf-8")).processes??{};for(let[n,o]of Object.entries(i))this.entries.set(n,o)}catch(r){r instanceof Error?I.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):I.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&I.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,i){this.initialize(),this.entries.set(e,r),i&&this.runtimeProcesses.set(e,i),this.persist()}unregister(e){this.initialize();let r=this.entries.get(e);this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist(),r?.type==="sdk"&&jb()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let i=Date.parse(e.startedAt),n=Date.parse(r.startedAt);return(Number.isNaN(i)?0:i)-(Number.isNaN(n)?0:n)})}getBySession(e){let r=String(e);return this.getAll().filter(i=>i.sessionId!==void 0&&String(i.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}pruneDeadEntries(){this.initialize();let e=0,r=0;for(let[i,n]of this.entries)Br(n.pid)||(this.entries.delete(i),this.runtimeProcesses.delete(i),e+=1,n.type==="sdk"&&(r+=1));e>0&&this.persist();for(let i=0;i<r;i+=1)jb();return e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let i=typeof e=="number"?e:Number(e)||void 0;I.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:i,pids:r.map(s=>s.pid)});let n=r.filter(s=>Br(s.pid));for(let s of n)try{typeof s.pgid=="number"&&process.platform!=="win32"?process.kill(-s.pgid,"SIGTERM"):process.kill(s.pid,"SIGTERM")}catch(a){a instanceof Error?a.code!=="ESRCH"&&I.debug("SYSTEM",`Failed to SIGTERM session process PID ${s.pid}`,{pid:s.pid,pgid:s.pgid},a):I.warn("SYSTEM",`Failed to SIGTERM session process PID ${s.pid} (non-Error)`,{pid:s.pid,pgid:s.pgid,error:String(a)})}await jd(n,C3);let o=n.filter(s=>Br(s.pid));for(let s of o){I.warn("SYSTEM",`Session process PID ${s.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:s.pid,pgid:s.pgid,sessionId:i});try{typeof s.pgid=="number"&&process.platform!=="win32"?process.kill(-s.pgid,"SIGKILL"):process.kill(s.pid,"SIGKILL")}catch(a){a instanceof Error?a.code!=="ESRCH"&&I.debug("SYSTEM",`Failed to SIGKILL session process PID ${s.pid}`,{pid:s.pid,pgid:s.pgid},a):I.warn("SYSTEM",`Failed to SIGKILL session process PID ${s.pid} (non-Error)`,{pid:s.pid,pgid:s.pgid,error:String(a)})}}if(o.length>0){let s=Date.now()+O3;for(;Date.now()<s&&o.filter(l=>Br(l.pid)).length!==0;)await new Promise(l=>setTimeout(l,100))}for(let s of r)this.entries.delete(s.id),this.runtimeProcesses.delete(s.id);this.persist();for(let s of r)s.type==="sdk"&&jb();return I.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:i,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};UA($A.dirname(this.registryPath),{recursive:!0}),T3(this.registryPath,JSON.stringify(e,null,2))}},Db=null;j3=[]});import{execFile as P3}from"child_process";import{existsSync as M3,readFileSync as N3,rmSync as L3}from"fs";import{promisify as U3}from"util";async function VA(t){let e=t.currentPid??process.pid,r=t.pidFilePath??J3,i=t.registry.getAll(),n=[...i].filter(s=>s.pid!==e).sort((s,a)=>Date.parse(a.startedAt)-Date.parse(s.startedAt));for(let s of n){if(!Br(s.pid)){t.registry.unregister(s.id);continue}try{await GA(s,"SIGTERM")}catch(a){a instanceof Error?I.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:s.pid,pgid:s.pgid,type:s.type},a):I.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:s.pid,pgid:s.pgid,type:s.type,error:String(a)})}}await jd(n,5e3);let o=n.filter(s=>Br(s.pid));for(let s of o)try{await GA(s,"SIGKILL")}catch(a){a instanceof Error?I.debug("SYSTEM","Failed to force kill child process",{pid:s.pid,pgid:s.pgid,type:s.type},a):I.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:s.pid,pgid:s.pgid,type:s.type,error:String(a)})}await jd(o,1e3);for(let s of n)t.registry.unregister(s.id);for(let s of i.filter(a=>a.pid===e))t.registry.unregister(s.id);BA(r,e),t.registry.pruneDeadEntries()}function BA(t,e,r=!1){if(!M3(t))return;let i=null;try{let s=JSON.parse(N3(t,"utf-8"));i=typeof s.pid=="number"?s.pid:null}catch(s){I.debug("SYSTEM","PID file unreadable \u2014 leaving it (cannot prove ownership)",{pidFilePath:t,error:s instanceof Error?s.message:String(s)});return}let n=e!==null&&i===e,o=i===null||!Br(i);if(!n&&!(r&&o)){I.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:t,recordedPid:i,currentPid:e});return}try{L3(t,{force:!0})}catch(s){s instanceof Error?I.debug("SYSTEM","Failed to remove PID file",{pidFilePath:t},s):I.warn("SYSTEM","Failed to remove PID file (non-Error)",{pidFilePath:t,error:String(s)})}}async function GA(t,e){let{pid:r,pgid:i}=t;if(process.platform!=="win32"){if(typeof i=="number")try{process.kill(-i,e);return}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}try{process.kill(r,e)}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(o){if(o instanceof Error&&o.code==="ESRCH")return;throw o}return}let n=["/PID",String(r),"/T"];e==="SIGKILL"&&n.push("/F"),await $3("taskkill",n,{timeout:nr.POWERSHELL_COMMAND,windowsHide:!0})}var $3,J3,Nb=S(()=>{"use strict";Me();Fl();$s();nt();$3=U3(P3),J3=yt.workerPid()});function F3(){let e=Pd().pruneDeadEntries();e>0&&I.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function ZA(){Js===null&&(Js=setInterval(F3,WA),Js.unref(),I.debug("SYSTEM","Health checker started",{intervalMs:WA}))}function HA(){Js!==null&&(clearInterval(Js),Js=null,I.debug("SYSTEM","Health checker stopped"))}var WA,Js,YA=S(()=>{"use strict";Me();$s();WA=3e4,Js=null});import{existsSync as q3,readFileSync as z3,rmSync as XA}from"fs";function Ub(){return V3}function Md(t={}){let e=t.pidFilePath??G3;if(!q3(e))return"missing";let r=null;try{r=JSON.parse(z3(e,"utf-8"))}catch(n){return n instanceof Error?I.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},n):I.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(n)}),XA(e,{force:!0}),"invalid"}return Mb(r)&&r?((t.logAlive??!0)&&I.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(I.info("SYSTEM","Removing stale PID file (worker process is dead or PID has been reused)",{pid:r?.pid,port:r?.port,startedAt:r?.startedAt}),XA(e,{force:!0}),"stale")}var G3,Lb,V3,Nd=S(()=>{"use strict";Me();$s();Nb();YA();nt();G3=yt.workerPid(),Lb=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),Md({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,ZA()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async i=>{if(this.shutdownInitiated){I.warn("SYSTEM",`Received ${i} but shutdown already in progress`);return}this.shutdownInitiated=!0,I.info("SYSTEM",`Received ${i}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(n){n instanceof Error?I.error("SYSTEM","Error during shutdown",{},n):I.error("SYSTEM","Error during shutdown (non-Error)",{error:String(n)});try{await this.stop()}catch(o){o instanceof Error?I.debug("SYSTEM","Supervisor shutdown fallback failed",{},o):I.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(o)})}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{I.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}HA(),this.stopPromise=VA({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,i){this.registry.register(e,r,i)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},V3=new Lb(Pd())});import{createHash as sbe,randomUUID as abe}from"crypto";var QA=S(()=>{"use strict";Me()});import{randomUUID as mbe}from"crypto";var eK=S(()=>{"use strict";Me();QA()});import Fs from"path";import{homedir as B3}from"os";import{existsSync as Jb,writeFileSync as xbe,readFileSync as Ibe,unlinkSync as kbe,mkdirSync as _be,statSync as Tbe,utimesSync as W3,copyFileSync as Cbe}from"fs";import{execSync as nK,spawnSync as Abe}from"child_process";function rK(t){return t?/(^|[\\/])bun(\.exe)?$/i.test(t.trim()):!1}function Z3(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,i;try{i=nK(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(o){return o instanceof Error?I.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},o):I.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},new Error(String(o))),null}return i.split(/\r?\n/).map(o=>o.trim()).find(o=>o.length>0)||null}function iK(t={}){let e=Object.keys(t).length===0;if(e&&$b!==void 0)return $b;let r=H3(t);return e&&r!==null&&($b=r),r}function H3(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(rK(r))return r;let i=t.env??process.env,n=t.homeDirectory??B3(),o=t.pathExists??Jb,s=t.lookupInPath??Z3,a=e==="win32"?[i.BUN,i.BUN_PATH,Fs.join(n,".bun","bin","bun.exe"),Fs.join(n,".bun","bin","bun"),i.USERPROFILE?Fs.join(i.USERPROFILE,".bun","bin","bun.exe"):void 0,i.LOCALAPPDATA?Fs.join(i.LOCALAPPDATA,"bun","bun.exe"):void 0,i.LOCALAPPDATA?Fs.join(i.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[i.BUN,i.BUN_PATH,Fs.join(n,".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun","/usr/bin/bun","/snap/bin/bun"];for(let l of a){let c=l?.trim();if(c&&(rK(c)&&o(c)||c.toLowerCase()==="bun"))return c}return s("bun",e)}function qs(t){return process.platform==="win32"?Math.round(t*2):t}function Y3(t,e){let r=i=>i.replace(/'/g,"''");return`Start-Process -FilePath '${r(t)}' -ArgumentList @('"${r(e)}"','--daemon') -WindowStyle Hidden`}function oK(t,e,r={}){Ub().assertCanSpawn("worker daemon");let i=To({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),n=iK();if(!n){I.error("SYSTEM","Bun runtime not found \u2014 install from https://bun.sh and ensure it is on PATH or set BUN env var. The worker daemon requires Bun because it uses bun:sqlite.");return}if(process.platform==="win32"){let u=Y3(n,t),d=Buffer.from(u,"utf16le").toString("base64");try{return nK(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:i}),0}catch(f){let p=f instanceof Error?f:new Error(String(f));I.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:n},p);return}}let o="/usr/bin/setsid",s=Jb(o),c=Oi(s?o:n,s?[n,t,"--daemon"]:[t,"--daemon"],{detached:!0,stdio:"ignore",env:i});if(c.pid!==void 0)return c.unref(),c.pid}function sK(){try{if(!Jb(tK))return;let t=new Date;W3(tK,t,t)}catch{}}function Ld(){return Md({logAlive:!1})}var Lbe,tK,$b,Ud=S(()=>{"use strict";Ai();Me();Dd();Nb();Nd();eK();nt();$s();Lbe=yt.dataDir(),tK=yt.workerPid()});import X3 from"net";function Fb(){return Fe.loadFromFile(ht).CLAUDE_MEM_WORKER_HOST}function aK(t){return t.startsWith("[")&&t.endsWith("]")?t:t.includes(":")?`[${t}]`:t}async function Q3(t,e,r="GET"){let i=await fetch(`http://${aK(Fb())}:${t}${e}`,{method:r}),n="";try{n=await i.text()}catch{}return{ok:i.ok,statusCode:i.status,body:n}}async function lK(t){if(process.platform==="win32")try{let e=await fetch(`http://${aK(Fb())}:${t}/api/health`);if(e.ok)return!0;I.debug("SYSTEM","Windows health check returned non-ok; falling through to socket probe",{port:t,status:e.status})}catch(e){e instanceof Error?I.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:t,message:e.message}):I.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:t,error:String(e)})}return new Promise(e=>{let r=X3.createServer(),i=Fb();r.once("error",n=>{n.code==="EADDRINUSE"?e(!0):e(!1)}),r.once("listening",()=>{r.close(()=>e(!1))}),r.listen(t,i)})}async function cK(t,e,r,i){let n=Date.now();for(;Date.now()-n<r;){try{if((await Q3(t,e)).ok)return!0}catch(o){o instanceof Error?I.debug("SYSTEM",i,{},o):I.debug("SYSTEM",i,{error:String(o)})}await new Promise(o=>setTimeout(o,500))}return!1}function Gl(t,e=3e4){return cK(t,"/api/health",e,"Service not ready yet, will retry")}function Vl(t,e=3e4){return cK(t,"/api/readiness",e,"Worker not ready yet, will retry")}var qb=S(()=>{"use strict";Me();Vr();nt()});import{dirname as eZ,join as tZ}from"path";import{mkdirSync as rZ,readFileSync as nZ,statSync as uK,unlinkSync as dK,writeFileSync as iZ}from"fs";function pK(){return tZ(Cn(),"spawn.lock")}function zb(){let t=pK(),e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return rZ(eZ(t),{recursive:!0}),iZ(t,e,{flag:"wx"}),!0}catch(i){let n=i instanceof Error?i:new Error(String(i)),o=n.code;if(o!=="EEXIST")return I.warn("SYSTEM","Spawn lock write failed for a non-contention reason; failing open (spawning unlocked)",{lockPath:t,code:o},n),!0;if(r>0)return!1;let s;try{s=uK(t).mtimeMs}catch{continue}if(Date.now()-s<=oZ)return!1;let a;try{a=uK(t).mtimeMs}catch{continue}if(a!==s)return!1;try{dK(t)}catch{return!1}}return!1}function Gb(){let t=pK();try{if(JSON.parse(nZ(t,"utf-8")).pid!==process.pid)return;dK(t)}catch{}}var oZ,Vb=S(()=>{"use strict";nt();Me();oZ=9e4});import fK from"path";import{existsSync as Bb,mkdirSync as sZ,writeFileSync as aZ,unlinkSync as lZ,statSync as cZ}from"fs";function Wb(){return fK.join(Fe.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function dZ(){if(process.platform!=="win32")return!1;let t=Wb();if(!Bb(t))return!1;try{let e=cZ(t).mtimeMs;return Date.now()-e<uZ}catch(e){return e instanceof Error?I.debug("SYSTEM","Could not stat worker spawn lock file",{},e):I.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(e)}),!1}}function pZ(){if(process.platform==="win32")try{let t=Wb();sZ(fK.dirname(t),{recursive:!0}),aZ(t,"","utf-8")}catch{}}function $d(){if(process.platform==="win32")try{let t=Wb();Bb(t)&&lZ(t)}catch{}}async function mK(t,e){if(!e)return I.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!Bb(e))return I.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(Ld()==="alive"){if(I.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Vl(t,qs(nr.READINESS_WAIT)))return $d(),I.info("SYSTEM","Worker became ready while waiting on live PID"),"ready";let a=await Gl(t,1e3),l=Ld()==="alive";return!a&&!l?(I.error("SYSTEM","Live PID disappeared before readiness endpoint became available"),"dead"):(I.warn("SYSTEM","Live PID detected but worker did not become ready before timeout"),"warming")}if(await Gl(t,1e3)){$d();let s=await Vl(t,qs(nr.READINESS_WAIT));return s||I.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),I.info("SYSTEM","Worker already running and healthy"),s?"ready":"warming"}if(await lK(t)){if(I.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Gl(t,qs(nr.PORT_IN_USE_WAIT))){$d();let a=await Vl(t,qs(nr.READINESS_WAIT));return I.info("SYSTEM","Worker is now healthy"),a?"ready":"warming"}return I.error("SYSTEM","Port in use but worker not responding to health checks"),"dead"}if(dZ())return I.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let n=zb(),o;try{if(n){if(I.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),pZ(),o=oK(e,t),o===void 0)return I.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else I.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await Vl(t,qs(nr.READINESS_WAIT))){let a=await Gl(t,1e3),l=Ld()==="alive",c=o!==void 0&&o>0&&Br(o);return!a&&!l&&!c?(I.error("SYSTEM",n?"Worker exited before readiness endpoint became available":"Spawn-lock holder never produced a live worker before readiness timed out"),"dead"):(I.warn("SYSTEM",n?"Worker spawned but readiness endpoint not responding within window":"Spawn-lock holder's worker not ready within window"),"warming")}return $d(),sK(),I.info("SYSTEM",n?"Worker started successfully":"Worker is up (started by another launcher)"),"ready"}finally{n&&Gb()}}var uZ,hK=S(()=>{"use strict";Me();Fl();Vr();Ud();qb();Vb();$s();uZ=120*1e3});var yK=S(()=>{"use strict";Vr();nt()});var gK=S(()=>{"use strict";Me();Nd()});var bK=S(()=>{"use strict";Ud();qb();gK()});import fZ from"path";import{readFileSync as wve,existsSync as xve,writeFileSync as Ive,renameSync as kve,mkdirSync as _ve,readdirSync as Tve,statSync as Cve}from"fs";function SK(t,e,r){let i=process.env[t];if(i){let n=parseInt(i,10);if(Number.isFinite(n)&&n>=r.min&&n<=r.max)return n;I.warn("SYSTEM",`Invalid ${t}, using default`,{value:i,min:r.min,max:r.max})}return e}async function hZ(t,e={},r){try{return await fetch(t,{...e,signal:AbortSignal.timeout(r)})}catch(i){throw i instanceof DOMException&&i.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):i}}function yZ(){return fZ.join(Fe.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function Zb(){return qd!==null||(qd=Fe.loadFromFile(yZ())),qd}function vK(t,e){if(!t)return null;let r=parseInt(t,10);return Number.isFinite(r)&&r>=e.min&&r<=e.max?r:null}function gZ(t,e,r){let i=process.env[t];if(i!==void 0){let s=vK(i,r);return s!==null?s:(I.warn("SYSTEM",`Invalid ${t}, using default`,{value:i,min:r.min,max:r.max}),e)}let n=Zb()[t],o=vK(n,r);return o!==null?o:(I.warn("SYSTEM",`Invalid ${t} in settings.json, using default`,{value:n,min:r.min,max:r.max}),e)}function Bl(){if(Jd!==null)return Jd;let t=Zb();return Jd=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),Jd}function Wl(){return Fd!==null||(Fd=Zb().CLAUDE_MEM_WORKER_HOST),Fd}function bZ(){return zd!==null||(zd=gZ("CLAUDE_MEM_API_TIMEOUT_MS",Us(nr.API_REQUEST),mZ)),zd}function Hb(t){return t.startsWith("[")&&t.endsWith("]")?t:t.includes(":")?`[${t}]`:t}function vZ(t){return`http://${Hb(Wl())}:${Bl()}${t}`}function Gd(t,e={}){let r=e.method??"GET",i=e.timeoutMs??bZ(),n=vZ(t),o={method:r};return e.headers&&(o.headers=e.headers),e.body&&(o.body=e.body),i>0?hZ(n,o,i):fetch(n,o)}var Jve,Fve,mZ,Jd,Fd,qd,zd,Zl=S(()=>{"use strict";Ai();Me();Fl();Vr();nt();yK();Nd();fd();Kd();bK();Ud();Vb();Jve=SK("CLAUDE_MEM_HEALTH_TIMEOUT_MS",Us(nr.HEALTH_CHECK),{min:500,max:3e5}),Fve=SK("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",Us(nr.HOOK_READINESS_WAIT),{min:0,max:3e5}),mZ={min:500,max:3e5};Jd=null,Fd=null,qd=null,zd=null});function zs(t){return t instanceof Error?t.message:typeof t=="string"?t:t&&typeof t=="object"&&"message"in t?String(t.message):String(t??"")}function EK(t,e){for(let r of Yb)if(r.match(t,e))return r;return Yb[Yb.length-1]}var SZ,EZ,Yb,Vd=S(()=>{"use strict";SZ=t=>t.platform==="win32"?'Install Bun manually then re-run `npx claude-mem install`. Windows: `winget install Oven-sh.Bun` (or `powershell -c "irm bun.sh/install.ps1 | iex"`).':"Install Bun manually then re-run `npx claude-mem install`. macOS/Linux: `curl -fsSL https://bun.sh/install | bash` (or `brew install oven-sh/bun/bun`).",EZ=t=>t.platform==="win32"?'Install uv manually then re-run `npx claude-mem install`. Windows: `winget install astral-sh.uv` (or `powershell -c "irm https://astral.sh/uv/install.ps1 | iex"`).':"Install uv manually then re-run `npx claude-mem install`. macOS/Linux: `curl -LsSf https://astral.sh/uv/install.sh | sh` (or `brew install uv`).",Yb=[{id:"bun-missing-after-install",severity:"ABORT",match:t=>{let e=zs(t);return e.includes("Bun executable not found")||e.includes("Bun installation completed but binary not found")||e.includes("Failed to install Bun")},remediation:SZ},{id:"uv-missing-after-install",severity:"ABORT",match:t=>{let e=zs(t);return e.includes("uv executable not found")||e.includes("uv installed but version probe failed")||e.includes("uv binary not found")||e.includes("Failed to install uv")},remediation:EZ},{id:"tree-sitter-eresolve",severity:"ABORT",match:t=>/\bERESOLVE\b/.test(zs(t)),remediation:()=>"ERESOLVE peer-dependency conflict in marketplace deps that --legacy-peer-deps could not resolve. Open an issue at https://github.com/thedotmack/claude-mem/issues with the conflicting peer ranges shown above."},{id:"marketplace-dir-not-writable",severity:"ABORT",match:t=>/\b(EACCES|EPERM)\b/.test(zs(t)),remediation:t=>`Cannot write to the claude-mem data/marketplace directory under ${t.dataDir}. Check filesystem permissions or set CLAUDE_MEM_DATA_DIR to a writable path, then re-run.`},{id:"plugin-json-corrupt",severity:"ABORT",match:(t,e)=>e.component==="plugin-json"&&/Unexpected token|JSON|parse/i.test(zs(t)),remediation:()=>"Existing plugin.json is corrupt. Run `rm -rf ~/.claude/plugins/marketplaces/thedotmack` and re-run `npx claude-mem install`."},{id:"all-ides-failed",severity:"ABORT",match:(t,e)=>e.component==="all-ides",remediation:()=>"Every selected IDE integration failed. See the per-IDE errors above. Re-run with `--ide=<single>` to isolate the failure."},{id:"single-ide-failed",severity:"FAIL_LOUD_PER_IDE",match:(t,e)=>e.phase==="ide-install",remediation:()=>"Re-run `npx claude-mem install --ide=<name>` to retry just this IDE. The captured stderr is shown above."},{id:"path-update-failed",severity:"WARN_CONTINUE",match:(t,e)=>e.component==="path-update",remediation:()=>"Could not auto-update PATH in your shell config. Add the printed export line manually and restart your shell."},{id:"auto-memory-toggle-failed",severity:"WARN_CONTINUE",match:(t,e)=>e.component==="auto-memory",remediation:()=>'Could not disable Claude Code auto-memory. Add `"CLAUDE_CODE_DISABLE_AUTO_MEMORY": "1"` to the env block in ~/.claude/settings.json.'},{id:"version-probe-transient",severity:"WARN_CONTINUE",match:(t,e)=>e.component.endsWith("-version-probe"),remediation:()=>"Could not verify the tool version after install \u2014 the installation is likely OK. Re-run `npx claude-mem install` if features misbehave."},{id:"child-process-timeout",severity:"ABORT",match:t=>/timed out|ETIMEDOUT|SIGTERM|did not finish/i.test(zs(t)),remediation:()=>"An install command did not finish in time. Check network connectivity. On a slow host, raise the budget with CLAUDE_MEM_INSTALL_TIMEOUT_MS and re-run."},{id:"unknown-install-error",severity:"ABORT",match:()=>!0,remediation:t=>`An unexpected installer error occurred. Capture ${t.dataDir}/last-install-error.json and open an issue at https://github.com/thedotmack/claude-mem/issues.`}]});import{mkdirSync as wZ,writeFileSync as xZ}from"fs";import{join as IZ}from"path";function Xb(){return{warnings:[],failedIDEs:[]}}function Hl(t){return t instanceof Error?t.message:typeof t=="string"?t:String(t??"")}function kZ(t,e,r,i){let n={severity:t.severity,categoryId:t.id,component:e.component,phase:e.phase,cause:Hl(e.cause),remediation:r,details:e.details??null,timestamp:new Date().toISOString()};try{wZ(i,{recursive:!0}),xZ(IZ(i,"last-install-error.json"),JSON.stringify(n,null,2))}catch{}}function zt(t,e,r){let i=Cn(),n=EK(e.cause,{component:e.component,phase:e.phase}),o=e.remediation??n.remediation({platform:process.platform,dataDir:i});switch(t){case"ABORT":throw kZ(n,e,o,i),new Gs(`${e.component} failed during ${e.phase}: ${Hl(e.cause)}`,{category:n,remediation:o,cause:e.cause});case"FAIL_LOUD_PER_IDE":{let s=e.ide??e.component;r.failedIDEs.includes(s)||r.failedIDEs.push(s),r.warnings.push({component:s,message:e.details?`${Hl(e.cause)}
104
+ `}function ql(){let t=PA();if(!Rb(t))return{};try{let e=jA(t,"utf-8"),r=NA(e),i={};for(let n of MA)r[n]&&(i[n]=r[n]);return i}catch(e){return I.warn("ENV","Failed to load .env file",{path:t},e instanceof Error?e:new Error(String(e))),{}}}function zl(t){let e=PA(),r={};try{Rb(yt.dataDir())||v3(yt.dataDir(),{recursive:!0,mode:448}),DA(yt.dataDir(),448),r=Rb(e)?NA(jA(e,"utf-8")):{}}catch(n){let o=n instanceof Error?n:new Error(String(n));throw I.error("ENV","Failed to set up env directory or read existing env",{},o),o}let i={...r};for(let n of MA){let o=t[n];o!==void 0&&(o?i[n]=o:delete i[n])}try{b3(e,E3(i),{encoding:"utf-8",mode:384}),DA(e,384)}catch(n){throw I.error("ENV","Failed to save .env file",{path:e},n instanceof Error?n:new Error(String(n))),n}}var MA,LA=S(()=>{"use strict";Me();nt();RA();MA=["ANTHROPIC_API_KEY","ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN","GEMINI_API_KEY","OPENROUTER_API_KEY"]});function To(t=process.env){let e={};for(let[r,i]of Object.entries(t))if(i!==void 0){if(k3.has(r)){e[r]=i;continue}x3.has(r)||w3.some(n=>r.startsWith(n))||(e[r]=i)}return e}var w3,x3,I3,k3,Dd=S(()=>{"use strict";w3=["CLAUDECODE_","CLAUDE_CODE_"],x3=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),I3=new Set(["HTTP_PROXY","HTTPS_PROXY","ALL_PROXY","NO_PROXY","http_proxy","https_proxy","all_proxy","no_proxy","npm_config_proxy","npm_config_https_proxy","npm_config_noproxy"]),k3=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_USE_FOUNDRY","CLAUDE_CODE_SKIP_BEDROCK_AUTH","CLAUDE_CODE_SKIP_VERTEX_AUTH","CLAUDE_CODE_SKIP_FOUNDRY_AUTH","ANTHROPIC_BEDROCK_BASE_URL","AWS_REGION","AWS_PROFILE","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","ANTHROPIC_VERTEX_PROJECT_ID","CLOUD_ML_REGION","GOOGLE_APPLICATION_CREDENTIALS",...I3])});import{spawnSync as FA}from"child_process";import{existsSync as _3,mkdirSync as UA,readFileSync as qA,writeFileSync as T3}from"fs";import $A from"path";function Br(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(I.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return I.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}async function jd(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.every(i=>!Br(i.pid)))return;await new Promise(i=>setTimeout(i,100))}}function R3(t){let e=FA("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${t}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...To(process.env),LC_ALL:"C",LANG:"C"}});if(e.status===0){let r=e.stdout.trim();return r.length>0?r:null}return null}function D3(t){let e=JA.get(t);if(e&&Date.now()-e.capturedAtMs<K3)return e.token;let r=null;try{r=R3(t)}catch(i){I.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:t,error:i instanceof Error?i.message:String(i)}),r=null}return JA.set(t,{token:r,capturedAtMs:Date.now()}),r}function zA(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=qA(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let n=e.slice(r+2).split(" ")[19];return n&&/^\d+$/.test(n)?n:null}catch(e){return I.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return D3(t);try{let e=FA("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...To(process.env),LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return I.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function Mb(t){if(!t||!Br(t.pid))return!1;if(!t.startToken)return!0;let e=zA(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||I.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}function Pd(){return Db||(Db=new Pb),Db}function jb(){let t=j3.shift();t&&t()}var C3,O3,A3,K3,JA,Pb,Db,j3,$s=S(()=>{"use strict";Ai();Me();Dd();nt();C3=5e3,O3=1e3,A3=yt.supervisorRegistry();K3=5e3,JA=new Map;Pb=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=A3){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,UA($A.dirname(this.registryPath),{recursive:!0}),!_3(this.registryPath)){this.persist();return}try{let i=JSON.parse(qA(this.registryPath,"utf-8")).processes??{};for(let[n,o]of Object.entries(i))this.entries.set(n,o)}catch(r){r instanceof Error?I.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):I.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&I.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,i){this.initialize(),this.entries.set(e,r),i&&this.runtimeProcesses.set(e,i),this.persist()}unregister(e){this.initialize();let r=this.entries.get(e);this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist(),r?.type==="sdk"&&jb()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let i=Date.parse(e.startedAt),n=Date.parse(r.startedAt);return(Number.isNaN(i)?0:i)-(Number.isNaN(n)?0:n)})}getBySession(e){let r=String(e);return this.getAll().filter(i=>i.sessionId!==void 0&&String(i.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}pruneDeadEntries(){this.initialize();let e=0,r=0;for(let[i,n]of this.entries)Br(n.pid)||(this.entries.delete(i),this.runtimeProcesses.delete(i),e+=1,n.type==="sdk"&&(r+=1));e>0&&this.persist();for(let i=0;i<r;i+=1)jb();return e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let i=typeof e=="number"?e:Number(e)||void 0;I.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:i,pids:r.map(s=>s.pid)});let n=r.filter(s=>Br(s.pid));for(let s of n)try{typeof s.pgid=="number"&&process.platform!=="win32"?process.kill(-s.pgid,"SIGTERM"):process.kill(s.pid,"SIGTERM")}catch(a){a instanceof Error?a.code!=="ESRCH"&&I.debug("SYSTEM",`Failed to SIGTERM session process PID ${s.pid}`,{pid:s.pid,pgid:s.pgid},a):I.warn("SYSTEM",`Failed to SIGTERM session process PID ${s.pid} (non-Error)`,{pid:s.pid,pgid:s.pgid,error:String(a)})}await jd(n,C3);let o=n.filter(s=>Br(s.pid));for(let s of o){I.warn("SYSTEM",`Session process PID ${s.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:s.pid,pgid:s.pgid,sessionId:i});try{typeof s.pgid=="number"&&process.platform!=="win32"?process.kill(-s.pgid,"SIGKILL"):process.kill(s.pid,"SIGKILL")}catch(a){a instanceof Error?a.code!=="ESRCH"&&I.debug("SYSTEM",`Failed to SIGKILL session process PID ${s.pid}`,{pid:s.pid,pgid:s.pgid},a):I.warn("SYSTEM",`Failed to SIGKILL session process PID ${s.pid} (non-Error)`,{pid:s.pid,pgid:s.pgid,error:String(a)})}}if(o.length>0){let s=Date.now()+O3;for(;Date.now()<s&&o.filter(l=>Br(l.pid)).length!==0;)await new Promise(l=>setTimeout(l,100))}for(let s of r)this.entries.delete(s.id),this.runtimeProcesses.delete(s.id);this.persist();for(let s of r)s.type==="sdk"&&jb();return I.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:i,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};UA($A.dirname(this.registryPath),{recursive:!0}),T3(this.registryPath,JSON.stringify(e,null,2))}},Db=null;j3=[]});import{execFile as P3}from"child_process";import{existsSync as M3,readFileSync as N3,rmSync as L3}from"fs";import{promisify as U3}from"util";async function VA(t){let e=t.currentPid??process.pid,r=t.pidFilePath??J3,i=t.registry.getAll(),n=[...i].filter(s=>s.pid!==e).sort((s,a)=>Date.parse(a.startedAt)-Date.parse(s.startedAt));for(let s of n){if(!Br(s.pid)){t.registry.unregister(s.id);continue}try{await GA(s,"SIGTERM")}catch(a){a instanceof Error?I.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:s.pid,pgid:s.pgid,type:s.type},a):I.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:s.pid,pgid:s.pgid,type:s.type,error:String(a)})}}await jd(n,5e3);let o=n.filter(s=>Br(s.pid));for(let s of o)try{await GA(s,"SIGKILL")}catch(a){a instanceof Error?I.debug("SYSTEM","Failed to force kill child process",{pid:s.pid,pgid:s.pgid,type:s.type},a):I.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:s.pid,pgid:s.pgid,type:s.type,error:String(a)})}await jd(o,1e3);for(let s of n)t.registry.unregister(s.id);for(let s of i.filter(a=>a.pid===e))t.registry.unregister(s.id);BA(r,e),t.registry.pruneDeadEntries()}function BA(t,e,r=!1){if(!M3(t))return;let i=null;try{let s=JSON.parse(N3(t,"utf-8"));i=typeof s.pid=="number"?s.pid:null}catch(s){I.debug("SYSTEM","PID file unreadable \u2014 leaving it (cannot prove ownership)",{pidFilePath:t,error:s instanceof Error?s.message:String(s)});return}let n=e!==null&&i===e,o=i===null||!Br(i);if(!n&&!(r&&o)){I.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:t,recordedPid:i,currentPid:e});return}try{L3(t,{force:!0})}catch(s){s instanceof Error?I.debug("SYSTEM","Failed to remove PID file",{pidFilePath:t},s):I.warn("SYSTEM","Failed to remove PID file (non-Error)",{pidFilePath:t,error:String(s)})}}async function GA(t,e){let{pid:r,pgid:i}=t;if(process.platform!=="win32"){if(typeof i=="number")try{process.kill(-i,e);return}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}try{process.kill(r,e)}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(o){if(o instanceof Error&&o.code==="ESRCH")return;throw o}return}let n=["/PID",String(r),"/T"];e==="SIGKILL"&&n.push("/F"),await $3("taskkill",n,{timeout:nr.POWERSHELL_COMMAND,windowsHide:!0})}var $3,J3,Nb=S(()=>{"use strict";Me();Fl();$s();nt();$3=U3(P3),J3=yt.workerPid()});function F3(){let e=Pd().pruneDeadEntries();e>0&&I.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function ZA(){Js===null&&(Js=setInterval(F3,WA),Js.unref(),I.debug("SYSTEM","Health checker started",{intervalMs:WA}))}function HA(){Js!==null&&(clearInterval(Js),Js=null,I.debug("SYSTEM","Health checker stopped"))}var WA,Js,YA=S(()=>{"use strict";Me();$s();WA=3e4,Js=null});import{existsSync as q3,readFileSync as z3,rmSync as XA}from"fs";function Ub(){return V3}function Md(t={}){let e=t.pidFilePath??G3;if(!q3(e))return"missing";let r=null;try{r=JSON.parse(z3(e,"utf-8"))}catch(n){return n instanceof Error?I.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},n):I.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(n)}),XA(e,{force:!0}),"invalid"}return Mb(r)&&r?((t.logAlive??!0)&&I.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(I.info("SYSTEM","Removing stale PID file (worker process is dead or PID has been reused)",{pid:r?.pid,port:r?.port,startedAt:r?.startedAt}),XA(e,{force:!0}),"stale")}var G3,Lb,V3,Nd=S(()=>{"use strict";Me();$s();Nb();YA();nt();G3=yt.workerPid(),Lb=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),Md({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,ZA()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async i=>{if(this.shutdownInitiated){I.warn("SYSTEM",`Received ${i} but shutdown already in progress`);return}this.shutdownInitiated=!0,I.info("SYSTEM",`Received ${i}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(n){n instanceof Error?I.error("SYSTEM","Error during shutdown",{},n):I.error("SYSTEM","Error during shutdown (non-Error)",{error:String(n)});try{await this.stop()}catch(o){o instanceof Error?I.debug("SYSTEM","Supervisor shutdown fallback failed",{},o):I.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(o)})}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{I.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}HA(),this.stopPromise=VA({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,i){this.registry.register(e,r,i)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},V3=new Lb(Pd())});import{createHash as sbe,randomUUID as abe}from"crypto";var QA=S(()=>{"use strict";Me()});import{randomUUID as mbe}from"crypto";var eK=S(()=>{"use strict";Me();QA()});import Fs from"path";import{homedir as B3}from"os";import{existsSync as Jb,writeFileSync as xbe,readFileSync as Ibe,unlinkSync as kbe,mkdirSync as _be,statSync as Tbe,utimesSync as W3,copyFileSync as Cbe}from"fs";import{execSync as nK,spawnSync as Abe}from"child_process";function rK(t){return t?/(^|[\\/])bun(\.exe)?$/i.test(t.trim()):!1}function Z3(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,i;try{i=nK(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(o){return o instanceof Error?I.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},o):I.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},new Error(String(o))),null}return i.split(/\r?\n/).map(o=>o.trim()).find(o=>o.length>0)||null}function iK(t={}){let e=Object.keys(t).length===0;if(e&&$b!==void 0)return $b;let r=H3(t);return e&&r!==null&&($b=r),r}function H3(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(rK(r))return r;let i=t.env??process.env,n=t.homeDirectory??B3(),o=t.pathExists??Jb,s=t.lookupInPath??Z3,a=e==="win32"?[i.BUN,i.BUN_PATH,Fs.join(n,".bun","bin","bun.exe"),Fs.join(n,".bun","bin","bun"),i.USERPROFILE?Fs.join(i.USERPROFILE,".bun","bin","bun.exe"):void 0,i.LOCALAPPDATA?Fs.join(i.LOCALAPPDATA,"bun","bun.exe"):void 0,i.LOCALAPPDATA?Fs.join(i.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[i.BUN,i.BUN_PATH,Fs.join(n,".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun","/usr/bin/bun","/snap/bin/bun"];for(let l of a){let c=l?.trim();if(c&&(rK(c)&&o(c)||c.toLowerCase()==="bun"))return c}return s("bun",e)}function qs(t){return process.platform==="win32"?Math.round(t*2):t}function Y3(t,e){let r=i=>i.replace(/'/g,"''");return`Start-Process -FilePath '${r(t)}' -ArgumentList @('"${r(e)}"','--daemon') -WindowStyle Hidden`}function oK(t,e,r={}){Ub().assertCanSpawn("worker daemon");let i=To({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),n=iK();if(!n){I.error("SYSTEM","Bun runtime not found \u2014 install from https://bun.sh and ensure it is on PATH or set BUN env var. The worker daemon requires Bun because it uses bun:sqlite.");return}if(process.platform==="win32"){let u=Y3(n,t),d=Buffer.from(u,"utf16le").toString("base64");try{return nK(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:i}),0}catch(f){let p=f instanceof Error?f:new Error(String(f));I.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:n},p);return}}let o="/usr/bin/setsid",s=Jb(o),c=Oi(s?o:n,s?[n,t,"--daemon"]:[t,"--daemon"],{detached:!0,stdio:"ignore",env:i});if(c.pid!==void 0)return c.unref(),c.pid}function sK(){try{if(!Jb(tK))return;let t=new Date;W3(tK,t,t)}catch{}}function Ld(){return Md({logAlive:!1})}var Lbe,tK,$b,Ud=S(()=>{"use strict";Ai();Me();Dd();Nb();Nd();eK();nt();$s();Lbe=yt.dataDir(),tK=yt.workerPid()});import X3 from"net";function Fb(){return Fe.loadFromFile(ht).CLAUDE_MEM_WORKER_HOST}function aK(t){return t.startsWith("[")&&t.endsWith("]")?t:t.includes(":")?`[${t}]`:t}async function Q3(t,e,r="GET"){let i=await fetch(`http://${aK(Fb())}:${t}${e}`,{method:r}),n="";try{n=await i.text()}catch{}return{ok:i.ok,statusCode:i.status,body:n}}async function lK(t){if(process.platform==="win32")try{let e=await fetch(`http://${aK(Fb())}:${t}/api/health`);if(e.ok)return!0;I.debug("SYSTEM","Windows health check returned non-ok; falling through to socket probe",{port:t,status:e.status})}catch(e){e instanceof Error?I.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:t,message:e.message}):I.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:t,error:String(e)})}return new Promise(e=>{let r=X3.createServer(),i=Fb();r.once("error",n=>{n.code==="EADDRINUSE"?e(!0):e(!1)}),r.once("listening",()=>{r.close(()=>e(!1))}),r.listen(t,i)})}async function cK(t,e,r,i){let n=Date.now();for(;Date.now()-n<r;){try{if((await Q3(t,e)).ok)return!0}catch(o){o instanceof Error?I.debug("SYSTEM",i,{},o):I.debug("SYSTEM",i,{error:String(o)})}await new Promise(o=>setTimeout(o,500))}return!1}function Gl(t,e=3e4){return cK(t,"/api/health",e,"Service not ready yet, will retry")}function Vl(t,e=3e4){return cK(t,"/api/readiness",e,"Worker not ready yet, will retry")}var qb=S(()=>{"use strict";Me();Vr();nt()});import{dirname as eZ,join as tZ}from"path";import{mkdirSync as rZ,readFileSync as nZ,statSync as uK,unlinkSync as dK,writeFileSync as iZ}from"fs";function pK(){return tZ(Cn(),"spawn.lock")}function zb(){let t=pK(),e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return rZ(eZ(t),{recursive:!0}),iZ(t,e,{flag:"wx"}),!0}catch(i){let n=i instanceof Error?i:new Error(String(i)),o=n.code;if(o!=="EEXIST")return I.warn("SYSTEM","Spawn lock write failed for a non-contention reason; failing open (spawning unlocked)",{lockPath:t,code:o},n),!0;if(r>0)return!1;let s;try{s=uK(t).mtimeMs}catch{continue}if(Date.now()-s<=oZ)return!1;let a;try{a=uK(t).mtimeMs}catch{continue}if(a!==s)return!1;try{dK(t)}catch{return!1}}return!1}function Gb(){let t=pK();try{if(JSON.parse(nZ(t,"utf-8")).pid!==process.pid)return;dK(t)}catch{}}var oZ,Vb=S(()=>{"use strict";nt();Me();oZ=9e4});import fK from"path";import{existsSync as Bb,mkdirSync as sZ,writeFileSync as aZ,unlinkSync as lZ,statSync as cZ}from"fs";function Wb(){return fK.join(Fe.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function dZ(){if(process.platform!=="win32")return!1;let t=Wb();if(!Bb(t))return!1;try{let e=cZ(t).mtimeMs;return Date.now()-e<uZ}catch(e){return e instanceof Error?I.debug("SYSTEM","Could not stat worker spawn lock file",{},e):I.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(e)}),!1}}function pZ(){if(process.platform==="win32")try{let t=Wb();sZ(fK.dirname(t),{recursive:!0}),aZ(t,"","utf-8")}catch{}}function $d(){if(process.platform==="win32")try{let t=Wb();Bb(t)&&lZ(t)}catch{}}async function mK(t,e){if(!e)return I.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!Bb(e))return I.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(Ld()==="alive"){if(I.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Vl(t,qs(nr.READINESS_WAIT)))return $d(),I.info("SYSTEM","Worker became ready while waiting on live PID"),"ready";let a=await Gl(t,1e3),l=Ld()==="alive";return!a&&!l?(I.error("SYSTEM","Live PID disappeared before readiness endpoint became available"),"dead"):(I.warn("SYSTEM","Live PID detected but worker did not become ready before timeout"),"warming")}if(await Gl(t,1e3)){$d();let s=await Vl(t,qs(nr.READINESS_WAIT));return s||I.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),I.info("SYSTEM","Worker already running and healthy"),s?"ready":"warming"}if(await lK(t)){if(I.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Gl(t,qs(nr.PORT_IN_USE_WAIT))){$d();let a=await Vl(t,qs(nr.READINESS_WAIT));return I.info("SYSTEM","Worker is now healthy"),a?"ready":"warming"}return I.error("SYSTEM","Port in use but worker not responding to health checks"),"dead"}if(dZ())return I.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let n=zb(),o;try{if(n){if(I.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),pZ(),o=oK(e,t),o===void 0)return I.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else I.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await Vl(t,qs(nr.READINESS_WAIT))){let a=await Gl(t,1e3),l=Ld()==="alive",c=o!==void 0&&o>0&&Br(o);return!a&&!l&&!c?(I.error("SYSTEM",n?"Worker exited before readiness endpoint became available":"Spawn-lock holder never produced a live worker before readiness timed out"),"dead"):(I.warn("SYSTEM",n?"Worker spawned but readiness endpoint not responding within window":"Spawn-lock holder's worker not ready within window"),"warming")}return $d(),sK(),I.info("SYSTEM",n?"Worker started successfully":"Worker is up (started by another launcher)"),"ready"}finally{n&&Gb()}}var uZ,hK=S(()=>{"use strict";Me();Fl();Vr();Ud();qb();Vb();$s();uZ=120*1e3});var yK=S(()=>{"use strict";Vr();nt()});var gK=S(()=>{"use strict";Me();Nd()});var bK=S(()=>{"use strict";Ud();qb();gK()});import fZ from"path";import{readFileSync as xve,existsSync as Ive,writeFileSync as kve,renameSync as _ve,mkdirSync as Tve,readdirSync as Cve,statSync as Ove}from"fs";function SK(t,e,r){let i=process.env[t];if(i){let n=parseInt(i,10);if(Number.isFinite(n)&&n>=r.min&&n<=r.max)return n;I.warn("SYSTEM",`Invalid ${t}, using default`,{value:i,min:r.min,max:r.max})}return e}async function hZ(t,e={},r){try{return await fetch(t,{...e,signal:AbortSignal.timeout(r)})}catch(i){throw i instanceof DOMException&&i.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):i}}function yZ(){return fZ.join(Fe.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function Zb(){return qd!==null||(qd=Fe.loadFromFile(yZ())),qd}function vK(t,e){if(!t)return null;let r=parseInt(t,10);return Number.isFinite(r)&&r>=e.min&&r<=e.max?r:null}function gZ(t,e,r){let i=process.env[t];if(i!==void 0){let s=vK(i,r);return s!==null?s:(I.warn("SYSTEM",`Invalid ${t}, using default`,{value:i,min:r.min,max:r.max}),e)}let n=Zb()[t],o=vK(n,r);return o!==null?o:(I.warn("SYSTEM",`Invalid ${t} in settings.json, using default`,{value:n,min:r.min,max:r.max}),e)}function Bl(){if(Jd!==null)return Jd;let t=Zb();return Jd=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),Jd}function Wl(){return Fd!==null||(Fd=Zb().CLAUDE_MEM_WORKER_HOST),Fd}function bZ(){return zd!==null||(zd=gZ("CLAUDE_MEM_API_TIMEOUT_MS",Us(nr.API_REQUEST),mZ)),zd}function Hb(t){return t.startsWith("[")&&t.endsWith("]")?t:t.includes(":")?`[${t}]`:t}function vZ(t){return`http://${Hb(Wl())}:${Bl()}${t}`}function Gd(t,e={}){let r=e.method??"GET",i=e.timeoutMs??bZ(),n=vZ(t),o={method:r};return e.headers&&(o.headers=e.headers),e.body&&(o.body=e.body),i>0?hZ(n,o,i):fetch(n,o)}var Fve,qve,mZ,Jd,Fd,qd,zd,Zl=S(()=>{"use strict";Ai();Me();Fl();Vr();nt();yK();Nd();fd();Kd();bK();Ud();Vb();Fve=SK("CLAUDE_MEM_HEALTH_TIMEOUT_MS",Us(nr.HEALTH_CHECK),{min:500,max:3e5}),qve=SK("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",Us(nr.HOOK_READINESS_WAIT),{min:0,max:3e5}),mZ={min:500,max:3e5};Jd=null,Fd=null,qd=null,zd=null});function zs(t){return t instanceof Error?t.message:typeof t=="string"?t:t&&typeof t=="object"&&"message"in t?String(t.message):String(t??"")}function EK(t,e){for(let r of Yb)if(r.match(t,e))return r;return Yb[Yb.length-1]}var SZ,EZ,Yb,Vd=S(()=>{"use strict";SZ=t=>t.platform==="win32"?'Install Bun manually then re-run `npx claude-mem install`. Windows: `winget install Oven-sh.Bun` (or `powershell -c "irm bun.sh/install.ps1 | iex"`).':"Install Bun manually then re-run `npx claude-mem install`. macOS/Linux: `curl -fsSL https://bun.sh/install | bash` (or `brew install oven-sh/bun/bun`).",EZ=t=>t.platform==="win32"?'Install uv manually then re-run `npx claude-mem install`. Windows: `winget install astral-sh.uv` (or `powershell -c "irm https://astral.sh/uv/install.ps1 | iex"`).':"Install uv manually then re-run `npx claude-mem install`. macOS/Linux: `curl -LsSf https://astral.sh/uv/install.sh | sh` (or `brew install uv`).",Yb=[{id:"bun-missing-after-install",severity:"ABORT",match:t=>{let e=zs(t);return e.includes("Bun executable not found")||e.includes("Bun installation completed but binary not found")||e.includes("Failed to install Bun")},remediation:SZ},{id:"uv-missing-after-install",severity:"ABORT",match:t=>{let e=zs(t);return e.includes("uv executable not found")||e.includes("uv installed but version probe failed")||e.includes("uv binary not found")||e.includes("Failed to install uv")},remediation:EZ},{id:"tree-sitter-eresolve",severity:"ABORT",match:t=>/\bERESOLVE\b/.test(zs(t)),remediation:()=>"ERESOLVE peer-dependency conflict in marketplace deps that --legacy-peer-deps could not resolve. Open an issue at https://github.com/thedotmack/claude-mem/issues with the conflicting peer ranges shown above."},{id:"marketplace-dir-not-writable",severity:"ABORT",match:t=>/\b(EACCES|EPERM)\b/.test(zs(t)),remediation:t=>`Cannot write to the claude-mem data/marketplace directory under ${t.dataDir}. Check filesystem permissions or set CLAUDE_MEM_DATA_DIR to a writable path, then re-run.`},{id:"plugin-json-corrupt",severity:"ABORT",match:(t,e)=>e.component==="plugin-json"&&/Unexpected token|JSON|parse/i.test(zs(t)),remediation:()=>"Existing plugin.json is corrupt. Run `rm -rf ~/.claude/plugins/marketplaces/thedotmack` and re-run `npx claude-mem install`."},{id:"all-ides-failed",severity:"ABORT",match:(t,e)=>e.component==="all-ides",remediation:()=>"Every selected IDE integration failed. See the per-IDE errors above. Re-run with `--ide=<single>` to isolate the failure."},{id:"single-ide-failed",severity:"FAIL_LOUD_PER_IDE",match:(t,e)=>e.phase==="ide-install",remediation:()=>"Re-run `npx claude-mem install --ide=<name>` to retry just this IDE. The captured stderr is shown above."},{id:"path-update-failed",severity:"WARN_CONTINUE",match:(t,e)=>e.component==="path-update",remediation:()=>"Could not auto-update PATH in your shell config. Add the printed export line manually and restart your shell."},{id:"auto-memory-toggle-failed",severity:"WARN_CONTINUE",match:(t,e)=>e.component==="auto-memory",remediation:()=>'Could not disable Claude Code auto-memory. Add `"CLAUDE_CODE_DISABLE_AUTO_MEMORY": "1"` to the env block in ~/.claude/settings.json.'},{id:"version-probe-transient",severity:"WARN_CONTINUE",match:(t,e)=>e.component.endsWith("-version-probe"),remediation:()=>"Could not verify the tool version after install \u2014 the installation is likely OK. Re-run `npx claude-mem install` if features misbehave."},{id:"child-process-timeout",severity:"ABORT",match:t=>/timed out|ETIMEDOUT|SIGTERM|did not finish/i.test(zs(t)),remediation:()=>"An install command did not finish in time. Check network connectivity. On a slow host, raise the budget with CLAUDE_MEM_INSTALL_TIMEOUT_MS and re-run."},{id:"unknown-install-error",severity:"ABORT",match:()=>!0,remediation:t=>`An unexpected installer error occurred. Capture ${t.dataDir}/last-install-error.json and open an issue at https://github.com/thedotmack/claude-mem/issues.`}]});import{mkdirSync as wZ,writeFileSync as xZ}from"fs";import{join as IZ}from"path";function Xb(){return{warnings:[],failedIDEs:[]}}function Hl(t){return t instanceof Error?t.message:typeof t=="string"?t:String(t??"")}function kZ(t,e,r,i){let n={severity:t.severity,categoryId:t.id,component:e.component,phase:e.phase,cause:Hl(e.cause),remediation:r,details:e.details??null,timestamp:new Date().toISOString()};try{wZ(i,{recursive:!0}),xZ(IZ(i,"last-install-error.json"),JSON.stringify(n,null,2))}catch{}}function zt(t,e,r){let i=Cn(),n=EK(e.cause,{component:e.component,phase:e.phase}),o=e.remediation??n.remediation({platform:process.platform,dataDir:i});switch(t){case"ABORT":throw kZ(n,e,o,i),new Gs(`${e.component} failed during ${e.phase}: ${Hl(e.cause)}`,{category:n,remediation:o,cause:e.cause});case"FAIL_LOUD_PER_IDE":{let s=e.ide??e.component;r.failedIDEs.includes(s)||r.failedIDEs.push(s),r.warnings.push({component:s,message:e.details?`${Hl(e.cause)}
105
105
  ${e.details}`:Hl(e.cause),remediation:o});return}case"WARN_CONTINUE":{r.warnings.push({component:e.component,message:Hl(e.cause),remediation:o});return}}}function Yl(t,e){if(t.warnings.length!==0){e(""),e("Warnings & remediation:");for(let r of t.warnings)e(` \u2022 [${r.component}] ${r.message}`),r.remediation&&r.remediation!=="No action required."&&e(` \u2192 ${r.remediation}`)}}var Gs,Qb=S(()=>{"use strict";Vd();nt();Gs=class extends Error{category;remediation;constructor(e,r){super(e,{cause:r.cause}),this.name="InstallAbortError",this.category=r.category,this.remediation=r.remediation}}});import{existsSync as Co,readFileSync as ev,writeFileSync as _Z}from"fs";import{exec as TZ,execSync as Bd,spawnSync as CZ}from"child_process";import{createRequire as OZ}from"module";import{join as Wr}from"path";import{homedir as Vs}from"os";function xK(){return mt?'Install Bun manually: `winget install Oven-sh.Bun` (or `powershell -c "irm bun.sh/install.ps1 | iex"`), then re-run `npx claude-mem install`.':"Install Bun manually: `curl -fsSL https://bun.sh/install | bash` (or `brew install oven-sh/bun/bun`), then re-run `npx claude-mem install`."}function IK(){return mt?'Install uv manually: `winget install astral-sh.uv` (or `powershell -c "irm https://astral.sh/uv/install.ps1 | iex"`), then re-run `npx claude-mem install`.':"Install uv manually: `curl -LsSf https://astral.sh/uv/install.sh | sh` (or `brew install uv`), then re-run `npx claude-mem install`."}function kK(){let t;try{if(!Co(ht))return!1;t=er(ev(ht,"utf-8"))}catch(n){let o=n instanceof Error?n:new Error(String(n));return console.warn(`claude-mem: could not read ${ht} while checking vector-search opt-out:`,o),!1}if(!t||typeof t!="object")return!1;let e=t,r=e.env&&typeof e.env=="object"?e.env:{},i=e.CLAUDE_MEM_DISABLE_VECTOR_SEARCH??r.CLAUDE_MEM_DISABLE_VECTOR_SEARCH;return i===!0||i==="true"||i==="1"}function CK(t){return Wr(t,".install-version")}function tv(t,e){let i=Ls(t,e,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]});return CZ(i.command,i.args,i.options)}function OK(t,e){let r=mt?Rd(t):t;try{if(r&&tv(r,["--version"]).status===0)return r}catch{}return e.find(Co)||null}function ec(){return OK("bun",_K)}function AK(){return ec()!==null}function Ql(){let t=ec();if(!t)return null;try{let e=tv(t,["--version"]);return e.status===0?e.stdout.trim():null}catch(e){let r=e instanceof Error?e:new Error(String(e));return console.warn("claude-mem: bun --version probe failed:",r),null}}function rv(){return OK("uv",TK)}function KK(){return rv()!==null}function Wd(){let t=rv();if(!t)return null;try{let e=tv(t,["--version"]);return e.status===0?e.stdout.trim():null}catch(e){let r=e instanceof Error?e:new Error(String(e));return console.warn("claude-mem: uv --version probe failed:",r),null}}function nv(t){if(t&&typeof t=="object"){let e=t,r=[];e.message&&r.push(e.message);let i=e.stderr?e.stderr.toString().trim():"";i&&r.push(`stderr: ${i}`);let n=e.stdout?e.stdout.toString().trim():"";return!i&&n&&r.push(`stdout: ${n}`),r.join(`
106
106
  `)}return String(t)}function KZ(){if(mt?Bd('powershell -c "irm bun.sh/install.ps1 | iex"',{stdio:"pipe",timeout:Xl,shell:process.env.ComSpec??"cmd.exe"}):Bd("curl -fsSL https://bun.sh/install | bash",{stdio:"pipe",timeout:Xl,shell:"/bin/bash"}),!AK())throw new Error("Bun installation completed but binary not found. Please restart your terminal and try again.")}function RZ(){try{KZ()}catch(t){let e=t instanceof Error?t:new Error(String(t)),r=mt?` - winget install Oven-sh.Bun
107
107
  - Or: powershell -c "irm bun.sh/install.ps1 | iex"`:` - curl -fsSL https://bun.sh/install | bash
@@ -417,15 +417,15 @@ Examples:
417
417
  claude-mem antigravity-cli uninstall # Remove hooks + MCP
418
418
 
419
419
  For more info: https://docs.claude-mem.ai/antigravity-cli/setup
420
- `),0}}var oa,or,Rn,gp,mc,hc,KY,sa,vp=S(()=>{"use strict";Me();ic();Gv();wo();op();oa=ia.join(rD(),".gemini"),or=ia.join(oa,"settings.json"),Rn=ia.join(oa,"GEMINI.md"),gp=[ia.join(oa,"antigravity","mcp_config.json"),ia.join(oa,"config","mcp_config.json")],mc=ia.join(rD(),".agents","rules","claude-mem-context.md"),hc="claude-mem",KY=1e4,sa={SessionStart:"context",BeforeAgent:"session-init",AfterAgent:"observation",BeforeTool:"observation",AfterTool:"observation",Notification:"observation",PreCompress:"summarize"}});var Wv=h(uD=>{"use strict";uD.parse=function(t,e){return new Bv(t,e).parse()};var Bv=class t{constructor(e,r){this.source=e,this.transform=r||qY,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e==="\\"?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push(e)}newEntry(e){var r;(this.recorded.length>0||e)&&(r=this.recorded.join(""),r==="NULL"&&!e&&(r=null),r!==null&&(r=this.transform(r)),this.entries.push(r),this.recorded=[])}consumeDimensions(){if(this.source[0]==="[")for(;!this.isEof();){var e=this.nextCharacter();if(e.value==="=")break}}parse(e){var r,i,n;for(this.consumeDimensions();!this.isEof();)if(r=this.nextCharacter(),r.value==="{"&&!n)this.dimension++,this.dimension>1&&(i=new t(this.source.substr(this.position-1),this.transform),this.entries.push(i.parse(!0)),this.position+=i.position-2);else if(r.value==="}"&&!n){if(this.dimension--,!this.dimension&&(this.newEntry(),e))return this.entries}else r.value==='"'&&!r.escaped?(n&&this.newEntry(!0),n=!n):r.value===","&&!n?this.newEntry():this.record(r.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}};function qY(t){return t}});var Zv=h((LEe,dD)=>{var zY=Wv();dD.exports={create:function(t,e){return{parse:function(){return zY.parse(t,e)}}}}});var mD=h((UEe,fD)=>{"use strict";var GY=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,VY=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,BY=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,WY=/^-?infinity$/;fD.exports=function(e){if(WY.test(e))return Number(e.replace("i","I"));var r=GY.exec(e);if(!r)return ZY(e)||null;var i=!!r[8],n=parseInt(r[1],10);i&&(n=pD(n));var o=parseInt(r[2],10)-1,s=r[3],a=parseInt(r[4],10),l=parseInt(r[5],10),c=parseInt(r[6],10),u=r[7];u=u?1e3*parseFloat(u):0;var d,f=HY(e);return f!=null?(d=new Date(Date.UTC(n,o,s,a,l,c,u)),Hv(n)&&d.setUTCFullYear(n),f!==0&&d.setTime(d.getTime()-f)):(d=new Date(n,o,s,a,l,c,u),Hv(n)&&d.setFullYear(n)),d};function ZY(t){var e=VY.exec(t);if(e){var r=parseInt(e[1],10),i=!!e[4];i&&(r=pD(r));var n=parseInt(e[2],10)-1,o=e[3],s=new Date(r,n,o);return Hv(r)&&s.setFullYear(r),s}}function HY(t){if(t.endsWith("+00"))return 0;var e=BY.exec(t.split(" ")[1]);if(e){var r=e[1];if(r==="Z")return 0;var i=r==="-"?-1:1,n=parseInt(e[2],10)*3600+parseInt(e[3]||0,10)*60+parseInt(e[4]||0,10);return n*i*1e3}}function pD(t){return-(t-1)}function Hv(t){return t>=0&&t<100}});var yD=h(($Ee,hD)=>{hD.exports=XY;var YY=Object.prototype.hasOwnProperty;function XY(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)YY.call(r,i)&&(t[i]=r[i])}return t}});var vD=h((JEe,bD)=>{"use strict";var QY=yD();bD.exports=la;function la(t){if(!(this instanceof la))return new la(t);QY(this,d5(t))}var e5=["seconds","minutes","hours","days","months","years"];la.prototype.toPostgres=function(){var t=e5.filter(this.hasOwnProperty,this);return this.milliseconds&&t.indexOf("seconds")<0&&t.push("seconds"),t.length===0?"0":t.map(function(e){var r=this[e]||0;return e==="seconds"&&this.milliseconds&&(r=(r+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,"")),r+" "+e},this).join(" ")};var t5={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},r5=["years","months","days"],n5=["hours","minutes","seconds"];la.prototype.toISOString=la.prototype.toISO=function(){var t=r5.map(r,this).join(""),e=n5.map(r,this).join("");return"P"+t+"T"+e;function r(i){var n=this[i]||0;return i==="seconds"&&this.milliseconds&&(n=(n+this.milliseconds/1e3).toFixed(6).replace(/0+$/,"")),n+t5[i]}};var Yv="([+-]?\\d+)",i5=Yv+"\\s+years?",o5=Yv+"\\s+mons?",s5=Yv+"\\s+days?",a5="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",l5=new RegExp([i5,o5,s5,a5].map(function(t){return"("+t+")?"}).join("\\s*")),gD={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},c5=["hours","minutes","seconds","milliseconds"];function u5(t){var e=t+"000000".slice(t.length);return parseInt(e,10)/1e3}function d5(t){if(!t)return{};var e=l5.exec(t),r=e[8]==="-";return Object.keys(gD).reduce(function(i,n){var o=gD[n],s=e[o];return!s||(s=n==="milliseconds"?u5(s):parseInt(s,10),!s)||(r&&~c5.indexOf(n)&&(s*=-1),i[n]=s),i},{})}});var wD=h((FEe,ED)=>{"use strict";var SD=Buffer.from||Buffer;ED.exports=function(e){if(/^\\x/.test(e))return SD(e.substr(2),"hex");for(var r="",i=0;i<e.length;)if(e[i]!=="\\")r+=e[i],++i;else if(/[0-7]{3}/.test(e.substr(i+1,3)))r+=String.fromCharCode(parseInt(e.substr(i+1,3),8)),i+=4;else{for(var n=1;i+n<e.length&&e[i+n]==="\\";)n++;for(var o=0;o<Math.floor(n/2);++o)r+="\\";i+=Math.floor(n/2)*2}return SD(r,"binary")}});var OD=h((qEe,CD)=>{var gc=Wv(),bc=Zv(),Sp=mD(),ID=vD(),kD=wD();function Ep(t){return function(r){return r===null?r:t(r)}}function _D(t){return t===null?t:t==="TRUE"||t==="t"||t==="true"||t==="y"||t==="yes"||t==="on"||t==="1"}function p5(t){return t?gc.parse(t,_D):null}function f5(t){return parseInt(t,10)}function Xv(t){return t?gc.parse(t,Ep(f5)):null}function m5(t){return t?gc.parse(t,Ep(function(e){return TD(e).trim()})):null}var h5=function(t){if(!t)return null;var e=bc.create(t,function(r){return r!==null&&(r=rS(r)),r});return e.parse()},Qv=function(t){if(!t)return null;var e=bc.create(t,function(r){return r!==null&&(r=parseFloat(r)),r});return e.parse()},Hr=function(t){if(!t)return null;var e=bc.create(t);return e.parse()},eS=function(t){if(!t)return null;var e=bc.create(t,function(r){return r!==null&&(r=Sp(r)),r});return e.parse()},y5=function(t){if(!t)return null;var e=bc.create(t,function(r){return r!==null&&(r=ID(r)),r});return e.parse()},g5=function(t){return t?gc.parse(t,Ep(kD)):null},tS=function(t){return parseInt(t,10)},TD=function(t){var e=String(t);return/^\d+$/.test(e)?e:t},xD=function(t){return t?gc.parse(t,Ep(JSON.parse)):null},rS=function(t){return t[0]!=="("?null:(t=t.substring(1,t.length-1).split(","),{x:parseFloat(t[0]),y:parseFloat(t[1])})},b5=function(t){if(t[0]!=="<"&&t[1]!=="(")return null;for(var e="(",r="",i=!1,n=2;n<t.length-1;n++){if(i||(e+=t[n]),t[n]===")"){i=!0;continue}else if(!i)continue;t[n]!==","&&(r+=t[n])}var o=rS(e);return o.radius=parseFloat(r),o},v5=function(t){t(20,TD),t(21,tS),t(23,tS),t(26,tS),t(700,parseFloat),t(701,parseFloat),t(16,_D),t(1082,Sp),t(1114,Sp),t(1184,Sp),t(600,rS),t(651,Hr),t(718,b5),t(1e3,p5),t(1001,g5),t(1005,Xv),t(1007,Xv),t(1028,Xv),t(1016,m5),t(1017,h5),t(1021,Qv),t(1022,Qv),t(1231,Qv),t(1014,Hr),t(1015,Hr),t(1008,Hr),t(1009,Hr),t(1040,Hr),t(1041,Hr),t(1115,eS),t(1182,eS),t(1185,eS),t(1186,ID),t(1187,y5),t(17,kD),t(114,JSON.parse.bind(JSON)),t(3802,JSON.parse.bind(JSON)),t(199,xD),t(3807,xD),t(3907,Hr),t(2951,Hr),t(791,Hr),t(1183,Hr),t(1270,Hr)};CD.exports={init:v5}});var KD=h((zEe,AD)=>{"use strict";var hr=1e6;function S5(t){var e=t.readInt32BE(0),r=t.readUInt32BE(4),i="";e<0&&(e=~e+(r===0),r=~r+1>>>0,i="-");var n="",o,s,a,l,c,u;{if(o=e%hr,e=e/hr>>>0,s=4294967296*o+r,r=s/hr>>>0,a=""+(s-hr*r),r===0&&e===0)return i+a+n;for(l="",c=6-a.length,u=0;u<c;u++)l+="0";n=l+a+n}{if(o=e%hr,e=e/hr>>>0,s=4294967296*o+r,r=s/hr>>>0,a=""+(s-hr*r),r===0&&e===0)return i+a+n;for(l="",c=6-a.length,u=0;u<c;u++)l+="0";n=l+a+n}{if(o=e%hr,e=e/hr>>>0,s=4294967296*o+r,r=s/hr>>>0,a=""+(s-hr*r),r===0&&e===0)return i+a+n;for(l="",c=6-a.length,u=0;u<c;u++)l+="0";n=l+a+n}return o=e%hr,s=4294967296*o+r,a=""+s%hr,i+a+n}AD.exports=S5});var MD=h((GEe,PD)=>{var E5=KD(),it=function(t,e,r,i,n){r=r||0,i=i||!1,n=n||function(p,m,y){return p*Math.pow(2,y)+m};var o=r>>3,s=function(p){return i?~p&255:p},a=255,l=8-r%8;e<l&&(a=255<<8-e&255,l=e),r&&(a=a>>r%8);var c=0;r%8+e>=8&&(c=n(0,s(t[o])&a,l));for(var u=e+r>>3,d=o+1;d<u;d++)c=n(c,s(t[d]),8);var f=(e+r)%8;return f>0&&(c=n(c,s(t[u])>>8-f,f)),c},jD=function(t,e,r){var i=Math.pow(2,r-1)-1,n=it(t,1),o=it(t,r,1);if(o===0)return 0;var s=1,a=function(c,u,d){c===0&&(c=1);for(var f=1;f<=d;f++)s/=2,(u&1<<d-f)>0&&(c+=s);return c},l=it(t,e,r+1,!1,a);return o==Math.pow(2,r+1)-1?l===0?n===0?1/0:-1/0:NaN:(n===0?1:-1)*Math.pow(2,o-i)*l},w5=function(t){return it(t,1)==1?-1*(it(t,15,1,!0)+1):it(t,15,1)},RD=function(t){return it(t,1)==1?-1*(it(t,31,1,!0)+1):it(t,31,1)},x5=function(t){return jD(t,23,8)},I5=function(t){return jD(t,52,11)},k5=function(t){var e=it(t,16,32);if(e==49152)return NaN;for(var r=Math.pow(1e4,it(t,16,16)),i=0,n=[],o=it(t,16),s=0;s<o;s++)i+=it(t,16,64+16*s)*r,r/=1e4;var a=Math.pow(10,it(t,16,48));return(e===0?1:-1)*Math.round(i*a)/a},DD=function(t,e){var r=it(e,1),i=it(e,63,1),n=new Date((r===0?1:-1)*i/1e3+9466848e5);return t||n.setTime(n.getTime()+n.getTimezoneOffset()*6e4),n.usec=i%1e3,n.getMicroSeconds=function(){return this.usec},n.setMicroSeconds=function(o){this.usec=o},n.getUTCMicroSeconds=function(){return this.usec},n},vc=function(t){for(var e=it(t,32),r=it(t,32,32),i=it(t,32,64),n=96,o=[],s=0;s<e;s++)o[s]=it(t,32,n),n+=32,n+=32;var a=function(c){var u=it(t,32,n);if(n+=32,u==4294967295)return null;var d;if(c==23||c==20)return d=it(t,u*8,n),n+=u*8,d;if(c==25)return d=t.toString(this.encoding,n>>3,(n+=u<<3)>>3),d;console.log("ERROR: ElementType not implemented: "+c)},l=function(c,u){var d=[],f;if(c.length>1){var p=c.shift();for(f=0;f<p;f++)d[f]=l(c,u);c.unshift(p)}else for(f=0;f<c[0];f++)d[f]=a(u);return d};return l(o,i)},_5=function(t){return t.toString("utf8")},T5=function(t){return t===null?null:it(t,8)>0},C5=function(t){t(20,E5),t(21,w5),t(23,RD),t(26,RD),t(1700,k5),t(700,x5),t(701,I5),t(16,T5),t(1114,DD.bind(null,!1)),t(1184,DD.bind(null,!0)),t(1e3,vc),t(1007,vc),t(1016,vc),t(1008,vc),t(1009,vc),t(25,_5)};PD.exports={init:C5}});var LD=h((VEe,ND)=>{ND.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}});var wc=h(Ec=>{var O5=OD(),A5=MD(),K5=Zv(),R5=LD();Ec.getTypeParser=D5;Ec.setTypeParser=j5;Ec.arrayParser=K5;Ec.builtins=R5;var Sc={text:{},binary:{}};function UD(t){return String(t)}function D5(t,e){return e=e||"text",Sc[e]&&Sc[e][t]||UD}function j5(t,e,r){typeof e=="function"&&(r=e,e="text"),Sc[e][t]=r}O5.init(function(t,e){Sc.text[t]=e});A5.init(function(t,e){Sc.binary[t]=e})});var xc=h((WEe,nS)=>{"use strict";var $D;try{$D=process.platform==="win32"?process.env.USERNAME:process.env.USER}catch{}nS.exports={host:"localhost",user:$D,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4,client_encoding:"",ssl:!1,sslnegotiation:void 0,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};var ca=wc(),P5=ca.getTypeParser(20,"text"),M5=ca.getTypeParser(1016,"text");nS.exports.__defineSetter__("parseInt8",function(t){ca.setTypeParser(20,"text",t?ca.getTypeParser(23,"text"):P5),ca.setTypeParser(1016,"text",t?ca.getTypeParser(1007,"text"):M5)})});var ua=h((ZEe,FD)=>{"use strict";var N5=xc(),{isDate:L5}=U("util/types");function U5(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function JD(t){let e="{";for(let r=0;r<t.length;r++){r>0&&(e+=",");let i=t[r];i==null?e+="NULL":Array.isArray(i)?e+=JD(i):ArrayBuffer.isView(i)?(i instanceof Buffer||(i=Buffer.from(i.buffer,i.byteOffset,i.byteLength)),e+="\\\\x"+i.toString("hex")):e+=U5(wp(i))}return e+="}",e}var wp=function(t,e){return t==null?null:typeof t=="object"?t instanceof Buffer?t:ArrayBuffer.isView(t)?Buffer.from(t.buffer,t.byteOffset,t.byteLength):L5(t)?N5.parseInputDatesAsUTC?F5(t):J5(t):Array.isArray(t)?JD(t):$5(t,e):t.toString()};function $5(t,e){if(t&&typeof t.toPostgres=="function"){if(e=e||[],e.indexOf(t)!==-1)throw new Error('circular reference detected while preparing "'+t+'" for query');return e.push(t),wp(t.toPostgres(wp),e)}return JSON.stringify(t)}function J5(t){let e=-t.getTimezoneOffset(),r=t.getFullYear(),i=r<1;i&&(r=Math.abs(r)+1);let n=String(r).padStart(4,"0")+"-"+String(t.getMonth()+1).padStart(2,"0")+"-"+String(t.getDate()).padStart(2,"0")+"T"+String(t.getHours()).padStart(2,"0")+":"+String(t.getMinutes()).padStart(2,"0")+":"+String(t.getSeconds()).padStart(2,"0")+"."+String(t.getMilliseconds()).padStart(3,"0");return e<0?(n+="-",e*=-1):n+="+",n+=String(Math.floor(e/60)).padStart(2,"0")+":"+String(e%60).padStart(2,"0"),i&&(n+=" BC"),n}function F5(t){let e=t.getUTCFullYear(),r=e<1;r&&(e=Math.abs(e)+1);let i=String(e).padStart(4,"0")+"-"+String(t.getUTCMonth()+1).padStart(2,"0")+"-"+String(t.getUTCDate()).padStart(2,"0")+"T"+String(t.getUTCHours()).padStart(2,"0")+":"+String(t.getUTCMinutes()).padStart(2,"0")+":"+String(t.getUTCSeconds()).padStart(2,"0")+"."+String(t.getUTCMilliseconds()).padStart(3,"0");return i+="+00:00",r&&(i+=" BC"),i}function q5(t,e,r){return t=typeof t=="string"?{text:t}:t,e&&(typeof e=="function"?t.callback=e:t.values=e),r&&(t.callback=r),t}var z5=function(t){return'"'+t.replace(/"/g,'""')+'"'},G5=function(t){let e=!1,r="'";if(t==null||typeof t!="string")return"''";for(let i=0;i<t.length;i++){let n=t[i];n==="'"?r+=n+n:n==="\\"?(r+=n+n,e=!0):r+=n}return r+="'",e===!0&&(r=" E"+r),r};FD.exports={prepareValue:function(e){return wp(e)},normalizeQueryConfig:q5,escapeIdentifier:z5,escapeLiteral:G5}});var sS=h((HEe,GD)=>{var qD=U("crypto");GD.exports={postgresMd5PasswordHash:B5,randomBytes:V5,deriveKey:Y5,sha256:W5,hashByName:Z5,hmacSha256:H5,md5:iS};var zD=qD.webcrypto||globalThis.crypto,jo=zD.subtle,oS=new TextEncoder;function V5(t){return zD.getRandomValues(Buffer.alloc(t))}async function iS(t){try{return qD.createHash("md5").update(t,"utf-8").digest("hex")}catch{let r=typeof t=="string"?oS.encode(t):t,i=await jo.digest("MD5",r);return Array.from(new Uint8Array(i)).map(n=>n.toString(16).padStart(2,"0")).join("")}}async function B5(t,e,r){let i=await iS(e+t);return"md5"+await iS(Buffer.concat([Buffer.from(i),r]))}async function W5(t){return await jo.digest("SHA-256",t)}async function Z5(t,e){return await jo.digest(t,e)}async function H5(t,e){let r=await jo.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await jo.sign("HMAC",r,oS.encode(e))}async function Y5(t,e,r){let i=await jo.importKey("raw",oS.encode(t),"PBKDF2",!1,["deriveBits"]),n={name:"PBKDF2",hash:"SHA-256",salt:e,iterations:r};return await jo.deriveBits(n,i,256,["deriveBits"])}});var WD=h((YEe,BD)=>{function Po(t,e){return new Error("SASL channel binding: "+t+" when parsing public certificate "+e.toString("base64"))}function aS(t,e){let r=t[e++];if(r<128)return{length:r,index:e};let i=r&127;if(i>4)throw Po("bad length",t);r=0;for(let n=0;n<i;n++)r=r<<8|t[e++];return{length:r,index:e}}function VD(t,e){if(t[e++]!==6)throw Po("non-OID data",t);let{length:r,index:i}=aS(t,e);e=i;let n=e+r,o=t[e++],s=(o/40>>0)+"."+o%40;for(;e<n;){let a=0;for(;e<n;){let l=t[e++];if(a=a<<7|l&127,l<128)break}s+="."+a}return{oid:s,index:e}}function Ic(t,e){if(t[e++]!==48)throw Po("non-sequence data",t);return aS(t,e)}function X5(t,e){e===void 0&&(e=0),e=Ic(t,e).index;let{length:r,index:i}=Ic(t,e);e=i+r,e=Ic(t,e).index;let{oid:n,index:o}=VD(t,e);switch(n){case"1.2.840.113549.1.1.4":return"MD5";case"1.2.840.113549.1.1.5":return"SHA-1";case"1.2.840.113549.1.1.11":return"SHA-256";case"1.2.840.113549.1.1.12":return"SHA-384";case"1.2.840.113549.1.1.13":return"SHA-512";case"1.2.840.113549.1.1.14":return"SHA-224";case"1.2.840.113549.1.1.15":return"SHA512-224";case"1.2.840.113549.1.1.16":return"SHA512-256";case"1.2.840.10045.4.1":return"SHA-1";case"1.2.840.10045.4.3.1":return"SHA-224";case"1.2.840.10045.4.3.2":return"SHA-256";case"1.2.840.10045.4.3.3":return"SHA-384";case"1.2.840.10045.4.3.4":return"SHA-512";case"1.2.840.113549.1.1.10":{if(e=o,e=Ic(t,e).index,t[e++]!==160)throw Po("non-tag data",t);e=aS(t,e).index,e=Ic(t,e).index;let{oid:s}=VD(t,e);switch(s){case"1.2.840.113549.2.5":return"MD5";case"1.3.14.3.2.26":return"SHA-1";case"2.16.840.1.101.3.4.2.1":return"SHA-256";case"2.16.840.1.101.3.4.2.2":return"SHA-384";case"2.16.840.1.101.3.4.2.3":return"SHA-512"}throw Po("unknown hash OID "+s,t)}case"1.3.101.110":case"1.3.101.112":return"SHA-512";case"1.3.101.111":case"1.3.101.113":throw Po("Ed448 certificate channel binding is not currently supported by Postgres")}throw Po("unknown OID "+n,t)}BD.exports={signatureAlgorithmHashFromCertificate:X5}});var XD=h((XEe,YD)=>{"use strict";var ji=sS(),{signatureAlgorithmHashFromCertificate:Q5}=WD();function e8(t){let e=/[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g,r=/[\u00AD\u034F\u1806\u180B\u180C\u180D\u200C\u200D\u2060\uFE00-\uFE0F\uFEFF]/g;return t.replace(e," ").replace(r,"").normalize("NFKC")}var lS=1e5;function t8(t,e,r=lS){let i=["SCRAM-SHA-256"];e&&i.unshift("SCRAM-SHA-256-PLUS");let n=i.find(a=>t.includes(a));if(!n)throw new Error("SASL: Only mechanism(s) "+i.join(" and ")+" are supported");if(n==="SCRAM-SHA-256-PLUS"&&typeof e.getPeerCertificate!="function")throw new Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate");let o=ji.randomBytes(18).toString("base64");return{mechanism:n,clientNonce:o,response:(n==="SCRAM-SHA-256-PLUS"?"p=tls-server-end-point":e?"y":"n")+",,n=*,r="+o,message:"SASLInitialResponse",scramMaxIterations:r}}async function r8(t,e,r,i){if(t.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(e==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof r!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let n=o8(r);if(n.nonce.startsWith(t.clientNonce)){if(n.nonce.length===t.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");let o=typeof t.scramMaxIterations=="number"?t.scramMaxIterations:lS;if(o!==0&&n.iteration>o)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count "+n.iteration+" exceeds scramMaxIterations of "+o);let s="n=*,r="+t.clientNonce,a="r="+n.nonce+",s="+n.salt+",i="+n.iteration,l=i?"eSws":"biws";if(t.mechanism==="SCRAM-SHA-256-PLUS"){let O=i.getPeerCertificate().raw,C=Q5(O);(C==="MD5"||C==="SHA-1")&&(C="SHA-256");let $=await ji.hashByName(C,O);l=Buffer.concat([Buffer.from("p=tls-server-end-point,,"),Buffer.from($)]).toString("base64")}let c="c="+l+",r="+n.nonce,u=s+","+a+","+c,d=Buffer.from(n.salt,"base64"),f=await ji.deriveKey(e8(e),d,n.iteration),p=await ji.hmacSha256(f,"Client Key"),m=await ji.sha256(p),y=await ji.hmacSha256(m,u),w=a8(Buffer.from(p),Buffer.from(y)).toString("base64"),_=await ji.hmacSha256(f,"Server Key"),A=await ji.hmacSha256(_,u);t.message="SASLResponse",t.serverSignature=Buffer.from(A).toString("base64"),t.response=c+",p="+w}function n8(t,e){if(t.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:r}=s8(e);if(r!==t.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}function i8(t){if(typeof t!="string")throw new TypeError("SASL: text must be a string");return t.split("").map((e,r)=>t.charCodeAt(r)).every(e=>e>=33&&e<=43||e>=45&&e<=126)}function ZD(t){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(t)}function HD(t){if(typeof t!="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map(t.split(",").map(e=>{if(!/^.=/.test(e))throw new Error("SASL: Invalid attribute pair entry");let r=e[0],i=e.substring(2);return[r,i]}))}function o8(t){let e=HD(t),r=e.get("r");if(r){if(!i8(r))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");let i=e.get("s");if(i){if(!ZD(i))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");let n=e.get("i");if(n){if(!/^[1-9][0-9]*$/.test(n))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");let o=parseInt(n,10);return{nonce:r,salt:i,iteration:o}}function s8(t){let e=HD(t),r=e.get("e"),i=e.get("v");if(r)throw new Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${r}"`);if(i){if(!ZD(i))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64")}else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");return{serverSignature:i}}function a8(t,e){if(!Buffer.isBuffer(t))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(e))throw new TypeError("second argument must be a Buffer");if(t.length!==e.length)throw new Error("Buffer lengths must match");if(t.length===0)throw new Error("Buffers cannot be empty");return Buffer.from(t.map((r,i)=>t[i]^e[i]))}YD.exports={startSession:t8,continueSession:r8,finalizeSession:n8,DEFAULT_MAX_SCRAM_ITERATIONS:lS}});var Ip=h((QEe,QD)=>{"use strict";var l8=wc();function xp(t){this._types=t||l8,this.text={},this.binary={}}xp.prototype.getOverrides=function(t){switch(t){case"text":return this.text;case"binary":return this.binary;default:return{}}};xp.prototype.setTypeParser=function(t,e,r){typeof e=="function"&&(r=e,e="text"),this.getOverrides(e)[t]=r};xp.prototype.getTypeParser=function(t,e){return e=e||"text",this.getOverrides(e)[t]||this._types.getTypeParser(t,e)};QD.exports=xp});var rj=h((e0e,tj)=>{"use strict";function da(t,e={}){if(t.charAt(0)==="/"){let l=t.split(" ");return{host:l[0],database:l[1]}}let r=Object.create(null),i,n=!1;/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(t)&&(t=encodeURI(t).replace(/%25(\d\d)/g,"%$1"));try{try{i=new URL(t,"postgres://base")}catch{i=new URL(t.replace("@/","@___DUMMY___/"),"postgres://base"),n=!0}}catch(l){throw l.input&&(l.input="*****REDACTED*****"),l}for(let l of i.searchParams.entries())r[l[0]]=l[1];if(r.user=r.user||decodeURIComponent(i.username),r.password=r.password||decodeURIComponent(i.password),i.protocol=="socket:")return r.host=decodeURI(i.pathname),r.database=i.searchParams.get("db"),r.client_encoding=i.searchParams.get("encoding"),r;let o=n?"":i.hostname;r.host?o&&/^%2f/i.test(o)&&(i.pathname=o+i.pathname):r.host=decodeURIComponent(o),r.port||(r.port=i.port);let s=i.pathname.slice(1)||null;r.database=s?decodeURI(s):null,(r.ssl==="true"||r.ssl==="1")&&(r.ssl=!0),r.ssl==="0"&&(r.ssl=!1),(r.sslcert||r.sslkey||r.sslrootcert||r.sslmode)&&(r.ssl={}),r.sslnegotiation==="direct"&&r.ssl===void 0&&(r.ssl=!0);let a=r.sslcert||r.sslkey||r.sslrootcert?U("fs"):null;if(r.sslcert&&(r.ssl.cert=a.readFileSync(r.sslcert).toString()),r.sslkey&&(r.ssl.key=a.readFileSync(r.sslkey).toString()),r.sslrootcert&&(r.ssl.ca=a.readFileSync(r.sslrootcert).toString()),e.useLibpqCompat&&r.uselibpqcompat)throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");if(r.uselibpqcompat==="true"||e.useLibpqCompat)switch(r.sslmode){case"disable":{r.ssl=!1;break}case"prefer":{r.ssl.rejectUnauthorized=!1;break}case"require":{r.sslrootcert?r.ssl.checkServerIdentity=function(){}:r.ssl.rejectUnauthorized=!1;break}case"verify-ca":{if(!r.ssl.ca)throw new Error("SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.");r.ssl.checkServerIdentity=function(){};break}case"verify-full":break}else switch(r.sslmode){case"disable":{r.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":{r.sslmode!=="verify-full"&&cS(r.sslmode);break}case"no-verify":{r.ssl.rejectUnauthorized=!1;break}}return r}function c8(t){return Object.entries(t).reduce((r,[i,n])=>(n!=null&&(r[i]=n),r),Object.create(null))}function ej(t){return Object.entries(t).reduce((r,[i,n])=>{if(i==="ssl"){let o=n;typeof o=="boolean"&&(r[i]=o),typeof o=="object"&&(r[i]=c8(o))}else if(n!=null)if(i==="port"){if(n!==""){let o=parseInt(n,10);if(isNaN(o))throw new Error(`Invalid ${i}: ${n}`);r[i]=o}}else r[i]=n;return r},Object.create(null))}function u8(t){return ej(da(t))}function cS(t){!cS.warned&&typeof process<"u"&&process.emitWarning&&(cS.warned=!0,process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
420
+ `),0}}var oa,or,Rn,gp,mc,hc,KY,sa,vp=S(()=>{"use strict";Me();ic();Gv();wo();op();oa=ia.join(rD(),".gemini"),or=ia.join(oa,"settings.json"),Rn=ia.join(oa,"GEMINI.md"),gp=[ia.join(oa,"antigravity","mcp_config.json"),ia.join(oa,"config","mcp_config.json")],mc=ia.join(rD(),".agents","rules","claude-mem-context.md"),hc="claude-mem",KY=1e4,sa={SessionStart:"context",BeforeAgent:"session-init",AfterAgent:"observation",BeforeTool:"observation",AfterTool:"observation",Notification:"observation",PreCompress:"summarize"}});var Wv=h(uD=>{"use strict";uD.parse=function(t,e){return new Bv(t,e).parse()};var Bv=class t{constructor(e,r){this.source=e,this.transform=r||qY,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e==="\\"?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push(e)}newEntry(e){var r;(this.recorded.length>0||e)&&(r=this.recorded.join(""),r==="NULL"&&!e&&(r=null),r!==null&&(r=this.transform(r)),this.entries.push(r),this.recorded=[])}consumeDimensions(){if(this.source[0]==="[")for(;!this.isEof();){var e=this.nextCharacter();if(e.value==="=")break}}parse(e){var r,i,n;for(this.consumeDimensions();!this.isEof();)if(r=this.nextCharacter(),r.value==="{"&&!n)this.dimension++,this.dimension>1&&(i=new t(this.source.substr(this.position-1),this.transform),this.entries.push(i.parse(!0)),this.position+=i.position-2);else if(r.value==="}"&&!n){if(this.dimension--,!this.dimension&&(this.newEntry(),e))return this.entries}else r.value==='"'&&!r.escaped?(n&&this.newEntry(!0),n=!n):r.value===","&&!n?this.newEntry():this.record(r.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}};function qY(t){return t}});var Zv=h((UEe,dD)=>{var zY=Wv();dD.exports={create:function(t,e){return{parse:function(){return zY.parse(t,e)}}}}});var mD=h(($Ee,fD)=>{"use strict";var GY=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,VY=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,BY=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,WY=/^-?infinity$/;fD.exports=function(e){if(WY.test(e))return Number(e.replace("i","I"));var r=GY.exec(e);if(!r)return ZY(e)||null;var i=!!r[8],n=parseInt(r[1],10);i&&(n=pD(n));var o=parseInt(r[2],10)-1,s=r[3],a=parseInt(r[4],10),l=parseInt(r[5],10),c=parseInt(r[6],10),u=r[7];u=u?1e3*parseFloat(u):0;var d,f=HY(e);return f!=null?(d=new Date(Date.UTC(n,o,s,a,l,c,u)),Hv(n)&&d.setUTCFullYear(n),f!==0&&d.setTime(d.getTime()-f)):(d=new Date(n,o,s,a,l,c,u),Hv(n)&&d.setFullYear(n)),d};function ZY(t){var e=VY.exec(t);if(e){var r=parseInt(e[1],10),i=!!e[4];i&&(r=pD(r));var n=parseInt(e[2],10)-1,o=e[3],s=new Date(r,n,o);return Hv(r)&&s.setFullYear(r),s}}function HY(t){if(t.endsWith("+00"))return 0;var e=BY.exec(t.split(" ")[1]);if(e){var r=e[1];if(r==="Z")return 0;var i=r==="-"?-1:1,n=parseInt(e[2],10)*3600+parseInt(e[3]||0,10)*60+parseInt(e[4]||0,10);return n*i*1e3}}function pD(t){return-(t-1)}function Hv(t){return t>=0&&t<100}});var yD=h((JEe,hD)=>{hD.exports=XY;var YY=Object.prototype.hasOwnProperty;function XY(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)YY.call(r,i)&&(t[i]=r[i])}return t}});var vD=h((FEe,bD)=>{"use strict";var QY=yD();bD.exports=la;function la(t){if(!(this instanceof la))return new la(t);QY(this,d5(t))}var e5=["seconds","minutes","hours","days","months","years"];la.prototype.toPostgres=function(){var t=e5.filter(this.hasOwnProperty,this);return this.milliseconds&&t.indexOf("seconds")<0&&t.push("seconds"),t.length===0?"0":t.map(function(e){var r=this[e]||0;return e==="seconds"&&this.milliseconds&&(r=(r+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,"")),r+" "+e},this).join(" ")};var t5={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},r5=["years","months","days"],n5=["hours","minutes","seconds"];la.prototype.toISOString=la.prototype.toISO=function(){var t=r5.map(r,this).join(""),e=n5.map(r,this).join("");return"P"+t+"T"+e;function r(i){var n=this[i]||0;return i==="seconds"&&this.milliseconds&&(n=(n+this.milliseconds/1e3).toFixed(6).replace(/0+$/,"")),n+t5[i]}};var Yv="([+-]?\\d+)",i5=Yv+"\\s+years?",o5=Yv+"\\s+mons?",s5=Yv+"\\s+days?",a5="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",l5=new RegExp([i5,o5,s5,a5].map(function(t){return"("+t+")?"}).join("\\s*")),gD={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},c5=["hours","minutes","seconds","milliseconds"];function u5(t){var e=t+"000000".slice(t.length);return parseInt(e,10)/1e3}function d5(t){if(!t)return{};var e=l5.exec(t),r=e[8]==="-";return Object.keys(gD).reduce(function(i,n){var o=gD[n],s=e[o];return!s||(s=n==="milliseconds"?u5(s):parseInt(s,10),!s)||(r&&~c5.indexOf(n)&&(s*=-1),i[n]=s),i},{})}});var wD=h((qEe,ED)=>{"use strict";var SD=Buffer.from||Buffer;ED.exports=function(e){if(/^\\x/.test(e))return SD(e.substr(2),"hex");for(var r="",i=0;i<e.length;)if(e[i]!=="\\")r+=e[i],++i;else if(/[0-7]{3}/.test(e.substr(i+1,3)))r+=String.fromCharCode(parseInt(e.substr(i+1,3),8)),i+=4;else{for(var n=1;i+n<e.length&&e[i+n]==="\\";)n++;for(var o=0;o<Math.floor(n/2);++o)r+="\\";i+=Math.floor(n/2)*2}return SD(r,"binary")}});var OD=h((zEe,CD)=>{var gc=Wv(),bc=Zv(),Sp=mD(),ID=vD(),kD=wD();function Ep(t){return function(r){return r===null?r:t(r)}}function _D(t){return t===null?t:t==="TRUE"||t==="t"||t==="true"||t==="y"||t==="yes"||t==="on"||t==="1"}function p5(t){return t?gc.parse(t,_D):null}function f5(t){return parseInt(t,10)}function Xv(t){return t?gc.parse(t,Ep(f5)):null}function m5(t){return t?gc.parse(t,Ep(function(e){return TD(e).trim()})):null}var h5=function(t){if(!t)return null;var e=bc.create(t,function(r){return r!==null&&(r=rS(r)),r});return e.parse()},Qv=function(t){if(!t)return null;var e=bc.create(t,function(r){return r!==null&&(r=parseFloat(r)),r});return e.parse()},Hr=function(t){if(!t)return null;var e=bc.create(t);return e.parse()},eS=function(t){if(!t)return null;var e=bc.create(t,function(r){return r!==null&&(r=Sp(r)),r});return e.parse()},y5=function(t){if(!t)return null;var e=bc.create(t,function(r){return r!==null&&(r=ID(r)),r});return e.parse()},g5=function(t){return t?gc.parse(t,Ep(kD)):null},tS=function(t){return parseInt(t,10)},TD=function(t){var e=String(t);return/^\d+$/.test(e)?e:t},xD=function(t){return t?gc.parse(t,Ep(JSON.parse)):null},rS=function(t){return t[0]!=="("?null:(t=t.substring(1,t.length-1).split(","),{x:parseFloat(t[0]),y:parseFloat(t[1])})},b5=function(t){if(t[0]!=="<"&&t[1]!=="(")return null;for(var e="(",r="",i=!1,n=2;n<t.length-1;n++){if(i||(e+=t[n]),t[n]===")"){i=!0;continue}else if(!i)continue;t[n]!==","&&(r+=t[n])}var o=rS(e);return o.radius=parseFloat(r),o},v5=function(t){t(20,TD),t(21,tS),t(23,tS),t(26,tS),t(700,parseFloat),t(701,parseFloat),t(16,_D),t(1082,Sp),t(1114,Sp),t(1184,Sp),t(600,rS),t(651,Hr),t(718,b5),t(1e3,p5),t(1001,g5),t(1005,Xv),t(1007,Xv),t(1028,Xv),t(1016,m5),t(1017,h5),t(1021,Qv),t(1022,Qv),t(1231,Qv),t(1014,Hr),t(1015,Hr),t(1008,Hr),t(1009,Hr),t(1040,Hr),t(1041,Hr),t(1115,eS),t(1182,eS),t(1185,eS),t(1186,ID),t(1187,y5),t(17,kD),t(114,JSON.parse.bind(JSON)),t(3802,JSON.parse.bind(JSON)),t(199,xD),t(3807,xD),t(3907,Hr),t(2951,Hr),t(791,Hr),t(1183,Hr),t(1270,Hr)};CD.exports={init:v5}});var KD=h((GEe,AD)=>{"use strict";var hr=1e6;function S5(t){var e=t.readInt32BE(0),r=t.readUInt32BE(4),i="";e<0&&(e=~e+(r===0),r=~r+1>>>0,i="-");var n="",o,s,a,l,c,u;{if(o=e%hr,e=e/hr>>>0,s=4294967296*o+r,r=s/hr>>>0,a=""+(s-hr*r),r===0&&e===0)return i+a+n;for(l="",c=6-a.length,u=0;u<c;u++)l+="0";n=l+a+n}{if(o=e%hr,e=e/hr>>>0,s=4294967296*o+r,r=s/hr>>>0,a=""+(s-hr*r),r===0&&e===0)return i+a+n;for(l="",c=6-a.length,u=0;u<c;u++)l+="0";n=l+a+n}{if(o=e%hr,e=e/hr>>>0,s=4294967296*o+r,r=s/hr>>>0,a=""+(s-hr*r),r===0&&e===0)return i+a+n;for(l="",c=6-a.length,u=0;u<c;u++)l+="0";n=l+a+n}return o=e%hr,s=4294967296*o+r,a=""+s%hr,i+a+n}AD.exports=S5});var MD=h((VEe,PD)=>{var E5=KD(),it=function(t,e,r,i,n){r=r||0,i=i||!1,n=n||function(p,m,y){return p*Math.pow(2,y)+m};var o=r>>3,s=function(p){return i?~p&255:p},a=255,l=8-r%8;e<l&&(a=255<<8-e&255,l=e),r&&(a=a>>r%8);var c=0;r%8+e>=8&&(c=n(0,s(t[o])&a,l));for(var u=e+r>>3,d=o+1;d<u;d++)c=n(c,s(t[d]),8);var f=(e+r)%8;return f>0&&(c=n(c,s(t[u])>>8-f,f)),c},jD=function(t,e,r){var i=Math.pow(2,r-1)-1,n=it(t,1),o=it(t,r,1);if(o===0)return 0;var s=1,a=function(c,u,d){c===0&&(c=1);for(var f=1;f<=d;f++)s/=2,(u&1<<d-f)>0&&(c+=s);return c},l=it(t,e,r+1,!1,a);return o==Math.pow(2,r+1)-1?l===0?n===0?1/0:-1/0:NaN:(n===0?1:-1)*Math.pow(2,o-i)*l},w5=function(t){return it(t,1)==1?-1*(it(t,15,1,!0)+1):it(t,15,1)},RD=function(t){return it(t,1)==1?-1*(it(t,31,1,!0)+1):it(t,31,1)},x5=function(t){return jD(t,23,8)},I5=function(t){return jD(t,52,11)},k5=function(t){var e=it(t,16,32);if(e==49152)return NaN;for(var r=Math.pow(1e4,it(t,16,16)),i=0,n=[],o=it(t,16),s=0;s<o;s++)i+=it(t,16,64+16*s)*r,r/=1e4;var a=Math.pow(10,it(t,16,48));return(e===0?1:-1)*Math.round(i*a)/a},DD=function(t,e){var r=it(e,1),i=it(e,63,1),n=new Date((r===0?1:-1)*i/1e3+9466848e5);return t||n.setTime(n.getTime()+n.getTimezoneOffset()*6e4),n.usec=i%1e3,n.getMicroSeconds=function(){return this.usec},n.setMicroSeconds=function(o){this.usec=o},n.getUTCMicroSeconds=function(){return this.usec},n},vc=function(t){for(var e=it(t,32),r=it(t,32,32),i=it(t,32,64),n=96,o=[],s=0;s<e;s++)o[s]=it(t,32,n),n+=32,n+=32;var a=function(c){var u=it(t,32,n);if(n+=32,u==4294967295)return null;var d;if(c==23||c==20)return d=it(t,u*8,n),n+=u*8,d;if(c==25)return d=t.toString(this.encoding,n>>3,(n+=u<<3)>>3),d;console.log("ERROR: ElementType not implemented: "+c)},l=function(c,u){var d=[],f;if(c.length>1){var p=c.shift();for(f=0;f<p;f++)d[f]=l(c,u);c.unshift(p)}else for(f=0;f<c[0];f++)d[f]=a(u);return d};return l(o,i)},_5=function(t){return t.toString("utf8")},T5=function(t){return t===null?null:it(t,8)>0},C5=function(t){t(20,E5),t(21,w5),t(23,RD),t(26,RD),t(1700,k5),t(700,x5),t(701,I5),t(16,T5),t(1114,DD.bind(null,!1)),t(1184,DD.bind(null,!0)),t(1e3,vc),t(1007,vc),t(1016,vc),t(1008,vc),t(1009,vc),t(25,_5)};PD.exports={init:C5}});var LD=h((BEe,ND)=>{ND.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}});var wc=h(Ec=>{var O5=OD(),A5=MD(),K5=Zv(),R5=LD();Ec.getTypeParser=D5;Ec.setTypeParser=j5;Ec.arrayParser=K5;Ec.builtins=R5;var Sc={text:{},binary:{}};function UD(t){return String(t)}function D5(t,e){return e=e||"text",Sc[e]&&Sc[e][t]||UD}function j5(t,e,r){typeof e=="function"&&(r=e,e="text"),Sc[e][t]=r}O5.init(function(t,e){Sc.text[t]=e});A5.init(function(t,e){Sc.binary[t]=e})});var xc=h((ZEe,nS)=>{"use strict";var $D;try{$D=process.platform==="win32"?process.env.USERNAME:process.env.USER}catch{}nS.exports={host:"localhost",user:$D,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4,client_encoding:"",ssl:!1,sslnegotiation:void 0,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};var ca=wc(),P5=ca.getTypeParser(20,"text"),M5=ca.getTypeParser(1016,"text");nS.exports.__defineSetter__("parseInt8",function(t){ca.setTypeParser(20,"text",t?ca.getTypeParser(23,"text"):P5),ca.setTypeParser(1016,"text",t?ca.getTypeParser(1007,"text"):M5)})});var ua=h((HEe,FD)=>{"use strict";var N5=xc(),{isDate:L5}=U("util/types");function U5(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function JD(t){let e="{";for(let r=0;r<t.length;r++){r>0&&(e+=",");let i=t[r];i==null?e+="NULL":Array.isArray(i)?e+=JD(i):ArrayBuffer.isView(i)?(i instanceof Buffer||(i=Buffer.from(i.buffer,i.byteOffset,i.byteLength)),e+="\\\\x"+i.toString("hex")):e+=U5(wp(i))}return e+="}",e}var wp=function(t,e){return t==null?null:typeof t=="object"?t instanceof Buffer?t:ArrayBuffer.isView(t)?Buffer.from(t.buffer,t.byteOffset,t.byteLength):L5(t)?N5.parseInputDatesAsUTC?F5(t):J5(t):Array.isArray(t)?JD(t):$5(t,e):t.toString()};function $5(t,e){if(t&&typeof t.toPostgres=="function"){if(e=e||[],e.indexOf(t)!==-1)throw new Error('circular reference detected while preparing "'+t+'" for query');return e.push(t),wp(t.toPostgres(wp),e)}return JSON.stringify(t)}function J5(t){let e=-t.getTimezoneOffset(),r=t.getFullYear(),i=r<1;i&&(r=Math.abs(r)+1);let n=String(r).padStart(4,"0")+"-"+String(t.getMonth()+1).padStart(2,"0")+"-"+String(t.getDate()).padStart(2,"0")+"T"+String(t.getHours()).padStart(2,"0")+":"+String(t.getMinutes()).padStart(2,"0")+":"+String(t.getSeconds()).padStart(2,"0")+"."+String(t.getMilliseconds()).padStart(3,"0");return e<0?(n+="-",e*=-1):n+="+",n+=String(Math.floor(e/60)).padStart(2,"0")+":"+String(e%60).padStart(2,"0"),i&&(n+=" BC"),n}function F5(t){let e=t.getUTCFullYear(),r=e<1;r&&(e=Math.abs(e)+1);let i=String(e).padStart(4,"0")+"-"+String(t.getUTCMonth()+1).padStart(2,"0")+"-"+String(t.getUTCDate()).padStart(2,"0")+"T"+String(t.getUTCHours()).padStart(2,"0")+":"+String(t.getUTCMinutes()).padStart(2,"0")+":"+String(t.getUTCSeconds()).padStart(2,"0")+"."+String(t.getUTCMilliseconds()).padStart(3,"0");return i+="+00:00",r&&(i+=" BC"),i}function q5(t,e,r){return t=typeof t=="string"?{text:t}:t,e&&(typeof e=="function"?t.callback=e:t.values=e),r&&(t.callback=r),t}var z5=function(t){return'"'+t.replace(/"/g,'""')+'"'},G5=function(t){let e=!1,r="'";if(t==null||typeof t!="string")return"''";for(let i=0;i<t.length;i++){let n=t[i];n==="'"?r+=n+n:n==="\\"?(r+=n+n,e=!0):r+=n}return r+="'",e===!0&&(r=" E"+r),r};FD.exports={prepareValue:function(e){return wp(e)},normalizeQueryConfig:q5,escapeIdentifier:z5,escapeLiteral:G5}});var sS=h((YEe,GD)=>{var qD=U("crypto");GD.exports={postgresMd5PasswordHash:B5,randomBytes:V5,deriveKey:Y5,sha256:W5,hashByName:Z5,hmacSha256:H5,md5:iS};var zD=qD.webcrypto||globalThis.crypto,jo=zD.subtle,oS=new TextEncoder;function V5(t){return zD.getRandomValues(Buffer.alloc(t))}async function iS(t){try{return qD.createHash("md5").update(t,"utf-8").digest("hex")}catch{let r=typeof t=="string"?oS.encode(t):t,i=await jo.digest("MD5",r);return Array.from(new Uint8Array(i)).map(n=>n.toString(16).padStart(2,"0")).join("")}}async function B5(t,e,r){let i=await iS(e+t);return"md5"+await iS(Buffer.concat([Buffer.from(i),r]))}async function W5(t){return await jo.digest("SHA-256",t)}async function Z5(t,e){return await jo.digest(t,e)}async function H5(t,e){let r=await jo.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await jo.sign("HMAC",r,oS.encode(e))}async function Y5(t,e,r){let i=await jo.importKey("raw",oS.encode(t),"PBKDF2",!1,["deriveBits"]),n={name:"PBKDF2",hash:"SHA-256",salt:e,iterations:r};return await jo.deriveBits(n,i,256,["deriveBits"])}});var WD=h((XEe,BD)=>{function Po(t,e){return new Error("SASL channel binding: "+t+" when parsing public certificate "+e.toString("base64"))}function aS(t,e){let r=t[e++];if(r<128)return{length:r,index:e};let i=r&127;if(i>4)throw Po("bad length",t);r=0;for(let n=0;n<i;n++)r=r<<8|t[e++];return{length:r,index:e}}function VD(t,e){if(t[e++]!==6)throw Po("non-OID data",t);let{length:r,index:i}=aS(t,e);e=i;let n=e+r,o=t[e++],s=(o/40>>0)+"."+o%40;for(;e<n;){let a=0;for(;e<n;){let l=t[e++];if(a=a<<7|l&127,l<128)break}s+="."+a}return{oid:s,index:e}}function Ic(t,e){if(t[e++]!==48)throw Po("non-sequence data",t);return aS(t,e)}function X5(t,e){e===void 0&&(e=0),e=Ic(t,e).index;let{length:r,index:i}=Ic(t,e);e=i+r,e=Ic(t,e).index;let{oid:n,index:o}=VD(t,e);switch(n){case"1.2.840.113549.1.1.4":return"MD5";case"1.2.840.113549.1.1.5":return"SHA-1";case"1.2.840.113549.1.1.11":return"SHA-256";case"1.2.840.113549.1.1.12":return"SHA-384";case"1.2.840.113549.1.1.13":return"SHA-512";case"1.2.840.113549.1.1.14":return"SHA-224";case"1.2.840.113549.1.1.15":return"SHA512-224";case"1.2.840.113549.1.1.16":return"SHA512-256";case"1.2.840.10045.4.1":return"SHA-1";case"1.2.840.10045.4.3.1":return"SHA-224";case"1.2.840.10045.4.3.2":return"SHA-256";case"1.2.840.10045.4.3.3":return"SHA-384";case"1.2.840.10045.4.3.4":return"SHA-512";case"1.2.840.113549.1.1.10":{if(e=o,e=Ic(t,e).index,t[e++]!==160)throw Po("non-tag data",t);e=aS(t,e).index,e=Ic(t,e).index;let{oid:s}=VD(t,e);switch(s){case"1.2.840.113549.2.5":return"MD5";case"1.3.14.3.2.26":return"SHA-1";case"2.16.840.1.101.3.4.2.1":return"SHA-256";case"2.16.840.1.101.3.4.2.2":return"SHA-384";case"2.16.840.1.101.3.4.2.3":return"SHA-512"}throw Po("unknown hash OID "+s,t)}case"1.3.101.110":case"1.3.101.112":return"SHA-512";case"1.3.101.111":case"1.3.101.113":throw Po("Ed448 certificate channel binding is not currently supported by Postgres")}throw Po("unknown OID "+n,t)}BD.exports={signatureAlgorithmHashFromCertificate:X5}});var XD=h((QEe,YD)=>{"use strict";var ji=sS(),{signatureAlgorithmHashFromCertificate:Q5}=WD();function e8(t){let e=/[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g,r=/[\u00AD\u034F\u1806\u180B\u180C\u180D\u200C\u200D\u2060\uFE00-\uFE0F\uFEFF]/g;return t.replace(e," ").replace(r,"").normalize("NFKC")}var lS=1e5;function t8(t,e,r=lS){let i=["SCRAM-SHA-256"];e&&i.unshift("SCRAM-SHA-256-PLUS");let n=i.find(a=>t.includes(a));if(!n)throw new Error("SASL: Only mechanism(s) "+i.join(" and ")+" are supported");if(n==="SCRAM-SHA-256-PLUS"&&typeof e.getPeerCertificate!="function")throw new Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate");let o=ji.randomBytes(18).toString("base64");return{mechanism:n,clientNonce:o,response:(n==="SCRAM-SHA-256-PLUS"?"p=tls-server-end-point":e?"y":"n")+",,n=*,r="+o,message:"SASLInitialResponse",scramMaxIterations:r}}async function r8(t,e,r,i){if(t.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(e==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof r!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let n=o8(r);if(n.nonce.startsWith(t.clientNonce)){if(n.nonce.length===t.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");let o=typeof t.scramMaxIterations=="number"?t.scramMaxIterations:lS;if(o!==0&&n.iteration>o)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count "+n.iteration+" exceeds scramMaxIterations of "+o);let s="n=*,r="+t.clientNonce,a="r="+n.nonce+",s="+n.salt+",i="+n.iteration,l=i?"eSws":"biws";if(t.mechanism==="SCRAM-SHA-256-PLUS"){let O=i.getPeerCertificate().raw,C=Q5(O);(C==="MD5"||C==="SHA-1")&&(C="SHA-256");let $=await ji.hashByName(C,O);l=Buffer.concat([Buffer.from("p=tls-server-end-point,,"),Buffer.from($)]).toString("base64")}let c="c="+l+",r="+n.nonce,u=s+","+a+","+c,d=Buffer.from(n.salt,"base64"),f=await ji.deriveKey(e8(e),d,n.iteration),p=await ji.hmacSha256(f,"Client Key"),m=await ji.sha256(p),y=await ji.hmacSha256(m,u),w=a8(Buffer.from(p),Buffer.from(y)).toString("base64"),_=await ji.hmacSha256(f,"Server Key"),A=await ji.hmacSha256(_,u);t.message="SASLResponse",t.serverSignature=Buffer.from(A).toString("base64"),t.response=c+",p="+w}function n8(t,e){if(t.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:r}=s8(e);if(r!==t.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}function i8(t){if(typeof t!="string")throw new TypeError("SASL: text must be a string");return t.split("").map((e,r)=>t.charCodeAt(r)).every(e=>e>=33&&e<=43||e>=45&&e<=126)}function ZD(t){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(t)}function HD(t){if(typeof t!="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map(t.split(",").map(e=>{if(!/^.=/.test(e))throw new Error("SASL: Invalid attribute pair entry");let r=e[0],i=e.substring(2);return[r,i]}))}function o8(t){let e=HD(t),r=e.get("r");if(r){if(!i8(r))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");let i=e.get("s");if(i){if(!ZD(i))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");let n=e.get("i");if(n){if(!/^[1-9][0-9]*$/.test(n))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");let o=parseInt(n,10);return{nonce:r,salt:i,iteration:o}}function s8(t){let e=HD(t),r=e.get("e"),i=e.get("v");if(r)throw new Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${r}"`);if(i){if(!ZD(i))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64")}else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");return{serverSignature:i}}function a8(t,e){if(!Buffer.isBuffer(t))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(e))throw new TypeError("second argument must be a Buffer");if(t.length!==e.length)throw new Error("Buffer lengths must match");if(t.length===0)throw new Error("Buffers cannot be empty");return Buffer.from(t.map((r,i)=>t[i]^e[i]))}YD.exports={startSession:t8,continueSession:r8,finalizeSession:n8,DEFAULT_MAX_SCRAM_ITERATIONS:lS}});var Ip=h((e0e,QD)=>{"use strict";var l8=wc();function xp(t){this._types=t||l8,this.text={},this.binary={}}xp.prototype.getOverrides=function(t){switch(t){case"text":return this.text;case"binary":return this.binary;default:return{}}};xp.prototype.setTypeParser=function(t,e,r){typeof e=="function"&&(r=e,e="text"),this.getOverrides(e)[t]=r};xp.prototype.getTypeParser=function(t,e){return e=e||"text",this.getOverrides(e)[t]||this._types.getTypeParser(t,e)};QD.exports=xp});var rj=h((t0e,tj)=>{"use strict";function da(t,e={}){if(t.charAt(0)==="/"){let l=t.split(" ");return{host:l[0],database:l[1]}}let r=Object.create(null),i,n=!1;/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(t)&&(t=encodeURI(t).replace(/%25(\d\d)/g,"%$1"));try{try{i=new URL(t,"postgres://base")}catch{i=new URL(t.replace("@/","@___DUMMY___/"),"postgres://base"),n=!0}}catch(l){throw l.input&&(l.input="*****REDACTED*****"),l}for(let l of i.searchParams.entries())r[l[0]]=l[1];if(r.user=r.user||decodeURIComponent(i.username),r.password=r.password||decodeURIComponent(i.password),i.protocol=="socket:")return r.host=decodeURI(i.pathname),r.database=i.searchParams.get("db"),r.client_encoding=i.searchParams.get("encoding"),r;let o=n?"":i.hostname;r.host?o&&/^%2f/i.test(o)&&(i.pathname=o+i.pathname):r.host=decodeURIComponent(o),r.port||(r.port=i.port);let s=i.pathname.slice(1)||null;r.database=s?decodeURI(s):null,(r.ssl==="true"||r.ssl==="1")&&(r.ssl=!0),r.ssl==="0"&&(r.ssl=!1),(r.sslcert||r.sslkey||r.sslrootcert||r.sslmode)&&(r.ssl={}),r.sslnegotiation==="direct"&&r.ssl===void 0&&(r.ssl=!0);let a=r.sslcert||r.sslkey||r.sslrootcert?U("fs"):null;if(r.sslcert&&(r.ssl.cert=a.readFileSync(r.sslcert).toString()),r.sslkey&&(r.ssl.key=a.readFileSync(r.sslkey).toString()),r.sslrootcert&&(r.ssl.ca=a.readFileSync(r.sslrootcert).toString()),e.useLibpqCompat&&r.uselibpqcompat)throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");if(r.uselibpqcompat==="true"||e.useLibpqCompat)switch(r.sslmode){case"disable":{r.ssl=!1;break}case"prefer":{r.ssl.rejectUnauthorized=!1;break}case"require":{r.sslrootcert?r.ssl.checkServerIdentity=function(){}:r.ssl.rejectUnauthorized=!1;break}case"verify-ca":{if(!r.ssl.ca)throw new Error("SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.");r.ssl.checkServerIdentity=function(){};break}case"verify-full":break}else switch(r.sslmode){case"disable":{r.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":{r.sslmode!=="verify-full"&&cS(r.sslmode);break}case"no-verify":{r.ssl.rejectUnauthorized=!1;break}}return r}function c8(t){return Object.entries(t).reduce((r,[i,n])=>(n!=null&&(r[i]=n),r),Object.create(null))}function ej(t){return Object.entries(t).reduce((r,[i,n])=>{if(i==="ssl"){let o=n;typeof o=="boolean"&&(r[i]=o),typeof o=="object"&&(r[i]=c8(o))}else if(n!=null)if(i==="port"){if(n!==""){let o=parseInt(n,10);if(isNaN(o))throw new Error(`Invalid ${i}: ${n}`);r[i]=o}}else r[i]=n;return r},Object.create(null))}function u8(t){return ej(da(t))}function cS(t){!cS.warned&&typeof process<"u"&&process.emitWarning&&(cS.warned=!0,process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
421
421
  In the next major version (pg-connection-string v3.0.0 and pg v9.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees.
422
422
 
423
423
  To prepare for this change:
424
424
  - If you want the current behavior, explicitly use 'sslmode=verify-full'
425
425
  - If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${t}'
426
426
 
427
- See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`))}tj.exports=da;da.parse=da;da.toClientConfig=ej;da.parseIntoClientConfig=u8});var dS=h((t0e,oj)=>{"use strict";var d8=U("dns"),ij=xc(),nj=rj().parse,Gt=function(t,e,r){return e[t]?e[t]:(r===void 0?r=process.env["PG"+t.toUpperCase()]:r===!1||(r=process.env[r]),r||ij[t])},p8=function(){switch(process.env.PGSSLMODE){case"disable":return!1;case"prefer":case"require":case"verify-ca":case"verify-full":return!0;case"no-verify":return{rejectUnauthorized:!1}}return ij.ssl},pa=function(t){return"'"+(""+t).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},kr=function(t,e,r){let i=e[r];i!=null&&t.push(r+"="+pa(i))},uS=class{constructor(e){if(e=typeof e=="string"?nj(e):e||{},e.connectionString&&(e=Object.assign({},e,nj(e.connectionString))),this.user=Gt("user",e),this.database=Gt("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt(Gt("port",e),10),this.host=Gt("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:Gt("password",e)}),this.binary=Gt("binary",e),this.options=Gt("options",e),this.ssl=typeof e.ssl>"u"?p8():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this.sslnegotiation=Gt("sslnegotiation",e,"PGSSLNEGOTIATION"),this.sslnegotiation!==void 0&&this.sslnegotiation!=="postgres"&&this.sslnegotiation!=="direct")throw new Error(`Invalid sslnegotiation value: "${this.sslnegotiation}". Valid values are "postgres" and "direct".`);if(this.sslnegotiation==="direct"&&!this.ssl)throw new Error("sslnegotiation=direct requires SSL to be enabled");this.client_encoding=Gt("client_encoding",e),this.replication=Gt("replication",e),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=Gt("application_name",e,"PGAPPNAME"),this.fallback_application_name=Gt("fallback_application_name",e,!1),this.statement_timeout=Gt("statement_timeout",e,!1),this.lock_timeout=Gt("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=Gt("idle_in_transaction_session_timeout",e,!1),this.query_timeout=Gt("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout=process.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive===!1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis=="number"&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){let r=[];kr(r,this,"user"),kr(r,this,"password"),kr(r,this,"port"),kr(r,this,"application_name"),kr(r,this,"fallback_application_name"),kr(r,this,"connect_timeout"),kr(r,this,"options");let i=typeof this.ssl=="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(kr(r,i,"sslmode"),kr(r,i,"sslca"),kr(r,i,"sslkey"),kr(r,i,"sslcert"),kr(r,i,"sslrootcert"),kr(r,this,"sslnegotiation"),this.database&&r.push("dbname="+pa(this.database)),this.replication&&r.push("replication="+pa(this.replication)),this.host&&r.push("host="+pa(this.host)),this.isDomainSocket)return e(null,r.join(" "));this.client_encoding&&r.push("client_encoding="+pa(this.client_encoding)),d8.lookup(this.host,function(n,o){return n?e(n,null):(r.push("hostaddr="+pa(o)),e(null,r.join(" ")))})}};oj.exports=uS});var fS=h((r0e,aj)=>{"use strict";var f8=wc(),sj=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,pS=class{constructor(e,r){this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=r,this.RowCtor=null,this.rowAsArray=e==="array",this.rowAsArray&&(this.parseRow=this._parseRowAsArray),this._prebuiltEmptyResultObject=null}addCommandComplete(e){let r;e.text?r=sj.exec(e.text):r=sj.exec(e.command),r&&(this.command=r[1],r[3]?(this.oid=parseInt(r[2],10),this.rowCount=parseInt(r[3],10)):r[2]&&(this.rowCount=parseInt(r[2],10)))}_parseRowAsArray(e){let r=new Array(e.length);for(let i=0,n=e.length;i<n;i++){let o=e[i];o!==null?r[i]=this._parsers[i](o):r[i]=null}return r}parseRow(e){let r={...this._prebuiltEmptyResultObject};for(let i=0,n=e.length;i<n;i++){let o=e[i],s=this.fields[i].name;if(o!==null){let a=this.fields[i].format==="binary"?Buffer.from(o):o;r[s]=this._parsers[i](a)}else r[s]=null}return r}addRow(e){this.rows.push(e)}addFields(e){this.fields=e,this.fields.length&&(this._parsers=new Array(e.length));let r=Object.create(null);for(let i=0;i<e.length;i++){let n=e[i];r[n.name]=null,this._types?this._parsers[i]=this._types.getTypeParser(n.dataTypeID,n.format||"text"):this._parsers[i]=f8.getTypeParser(n.dataTypeID,n.format||"text")}this._prebuiltEmptyResultObject={...r}}};aj.exports=pS});var dj=h((n0e,uj)=>{"use strict";var{EventEmitter:m8}=U("events"),lj=fS(),cj=ua(),mS=class extends m8{constructor(e,r,i){super(),e=cj.normalizeQueryConfig(e,r,i),this.text=e.text,this.values=e.values,this.rows=e.rows,this.types=e.types,this.name=e.name,this.queryMode=e.queryMode,this.binary=e.binary,this.portal=e.portal||"",this.callback=e.callback,this._rowMode=e.rowMode,process.domain&&e.callback&&(this.callback=process.domain.bind(e.callback)),this._result=new lj(this._rowMode,this.types),this._results=this._result,this._canceledDueToError=!1}requiresPreparation(){return this.queryMode==="extended"||this.name||this.rows?!0:!this.text||!this.values?!1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new lj(this._rowMode,this._result._types),this._results.push(this._result))}handleRowDescription(e){this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow(e){let r;if(!this._canceledDueToError){try{r=this._result.parseRow(e.fields)}catch(i){this._canceledDueToError=i;return}this.emit("row",r,this._result),this._accumulateRows&&this._result.addRow(r)}}handleCommandComplete(e,r){this._checkForMultirow(),this._result.addCommandComplete(e),this.rows&&r.sync()}handleEmptyQuery(e){this.rows&&e.sync()}handleError(e,r){if(this._canceledDueToError&&(e=this._canceledDueToError,this._canceledDueToError=!1),this.callback)return this.callback(e);this.emit("error",e)}handleReadyForQuery(e){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,e);if(this.callback)try{this.callback(null,this._results)}catch(r){process.nextTick(()=>{throw r})}this.emit("end",this._results)}submit(e){if(typeof this.text!="string"&&typeof this.name!="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");let r=e.parsedStatements[this.name];if(this.text&&r&&this.text!==r)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation()){e.stream.cork&&e.stream.cork();try{this.prepare(e)}finally{e.stream.uncork&&e.stream.uncork()}}else e.query(this.text);return null}hasBeenParsed(e){return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,r){e.execute({portal:this.portal,rows:r}),r?e.flush():e.sync()}prepare(e){this.hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:cj.prepareValue})}catch(r){e.close({type:"S",name:this.name}),e.sync(),this.handleError(r,e);return}e.describe({type:"P",name:this.portal||""}),this._getRows(e,this.rows)}handleCopyInResponse(e){e.sendCopyFail("No source stream defined")}handleCopyData(e,r){}};uj.exports=mS});var OS=h(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.NoticeMessage=oe.DataRowMessage=oe.CommandCompleteMessage=oe.ReadyForQueryMessage=oe.NotificationResponseMessage=oe.BackendKeyDataMessage=oe.AuthenticationMD5Password=oe.ParameterStatusMessage=oe.ParameterDescriptionMessage=oe.RowDescriptionMessage=oe.Field=oe.CopyResponse=oe.CopyDataMessage=oe.DatabaseError=oe.copyDone=oe.emptyQuery=oe.replicationStart=oe.portalSuspended=oe.noData=oe.closeComplete=oe.bindComplete=oe.parseComplete=void 0;oe.parseComplete={name:"parseComplete",length:5};oe.bindComplete={name:"bindComplete",length:5};oe.closeComplete={name:"closeComplete",length:5};oe.noData={name:"noData",length:5};oe.portalSuspended={name:"portalSuspended",length:5};oe.replicationStart={name:"replicationStart",length:4};oe.emptyQuery={name:"emptyQuery",length:4};oe.copyDone={name:"copyDone",length:4};var hS=class extends Error{constructor(e,r,i){super(e),this.length=r,this.name=i}};oe.DatabaseError=hS;var yS=class{constructor(e,r){this.length=e,this.chunk=r,this.name="copyData"}};oe.CopyDataMessage=yS;var gS=class{constructor(e,r,i,n){this.length=e,this.name=r,this.binary=i,this.columnTypes=new Array(n)}};oe.CopyResponse=gS;var bS=class{constructor(e,r,i,n,o,s,a){this.name=e,this.tableID=r,this.columnID=i,this.dataTypeID=n,this.dataTypeSize=o,this.dataTypeModifier=s,this.format=a}};oe.Field=bS;var vS=class{constructor(e,r){this.length=e,this.fieldCount=r,this.name="rowDescription",this.fields=new Array(this.fieldCount)}};oe.RowDescriptionMessage=vS;var SS=class{constructor(e,r){this.length=e,this.parameterCount=r,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}};oe.ParameterDescriptionMessage=SS;var ES=class{constructor(e,r,i){this.length=e,this.parameterName=r,this.parameterValue=i,this.name="parameterStatus"}};oe.ParameterStatusMessage=ES;var wS=class{constructor(e,r){this.length=e,this.salt=r,this.name="authenticationMD5Password"}};oe.AuthenticationMD5Password=wS;var xS=class{constructor(e,r,i){this.length=e,this.processID=r,this.secretKey=i,this.name="backendKeyData"}};oe.BackendKeyDataMessage=xS;var IS=class{constructor(e,r,i,n){this.length=e,this.processId=r,this.channel=i,this.payload=n,this.name="notification"}};oe.NotificationResponseMessage=IS;var kS=class{constructor(e,r){this.length=e,this.status=r,this.name="readyForQuery"}};oe.ReadyForQueryMessage=kS;var _S=class{constructor(e,r){this.length=e,this.text=r,this.name="commandComplete"}};oe.CommandCompleteMessage=_S;var TS=class{constructor(e,r){this.length=e,this.fields=r,this.name="dataRow",this.fieldCount=r.length}};oe.DataRowMessage=TS;var CS=class{constructor(e,r){this.length=e,this.message=r,this.name="notice"}};oe.NoticeMessage=CS});var pj=h(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});kp.Writer=void 0;var AS=class{constructor(e=256){this.size=e,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(e)}ensure(e){if(this.buffer.length-this.offset<e){let i=this.buffer,n=i.length+(i.length>>1)+e;this.buffer=Buffer.allocUnsafe(n),i.copy(this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this.offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){if(!e)this.ensure(1);else{let r=Buffer.byteLength(e);this.ensure(r+1),this.buffer.write(e,this.offset,"utf-8"),this.offset+=r}return this.buffer[this.offset++]=0,this}addString(e=""){let r=Buffer.byteLength(e);return this.ensure(r),this.buffer.write(e,this.offset),this.offset+=r,this}addInt32PrefixedString(e){let r=Buffer.byteLength(e);this.ensure(4+r);let i=this.buffer,n=this.offset;return i[n++]=r>>>24&255,i[n++]=r>>>16&255,i[n++]=r>>>8&255,i[n++]=r>>>0&255,i.write(e,n,"utf-8"),this.offset=n+r,this}add(e){return this.ensure(e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this.headerPosition]=e;let r=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(r,this.headerPosition+1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let r=this.join(e);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),r}clear(){this.offset=5,this.headerPosition=0}};kp.Writer=AS});var mj=h(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});Tp.serialize=void 0;var KS=pj(),He=new KS.Writer,h8=t=>{He.addInt16(3).addInt16(0);for(let i of Object.keys(t))He.addCString(i).addCString(t[i]);He.addCString("client_encoding").addCString("UTF8");let e=He.addCString("").flush(),r=e.length+4;return new KS.Writer().addInt32(r).add(e).flush()},y8=()=>{let t=Buffer.allocUnsafe(8);return t.writeInt32BE(8,0),t.writeInt32BE(80877103,4),t},g8=t=>He.addCString(t).flush(112),b8=function(t,e){return He.addCString(t).addInt32PrefixedString(e),He.flush(112)},v8=function(t){return He.addString(t).flush(112)},S8=t=>He.addCString(t).flush(81),fj=[],E8=t=>{let e=t.name||"";e.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",e,e.length),console.error("This can cause conflicts and silent errors executing queries"));let r=t.types||fj,i=r.length,n=He.addCString(e).addCString(t.text).addInt16(i);for(let o=0;o<i;o++)n.addInt32(r[o]);return He.flush(80)},fa=new KS.Writer,w8=function(t,e){for(let r=0;r<t.length;r++){let i=e?e(t[r],r):t[r];i==null?(He.addInt16(0),fa.addInt32(-1)):i instanceof Buffer?(He.addInt16(1),fa.addInt32(i.length),fa.add(i)):(He.addInt16(0),fa.addInt32PrefixedString(i))}},x8=(t={})=>{let e=t.portal||"",r=t.statement||"",i=t.binary||!1,n=t.values||fj,o=n.length;He.addCString(e).addCString(r),He.addInt16(o);try{w8(n,t.valueMapper)}catch(s){throw He.clear(),fa.clear(),s}return He.addInt16(o),He.add(fa.flush()),He.addInt16(1),He.addInt16(i?1:0),He.flush(66)},I8=Buffer.from([69,0,0,0,9,0,0,0,0,0]),k8=t=>{if(!t||!t.portal&&!t.rows)return I8;let e=t.portal||"",r=t.rows||0,i=Buffer.byteLength(e),n=4+i+1+4,o=Buffer.allocUnsafe(1+n);return o[0]=69,o.writeInt32BE(n,1),o.write(e,5,"utf-8"),o[i+5]=0,o.writeUInt32BE(r,o.length-4),o},_8=(t,e)=>{let r=Buffer.allocUnsafe(16);return r.writeInt32BE(16,0),r.writeInt16BE(1234,4),r.writeInt16BE(5678,6),r.writeInt32BE(t,8),r.writeInt32BE(e,12),r},RS=(t,e)=>{let i=4+Buffer.byteLength(e)+1,n=Buffer.allocUnsafe(1+i);return n[0]=t,n.writeInt32BE(i,1),n.write(e,5,"utf-8"),n[i]=0,n},T8=He.addCString("P").flush(68),C8=He.addCString("S").flush(68),O8=t=>t.name?RS(68,`${t.type}${t.name||""}`):t.type==="P"?T8:C8,A8=t=>{let e=`${t.type}${t.name||""}`;return RS(67,e)},K8=t=>He.add(t).flush(100),R8=t=>RS(102,t),_p=t=>Buffer.from([t,0,0,0,4]),D8=_p(72),j8=_p(83),P8=_p(88),M8=_p(99),N8={startup:h8,password:g8,requestSsl:y8,sendSASLInitialResponseMessage:b8,sendSCRAMClientFinalMessage:v8,query:S8,parse:E8,bind:x8,execute:k8,describe:O8,close:A8,flush:()=>D8,sync:()=>j8,end:()=>P8,copyData:K8,copyDone:()=>M8,copyFail:R8,cancel:_8};Tp.serialize=N8});var hj=h(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.BufferReader=void 0;var DS=class{constructor(e=0){this.offset=e,this.buffer=Buffer.allocUnsafe(0),this.encoding="utf-8"}setBuffer(e,r){this.offset=e,this.buffer=r}int16(){let e=this.buffer.readInt16BE(this.offset);return this.offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE(this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this.offset+=4,e}string(e){let r=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this.offset+=e,r}cstring(){let e=this.offset,r=e;for(;this.buffer[r++];);return this.offset=r,this.buffer.toString(this.encoding,e,r-1)}bytes(e){let r=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,r}};Cp.BufferReader=DS});var vj=h(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});Op.Parser=void 0;var ot=OS(),L8=hj(),PS=1,U8=4,yj=PS+U8,_r=-1,jS=Buffer.allocUnsafe(0),MS=class{constructor(e){if(this.buffer=jS,this.bufferLength=0,this.bufferOffset=0,this.reader=new L8.BufferReader,e?.mode==="binary")throw new Error("Binary mode not supported yet");this.mode=e?.mode||"text"}parse(e,r){this.mergeBuffer(e);let i=this.bufferOffset+this.bufferLength,n=this.bufferOffset;for(;n+yj<=i;){let o=this.buffer[n],s=this.buffer.readUInt32BE(n+PS),a=PS+s;if(a+n<=i){let l=this.handlePacket(n+yj,o,s,this.buffer);r(l),n+=a}else break}n===i?(this.buffer=jS,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=i-n,this.bufferOffset=n)}mergeBuffer(e){if(this.bufferLength>0){let r=this.bufferLength+e.byteLength;if(r+this.bufferOffset>this.buffer.byteLength){let n;if(r<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)n=this.buffer;else{let o=this.buffer.byteLength*2;for(;r>=o;)o*=2;n=Buffer.allocUnsafe(o)}this.buffer.copy(n,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=n,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=r}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,r,i,n){let{reader:o}=this;o.setBuffer(e,n);let s;switch(r){case 50:s=ot.bindComplete;break;case 49:s=ot.parseComplete;break;case 51:s=ot.closeComplete;break;case 110:s=ot.noData;break;case 115:s=ot.portalSuspended;break;case 99:s=ot.copyDone;break;case 87:s=ot.replicationStart;break;case 73:s=ot.emptyQuery;break;case 68:s=Z8(o);break;case 67:s=J8(o);break;case 90:s=$8(o);break;case 65:s=G8(o);break;case 82:s=X8(o,i);break;case 83:s=H8(o);break;case 75:s=Y8(o);break;case 69:s=gj(o,"error");break;case 78:s=gj(o,"notice");break;case 84:s=V8(o);break;case 116:s=W8(o);break;case 71:s=q8(o);break;case 72:s=z8(o);break;case 100:s=F8(o,i);break;default:return new ot.DatabaseError("received invalid response: "+r.toString(16),i,"error")}return o.setBuffer(0,jS),s.length=i,s}};Op.Parser=MS;var $8=t=>{let e=t.string(1);return new ot.ReadyForQueryMessage(_r,e)},J8=t=>{let e=t.cstring();return new ot.CommandCompleteMessage(_r,e)},F8=(t,e)=>{let r=t.bytes(e-4);return new ot.CopyDataMessage(_r,r)},q8=t=>bj(t,"copyInResponse"),z8=t=>bj(t,"copyOutResponse"),bj=(t,e)=>{let r=t.byte()!==0,i=t.int16(),n=new ot.CopyResponse(_r,e,r,i);for(let o=0;o<i;o++)n.columnTypes[o]=t.int16();return n},G8=t=>{let e=t.int32(),r=t.cstring(),i=t.cstring();return new ot.NotificationResponseMessage(_r,e,r,i)},V8=t=>{let e=t.int16(),r=new ot.RowDescriptionMessage(_r,e);for(let i=0;i<e;i++)r.fields[i]=B8(t);return r},B8=t=>{let e=t.cstring(),r=t.uint32(),i=t.int16(),n=t.uint32(),o=t.int16(),s=t.int32(),a=t.int16()===0?"text":"binary";return new ot.Field(e,r,i,n,o,s,a)},W8=t=>{let e=t.int16(),r=new ot.ParameterDescriptionMessage(_r,e);for(let i=0;i<e;i++)r.dataTypeIDs[i]=t.int32();return r},Z8=t=>{let e=t.int16(),r=new Array(e);for(let i=0;i<e;i++){let n=t.int32();r[i]=n===-1?null:t.string(n)}return new ot.DataRowMessage(_r,r)},H8=t=>{let e=t.cstring(),r=t.cstring();return new ot.ParameterStatusMessage(_r,e,r)},Y8=t=>{let e=t.int32(),r=t.int32();return new ot.BackendKeyDataMessage(_r,e,r)},X8=(t,e)=>{let r=t.int32(),i={name:"authenticationOk",length:e};switch(r){case 0:break;case 3:i.length===8&&(i.name="authenticationCleartextPassword");break;case 5:if(i.length===12){i.name="authenticationMD5Password";let n=t.bytes(4);return new ot.AuthenticationMD5Password(_r,n)}break;case 10:{i.name="authenticationSASL",i.mechanisms=[];let n;do n=t.cstring(),n&&i.mechanisms.push(n);while(n)}break;case 11:i.name="authenticationSASLContinue",i.data=t.string(e-8);break;case 12:i.name="authenticationSASLFinal",i.data=t.string(e-8);break;default:throw new Error("Unknown authenticationOk message type "+r)}return i},gj=(t,e)=>{let r={},i=t.string(1);for(;i!=="\0";)r[i]=t.cstring(),i=t.string(1);let n=r.M,o=e==="notice"?new ot.NoticeMessage(_r,n):new ot.DatabaseError(n,_r,e);return o.severity=r.S,o.code=r.C,o.detail=r.D,o.hint=r.H,o.position=r.P,o.internalPosition=r.p,o.internalQuery=r.q,o.where=r.W,o.schema=r.s,o.table=r.t,o.column=r.c,o.dataType=r.d,o.constraint=r.n,o.file=r.F,o.line=r.L,o.routine=r.R,o}});var NS=h(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.DatabaseError=Mo.serialize=void 0;Mo.parse=rX;var Q8=OS();Object.defineProperty(Mo,"DatabaseError",{enumerable:!0,get:function(){return Q8.DatabaseError}});var eX=mj();Object.defineProperty(Mo,"serialize",{enumerable:!0,get:function(){return eX.serialize}});var tX=vj();function rX(t,e){let r=new tX.Parser;return t.on("data",i=>r.parse(i,e)),new Promise(i=>t.on("end",()=>i()))}});var Sj=h(LS=>{"use strict";Object.defineProperty(LS,"__esModule",{value:!0});LS.default={}});var wj=h((d0e,Ej)=>{var{getStream:nX,getSecureStream:iX}=lX();Ej.exports={getStream:nX,getSecureStream:iX};function oX(){function t(r){let i=U("net");return new i.Socket}function e(r){return U("tls").connect(r)}return{getStream:t,getSecureStream:e}}function sX(){function t(r){let{CloudflareSocket:i}=Sj();return new i(r)}function e(r){return r.socket.startTls(r),r.socket}return{getStream:t,getSecureStream:e}}function aX(){if(typeof navigator=="object"&&navigator!==null&&typeof navigator.userAgent=="string")return navigator.userAgent==="Cloudflare-Workers";if(typeof Response=="function"){let t=new Response(null,{cf:{thing:!0}});if(typeof t.cf=="object"&&t.cf!==null&&t.cf.thing)return!0}return!1}function lX(){return aX()?sX():oX()}});var $S=h((p0e,Ij)=>{"use strict";var cX=U("events").EventEmitter,{parse:uX,serialize:At}=NS(),xj=wj(),{getStream:dX}=xj,pX=At.flush(),fX=At.sync(),mX=At.end(),US=class extends cX{constructor(e){super(),e=e||{},this.stream=e.stream||dX(e.ssl),typeof this.stream=="function"&&(this.stream=this.stream(e)),this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis,this.parsedStatements={},this.ssl=e.ssl||!1,this.sslNegotiation=e.sslNegotiation||"postgres",this._ending=!1,this._emitMessage=!1;let r=this;this.on("newListener",function(i){i==="message"&&(r._emitMessage=!0)})}connect(e,r){let i=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,r),this.stream.once("connect",function(){i._keepAlive&&i.stream.setKeepAlive(!0,i._keepAliveInitialDelayMillis),i.emit("connect")});let n=function(o){i._ending&&(o.code==="ECONNRESET"||o.code==="EPIPE")||i.emit("error",o)};if(this.stream.on("error",n),this.stream.on("close",function(){i.emit("end")}),!this.ssl)return this.attachListeners(this.stream);if(this.sslNegotiation==="direct")return this.stream.once("connect",function(){i.upgradeToSSL(r,n)});this.stream.once("data",function(o){switch(o.toString("utf8")){case"S":break;case"N":return i.stream.end(),i.emit("error",new Error("The server does not support SSL connections"));default:return i.stream.end(),i.emit("error",new Error("There was an error establishing an SSL connection"))}i.upgradeToSSL(r,n)})}upgradeToSSL(e,r){let i=this,n={socket:i.stream};i.ssl!==!0&&(Object.assign(n,i.ssl),"key"in i.ssl&&(n.key=i.ssl.key)),i.sslNegotiation==="direct"&&(n.ALPNProtocols=["postgresql"]);let o=U("net");o.isIP&&o.isIP(e)===0&&(n.servername=e);try{i.stream=xj.getSecureStream(n)}catch(s){return i.emit("error",s)}i.attachListeners(i.stream),i.stream.on("error",r),i.emit("sslconnect")}attachListeners(e){uX(e,r=>{let i=r.name==="error"?"errorMessage":r.name;this._emitMessage&&this.emit("message",r),this.emit(i,r)})}requestSsl(){this.stream.write(At.requestSsl())}startup(e){this.stream.write(At.startup(e))}cancel(e,r){this._send(At.cancel(e,r))}password(e){this._send(At.password(e))}sendSASLInitialResponseMessage(e,r){this._send(At.sendSASLInitialResponseMessage(e,r))}sendSCRAMClientFinalMessage(e){this._send(At.sendSCRAMClientFinalMessage(e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(At.query(e))}parse(e){this._send(At.parse(e))}bind(e){this._send(At.bind(e))}execute(e){this._send(At.execute(e))}flush(){this.stream.writable&&this.stream.write(pX)}sync(){this._ending=!0,this._send(fX)}ref(){this.stream.ref()}unref(){this.stream.unref()}end(){if(this._ending=!0,!this._connecting||!this.stream.writable){this.stream.end();return}return this.stream.write(mX,()=>{this.stream.end()})}close(e){this._send(At.close(e))}describe(e){this._send(At.describe(e))}sendCopyFromChunk(e){this._send(At.copyData(e))}endCopyFrom(){this._send(At.copyDone())}sendCopyFail(e){this._send(At.copyFail(e))}};Ij.exports=US});var Cj=h((f0e,Tj)=>{"use strict";var{Transform:hX}=U("stream"),{StringDecoder:yX}=U("string_decoder"),Pi=Symbol("last"),Ap=Symbol("decoder");function gX(t,e,r){let i;if(this.overflow){if(i=this[Ap].write(t).split(this.matcher),i.length===1)return r();i.shift(),this.overflow=!1}else this[Pi]+=this[Ap].write(t),i=this[Pi].split(this.matcher);this[Pi]=i.pop();for(let n=0;n<i.length;n++)try{_j(this,this.mapper(i[n]))}catch(o){return r(o)}if(this.overflow=this[Pi].length>this.maxLength,this.overflow&&!this.skipOverflow){r(new Error("maximum buffer reached"));return}r()}function bX(t){if(this[Pi]+=this[Ap].end(),this[Pi])try{_j(this,this.mapper(this[Pi]))}catch(e){return t(e)}t()}function _j(t,e){e!==void 0&&t.push(e)}function kj(t){return t}function vX(t,e,r){switch(t=t||/\r?\n/,e=e||kj,r=r||{},arguments.length){case 1:typeof t=="function"?(e=t,t=/\r?\n/):typeof t=="object"&&!(t instanceof RegExp)&&!t[Symbol.split]&&(r=t,t=/\r?\n/);break;case 2:typeof t=="function"?(r=e,e=t,t=/\r?\n/):typeof e=="object"&&(r=e,e=kj)}r=Object.assign({},r),r.autoDestroy=!0,r.transform=gX,r.flush=bX,r.readableObjectMode=!0;let i=new hX(r);return i[Pi]="",i[Ap]=new yX("utf8"),i.matcher=t,i.mapper=e,i.maxLength=r.maxLength,i.skipOverflow=r.skipOverflow||!1,i.overflow=!1,i._destroy=function(n,o){this._writableState.errorEmitted=!1,o(n)},i}Tj.exports=vX});var Kj=h((m0e,ri)=>{"use strict";var Oj=U("path"),SX=U("stream").Stream,EX=Cj(),Aj=U("util"),wX=5432,Kp=process.platform==="win32",kc=process.stderr,xX=56,IX=7,kX=61440,_X=32768;function TX(t){return(t&kX)==_X}var ma=["host","port","database","user","password"],JS=ma.length,CX=ma[JS-1];function FS(){var t=kc instanceof SX&&kc.writable===!0;if(t){var e=Array.prototype.slice.call(arguments).concat(`
428
- `);kc.write(Aj.format.apply(Aj,e))}}Object.defineProperty(ri.exports,"isWin",{get:function(){return Kp},set:function(t){Kp=t}});ri.exports.warnTo=function(t){var e=kc;return kc=t,e};ri.exports.getFileName=function(t){var e=t||process.env,r=e.PGPASSFILE||(Kp?Oj.join(e.APPDATA||"./","postgresql","pgpass.conf"):Oj.join(e.HOME||"./",".pgpass"));return r};ri.exports.usePgPass=function(t,e){return Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD")?!1:Kp?!0:(e=e||"<unkn>",TX(t.mode)?t.mode&(xX|IX)?(FS('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',e),!1):!0:(FS('WARNING: password file "%s" is not a plain file',e),!1))};var OX=ri.exports.match=function(t,e){return ma.slice(0,-1).reduce(function(r,i,n){return n==1&&Number(t[i]||wX)===Number(e[i])?r&&!0:r&&(e[i]==="*"||e[i]===t[i])},!0)};ri.exports.getPassword=function(t,e,r){var i,n=e.pipe(EX());function o(l){var c=AX(l);c&&KX(c)&&OX(t,c)&&(i=c[CX],n.end())}var s=function(){e.destroy(),r(i)},a=function(l){e.destroy(),FS("WARNING: error on reading file: %s",l),r(void 0)};e.on("error",a),n.on("data",o).on("end",s).on("error",a)};var AX=ri.exports.parseLine=function(t){if(t.length<11||t.match(/^\s+#/))return null;for(var e="",r="",i=0,n=0,o=0,s={},a=!1,l=function(u,d,f){var p=t.substring(d,f);Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE")||(p=p.replace(/\\([:\\])/g,"$1")),s[ma[u]]=p},c=0;c<t.length-1;c+=1){if(e=t.charAt(c+1),r=t.charAt(c),a=i==JS-1,a){l(i,n);break}c>=0&&e==":"&&r!=="\\"&&(l(i,n,c+1),n=c+2,i+=1)}return s=Object.keys(s).length===JS?s:null,s},KX=ri.exports.isValidEntry=function(t){for(var e={0:function(s){return s.length>0},1:function(s){return s==="*"?!0:(s=Number(s),isFinite(s)&&s>0&&s<9007199254740992&&Math.floor(s)===s)},2:function(s){return s.length>0},3:function(s){return s.length>0},4:function(s){return s.length>0}},r=0;r<ma.length;r+=1){var i=e[r],n=t[ma[r]]||"",o=i(n);if(!o)return!1}return!0}});var Dj=h((y0e,qS)=>{"use strict";var h0e=U("path"),Rj=U("fs"),Rp=Kj();qS.exports=function(t,e){var r=Rp.getFileName();Rj.stat(r,function(i,n){if(i||!Rp.usePgPass(n,r))return e(void 0);var o=Rj.createReadStream(r);Rp.getPassword(t,o,e)})};qS.exports.warnTo=Rp.warnTo});var Lj=h((g0e,Nj)=>{var RX=U("events").EventEmitter,jj=ua(),_c=U("util"),Dp=XD(),DX=Ip(),jX=dS(),Mj=dj(),PX=xc(),MX=$S(),NX=sS(),Pj=_c.deprecate(()=>{},"Client.activeQuery is deprecated and will be removed in pg@9.0"),LX=_c.deprecate(()=>{},"Client.queryQueue is deprecated and will be removed in pg@9.0."),UX=_c.deprecate(()=>{},"pgpass support is deprecated and will be removed in pg@9.0. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code."),$X=_c.deprecate(()=>{},"Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0."),JX=_c.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead.");function FX(t,e){if(typeof t=="number")return Number.isFinite(t)?t:e;if(typeof t=="string"&&t.trim()!==""){let r=Number(t);return Number.isFinite(r)?r:e}return e}var jp=class extends RX{constructor(e){super(),this.connectionParameters=new jX(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let r=e||{};r.Promise&&$X(),this._Promise=r.Promise||global.Promise,this._types=new DX(r.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this._activeQuery=null,this._txStatus=null,this.enableChannelBinding=!!r.enableChannelBinding,this.scramMaxIterations=FX(r.scramMaxIterations,Dp.DEFAULT_MAX_SCRAM_ITERATIONS),this.connection=r.connection||new MX({stream:r.stream,ssl:this.connectionParameters.ssl,sslNegotiation:this.connectionParameters.sslnegotiation,keepAlive:r.keepAlive||!1,keepAliveInitialDelayMillis:r.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this._queryQueue=[],this.binary=r.binary||PX.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.sslNegotiation=this.connectionParameters.sslnegotiation||"postgres",this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this._connectionTimeoutMillis=r.connectionTimeoutMillis||0}get activeQuery(){return Pj(),this._activeQuery}set activeQuery(e){Pj(),this._activeQuery=e}_getActiveQuery(){return this._activeQuery}_errorAllQueries(e){let r=n=>{process.nextTick(()=>{n.handleError(e,this.connection)})},i=this._getActiveQuery();i&&(r(i),this._activeQuery=null),this._queryQueue.forEach(r),this._queryQueue.length=0}_connect(e){let r=this,i=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let n=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{e(n)});return}this._connecting=!0,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{i._ending=!0,i.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref&&this.connectionTimeoutHandle.unref()),this.host&&this.host.indexOf("/")===0?i.connect(this.host+"/.s.PGSQL."+this.port):i.connect(this.port,this.host),i.on("connect",function(){r.ssl?r.sslNegotiation!=="direct"&&i.requestSsl():i.startup(r.getStartupConf())}),i.on("sslconnect",function(){i.startup(r.getStartupConf())}),this._attachListeners(i),i.once("end",()=>{let n=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(n),this._ended=!0,this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(n):this._handleErrorEvent(n):this._connectionError||this._handleErrorEvent(n)),process.nextTick(()=>{this.emit("end")})})}connect(e){if(e){this._connect(e);return}return new this._Promise((r,i)=>{this._connect(n=>{n?i(n):r(this)})})}_attachListeners(e){e.on("authenticationCleartextPassword",this._handleAuthCleartextPassword.bind(this)),e.on("authenticationMD5Password",this._handleAuthMD5Password.bind(this)),e.on("authenticationSASL",this._handleAuthSASL.bind(this)),e.on("authenticationSASLContinue",this._handleAuthSASLContinue.bind(this)),e.on("authenticationSASLFinal",this._handleAuthSASLFinal.bind(this)),e.on("backendKeyData",this._handleBackendKeyData.bind(this)),e.on("error",this._handleErrorEvent.bind(this)),e.on("errorMessage",this._handleErrorMessage.bind(this)),e.on("readyForQuery",this._handleReadyForQuery.bind(this)),e.on("notice",this._handleNotice.bind(this)),e.on("rowDescription",this._handleRowDescription.bind(this)),e.on("dataRow",this._handleDataRow.bind(this)),e.on("portalSuspended",this._handlePortalSuspended.bind(this)),e.on("emptyQuery",this._handleEmptyQuery.bind(this)),e.on("commandComplete",this._handleCommandComplete.bind(this)),e.on("parseComplete",this._handleParseComplete.bind(this)),e.on("copyInResponse",this._handleCopyInResponse.bind(this)),e.on("copyData",this._handleCopyData.bind(this)),e.on("notification",this._handleNotification.bind(this))}_getPassword(e){let r=this.connection;if(typeof this.password=="function")this._Promise.resolve().then(()=>this.password(this.connectionParameters)).then(i=>{if(i!==void 0){if(typeof i!="string"){r.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=i}else this.connectionParameters.password=this.password=null;e()}).catch(i=>{r.emit("error",i)});else if(this.password!==null)e();else try{Dj()(this.connectionParameters,n=>{n!==void 0&&(UX(),this.connectionParameters.password=this.password=n),e()})}catch(i){this.emit("error",i)}}_handleAuthCleartextPassword(e){this._getPassword(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._getPassword(async()=>{try{let r=await NX.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(r)}catch(r){this.emit("error",r)}})}_handleAuthSASL(e){this._getPassword(()=>{try{this.saslSession=Dp.startSession(e.mechanisms,this.enableChannelBinding&&this.connection.stream,this.scramMaxIterations),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(r){this.connection.emit("error",r)}})}async _handleAuthSASLContinue(e){try{await Dp.continueSession(this.saslSession,this.password,e.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(r){this.connection.emit("error",r)}}_handleAuthSASLFinal(e){try{Dp.finalizeSession(this.saslSession,e.data),this.saslSession=null}catch(r){this.connection.emit("error",r)}}_handleBackendKeyData(e){this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&(this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let r=this._getActiveQuery();this._activeQuery=null,this._txStatus=e?.status??null,this.readyForQuery=!0,r&&r.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(e){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(e);this.emit("error",e)}}_handleErrorEvent(e){if(this._connecting)return this._handleErrorWhileConnecting(e);this._queryable=!1,this._errorAllQueries(e),this.emit("error",e)}_handleErrorMessage(e){if(this._connecting)return this._handleErrorWhileConnecting(e);let r=this._getActiveQuery();if(!r){this._handleErrorEvent(e);return}this._activeQuery=null,r.handleError(e,this.connection)}_handleRowDescription(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected rowDescription message from backend.");this._handleErrorEvent(i);return}r.handleRowDescription(e)}_handleDataRow(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected dataRow message from backend.");this._handleErrorEvent(i);return}r.handleDataRow(e)}_handlePortalSuspended(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected portalSuspended message from backend.");this._handleErrorEvent(i);return}r.handlePortalSuspended(this.connection)}_handleEmptyQuery(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected emptyQuery message from backend.");this._handleErrorEvent(i);return}r.handleEmptyQuery(this.connection)}_handleCommandComplete(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected commandComplete message from backend.");this._handleErrorEvent(i);return}r.handleCommandComplete(e,this.connection)}_handleParseComplete(){let e=this._getActiveQuery();if(e==null){let r=new Error("Received unexpected parseComplete message from backend.");this._handleErrorEvent(r);return}e.name&&(this.connection.parsedStatements[e.name]=e.text)}_handleCopyInResponse(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected copyInResponse message from backend.");this._handleErrorEvent(i);return}r.handleCopyInResponse(this.connection)}_handleCopyData(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected copyData message from backend.");this._handleErrorEvent(i);return}r.handleCopyData(e,this.connection)}_handleNotification(e){this.emit("notification",e)}_handleNotice(e){this.emit("notice",e)}getStartupConf(){let e=this.connectionParameters,r={user:e.user,database:e.database},i=e.application_name||e.fallback_application_name;return i&&(r.application_name=i),e.replication&&(r.replication=""+e.replication),e.statement_timeout&&(r.statement_timeout=String(parseInt(e.statement_timeout,10))),e.lock_timeout&&(r.lock_timeout=String(parseInt(e.lock_timeout,10))),e.idle_in_transaction_session_timeout&&(r.idle_in_transaction_session_timeout=String(parseInt(e.idle_in_transaction_session_timeout,10))),e.options&&(r.options=e.options),r}cancel(e,r){if(e.activeQuery===r){let i=this.connection;this.host&&this.host.indexOf("/")===0?i.connect(this.host+"/.s.PGSQL."+this.port):i.connect(this.port,this.host),i.on("connect",function(){i.cancel(e.processID,e.secretKey)})}else e._queryQueue.indexOf(r)!==-1&&e._queryQueue.splice(e._queryQueue.indexOf(r),1)}setTypeParser(e,r,i){return this._types.setTypeParser(e,r,i)}getTypeParser(e,r){return this._types.getTypeParser(e,r)}escapeIdentifier(e){return jj.escapeIdentifier(e)}escapeLiteral(e){return jj.escapeLiteral(e)}_pulseQueryQueue(){if(this.readyForQuery===!0){this._activeQuery=this._queryQueue.shift();let e=this._getActiveQuery();if(e){this.readyForQuery=!1,this.hasExecuted=!0;let r=e.submit(this.connection);r&&process.nextTick(()=>{e.handleError(r,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this._activeQuery=null,this.emit("drain"))}}query(e,r,i){let n,o;if(e==null)throw new TypeError("Client was passed a null or undefined query");if(typeof e.submit=="function")o=n=e,n.callback||(typeof r=="function"?n.callback=r:i&&(n.callback=i));else if(n=new Mj(e,r,i),!n.callback)o=new this._Promise((a,l)=>{n.callback=(c,u)=>c?l(c):a(u)}).catch(a=>{throw Error.captureStackTrace(a),a});else if(typeof n.callback!="function")throw new TypeError("callback is not a function");let s=e.query_timeout||this.connectionParameters.query_timeout;if(s){let a=n.callback||(()=>{}),l=setTimeout(()=>{let c=new Error("Query read timeout");process.nextTick(()=>{n.handleError(c,this.connection)}),a(c),n.callback=()=>{};let u=this._queryQueue.indexOf(n);u>-1&&this._queryQueue.splice(u,1),this._pulseQueryQueue()},s);n.callback=(c,u)=>{clearTimeout(l),a(c,u)}}return this.binary&&!n.binary&&(n.binary=!0),n._result&&!n._result._types&&(n._result._types=this._types),this._queryable?this._ending?(process.nextTick(()=>{n.handleError(new Error("Client was closed and is not queryable"),this.connection)}),o):(this._queryQueue.length>0&&JX(),this._queryQueue.push(n),this._pulseQueryQueue(),o):(process.nextTick(()=>{n.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),o)}ref(){this.connection.ref()}unref(){this.connection.unref()}getTransactionStatus(){return this._txStatus}end(e){if(this._ending=!0,!this.connection._connecting||this._ended)if(e){e();return}else return this._Promise.resolve();if(this._getActiveQuery()||!this._queryable?this.connection.stream.destroy():this.connection.end(),e)this.connection.once("end",e);else return new this._Promise(r=>{this.connection.once("end",r)})}get queryQueue(){return LX(),this._queryQueue}};jp.Query=Mj;Nj.exports=jp});var Jj=h((b0e,$j)=>{"use strict";var qX=U("events").EventEmitter,zS=function(){},Uj=(t,e)=>{let r=t.findIndex(e);return r===-1?void 0:t.splice(r,1)[0]},GS=class{constructor(e,r,i){this.client=e,this.idleListener=r,this.timeoutId=i}},ha=class{constructor(e){this.callback=e}};function zX(){throw new Error("Release called on client which has already been released to the pool.")}function Pp(t,e){if(e)return{callback:e,result:void 0};let r,i,n=function(s,a){s?r(s):i(a)},o=new t(function(s,a){i=s,r=a}).catch(s=>{throw Error.captureStackTrace(s),s});return{callback:n,result:o}}function GX(t,e){return function r(i){i.client=e,e.removeListener("error",r),e.on("error",()=>{t.log("additional client error after disconnection due to error",i)}),t._remove(e),t.emit("error",i,e)}}var VS=class extends qX{constructor(e,r){super(),this.options=Object.assign({},e),e!=null&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options.ssl,"key",{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||r||BS().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis=1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_promiseTry(e){let r=this.Promise;return typeof r.try=="function"?r.try(e):new r(i=>i(e()))}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this.log("pulse queue ended");return}if(this.ending){this.log("pulse queue on ending"),this._idle.length&&this._idle.slice().map(r=>{this._remove(r.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this._isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let r=this._idle.pop();clearTimeout(r.timeoutId);let i=r.client;i.ref&&i.ref();let n=r.idleListener;return this._acquireClient(i,e,n,!1)}if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e,r){let i=Uj(this._idle,o=>o.client===e);i!==void 0&&clearTimeout(i.timeoutId),this._clients=this._clients.filter(o=>o!==e);let n=this;e.end(()=>{n.emit("remove",e),typeof r=="function"&&r()})}connect(e){if(this.ending){let n=new Error("Cannot use a pool after calling end on the pool");return e?e(n):this.Promise.reject(n)}let r=Pp(this.Promise,e),i=r.result;if(this._isFull()||this._idle.length){if(this._idle.length&&process.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new ha(r.callback)),i;let n=(a,l,c)=>{clearTimeout(s),r.callback(a,l,c)},o=new ha(n),s=setTimeout(()=>{Uj(this._pendingQueue,a=>a.callback===n),o.timedOut=!0,r.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return s.unref&&s.unref(),this._pendingQueue.push(o),i}return this.newClient(new ha(r.callback)),i}newClient(e){let r=new this.Client(this.options);this._clients.push(r);let i=GX(this,r);this.log("checking client timeout");let n,o=!1;this.options.connectionTimeoutMillis&&(n=setTimeout(()=>{r.connection?(this.log("ending client due to timeout"),o=!0,r.connection.stream.destroy()):r.isConnected()||(this.log("ending client due to timeout"),o=!0,r.end())},this.options.connectionTimeoutMillis)),this.log("connecting new client"),r.connect(s=>{if(n&&clearTimeout(n),r.on("error",i),s)this.log("client failed to connect",s),this._clients=this._clients.filter(a=>a!==r),o&&(s=new Error("Connection terminated due to connection timeout",{cause:s})),this._pulseQueue(),e.timedOut||e.callback(s,void 0,zS);else{if(this.log("new client connected"),this.options.onConnect){this._promiseTry(()=>this.options.onConnect(r)).then(()=>{this._afterConnect(r,e,i)},a=>{this._clients=this._clients.filter(l=>l!==r),r.end(()=>{this._pulseQueue(),e.timedOut||e.callback(a,void 0,zS)})});return}return this._afterConnect(r,e,i)}})}_afterConnect(e,r,i){if(this.options.maxLifetimeSeconds!==0){let n=setTimeout(()=>{this.log("ending client due to expired lifetime"),this._expired.add(e),this._idle.findIndex(s=>s.client===e)!==-1&&this._acquireClient(e,new ha((s,a,l)=>l()),i,!1)},this.options.maxLifetimeSeconds*1e3);n.unref(),e.once("end",()=>clearTimeout(n))}return this._acquireClient(e,r,i,!0)}_acquireClient(e,r,i,n){n&&this.emit("connect",e),this.emit("acquire",e),e.release=this._releaseOnce(e,i),e.removeListener("error",i),r.timedOut?n&&this.options.verify?this.options.verify(e,e.release):e.release():n&&this.options.verify?this.options.verify(e,o=>{if(o)return e.release(o),r.callback(o,void 0,zS);r.callback(void 0,e,e.release)}):r.callback(void 0,e,e.release)}_releaseOnce(e,r){let i=!1;return n=>{i&&zX(),i=!0,this._release(e,r,n)}}_release(e,r,i){if(e.on("error",r),e._poolUseCount=(e._poolUseCount||0)+1,this.emit("release",i,e),i||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses)return e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this._remove(e,this._pulseQueue.bind(this));if(this._expired.has(e))return this.log("remove expired client"),this._expired.delete(e),this._remove(e,this._pulseQueue.bind(this));let o;this.options.idleTimeoutMillis&&this._isAboveMin()&&(o=setTimeout(()=>{this._isAboveMin()&&(this.log("remove idle client"),this._remove(e,this._pulseQueue.bind(this)))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&o.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new GS(e,r,o)),this._pulseQueue()}query(e,r,i){if(typeof e=="function"){let o=Pp(this.Promise,e);return setImmediate(function(){return o.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),o.result}typeof r=="function"&&(i=r,r=void 0);let n=Pp(this.Promise,i);return i=n.callback,this.connect((o,s)=>{if(o)return i(o);let a=!1,l=c=>{a||(a=!0,s.release(c),i(c))};s.once("error",l),this.log("dispatching query");try{s.query(e,r,(c,u)=>{if(this.log("query dispatched"),s.removeListener("error",l),!a)return a=!0,s.release(c),c?i(c):i(void 0,u)})}catch(c){return s.release(c),i(c)}}),n.result}end(e){if(this.log("ending"),this.ending){let i=new Error("Called end on pool more than once");return e?e(i):this.Promise.reject(i)}this.ending=!0;let r=Pp(this.Promise,e);return this._endCallback=r.callback,this._pulseQueue(),r.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((e,r)=>e+(this._expired.has(r)?1:0),0)}get totalCount(){return this._clients.length}};$j.exports=VS});var zj=h((v0e,qj)=>{"use strict";var Fj=U("events").EventEmitter,VX=U("util"),WS=ua(),ya=qj.exports=function(t,e,r){Fj.call(this),t=WS.normalizeQueryConfig(t,e,r),this.text=t.text,this.values=t.values,this.name=t.name,this.queryMode=t.queryMode,this.callback=t.callback,this.state="new",this._arrayMode=t.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(i){i==="row"&&(this._emitRowEvents=!0)}.bind(this))};VX.inherits(ya,Fj);var BX={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};ya.prototype.handleError=function(t){let e=this.native.pq.resultErrorFields();if(e)for(let r in e){let i=BX[r]||r;t[i]=e[r]}this.callback?this.callback(t):this.emit("error",t),this.state="error"};ya.prototype.then=function(t,e){return this._getPromise().then(t,e)};ya.prototype.catch=function(t){return this._getPromise().catch(t)};ya.prototype._getPromise=function(){return this._promise?this._promise:(this._promise=new Promise(function(t,e){this._once("end",t),this._once("error",e)}.bind(this)),this._promise)};ya.prototype.submit=function(t){this.state="running";let e=this;this.native=t.native,t.native.arrayMode=this._arrayMode;let r=function(i,n,o){if(t.native.arrayMode=!1,setImmediate(function(){e.emit("_done")}),i)return e.handleError(i);e._emitRowEvents&&(o.length>1?n.forEach((s,a)=>{s.forEach(l=>{e.emit("row",l,o[a])})}):n.forEach(function(s){e.emit("row",s,o)})),e.state="end",e.emit("end",o),e.callback&&e.callback(null,o)};if(process.domain&&(r=process.domain.bind(r)),this.name){this.name.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",this.name,this.name.length),console.error("This can cause conflicts and silent errors executing queries"));let i=(this.values||[]).map(WS.prepareValue);if(t.namedQueries[this.name]){if(this.text&&t.namedQueries[this.name]!==this.text){let n=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return r(n)}return t.native.execute(this.name,i,r)}return t.native.prepare(this.name,this.text,i.length,function(n){return n?r(n):(t.namedQueries[e.name]=e.text,e.native.execute(e.name,i,r))})}else if(this.values){if(!Array.isArray(this.values)){let n=new Error("Query values must be an array");return r(n)}let i=this.values.map(WS.prepareValue);t.native.query(this.text,i,r)}else this.queryMode==="extended"?t.native.query(this.text,[],r):t.native.query(this.text,r)}});var Zj=h((S0e,Wj)=>{var WX=U("util"),Gj;try{Gj=U("pg-native")}catch(t){throw t}var ZX=Ip(),Vj=U("events").EventEmitter,HX=U("util"),YX=dS(),Bj=zj(),XX=WX.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."),Vt=Wj.exports=function(t){Vj.call(this),t=t||{},this._Promise=t.Promise||global.Promise,this._types=new ZX(t.types),this.native=new Gj({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let e=this.connectionParameters=new YX(t);t.nativeConnectionString&&(e.nativeConnectionString=t.nativeConnectionString),this.user=e.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),this.database=e.database,this.host=e.host,this.port=e.port,this.namedQueries={}};Vt.Query=Bj;HX.inherits(Vt,Vj);Vt.prototype._errorAllQueries=function(t){let e=r=>{process.nextTick(()=>{r.native=this.native,r.handleError(t)})};this._hasActiveQuery()&&(e(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(e),this._queryQueue.length=0};Vt.prototype._connect=function(t){let e=this;if(this._connecting){process.nextTick(()=>t(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(r,i){if(e.connectionParameters.nativeConnectionString&&(i=e.connectionParameters.nativeConnectionString),r)return t(r);e.native.connect(i,function(n){if(n)return e.native.end(),t(n);e._connected=!0,e.native.on("error",function(o){e._queryable=!1,e._errorAllQueries(o),e.emit("error",o)}),e.native.on("notification",function(o){e.emit("notification",{channel:o.relname,payload:o.extra})}),e.emit("connect"),e._pulseQueryQueue(!0),t(null,this)})})};Vt.prototype.connect=function(t){if(t){this._connect(t);return}return new this._Promise((e,r)=>{this._connect(i=>{i?r(i):e(this)})})};Vt.prototype.query=function(t,e,r){let i,n,o,s,a;if(t==null)throw new TypeError("Client was passed a null or undefined query");if(typeof t.submit=="function")o=t.query_timeout||this.connectionParameters.query_timeout,n=i=t,typeof e=="function"&&(t.callback=e);else if(o=t.query_timeout||this.connectionParameters.query_timeout,i=new Bj(t,e,r),!i.callback){let l,c;n=new this._Promise((u,d)=>{l=u,c=d}).catch(u=>{throw Error.captureStackTrace(u),u}),i.callback=(u,d)=>u?c(u):l(d)}return o&&(a=i.callback||(()=>{}),s=setTimeout(()=>{let l=new Error("Query read timeout");process.nextTick(()=>{i.handleError(l,this.connection)}),a(l),i.callback=()=>{};let c=this._queryQueue.indexOf(i);c>-1&&this._queryQueue.splice(c,1),this._pulseQueryQueue()},o),i.callback=(l,c)=>{clearTimeout(s),a(l,c)}),this._queryable?this._ending?(i.native=this.native,process.nextTick(()=>{i.handleError(new Error("Client was closed and is not queryable"))}),n):(this._queryQueue.length>0&&XX(),this._queryQueue.push(i),this._pulseQueryQueue(),n):(i.native=this.native,process.nextTick(()=>{i.handleError(new Error("Client has encountered a connection error and is not queryable"))}),n)};Vt.prototype.end=function(t){let e=this;this._ending=!0,this._connecting&&!this._connected&&this.once("connect",()=>{this.end(()=>{})});let r;return t||(r=new this._Promise(function(i,n){t=o=>o?n(o):i()})),this.native.end(function(){e._connected=!1,e._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{e.emit("end"),t&&t()})}),r};Vt.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};Vt.prototype._pulseQueryQueue=function(t){if(!this._connected||this._hasActiveQuery())return;let e=this._queryQueue.shift();if(!e){t||this.emit("drain");return}this._activeQuery=e,e.submit(this);let r=this;e.once("_done",function(){r._pulseQueryQueue()})};Vt.prototype.cancel=function(t){this._activeQuery===t?this.native.cancel(function(){}):this._queryQueue.indexOf(t)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(t),1)};Vt.prototype.ref=function(){};Vt.prototype.unref=function(){};Vt.prototype.setTypeParser=function(t,e,r){return this._types.setTypeParser(t,e,r)};Vt.prototype.getTypeParser=function(t,e){return this._types.getTypeParser(t,e)};Vt.prototype.isConnected=function(){return this._connected};Vt.prototype.getTransactionStatus=function(){return this.native.getTransactionStatus()}});var ZS=h((E0e,Hj)=>{"use strict";Hj.exports=Zj()});var BS=h((x0e,Mp)=>{"use strict";var QX=Lj(),eQ=xc(),tQ=$S(),rQ=fS(),nQ=ua(),iQ=Jj(),oQ=Ip(),{DatabaseError:sQ}=NS(),{escapeIdentifier:aQ,escapeLiteral:lQ}=ua(),cQ=t=>class extends iQ{constructor(r){super(r,t)}},Yj=function(t){this.defaults=eQ,this.Client=t,this.Query=this.Client.Query,this.Pool=cQ(this.Client),this._pools=[],this.Connection=tQ,this.types=wc(),this.DatabaseError=sQ,this.TypeOverrides=oQ,this.escapeIdentifier=aQ,this.escapeLiteral=lQ,this.Result=rQ,this.utils=nQ},Xj=QX,Qj=!1;try{Qj=!!process.env.NODE_PG_FORCE_NATIVE}catch{}Qj&&(Xj=ZS());Mp.exports=new Yj(Xj);Object.defineProperty(Mp.exports,"native",{configurable:!0,enumerable:!1,get(){let t=null;try{t=new Yj(ZS())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object.defineProperty(Mp.exports,"native",{value:t}),t}})});var Tr,I0e,k0e,_0e,T0e,C0e,O0e,A0e,K0e,R0e,D0e,j0e,e1,t1=S(()=>{Tr=Cs(BS(),1),I0e=Tr.default.Client,k0e=Tr.default.Pool,_0e=Tr.default.Connection,T0e=Tr.default.types,C0e=Tr.default.Query,O0e=Tr.default.DatabaseError,A0e=Tr.default.escapeIdentifier,K0e=Tr.default.escapeLiteral,R0e=Tr.default.Result,D0e=Tr.default.TypeOverrides,j0e=Tr.default.defaults,e1=Tr.default});var r1={};Ce(r1,{getPostgresDatabaseUrl:()=>HS,parsePostgresConfig:()=>ga});function HS(t=process.env){return t.CLAUDE_MEM_SERVER_DATABASE_URL||null}function ga(t={}){let e=t.env??process.env,r=HS(e);if(!r){if(t.requireDatabaseUrl)throw new Error("Postgres requires CLAUDE_MEM_SERVER_DATABASE_URL");return null}return{connectionString:r,max:Np(e.CLAUDE_MEM_POSTGRES_POOL_MAX,uQ),idleTimeoutMillis:Np(e.CLAUDE_MEM_POSTGRES_IDLE_TIMEOUT_MS,dQ),connectionTimeoutMillis:Np(e.CLAUDE_MEM_POSTGRES_CONNECTION_TIMEOUT_MS,pQ),statementTimeoutMillis:Np(e.CLAUDE_MEM_POSTGRES_STATEMENT_TIMEOUT_MS,fQ),ssl:mQ(r,e)}}function Np(t,e){if(!t)return e;let r=Number.parseInt(t,10);return Number.isFinite(r)&&r>0?r:e}function mQ(t,e){if(e.CLAUDE_MEM_POSTGRES_SSL==="disable"||e.PGSSLMODE==="disable")return!1;if(e.CLAUDE_MEM_POSTGRES_SSL==="require"||e.PGSSLMODE==="require")return{rejectUnauthorized:!1};try{if(new URL(t).searchParams.get("sslmode")==="require")return{rejectUnauthorized:!1}}catch(r){let i=r instanceof Error?r:new Error(String(r));return I.warn("DB","Failed to parse Postgres connection string for sslmode, defaulting SSL off",{},i),!1}return!1}var uQ,dQ,pQ,fQ,Tc=S(()=>{"use strict";Me();uQ=10,dQ=3e4,pQ=5e3,fQ=3e4});var o1={};Ce(o1,{closePostgresPool:()=>i1,createPostgresPool:()=>Cc,getSharedPostgresPool:()=>n1,withPostgresTransaction:()=>Lp});function Cc(t){return new hQ({connectionString:t.connectionString,max:t.max,idleTimeoutMillis:t.idleTimeoutMillis,connectionTimeoutMillis:t.connectionTimeoutMillis,statement_timeout:t.statementTimeoutMillis,ssl:t.ssl})}function n1(t={}){if(ba)return ba;let e=ga({requireDatabaseUrl:t.requireDatabaseUrl??!0});if(!e)throw new Error("Postgres requires CLAUDE_MEM_SERVER_DATABASE_URL");return ba=Cc(e),ba}async function Lp(t,e){let r=await t.connect();try{await r.query("BEGIN");let i=await e(r);return await r.query("COMMIT"),i}catch(i){let n=i instanceof Error?i:new Error(String(i));throw I.warn("DB","Postgres transaction rolled back",{},n),await r.query("ROLLBACK"),i}finally{r.release()}}async function i1(t){t===ba&&(ba=null),await t.end()}var hQ,ba,Oc=S(()=>{"use strict";t1();Tc();Me();({Pool:hQ}=e1),ba=null});import{createHash as yQ,randomUUID as gQ}from"crypto";function It(){return gQ()}function gt(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function s1(t){return Array.isArray(t)?t:[]}function Ue(t){return typeof t=="number"?t:new Date(t).getTime()}function Yr(t){return t==null?null:t instanceof Date?t:new Date(t)}async function ue(t,e,r=[]){return(await t.query(e,r)).rows[0]??null}async function pn(t,e,r){if(!await ue(t,"SELECT id FROM projects WHERE id = $1 AND team_id = $2",[e,r]))throw new Error("project_id must belong to team_id")}async function ni(t,e,r,i){if(!await ue(t,"SELECT id FROM server_sessions WHERE id = $1 AND project_id = $2 AND team_id = $3",[e,r,i]))throw new Error("server_session_id must belong to project_id and team_id")}function Ac(t){return JSON.stringify(YS(t))}function fn(t){return yQ("sha256").update(Ac(t)).digest("hex")}function YS(t){if(Array.isArray(t))return t.map(YS);if(t&&typeof t=="object"){let e=t;return Object.keys(e).sort().reduce((r,i)=>(r[i]=YS(e[i]),r),{})}return t}var ii=S(()=>{"use strict"});function a1(t){return{id:t.id,keyHash:t.key_hash,teamId:t.team_id,projectId:t.project_id,actorId:t.actor_id,scopes:s1(t.scopes),revokedAtEpoch:Yr(t.revoked_at)?.getTime()??null,expiresAtEpoch:Yr(t.expires_at)?.getTime()??null,createdAtEpoch:Ue(t.created_at),updatedAtEpoch:Ue(t.updated_at)}}function bQ(t){return{id:t.id,teamId:t.team_id,projectId:t.project_id,actorId:t.actor_id,apiKeyId:t.api_key_id,action:t.action,resourceType:t.resource_type,resourceId:t.resource_id,details:gt(t.details),createdAtEpoch:Ue(t.created_at)}}var No,Up=S(()=>{"use strict";ii();No=class{constructor(e){this.client=e}client;async createApiKey(e){e.projectId&&e.teamId&&await pn(this.client,e.projectId,e.teamId);let r=e.id??It(),i=await ue(this.client,`
427
+ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`))}tj.exports=da;da.parse=da;da.toClientConfig=ej;da.parseIntoClientConfig=u8});var dS=h((r0e,oj)=>{"use strict";var d8=U("dns"),ij=xc(),nj=rj().parse,Gt=function(t,e,r){return e[t]?e[t]:(r===void 0?r=process.env["PG"+t.toUpperCase()]:r===!1||(r=process.env[r]),r||ij[t])},p8=function(){switch(process.env.PGSSLMODE){case"disable":return!1;case"prefer":case"require":case"verify-ca":case"verify-full":return!0;case"no-verify":return{rejectUnauthorized:!1}}return ij.ssl},pa=function(t){return"'"+(""+t).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},kr=function(t,e,r){let i=e[r];i!=null&&t.push(r+"="+pa(i))},uS=class{constructor(e){if(e=typeof e=="string"?nj(e):e||{},e.connectionString&&(e=Object.assign({},e,nj(e.connectionString))),this.user=Gt("user",e),this.database=Gt("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt(Gt("port",e),10),this.host=Gt("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:Gt("password",e)}),this.binary=Gt("binary",e),this.options=Gt("options",e),this.ssl=typeof e.ssl>"u"?p8():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this.sslnegotiation=Gt("sslnegotiation",e,"PGSSLNEGOTIATION"),this.sslnegotiation!==void 0&&this.sslnegotiation!=="postgres"&&this.sslnegotiation!=="direct")throw new Error(`Invalid sslnegotiation value: "${this.sslnegotiation}". Valid values are "postgres" and "direct".`);if(this.sslnegotiation==="direct"&&!this.ssl)throw new Error("sslnegotiation=direct requires SSL to be enabled");this.client_encoding=Gt("client_encoding",e),this.replication=Gt("replication",e),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=Gt("application_name",e,"PGAPPNAME"),this.fallback_application_name=Gt("fallback_application_name",e,!1),this.statement_timeout=Gt("statement_timeout",e,!1),this.lock_timeout=Gt("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=Gt("idle_in_transaction_session_timeout",e,!1),this.query_timeout=Gt("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout=process.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive===!1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis=="number"&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){let r=[];kr(r,this,"user"),kr(r,this,"password"),kr(r,this,"port"),kr(r,this,"application_name"),kr(r,this,"fallback_application_name"),kr(r,this,"connect_timeout"),kr(r,this,"options");let i=typeof this.ssl=="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(kr(r,i,"sslmode"),kr(r,i,"sslca"),kr(r,i,"sslkey"),kr(r,i,"sslcert"),kr(r,i,"sslrootcert"),kr(r,this,"sslnegotiation"),this.database&&r.push("dbname="+pa(this.database)),this.replication&&r.push("replication="+pa(this.replication)),this.host&&r.push("host="+pa(this.host)),this.isDomainSocket)return e(null,r.join(" "));this.client_encoding&&r.push("client_encoding="+pa(this.client_encoding)),d8.lookup(this.host,function(n,o){return n?e(n,null):(r.push("hostaddr="+pa(o)),e(null,r.join(" ")))})}};oj.exports=uS});var fS=h((n0e,aj)=>{"use strict";var f8=wc(),sj=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,pS=class{constructor(e,r){this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=r,this.RowCtor=null,this.rowAsArray=e==="array",this.rowAsArray&&(this.parseRow=this._parseRowAsArray),this._prebuiltEmptyResultObject=null}addCommandComplete(e){let r;e.text?r=sj.exec(e.text):r=sj.exec(e.command),r&&(this.command=r[1],r[3]?(this.oid=parseInt(r[2],10),this.rowCount=parseInt(r[3],10)):r[2]&&(this.rowCount=parseInt(r[2],10)))}_parseRowAsArray(e){let r=new Array(e.length);for(let i=0,n=e.length;i<n;i++){let o=e[i];o!==null?r[i]=this._parsers[i](o):r[i]=null}return r}parseRow(e){let r={...this._prebuiltEmptyResultObject};for(let i=0,n=e.length;i<n;i++){let o=e[i],s=this.fields[i].name;if(o!==null){let a=this.fields[i].format==="binary"?Buffer.from(o):o;r[s]=this._parsers[i](a)}else r[s]=null}return r}addRow(e){this.rows.push(e)}addFields(e){this.fields=e,this.fields.length&&(this._parsers=new Array(e.length));let r=Object.create(null);for(let i=0;i<e.length;i++){let n=e[i];r[n.name]=null,this._types?this._parsers[i]=this._types.getTypeParser(n.dataTypeID,n.format||"text"):this._parsers[i]=f8.getTypeParser(n.dataTypeID,n.format||"text")}this._prebuiltEmptyResultObject={...r}}};aj.exports=pS});var dj=h((i0e,uj)=>{"use strict";var{EventEmitter:m8}=U("events"),lj=fS(),cj=ua(),mS=class extends m8{constructor(e,r,i){super(),e=cj.normalizeQueryConfig(e,r,i),this.text=e.text,this.values=e.values,this.rows=e.rows,this.types=e.types,this.name=e.name,this.queryMode=e.queryMode,this.binary=e.binary,this.portal=e.portal||"",this.callback=e.callback,this._rowMode=e.rowMode,process.domain&&e.callback&&(this.callback=process.domain.bind(e.callback)),this._result=new lj(this._rowMode,this.types),this._results=this._result,this._canceledDueToError=!1}requiresPreparation(){return this.queryMode==="extended"||this.name||this.rows?!0:!this.text||!this.values?!1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new lj(this._rowMode,this._result._types),this._results.push(this._result))}handleRowDescription(e){this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow(e){let r;if(!this._canceledDueToError){try{r=this._result.parseRow(e.fields)}catch(i){this._canceledDueToError=i;return}this.emit("row",r,this._result),this._accumulateRows&&this._result.addRow(r)}}handleCommandComplete(e,r){this._checkForMultirow(),this._result.addCommandComplete(e),this.rows&&r.sync()}handleEmptyQuery(e){this.rows&&e.sync()}handleError(e,r){if(this._canceledDueToError&&(e=this._canceledDueToError,this._canceledDueToError=!1),this.callback)return this.callback(e);this.emit("error",e)}handleReadyForQuery(e){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,e);if(this.callback)try{this.callback(null,this._results)}catch(r){process.nextTick(()=>{throw r})}this.emit("end",this._results)}submit(e){if(typeof this.text!="string"&&typeof this.name!="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");let r=e.parsedStatements[this.name];if(this.text&&r&&this.text!==r)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation()){e.stream.cork&&e.stream.cork();try{this.prepare(e)}finally{e.stream.uncork&&e.stream.uncork()}}else e.query(this.text);return null}hasBeenParsed(e){return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,r){e.execute({portal:this.portal,rows:r}),r?e.flush():e.sync()}prepare(e){this.hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:cj.prepareValue})}catch(r){e.close({type:"S",name:this.name}),e.sync(),this.handleError(r,e);return}e.describe({type:"P",name:this.portal||""}),this._getRows(e,this.rows)}handleCopyInResponse(e){e.sendCopyFail("No source stream defined")}handleCopyData(e,r){}};uj.exports=mS});var OS=h(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.NoticeMessage=oe.DataRowMessage=oe.CommandCompleteMessage=oe.ReadyForQueryMessage=oe.NotificationResponseMessage=oe.BackendKeyDataMessage=oe.AuthenticationMD5Password=oe.ParameterStatusMessage=oe.ParameterDescriptionMessage=oe.RowDescriptionMessage=oe.Field=oe.CopyResponse=oe.CopyDataMessage=oe.DatabaseError=oe.copyDone=oe.emptyQuery=oe.replicationStart=oe.portalSuspended=oe.noData=oe.closeComplete=oe.bindComplete=oe.parseComplete=void 0;oe.parseComplete={name:"parseComplete",length:5};oe.bindComplete={name:"bindComplete",length:5};oe.closeComplete={name:"closeComplete",length:5};oe.noData={name:"noData",length:5};oe.portalSuspended={name:"portalSuspended",length:5};oe.replicationStart={name:"replicationStart",length:4};oe.emptyQuery={name:"emptyQuery",length:4};oe.copyDone={name:"copyDone",length:4};var hS=class extends Error{constructor(e,r,i){super(e),this.length=r,this.name=i}};oe.DatabaseError=hS;var yS=class{constructor(e,r){this.length=e,this.chunk=r,this.name="copyData"}};oe.CopyDataMessage=yS;var gS=class{constructor(e,r,i,n){this.length=e,this.name=r,this.binary=i,this.columnTypes=new Array(n)}};oe.CopyResponse=gS;var bS=class{constructor(e,r,i,n,o,s,a){this.name=e,this.tableID=r,this.columnID=i,this.dataTypeID=n,this.dataTypeSize=o,this.dataTypeModifier=s,this.format=a}};oe.Field=bS;var vS=class{constructor(e,r){this.length=e,this.fieldCount=r,this.name="rowDescription",this.fields=new Array(this.fieldCount)}};oe.RowDescriptionMessage=vS;var SS=class{constructor(e,r){this.length=e,this.parameterCount=r,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}};oe.ParameterDescriptionMessage=SS;var ES=class{constructor(e,r,i){this.length=e,this.parameterName=r,this.parameterValue=i,this.name="parameterStatus"}};oe.ParameterStatusMessage=ES;var wS=class{constructor(e,r){this.length=e,this.salt=r,this.name="authenticationMD5Password"}};oe.AuthenticationMD5Password=wS;var xS=class{constructor(e,r,i){this.length=e,this.processID=r,this.secretKey=i,this.name="backendKeyData"}};oe.BackendKeyDataMessage=xS;var IS=class{constructor(e,r,i,n){this.length=e,this.processId=r,this.channel=i,this.payload=n,this.name="notification"}};oe.NotificationResponseMessage=IS;var kS=class{constructor(e,r){this.length=e,this.status=r,this.name="readyForQuery"}};oe.ReadyForQueryMessage=kS;var _S=class{constructor(e,r){this.length=e,this.text=r,this.name="commandComplete"}};oe.CommandCompleteMessage=_S;var TS=class{constructor(e,r){this.length=e,this.fields=r,this.name="dataRow",this.fieldCount=r.length}};oe.DataRowMessage=TS;var CS=class{constructor(e,r){this.length=e,this.message=r,this.name="notice"}};oe.NoticeMessage=CS});var pj=h(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});kp.Writer=void 0;var AS=class{constructor(e=256){this.size=e,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(e)}ensure(e){if(this.buffer.length-this.offset<e){let i=this.buffer,n=i.length+(i.length>>1)+e;this.buffer=Buffer.allocUnsafe(n),i.copy(this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this.offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){if(!e)this.ensure(1);else{let r=Buffer.byteLength(e);this.ensure(r+1),this.buffer.write(e,this.offset,"utf-8"),this.offset+=r}return this.buffer[this.offset++]=0,this}addString(e=""){let r=Buffer.byteLength(e);return this.ensure(r),this.buffer.write(e,this.offset),this.offset+=r,this}addInt32PrefixedString(e){let r=Buffer.byteLength(e);this.ensure(4+r);let i=this.buffer,n=this.offset;return i[n++]=r>>>24&255,i[n++]=r>>>16&255,i[n++]=r>>>8&255,i[n++]=r>>>0&255,i.write(e,n,"utf-8"),this.offset=n+r,this}add(e){return this.ensure(e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this.headerPosition]=e;let r=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(r,this.headerPosition+1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let r=this.join(e);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),r}clear(){this.offset=5,this.headerPosition=0}};kp.Writer=AS});var mj=h(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});Tp.serialize=void 0;var KS=pj(),He=new KS.Writer,h8=t=>{He.addInt16(3).addInt16(0);for(let i of Object.keys(t))He.addCString(i).addCString(t[i]);He.addCString("client_encoding").addCString("UTF8");let e=He.addCString("").flush(),r=e.length+4;return new KS.Writer().addInt32(r).add(e).flush()},y8=()=>{let t=Buffer.allocUnsafe(8);return t.writeInt32BE(8,0),t.writeInt32BE(80877103,4),t},g8=t=>He.addCString(t).flush(112),b8=function(t,e){return He.addCString(t).addInt32PrefixedString(e),He.flush(112)},v8=function(t){return He.addString(t).flush(112)},S8=t=>He.addCString(t).flush(81),fj=[],E8=t=>{let e=t.name||"";e.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",e,e.length),console.error("This can cause conflicts and silent errors executing queries"));let r=t.types||fj,i=r.length,n=He.addCString(e).addCString(t.text).addInt16(i);for(let o=0;o<i;o++)n.addInt32(r[o]);return He.flush(80)},fa=new KS.Writer,w8=function(t,e){for(let r=0;r<t.length;r++){let i=e?e(t[r],r):t[r];i==null?(He.addInt16(0),fa.addInt32(-1)):i instanceof Buffer?(He.addInt16(1),fa.addInt32(i.length),fa.add(i)):(He.addInt16(0),fa.addInt32PrefixedString(i))}},x8=(t={})=>{let e=t.portal||"",r=t.statement||"",i=t.binary||!1,n=t.values||fj,o=n.length;He.addCString(e).addCString(r),He.addInt16(o);try{w8(n,t.valueMapper)}catch(s){throw He.clear(),fa.clear(),s}return He.addInt16(o),He.add(fa.flush()),He.addInt16(1),He.addInt16(i?1:0),He.flush(66)},I8=Buffer.from([69,0,0,0,9,0,0,0,0,0]),k8=t=>{if(!t||!t.portal&&!t.rows)return I8;let e=t.portal||"",r=t.rows||0,i=Buffer.byteLength(e),n=4+i+1+4,o=Buffer.allocUnsafe(1+n);return o[0]=69,o.writeInt32BE(n,1),o.write(e,5,"utf-8"),o[i+5]=0,o.writeUInt32BE(r,o.length-4),o},_8=(t,e)=>{let r=Buffer.allocUnsafe(16);return r.writeInt32BE(16,0),r.writeInt16BE(1234,4),r.writeInt16BE(5678,6),r.writeInt32BE(t,8),r.writeInt32BE(e,12),r},RS=(t,e)=>{let i=4+Buffer.byteLength(e)+1,n=Buffer.allocUnsafe(1+i);return n[0]=t,n.writeInt32BE(i,1),n.write(e,5,"utf-8"),n[i]=0,n},T8=He.addCString("P").flush(68),C8=He.addCString("S").flush(68),O8=t=>t.name?RS(68,`${t.type}${t.name||""}`):t.type==="P"?T8:C8,A8=t=>{let e=`${t.type}${t.name||""}`;return RS(67,e)},K8=t=>He.add(t).flush(100),R8=t=>RS(102,t),_p=t=>Buffer.from([t,0,0,0,4]),D8=_p(72),j8=_p(83),P8=_p(88),M8=_p(99),N8={startup:h8,password:g8,requestSsl:y8,sendSASLInitialResponseMessage:b8,sendSCRAMClientFinalMessage:v8,query:S8,parse:E8,bind:x8,execute:k8,describe:O8,close:A8,flush:()=>D8,sync:()=>j8,end:()=>P8,copyData:K8,copyDone:()=>M8,copyFail:R8,cancel:_8};Tp.serialize=N8});var hj=h(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.BufferReader=void 0;var DS=class{constructor(e=0){this.offset=e,this.buffer=Buffer.allocUnsafe(0),this.encoding="utf-8"}setBuffer(e,r){this.offset=e,this.buffer=r}int16(){let e=this.buffer.readInt16BE(this.offset);return this.offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE(this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this.offset+=4,e}string(e){let r=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this.offset+=e,r}cstring(){let e=this.offset,r=e;for(;this.buffer[r++];);return this.offset=r,this.buffer.toString(this.encoding,e,r-1)}bytes(e){let r=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,r}};Cp.BufferReader=DS});var vj=h(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});Op.Parser=void 0;var ot=OS(),L8=hj(),PS=1,U8=4,yj=PS+U8,_r=-1,jS=Buffer.allocUnsafe(0),MS=class{constructor(e){if(this.buffer=jS,this.bufferLength=0,this.bufferOffset=0,this.reader=new L8.BufferReader,e?.mode==="binary")throw new Error("Binary mode not supported yet");this.mode=e?.mode||"text"}parse(e,r){this.mergeBuffer(e);let i=this.bufferOffset+this.bufferLength,n=this.bufferOffset;for(;n+yj<=i;){let o=this.buffer[n],s=this.buffer.readUInt32BE(n+PS),a=PS+s;if(a+n<=i){let l=this.handlePacket(n+yj,o,s,this.buffer);r(l),n+=a}else break}n===i?(this.buffer=jS,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=i-n,this.bufferOffset=n)}mergeBuffer(e){if(this.bufferLength>0){let r=this.bufferLength+e.byteLength;if(r+this.bufferOffset>this.buffer.byteLength){let n;if(r<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)n=this.buffer;else{let o=this.buffer.byteLength*2;for(;r>=o;)o*=2;n=Buffer.allocUnsafe(o)}this.buffer.copy(n,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=n,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=r}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,r,i,n){let{reader:o}=this;o.setBuffer(e,n);let s;switch(r){case 50:s=ot.bindComplete;break;case 49:s=ot.parseComplete;break;case 51:s=ot.closeComplete;break;case 110:s=ot.noData;break;case 115:s=ot.portalSuspended;break;case 99:s=ot.copyDone;break;case 87:s=ot.replicationStart;break;case 73:s=ot.emptyQuery;break;case 68:s=Z8(o);break;case 67:s=J8(o);break;case 90:s=$8(o);break;case 65:s=G8(o);break;case 82:s=X8(o,i);break;case 83:s=H8(o);break;case 75:s=Y8(o);break;case 69:s=gj(o,"error");break;case 78:s=gj(o,"notice");break;case 84:s=V8(o);break;case 116:s=W8(o);break;case 71:s=q8(o);break;case 72:s=z8(o);break;case 100:s=F8(o,i);break;default:return new ot.DatabaseError("received invalid response: "+r.toString(16),i,"error")}return o.setBuffer(0,jS),s.length=i,s}};Op.Parser=MS;var $8=t=>{let e=t.string(1);return new ot.ReadyForQueryMessage(_r,e)},J8=t=>{let e=t.cstring();return new ot.CommandCompleteMessage(_r,e)},F8=(t,e)=>{let r=t.bytes(e-4);return new ot.CopyDataMessage(_r,r)},q8=t=>bj(t,"copyInResponse"),z8=t=>bj(t,"copyOutResponse"),bj=(t,e)=>{let r=t.byte()!==0,i=t.int16(),n=new ot.CopyResponse(_r,e,r,i);for(let o=0;o<i;o++)n.columnTypes[o]=t.int16();return n},G8=t=>{let e=t.int32(),r=t.cstring(),i=t.cstring();return new ot.NotificationResponseMessage(_r,e,r,i)},V8=t=>{let e=t.int16(),r=new ot.RowDescriptionMessage(_r,e);for(let i=0;i<e;i++)r.fields[i]=B8(t);return r},B8=t=>{let e=t.cstring(),r=t.uint32(),i=t.int16(),n=t.uint32(),o=t.int16(),s=t.int32(),a=t.int16()===0?"text":"binary";return new ot.Field(e,r,i,n,o,s,a)},W8=t=>{let e=t.int16(),r=new ot.ParameterDescriptionMessage(_r,e);for(let i=0;i<e;i++)r.dataTypeIDs[i]=t.int32();return r},Z8=t=>{let e=t.int16(),r=new Array(e);for(let i=0;i<e;i++){let n=t.int32();r[i]=n===-1?null:t.string(n)}return new ot.DataRowMessage(_r,r)},H8=t=>{let e=t.cstring(),r=t.cstring();return new ot.ParameterStatusMessage(_r,e,r)},Y8=t=>{let e=t.int32(),r=t.int32();return new ot.BackendKeyDataMessage(_r,e,r)},X8=(t,e)=>{let r=t.int32(),i={name:"authenticationOk",length:e};switch(r){case 0:break;case 3:i.length===8&&(i.name="authenticationCleartextPassword");break;case 5:if(i.length===12){i.name="authenticationMD5Password";let n=t.bytes(4);return new ot.AuthenticationMD5Password(_r,n)}break;case 10:{i.name="authenticationSASL",i.mechanisms=[];let n;do n=t.cstring(),n&&i.mechanisms.push(n);while(n)}break;case 11:i.name="authenticationSASLContinue",i.data=t.string(e-8);break;case 12:i.name="authenticationSASLFinal",i.data=t.string(e-8);break;default:throw new Error("Unknown authenticationOk message type "+r)}return i},gj=(t,e)=>{let r={},i=t.string(1);for(;i!=="\0";)r[i]=t.cstring(),i=t.string(1);let n=r.M,o=e==="notice"?new ot.NoticeMessage(_r,n):new ot.DatabaseError(n,_r,e);return o.severity=r.S,o.code=r.C,o.detail=r.D,o.hint=r.H,o.position=r.P,o.internalPosition=r.p,o.internalQuery=r.q,o.where=r.W,o.schema=r.s,o.table=r.t,o.column=r.c,o.dataType=r.d,o.constraint=r.n,o.file=r.F,o.line=r.L,o.routine=r.R,o}});var NS=h(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.DatabaseError=Mo.serialize=void 0;Mo.parse=rX;var Q8=OS();Object.defineProperty(Mo,"DatabaseError",{enumerable:!0,get:function(){return Q8.DatabaseError}});var eX=mj();Object.defineProperty(Mo,"serialize",{enumerable:!0,get:function(){return eX.serialize}});var tX=vj();function rX(t,e){let r=new tX.Parser;return t.on("data",i=>r.parse(i,e)),new Promise(i=>t.on("end",()=>i()))}});var Sj=h(LS=>{"use strict";Object.defineProperty(LS,"__esModule",{value:!0});LS.default={}});var wj=h((p0e,Ej)=>{var{getStream:nX,getSecureStream:iX}=lX();Ej.exports={getStream:nX,getSecureStream:iX};function oX(){function t(r){let i=U("net");return new i.Socket}function e(r){return U("tls").connect(r)}return{getStream:t,getSecureStream:e}}function sX(){function t(r){let{CloudflareSocket:i}=Sj();return new i(r)}function e(r){return r.socket.startTls(r),r.socket}return{getStream:t,getSecureStream:e}}function aX(){if(typeof navigator=="object"&&navigator!==null&&typeof navigator.userAgent=="string")return navigator.userAgent==="Cloudflare-Workers";if(typeof Response=="function"){let t=new Response(null,{cf:{thing:!0}});if(typeof t.cf=="object"&&t.cf!==null&&t.cf.thing)return!0}return!1}function lX(){return aX()?sX():oX()}});var $S=h((f0e,Ij)=>{"use strict";var cX=U("events").EventEmitter,{parse:uX,serialize:At}=NS(),xj=wj(),{getStream:dX}=xj,pX=At.flush(),fX=At.sync(),mX=At.end(),US=class extends cX{constructor(e){super(),e=e||{},this.stream=e.stream||dX(e.ssl),typeof this.stream=="function"&&(this.stream=this.stream(e)),this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis,this.parsedStatements={},this.ssl=e.ssl||!1,this.sslNegotiation=e.sslNegotiation||"postgres",this._ending=!1,this._emitMessage=!1;let r=this;this.on("newListener",function(i){i==="message"&&(r._emitMessage=!0)})}connect(e,r){let i=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,r),this.stream.once("connect",function(){i._keepAlive&&i.stream.setKeepAlive(!0,i._keepAliveInitialDelayMillis),i.emit("connect")});let n=function(o){i._ending&&(o.code==="ECONNRESET"||o.code==="EPIPE")||i.emit("error",o)};if(this.stream.on("error",n),this.stream.on("close",function(){i.emit("end")}),!this.ssl)return this.attachListeners(this.stream);if(this.sslNegotiation==="direct")return this.stream.once("connect",function(){i.upgradeToSSL(r,n)});this.stream.once("data",function(o){switch(o.toString("utf8")){case"S":break;case"N":return i.stream.end(),i.emit("error",new Error("The server does not support SSL connections"));default:return i.stream.end(),i.emit("error",new Error("There was an error establishing an SSL connection"))}i.upgradeToSSL(r,n)})}upgradeToSSL(e,r){let i=this,n={socket:i.stream};i.ssl!==!0&&(Object.assign(n,i.ssl),"key"in i.ssl&&(n.key=i.ssl.key)),i.sslNegotiation==="direct"&&(n.ALPNProtocols=["postgresql"]);let o=U("net");o.isIP&&o.isIP(e)===0&&(n.servername=e);try{i.stream=xj.getSecureStream(n)}catch(s){return i.emit("error",s)}i.attachListeners(i.stream),i.stream.on("error",r),i.emit("sslconnect")}attachListeners(e){uX(e,r=>{let i=r.name==="error"?"errorMessage":r.name;this._emitMessage&&this.emit("message",r),this.emit(i,r)})}requestSsl(){this.stream.write(At.requestSsl())}startup(e){this.stream.write(At.startup(e))}cancel(e,r){this._send(At.cancel(e,r))}password(e){this._send(At.password(e))}sendSASLInitialResponseMessage(e,r){this._send(At.sendSASLInitialResponseMessage(e,r))}sendSCRAMClientFinalMessage(e){this._send(At.sendSCRAMClientFinalMessage(e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(At.query(e))}parse(e){this._send(At.parse(e))}bind(e){this._send(At.bind(e))}execute(e){this._send(At.execute(e))}flush(){this.stream.writable&&this.stream.write(pX)}sync(){this._ending=!0,this._send(fX)}ref(){this.stream.ref()}unref(){this.stream.unref()}end(){if(this._ending=!0,!this._connecting||!this.stream.writable){this.stream.end();return}return this.stream.write(mX,()=>{this.stream.end()})}close(e){this._send(At.close(e))}describe(e){this._send(At.describe(e))}sendCopyFromChunk(e){this._send(At.copyData(e))}endCopyFrom(){this._send(At.copyDone())}sendCopyFail(e){this._send(At.copyFail(e))}};Ij.exports=US});var Cj=h((m0e,Tj)=>{"use strict";var{Transform:hX}=U("stream"),{StringDecoder:yX}=U("string_decoder"),Pi=Symbol("last"),Ap=Symbol("decoder");function gX(t,e,r){let i;if(this.overflow){if(i=this[Ap].write(t).split(this.matcher),i.length===1)return r();i.shift(),this.overflow=!1}else this[Pi]+=this[Ap].write(t),i=this[Pi].split(this.matcher);this[Pi]=i.pop();for(let n=0;n<i.length;n++)try{_j(this,this.mapper(i[n]))}catch(o){return r(o)}if(this.overflow=this[Pi].length>this.maxLength,this.overflow&&!this.skipOverflow){r(new Error("maximum buffer reached"));return}r()}function bX(t){if(this[Pi]+=this[Ap].end(),this[Pi])try{_j(this,this.mapper(this[Pi]))}catch(e){return t(e)}t()}function _j(t,e){e!==void 0&&t.push(e)}function kj(t){return t}function vX(t,e,r){switch(t=t||/\r?\n/,e=e||kj,r=r||{},arguments.length){case 1:typeof t=="function"?(e=t,t=/\r?\n/):typeof t=="object"&&!(t instanceof RegExp)&&!t[Symbol.split]&&(r=t,t=/\r?\n/);break;case 2:typeof t=="function"?(r=e,e=t,t=/\r?\n/):typeof e=="object"&&(r=e,e=kj)}r=Object.assign({},r),r.autoDestroy=!0,r.transform=gX,r.flush=bX,r.readableObjectMode=!0;let i=new hX(r);return i[Pi]="",i[Ap]=new yX("utf8"),i.matcher=t,i.mapper=e,i.maxLength=r.maxLength,i.skipOverflow=r.skipOverflow||!1,i.overflow=!1,i._destroy=function(n,o){this._writableState.errorEmitted=!1,o(n)},i}Tj.exports=vX});var Kj=h((h0e,ri)=>{"use strict";var Oj=U("path"),SX=U("stream").Stream,EX=Cj(),Aj=U("util"),wX=5432,Kp=process.platform==="win32",kc=process.stderr,xX=56,IX=7,kX=61440,_X=32768;function TX(t){return(t&kX)==_X}var ma=["host","port","database","user","password"],JS=ma.length,CX=ma[JS-1];function FS(){var t=kc instanceof SX&&kc.writable===!0;if(t){var e=Array.prototype.slice.call(arguments).concat(`
428
+ `);kc.write(Aj.format.apply(Aj,e))}}Object.defineProperty(ri.exports,"isWin",{get:function(){return Kp},set:function(t){Kp=t}});ri.exports.warnTo=function(t){var e=kc;return kc=t,e};ri.exports.getFileName=function(t){var e=t||process.env,r=e.PGPASSFILE||(Kp?Oj.join(e.APPDATA||"./","postgresql","pgpass.conf"):Oj.join(e.HOME||"./",".pgpass"));return r};ri.exports.usePgPass=function(t,e){return Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD")?!1:Kp?!0:(e=e||"<unkn>",TX(t.mode)?t.mode&(xX|IX)?(FS('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',e),!1):!0:(FS('WARNING: password file "%s" is not a plain file',e),!1))};var OX=ri.exports.match=function(t,e){return ma.slice(0,-1).reduce(function(r,i,n){return n==1&&Number(t[i]||wX)===Number(e[i])?r&&!0:r&&(e[i]==="*"||e[i]===t[i])},!0)};ri.exports.getPassword=function(t,e,r){var i,n=e.pipe(EX());function o(l){var c=AX(l);c&&KX(c)&&OX(t,c)&&(i=c[CX],n.end())}var s=function(){e.destroy(),r(i)},a=function(l){e.destroy(),FS("WARNING: error on reading file: %s",l),r(void 0)};e.on("error",a),n.on("data",o).on("end",s).on("error",a)};var AX=ri.exports.parseLine=function(t){if(t.length<11||t.match(/^\s+#/))return null;for(var e="",r="",i=0,n=0,o=0,s={},a=!1,l=function(u,d,f){var p=t.substring(d,f);Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE")||(p=p.replace(/\\([:\\])/g,"$1")),s[ma[u]]=p},c=0;c<t.length-1;c+=1){if(e=t.charAt(c+1),r=t.charAt(c),a=i==JS-1,a){l(i,n);break}c>=0&&e==":"&&r!=="\\"&&(l(i,n,c+1),n=c+2,i+=1)}return s=Object.keys(s).length===JS?s:null,s},KX=ri.exports.isValidEntry=function(t){for(var e={0:function(s){return s.length>0},1:function(s){return s==="*"?!0:(s=Number(s),isFinite(s)&&s>0&&s<9007199254740992&&Math.floor(s)===s)},2:function(s){return s.length>0},3:function(s){return s.length>0},4:function(s){return s.length>0}},r=0;r<ma.length;r+=1){var i=e[r],n=t[ma[r]]||"",o=i(n);if(!o)return!1}return!0}});var Dj=h((g0e,qS)=>{"use strict";var y0e=U("path"),Rj=U("fs"),Rp=Kj();qS.exports=function(t,e){var r=Rp.getFileName();Rj.stat(r,function(i,n){if(i||!Rp.usePgPass(n,r))return e(void 0);var o=Rj.createReadStream(r);Rp.getPassword(t,o,e)})};qS.exports.warnTo=Rp.warnTo});var Lj=h((b0e,Nj)=>{var RX=U("events").EventEmitter,jj=ua(),_c=U("util"),Dp=XD(),DX=Ip(),jX=dS(),Mj=dj(),PX=xc(),MX=$S(),NX=sS(),Pj=_c.deprecate(()=>{},"Client.activeQuery is deprecated and will be removed in pg@9.0"),LX=_c.deprecate(()=>{},"Client.queryQueue is deprecated and will be removed in pg@9.0."),UX=_c.deprecate(()=>{},"pgpass support is deprecated and will be removed in pg@9.0. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code."),$X=_c.deprecate(()=>{},"Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0."),JX=_c.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead.");function FX(t,e){if(typeof t=="number")return Number.isFinite(t)?t:e;if(typeof t=="string"&&t.trim()!==""){let r=Number(t);return Number.isFinite(r)?r:e}return e}var jp=class extends RX{constructor(e){super(),this.connectionParameters=new jX(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let r=e||{};r.Promise&&$X(),this._Promise=r.Promise||global.Promise,this._types=new DX(r.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this._activeQuery=null,this._txStatus=null,this.enableChannelBinding=!!r.enableChannelBinding,this.scramMaxIterations=FX(r.scramMaxIterations,Dp.DEFAULT_MAX_SCRAM_ITERATIONS),this.connection=r.connection||new MX({stream:r.stream,ssl:this.connectionParameters.ssl,sslNegotiation:this.connectionParameters.sslnegotiation,keepAlive:r.keepAlive||!1,keepAliveInitialDelayMillis:r.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this._queryQueue=[],this.binary=r.binary||PX.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.sslNegotiation=this.connectionParameters.sslnegotiation||"postgres",this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this._connectionTimeoutMillis=r.connectionTimeoutMillis||0}get activeQuery(){return Pj(),this._activeQuery}set activeQuery(e){Pj(),this._activeQuery=e}_getActiveQuery(){return this._activeQuery}_errorAllQueries(e){let r=n=>{process.nextTick(()=>{n.handleError(e,this.connection)})},i=this._getActiveQuery();i&&(r(i),this._activeQuery=null),this._queryQueue.forEach(r),this._queryQueue.length=0}_connect(e){let r=this,i=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let n=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{e(n)});return}this._connecting=!0,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{i._ending=!0,i.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref&&this.connectionTimeoutHandle.unref()),this.host&&this.host.indexOf("/")===0?i.connect(this.host+"/.s.PGSQL."+this.port):i.connect(this.port,this.host),i.on("connect",function(){r.ssl?r.sslNegotiation!=="direct"&&i.requestSsl():i.startup(r.getStartupConf())}),i.on("sslconnect",function(){i.startup(r.getStartupConf())}),this._attachListeners(i),i.once("end",()=>{let n=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(n),this._ended=!0,this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(n):this._handleErrorEvent(n):this._connectionError||this._handleErrorEvent(n)),process.nextTick(()=>{this.emit("end")})})}connect(e){if(e){this._connect(e);return}return new this._Promise((r,i)=>{this._connect(n=>{n?i(n):r(this)})})}_attachListeners(e){e.on("authenticationCleartextPassword",this._handleAuthCleartextPassword.bind(this)),e.on("authenticationMD5Password",this._handleAuthMD5Password.bind(this)),e.on("authenticationSASL",this._handleAuthSASL.bind(this)),e.on("authenticationSASLContinue",this._handleAuthSASLContinue.bind(this)),e.on("authenticationSASLFinal",this._handleAuthSASLFinal.bind(this)),e.on("backendKeyData",this._handleBackendKeyData.bind(this)),e.on("error",this._handleErrorEvent.bind(this)),e.on("errorMessage",this._handleErrorMessage.bind(this)),e.on("readyForQuery",this._handleReadyForQuery.bind(this)),e.on("notice",this._handleNotice.bind(this)),e.on("rowDescription",this._handleRowDescription.bind(this)),e.on("dataRow",this._handleDataRow.bind(this)),e.on("portalSuspended",this._handlePortalSuspended.bind(this)),e.on("emptyQuery",this._handleEmptyQuery.bind(this)),e.on("commandComplete",this._handleCommandComplete.bind(this)),e.on("parseComplete",this._handleParseComplete.bind(this)),e.on("copyInResponse",this._handleCopyInResponse.bind(this)),e.on("copyData",this._handleCopyData.bind(this)),e.on("notification",this._handleNotification.bind(this))}_getPassword(e){let r=this.connection;if(typeof this.password=="function")this._Promise.resolve().then(()=>this.password(this.connectionParameters)).then(i=>{if(i!==void 0){if(typeof i!="string"){r.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=i}else this.connectionParameters.password=this.password=null;e()}).catch(i=>{r.emit("error",i)});else if(this.password!==null)e();else try{Dj()(this.connectionParameters,n=>{n!==void 0&&(UX(),this.connectionParameters.password=this.password=n),e()})}catch(i){this.emit("error",i)}}_handleAuthCleartextPassword(e){this._getPassword(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._getPassword(async()=>{try{let r=await NX.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(r)}catch(r){this.emit("error",r)}})}_handleAuthSASL(e){this._getPassword(()=>{try{this.saslSession=Dp.startSession(e.mechanisms,this.enableChannelBinding&&this.connection.stream,this.scramMaxIterations),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(r){this.connection.emit("error",r)}})}async _handleAuthSASLContinue(e){try{await Dp.continueSession(this.saslSession,this.password,e.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(r){this.connection.emit("error",r)}}_handleAuthSASLFinal(e){try{Dp.finalizeSession(this.saslSession,e.data),this.saslSession=null}catch(r){this.connection.emit("error",r)}}_handleBackendKeyData(e){this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&(this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let r=this._getActiveQuery();this._activeQuery=null,this._txStatus=e?.status??null,this.readyForQuery=!0,r&&r.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(e){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(e);this.emit("error",e)}}_handleErrorEvent(e){if(this._connecting)return this._handleErrorWhileConnecting(e);this._queryable=!1,this._errorAllQueries(e),this.emit("error",e)}_handleErrorMessage(e){if(this._connecting)return this._handleErrorWhileConnecting(e);let r=this._getActiveQuery();if(!r){this._handleErrorEvent(e);return}this._activeQuery=null,r.handleError(e,this.connection)}_handleRowDescription(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected rowDescription message from backend.");this._handleErrorEvent(i);return}r.handleRowDescription(e)}_handleDataRow(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected dataRow message from backend.");this._handleErrorEvent(i);return}r.handleDataRow(e)}_handlePortalSuspended(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected portalSuspended message from backend.");this._handleErrorEvent(i);return}r.handlePortalSuspended(this.connection)}_handleEmptyQuery(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected emptyQuery message from backend.");this._handleErrorEvent(i);return}r.handleEmptyQuery(this.connection)}_handleCommandComplete(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected commandComplete message from backend.");this._handleErrorEvent(i);return}r.handleCommandComplete(e,this.connection)}_handleParseComplete(){let e=this._getActiveQuery();if(e==null){let r=new Error("Received unexpected parseComplete message from backend.");this._handleErrorEvent(r);return}e.name&&(this.connection.parsedStatements[e.name]=e.text)}_handleCopyInResponse(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected copyInResponse message from backend.");this._handleErrorEvent(i);return}r.handleCopyInResponse(this.connection)}_handleCopyData(e){let r=this._getActiveQuery();if(r==null){let i=new Error("Received unexpected copyData message from backend.");this._handleErrorEvent(i);return}r.handleCopyData(e,this.connection)}_handleNotification(e){this.emit("notification",e)}_handleNotice(e){this.emit("notice",e)}getStartupConf(){let e=this.connectionParameters,r={user:e.user,database:e.database},i=e.application_name||e.fallback_application_name;return i&&(r.application_name=i),e.replication&&(r.replication=""+e.replication),e.statement_timeout&&(r.statement_timeout=String(parseInt(e.statement_timeout,10))),e.lock_timeout&&(r.lock_timeout=String(parseInt(e.lock_timeout,10))),e.idle_in_transaction_session_timeout&&(r.idle_in_transaction_session_timeout=String(parseInt(e.idle_in_transaction_session_timeout,10))),e.options&&(r.options=e.options),r}cancel(e,r){if(e.activeQuery===r){let i=this.connection;this.host&&this.host.indexOf("/")===0?i.connect(this.host+"/.s.PGSQL."+this.port):i.connect(this.port,this.host),i.on("connect",function(){i.cancel(e.processID,e.secretKey)})}else e._queryQueue.indexOf(r)!==-1&&e._queryQueue.splice(e._queryQueue.indexOf(r),1)}setTypeParser(e,r,i){return this._types.setTypeParser(e,r,i)}getTypeParser(e,r){return this._types.getTypeParser(e,r)}escapeIdentifier(e){return jj.escapeIdentifier(e)}escapeLiteral(e){return jj.escapeLiteral(e)}_pulseQueryQueue(){if(this.readyForQuery===!0){this._activeQuery=this._queryQueue.shift();let e=this._getActiveQuery();if(e){this.readyForQuery=!1,this.hasExecuted=!0;let r=e.submit(this.connection);r&&process.nextTick(()=>{e.handleError(r,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this._activeQuery=null,this.emit("drain"))}}query(e,r,i){let n,o;if(e==null)throw new TypeError("Client was passed a null or undefined query");if(typeof e.submit=="function")o=n=e,n.callback||(typeof r=="function"?n.callback=r:i&&(n.callback=i));else if(n=new Mj(e,r,i),!n.callback)o=new this._Promise((a,l)=>{n.callback=(c,u)=>c?l(c):a(u)}).catch(a=>{throw Error.captureStackTrace(a),a});else if(typeof n.callback!="function")throw new TypeError("callback is not a function");let s=e.query_timeout||this.connectionParameters.query_timeout;if(s){let a=n.callback||(()=>{}),l=setTimeout(()=>{let c=new Error("Query read timeout");process.nextTick(()=>{n.handleError(c,this.connection)}),a(c),n.callback=()=>{};let u=this._queryQueue.indexOf(n);u>-1&&this._queryQueue.splice(u,1),this._pulseQueryQueue()},s);n.callback=(c,u)=>{clearTimeout(l),a(c,u)}}return this.binary&&!n.binary&&(n.binary=!0),n._result&&!n._result._types&&(n._result._types=this._types),this._queryable?this._ending?(process.nextTick(()=>{n.handleError(new Error("Client was closed and is not queryable"),this.connection)}),o):(this._queryQueue.length>0&&JX(),this._queryQueue.push(n),this._pulseQueryQueue(),o):(process.nextTick(()=>{n.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),o)}ref(){this.connection.ref()}unref(){this.connection.unref()}getTransactionStatus(){return this._txStatus}end(e){if(this._ending=!0,!this.connection._connecting||this._ended)if(e){e();return}else return this._Promise.resolve();if(this._getActiveQuery()||!this._queryable?this.connection.stream.destroy():this.connection.end(),e)this.connection.once("end",e);else return new this._Promise(r=>{this.connection.once("end",r)})}get queryQueue(){return LX(),this._queryQueue}};jp.Query=Mj;Nj.exports=jp});var Jj=h((v0e,$j)=>{"use strict";var qX=U("events").EventEmitter,zS=function(){},Uj=(t,e)=>{let r=t.findIndex(e);return r===-1?void 0:t.splice(r,1)[0]},GS=class{constructor(e,r,i){this.client=e,this.idleListener=r,this.timeoutId=i}},ha=class{constructor(e){this.callback=e}};function zX(){throw new Error("Release called on client which has already been released to the pool.")}function Pp(t,e){if(e)return{callback:e,result:void 0};let r,i,n=function(s,a){s?r(s):i(a)},o=new t(function(s,a){i=s,r=a}).catch(s=>{throw Error.captureStackTrace(s),s});return{callback:n,result:o}}function GX(t,e){return function r(i){i.client=e,e.removeListener("error",r),e.on("error",()=>{t.log("additional client error after disconnection due to error",i)}),t._remove(e),t.emit("error",i,e)}}var VS=class extends qX{constructor(e,r){super(),this.options=Object.assign({},e),e!=null&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options.ssl,"key",{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||r||BS().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis=1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_promiseTry(e){let r=this.Promise;return typeof r.try=="function"?r.try(e):new r(i=>i(e()))}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this.log("pulse queue ended");return}if(this.ending){this.log("pulse queue on ending"),this._idle.length&&this._idle.slice().map(r=>{this._remove(r.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this._isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let r=this._idle.pop();clearTimeout(r.timeoutId);let i=r.client;i.ref&&i.ref();let n=r.idleListener;return this._acquireClient(i,e,n,!1)}if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e,r){let i=Uj(this._idle,o=>o.client===e);i!==void 0&&clearTimeout(i.timeoutId),this._clients=this._clients.filter(o=>o!==e);let n=this;e.end(()=>{n.emit("remove",e),typeof r=="function"&&r()})}connect(e){if(this.ending){let n=new Error("Cannot use a pool after calling end on the pool");return e?e(n):this.Promise.reject(n)}let r=Pp(this.Promise,e),i=r.result;if(this._isFull()||this._idle.length){if(this._idle.length&&process.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new ha(r.callback)),i;let n=(a,l,c)=>{clearTimeout(s),r.callback(a,l,c)},o=new ha(n),s=setTimeout(()=>{Uj(this._pendingQueue,a=>a.callback===n),o.timedOut=!0,r.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return s.unref&&s.unref(),this._pendingQueue.push(o),i}return this.newClient(new ha(r.callback)),i}newClient(e){let r=new this.Client(this.options);this._clients.push(r);let i=GX(this,r);this.log("checking client timeout");let n,o=!1;this.options.connectionTimeoutMillis&&(n=setTimeout(()=>{r.connection?(this.log("ending client due to timeout"),o=!0,r.connection.stream.destroy()):r.isConnected()||(this.log("ending client due to timeout"),o=!0,r.end())},this.options.connectionTimeoutMillis)),this.log("connecting new client"),r.connect(s=>{if(n&&clearTimeout(n),r.on("error",i),s)this.log("client failed to connect",s),this._clients=this._clients.filter(a=>a!==r),o&&(s=new Error("Connection terminated due to connection timeout",{cause:s})),this._pulseQueue(),e.timedOut||e.callback(s,void 0,zS);else{if(this.log("new client connected"),this.options.onConnect){this._promiseTry(()=>this.options.onConnect(r)).then(()=>{this._afterConnect(r,e,i)},a=>{this._clients=this._clients.filter(l=>l!==r),r.end(()=>{this._pulseQueue(),e.timedOut||e.callback(a,void 0,zS)})});return}return this._afterConnect(r,e,i)}})}_afterConnect(e,r,i){if(this.options.maxLifetimeSeconds!==0){let n=setTimeout(()=>{this.log("ending client due to expired lifetime"),this._expired.add(e),this._idle.findIndex(s=>s.client===e)!==-1&&this._acquireClient(e,new ha((s,a,l)=>l()),i,!1)},this.options.maxLifetimeSeconds*1e3);n.unref(),e.once("end",()=>clearTimeout(n))}return this._acquireClient(e,r,i,!0)}_acquireClient(e,r,i,n){n&&this.emit("connect",e),this.emit("acquire",e),e.release=this._releaseOnce(e,i),e.removeListener("error",i),r.timedOut?n&&this.options.verify?this.options.verify(e,e.release):e.release():n&&this.options.verify?this.options.verify(e,o=>{if(o)return e.release(o),r.callback(o,void 0,zS);r.callback(void 0,e,e.release)}):r.callback(void 0,e,e.release)}_releaseOnce(e,r){let i=!1;return n=>{i&&zX(),i=!0,this._release(e,r,n)}}_release(e,r,i){if(e.on("error",r),e._poolUseCount=(e._poolUseCount||0)+1,this.emit("release",i,e),i||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses)return e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this._remove(e,this._pulseQueue.bind(this));if(this._expired.has(e))return this.log("remove expired client"),this._expired.delete(e),this._remove(e,this._pulseQueue.bind(this));let o;this.options.idleTimeoutMillis&&this._isAboveMin()&&(o=setTimeout(()=>{this._isAboveMin()&&(this.log("remove idle client"),this._remove(e,this._pulseQueue.bind(this)))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&o.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new GS(e,r,o)),this._pulseQueue()}query(e,r,i){if(typeof e=="function"){let o=Pp(this.Promise,e);return setImmediate(function(){return o.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),o.result}typeof r=="function"&&(i=r,r=void 0);let n=Pp(this.Promise,i);return i=n.callback,this.connect((o,s)=>{if(o)return i(o);let a=!1,l=c=>{a||(a=!0,s.release(c),i(c))};s.once("error",l),this.log("dispatching query");try{s.query(e,r,(c,u)=>{if(this.log("query dispatched"),s.removeListener("error",l),!a)return a=!0,s.release(c),c?i(c):i(void 0,u)})}catch(c){return s.release(c),i(c)}}),n.result}end(e){if(this.log("ending"),this.ending){let i=new Error("Called end on pool more than once");return e?e(i):this.Promise.reject(i)}this.ending=!0;let r=Pp(this.Promise,e);return this._endCallback=r.callback,this._pulseQueue(),r.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((e,r)=>e+(this._expired.has(r)?1:0),0)}get totalCount(){return this._clients.length}};$j.exports=VS});var zj=h((S0e,qj)=>{"use strict";var Fj=U("events").EventEmitter,VX=U("util"),WS=ua(),ya=qj.exports=function(t,e,r){Fj.call(this),t=WS.normalizeQueryConfig(t,e,r),this.text=t.text,this.values=t.values,this.name=t.name,this.queryMode=t.queryMode,this.callback=t.callback,this.state="new",this._arrayMode=t.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(i){i==="row"&&(this._emitRowEvents=!0)}.bind(this))};VX.inherits(ya,Fj);var BX={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};ya.prototype.handleError=function(t){let e=this.native.pq.resultErrorFields();if(e)for(let r in e){let i=BX[r]||r;t[i]=e[r]}this.callback?this.callback(t):this.emit("error",t),this.state="error"};ya.prototype.then=function(t,e){return this._getPromise().then(t,e)};ya.prototype.catch=function(t){return this._getPromise().catch(t)};ya.prototype._getPromise=function(){return this._promise?this._promise:(this._promise=new Promise(function(t,e){this._once("end",t),this._once("error",e)}.bind(this)),this._promise)};ya.prototype.submit=function(t){this.state="running";let e=this;this.native=t.native,t.native.arrayMode=this._arrayMode;let r=function(i,n,o){if(t.native.arrayMode=!1,setImmediate(function(){e.emit("_done")}),i)return e.handleError(i);e._emitRowEvents&&(o.length>1?n.forEach((s,a)=>{s.forEach(l=>{e.emit("row",l,o[a])})}):n.forEach(function(s){e.emit("row",s,o)})),e.state="end",e.emit("end",o),e.callback&&e.callback(null,o)};if(process.domain&&(r=process.domain.bind(r)),this.name){this.name.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",this.name,this.name.length),console.error("This can cause conflicts and silent errors executing queries"));let i=(this.values||[]).map(WS.prepareValue);if(t.namedQueries[this.name]){if(this.text&&t.namedQueries[this.name]!==this.text){let n=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return r(n)}return t.native.execute(this.name,i,r)}return t.native.prepare(this.name,this.text,i.length,function(n){return n?r(n):(t.namedQueries[e.name]=e.text,e.native.execute(e.name,i,r))})}else if(this.values){if(!Array.isArray(this.values)){let n=new Error("Query values must be an array");return r(n)}let i=this.values.map(WS.prepareValue);t.native.query(this.text,i,r)}else this.queryMode==="extended"?t.native.query(this.text,[],r):t.native.query(this.text,r)}});var Zj=h((E0e,Wj)=>{var WX=U("util"),Gj;try{Gj=U("pg-native")}catch(t){throw t}var ZX=Ip(),Vj=U("events").EventEmitter,HX=U("util"),YX=dS(),Bj=zj(),XX=WX.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."),Vt=Wj.exports=function(t){Vj.call(this),t=t||{},this._Promise=t.Promise||global.Promise,this._types=new ZX(t.types),this.native=new Gj({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let e=this.connectionParameters=new YX(t);t.nativeConnectionString&&(e.nativeConnectionString=t.nativeConnectionString),this.user=e.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),this.database=e.database,this.host=e.host,this.port=e.port,this.namedQueries={}};Vt.Query=Bj;HX.inherits(Vt,Vj);Vt.prototype._errorAllQueries=function(t){let e=r=>{process.nextTick(()=>{r.native=this.native,r.handleError(t)})};this._hasActiveQuery()&&(e(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(e),this._queryQueue.length=0};Vt.prototype._connect=function(t){let e=this;if(this._connecting){process.nextTick(()=>t(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(r,i){if(e.connectionParameters.nativeConnectionString&&(i=e.connectionParameters.nativeConnectionString),r)return t(r);e.native.connect(i,function(n){if(n)return e.native.end(),t(n);e._connected=!0,e.native.on("error",function(o){e._queryable=!1,e._errorAllQueries(o),e.emit("error",o)}),e.native.on("notification",function(o){e.emit("notification",{channel:o.relname,payload:o.extra})}),e.emit("connect"),e._pulseQueryQueue(!0),t(null,this)})})};Vt.prototype.connect=function(t){if(t){this._connect(t);return}return new this._Promise((e,r)=>{this._connect(i=>{i?r(i):e(this)})})};Vt.prototype.query=function(t,e,r){let i,n,o,s,a;if(t==null)throw new TypeError("Client was passed a null or undefined query");if(typeof t.submit=="function")o=t.query_timeout||this.connectionParameters.query_timeout,n=i=t,typeof e=="function"&&(t.callback=e);else if(o=t.query_timeout||this.connectionParameters.query_timeout,i=new Bj(t,e,r),!i.callback){let l,c;n=new this._Promise((u,d)=>{l=u,c=d}).catch(u=>{throw Error.captureStackTrace(u),u}),i.callback=(u,d)=>u?c(u):l(d)}return o&&(a=i.callback||(()=>{}),s=setTimeout(()=>{let l=new Error("Query read timeout");process.nextTick(()=>{i.handleError(l,this.connection)}),a(l),i.callback=()=>{};let c=this._queryQueue.indexOf(i);c>-1&&this._queryQueue.splice(c,1),this._pulseQueryQueue()},o),i.callback=(l,c)=>{clearTimeout(s),a(l,c)}),this._queryable?this._ending?(i.native=this.native,process.nextTick(()=>{i.handleError(new Error("Client was closed and is not queryable"))}),n):(this._queryQueue.length>0&&XX(),this._queryQueue.push(i),this._pulseQueryQueue(),n):(i.native=this.native,process.nextTick(()=>{i.handleError(new Error("Client has encountered a connection error and is not queryable"))}),n)};Vt.prototype.end=function(t){let e=this;this._ending=!0,this._connecting&&!this._connected&&this.once("connect",()=>{this.end(()=>{})});let r;return t||(r=new this._Promise(function(i,n){t=o=>o?n(o):i()})),this.native.end(function(){e._connected=!1,e._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{e.emit("end"),t&&t()})}),r};Vt.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};Vt.prototype._pulseQueryQueue=function(t){if(!this._connected||this._hasActiveQuery())return;let e=this._queryQueue.shift();if(!e){t||this.emit("drain");return}this._activeQuery=e,e.submit(this);let r=this;e.once("_done",function(){r._pulseQueryQueue()})};Vt.prototype.cancel=function(t){this._activeQuery===t?this.native.cancel(function(){}):this._queryQueue.indexOf(t)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(t),1)};Vt.prototype.ref=function(){};Vt.prototype.unref=function(){};Vt.prototype.setTypeParser=function(t,e,r){return this._types.setTypeParser(t,e,r)};Vt.prototype.getTypeParser=function(t,e){return this._types.getTypeParser(t,e)};Vt.prototype.isConnected=function(){return this._connected};Vt.prototype.getTransactionStatus=function(){return this.native.getTransactionStatus()}});var ZS=h((w0e,Hj)=>{"use strict";Hj.exports=Zj()});var BS=h((I0e,Mp)=>{"use strict";var QX=Lj(),eQ=xc(),tQ=$S(),rQ=fS(),nQ=ua(),iQ=Jj(),oQ=Ip(),{DatabaseError:sQ}=NS(),{escapeIdentifier:aQ,escapeLiteral:lQ}=ua(),cQ=t=>class extends iQ{constructor(r){super(r,t)}},Yj=function(t){this.defaults=eQ,this.Client=t,this.Query=this.Client.Query,this.Pool=cQ(this.Client),this._pools=[],this.Connection=tQ,this.types=wc(),this.DatabaseError=sQ,this.TypeOverrides=oQ,this.escapeIdentifier=aQ,this.escapeLiteral=lQ,this.Result=rQ,this.utils=nQ},Xj=QX,Qj=!1;try{Qj=!!process.env.NODE_PG_FORCE_NATIVE}catch{}Qj&&(Xj=ZS());Mp.exports=new Yj(Xj);Object.defineProperty(Mp.exports,"native",{configurable:!0,enumerable:!1,get(){let t=null;try{t=new Yj(ZS())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object.defineProperty(Mp.exports,"native",{value:t}),t}})});var Tr,k0e,_0e,T0e,C0e,O0e,A0e,K0e,R0e,D0e,j0e,P0e,e1,t1=S(()=>{Tr=Cs(BS(),1),k0e=Tr.default.Client,_0e=Tr.default.Pool,T0e=Tr.default.Connection,C0e=Tr.default.types,O0e=Tr.default.Query,A0e=Tr.default.DatabaseError,K0e=Tr.default.escapeIdentifier,R0e=Tr.default.escapeLiteral,D0e=Tr.default.Result,j0e=Tr.default.TypeOverrides,P0e=Tr.default.defaults,e1=Tr.default});var r1={};Ce(r1,{getPostgresDatabaseUrl:()=>HS,parsePostgresConfig:()=>ga});function HS(t=process.env){return t.CLAUDE_MEM_SERVER_DATABASE_URL||null}function ga(t={}){let e=t.env??process.env,r=HS(e);if(!r){if(t.requireDatabaseUrl)throw new Error("Postgres requires CLAUDE_MEM_SERVER_DATABASE_URL");return null}return{connectionString:r,max:Np(e.CLAUDE_MEM_POSTGRES_POOL_MAX,uQ),idleTimeoutMillis:Np(e.CLAUDE_MEM_POSTGRES_IDLE_TIMEOUT_MS,dQ),connectionTimeoutMillis:Np(e.CLAUDE_MEM_POSTGRES_CONNECTION_TIMEOUT_MS,pQ),statementTimeoutMillis:Np(e.CLAUDE_MEM_POSTGRES_STATEMENT_TIMEOUT_MS,fQ),ssl:mQ(r,e)}}function Np(t,e){if(!t)return e;let r=Number.parseInt(t,10);return Number.isFinite(r)&&r>0?r:e}function mQ(t,e){if(e.CLAUDE_MEM_POSTGRES_SSL==="disable"||e.PGSSLMODE==="disable")return!1;if(e.CLAUDE_MEM_POSTGRES_SSL==="require"||e.PGSSLMODE==="require")return{rejectUnauthorized:!1};try{if(new URL(t).searchParams.get("sslmode")==="require")return{rejectUnauthorized:!1}}catch(r){let i=r instanceof Error?r:new Error(String(r));return I.warn("DB","Failed to parse Postgres connection string for sslmode, defaulting SSL off",{},i),!1}return!1}var uQ,dQ,pQ,fQ,Tc=S(()=>{"use strict";Me();uQ=10,dQ=3e4,pQ=5e3,fQ=3e4});var o1={};Ce(o1,{closePostgresPool:()=>i1,createPostgresPool:()=>Cc,getSharedPostgresPool:()=>n1,withPostgresTransaction:()=>Lp});function Cc(t){return new hQ({connectionString:t.connectionString,max:t.max,idleTimeoutMillis:t.idleTimeoutMillis,connectionTimeoutMillis:t.connectionTimeoutMillis,statement_timeout:t.statementTimeoutMillis,ssl:t.ssl})}function n1(t={}){if(ba)return ba;let e=ga({requireDatabaseUrl:t.requireDatabaseUrl??!0});if(!e)throw new Error("Postgres requires CLAUDE_MEM_SERVER_DATABASE_URL");return ba=Cc(e),ba}async function Lp(t,e){let r=await t.connect();try{await r.query("BEGIN");let i=await e(r);return await r.query("COMMIT"),i}catch(i){let n=i instanceof Error?i:new Error(String(i));throw I.warn("DB","Postgres transaction rolled back",{},n),await r.query("ROLLBACK"),i}finally{r.release()}}async function i1(t){t===ba&&(ba=null),await t.end()}var hQ,ba,Oc=S(()=>{"use strict";t1();Tc();Me();({Pool:hQ}=e1),ba=null});import{createHash as yQ,randomUUID as gQ}from"crypto";function It(){return gQ()}function gt(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function s1(t){return Array.isArray(t)?t:[]}function Ue(t){return typeof t=="number"?t:new Date(t).getTime()}function Yr(t){return t==null?null:t instanceof Date?t:new Date(t)}async function ue(t,e,r=[]){return(await t.query(e,r)).rows[0]??null}async function pn(t,e,r){if(!await ue(t,"SELECT id FROM projects WHERE id = $1 AND team_id = $2",[e,r]))throw new Error("project_id must belong to team_id")}async function ni(t,e,r,i){if(!await ue(t,"SELECT id FROM server_sessions WHERE id = $1 AND project_id = $2 AND team_id = $3",[e,r,i]))throw new Error("server_session_id must belong to project_id and team_id")}function Ac(t){return JSON.stringify(YS(t))}function fn(t){return yQ("sha256").update(Ac(t)).digest("hex")}function YS(t){if(Array.isArray(t))return t.map(YS);if(t&&typeof t=="object"){let e=t;return Object.keys(e).sort().reduce((r,i)=>(r[i]=YS(e[i]),r),{})}return t}var ii=S(()=>{"use strict"});function a1(t){return{id:t.id,keyHash:t.key_hash,teamId:t.team_id,projectId:t.project_id,actorId:t.actor_id,scopes:s1(t.scopes),revokedAtEpoch:Yr(t.revoked_at)?.getTime()??null,expiresAtEpoch:Yr(t.expires_at)?.getTime()??null,createdAtEpoch:Ue(t.created_at),updatedAtEpoch:Ue(t.updated_at)}}function bQ(t){return{id:t.id,teamId:t.team_id,projectId:t.project_id,actorId:t.actor_id,apiKeyId:t.api_key_id,action:t.action,resourceType:t.resource_type,resourceId:t.resource_id,details:gt(t.details),createdAtEpoch:Ue(t.created_at)}}var No,Up=S(()=>{"use strict";ii();No=class{constructor(e){this.client=e}client;async createApiKey(e){e.projectId&&e.teamId&&await pn(this.client,e.projectId,e.teamId);let r=e.id??It(),i=await ue(this.client,`
429
429
  INSERT INTO api_keys (id, key_hash, team_id, project_id, actor_id, scopes, expires_at)
430
430
  VALUES ($1, $2, $3, $4, $5, $6::jsonb, $7)
431
431
  RETURNING *
@@ -976,11 +976,11 @@ CREATE TABLE IF NOT EXISTS rate_limit_counters (
976
976
  );
977
977
  CREATE INDEX IF NOT EXISTS idx_rate_limit_counters_window ON rate_limit_counters(window_start);
978
978
  `});var Q1={};Ce(Q1,{PostgresAgentEventsRepository:()=>Mc,PostgresAuthRepository:()=>No,PostgresDataDeletionRepository:()=>EE,PostgresObservationGenerationJobEventsRepository:()=>Uc,PostgresObservationGenerationJobRepository:()=>Lc,PostgresObservationRepository:()=>$c,PostgresObservationSourcesRepository:()=>Jc,PostgresProjectsRepository:()=>Lo,PostgresRateLimitRepository:()=>zc,PostgresServerSessionsRepository:()=>Fc,PostgresTeamsRepository:()=>Uo,PostgresUsageRepository:()=>qc,SERVER_POSTGRES_SCHEMA_VERSION:()=>H1,SERVER_POSTGRES_TABLES:()=>B9,bootstrapServerPostgresSchema:()=>Y1,buildAgentEventIdempotencyKey:()=>z1,buildObservationGenerationJobIdempotencyKey:()=>V1,buildObservationGenerationKey:()=>J9,buildServerSessionIdempotencyKey:()=>W1,closePostgresPool:()=>i1,createPostgresPool:()=>Cc,createPostgresStorageRepositories:()=>Y9,getPostgresDatabaseUrl:()=>HS,getSharedPostgresPool:()=>n1,parsePostgresConfig:()=>ga,withPostgresTransaction:()=>Lp});function Y9(t){return{teams:new Uo(t),projects:new Lo(t),auth:new No(t),sessions:new Fc(t),agentEvents:new Mc(t),observations:new $c(t),observationSources:new Jc(t),observationGenerationJobs:new Lc(t),observationGenerationJobEvents:new Uc(t),usage:new qc(t),rateLimits:new zc(t)}}var eP=S(()=>{"use strict";hE();Up();yE();gE();$p();bE();Jp();vE();SE();hE();Up();Tc();Z1();yE();gE();Oc();$p();SE();X1();bE();Jp();vE()});var Xp={};Ce(Xp,{getObservationQueueEngineName:()=>rP,getRedisQueueConfig:()=>Q9});import{existsSync as X9}from"fs";function rP(){let t=va("CLAUDE_MEM_QUEUE_ENGINE").trim().toLowerCase();if(t==="sqlite"||t==="bullmq")return t;throw new Error(`Invalid CLAUDE_MEM_QUEUE_ENGINE=${t}; expected sqlite or bullmq`)}function Q9(){let t=rP(),e=e7(va("CLAUDE_MEM_REDIS_MODE")),r=va("CLAUDE_MEM_REDIS_URL").trim()||null,i=va("CLAUDE_MEM_REDIS_HOST").trim()||"127.0.0.1",n=t7(va("CLAUDE_MEM_REDIS_PORT")),o=r7(va("CLAUDE_MEM_QUEUE_REDIS_PREFIX")),s=r?i7(r):n7(i,n);return{engine:t,mode:e,url:r,host:r?tP(r).host:i,port:r?tP(r).port:n,prefix:o,connection:s}}function va(t){if(process.env[t]!==void 0)return process.env[t];if(X9(ht)){let e=Fe.loadFromFile(ht,!1)[t];if(e!==void 0)return e}return Fe.get(t)}function e7(t){let e=t.trim().toLowerCase();if(e==="external"||e==="managed"||e==="docker")return e;throw new Error(`Invalid CLAUDE_MEM_REDIS_MODE=${t}; expected external, managed, or docker`)}function t7(t){let e=Number.parseInt(t,10);if(!Number.isInteger(e)||e<=0||e>65535)throw new Error(`Invalid CLAUDE_MEM_REDIS_PORT=${t}; expected a TCP port`);return e}function r7(t){return(t.trim()||"claude_mem").replace(/[^a-zA-Z0-9_-]/g,"_")}function n7(t,e){return{host:t,port:e,maxRetriesPerRequest:null,connectTimeout:1e3,lazyConnect:!0}}function i7(t){let e=new URL(t);if(e.protocol!=="redis:"&&e.protocol!=="rediss:")throw new Error("CLAUDE_MEM_REDIS_URL must use redis:// or rediss://");let r=e.pathname.length>1?Number.parseInt(e.pathname.slice(1),10):void 0;if(r!==void 0&&(!Number.isInteger(r)||r<0))throw new Error(`Invalid Redis database in CLAUDE_MEM_REDIS_URL: ${e.pathname}`);return{host:e.hostname||"127.0.0.1",port:e.port?Number.parseInt(e.port,10):6379,username:e.username?decodeURIComponent(e.username):void 0,password:e.password?decodeURIComponent(e.password):void 0,db:r,tls:e.protocol==="rediss:"?{}:void 0,maxRetriesPerRequest:null,connectTimeout:1e3,lazyConnect:!0}}function tP(t){let e=new URL(t);return{host:e.hostname||"127.0.0.1",port:e.port?Number.parseInt(e.port,10):6379}}var Qp=S(()=>{"use strict";Vr();nt()});var Wt={};Ce(Wt,{__addDisposableResource:()=>TP,__assign:()=>ef,__asyncDelegator:()=>vP,__asyncGenerator:()=>bP,__asyncValues:()=>SP,__await:()=>Sa,__awaiter:()=>pP,__classPrivateFieldGet:()=>IP,__classPrivateFieldIn:()=>_P,__classPrivateFieldSet:()=>kP,__createBinding:()=>rf,__decorate:()=>oP,__disposeResources:()=>CP,__esDecorate:()=>aP,__exportStar:()=>mP,__extends:()=>nP,__generator:()=>fP,__importDefault:()=>xP,__importStar:()=>wP,__makeTemplateObject:()=>EP,__metadata:()=>dP,__param:()=>sP,__propKey:()=>cP,__read:()=>IE,__rest:()=>iP,__rewriteRelativeImportExtension:()=>OP,__runInitializers:()=>lP,__setFunctionName:()=>uP,__spread:()=>hP,__spreadArray:()=>gP,__spreadArrays:()=>yP,__values:()=>tf,default:()=>a7});function nP(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");wE(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function iP(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function oP(t,e,r,i){var n=arguments.length,o=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(e,r,o):s(e,r))||o);return n>3&&o&&Object.defineProperty(e,r,o),o}function sP(t,e){return function(r,i){e(r,i,t)}}function aP(t,e,r,i,n,o){function s(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}for(var a=i.kind,l=a==="getter"?"get":a==="setter"?"set":"value",c=!e&&t?i.static?t:t.prototype:null,u=e||(c?Object.getOwnPropertyDescriptor(c,i.name):{}),d,f=!1,p=r.length-1;p>=0;p--){var m={};for(var y in i)m[y]=y==="access"?{}:i[y];for(var y in i.access)m.access[y]=i.access[y];m.addInitializer=function(_){if(f)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(_||null))};var w=(0,r[p])(a==="accessor"?{get:u.get,set:u.set}:u[l],m);if(a==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(d=s(w.get))&&(u.get=d),(d=s(w.set))&&(u.set=d),(d=s(w.init))&&n.unshift(d)}else(d=s(w))&&(a==="field"?n.unshift(d):u[l]=d)}c&&Object.defineProperty(c,i.name,u),f=!0}function lP(t,e,r){for(var i=arguments.length>2,n=0;n<e.length;n++)r=i?e[n].call(t,r):e[n].call(t);return i?r:void 0}function cP(t){return typeof t=="symbol"?t:"".concat(t)}function uP(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function dP(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function pP(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(u){try{c(i.next(u))}catch(d){s(d)}}function l(u){try{c(i.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):n(u.value).then(a,l)}c((i=i.apply(t,e||[])).next())})}function fP(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,n,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(r=0)),r;)try{if(i=1,n&&(o=c[0]&2?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,n=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(u){c=[6,u],n=0}finally{i=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function mP(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&rf(e,t,r)}function tf(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function IE(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(s)throw s.error}}return o}function hP(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(IE(arguments[e]));return t}function yP(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,n++)i[n]=o[s];return i}function gP(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,o;i<n;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}function Sa(t){return this instanceof Sa?(this.v=t,this):new Sa(t)}function bP(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),n[Symbol.asyncIterator]=function(){return this},n;function s(p){return function(m){return Promise.resolve(m).then(p,d)}}function a(p,m){i[p]&&(n[p]=function(y){return new Promise(function(w,_){o.push([p,y,w,_])>1||l(p,y)})},m&&(n[p]=m(n[p])))}function l(p,m){try{c(i[p](m))}catch(y){f(o[0][3],y)}}function c(p){p.value instanceof Sa?Promise.resolve(p.value.v).then(u,d):f(o[0][2],p)}function u(p){l("next",p)}function d(p){l("throw",p)}function f(p,m){p(m),o.shift(),o.length&&l(o[0][0],o[0][1])}}function vP(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,o){e[n]=t[n]?function(s){return(r=!r)?{value:Sa(t[n](s)),done:!1}:o?o(s):s}:o}}function SP(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof tf=="function"?tf(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(o){r[o]=t[o]&&function(s){return new Promise(function(a,l){s=t[o](s),n(a,l,s.done,s.value)})}}function n(o,s,a,l){Promise.resolve(l).then(function(c){o({value:c,done:a})},s)}}function EP(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function wP(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=xE(t),i=0;i<r.length;i++)r[i]!=="default"&&rf(e,t,r[i]);return o7(e,t),e}function xP(t){return t&&t.__esModule?t:{default:t}}function IP(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)}function kP(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r}function _P(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function TP(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var i,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(i===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],r&&(n=i)}if(typeof i!="function")throw new TypeError("Object not disposable.");n&&(i=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),t.stack.push({value:e,dispose:i,async:r})}else r&&t.stack.push({async:!0});return e}function CP(t){function e(o){t.error=t.hasError?new s7(o,t.error,"An error was suppressed during disposal."):o,t.hasError=!0}var r,i=0;function n(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(o).then(n,function(s){return e(s),n()})}else i|=1}catch(s){e(s)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return n()}function OP(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,i,n,o,s){return i?e?".jsx":".js":n&&(!o||!s)?r:n+o+"."+s.toLowerCase()+"js"}):t}var wE,ef,rf,o7,xE,s7,a7,Zt=S(()=>{wE=function(t,e){return wE=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r[n]=i[n])},wE(t,e)};ef=function(){return ef=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},ef.apply(this,arguments)};rf=Object.create?(function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}):(function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]});o7=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},xE=function(t){return xE=Object.getOwnPropertyNames||function(e){var r=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[r.length]=i);return r},xE(t)};s7=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var i=new Error(r);return i.name="SuppressedError",i.error=t,i.suppressed=e,i};a7={__extends:nP,__assign:ef,__rest:iP,__decorate:oP,__param:sP,__esDecorate:aP,__runInitializers:lP,__propKey:cP,__setFunctionName:uP,__metadata:dP,__awaiter:pP,__generator:fP,__createBinding:rf,__exportStar:mP,__values:tf,__read:IE,__spread:hP,__spreadArrays:yP,__spreadArray:gP,__await:Sa,__asyncGenerator:bP,__asyncDelegator:vP,__asyncValues:SP,__makeTemplateObject:EP,__importStar:wP,__importDefault:xP,__classPrivateFieldGet:IP,__classPrivateFieldSet:kP,__classPrivateFieldIn:_P,__addDisposableResource:TP,__disposeResources:CP,__rewriteRelativeImportExtension:OP}});var CE=h(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.AsyncFifoQueue=void 0;var kE=class{constructor(e){this.value=void 0,this.next=null,this.value=e}},_E=class{constructor(){this.length=0,this.head=null,this.tail=null}push(e){let r=new kE(e);return this.length?this.tail.next=r:this.head=r,this.tail=r,this.length+=1,r}shift(){if(this.length){let e=this.head;return this.head=this.head.next,this.length-=1,e}else return null}},TE=class{constructor(e=!1){this.ignoreErrors=e,this.queue=new _E,this.pending=new Set,this.newPromise()}add(e){this.pending.add(e),e.then(r=>{this.pending.delete(e),this.queue.length===0&&this.resolvePromise(r),this.queue.push(r)}).catch(r=>{this.ignoreErrors&&this.queue.push(void 0),this.pending.delete(e),this.rejectPromise(r)})}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,r)=>{this.resolve=e,this.reject=r})}async wait(){return this.nextPromise}async fetch(){var e;if(!(this.pending.size===0&&this.queue.length===0)){for(;this.queue.length===0;)try{await this.wait()}catch(r){this.ignoreErrors||console.error("Unexpected Error in AsyncFifoQueue",r)}return(e=this.queue.shift())===null||e===void 0?void 0:e.value}}};nf.AsyncFifoQueue=TE});var OE=h(of=>{"use strict";Object.defineProperty(of,"__esModule",{value:!0});of.Backoffs=void 0;var Ea=class{static normalize(e){if(Number.isFinite(e))return{type:"fixed",delay:e};if(e)return e}static calculate(e,r,i,n,o){if(e)return l7(e,o)(r,e.type,i,n)}};of.Backoffs=Ea;Ea.builtinStrategies={fixed:function(t,e=0){return function(){if(e>0){let r=t*(1-e);return Math.floor(Math.random()*t*e+r)}else return t}},exponential:function(t,e=0){return function(r){if(e>0){let i=Math.round(Math.pow(2,r-1)*t),n=i*(1-e);return Math.floor(Math.random()*i*e+n)}else return Math.round(Math.pow(2,r-1)*t)}}};function l7(t,e){if(t.type in Ea.builtinStrategies)return Ea.builtinStrategies[t.type](t.delay,t.jitter);if(e)return e;throw new Error(`Unknown backoff strategy ${t.type}.
979
- If a custom backoff strategy is used, specify it when the queue is created.`)}});var KP=h(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});sf.ChildCommand=void 0;var AP;(function(t){t[t.Init=0]="Init",t[t.Start=1]="Start",t[t.Stop=2]="Stop",t[t.GetChildrenValuesResponse=3]="GetChildrenValuesResponse",t[t.GetIgnoredChildrenFailuresResponse=4]="GetIgnoredChildrenFailuresResponse",t[t.GetDependenciesCountResponse=5]="GetDependenciesCountResponse",t[t.MoveToWaitingChildrenResponse=6]="MoveToWaitingChildrenResponse",t[t.Cancel=7]="Cancel",t[t.GetDependenciesResponse=8]="GetDependenciesResponse"})(AP||(sf.ChildCommand=AP={}))});var DP=h(af=>{"use strict";Object.defineProperty(af,"__esModule",{value:!0});af.ErrorCode=void 0;var RP;(function(t){t[t.JobNotExist=-1]="JobNotExist",t[t.JobLockNotExist=-2]="JobLockNotExist",t[t.JobNotInState=-3]="JobNotInState",t[t.JobPendingChildren=-4]="JobPendingChildren",t[t.ParentJobNotExist=-5]="ParentJobNotExist",t[t.JobLockMismatch=-6]="JobLockMismatch",t[t.ParentJobCannotBeReplaced=-7]="ParentJobCannotBeReplaced",t[t.JobBelongsToJobScheduler=-8]="JobBelongsToJobScheduler",t[t.JobHasFailedChildren=-9]="JobHasFailedChildren",t[t.SchedulerJobIdCollision=-10]="SchedulerJobIdCollision",t[t.SchedulerJobSlotsBusy=-11]="SchedulerJobSlotsBusy"})(RP||(af.ErrorCode=RP={}))});var PP=h(lf=>{"use strict";Object.defineProperty(lf,"__esModule",{value:!0});lf.ParentCommand=void 0;var jP;(function(t){t[t.Completed=0]="Completed",t[t.Error=1]="Error",t[t.Failed=2]="Failed",t[t.InitFailed=3]="InitFailed",t[t.InitCompleted=4]="InitCompleted",t[t.Log=5]="Log",t[t.MoveToDelayed=6]="MoveToDelayed",t[t.MoveToWait=7]="MoveToWait",t[t.Progress=8]="Progress",t[t.Update=9]="Update",t[t.GetChildrenValues=10]="GetChildrenValues",t[t.GetIgnoredChildrenFailures=11]="GetIgnoredChildrenFailures",t[t.GetDependenciesCount=12]="GetDependenciesCount",t[t.MoveToWaitingChildren=13]="MoveToWaitingChildren",t[t.GetDependencies=14]="GetDependencies"})(jP||(lf.ParentCommand=jP={}))});var NP=h(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});cf.MetricsTime=void 0;var MP;(function(t){t[t.ONE_MINUTE=1]="ONE_MINUTE",t[t.FIVE_MINUTES=5]="FIVE_MINUTES",t[t.FIFTEEN_MINUTES=15]="FIFTEEN_MINUTES",t[t.THIRTY_MINUTES=30]="THIRTY_MINUTES",t[t.ONE_HOUR=60]="ONE_HOUR",t[t.ONE_WEEK=10080]="ONE_WEEK",t[t.TWO_WEEKS=20160]="TWO_WEEKS",t[t.ONE_MONTH=80640]="ONE_MONTH"})(MP||(cf.MetricsTime=MP={}))});var JP=h(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.SpanKind=Ui.MetricNames=Ui.TelemetryAttributes=void 0;var LP;(function(t){t.QueueName="bullmq.queue.name",t.QueueOperation="bullmq.queue.operation",t.BulkCount="bullmq.job.bulk.count",t.BulkNames="bullmq.job.bulk.names",t.JobName="bullmq.job.name",t.JobId="bullmq.job.id",t.JobKey="bullmq.job.key",t.JobIds="bullmq.job.ids",t.JobAttemptsMade="bullmq.job.attempts.made",t.DeduplicationKey="bullmq.job.deduplication.key",t.JobOptions="bullmq.job.options",t.JobProgress="bullmq.job.progress",t.QueueDrainDelay="bullmq.queue.drain.delay",t.QueueGrace="bullmq.queue.grace",t.QueueCleanLimit="bullmq.queue.clean.limit",t.QueueRateLimit="bullmq.queue.rate.limit",t.JobType="bullmq.job.type",t.QueueOptions="bullmq.queue.options",t.QueueEventMaxLength="bullmq.queue.event.max.length",t.QueueJobsState="bullmq.queue.jobs.state",t.WorkerOptions="bullmq.worker.options",t.WorkerName="bullmq.worker.name",t.WorkerId="bullmq.worker.id",t.WorkerRateLimit="bullmq.worker.rate.limit",t.WorkerDoNotWaitActive="bullmq.worker.do.not.wait.active",t.WorkerForceClose="bullmq.worker.force.close",t.WorkerStalledJobs="bullmq.worker.stalled.jobs",t.WorkerFailedJobs="bullmq.worker.failed.jobs",t.WorkerJobsToExtendLocks="bullmq.worker.jobs.to.extend.locks",t.JobFinishedTimestamp="bullmq.job.finished.timestamp",t.JobAttemptFinishedTimestamp="bullmq.job.attempt_finished_timestamp",t.JobProcessedTimestamp="bullmq.job.processed.timestamp",t.JobResult="bullmq.job.result",t.JobFailedReason="bullmq.job.failed.reason",t.FlowName="bullmq.flow.name",t.JobSchedulerId="bullmq.job.scheduler.id",t.JobStatus="bullmq.job.status"})(LP||(Ui.TelemetryAttributes=LP={}));var UP;(function(t){t.QueueJobsCount="bullmq.queue.jobs",t.JobsCompleted="bullmq.jobs.completed",t.JobsFailed="bullmq.jobs.failed",t.JobsDelayed="bullmq.jobs.delayed",t.JobsRetried="bullmq.jobs.retried",t.JobsWaiting="bullmq.jobs.waiting",t.JobsWaitingChildren="bullmq.jobs.waiting_children",t.JobDuration="bullmq.job.duration"})(UP||(Ui.MetricNames=UP={}));var $P;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})($P||(Ui.SpanKind=$P={}))});var gr=h(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});var Gc=(Zt(),Jt(Wt));Gc.__exportStar(KP(),qo);Gc.__exportStar(DP(),qo);Gc.__exportStar(PP(),qo);Gc.__exportStar(NP(),qo);Gc.__exportStar(JP(),qo)});var KE=h(df=>{"use strict";Object.defineProperty(df,"__esModule",{value:!0});df.Child=void 0;var c7=U("child_process"),u7=U("net"),d7=U("worker_threads"),uf=gr(),p7=U("events"),f7={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"},AE=class extends p7.EventEmitter{constructor(e,r,i={useWorkerThreads:!1}){super(),this.mainFile=e,this.processFile=r,this.opts=i,this._exitCode=null,this._signalCode=null,this._killed=!1}get pid(){if(this.childProcess)return this.childProcess.pid;if(this.worker)return Math.abs(this.worker.threadId);throw new Error("No child process or worker thread")}get exitCode(){return this._exitCode}get signalCode(){return this._signalCode}get killed(){return this.childProcess?this.childProcess.killed:this._killed}async init(){let e=await y7(process.execArgv),r;this.opts.useWorkerThreads?this.worker=r=new d7.Worker(this.mainFile,Object.assign({execArgv:e,stdin:!0,stdout:!0,stderr:!0},this.opts.workerThreadsOptions?this.opts.workerThreadsOptions:{})):this.childProcess=r=(0,c7.fork)(this.mainFile,[],Object.assign({execArgv:e,stdio:"pipe"},this.opts.workerForkOptions?this.opts.workerForkOptions:{})),r.on("exit",(i,n)=>{this._exitCode=i,n=typeof n>"u"?null:n,this._signalCode=n,this._killed=!0,this.emit("exit",i,n),r.removeAllListeners(),this.removeAllListeners()}),r.on("error",(...i)=>this.emit("error",...i)),r.on("message",(...i)=>this.emit("message",...i)),r.on("close",(...i)=>this.emit("close",...i)),r.stdout.pipe(process.stdout),r.stderr.pipe(process.stderr),await this.initChild()}async send(e){return new Promise((r,i)=>{this.childProcess?this.childProcess.send(e,n=>{n?i(n):r()}):this.worker?r(this.worker.postMessage(e)):r()})}killProcess(e="SIGKILL"){this.childProcess?this.childProcess.kill(e):this.worker&&this.worker.terminate()}async kill(e="SIGKILL",r){if(this.hasProcessExited())return;let i=m7(this.childProcess||this.worker);if(this.killProcess(e),r!==void 0&&(r===0||isFinite(r))){let n=setTimeout(()=>{this.hasProcessExited()||this.killProcess("SIGKILL")},r);await i,clearTimeout(n)}await i}async initChild(){let e=new Promise((r,i)=>{let n=s=>{if(Object.values(uf.ParentCommand).includes(s.cmd)){if(s.cmd===uf.ParentCommand.InitCompleted)r();else if(s.cmd===uf.ParentCommand.InitFailed){let a=new Error;a.stack=s.err.stack,a.message=s.err.message,i(a)}this.off("message",n),this.off("close",o)}},o=(s,a)=>{s>128&&(s-=128);let l=f7[s]||`Unknown exit code ${s}`;i(new Error(`Error initializing child: ${l} and signal ${a}`)),this.off("message",n),this.off("close",o)};this.on("message",n),this.on("close",o)});await this.send({cmd:uf.ChildCommand.Init,value:this.processFile}),await e}hasProcessExited(){return!!(this.exitCode!==null||this.signalCode)}};df.Child=AE;function m7(t){return new Promise(e=>{t.once("exit",()=>e())})}var h7=async()=>new Promise(t=>{let e=(0,u7.createServer)();e.listen(0,()=>{let{port:r}=e.address();e.close(()=>t(r))})}),y7=async t=>{let e=[],r=[];for(let i=0;i<t.length;i++){let n=t[i];if(n.indexOf("--inspect")===-1)e.push(n);else{let o=n.split("=")[0],s=await h7();r.push(`${o}=${s}`)}}return e.concat(r)}});var jE=h((pf,DE)=>{"use strict";Object.defineProperty(pf,"__esModule",{value:!0});pf.ChildPool=void 0;var FP=U("path"),g7=KE(),b7=3e4,v7=()=>typeof U=="function"&&typeof DE=="object"&&typeof DE.exports=="object",RE=class{constructor({mainFile:e=v7()?FP.join(process.cwd(),"dist/cjs/classes/main.js"):FP.join(process.cwd(),"dist/esm/classes/main.js"),useWorkerThreads:r,workerForkOptions:i,workerThreadsOptions:n}){this.retained={},this.free={},this.opts={mainFile:e,useWorkerThreads:r,workerForkOptions:i,workerThreadsOptions:n}}async retain(e){let r=this.getFree(e).pop();if(r)return this.retained[r.pid]=r,r;r=new g7.Child(this.opts.mainFile,e,{useWorkerThreads:this.opts.useWorkerThreads,workerForkOptions:this.opts.workerForkOptions,workerThreadsOptions:this.opts.workerThreadsOptions}),r.on("exit",this.remove.bind(this,r));try{if(await r.init(),r.exitCode!==null||r.signalCode!==null)throw new Error("Child exited before it could be retained");return this.retained[r.pid]=r,r}catch(i){throw console.error(i),this.release(r),i}}release(e){delete this.retained[e.pid],this.getFree(e.processFile).push(e)}remove(e){delete this.retained[e.pid];let r=this.getFree(e.processFile),i=r.indexOf(e);i>-1&&r.splice(i,1)}async kill(e,r="SIGKILL"){return this.remove(e),e.kill(r,b7)}async clean(){let e=Object.values(this.retained).concat(this.getAllFree());this.retained={},this.free={},await Promise.all(e.map(r=>this.kill(r,"SIGTERM")))}getFree(e){return this.free[e]=this.free[e]||[]}getAllFree(){return Object.values(this.free).reduce((e,r)=>e.concat(r),[])}};pf.ChildPool=RE});var zP=h((sIe,qP)=>{var{EventEmitter:S7}=U("events"),ff=class{constructor(){this.eventEmitter=new S7,this.onabort=null,this.aborted=!1,this.reason=void 0}toString(){return"[object AbortSignal]"}get[Symbol.toStringTag](){return"AbortSignal"}removeEventListener(e,r){this.eventEmitter.removeListener(e,r)}addEventListener(e,r){this.eventEmitter.on(e,r)}dispatchEvent(e){let r={type:e,target:this},i=`on${e}`;typeof this[i]=="function"&&this[i](r),this.eventEmitter.emit(e,r)}throwIfAborted(){if(this.aborted)throw this.reason}static abort(e){let r=new Vc;return r.abort(),r.signal}static timeout(e){let r=new Vc;return setTimeout(()=>r.abort(new Error("TimeoutError")),e),r.signal}},Vc=class{constructor(){this.signal=new ff}abort(e){this.signal.aborted||(this.signal.aborted=!0,e?this.signal.reason=e:this.signal.reason=new Error("AbortError"),this.signal.dispatchEvent("abort"))}toString(){return"[object AbortController]"}get[Symbol.toStringTag](){return"AbortController"}};qP.exports={AbortController:Vc,AbortSignal:ff}});var hf=h(mf=>{"use strict";Object.defineProperty(mf,"__esModule",{value:!0});mf.AbortController=void 0;var E7=zP(),PE;globalThis.AbortController?PE=globalThis.AbortController:PE=E7.AbortController;var ME=class extends PE{};mf.AbortController=ME});var XP=h((lIe,YP)=>{var VP=9007199254740991,w7="[object Arguments]",x7="[object Function]",I7="[object GeneratorFunction]",k7=/^(?:0|[1-9]\d*)$/;function BP(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function _7(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}var Bc=Object.prototype,Wc=Bc.hasOwnProperty,WP=Bc.toString,T7=Bc.propertyIsEnumerable,GP=Math.max;function C7(t,e){var r=L7(t)||N7(t)?_7(t.length,String):[],i=r.length,n=!!i;for(var o in t)(e||Wc.call(t,o))&&!(n&&(o=="length"||HP(o,i)))&&r.push(o);return r}function O7(t,e,r,i){return t===void 0||NE(t,Bc[r])&&!Wc.call(i,r)?e:t}function A7(t,e,r){var i=t[e];(!(Wc.call(t,e)&&NE(i,r))||r===void 0&&!(e in t))&&(t[e]=r)}function K7(t){if(!UE(t))return M7(t);var e=P7(t),r=[];for(var i in t)i=="constructor"&&(e||!Wc.call(t,i))||r.push(i);return r}function ZP(t,e){return e=GP(e===void 0?t.length-1:e,0),function(){for(var r=arguments,i=-1,n=GP(r.length-e,0),o=Array(n);++i<n;)o[i]=r[e+i];i=-1;for(var s=Array(e+1);++i<e;)s[i]=r[i];return s[e]=o,BP(t,this,s)}}function R7(t,e,r,i){r||(r={});for(var n=-1,o=e.length;++n<o;){var s=e[n],a=i?i(r[s],t[s],s,r,t):void 0;A7(r,s,a===void 0?t[s]:a)}return r}function D7(t){return ZP(function(e,r){var i=-1,n=r.length,o=n>1?r[n-1]:void 0,s=n>2?r[2]:void 0;for(o=t.length>3&&typeof o=="function"?(n--,o):void 0,s&&j7(r[0],r[1],s)&&(o=n<3?void 0:o,n=1),e=Object(e);++i<n;){var a=r[i];a&&t(e,a,i,o)}return e})}function HP(t,e){return e=e??VP,!!e&&(typeof t=="number"||k7.test(t))&&t>-1&&t%1==0&&t<e}function j7(t,e,r){if(!UE(r))return!1;var i=typeof e;return(i=="number"?LE(r)&&HP(e,r.length):i=="string"&&e in r)?NE(r[e],t):!1}function P7(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Bc;return t===r}function M7(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}function NE(t,e){return t===e||t!==t&&e!==e}function N7(t){return U7(t)&&Wc.call(t,"callee")&&(!T7.call(t,"callee")||WP.call(t)==w7)}var L7=Array.isArray;function LE(t){return t!=null&&J7(t.length)&&!$7(t)}function U7(t){return F7(t)&&LE(t)}function $7(t){var e=UE(t)?WP.call(t):"";return e==x7||e==I7}function J7(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=VP}function UE(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function F7(t){return!!t&&typeof t=="object"}var q7=D7(function(t,e,r,i){R7(e,G7(e),t,i)}),z7=ZP(function(t){return t.push(void 0,O7),BP(q7,void 0,t)});function G7(t){return LE(t)?C7(t,!0):K7(t)}YP.exports=z7});var tM=h((cIe,eM)=>{var V7=9007199254740991,B7="[object Arguments]",W7="[object Function]",Z7="[object GeneratorFunction]",$E=Object.prototype,H7=$E.hasOwnProperty,QP=$E.toString,Y7=$E.propertyIsEnumerable;function X7(t){return eee(t)&&H7.call(t,"callee")&&(!Y7.call(t,"callee")||QP.call(t)==B7)}function Q7(t){return t!=null&&ree(t.length)&&!tee(t)}function eee(t){return iee(t)&&Q7(t)}function tee(t){var e=nee(t)?QP.call(t):"";return e==W7||e==Z7}function ree(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=V7}function nee(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function iee(t){return!!t&&typeof t=="object"}eM.exports=X7});var yf=h($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.isArguments=$i.defaults=$i.noop=void 0;var oee=XP();$i.defaults=oee;var see=tM();$i.isArguments=see;function aee(){}$i.noop=aee});var nM=h((dIe,rM)=>{var wa=1e3,xa=wa*60,Ia=xa*60,zo=Ia*24,lee=zo*7,cee=zo*365.25;rM.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return uee(t);if(r==="number"&&isFinite(t))return e.long?pee(t):dee(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function uee(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return r*cee;case"weeks":case"week":case"w":return r*lee;case"days":case"day":case"d":return r*zo;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ia;case"minutes":case"minute":case"mins":case"min":case"m":return r*xa;case"seconds":case"second":case"secs":case"sec":case"s":return r*wa;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function dee(t){var e=Math.abs(t);return e>=zo?Math.round(t/zo)+"d":e>=Ia?Math.round(t/Ia)+"h":e>=xa?Math.round(t/xa)+"m":e>=wa?Math.round(t/wa)+"s":t+"ms"}function pee(t){var e=Math.abs(t);return e>=zo?gf(t,e,zo,"day"):e>=Ia?gf(t,e,Ia,"hour"):e>=xa?gf(t,e,xa,"minute"):e>=wa?gf(t,e,wa,"second"):t+" ms"}function gf(t,e,r,i){var n=e>=r*1.5;return Math.round(t/r)+" "+i+(n?"s":"")}});var JE=h((pIe,iM)=>{function fee(t){r.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=n,r.enabled=a,r.humanize=nM(),r.destroy=c,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let d=0;for(let f=0;f<u.length;f++)d=(d<<5)-d+u.charCodeAt(f),d|=0;return r.colors[Math.abs(d)%r.colors.length]}r.selectColor=e;function r(u){let d,f=null,p,m;function y(...w){if(!y.enabled)return;let _=y,A=Number(new Date),O=A-(d||A);_.diff=O,_.prev=d,_.curr=A,d=A,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let C=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(re,pe)=>{if(re==="%%")return"%";C++;let ve=r.formatters[pe];if(typeof ve=="function"){let me=w[C];re=ve.call(_,me),w.splice(C,1),C--}return re}),r.formatArgs.call(_,w),(_.log||r.log).apply(_,w)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=i,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(p!==r.namespaces&&(p=r.namespaces,m=r.enabled(u)),m),set:w=>{f=w}}),typeof r.init=="function"&&r.init(y),y}function i(u,d){let f=r(this.namespace+(typeof d>"u"?":":d)+u);return f.log=this.log,f}function n(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let d=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let f of d)f[0]==="-"?r.skips.push(f.slice(1)):r.names.push(f)}function o(u,d){let f=0,p=0,m=-1,y=0;for(;f<u.length;)if(p<d.length&&(d[p]===u[f]||d[p]==="*"))d[p]==="*"?(m=p,y=f,p++):(f++,p++);else if(m!==-1)p=m+1,y++,f=y;else return!1;for(;p<d.length&&d[p]==="*";)p++;return p===d.length}function s(){let u=[...r.names,...r.skips.map(d=>"-"+d)].join(",");return r.enable(""),u}function a(u){for(let d of r.skips)if(o(u,d))return!1;for(let d of r.names)if(o(u,d))return!0;return!1}function l(u){return u instanceof Error?u.stack||u.message:u}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}iM.exports=fee});var oM=h((br,bf)=>{br.formatArgs=hee;br.save=yee;br.load=gee;br.useColors=mee;br.storage=bee();br.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();br.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 mee(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function hee(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+bf.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(i=r))}),t.splice(i,0,e)}br.log=console.debug||console.log||(()=>{});function yee(t){try{t?br.storage.setItem("debug",t):br.storage.removeItem("debug")}catch{}}function gee(){let t;try{t=br.storage.getItem("debug")||br.storage.getItem("DEBUG")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function bee(){try{return localStorage}catch{}}bf.exports=JE()(br);var{formatters:vee}=bf.exports;vee.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var aM={};Ce(aM,{createSupportsColor:()=>FE,default:()=>kee});import qE from"node:process";import See from"node:os";import sM from"node:tty";function Xr(t,e=globalThis.Deno?globalThis.Deno.args:qE.argv){let r=t.startsWith("-")?"":t.length===1?"-":"--",i=e.indexOf(r+t),n=e.indexOf("--");return i!==-1&&(n===-1||i<n)}function Eee(){if(!("FORCE_COLOR"in Qe))return;if(Qe.FORCE_COLOR==="true")return 1;if(Qe.FORCE_COLOR==="false")return 0;if(Qe.FORCE_COLOR.length===0)return 1;let t=Math.min(Number.parseInt(Qe.FORCE_COLOR,10),3);if([0,1,2,3].includes(t))return t}function wee(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function xee(t,{streamIsTTY:e,sniffFlags:r=!0}={}){let i=Eee();i!==void 0&&(vf=i);let n=r?vf:i;if(n===0)return 0;if(r){if(Xr("color=16m")||Xr("color=full")||Xr("color=truecolor"))return 3;if(Xr("color=256"))return 2}if("TF_BUILD"in Qe&&"AGENT_NAME"in Qe)return 1;if(t&&!e&&n===void 0)return 0;let o=n||0;if(Qe.TERM==="dumb")return o;if(qE.platform==="win32"){let s=See.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in Qe)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in Qe)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in Qe)||Qe.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in Qe)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Qe.TEAMCITY_VERSION)?1:0;if(Qe.COLORTERM==="truecolor"||Qe.TERM==="xterm-kitty"||Qe.TERM==="xterm-ghostty"||Qe.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Qe){let s=Number.parseInt((Qe.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Qe.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Qe.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Qe.TERM)||"COLORTERM"in Qe?1:o}function FE(t,e={}){let r=xee(t,{streamIsTTY:t&&t.isTTY,...e});return wee(r)}var Qe,vf,Iee,kee,lM=S(()=>{({env:Qe}=qE);Xr("no-color")||Xr("no-colors")||Xr("color=false")||Xr("color=never")?vf=0:(Xr("color")||Xr("colors")||Xr("color=true")||Xr("color=always"))&&(vf=1);Iee={stdout:FE({isTTY:sM.isatty(1)}),stderr:FE({isTTY:sM.isatty(2)})},kee=Iee});var uM=h((Kt,Ef)=>{var _ee=U("tty"),Sf=U("util");Kt.init=Dee;Kt.log=Aee;Kt.formatArgs=Cee;Kt.save=Kee;Kt.load=Ree;Kt.useColors=Tee;Kt.destroy=Sf.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Kt.colors=[6,2,3,4,5,1];try{let t=(lM(),Jt(aM));t&&(t.stderr||t).level>=2&&(Kt.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{}Kt.inspectOpts=Object.keys(process.env).filter(t=>/^debug_/i.test(t)).reduce((t,e)=>{let r=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,o)=>o.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),t[r]=i,t},{});function Tee(){return"colors"in Kt.inspectOpts?!!Kt.inspectOpts.colors:_ee.isatty(process.stderr.fd)}function Cee(t){let{namespace:e,useColors:r}=this;if(r){let i=this.color,n="\x1B[3"+(i<8?i:"8;5;"+i),o=` ${n};1m${e} \x1B[0m`;t[0]=o+t[0].split(`
979
+ If a custom backoff strategy is used, specify it when the queue is created.`)}});var KP=h(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});sf.ChildCommand=void 0;var AP;(function(t){t[t.Init=0]="Init",t[t.Start=1]="Start",t[t.Stop=2]="Stop",t[t.GetChildrenValuesResponse=3]="GetChildrenValuesResponse",t[t.GetIgnoredChildrenFailuresResponse=4]="GetIgnoredChildrenFailuresResponse",t[t.GetDependenciesCountResponse=5]="GetDependenciesCountResponse",t[t.MoveToWaitingChildrenResponse=6]="MoveToWaitingChildrenResponse",t[t.Cancel=7]="Cancel",t[t.GetDependenciesResponse=8]="GetDependenciesResponse"})(AP||(sf.ChildCommand=AP={}))});var DP=h(af=>{"use strict";Object.defineProperty(af,"__esModule",{value:!0});af.ErrorCode=void 0;var RP;(function(t){t[t.JobNotExist=-1]="JobNotExist",t[t.JobLockNotExist=-2]="JobLockNotExist",t[t.JobNotInState=-3]="JobNotInState",t[t.JobPendingChildren=-4]="JobPendingChildren",t[t.ParentJobNotExist=-5]="ParentJobNotExist",t[t.JobLockMismatch=-6]="JobLockMismatch",t[t.ParentJobCannotBeReplaced=-7]="ParentJobCannotBeReplaced",t[t.JobBelongsToJobScheduler=-8]="JobBelongsToJobScheduler",t[t.JobHasFailedChildren=-9]="JobHasFailedChildren",t[t.SchedulerJobIdCollision=-10]="SchedulerJobIdCollision",t[t.SchedulerJobSlotsBusy=-11]="SchedulerJobSlotsBusy"})(RP||(af.ErrorCode=RP={}))});var PP=h(lf=>{"use strict";Object.defineProperty(lf,"__esModule",{value:!0});lf.ParentCommand=void 0;var jP;(function(t){t[t.Completed=0]="Completed",t[t.Error=1]="Error",t[t.Failed=2]="Failed",t[t.InitFailed=3]="InitFailed",t[t.InitCompleted=4]="InitCompleted",t[t.Log=5]="Log",t[t.MoveToDelayed=6]="MoveToDelayed",t[t.MoveToWait=7]="MoveToWait",t[t.Progress=8]="Progress",t[t.Update=9]="Update",t[t.GetChildrenValues=10]="GetChildrenValues",t[t.GetIgnoredChildrenFailures=11]="GetIgnoredChildrenFailures",t[t.GetDependenciesCount=12]="GetDependenciesCount",t[t.MoveToWaitingChildren=13]="MoveToWaitingChildren",t[t.GetDependencies=14]="GetDependencies"})(jP||(lf.ParentCommand=jP={}))});var NP=h(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});cf.MetricsTime=void 0;var MP;(function(t){t[t.ONE_MINUTE=1]="ONE_MINUTE",t[t.FIVE_MINUTES=5]="FIVE_MINUTES",t[t.FIFTEEN_MINUTES=15]="FIFTEEN_MINUTES",t[t.THIRTY_MINUTES=30]="THIRTY_MINUTES",t[t.ONE_HOUR=60]="ONE_HOUR",t[t.ONE_WEEK=10080]="ONE_WEEK",t[t.TWO_WEEKS=20160]="TWO_WEEKS",t[t.ONE_MONTH=80640]="ONE_MONTH"})(MP||(cf.MetricsTime=MP={}))});var JP=h(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.SpanKind=Ui.MetricNames=Ui.TelemetryAttributes=void 0;var LP;(function(t){t.QueueName="bullmq.queue.name",t.QueueOperation="bullmq.queue.operation",t.BulkCount="bullmq.job.bulk.count",t.BulkNames="bullmq.job.bulk.names",t.JobName="bullmq.job.name",t.JobId="bullmq.job.id",t.JobKey="bullmq.job.key",t.JobIds="bullmq.job.ids",t.JobAttemptsMade="bullmq.job.attempts.made",t.DeduplicationKey="bullmq.job.deduplication.key",t.JobOptions="bullmq.job.options",t.JobProgress="bullmq.job.progress",t.QueueDrainDelay="bullmq.queue.drain.delay",t.QueueGrace="bullmq.queue.grace",t.QueueCleanLimit="bullmq.queue.clean.limit",t.QueueRateLimit="bullmq.queue.rate.limit",t.JobType="bullmq.job.type",t.QueueOptions="bullmq.queue.options",t.QueueEventMaxLength="bullmq.queue.event.max.length",t.QueueJobsState="bullmq.queue.jobs.state",t.WorkerOptions="bullmq.worker.options",t.WorkerName="bullmq.worker.name",t.WorkerId="bullmq.worker.id",t.WorkerRateLimit="bullmq.worker.rate.limit",t.WorkerDoNotWaitActive="bullmq.worker.do.not.wait.active",t.WorkerForceClose="bullmq.worker.force.close",t.WorkerStalledJobs="bullmq.worker.stalled.jobs",t.WorkerFailedJobs="bullmq.worker.failed.jobs",t.WorkerJobsToExtendLocks="bullmq.worker.jobs.to.extend.locks",t.JobFinishedTimestamp="bullmq.job.finished.timestamp",t.JobAttemptFinishedTimestamp="bullmq.job.attempt_finished_timestamp",t.JobProcessedTimestamp="bullmq.job.processed.timestamp",t.JobResult="bullmq.job.result",t.JobFailedReason="bullmq.job.failed.reason",t.FlowName="bullmq.flow.name",t.JobSchedulerId="bullmq.job.scheduler.id",t.JobStatus="bullmq.job.status"})(LP||(Ui.TelemetryAttributes=LP={}));var UP;(function(t){t.QueueJobsCount="bullmq.queue.jobs",t.JobsCompleted="bullmq.jobs.completed",t.JobsFailed="bullmq.jobs.failed",t.JobsDelayed="bullmq.jobs.delayed",t.JobsRetried="bullmq.jobs.retried",t.JobsWaiting="bullmq.jobs.waiting",t.JobsWaitingChildren="bullmq.jobs.waiting_children",t.JobDuration="bullmq.job.duration"})(UP||(Ui.MetricNames=UP={}));var $P;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})($P||(Ui.SpanKind=$P={}))});var gr=h(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});var Gc=(Zt(),Jt(Wt));Gc.__exportStar(KP(),qo);Gc.__exportStar(DP(),qo);Gc.__exportStar(PP(),qo);Gc.__exportStar(NP(),qo);Gc.__exportStar(JP(),qo)});var KE=h(df=>{"use strict";Object.defineProperty(df,"__esModule",{value:!0});df.Child=void 0;var c7=U("child_process"),u7=U("net"),d7=U("worker_threads"),uf=gr(),p7=U("events"),f7={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"},AE=class extends p7.EventEmitter{constructor(e,r,i={useWorkerThreads:!1}){super(),this.mainFile=e,this.processFile=r,this.opts=i,this._exitCode=null,this._signalCode=null,this._killed=!1}get pid(){if(this.childProcess)return this.childProcess.pid;if(this.worker)return Math.abs(this.worker.threadId);throw new Error("No child process or worker thread")}get exitCode(){return this._exitCode}get signalCode(){return this._signalCode}get killed(){return this.childProcess?this.childProcess.killed:this._killed}async init(){let e=await y7(process.execArgv),r;this.opts.useWorkerThreads?this.worker=r=new d7.Worker(this.mainFile,Object.assign({execArgv:e,stdin:!0,stdout:!0,stderr:!0},this.opts.workerThreadsOptions?this.opts.workerThreadsOptions:{})):this.childProcess=r=(0,c7.fork)(this.mainFile,[],Object.assign({execArgv:e,stdio:"pipe"},this.opts.workerForkOptions?this.opts.workerForkOptions:{})),r.on("exit",(i,n)=>{this._exitCode=i,n=typeof n>"u"?null:n,this._signalCode=n,this._killed=!0,this.emit("exit",i,n),r.removeAllListeners(),this.removeAllListeners()}),r.on("error",(...i)=>this.emit("error",...i)),r.on("message",(...i)=>this.emit("message",...i)),r.on("close",(...i)=>this.emit("close",...i)),r.stdout.pipe(process.stdout),r.stderr.pipe(process.stderr),await this.initChild()}async send(e){return new Promise((r,i)=>{this.childProcess?this.childProcess.send(e,n=>{n?i(n):r()}):this.worker?r(this.worker.postMessage(e)):r()})}killProcess(e="SIGKILL"){this.childProcess?this.childProcess.kill(e):this.worker&&this.worker.terminate()}async kill(e="SIGKILL",r){if(this.hasProcessExited())return;let i=m7(this.childProcess||this.worker);if(this.killProcess(e),r!==void 0&&(r===0||isFinite(r))){let n=setTimeout(()=>{this.hasProcessExited()||this.killProcess("SIGKILL")},r);await i,clearTimeout(n)}await i}async initChild(){let e=new Promise((r,i)=>{let n=s=>{if(Object.values(uf.ParentCommand).includes(s.cmd)){if(s.cmd===uf.ParentCommand.InitCompleted)r();else if(s.cmd===uf.ParentCommand.InitFailed){let a=new Error;a.stack=s.err.stack,a.message=s.err.message,i(a)}this.off("message",n),this.off("close",o)}},o=(s,a)=>{s>128&&(s-=128);let l=f7[s]||`Unknown exit code ${s}`;i(new Error(`Error initializing child: ${l} and signal ${a}`)),this.off("message",n),this.off("close",o)};this.on("message",n),this.on("close",o)});await this.send({cmd:uf.ChildCommand.Init,value:this.processFile}),await e}hasProcessExited(){return!!(this.exitCode!==null||this.signalCode)}};df.Child=AE;function m7(t){return new Promise(e=>{t.once("exit",()=>e())})}var h7=async()=>new Promise(t=>{let e=(0,u7.createServer)();e.listen(0,()=>{let{port:r}=e.address();e.close(()=>t(r))})}),y7=async t=>{let e=[],r=[];for(let i=0;i<t.length;i++){let n=t[i];if(n.indexOf("--inspect")===-1)e.push(n);else{let o=n.split("=")[0],s=await h7();r.push(`${o}=${s}`)}}return e.concat(r)}});var jE=h((pf,DE)=>{"use strict";Object.defineProperty(pf,"__esModule",{value:!0});pf.ChildPool=void 0;var FP=U("path"),g7=KE(),b7=3e4,v7=()=>typeof U=="function"&&typeof DE=="object"&&typeof DE.exports=="object",RE=class{constructor({mainFile:e=v7()?FP.join(process.cwd(),"dist/cjs/classes/main.js"):FP.join(process.cwd(),"dist/esm/classes/main.js"),useWorkerThreads:r,workerForkOptions:i,workerThreadsOptions:n}){this.retained={},this.free={},this.opts={mainFile:e,useWorkerThreads:r,workerForkOptions:i,workerThreadsOptions:n}}async retain(e){let r=this.getFree(e).pop();if(r)return this.retained[r.pid]=r,r;r=new g7.Child(this.opts.mainFile,e,{useWorkerThreads:this.opts.useWorkerThreads,workerForkOptions:this.opts.workerForkOptions,workerThreadsOptions:this.opts.workerThreadsOptions}),r.on("exit",this.remove.bind(this,r));try{if(await r.init(),r.exitCode!==null||r.signalCode!==null)throw new Error("Child exited before it could be retained");return this.retained[r.pid]=r,r}catch(i){throw console.error(i),this.release(r),i}}release(e){delete this.retained[e.pid],this.getFree(e.processFile).push(e)}remove(e){delete this.retained[e.pid];let r=this.getFree(e.processFile),i=r.indexOf(e);i>-1&&r.splice(i,1)}async kill(e,r="SIGKILL"){return this.remove(e),e.kill(r,b7)}async clean(){let e=Object.values(this.retained).concat(this.getAllFree());this.retained={},this.free={},await Promise.all(e.map(r=>this.kill(r,"SIGTERM")))}getFree(e){return this.free[e]=this.free[e]||[]}getAllFree(){return Object.values(this.free).reduce((e,r)=>e.concat(r),[])}};pf.ChildPool=RE});var zP=h((aIe,qP)=>{var{EventEmitter:S7}=U("events"),ff=class{constructor(){this.eventEmitter=new S7,this.onabort=null,this.aborted=!1,this.reason=void 0}toString(){return"[object AbortSignal]"}get[Symbol.toStringTag](){return"AbortSignal"}removeEventListener(e,r){this.eventEmitter.removeListener(e,r)}addEventListener(e,r){this.eventEmitter.on(e,r)}dispatchEvent(e){let r={type:e,target:this},i=`on${e}`;typeof this[i]=="function"&&this[i](r),this.eventEmitter.emit(e,r)}throwIfAborted(){if(this.aborted)throw this.reason}static abort(e){let r=new Vc;return r.abort(),r.signal}static timeout(e){let r=new Vc;return setTimeout(()=>r.abort(new Error("TimeoutError")),e),r.signal}},Vc=class{constructor(){this.signal=new ff}abort(e){this.signal.aborted||(this.signal.aborted=!0,e?this.signal.reason=e:this.signal.reason=new Error("AbortError"),this.signal.dispatchEvent("abort"))}toString(){return"[object AbortController]"}get[Symbol.toStringTag](){return"AbortController"}};qP.exports={AbortController:Vc,AbortSignal:ff}});var hf=h(mf=>{"use strict";Object.defineProperty(mf,"__esModule",{value:!0});mf.AbortController=void 0;var E7=zP(),PE;globalThis.AbortController?PE=globalThis.AbortController:PE=E7.AbortController;var ME=class extends PE{};mf.AbortController=ME});var XP=h((cIe,YP)=>{var VP=9007199254740991,w7="[object Arguments]",x7="[object Function]",I7="[object GeneratorFunction]",k7=/^(?:0|[1-9]\d*)$/;function BP(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function _7(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}var Bc=Object.prototype,Wc=Bc.hasOwnProperty,WP=Bc.toString,T7=Bc.propertyIsEnumerable,GP=Math.max;function C7(t,e){var r=L7(t)||N7(t)?_7(t.length,String):[],i=r.length,n=!!i;for(var o in t)(e||Wc.call(t,o))&&!(n&&(o=="length"||HP(o,i)))&&r.push(o);return r}function O7(t,e,r,i){return t===void 0||NE(t,Bc[r])&&!Wc.call(i,r)?e:t}function A7(t,e,r){var i=t[e];(!(Wc.call(t,e)&&NE(i,r))||r===void 0&&!(e in t))&&(t[e]=r)}function K7(t){if(!UE(t))return M7(t);var e=P7(t),r=[];for(var i in t)i=="constructor"&&(e||!Wc.call(t,i))||r.push(i);return r}function ZP(t,e){return e=GP(e===void 0?t.length-1:e,0),function(){for(var r=arguments,i=-1,n=GP(r.length-e,0),o=Array(n);++i<n;)o[i]=r[e+i];i=-1;for(var s=Array(e+1);++i<e;)s[i]=r[i];return s[e]=o,BP(t,this,s)}}function R7(t,e,r,i){r||(r={});for(var n=-1,o=e.length;++n<o;){var s=e[n],a=i?i(r[s],t[s],s,r,t):void 0;A7(r,s,a===void 0?t[s]:a)}return r}function D7(t){return ZP(function(e,r){var i=-1,n=r.length,o=n>1?r[n-1]:void 0,s=n>2?r[2]:void 0;for(o=t.length>3&&typeof o=="function"?(n--,o):void 0,s&&j7(r[0],r[1],s)&&(o=n<3?void 0:o,n=1),e=Object(e);++i<n;){var a=r[i];a&&t(e,a,i,o)}return e})}function HP(t,e){return e=e??VP,!!e&&(typeof t=="number"||k7.test(t))&&t>-1&&t%1==0&&t<e}function j7(t,e,r){if(!UE(r))return!1;var i=typeof e;return(i=="number"?LE(r)&&HP(e,r.length):i=="string"&&e in r)?NE(r[e],t):!1}function P7(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Bc;return t===r}function M7(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}function NE(t,e){return t===e||t!==t&&e!==e}function N7(t){return U7(t)&&Wc.call(t,"callee")&&(!T7.call(t,"callee")||WP.call(t)==w7)}var L7=Array.isArray;function LE(t){return t!=null&&J7(t.length)&&!$7(t)}function U7(t){return F7(t)&&LE(t)}function $7(t){var e=UE(t)?WP.call(t):"";return e==x7||e==I7}function J7(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=VP}function UE(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function F7(t){return!!t&&typeof t=="object"}var q7=D7(function(t,e,r,i){R7(e,G7(e),t,i)}),z7=ZP(function(t){return t.push(void 0,O7),BP(q7,void 0,t)});function G7(t){return LE(t)?C7(t,!0):K7(t)}YP.exports=z7});var tM=h((uIe,eM)=>{var V7=9007199254740991,B7="[object Arguments]",W7="[object Function]",Z7="[object GeneratorFunction]",$E=Object.prototype,H7=$E.hasOwnProperty,QP=$E.toString,Y7=$E.propertyIsEnumerable;function X7(t){return eee(t)&&H7.call(t,"callee")&&(!Y7.call(t,"callee")||QP.call(t)==B7)}function Q7(t){return t!=null&&ree(t.length)&&!tee(t)}function eee(t){return iee(t)&&Q7(t)}function tee(t){var e=nee(t)?QP.call(t):"";return e==W7||e==Z7}function ree(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=V7}function nee(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function iee(t){return!!t&&typeof t=="object"}eM.exports=X7});var yf=h($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.isArguments=$i.defaults=$i.noop=void 0;var oee=XP();$i.defaults=oee;var see=tM();$i.isArguments=see;function aee(){}$i.noop=aee});var nM=h((pIe,rM)=>{var wa=1e3,xa=wa*60,Ia=xa*60,zo=Ia*24,lee=zo*7,cee=zo*365.25;rM.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return uee(t);if(r==="number"&&isFinite(t))return e.long?pee(t):dee(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function uee(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return r*cee;case"weeks":case"week":case"w":return r*lee;case"days":case"day":case"d":return r*zo;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ia;case"minutes":case"minute":case"mins":case"min":case"m":return r*xa;case"seconds":case"second":case"secs":case"sec":case"s":return r*wa;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function dee(t){var e=Math.abs(t);return e>=zo?Math.round(t/zo)+"d":e>=Ia?Math.round(t/Ia)+"h":e>=xa?Math.round(t/xa)+"m":e>=wa?Math.round(t/wa)+"s":t+"ms"}function pee(t){var e=Math.abs(t);return e>=zo?gf(t,e,zo,"day"):e>=Ia?gf(t,e,Ia,"hour"):e>=xa?gf(t,e,xa,"minute"):e>=wa?gf(t,e,wa,"second"):t+" ms"}function gf(t,e,r,i){var n=e>=r*1.5;return Math.round(t/r)+" "+i+(n?"s":"")}});var JE=h((fIe,iM)=>{function fee(t){r.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=n,r.enabled=a,r.humanize=nM(),r.destroy=c,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let d=0;for(let f=0;f<u.length;f++)d=(d<<5)-d+u.charCodeAt(f),d|=0;return r.colors[Math.abs(d)%r.colors.length]}r.selectColor=e;function r(u){let d,f=null,p,m;function y(...w){if(!y.enabled)return;let _=y,A=Number(new Date),O=A-(d||A);_.diff=O,_.prev=d,_.curr=A,d=A,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let C=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(re,pe)=>{if(re==="%%")return"%";C++;let ve=r.formatters[pe];if(typeof ve=="function"){let me=w[C];re=ve.call(_,me),w.splice(C,1),C--}return re}),r.formatArgs.call(_,w),(_.log||r.log).apply(_,w)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=i,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(p!==r.namespaces&&(p=r.namespaces,m=r.enabled(u)),m),set:w=>{f=w}}),typeof r.init=="function"&&r.init(y),y}function i(u,d){let f=r(this.namespace+(typeof d>"u"?":":d)+u);return f.log=this.log,f}function n(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let d=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let f of d)f[0]==="-"?r.skips.push(f.slice(1)):r.names.push(f)}function o(u,d){let f=0,p=0,m=-1,y=0;for(;f<u.length;)if(p<d.length&&(d[p]===u[f]||d[p]==="*"))d[p]==="*"?(m=p,y=f,p++):(f++,p++);else if(m!==-1)p=m+1,y++,f=y;else return!1;for(;p<d.length&&d[p]==="*";)p++;return p===d.length}function s(){let u=[...r.names,...r.skips.map(d=>"-"+d)].join(",");return r.enable(""),u}function a(u){for(let d of r.skips)if(o(u,d))return!1;for(let d of r.names)if(o(u,d))return!0;return!1}function l(u){return u instanceof Error?u.stack||u.message:u}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}iM.exports=fee});var oM=h((br,bf)=>{br.formatArgs=hee;br.save=yee;br.load=gee;br.useColors=mee;br.storage=bee();br.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();br.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 mee(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function hee(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+bf.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(i=r))}),t.splice(i,0,e)}br.log=console.debug||console.log||(()=>{});function yee(t){try{t?br.storage.setItem("debug",t):br.storage.removeItem("debug")}catch{}}function gee(){let t;try{t=br.storage.getItem("debug")||br.storage.getItem("DEBUG")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function bee(){try{return localStorage}catch{}}bf.exports=JE()(br);var{formatters:vee}=bf.exports;vee.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var aM={};Ce(aM,{createSupportsColor:()=>FE,default:()=>kee});import qE from"node:process";import See from"node:os";import sM from"node:tty";function Xr(t,e=globalThis.Deno?globalThis.Deno.args:qE.argv){let r=t.startsWith("-")?"":t.length===1?"-":"--",i=e.indexOf(r+t),n=e.indexOf("--");return i!==-1&&(n===-1||i<n)}function Eee(){if(!("FORCE_COLOR"in Qe))return;if(Qe.FORCE_COLOR==="true")return 1;if(Qe.FORCE_COLOR==="false")return 0;if(Qe.FORCE_COLOR.length===0)return 1;let t=Math.min(Number.parseInt(Qe.FORCE_COLOR,10),3);if([0,1,2,3].includes(t))return t}function wee(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function xee(t,{streamIsTTY:e,sniffFlags:r=!0}={}){let i=Eee();i!==void 0&&(vf=i);let n=r?vf:i;if(n===0)return 0;if(r){if(Xr("color=16m")||Xr("color=full")||Xr("color=truecolor"))return 3;if(Xr("color=256"))return 2}if("TF_BUILD"in Qe&&"AGENT_NAME"in Qe)return 1;if(t&&!e&&n===void 0)return 0;let o=n||0;if(Qe.TERM==="dumb")return o;if(qE.platform==="win32"){let s=See.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in Qe)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in Qe)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in Qe)||Qe.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in Qe)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Qe.TEAMCITY_VERSION)?1:0;if(Qe.COLORTERM==="truecolor"||Qe.TERM==="xterm-kitty"||Qe.TERM==="xterm-ghostty"||Qe.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Qe){let s=Number.parseInt((Qe.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Qe.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Qe.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Qe.TERM)||"COLORTERM"in Qe?1:o}function FE(t,e={}){let r=xee(t,{streamIsTTY:t&&t.isTTY,...e});return wee(r)}var Qe,vf,Iee,kee,lM=S(()=>{({env:Qe}=qE);Xr("no-color")||Xr("no-colors")||Xr("color=false")||Xr("color=never")?vf=0:(Xr("color")||Xr("colors")||Xr("color=true")||Xr("color=always"))&&(vf=1);Iee={stdout:FE({isTTY:sM.isatty(1)}),stderr:FE({isTTY:sM.isatty(2)})},kee=Iee});var uM=h((Kt,Ef)=>{var _ee=U("tty"),Sf=U("util");Kt.init=Dee;Kt.log=Aee;Kt.formatArgs=Cee;Kt.save=Kee;Kt.load=Ree;Kt.useColors=Tee;Kt.destroy=Sf.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Kt.colors=[6,2,3,4,5,1];try{let t=(lM(),Jt(aM));t&&(t.stderr||t).level>=2&&(Kt.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{}Kt.inspectOpts=Object.keys(process.env).filter(t=>/^debug_/i.test(t)).reduce((t,e)=>{let r=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,o)=>o.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),t[r]=i,t},{});function Tee(){return"colors"in Kt.inspectOpts?!!Kt.inspectOpts.colors:_ee.isatty(process.stderr.fd)}function Cee(t){let{namespace:e,useColors:r}=this;if(r){let i=this.color,n="\x1B[3"+(i<8?i:"8;5;"+i),o=` ${n};1m${e} \x1B[0m`;t[0]=o+t[0].split(`
980
980
  `).join(`
981
981
  `+o),t.push(n+"m+"+Ef.exports.humanize(this.diff)+"\x1B[0m")}else t[0]=Oee()+e+" "+t[0]}function Oee(){return Kt.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Aee(...t){return process.stderr.write(Sf.formatWithOptions(Kt.inspectOpts,...t)+`
982
982
  `)}function Kee(t){t?process.env.DEBUG=t:delete process.env.DEBUG}function Ree(){return process.env.DEBUG}function Dee(t){t.inspectOpts={};let e=Object.keys(Kt.inspectOpts);for(let r=0;r<e.length;r++)t.inspectOpts[e[r]]=Kt.inspectOpts[e[r]]}Ef.exports=JE()(Kt);var{formatters:cM}=Ef.exports;cM.o=function(t){return this.inspectOpts.colors=this.useColors,Sf.inspect(t,this.inspectOpts).split(`
983
- `).map(e=>e.trim()).join(" ")};cM.O=function(t){return this.inspectOpts.colors=this.useColors,Sf.inspect(t,this.inspectOpts)}});var dM=h((yIe,zE)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?zE.exports=oM():zE.exports=uM()});var mM=h(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.genRedactedString=si.getStringValue=si.MAX_ARGUMENT_LENGTH=void 0;var jee=dM(),GE=200;si.MAX_ARGUMENT_LENGTH=GE;var Pee="ioredis";function pM(t){if(t!==null)switch(typeof t){case"boolean":return;case"number":return;case"object":if(Buffer.isBuffer(t))return t.toString("hex");if(Array.isArray(t))return t.join(",");try{return JSON.stringify(t)}catch{return}case"string":return t}}si.getStringValue=pM;function fM(t,e){let{length:r}=t;return r<=e?t:t.slice(0,e)+' ... <REDACTED full-length="'+r+'">'}si.genRedactedString=fM;function Mee(t){let e=(0,jee.default)(`${Pee}:${t}`);function r(...i){if(e.enabled){for(let n=1;n<i.length;n++){let o=pM(i[n]);typeof o=="string"&&o.length>GE&&(i[n]=fM(o,GE))}return e.apply(null,i)}}return Object.defineProperties(r,{namespace:{get(){return e.namespace}},enabled:{get(){return e.enabled}},destroy:{get(){return e.destroy}},log:{get(){return e.log},set(i){e.log=i}}}),r}si.default=Mee});var yM=h(VE=>{"use strict";Object.defineProperty(VE,"__esModule",{value:!0});var hM=`-----BEGIN CERTIFICATE-----
983
+ `).map(e=>e.trim()).join(" ")};cM.O=function(t){return this.inspectOpts.colors=this.useColors,Sf.inspect(t,this.inspectOpts)}});var dM=h((gIe,zE)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?zE.exports=oM():zE.exports=uM()});var mM=h(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.genRedactedString=si.getStringValue=si.MAX_ARGUMENT_LENGTH=void 0;var jee=dM(),GE=200;si.MAX_ARGUMENT_LENGTH=GE;var Pee="ioredis";function pM(t){if(t!==null)switch(typeof t){case"boolean":return;case"number":return;case"object":if(Buffer.isBuffer(t))return t.toString("hex");if(Array.isArray(t))return t.join(",");try{return JSON.stringify(t)}catch{return}case"string":return t}}si.getStringValue=pM;function fM(t,e){let{length:r}=t;return r<=e?t:t.slice(0,e)+' ... <REDACTED full-length="'+r+'">'}si.genRedactedString=fM;function Mee(t){let e=(0,jee.default)(`${Pee}:${t}`);function r(...i){if(e.enabled){for(let n=1;n<i.length;n++){let o=pM(i[n]);typeof o=="string"&&o.length>GE&&(i[n]=fM(o,GE))}return e.apply(null,i)}}return Object.defineProperties(r,{namespace:{get(){return e.namespace}},enabled:{get(){return e.enabled}},destroy:{get(){return e.destroy}},log:{get(){return e.log},set(i){e.log=i}}}),r}si.default=Mee});var yM=h(VE=>{"use strict";Object.defineProperty(VE,"__esModule",{value:!0});var hM=`-----BEGIN CERTIFICATE-----
984
984
  MIIDTzCCAjegAwIBAgIJAKSVpiDswLcwMA0GCSqGSIb3DQEBBQUAMD4xFjAUBgNV
985
985
  BAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1
986
986
  dGhvcml0eTAeFw0xMzEwMDExMjE0NTVaFw0yMzA5MjkxMjE0NTVaMD4xFjAUBgNV
@@ -1121,11 +1121,11 @@ WD9f
1121
1121
  -----END CERTIFICATE-----`,Nee={RedisCloudFixed:{ca:hM},RedisCloudFlexible:{ca:hM}};VE.default=Nee});var bt=h(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.noop=he.defaults=he.Debug=he.getPackageMeta=he.zipMap=he.CONNECTION_CLOSED_ERROR_MSG=he.shuffle=he.sample=he.resolveTLSProfile=he.parseURL=he.optimizeErrorStack=he.toArg=he.convertMapToArray=he.convertObjectToArray=he.timeout=he.packObject=he.isInt=he.wrapMultiResult=he.convertBufferToString=void 0;var Lee=U("fs"),Uee=U("path"),gM=U("url"),BE=yf();Object.defineProperty(he,"defaults",{enumerable:!0,get:function(){return BE.defaults}});Object.defineProperty(he,"noop",{enumerable:!0,get:function(){return BE.noop}});var $ee=mM();he.Debug=$ee.default;var Jee=yM();function bM(t,e){if(t instanceof Buffer)return t.toString(e);if(Array.isArray(t)){let r=t.length,i=Array(r);for(let n=0;n<r;++n)i[n]=t[n]instanceof Buffer&&e==="utf8"?t[n].toString():bM(t[n],e);return i}return t}he.convertBufferToString=bM;function Fee(t){if(!t)return null;let e=[],r=t.length;for(let i=0;i<r;++i){let n=t[i];n instanceof Error?e.push([n]):e.push([null,n])}return e}he.wrapMultiResult=Fee;function vM(t){let e=parseFloat(t);return!isNaN(t)&&(e|0)===e}he.isInt=vM;function qee(t){let e={},r=t.length;for(let i=1;i<r;i+=2)e[t[i-1]]=t[i];return e}he.packObject=qee;function zee(t,e){let r=null,i=function(){r&&(clearTimeout(r),r=null,t.apply(this,arguments))};return r=setTimeout(i,e,new Error("timeout")),i}he.timeout=zee;function Gee(t){let e=[],r=Object.keys(t);for(let i=0,n=r.length;i<n;i++)e.push(r[i],t[r[i]]);return e}he.convertObjectToArray=Gee;function Vee(t){let e=[],r=0;return t.forEach(function(i,n){e[r]=n,e[r+1]=i,r+=2}),e}he.convertMapToArray=Vee;function Bee(t){return t===null||typeof t>"u"?"":String(t)}he.toArg=Bee;function Wee(t,e,r){let i=e.split(`
1122
1122
  `),n="",o;for(o=1;o<i.length&&i[o].indexOf(r)!==-1;++o);for(let s=o;s<i.length;++s)n+=`
1123
1123
  `+i[s];if(t.stack){let s=t.stack.indexOf(`
1124
- `);t.stack=t.stack.slice(0,s)+n}return t}he.optimizeErrorStack=Wee;function Zee(t){if(vM(t))return{port:t};let e=(0,gM.parse)(t,!0,!0);!e.slashes&&t[0]!=="/"&&(t="//"+t,e=(0,gM.parse)(t,!0,!0));let r=e.query||{},i={};if(e.auth){let n=e.auth.indexOf(":");i.username=n===-1?e.auth:e.auth.slice(0,n),i.password=n===-1?"":e.auth.slice(n+1)}if(e.pathname&&(e.protocol==="redis:"||e.protocol==="rediss:"?e.pathname.length>1&&(i.db=e.pathname.slice(1)):i.path=e.pathname),e.host&&(i.host=e.hostname),e.port&&(i.port=e.port),typeof r.family=="string"){let n=Number.parseInt(r.family,10);Number.isNaN(n)||(i.family=n)}return(0,BE.defaults)(i,r),i}he.parseURL=Zee;function Hee(t){let e=t?.tls;typeof e=="string"&&(e={profile:e});let r=Jee.default[e?.profile];return r&&(e=Object.assign({},r,e),delete e.profile,t=Object.assign({},t,{tls:e})),t}he.resolveTLSProfile=Hee;function Yee(t,e=0){let r=t.length;return e>=r?null:t[e+Math.floor(Math.random()*(r-e))]}he.sample=Yee;function Xee(t){let e=t.length;for(;e>0;){let r=Math.floor(Math.random()*e);e--,[t[e],t[r]]=[t[r],t[e]]}return t}he.shuffle=Xee;he.CONNECTION_CLOSED_ERROR_MSG="Connection is closed.";function Qee(t,e){let r=new Map;return t.forEach((i,n)=>{r.set(i,e[n])}),r}he.zipMap=Qee;var ka=null;async function ete(){if(ka)return ka;try{let t=(0,Uee.resolve)(__dirname,"..","..","package.json"),e=await Lee.promises.readFile(t,"utf8");return ka={version:JSON.parse(e).version},ka}catch{return ka={version:"error-fetching-version"},ka}}he.getPackageMeta=ete});var _a=h(wf=>{"use strict";Object.defineProperty(wf,"__esModule",{value:!0});wf.ConnectionClosedError=void 0;var WE=class extends Error{constructor(e,r){super(e??"Connection is closed"),this.cause=r,this.name="ConnectionClosedError",Object.setPrototypeOf(this,new.target.prototype)}};wf.ConnectionClosedError=WE});var Ta=h((EIe,SM)=>{"use strict";var tte="2.0.0",rte=Number.MAX_SAFE_INTEGER||9007199254740991,nte=16,ite=250,ote=["major","premajor","minor","preminor","patch","prepatch","prerelease"];SM.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:nte,MAX_SAFE_BUILD_LENGTH:ite,MAX_SAFE_INTEGER:rte,RELEASE_TYPES:ote,SEMVER_SPEC_VERSION:tte,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Zc=h((wIe,EM)=>{"use strict";var ste=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};EM.exports=ste});var Ca=h((Pn,wM)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:ZE,MAX_SAFE_BUILD_LENGTH:ate,MAX_LENGTH:lte}=Ta(),cte=Zc();Pn=wM.exports={};var ute=Pn.re=[],dte=Pn.safeRe=[],V=Pn.src=[],pte=Pn.safeSrc=[],B=Pn.t={},fte=0,HE="[a-zA-Z0-9-]",mte=[["\\s",1],["\\d",lte],[HE,ate]],hte=t=>{for(let[e,r]of mte)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t},ce=(t,e,r)=>{let i=hte(e),n=fte++;cte(t,n,e),B[t]=n,V[n]=e,pte[n]=i,ute[n]=new RegExp(e,r?"g":void 0),dte[n]=new RegExp(i,r?"g":void 0)};ce("NUMERICIDENTIFIER","0|[1-9]\\d*");ce("NUMERICIDENTIFIERLOOSE","\\d+");ce("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${HE}*`);ce("MAINVERSION",`(${V[B.NUMERICIDENTIFIER]})\\.(${V[B.NUMERICIDENTIFIER]})\\.(${V[B.NUMERICIDENTIFIER]})`);ce("MAINVERSIONLOOSE",`(${V[B.NUMERICIDENTIFIERLOOSE]})\\.(${V[B.NUMERICIDENTIFIERLOOSE]})\\.(${V[B.NUMERICIDENTIFIERLOOSE]})`);ce("PRERELEASEIDENTIFIER",`(?:${V[B.NONNUMERICIDENTIFIER]}|${V[B.NUMERICIDENTIFIER]})`);ce("PRERELEASEIDENTIFIERLOOSE",`(?:${V[B.NONNUMERICIDENTIFIER]}|${V[B.NUMERICIDENTIFIERLOOSE]})`);ce("PRERELEASE",`(?:-(${V[B.PRERELEASEIDENTIFIER]}(?:\\.${V[B.PRERELEASEIDENTIFIER]})*))`);ce("PRERELEASELOOSE",`(?:-?(${V[B.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${V[B.PRERELEASEIDENTIFIERLOOSE]})*))`);ce("BUILDIDENTIFIER",`${HE}+`);ce("BUILD",`(?:\\+(${V[B.BUILDIDENTIFIER]}(?:\\.${V[B.BUILDIDENTIFIER]})*))`);ce("FULLPLAIN",`v?${V[B.MAINVERSION]}${V[B.PRERELEASE]}?${V[B.BUILD]}?`);ce("FULL",`^${V[B.FULLPLAIN]}$`);ce("LOOSEPLAIN",`[v=\\s]*${V[B.MAINVERSIONLOOSE]}${V[B.PRERELEASELOOSE]}?${V[B.BUILD]}?`);ce("LOOSE",`^${V[B.LOOSEPLAIN]}$`);ce("GTLT","((?:<|>)?=?)");ce("XRANGEIDENTIFIERLOOSE",`${V[B.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);ce("XRANGEIDENTIFIER",`${V[B.NUMERICIDENTIFIER]}|x|X|\\*`);ce("XRANGEPLAIN",`[v=\\s]*(${V[B.XRANGEIDENTIFIER]})(?:\\.(${V[B.XRANGEIDENTIFIER]})(?:\\.(${V[B.XRANGEIDENTIFIER]})(?:${V[B.PRERELEASE]})?${V[B.BUILD]}?)?)?`);ce("XRANGEPLAINLOOSE",`[v=\\s]*(${V[B.XRANGEIDENTIFIERLOOSE]})(?:\\.(${V[B.XRANGEIDENTIFIERLOOSE]})(?:\\.(${V[B.XRANGEIDENTIFIERLOOSE]})(?:${V[B.PRERELEASELOOSE]})?${V[B.BUILD]}?)?)?`);ce("XRANGE",`^${V[B.GTLT]}\\s*${V[B.XRANGEPLAIN]}$`);ce("XRANGELOOSE",`^${V[B.GTLT]}\\s*${V[B.XRANGEPLAINLOOSE]}$`);ce("COERCEPLAIN",`(^|[^\\d])(\\d{1,${ZE}})(?:\\.(\\d{1,${ZE}}))?(?:\\.(\\d{1,${ZE}}))?`);ce("COERCE",`${V[B.COERCEPLAIN]}(?:$|[^\\d])`);ce("COERCEFULL",V[B.COERCEPLAIN]+`(?:${V[B.PRERELEASE]})?(?:${V[B.BUILD]})?(?:$|[^\\d])`);ce("COERCERTL",V[B.COERCE],!0);ce("COERCERTLFULL",V[B.COERCEFULL],!0);ce("LONETILDE","(?:~>?)");ce("TILDETRIM",`(\\s*)${V[B.LONETILDE]}\\s+`,!0);Pn.tildeTrimReplace="$1~";ce("TILDE",`^${V[B.LONETILDE]}${V[B.XRANGEPLAIN]}$`);ce("TILDELOOSE",`^${V[B.LONETILDE]}${V[B.XRANGEPLAINLOOSE]}$`);ce("LONECARET","(?:\\^)");ce("CARETTRIM",`(\\s*)${V[B.LONECARET]}\\s+`,!0);Pn.caretTrimReplace="$1^";ce("CARET",`^${V[B.LONECARET]}${V[B.XRANGEPLAIN]}$`);ce("CARETLOOSE",`^${V[B.LONECARET]}${V[B.XRANGEPLAINLOOSE]}$`);ce("COMPARATORLOOSE",`^${V[B.GTLT]}\\s*(${V[B.LOOSEPLAIN]})$|^$`);ce("COMPARATOR",`^${V[B.GTLT]}\\s*(${V[B.FULLPLAIN]})$|^$`);ce("COMPARATORTRIM",`(\\s*)${V[B.GTLT]}\\s*(${V[B.LOOSEPLAIN]}|${V[B.XRANGEPLAIN]})`,!0);Pn.comparatorTrimReplace="$1$2$3";ce("HYPHENRANGE",`^\\s*(${V[B.XRANGEPLAIN]})\\s+-\\s+(${V[B.XRANGEPLAIN]})\\s*$`);ce("HYPHENRANGELOOSE",`^\\s*(${V[B.XRANGEPLAINLOOSE]})\\s+-\\s+(${V[B.XRANGEPLAINLOOSE]})\\s*$`);ce("STAR","(<|>)?=?\\s*\\*");ce("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");ce("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var xf=h((xIe,xM)=>{"use strict";var yte=Object.freeze({loose:!0}),gte=Object.freeze({}),bte=t=>t?typeof t!="object"?yte:t:gte;xM.exports=bte});var YE=h((IIe,_M)=>{"use strict";var IM=/^[0-9]+$/,kM=(t,e)=>{if(typeof t=="number"&&typeof e=="number")return t===e?0:t<e?-1:1;let r=IM.test(t),i=IM.test(e);return r&&i&&(t=+t,e=+e),t===e?0:r&&!i?-1:i&&!r?1:t<e?-1:1},vte=(t,e)=>kM(e,t);_M.exports={compareIdentifiers:kM,rcompareIdentifiers:vte}});var Nt=h((kIe,CM)=>{"use strict";var If=Zc(),{MAX_LENGTH:TM,MAX_SAFE_INTEGER:kf}=Ta(),{safeRe:_f,t:Tf}=Ca(),Ste=xf(),{compareIdentifiers:XE}=YE(),Ete=(t,e)=>{let r=e.split(".");if(r.length>t.length)return!1;for(let i=0;i<r.length;i++)if(XE(t[i],r[i])!==0)return!1;return!0},QE=class t{constructor(e,r){if(r=Ste(r),e instanceof t){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>TM)throw new TypeError(`version is longer than ${TM} characters`);If("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let i=e.trim().match(r.loose?_f[Tf.LOOSE]:_f[Tf.FULL]);if(!i)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>kf||this.major<0)throw new TypeError("Invalid major version");if(this.minor>kf||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>kf||this.patch<0)throw new TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let o=+n;if(o>=0&&o<kf)return o}return n}):this.prerelease=[],this.build=i[5]?i[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(If("SemVer.compare",this.version,this.options,e),!(e instanceof t)){if(typeof e=="string"&&e===this.version)return 0;e=new t(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof t||(e=new t(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof t||(e=new t(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{let i=this.prerelease[r],n=e.prerelease[r];if(If("prerelease compare",r,i,n),i===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(i===void 0)return-1;if(i===n)continue;return XE(i,n)}while(++r)}compareBuild(e){e instanceof t||(e=new t(e,this.options));let r=0;do{let i=this.build[r],n=e.build[r];if(If("build compare",r,i,n),i===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(i===void 0)return-1;if(i===n)continue;return XE(i,n)}while(++r)}inc(e,r,i){if(e.startsWith("pre")){if(!r&&i===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let n=`-${r}`.match(this.options.loose?_f[Tf.PRERELEASELOOSE]:_f[Tf.PRERELEASE]);if(!n||n[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,i);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,i);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,i),this.inc("pre",r,i);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,i),this.inc("pre",r,i);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":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(i)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let o=this.prerelease.length;for(;--o>=0;)typeof this.prerelease[o]=="number"&&(this.prerelease[o]++,o=-2);if(o===-1){if(r===this.prerelease.join(".")&&i===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(r){let o=[r,n];if(i===!1&&(o=[r]),Ete(this.prerelease,r)){let s=this.prerelease[r.split(".").length];isNaN(s)&&(this.prerelease=o)}else this.prerelease=o}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};CM.exports=QE});var Ji=h((_Ie,AM)=>{"use strict";var OM=Nt(),wte=(t,e,r=!1)=>{if(t instanceof OM)return t;try{return new OM(t,e)}catch(i){if(!r)return null;throw i}};AM.exports=wte});var RM=h((TIe,KM)=>{"use strict";var xte=Ji(),Ite=(t,e)=>{let r=xte(t,e);return r?r.version:null};KM.exports=Ite});var jM=h((CIe,DM)=>{"use strict";var kte=Ji(),_te=(t,e)=>{let r=kte(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null};DM.exports=_te});var NM=h((OIe,MM)=>{"use strict";var PM=Nt(),Tte=(t,e,r,i,n)=>{typeof r=="string"&&(n=i,i=r,r=void 0);try{return new PM(t instanceof PM?t.version:t,r).inc(e,i,n).version}catch{return null}};MM.exports=Tte});var $M=h((AIe,UM)=>{"use strict";var LM=Ji(),Cte=(t,e)=>{let r=LM(t,null,!0),i=LM(e,null,!0),n=r.compare(i);if(n===0)return null;let o=n>0,s=o?r:i,a=o?i:r,l=!!s.prerelease.length;if(!!a.prerelease.length&&!l){if(!a.patch&&!a.minor)return"major";if(a.compareMain(s)===0)return a.minor&&!a.patch?"minor":"patch"}let u=l?"pre":"";return r.major!==i.major?u+"major":r.minor!==i.minor?u+"minor":r.patch!==i.patch?u+"patch":"prerelease"};UM.exports=Cte});var FM=h((KIe,JM)=>{"use strict";var Ote=Nt(),Ate=(t,e)=>new Ote(t,e).major;JM.exports=Ate});var zM=h((RIe,qM)=>{"use strict";var Kte=Nt(),Rte=(t,e)=>new Kte(t,e).minor;qM.exports=Rte});var VM=h((DIe,GM)=>{"use strict";var Dte=Nt(),jte=(t,e)=>new Dte(t,e).patch;GM.exports=jte});var WM=h((jIe,BM)=>{"use strict";var Pte=Ji(),Mte=(t,e)=>{let r=Pte(t,e);return r&&r.prerelease.length?r.prerelease:null};BM.exports=Mte});var Qr=h((PIe,HM)=>{"use strict";var ZM=Nt(),Nte=(t,e,r)=>new ZM(t,r).compare(new ZM(e,r));HM.exports=Nte});var XM=h((MIe,YM)=>{"use strict";var Lte=Qr(),Ute=(t,e,r)=>Lte(e,t,r);YM.exports=Ute});var eN=h((NIe,QM)=>{"use strict";var $te=Qr(),Jte=(t,e)=>$te(t,e,!0);QM.exports=Jte});var Cf=h((LIe,rN)=>{"use strict";var tN=Nt(),Fte=(t,e,r)=>{let i=new tN(t,r),n=new tN(e,r);return i.compare(n)||i.compareBuild(n)};rN.exports=Fte});var iN=h((UIe,nN)=>{"use strict";var qte=Cf(),zte=(t,e)=>t.sort((r,i)=>qte(r,i,e));nN.exports=zte});var sN=h(($Ie,oN)=>{"use strict";var Gte=Cf(),Vte=(t,e)=>t.sort((r,i)=>Gte(i,r,e));oN.exports=Vte});var Hc=h((JIe,aN)=>{"use strict";var Bte=Qr(),Wte=(t,e,r)=>Bte(t,e,r)>0;aN.exports=Wte});var Of=h((FIe,lN)=>{"use strict";var Zte=Qr(),Hte=(t,e,r)=>Zte(t,e,r)<0;lN.exports=Hte});var e0=h((qIe,cN)=>{"use strict";var Yte=Qr(),Xte=(t,e,r)=>Yte(t,e,r)===0;cN.exports=Xte});var t0=h((zIe,uN)=>{"use strict";var Qte=Qr(),ere=(t,e,r)=>Qte(t,e,r)!==0;uN.exports=ere});var Af=h((GIe,dN)=>{"use strict";var tre=Qr(),rre=(t,e,r)=>tre(t,e,r)>=0;dN.exports=rre});var Kf=h((VIe,pN)=>{"use strict";var nre=Qr(),ire=(t,e,r)=>nre(t,e,r)<=0;pN.exports=ire});var r0=h((BIe,fN)=>{"use strict";var ore=e0(),sre=t0(),are=Hc(),lre=Af(),cre=Of(),ure=Kf(),dre=(t,e,r,i)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return ore(t,r,i);case"!=":return sre(t,r,i);case">":return are(t,r,i);case">=":return lre(t,r,i);case"<":return cre(t,r,i);case"<=":return ure(t,r,i);default:throw new TypeError(`Invalid operator: ${e}`)}};fN.exports=dre});var hN=h((WIe,mN)=>{"use strict";var pre=Nt(),fre=Ji(),{safeRe:Rf,t:Df}=Ca(),mre=(t,e)=>{if(t instanceof pre)return t;if(typeof t=="number"&&(t=String(t)),typeof t!="string")return null;e=e||{};let r=null;if(!e.rtl)r=t.match(e.includePrerelease?Rf[Df.COERCEFULL]:Rf[Df.COERCE]);else{let l=e.includePrerelease?Rf[Df.COERCERTLFULL]:Rf[Df.COERCERTL],c;for(;(c=l.exec(t))&&(!r||r.index+r[0].length!==t.length);)(!r||c.index+c[0].length!==r.index+r[0].length)&&(r=c),l.lastIndex=c.index+c[1].length+c[2].length;l.lastIndex=-1}if(r===null)return null;let i=r[2],n=r[3]||"0",o=r[4]||"0",s=e.includePrerelease&&r[5]?`-${r[5]}`:"",a=e.includePrerelease&&r[6]?`+${r[6]}`:"";return fre(`${i}.${n}.${o}${s}${a}`,e)};mN.exports=mre});var gN=h((ZIe,yN)=>{"use strict";var hre=Ji(),yre=Ta(),gre=Nt(),bre=(t,e,r)=>{if(!yre.RELEASE_TYPES.includes(e))return null;let i=vre(t,r);return i&&Sre(i,e)},vre=(t,e)=>{let r=t instanceof gre?t.version:t;return hre(r,e)},Sre=(t,e)=>{if(Ere(e))return t.version;switch(t.prerelease=[],e){case"major":t.minor=0,t.patch=0;break;case"minor":t.patch=0;break}return t.format()},Ere=t=>t.startsWith("pre");yN.exports=bre});var vN=h((HIe,bN)=>{"use strict";var n0=class{constructor(){this.max=1e3,this.map=new Map}get(e){let r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}delete(e){return this.map.delete(e)}set(e,r){if(!this.delete(e)&&r!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(e,r)}return this}};bN.exports=n0});var en=h((YIe,xN)=>{"use strict";var wre=/\s+/g,i0=class t{constructor(e,r){if(r=Ire(r),e instanceof t)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new t(e.raw,r);if(e instanceof o0)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e.trim().replace(wre," "),this.set=this.raw.split("||").map(i=>this.parseRange(i.trim())).filter(i=>i.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let i=this.set[0];if(this.set=this.set.filter(n=>!EN(n[0])),this.set.length===0)this.set=[i];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&Dre(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let r=this.set[e];for(let i=0;i<r.length;i++)i>0&&(this.formatted+=" "),this.formatted+=r[i].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){e=e.replace(Rre,"");let i=((this.options.includePrerelease&&Are)|(this.options.loose&&Kre))+":"+e,n=SN.get(i);if(n)return n;let o=this.options.loose,s=o?ar[Lt.HYPHENRANGELOOSE]:ar[Lt.HYPHENRANGE];e=e.replace(s,zre(this.options.includePrerelease)),Ye("hyphen replace",e),e=e.replace(ar[Lt.COMPARATORTRIM],Tre),Ye("comparator trim",e),e=e.replace(ar[Lt.TILDETRIM],Cre),Ye("tilde trim",e),e=e.replace(ar[Lt.CARETTRIM],Ore),Ye("caret trim",e);let a=e.split(" ").map(d=>jre(d,this.options)).join(" ").split(/\s+/).map(d=>qre(d,this.options));o&&(a=a.filter(d=>(Ye("loose invalid filter",d,this.options),!!d.match(ar[Lt.COMPARATORLOOSE])))),Ye("range list",a);let l=new Map,c=a.map(d=>new o0(d,this.options));for(let d of c){if(EN(d))return[d];l.set(d.value,d)}l.size>1&&l.has("")&&l.delete("");let u=[...l.values()];return SN.set(i,u),u}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(i=>wN(i,r)&&e.set.some(n=>wN(n,r)&&i.every(o=>n.every(s=>o.intersects(s,r)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new kre(e,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(Gre(this.set[r],e,this.options))return!0;return!1}};xN.exports=i0;var xre=vN(),SN=new xre,Ire=xf(),o0=Yc(),Ye=Zc(),kre=Nt(),{safeRe:ar,src:_re,t:Lt,comparatorTrimReplace:Tre,tildeTrimReplace:Cre,caretTrimReplace:Ore}=Ca(),{FLAG_INCLUDE_PRERELEASE:Are,FLAG_LOOSE:Kre}=Ta(),Rre=new RegExp(_re[Lt.BUILD],"g"),EN=t=>t.value==="<0.0.0-0",Dre=t=>t.value==="",wN=(t,e)=>{let r=!0,i=t.slice(),n=i.pop();for(;r&&i.length;)r=i.every(o=>n.intersects(o,e)),n=i.pop();return r},jre=(t,e)=>(t=t.replace(ar[Lt.BUILD],""),Ye("comp",t,e),t=Lre(t,e),Ye("caret",t),t=Mre(t,e),Ye("tildes",t),t=$re(t,e),Ye("xrange",t),t=Fre(t,e),Ye("stars",t),t),_t=t=>!t||t.toLowerCase()==="x"||t==="*",Pre=(t,e,r)=>_t(t)&&!_t(e)||_t(e)&&r&&!_t(r),Mre=(t,e)=>t.trim().split(/\s+/).map(r=>Nre(r,e)).join(" "),Nre=(t,e)=>{let r=e.loose?ar[Lt.TILDELOOSE]:ar[Lt.TILDE],i=e.includePrerelease?"-0":"";return t.replace(r,(n,o,s,a,l)=>{Ye("tilde",t,n,o,s,a,l);let c;return _t(o)?c="":_t(s)?c=`>=${o}.0.0${i} <${+o+1}.0.0-0`:_t(a)?c=`>=${o}.${s}.0${i} <${o}.${+s+1}.0-0`:l?(Ye("replaceTilde pr",l),c=`>=${o}.${s}.${a}-${l} <${o}.${+s+1}.0-0`):c=`>=${o}.${s}.${a} <${o}.${+s+1}.0-0`,Ye("tilde return",c),c})},Lre=(t,e)=>t.trim().split(/\s+/).map(r=>Ure(r,e)).join(" "),Ure=(t,e)=>{Ye("caret",t,e);let r=e.loose?ar[Lt.CARETLOOSE]:ar[Lt.CARET],i=e.includePrerelease?"-0":"";return t.replace(r,(n,o,s,a,l)=>{Ye("caret",t,n,o,s,a,l);let c;return _t(o)?c="":_t(s)?c=`>=${o}.0.0${i} <${+o+1}.0.0-0`:_t(a)?o==="0"?c=`>=${o}.${s}.0${i} <${o}.${+s+1}.0-0`:c=`>=${o}.${s}.0${i} <${+o+1}.0.0-0`:l?(Ye("replaceCaret pr",l),o==="0"?s==="0"?c=`>=${o}.${s}.${a}-${l} <${o}.${s}.${+a+1}-0`:c=`>=${o}.${s}.${a}-${l} <${o}.${+s+1}.0-0`:c=`>=${o}.${s}.${a}-${l} <${+o+1}.0.0-0`):(Ye("no pr"),o==="0"?s==="0"?c=`>=${o}.${s}.${a} <${o}.${s}.${+a+1}-0`:c=`>=${o}.${s}.${a} <${o}.${+s+1}.0-0`:c=`>=${o}.${s}.${a} <${+o+1}.0.0-0`),Ye("caret return",c),c})},$re=(t,e)=>(Ye("replaceXRanges",t,e),t.split(/\s+/).map(r=>Jre(r,e)).join(" ")),Jre=(t,e)=>{t=t.trim();let r=e.loose?ar[Lt.XRANGELOOSE]:ar[Lt.XRANGE];return t.replace(r,(i,n,o,s,a,l)=>{if(Ye("xRange",t,i,n,o,s,a,l),Pre(o,s,a))return t;let c=_t(o),u=c||_t(s),d=u||_t(a),f=d;return n==="="&&f&&(n=""),l=e.includePrerelease?"-0":"",c?n===">"||n==="<"?i="<0.0.0-0":i="*":n&&f?(u&&(s=0),a=0,n===">"?(n=">=",u?(o=+o+1,s=0,a=0):(s=+s+1,a=0)):n==="<="&&(n="<",u?o=+o+1:s=+s+1),n==="<"&&(l="-0"),i=`${n+o}.${s}.${a}${l}`):u?i=`>=${o}.0.0${l} <${+o+1}.0.0-0`:d&&(i=`>=${o}.${s}.0${l} <${o}.${+s+1}.0-0`),Ye("xRange return",i),i})},Fre=(t,e)=>(Ye("replaceStars",t,e),t.trim().replace(ar[Lt.STAR],"")),qre=(t,e)=>(Ye("replaceGTE0",t,e),t.trim().replace(ar[e.includePrerelease?Lt.GTE0PRE:Lt.GTE0],"")),zre=t=>(e,r,i,n,o,s,a,l,c,u,d,f)=>(_t(i)?r="":_t(n)?r=`>=${i}.0.0${t?"-0":""}`:_t(o)?r=`>=${i}.${n}.0${t?"-0":""}`:s?r=`>=${r}`:r=`>=${r}${t?"-0":""}`,_t(c)?l="":_t(u)?l=`<${+c+1}.0.0-0`:_t(d)?l=`<${c}.${+u+1}.0-0`:f?l=`<=${c}.${u}.${d}-${f}`:t?l=`<${c}.${u}.${+d+1}-0`:l=`<=${l}`,`${r} ${l}`.trim()),Gre=(t,e,r)=>{for(let i=0;i<t.length;i++)if(!t[i].test(e))return!1;if(e.prerelease.length&&!r.includePrerelease){for(let i=0;i<t.length;i++)if(Ye(t[i].semver),t[i].semver!==o0.ANY&&t[i].semver.prerelease.length>0){let n=t[i].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}});var Yc=h((XIe,ON)=>{"use strict";var Xc=Symbol("SemVer ANY"),l0=class t{static get ANY(){return Xc}constructor(e,r){if(r=IN(r),e instanceof t){if(e.loose===!!r.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),a0("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===Xc?this.value="":this.value=this.operator+this.semver.version,a0("comp",this)}parse(e){let r=this.options.loose?kN[_N.COMPARATORLOOSE]:kN[_N.COMPARATOR],i=e.match(r);if(!i)throw new TypeError(`Invalid comparator: ${e}`);this.operator=i[1]!==void 0?i[1]:"",this.operator==="="&&(this.operator=""),i[2]?this.semver=new TN(i[2],this.options.loose):this.semver=Xc}toString(){return this.value}test(e){if(a0("Comparator.test",e,this.options.loose),this.semver===Xc||e===Xc)return!0;if(typeof e=="string")try{e=new TN(e,this.options)}catch{return!1}return s0(e,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new CN(e.value,r).test(this.value):e.operator===""?e.value===""?!0:new CN(this.value,r).test(e.semver):(r=IN(r),r.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||s0(this.semver,"<",e.semver,r)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||s0(this.semver,">",e.semver,r)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};ON.exports=l0;var IN=xf(),{safeRe:kN,t:_N}=Ca(),s0=r0(),a0=Zc(),TN=Nt(),CN=en()});var Qc=h((QIe,AN)=>{"use strict";var Vre=en(),Bre=(t,e,r)=>{try{e=new Vre(e,r)}catch{return!1}return e.test(t)};AN.exports=Bre});var RN=h((eke,KN)=>{"use strict";var Wre=en(),Zre=(t,e)=>new Wre(t,e).set.map(r=>r.map(i=>i.value).join(" ").trim().split(" "));KN.exports=Zre});var jN=h((tke,DN)=>{"use strict";var Hre=Nt(),Yre=en(),Xre=(t,e,r)=>{let i=null,n=null,o=null;try{o=new Yre(e,r)}catch{return null}return t.forEach(s=>{o.test(s)&&(!i||n.compare(s)===-1)&&(i=s,n=new Hre(i,r))}),i};DN.exports=Xre});var MN=h((rke,PN)=>{"use strict";var Qre=Nt(),ene=en(),tne=(t,e,r)=>{let i=null,n=null,o=null;try{o=new ene(e,r)}catch{return null}return t.forEach(s=>{o.test(s)&&(!i||n.compare(s)===1)&&(i=s,n=new Qre(i,r))}),i};PN.exports=tne});var UN=h((nke,LN)=>{"use strict";var c0=Nt(),rne=en(),NN=Hc(),nne=(t,e)=>{t=new rne(t,e);let r=new c0("0.0.0");if(t.test(r)||(r=new c0("0.0.0-0"),t.test(r)))return r;r=null;for(let i=0;i<t.set.length;++i){let n=t.set[i],o=null;n.forEach(s=>{let a=new c0(s.semver.version);switch(s.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!o||NN(a,o))&&(o=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${s.operator}`)}}),o&&(!r||NN(r,o))&&(r=o)}return r&&t.test(r)?r:null};LN.exports=nne});var JN=h((ike,$N)=>{"use strict";var ine=en(),one=(t,e)=>{try{return new ine(t,e).range||"*"}catch{return null}};$N.exports=one});var jf=h((oke,GN)=>{"use strict";var sne=Nt(),zN=Yc(),{ANY:ane}=zN,lne=en(),cne=Qc(),FN=Hc(),qN=Of(),une=Kf(),dne=Af(),pne=(t,e,r,i)=>{t=new sne(t,i),e=new lne(e,i);let n,o,s,a,l;switch(r){case">":n=FN,o=une,s=qN,a=">",l=">=";break;case"<":n=qN,o=dne,s=FN,a="<",l="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(cne(t,e,i))return!1;for(let c=0;c<e.set.length;++c){let u=e.set[c],d=null,f=null;if(u.forEach(p=>{p.semver===ane&&(p=new zN(">=0.0.0")),d=d||p,f=f||p,n(p.semver,d.semver,i)?d=p:s(p.semver,f.semver,i)&&(f=p)}),d.operator===a||d.operator===l||(!f.operator||f.operator===a)&&o(t,f.semver))return!1;if(f.operator===l&&s(t,f.semver))return!1}return!0};GN.exports=pne});var BN=h((ske,VN)=>{"use strict";var fne=jf(),mne=(t,e,r)=>fne(t,e,">",r);VN.exports=mne});var ZN=h((ake,WN)=>{"use strict";var hne=jf(),yne=(t,e,r)=>hne(t,e,"<",r);WN.exports=yne});var XN=h((lke,YN)=>{"use strict";var HN=en(),gne=(t,e,r)=>(t=new HN(t,r),e=new HN(e,r),t.intersects(e,r));YN.exports=gne});var eL=h((cke,QN)=>{"use strict";var bne=Qc(),vne=Qr();QN.exports=(t,e,r)=>{let i=[],n=null,o=null,s=t.sort((u,d)=>vne(u,d,r));for(let u of s)bne(u,e,r)?(o=u,n||(n=u)):(o&&i.push([n,o]),o=null,n=null);n&&i.push([n,null]);let a=[];for(let[u,d]of i)u===d?a.push(u):!d&&u===s[0]?a.push("*"):d?u===s[0]?a.push(`<=${d}`):a.push(`${u} - ${d}`):a.push(`>=${u}`);let l=a.join(" || "),c=typeof e.raw=="string"?e.raw:String(e);return l.length<c.length?l:e}});var sL=h((uke,oL)=>{"use strict";var tL=en(),p0=Yc(),{ANY:u0}=p0,d0=Qc(),f0=Qr(),Sne=(t,e,r={})=>{if(t===e)return!0;t=new tL(t,r),e=new tL(e,r);let i=!1;e:for(let n of t.set){for(let o of e.set){let s=wne(n,o,r);if(i=i||s!==null,s)continue e}if(i)return!1}return!0},Ene=[new p0(">=0.0.0-0")],rL=[new p0(">=0.0.0")],wne=(t,e,r)=>{if(t===e)return!0;if(t.length===1&&t[0].semver===u0){if(e.length===1&&e[0].semver===u0)return!0;r.includePrerelease?t=Ene:t=rL}if(e.length===1&&e[0].semver===u0){if(r.includePrerelease)return!0;e=rL}let i=new Set,n,o;for(let p of t)p.operator===">"||p.operator===">="?n=nL(n,p,r):p.operator==="<"||p.operator==="<="?o=iL(o,p,r):i.add(p.semver);if(i.size>1)return null;let s;if(n&&o){if(s=f0(n.semver,o.semver,r),s>0)return null;if(s===0&&(n.operator!==">="||o.operator!=="<="))return null}for(let p of i){if(n&&!d0(p,String(n),r)||o&&!d0(p,String(o),r))return null;for(let m of e)if(!d0(p,String(m),r))return!1;return!0}let a,l,c,u,d=o&&!r.includePrerelease&&o.semver.prerelease.length?o.semver:!1,f=n&&!r.includePrerelease&&n.semver.prerelease.length?n.semver:!1;d&&d.prerelease.length===1&&o.operator==="<"&&d.prerelease[0]===0&&(d=!1);for(let p of e){if(u=u||p.operator===">"||p.operator===">=",c=c||p.operator==="<"||p.operator==="<=",n){if(f&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===f.major&&p.semver.minor===f.minor&&p.semver.patch===f.patch&&(f=!1),p.operator===">"||p.operator===">="){if(a=nL(n,p,r),a===p&&a!==n)return!1}else if(n.operator===">="&&!p.test(n.semver))return!1}if(o){if(d&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===d.major&&p.semver.minor===d.minor&&p.semver.patch===d.patch&&(d=!1),p.operator==="<"||p.operator==="<="){if(l=iL(o,p,r),l===p&&l!==o)return!1}else if(o.operator==="<="&&!p.test(o.semver))return!1}if(!p.operator&&(o||n)&&s!==0)return!1}return!(n&&c&&!o&&s!==0||o&&u&&!n&&s!==0||f||d)},nL=(t,e,r)=>{if(!t)return e;let i=f0(t.semver,e.semver,r);return i>0?t:i<0||e.operator===">"&&t.operator===">="?e:t},iL=(t,e,r)=>{if(!t)return e;let i=f0(t.semver,e.semver,r);return i<0?t:i>0||e.operator==="<"&&t.operator==="<="?e:t};oL.exports=Sne});var uL=h((dke,cL)=>{"use strict";var m0=Ca(),aL=Ta(),xne=Nt(),lL=YE(),Ine=Ji(),kne=RM(),_ne=jM(),Tne=NM(),Cne=$M(),One=FM(),Ane=zM(),Kne=VM(),Rne=WM(),Dne=Qr(),jne=XM(),Pne=eN(),Mne=Cf(),Nne=iN(),Lne=sN(),Une=Hc(),$ne=Of(),Jne=e0(),Fne=t0(),qne=Af(),zne=Kf(),Gne=r0(),Vne=hN(),Bne=gN(),Wne=Yc(),Zne=en(),Hne=Qc(),Yne=RN(),Xne=jN(),Qne=MN(),eie=UN(),tie=JN(),rie=jf(),nie=BN(),iie=ZN(),oie=XN(),sie=eL(),aie=sL();cL.exports={parse:Ine,valid:kne,clean:_ne,inc:Tne,diff:Cne,major:One,minor:Ane,patch:Kne,prerelease:Rne,compare:Dne,rcompare:jne,compareLoose:Pne,compareBuild:Mne,sort:Nne,rsort:Lne,gt:Une,lt:$ne,eq:Jne,neq:Fne,gte:qne,lte:zne,cmp:Gne,coerce:Vne,truncate:Bne,Comparator:Wne,Range:Zne,satisfies:Hne,toComparators:Yne,maxSatisfying:Xne,minSatisfying:Qne,minVersion:eie,validRange:tie,outside:rie,gtr:nie,ltr:iie,intersects:oie,simplifyRange:sie,subset:aie,SemVer:xne,re:m0.re,src:m0.src,tokens:m0.t,SEMVER_SPEC_VERSION:aL.SEMVER_SPEC_VERSION,RELEASE_TYPES:aL.RELEASE_TYPES,compareIdentifiers:lL.compareIdentifiers,rcompareIdentifiers:lL.rcompareIdentifiers}});var Or=h(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.QUEUE_EVENT_SUFFIX=te.toString=te.errorToJSON=te.parseObjectValues=te.isRedisVersionLowerThan=te.childSend=te.asyncSend=te.DELAY_TIME_1=te.DELAY_TIME_5=te.clientCommandMessageReg=te.optsEncodeMap=te.optsDecodeMap=te.errorObject=void 0;te.tryCatch=uie;te.lengthInUtf8Bytes=die;te.isEmpty=pie;te.array2obj=fie;te.objectToFlatArray=mie;te.delay=hie;te.increaseMaxListeners=dL;te.invertObject=pL;te.isRedisInstance=fL;te.isRedisCluster=yie;te.decreaseMaxListeners=gie;te.removeAllQueueData=bie;te.getParentKey=vie;te.isNotConnectionError=mL;te.removeUndefinedFields=Cie;te.trace=Oie;te.randomUUID=Aie;var h0=U("crypto"),lie=bt(),cie=_a(),y0=uL(),g0=gr();te.errorObject={value:null};function uie(t,e,r){try{return t.apply(e,r)}catch(i){return te.errorObject.value=i,te.errorObject}}function die(t){return Buffer.byteLength(t,"utf8")}function pie(t){for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function fie(t){let e={};for(let r=0;r<t.length;r+=2)e[t[r]]=t[r+1];return e}function mie(t){let e=[];for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&t[r]!==void 0&&(e[e.length]=r,e[e.length]=t[r]);return e}function hie(t,e){return new Promise(r=>{let i,n=()=>{e?.signal.removeEventListener("abort",n),clearTimeout(i),r()};i=setTimeout(n,t),e?.signal.addEventListener("abort",n)})}function dL(t,e){let r=t.getMaxListeners();t.setMaxListeners(r+e)}function pL(t){return Object.entries(t).reduce((e,[r,i])=>(e[i]=r,e),{})}te.optsDecodeMap={de:"deduplication",fpof:"failParentOnFailure",cpof:"continueParentOnFailure",idof:"ignoreDependencyOnFailure",kl:"keepLogs",rdof:"removeDependencyOnFailure"};te.optsEncodeMap=Object.assign(Object.assign({},pL(te.optsDecodeMap)),{debounce:"de"});function fL(t){return t?["connect","disconnect","duplicate"].every(r=>typeof t[r]=="function"):!1}function yie(t){return fL(t)&&!!t.isCluster}function gie(t,e){dL(t,-e)}async function bie(t,e,r=process.env.BULLMQ_TEST_PREFIX||"bull"){if(t.isCluster)return!1;let i=`${r}:${e}:*`,n=[];await new Promise((o,s)=>{let a=t.scanStream({match:i});a.on("data",l=>{if(l.length){let c=t.pipeline();l.forEach(d=>{c.del(d)});let u=c.exec().catch(d=>{throw s(d),d});n.push(u)}}),a.on("end",()=>o()),a.on("error",l=>s(l))}),await Promise.all(n);try{await t.quit()}catch(o){if(mL(o))throw o}}function vie(t){if(t)return`${t.queue}:${t.id}`}te.clientCommandMessageReg=/ERR unknown command ['`]\s*client\s*['`]/;te.DELAY_TIME_5=5e3;te.DELAY_TIME_1=100;function mL(t){if(t instanceof cie.ConnectionClosedError)return!1;let{code:e,message:r}=t;return r!==lie.CONNECTION_CLOSED_ERROR_MSG&&!r.includes("ECONNREFUSED")&&e!=="ECONNREFUSED"}var Sie=(t,e)=>new Promise((r,i)=>{typeof t.send=="function"?t.send(e,n=>{n?i(n):r()}):typeof t.postMessage=="function"?r(t.postMessage(e)):r()});te.asyncSend=Sie;var Eie=(t,e)=>(0,te.asyncSend)(t,e);te.childSend=Eie;var wie=(t,e,r,i="redis")=>{if(r===i){let n=y0.valid(y0.coerce(t));return y0.lt(n,e)}return!1};te.isRedisVersionLowerThan=wie;var xie=t=>{let e={};for(let r of Object.entries(t))e[r[0]]=JSON.parse(r[1]);return e};te.parseObjectValues=xie;var Iie=t=>{let e=new WeakSet;return e.add(t),(r,i)=>{if(typeof i=="object"&&i!==null){if(e.has(i))return"[Circular]";e.add(i)}return i}},kie=t=>{let e={};return Object.getOwnPropertyNames(t).forEach(function(r){e[r]=t[r]}),JSON.parse(JSON.stringify(e,Iie(t)))};te.errorToJSON=kie;var _ie=1/0,Tie=t=>{if(t==null)return"";if(typeof t=="string")return t;if(Array.isArray(t))return`${t.map(r=>r==null?r:(0,te.toString)(r))}`;if(typeof t=="symbol"||Object.prototype.toString.call(t)=="[object Symbol]")return t.toString();let e=`${t}`;return e==="0"&&1/t===-_ie?"-0":e};te.toString=Tie;te.QUEUE_EVENT_SUFFIX=":qe";function Cie(t){let e={};for(let r in t)t[r]!==void 0&&(e[r]=t[r]);return e}async function Oie(t,e,r,i,n,o,s){if(t){let{tracer:a,contextManager:l}=t,c=l.active(),u;s&&(u=l.fromMetadata(c,s));let d=n?`${i} ${n}`:i,f=a.startSpan(d,{kind:e},u);try{f.setAttributes({[g0.TelemetryAttributes.QueueName]:r,[g0.TelemetryAttributes.QueueOperation]:i});let p,m;return e===g0.SpanKind.CONSUMER&&u?p=f.setSpanOnContext(u):p=f.setSpanOnContext(c),o.length==2&&(m=l.getMetadata(p)),await l.with(p,()=>o(f,m))}catch(p){throw f.recordException(p),p}finally{f.end()}}else return o()}function Aie(){if(typeof h0.randomUUID=="function")return(0,h0.randomUUID)();let t=(0,h0.randomBytes)(16);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,[t.toString("hex",0,4),t.toString("hex",4,6),t.toString("hex",6,8),t.toString("hex",8,10),t.toString("hex",10,16)].join("-")}});var hL=h(Pf=>{"use strict";Object.defineProperty(Pf,"__esModule",{value:!0});Pf.ChildProcessor=void 0;var Kie=hf(),lr=gr(),b0=Or(),Fi;(function(t){t[t.Idle=0]="Idle",t[t.Started=1]="Started",t[t.Terminating=2]="Terminating",t[t.Errored=3]="Errored"})(Fi||(Fi={}));var eu=process.env.NODE_ENV==="test"?500:5e3,v0=class{constructor(e,r){this.send=e,this.receiver=r}async init(e){let r;try{let{default:n}=await import(e);if(r=n,r.default&&(r=r.default),typeof r!="function")throw new Error("No function is exported in processor file")}catch(n){return this.status=Fi.Errored,this.send({cmd:lr.ParentCommand.InitFailed,err:(0,b0.errorToJSON)(n)})}let i=r;r=function(n,o,s){try{return Promise.resolve(i(n,o,s))}catch(a){return Promise.reject(a)}},this.processor=r,this.status=Fi.Idle,await this.send({cmd:lr.ParentCommand.InitCompleted})}async start(e,r){if(this.status!==Fi.Idle)return this.send({cmd:lr.ParentCommand.Error,err:(0,b0.errorToJSON)(new Error("cannot start a not idling child process"))});this.status=Fi.Started,this.abortController=new Kie.AbortController,this.currentJobPromise=(async()=>{try{let i=this.wrapJob(e,this.send),n=await this.processor(i,r,this.abortController.signal);await this.send({cmd:lr.ParentCommand.Completed,value:typeof n>"u"?null:n})}catch(i){await this.send({cmd:lr.ParentCommand.Failed,value:(0,b0.errorToJSON)(i.message?i:new Error(i))})}finally{this.status=Fi.Idle,this.currentJobPromise=void 0,this.abortController=void 0}})()}cancel(e){this.abortController&&this.abortController.abort(e)}async stop(){}async waitForCurrentJobAndExit(){this.status=Fi.Terminating;try{await this.currentJobPromise}finally{process.exit(process.exitCode||0)}}wrapJob(e,r){let i=Object.assign(Object.assign({},e),{queueQualifiedName:e.queueQualifiedName,data:JSON.parse(e.data||"{}"),opts:e.opts,returnValue:JSON.parse(e.returnvalue||"{}"),async updateProgress(n){this.progress=n,await r({cmd:lr.ParentCommand.Progress,value:n})},log:async n=>{await r({cmd:lr.ParentCommand.Log,value:n})},moveToDelayed:async(n,o)=>{await r({cmd:lr.ParentCommand.MoveToDelayed,value:{timestamp:n,token:o}})},moveToWait:async n=>{await r({cmd:lr.ParentCommand.MoveToWait,value:{token:n}})},moveToWaitingChildren:async(n,o)=>{let s=Math.random().toString(36).substring(2,15);return await r({requestId:s,cmd:lr.ParentCommand.MoveToWaitingChildren,value:{token:n,opts:o}}),tu(s,this.receiver,eu,"moveToWaitingChildren")},updateData:async n=>{await r({cmd:lr.ParentCommand.Update,value:n}),i.data=n},getChildrenValues:async()=>{let n=Math.random().toString(36).substring(2,15);return await r({requestId:n,cmd:lr.ParentCommand.GetChildrenValues}),tu(n,this.receiver,eu,"getChildrenValues")},getIgnoredChildrenFailures:async()=>{let n=Math.random().toString(36).substring(2,15);return await r({requestId:n,cmd:lr.ParentCommand.GetIgnoredChildrenFailures}),tu(n,this.receiver,eu,"getIgnoredChildrenFailures")},getDependenciesCount:async n=>{let o=Math.random().toString(36).substring(2,15);return await r({requestId:o,cmd:lr.ParentCommand.GetDependenciesCount,value:n}),tu(o,this.receiver,eu,"getDependenciesCount")},getDependencies:async n=>{let o=Math.random().toString(36).substring(2,15);return await r({requestId:o,cmd:lr.ParentCommand.GetDependencies,value:n}),tu(o,this.receiver,eu,"getDependencies")}});return i}};Pf.ChildProcessor=v0;var tu=async(t,e,r,i)=>new Promise((n,o)=>{let s=a=>{a.requestId===t&&(n(a.value),e.off("message",s))};e.on("message",s),setTimeout(()=>{e.off("message",s),o(new Error(`TimeoutError: ${i} timed out in (${r}ms)`))},r)})});var yL=h(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.DelayedError=Go.DELAYED_ERROR=void 0;Go.DELAYED_ERROR="bullmq:movedToDelayed";var S0=class extends Error{constructor(e=Go.DELAYED_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Go.DelayedError=S0});var gL=h(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.RateLimitError=Vo.RATE_LIMIT_ERROR=void 0;Vo.RATE_LIMIT_ERROR="bullmq:rateLimitExceeded";var E0=class extends Error{constructor(e=Vo.RATE_LIMIT_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Vo.RateLimitError=E0});var x0=h(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.UnrecoverableError=Bo.UNRECOVERABLE_ERROR=void 0;Bo.UNRECOVERABLE_ERROR="bullmq:unrecoverable";var w0=class extends Error{constructor(e=Bo.UNRECOVERABLE_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Bo.UnrecoverableError=w0});var bL=h(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.WaitingChildrenError=Wo.WAITING_CHILDREN_ERROR=void 0;Wo.WAITING_CHILDREN_ERROR="bullmq:movedToWaitingChildren";var I0=class extends Error{constructor(e=Wo.WAITING_CHILDREN_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Wo.WaitingChildrenError=I0});var vL=h(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.WaitingError=Zo.WAITING_ERROR=void 0;Zo.WAITING_ERROR="bullmq:movedToWait";var k0=class extends Error{constructor(e=Zo.WAITING_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Zo.WaitingError=k0});var Mf=h(qi=>{"use strict";Object.defineProperty(qi,"__esModule",{value:!0});var Oa=(Zt(),Jt(Wt));Oa.__exportStar(_a(),qi);Oa.__exportStar(yL(),qi);Oa.__exportStar(gL(),qi);Oa.__exportStar(x0(),qi);Oa.__exportStar(bL(),qi);Oa.__exportStar(vL(),qi)});var wL=h((Ske,EL)=>{"use strict";var SL=()=>process.platform==="linux",Nf=null,Rie=()=>{if(!Nf)if(SL()&&process.report){let t=process.report.excludeNetwork;process.report.excludeNetwork=!0,Nf=process.report.getReport(),process.report.excludeNetwork=t}else Nf={};return Nf};EL.exports={isLinux:SL,getReport:Rie}});var IL=h((Eke,xL)=>{"use strict";var Aa=U("fs"),Die="/usr/bin/ldd",jie="/proc/self/exe",Lf=2048,Pie=t=>{let e=Aa.openSync(t,"r"),r=Buffer.alloc(Lf),i=Aa.readSync(e,r,0,Lf,0);return Aa.close(e,()=>{}),r.subarray(0,i)},Mie=t=>new Promise((e,r)=>{Aa.open(t,"r",(i,n)=>{if(i)r(i);else{let o=Buffer.alloc(Lf);Aa.read(n,o,0,Lf,0,(s,a)=>{e(o.subarray(0,a)),Aa.close(n,()=>{})})}})});xL.exports={LDD_PATH:Die,SELF_PATH:jie,readFileSync:Pie,readFile:Mie}});var _L=h((wke,kL)=>{"use strict";var Nie=t=>{if(t.length<64||t.readUInt32BE(0)!==2135247942||t.readUInt8(4)!==2||t.readUInt8(5)!==1)return null;let e=t.readUInt32LE(32),r=t.readUInt16LE(54),i=t.readUInt16LE(56);for(let n=0;n<i;n++){let o=e+n*r;if(t.readUInt32LE(o)===3){let a=t.readUInt32LE(o+8),l=t.readUInt32LE(o+32);return t.subarray(a,a+l).toString().replace(/\0.*$/g,"")}}return null};kL.exports={interpreterPath:Nie}});var GL=h((xke,zL)=>{"use strict";var CL=U("child_process"),{isLinux:Ka,getReport:OL}=wL(),{LDD_PATH:Uf,SELF_PATH:AL,readFile:_0,readFileSync:T0}=IL(),{interpreterPath:KL}=_L(),Mn,Nn,Ln,RL="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",zi="",DL=()=>zi||new Promise(t=>{CL.exec(RL,(e,r)=>{zi=e?" ":r,t(zi)})}),jL=()=>{if(!zi)try{zi=CL.execSync(RL,{encoding:"utf8"})}catch{zi=" "}return zi},ai="glibc",PL=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,Ho="musl",Lie=t=>t.includes("libc.musl-")||t.includes("ld-musl-"),ML=()=>{let t=OL();return t.header&&t.header.glibcVersionRuntime?ai:Array.isArray(t.sharedObjects)&&t.sharedObjects.some(Lie)?Ho:null},NL=t=>{let[e,r]=t.split(/[\r\n]+/);return e&&e.includes(ai)?ai:r&&r.includes(Ho)?Ho:null},LL=t=>{if(t){if(t.includes("/ld-musl-"))return Ho;if(t.includes("/ld-linux-"))return ai}return null},UL=t=>(t=t.toString(),t.includes("musl")?Ho:t.includes("GNU C Library")?ai:null),Uie=async()=>{if(Nn!==void 0)return Nn;Nn=null;try{let t=await _0(Uf);Nn=UL(t)}catch{}return Nn},$ie=()=>{if(Nn!==void 0)return Nn;Nn=null;try{let t=T0(Uf);Nn=UL(t)}catch{}return Nn},Jie=async()=>{if(Mn!==void 0)return Mn;Mn=null;try{let t=await _0(AL),e=KL(t);Mn=LL(e)}catch{}return Mn},Fie=()=>{if(Mn!==void 0)return Mn;Mn=null;try{let t=T0(AL),e=KL(t);Mn=LL(e)}catch{}return Mn},$L=async()=>{let t=null;if(Ka()&&(t=await Jie(),!t&&(t=await Uie(),t||(t=ML()),!t))){let e=await DL();t=NL(e)}return t},JL=()=>{let t=null;if(Ka()&&(t=Fie(),!t&&(t=$ie(),t||(t=ML()),!t))){let e=jL();t=NL(e)}return t},qie=async()=>Ka()&&await $L()!==ai,zie=()=>Ka()&&JL()!==ai,Gie=async()=>{if(Ln!==void 0)return Ln;Ln=null;try{let e=(await _0(Uf)).match(PL);e&&(Ln=e[1])}catch{}return Ln},Vie=()=>{if(Ln!==void 0)return Ln;Ln=null;try{let e=T0(Uf).match(PL);e&&(Ln=e[1])}catch{}return Ln},FL=()=>{let t=OL();return t.header&&t.header.glibcVersionRuntime?t.header.glibcVersionRuntime:null},TL=t=>t.trim().split(/\s+/)[1],qL=t=>{let[e,r,i]=t.split(/[\r\n]+/);return e&&e.includes(ai)?TL(e):r&&i&&r.includes(Ho)?TL(i):null},Bie=async()=>{let t=null;if(Ka()&&(t=await Gie(),t||(t=FL()),!t)){let e=await DL();t=qL(e)}return t},Wie=()=>{let t=null;if(Ka()&&(t=Vie(),t||(t=FL()),!t)){let e=jL();t=qL(e)}return t};zL.exports={GLIBC:ai,MUSL:Ho,family:$L,familySync:JL,isNonGlibcLinux:qie,isNonGlibcLinuxSync:zie,version:Bie,versionSync:Wie}});var oU=h((Ike,iU)=>{var Zie=U("fs"),yn=U("path"),Hie=U("url"),WL=U("os"),ZL=typeof __webpack_require__=="function"?__non_webpack_require__:U,Yie=process.config&&process.config.variables||{},Xie=!!process.env.PREBUILDS_ONLY,R0=process.versions,O0=R0.modules;(R0.deno||process.isBun)&&(O0="unsupported");var C0=toe()?"electron":eoe()?"node-webkit":"node",$f=process.env.npm_config_arch||WL.arch(),Jf=process.env.npm_config_platform||WL.platform(),HL=process.env.LIBC||(roe(Jf)?"musl":"glibc"),A0=process.env.ARM_VERSION||($f==="arm64"?"8":Yie.arm_version)||"",YL=(R0.uv||"").split(".")[0];iU.exports=Un;function Un(t){return ZL(Un.resolve(t))}Un.resolve=Un.path=function(t){t=yn.resolve(t||".");var e="",r;try{e=ZL(yn.join(t,"package.json")).name;var i=e.toUpperCase().replace(/-/g,"_");process.env[i+"_PREBUILD"]&&(t=process.env[i+"_PREBUILD"])}catch(y){r=y}if(!Xie){var n=VL(yn.join(t,"build/Release"),BL);if(n)return n;var o=VL(yn.join(t,"build/Debug"),BL);if(o)return o}var s=p(t);if(s)return s;var a=p(yn.dirname(process.execPath));if(a)return a;var l=(e[0]=="@"?"":"@"+e+"/")+e+"-"+Jf+"-"+$f,c;try{var u=yn.dirname(U("module").createRequire(Hie.pathToFileURL(yn.join(t,"package.json"))).resolve(l));return m(u)}catch(y){c=y}var d=["platform="+Jf,"arch="+$f,"runtime="+C0,"abi="+O0,"uv="+YL,A0?"armv="+A0:"","libc="+HL,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");let f="No native build was found for "+d+`
1124
+ `);t.stack=t.stack.slice(0,s)+n}return t}he.optimizeErrorStack=Wee;function Zee(t){if(vM(t))return{port:t};let e=(0,gM.parse)(t,!0,!0);!e.slashes&&t[0]!=="/"&&(t="//"+t,e=(0,gM.parse)(t,!0,!0));let r=e.query||{},i={};if(e.auth){let n=e.auth.indexOf(":");i.username=n===-1?e.auth:e.auth.slice(0,n),i.password=n===-1?"":e.auth.slice(n+1)}if(e.pathname&&(e.protocol==="redis:"||e.protocol==="rediss:"?e.pathname.length>1&&(i.db=e.pathname.slice(1)):i.path=e.pathname),e.host&&(i.host=e.hostname),e.port&&(i.port=e.port),typeof r.family=="string"){let n=Number.parseInt(r.family,10);Number.isNaN(n)||(i.family=n)}return(0,BE.defaults)(i,r),i}he.parseURL=Zee;function Hee(t){let e=t?.tls;typeof e=="string"&&(e={profile:e});let r=Jee.default[e?.profile];return r&&(e=Object.assign({},r,e),delete e.profile,t=Object.assign({},t,{tls:e})),t}he.resolveTLSProfile=Hee;function Yee(t,e=0){let r=t.length;return e>=r?null:t[e+Math.floor(Math.random()*(r-e))]}he.sample=Yee;function Xee(t){let e=t.length;for(;e>0;){let r=Math.floor(Math.random()*e);e--,[t[e],t[r]]=[t[r],t[e]]}return t}he.shuffle=Xee;he.CONNECTION_CLOSED_ERROR_MSG="Connection is closed.";function Qee(t,e){let r=new Map;return t.forEach((i,n)=>{r.set(i,e[n])}),r}he.zipMap=Qee;var ka=null;async function ete(){if(ka)return ka;try{let t=(0,Uee.resolve)(__dirname,"..","..","package.json"),e=await Lee.promises.readFile(t,"utf8");return ka={version:JSON.parse(e).version},ka}catch{return ka={version:"error-fetching-version"},ka}}he.getPackageMeta=ete});var _a=h(wf=>{"use strict";Object.defineProperty(wf,"__esModule",{value:!0});wf.ConnectionClosedError=void 0;var WE=class extends Error{constructor(e,r){super(e??"Connection is closed"),this.cause=r,this.name="ConnectionClosedError",Object.setPrototypeOf(this,new.target.prototype)}};wf.ConnectionClosedError=WE});var Ta=h((wIe,SM)=>{"use strict";var tte="2.0.0",rte=Number.MAX_SAFE_INTEGER||9007199254740991,nte=16,ite=250,ote=["major","premajor","minor","preminor","patch","prepatch","prerelease"];SM.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:nte,MAX_SAFE_BUILD_LENGTH:ite,MAX_SAFE_INTEGER:rte,RELEASE_TYPES:ote,SEMVER_SPEC_VERSION:tte,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Zc=h((xIe,EM)=>{"use strict";var ste=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};EM.exports=ste});var Ca=h((Pn,wM)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:ZE,MAX_SAFE_BUILD_LENGTH:ate,MAX_LENGTH:lte}=Ta(),cte=Zc();Pn=wM.exports={};var ute=Pn.re=[],dte=Pn.safeRe=[],V=Pn.src=[],pte=Pn.safeSrc=[],B=Pn.t={},fte=0,HE="[a-zA-Z0-9-]",mte=[["\\s",1],["\\d",lte],[HE,ate]],hte=t=>{for(let[e,r]of mte)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t},ce=(t,e,r)=>{let i=hte(e),n=fte++;cte(t,n,e),B[t]=n,V[n]=e,pte[n]=i,ute[n]=new RegExp(e,r?"g":void 0),dte[n]=new RegExp(i,r?"g":void 0)};ce("NUMERICIDENTIFIER","0|[1-9]\\d*");ce("NUMERICIDENTIFIERLOOSE","\\d+");ce("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${HE}*`);ce("MAINVERSION",`(${V[B.NUMERICIDENTIFIER]})\\.(${V[B.NUMERICIDENTIFIER]})\\.(${V[B.NUMERICIDENTIFIER]})`);ce("MAINVERSIONLOOSE",`(${V[B.NUMERICIDENTIFIERLOOSE]})\\.(${V[B.NUMERICIDENTIFIERLOOSE]})\\.(${V[B.NUMERICIDENTIFIERLOOSE]})`);ce("PRERELEASEIDENTIFIER",`(?:${V[B.NONNUMERICIDENTIFIER]}|${V[B.NUMERICIDENTIFIER]})`);ce("PRERELEASEIDENTIFIERLOOSE",`(?:${V[B.NONNUMERICIDENTIFIER]}|${V[B.NUMERICIDENTIFIERLOOSE]})`);ce("PRERELEASE",`(?:-(${V[B.PRERELEASEIDENTIFIER]}(?:\\.${V[B.PRERELEASEIDENTIFIER]})*))`);ce("PRERELEASELOOSE",`(?:-?(${V[B.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${V[B.PRERELEASEIDENTIFIERLOOSE]})*))`);ce("BUILDIDENTIFIER",`${HE}+`);ce("BUILD",`(?:\\+(${V[B.BUILDIDENTIFIER]}(?:\\.${V[B.BUILDIDENTIFIER]})*))`);ce("FULLPLAIN",`v?${V[B.MAINVERSION]}${V[B.PRERELEASE]}?${V[B.BUILD]}?`);ce("FULL",`^${V[B.FULLPLAIN]}$`);ce("LOOSEPLAIN",`[v=\\s]*${V[B.MAINVERSIONLOOSE]}${V[B.PRERELEASELOOSE]}?${V[B.BUILD]}?`);ce("LOOSE",`^${V[B.LOOSEPLAIN]}$`);ce("GTLT","((?:<|>)?=?)");ce("XRANGEIDENTIFIERLOOSE",`${V[B.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);ce("XRANGEIDENTIFIER",`${V[B.NUMERICIDENTIFIER]}|x|X|\\*`);ce("XRANGEPLAIN",`[v=\\s]*(${V[B.XRANGEIDENTIFIER]})(?:\\.(${V[B.XRANGEIDENTIFIER]})(?:\\.(${V[B.XRANGEIDENTIFIER]})(?:${V[B.PRERELEASE]})?${V[B.BUILD]}?)?)?`);ce("XRANGEPLAINLOOSE",`[v=\\s]*(${V[B.XRANGEIDENTIFIERLOOSE]})(?:\\.(${V[B.XRANGEIDENTIFIERLOOSE]})(?:\\.(${V[B.XRANGEIDENTIFIERLOOSE]})(?:${V[B.PRERELEASELOOSE]})?${V[B.BUILD]}?)?)?`);ce("XRANGE",`^${V[B.GTLT]}\\s*${V[B.XRANGEPLAIN]}$`);ce("XRANGELOOSE",`^${V[B.GTLT]}\\s*${V[B.XRANGEPLAINLOOSE]}$`);ce("COERCEPLAIN",`(^|[^\\d])(\\d{1,${ZE}})(?:\\.(\\d{1,${ZE}}))?(?:\\.(\\d{1,${ZE}}))?`);ce("COERCE",`${V[B.COERCEPLAIN]}(?:$|[^\\d])`);ce("COERCEFULL",V[B.COERCEPLAIN]+`(?:${V[B.PRERELEASE]})?(?:${V[B.BUILD]})?(?:$|[^\\d])`);ce("COERCERTL",V[B.COERCE],!0);ce("COERCERTLFULL",V[B.COERCEFULL],!0);ce("LONETILDE","(?:~>?)");ce("TILDETRIM",`(\\s*)${V[B.LONETILDE]}\\s+`,!0);Pn.tildeTrimReplace="$1~";ce("TILDE",`^${V[B.LONETILDE]}${V[B.XRANGEPLAIN]}$`);ce("TILDELOOSE",`^${V[B.LONETILDE]}${V[B.XRANGEPLAINLOOSE]}$`);ce("LONECARET","(?:\\^)");ce("CARETTRIM",`(\\s*)${V[B.LONECARET]}\\s+`,!0);Pn.caretTrimReplace="$1^";ce("CARET",`^${V[B.LONECARET]}${V[B.XRANGEPLAIN]}$`);ce("CARETLOOSE",`^${V[B.LONECARET]}${V[B.XRANGEPLAINLOOSE]}$`);ce("COMPARATORLOOSE",`^${V[B.GTLT]}\\s*(${V[B.LOOSEPLAIN]})$|^$`);ce("COMPARATOR",`^${V[B.GTLT]}\\s*(${V[B.FULLPLAIN]})$|^$`);ce("COMPARATORTRIM",`(\\s*)${V[B.GTLT]}\\s*(${V[B.LOOSEPLAIN]}|${V[B.XRANGEPLAIN]})`,!0);Pn.comparatorTrimReplace="$1$2$3";ce("HYPHENRANGE",`^\\s*(${V[B.XRANGEPLAIN]})\\s+-\\s+(${V[B.XRANGEPLAIN]})\\s*$`);ce("HYPHENRANGELOOSE",`^\\s*(${V[B.XRANGEPLAINLOOSE]})\\s+-\\s+(${V[B.XRANGEPLAINLOOSE]})\\s*$`);ce("STAR","(<|>)?=?\\s*\\*");ce("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");ce("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var xf=h((IIe,xM)=>{"use strict";var yte=Object.freeze({loose:!0}),gte=Object.freeze({}),bte=t=>t?typeof t!="object"?yte:t:gte;xM.exports=bte});var YE=h((kIe,_M)=>{"use strict";var IM=/^[0-9]+$/,kM=(t,e)=>{if(typeof t=="number"&&typeof e=="number")return t===e?0:t<e?-1:1;let r=IM.test(t),i=IM.test(e);return r&&i&&(t=+t,e=+e),t===e?0:r&&!i?-1:i&&!r?1:t<e?-1:1},vte=(t,e)=>kM(e,t);_M.exports={compareIdentifiers:kM,rcompareIdentifiers:vte}});var Nt=h((_Ie,CM)=>{"use strict";var If=Zc(),{MAX_LENGTH:TM,MAX_SAFE_INTEGER:kf}=Ta(),{safeRe:_f,t:Tf}=Ca(),Ste=xf(),{compareIdentifiers:XE}=YE(),Ete=(t,e)=>{let r=e.split(".");if(r.length>t.length)return!1;for(let i=0;i<r.length;i++)if(XE(t[i],r[i])!==0)return!1;return!0},QE=class t{constructor(e,r){if(r=Ste(r),e instanceof t){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>TM)throw new TypeError(`version is longer than ${TM} characters`);If("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let i=e.trim().match(r.loose?_f[Tf.LOOSE]:_f[Tf.FULL]);if(!i)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>kf||this.major<0)throw new TypeError("Invalid major version");if(this.minor>kf||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>kf||this.patch<0)throw new TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let o=+n;if(o>=0&&o<kf)return o}return n}):this.prerelease=[],this.build=i[5]?i[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(If("SemVer.compare",this.version,this.options,e),!(e instanceof t)){if(typeof e=="string"&&e===this.version)return 0;e=new t(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof t||(e=new t(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof t||(e=new t(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{let i=this.prerelease[r],n=e.prerelease[r];if(If("prerelease compare",r,i,n),i===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(i===void 0)return-1;if(i===n)continue;return XE(i,n)}while(++r)}compareBuild(e){e instanceof t||(e=new t(e,this.options));let r=0;do{let i=this.build[r],n=e.build[r];if(If("build compare",r,i,n),i===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(i===void 0)return-1;if(i===n)continue;return XE(i,n)}while(++r)}inc(e,r,i){if(e.startsWith("pre")){if(!r&&i===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let n=`-${r}`.match(this.options.loose?_f[Tf.PRERELEASELOOSE]:_f[Tf.PRERELEASE]);if(!n||n[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,i);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,i);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,i),this.inc("pre",r,i);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,i),this.inc("pre",r,i);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":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(i)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let o=this.prerelease.length;for(;--o>=0;)typeof this.prerelease[o]=="number"&&(this.prerelease[o]++,o=-2);if(o===-1){if(r===this.prerelease.join(".")&&i===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(r){let o=[r,n];if(i===!1&&(o=[r]),Ete(this.prerelease,r)){let s=this.prerelease[r.split(".").length];isNaN(s)&&(this.prerelease=o)}else this.prerelease=o}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};CM.exports=QE});var Ji=h((TIe,AM)=>{"use strict";var OM=Nt(),wte=(t,e,r=!1)=>{if(t instanceof OM)return t;try{return new OM(t,e)}catch(i){if(!r)return null;throw i}};AM.exports=wte});var RM=h((CIe,KM)=>{"use strict";var xte=Ji(),Ite=(t,e)=>{let r=xte(t,e);return r?r.version:null};KM.exports=Ite});var jM=h((OIe,DM)=>{"use strict";var kte=Ji(),_te=(t,e)=>{let r=kte(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null};DM.exports=_te});var NM=h((AIe,MM)=>{"use strict";var PM=Nt(),Tte=(t,e,r,i,n)=>{typeof r=="string"&&(n=i,i=r,r=void 0);try{return new PM(t instanceof PM?t.version:t,r).inc(e,i,n).version}catch{return null}};MM.exports=Tte});var $M=h((KIe,UM)=>{"use strict";var LM=Ji(),Cte=(t,e)=>{let r=LM(t,null,!0),i=LM(e,null,!0),n=r.compare(i);if(n===0)return null;let o=n>0,s=o?r:i,a=o?i:r,l=!!s.prerelease.length;if(!!a.prerelease.length&&!l){if(!a.patch&&!a.minor)return"major";if(a.compareMain(s)===0)return a.minor&&!a.patch?"minor":"patch"}let u=l?"pre":"";return r.major!==i.major?u+"major":r.minor!==i.minor?u+"minor":r.patch!==i.patch?u+"patch":"prerelease"};UM.exports=Cte});var FM=h((RIe,JM)=>{"use strict";var Ote=Nt(),Ate=(t,e)=>new Ote(t,e).major;JM.exports=Ate});var zM=h((DIe,qM)=>{"use strict";var Kte=Nt(),Rte=(t,e)=>new Kte(t,e).minor;qM.exports=Rte});var VM=h((jIe,GM)=>{"use strict";var Dte=Nt(),jte=(t,e)=>new Dte(t,e).patch;GM.exports=jte});var WM=h((PIe,BM)=>{"use strict";var Pte=Ji(),Mte=(t,e)=>{let r=Pte(t,e);return r&&r.prerelease.length?r.prerelease:null};BM.exports=Mte});var Qr=h((MIe,HM)=>{"use strict";var ZM=Nt(),Nte=(t,e,r)=>new ZM(t,r).compare(new ZM(e,r));HM.exports=Nte});var XM=h((NIe,YM)=>{"use strict";var Lte=Qr(),Ute=(t,e,r)=>Lte(e,t,r);YM.exports=Ute});var eN=h((LIe,QM)=>{"use strict";var $te=Qr(),Jte=(t,e)=>$te(t,e,!0);QM.exports=Jte});var Cf=h((UIe,rN)=>{"use strict";var tN=Nt(),Fte=(t,e,r)=>{let i=new tN(t,r),n=new tN(e,r);return i.compare(n)||i.compareBuild(n)};rN.exports=Fte});var iN=h(($Ie,nN)=>{"use strict";var qte=Cf(),zte=(t,e)=>t.sort((r,i)=>qte(r,i,e));nN.exports=zte});var sN=h((JIe,oN)=>{"use strict";var Gte=Cf(),Vte=(t,e)=>t.sort((r,i)=>Gte(i,r,e));oN.exports=Vte});var Hc=h((FIe,aN)=>{"use strict";var Bte=Qr(),Wte=(t,e,r)=>Bte(t,e,r)>0;aN.exports=Wte});var Of=h((qIe,lN)=>{"use strict";var Zte=Qr(),Hte=(t,e,r)=>Zte(t,e,r)<0;lN.exports=Hte});var e0=h((zIe,cN)=>{"use strict";var Yte=Qr(),Xte=(t,e,r)=>Yte(t,e,r)===0;cN.exports=Xte});var t0=h((GIe,uN)=>{"use strict";var Qte=Qr(),ere=(t,e,r)=>Qte(t,e,r)!==0;uN.exports=ere});var Af=h((VIe,dN)=>{"use strict";var tre=Qr(),rre=(t,e,r)=>tre(t,e,r)>=0;dN.exports=rre});var Kf=h((BIe,pN)=>{"use strict";var nre=Qr(),ire=(t,e,r)=>nre(t,e,r)<=0;pN.exports=ire});var r0=h((WIe,fN)=>{"use strict";var ore=e0(),sre=t0(),are=Hc(),lre=Af(),cre=Of(),ure=Kf(),dre=(t,e,r,i)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return ore(t,r,i);case"!=":return sre(t,r,i);case">":return are(t,r,i);case">=":return lre(t,r,i);case"<":return cre(t,r,i);case"<=":return ure(t,r,i);default:throw new TypeError(`Invalid operator: ${e}`)}};fN.exports=dre});var hN=h((ZIe,mN)=>{"use strict";var pre=Nt(),fre=Ji(),{safeRe:Rf,t:Df}=Ca(),mre=(t,e)=>{if(t instanceof pre)return t;if(typeof t=="number"&&(t=String(t)),typeof t!="string")return null;e=e||{};let r=null;if(!e.rtl)r=t.match(e.includePrerelease?Rf[Df.COERCEFULL]:Rf[Df.COERCE]);else{let l=e.includePrerelease?Rf[Df.COERCERTLFULL]:Rf[Df.COERCERTL],c;for(;(c=l.exec(t))&&(!r||r.index+r[0].length!==t.length);)(!r||c.index+c[0].length!==r.index+r[0].length)&&(r=c),l.lastIndex=c.index+c[1].length+c[2].length;l.lastIndex=-1}if(r===null)return null;let i=r[2],n=r[3]||"0",o=r[4]||"0",s=e.includePrerelease&&r[5]?`-${r[5]}`:"",a=e.includePrerelease&&r[6]?`+${r[6]}`:"";return fre(`${i}.${n}.${o}${s}${a}`,e)};mN.exports=mre});var gN=h((HIe,yN)=>{"use strict";var hre=Ji(),yre=Ta(),gre=Nt(),bre=(t,e,r)=>{if(!yre.RELEASE_TYPES.includes(e))return null;let i=vre(t,r);return i&&Sre(i,e)},vre=(t,e)=>{let r=t instanceof gre?t.version:t;return hre(r,e)},Sre=(t,e)=>{if(Ere(e))return t.version;switch(t.prerelease=[],e){case"major":t.minor=0,t.patch=0;break;case"minor":t.patch=0;break}return t.format()},Ere=t=>t.startsWith("pre");yN.exports=bre});var vN=h((YIe,bN)=>{"use strict";var n0=class{constructor(){this.max=1e3,this.map=new Map}get(e){let r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}delete(e){return this.map.delete(e)}set(e,r){if(!this.delete(e)&&r!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(e,r)}return this}};bN.exports=n0});var en=h((XIe,xN)=>{"use strict";var wre=/\s+/g,i0=class t{constructor(e,r){if(r=Ire(r),e instanceof t)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new t(e.raw,r);if(e instanceof o0)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e.trim().replace(wre," "),this.set=this.raw.split("||").map(i=>this.parseRange(i.trim())).filter(i=>i.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let i=this.set[0];if(this.set=this.set.filter(n=>!EN(n[0])),this.set.length===0)this.set=[i];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&Dre(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let r=this.set[e];for(let i=0;i<r.length;i++)i>0&&(this.formatted+=" "),this.formatted+=r[i].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){e=e.replace(Rre,"");let i=((this.options.includePrerelease&&Are)|(this.options.loose&&Kre))+":"+e,n=SN.get(i);if(n)return n;let o=this.options.loose,s=o?ar[Lt.HYPHENRANGELOOSE]:ar[Lt.HYPHENRANGE];e=e.replace(s,zre(this.options.includePrerelease)),Ye("hyphen replace",e),e=e.replace(ar[Lt.COMPARATORTRIM],Tre),Ye("comparator trim",e),e=e.replace(ar[Lt.TILDETRIM],Cre),Ye("tilde trim",e),e=e.replace(ar[Lt.CARETTRIM],Ore),Ye("caret trim",e);let a=e.split(" ").map(d=>jre(d,this.options)).join(" ").split(/\s+/).map(d=>qre(d,this.options));o&&(a=a.filter(d=>(Ye("loose invalid filter",d,this.options),!!d.match(ar[Lt.COMPARATORLOOSE])))),Ye("range list",a);let l=new Map,c=a.map(d=>new o0(d,this.options));for(let d of c){if(EN(d))return[d];l.set(d.value,d)}l.size>1&&l.has("")&&l.delete("");let u=[...l.values()];return SN.set(i,u),u}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(i=>wN(i,r)&&e.set.some(n=>wN(n,r)&&i.every(o=>n.every(s=>o.intersects(s,r)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new kre(e,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(Gre(this.set[r],e,this.options))return!0;return!1}};xN.exports=i0;var xre=vN(),SN=new xre,Ire=xf(),o0=Yc(),Ye=Zc(),kre=Nt(),{safeRe:ar,src:_re,t:Lt,comparatorTrimReplace:Tre,tildeTrimReplace:Cre,caretTrimReplace:Ore}=Ca(),{FLAG_INCLUDE_PRERELEASE:Are,FLAG_LOOSE:Kre}=Ta(),Rre=new RegExp(_re[Lt.BUILD],"g"),EN=t=>t.value==="<0.0.0-0",Dre=t=>t.value==="",wN=(t,e)=>{let r=!0,i=t.slice(),n=i.pop();for(;r&&i.length;)r=i.every(o=>n.intersects(o,e)),n=i.pop();return r},jre=(t,e)=>(t=t.replace(ar[Lt.BUILD],""),Ye("comp",t,e),t=Lre(t,e),Ye("caret",t),t=Mre(t,e),Ye("tildes",t),t=$re(t,e),Ye("xrange",t),t=Fre(t,e),Ye("stars",t),t),_t=t=>!t||t.toLowerCase()==="x"||t==="*",Pre=(t,e,r)=>_t(t)&&!_t(e)||_t(e)&&r&&!_t(r),Mre=(t,e)=>t.trim().split(/\s+/).map(r=>Nre(r,e)).join(" "),Nre=(t,e)=>{let r=e.loose?ar[Lt.TILDELOOSE]:ar[Lt.TILDE],i=e.includePrerelease?"-0":"";return t.replace(r,(n,o,s,a,l)=>{Ye("tilde",t,n,o,s,a,l);let c;return _t(o)?c="":_t(s)?c=`>=${o}.0.0${i} <${+o+1}.0.0-0`:_t(a)?c=`>=${o}.${s}.0${i} <${o}.${+s+1}.0-0`:l?(Ye("replaceTilde pr",l),c=`>=${o}.${s}.${a}-${l} <${o}.${+s+1}.0-0`):c=`>=${o}.${s}.${a} <${o}.${+s+1}.0-0`,Ye("tilde return",c),c})},Lre=(t,e)=>t.trim().split(/\s+/).map(r=>Ure(r,e)).join(" "),Ure=(t,e)=>{Ye("caret",t,e);let r=e.loose?ar[Lt.CARETLOOSE]:ar[Lt.CARET],i=e.includePrerelease?"-0":"";return t.replace(r,(n,o,s,a,l)=>{Ye("caret",t,n,o,s,a,l);let c;return _t(o)?c="":_t(s)?c=`>=${o}.0.0${i} <${+o+1}.0.0-0`:_t(a)?o==="0"?c=`>=${o}.${s}.0${i} <${o}.${+s+1}.0-0`:c=`>=${o}.${s}.0${i} <${+o+1}.0.0-0`:l?(Ye("replaceCaret pr",l),o==="0"?s==="0"?c=`>=${o}.${s}.${a}-${l} <${o}.${s}.${+a+1}-0`:c=`>=${o}.${s}.${a}-${l} <${o}.${+s+1}.0-0`:c=`>=${o}.${s}.${a}-${l} <${+o+1}.0.0-0`):(Ye("no pr"),o==="0"?s==="0"?c=`>=${o}.${s}.${a} <${o}.${s}.${+a+1}-0`:c=`>=${o}.${s}.${a} <${o}.${+s+1}.0-0`:c=`>=${o}.${s}.${a} <${+o+1}.0.0-0`),Ye("caret return",c),c})},$re=(t,e)=>(Ye("replaceXRanges",t,e),t.split(/\s+/).map(r=>Jre(r,e)).join(" ")),Jre=(t,e)=>{t=t.trim();let r=e.loose?ar[Lt.XRANGELOOSE]:ar[Lt.XRANGE];return t.replace(r,(i,n,o,s,a,l)=>{if(Ye("xRange",t,i,n,o,s,a,l),Pre(o,s,a))return t;let c=_t(o),u=c||_t(s),d=u||_t(a),f=d;return n==="="&&f&&(n=""),l=e.includePrerelease?"-0":"",c?n===">"||n==="<"?i="<0.0.0-0":i="*":n&&f?(u&&(s=0),a=0,n===">"?(n=">=",u?(o=+o+1,s=0,a=0):(s=+s+1,a=0)):n==="<="&&(n="<",u?o=+o+1:s=+s+1),n==="<"&&(l="-0"),i=`${n+o}.${s}.${a}${l}`):u?i=`>=${o}.0.0${l} <${+o+1}.0.0-0`:d&&(i=`>=${o}.${s}.0${l} <${o}.${+s+1}.0-0`),Ye("xRange return",i),i})},Fre=(t,e)=>(Ye("replaceStars",t,e),t.trim().replace(ar[Lt.STAR],"")),qre=(t,e)=>(Ye("replaceGTE0",t,e),t.trim().replace(ar[e.includePrerelease?Lt.GTE0PRE:Lt.GTE0],"")),zre=t=>(e,r,i,n,o,s,a,l,c,u,d,f)=>(_t(i)?r="":_t(n)?r=`>=${i}.0.0${t?"-0":""}`:_t(o)?r=`>=${i}.${n}.0${t?"-0":""}`:s?r=`>=${r}`:r=`>=${r}${t?"-0":""}`,_t(c)?l="":_t(u)?l=`<${+c+1}.0.0-0`:_t(d)?l=`<${c}.${+u+1}.0-0`:f?l=`<=${c}.${u}.${d}-${f}`:t?l=`<${c}.${u}.${+d+1}-0`:l=`<=${l}`,`${r} ${l}`.trim()),Gre=(t,e,r)=>{for(let i=0;i<t.length;i++)if(!t[i].test(e))return!1;if(e.prerelease.length&&!r.includePrerelease){for(let i=0;i<t.length;i++)if(Ye(t[i].semver),t[i].semver!==o0.ANY&&t[i].semver.prerelease.length>0){let n=t[i].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}});var Yc=h((QIe,ON)=>{"use strict";var Xc=Symbol("SemVer ANY"),l0=class t{static get ANY(){return Xc}constructor(e,r){if(r=IN(r),e instanceof t){if(e.loose===!!r.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),a0("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===Xc?this.value="":this.value=this.operator+this.semver.version,a0("comp",this)}parse(e){let r=this.options.loose?kN[_N.COMPARATORLOOSE]:kN[_N.COMPARATOR],i=e.match(r);if(!i)throw new TypeError(`Invalid comparator: ${e}`);this.operator=i[1]!==void 0?i[1]:"",this.operator==="="&&(this.operator=""),i[2]?this.semver=new TN(i[2],this.options.loose):this.semver=Xc}toString(){return this.value}test(e){if(a0("Comparator.test",e,this.options.loose),this.semver===Xc||e===Xc)return!0;if(typeof e=="string")try{e=new TN(e,this.options)}catch{return!1}return s0(e,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new CN(e.value,r).test(this.value):e.operator===""?e.value===""?!0:new CN(this.value,r).test(e.semver):(r=IN(r),r.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||s0(this.semver,"<",e.semver,r)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||s0(this.semver,">",e.semver,r)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};ON.exports=l0;var IN=xf(),{safeRe:kN,t:_N}=Ca(),s0=r0(),a0=Zc(),TN=Nt(),CN=en()});var Qc=h((eke,AN)=>{"use strict";var Vre=en(),Bre=(t,e,r)=>{try{e=new Vre(e,r)}catch{return!1}return e.test(t)};AN.exports=Bre});var RN=h((tke,KN)=>{"use strict";var Wre=en(),Zre=(t,e)=>new Wre(t,e).set.map(r=>r.map(i=>i.value).join(" ").trim().split(" "));KN.exports=Zre});var jN=h((rke,DN)=>{"use strict";var Hre=Nt(),Yre=en(),Xre=(t,e,r)=>{let i=null,n=null,o=null;try{o=new Yre(e,r)}catch{return null}return t.forEach(s=>{o.test(s)&&(!i||n.compare(s)===-1)&&(i=s,n=new Hre(i,r))}),i};DN.exports=Xre});var MN=h((nke,PN)=>{"use strict";var Qre=Nt(),ene=en(),tne=(t,e,r)=>{let i=null,n=null,o=null;try{o=new ene(e,r)}catch{return null}return t.forEach(s=>{o.test(s)&&(!i||n.compare(s)===1)&&(i=s,n=new Qre(i,r))}),i};PN.exports=tne});var UN=h((ike,LN)=>{"use strict";var c0=Nt(),rne=en(),NN=Hc(),nne=(t,e)=>{t=new rne(t,e);let r=new c0("0.0.0");if(t.test(r)||(r=new c0("0.0.0-0"),t.test(r)))return r;r=null;for(let i=0;i<t.set.length;++i){let n=t.set[i],o=null;n.forEach(s=>{let a=new c0(s.semver.version);switch(s.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!o||NN(a,o))&&(o=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${s.operator}`)}}),o&&(!r||NN(r,o))&&(r=o)}return r&&t.test(r)?r:null};LN.exports=nne});var JN=h((oke,$N)=>{"use strict";var ine=en(),one=(t,e)=>{try{return new ine(t,e).range||"*"}catch{return null}};$N.exports=one});var jf=h((ske,GN)=>{"use strict";var sne=Nt(),zN=Yc(),{ANY:ane}=zN,lne=en(),cne=Qc(),FN=Hc(),qN=Of(),une=Kf(),dne=Af(),pne=(t,e,r,i)=>{t=new sne(t,i),e=new lne(e,i);let n,o,s,a,l;switch(r){case">":n=FN,o=une,s=qN,a=">",l=">=";break;case"<":n=qN,o=dne,s=FN,a="<",l="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(cne(t,e,i))return!1;for(let c=0;c<e.set.length;++c){let u=e.set[c],d=null,f=null;if(u.forEach(p=>{p.semver===ane&&(p=new zN(">=0.0.0")),d=d||p,f=f||p,n(p.semver,d.semver,i)?d=p:s(p.semver,f.semver,i)&&(f=p)}),d.operator===a||d.operator===l||(!f.operator||f.operator===a)&&o(t,f.semver))return!1;if(f.operator===l&&s(t,f.semver))return!1}return!0};GN.exports=pne});var BN=h((ake,VN)=>{"use strict";var fne=jf(),mne=(t,e,r)=>fne(t,e,">",r);VN.exports=mne});var ZN=h((lke,WN)=>{"use strict";var hne=jf(),yne=(t,e,r)=>hne(t,e,"<",r);WN.exports=yne});var XN=h((cke,YN)=>{"use strict";var HN=en(),gne=(t,e,r)=>(t=new HN(t,r),e=new HN(e,r),t.intersects(e,r));YN.exports=gne});var eL=h((uke,QN)=>{"use strict";var bne=Qc(),vne=Qr();QN.exports=(t,e,r)=>{let i=[],n=null,o=null,s=t.sort((u,d)=>vne(u,d,r));for(let u of s)bne(u,e,r)?(o=u,n||(n=u)):(o&&i.push([n,o]),o=null,n=null);n&&i.push([n,null]);let a=[];for(let[u,d]of i)u===d?a.push(u):!d&&u===s[0]?a.push("*"):d?u===s[0]?a.push(`<=${d}`):a.push(`${u} - ${d}`):a.push(`>=${u}`);let l=a.join(" || "),c=typeof e.raw=="string"?e.raw:String(e);return l.length<c.length?l:e}});var sL=h((dke,oL)=>{"use strict";var tL=en(),p0=Yc(),{ANY:u0}=p0,d0=Qc(),f0=Qr(),Sne=(t,e,r={})=>{if(t===e)return!0;t=new tL(t,r),e=new tL(e,r);let i=!1;e:for(let n of t.set){for(let o of e.set){let s=wne(n,o,r);if(i=i||s!==null,s)continue e}if(i)return!1}return!0},Ene=[new p0(">=0.0.0-0")],rL=[new p0(">=0.0.0")],wne=(t,e,r)=>{if(t===e)return!0;if(t.length===1&&t[0].semver===u0){if(e.length===1&&e[0].semver===u0)return!0;r.includePrerelease?t=Ene:t=rL}if(e.length===1&&e[0].semver===u0){if(r.includePrerelease)return!0;e=rL}let i=new Set,n,o;for(let p of t)p.operator===">"||p.operator===">="?n=nL(n,p,r):p.operator==="<"||p.operator==="<="?o=iL(o,p,r):i.add(p.semver);if(i.size>1)return null;let s;if(n&&o){if(s=f0(n.semver,o.semver,r),s>0)return null;if(s===0&&(n.operator!==">="||o.operator!=="<="))return null}for(let p of i){if(n&&!d0(p,String(n),r)||o&&!d0(p,String(o),r))return null;for(let m of e)if(!d0(p,String(m),r))return!1;return!0}let a,l,c,u,d=o&&!r.includePrerelease&&o.semver.prerelease.length?o.semver:!1,f=n&&!r.includePrerelease&&n.semver.prerelease.length?n.semver:!1;d&&d.prerelease.length===1&&o.operator==="<"&&d.prerelease[0]===0&&(d=!1);for(let p of e){if(u=u||p.operator===">"||p.operator===">=",c=c||p.operator==="<"||p.operator==="<=",n){if(f&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===f.major&&p.semver.minor===f.minor&&p.semver.patch===f.patch&&(f=!1),p.operator===">"||p.operator===">="){if(a=nL(n,p,r),a===p&&a!==n)return!1}else if(n.operator===">="&&!p.test(n.semver))return!1}if(o){if(d&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===d.major&&p.semver.minor===d.minor&&p.semver.patch===d.patch&&(d=!1),p.operator==="<"||p.operator==="<="){if(l=iL(o,p,r),l===p&&l!==o)return!1}else if(o.operator==="<="&&!p.test(o.semver))return!1}if(!p.operator&&(o||n)&&s!==0)return!1}return!(n&&c&&!o&&s!==0||o&&u&&!n&&s!==0||f||d)},nL=(t,e,r)=>{if(!t)return e;let i=f0(t.semver,e.semver,r);return i>0?t:i<0||e.operator===">"&&t.operator===">="?e:t},iL=(t,e,r)=>{if(!t)return e;let i=f0(t.semver,e.semver,r);return i<0?t:i>0||e.operator==="<"&&t.operator==="<="?e:t};oL.exports=Sne});var uL=h((pke,cL)=>{"use strict";var m0=Ca(),aL=Ta(),xne=Nt(),lL=YE(),Ine=Ji(),kne=RM(),_ne=jM(),Tne=NM(),Cne=$M(),One=FM(),Ane=zM(),Kne=VM(),Rne=WM(),Dne=Qr(),jne=XM(),Pne=eN(),Mne=Cf(),Nne=iN(),Lne=sN(),Une=Hc(),$ne=Of(),Jne=e0(),Fne=t0(),qne=Af(),zne=Kf(),Gne=r0(),Vne=hN(),Bne=gN(),Wne=Yc(),Zne=en(),Hne=Qc(),Yne=RN(),Xne=jN(),Qne=MN(),eie=UN(),tie=JN(),rie=jf(),nie=BN(),iie=ZN(),oie=XN(),sie=eL(),aie=sL();cL.exports={parse:Ine,valid:kne,clean:_ne,inc:Tne,diff:Cne,major:One,minor:Ane,patch:Kne,prerelease:Rne,compare:Dne,rcompare:jne,compareLoose:Pne,compareBuild:Mne,sort:Nne,rsort:Lne,gt:Une,lt:$ne,eq:Jne,neq:Fne,gte:qne,lte:zne,cmp:Gne,coerce:Vne,truncate:Bne,Comparator:Wne,Range:Zne,satisfies:Hne,toComparators:Yne,maxSatisfying:Xne,minSatisfying:Qne,minVersion:eie,validRange:tie,outside:rie,gtr:nie,ltr:iie,intersects:oie,simplifyRange:sie,subset:aie,SemVer:xne,re:m0.re,src:m0.src,tokens:m0.t,SEMVER_SPEC_VERSION:aL.SEMVER_SPEC_VERSION,RELEASE_TYPES:aL.RELEASE_TYPES,compareIdentifiers:lL.compareIdentifiers,rcompareIdentifiers:lL.rcompareIdentifiers}});var Or=h(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.QUEUE_EVENT_SUFFIX=te.toString=te.errorToJSON=te.parseObjectValues=te.isRedisVersionLowerThan=te.childSend=te.asyncSend=te.DELAY_TIME_1=te.DELAY_TIME_5=te.clientCommandMessageReg=te.optsEncodeMap=te.optsDecodeMap=te.errorObject=void 0;te.tryCatch=uie;te.lengthInUtf8Bytes=die;te.isEmpty=pie;te.array2obj=fie;te.objectToFlatArray=mie;te.delay=hie;te.increaseMaxListeners=dL;te.invertObject=pL;te.isRedisInstance=fL;te.isRedisCluster=yie;te.decreaseMaxListeners=gie;te.removeAllQueueData=bie;te.getParentKey=vie;te.isNotConnectionError=mL;te.removeUndefinedFields=Cie;te.trace=Oie;te.randomUUID=Aie;var h0=U("crypto"),lie=bt(),cie=_a(),y0=uL(),g0=gr();te.errorObject={value:null};function uie(t,e,r){try{return t.apply(e,r)}catch(i){return te.errorObject.value=i,te.errorObject}}function die(t){return Buffer.byteLength(t,"utf8")}function pie(t){for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function fie(t){let e={};for(let r=0;r<t.length;r+=2)e[t[r]]=t[r+1];return e}function mie(t){let e=[];for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&t[r]!==void 0&&(e[e.length]=r,e[e.length]=t[r]);return e}function hie(t,e){return new Promise(r=>{let i,n=()=>{e?.signal.removeEventListener("abort",n),clearTimeout(i),r()};i=setTimeout(n,t),e?.signal.addEventListener("abort",n)})}function dL(t,e){let r=t.getMaxListeners();t.setMaxListeners(r+e)}function pL(t){return Object.entries(t).reduce((e,[r,i])=>(e[i]=r,e),{})}te.optsDecodeMap={de:"deduplication",fpof:"failParentOnFailure",cpof:"continueParentOnFailure",idof:"ignoreDependencyOnFailure",kl:"keepLogs",rdof:"removeDependencyOnFailure"};te.optsEncodeMap=Object.assign(Object.assign({},pL(te.optsDecodeMap)),{debounce:"de"});function fL(t){return t?["connect","disconnect","duplicate"].every(r=>typeof t[r]=="function"):!1}function yie(t){return fL(t)&&!!t.isCluster}function gie(t,e){dL(t,-e)}async function bie(t,e,r=process.env.BULLMQ_TEST_PREFIX||"bull"){if(t.isCluster)return!1;let i=`${r}:${e}:*`,n=[];await new Promise((o,s)=>{let a=t.scanStream({match:i});a.on("data",l=>{if(l.length){let c=t.pipeline();l.forEach(d=>{c.del(d)});let u=c.exec().catch(d=>{throw s(d),d});n.push(u)}}),a.on("end",()=>o()),a.on("error",l=>s(l))}),await Promise.all(n);try{await t.quit()}catch(o){if(mL(o))throw o}}function vie(t){if(t)return`${t.queue}:${t.id}`}te.clientCommandMessageReg=/ERR unknown command ['`]\s*client\s*['`]/;te.DELAY_TIME_5=5e3;te.DELAY_TIME_1=100;function mL(t){if(t instanceof cie.ConnectionClosedError)return!1;let{code:e,message:r}=t;return r!==lie.CONNECTION_CLOSED_ERROR_MSG&&!r.includes("ECONNREFUSED")&&e!=="ECONNREFUSED"}var Sie=(t,e)=>new Promise((r,i)=>{typeof t.send=="function"?t.send(e,n=>{n?i(n):r()}):typeof t.postMessage=="function"?r(t.postMessage(e)):r()});te.asyncSend=Sie;var Eie=(t,e)=>(0,te.asyncSend)(t,e);te.childSend=Eie;var wie=(t,e,r,i="redis")=>{if(r===i){let n=y0.valid(y0.coerce(t));return y0.lt(n,e)}return!1};te.isRedisVersionLowerThan=wie;var xie=t=>{let e={};for(let r of Object.entries(t))e[r[0]]=JSON.parse(r[1]);return e};te.parseObjectValues=xie;var Iie=t=>{let e=new WeakSet;return e.add(t),(r,i)=>{if(typeof i=="object"&&i!==null){if(e.has(i))return"[Circular]";e.add(i)}return i}},kie=t=>{let e={};return Object.getOwnPropertyNames(t).forEach(function(r){e[r]=t[r]}),JSON.parse(JSON.stringify(e,Iie(t)))};te.errorToJSON=kie;var _ie=1/0,Tie=t=>{if(t==null)return"";if(typeof t=="string")return t;if(Array.isArray(t))return`${t.map(r=>r==null?r:(0,te.toString)(r))}`;if(typeof t=="symbol"||Object.prototype.toString.call(t)=="[object Symbol]")return t.toString();let e=`${t}`;return e==="0"&&1/t===-_ie?"-0":e};te.toString=Tie;te.QUEUE_EVENT_SUFFIX=":qe";function Cie(t){let e={};for(let r in t)t[r]!==void 0&&(e[r]=t[r]);return e}async function Oie(t,e,r,i,n,o,s){if(t){let{tracer:a,contextManager:l}=t,c=l.active(),u;s&&(u=l.fromMetadata(c,s));let d=n?`${i} ${n}`:i,f=a.startSpan(d,{kind:e},u);try{f.setAttributes({[g0.TelemetryAttributes.QueueName]:r,[g0.TelemetryAttributes.QueueOperation]:i});let p,m;return e===g0.SpanKind.CONSUMER&&u?p=f.setSpanOnContext(u):p=f.setSpanOnContext(c),o.length==2&&(m=l.getMetadata(p)),await l.with(p,()=>o(f,m))}catch(p){throw f.recordException(p),p}finally{f.end()}}else return o()}function Aie(){if(typeof h0.randomUUID=="function")return(0,h0.randomUUID)();let t=(0,h0.randomBytes)(16);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,[t.toString("hex",0,4),t.toString("hex",4,6),t.toString("hex",6,8),t.toString("hex",8,10),t.toString("hex",10,16)].join("-")}});var hL=h(Pf=>{"use strict";Object.defineProperty(Pf,"__esModule",{value:!0});Pf.ChildProcessor=void 0;var Kie=hf(),lr=gr(),b0=Or(),Fi;(function(t){t[t.Idle=0]="Idle",t[t.Started=1]="Started",t[t.Terminating=2]="Terminating",t[t.Errored=3]="Errored"})(Fi||(Fi={}));var eu=process.env.NODE_ENV==="test"?500:5e3,v0=class{constructor(e,r){this.send=e,this.receiver=r}async init(e){let r;try{let{default:n}=await import(e);if(r=n,r.default&&(r=r.default),typeof r!="function")throw new Error("No function is exported in processor file")}catch(n){return this.status=Fi.Errored,this.send({cmd:lr.ParentCommand.InitFailed,err:(0,b0.errorToJSON)(n)})}let i=r;r=function(n,o,s){try{return Promise.resolve(i(n,o,s))}catch(a){return Promise.reject(a)}},this.processor=r,this.status=Fi.Idle,await this.send({cmd:lr.ParentCommand.InitCompleted})}async start(e,r){if(this.status!==Fi.Idle)return this.send({cmd:lr.ParentCommand.Error,err:(0,b0.errorToJSON)(new Error("cannot start a not idling child process"))});this.status=Fi.Started,this.abortController=new Kie.AbortController,this.currentJobPromise=(async()=>{try{let i=this.wrapJob(e,this.send),n=await this.processor(i,r,this.abortController.signal);await this.send({cmd:lr.ParentCommand.Completed,value:typeof n>"u"?null:n})}catch(i){await this.send({cmd:lr.ParentCommand.Failed,value:(0,b0.errorToJSON)(i.message?i:new Error(i))})}finally{this.status=Fi.Idle,this.currentJobPromise=void 0,this.abortController=void 0}})()}cancel(e){this.abortController&&this.abortController.abort(e)}async stop(){}async waitForCurrentJobAndExit(){this.status=Fi.Terminating;try{await this.currentJobPromise}finally{process.exit(process.exitCode||0)}}wrapJob(e,r){let i=Object.assign(Object.assign({},e),{queueQualifiedName:e.queueQualifiedName,data:JSON.parse(e.data||"{}"),opts:e.opts,returnValue:JSON.parse(e.returnvalue||"{}"),async updateProgress(n){this.progress=n,await r({cmd:lr.ParentCommand.Progress,value:n})},log:async n=>{await r({cmd:lr.ParentCommand.Log,value:n})},moveToDelayed:async(n,o)=>{await r({cmd:lr.ParentCommand.MoveToDelayed,value:{timestamp:n,token:o}})},moveToWait:async n=>{await r({cmd:lr.ParentCommand.MoveToWait,value:{token:n}})},moveToWaitingChildren:async(n,o)=>{let s=Math.random().toString(36).substring(2,15);return await r({requestId:s,cmd:lr.ParentCommand.MoveToWaitingChildren,value:{token:n,opts:o}}),tu(s,this.receiver,eu,"moveToWaitingChildren")},updateData:async n=>{await r({cmd:lr.ParentCommand.Update,value:n}),i.data=n},getChildrenValues:async()=>{let n=Math.random().toString(36).substring(2,15);return await r({requestId:n,cmd:lr.ParentCommand.GetChildrenValues}),tu(n,this.receiver,eu,"getChildrenValues")},getIgnoredChildrenFailures:async()=>{let n=Math.random().toString(36).substring(2,15);return await r({requestId:n,cmd:lr.ParentCommand.GetIgnoredChildrenFailures}),tu(n,this.receiver,eu,"getIgnoredChildrenFailures")},getDependenciesCount:async n=>{let o=Math.random().toString(36).substring(2,15);return await r({requestId:o,cmd:lr.ParentCommand.GetDependenciesCount,value:n}),tu(o,this.receiver,eu,"getDependenciesCount")},getDependencies:async n=>{let o=Math.random().toString(36).substring(2,15);return await r({requestId:o,cmd:lr.ParentCommand.GetDependencies,value:n}),tu(o,this.receiver,eu,"getDependencies")}});return i}};Pf.ChildProcessor=v0;var tu=async(t,e,r,i)=>new Promise((n,o)=>{let s=a=>{a.requestId===t&&(n(a.value),e.off("message",s))};e.on("message",s),setTimeout(()=>{e.off("message",s),o(new Error(`TimeoutError: ${i} timed out in (${r}ms)`))},r)})});var yL=h(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.DelayedError=Go.DELAYED_ERROR=void 0;Go.DELAYED_ERROR="bullmq:movedToDelayed";var S0=class extends Error{constructor(e=Go.DELAYED_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Go.DelayedError=S0});var gL=h(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.RateLimitError=Vo.RATE_LIMIT_ERROR=void 0;Vo.RATE_LIMIT_ERROR="bullmq:rateLimitExceeded";var E0=class extends Error{constructor(e=Vo.RATE_LIMIT_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Vo.RateLimitError=E0});var x0=h(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.UnrecoverableError=Bo.UNRECOVERABLE_ERROR=void 0;Bo.UNRECOVERABLE_ERROR="bullmq:unrecoverable";var w0=class extends Error{constructor(e=Bo.UNRECOVERABLE_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Bo.UnrecoverableError=w0});var bL=h(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.WaitingChildrenError=Wo.WAITING_CHILDREN_ERROR=void 0;Wo.WAITING_CHILDREN_ERROR="bullmq:movedToWaitingChildren";var I0=class extends Error{constructor(e=Wo.WAITING_CHILDREN_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Wo.WaitingChildrenError=I0});var vL=h(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.WaitingError=Zo.WAITING_ERROR=void 0;Zo.WAITING_ERROR="bullmq:movedToWait";var k0=class extends Error{constructor(e=Zo.WAITING_ERROR){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Zo.WaitingError=k0});var Mf=h(qi=>{"use strict";Object.defineProperty(qi,"__esModule",{value:!0});var Oa=(Zt(),Jt(Wt));Oa.__exportStar(_a(),qi);Oa.__exportStar(yL(),qi);Oa.__exportStar(gL(),qi);Oa.__exportStar(x0(),qi);Oa.__exportStar(bL(),qi);Oa.__exportStar(vL(),qi)});var wL=h((Eke,EL)=>{"use strict";var SL=()=>process.platform==="linux",Nf=null,Rie=()=>{if(!Nf)if(SL()&&process.report){let t=process.report.excludeNetwork;process.report.excludeNetwork=!0,Nf=process.report.getReport(),process.report.excludeNetwork=t}else Nf={};return Nf};EL.exports={isLinux:SL,getReport:Rie}});var IL=h((wke,xL)=>{"use strict";var Aa=U("fs"),Die="/usr/bin/ldd",jie="/proc/self/exe",Lf=2048,Pie=t=>{let e=Aa.openSync(t,"r"),r=Buffer.alloc(Lf),i=Aa.readSync(e,r,0,Lf,0);return Aa.close(e,()=>{}),r.subarray(0,i)},Mie=t=>new Promise((e,r)=>{Aa.open(t,"r",(i,n)=>{if(i)r(i);else{let o=Buffer.alloc(Lf);Aa.read(n,o,0,Lf,0,(s,a)=>{e(o.subarray(0,a)),Aa.close(n,()=>{})})}})});xL.exports={LDD_PATH:Die,SELF_PATH:jie,readFileSync:Pie,readFile:Mie}});var _L=h((xke,kL)=>{"use strict";var Nie=t=>{if(t.length<64||t.readUInt32BE(0)!==2135247942||t.readUInt8(4)!==2||t.readUInt8(5)!==1)return null;let e=t.readUInt32LE(32),r=t.readUInt16LE(54),i=t.readUInt16LE(56);for(let n=0;n<i;n++){let o=e+n*r;if(t.readUInt32LE(o)===3){let a=t.readUInt32LE(o+8),l=t.readUInt32LE(o+32);return t.subarray(a,a+l).toString().replace(/\0.*$/g,"")}}return null};kL.exports={interpreterPath:Nie}});var GL=h((Ike,zL)=>{"use strict";var CL=U("child_process"),{isLinux:Ka,getReport:OL}=wL(),{LDD_PATH:Uf,SELF_PATH:AL,readFile:_0,readFileSync:T0}=IL(),{interpreterPath:KL}=_L(),Mn,Nn,Ln,RL="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",zi="",DL=()=>zi||new Promise(t=>{CL.exec(RL,(e,r)=>{zi=e?" ":r,t(zi)})}),jL=()=>{if(!zi)try{zi=CL.execSync(RL,{encoding:"utf8"})}catch{zi=" "}return zi},ai="glibc",PL=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,Ho="musl",Lie=t=>t.includes("libc.musl-")||t.includes("ld-musl-"),ML=()=>{let t=OL();return t.header&&t.header.glibcVersionRuntime?ai:Array.isArray(t.sharedObjects)&&t.sharedObjects.some(Lie)?Ho:null},NL=t=>{let[e,r]=t.split(/[\r\n]+/);return e&&e.includes(ai)?ai:r&&r.includes(Ho)?Ho:null},LL=t=>{if(t){if(t.includes("/ld-musl-"))return Ho;if(t.includes("/ld-linux-"))return ai}return null},UL=t=>(t=t.toString(),t.includes("musl")?Ho:t.includes("GNU C Library")?ai:null),Uie=async()=>{if(Nn!==void 0)return Nn;Nn=null;try{let t=await _0(Uf);Nn=UL(t)}catch{}return Nn},$ie=()=>{if(Nn!==void 0)return Nn;Nn=null;try{let t=T0(Uf);Nn=UL(t)}catch{}return Nn},Jie=async()=>{if(Mn!==void 0)return Mn;Mn=null;try{let t=await _0(AL),e=KL(t);Mn=LL(e)}catch{}return Mn},Fie=()=>{if(Mn!==void 0)return Mn;Mn=null;try{let t=T0(AL),e=KL(t);Mn=LL(e)}catch{}return Mn},$L=async()=>{let t=null;if(Ka()&&(t=await Jie(),!t&&(t=await Uie(),t||(t=ML()),!t))){let e=await DL();t=NL(e)}return t},JL=()=>{let t=null;if(Ka()&&(t=Fie(),!t&&(t=$ie(),t||(t=ML()),!t))){let e=jL();t=NL(e)}return t},qie=async()=>Ka()&&await $L()!==ai,zie=()=>Ka()&&JL()!==ai,Gie=async()=>{if(Ln!==void 0)return Ln;Ln=null;try{let e=(await _0(Uf)).match(PL);e&&(Ln=e[1])}catch{}return Ln},Vie=()=>{if(Ln!==void 0)return Ln;Ln=null;try{let e=T0(Uf).match(PL);e&&(Ln=e[1])}catch{}return Ln},FL=()=>{let t=OL();return t.header&&t.header.glibcVersionRuntime?t.header.glibcVersionRuntime:null},TL=t=>t.trim().split(/\s+/)[1],qL=t=>{let[e,r,i]=t.split(/[\r\n]+/);return e&&e.includes(ai)?TL(e):r&&i&&r.includes(Ho)?TL(i):null},Bie=async()=>{let t=null;if(Ka()&&(t=await Gie(),t||(t=FL()),!t)){let e=await DL();t=qL(e)}return t},Wie=()=>{let t=null;if(Ka()&&(t=Vie(),t||(t=FL()),!t)){let e=jL();t=qL(e)}return t};zL.exports={GLIBC:ai,MUSL:Ho,family:$L,familySync:JL,isNonGlibcLinux:qie,isNonGlibcLinuxSync:zie,version:Bie,versionSync:Wie}});var oU=h((kke,iU)=>{var Zie=U("fs"),yn=U("path"),Hie=U("url"),WL=U("os"),ZL=typeof __webpack_require__=="function"?__non_webpack_require__:U,Yie=process.config&&process.config.variables||{},Xie=!!process.env.PREBUILDS_ONLY,R0=process.versions,O0=R0.modules;(R0.deno||process.isBun)&&(O0="unsupported");var C0=toe()?"electron":eoe()?"node-webkit":"node",$f=process.env.npm_config_arch||WL.arch(),Jf=process.env.npm_config_platform||WL.platform(),HL=process.env.LIBC||(roe(Jf)?"musl":"glibc"),A0=process.env.ARM_VERSION||($f==="arm64"?"8":Yie.arm_version)||"",YL=(R0.uv||"").split(".")[0];iU.exports=Un;function Un(t){return ZL(Un.resolve(t))}Un.resolve=Un.path=function(t){t=yn.resolve(t||".");var e="",r;try{e=ZL(yn.join(t,"package.json")).name;var i=e.toUpperCase().replace(/-/g,"_");process.env[i+"_PREBUILD"]&&(t=process.env[i+"_PREBUILD"])}catch(y){r=y}if(!Xie){var n=VL(yn.join(t,"build/Release"),BL);if(n)return n;var o=VL(yn.join(t,"build/Debug"),BL);if(o)return o}var s=p(t);if(s)return s;var a=p(yn.dirname(process.execPath));if(a)return a;var l=(e[0]=="@"?"":"@"+e+"/")+e+"-"+Jf+"-"+$f,c;try{var u=yn.dirname(U("module").createRequire(Hie.pathToFileURL(yn.join(t,"package.json"))).resolve(l));return m(u)}catch(y){c=y}var d=["platform="+Jf,"arch="+$f,"runtime="+C0,"abi="+O0,"uv="+YL,A0?"armv="+A0:"","libc="+HL,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");let f="No native build was found for "+d+`
1125
1125
  attempted loading from: `+t+" and package: "+l+`
1126
1126
  `;throw r&&(f+="Error finding package.json: "+r.message+`
1127
1127
  `),c&&(f+="Error resolving package: "+c.message+`
1128
- `),new Error(f);function p(y){var w=K0(yn.join(y,"prebuilds")).map(XL),_=w.filter(QL(Jf,$f)).sort(eU)[0];if(_)return m(yn.join(y,"prebuilds",_.name))}function m(y){var w=K0(y).map(tU),_=w.filter(rU(C0,O0)),A=_.sort(nU(C0))[0];if(A)return yn.join(y,A.file)}};function K0(t){try{return Zie.readdirSync(t)}catch{return[]}}function VL(t,e){var r=K0(t).filter(e);return r[0]&&yn.join(t,r[0])}function BL(t){return/\.node$/.test(t)}function XL(t){var e=t.split("-");if(e.length===2){var r=e[0],i=e[1].split("+");if(r&&i.length&&i.every(Boolean))return{name:t,platform:r,architectures:i}}}function QL(t,e){return function(r){return r==null||r.platform!==t?!1:r.architectures.includes(e)}}function eU(t,e){return t.architectures.length-e.architectures.length}function tU(t){var e=t.split("."),r=e.pop(),i={file:t,specificity:0};if(r==="node"){for(var n=0;n<e.length;n++){var o=e[n];if(o==="node"||o==="electron"||o==="node-webkit")i.runtime=o;else if(o==="napi")i.napi=!0;else if(o.slice(0,3)==="abi")i.abi=o.slice(3);else if(o.slice(0,2)==="uv")i.uv=o.slice(2);else if(o.slice(0,4)==="armv")i.armv=o.slice(4);else if(o==="glibc"||o==="musl")i.libc=o;else continue;i.specificity++}return i}}function rU(t,e){return function(r){return!(r==null||r.runtime!==t&&!Qie(r)||r.abi!==e&&!r.napi||r.uv&&r.uv!==YL||r.armv&&r.armv!==A0||r.libc&&r.libc!==HL)}}function Qie(t){return t.runtime==="node"&&t.napi}function nU(t){return function(e,r){return e.runtime!==r.runtime?e.runtime===t?-1:1:e.abi!==r.abi?e.abi?-1:1:e.specificity!==r.specificity?e.specificity>r.specificity?-1:1:0}}function eoe(){return!!(process.versions&&process.versions.nw)}function toe(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<"u"&&window.process&&window.process.type==="renderer"}function roe(t){if(t!=="linux")return!1;let{familySync:e,MUSL:r}=GL();return e()===r}Un.parseTags=tU;Un.matchTags=rU;Un.compareTags=nU;Un.parseTuple=XL;Un.matchTuple=QL;Un.compareTuples=eU});var sU=h((_ke,j0)=>{var D0=typeof __webpack_require__=="function"?__non_webpack_require__:U;typeof D0.addon=="function"?j0.exports=D0.addon.bind(D0):j0.exports=oU()});var lU=h((Cke,aU)=>{aU.exports=sU()(__dirname)});var $U=h(Oe=>{"use strict";var xU=U("stream"),noe=U("module"),L0;try{L0=new TextDecoder}catch{}var J,Kr,g=0,U0=[],Xo=U0,nu=0,je={},Ie,li,Ar=0,tn=0,Tt,ci,Yt=[],we,cU={useRecords:!1,mapsAsObjects:!0},Gf=class{},$0=new Gf;$0.name="MessagePack 0xC1";var Gi=!1,uU=2,ui=class t{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,r){if(J)return RU(()=>(Bf(),this?this.unpack(e,r):t.prototype.unpack.call(cU,e,r)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof r=="object"?(Kr=r.end||e.length,g=r.start||0):(g=0,Kr=r>-1?r:e.length),nu=0,tn=0,li=null,Xo=U0,Tt=null,J=e;try{we=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw J=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof t){if(je=this,this.structures)return Ie=this.structures,Ff(r);(!Ie||Ie.length>0)&&(Ie=[])}else je=cU,(!Ie||Ie.length>0)&&(Ie=[]);return Ff(r)}unpackMultiple(e,r){let i,n=0;try{Gi=!0;let o=e.length,s=this?this.unpack(e,o):Qf.unpack(e,o);if(r){if(r(s,n,g)===!1)return;for(;g<o;)if(n=g,r(Ff(),n,g)===!1)return}else{for(i=[s];g<o;)n=g,i.push(Ff());return i}}catch(o){throw o.lastPosition=n,o.values=i,o}finally{Gi=!1,Bf()}}_mergeStructures(e,r){this._onLoadedStructures&&(e=this._onLoadedStructures(e)),e=e||[],Object.isFrozen(e)&&(e=e.map(i=>i.slice(0)));for(let i=0,n=e.length;i<n;i++){let o=e[i];o&&(o.isShared=!0,i>=32&&(o.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in r||[])if(i>=0){let n=e[i],o=r[i];o&&(n&&((e.restoreStructures||(e.restoreStructures=[]))[i]=n),e[i]=o)}return this.structures=e}decode(e,r){return this.unpack(e,r)}};function Ff(t){try{if(!je.trusted&&!Gi){let r=Ie.sharedLength||0;r<Ie.length&&(Ie.length=r)}let e;if(je._readStruct&&J[g]<64&&J[g]>=32?(e=je._readStruct(J,g,Kr),J=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),g=Kr):e=ft(),Tt&&(g=Tt.postBundlePosition,Tt=null),Gi&&(Ie.restoreStructures=null),g==Kr)Ie&&Ie.restoreStructures&&dU(),Ie=null,J=null,ci&&(ci=null);else{if(g>Kr)throw new Error("Unexpected end of MessagePack data");if(!Gi){let r;try{r=JSON.stringify(e,(i,n)=>typeof n=="bigint"?`${n}n`:n).slice(0,100)}catch(i){r="(JSON view not available "+i+")"}throw new Error("Data read, but end of buffer not reached "+r)}}return e}catch(e){throw Ie&&Ie.restoreStructures&&dU(),Bf(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||g>Kr)&&(e.incomplete=!0),e}}function dU(){for(let t in Ie.restoreStructures)Ie[t]=Ie.restoreStructures[t];Ie.restoreStructures=null}function ft(){let t=J[g++];if(t<160)if(t<128){if(t<64)return t;{let e=Ie[t&63]||je.getStructures&&IU()[t&63];return e?(e.read||(e.read=J0(e,t&63)),e.read()):t}}else if(t<144)if(t-=128,je.mapsAsObjects){let e={};for(let r=0;r<t;r++){let i=OU();i==="__proto__"&&(i="__proto_"),e[i]=ft()}return e}else{let e=new Map;for(let r=0;r<t;r++)e.set(ft(),ft());return e}else{t-=144;let e=new Array(t);for(let r=0;r<t;r++)e[r]=ft();return je.freezeData?Object.freeze(e):e}else if(t<192){let e=t-160;if(tn>=g)return li.slice(g-Ar,(g+=e)-Ar);if(tn==0&&Kr<140){let r=e<16?F0(e):CU(e);if(r!=null)return r}return Vf(e)}else{let e;switch(t){case 192:return null;case 193:return Tt?(e=ft(),e>0?Tt[1].slice(Tt.position1,Tt.position1+=e):Tt[0].slice(Tt.position0,Tt.position0-=e)):$0;case 194:return!1;case 195:return!0;case 196:if(e=J[g++],e===void 0)throw new Error("Unexpected end of buffer");return P0(e);case 197:return e=we.getUint16(g),g+=2,P0(e);case 198:return e=we.getUint32(g),g+=4,P0(e);case 199:return Yo(J[g++]);case 200:return e=we.getUint16(g),g+=2,Yo(e);case 201:return e=we.getUint32(g),g+=4,Yo(e);case 202:if(e=we.getFloat32(g),je.useFloat32>2){let r=Xf[(J[g]&127)<<1|J[g+1]>>7];return g+=4,(r*e+(e>0?.5:-.5)>>0)/r}return g+=4,e;case 203:return e=we.getFloat64(g),g+=8,e;case 204:return J[g++];case 205:return e=we.getUint16(g),g+=2,e;case 206:return e=we.getUint32(g),g+=4,e;case 207:return je.int64AsType==="number"?(e=we.getUint32(g)*4294967296,e+=we.getUint32(g+4)):je.int64AsType==="string"?e=we.getBigUint64(g).toString():je.int64AsType==="auto"?(e=we.getBigUint64(g),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=we.getBigUint64(g),g+=8,e;case 208:return we.getInt8(g++);case 209:return e=we.getInt16(g),g+=2,e;case 210:return e=we.getInt32(g),g+=4,e;case 211:return je.int64AsType==="number"?(e=we.getInt32(g)*4294967296,e+=we.getUint32(g+4)):je.int64AsType==="string"?e=we.getBigInt64(g).toString():je.int64AsType==="auto"?(e=we.getBigInt64(g),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=we.getBigInt64(g),g+=8,e;case 212:if(e=J[g++],e==114)return gU(J[g++]&63);{let r=Yt[e];if(r)return r.read?(g++,r.read(ft())):r.noBuffer?(g++,r()):r(J.subarray(g,++g));throw new Error("Unknown extension "+e)}case 213:return e=J[g],e==114?(g++,gU(J[g++]&63,J[g++])):Yo(2);case 214:return Yo(4);case 215:return Yo(8);case 216:return Yo(16);case 217:return e=J[g++],tn>=g?li.slice(g-Ar,(g+=e)-Ar):kU(e);case 218:return e=we.getUint16(g),g+=2,tn>=g?li.slice(g-Ar,(g+=e)-Ar):_U(e);case 219:return e=we.getUint32(g),g+=4,tn>=g?li.slice(g-Ar,(g+=e)-Ar):TU(e);case 220:return e=we.getUint16(g),g+=2,fU(e);case 221:return e=we.getUint32(g),g+=4,fU(e);case 222:return e=we.getUint16(g),g+=2,mU(e);case 223:return e=we.getUint32(g),g+=4,mU(e);default:if(t>=224)return t-256;if(t===void 0){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}throw new Error("Unknown MessagePack token "+t)}}}var ioe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function J0(t,e){function r(){if(r.count++>uU){let n;try{n=t.read=new Function("r","return function(){return "+(je.freezeData?"Object.freeze":"")+"({"+t.map(o=>o==="__proto__"?"__proto_:r()":ioe.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"})}")(ft)}catch{return uU=1/0,r()}return t.read0=n,t.highByte===0&&(t.read=pU(e,t.read)),n()}let i={};for(let n=0,o=t.length;n<o;n++){let s=t[n];s==="__proto__"&&(s="__proto_"),i[s]=ft()}return je.freezeData?Object.freeze(i):i}return r.count=0,t.read0=r,t.highByte===0?pU(e,r):r}var pU=(t,e)=>function(){let r=J[g++];if(r===0)return e();let i=t<32?-(t+(r<<5)):t+(r<<5),n=Ie[i]||IU()[i];if(!n)throw new Error("Record id is not defined for "+i);return n.read||(n.read=J0(n,t)),n.read()};function IU(){let t=RU(()=>(J=null,je.getStructures()));return Ie=je._mergeStructures(t,Ie)}var Vf=ja,kU=ja,_U=ja,TU=ja;Oe.isNativeAccelerationEnabled=!1;function ooe(t){Oe.isNativeAccelerationEnabled=!0,Vf=e(1),kU=e(2),_U=e(3),TU=e(5);function e(r){return function(n){let o=Xo[nu++];if(o==null){if(Tt)return ja(n);let a=J.byteOffset,l=t(g-r+a,Kr+a,J.buffer);if(typeof l=="string")o=l,Xo=U0;else if(Xo=l,nu=1,tn=1,o=Xo[0],o===void 0)throw new Error("Unexpected end of buffer")}let s=o.length;return s<=n?(g+=n,o):(li=o,Ar=g,tn=g+s,g+=n,o.slice(0,n))}}}function ja(t){let e;if(t<16&&(e=F0(t)))return e;if(t>64&&L0)return L0.decode(J.subarray(g,g+=t));let r=g+t,i=[];for(e="";g<r;){let n=J[g++];if((n&128)===0)i.push(n);else if((n&224)===192){let o=J[g++]&63,s=(n&31)<<6|o;s<128?i.push(65533):i.push(s)}else if((n&240)===224){let o=J[g++]&63,s=J[g++]&63,a=(n&31)<<12|o<<6|s;a<2048||a>=55296&&a<=57343?i.push(65533):i.push(a)}else if((n&248)===240){let o=J[g++]&63,s=J[g++]&63,a=J[g++]&63,l=(n&7)<<18|o<<12|s<<6|a;l<65536||l>1114111?i.push(65533):(l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|l&1023),i.push(l))}else i.push(65533);i.length>=4096&&(e+=Rt.apply(String,i),i.length=0)}return i.length>0&&(e+=Rt.apply(String,i)),e}function fU(t){let e=new Array(t);for(let r=0;r<t;r++)e[r]=ft();return je.freezeData?Object.freeze(e):e}function mU(t){if(je.mapsAsObjects){let e={};for(let r=0;r<t;r++){let i=OU();i==="__proto__"&&(i="__proto_"),e[i]=ft()}return e}else{let e=new Map;for(let r=0;r<t;r++)e.set(ft(),ft());return e}}var Rt=String.fromCharCode;function CU(t){let e=g,r=new Array(t);for(let i=0;i<t;i++){let n=J[g++];if((n&128)>0){g=e;return}r[i]=n}return Rt.apply(String,r)}function F0(t){if(t<4)if(t<2){if(t===0)return"";{let e=J[g++];if((e&128)>1){g-=1;return}return Rt(e)}}else{let e=J[g++],r=J[g++];if((e&128)>0||(r&128)>0){g-=2;return}if(t<3)return Rt(e,r);let i=J[g++];if((i&128)>0){g-=3;return}return Rt(e,r,i)}else{let e=J[g++],r=J[g++],i=J[g++],n=J[g++];if((e&128)>0||(r&128)>0||(i&128)>0||(n&128)>0){g-=4;return}if(t<6){if(t===4)return Rt(e,r,i,n);{let o=J[g++];if((o&128)>0){g-=5;return}return Rt(e,r,i,n,o)}}else if(t<8){let o=J[g++],s=J[g++];if((o&128)>0||(s&128)>0){g-=6;return}if(t<7)return Rt(e,r,i,n,o,s);let a=J[g++];if((a&128)>0){g-=7;return}return Rt(e,r,i,n,o,s,a)}else{let o=J[g++],s=J[g++],a=J[g++],l=J[g++];if((o&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){g-=8;return}if(t<10){if(t===8)return Rt(e,r,i,n,o,s,a,l);{let c=J[g++];if((c&128)>0){g-=9;return}return Rt(e,r,i,n,o,s,a,l,c)}}else if(t<12){let c=J[g++],u=J[g++];if((c&128)>0||(u&128)>0){g-=10;return}if(t<11)return Rt(e,r,i,n,o,s,a,l,c,u);let d=J[g++];if((d&128)>0){g-=11;return}return Rt(e,r,i,n,o,s,a,l,c,u,d)}else{let c=J[g++],u=J[g++],d=J[g++],f=J[g++];if((c&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){g-=12;return}if(t<14){if(t===12)return Rt(e,r,i,n,o,s,a,l,c,u,d,f);{let p=J[g++];if((p&128)>0){g-=13;return}return Rt(e,r,i,n,o,s,a,l,c,u,d,f,p)}}else{let p=J[g++],m=J[g++];if((p&128)>0||(m&128)>0){g-=14;return}if(t<15)return Rt(e,r,i,n,o,s,a,l,c,u,d,f,p,m);let y=J[g++];if((y&128)>0){g-=15;return}return Rt(e,r,i,n,o,s,a,l,c,u,d,f,p,m,y)}}}}}function hU(){let t=J[g++],e;if(t<192)e=t-160;else switch(t){case 217:e=J[g++];break;case 218:e=we.getUint16(g),g+=2;break;case 219:e=we.getUint32(g),g+=4;break;default:throw new Error("Expected string")}return ja(e)}function P0(t){return je.copyBuffers?Uint8Array.prototype.slice.call(J,g,g+=t):J.subarray(g,g+=t)}function Yo(t){let e=J[g++];if(Yt[e]){let r;return Yt[e](J.subarray(g,r=g+=t),i=>{g=i;try{return ft()}finally{g=r}})}else throw new Error("Unknown extension type "+e)}var yU=new Array(4096);function OU(){let t=J[g++];if(t>=160&&t<192){if(t=t-160,tn>=g)return li.slice(g-Ar,(g+=t)-Ar);if(!(tn==0&&Kr<180))return Vf(t)}else return g--,AU(ft());let e=(t<<5^(t>1?we.getUint16(g):t>0?J[g]:0))&4095,r=yU[e],i=g,n=g+t-3,o,s=0;if(r&&r.bytes==t){for(;i<n;){if(o=we.getUint32(i),o!=r[s++]){i=1879048192;break}i+=4}for(n+=3;i<n;)if(o=J[i++],o!=r[s++]){i=1879048192;break}if(i===n)return g=i,r.string;n-=3,i=g}for(r=[],yU[e]=r,r.bytes=t;i<n;)o=we.getUint32(i),r.push(o),i+=4;for(n+=3;i<n;)o=J[i++],r.push(o);let a=t<16?F0(t):CU(t);return a!=null?r.string=a:r.string=Vf(t)}function AU(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return t.toString();if(t==null)return t+"";if(je.allowArraysInMapKeys&&Array.isArray(t)&&t.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return t.flat().toString();throw new Error(`Invalid property type for record: ${typeof t}`)}var gU=(t,e)=>{let r=ft().map(AU),i=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,r.highByte=e);let n=Ie[t];return n&&(n.isShared||Gi)&&((Ie.restoreStructures||(Ie.restoreStructures=[]))[t]=n),Ie[t]=r,r.read=J0(r,i),(r.read0||r.read)()};Yt[0]=()=>{};Yt[0].noBuffer=!0;Yt[66]=t=>{let e=t.byteLength%8||8,r=BigInt(t[0]&128?t[0]-256:t[0]);for(let i=1;i<e;i++)r<<=BigInt(8),r+=BigInt(t[i]);if(t.byteLength!==e){let i=new DataView(t.buffer,t.byteOffset,t.byteLength),n=(o,s)=>{let a=s-o;if(a<=40){let d=i.getBigUint64(o);for(let f=o+8;f<s;f+=8)d<<=BigInt(64),d|=i.getBigUint64(f);return d}let l=o+(a>>4<<3),c=n(o,l),u=n(l,s);return c<<BigInt((s-l)*8)|u};r=r<<BigInt((i.byteLength-e)*8)|n(e,i.byteLength)}return r};var bU={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};Yt[101]=()=>{let t=ft();if(!bU[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return bU[t[0]](t[1],{cause:t[2]})};Yt[105]=t=>{if(je.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=we.getUint32(g-4);ci||(ci=new Map);let r=J[g],i;r>=144&&r<160||r==220||r==221?i=[]:r>=128&&r<144||r==222||r==223?i=new Map:(r>=199&&r<=201||r>=212&&r<=216)&&J[g+1]===115?i=new Set:i={};let n={target:i};ci.set(e,n);let o=ft();if(n.used)Object.assign(i,o);else return n.target=o;if(i instanceof Map)for(let[s,a]of o.entries())i.set(s,a);if(i instanceof Set)for(let s of Array.from(o))i.add(s);return i};Yt[112]=t=>{if(je.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=we.getUint32(g-4),r=ci.get(e);return r.used=!0,r.target};Yt[115]=()=>new Set(ft());var KU=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),soe=typeof globalThis=="object"?globalThis:window;Yt[116]=t=>{let e=t[0],r=Uint8Array.prototype.slice.call(t,1).buffer,i=KU[e];if(!i){if(e===16)return r;if(e===17)return new DataView(r);throw new Error("Could not find typed array for code "+e)}return new soe[i](r)};Yt[120]=()=>{let t=ft();return new RegExp(t[0],t[1])};var aoe=[];Yt[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],r=g;return g+=e-t.length,Tt=aoe,Tt=[hU(),hU()],Tt.position0=0,Tt.position1=0,Tt.postBundlePosition=g,g=r,ft()};Yt[255]=t=>t.length==4?new Date((t[0]*16777216+(t[1]<<16)+(t[2]<<8)+t[3])*1e3):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+((t[3]&3)*4294967296+t[4]*16777216+(t[5]<<16)+(t[6]<<8)+t[7])*1e3):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+((t[4]&128?-281474976710656:0)+t[6]*1099511627776+t[7]*4294967296+t[8]*16777216+(t[9]<<16)+(t[10]<<8)+t[11])*1e3):new Date("invalid");function RU(t){je&&je._onSaveState&&je._onSaveState();let e=Kr,r=g,i=nu,n=Ar,o=tn,s=li,a=Xo,l=ci,c=Tt,u=new Uint8Array(J.slice(0,Kr)),d=Ie,f=Ie.slice(0,Ie.length),p=je,m=Gi,y=t();return Kr=e,g=r,nu=i,Ar=n,tn=o,li=s,Xo=a,ci=l,Tt=c,J=u,Gi=m,Ie=d,Ie.splice(0,Ie.length,...f),je=p,we=new DataView(J.buffer,J.byteOffset,J.byteLength),y}function Bf(){J=null,ci=null,Ie=null}function loe(t){t.unpack?Yt[t.type]=t.unpack:Yt[t.type]=t}var Xf=new Array(147);for(let t=0;t<256;t++)Xf[t]=+("1e"+Math.floor(45.15-t*.30103));var coe=ui,Qf=new ui({useRecords:!1}),uoe=Qf.unpack,doe=Qf.unpackMultiple,poe=Qf.unpack,DU={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},jU=new Float32Array(1),vU=new Uint8Array(jU.buffer,0,4);function foe(t){jU[0]=t;let e=Xf[(vU[3]&127)<<1|vU[2]>>7];return(e*t+(t>0?.5:-.5)>>0)/e}ui.SUPPORTS_STRUCT_HOOKS=!0;var zf;try{zf=new TextEncoder}catch{}var Wf,Zf,Da=typeof Buffer<"u",qf=Da?function(t){return Buffer.allocUnsafeSlow(t)}:Uint8Array,PU=Da?Buffer:Uint8Array,SU=Da?4294967296:2144337920,x,ru,qe,v=0,Ht,st=null,moe=21760,hoe=/[\u0080-\uFFFF]/,Ra=Symbol("record-id"),di=class extends ui{constructor(e){super(e),this.offset=0;let r,i,n,o,s=PU.prototype.utf8Write?function(E,D){return x.utf8Write(E,D,x.byteLength-D)}:zf&&zf.encodeInto?function(E,D){return zf.encodeInto(E,x.subarray(D)).written}:!1,a=this;e||(e={});let l=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let d=e.maxOwnStructures;d==null&&(d=c?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let f=u>32||d+u>64,p=u+64,m=u+d+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],w=0,_=0;this.pack=this.encode=function(E,D){if(x||(x=new qf(8192),qe=x.dataView||(x.dataView=new DataView(x.buffer,0,8192)),v=0),Ht=x.length-10,Ht-v<2048?(x=new qf(x.length),qe=x.dataView||(x.dataView=new DataView(x.buffer,0,x.length)),Ht=x.length-10,v=0):v=v+7&2147483640,r=v,D&UU&&(v+=D&255),o=a.structuredClone?new Map:null,a.bundleStrings&&typeof E!="string"?(st=[],st.size=1/0):st=null,n=a.structures,n){n.uninitialized&&(n=a._mergeStructures(a.getStructures()));let j=n.sharedLength||0;if(j>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let P=0;P<j;P++){let Y=n[P];if(!Y)continue;let ee,H=n.transitions;for(let Ae=0,W=Y.length;Ae<W;Ae++){let _e=Y[Ae];ee=H[_e],ee||(ee=H[_e]=Object.create(null)),H=ee}H[Ra]=P+64}this.lastNamedStructuresLength=j}l||(n.nextId=j+64)}i&&(i=!1);let N;try{a._writeStruct&&E&&typeof E=="object"?E.constructor===Object?me(E):E.constructor!==Map&&!Array.isArray(E)&&!Zf.some(P=>E instanceof P)?me(E.toJSON?E.toJSON():E):C(E):C(E);let j=st;if(st&&wU(r,C,0),o&&o.idsToInsert){let P=o.idsToInsert.sort((Ae,W)=>Ae.offset>W.offset?1:-1),Y=P.length,ee=-1;for(;j&&Y>0;){let Ae=P[--Y].offset+r;Ae<j.stringsPosition+r&&ee===-1&&(ee=0),Ae>j.position+r?ee>=0&&(ee+=6):(ee>=0&&(qe.setUint32(j.position+r,qe.getUint32(j.position+r)+ee),ee=-1),j=j.previous,Y++)}ee>=0&&j&&qe.setUint32(j.position+r,qe.getUint32(j.position+r)+ee),v+=P.length*6,v>Ht&&fe(v),a.offset=v;let H=yoe(x.subarray(r,v),P);return o=null,H}return a.offset=v,D&NU?(x.start=r,x.end=v,x):x.subarray(r,v)}catch(j){throw N=j,j}finally{if(n&&(A(),i&&a.saveStructures)){let j=n.sharedLength||0,P=x.subarray(r,v),Y=(a._prepareStructures||boe)(n,a);if(!N)return a.saveStructures(Y,Y.isCompatible)===!1?(n.uninitialized=!0,a.pack(E,D)):(a.lastNamedStructuresLength=j,x.length>1073741824&&(x=null),P)}x.length>1073741824&&(x=null),D&LU&&(v=r)}};let A=()=>{_<10&&_++;let E=n.sharedLength||0;if(n.length>E&&!l&&(n.length=E),w>1e4)n.transitions=null,_=0,w=0,y.length>0&&(y=[]);else if(y.length>0&&!l){for(let D=0,N=y.length;D<N;D++)y[D][Ra]=0;y=[]}},O=E=>{var D=E.length;D<16?x[v++]=144|D:D<65536?(x[v++]=220,x[v++]=D>>8,x[v++]=D&255):(x[v++]=221,qe.setUint32(v,D),v+=4);for(let N=0;N<D;N++)C(E[N])},C=E=>{v>Ht&&(x=fe(v));var D=typeof E,N;if(D==="string"){let j=E.length;if(st&&j>=4&&j<4096){if((st.size+=j)>moe){let H,Ae=(st[0]?st[0].length*3+st[1].length:0)+10;v+Ae>Ht&&(x=fe(v+Ae));let W;st.position?(W=st,x[v]=200,v+=3,x[v++]=98,H=v-r,v+=4,wU(r,C,0),qe.setUint16(H+r-3,v-r-H)):(x[v++]=214,x[v++]=98,H=v-r,v+=4),st=["",""],st.previous=W,st.size=0,st.position=H}let ee=hoe.test(E);st[ee?0:1]+=E,x[v++]=193,C(ee?-j:j);return}let P;j<32?P=1:j<256?P=2:j<65536?P=3:P=5;let Y=j*3;if(v+Y>Ht&&(x=fe(v+Y)),j<64||!s){let ee,H,Ae,W=v+P;for(ee=0;ee<j;ee++)H=E.charCodeAt(ee),H<128?x[W++]=H:H<2048?(x[W++]=H>>6|192,x[W++]=H&63|128):(H&64512)===55296&&((Ae=E.charCodeAt(ee+1))&64512)===56320?(H=65536+((H&1023)<<10)+(Ae&1023),ee++,x[W++]=H>>18|240,x[W++]=H>>12&63|128,x[W++]=H>>6&63|128,x[W++]=H&63|128):(x[W++]=H>>12|224,x[W++]=H>>6&63|128,x[W++]=H&63|128);N=W-v-P}else N=s(E,v+P);N<32?x[v++]=160|N:N<256?(P<2&&x.copyWithin(v+2,v+1,v+1+N),x[v++]=217,x[v++]=N):N<65536?(P<3&&x.copyWithin(v+3,v+2,v+2+N),x[v++]=218,x[v++]=N>>8,x[v++]=N&255):(P<5&&x.copyWithin(v+5,v+3,v+3+N),x[v++]=219,qe.setUint32(v,N),v+=4),v+=N}else if(D==="number")if(E>>>0===E)E<32||E<128&&this.useRecords===!1||E<64&&!this._writeStruct?x[v++]=E:E<256?(x[v++]=204,x[v++]=E):E<65536?(x[v++]=205,x[v++]=E>>8,x[v++]=E&255):(x[v++]=206,qe.setUint32(v,E),v+=4);else if(E>>0===E)E>=-32?x[v++]=256+E:E>=-128?(x[v++]=208,x[v++]=E+256):E>=-32768?(x[v++]=209,qe.setInt16(v,E),v+=2):(x[v++]=210,qe.setInt32(v,E),v+=4);else{let j;if((j=this.useFloat32)>0&&E<4294967296&&E>=-2147483648){x[v++]=202,qe.setFloat32(v,E);let P;if(j<4||(P=E*Xf[(x[v]&127)<<1|x[v+1]>>7])>>0===P){v+=4;return}else v--}x[v++]=203,qe.setFloat64(v,E),v+=8}else if(D==="object"||D==="function")if(!E)x[v++]=192;else{if(o){let P=o.get(E);if(P){if(!P.id){let Y=o.idsToInsert||(o.idsToInsert=[]);P.id=Y.push(P)}x[v++]=214,x[v++]=112,qe.setUint32(v,P.id),v+=4;return}else o.set(E,{offset:v-r})}let j=E.constructor;if(j===Object)ve(E);else if(j===Array)O(E);else if(j===Map)if(this.mapAsEmptyObject)x[v++]=128;else{N=E.size,N<16?x[v++]=128|N:N<65536?(x[v++]=222,x[v++]=N>>8,x[v++]=N&255):(x[v++]=223,qe.setUint32(v,N),v+=4);for(let[P,Y]of E)C(P),C(Y)}else{for(let P=0,Y=Wf.length;P<Y;P++){let ee=Zf[P];if(E instanceof ee){let H=Wf[P];if(H.write){H.type&&(x[v++]=212,x[v++]=H.type,x[v++]=0);let Et=H.write.call(this,E);Et===E?Array.isArray(E)?O(E):ve(E):C(Et);return}let Ae=x,W=qe,_e=v;x=null;let Te;try{Te=H.pack.call(this,E,Et=>(x=Ae,Ae=null,v+=Et,v>Ht&&fe(v),{target:x,targetView:qe,position:v-Et}),C)}finally{Ae&&(x=Ae,qe=W,v=_e,Ht=x.length-10)}Te&&(Te.length+v>Ht&&fe(Te.length+v),v=EU(Te,x,v,H.type));return}}if(Array.isArray(E))O(E);else{if(E.toJSON){let P=E.toJSON();if(P!==E)return C(P)}if(D==="function")return C(this.writeFunction&&this.writeFunction(E));ve(E)}}}else if(D==="boolean")x[v++]=E?195:194;else if(D==="bigint"){if(E<9223372036854776e3&&E>=-9223372036854776e3)x[v++]=211,qe.setBigInt64(v,E);else if(E<18446744073709552e3&&E>0)x[v++]=207,qe.setBigUint64(v,E);else if(this.largeBigIntToFloat)x[v++]=203,qe.setFloat64(v,Number(E));else{if(this.largeBigIntToString)return C(E.toString());if(this.useBigIntExtension||this.moreTypes){let j=E<0?BigInt(-1):BigInt(0),P;if(E>>BigInt(65536)===j){let Y=BigInt(18446744073709552e3)-BigInt(1),ee=[];for(;ee.push(E&Y),E>>BigInt(63)!==j;)E>>=BigInt(64);P=new Uint8Array(new BigUint64Array(ee).buffer),P.reverse()}else{let Y=E<0,ee=(Y?~E:E).toString(16);if(ee.length%2?ee="0"+ee:parseInt(ee.charAt(0),16)>=8&&(ee="00"+ee),Da)P=Buffer.from(ee,"hex");else{P=new Uint8Array(ee.length/2);for(let H=0;H<P.length;H++)P[H]=parseInt(ee.slice(H*2,H*2+2),16)}if(Y)for(let H=0;H<P.length;H++)P[H]=~P[H]}P.length+v>Ht&&fe(P.length+v),v=EU(P,x,v,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")}v+=8}else if(D==="undefined")this.encodeUndefinedAsNil?x[v++]=192:(x[v++]=212,x[v++]=0,x[v++]=0);else throw new Error("Unknown type: "+D)},$=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?E=>{let D;if(this.skipValues){D=[];for(let P in E)(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(P))&&!this.skipValues.includes(E[P])&&D.push(P)}else D=Object.keys(E);let N=D.length;N<16?x[v++]=128|N:N<65536?(x[v++]=222,x[v++]=N>>8,x[v++]=N&255):(x[v++]=223,qe.setUint32(v,N),v+=4);let j;if(this.coercibleKeyAsNumber)for(let P=0;P<N;P++){j=D[P];let Y=Number(j);C(isNaN(Y)?j:Y),C(E[j])}else for(let P=0;P<N;P++)C(j=D[P]),C(E[j])}:E=>{x[v++]=222;let D=v-r;v+=2;let N=0;for(let j in E)(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(j))&&(C(j),C(E[j]),N++);if(N>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');x[D+++r]=N>>8,x[D+r]=N&255},re=this.useRecords===!1?$:e.progressiveRecords&&!f?E=>{let D,N=n.transitions||(n.transitions=Object.create(null)),j=v++-r,P;for(let Y in E)if(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(Y)){if(D=N[Y],D)N=D;else{let ee=Object.keys(E),H=N;N=n.transitions;let Ae=0;for(let W=0,_e=ee.length;W<_e;W++){let Te=ee[W];D=N[Te],D||(D=N[Te]=Object.create(null),Ae++),N=D}j+r+1==v?(v--,Ee(N,ee,Ae)):qr(N,ee,j,Ae),P=!0,N=H[Y]}C(E[Y])}if(!P){let Y=N[Ra];Y?x[j+r]=Y:qr(N,Object.keys(E),j,0)}}:E=>{let D,N=n.transitions||(n.transitions=Object.create(null)),j=0;for(let Y in E)(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(Y))&&(D=N[Y],D||(D=N[Y]=Object.create(null),j++),N=D);let P=N[Ra];P?P>=96&&f?(x[v++]=((P-=96)&31)+96,x[v++]=P>>5):x[v++]=P:Ee(N,N.__keys__||Object.keys(E),j);for(let Y in E)(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(Y))&&C(E[Y])},pe=typeof this.useRecords=="function"&&this.useRecords,ve=pe?E=>{pe(E)?re(E):$(E)}:re,me=E=>{let D=a._writeStruct(E,x,r,v,n,fe,(N,j,P)=>{if(P)return i=!0;v=j;let Y=x;return C(N),A(),Y!==x?{position:v,targetView:qe,target:x}:v});if(D===0)return ve(E);v=D},fe=E=>{let D;if(E>16777216){if(E-r>SU)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(SU,Math.round(Math.max((E-r)*(E>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(E-r<<2,x.length-1)>>12)+1<<12;let N=new qf(D);return qe=N.dataView||(N.dataView=new DataView(N.buffer,0,D)),E=Math.min(E,x.length),x.copy?x.copy(N,0,r,E):N.set(x.slice(r,E)),v-=r,r=0,Ht=N.length-10,x=N},Ee=(E,D,N)=>{let j=n.nextId;j||(j=64),j<p&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(j=n.nextOwnId,j<m||(j=p),n.nextOwnId=j+1):(j>=m&&(j=p),n.nextId=j+1);let P=D.highByte=j>=96&&f?j-96>>5:-1;E[Ra]=j,E.__keys__=D,n[j-64]=D,j<p?(D.isShared=!0,n.sharedLength=j-63,i=!0,P>=0?(x[v++]=(j&31)+96,x[v++]=P):x[v++]=j):(P>=0?(x[v++]=213,x[v++]=114,x[v++]=(j&31)+96,x[v++]=P):(x[v++]=212,x[v++]=114,x[v++]=j),N&&(w+=_*N),y.length>=d&&(y.shift()[Ra]=0),y.push(E),C(D))},qr=(E,D,N,j)=>{let P=x,Y=v,ee=Ht,H=r;x=ru,v=0,r=0,x||(ru=x=new qf(8192)),Ht=x.length-10,Ee(E,D,j),ru=x;let Ae=v;if(x=P,v=Y,Ht=ee,r=H,Ae>1){let W=v+Ae-1;W>Ht&&fe(W);let _e=N+r;x.copyWithin(_e+Ae,_e+1,v),x.set(ru.slice(0,Ae),_e),v=W}else x[N+r]=ru[0]}}useBuffer(e){x=e,x.dataView||(x.dataView=new DataView(x.buffer,x.byteOffset,x.byteLength)),qe=x.dataView,v=0}set position(e){v=e}get position(){return v}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};Zf=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Gf];Wf=[{pack(t,e,r){let i=t.getTime()/1e3;if((this.useTimestamp32||t.getMilliseconds()===0)&&i>=0&&i<4294967296){let{target:n,targetView:o,position:s}=e(6);n[s++]=214,n[s++]=255,o.setUint32(s,i)}else if(i>0&&i<4294967296){let{target:n,targetView:o,position:s}=e(10);n[s++]=215,n[s++]=255,o.setUint32(s,t.getMilliseconds()*4e6+(i/1e3/4294967296>>0)),o.setUint32(s+4,i)}else if(isNaN(i)){if(this.onInvalidDate)return e(0),r(this.onInvalidDate());let{target:n,targetView:o,position:s}=e(3);n[s++]=212,n[s++]=255,n[s++]=255}else{let{target:n,targetView:o,position:s}=e(15);n[s++]=199,n[s++]=12,n[s++]=255,o.setUint32(s,t.getMilliseconds()*1e6),o.setBigInt64(s+4,BigInt(Math.floor(i)))}}},{pack(t,e,r){if(this.setAsEmptyObject)return e(0),r({});let i=Array.from(t),{target:n,position:o}=e(this.moreTypes?3:0);this.moreTypes&&(n[o++]=212,n[o++]=115,n[o++]=0),r(i)}},{pack(t,e,r){let{target:i,position:n}=e(this.moreTypes?3:0);this.moreTypes&&(i[n++]=212,i[n++]=101,i[n++]=0),r([t.name,t.message,t.cause])}},{pack(t,e,r){let{target:i,position:n}=e(this.moreTypes?3:0);this.moreTypes&&(i[n++]=212,i[n++]=120,i[n++]=0),r([t.source,t.flags])}},{pack(t,e){this.moreTypes?M0(t,16,e):N0(Da?Buffer.from(t):new Uint8Array(t),e)}},{pack(t,e){let r=t.constructor;r!==PU&&this.moreTypes?M0(t,KU.indexOf(r.name),e):N0(t,e)}},{pack(t,e){this.moreTypes?M0(t,17,e):N0(Da?Buffer.from(t):new Uint8Array(t),e)}},{pack(t,e){let{target:r,position:i}=e(1);r[i]=193}}];function M0(t,e,r,i){let n=t.byteLength;if(n+1<256){var{target:o,position:s}=r(4+n);o[s++]=199,o[s++]=n+1}else if(n+1<65536){var{target:o,position:s}=r(5+n);o[s++]=200,o[s++]=n+1>>8,o[s++]=n+1&255}else{var{target:o,position:s,targetView:a}=r(7+n);o[s++]=201,a.setUint32(s,n+1),s+=4}o[s++]=116,o[s++]=e,t.buffer||(t=new Uint8Array(t)),o.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),s)}function N0(t,e){let r=t.byteLength;var i,n;if(r<256){var{target:i,position:n}=e(r+2);i[n++]=196,i[n++]=r}else if(r<65536){var{target:i,position:n}=e(r+3);i[n++]=197,i[n++]=r>>8,i[n++]=r&255}else{var{target:i,position:n,targetView:o}=e(r+5);i[n++]=198,o.setUint32(n,r),n+=4}i.set(t,n)}function EU(t,e,r,i){let n=t.length;switch(n){case 1:e[r++]=212;break;case 2:e[r++]=213;break;case 4:e[r++]=214;break;case 8:e[r++]=215;break;case 16:e[r++]=216;break;default:n<256?(e[r++]=199,e[r++]=n):n<65536?(e[r++]=200,e[r++]=n>>8,e[r++]=n&255):(e[r++]=201,e[r++]=n>>24,e[r++]=n>>16&255,e[r++]=n>>8&255,e[r++]=n&255)}return e[r++]=i,e.set(t,r),r+=n,r}function yoe(t,e){let r,i=e.length*6,n=t.length-i;for(;r=e.pop();){let o=r.offset,s=r.id;t.copyWithin(o+i,o,n),i-=6;let a=o+i;t[a++]=214,t[a++]=105,t[a++]=s>>24,t[a++]=s>>16&255,t[a++]=s>>8&255,t[a++]=s&255,n=o}return t}function wU(t,e,r){if(st.length>0){qe.setUint32(st.position+t,v+r-st.position-t),st.stringsPosition=v-t;let i=st;st=null,e(i[0]),e(i[1])}}function goe(t){if(t.Class){if(!t.pack&&!t.write)throw new Error("Extension has no pack or write function");if(t.pack&&!t.type)throw new Error("Extension has no type (numeric code to identify the extension)");Zf.unshift(t.Class),Wf.unshift(t)}loe(t)}function boe(t,e){return t.isCompatible=r=>{let i=!r||(e.lastNamedStructuresLength||0)===r.length;return i||e._mergeStructures(r),i},t}di.SUPPORTS_STRUCT_HOOKS=!0;var MU=new di({useRecords:!1}),voe=MU.pack,Soe=MU.pack,Eoe=di,{NEVER:woe,ALWAYS:xoe,DECIMAL_ROUND:Ioe,DECIMAL_FIT:koe}=DU,NU=512,LU=1024,UU=2048,Hf=class extends xU.Transform{constructor(e){e||(e={}),e.writableObjectMode=!0,super(e),e.sequential=!0,this.packr=e.packr||new di(e)}_transform(e,r,i){this.push(this.packr.pack(e)),i()}},Yf=class extends xU.Transform{constructor(e){e||(e={}),e.objectMode=!0,super(e),e.structures=[],this.maxIncompleteBufferSize=e.maxIncompleteBufferSize!==void 0?e.maxIncompleteBufferSize:67108864,this.unpackr=e.unpackr||new ui(e)}_transform(e,r,i){this.incompleteBuffer&&(e=Buffer.concat([this.incompleteBuffer,e]),this.incompleteBuffer=null);let n;try{n=this.unpackr.unpackMultiple(e)}catch(o){if(o.incomplete){let s=e.slice(o.lastPosition);if(s.length>this.maxIncompleteBufferSize)return this.incompleteBuffer=null,i(new Error("Maximum incomplete buffer size exceeded"));this.incompleteBuffer=s,n=o.values}else return i(o)}for(let o of n||[])o===null&&(o=this.getNullValue()),this.push(o);i()}getNullValue(){return Symbol.for(null)}};function _oe(t,e={}){if(!t||typeof t!="object")throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable");if(typeof t[Symbol.iterator]=="function")return Toe(t,e);if(typeof t.then=="function"||typeof t[Symbol.asyncIterator]=="function")return Coe(t,e);throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}function*Toe(t,e){let r=new di(e);for(let i of t)yield r.pack(i)}async function*Coe(t,e){let r=new di(e);for await(let i of t)yield r.pack(i)}function Ooe(t,e={}){if(!t||typeof t!="object")throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");let r=new ui(e),i,n=o=>{let s;i&&(o=Buffer.concat([i,o]),i=void 0);try{s=r.unpackMultiple(o)}catch(a){if(a.incomplete)i=o.slice(a.lastPosition),s=a.values;else throw a}return s};if(typeof t[Symbol.iterator]=="function")return(function*(){for(let s of t)yield*n(s)})();if(typeof t[Symbol.asyncIterator]=="function")return(async function*(){for await(let s of t)yield*n(s)})()}var Aoe=Ooe,Koe=_oe,Roe=!1,Doe=!0,joe=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!joe){let t;try{typeof U=="function"?t=lU():t=noe.createRequire(typeof document>"u"?new(U("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("node.cjs",document.baseURI).href)("msgpackr-extract"),t&&ooe(t.extractStrings)}catch{}}Oe.ALWAYS=xoe;Oe.C1=$0;Oe.DECIMAL_FIT=koe;Oe.DECIMAL_ROUND=Ioe;Oe.Decoder=coe;Oe.DecoderStream=Yf;Oe.Encoder=Eoe;Oe.EncoderStream=Hf;Oe.FLOAT32_OPTIONS=DU;Oe.NEVER=woe;Oe.Packr=di;Oe.PackrStream=Hf;Oe.RESERVE_START_SPACE=UU;Oe.RESET_BUFFER_MODE=LU;Oe.REUSE_BUFFER_MODE=NU;Oe.Unpackr=ui;Oe.UnpackrStream=Yf;Oe.addExtension=goe;Oe.clearSource=Bf;Oe.decode=poe;Oe.decodeIter=Aoe;Oe.encode=Soe;Oe.encodeIter=Koe;Oe.mapsAsObjects=Doe;Oe.pack=voe;Oe.roundFloat32=foe;Oe.unpack=uoe;Oe.unpackMultiple=doe;Oe.useRecords=Roe});var tm=h(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0});em.version=void 0;em.version="5.80.2"});var z0=h(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});iu.Scripts=void 0;iu.raw2NextJobData=rm;var Poe=$U(),Moe=new Poe.Packr({useRecords:!1,encodeUndefinedAsNil:!0}),Ct=Moe.pack,gn=gr(),Vi=Or(),Noe=tm(),Loe=Mf(),q0=class{constructor(e){this.queue=e,this.version=Noe.version;let r=this.queue.keys;this.moveToFinishedKeys=[r.wait,r.active,r.prioritized,r.events,r.stalled,r.limiter,r.delayed,r.paused,r.meta,r.pc,void 0,void 0,void 0,void 0]}execCommand(e,r,i){let n=`${r}:${this.version}`;return e.runCommand(n,i)}async isJobInList(e,r){let i=await this.queue.client,n;return(0,Vi.isRedisVersionLowerThan)(this.queue.redisVersion,"6.0.6",this.queue.databaseType)?n=await this.execCommand(i,"isJobInList",[e,r]):n=await i.lpos(e,r),Number.isInteger(n)}addDelayedJobArgs(e,r,i){let n=this.queue.keys,o=[n.marker,n.meta,n.id,n.delayed,n.completed,n.events];return o.push(Ct(i),e.data,r),o}addDelayedJob(e,r,i,n){let o=this.addDelayedJobArgs(r,i,n);return this.execCommand(e,"addDelayedJob",o)}addPrioritizedJobArgs(e,r,i){let n=this.queue.keys,o=[n.marker,n.meta,n.id,n.prioritized,n.delayed,n.completed,n.active,n.events,n.pc];return o.push(Ct(i),e.data,r),o}addPrioritizedJob(e,r,i,n){let o=this.addPrioritizedJobArgs(r,i,n);return this.execCommand(e,"addPrioritizedJob",o)}addParentJobArgs(e,r,i){let n=this.queue.keys,o=[n.meta,n.id,n.delayed,n["waiting-children"],n.completed,n.events];return o.push(Ct(i),e.data,r),o}addParentJob(e,r,i,n){let o=this.addParentJobArgs(r,i,n);return this.execCommand(e,"addParentJob",o)}addStandardJobArgs(e,r,i){let n=this.queue.keys,o=[n.wait,n.paused,n.meta,n.id,n.completed,n.delayed,n.active,n.events,n.marker];return o.push(Ct(i),e.data,r),o}addStandardJob(e,r,i,n){let o=this.addStandardJobArgs(r,i,n);return this.execCommand(e,"addStandardJob",o)}async addJob(e,r,i,n,o={}){let s=this.queue.keys,a=r.parent,l=[s[""],typeof n<"u"?n:"",r.name,r.timestamp,r.parentKey||null,o.parentDependenciesKey||null,a,r.repeatJobKey,r.deduplicationId?`${s.de}:${r.deduplicationId}`:null],c;if(i.repeat){let d=Object.assign({},i.repeat);d.startDate&&(d.startDate=+new Date(d.startDate)),d.endDate&&(d.endDate=+new Date(d.endDate)),c=Ct(Object.assign(Object.assign({},i),{repeat:d}))}else c=Ct(i);let u;if(o.addToWaitingChildren?u=await this.addParentJob(e,r,c,l):typeof i.delay=="number"&&i.delay>0?u=await this.addDelayedJob(e,r,c,l):i.priority?u=await this.addPrioritizedJob(e,r,c,l):u=await this.addStandardJob(e,r,c,l),u<0)throw this.finishedErrors({code:u,parentKey:o.parentKey,command:"addJob"});return u}pauseArgs(e){let r="wait",i="paused";e||(r="paused",i="wait");let n=[r,i,"meta","prioritized"].map(s=>this.queue.toKey(s));n.push(this.queue.keys.events,this.queue.keys.delayed,this.queue.keys.marker);let o=[e?"paused":"resumed"];return n.concat(o)}async pause(e){let r=await this.queue.client,i=this.pauseArgs(e);return this.execCommand(r,"pause",i)}addRepeatableJobArgs(e,r,i,n){let o=this.queue.keys,s=[o.repeat,o.delayed],a=[r,Ct(i),n,e,o[""]];return s.concat(a)}async addRepeatableJob(e,r,i,n){let o=await this.queue.client,s=this.addRepeatableJobArgs(e,r,i,n);return this.execCommand(o,"addRepeatableJob",s)}async removeDeduplicationKey(e,r){let i=await this.queue.client,o=[`${this.queue.keys.de}:${e}`],s=[r];return this.execCommand(i,"removeDeduplicationKey",o.concat(s))}async addJobScheduler(e,r,i,n,o,s,a){let l=await this.queue.client,c=this.queue.keys,u=[c.repeat,c.delayed,c.wait,c.paused,c.meta,c.prioritized,c.marker,c.id,c.events,c.pc,c.active],d=[r,Ct(o),e,i,Ct(n),Ct(s),Date.now(),c[""],a?this.queue.toKey(a):""],f=await this.execCommand(l,"addJobScheduler",u.concat(d));if(typeof f=="number"&&f<0)throw this.finishedErrors({code:f,command:"addJobScheduler"});return f}async updateRepeatableJobMillis(e,r,i,n){let o=[this.queue.keys.repeat,i,r,n];return this.execCommand(e,"updateRepeatableJobMillis",o)}async updateJobSchedulerNextMillis(e,r,i,n,o){let s=await this.queue.client,a=this.queue.keys,l=[a.repeat,a.delayed,a.wait,a.paused,a.meta,a.prioritized,a.marker,a.id,a.events,a.pc,o?this.queue.toKey(o):"",a.active],c=[r,e,i,Ct(n),Date.now(),a[""],o];return this.execCommand(s,"updateJobScheduler",l.concat(c))}removeRepeatableArgs(e,r,i){let n=this.queue.keys,o=[n.repeat,n.delayed,n.events],s=[e,this.getRepeatConcatOptions(r,i),i,n[""]];return o.concat(s)}getRepeatConcatOptions(e,r){return r&&r.split(":").length>2?r:e}async removeRepeatable(e,r,i){let n=await this.queue.client,o=this.removeRepeatableArgs(e,r,i);return this.execCommand(n,"removeRepeatable",o)}async removeJobScheduler(e){let r=await this.queue.client,i=this.queue.keys,n=[i.repeat,i.delayed,i.events],o=[e,i[""]];return this.execCommand(r,"removeJobScheduler",n.concat(o))}removeArgs(e,r){let i=[e,"repeat"].map(o=>this.queue.toKey(o)),n=[e,r?1:0,this.queue.toKey("")];return i.concat(n)}async remove(e,r){let i=await this.queue.client,n=this.removeArgs(e,r),o=await this.execCommand(i,"removeJob",n);if(o<0)throw this.finishedErrors({code:o,jobId:e,command:"removeJob"});return o}async removeUnprocessedChildren(e){let r=await this.queue.client,i=[this.queue.toKey(e),this.queue.keys.meta,this.queue.toKey(""),e];await this.execCommand(r,"removeUnprocessedChildren",i)}async extendLock(e,r,i,n){n=n||await this.queue.client;let o=[this.queue.toKey(e)+":lock",this.queue.keys.stalled,r,i,e];return this.execCommand(n,"extendLock",o)}async extendLocks(e,r,i){let n=await this.queue.client,o=[this.queue.keys.stalled,this.queue.toKey(""),Ct(r),Ct(e),i];return this.execCommand(n,"extendLocks",o)}async updateData(e,r){let i=await this.queue.client,n=[this.queue.toKey(e.id)],o=JSON.stringify(r),s=await this.execCommand(i,"updateData",n.concat([o]));if(s<0)throw this.finishedErrors({code:s,jobId:e.id,command:"updateData"})}async updateProgress(e,r){let i=await this.queue.client,n=[this.queue.toKey(e),this.queue.keys.events,this.queue.keys.meta],o=JSON.stringify(r),s=await this.execCommand(i,"updateProgress",n.concat([e,o]));if(s<0)throw this.finishedErrors({code:s,jobId:e,command:"updateProgress"})}async addLog(e,r,i){let n=await this.queue.client,o=[this.queue.toKey(e),this.queue.toKey(e)+":logs"],s=await this.execCommand(n,"addLog",o.concat([e,r,i||""]));if(s<0)throw this.finishedErrors({code:s,jobId:e,command:"addLog"});return s}moveToFinishedArgs(e,r,i,n,o,s,a,l=!0,c){var u,d,f,p,m,y,w;let _=this.queue.keys,A=this.queue.opts,O=o==="completed"?A.removeOnComplete:A.removeOnFail,C=this.queue.toKey(`metrics:${o}`),$=this.moveToFinishedKeys;$[10]=_[o],$[11]=this.queue.toKey((u=e.id)!==null&&u!==void 0?u:""),$[12]=C,$[13]=this.queue.keys.marker;let re=this.getKeepJobs(n,O),pe=[e.id,a,i,typeof r>"u"?"null":r,o,!l||this.queue.closing?0:1,_[""],Ct({token:s,name:A.name,keepJobs:re,limiter:A.limiter,lockDuration:A.lockDuration,attempts:e.opts.attempts,maxMetricsSize:!((d=A.metrics)===null||d===void 0)&&d.maxDataPoints?(f=A.metrics)===null||f===void 0?void 0:f.maxDataPoints:"",fpof:!!(!((p=e.opts)===null||p===void 0)&&p.failParentOnFailure),cpof:!!(!((m=e.opts)===null||m===void 0)&&m.continueParentOnFailure),idof:!!(!((y=e.opts)===null||y===void 0)&&y.ignoreDependencyOnFailure),rdof:!!(!((w=e.opts)===null||w===void 0)&&w.removeDependencyOnFailure)}),c?Ct((0,Vi.objectToFlatArray)(c)):void 0];return $.concat(pe)}getKeepJobs(e,r){return typeof e>"u"?r||{count:e?0:-1}:typeof e=="object"?e:typeof e=="number"?{count:e}:{count:e?0:-1}}async moveToFinished(e,r){let i=await this.queue.client,n=await this.execCommand(i,"moveToFinished",r);if(n<0)throw this.finishedErrors({code:n,jobId:e,command:"moveToFinished",state:"active"});if(typeof n<"u")return rm(n)}drainArgs(e){let r=this.queue.keys,i=[r.wait,r.paused,r.delayed,r.prioritized,r.repeat],n=[r[""],e?"1":"0"];return i.concat(n)}async drain(e){let r=await this.queue.client,i=this.drainArgs(e);return this.execCommand(r,"drain",i)}removeChildDependencyArgs(e,r){let n=[this.queue.keys[""]],o=[this.queue.toKey(e),r];return n.concat(o)}async removeChildDependency(e,r){let i=await this.queue.client,n=this.removeChildDependencyArgs(e,r),o=await this.execCommand(i,"removeChildDependency",n);switch(o){case 0:return!0;case 1:return!1;default:throw this.finishedErrors({code:o,jobId:e,parentKey:r,command:"removeChildDependency"})}}getRangesArgs(e,r,i,n){let o=this.queue.keys,s=e.map(c=>c==="waiting"?"wait":c),a=[o[""]],l=[r,i,n?"1":"0",...s];return a.concat(l)}async getRanges(e,r=0,i=1,n=!1){let o=await this.queue.client,s=this.getRangesArgs(e,r,i,n);return await this.execCommand(o,"getRanges",s)}getCountsArgs(e){let r=this.queue.keys,i=e.map(s=>s==="waiting"?"wait":s),n=[r[""]],o=[...i];return n.concat(o)}async getCounts(e){let r=await this.queue.client,i=this.getCountsArgs(e);return await this.execCommand(r,"getCounts",i)}getCountsPerPriorityArgs(e){let r=[this.queue.keys.wait,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.prioritized],i=e;return r.concat(i)}async getCountsPerPriority(e){let r=await this.queue.client,i=this.getCountsPerPriorityArgs(e);return await this.execCommand(r,"getCountsPerPriority",i)}getDependencyCountsArgs(e,r){let i=[`${e}:processed`,`${e}:dependencies`,`${e}:failed`,`${e}:unsuccessful`].map(o=>this.queue.toKey(o)),n=r;return i.concat(n)}async getDependencyCounts(e,r){let i=await this.queue.client,n=this.getDependencyCountsArgs(e,r);return await this.execCommand(i,"getDependencyCounts",n)}moveToCompletedArgs(e,r,i,n,o=!1){let s=Date.now();return this.moveToFinishedArgs(e,r,"returnvalue",i,"completed",n,s,o)}moveToFailedArgs(e,r,i,n,o=!1,s){let a=Date.now();return this.moveToFinishedArgs(e,r,"failedReason",i,"failed",n,a,o,s)}async isFinished(e,r=!1){let i=await this.queue.client,n=["completed","failed",e].map(o=>this.queue.toKey(o));return this.execCommand(i,"isFinished",n.concat([e,r?"1":""]))}async getState(e){let r=await this.queue.client,i=["completed","failed","delayed","active","wait","paused","waiting-children","prioritized"].map(n=>this.queue.toKey(n));return(0,Vi.isRedisVersionLowerThan)(this.queue.redisVersion,"6.0.6",this.queue.databaseType)?this.execCommand(r,"getState",i.concat([e])):this.execCommand(r,"getStateV2",i.concat([e]))}async changeDelay(e,r){let i=await this.queue.client,n=this.changeDelayArgs(e,r),o=await this.execCommand(i,"changeDelay",n);if(o<0)throw this.finishedErrors({code:o,jobId:e,command:"changeDelay",state:"delayed"})}changeDelayArgs(e,r){let i=Date.now();return[this.queue.keys.delayed,this.queue.keys.meta,this.queue.keys.marker,this.queue.keys.events].concat([r,JSON.stringify(i),e,this.queue.toKey(e)])}async changePriority(e,r=0,i=!1){let n=await this.queue.client,o=this.changePriorityArgs(e,r,i),s=await this.execCommand(n,"changePriority",o);if(s<0)throw this.finishedErrors({code:s,jobId:e,command:"changePriority"})}changePriorityArgs(e,r=0,i=!1){return[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].concat([r,this.queue.toKey(""),e,i?1:0])}moveToDelayedArgs(e,r,i,n,o={}){let s=this.queue.keys,a=this.queue.opts,l=[s.marker,s.active,s.prioritized,s.delayed,this.queue.toKey(e),s.events,s.meta,s.stalled,s.wait,s.limiter,s.paused,s.pc],c=o.fetchNext&&!this.queue.closing?1:0;return l.concat([this.queue.keys[""],r,e,i,n,o.skipAttempt?"1":"0",o.fieldsToUpdate?Ct((0,Vi.objectToFlatArray)(o.fieldsToUpdate)):void 0,c,c?Ct({token:i,lockDuration:a.lockDuration,limiter:a.limiter,name:a.name}):void 0])}moveToWaitingChildrenArgs(e,r,i){let n=Date.now(),o=(0,Vi.getParentKey)(i.child);return["active","waiting-children",e,`${e}:dependencies`,`${e}:unsuccessful`,"stalled","events"].map(a=>this.queue.toKey(a)).concat([r,o??"",JSON.stringify(n),e,this.queue.toKey("")])}isMaxedArgs(){let e=this.queue.keys;return[e.meta,e.active]}async isMaxed(){let e=await this.queue.client,r=this.isMaxedArgs();return!!await this.execCommand(e,"isMaxed",r)}async moveToDelayed(e,r,i,n="0",o={}){let s=await this.queue.client,a=this.moveToDelayedArgs(e,r,n,i,o),l=await this.execCommand(s,"moveToDelayed",a);if(l<0)throw this.finishedErrors({code:l,jobId:e,command:"moveToDelayed",state:"active"});if(typeof l<"u")return rm(l)}async moveToWaitingChildren(e,r,i={}){let n=await this.queue.client,o=this.moveToWaitingChildrenArgs(e,r,i),s=await this.execCommand(n,"moveToWaitingChildren",o);switch(s){case 0:return!0;case 1:return!1;default:throw this.finishedErrors({code:s,jobId:e,command:"moveToWaitingChildren",state:"active"})}}getRateLimitTtlArgs(e){return[this.queue.keys.limiter,this.queue.keys.meta].concat([e??"0"])}async getRateLimitTtl(e){let r=await this.queue.client,i=this.getRateLimitTtlArgs(e);return this.execCommand(r,"getRateLimitTtl",i)}async cleanJobsInSet(e,r,i=0){let n=await this.queue.client;return this.execCommand(n,"cleanJobsInSet",[this.queue.toKey(e),this.queue.toKey("events"),this.queue.toKey("repeat"),this.queue.toKey(""),r,i,e])}getJobSchedulerArgs(e){return[this.queue.keys.repeat].concat([e])}async getJobScheduler(e){let r=await this.queue.client,i=this.getJobSchedulerArgs(e);return this.execCommand(r,"getJobScheduler",i)}retryJobArgs(e,r,i,n={}){let o=[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],s=(r?"R":"L")+"PUSH";return o.concat([this.queue.toKey(""),Date.now(),s,e,i,n.fieldsToUpdate?Ct((0,Vi.objectToFlatArray)(n.fieldsToUpdate)):void 0])}async retryJob(e,r,i="0",n={}){let o=await this.queue.client,s=this.retryJobArgs(e,r,i,n),a=await this.execCommand(o,"retryJob",s);if(a<0)throw this.finishedErrors({code:a,jobId:e,command:"retryJob",state:"active"})}moveJobsToWaitArgs(e,r,i){let n=[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],o=[r,i,e];return n.concat(o)}async retryJobs(e="failed",r=1e3,i=new Date().getTime()){let n=await this.queue.client,o=this.moveJobsToWaitArgs(e,r,i);return this.execCommand(n,"moveJobsToWait",o)}async promoteJobs(e=1e3){let r=await this.queue.client,i=this.moveJobsToWaitArgs("delayed",e,Number.MAX_VALUE);return this.execCommand(r,"moveJobsToWait",i)}async reprocessJob(e,r,i={}){let n=await this.queue.client,o=[this.queue.toKey(e.id),this.queue.keys.events,this.queue.toKey(r),this.queue.keys.wait,this.queue.keys.meta,this.queue.keys.paused,this.queue.keys.active,this.queue.keys.marker],s=[e.id,(e.opts.lifo?"R":"L")+"PUSH",r==="failed"?"failedReason":"returnvalue",r,i.resetAttemptsMade?"1":"0",i.resetAttemptsStarted?"1":"0"],a=await this.execCommand(n,"reprocessJob",o.concat(s));if(a!==1)throw this.finishedErrors({code:a,jobId:e.id,command:"reprocessJob",state:r})}async getMetrics(e,r=0,i=-1){let n=await this.queue.client,o=[this.queue.toKey(`metrics:${e}`),this.queue.toKey(`metrics:${e}:data`)],s=[r,i];return await this.execCommand(n,"getMetrics",o.concat(s))}async moveToActive(e,r,i){let n=this.queue.opts,o=this.queue.keys,s=[o.wait,o.active,o.prioritized,o.events,o.stalled,o.limiter,o.delayed,o.paused,o.meta,o.pc,o.marker],a=[o[""],Date.now(),Ct({token:r,lockDuration:n.lockDuration,limiter:n.limiter,name:i})],l=await this.execCommand(e,"moveToActive",s.concat(a));return rm(l)}async promote(e){let r=await this.queue.client,i=[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],n=[this.queue.toKey(""),e],o=await this.execCommand(r,"promote",i.concat(n));if(o<0)throw this.finishedErrors({code:o,jobId:e,command:"promote",state:"delayed"})}moveStalledJobsToWaitArgs(){let e=this.queue.opts,r=[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,this.queue.keys.repeat],i=[e.maxStalledCount,this.queue.toKey(""),Date.now(),e.stalledInterval];return r.concat(i)}async moveStalledJobsToWait(){let e=await this.queue.client,r=this.moveStalledJobsToWaitArgs();return this.execCommand(e,"moveStalledJobsToWait",r)}async moveJobFromActiveToWait(e,r="0"){let i=await this.queue.client,n=[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],o=[e,r,this.queue.toKey(e)],s=await this.execCommand(i,"moveJobFromActiveToWait",n.concat(o));if(s<0)throw this.finishedErrors({code:s,jobId:e,command:"moveJobFromActiveToWait",state:"active"});return s}async obliterate(e){let r=await this.queue.client,i=[this.queue.keys.meta,this.queue.toKey("")],n=[e.count,e.force?"force":null],o=await this.execCommand(r,"obliterate",i.concat(n));if(o<0)switch(o){case-1:throw new Error("Cannot obliterate non-paused queue");case-2:throw new Error("Cannot obliterate queue with active jobs")}return o}async paginate(e,r){let i=await this.queue.client,n=[e],o=5,s=r.end>=0?r.end-r.start+1:1/0,a="0",l=0,c,u,d,f=[],p=[];do{let m=[r.start+f.length,r.end,a,l,o];r.fetchJobs&&m.push(1),[a,l,c,u,d]=await this.execCommand(i,"paginate",n.concat(m)),f=f.concat(c),d&&d.length&&(p=p.concat(d.map(Vi.array2obj)))}while(a!="0"&&f.length<s);if(f.length&&Array.isArray(f[0])){let m=[];for(let y=0;y<f.length;y++){let[w,_]=f[y];try{m.push({id:w,v:JSON.parse(_)})}catch(A){m.push({id:w,err:A.message})}}return{cursor:a,items:m,total:u,jobs:p}}else return{cursor:a,items:f.map(m=>({id:m})),total:u,jobs:p}}finishedErrors({code:e,jobId:r,parentKey:i,command:n,state:o}){let s;switch(e){case gn.ErrorCode.JobNotExist:s=new Error(`Missing key for job ${r}. ${n}`);break;case gn.ErrorCode.JobLockNotExist:s=new Error(`Missing lock for job ${r}. ${n}`);break;case gn.ErrorCode.JobNotInState:s=new Error(`Job ${r} is not in the ${o} state. ${n}`);break;case gn.ErrorCode.JobPendingChildren:s=new Error(`Job ${r} has pending dependencies. ${n}`);break;case gn.ErrorCode.ParentJobNotExist:s=new Error(`Missing key for parent job ${i}. ${n}`);break;case gn.ErrorCode.JobLockMismatch:s=new Error(`Lock mismatch for job ${r}. Cmd ${n} from ${o}`);break;case gn.ErrorCode.ParentJobCannotBeReplaced:s=new Error(`The parent job ${i} cannot be replaced. ${n}`);break;case gn.ErrorCode.JobBelongsToJobScheduler:s=new Error(`Job ${r} belongs to a job scheduler and cannot be removed directly. ${n}`);break;case gn.ErrorCode.JobHasFailedChildren:s=new Loe.UnrecoverableError(`Cannot complete job ${r} because it has at least one failed child. ${n}`);break;case gn.ErrorCode.SchedulerJobIdCollision:s=new Error(`Cannot create job scheduler iteration - job ID already exists. ${n}`);break;case gn.ErrorCode.SchedulerJobSlotsBusy:s=new Error(`Cannot create job scheduler iteration - current and next time slots already have jobs. ${n}`);break;default:s=new Error(`Unknown code ${e} error for ${r}. ${n}`)}return s.code=e,s}async removeOrphanedJobs(e,r,i){let n=await this.queue.client,o=[this.queue.toKey(""),r.length,...r,i.length,...i,...e];return this.execCommand(n,"removeOrphanedJobs",o)}};iu.Scripts=q0;function rm(t){if(t){let e=[null,t[1],t[2],t[3]];return t[0]&&(e[0]=(0,Vi.array2obj)(t[0])),e}return[]}});var im=h(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});nm.createScripts=void 0;var Uoe=z0(),$oe=t=>new Uoe.Scripts({keys:t.keys,client:t.client,get redisVersion(){return t.redisVersion},toKey:t.toKey,opts:t.opts,closing:t.closing,databaseType:t.databaseType});nm.createScripts=$oe});var Pa=h(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.Job=Bi.PRIORITY_LIMIT=void 0;var JU=(Zt(),Jt(Wt)),Joe=U("util"),cr=Or(),Foe=im(),FU=OE(),qoe=x0(),vr=gr(),zoe=(0,Joe.debuglog)("bull");Bi.PRIORITY_LIMIT=2**21-1;var G0=class t{constructor(e,r,i,n={},o){this.queue=e,this.name=r,this.data=i,this.opts=n,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;let s=this.opts,{repeatJobKey:a}=s,l=JU.__rest(s,["repeatJobKey"]);this.opts=Object.assign({attempts:0},l),this.delay=this.opts.delay,this.priority=this.opts.priority||0,this.repeatJobKey=a,this.timestamp=n.timestamp?n.timestamp:Date.now(),this.opts.backoff=FU.Backoffs.normalize(n.backoff),this.parentKey=(0,cr.getParentKey)(n.parent),n.parent&&(this.parent={id:n.parent.id,queueKey:n.parent.queue},n.failParentOnFailure&&(this.parent.fpof=!0),n.removeDependencyOnFailure&&(this.parent.rdof=!0),n.ignoreDependencyOnFailure&&(this.parent.idof=!0),n.continueParentOnFailure&&(this.parent.cpof=!0)),this.debounceId=n.debounce?n.debounce.id:void 0,this.deduplicationId=n.deduplication?n.deduplication.id:this.debounceId,this.toKey=e.toKey.bind(e),this.createScripts(),this.queueQualifiedName=e.qualifiedName}static async create(e,r,i,n){let o=await e.client,s=new this(e,r,i,n,n&&n.jobId);return s.id=await s.addJob(o,{parentKey:s.parentKey,parentDependenciesKey:s.parentKey?`${s.parentKey}:dependencies`:""}),s}static async createBulk(e,r){let i=await e.client,n=r.map(a=>{var l;return new this(e,a.name,a.data,a.opts,(l=a.opts)===null||l===void 0?void 0:l.jobId)}),o=i.pipeline();for(let a of n)a.addJob(o,{parentKey:a.parentKey,parentDependenciesKey:a.parentKey?`${a.parentKey}:dependencies`:""});let s=await o.exec();for(let a=0;a<s.length;++a){let[l,c]=s[a];if(l)throw l;n[a].id=c}return n}static fromJSON(e,r,i){let n=JSON.parse(r.data||"{}"),o=t.optsFromJSON(r.opts),s=new this(e,r.name,n,o,r.id||i);return s.progress=JSON.parse(r.progress||"0"),s.delay=parseInt(r.delay),s.priority=parseInt(r.priority),s.timestamp=parseInt(r.timestamp),r.finishedOn&&(s.finishedOn=parseInt(r.finishedOn)),r.processedOn&&(s.processedOn=parseInt(r.processedOn)),r.rjk&&(s.repeatJobKey=r.rjk),r.deid&&(s.debounceId=r.deid,s.deduplicationId=r.deid),r.failedReason&&(s.failedReason=r.failedReason),s.attemptsStarted=parseInt(r.ats||"0"),s.attemptsMade=parseInt(r.attemptsMade||r.atm||"0"),s.stalledCounter=parseInt(r.stc||"0"),r.defa&&(s.deferredFailure=r.defa),s.stacktrace=Goe(r.stacktrace),typeof r.returnvalue=="string"&&(s.returnvalue=qU(r.returnvalue)),r.parentKey?s.parentKey=r.parentKey:s.parentKey=void 0,r.parent?s.parent=JSON.parse(r.parent):s.parent=void 0,r.pb&&(s.processedBy=r.pb),r.nrjid&&(s.nextRepeatableJobId=r.nrjid),s}createScripts(){this.scripts=(0,Foe.createScripts)(this.queue)}static optsFromJSON(e,r=cr.optsDecodeMap){let i=JSON.parse(e||"{}"),n=Object.entries(i),o={};for(let s of n){let[a,l]=s;r[a]?o[r[a]]=l:a==="tm"?o.telemetry=Object.assign(Object.assign({},o.telemetry),{metadata:l}):a==="omc"?o.telemetry=Object.assign(Object.assign({},o.telemetry),{omitContext:l}):o[a]=l}return o}static async fromId(e,r){if(r){let n=await(await e.client).hgetall(e.toKey(r));return(0,cr.isEmpty)(n)?void 0:this.fromJSON(e,n,r)}}static addJobLog(e,r,i,n){return e.scripts.addLog(r,i,n)}toJSON(){let e=this,{queue:r,scripts:i}=e;return JU.__rest(e,["queue","scripts"])}asJSON(){return(0,cr.removeUndefinedFields)({id:this.id,name:this.name,data:JSON.stringify(typeof this.data>"u"?{}:this.data),opts:t.optsAsJSON(this.opts),parent:this.parent?Object.assign({},this.parent):void 0,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={},r=cr.optsEncodeMap){let i=Object.entries(e),n={};for(let[o,s]of i)if(!(typeof s>"u"))if(o in r){let l=r[o];n[l]=s}else o==="telemetry"?(s.metadata!==void 0&&(n.tm=s.metadata),s.omitContext!==void 0&&(n.omc=s.omitContext)):n[o]=s;return n}asJSONSandbox(){return Object.assign(Object.assign({},this.asJSON()),{queueName:this.queueName,queueQualifiedName:this.queueQualifiedName,prefix:this.prefix})}updateData(e){return this.data=e,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 t.addJobLog(this.queue,this.id,e,this.opts.keepLogs)}async removeChildDependency(){return await this.scripts.removeChildDependency(this.id,this.parentKey)?(this.parent=void 0,this.parentKey=void 0,!0):!1}async clearLogs(e){let r=await this.queue.client,i=this.toKey(this.id)+":logs";e?await r.ltrim(i,-e,-1):await r.del(i)}async remove({removeChildren:e=!0}={}){await this.queue.waitUntilReady();let r=this.queue,i=this;if(await this.scripts.remove(i.id,e))r.emit("removed",i);else throw new Error(`Job ${this.id} could not be removed because it is locked by another worker`)}async removeUnprocessedChildren(){let e=this.id;await this.scripts.removeUnprocessedChildren(e)}extendLock(e,r){return this.scripts.extendLock(this.id,e,r)}async moveToCompleted(e,r,i=!0){return this.queue.trace(vr.SpanKind.INTERNAL,"complete",this.queue.name,async n=>{this.setSpanJobAttributes(n),await this.queue.waitUntilReady(),this.returnvalue=e||void 0;let o=(0,cr.tryCatch)(JSON.stringify,JSON,[e]);if(o===cr.errorObject)throw cr.errorObject.value;let s=this.scripts.moveToCompletedArgs(this,o,this.opts.removeOnComplete,r,i),a=await this.scripts.moveToFinished(this.id,s);return this.finishedOn=s[this.scripts.moveToFinishedKeys.length+1],this.attemptsMade+=1,this.recordJobMetrics("completed"),a})}async moveToWait(e){let r=await this.scripts.moveJobFromActiveToWait(this.id,e);return this.recordJobMetrics("waiting"),r}async shouldRetryJob(e){if(this.attemptsMade+1<this.opts.attempts&&!this.discarded&&!(e instanceof qoe.UnrecoverableError||e.name=="UnrecoverableError")){let r=this.queue.opts,i=await FU.Backoffs.calculate(this.opts.backoff,this.attemptsMade+1,e,this,r.settings&&r.settings.backoffStrategy);return[i!=-1,i==-1?0:i]}else return[!1,0]}async moveToFailed(e,r,i=!1){this.failedReason=e?.message;let[n,o]=await this.shouldRetryJob(e);return this.queue.trace(vr.SpanKind.INTERNAL,this.getSpanOperation(n,o),this.queue.name,async(s,a)=>{var l,c;this.setSpanJobAttributes(s);let u;!(!((c=(l=this.opts)===null||l===void 0?void 0:l.telemetry)===null||c===void 0)&&c.omitContext)&&a&&(u=a);let d;this.updateStacktrace(e);let f={failedReason:this.failedReason,stacktrace:JSON.stringify(this.stacktrace),tm:u},p;if(n)o?(d=await this.scripts.moveToDelayed(this.id,Date.now(),o,r,{fieldsToUpdate:f,fetchNext:i}),this.recordJobMetrics("delayed")):(d=await this.scripts.retryJob(this.id,this.opts.lifo,r,{fieldsToUpdate:f}),this.recordJobMetrics("retried"));else{let m=this.scripts.moveToFailedArgs(this,this.failedReason,this.opts.removeOnFail,r,i,f);d=await this.scripts.moveToFinished(this.id,m),p=m[this.scripts.moveToFinishedKeys.length+1],this.recordJobMetrics("failed")}return p&&typeof p=="number"&&(this.finishedOn=p),o&&typeof o=="number"&&(this.delay=o),this.attemptsMade+=1,d})}getSpanOperation(e,r){return e?r?"delay":"retry":"fail"}recordJobMetrics(e){var r,i;let n=(i=(r=this.queue.opts)===null||r===void 0?void 0:r.telemetry)===null||i===void 0?void 0:i.meter;if(!n)return;let o={[vr.TelemetryAttributes.QueueName]:this.queue.name,[vr.TelemetryAttributes.JobName]:this.name,[vr.TelemetryAttributes.JobStatus]:e},a={completed:vr.MetricNames.JobsCompleted,failed:vr.MetricNames.JobsFailed,delayed:vr.MetricNames.JobsDelayed,retried:vr.MetricNames.JobsRetried,waiting:vr.MetricNames.JobsWaiting,"waiting-children":vr.MetricNames.JobsWaitingChildren}[e];if(n.createCounter(a,{description:`Number of jobs ${e}`,unit:"1"}).add(1,o),this.processedOn){let c=Date.now()-this.processedOn;n.createHistogram(vr.MetricNames.JobDuration,{description:"Job processing duration",unit:"ms"}).record(c,o)}}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(){let r=await(await this.queue.client).hgetall(this.toKey(`${this.id}:processed`));if(r)return(0,cr.parseObjectValues)(r)}async getIgnoredChildrenFailures(){return(await this.queue.client).hgetall(this.toKey(`${this.id}:failed`))}async getFailedChildrenValues(){return(await this.queue.client).hgetall(this.toKey(`${this.id}:failed`))}async getDependencies(e={}){let i=(await this.queue.client).pipeline();if(!e.processed&&!e.unprocessed&&!e.ignored&&!e.failed){i.hgetall(this.toKey(`${this.id}:processed`)),i.smembers(this.toKey(`${this.id}:dependencies`)),i.hgetall(this.toKey(`${this.id}:failed`)),i.zrange(this.toKey(`${this.id}:unsuccessful`),0,-1);let[[n,o],[s,a],[l,c],[u,d]]=await i.exec();return{processed:(0,cr.parseObjectValues)(o),unprocessed:a,failed:d,ignored:c}}else{let n={cursor:0,count:20},o=[];if(e.processed){o.push("processed");let y=Object.assign(Object.assign({},n),e.processed);i.hscan(this.toKey(`${this.id}:processed`),y.cursor,{COUNT:y.count})}if(e.unprocessed){o.push("unprocessed");let y=Object.assign(Object.assign({},n),e.unprocessed);i.sscan(this.toKey(`${this.id}:dependencies`),y.cursor,{COUNT:y.count})}if(e.ignored){o.push("ignored");let y=Object.assign(Object.assign({},n),e.ignored);i.hscan(this.toKey(`${this.id}:failed`),y.cursor,{COUNT:y.count})}let s;if(e.failed){o.push("failed");let y=Object.assign(Object.assign({},n),e.failed);s=y.cursor+y.count,i.zrange(this.toKey(`${this.id}:unsuccessful`),y.cursor,y.count-1)}let a=await i.exec(),l,c,u,d,f,p,m;return o.forEach((y,w)=>{switch(y){case"processed":{l=a[w][1][0];let _=a[w][1][1],A={};for(let O=0;O<_.length;++O)O%2&&(A[_[O-1]]=JSON.parse(_[O]));c=A;break}case"failed":{f=a[w][1];break}case"ignored":{p=a[w][1][0];let _=a[w][1][1],A={};for(let O=0;O<_.length;++O)O%2&&(A[_[O-1]]=_[O]);m=A;break}case"unprocessed":{u=a[w][1][0],d=a[w][1][1];break}}}),Object.assign(Object.assign(Object.assign(Object.assign({},l?{processed:c,nextProcessedCursor:Number(l)}:{}),p?{ignored:m,nextIgnoredCursor:Number(p)}:{}),s?{failed:f,nextFailedCursor:s}:{}),u?{unprocessed:d,nextUnprocessedCursor:Number(u)}:{})}}async getDependenciesCount(e={}){let r=[];Object.entries(e).forEach(([s,a])=>{a&&r.push(s)});let i=r.length?r:["processed","unprocessed","ignored","failed"],n=await this.scripts.getDependencyCounts(this.id,i),o={};return n.forEach((s,a)=>{o[`${i[a]}`]=s||0}),o}async waitUntilFinished(e,r){await this.queue.waitUntilReady();let i=this.id;return new Promise(async(n,o)=>{let s;r&&(s=setTimeout(()=>l(`Job wait ${this.name} timed out before finishing, no finish notification arrived after ${r}ms (id=${i})`),r));function a(y){d(),n(y.returnvalue)}function l(y){d(),o(new Error(y.failedReason||y))}let c=`completed:${i}`,u=`failed:${i}`;e.on(c,a),e.on(u,l),this.queue.on("closing",l);let d=()=>{clearInterval(s),e.removeListener(c,a),e.removeListener(u,l),this.queue.removeListener("closing",l)};await e.waitUntilReady();let[f,p]=await this.scripts.isFinished(i,!0);f!=0&&(f==-1||f==2?l({failedReason:p}):a({returnvalue:qU(p)}))})}async moveToDelayed(e,r){let i=Date.now(),n=e-i,o=n>0?n:0;await this.scripts.moveToDelayed(this.id,i,o,r,{skipAttempt:!0}),this.delay=o,this.recordJobMetrics("delayed")}async moveToWaitingChildren(e,r={}){let i=await this.scripts.moveToWaitingChildren(this.id,e,r);return i&&this.recordJobMetrics("waiting-children"),i}async promote(){let e=this.id;await this.scripts.promote(e),this.delay=0}async retry(e="failed",r={}){await this.scripts.reprocessJob(this,e,r),this.failedReason=null,this.finishedOn=null,this.processedOn=null,this.returnvalue=null,r.resetAttemptsMade&&(this.attemptsMade=0),r.resetAttemptsStarted&&(this.attemptsStarted=0)}discard(){this.discarded=!0}async isInZSet(e){return await(await this.queue.client).zscore(this.queue.toKey(e),this.id)!==null}async isInList(e){return this.scripts.isJobInList(this.queue.toKey(e),this.id)}addJob(e,r){let i=this.asJSON();return this.validateOptions(i),this.scripts.addJob(e,i,i.opts,this.id,r)}async removeDeduplicationKey(){return this.deduplicationId?await this.scripts.removeDeduplicationKey(this.deduplicationId,this.id)>0:!1}validateOptions(e){var r,i,n,o,s,a,l,c;let u=["removeDependencyOnFailure","failParentOnFailure","continueParentOnFailure","ignoreDependencyOnFailure"];if(this.opts.sizeLimit&&(0,cr.lengthInUtf8Bytes)(e.data)>this.opts.sizeLimit)throw new Error(`The size of job ${this.name} exceeds the limit ${this.opts.sizeLimit} bytes`);if(this.opts.delay&&this.opts.repeat&&!(!((r=this.opts.repeat)===null||r===void 0)&&r.count))throw new Error("Delay and repeat options cannot be used together");let f=u.filter(p=>this.opts[p]);if(f.length>1){let p=f.join(", ");throw new Error(`The following options cannot be used together: ${p}`)}if(!((i=this.opts)===null||i===void 0)&&i.jobId){if(`${parseInt(this.opts.jobId,10)}`===((n=this.opts)===null||n===void 0?void 0:n.jobId))throw new Error("Custom Id cannot be integers");if(!((o=this.opts)===null||o===void 0)&&o.jobId.includes(":")&&((a=(s=this.opts)===null||s===void 0?void 0:s.jobId)===null||a===void 0?void 0:a.split(":").length)!==3)throw new Error("Custom Id cannot contain :")}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>Bi.PRIORITY_LIMIT)throw new Error(`Priority should be between 0 and ${Bi.PRIORITY_LIMIT}`)}if(this.opts.deduplication){if(!(!((l=this.opts.deduplication)===null||l===void 0)&&l.id))throw new Error("Deduplication id must be provided");if(this.parentKey)throw new Error("Deduplication and parent options cannot be used together")}if(this.opts.debounce){if(!(!((c=this.opts.debounce)===null||c===void 0)&&c.id))throw new Error("Debounce id must be provided");if(this.parentKey)throw new Error("Debounce and parent options cannot be used together")}if(typeof this.opts.backoff=="object"&&typeof this.opts.backoff.jitter=="number"&&(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||[],e?.stack&&(this.stacktrace.push(e.stack),this.opts.stackTraceLimit===0?this.stacktrace=[]:this.opts.stackTraceLimit&&(this.stacktrace=this.stacktrace.slice(-this.opts.stackTraceLimit)))}setSpanJobAttributes(e){e?.setAttributes({[vr.TelemetryAttributes.JobName]:this.name,[vr.TelemetryAttributes.JobId]:this.id})}};Bi.Job=G0;function Goe(t){if(!t)return[];let e=(0,cr.tryCatch)(JSON.parse,JSON,[t]);return e===cr.errorObject||!(e instanceof Array)?[]:e}function qU(t){let e=(0,cr.tryCatch)(JSON.parse,JSON,[t]);if(e!==cr.errorObject)return e;zoe("corrupted returnvalue: "+t,e)}});var sm=h(om=>{"use strict";Object.defineProperty(om,"__esModule",{value:!0});om.QueueKeys=void 0;var V0=class{constructor(e="bull"){this.prefix=e}getKeys(e){let r={};return["","active","wait","waiting-children","paused","id","delayed","prioritized","stalled-check","completed","failed","stalled","repeat","limiter","meta","events","pc","marker","de"].forEach(i=>{r[i]=this.toKey(e,i)}),r}toKey(e,r){return`${this.getQueueQualifiedName(e)}:${r}`}getQueueQualifiedName(e){return`${this.prefix}:${e}`}};om.QueueKeys=V0});var zU=h((Mke,Voe)=>{Voe.exports={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},hexpireat:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hexpiretime:{arity:-5,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},hgetdel:{arity:-5,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hgetex:{arity:-5,flags:["write","fast"],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},hpersist:{arity:-5,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hpexpire:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hpexpireat:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hpexpiretime:{arity:-5,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hpttl:{arity:-5,flags:["readonly","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},hsetex:{arity:-6,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},httl:{arity:-5,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},xdelex:{arity:-5,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 Qo=h(Rr=>{"use strict";var Boe=Rr&&Rr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Rr,"__esModule",{value:!0});Rr.getKeyIndexes=Rr.hasFlag=Rr.exists=Rr.list=void 0;var am=Boe(zU());Rr.list=Object.keys(am.default);var B0={};Rr.list.forEach(t=>{B0[t]=am.default[t].flags.reduce(function(e,r){return e[r]=!0,e},{})});function Woe(t,e){return t=e?.caseInsensitive?String(t).toLowerCase():t,!!am.default[t]}Rr.exists=Woe;function Zoe(t,e,r){if(t=r?.nameCaseInsensitive?String(t).toLowerCase():t,!B0[t])throw new Error("Unknown command "+t);return!!B0[t][e]}Rr.hasFlag=Zoe;function Hoe(t,e,r){t=r?.nameCaseInsensitive?String(t).toLowerCase():t;let i=am.default[t];if(!i)throw new Error("Unknown command "+t);if(!Array.isArray(e))throw new Error("Expect args to be an array");let n=[],o=!!(r&&r.parseExternalKey),s=(l,c)=>{let u=[],d=Number(l[c]);for(let f=0;f<d;f++)u.push(f+c+1);return u},a=(l,c,u)=>{for(let d=c;d<l.length-1;d+=1)if(String(l[d]).toLowerCase()===u.toLowerCase())return d+1;return null};switch(t){case"zunionstore":case"zinterstore":case"zdiffstore":n.push(0,...s(e,1));break;case"eval":case"evalsha":case"eval_ro":case"evalsha_ro":case"fcall":case"fcall_ro":case"blmpop":case"bzmpop":n.push(...s(e,1));break;case"sintercard":case"lmpop":case"zunion":case"zinter":case"zmpop":case"zintercard":case"zdiff":{n.push(...s(e,0));break}case"georadius":{n.push(0);let l=a(e,5,"STORE");l&&n.push(l);let c=a(e,5,"STOREDIST");c&&n.push(c);break}case"georadiusbymember":{n.push(0);let l=a(e,4,"STORE");l&&n.push(l);let c=a(e,4,"STOREDIST");c&&n.push(c);break}case"sort":case"sort_ro":n.push(0);for(let l=1;l<e.length-1;l++){let c=e[l];if(typeof c!="string")continue;let u=c.toUpperCase();u==="GET"?(l+=1,c=e[l],c!=="#"&&(o?n.push([l,GU(c)]):n.push(l))):u==="BY"?(l+=1,o?n.push([l,GU(e[l])]):n.push(l)):u==="STORE"&&(l+=1,n.push(l))}break;case"migrate":if(e[2]==="")for(let l=5;l<e.length-1;l++){let c=e[l];if(typeof c=="string"&&c.toUpperCase()==="KEYS"){for(let u=l+1;u<e.length;u++)n.push(u);break}}else n.push(2);break;case"xreadgroup":case"xread":for(let l=t==="xread"?0:3;l<e.length-1;l++)if(String(e[l]).toUpperCase()==="STREAMS"){for(let c=l+1;c<=l+(e.length-1-l)/2;c++)n.push(c);break}break;default:if(i.step>0){let l=i.keyStart-1,c=i.keyStop>0?i.keyStop:e.length+i.keyStop+1;for(let u=l;u<c;u+=i.step)n.push(u)}break}return n}Rr.getKeyIndexes=Hoe;function GU(t){typeof t!="string"&&(t=String(t));let e=t.indexOf("->");return e===-1?t.length:e}});var VU=h(Wi=>{"use strict";Object.defineProperty(Wi,"__esModule",{value:!0});Wi.tryCatch=Wi.errorObj=void 0;Wi.errorObj={e:{}};var W0;function Yoe(t,e){try{let r=W0;return W0=null,r.apply(this,arguments)}catch(r){return Wi.errorObj.e=r,Wi.errorObj}}function Xoe(t){return W0=t,Yoe}Wi.tryCatch=Xoe});var Zi=h(Z0=>{"use strict";Object.defineProperty(Z0,"__esModule",{value:!0});var Ma=VU();function BU(t){setTimeout(function(){throw t},0)}function Qoe(t,e,r){return typeof e=="function"&&t.then(i=>{let n;r!==void 0&&Object(r).spread&&Array.isArray(i)?n=Ma.tryCatch(e).apply(void 0,[null].concat(i)):n=i===void 0?Ma.tryCatch(e)(null):Ma.tryCatch(e)(null,i),n===Ma.errorObj&&BU(n.e)},i=>{if(!i){let o=new Error(i+"");Object.assign(o,{cause:i}),i=o}let n=Ma.tryCatch(e)(i);n===Ma.errorObj&&BU(n.e)}),t}Z0.default=Qoe});var HU=h(($ke,ZU)=>{"use strict";var WU=U("assert"),ou=U("util");function Na(t){Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}ou.inherits(Na,Error);Object.defineProperty(Na.prototype,"name",{value:"RedisError",configurable:!0,writable:!0});function H0(t,e,r){WU(e),WU.strictEqual(typeof r,"number"),Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0});let i=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=i,this.offset=r,this.buffer=e}ou.inherits(H0,Na);Object.defineProperty(H0.prototype,"name",{value:"ParserError",configurable:!0,writable:!0});function Y0(t){Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0});let e=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=e}ou.inherits(Y0,Na);Object.defineProperty(Y0.prototype,"name",{value:"ReplyError",configurable:!0,writable:!0});function lm(t){Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}ou.inherits(lm,Na);Object.defineProperty(lm.prototype,"name",{value:"AbortError",configurable:!0,writable:!0});function X0(t){Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}ou.inherits(X0,lm);Object.defineProperty(X0.prototype,"name",{value:"InterruptError",configurable:!0,writable:!0});ZU.exports={RedisError:Na,ParserError:H0,ReplyError:Y0,AbortError:lm,InterruptError:X0}});var QU=h((Jke,XU)=>{"use strict";var YU=U("assert"),La=class extends Error{get name(){return this.constructor.name}},Q0=class extends La{constructor(e,r,i){YU(r),YU.strictEqual(typeof i,"number");let n=Error.stackTraceLimit;Error.stackTraceLimit=2,super(e),Error.stackTraceLimit=n,this.offset=i,this.buffer=r}get name(){return this.constructor.name}},ew=class extends La{constructor(e){let r=Error.stackTraceLimit;Error.stackTraceLimit=2,super(e),Error.stackTraceLimit=r}get name(){return this.constructor.name}},cm=class extends La{get name(){return this.constructor.name}},tw=class extends cm{get name(){return this.constructor.name}};XU.exports={RedisError:La,ParserError:Q0,ReplyError:ew,AbortError:cm,InterruptError:tw}});var es=h((Fke,e$)=>{"use strict";var ese=process.version.charCodeAt(1)<55&&process.version.charCodeAt(2)===46?HU():QU();e$.exports=ese});var su=h((qke,rw)=>{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],tse=function(e){for(var r,i=0,n=0,o=[],s=e.length;i<s;i++)r=e.charCodeAt(i),r<128?o[n++]=r:r<2048?(o[n++]=r>>6|192,o[n++]=r&63|128):(r&64512)===55296&&i+1<e.length&&(e.charCodeAt(i+1)&64512)===56320?(r=65536+((r&1023)<<10)+(e.charCodeAt(++i)&1023),o[n++]=r>>18|240,o[n++]=r>>12&63|128,o[n++]=r>>6&63|128,o[n++]=r&63|128):(o[n++]=r>>12|224,o[n++]=r>>6&63|128,o[n++]=r&63|128);return o},r$=rw.exports=function(e){for(var r,i=0,n=-1,o=0,s=0,a=typeof e=="string"?tse(e):e,l=a.length;i<l;){if(r=a[i++],n===-1)r===123&&(n=i);else if(r!==125)s=t$[(r^s>>8)&255]^s<<8;else if(i-1!==n)return s&16383;o=t$[(r^o>>8)&255]^o<<8}return o&16383};rw.exports.generateMulti=function(e){for(var r=1,i=e.length,n=r$(e[0]);r<i;)if(r$(e[r++])!==n)return-1;return n}});var n$=h(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.parseBlockOption=Ua.parseSecondsArgument=void 0;var nw=t=>{if(typeof t=="number")return t;if(Buffer.isBuffer(t))return nw(t.toString());if(typeof t=="string"){let e=Number(t);return Number.isFinite(e)?e:void 0}},rse=t=>{if(typeof t=="string")return t;if(Buffer.isBuffer(t))return t.toString()},nse=t=>{let e=nw(t);if(e!==void 0)return e<=0?0:e*1e3};Ua.parseSecondsArgument=nse;var ise=t=>{for(let e=0;e<t.length;e++){let r=rse(t[e]);if(r&&r.toLowerCase()==="block"){let i=nw(t[e+1]);return i===void 0?void 0:i<=0?0:i}}return null};Ua.parseBlockOption=ise});var pi=h(sw=>{"use strict";Object.defineProperty(sw,"__esModule",{value:!0});var i$=Qo(),ose=su(),sse=Zi(),ts=bt(),iw=n$(),$n=class t{constructor(e,r=[],i={},n){if(this.name=e,this.inTransaction=!1,this.isResolved=!1,this.transformed=!1,this.replyEncoding=i.replyEncoding,this.errorStack=i.errorStack,this.args=r.flat(),this.callback=n,this.initPromise(),i.keyPrefix){let o=i.keyPrefix instanceof Buffer,s=o?i.keyPrefix:null;this._iterateKeys(a=>a instanceof Buffer?(s===null&&(s=Buffer.from(i.keyPrefix)),Buffer.concat([s,a])):o?Buffer.concat([i.keyPrefix,Buffer.from(String(a))]):i.keyPrefix+a)}i.readOnly&&(this.isReadOnly=!0)}static checkFlag(e,r){return r=r.toLowerCase(),!!this.getFlagMap()[e][r]}static setArgumentTransformer(e,r){this._transformer.argument[e]=r}static setReplyTransformer(e,r){this._transformer.reply[e]=r}static getFlagMap(){return this.flagMap||(this.flagMap=Object.keys(t.FLAGS).reduce((e,r)=>(e[r]={},t.FLAGS[r].forEach(i=>{e[r][i]=!0}),e),{})),this.flagMap}getSlot(){if(typeof this.slot>"u"){let e=this.getKeys()[0];this.slot=e==null?null:ose(e)}return this.slot}getKeys(){return this._iterateKeys()}toWritable(e){let r,i="*"+(this.args.length+1)+`\r
1128
+ `),new Error(f);function p(y){var w=K0(yn.join(y,"prebuilds")).map(XL),_=w.filter(QL(Jf,$f)).sort(eU)[0];if(_)return m(yn.join(y,"prebuilds",_.name))}function m(y){var w=K0(y).map(tU),_=w.filter(rU(C0,O0)),A=_.sort(nU(C0))[0];if(A)return yn.join(y,A.file)}};function K0(t){try{return Zie.readdirSync(t)}catch{return[]}}function VL(t,e){var r=K0(t).filter(e);return r[0]&&yn.join(t,r[0])}function BL(t){return/\.node$/.test(t)}function XL(t){var e=t.split("-");if(e.length===2){var r=e[0],i=e[1].split("+");if(r&&i.length&&i.every(Boolean))return{name:t,platform:r,architectures:i}}}function QL(t,e){return function(r){return r==null||r.platform!==t?!1:r.architectures.includes(e)}}function eU(t,e){return t.architectures.length-e.architectures.length}function tU(t){var e=t.split("."),r=e.pop(),i={file:t,specificity:0};if(r==="node"){for(var n=0;n<e.length;n++){var o=e[n];if(o==="node"||o==="electron"||o==="node-webkit")i.runtime=o;else if(o==="napi")i.napi=!0;else if(o.slice(0,3)==="abi")i.abi=o.slice(3);else if(o.slice(0,2)==="uv")i.uv=o.slice(2);else if(o.slice(0,4)==="armv")i.armv=o.slice(4);else if(o==="glibc"||o==="musl")i.libc=o;else continue;i.specificity++}return i}}function rU(t,e){return function(r){return!(r==null||r.runtime!==t&&!Qie(r)||r.abi!==e&&!r.napi||r.uv&&r.uv!==YL||r.armv&&r.armv!==A0||r.libc&&r.libc!==HL)}}function Qie(t){return t.runtime==="node"&&t.napi}function nU(t){return function(e,r){return e.runtime!==r.runtime?e.runtime===t?-1:1:e.abi!==r.abi?e.abi?-1:1:e.specificity!==r.specificity?e.specificity>r.specificity?-1:1:0}}function eoe(){return!!(process.versions&&process.versions.nw)}function toe(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<"u"&&window.process&&window.process.type==="renderer"}function roe(t){if(t!=="linux")return!1;let{familySync:e,MUSL:r}=GL();return e()===r}Un.parseTags=tU;Un.matchTags=rU;Un.compareTags=nU;Un.parseTuple=XL;Un.matchTuple=QL;Un.compareTuples=eU});var sU=h((Tke,j0)=>{var D0=typeof __webpack_require__=="function"?__non_webpack_require__:U;typeof D0.addon=="function"?j0.exports=D0.addon.bind(D0):j0.exports=oU()});var lU=h((Oke,aU)=>{aU.exports=sU()(__dirname)});var $U=h(Oe=>{"use strict";var xU=U("stream"),noe=U("module"),L0;try{L0=new TextDecoder}catch{}var J,Kr,g=0,U0=[],Xo=U0,nu=0,je={},Ie,li,Ar=0,tn=0,Tt,ci,Yt=[],we,cU={useRecords:!1,mapsAsObjects:!0},Gf=class{},$0=new Gf;$0.name="MessagePack 0xC1";var Gi=!1,uU=2,ui=class t{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,r){if(J)return RU(()=>(Bf(),this?this.unpack(e,r):t.prototype.unpack.call(cU,e,r)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof r=="object"?(Kr=r.end||e.length,g=r.start||0):(g=0,Kr=r>-1?r:e.length),nu=0,tn=0,li=null,Xo=U0,Tt=null,J=e;try{we=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw J=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof t){if(je=this,this.structures)return Ie=this.structures,Ff(r);(!Ie||Ie.length>0)&&(Ie=[])}else je=cU,(!Ie||Ie.length>0)&&(Ie=[]);return Ff(r)}unpackMultiple(e,r){let i,n=0;try{Gi=!0;let o=e.length,s=this?this.unpack(e,o):Qf.unpack(e,o);if(r){if(r(s,n,g)===!1)return;for(;g<o;)if(n=g,r(Ff(),n,g)===!1)return}else{for(i=[s];g<o;)n=g,i.push(Ff());return i}}catch(o){throw o.lastPosition=n,o.values=i,o}finally{Gi=!1,Bf()}}_mergeStructures(e,r){this._onLoadedStructures&&(e=this._onLoadedStructures(e)),e=e||[],Object.isFrozen(e)&&(e=e.map(i=>i.slice(0)));for(let i=0,n=e.length;i<n;i++){let o=e[i];o&&(o.isShared=!0,i>=32&&(o.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in r||[])if(i>=0){let n=e[i],o=r[i];o&&(n&&((e.restoreStructures||(e.restoreStructures=[]))[i]=n),e[i]=o)}return this.structures=e}decode(e,r){return this.unpack(e,r)}};function Ff(t){try{if(!je.trusted&&!Gi){let r=Ie.sharedLength||0;r<Ie.length&&(Ie.length=r)}let e;if(je._readStruct&&J[g]<64&&J[g]>=32?(e=je._readStruct(J,g,Kr),J=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),g=Kr):e=ft(),Tt&&(g=Tt.postBundlePosition,Tt=null),Gi&&(Ie.restoreStructures=null),g==Kr)Ie&&Ie.restoreStructures&&dU(),Ie=null,J=null,ci&&(ci=null);else{if(g>Kr)throw new Error("Unexpected end of MessagePack data");if(!Gi){let r;try{r=JSON.stringify(e,(i,n)=>typeof n=="bigint"?`${n}n`:n).slice(0,100)}catch(i){r="(JSON view not available "+i+")"}throw new Error("Data read, but end of buffer not reached "+r)}}return e}catch(e){throw Ie&&Ie.restoreStructures&&dU(),Bf(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||g>Kr)&&(e.incomplete=!0),e}}function dU(){for(let t in Ie.restoreStructures)Ie[t]=Ie.restoreStructures[t];Ie.restoreStructures=null}function ft(){let t=J[g++];if(t<160)if(t<128){if(t<64)return t;{let e=Ie[t&63]||je.getStructures&&IU()[t&63];return e?(e.read||(e.read=J0(e,t&63)),e.read()):t}}else if(t<144)if(t-=128,je.mapsAsObjects){let e={};for(let r=0;r<t;r++){let i=OU();i==="__proto__"&&(i="__proto_"),e[i]=ft()}return e}else{let e=new Map;for(let r=0;r<t;r++)e.set(ft(),ft());return e}else{t-=144;let e=new Array(t);for(let r=0;r<t;r++)e[r]=ft();return je.freezeData?Object.freeze(e):e}else if(t<192){let e=t-160;if(tn>=g)return li.slice(g-Ar,(g+=e)-Ar);if(tn==0&&Kr<140){let r=e<16?F0(e):CU(e);if(r!=null)return r}return Vf(e)}else{let e;switch(t){case 192:return null;case 193:return Tt?(e=ft(),e>0?Tt[1].slice(Tt.position1,Tt.position1+=e):Tt[0].slice(Tt.position0,Tt.position0-=e)):$0;case 194:return!1;case 195:return!0;case 196:if(e=J[g++],e===void 0)throw new Error("Unexpected end of buffer");return P0(e);case 197:return e=we.getUint16(g),g+=2,P0(e);case 198:return e=we.getUint32(g),g+=4,P0(e);case 199:return Yo(J[g++]);case 200:return e=we.getUint16(g),g+=2,Yo(e);case 201:return e=we.getUint32(g),g+=4,Yo(e);case 202:if(e=we.getFloat32(g),je.useFloat32>2){let r=Xf[(J[g]&127)<<1|J[g+1]>>7];return g+=4,(r*e+(e>0?.5:-.5)>>0)/r}return g+=4,e;case 203:return e=we.getFloat64(g),g+=8,e;case 204:return J[g++];case 205:return e=we.getUint16(g),g+=2,e;case 206:return e=we.getUint32(g),g+=4,e;case 207:return je.int64AsType==="number"?(e=we.getUint32(g)*4294967296,e+=we.getUint32(g+4)):je.int64AsType==="string"?e=we.getBigUint64(g).toString():je.int64AsType==="auto"?(e=we.getBigUint64(g),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=we.getBigUint64(g),g+=8,e;case 208:return we.getInt8(g++);case 209:return e=we.getInt16(g),g+=2,e;case 210:return e=we.getInt32(g),g+=4,e;case 211:return je.int64AsType==="number"?(e=we.getInt32(g)*4294967296,e+=we.getUint32(g+4)):je.int64AsType==="string"?e=we.getBigInt64(g).toString():je.int64AsType==="auto"?(e=we.getBigInt64(g),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=we.getBigInt64(g),g+=8,e;case 212:if(e=J[g++],e==114)return gU(J[g++]&63);{let r=Yt[e];if(r)return r.read?(g++,r.read(ft())):r.noBuffer?(g++,r()):r(J.subarray(g,++g));throw new Error("Unknown extension "+e)}case 213:return e=J[g],e==114?(g++,gU(J[g++]&63,J[g++])):Yo(2);case 214:return Yo(4);case 215:return Yo(8);case 216:return Yo(16);case 217:return e=J[g++],tn>=g?li.slice(g-Ar,(g+=e)-Ar):kU(e);case 218:return e=we.getUint16(g),g+=2,tn>=g?li.slice(g-Ar,(g+=e)-Ar):_U(e);case 219:return e=we.getUint32(g),g+=4,tn>=g?li.slice(g-Ar,(g+=e)-Ar):TU(e);case 220:return e=we.getUint16(g),g+=2,fU(e);case 221:return e=we.getUint32(g),g+=4,fU(e);case 222:return e=we.getUint16(g),g+=2,mU(e);case 223:return e=we.getUint32(g),g+=4,mU(e);default:if(t>=224)return t-256;if(t===void 0){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}throw new Error("Unknown MessagePack token "+t)}}}var ioe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function J0(t,e){function r(){if(r.count++>uU){let n;try{n=t.read=new Function("r","return function(){return "+(je.freezeData?"Object.freeze":"")+"({"+t.map(o=>o==="__proto__"?"__proto_:r()":ioe.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"})}")(ft)}catch{return uU=1/0,r()}return t.read0=n,t.highByte===0&&(t.read=pU(e,t.read)),n()}let i={};for(let n=0,o=t.length;n<o;n++){let s=t[n];s==="__proto__"&&(s="__proto_"),i[s]=ft()}return je.freezeData?Object.freeze(i):i}return r.count=0,t.read0=r,t.highByte===0?pU(e,r):r}var pU=(t,e)=>function(){let r=J[g++];if(r===0)return e();let i=t<32?-(t+(r<<5)):t+(r<<5),n=Ie[i]||IU()[i];if(!n)throw new Error("Record id is not defined for "+i);return n.read||(n.read=J0(n,t)),n.read()};function IU(){let t=RU(()=>(J=null,je.getStructures()));return Ie=je._mergeStructures(t,Ie)}var Vf=ja,kU=ja,_U=ja,TU=ja;Oe.isNativeAccelerationEnabled=!1;function ooe(t){Oe.isNativeAccelerationEnabled=!0,Vf=e(1),kU=e(2),_U=e(3),TU=e(5);function e(r){return function(n){let o=Xo[nu++];if(o==null){if(Tt)return ja(n);let a=J.byteOffset,l=t(g-r+a,Kr+a,J.buffer);if(typeof l=="string")o=l,Xo=U0;else if(Xo=l,nu=1,tn=1,o=Xo[0],o===void 0)throw new Error("Unexpected end of buffer")}let s=o.length;return s<=n?(g+=n,o):(li=o,Ar=g,tn=g+s,g+=n,o.slice(0,n))}}}function ja(t){let e;if(t<16&&(e=F0(t)))return e;if(t>64&&L0)return L0.decode(J.subarray(g,g+=t));let r=g+t,i=[];for(e="";g<r;){let n=J[g++];if((n&128)===0)i.push(n);else if((n&224)===192){let o=J[g++]&63,s=(n&31)<<6|o;s<128?i.push(65533):i.push(s)}else if((n&240)===224){let o=J[g++]&63,s=J[g++]&63,a=(n&31)<<12|o<<6|s;a<2048||a>=55296&&a<=57343?i.push(65533):i.push(a)}else if((n&248)===240){let o=J[g++]&63,s=J[g++]&63,a=J[g++]&63,l=(n&7)<<18|o<<12|s<<6|a;l<65536||l>1114111?i.push(65533):(l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|l&1023),i.push(l))}else i.push(65533);i.length>=4096&&(e+=Rt.apply(String,i),i.length=0)}return i.length>0&&(e+=Rt.apply(String,i)),e}function fU(t){let e=new Array(t);for(let r=0;r<t;r++)e[r]=ft();return je.freezeData?Object.freeze(e):e}function mU(t){if(je.mapsAsObjects){let e={};for(let r=0;r<t;r++){let i=OU();i==="__proto__"&&(i="__proto_"),e[i]=ft()}return e}else{let e=new Map;for(let r=0;r<t;r++)e.set(ft(),ft());return e}}var Rt=String.fromCharCode;function CU(t){let e=g,r=new Array(t);for(let i=0;i<t;i++){let n=J[g++];if((n&128)>0){g=e;return}r[i]=n}return Rt.apply(String,r)}function F0(t){if(t<4)if(t<2){if(t===0)return"";{let e=J[g++];if((e&128)>1){g-=1;return}return Rt(e)}}else{let e=J[g++],r=J[g++];if((e&128)>0||(r&128)>0){g-=2;return}if(t<3)return Rt(e,r);let i=J[g++];if((i&128)>0){g-=3;return}return Rt(e,r,i)}else{let e=J[g++],r=J[g++],i=J[g++],n=J[g++];if((e&128)>0||(r&128)>0||(i&128)>0||(n&128)>0){g-=4;return}if(t<6){if(t===4)return Rt(e,r,i,n);{let o=J[g++];if((o&128)>0){g-=5;return}return Rt(e,r,i,n,o)}}else if(t<8){let o=J[g++],s=J[g++];if((o&128)>0||(s&128)>0){g-=6;return}if(t<7)return Rt(e,r,i,n,o,s);let a=J[g++];if((a&128)>0){g-=7;return}return Rt(e,r,i,n,o,s,a)}else{let o=J[g++],s=J[g++],a=J[g++],l=J[g++];if((o&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){g-=8;return}if(t<10){if(t===8)return Rt(e,r,i,n,o,s,a,l);{let c=J[g++];if((c&128)>0){g-=9;return}return Rt(e,r,i,n,o,s,a,l,c)}}else if(t<12){let c=J[g++],u=J[g++];if((c&128)>0||(u&128)>0){g-=10;return}if(t<11)return Rt(e,r,i,n,o,s,a,l,c,u);let d=J[g++];if((d&128)>0){g-=11;return}return Rt(e,r,i,n,o,s,a,l,c,u,d)}else{let c=J[g++],u=J[g++],d=J[g++],f=J[g++];if((c&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){g-=12;return}if(t<14){if(t===12)return Rt(e,r,i,n,o,s,a,l,c,u,d,f);{let p=J[g++];if((p&128)>0){g-=13;return}return Rt(e,r,i,n,o,s,a,l,c,u,d,f,p)}}else{let p=J[g++],m=J[g++];if((p&128)>0||(m&128)>0){g-=14;return}if(t<15)return Rt(e,r,i,n,o,s,a,l,c,u,d,f,p,m);let y=J[g++];if((y&128)>0){g-=15;return}return Rt(e,r,i,n,o,s,a,l,c,u,d,f,p,m,y)}}}}}function hU(){let t=J[g++],e;if(t<192)e=t-160;else switch(t){case 217:e=J[g++];break;case 218:e=we.getUint16(g),g+=2;break;case 219:e=we.getUint32(g),g+=4;break;default:throw new Error("Expected string")}return ja(e)}function P0(t){return je.copyBuffers?Uint8Array.prototype.slice.call(J,g,g+=t):J.subarray(g,g+=t)}function Yo(t){let e=J[g++];if(Yt[e]){let r;return Yt[e](J.subarray(g,r=g+=t),i=>{g=i;try{return ft()}finally{g=r}})}else throw new Error("Unknown extension type "+e)}var yU=new Array(4096);function OU(){let t=J[g++];if(t>=160&&t<192){if(t=t-160,tn>=g)return li.slice(g-Ar,(g+=t)-Ar);if(!(tn==0&&Kr<180))return Vf(t)}else return g--,AU(ft());let e=(t<<5^(t>1?we.getUint16(g):t>0?J[g]:0))&4095,r=yU[e],i=g,n=g+t-3,o,s=0;if(r&&r.bytes==t){for(;i<n;){if(o=we.getUint32(i),o!=r[s++]){i=1879048192;break}i+=4}for(n+=3;i<n;)if(o=J[i++],o!=r[s++]){i=1879048192;break}if(i===n)return g=i,r.string;n-=3,i=g}for(r=[],yU[e]=r,r.bytes=t;i<n;)o=we.getUint32(i),r.push(o),i+=4;for(n+=3;i<n;)o=J[i++],r.push(o);let a=t<16?F0(t):CU(t);return a!=null?r.string=a:r.string=Vf(t)}function AU(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return t.toString();if(t==null)return t+"";if(je.allowArraysInMapKeys&&Array.isArray(t)&&t.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return t.flat().toString();throw new Error(`Invalid property type for record: ${typeof t}`)}var gU=(t,e)=>{let r=ft().map(AU),i=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,r.highByte=e);let n=Ie[t];return n&&(n.isShared||Gi)&&((Ie.restoreStructures||(Ie.restoreStructures=[]))[t]=n),Ie[t]=r,r.read=J0(r,i),(r.read0||r.read)()};Yt[0]=()=>{};Yt[0].noBuffer=!0;Yt[66]=t=>{let e=t.byteLength%8||8,r=BigInt(t[0]&128?t[0]-256:t[0]);for(let i=1;i<e;i++)r<<=BigInt(8),r+=BigInt(t[i]);if(t.byteLength!==e){let i=new DataView(t.buffer,t.byteOffset,t.byteLength),n=(o,s)=>{let a=s-o;if(a<=40){let d=i.getBigUint64(o);for(let f=o+8;f<s;f+=8)d<<=BigInt(64),d|=i.getBigUint64(f);return d}let l=o+(a>>4<<3),c=n(o,l),u=n(l,s);return c<<BigInt((s-l)*8)|u};r=r<<BigInt((i.byteLength-e)*8)|n(e,i.byteLength)}return r};var bU={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};Yt[101]=()=>{let t=ft();if(!bU[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return bU[t[0]](t[1],{cause:t[2]})};Yt[105]=t=>{if(je.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=we.getUint32(g-4);ci||(ci=new Map);let r=J[g],i;r>=144&&r<160||r==220||r==221?i=[]:r>=128&&r<144||r==222||r==223?i=new Map:(r>=199&&r<=201||r>=212&&r<=216)&&J[g+1]===115?i=new Set:i={};let n={target:i};ci.set(e,n);let o=ft();if(n.used)Object.assign(i,o);else return n.target=o;if(i instanceof Map)for(let[s,a]of o.entries())i.set(s,a);if(i instanceof Set)for(let s of Array.from(o))i.add(s);return i};Yt[112]=t=>{if(je.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=we.getUint32(g-4),r=ci.get(e);return r.used=!0,r.target};Yt[115]=()=>new Set(ft());var KU=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),soe=typeof globalThis=="object"?globalThis:window;Yt[116]=t=>{let e=t[0],r=Uint8Array.prototype.slice.call(t,1).buffer,i=KU[e];if(!i){if(e===16)return r;if(e===17)return new DataView(r);throw new Error("Could not find typed array for code "+e)}return new soe[i](r)};Yt[120]=()=>{let t=ft();return new RegExp(t[0],t[1])};var aoe=[];Yt[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],r=g;return g+=e-t.length,Tt=aoe,Tt=[hU(),hU()],Tt.position0=0,Tt.position1=0,Tt.postBundlePosition=g,g=r,ft()};Yt[255]=t=>t.length==4?new Date((t[0]*16777216+(t[1]<<16)+(t[2]<<8)+t[3])*1e3):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+((t[3]&3)*4294967296+t[4]*16777216+(t[5]<<16)+(t[6]<<8)+t[7])*1e3):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+((t[4]&128?-281474976710656:0)+t[6]*1099511627776+t[7]*4294967296+t[8]*16777216+(t[9]<<16)+(t[10]<<8)+t[11])*1e3):new Date("invalid");function RU(t){je&&je._onSaveState&&je._onSaveState();let e=Kr,r=g,i=nu,n=Ar,o=tn,s=li,a=Xo,l=ci,c=Tt,u=new Uint8Array(J.slice(0,Kr)),d=Ie,f=Ie.slice(0,Ie.length),p=je,m=Gi,y=t();return Kr=e,g=r,nu=i,Ar=n,tn=o,li=s,Xo=a,ci=l,Tt=c,J=u,Gi=m,Ie=d,Ie.splice(0,Ie.length,...f),je=p,we=new DataView(J.buffer,J.byteOffset,J.byteLength),y}function Bf(){J=null,ci=null,Ie=null}function loe(t){t.unpack?Yt[t.type]=t.unpack:Yt[t.type]=t}var Xf=new Array(147);for(let t=0;t<256;t++)Xf[t]=+("1e"+Math.floor(45.15-t*.30103));var coe=ui,Qf=new ui({useRecords:!1}),uoe=Qf.unpack,doe=Qf.unpackMultiple,poe=Qf.unpack,DU={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},jU=new Float32Array(1),vU=new Uint8Array(jU.buffer,0,4);function foe(t){jU[0]=t;let e=Xf[(vU[3]&127)<<1|vU[2]>>7];return(e*t+(t>0?.5:-.5)>>0)/e}ui.SUPPORTS_STRUCT_HOOKS=!0;var zf;try{zf=new TextEncoder}catch{}var Wf,Zf,Da=typeof Buffer<"u",qf=Da?function(t){return Buffer.allocUnsafeSlow(t)}:Uint8Array,PU=Da?Buffer:Uint8Array,SU=Da?4294967296:2144337920,x,ru,qe,v=0,Ht,st=null,moe=21760,hoe=/[\u0080-\uFFFF]/,Ra=Symbol("record-id"),di=class extends ui{constructor(e){super(e),this.offset=0;let r,i,n,o,s=PU.prototype.utf8Write?function(E,D){return x.utf8Write(E,D,x.byteLength-D)}:zf&&zf.encodeInto?function(E,D){return zf.encodeInto(E,x.subarray(D)).written}:!1,a=this;e||(e={});let l=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let d=e.maxOwnStructures;d==null&&(d=c?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let f=u>32||d+u>64,p=u+64,m=u+d+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],w=0,_=0;this.pack=this.encode=function(E,D){if(x||(x=new qf(8192),qe=x.dataView||(x.dataView=new DataView(x.buffer,0,8192)),v=0),Ht=x.length-10,Ht-v<2048?(x=new qf(x.length),qe=x.dataView||(x.dataView=new DataView(x.buffer,0,x.length)),Ht=x.length-10,v=0):v=v+7&2147483640,r=v,D&UU&&(v+=D&255),o=a.structuredClone?new Map:null,a.bundleStrings&&typeof E!="string"?(st=[],st.size=1/0):st=null,n=a.structures,n){n.uninitialized&&(n=a._mergeStructures(a.getStructures()));let j=n.sharedLength||0;if(j>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let P=0;P<j;P++){let Y=n[P];if(!Y)continue;let ee,H=n.transitions;for(let Ae=0,W=Y.length;Ae<W;Ae++){let _e=Y[Ae];ee=H[_e],ee||(ee=H[_e]=Object.create(null)),H=ee}H[Ra]=P+64}this.lastNamedStructuresLength=j}l||(n.nextId=j+64)}i&&(i=!1);let N;try{a._writeStruct&&E&&typeof E=="object"?E.constructor===Object?me(E):E.constructor!==Map&&!Array.isArray(E)&&!Zf.some(P=>E instanceof P)?me(E.toJSON?E.toJSON():E):C(E):C(E);let j=st;if(st&&wU(r,C,0),o&&o.idsToInsert){let P=o.idsToInsert.sort((Ae,W)=>Ae.offset>W.offset?1:-1),Y=P.length,ee=-1;for(;j&&Y>0;){let Ae=P[--Y].offset+r;Ae<j.stringsPosition+r&&ee===-1&&(ee=0),Ae>j.position+r?ee>=0&&(ee+=6):(ee>=0&&(qe.setUint32(j.position+r,qe.getUint32(j.position+r)+ee),ee=-1),j=j.previous,Y++)}ee>=0&&j&&qe.setUint32(j.position+r,qe.getUint32(j.position+r)+ee),v+=P.length*6,v>Ht&&fe(v),a.offset=v;let H=yoe(x.subarray(r,v),P);return o=null,H}return a.offset=v,D&NU?(x.start=r,x.end=v,x):x.subarray(r,v)}catch(j){throw N=j,j}finally{if(n&&(A(),i&&a.saveStructures)){let j=n.sharedLength||0,P=x.subarray(r,v),Y=(a._prepareStructures||boe)(n,a);if(!N)return a.saveStructures(Y,Y.isCompatible)===!1?(n.uninitialized=!0,a.pack(E,D)):(a.lastNamedStructuresLength=j,x.length>1073741824&&(x=null),P)}x.length>1073741824&&(x=null),D&LU&&(v=r)}};let A=()=>{_<10&&_++;let E=n.sharedLength||0;if(n.length>E&&!l&&(n.length=E),w>1e4)n.transitions=null,_=0,w=0,y.length>0&&(y=[]);else if(y.length>0&&!l){for(let D=0,N=y.length;D<N;D++)y[D][Ra]=0;y=[]}},O=E=>{var D=E.length;D<16?x[v++]=144|D:D<65536?(x[v++]=220,x[v++]=D>>8,x[v++]=D&255):(x[v++]=221,qe.setUint32(v,D),v+=4);for(let N=0;N<D;N++)C(E[N])},C=E=>{v>Ht&&(x=fe(v));var D=typeof E,N;if(D==="string"){let j=E.length;if(st&&j>=4&&j<4096){if((st.size+=j)>moe){let H,Ae=(st[0]?st[0].length*3+st[1].length:0)+10;v+Ae>Ht&&(x=fe(v+Ae));let W;st.position?(W=st,x[v]=200,v+=3,x[v++]=98,H=v-r,v+=4,wU(r,C,0),qe.setUint16(H+r-3,v-r-H)):(x[v++]=214,x[v++]=98,H=v-r,v+=4),st=["",""],st.previous=W,st.size=0,st.position=H}let ee=hoe.test(E);st[ee?0:1]+=E,x[v++]=193,C(ee?-j:j);return}let P;j<32?P=1:j<256?P=2:j<65536?P=3:P=5;let Y=j*3;if(v+Y>Ht&&(x=fe(v+Y)),j<64||!s){let ee,H,Ae,W=v+P;for(ee=0;ee<j;ee++)H=E.charCodeAt(ee),H<128?x[W++]=H:H<2048?(x[W++]=H>>6|192,x[W++]=H&63|128):(H&64512)===55296&&((Ae=E.charCodeAt(ee+1))&64512)===56320?(H=65536+((H&1023)<<10)+(Ae&1023),ee++,x[W++]=H>>18|240,x[W++]=H>>12&63|128,x[W++]=H>>6&63|128,x[W++]=H&63|128):(x[W++]=H>>12|224,x[W++]=H>>6&63|128,x[W++]=H&63|128);N=W-v-P}else N=s(E,v+P);N<32?x[v++]=160|N:N<256?(P<2&&x.copyWithin(v+2,v+1,v+1+N),x[v++]=217,x[v++]=N):N<65536?(P<3&&x.copyWithin(v+3,v+2,v+2+N),x[v++]=218,x[v++]=N>>8,x[v++]=N&255):(P<5&&x.copyWithin(v+5,v+3,v+3+N),x[v++]=219,qe.setUint32(v,N),v+=4),v+=N}else if(D==="number")if(E>>>0===E)E<32||E<128&&this.useRecords===!1||E<64&&!this._writeStruct?x[v++]=E:E<256?(x[v++]=204,x[v++]=E):E<65536?(x[v++]=205,x[v++]=E>>8,x[v++]=E&255):(x[v++]=206,qe.setUint32(v,E),v+=4);else if(E>>0===E)E>=-32?x[v++]=256+E:E>=-128?(x[v++]=208,x[v++]=E+256):E>=-32768?(x[v++]=209,qe.setInt16(v,E),v+=2):(x[v++]=210,qe.setInt32(v,E),v+=4);else{let j;if((j=this.useFloat32)>0&&E<4294967296&&E>=-2147483648){x[v++]=202,qe.setFloat32(v,E);let P;if(j<4||(P=E*Xf[(x[v]&127)<<1|x[v+1]>>7])>>0===P){v+=4;return}else v--}x[v++]=203,qe.setFloat64(v,E),v+=8}else if(D==="object"||D==="function")if(!E)x[v++]=192;else{if(o){let P=o.get(E);if(P){if(!P.id){let Y=o.idsToInsert||(o.idsToInsert=[]);P.id=Y.push(P)}x[v++]=214,x[v++]=112,qe.setUint32(v,P.id),v+=4;return}else o.set(E,{offset:v-r})}let j=E.constructor;if(j===Object)ve(E);else if(j===Array)O(E);else if(j===Map)if(this.mapAsEmptyObject)x[v++]=128;else{N=E.size,N<16?x[v++]=128|N:N<65536?(x[v++]=222,x[v++]=N>>8,x[v++]=N&255):(x[v++]=223,qe.setUint32(v,N),v+=4);for(let[P,Y]of E)C(P),C(Y)}else{for(let P=0,Y=Wf.length;P<Y;P++){let ee=Zf[P];if(E instanceof ee){let H=Wf[P];if(H.write){H.type&&(x[v++]=212,x[v++]=H.type,x[v++]=0);let Et=H.write.call(this,E);Et===E?Array.isArray(E)?O(E):ve(E):C(Et);return}let Ae=x,W=qe,_e=v;x=null;let Te;try{Te=H.pack.call(this,E,Et=>(x=Ae,Ae=null,v+=Et,v>Ht&&fe(v),{target:x,targetView:qe,position:v-Et}),C)}finally{Ae&&(x=Ae,qe=W,v=_e,Ht=x.length-10)}Te&&(Te.length+v>Ht&&fe(Te.length+v),v=EU(Te,x,v,H.type));return}}if(Array.isArray(E))O(E);else{if(E.toJSON){let P=E.toJSON();if(P!==E)return C(P)}if(D==="function")return C(this.writeFunction&&this.writeFunction(E));ve(E)}}}else if(D==="boolean")x[v++]=E?195:194;else if(D==="bigint"){if(E<9223372036854776e3&&E>=-9223372036854776e3)x[v++]=211,qe.setBigInt64(v,E);else if(E<18446744073709552e3&&E>0)x[v++]=207,qe.setBigUint64(v,E);else if(this.largeBigIntToFloat)x[v++]=203,qe.setFloat64(v,Number(E));else{if(this.largeBigIntToString)return C(E.toString());if(this.useBigIntExtension||this.moreTypes){let j=E<0?BigInt(-1):BigInt(0),P;if(E>>BigInt(65536)===j){let Y=BigInt(18446744073709552e3)-BigInt(1),ee=[];for(;ee.push(E&Y),E>>BigInt(63)!==j;)E>>=BigInt(64);P=new Uint8Array(new BigUint64Array(ee).buffer),P.reverse()}else{let Y=E<0,ee=(Y?~E:E).toString(16);if(ee.length%2?ee="0"+ee:parseInt(ee.charAt(0),16)>=8&&(ee="00"+ee),Da)P=Buffer.from(ee,"hex");else{P=new Uint8Array(ee.length/2);for(let H=0;H<P.length;H++)P[H]=parseInt(ee.slice(H*2,H*2+2),16)}if(Y)for(let H=0;H<P.length;H++)P[H]=~P[H]}P.length+v>Ht&&fe(P.length+v),v=EU(P,x,v,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")}v+=8}else if(D==="undefined")this.encodeUndefinedAsNil?x[v++]=192:(x[v++]=212,x[v++]=0,x[v++]=0);else throw new Error("Unknown type: "+D)},$=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?E=>{let D;if(this.skipValues){D=[];for(let P in E)(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(P))&&!this.skipValues.includes(E[P])&&D.push(P)}else D=Object.keys(E);let N=D.length;N<16?x[v++]=128|N:N<65536?(x[v++]=222,x[v++]=N>>8,x[v++]=N&255):(x[v++]=223,qe.setUint32(v,N),v+=4);let j;if(this.coercibleKeyAsNumber)for(let P=0;P<N;P++){j=D[P];let Y=Number(j);C(isNaN(Y)?j:Y),C(E[j])}else for(let P=0;P<N;P++)C(j=D[P]),C(E[j])}:E=>{x[v++]=222;let D=v-r;v+=2;let N=0;for(let j in E)(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(j))&&(C(j),C(E[j]),N++);if(N>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');x[D+++r]=N>>8,x[D+r]=N&255},re=this.useRecords===!1?$:e.progressiveRecords&&!f?E=>{let D,N=n.transitions||(n.transitions=Object.create(null)),j=v++-r,P;for(let Y in E)if(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(Y)){if(D=N[Y],D)N=D;else{let ee=Object.keys(E),H=N;N=n.transitions;let Ae=0;for(let W=0,_e=ee.length;W<_e;W++){let Te=ee[W];D=N[Te],D||(D=N[Te]=Object.create(null),Ae++),N=D}j+r+1==v?(v--,Ee(N,ee,Ae)):qr(N,ee,j,Ae),P=!0,N=H[Y]}C(E[Y])}if(!P){let Y=N[Ra];Y?x[j+r]=Y:qr(N,Object.keys(E),j,0)}}:E=>{let D,N=n.transitions||(n.transitions=Object.create(null)),j=0;for(let Y in E)(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(Y))&&(D=N[Y],D||(D=N[Y]=Object.create(null),j++),N=D);let P=N[Ra];P?P>=96&&f?(x[v++]=((P-=96)&31)+96,x[v++]=P>>5):x[v++]=P:Ee(N,N.__keys__||Object.keys(E),j);for(let Y in E)(typeof E.hasOwnProperty!="function"||E.hasOwnProperty(Y))&&C(E[Y])},pe=typeof this.useRecords=="function"&&this.useRecords,ve=pe?E=>{pe(E)?re(E):$(E)}:re,me=E=>{let D=a._writeStruct(E,x,r,v,n,fe,(N,j,P)=>{if(P)return i=!0;v=j;let Y=x;return C(N),A(),Y!==x?{position:v,targetView:qe,target:x}:v});if(D===0)return ve(E);v=D},fe=E=>{let D;if(E>16777216){if(E-r>SU)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(SU,Math.round(Math.max((E-r)*(E>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(E-r<<2,x.length-1)>>12)+1<<12;let N=new qf(D);return qe=N.dataView||(N.dataView=new DataView(N.buffer,0,D)),E=Math.min(E,x.length),x.copy?x.copy(N,0,r,E):N.set(x.slice(r,E)),v-=r,r=0,Ht=N.length-10,x=N},Ee=(E,D,N)=>{let j=n.nextId;j||(j=64),j<p&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(j=n.nextOwnId,j<m||(j=p),n.nextOwnId=j+1):(j>=m&&(j=p),n.nextId=j+1);let P=D.highByte=j>=96&&f?j-96>>5:-1;E[Ra]=j,E.__keys__=D,n[j-64]=D,j<p?(D.isShared=!0,n.sharedLength=j-63,i=!0,P>=0?(x[v++]=(j&31)+96,x[v++]=P):x[v++]=j):(P>=0?(x[v++]=213,x[v++]=114,x[v++]=(j&31)+96,x[v++]=P):(x[v++]=212,x[v++]=114,x[v++]=j),N&&(w+=_*N),y.length>=d&&(y.shift()[Ra]=0),y.push(E),C(D))},qr=(E,D,N,j)=>{let P=x,Y=v,ee=Ht,H=r;x=ru,v=0,r=0,x||(ru=x=new qf(8192)),Ht=x.length-10,Ee(E,D,j),ru=x;let Ae=v;if(x=P,v=Y,Ht=ee,r=H,Ae>1){let W=v+Ae-1;W>Ht&&fe(W);let _e=N+r;x.copyWithin(_e+Ae,_e+1,v),x.set(ru.slice(0,Ae),_e),v=W}else x[N+r]=ru[0]}}useBuffer(e){x=e,x.dataView||(x.dataView=new DataView(x.buffer,x.byteOffset,x.byteLength)),qe=x.dataView,v=0}set position(e){v=e}get position(){return v}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};Zf=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Gf];Wf=[{pack(t,e,r){let i=t.getTime()/1e3;if((this.useTimestamp32||t.getMilliseconds()===0)&&i>=0&&i<4294967296){let{target:n,targetView:o,position:s}=e(6);n[s++]=214,n[s++]=255,o.setUint32(s,i)}else if(i>0&&i<4294967296){let{target:n,targetView:o,position:s}=e(10);n[s++]=215,n[s++]=255,o.setUint32(s,t.getMilliseconds()*4e6+(i/1e3/4294967296>>0)),o.setUint32(s+4,i)}else if(isNaN(i)){if(this.onInvalidDate)return e(0),r(this.onInvalidDate());let{target:n,targetView:o,position:s}=e(3);n[s++]=212,n[s++]=255,n[s++]=255}else{let{target:n,targetView:o,position:s}=e(15);n[s++]=199,n[s++]=12,n[s++]=255,o.setUint32(s,t.getMilliseconds()*1e6),o.setBigInt64(s+4,BigInt(Math.floor(i)))}}},{pack(t,e,r){if(this.setAsEmptyObject)return e(0),r({});let i=Array.from(t),{target:n,position:o}=e(this.moreTypes?3:0);this.moreTypes&&(n[o++]=212,n[o++]=115,n[o++]=0),r(i)}},{pack(t,e,r){let{target:i,position:n}=e(this.moreTypes?3:0);this.moreTypes&&(i[n++]=212,i[n++]=101,i[n++]=0),r([t.name,t.message,t.cause])}},{pack(t,e,r){let{target:i,position:n}=e(this.moreTypes?3:0);this.moreTypes&&(i[n++]=212,i[n++]=120,i[n++]=0),r([t.source,t.flags])}},{pack(t,e){this.moreTypes?M0(t,16,e):N0(Da?Buffer.from(t):new Uint8Array(t),e)}},{pack(t,e){let r=t.constructor;r!==PU&&this.moreTypes?M0(t,KU.indexOf(r.name),e):N0(t,e)}},{pack(t,e){this.moreTypes?M0(t,17,e):N0(Da?Buffer.from(t):new Uint8Array(t),e)}},{pack(t,e){let{target:r,position:i}=e(1);r[i]=193}}];function M0(t,e,r,i){let n=t.byteLength;if(n+1<256){var{target:o,position:s}=r(4+n);o[s++]=199,o[s++]=n+1}else if(n+1<65536){var{target:o,position:s}=r(5+n);o[s++]=200,o[s++]=n+1>>8,o[s++]=n+1&255}else{var{target:o,position:s,targetView:a}=r(7+n);o[s++]=201,a.setUint32(s,n+1),s+=4}o[s++]=116,o[s++]=e,t.buffer||(t=new Uint8Array(t)),o.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),s)}function N0(t,e){let r=t.byteLength;var i,n;if(r<256){var{target:i,position:n}=e(r+2);i[n++]=196,i[n++]=r}else if(r<65536){var{target:i,position:n}=e(r+3);i[n++]=197,i[n++]=r>>8,i[n++]=r&255}else{var{target:i,position:n,targetView:o}=e(r+5);i[n++]=198,o.setUint32(n,r),n+=4}i.set(t,n)}function EU(t,e,r,i){let n=t.length;switch(n){case 1:e[r++]=212;break;case 2:e[r++]=213;break;case 4:e[r++]=214;break;case 8:e[r++]=215;break;case 16:e[r++]=216;break;default:n<256?(e[r++]=199,e[r++]=n):n<65536?(e[r++]=200,e[r++]=n>>8,e[r++]=n&255):(e[r++]=201,e[r++]=n>>24,e[r++]=n>>16&255,e[r++]=n>>8&255,e[r++]=n&255)}return e[r++]=i,e.set(t,r),r+=n,r}function yoe(t,e){let r,i=e.length*6,n=t.length-i;for(;r=e.pop();){let o=r.offset,s=r.id;t.copyWithin(o+i,o,n),i-=6;let a=o+i;t[a++]=214,t[a++]=105,t[a++]=s>>24,t[a++]=s>>16&255,t[a++]=s>>8&255,t[a++]=s&255,n=o}return t}function wU(t,e,r){if(st.length>0){qe.setUint32(st.position+t,v+r-st.position-t),st.stringsPosition=v-t;let i=st;st=null,e(i[0]),e(i[1])}}function goe(t){if(t.Class){if(!t.pack&&!t.write)throw new Error("Extension has no pack or write function");if(t.pack&&!t.type)throw new Error("Extension has no type (numeric code to identify the extension)");Zf.unshift(t.Class),Wf.unshift(t)}loe(t)}function boe(t,e){return t.isCompatible=r=>{let i=!r||(e.lastNamedStructuresLength||0)===r.length;return i||e._mergeStructures(r),i},t}di.SUPPORTS_STRUCT_HOOKS=!0;var MU=new di({useRecords:!1}),voe=MU.pack,Soe=MU.pack,Eoe=di,{NEVER:woe,ALWAYS:xoe,DECIMAL_ROUND:Ioe,DECIMAL_FIT:koe}=DU,NU=512,LU=1024,UU=2048,Hf=class extends xU.Transform{constructor(e){e||(e={}),e.writableObjectMode=!0,super(e),e.sequential=!0,this.packr=e.packr||new di(e)}_transform(e,r,i){this.push(this.packr.pack(e)),i()}},Yf=class extends xU.Transform{constructor(e){e||(e={}),e.objectMode=!0,super(e),e.structures=[],this.maxIncompleteBufferSize=e.maxIncompleteBufferSize!==void 0?e.maxIncompleteBufferSize:67108864,this.unpackr=e.unpackr||new ui(e)}_transform(e,r,i){this.incompleteBuffer&&(e=Buffer.concat([this.incompleteBuffer,e]),this.incompleteBuffer=null);let n;try{n=this.unpackr.unpackMultiple(e)}catch(o){if(o.incomplete){let s=e.slice(o.lastPosition);if(s.length>this.maxIncompleteBufferSize)return this.incompleteBuffer=null,i(new Error("Maximum incomplete buffer size exceeded"));this.incompleteBuffer=s,n=o.values}else return i(o)}for(let o of n||[])o===null&&(o=this.getNullValue()),this.push(o);i()}getNullValue(){return Symbol.for(null)}};function _oe(t,e={}){if(!t||typeof t!="object")throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable");if(typeof t[Symbol.iterator]=="function")return Toe(t,e);if(typeof t.then=="function"||typeof t[Symbol.asyncIterator]=="function")return Coe(t,e);throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}function*Toe(t,e){let r=new di(e);for(let i of t)yield r.pack(i)}async function*Coe(t,e){let r=new di(e);for await(let i of t)yield r.pack(i)}function Ooe(t,e={}){if(!t||typeof t!="object")throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");let r=new ui(e),i,n=o=>{let s;i&&(o=Buffer.concat([i,o]),i=void 0);try{s=r.unpackMultiple(o)}catch(a){if(a.incomplete)i=o.slice(a.lastPosition),s=a.values;else throw a}return s};if(typeof t[Symbol.iterator]=="function")return(function*(){for(let s of t)yield*n(s)})();if(typeof t[Symbol.asyncIterator]=="function")return(async function*(){for await(let s of t)yield*n(s)})()}var Aoe=Ooe,Koe=_oe,Roe=!1,Doe=!0,joe=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!joe){let t;try{typeof U=="function"?t=lU():t=noe.createRequire(typeof document>"u"?new(U("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("node.cjs",document.baseURI).href)("msgpackr-extract"),t&&ooe(t.extractStrings)}catch{}}Oe.ALWAYS=xoe;Oe.C1=$0;Oe.DECIMAL_FIT=koe;Oe.DECIMAL_ROUND=Ioe;Oe.Decoder=coe;Oe.DecoderStream=Yf;Oe.Encoder=Eoe;Oe.EncoderStream=Hf;Oe.FLOAT32_OPTIONS=DU;Oe.NEVER=woe;Oe.Packr=di;Oe.PackrStream=Hf;Oe.RESERVE_START_SPACE=UU;Oe.RESET_BUFFER_MODE=LU;Oe.REUSE_BUFFER_MODE=NU;Oe.Unpackr=ui;Oe.UnpackrStream=Yf;Oe.addExtension=goe;Oe.clearSource=Bf;Oe.decode=poe;Oe.decodeIter=Aoe;Oe.encode=Soe;Oe.encodeIter=Koe;Oe.mapsAsObjects=Doe;Oe.pack=voe;Oe.roundFloat32=foe;Oe.unpack=uoe;Oe.unpackMultiple=doe;Oe.useRecords=Roe});var tm=h(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0});em.version=void 0;em.version="5.80.2"});var z0=h(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});iu.Scripts=void 0;iu.raw2NextJobData=rm;var Poe=$U(),Moe=new Poe.Packr({useRecords:!1,encodeUndefinedAsNil:!0}),Ct=Moe.pack,gn=gr(),Vi=Or(),Noe=tm(),Loe=Mf(),q0=class{constructor(e){this.queue=e,this.version=Noe.version;let r=this.queue.keys;this.moveToFinishedKeys=[r.wait,r.active,r.prioritized,r.events,r.stalled,r.limiter,r.delayed,r.paused,r.meta,r.pc,void 0,void 0,void 0,void 0]}execCommand(e,r,i){let n=`${r}:${this.version}`;return e.runCommand(n,i)}async isJobInList(e,r){let i=await this.queue.client,n;return(0,Vi.isRedisVersionLowerThan)(this.queue.redisVersion,"6.0.6",this.queue.databaseType)?n=await this.execCommand(i,"isJobInList",[e,r]):n=await i.lpos(e,r),Number.isInteger(n)}addDelayedJobArgs(e,r,i){let n=this.queue.keys,o=[n.marker,n.meta,n.id,n.delayed,n.completed,n.events];return o.push(Ct(i),e.data,r),o}addDelayedJob(e,r,i,n){let o=this.addDelayedJobArgs(r,i,n);return this.execCommand(e,"addDelayedJob",o)}addPrioritizedJobArgs(e,r,i){let n=this.queue.keys,o=[n.marker,n.meta,n.id,n.prioritized,n.delayed,n.completed,n.active,n.events,n.pc];return o.push(Ct(i),e.data,r),o}addPrioritizedJob(e,r,i,n){let o=this.addPrioritizedJobArgs(r,i,n);return this.execCommand(e,"addPrioritizedJob",o)}addParentJobArgs(e,r,i){let n=this.queue.keys,o=[n.meta,n.id,n.delayed,n["waiting-children"],n.completed,n.events];return o.push(Ct(i),e.data,r),o}addParentJob(e,r,i,n){let o=this.addParentJobArgs(r,i,n);return this.execCommand(e,"addParentJob",o)}addStandardJobArgs(e,r,i){let n=this.queue.keys,o=[n.wait,n.paused,n.meta,n.id,n.completed,n.delayed,n.active,n.events,n.marker];return o.push(Ct(i),e.data,r),o}addStandardJob(e,r,i,n){let o=this.addStandardJobArgs(r,i,n);return this.execCommand(e,"addStandardJob",o)}async addJob(e,r,i,n,o={}){let s=this.queue.keys,a=r.parent,l=[s[""],typeof n<"u"?n:"",r.name,r.timestamp,r.parentKey||null,o.parentDependenciesKey||null,a,r.repeatJobKey,r.deduplicationId?`${s.de}:${r.deduplicationId}`:null],c;if(i.repeat){let d=Object.assign({},i.repeat);d.startDate&&(d.startDate=+new Date(d.startDate)),d.endDate&&(d.endDate=+new Date(d.endDate)),c=Ct(Object.assign(Object.assign({},i),{repeat:d}))}else c=Ct(i);let u;if(o.addToWaitingChildren?u=await this.addParentJob(e,r,c,l):typeof i.delay=="number"&&i.delay>0?u=await this.addDelayedJob(e,r,c,l):i.priority?u=await this.addPrioritizedJob(e,r,c,l):u=await this.addStandardJob(e,r,c,l),u<0)throw this.finishedErrors({code:u,parentKey:o.parentKey,command:"addJob"});return u}pauseArgs(e){let r="wait",i="paused";e||(r="paused",i="wait");let n=[r,i,"meta","prioritized"].map(s=>this.queue.toKey(s));n.push(this.queue.keys.events,this.queue.keys.delayed,this.queue.keys.marker);let o=[e?"paused":"resumed"];return n.concat(o)}async pause(e){let r=await this.queue.client,i=this.pauseArgs(e);return this.execCommand(r,"pause",i)}addRepeatableJobArgs(e,r,i,n){let o=this.queue.keys,s=[o.repeat,o.delayed],a=[r,Ct(i),n,e,o[""]];return s.concat(a)}async addRepeatableJob(e,r,i,n){let o=await this.queue.client,s=this.addRepeatableJobArgs(e,r,i,n);return this.execCommand(o,"addRepeatableJob",s)}async removeDeduplicationKey(e,r){let i=await this.queue.client,o=[`${this.queue.keys.de}:${e}`],s=[r];return this.execCommand(i,"removeDeduplicationKey",o.concat(s))}async addJobScheduler(e,r,i,n,o,s,a){let l=await this.queue.client,c=this.queue.keys,u=[c.repeat,c.delayed,c.wait,c.paused,c.meta,c.prioritized,c.marker,c.id,c.events,c.pc,c.active],d=[r,Ct(o),e,i,Ct(n),Ct(s),Date.now(),c[""],a?this.queue.toKey(a):""],f=await this.execCommand(l,"addJobScheduler",u.concat(d));if(typeof f=="number"&&f<0)throw this.finishedErrors({code:f,command:"addJobScheduler"});return f}async updateRepeatableJobMillis(e,r,i,n){let o=[this.queue.keys.repeat,i,r,n];return this.execCommand(e,"updateRepeatableJobMillis",o)}async updateJobSchedulerNextMillis(e,r,i,n,o){let s=await this.queue.client,a=this.queue.keys,l=[a.repeat,a.delayed,a.wait,a.paused,a.meta,a.prioritized,a.marker,a.id,a.events,a.pc,o?this.queue.toKey(o):"",a.active],c=[r,e,i,Ct(n),Date.now(),a[""],o];return this.execCommand(s,"updateJobScheduler",l.concat(c))}removeRepeatableArgs(e,r,i){let n=this.queue.keys,o=[n.repeat,n.delayed,n.events],s=[e,this.getRepeatConcatOptions(r,i),i,n[""]];return o.concat(s)}getRepeatConcatOptions(e,r){return r&&r.split(":").length>2?r:e}async removeRepeatable(e,r,i){let n=await this.queue.client,o=this.removeRepeatableArgs(e,r,i);return this.execCommand(n,"removeRepeatable",o)}async removeJobScheduler(e){let r=await this.queue.client,i=this.queue.keys,n=[i.repeat,i.delayed,i.events],o=[e,i[""]];return this.execCommand(r,"removeJobScheduler",n.concat(o))}removeArgs(e,r){let i=[e,"repeat"].map(o=>this.queue.toKey(o)),n=[e,r?1:0,this.queue.toKey("")];return i.concat(n)}async remove(e,r){let i=await this.queue.client,n=this.removeArgs(e,r),o=await this.execCommand(i,"removeJob",n);if(o<0)throw this.finishedErrors({code:o,jobId:e,command:"removeJob"});return o}async removeUnprocessedChildren(e){let r=await this.queue.client,i=[this.queue.toKey(e),this.queue.keys.meta,this.queue.toKey(""),e];await this.execCommand(r,"removeUnprocessedChildren",i)}async extendLock(e,r,i,n){n=n||await this.queue.client;let o=[this.queue.toKey(e)+":lock",this.queue.keys.stalled,r,i,e];return this.execCommand(n,"extendLock",o)}async extendLocks(e,r,i){let n=await this.queue.client,o=[this.queue.keys.stalled,this.queue.toKey(""),Ct(r),Ct(e),i];return this.execCommand(n,"extendLocks",o)}async updateData(e,r){let i=await this.queue.client,n=[this.queue.toKey(e.id)],o=JSON.stringify(r),s=await this.execCommand(i,"updateData",n.concat([o]));if(s<0)throw this.finishedErrors({code:s,jobId:e.id,command:"updateData"})}async updateProgress(e,r){let i=await this.queue.client,n=[this.queue.toKey(e),this.queue.keys.events,this.queue.keys.meta],o=JSON.stringify(r),s=await this.execCommand(i,"updateProgress",n.concat([e,o]));if(s<0)throw this.finishedErrors({code:s,jobId:e,command:"updateProgress"})}async addLog(e,r,i){let n=await this.queue.client,o=[this.queue.toKey(e),this.queue.toKey(e)+":logs"],s=await this.execCommand(n,"addLog",o.concat([e,r,i||""]));if(s<0)throw this.finishedErrors({code:s,jobId:e,command:"addLog"});return s}moveToFinishedArgs(e,r,i,n,o,s,a,l=!0,c){var u,d,f,p,m,y,w;let _=this.queue.keys,A=this.queue.opts,O=o==="completed"?A.removeOnComplete:A.removeOnFail,C=this.queue.toKey(`metrics:${o}`),$=this.moveToFinishedKeys;$[10]=_[o],$[11]=this.queue.toKey((u=e.id)!==null&&u!==void 0?u:""),$[12]=C,$[13]=this.queue.keys.marker;let re=this.getKeepJobs(n,O),pe=[e.id,a,i,typeof r>"u"?"null":r,o,!l||this.queue.closing?0:1,_[""],Ct({token:s,name:A.name,keepJobs:re,limiter:A.limiter,lockDuration:A.lockDuration,attempts:e.opts.attempts,maxMetricsSize:!((d=A.metrics)===null||d===void 0)&&d.maxDataPoints?(f=A.metrics)===null||f===void 0?void 0:f.maxDataPoints:"",fpof:!!(!((p=e.opts)===null||p===void 0)&&p.failParentOnFailure),cpof:!!(!((m=e.opts)===null||m===void 0)&&m.continueParentOnFailure),idof:!!(!((y=e.opts)===null||y===void 0)&&y.ignoreDependencyOnFailure),rdof:!!(!((w=e.opts)===null||w===void 0)&&w.removeDependencyOnFailure)}),c?Ct((0,Vi.objectToFlatArray)(c)):void 0];return $.concat(pe)}getKeepJobs(e,r){return typeof e>"u"?r||{count:e?0:-1}:typeof e=="object"?e:typeof e=="number"?{count:e}:{count:e?0:-1}}async moveToFinished(e,r){let i=await this.queue.client,n=await this.execCommand(i,"moveToFinished",r);if(n<0)throw this.finishedErrors({code:n,jobId:e,command:"moveToFinished",state:"active"});if(typeof n<"u")return rm(n)}drainArgs(e){let r=this.queue.keys,i=[r.wait,r.paused,r.delayed,r.prioritized,r.repeat],n=[r[""],e?"1":"0"];return i.concat(n)}async drain(e){let r=await this.queue.client,i=this.drainArgs(e);return this.execCommand(r,"drain",i)}removeChildDependencyArgs(e,r){let n=[this.queue.keys[""]],o=[this.queue.toKey(e),r];return n.concat(o)}async removeChildDependency(e,r){let i=await this.queue.client,n=this.removeChildDependencyArgs(e,r),o=await this.execCommand(i,"removeChildDependency",n);switch(o){case 0:return!0;case 1:return!1;default:throw this.finishedErrors({code:o,jobId:e,parentKey:r,command:"removeChildDependency"})}}getRangesArgs(e,r,i,n){let o=this.queue.keys,s=e.map(c=>c==="waiting"?"wait":c),a=[o[""]],l=[r,i,n?"1":"0",...s];return a.concat(l)}async getRanges(e,r=0,i=1,n=!1){let o=await this.queue.client,s=this.getRangesArgs(e,r,i,n);return await this.execCommand(o,"getRanges",s)}getCountsArgs(e){let r=this.queue.keys,i=e.map(s=>s==="waiting"?"wait":s),n=[r[""]],o=[...i];return n.concat(o)}async getCounts(e){let r=await this.queue.client,i=this.getCountsArgs(e);return await this.execCommand(r,"getCounts",i)}getCountsPerPriorityArgs(e){let r=[this.queue.keys.wait,this.queue.keys.paused,this.queue.keys.meta,this.queue.keys.prioritized],i=e;return r.concat(i)}async getCountsPerPriority(e){let r=await this.queue.client,i=this.getCountsPerPriorityArgs(e);return await this.execCommand(r,"getCountsPerPriority",i)}getDependencyCountsArgs(e,r){let i=[`${e}:processed`,`${e}:dependencies`,`${e}:failed`,`${e}:unsuccessful`].map(o=>this.queue.toKey(o)),n=r;return i.concat(n)}async getDependencyCounts(e,r){let i=await this.queue.client,n=this.getDependencyCountsArgs(e,r);return await this.execCommand(i,"getDependencyCounts",n)}moveToCompletedArgs(e,r,i,n,o=!1){let s=Date.now();return this.moveToFinishedArgs(e,r,"returnvalue",i,"completed",n,s,o)}moveToFailedArgs(e,r,i,n,o=!1,s){let a=Date.now();return this.moveToFinishedArgs(e,r,"failedReason",i,"failed",n,a,o,s)}async isFinished(e,r=!1){let i=await this.queue.client,n=["completed","failed",e].map(o=>this.queue.toKey(o));return this.execCommand(i,"isFinished",n.concat([e,r?"1":""]))}async getState(e){let r=await this.queue.client,i=["completed","failed","delayed","active","wait","paused","waiting-children","prioritized"].map(n=>this.queue.toKey(n));return(0,Vi.isRedisVersionLowerThan)(this.queue.redisVersion,"6.0.6",this.queue.databaseType)?this.execCommand(r,"getState",i.concat([e])):this.execCommand(r,"getStateV2",i.concat([e]))}async changeDelay(e,r){let i=await this.queue.client,n=this.changeDelayArgs(e,r),o=await this.execCommand(i,"changeDelay",n);if(o<0)throw this.finishedErrors({code:o,jobId:e,command:"changeDelay",state:"delayed"})}changeDelayArgs(e,r){let i=Date.now();return[this.queue.keys.delayed,this.queue.keys.meta,this.queue.keys.marker,this.queue.keys.events].concat([r,JSON.stringify(i),e,this.queue.toKey(e)])}async changePriority(e,r=0,i=!1){let n=await this.queue.client,o=this.changePriorityArgs(e,r,i),s=await this.execCommand(n,"changePriority",o);if(s<0)throw this.finishedErrors({code:s,jobId:e,command:"changePriority"})}changePriorityArgs(e,r=0,i=!1){return[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].concat([r,this.queue.toKey(""),e,i?1:0])}moveToDelayedArgs(e,r,i,n,o={}){let s=this.queue.keys,a=this.queue.opts,l=[s.marker,s.active,s.prioritized,s.delayed,this.queue.toKey(e),s.events,s.meta,s.stalled,s.wait,s.limiter,s.paused,s.pc],c=o.fetchNext&&!this.queue.closing?1:0;return l.concat([this.queue.keys[""],r,e,i,n,o.skipAttempt?"1":"0",o.fieldsToUpdate?Ct((0,Vi.objectToFlatArray)(o.fieldsToUpdate)):void 0,c,c?Ct({token:i,lockDuration:a.lockDuration,limiter:a.limiter,name:a.name}):void 0])}moveToWaitingChildrenArgs(e,r,i){let n=Date.now(),o=(0,Vi.getParentKey)(i.child);return["active","waiting-children",e,`${e}:dependencies`,`${e}:unsuccessful`,"stalled","events"].map(a=>this.queue.toKey(a)).concat([r,o??"",JSON.stringify(n),e,this.queue.toKey("")])}isMaxedArgs(){let e=this.queue.keys;return[e.meta,e.active]}async isMaxed(){let e=await this.queue.client,r=this.isMaxedArgs();return!!await this.execCommand(e,"isMaxed",r)}async moveToDelayed(e,r,i,n="0",o={}){let s=await this.queue.client,a=this.moveToDelayedArgs(e,r,n,i,o),l=await this.execCommand(s,"moveToDelayed",a);if(l<0)throw this.finishedErrors({code:l,jobId:e,command:"moveToDelayed",state:"active"});if(typeof l<"u")return rm(l)}async moveToWaitingChildren(e,r,i={}){let n=await this.queue.client,o=this.moveToWaitingChildrenArgs(e,r,i),s=await this.execCommand(n,"moveToWaitingChildren",o);switch(s){case 0:return!0;case 1:return!1;default:throw this.finishedErrors({code:s,jobId:e,command:"moveToWaitingChildren",state:"active"})}}getRateLimitTtlArgs(e){return[this.queue.keys.limiter,this.queue.keys.meta].concat([e??"0"])}async getRateLimitTtl(e){let r=await this.queue.client,i=this.getRateLimitTtlArgs(e);return this.execCommand(r,"getRateLimitTtl",i)}async cleanJobsInSet(e,r,i=0){let n=await this.queue.client;return this.execCommand(n,"cleanJobsInSet",[this.queue.toKey(e),this.queue.toKey("events"),this.queue.toKey("repeat"),this.queue.toKey(""),r,i,e])}getJobSchedulerArgs(e){return[this.queue.keys.repeat].concat([e])}async getJobScheduler(e){let r=await this.queue.client,i=this.getJobSchedulerArgs(e);return this.execCommand(r,"getJobScheduler",i)}retryJobArgs(e,r,i,n={}){let o=[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],s=(r?"R":"L")+"PUSH";return o.concat([this.queue.toKey(""),Date.now(),s,e,i,n.fieldsToUpdate?Ct((0,Vi.objectToFlatArray)(n.fieldsToUpdate)):void 0])}async retryJob(e,r,i="0",n={}){let o=await this.queue.client,s=this.retryJobArgs(e,r,i,n),a=await this.execCommand(o,"retryJob",s);if(a<0)throw this.finishedErrors({code:a,jobId:e,command:"retryJob",state:"active"})}moveJobsToWaitArgs(e,r,i){let n=[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],o=[r,i,e];return n.concat(o)}async retryJobs(e="failed",r=1e3,i=new Date().getTime()){let n=await this.queue.client,o=this.moveJobsToWaitArgs(e,r,i);return this.execCommand(n,"moveJobsToWait",o)}async promoteJobs(e=1e3){let r=await this.queue.client,i=this.moveJobsToWaitArgs("delayed",e,Number.MAX_VALUE);return this.execCommand(r,"moveJobsToWait",i)}async reprocessJob(e,r,i={}){let n=await this.queue.client,o=[this.queue.toKey(e.id),this.queue.keys.events,this.queue.toKey(r),this.queue.keys.wait,this.queue.keys.meta,this.queue.keys.paused,this.queue.keys.active,this.queue.keys.marker],s=[e.id,(e.opts.lifo?"R":"L")+"PUSH",r==="failed"?"failedReason":"returnvalue",r,i.resetAttemptsMade?"1":"0",i.resetAttemptsStarted?"1":"0"],a=await this.execCommand(n,"reprocessJob",o.concat(s));if(a!==1)throw this.finishedErrors({code:a,jobId:e.id,command:"reprocessJob",state:r})}async getMetrics(e,r=0,i=-1){let n=await this.queue.client,o=[this.queue.toKey(`metrics:${e}`),this.queue.toKey(`metrics:${e}:data`)],s=[r,i];return await this.execCommand(n,"getMetrics",o.concat(s))}async moveToActive(e,r,i){let n=this.queue.opts,o=this.queue.keys,s=[o.wait,o.active,o.prioritized,o.events,o.stalled,o.limiter,o.delayed,o.paused,o.meta,o.pc,o.marker],a=[o[""],Date.now(),Ct({token:r,lockDuration:n.lockDuration,limiter:n.limiter,name:i})],l=await this.execCommand(e,"moveToActive",s.concat(a));return rm(l)}async promote(e){let r=await this.queue.client,i=[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],n=[this.queue.toKey(""),e],o=await this.execCommand(r,"promote",i.concat(n));if(o<0)throw this.finishedErrors({code:o,jobId:e,command:"promote",state:"delayed"})}moveStalledJobsToWaitArgs(){let e=this.queue.opts,r=[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,this.queue.keys.repeat],i=[e.maxStalledCount,this.queue.toKey(""),Date.now(),e.stalledInterval];return r.concat(i)}async moveStalledJobsToWait(){let e=await this.queue.client,r=this.moveStalledJobsToWaitArgs();return this.execCommand(e,"moveStalledJobsToWait",r)}async moveJobFromActiveToWait(e,r="0"){let i=await this.queue.client,n=[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],o=[e,r,this.queue.toKey(e)],s=await this.execCommand(i,"moveJobFromActiveToWait",n.concat(o));if(s<0)throw this.finishedErrors({code:s,jobId:e,command:"moveJobFromActiveToWait",state:"active"});return s}async obliterate(e){let r=await this.queue.client,i=[this.queue.keys.meta,this.queue.toKey("")],n=[e.count,e.force?"force":null],o=await this.execCommand(r,"obliterate",i.concat(n));if(o<0)switch(o){case-1:throw new Error("Cannot obliterate non-paused queue");case-2:throw new Error("Cannot obliterate queue with active jobs")}return o}async paginate(e,r){let i=await this.queue.client,n=[e],o=5,s=r.end>=0?r.end-r.start+1:1/0,a="0",l=0,c,u,d,f=[],p=[];do{let m=[r.start+f.length,r.end,a,l,o];r.fetchJobs&&m.push(1),[a,l,c,u,d]=await this.execCommand(i,"paginate",n.concat(m)),f=f.concat(c),d&&d.length&&(p=p.concat(d.map(Vi.array2obj)))}while(a!="0"&&f.length<s);if(f.length&&Array.isArray(f[0])){let m=[];for(let y=0;y<f.length;y++){let[w,_]=f[y];try{m.push({id:w,v:JSON.parse(_)})}catch(A){m.push({id:w,err:A.message})}}return{cursor:a,items:m,total:u,jobs:p}}else return{cursor:a,items:f.map(m=>({id:m})),total:u,jobs:p}}finishedErrors({code:e,jobId:r,parentKey:i,command:n,state:o}){let s;switch(e){case gn.ErrorCode.JobNotExist:s=new Error(`Missing key for job ${r}. ${n}`);break;case gn.ErrorCode.JobLockNotExist:s=new Error(`Missing lock for job ${r}. ${n}`);break;case gn.ErrorCode.JobNotInState:s=new Error(`Job ${r} is not in the ${o} state. ${n}`);break;case gn.ErrorCode.JobPendingChildren:s=new Error(`Job ${r} has pending dependencies. ${n}`);break;case gn.ErrorCode.ParentJobNotExist:s=new Error(`Missing key for parent job ${i}. ${n}`);break;case gn.ErrorCode.JobLockMismatch:s=new Error(`Lock mismatch for job ${r}. Cmd ${n} from ${o}`);break;case gn.ErrorCode.ParentJobCannotBeReplaced:s=new Error(`The parent job ${i} cannot be replaced. ${n}`);break;case gn.ErrorCode.JobBelongsToJobScheduler:s=new Error(`Job ${r} belongs to a job scheduler and cannot be removed directly. ${n}`);break;case gn.ErrorCode.JobHasFailedChildren:s=new Loe.UnrecoverableError(`Cannot complete job ${r} because it has at least one failed child. ${n}`);break;case gn.ErrorCode.SchedulerJobIdCollision:s=new Error(`Cannot create job scheduler iteration - job ID already exists. ${n}`);break;case gn.ErrorCode.SchedulerJobSlotsBusy:s=new Error(`Cannot create job scheduler iteration - current and next time slots already have jobs. ${n}`);break;default:s=new Error(`Unknown code ${e} error for ${r}. ${n}`)}return s.code=e,s}async removeOrphanedJobs(e,r,i){let n=await this.queue.client,o=[this.queue.toKey(""),r.length,...r,i.length,...i,...e];return this.execCommand(n,"removeOrphanedJobs",o)}};iu.Scripts=q0;function rm(t){if(t){let e=[null,t[1],t[2],t[3]];return t[0]&&(e[0]=(0,Vi.array2obj)(t[0])),e}return[]}});var im=h(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});nm.createScripts=void 0;var Uoe=z0(),$oe=t=>new Uoe.Scripts({keys:t.keys,client:t.client,get redisVersion(){return t.redisVersion},toKey:t.toKey,opts:t.opts,closing:t.closing,databaseType:t.databaseType});nm.createScripts=$oe});var Pa=h(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.Job=Bi.PRIORITY_LIMIT=void 0;var JU=(Zt(),Jt(Wt)),Joe=U("util"),cr=Or(),Foe=im(),FU=OE(),qoe=x0(),vr=gr(),zoe=(0,Joe.debuglog)("bull");Bi.PRIORITY_LIMIT=2**21-1;var G0=class t{constructor(e,r,i,n={},o){this.queue=e,this.name=r,this.data=i,this.opts=n,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;let s=this.opts,{repeatJobKey:a}=s,l=JU.__rest(s,["repeatJobKey"]);this.opts=Object.assign({attempts:0},l),this.delay=this.opts.delay,this.priority=this.opts.priority||0,this.repeatJobKey=a,this.timestamp=n.timestamp?n.timestamp:Date.now(),this.opts.backoff=FU.Backoffs.normalize(n.backoff),this.parentKey=(0,cr.getParentKey)(n.parent),n.parent&&(this.parent={id:n.parent.id,queueKey:n.parent.queue},n.failParentOnFailure&&(this.parent.fpof=!0),n.removeDependencyOnFailure&&(this.parent.rdof=!0),n.ignoreDependencyOnFailure&&(this.parent.idof=!0),n.continueParentOnFailure&&(this.parent.cpof=!0)),this.debounceId=n.debounce?n.debounce.id:void 0,this.deduplicationId=n.deduplication?n.deduplication.id:this.debounceId,this.toKey=e.toKey.bind(e),this.createScripts(),this.queueQualifiedName=e.qualifiedName}static async create(e,r,i,n){let o=await e.client,s=new this(e,r,i,n,n&&n.jobId);return s.id=await s.addJob(o,{parentKey:s.parentKey,parentDependenciesKey:s.parentKey?`${s.parentKey}:dependencies`:""}),s}static async createBulk(e,r){let i=await e.client,n=r.map(a=>{var l;return new this(e,a.name,a.data,a.opts,(l=a.opts)===null||l===void 0?void 0:l.jobId)}),o=i.pipeline();for(let a of n)a.addJob(o,{parentKey:a.parentKey,parentDependenciesKey:a.parentKey?`${a.parentKey}:dependencies`:""});let s=await o.exec();for(let a=0;a<s.length;++a){let[l,c]=s[a];if(l)throw l;n[a].id=c}return n}static fromJSON(e,r,i){let n=JSON.parse(r.data||"{}"),o=t.optsFromJSON(r.opts),s=new this(e,r.name,n,o,r.id||i);return s.progress=JSON.parse(r.progress||"0"),s.delay=parseInt(r.delay),s.priority=parseInt(r.priority),s.timestamp=parseInt(r.timestamp),r.finishedOn&&(s.finishedOn=parseInt(r.finishedOn)),r.processedOn&&(s.processedOn=parseInt(r.processedOn)),r.rjk&&(s.repeatJobKey=r.rjk),r.deid&&(s.debounceId=r.deid,s.deduplicationId=r.deid),r.failedReason&&(s.failedReason=r.failedReason),s.attemptsStarted=parseInt(r.ats||"0"),s.attemptsMade=parseInt(r.attemptsMade||r.atm||"0"),s.stalledCounter=parseInt(r.stc||"0"),r.defa&&(s.deferredFailure=r.defa),s.stacktrace=Goe(r.stacktrace),typeof r.returnvalue=="string"&&(s.returnvalue=qU(r.returnvalue)),r.parentKey?s.parentKey=r.parentKey:s.parentKey=void 0,r.parent?s.parent=JSON.parse(r.parent):s.parent=void 0,r.pb&&(s.processedBy=r.pb),r.nrjid&&(s.nextRepeatableJobId=r.nrjid),s}createScripts(){this.scripts=(0,Foe.createScripts)(this.queue)}static optsFromJSON(e,r=cr.optsDecodeMap){let i=JSON.parse(e||"{}"),n=Object.entries(i),o={};for(let s of n){let[a,l]=s;r[a]?o[r[a]]=l:a==="tm"?o.telemetry=Object.assign(Object.assign({},o.telemetry),{metadata:l}):a==="omc"?o.telemetry=Object.assign(Object.assign({},o.telemetry),{omitContext:l}):o[a]=l}return o}static async fromId(e,r){if(r){let n=await(await e.client).hgetall(e.toKey(r));return(0,cr.isEmpty)(n)?void 0:this.fromJSON(e,n,r)}}static addJobLog(e,r,i,n){return e.scripts.addLog(r,i,n)}toJSON(){let e=this,{queue:r,scripts:i}=e;return JU.__rest(e,["queue","scripts"])}asJSON(){return(0,cr.removeUndefinedFields)({id:this.id,name:this.name,data:JSON.stringify(typeof this.data>"u"?{}:this.data),opts:t.optsAsJSON(this.opts),parent:this.parent?Object.assign({},this.parent):void 0,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={},r=cr.optsEncodeMap){let i=Object.entries(e),n={};for(let[o,s]of i)if(!(typeof s>"u"))if(o in r){let l=r[o];n[l]=s}else o==="telemetry"?(s.metadata!==void 0&&(n.tm=s.metadata),s.omitContext!==void 0&&(n.omc=s.omitContext)):n[o]=s;return n}asJSONSandbox(){return Object.assign(Object.assign({},this.asJSON()),{queueName:this.queueName,queueQualifiedName:this.queueQualifiedName,prefix:this.prefix})}updateData(e){return this.data=e,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 t.addJobLog(this.queue,this.id,e,this.opts.keepLogs)}async removeChildDependency(){return await this.scripts.removeChildDependency(this.id,this.parentKey)?(this.parent=void 0,this.parentKey=void 0,!0):!1}async clearLogs(e){let r=await this.queue.client,i=this.toKey(this.id)+":logs";e?await r.ltrim(i,-e,-1):await r.del(i)}async remove({removeChildren:e=!0}={}){await this.queue.waitUntilReady();let r=this.queue,i=this;if(await this.scripts.remove(i.id,e))r.emit("removed",i);else throw new Error(`Job ${this.id} could not be removed because it is locked by another worker`)}async removeUnprocessedChildren(){let e=this.id;await this.scripts.removeUnprocessedChildren(e)}extendLock(e,r){return this.scripts.extendLock(this.id,e,r)}async moveToCompleted(e,r,i=!0){return this.queue.trace(vr.SpanKind.INTERNAL,"complete",this.queue.name,async n=>{this.setSpanJobAttributes(n),await this.queue.waitUntilReady(),this.returnvalue=e||void 0;let o=(0,cr.tryCatch)(JSON.stringify,JSON,[e]);if(o===cr.errorObject)throw cr.errorObject.value;let s=this.scripts.moveToCompletedArgs(this,o,this.opts.removeOnComplete,r,i),a=await this.scripts.moveToFinished(this.id,s);return this.finishedOn=s[this.scripts.moveToFinishedKeys.length+1],this.attemptsMade+=1,this.recordJobMetrics("completed"),a})}async moveToWait(e){let r=await this.scripts.moveJobFromActiveToWait(this.id,e);return this.recordJobMetrics("waiting"),r}async shouldRetryJob(e){if(this.attemptsMade+1<this.opts.attempts&&!this.discarded&&!(e instanceof qoe.UnrecoverableError||e.name=="UnrecoverableError")){let r=this.queue.opts,i=await FU.Backoffs.calculate(this.opts.backoff,this.attemptsMade+1,e,this,r.settings&&r.settings.backoffStrategy);return[i!=-1,i==-1?0:i]}else return[!1,0]}async moveToFailed(e,r,i=!1){this.failedReason=e?.message;let[n,o]=await this.shouldRetryJob(e);return this.queue.trace(vr.SpanKind.INTERNAL,this.getSpanOperation(n,o),this.queue.name,async(s,a)=>{var l,c;this.setSpanJobAttributes(s);let u;!(!((c=(l=this.opts)===null||l===void 0?void 0:l.telemetry)===null||c===void 0)&&c.omitContext)&&a&&(u=a);let d;this.updateStacktrace(e);let f={failedReason:this.failedReason,stacktrace:JSON.stringify(this.stacktrace),tm:u},p;if(n)o?(d=await this.scripts.moveToDelayed(this.id,Date.now(),o,r,{fieldsToUpdate:f,fetchNext:i}),this.recordJobMetrics("delayed")):(d=await this.scripts.retryJob(this.id,this.opts.lifo,r,{fieldsToUpdate:f}),this.recordJobMetrics("retried"));else{let m=this.scripts.moveToFailedArgs(this,this.failedReason,this.opts.removeOnFail,r,i,f);d=await this.scripts.moveToFinished(this.id,m),p=m[this.scripts.moveToFinishedKeys.length+1],this.recordJobMetrics("failed")}return p&&typeof p=="number"&&(this.finishedOn=p),o&&typeof o=="number"&&(this.delay=o),this.attemptsMade+=1,d})}getSpanOperation(e,r){return e?r?"delay":"retry":"fail"}recordJobMetrics(e){var r,i;let n=(i=(r=this.queue.opts)===null||r===void 0?void 0:r.telemetry)===null||i===void 0?void 0:i.meter;if(!n)return;let o={[vr.TelemetryAttributes.QueueName]:this.queue.name,[vr.TelemetryAttributes.JobName]:this.name,[vr.TelemetryAttributes.JobStatus]:e},a={completed:vr.MetricNames.JobsCompleted,failed:vr.MetricNames.JobsFailed,delayed:vr.MetricNames.JobsDelayed,retried:vr.MetricNames.JobsRetried,waiting:vr.MetricNames.JobsWaiting,"waiting-children":vr.MetricNames.JobsWaitingChildren}[e];if(n.createCounter(a,{description:`Number of jobs ${e}`,unit:"1"}).add(1,o),this.processedOn){let c=Date.now()-this.processedOn;n.createHistogram(vr.MetricNames.JobDuration,{description:"Job processing duration",unit:"ms"}).record(c,o)}}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(){let r=await(await this.queue.client).hgetall(this.toKey(`${this.id}:processed`));if(r)return(0,cr.parseObjectValues)(r)}async getIgnoredChildrenFailures(){return(await this.queue.client).hgetall(this.toKey(`${this.id}:failed`))}async getFailedChildrenValues(){return(await this.queue.client).hgetall(this.toKey(`${this.id}:failed`))}async getDependencies(e={}){let i=(await this.queue.client).pipeline();if(!e.processed&&!e.unprocessed&&!e.ignored&&!e.failed){i.hgetall(this.toKey(`${this.id}:processed`)),i.smembers(this.toKey(`${this.id}:dependencies`)),i.hgetall(this.toKey(`${this.id}:failed`)),i.zrange(this.toKey(`${this.id}:unsuccessful`),0,-1);let[[n,o],[s,a],[l,c],[u,d]]=await i.exec();return{processed:(0,cr.parseObjectValues)(o),unprocessed:a,failed:d,ignored:c}}else{let n={cursor:0,count:20},o=[];if(e.processed){o.push("processed");let y=Object.assign(Object.assign({},n),e.processed);i.hscan(this.toKey(`${this.id}:processed`),y.cursor,{COUNT:y.count})}if(e.unprocessed){o.push("unprocessed");let y=Object.assign(Object.assign({},n),e.unprocessed);i.sscan(this.toKey(`${this.id}:dependencies`),y.cursor,{COUNT:y.count})}if(e.ignored){o.push("ignored");let y=Object.assign(Object.assign({},n),e.ignored);i.hscan(this.toKey(`${this.id}:failed`),y.cursor,{COUNT:y.count})}let s;if(e.failed){o.push("failed");let y=Object.assign(Object.assign({},n),e.failed);s=y.cursor+y.count,i.zrange(this.toKey(`${this.id}:unsuccessful`),y.cursor,y.count-1)}let a=await i.exec(),l,c,u,d,f,p,m;return o.forEach((y,w)=>{switch(y){case"processed":{l=a[w][1][0];let _=a[w][1][1],A={};for(let O=0;O<_.length;++O)O%2&&(A[_[O-1]]=JSON.parse(_[O]));c=A;break}case"failed":{f=a[w][1];break}case"ignored":{p=a[w][1][0];let _=a[w][1][1],A={};for(let O=0;O<_.length;++O)O%2&&(A[_[O-1]]=_[O]);m=A;break}case"unprocessed":{u=a[w][1][0],d=a[w][1][1];break}}}),Object.assign(Object.assign(Object.assign(Object.assign({},l?{processed:c,nextProcessedCursor:Number(l)}:{}),p?{ignored:m,nextIgnoredCursor:Number(p)}:{}),s?{failed:f,nextFailedCursor:s}:{}),u?{unprocessed:d,nextUnprocessedCursor:Number(u)}:{})}}async getDependenciesCount(e={}){let r=[];Object.entries(e).forEach(([s,a])=>{a&&r.push(s)});let i=r.length?r:["processed","unprocessed","ignored","failed"],n=await this.scripts.getDependencyCounts(this.id,i),o={};return n.forEach((s,a)=>{o[`${i[a]}`]=s||0}),o}async waitUntilFinished(e,r){await this.queue.waitUntilReady();let i=this.id;return new Promise(async(n,o)=>{let s;r&&(s=setTimeout(()=>l(`Job wait ${this.name} timed out before finishing, no finish notification arrived after ${r}ms (id=${i})`),r));function a(y){d(),n(y.returnvalue)}function l(y){d(),o(new Error(y.failedReason||y))}let c=`completed:${i}`,u=`failed:${i}`;e.on(c,a),e.on(u,l),this.queue.on("closing",l);let d=()=>{clearInterval(s),e.removeListener(c,a),e.removeListener(u,l),this.queue.removeListener("closing",l)};await e.waitUntilReady();let[f,p]=await this.scripts.isFinished(i,!0);f!=0&&(f==-1||f==2?l({failedReason:p}):a({returnvalue:qU(p)}))})}async moveToDelayed(e,r){let i=Date.now(),n=e-i,o=n>0?n:0;await this.scripts.moveToDelayed(this.id,i,o,r,{skipAttempt:!0}),this.delay=o,this.recordJobMetrics("delayed")}async moveToWaitingChildren(e,r={}){let i=await this.scripts.moveToWaitingChildren(this.id,e,r);return i&&this.recordJobMetrics("waiting-children"),i}async promote(){let e=this.id;await this.scripts.promote(e),this.delay=0}async retry(e="failed",r={}){await this.scripts.reprocessJob(this,e,r),this.failedReason=null,this.finishedOn=null,this.processedOn=null,this.returnvalue=null,r.resetAttemptsMade&&(this.attemptsMade=0),r.resetAttemptsStarted&&(this.attemptsStarted=0)}discard(){this.discarded=!0}async isInZSet(e){return await(await this.queue.client).zscore(this.queue.toKey(e),this.id)!==null}async isInList(e){return this.scripts.isJobInList(this.queue.toKey(e),this.id)}addJob(e,r){let i=this.asJSON();return this.validateOptions(i),this.scripts.addJob(e,i,i.opts,this.id,r)}async removeDeduplicationKey(){return this.deduplicationId?await this.scripts.removeDeduplicationKey(this.deduplicationId,this.id)>0:!1}validateOptions(e){var r,i,n,o,s,a,l,c;let u=["removeDependencyOnFailure","failParentOnFailure","continueParentOnFailure","ignoreDependencyOnFailure"];if(this.opts.sizeLimit&&(0,cr.lengthInUtf8Bytes)(e.data)>this.opts.sizeLimit)throw new Error(`The size of job ${this.name} exceeds the limit ${this.opts.sizeLimit} bytes`);if(this.opts.delay&&this.opts.repeat&&!(!((r=this.opts.repeat)===null||r===void 0)&&r.count))throw new Error("Delay and repeat options cannot be used together");let f=u.filter(p=>this.opts[p]);if(f.length>1){let p=f.join(", ");throw new Error(`The following options cannot be used together: ${p}`)}if(!((i=this.opts)===null||i===void 0)&&i.jobId){if(`${parseInt(this.opts.jobId,10)}`===((n=this.opts)===null||n===void 0?void 0:n.jobId))throw new Error("Custom Id cannot be integers");if(!((o=this.opts)===null||o===void 0)&&o.jobId.includes(":")&&((a=(s=this.opts)===null||s===void 0?void 0:s.jobId)===null||a===void 0?void 0:a.split(":").length)!==3)throw new Error("Custom Id cannot contain :")}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>Bi.PRIORITY_LIMIT)throw new Error(`Priority should be between 0 and ${Bi.PRIORITY_LIMIT}`)}if(this.opts.deduplication){if(!(!((l=this.opts.deduplication)===null||l===void 0)&&l.id))throw new Error("Deduplication id must be provided");if(this.parentKey)throw new Error("Deduplication and parent options cannot be used together")}if(this.opts.debounce){if(!(!((c=this.opts.debounce)===null||c===void 0)&&c.id))throw new Error("Debounce id must be provided");if(this.parentKey)throw new Error("Debounce and parent options cannot be used together")}if(typeof this.opts.backoff=="object"&&typeof this.opts.backoff.jitter=="number"&&(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||[],e?.stack&&(this.stacktrace.push(e.stack),this.opts.stackTraceLimit===0?this.stacktrace=[]:this.opts.stackTraceLimit&&(this.stacktrace=this.stacktrace.slice(-this.opts.stackTraceLimit)))}setSpanJobAttributes(e){e?.setAttributes({[vr.TelemetryAttributes.JobName]:this.name,[vr.TelemetryAttributes.JobId]:this.id})}};Bi.Job=G0;function Goe(t){if(!t)return[];let e=(0,cr.tryCatch)(JSON.parse,JSON,[t]);return e===cr.errorObject||!(e instanceof Array)?[]:e}function qU(t){let e=(0,cr.tryCatch)(JSON.parse,JSON,[t]);if(e!==cr.errorObject)return e;zoe("corrupted returnvalue: "+t,e)}});var sm=h(om=>{"use strict";Object.defineProperty(om,"__esModule",{value:!0});om.QueueKeys=void 0;var V0=class{constructor(e="bull"){this.prefix=e}getKeys(e){let r={};return["","active","wait","waiting-children","paused","id","delayed","prioritized","stalled-check","completed","failed","stalled","repeat","limiter","meta","events","pc","marker","de"].forEach(i=>{r[i]=this.toKey(e,i)}),r}toKey(e,r){return`${this.getQueueQualifiedName(e)}:${r}`}getQueueQualifiedName(e){return`${this.prefix}:${e}`}};om.QueueKeys=V0});var zU=h((Nke,Voe)=>{Voe.exports={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},hexpireat:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hexpiretime:{arity:-5,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},hgetdel:{arity:-5,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hgetex:{arity:-5,flags:["write","fast"],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},hpersist:{arity:-5,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hpexpire:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hpexpireat:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hpexpiretime:{arity:-5,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hpttl:{arity:-5,flags:["readonly","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},hsetex:{arity:-6,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},httl:{arity:-5,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},xdelex:{arity:-5,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 Qo=h(Rr=>{"use strict";var Boe=Rr&&Rr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Rr,"__esModule",{value:!0});Rr.getKeyIndexes=Rr.hasFlag=Rr.exists=Rr.list=void 0;var am=Boe(zU());Rr.list=Object.keys(am.default);var B0={};Rr.list.forEach(t=>{B0[t]=am.default[t].flags.reduce(function(e,r){return e[r]=!0,e},{})});function Woe(t,e){return t=e?.caseInsensitive?String(t).toLowerCase():t,!!am.default[t]}Rr.exists=Woe;function Zoe(t,e,r){if(t=r?.nameCaseInsensitive?String(t).toLowerCase():t,!B0[t])throw new Error("Unknown command "+t);return!!B0[t][e]}Rr.hasFlag=Zoe;function Hoe(t,e,r){t=r?.nameCaseInsensitive?String(t).toLowerCase():t;let i=am.default[t];if(!i)throw new Error("Unknown command "+t);if(!Array.isArray(e))throw new Error("Expect args to be an array");let n=[],o=!!(r&&r.parseExternalKey),s=(l,c)=>{let u=[],d=Number(l[c]);for(let f=0;f<d;f++)u.push(f+c+1);return u},a=(l,c,u)=>{for(let d=c;d<l.length-1;d+=1)if(String(l[d]).toLowerCase()===u.toLowerCase())return d+1;return null};switch(t){case"zunionstore":case"zinterstore":case"zdiffstore":n.push(0,...s(e,1));break;case"eval":case"evalsha":case"eval_ro":case"evalsha_ro":case"fcall":case"fcall_ro":case"blmpop":case"bzmpop":n.push(...s(e,1));break;case"sintercard":case"lmpop":case"zunion":case"zinter":case"zmpop":case"zintercard":case"zdiff":{n.push(...s(e,0));break}case"georadius":{n.push(0);let l=a(e,5,"STORE");l&&n.push(l);let c=a(e,5,"STOREDIST");c&&n.push(c);break}case"georadiusbymember":{n.push(0);let l=a(e,4,"STORE");l&&n.push(l);let c=a(e,4,"STOREDIST");c&&n.push(c);break}case"sort":case"sort_ro":n.push(0);for(let l=1;l<e.length-1;l++){let c=e[l];if(typeof c!="string")continue;let u=c.toUpperCase();u==="GET"?(l+=1,c=e[l],c!=="#"&&(o?n.push([l,GU(c)]):n.push(l))):u==="BY"?(l+=1,o?n.push([l,GU(e[l])]):n.push(l)):u==="STORE"&&(l+=1,n.push(l))}break;case"migrate":if(e[2]==="")for(let l=5;l<e.length-1;l++){let c=e[l];if(typeof c=="string"&&c.toUpperCase()==="KEYS"){for(let u=l+1;u<e.length;u++)n.push(u);break}}else n.push(2);break;case"xreadgroup":case"xread":for(let l=t==="xread"?0:3;l<e.length-1;l++)if(String(e[l]).toUpperCase()==="STREAMS"){for(let c=l+1;c<=l+(e.length-1-l)/2;c++)n.push(c);break}break;default:if(i.step>0){let l=i.keyStart-1,c=i.keyStop>0?i.keyStop:e.length+i.keyStop+1;for(let u=l;u<c;u+=i.step)n.push(u)}break}return n}Rr.getKeyIndexes=Hoe;function GU(t){typeof t!="string"&&(t=String(t));let e=t.indexOf("->");return e===-1?t.length:e}});var VU=h(Wi=>{"use strict";Object.defineProperty(Wi,"__esModule",{value:!0});Wi.tryCatch=Wi.errorObj=void 0;Wi.errorObj={e:{}};var W0;function Yoe(t,e){try{let r=W0;return W0=null,r.apply(this,arguments)}catch(r){return Wi.errorObj.e=r,Wi.errorObj}}function Xoe(t){return W0=t,Yoe}Wi.tryCatch=Xoe});var Zi=h(Z0=>{"use strict";Object.defineProperty(Z0,"__esModule",{value:!0});var Ma=VU();function BU(t){setTimeout(function(){throw t},0)}function Qoe(t,e,r){return typeof e=="function"&&t.then(i=>{let n;r!==void 0&&Object(r).spread&&Array.isArray(i)?n=Ma.tryCatch(e).apply(void 0,[null].concat(i)):n=i===void 0?Ma.tryCatch(e)(null):Ma.tryCatch(e)(null,i),n===Ma.errorObj&&BU(n.e)},i=>{if(!i){let o=new Error(i+"");Object.assign(o,{cause:i}),i=o}let n=Ma.tryCatch(e)(i);n===Ma.errorObj&&BU(n.e)}),t}Z0.default=Qoe});var HU=h((Jke,ZU)=>{"use strict";var WU=U("assert"),ou=U("util");function Na(t){Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}ou.inherits(Na,Error);Object.defineProperty(Na.prototype,"name",{value:"RedisError",configurable:!0,writable:!0});function H0(t,e,r){WU(e),WU.strictEqual(typeof r,"number"),Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0});let i=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=i,this.offset=r,this.buffer=e}ou.inherits(H0,Na);Object.defineProperty(H0.prototype,"name",{value:"ParserError",configurable:!0,writable:!0});function Y0(t){Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0});let e=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=e}ou.inherits(Y0,Na);Object.defineProperty(Y0.prototype,"name",{value:"ReplyError",configurable:!0,writable:!0});function lm(t){Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}ou.inherits(lm,Na);Object.defineProperty(lm.prototype,"name",{value:"AbortError",configurable:!0,writable:!0});function X0(t){Object.defineProperty(this,"message",{value:t||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}ou.inherits(X0,lm);Object.defineProperty(X0.prototype,"name",{value:"InterruptError",configurable:!0,writable:!0});ZU.exports={RedisError:Na,ParserError:H0,ReplyError:Y0,AbortError:lm,InterruptError:X0}});var QU=h((Fke,XU)=>{"use strict";var YU=U("assert"),La=class extends Error{get name(){return this.constructor.name}},Q0=class extends La{constructor(e,r,i){YU(r),YU.strictEqual(typeof i,"number");let n=Error.stackTraceLimit;Error.stackTraceLimit=2,super(e),Error.stackTraceLimit=n,this.offset=i,this.buffer=r}get name(){return this.constructor.name}},ew=class extends La{constructor(e){let r=Error.stackTraceLimit;Error.stackTraceLimit=2,super(e),Error.stackTraceLimit=r}get name(){return this.constructor.name}},cm=class extends La{get name(){return this.constructor.name}},tw=class extends cm{get name(){return this.constructor.name}};XU.exports={RedisError:La,ParserError:Q0,ReplyError:ew,AbortError:cm,InterruptError:tw}});var es=h((qke,e$)=>{"use strict";var ese=process.version.charCodeAt(1)<55&&process.version.charCodeAt(2)===46?HU():QU();e$.exports=ese});var su=h((zke,rw)=>{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],tse=function(e){for(var r,i=0,n=0,o=[],s=e.length;i<s;i++)r=e.charCodeAt(i),r<128?o[n++]=r:r<2048?(o[n++]=r>>6|192,o[n++]=r&63|128):(r&64512)===55296&&i+1<e.length&&(e.charCodeAt(i+1)&64512)===56320?(r=65536+((r&1023)<<10)+(e.charCodeAt(++i)&1023),o[n++]=r>>18|240,o[n++]=r>>12&63|128,o[n++]=r>>6&63|128,o[n++]=r&63|128):(o[n++]=r>>12|224,o[n++]=r>>6&63|128,o[n++]=r&63|128);return o},r$=rw.exports=function(e){for(var r,i=0,n=-1,o=0,s=0,a=typeof e=="string"?tse(e):e,l=a.length;i<l;){if(r=a[i++],n===-1)r===123&&(n=i);else if(r!==125)s=t$[(r^s>>8)&255]^s<<8;else if(i-1!==n)return s&16383;o=t$[(r^o>>8)&255]^o<<8}return o&16383};rw.exports.generateMulti=function(e){for(var r=1,i=e.length,n=r$(e[0]);r<i;)if(r$(e[r++])!==n)return-1;return n}});var n$=h(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.parseBlockOption=Ua.parseSecondsArgument=void 0;var nw=t=>{if(typeof t=="number")return t;if(Buffer.isBuffer(t))return nw(t.toString());if(typeof t=="string"){let e=Number(t);return Number.isFinite(e)?e:void 0}},rse=t=>{if(typeof t=="string")return t;if(Buffer.isBuffer(t))return t.toString()},nse=t=>{let e=nw(t);if(e!==void 0)return e<=0?0:e*1e3};Ua.parseSecondsArgument=nse;var ise=t=>{for(let e=0;e<t.length;e++){let r=rse(t[e]);if(r&&r.toLowerCase()==="block"){let i=nw(t[e+1]);return i===void 0?void 0:i<=0?0:i}}return null};Ua.parseBlockOption=ise});var pi=h(sw=>{"use strict";Object.defineProperty(sw,"__esModule",{value:!0});var i$=Qo(),ose=su(),sse=Zi(),ts=bt(),iw=n$(),$n=class t{constructor(e,r=[],i={},n){if(this.name=e,this.inTransaction=!1,this.isResolved=!1,this.transformed=!1,this.replyEncoding=i.replyEncoding,this.errorStack=i.errorStack,this.args=r.flat(),this.callback=n,this.initPromise(),i.keyPrefix){let o=i.keyPrefix instanceof Buffer,s=o?i.keyPrefix:null;this._iterateKeys(a=>a instanceof Buffer?(s===null&&(s=Buffer.from(i.keyPrefix)),Buffer.concat([s,a])):o?Buffer.concat([i.keyPrefix,Buffer.from(String(a))]):i.keyPrefix+a)}i.readOnly&&(this.isReadOnly=!0)}static checkFlag(e,r){return r=r.toLowerCase(),!!this.getFlagMap()[e][r]}static setArgumentTransformer(e,r){this._transformer.argument[e]=r}static setReplyTransformer(e,r){this._transformer.reply[e]=r}static getFlagMap(){return this.flagMap||(this.flagMap=Object.keys(t.FLAGS).reduce((e,r)=>(e[r]={},t.FLAGS[r].forEach(i=>{e[r][i]=!0}),e),{})),this.flagMap}getSlot(){if(typeof this.slot>"u"){let e=this.getKeys()[0];this.slot=e==null?null:ose(e)}return this.slot}getKeys(){return this._iterateKeys()}toWritable(e){let r,i="*"+(this.args.length+1)+`\r
1129
1129
  $`+Buffer.byteLength(this.name)+`\r
1130
1130
  `+this.name+`\r
1131
1131
  `;if(this.bufferMode){let n=new ow;n.push(i);for(let o=0;o<this.args.length;++o){let s=this.args[o];s instanceof Buffer?s.length===0?n.push(`$0\r
@@ -1136,8 +1136,8 @@ $`+Buffer.byteLength(this.name)+`\r
1136
1136
  `+s+`\r
1137
1137
  `)}r=n.toBuffer()}else{r=i;for(let n=0;n<this.args.length;++n){let o=this.args[n];r+="$"+Buffer.byteLength(o)+`\r
1138
1138
  `+o+`\r
1139
- `}}return r}stringifyArguments(){for(let e=0;e<this.args.length;++e){let r=this.args[e];typeof r=="string"||(r instanceof Buffer?this.bufferMode=!0:this.args[e]=(0,ts.toArg)(r))}}transformReply(e){this.replyEncoding&&(e=(0,ts.convertBufferToString)(e,this.replyEncoding));let r=t._transformer.reply[this.name];return r&&(e=r(e)),e}setTimeout(e){this._commandTimeoutTimer||(this._commandTimeoutTimer=setTimeout(()=>{this.isResolved||this.reject(new Error("Command timed out"))},e))}setBlockingTimeout(e){if(e<=0)return;this._blockingTimeoutTimer&&(clearTimeout(this._blockingTimeoutTimer),this._blockingTimeoutTimer=void 0);let r=Date.now();this._blockingDeadline===void 0&&(this._blockingDeadline=r+e);let i=this._blockingDeadline-r;if(i<=0){this.resolve(null);return}this._blockingTimeoutTimer=setTimeout(()=>{if(this.isResolved){this._blockingTimeoutTimer=void 0;return}this._blockingTimeoutTimer=void 0,this.resolve(null)},i)}extractBlockingTimeout(){let e=this.args;if(!e||e.length===0)return;let r=this.name.toLowerCase();if(t.checkFlag("LAST_ARG_TIMEOUT_COMMANDS",r))return(0,iw.parseSecondsArgument)(e[e.length-1]);if(t.checkFlag("FIRST_ARG_TIMEOUT_COMMANDS",r))return(0,iw.parseSecondsArgument)(e[0]);if(t.checkFlag("BLOCK_OPTION_COMMANDS",r))return(0,iw.parseBlockOption)(e)}_clearTimers(){let e=this._commandTimeoutTimer;e&&(clearTimeout(e),delete this._commandTimeoutTimer);let r=this._blockingTimeoutTimer;r&&(clearTimeout(r),delete this._blockingTimeoutTimer)}initPromise(){let e=new Promise((r,i)=>{if(!this.transformed){this.transformed=!0;let n=t._transformer.argument[this.name];n&&(this.args=n(this.args)),this.stringifyArguments()}this.resolve=this._convertValue(r),this.reject=n=>{this._clearTimers(),this.errorStack?i((0,ts.optimizeErrorStack)(n,this.errorStack.stack,__dirname)):i(n)}});this.promise=(0,sse.default)(e,this.callback)}_iterateKeys(e=r=>r){if(typeof this.keys>"u"&&(this.keys=[],(0,i$.exists)(this.name,{caseInsensitive:!0}))){let r=(0,i$.getKeyIndexes)(this.name,this.args,{nameCaseInsensitive:!0});for(let i of r)this.args[i]=e(this.args[i]),this.keys.push(this.args[i])}return this.keys}_convertValue(e){return r=>{try{this._clearTimers(),e(this.transformReply(r)),this.isResolved=!0}catch(i){this.reject(i)}return this.promise}}};sw.default=$n;$n.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"],HANDSHAKE_COMMANDS:["auth","select","client","readonly","info"],IGNORE_RECONNECT_ON_ERROR:["client"],BLOCKING_COMMANDS:["blpop","brpop","brpoplpush","blmove","bzpopmin","bzpopmax","bzmpop","blmpop","xread","xreadgroup"],LAST_ARG_TIMEOUT_COMMANDS:["blpop","brpop","brpoplpush","blmove","bzpopmin","bzpopmax"],FIRST_ARG_TIMEOUT_COMMANDS:["bzmpop","blmpop"],BLOCK_OPTION_COMMANDS:["xread","xreadgroup"]};$n._transformer={argument:{},reply:{}};var o$=function(t){if(t.length===1){if(t[0]instanceof Map)return(0,ts.convertMapToArray)(t[0]);if(typeof t[0]=="object"&&t[0]!==null)return(0,ts.convertObjectToArray)(t[0])}return t},s$=function(t){if(t.length===2){if(t[1]instanceof Map)return[t[0]].concat((0,ts.convertMapToArray)(t[1]));if(typeof t[1]=="object"&&t[1]!==null)return[t[0]].concat((0,ts.convertObjectToArray)(t[1]))}return t};$n.setArgumentTransformer("mset",o$);$n.setArgumentTransformer("msetnx",o$);$n.setArgumentTransformer("hset",s$);$n.setArgumentTransformer("hmset",s$);$n.setReplyTransformer("hgetall",function(t){if(Array.isArray(t)){let e={};for(let r=0;r<t.length;r+=2){let i=t[r],n=t[r+1];i in e?Object.defineProperty(e,i,{value:n,configurable:!0,enumerable:!0,writable:!0}):e[i]=n}return e}return t});var ow=class{constructor(){this.length=0,this.items=[]}push(e){this.length+=Buffer.byteLength(e),this.items.push(e)}toBuffer(){let e=Buffer.allocUnsafe(this.length),r=0;for(let i of this.items){let n=Buffer.byteLength(i);Buffer.isBuffer(i)?i.copy(e,r):e.write(i,r,n),r+=n}return e}}});var a$=h(aw=>{"use strict";Object.defineProperty(aw,"__esModule",{value:!0});var ase=es(),um=class extends ase.RedisError{constructor(e,r){super(e),this.lastNodeError=r,Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}};aw.default=um;um.defaultMessage="Failed to refresh slots cache."});var dm=h(cw=>{"use strict";Object.defineProperty(cw,"__esModule",{value:!0});var lse=U("stream"),lw=class extends lse.Readable{constructor(e){super(e),this.opt=e,this._redisCursor="0",this._redisDrained=!1}_read(){if(this._redisDrained){this.push(null);return}let e=[this._redisCursor];this.opt.key&&e.unshift(this.opt.key),this.opt.match&&e.push("MATCH",this.opt.match),this.opt.type&&e.push("TYPE",this.opt.type),this.opt.count&&e.push("COUNT",String(this.opt.count)),this.opt.noValues&&e.push("NOVALUES"),this.opt.redis[this.opt.command](e,(r,i)=>{if(r){this.emit("error",r);return}this._redisCursor=i[0]instanceof Buffer?i[0].toString():i[0],this._redisCursor==="0"&&(this._redisDrained=!0),this.push(i[1])})}close(){this._redisDrained=!0}};cw.default=lw});var m$=h(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.executeWithAutoPipelining=ut.getFirstValueInFlattenedArray=ut.shouldUseAutoPipelining=ut.notAllowedAutoPipelineCommands=ut.kCallbacks=ut.kExec=void 0;var u$=yf(),cse=su(),l$=Zi(),c$=Qo();ut.kExec=Symbol("exec");ut.kCallbacks=Symbol("callbacks");ut.notAllowedAutoPipelineCommands=["auth","info","script","quit","cluster","pipeline","multi","subscribe","psubscribe","unsubscribe","unpsubscribe","select","client"];function d$(t,e){if(t._runningAutoPipelines.has(e)||!t._autoPipelines.has(e))return;t._runningAutoPipelines.add(e);let r=t._autoPipelines.get(e);t._autoPipelines.delete(e);let i=r[ut.kCallbacks];r[ut.kCallbacks]=null,r.exec(function(n,o){if(t._runningAutoPipelines.delete(e),n)for(let s=0;s<i.length;s++)process.nextTick(i[s],n);else for(let s=0;s<i.length;s++)process.nextTick(i[s],...o[s]);t._autoPipelines.has(e)&&d$(t,e)})}function use(t,e,r){return e&&t.options.enableAutoPipelining&&!t.isPipeline&&!ut.notAllowedAutoPipelineCommands.includes(r)&&!t.options.autoPipeliningIgnoredCommands.includes(r)}ut.shouldUseAutoPipelining=use;function p$(t){for(let e=0;e<t.length;e++){let r=t[e];if(typeof r=="string")return r;if(Array.isArray(r)||(0,u$.isArguments)(r)){if(r.length===0)continue;return r[0]}let i=[r].flat();if(i.length>0)return i[0]}}ut.getFirstValueInFlattenedArray=p$;function f$(t,e,r,i,n){if(t.isCluster&&!t.slots.length)return t.status==="wait"&&t.connect().catch(u$.noop),(0,l$.default)(new Promise(function(c,u){t.delayUntilReady(d=>{if(d){u(d);return}f$(t,e,r,i,null).then(c,u)})}),n);let o=t.options.keyPrefix||"",s=t.isCluster?t.slots[cse(`${o}${p$(i)}`)].join(","):"main";if(t.isCluster&&t.options.scaleReads!=="master"){let c=(0,c$.exists)(r)&&(0,c$.hasFlag)(r,"readonly");s+=c?":read":":write"}if(!t._autoPipelines.has(s)){let c=t.pipeline();c[ut.kExec]=!1,c[ut.kCallbacks]=[],t._autoPipelines.set(s,c)}let a=t._autoPipelines.get(s);a[ut.kExec]||(a[ut.kExec]=!0,setImmediate(d$,t,s));let l=new Promise(function(c,u){a[ut.kCallbacks].push(function(d,f){if(d){u(d);return}c(f)}),e==="call"&&i.unshift(r),a[e](...i)});return(0,l$.default)(l,n)}ut.executeWithAutoPipelining=f$});var h$=h(dw=>{"use strict";Object.defineProperty(dw,"__esModule",{value:!0});var dse=U("crypto"),pse=pi(),fse=Zi(),uw=class{constructor(e,r=null,i="",n=!1){this.lua=e,this.numberOfKeys=r,this.keyPrefix=i,this.readOnly=n,this.sha=(0,dse.createHash)("sha1").update(e).digest("hex");let o=this.sha,s=new WeakSet;this.Command=class extends pse.default{toWritable(l){let c=this.reject;return this.reject=u=>{u.message.indexOf("NOSCRIPT")!==-1&&s.delete(l),c.call(this,u)},s.has(l)?this.name==="eval"&&(this.name="evalsha",this.args[0]=o):(s.add(l),this.name="eval",this.args[0]=e),super.toWritable(l)}}}execute(e,r,i,n){typeof this.numberOfKeys=="number"&&r.unshift(this.numberOfKeys),this.keyPrefix&&(i.keyPrefix=this.keyPrefix),this.readOnly&&(i.readOnly=!0);let o=new this.Command("evalsha",[this.sha,...r],i);return o.promise=o.promise.catch(s=>{if(s.message.indexOf("NOSCRIPT")===-1)throw s;let a=new this.Command("evalsha",[this.sha,...r],i);return(e.isPipeline?e.redis:e).sendCommand(a)}),(0,fse.default)(o.promise,n),e.sendCommand(o)}};dw.default=uw});var fm=h(fw=>{"use strict";Object.defineProperty(fw,"__esModule",{value:!0});var mse=Qo(),pm=m$(),hse=pi(),yse=h$(),fi=class{constructor(){this.options={},this.scriptsSet={},this.addedBuiltinSet=new Set}getBuiltinCommands(){return pw.slice(0)}createBuiltinCommand(e){return{string:Hi(null,e,"utf8"),buffer:Hi(null,e,null)}}addBuiltinCommand(e){this.addedBuiltinSet.add(e),this[e]=Hi(e,e,"utf8"),this[e+"Buffer"]=Hi(e+"Buffer",e,null)}defineCommand(e,r){let i=new yse.default(r.lua,r.numberOfKeys,this.options.keyPrefix,r.readOnly);this.scriptsSet[e]=i,this[e]=y$(e,e,i,"utf8"),this[e+"Buffer"]=y$(e+"Buffer",e,i,null)}sendCommand(e,r,i){throw new Error('"sendCommand" is not implemented')}},pw=mse.list.filter(t=>t!=="monitor");pw.push("sentinel");pw.forEach(function(t){fi.prototype[t]=Hi(t,t,"utf8"),fi.prototype[t+"Buffer"]=Hi(t+"Buffer",t,null)});fi.prototype.call=Hi("call","utf8");fi.prototype.callBuffer=Hi("callBuffer",null);fi.prototype.send_command=fi.prototype.call;function Hi(t,e,r){return typeof r>"u"&&(r=e,e=null),function(...i){let n=e||i.shift(),o=i[i.length-1];typeof o=="function"?i.pop():o=void 0;let s={errorStack:this.options.showFriendlyErrorStack?new Error:void 0,keyPrefix:this.options.keyPrefix,replyEncoding:r};return(0,pm.shouldUseAutoPipelining)(this,t,n)?(0,pm.executeWithAutoPipelining)(this,t,n,i,o):this.sendCommand(new hse.default(n,i,s,o))}}function y$(t,e,r,i){return function(...n){let o=typeof n[n.length-1]=="function"?n.pop():void 0,s={replyEncoding:i};return this.options.showFriendlyErrorStack&&(s.errorStack=new Error),(0,pm.shouldUseAutoPipelining)(this,t,e)?(0,pm.executeWithAutoPipelining)(this,t,e,n,o):r.execute(this,n,s,o)}}fw.default=fi});var yw=h(hw=>{"use strict";Object.defineProperty(hw,"__esModule",{value:!0});var mw=su(),g$=Qo(),b$=Zi(),gse=U("util"),bse=pi(),vse=bt(),Sse=fm();function Ese(t,e){let r=mw(e[0]),i=t._groupsBySlot[r];for(let n=1;n<e.length;n++)if(t._groupsBySlot[mw(e[n])]!==i)return-1;return r}var Yi=class extends Sse.default{constructor(e){super(),this.redis=e,this.isPipeline=!0,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(i=>{let n=e.scriptsSet[i];this._shaToScript[n.sha]=n,this[i]=e[i],this[i+"Buffer"]=e[i+"Buffer"]}),e.addedBuiltinSet.forEach(i=>{this[i]=e[i],this[i+"Buffer"]=e[i+"Buffer"]}),this.promise=new Promise((i,n)=>{this.resolve=i,this.reject=n});let r=this;Object.defineProperty(this,"length",{get:function(){return r._queue.length}})}fillResult(e,r){if(this._queue[r].name==="exec"&&Array.isArray(e[1])){let n=e[1].length;for(let o=0;o<n;o++){if(e[1][o]instanceof Error)continue;let s=this._queue[r-(n-o)];try{e[1][o]=s.transformReply(e[1][o])}catch(a){e[1][o]=a}}}if(this._result[r]=e,--this.replyPending)return;if(this.isCluster){let n=!0,o;for(let s=0;s<this._result.length;++s){let a=this._result[s][0],l=this._queue[s];if(a){if(l.name==="exec"&&a.message==="EXECABORT Transaction discarded because of previous errors.")continue;if(!o)o={name:a.name,message:a.message};else if(o.name!==a.name||o.message!==a.message){n=!1;break}}else if(!l.inTransaction&&!((0,g$.exists)(l.name,{caseInsensitive:!0})&&(0,g$.hasFlag)(l.name,"readonly",{nameCaseInsensitive:!0}))){n=!1;break}}if(o&&n){let s=this,a=o.message.split(" "),l=this._queue,c=!1;this._queue=[];for(let p=0;p<l.length;++p){if(a[0]==="ASK"&&!c&&l[p].name!=="asking"&&(!l[p-1]||l[p-1].name!=="asking")){let m=new bse.default("asking");m.ignore=!0,this.sendCommand(m)}l[p].initPromise(),this.sendCommand(l[p]),c=l[p].inTransaction}let u=!0;typeof this.leftRedirections>"u"&&(this.leftRedirections={});let d=function(){s.exec()},f=this.redis;if(f.handleError(o,this.leftRedirections,{moved:function(p,m){s.preferKey=m,f.slots[a[1]]?f.slots[a[1]][0]!==m&&(f.slots[a[1]]=[m]):f.slots[a[1]]=[m],f._groupsBySlot[a[1]]=f._groupsIds[f.slots[a[1]].join(";")],f.refreshSlotsCache(),s.exec()},ask:function(p,m){s.preferKey=m,s.exec()},tryagain:d,clusterDown:d,connectionClosed:d,maxRedirections:()=>{u=!1},defaults:()=>{u=!1}}),u)return}}let i=0;for(let n=0;n<this._queue.length-i;++n)this._queue[n+i].ignore&&(i+=1),this._result[n]=this._result[n+i];this.resolve(this._result.slice(0,this._result.length-i))}sendCommand(e){this._transactions>0&&(e.inTransaction=!0);let r=this._queue.length;return e.pipelineIndex=r,e.promise.then(i=>{this.fillResult([null,i],r)}).catch(i=>{this.fillResult([i],r)}),this._queue.push(e),this}addBatch(e){let r,i,n;for(let o=0;o<e.length;++o)r=e[o],i=r[0],n=r.slice(1),this[i].apply(this,n);return this}};hw.default=Yi;var wse=Yi.prototype.multi;Yi.prototype.multi=function(){return this._transactions+=1,wse.apply(this,arguments)};var v$=Yi.prototype.execBuffer;Yi.prototype.execBuffer=(0,gse.deprecate)(function(){return this._transactions>0&&(this._transactions-=1),v$.apply(this,arguments)},"Pipeline#execBuffer: Use Pipeline#exec instead");Yi.prototype.exec=function(t){if(this.isCluster&&!this.redis.slots.length)return this.redis.status==="wait"&&this.redis.connect().catch(vse.noop),t&&!this.nodeifiedPromise&&(this.nodeifiedPromise=!0,(0,b$.default)(this.promise,t)),this.redis.delayUntilReady(n=>{if(n){this.reject(n);return}this.exec(t)}),this.promise;if(this._transactions>0)return this._transactions-=1,v$.apply(this,arguments);this.nodeifiedPromise||(this.nodeifiedPromise=!0,(0,b$.default)(this.promise,t)),this._queue.length||this.resolve([]);let e;if(this.isCluster){let n=[];for(let o=0;o<this._queue.length;o++){let s=this._queue[o].getKeys();if(s.length&&n.push(s[0]),s.length&&mw.generateMulti(s)<0)return this.reject(new Error("All the keys in a pipeline command should belong to the same slot")),this.promise}if(n.length){if(e=Ese(this.redis,n),e<0)return this.reject(new Error("All keys in the pipeline should belong to the same slots allocation group")),this.promise}else e=Math.random()*16384|0}let r=this;return i(),this.promise;function i(){let n=r.replyPending=r._queue.length,o;r.isCluster&&(o={slot:e,redis:r.redis.connectionPool.nodes.all[r.preferKey]});let s="",a,l={isPipeline:!0,destination:r.isCluster?o:{redis:r.redis},write(c){typeof c!="string"?(a||(a=[]),s&&(a.push(Buffer.from(s,"utf8")),s=""),a.push(c)):s+=c,--n||(a?(s&&a.push(Buffer.from(s,"utf8")),l.destination.redis.stream.write(Buffer.concat(a))):l.destination.redis.stream.write(s),n=r._queue.length,s="",a=void 0)}};for(let c=0;c<r._queue.length;++c)r.redis.sendCommand(r._queue[c],l,o);return r.promise}}});var vw=h(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});mm.addTransactionSupport=void 0;var gw=bt(),bw=Zi(),S$=yw();function xse(t){t.pipeline=function(i){let n=new S$.default(this);return Array.isArray(i)&&n.addBatch(i),n};let{multi:e}=t;t.multi=function(i,n){if(typeof n>"u"&&!Array.isArray(i)&&(n=i,i=null),n&&n.pipeline===!1)return e.call(this);let o=new S$.default(this);o.multi(),Array.isArray(i)&&o.addBatch(i);let s=o.exec;o.exec=function(l){if(this.isCluster&&!this.redis.slots.length)return this.redis.status==="wait"&&this.redis.connect().catch(gw.noop),(0,bw.default)(new Promise((u,d)=>{this.redis.delayUntilReady(f=>{if(f){d(f);return}this.exec(o).then(u,d)})}),l);if(this._transactions>0&&s.call(o),this.nodeifiedPromise)return s.call(o);let c=s.call(o);return(0,bw.default)(c.then(function(u){let d=u[u.length-1];if(typeof d>"u")throw new Error("Pipeline cannot be used to send any commands when the `exec()` has been called on it.");if(d[0]){d[0].previousErrors=[];for(let f=0;f<u.length-1;++f)u[f][0]&&d[0].previousErrors.push(u[f][0]);throw d[0]}return(0,gw.wrapMultiResult)(d[1])}),l)};let{execBuffer:a}=o;return o.execBuffer=function(l){return this._transactions>0&&a.call(o),o.exec(l)},o};let{exec:r}=t;t.exec=function(i){return(0,bw.default)(r.call(this).then(function(n){return Array.isArray(n)&&(n=(0,gw.wrapMultiResult)(n)),n}),i)}}mm.addTransactionSupport=xse});var Ew=h(Sw=>{"use strict";Object.defineProperty(Sw,"__esModule",{value:!0});function Ise(t,e){Object.getOwnPropertyNames(e.prototype).forEach(r=>{Object.defineProperty(t.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r))})}Sw.default=Ise});var w$=h(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0});hm.DEFAULT_CLUSTER_OPTIONS=void 0;var E$=U("dns");hm.DEFAULT_CLUSTER_OPTIONS={clusterRetryStrategy:t=>Math.min(100+t*2,2e3),enableOfflineQueue:!0,enableReadyCheck:!0,scaleReads:"master",maxRedirections:16,retryDelayOnMoved:0,retryDelayOnFailover:100,retryDelayOnClusterDown:100,retryDelayOnTryAgain:100,slotsRefreshTimeout:1e3,useSRVRecords:!1,resolveSrv:E$.resolveSrv,dnsLookup:E$.lookup,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],shardedSubscribers:!1}});var $a=h(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.getConnectionName=Xt.weightSrvRecords=Xt.groupSrvRecords=Xt.getUniqueHostnamesFromOptions=Xt.normalizeNodeOptions=Xt.nodeKeyToRedisOptions=Xt.getNodeKey=void 0;var x$=bt(),kse=U("net");function _se(t){return t.port=t.port||6379,t.host=t.host||"127.0.0.1",t.host+":"+t.port}Xt.getNodeKey=_se;function Tse(t){let e=t.lastIndexOf(":");if(e===-1)throw new Error(`Invalid node key ${t}`);return{host:t.slice(0,e),port:Number(t.slice(e+1))}}Xt.nodeKeyToRedisOptions=Tse;function Cse(t){return t.map(e=>{let r={};if(typeof e=="object")Object.assign(r,e);else if(typeof e=="string")Object.assign(r,(0,x$.parseURL)(e));else if(typeof e=="number")r.port=e;else throw new Error("Invalid argument "+e);return typeof r.port=="string"&&(r.port=parseInt(r.port,10)),delete r.db,r.port||(r.port=6379),r.host||(r.host="127.0.0.1"),(0,x$.resolveTLSProfile)(r)})}Xt.normalizeNodeOptions=Cse;function Ose(t){let e={};return t.forEach(r=>{e[r.host]=!0}),Object.keys(e).filter(r=>!(0,kse.isIP)(r))}Xt.getUniqueHostnamesFromOptions=Ose;function Ase(t){let e={};for(let r of t)e.hasOwnProperty(r.priority)?(e[r.priority].totalWeight+=r.weight,e[r.priority].records.push(r)):e[r.priority]={totalWeight:r.weight,records:[r]};return e}Xt.groupSrvRecords=Ase;function Kse(t){if(t.records.length===1)return t.totalWeight=0,t.records.shift();let e=Math.floor(Math.random()*(t.totalWeight+t.records.length)),r=0;for(let[i,n]of t.records.entries())if(r+=1+n.weight,r>e)return t.totalWeight-=n.weight,t.records.splice(i,1),n}Xt.weightSrvRecords=Kse;function Rse(t,e){let r=`ioredis-cluster(${t})`;return e?`${r}:${e}`:r}Xt.getConnectionName=Rse});var k$=h(Iw=>{"use strict";Object.defineProperty(Iw,"__esModule",{value:!0});var I$=$a(),ww=bt(),Dse=mi(),Jn=(0,ww.Debug)("cluster:subscriber"),xw=class{constructor(e,r,i=!1){this.connectionPool=e,this.emitter=r,this.isSharded=i,this.started=!1,this.subscriber=null,this.slotRange=[],this.onSubscriberEnd=()=>{if(!this.started){Jn("subscriber has disconnected, but ClusterSubscriber is not started, so not reconnecting.");return}Jn("subscriber has disconnected, selecting a new one..."),this.selectSubscriber()},this.connectionPool.on("-node",(n,o)=>{!this.started||!this.subscriber||(0,I$.getNodeKey)(this.subscriber.options)===o&&(Jn("subscriber has left, selecting a new one..."),this.selectSubscriber())}),this.connectionPool.on("+node",()=>{!this.started||this.subscriber||(Jn("a new node is discovered and there is no subscriber, selecting a new one..."),this.selectSubscriber())})}getInstance(){return this.subscriber}associateSlotRange(e){return this.isSharded&&(this.slotRange=e),this.slotRange}start(){this.started=!0,this.selectSubscriber(),Jn("started")}stop(){this.started=!1,this.subscriber&&(this.subscriber.disconnect(),this.subscriber=null)}isStarted(){return this.started}selectSubscriber(){let e=this.lastActiveSubscriber;e&&(e.off("end",this.onSubscriberEnd),e.disconnect()),this.subscriber&&(this.subscriber.off("end",this.onSubscriberEnd),this.subscriber.disconnect());let r=(0,ww.sample)(this.connectionPool.getNodes());if(!r){Jn("selecting subscriber failed since there is no node discovered in the cluster yet"),this.subscriber=null;return}let{options:i}=r;Jn("selected a subscriber %s:%s",i.host,i.port);let n="subscriber";this.isSharded&&(n="ssubscriber"),this.subscriber=new Dse.default({port:i.port,host:i.host,username:i.username,password:i.password,enableReadyCheck:!0,connectionName:(0,I$.getConnectionName)(n,i.connectionName),lazyConnect:!0,tls:i.tls,retryStrategy:null}),this.subscriber.on("error",ww.noop),this.subscriber.on("moved",()=>{this.emitter.emit("forceRefresh")}),this.subscriber.once("end",this.onSubscriberEnd);let o={subscribe:[],psubscribe:[],ssubscribe:[]};if(e){let s=e.condition||e.prevCondition;s&&s.subscriber&&(o.subscribe=s.subscriber.channels("subscribe"),o.psubscribe=s.subscriber.channels("psubscribe"),o.ssubscribe=s.subscriber.channels("ssubscribe"))}if(o.subscribe.length||o.psubscribe.length||o.ssubscribe.length){let s=0;for(let a of["subscribe","psubscribe","ssubscribe"]){let l=o[a];if(l.length!=0)if(Jn("%s %d channels",a,l.length),a==="ssubscribe")for(let c of l)s+=1,this.subscriber[a](c).then(()=>{--s||(this.lastActiveSubscriber=this.subscriber)}).catch(()=>{Jn("failed to ssubscribe to channel: %s",c)});else s+=1,this.subscriber[a](l).then(()=>{--s||(this.lastActiveSubscriber=this.subscriber)}).catch(()=>{Jn("failed to %s %d channels",a,l.length)})}}else this.lastActiveSubscriber=this.subscriber;for(let s of["message","messageBuffer"])this.subscriber.on(s,(a,l)=>{this.emitter.emit(s,a,l)});for(let s of["pmessage","pmessageBuffer"])this.subscriber.on(s,(a,l,c)=>{this.emitter.emit(s,a,l,c)});if(this.isSharded==!0)for(let s of["smessage","smessageBuffer"])this.subscriber.on(s,(a,l)=>{this.emitter.emit(s,a,l)})}};Iw.default=xw});var _$=h(Tw=>{"use strict";Object.defineProperty(Tw,"__esModule",{value:!0});var jse=U("events"),ym=bt(),kw=$a(),Pse=mi(),au=(0,ym.Debug)("cluster:connectionPool"),_w=class extends jse.EventEmitter{constructor(e){super(),this.redisOptions=e,this.nodes={all:{},master:{},slave:{}},this.specifiedOptions={}}getNodes(e="all"){let r=this.nodes[e];return Object.keys(r).map(i=>r[i])}getInstanceByKey(e){return this.nodes.all[e]}getSampleInstance(e){let r=Object.keys(this.nodes[e]),i=(0,ym.sample)(r);return this.nodes[e][i]}addMasterNode(e){let r=(0,kw.getNodeKey)(e.options),i=this.createRedisFromOptions(e,e.options.readOnly);return e.options.readOnly?!1:(this.nodes.all[r]=i,this.nodes.master[r]=i,!0)}createRedisFromOptions(e,r){return new Pse.default((0,ym.defaults)({retryStrategy:null,enableOfflineQueue:!0,readOnly:r},e,this.redisOptions,{lazyConnect:!0}))}findOrCreate(e,r=!1){let i=(0,kw.getNodeKey)(e);r=!!r,this.specifiedOptions[i]?Object.assign(e,this.specifiedOptions[i]):this.specifiedOptions[i]=e;let n;return this.nodes.all[i]?(n=this.nodes.all[i],n.options.readOnly!==r&&(n.options.readOnly=r,au("Change role of %s to %s",i,r?"slave":"master"),n[r?"readonly":"readwrite"]().catch(ym.noop),r?(delete this.nodes.master[i],this.nodes.slave[i]=n):(delete this.nodes.slave[i],this.nodes.master[i]=n))):(au("Connecting to %s as %s",i,r?"slave":"master"),n=this.createRedisFromOptions(e,r),this.nodes.all[i]=n,this.nodes[r?"slave":"master"][i]=n,n.once("end",()=>{this.removeNode(i),this.emit("-node",n,i),Object.keys(this.nodes.all).length||this.emit("drain")}),this.emit("+node",n,i),n.on("error",function(o){this.emit("nodeError",o,i)})),n}reset(e){au("Reset with %O",e);let r={};e.forEach(i=>{let n=(0,kw.getNodeKey)(i);i.readOnly&&r[n]||(r[n]=i)}),Object.keys(this.nodes.all).forEach(i=>{r[i]||(au("Disconnect %s because the node does not hold any slot",i),this.nodes.all[i].disconnect(),this.removeNode(i))}),Object.keys(r).forEach(i=>{let n=r[i];this.findOrCreate(n,n.readOnly)})}removeNode(e){let{nodes:r}=this;r.all[e]&&(au("Remove %s from the pool",e),delete r.all[e]),delete r.master[e],delete r.slave[e]}};Tw.default=_w});var gm=h((o_e,T$)=>{"use strict";function at(t,r){var r=r||{};this._capacity=r.capacity,this._head=0,this._tail=0,Array.isArray(t)?this._fromArray(t):(this._capacityMask=3,this._list=new Array(4))}at.prototype.peekAt=function(e){var r=e;if(r===(r|0)){var i=this.size();if(!(r>=i||r<-i))return r<0&&(r+=i),r=this._head+r&this._capacityMask,this._list[r]}};at.prototype.get=function(e){return this.peekAt(e)};at.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]};at.prototype.peekFront=function(){return this.peek()};at.prototype.peekBack=function(){return this.peekAt(-1)};Object.defineProperty(at.prototype,"length",{get:function(){return this.size()}});at.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)};at.prototype.unshift=function(e){if(arguments.length===0)return this.size();var r=this._list.length;return this._head=this._head-1+r&this._capacityMask,this._list[this._head]=e,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)};at.prototype.shift=function(){var e=this._head;if(e!==this._tail){var r=this._list[e];return this._list[e]=void 0,this._head=e+1&this._capacityMask,e<2&&this._tail>1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),r}};at.prototype.push=function(e){if(arguments.length===0)return this.size();var r=this._tail;return this._list[r]=e,this._tail=r+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)};at.prototype.pop=function(){var e=this._tail;if(e!==this._head){var r=this._list.length;this._tail=e-1+r&this._capacityMask;var i=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&e>1e4&&e<=r>>>2&&this._shrinkArray(),i}};at.prototype.removeOne=function(e){var r=e;if(r===(r|0)&&this._head!==this._tail){var i=this.size(),n=this._list.length;if(!(r>=i||r<-i)){r<0&&(r+=i),r=this._head+r&this._capacityMask;var o=this._list[r],s;if(e<i/2){for(s=e;s>0;s--)this._list[r]=this._list[r=r-1+n&this._capacityMask];this._list[r]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(s=i-1-e;s>0;s--)this._list[r]=this._list[r=r+1+n&this._capacityMask];this._list[r]=void 0,this._tail=this._tail-1+n&this._capacityMask}return o}}};at.prototype.remove=function(e,r){var i=e,n,o=r;if(i===(i|0)&&this._head!==this._tail){var s=this.size(),a=this._list.length;if(!(i>=s||i<-s||r<1)){if(i<0&&(i+=s),r===1||!r)return n=new Array(1),n[0]=this.removeOne(i),n;if(i===0&&i+r>=s)return n=this.toArray(),this.clear(),n;i+r>s&&(r=s-i);var l;for(n=new Array(r),l=0;l<r;l++)n[l]=this._list[this._head+i+l&this._capacityMask];if(i=this._head+i&this._capacityMask,e+r===s){for(this._tail=this._tail-r+a&this._capacityMask,l=r;l>0;l--)this._list[i=i+1+a&this._capacityMask]=void 0;return n}if(e===0){for(this._head=this._head+r+a&this._capacityMask,l=r-1;l>0;l--)this._list[i=i+1+a&this._capacityMask]=void 0;return n}if(i<s/2){for(this._head=this._head+e+r+a&this._capacityMask,l=e;l>0;l--)this.unshift(this._list[i=i-1+a&this._capacityMask]);for(i=this._head-1+a&this._capacityMask;o>0;)this._list[i=i-1+a&this._capacityMask]=void 0,o--;e<0&&(this._tail=i)}else{for(this._tail=i,i=i+r+a&this._capacityMask,l=s-(r+e);l>0;l--)this.push(this._list[i++]);for(i=this._tail;o>0;)this._list[i=i+1+a&this._capacityMask]=void 0,o--}return this._head<2&&this._tail>1e4&&this._tail<=a>>>2&&this._shrinkArray(),n}}};at.prototype.splice=function(e,r){var i=e;if(i===(i|0)){var n=this.size();if(i<0&&(i+=n),!(i>n))if(arguments.length>2){var o,s,a,l=arguments.length,c=this._list.length,u=2;if(!n||i<n/2){for(s=new Array(i),o=0;o<i;o++)s[o]=this._list[this._head+o&this._capacityMask];for(r===0?(a=[],i>0&&(this._head=this._head+i+c&this._capacityMask)):(a=this.remove(i,r),this._head=this._head+i+c&this._capacityMask);l>u;)this.unshift(arguments[--l]);for(o=i;o>0;o--)this.unshift(s[o-1])}else{s=new Array(n-(i+r));var d=s.length;for(o=0;o<d;o++)s[o]=this._list[this._head+i+r+o&this._capacityMask];for(r===0?(a=[],i!=n&&(this._tail=this._head+i+c&this._capacityMask)):(a=this.remove(i,r),this._tail=this._tail-d+c&this._capacityMask);u<l;)this.push(arguments[u++]);for(o=0;o<d;o++)this.push(s[o])}return a}else return this.remove(i,r)}};at.prototype.clear=function(){this._list=new Array(this._list.length),this._head=0,this._tail=0};at.prototype.isEmpty=function(){return this._head===this._tail};at.prototype.toArray=function(){return this._copyArray(!1)};at.prototype._fromArray=function(e){var r=e.length,i=this._nextPowerOf2(r);this._list=new Array(i),this._capacityMask=i-1,this._tail=r;for(var n=0;n<r;n++)this._list[n]=e[n]};at.prototype._copyArray=function(e,r){var i=this._list,n=i.length,o=this.length;if(r=r|o,r==o&&this._head<this._tail)return this._list.slice(this._head,this._tail);var s=new Array(r),a=0,l;if(e||this._head>this._tail){for(l=this._head;l<n;l++)s[a++]=i[l];for(l=0;l<this._tail;l++)s[a++]=i[l]}else for(l=this._head;l<this._tail;l++)s[a++]=i[l];return s};at.prototype._growArray=function(){if(this._head!=0){var e=this._copyArray(!0,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};at.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1};at.prototype._nextPowerOf2=function(e){var r=Math.log(e)/Math.log(2),i=1<<r+1;return Math.max(i,4)};T$.exports=at});var C$=h(Ow=>{"use strict";Object.defineProperty(Ow,"__esModule",{value:!0});var Mse=bt(),Nse=gm(),Lse=(0,Mse.Debug)("delayqueue"),Cw=class{constructor(){this.queues={},this.timeouts={}}push(e,r,i){let n=i.callback||process.nextTick;this.queues[e]||(this.queues[e]=new Nse),this.queues[e].push(r),this.timeouts[e]||(this.timeouts[e]=setTimeout(()=>{n(()=>{this.timeouts[e]=null,this.execute(e)})},i.timeout))}execute(e){let r=this.queues[e];if(!r)return;let{length:i}=r;if(i)for(Lse("send %d commands in %s queue",i,e),this.queues[e]=null;r.length>0;)r.shift()()}};Ow.default=Cw});var R$=h(Kw=>{"use strict";Object.defineProperty(Kw,"__esModule",{value:!0});var O$=$a(),K$=bt(),Use=mi(),A$=(0,K$.Debug)("cluster:subscriberGroup:shardedSubscriber"),Ne={IDLE:"idle",STARTING:"starting",CONNECTED:"connected",STOPPING:"stopping",ENDED:"ended"},$se={[Ne.IDLE]:[Ne.STARTING,Ne.STOPPING,Ne.ENDED],[Ne.STARTING]:[Ne.CONNECTED,Ne.STOPPING,Ne.ENDED],[Ne.CONNECTED]:[Ne.STOPPING,Ne.ENDED],[Ne.STOPPING]:[Ne.ENDED],[Ne.ENDED]:[]},Aw=class{constructor(e,r,i){var n;this.emitter=e,this.status=Ne.IDLE,this.instance=null,this.connectPromise=null,this.messageListeners=new Map,this.onEnd=()=>{this.updateStatus(Ne.ENDED),this.emitter.emit("-node",this.instance,this.nodeKey)},this.onError=o=>{this.emitter.emit("nodeError",o,this.nodeKey)},this.onMoved=()=>{this.emitter.emit("moved")},this.instance=new Use.default((0,K$.defaults)({enableReadyCheck:!1,enableOfflineQueue:!0,connectionName:(0,O$.getConnectionName)("ssubscriber",r.connectionName),retryStrategy:null,lazyConnect:!0},r,i)),this.lazyConnect=(n=i?.lazyConnect)!==null&&n!==void 0?n:!0,this.nodeKey=(0,O$.getNodeKey)(r),this.instance.on("end",this.onEnd),this.instance.on("error",this.onError),this.instance.on("moved",this.onMoved);for(let o of["smessage","smessageBuffer"]){let s=(...a)=>{this.emitter.emit(o,...a)};this.messageListeners.set(o,s),this.instance.on(o,s)}}async start(){if(this.connectPromise)return this.connectPromise;if(!(this.status===Ne.STARTING||this.status===Ne.CONNECTED)){if(this.status===Ne.ENDED||!this.instance)throw new Error(`Sharded subscriber ${this.nodeKey} cannot be restarted once ended.`);this.updateStatus(Ne.STARTING),this.connectPromise=this.instance.connect();try{await this.connectPromise,this.updateStatus(Ne.CONNECTED)}catch(e){throw this.updateStatus(Ne.ENDED),e}finally{this.connectPromise=null}}}stop(){this.updateStatus(Ne.STOPPING),this.instance&&(this.instance.disconnect(),this.instance.removeAllListeners(),this.messageListeners.clear(),this.instance=null),this.updateStatus(Ne.ENDED),A$("stopped %s",this.nodeKey)}isStarted(){return[Ne.CONNECTED,Ne.STARTING].includes(this.status)}get subscriberStatus(){return this.status}isHealthy(){return(this.status===Ne.IDLE||this.status===Ne.CONNECTED||this.status===Ne.STARTING)&&this.instance!==null}getInstance(){return this.instance}getNodeKey(){return this.nodeKey}isLazyConnect(){return this.lazyConnect}updateStatus(e){if(this.status!==e){if(!$se[this.status].includes(e)){A$("Invalid status transition for %s: %s -> %s",this.nodeKey,this.status,e);return}this.status=e}}};Kw.default=Aw});var D$=h(Rw=>{"use strict";Object.defineProperty(Rw,"__esModule",{value:!0});var Jse=bt(),Fse=$a(),bm=su(),qse=R$(),rn=(0,Jse.Debug)("cluster:subscriberGroup"),Ja=class t{constructor(e,r){this.subscriberGroupEmitter=e,this.options=r,this.shardedSubscribers=new Map,this.clusterSlots=[],this.subscriberToSlotsIndex=new Map,this.channels=new Map,this.failedAttemptsByNode=new Map,this.isResetting=!1,this.pendingReset=null,this.handleSubscriberConnectFailed=(i,n)=>{let s=(this.failedAttemptsByNode.get(n)||0)+1;this.failedAttemptsByNode.set(n,s);let a=Math.min(s,t.MAX_RETRY_ATTEMPTS),l=Math.min(t.BASE_BACKOFF_MS*2**a,t.MAX_BACKOFF_MS),c=Math.floor((Math.random()-.5)*(l*.5)),u=Math.max(0,l+c);rn("Failed to connect subscriber for %s. Refreshing slots in %dms",n,u),this.subscriberGroupEmitter.emit("subscriberConnectFailed",{delay:u,error:i})},this.handleSubscriberConnectSucceeded=i=>{this.failedAttemptsByNode.delete(i)}}getResponsibleSubscriber(e){let r=this.clusterSlots[e][0],i=this.shardedSubscribers.get(r);return i&&i.subscriberStatus==="idle"&&i.start().then(()=>{this.handleSubscriberConnectSucceeded(i.getNodeKey())}).catch(n=>{this.handleSubscriberConnectFailed(n,i.getNodeKey())}),i}addChannels(e){let r=bm(e[0]);for(let n of e)if(bm(n)!==r)return-1;let i=this.channels.get(r);return i?this.channels.set(r,i.concat(e)):this.channels.set(r,e),Array.from(this.channels.values()).reduce((n,o)=>n+o.length,0)}removeChannels(e){let r=bm(e[0]);for(let n of e)if(bm(n)!==r)return-1;let i=this.channels.get(r);if(i){let n=i.filter(o=>!e.includes(o));this.channels.set(r,n)}return Array.from(this.channels.values()).reduce((n,o)=>n+o.length,0)}stop(){for(let e of this.shardedSubscribers.values())e.stop();this.pendingReset=null,this.shardedSubscribers.clear(),this.subscriberToSlotsIndex.clear()}start(){let e=[];for(let r of this.shardedSubscribers.values())this.shouldStartSubscriber(r)&&(e.push(r.start().then(()=>{this.handleSubscriberConnectSucceeded(r.getNodeKey())}).catch(i=>{this.handleSubscriberConnectFailed(i,r.getNodeKey())})),this.subscriberGroupEmitter.emit("+subscriber"));return Promise.all(e)}async reset(e,r){if(this.isResetting){this.pendingReset={slots:e,nodes:r};return}this.isResetting=!0;try{let i=this._refreshSlots(e),n=this.hasUnhealthySubscribers();if(!i&&!n){rn("No topology change detected or failed subscribers. Skipping reset.");return}for(let[s,a]of this.shardedSubscribers){if(this.subscriberToSlotsIndex.has(s)&&a.isHealthy()){rn("Skipping deleting subscriber for %s",s);continue}rn("Removing subscriber for %s",s),a.stop(),this.shardedSubscribers.delete(s),this.subscriberGroupEmitter.emit("-subscriber")}let o=[];for(let[s,a]of this.subscriberToSlotsIndex){let l=this.shardedSubscribers.get(s);if(l&&l.isHealthy()){rn("Skipping creating new subscriber for %s",s),!l.isStarted()&&this.shouldStartSubscriber(l)&&o.push(l.start().then(()=>{this.handleSubscriberConnectSucceeded(s)}).catch(d=>{this.handleSubscriberConnectFailed(d,s)}));continue}l&&!l.isHealthy()&&(rn("Replacing subscriber for %s",s),l.stop(),this.shardedSubscribers.delete(s),this.subscriberGroupEmitter.emit("-subscriber")),rn("Creating new subscriber for %s",s);let c=r.find(d=>(0,Fse.getNodeKey)(d.options)===s);if(!c){rn("Failed to find node for key %s",s);continue}let u=new qse.default(this.subscriberGroupEmitter,c.options,this.options.redisOptions);this.shardedSubscribers.set(s,u),this.shouldStartSubscriber(u)&&o.push(u.start().then(()=>{this.handleSubscriberConnectSucceeded(s)}).catch(d=>{this.handleSubscriberConnectFailed(d,s)})),this.subscriberGroupEmitter.emit("+subscriber")}await Promise.all(o),this._resubscribe(),this.subscriberGroupEmitter.emit("subscribersReady")}finally{if(this.isResetting=!1,this.pendingReset){let{slots:i,nodes:n}=this.pendingReset;this.pendingReset=null,await this.reset(i,n)}}}_refreshSlots(e){if(this._slotsAreEqual(e)&&this.subscriberToSlotsIndex.size>0)return rn("Nothing to refresh because the new cluster map is equal to the previous one."),!1;rn("Refreshing the slots of the subscriber group."),this.subscriberToSlotsIndex=new Map;for(let r=0;r<e.length;r++){let i=e[r][0];this.subscriberToSlotsIndex.has(i)||this.subscriberToSlotsIndex.set(i,[]),this.subscriberToSlotsIndex.get(i).push(Number(r))}return this.clusterSlots=JSON.parse(JSON.stringify(e)),!0}_resubscribe(){this.shardedSubscribers&&this.shardedSubscribers.forEach((e,r)=>{let i=this.subscriberToSlotsIndex.get(r);i&&i.forEach(n=>{let o=e.getInstance(),s=this.channels.get(n);if(s&&s.length>0){if(!o||o.status==="end")return;o.status==="ready"?o.ssubscribe(...s).catch(a=>{rn("Failed to ssubscribe on node %s: %s",r,a)}):o.once("ready",()=>{o.ssubscribe(...s).catch(a=>{rn("Failed to ssubscribe on node %s: %s",r,a)})})}})})}_slotsAreEqual(e){return this.clusterSlots===void 0?!1:JSON.stringify(this.clusterSlots)===JSON.stringify(e)}hasUnhealthySubscribers(){let e=Array.from(this.shardedSubscribers.values()).some(i=>!i.isHealthy()),r=Array.from(this.subscriberToSlotsIndex.keys()).some(i=>!this.shardedSubscribers.has(i));return e||r}shouldStartSubscriber(e){if(e.isStarted())return!1;if(!e.isLazyConnect())return!0;let r=this.subscriberToSlotsIndex.get(e.getNodeKey());return r?r.some(i=>{let n=this.channels.get(i);return!!(n&&n.length>0)}):!1}};Rw.default=Ja;Ja.MAX_RETRY_ATTEMPTS=10;Ja.MAX_BACKOFF_MS=2e3;Ja.BASE_BACKOFF_MS=100});var Pw=h(jw=>{"use strict";Object.defineProperty(jw,"__esModule",{value:!0});var j$=Qo(),Dw=U("events"),Fa=es(),P$=Zi(),M$=pi(),vm=a$(),zse=mi(),Gse=dm(),Vse=vw(),Dr=bt(),Bse=Ew(),Wse=fm(),Zse=w$(),Hse=k$(),Yse=_$(),Xse=C$(),qa=$a(),N$=gm(),Qse=D$(),Be=(0,Dr.Debug)("cluster"),L$=new WeakSet,lu=class t extends Wse.default{constructor(e,r={}){if(super(),this.slots=[],this._groupsIds={},this._groupsBySlot=Array(16384),this.isCluster=!0,this.retryAttempts=0,this.delayQueue=new Xse.default,this.offlineQueue=new N$,this.isRefreshing=!1,this._refreshSlotsCacheCallbacks=[],this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this._readyDelayedCallbacks=[],this.connectionEpoch=0,Dw.EventEmitter.call(this),this.startupNodes=e,this.options=(0,Dr.defaults)({},r,Zse.DEFAULT_CLUSTER_OPTIONS,this.options),this.options.shardedSubscribers&&this.createShardedSubscriberGroup(),this.options.redisOptions&&this.options.redisOptions.keyPrefix&&!this.options.keyPrefix&&(this.options.keyPrefix=this.options.redisOptions.keyPrefix),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 Yse.default(this.options.redisOptions),this.connectionPool.on("-node",(i,n)=>{this.emit("-node",i)}),this.connectionPool.on("+node",i=>{this.emit("+node",i)}),this.connectionPool.on("drain",()=>{this.setStatus("close")}),this.connectionPool.on("nodeError",(i,n)=>{this.emit("node error",i,n)}),this.subscriber=new Hse.default(this.connectionPool,this),this.options.scripts&&Object.entries(this.options.scripts).forEach(([i,n])=>{this.defineCommand(i,n)}),this.options.lazyConnect?this.setStatus("wait"):this.connect().catch(i=>{Be("connecting failed: %s",i)})}connect(){return new Promise((e,r)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){r(new Error("Redis is already connecting/connected"));return}let i=++this.connectionEpoch;this.setStatus("connecting"),this.resolveStartupNodeHostnames().then(n=>{if(this.connectionEpoch!==i){Be("discard connecting after resolving startup nodes because epoch not match: %d != %d",i,this.connectionEpoch),r(new Fa.RedisError("Connection is discarded because a new connection is made"));return}if(this.status!=="connecting"){Be("discard connecting after resolving startup nodes because the status changed to %s",this.status),r(new Fa.RedisError("Connection is aborted"));return}this.connectionPool.reset(n),this.options.shardedSubscribers&&this.shardedSubscribers.reset(this.slots,this.connectionPool.getNodes("all")).catch(l=>{Be("Error while starting subscribers: %s",l)});let o=()=>{this.setStatus("ready"),this.retryAttempts=0,this.executeOfflineCommands(),this.resetNodesRefreshInterval(),e()},s,a=()=>{this.invokeReadyDelayedCallbacks(void 0),this.removeListener("close",s),this.manuallyClosing=!1,this.setStatus("connect"),this.options.enableReadyCheck?this.readyCheck((l,c)=>{l||c?(Be("Ready check failed (%s). Reconnecting...",l||c),this.status==="connect"&&this.disconnect(!0)):o()}):o()};s=()=>{let l=new Error("None of startup nodes is available");this.removeListener("refresh",a),this.invokeReadyDelayedCallbacks(l),r(l)},this.once("refresh",a),this.once("close",s),this.once("close",this.handleCloseEvent.bind(this)),this.refreshSlotsCache(l=>{l&&l.message===vm.default.defaultMessage&&(zse.default.prototype.silentEmit.call(this,"error",l),this.connectionPool.reset([]))}),this.subscriber.start(),this.options.shardedSubscribers&&this.shardedSubscribers.start().catch(l=>{Be("Error while starting subscribers: %s",l)})}).catch(n=>{this.setStatus("close"),this.handleCloseEvent(n),this.invokeReadyDelayedCallbacks(n),r(n)})})}disconnect(e=!1){let r=this.status;this.setStatus("disconnecting"),e||(this.manuallyClosing=!0),this.reconnectTimeout&&!e&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null,Be("Canceled reconnecting attempts")),this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers&&this.shardedSubscribers.stop(),r==="wait"?(this.setStatus("close"),this.handleCloseEvent()):this.connectionPool.reset([])}quit(e){let r=this.status;if(this.setStatus("disconnecting"),this.manuallyClosing=!0,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers&&this.shardedSubscribers.stop(),r==="wait"){let i=(0,P$.default)(Promise.resolve("OK"),e);return setImmediate(function(){this.setStatus("close"),this.handleCloseEvent()}.bind(this)),i}return(0,P$.default)(Promise.all(this.nodes().map(i=>i.quit().catch(n=>{if(n.message===Dr.CONNECTION_CLOSED_ERROR_MSG)return"OK";throw n}))).then(()=>"OK"),e)}duplicate(e=[],r={}){let i=e.length>0?e:this.startupNodes.slice(0),n=Object.assign({},this.options,r);return new t(i,n)}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(let r of this._autoPipelines.values())e+=r.length;return e}refreshSlotsCache(e){if(e&&this._refreshSlotsCacheCallbacks.push(e),this.isRefreshing)return;this.isRefreshing=!0;let r=this,i=a=>{this.isRefreshing=!1;for(let l of this._refreshSlotsCacheCallbacks)l(a);this._refreshSlotsCacheCallbacks=[]},n=(0,Dr.shuffle)(this.connectionPool.getNodes()),o=null;function s(a){if(a===n.length){let u=new vm.default(vm.default.defaultMessage,o);return i(u)}let l=n[a],c=`${l.options.host}:${l.options.port}`;Be("getting slot cache from %s",c),r.getInfoFromNode(l,function(u){switch(r.status){case"close":case"end":return i(new Error("Cluster is disconnected."));case"disconnecting":return i(new Error("Cluster is disconnecting."))}u?(r.emit("node error",u,c),o=u,s(a+1)):(r.emit("refresh"),i())})}s(0)}sendCommand(e,r,i){if(this.status==="wait"&&this.connect().catch(Dr.noop),this.status==="end")return e.reject(new Error(Dr.CONNECTION_CLOSED_ERROR_MSG)),e.promise;let n=this.options.scaleReads;n!=="master"&&(e.isReadOnly||(0,j$.exists)(e.name)&&(0,j$.hasFlag)(e.name,"readonly")||(n="master"));let o=i?i.slot:e.getSlot(),s={},a=this;if(!i&&!L$.has(e)){L$.add(e);let c=e.reject;e.reject=function(u){let d=l.bind(null,!0);a.handleError(u,s,{moved:function(f,p){Be("command %s is moved to %s",e.name,p),o=Number(f),a.slots[f]?a.slots[f][0]=p:a.slots[f]=[p],a._groupsBySlot[f]=a._groupsIds[a.slots[f].join(";")],a.connectionPool.findOrCreate(a.natMapper(p)),l(),Be("refreshing slot caches... (triggered by MOVED error)"),a.refreshSlotsCache()},ask:function(f,p){Be("command %s is required to ask %s:%s",e.name,p);let m=a.natMapper(p);a.connectionPool.findOrCreate(m),l(!1,`${m.host}:${m.port}`)},tryagain:d,clusterDown:d,connectionClosed:d,maxRedirections:function(f){c.call(e,f)},defaults:function(){c.call(e,u)}})}}l();function l(c,u){if(a.status==="end"){e.reject(new Fa.AbortError("Cluster is ended."));return}let d;if(a.status==="ready"||e.name==="cluster"){if(i&&i.redis)d=i.redis;else if(M$.default.checkFlag("ENTER_SUBSCRIBER_MODE",e.name)||M$.default.checkFlag("EXIT_SUBSCRIBER_MODE",e.name)){if(a.options.shardedSubscribers&&(e.name=="ssubscribe"||e.name=="sunsubscribe")){let f=a.shardedSubscribers.getResponsibleSubscriber(o);if(!f){e.reject(new Fa.AbortError(`No sharded subscriber for slot: ${o}`));return}let p=-1;e.name=="ssubscribe"&&(p=a.shardedSubscribers.addChannels(e.getKeys())),e.name=="sunsubscribe"&&(p=a.shardedSubscribers.removeChannels(e.getKeys())),p!==-1?d=f.getInstance():e.reject(new Fa.AbortError("Possible CROSSSLOT error: All channels must hash to the same slot"))}else d=a.subscriber.getInstance();if(!d){e.reject(new Fa.AbortError("No subscriber for the cluster"));return}}else{if(!c){if(typeof o=="number"&&a.slots[o]){let f=a.slots[o];if(typeof n=="function"){let p=f.map(function(m){return a.connectionPool.getInstanceByKey(m)});d=n(p,e),Array.isArray(d)&&(d=(0,Dr.sample)(d)),d||(d=p[0])}else{let p;n==="all"?p=(0,Dr.sample)(f):n==="slave"&&f.length>1?p=(0,Dr.sample)(f,1):p=f[0],d=a.connectionPool.getInstanceByKey(p)}}u&&(d=a.connectionPool.getInstanceByKey(u),d.asking())}d||(d=(typeof n=="function"?null:a.connectionPool.getSampleInstance(n))||a.connectionPool.getSampleInstance("all"))}i&&!i.redis&&(i.redis=d)}d?d.sendCommand(e,r):a.options.enableOfflineQueue?a.offlineQueue.push({command:e,stream:r,node:i}):e.reject(new Error("Cluster isn't ready and enableOfflineQueue options is false"))}return e.promise}sscanStream(e,r){return this.createScanStream("sscan",{key:e,options:r})}sscanBufferStream(e,r){return this.createScanStream("sscanBuffer",{key:e,options:r})}hscanStream(e,r){return this.createScanStream("hscan",{key:e,options:r})}hscanBufferStream(e,r){return this.createScanStream("hscanBuffer",{key:e,options:r})}zscanStream(e,r){return this.createScanStream("zscan",{key:e,options:r})}zscanBufferStream(e,r){return this.createScanStream("zscanBuffer",{key:e,options:r})}handleError(e,r,i){if(typeof r.value>"u"?r.value=this.options.maxRedirections:r.value-=1,r.value<=0){i.maxRedirections(new Error("Too many Cluster redirections. Last error: "+e));return}let n=e.message.split(" ");if(n[0]==="MOVED"){let o=this.options.retryDelayOnMoved;o&&typeof o=="number"?this.delayQueue.push("moved",i.moved.bind(null,n[1],n[2]),{timeout:o}):i.moved(n[1],n[2])}else n[0]==="ASK"?i.ask(n[1],n[2]):n[0]==="TRYAGAIN"?this.delayQueue.push("tryagain",i.tryagain,{timeout:this.options.retryDelayOnTryAgain}):n[0]==="CLUSTERDOWN"&&this.options.retryDelayOnClusterDown>0?this.delayQueue.push("clusterdown",i.connectionClosed,{timeout:this.options.retryDelayOnClusterDown,callback:this.refreshSlotsCache.bind(this)}):e.message===Dr.CONNECTION_CLOSED_ERROR_MSG&&this.options.retryDelayOnFailover>0&&this.status==="ready"?this.delayQueue.push("failover",i.connectionClosed,{timeout:this.options.retryDelayOnFailover,callback:this.refreshSlotsCache.bind(this)}):i.defaults()}resetOfflineQueue(){this.offlineQueue=new N$}clearNodesRefreshInterval(){this.slotsTimer&&(clearTimeout(this.slotsTimer),this.slotsTimer=null)}resetNodesRefreshInterval(){if(this.slotsTimer||!this.options.slotsRefreshInterval)return;let e=()=>{this.slotsTimer=setTimeout(()=>{Be('refreshing slot caches... (triggered by "slotsRefreshInterval" option)'),this.refreshSlotsCache(()=>{e()})},this.options.slotsRefreshInterval)};e()}setStatus(e){Be("status: %s -> %s",this.status||"[empty]",e),this.status=e,process.nextTick(()=>{this.emit(e)})}handleCloseEvent(e){var r;e&&Be("closed because %s",e);let i;!this.manuallyClosing&&typeof this.options.clusterRetryStrategy=="function"&&(i=this.options.clusterRetryStrategy.call(this,++this.retryAttempts,e)),typeof i=="number"?(this.setStatus("reconnecting"),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,Be("Cluster is disconnected. Retrying after %dms",i),this.connect().catch(function(n){Be("Got error %s when reconnecting. Ignoring...",n)})},i)):(this.options.shardedSubscribers&&((r=this.subscriberGroupEmitter)===null||r===void 0||r.removeAllListeners()),this.setStatus("end"),this.flushQueue(new Error("None of startup nodes is available")))}flushQueue(e){let r;for(;r=this.offlineQueue.shift();)r.command.reject(e)}executeOfflineCommands(){if(this.offlineQueue.length){Be("send %d commands in offline queue",this.offlineQueue.length);let e=this.offlineQueue;this.resetOfflineQueue();let r;for(;r=e.shift();)this.sendCommand(r.command,r.stream,r.node)}}natMapper(e){let r=typeof e=="string"?e:`${e.host}:${e.port}`,i=null;return this.options.natMap&&typeof this.options.natMap=="function"?i=this.options.natMap(r):this.options.natMap&&typeof this.options.natMap=="object"&&(i=this.options.natMap[r]),i?(Be("NAT mapping %s -> %O",r,i),Object.assign({},i)):typeof e=="string"?(0,qa.nodeKeyToRedisOptions)(e):e}getInfoFromNode(e,r){if(!e)return r(new Error("Node is disconnected"));let i=e.duplicate({enableOfflineQueue:!0,enableReadyCheck:!1,retryStrategy:null,connectionName:(0,qa.getConnectionName)("refresher",this.options.redisOptions&&this.options.redisOptions.connectionName)});i.on("error",Dr.noop),i.cluster("SLOTS",(0,Dr.timeout)((n,o)=>{if(i.disconnect(),n)return Be("error encountered running CLUSTER.SLOTS: %s",n),r(n);if(this.status==="disconnecting"||this.status==="close"||this.status==="end"){Be("ignore CLUSTER.SLOTS results (count: %d) since cluster status is %s",o.length,this.status),r();return}let s=[];Be("cluster slots result count: %d",o.length);for(let l=0;l<o.length;++l){let c=o[l],u=c[0],d=c[1],f=[];for(let p=2;p<c.length;p++){if(!c[p][0])continue;let m=this.natMapper({host:c[p][0],port:c[p][1]});m.readOnly=p!==2,s.push(m),f.push(m.host+":"+m.port)}Be("cluster slots result [%d]: slots %d~%d served by %s",l,u,d,f);for(let p=u;p<=d;p++)this.slots[p]=f}this._groupsIds=Object.create(null);let a=0;for(let l=0;l<16384;l++){let c=(this.slots[l]||[]).join(";");if(!c.length){this._groupsBySlot[l]=void 0;continue}this._groupsIds[c]||(this._groupsIds[c]=++a),this._groupsBySlot[l]=this._groupsIds[c]}this.connectionPool.reset(s),this.options.shardedSubscribers&&this.shardedSubscribers.reset(this.slots,this.connectionPool.getNodes("all")).catch(l=>{Be("Error while starting subscribers: %s",l)}),r()},this.options.slotsRefreshTimeout))}invokeReadyDelayedCallbacks(e){for(let r of this._readyDelayedCallbacks)process.nextTick(r,e);this._readyDelayedCallbacks=[]}readyCheck(e){this.cluster("INFO",(r,i)=>{if(r)return e(r);if(typeof i!="string")return e();let n,o=i.split(`\r
1140
- `);for(let s=0;s<o.length;++s){let a=o[s].split(":");if(a[0]==="cluster_state"){n=a[1];break}}n==="fail"?(Be("cluster state not ok (%s)",n),e(null,n)):e()})}resolveSrv(e){return new Promise((r,i)=>{this.options.resolveSrv(e,(n,o)=>{if(n)return i(n);let s=this,a=(0,qa.groupSrvRecords)(o),l=Object.keys(a).sort((u,d)=>parseInt(u)-parseInt(d));function c(u){if(!l.length)return i(u);let d=l[0],f=a[d],p=(0,qa.weightSrvRecords)(f);f.records.length||l.shift(),s.dnsLookup(p.name).then(m=>r({host:m,port:p.port}),c)}c()})})}dnsLookup(e){return new Promise((r,i)=>{this.options.dnsLookup(e,(n,o)=>{n?(Be("failed to resolve hostname %s to IP: %s",e,n.message),i(n)):(Be("resolved hostname %s to IP %s",e,o),r(o))})})}async resolveStartupNodeHostnames(){if(!Array.isArray(this.startupNodes)||this.startupNodes.length===0)throw new Error("`startupNodes` should contain at least one node.");let e=(0,qa.normalizeNodeOptions)(this.startupNodes),r=(0,qa.getUniqueHostnamesFromOptions)(e);if(r.length===0)return e;let i=await Promise.all(r.map((this.options.useSRVRecords?this.resolveSrv:this.dnsLookup).bind(this))),n=(0,Dr.zipMap)(r,i);return e.map(o=>{let s=n.get(o.host);return s?this.options.useSRVRecords?Object.assign({},o,s):Object.assign({},o,{host:s}):o})}createScanStream(e,{key:r,options:i={}}){return new Gse.default({objectMode:!0,key:r,redis:this,command:e,...i})}createShardedSubscriberGroup(){this.subscriberGroupEmitter=new Dw.EventEmitter,this.shardedSubscribers=new Qse.default(this.subscriberGroupEmitter,this.options);let e=r=>{r instanceof vm.default&&this.disconnect(!0)};this.subscriberGroupEmitter.on("-node",(r,i)=>{this.emit("-node",r,i),this.refreshSlotsCache(e)}),this.subscriberGroupEmitter.on("subscriberConnectFailed",({delay:r,error:i})=>{this.emit("error",i),setTimeout(()=>{this.refreshSlotsCache(e)},r)}),this.subscriberGroupEmitter.on("moved",()=>{this.refreshSlotsCache(e)}),this.subscriberGroupEmitter.on("-subscriber",()=>{this.emit("-subscriber")}),this.subscriberGroupEmitter.on("+subscriber",()=>{this.emit("+subscriber")}),this.subscriberGroupEmitter.on("nodeError",(r,i)=>{this.emit("nodeError",r,i)}),this.subscriberGroupEmitter.on("subscribersReady",()=>{this.emit("subscribersReady")});for(let r of["smessage","smessageBuffer"])this.subscriberGroupEmitter.on(r,(i,n,o)=>{this.emit(r,i,n,o)})}};(0,Bse.default)(lu,Dw.EventEmitter);(0,Vse.addTransactionSupport)(lu.prototype);jw.default=lu});var Sm=h(Nw=>{"use strict";Object.defineProperty(Nw,"__esModule",{value:!0});var eae=bt(),tae=(0,eae.Debug)("AbstractConnector"),Mw=class{constructor(e){this.connecting=!1,this.disconnectTimeout=e}check(e){return!0}disconnect(){if(this.connecting=!1,this.stream){let e=this.stream,r=setTimeout(()=>{tae("stream %s:%s still open, destroying it",e.remoteAddress,e.remotePort),e.destroy()},this.disconnectTimeout);e.on("close",()=>clearTimeout(r)),e.end()}}};Nw.default=Mw});var U$=h(Uw=>{"use strict";Object.defineProperty(Uw,"__esModule",{value:!0});var rae=U("net"),nae=U("tls"),iae=bt(),oae=Sm(),Lw=class extends oae.default{constructor(e){super(e.disconnectTimeout),this.options=e}connect(e){let{options:r}=this;this.connecting=!0;let i;return"path"in r&&r.path?i={path:r.path}:(i={},"port"in r&&r.port!=null&&(i.port=r.port),"host"in r&&r.host!=null&&(i.host=r.host),"family"in r&&r.family!=null&&(i.family=r.family)),r.tls&&Object.assign(i,r.tls),new Promise((n,o)=>{process.nextTick(()=>{if(!this.connecting){o(new Error(iae.CONNECTION_CLOSED_ERROR_MSG));return}try{r.tls?this.stream=(0,nae.connect)(i):this.stream=(0,rae.createConnection)(i)}catch(s){o(s);return}this.stream.once("error",s=>{this.firstError=s}),n(this.stream)})})}};Uw.default=Lw});var $$=h(Jw=>{"use strict";Object.defineProperty(Jw,"__esModule",{value:!0});function sae(t,e){return(t.host||"127.0.0.1")===(e.host||"127.0.0.1")&&(t.port||26379)===(e.port||26379)}var $w=class{constructor(e){this.cursor=0,this.sentinels=e.slice(0)}next(){let e=this.cursor>=this.sentinels.length;return{done:e,value:e?void 0:this.sentinels[this.cursor++]}}reset(e){e&&this.sentinels.length>1&&this.cursor!==1&&this.sentinels.unshift(...this.sentinels.splice(this.cursor-1)),this.cursor=0}add(e){for(let r=0;r<this.sentinels.length;r++)if(sae(e,this.sentinels[r]))return!1;return this.sentinels.push(e),!0}toString(){return`${JSON.stringify(this.sentinels)} @${this.cursor}`}};Jw.default=$w});var F$=h(Em=>{"use strict";Object.defineProperty(Em,"__esModule",{value:!0});Em.FailoverDetector=void 0;var aae=bt(),Fw=(0,aae.Debug)("FailoverDetector"),J$="+switch-master",qw=class{constructor(e,r){this.isDisconnected=!1,this.connector=e,this.sentinels=r}cleanup(){this.isDisconnected=!0;for(let e of this.sentinels)e.client.disconnect()}async subscribe(){Fw("Starting FailoverDetector");let e=[];for(let r of this.sentinels){let i=r.client.subscribe(J$).catch(n=>{Fw("Failed to subscribe to failover messages on sentinel %s:%s (%s)",r.address.host||"127.0.0.1",r.address.port||26739,n.message)});e.push(i),r.client.on("message",n=>{!this.isDisconnected&&n===J$&&this.disconnect()})}await Promise.all(e)}disconnect(){this.isDisconnected=!0,Fw("Failover detected, disconnecting"),this.connector.disconnect()}};Em.FailoverDetector=qw});var wm=h(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});uu.SentinelIterator=void 0;var lae=U("net"),cu=bt(),cae=U("tls"),q$=$$();uu.SentinelIterator=q$.default;var uae=Sm(),dae=mi(),pae=F$(),za=(0,cu.Debug)("SentinelConnector"),zw=class extends uae.default{constructor(e){if(super(e.disconnectTimeout),this.options=e,this.emitter=null,this.failoverDetector=null,!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 q$.default(this.options.sentinels)}check(e){let r=!e.role||this.options.role===e.role;return r||(za("role invalid, expected %s, but got %s",this.options.role,e.role),this.sentinelIterator.next(),this.sentinelIterator.next(),this.sentinelIterator.reset(!0)),r}disconnect(){super.disconnect(),this.failoverDetector&&this.failoverDetector.cleanup()}connect(e){this.connecting=!0,this.retryAttempts=0;let r,i=async()=>{let n=this.sentinelIterator.next();if(n.done){this.sentinelIterator.reset(!1);let l=typeof this.options.sentinelRetryStrategy=="function"?this.options.sentinelRetryStrategy(++this.retryAttempts):null,c=typeof l!="number"?"All sentinels are unreachable and retry is disabled.":`All sentinels are unreachable. Retrying from scratch after ${l}ms.`;r&&(c+=` Last error: ${r.message}`),za(c);let u=new Error(c);if(typeof l=="number")return e("error",u),await new Promise(d=>setTimeout(d,l)),i();throw u}let o=null,s=null;try{o=await this.resolve(n.value)}catch(l){s=l}if(!this.connecting)throw new Error(cu.CONNECTION_CLOSED_ERROR_MSG);let a=n.value.host+":"+n.value.port;if(o)return za("resolved: %s:%s from sentinel %s",o.host,o.port,a),this.options.enableTLSForSentinelMode&&this.options.tls?(Object.assign(o,this.options.tls),this.stream=(0,cae.connect)(o),this.stream.once("secureConnect",this.initFailoverDetector.bind(this))):(this.stream=(0,lae.createConnection)(o),this.stream.once("connect",this.initFailoverDetector.bind(this))),this.stream.once("error",l=>{this.firstError=l}),this.stream;{let l=s?"failed to connect to sentinel "+a+" because "+s.message:"connected to sentinel "+a+" successfully, but got an invalid reply: "+o;return za(l),e("sentinelError",new Error(l)),s&&(r=s),i()}};return i()}async updateSentinels(e){if(!this.options.updateSentinels)return;let r=await e.sentinel("sentinels",this.options.name);Array.isArray(r)&&(r.map(cu.packObject).forEach(i=>{if((i.flags?i.flags.split(","):[]).indexOf("disconnected")===-1&&i.ip&&i.port){let o=this.sentinelNatResolve(z$(i));this.sentinelIterator.add(o)&&za("adding sentinel %s:%s",o.host,o.port)}}),za("Updated internal sentinels: %s",this.sentinelIterator))}async resolveMaster(e){let r=await e.sentinel("get-master-addr-by-name",this.options.name);return await this.updateSentinels(e),this.sentinelNatResolve(Array.isArray(r)?{host:r[0],port:Number(r[1])}:null)}async resolveSlave(e){let r=await e.sentinel("slaves",this.options.name);if(!Array.isArray(r))return null;let i=r.map(cu.packObject).filter(n=>n.flags&&!n.flags.match(/(disconnected|s_down|o_down)/));return this.sentinelNatResolve(fae(i,this.options.preferredSlaves))}sentinelNatResolve(e){if(!e||!this.options.natMap)return e;let r=`${e.host}:${e.port}`,i=e;return typeof this.options.natMap=="function"?i=this.options.natMap(r)||e:typeof this.options.natMap=="object"&&(i=this.options.natMap[r]||e),i}connectToSentinel(e,r){return new dae.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?void 0:this.options.family),tls:this.options.sentinelTLS,retryStrategy:null,enableReadyCheck:!1,connectTimeout:this.options.connectTimeout,commandTimeout:this.options.sentinelCommandTimeout,...r})}async resolve(e){let r=this.connectToSentinel(e);r.on("error",mae);try{return this.options.role==="slave"?await this.resolveSlave(r):await this.resolveMaster(r)}finally{r.disconnect()}}async initFailoverDetector(){var e;if(!this.options.failoverDetector)return;this.sentinelIterator.reset(!0);let r=[];for(;r.length<this.options.sentinelMaxConnections;){let{done:i,value:n}=this.sentinelIterator.next();if(i)break;let o=this.connectToSentinel(n,{lazyConnect:!0,retryStrategy:this.options.sentinelReconnectStrategy});o.on("reconnecting",()=>{var s;(s=this.emitter)===null||s===void 0||s.emit("sentinelReconnecting")}),r.push({address:n,client:o})}this.sentinelIterator.reset(!1),this.failoverDetector&&this.failoverDetector.cleanup(),this.failoverDetector=new pae.FailoverDetector(this,r),await this.failoverDetector.subscribe(),(e=this.emitter)===null||e===void 0||e.emit("failoverSubscribed")}};uu.default=zw;function fae(t,e){if(t.length===0)return null;let r;if(typeof e=="function")r=e(t);else if(e!==null&&typeof e=="object"){let i=Array.isArray(e)?e:[e];i.sort((n,o)=>(n.prio||(n.prio=1),o.prio||(o.prio=1),n.prio<o.prio?-1:n.prio>o.prio?1:0));for(let n=0;n<i.length;n++){for(let o=0;o<t.length;o++){let s=t[o];if(s.ip===i[n].ip&&s.port===i[n].port){r=s;break}}if(r)break}}return r||(r=(0,cu.sample)(t)),z$(r)}function z$(t){return{host:t.ip,port:Number(t.port)}}function mae(){}});var G$=h(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.SentinelConnector=Ga.StandaloneConnector=void 0;var hae=U$();Ga.StandaloneConnector=hae.default;var yae=wm();Ga.SentinelConnector=yae.default});var V$=h(Vw=>{"use strict";Object.defineProperty(Vw,"__esModule",{value:!0});var gae=es(),Gw=class extends gae.AbortError{constructor(e){let r=`Reached the max retries per request limit (which is ${e}). Refer to "maxRetriesPerRequest" option for details.`;super(r),Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}};Vw.default=Gw});var B$=h(xm=>{"use strict";Object.defineProperty(xm,"__esModule",{value:!0});xm.MaxRetriesPerRequestError=void 0;var bae=V$();xm.MaxRetriesPerRequestError=bae.default});var eJ=h((b_e,Q$)=>{"use strict";var Xw=U("buffer").Buffer,vae=U("string_decoder").StringDecoder,Bw=new vae,W$=es(),Sae=W$.ReplyError,Eae=W$.ParserError,bn=Xw.allocUnsafe(32*1024),ur=0,Im=null,du=0,Ww=0;function wae(t){let e=t.buffer.length-1;var r=t.offset,i=0,n=1;for(t.buffer[r]===45&&(n=-1,r++);r<e;){let o=t.buffer[r++];if(o===13)return t.offset=r+1,n*i;i=i*10+(o-48)}}function xae(t){let e=t.buffer.length-1;var r=t.offset,i=0,n="";for(t.buffer[r]===45&&(n+="-",r++);r<e;){var o=t.buffer[r++];if(o===13)return t.offset=r+1,i!==0&&(n+=i),n;i>429496728?(n+=i*10+(o-48),i=0):o===48&&i===0?n+=0:i=i*10+(o-48)}}function Z$(t){let e=t.offset,r=t.buffer,i=r.length-1;for(var n=e;n<i;)if(r[n++]===13)return t.offset=n+1,t.optionReturnBuffers===!0?t.buffer.slice(e,n-1):t.buffer.toString("utf8",e,n-1)}function H$(t){let e=t.buffer.length-1;for(var r=t.offset,i=0;r<e;){let n=t.buffer[r++];if(n===13)return t.offset=r+1,i;i=i*10+(n-48)}}function Iae(t){return t.optionStringNumbers===!0?xae(t):wae(t)}function kae(t){let e=H$(t);if(e===void 0)return;if(e<0)return null;let r=t.offset+e;if(r+2>t.buffer.length){t.bigStrSize=r+2,t.totalChunkSize=t.buffer.length,t.bufferCache.push(t.buffer);return}let i=t.offset;return t.offset=r+2,t.optionReturnBuffers===!0?t.buffer.slice(i,r):t.buffer.toString("utf8",i,r)}function _ae(t){var e=Z$(t);if(e!==void 0)return t.optionReturnBuffers===!0&&(e=e.toString()),new Sae(e)}function Tae(t,e){let r=new Eae("Protocol error, got "+JSON.stringify(String.fromCharCode(e))+" as reply type byte",JSON.stringify(t.buffer),t.offset);t.buffer=null,t.returnFatalError(r)}function Cae(t){let e=H$(t);if(e===void 0)return;if(e<0)return null;let r=new Array(e);return Y$(t,r,0)}function Zw(t,e,r){t.arrayCache.push(e),t.arrayPos.push(r)}function Hw(t){let e=t.arrayCache.pop();var r=t.arrayPos.pop();if(t.arrayCache.length){let i=Hw(t);if(i===void 0){Zw(t,e,r);return}e[r++]=i}return Y$(t,e,r)}function Y$(t,e,r){let i=t.buffer.length;for(;r<e.length;){let n=t.offset;if(t.offset>=i){Zw(t,e,r);return}let o=X$(t,t.buffer[t.offset++]);if(o===void 0){t.arrayCache.length||t.bufferCache.length||(t.offset=n),Zw(t,e,r);return}e[r]=o,r++}return e}function X$(t,e){switch(e){case 36:return kae(t);case 43:return Z$(t);case 42:return Cae(t);case 58:return Iae(t);case 45:return _ae(t);default:return Tae(t,e)}}function Oae(){if(bn.length>50*1024)if(du===1||Ww>du*2){let t=Math.floor(bn.length/10),e=t<ur?ur:t;ur=0,bn=bn.slice(e,bn.length)}else Ww++,du--;else clearInterval(Im),du=0,Ww=0,Im=null}function Aae(t){if(bn.length<t+ur){let e=t>78643200?2:3;ur>1024*1024*111&&(ur=1024*1024*50),bn=Xw.allocUnsafe(t*e+ur),ur=0,du++,Im===null&&(Im=setInterval(Oae,50))}}function Kae(t){let e=t.bufferCache,r=t.offset;var i=e.length,n=t.bigStrSize-t.totalChunkSize;if(t.offset=n,n<=2){if(i===2)return e[0].toString("utf8",r,e[0].length+n-2);i--,n=e[e.length-2].length+n}for(var o=Bw.write(e[0].slice(r)),s=1;s<i-1;s++)o+=Bw.write(e[s]);return o+=Bw.end(e[s].slice(0,n-2)),o}function Rae(t){let e=t.bufferCache,r=t.offset,i=t.bigStrSize-r-2;var n=e.length,o=t.bigStrSize-t.totalChunkSize;if(t.offset=o,o<=2){if(n===2)return e[0].slice(r,e[0].length+o-2);n--,o=e[e.length-2].length+o}Aae(i);let s=ur;e[0].copy(bn,s,r,e[0].length),ur+=e[0].length-r;for(var a=1;a<n-1;a++)e[a].copy(bn,ur),ur+=e[a].length;return e[a].copy(bn,ur,0,o-2),ur+=o-2,bn.slice(s,ur)}var Yw=class{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){let i=this.buffer.length,n=i-this.offset,o=Xw.allocUnsafe(n+e.length);if(this.buffer.copy(o,0,this.offset,i),e.copy(o,n,0,e.length),this.buffer=o,this.offset=0,this.arrayCache.length){let s=Hw(this);if(s===void 0)return;this.returnReply(s)}}else if(this.totalChunkSize+e.length>=this.bigStrSize){this.bufferCache.push(e);var r=this.optionReturnBuffers?Rae(this):Kae(this);if(this.bigStrSize=0,this.bufferCache=[],this.buffer=e,this.arrayCache.length&&(this.arrayCache[0][this.arrayPos[0]++]=r,r=Hw(this),r===void 0))return;this.returnReply(r)}else{this.bufferCache.push(e),this.totalChunkSize+=e.length;return}for(;this.offset<this.buffer.length;){let i=this.offset,n=this.buffer[this.offset++],o=X$(this,n);if(o===void 0){this.arrayCache.length||this.bufferCache.length||(this.offset=i);return}n===45?this.returnError(o):this.returnReply(o)}this.buffer=null}};Q$.exports=Yw});var rJ=h((v_e,tJ)=>{"use strict";tJ.exports=eJ()});var nJ=h(tx=>{"use strict";Object.defineProperty(tx,"__esModule",{value:!0});var ex=class{constructor(){this.set={subscribe:{},psubscribe:{},ssubscribe:{}}}add(e,r){this.set[Qw(e)][r]=!0}del(e,r){delete this.set[Qw(e)][r]}channels(e){return Object.keys(this.set[Qw(e)])}isEmpty(){return this.channels("subscribe").length===0&&this.channels("psubscribe").length===0&&this.channels("ssubscribe").length===0}};tx.default=ex;function Qw(t){return t==="unsubscribe"?"subscribe":t==="punsubscribe"?"psubscribe":t==="sunsubscribe"?"ssubscribe":t}});var aJ=h(nx=>{"use strict";Object.defineProperty(nx,"__esModule",{value:!0});var iJ=pi(),Dae=bt(),jae=rJ(),Pae=nJ(),Mae=(0,Dae.Debug)("dataHandler"),rx=class{constructor(e,r){this.redis=e;let i=new jae({stringNumbers:r.stringNumbers,returnBuffers:!0,returnError:n=>{this.returnError(n)},returnFatalError:n=>{this.returnFatalError(n)},returnReply:n=>{this.returnReply(n)}});e.stream.prependListener("data",n=>{i.execute(n)}),e.stream.resume()}returnFatalError(e){e.message+=". Please report this.",this.redis.recoverFromFatalError(e,e,{offlineQueue:!1})}returnError(e){let r=this.shiftCommand(e);if(r){if(e.command={name:r.command.name,args:r.command.args},r.command.name=="ssubscribe"&&e.message.includes("MOVED")){this.redis.emit("moved");return}this.redis.handleReconnection(e,r)}}returnReply(e){if(this.handleMonitorReply(e)||this.handleSubscriberReply(e))return;let r=this.shiftCommand(e);r&&(iJ.default.checkFlag("ENTER_SUBSCRIBER_MODE",r.command.name)?(this.redis.condition.subscriber=new Pae.default,this.redis.condition.subscriber.add(r.command.name,e[1].toString()),oJ(r.command,e[2])||this.redis.commandQueue.unshift(r)):iJ.default.checkFlag("EXIT_SUBSCRIBER_MODE",r.command.name)?sJ(r.command,e[2])||this.redis.commandQueue.unshift(r):r.command.resolve(e))}handleSubscriberReply(e){if(!this.redis.condition.subscriber)return!1;let r=Array.isArray(e)?e[0].toString():null;switch(Mae('receive reply "%s" in subscriber mode',r),r){case"message":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":{let i=e[1].toString();this.redis.listeners("pmessage").length>0&&this.redis.emit("pmessage",i,e[2].toString(),e[3].toString()),this.redis.emit("pmessageBuffer",i,e[2],e[3]);break}case"smessage":{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":{let i=e[1].toString();this.redis.condition.subscriber.add(r,i);let n=this.shiftCommand(e);if(!n)return;oJ(n.command,e[2])||this.redis.commandQueue.unshift(n);break}case"sunsubscribe":case"unsubscribe":case"punsubscribe":{let i=e[1]?e[1].toString():null;i&&this.redis.condition.subscriber.del(r,i);let n=e[2];Number(n)===0&&(this.redis.condition.subscriber=!1);let o=this.shiftCommand(e);if(!o)return;sJ(o.command,n)||this.redis.commandQueue.unshift(o);break}default:{let i=this.shiftCommand(e);if(!i)return;i.command.resolve(e)}}return!0}handleMonitorReply(e){if(this.redis.status!=="monitoring")return!1;let r=e.toString();if(r==="OK")return!1;let i=r.indexOf(" "),n=r.slice(0,i),o=r.indexOf('"'),s=r.slice(o+1,-1).split('" "').map(l=>l.replace(/\\"/g,'"')),a=r.slice(i+2,o-2).split(" ");return this.redis.emit("monitor",n,s,a[1],a[0]),!0}shiftCommand(e){let r=this.redis.commandQueue.shift();if(!r){let i="Command queue state error. If you can reproduce this, please report it.",n=new Error(i+(e instanceof Error?` Last error: ${e.message}`:` Last reply: ${e.toString()}`));return this.redis.emit("error",n),null}return r}};nx.default=rx;var Xi=new WeakMap;function oJ(t,e){let r=Xi.has(t)?Xi.get(t):t.args.length;return r-=1,r<=0?(t.resolve(e),Xi.delete(t),!0):(Xi.set(t,r),!1)}function sJ(t,e){let r=Xi.has(t)?Xi.get(t):t.args.length;return r===0?Number(e)===0?(Xi.delete(t),t.resolve(e),!0):!1:(r-=1,r<=0?(t.resolve(e),!0):(Xi.set(t,r),!1))}});var lJ=h(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.readyHandler=nn.errorHandler=nn.closeHandler=nn.connectHandler=void 0;var Nae=es(),Lae=pi(),Uae=B$(),Fn=bt(),$ae=aJ(),Ut=(0,Fn.Debug)("connection");function Jae(t){return function(){var e;t.setStatus("connect"),t.resetCommandQueue();let r=!1,{connectionEpoch:i}=t;t.condition.auth&&t.auth(t.condition.auth,function(o){i===t.connectionEpoch&&o&&(o.message.indexOf("no password is set")!==-1?console.warn("[WARN] Redis server does not require a password, but a password was supplied."):o.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"):o.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.`):(r=!0,t.recoverFromFatalError(o,o)))}),t.condition.select&&t.select(t.condition.select).catch(o=>{t.silentEmit("error",o)}),new $ae.default(t,{stringNumbers:t.options.stringNumbers});let n=[];t.options.connectionName&&(Ut("set the connection name [%s]",t.options.connectionName),n.push(t.client("setname",t.options.connectionName).catch(Fn.noop))),t.options.disableClientInfo||(Ut("set the client info"),n.push((0,Fn.getPackageMeta)().then(o=>t.client("SETINFO","LIB-VER",o.version).catch(Fn.noop)).catch(Fn.noop)),n.push(t.client("SETINFO","LIB-NAME",!((e=t.options)===null||e===void 0)&&e.clientInfoTag?`ioredis(${t.options.clientInfoTag})`:"ioredis").catch(Fn.noop))),Promise.all(n).catch(Fn.noop).finally(()=>{t.options.enableReadyCheck||nn.readyHandler(t)(),t.options.enableReadyCheck&&t._readyCheck(function(o,s){i===t.connectionEpoch&&(o?r||t.recoverFromFatalError(new Error("Ready check failed: "+o.message),o):t.connector.check(s)?nn.readyHandler(t)():t.disconnect(!0))})})}}nn.connectHandler=Jae;function ix(t){let e=new Nae.AbortError("Command aborted due to connection close");return e.command={name:t.name,args:t.args},e}function Fae(t){var e;let r=0;for(let i=0;i<t.length;){let n=(e=t.peekAt(i))===null||e===void 0?void 0:e.command,o=n.pipelineIndex;if((o===void 0||o===0)&&(r=0),o!==void 0&&o!==r++){t.remove(i,1),n.reject(ix(n));continue}i++}}function qae(t){var e;for(let r=0;r<t.length;){let i=(e=t.peekAt(r))===null||e===void 0?void 0:e.command;if(i.name==="multi")break;if(i.name==="exec"){t.remove(r,1),i.reject(ix(i));break}i.inTransaction?(t.remove(r,1),i.reject(ix(i))):r++}}function zae(t){return function(){let r=t.status;if(t.setStatus("close"),t.commandQueue.length&&Fae(t.commandQueue),t.offlineQueue.length&&qae(t.offlineQueue),r==="ready"&&(t.prevCondition||(t.prevCondition=t.condition),t.commandQueue.length&&(t.prevCommandQueue=t.commandQueue)),t.manuallyClosing)return t.manuallyClosing=!1,Ut("skip reconnecting since the connection is manually closed."),e();if(typeof t.options.retryStrategy!="function")return Ut("skip reconnecting because `retryStrategy` is not a function"),e();let i=t.options.retryStrategy(++t.retryAttempts);if(typeof i!="number")return Ut("skip reconnecting because `retryStrategy` doesn't return a number"),e();Ut("reconnect in %sms",i),t.setStatus("reconnecting",i),t.reconnectTimeout=setTimeout(function(){t.reconnectTimeout=null,t.connect().catch(Fn.noop)},i);let{maxRetriesPerRequest:n}=t.options;typeof n=="number"&&(n<0?Ut("maxRetriesPerRequest is negative, ignoring..."):t.retryAttempts%(n+1)===0&&(Ut("reach maxRetriesPerRequest limitation, flushing command queue..."),t.flushQueue(new Uae.MaxRetriesPerRequestError(n))))};function e(){t.setStatus("end"),t.flushQueue(new Error(Fn.CONNECTION_CLOSED_ERROR_MSG))}}nn.closeHandler=zae;function Gae(t){return function(e){Ut("error: %s",e),t.silentEmit("error",e)}}nn.errorHandler=Gae;function Vae(t){return function(){if(t.setStatus("ready"),t.retryAttempts=0,t.options.monitor){t.call("monitor").then(()=>t.setStatus("monitoring"),i=>t.emit("error",i));let{sendCommand:r}=t;t.sendCommand=function(i){return Lae.default.checkFlag("VALID_IN_MONITOR_MODE",i.name)?r.call(t,i):(i.reject(new Error("Connection is in monitoring mode, can't process commands.")),i.promise)},t.once("close",function(){delete t.sendCommand});return}let e=t.prevCondition?t.prevCondition.select:t.condition.select;if(t.options.readOnly&&(Ut("set the connection to readonly mode"),t.readonly().catch(Fn.noop)),t.prevCondition){let r=t.prevCondition;if(t.prevCondition=null,r.subscriber&&t.options.autoResubscribe){t.condition.select!==e&&(Ut("connect to db [%d]",e),t.select(e));let i=r.subscriber.channels("subscribe");i.length&&(Ut("subscribe %d channels",i.length),t.subscribe(i));let n=r.subscriber.channels("psubscribe");n.length&&(Ut("psubscribe %d channels",n.length),t.psubscribe(n));let o=r.subscriber.channels("ssubscribe");if(o.length){Ut("ssubscribe %s",o.length);for(let s of o)t.ssubscribe(s)}}}if(t.prevCommandQueue)if(t.options.autoResendUnfulfilledCommands)for(Ut("resend %d unfulfilled commands",t.prevCommandQueue.length);t.prevCommandQueue.length>0;){let r=t.prevCommandQueue.shift();r.select!==t.condition.select&&r.command.name!=="select"&&t.select(r.select),t.sendCommand(r.command,r.stream)}else t.prevCommandQueue=null;if(t.offlineQueue.length){Ut("send %d commands in offline queue",t.offlineQueue.length);let r=t.offlineQueue;for(t.resetOfflineQueue();r.length>0;){let i=r.shift();i.select!==t.condition.select&&i.command.name!=="select"&&t.select(i.select),t.sendCommand(i.command,i.stream)}}t.condition.select!==e&&(Ut("connect to db [%d]",e),t.select(e))}}nn.readyHandler=Vae});var cJ=h(km=>{"use strict";Object.defineProperty(km,"__esModule",{value:!0});km.DEFAULT_REDIS_OPTIONS=void 0;km.DEFAULT_REDIS_OPTIONS={port:6379,host:"localhost",family:0,connectTimeout:1e4,disconnectTimeout:2e3,retryStrategy:function(t){return Math.min(t*50,2e3)},keepAlive:0,noDelay:!0,connectionName:null,disableClientInfo:!1,clientInfoTag:void 0,sentinels:null,name:null,role:"master",sentinelRetryStrategy:function(t){return Math.min(t*10,1e3)},sentinelReconnectStrategy:function(){return 6e4},natMap:null,enableTLSForSentinelMode:!1,updateSentinels:!0,failoverDetector:!1,username:null,password:null,db:0,enableOfflineQueue:!0,enableReadyCheck:!0,autoResubscribe:!0,autoResendUnfulfilledCommands:!0,lazyConnect:!1,keyPrefix:"",reconnectOnError:null,readOnly:!1,stringNumbers:!1,maxRetriesPerRequest:20,maxLoadingRetryTime:1e4,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],sentinelMaxConnections:10,blockingTimeoutGrace:100}});var mi=h(sx=>{"use strict";Object.defineProperty(sx,"__esModule",{value:!0});var uJ=Qo(),pJ=U("events"),ox=Zi(),Bae=Pw(),rs=pi(),Wae=G$(),Zae=wm(),Qi=lJ(),fJ=cJ(),Hae=dm(),Yae=vw(),ns=bt(),Xae=Ew(),Qae=fm(),eo=yf(),dJ=gm(),to=(0,ns.Debug)("redis"),ro=class t extends Qae.default{constructor(e,r,i){if(super(),this.status="wait",this.isCluster=!1,this.reconnectTimeout=null,this.connectionEpoch=0,this.retryAttempts=0,this.manuallyClosing=!1,this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this.parseOptions(e,r,i),pJ.EventEmitter.call(this),this.resetCommandQueue(),this.resetOfflineQueue(),this.options.Connector)this.connector=new this.options.Connector(this.options);else if(this.options.sentinels){let n=new Zae.default(this.options);n.emitter=this,this.connector=n}else this.connector=new Wae.StandaloneConnector(this.options);this.options.scripts&&Object.entries(this.options.scripts).forEach(([n,o])=>{this.defineCommand(n,o)}),this.options.lazyConnect?this.setStatus("wait"):this.connect().catch(eo.noop)}static createClient(...e){return new t(...e)}get autoPipelineQueueSize(){let e=0;for(let r of this._autoPipelines.values())e+=r.length;return e}connect(e){let r=new Promise((i,n)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){n(new Error("Redis is already connecting/connected"));return}this.connectionEpoch+=1,this.setStatus("connecting");let{options:o}=this;this.condition={select:o.db,auth:o.username?[o.username,o.password]:o.password,subscriber:!1};let s=this;(0,ox.default)(this.connector.connect(function(a,l){s.silentEmit(a,l)}),function(a,l){if(a){s.flushQueue(a),s.silentEmit("error",a),n(a),s.setStatus("end");return}let c=o.tls?"secureConnect":"connect";if("sentinels"in o&&o.sentinels&&!o.enableTLSForSentinelMode&&(c="connect"),s.stream=l,o.noDelay&&l.setNoDelay(!0),typeof o.keepAlive=="number"&&(l.connecting?l.once(c,()=>{l.setKeepAlive(!0,o.keepAlive)}):l.setKeepAlive(!0,o.keepAlive)),l.connecting){if(l.once(c,Qi.connectHandler(s)),o.connectTimeout){let f=!1;l.setTimeout(o.connectTimeout,function(){if(f)return;l.setTimeout(0),l.destroy();let p=new Error("connect ETIMEDOUT");p.errorno="ETIMEDOUT",p.code="ETIMEDOUT",p.syscall="connect",Qi.errorHandler(s)(p)}),l.once(c,function(){f=!0,l.setTimeout(0)})}}else if(l.destroyed){let f=s.connector.firstError;f&&process.nextTick(()=>{Qi.errorHandler(s)(f)}),process.nextTick(Qi.closeHandler(s))}else process.nextTick(Qi.connectHandler(s));l.destroyed||(l.once("error",Qi.errorHandler(s)),l.once("close",Qi.closeHandler(s)));let u=function(){s.removeListener("close",d),i()};var d=function(){s.removeListener("ready",u),n(new Error(ns.CONNECTION_CLOSED_ERROR_MSG))};s.once("ready",u),s.once("close",d)})});return(0,ox.default)(r,e)}disconnect(e=!1){e||(this.manuallyClosing=!0),this.reconnectTimeout&&!e&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.status==="wait"?Qi.closeHandler(this)():this.connector.disconnect()}end(){this.disconnect()}duplicate(e){return new t({...this.options,...e})}get mode(){var e;return this.options.monitor?"monitor":!((e=this.condition)===null||e===void 0)&&e.subscriber?"subscriber":"normal"}monitor(e){let r=this.duplicate({monitor:!0,lazyConnect:!1});return(0,ox.default)(new Promise(function(i,n){r.once("error",n),r.once("monitoring",function(){i(r)})}),e)}sendCommand(e,r){var i,n;if(this.status==="wait"&&this.connect().catch(eo.noop),this.status==="end")return e.reject(new Error(ns.CONNECTION_CLOSED_ERROR_MSG)),e.promise;if(!((i=this.condition)===null||i===void 0)&&i.subscriber&&!rs.default.checkFlag("VALID_IN_SUBSCRIBER_MODE",e.name))return e.reject(new Error("Connection in subscriber mode, only subscriber commands may be used")),e.promise;typeof this.options.commandTimeout=="number"&&e.setTimeout(this.options.commandTimeout);let o=this.getBlockingTimeoutInMs(e),s=this.status==="ready"||!r&&this.status==="connect"&&(0,uJ.exists)(e.name,{caseInsensitive:!0})&&((0,uJ.hasFlag)(e.name,"loading",{nameCaseInsensitive:!0})||rs.default.checkFlag("HANDSHAKE_COMMANDS",e.name));if(this.stream&&this.stream.writable?this.stream._writableState&&this.stream._writableState.ended&&(s=!1):s=!1,s)to.enabled&&to("write command[%s]: %d -> %s(%o)",this._getDescription(),(n=this.condition)===null||n===void 0?void 0:n.select,e.name,e.args),r?"isPipeline"in r&&r.isPipeline?r.write(e.toWritable(r.destination.redis.stream)):r.write(e.toWritable(r)):this.stream.write(e.toWritable(this.stream)),this.commandQueue.push({command:e,stream:r,select:this.condition.select}),o!==void 0&&e.setBlockingTimeout(o),rs.default.checkFlag("WILL_DISCONNECT",e.name)&&(this.manuallyClosing=!0),this.options.socketTimeout!==void 0&&this.socketTimeoutTimer===void 0&&this.setSocketTimeout();else{if(!this.options.enableOfflineQueue)return e.reject(new Error("Stream isn't writeable and enableOfflineQueue options is false")),e.promise;if(e.name==="quit"&&this.offlineQueue.length===0)return this.disconnect(),e.resolve(Buffer.from("OK")),e.promise;if(to.enabled&&to("queue command[%s]: %d -> %s(%o)",this._getDescription(),this.condition.select,e.name,e.args),this.offlineQueue.push({command:e,stream:r,select:this.condition.select}),rs.default.checkFlag("BLOCKING_COMMANDS",e.name)){let a=this.getConfiguredBlockingTimeout();a!==void 0&&e.setBlockingTimeout(a)}}if(e.name==="select"&&(0,ns.isInt)(e.args[0])){let a=parseInt(e.args[0],10);this.condition.select!==a&&(this.condition.select=a,this.emit("select",a),to("switch to db [%d]",this.condition.select))}return e.promise}getBlockingTimeoutInMs(e){var r;if(!rs.default.checkFlag("BLOCKING_COMMANDS",e.name))return;let i=this.getConfiguredBlockingTimeout();if(i===void 0)return;let n=e.extractBlockingTimeout();if(typeof n=="number")return n>0?n+((r=this.options.blockingTimeoutGrace)!==null&&r!==void 0?r:fJ.DEFAULT_REDIS_OPTIONS.blockingTimeoutGrace):i;if(n===null)return i}getConfiguredBlockingTimeout(){if(typeof this.options.blockingTimeout=="number"&&this.options.blockingTimeout>0)return this.options.blockingTimeout}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=void 0},this.options.socketTimeout),this.stream.once("data",()=>{clearTimeout(this.socketTimeoutTimer),this.socketTimeoutTimer=void 0,this.commandQueue.length!==0&&this.setSocketTimeout()})}scanStream(e){return this.createScanStream("scan",{options:e})}scanBufferStream(e){return this.createScanStream("scanBuffer",{options:e})}sscanStream(e,r){return this.createScanStream("sscan",{key:e,options:r})}sscanBufferStream(e,r){return this.createScanStream("sscanBuffer",{key:e,options:r})}hscanStream(e,r){return this.createScanStream("hscan",{key:e,options:r})}hscanBufferStream(e,r){return this.createScanStream("hscanBuffer",{key:e,options:r})}zscanStream(e,r){return this.createScanStream("zscan",{key:e,options:r})}zscanBufferStream(e,r){return this.createScanStream("zscanBuffer",{key:e,options:r})}silentEmit(e,r){let i;if(!(e==="error"&&(i=r,this.status==="end"||this.manuallyClosing&&i instanceof Error&&(i.message===ns.CONNECTION_CLOSED_ERROR_MSG||i.syscall==="connect"||i.syscall==="read"))))return this.listeners(e).length>0?this.emit.apply(this,arguments):(i&&i instanceof Error&&console.error("[ioredis] Unhandled error event:",i.stack),!1)}recoverFromFatalError(e,r,i){this.flushQueue(r,i),this.silentEmit("error",r),this.disconnect(!0)}handleReconnection(e,r){var i;let n=!1;switch(this.options.reconnectOnError&&!rs.default.checkFlag("IGNORE_RECONNECT_ON_ERROR",r.command.name)&&(n=this.options.reconnectOnError(e)),n){case 1:case!0:this.status!=="reconnecting"&&this.disconnect(!0),r.command.reject(e);break;case 2:this.status!=="reconnecting"&&this.disconnect(!0),((i=this.condition)===null||i===void 0?void 0:i.select)!==r.select&&r.command.name!=="select"&&this.select(r.select),this.sendCommand(r.command);break;default:r.command.reject(e)}}_getDescription(){let e;return"path"in this.options&&this.options.path?e=this.options.path:this.stream&&this.stream.remoteAddress&&this.stream.remotePort?e=this.stream.remoteAddress+":"+this.stream.remotePort:"host"in this.options&&this.options.host?e=this.options.host+":"+this.options.port:e="",this.options.connectionName&&(e+=` (${this.options.connectionName})`),e}resetCommandQueue(){this.commandQueue=new dJ}resetOfflineQueue(){this.offlineQueue=new dJ}parseOptions(...e){let r={},i=!1;for(let n=0;n<e.length;++n){let o=e[n];if(!(o===null||typeof o>"u"))if(typeof o=="object")(0,eo.defaults)(r,o);else if(typeof o=="string")(0,eo.defaults)(r,(0,ns.parseURL)(o)),o.startsWith("rediss://")&&(i=!0);else if(typeof o=="number")r.port=o;else throw new Error("Invalid argument "+o)}i&&(0,eo.defaults)(r,{tls:!0}),(0,eo.defaults)(r,t.defaultOptions),typeof r.port=="string"&&(r.port=parseInt(r.port,10)),typeof r.db=="string"&&(r.db=parseInt(r.db,10)),this.options=(0,ns.resolveTLSProfile)(r)}setStatus(e,r){to.enabled&&to("status[%s]: %s -> %s",this._getDescription(),this.status||"[empty]",e),this.status=e,process.nextTick(this.emit.bind(this,e,r))}createScanStream(e,{key:r,options:i={}}){return new Hae.default({objectMode:!0,key:r,redis:this,command:e,...i})}flushQueue(e,r){r=(0,eo.defaults)({},r,{offlineQueue:!0,commandQueue:!0});let i;if(r.offlineQueue)for(;i=this.offlineQueue.shift();)i.command.reject(e);if(r.commandQueue&&this.commandQueue.length>0)for(this.stream&&this.stream.removeAllListeners("data");i=this.commandQueue.shift();)i.command.reject(e)}_readyCheck(e){let r=this;this.info(function(i,n){if(i)return i.message&&i.message.includes("NOPERM")?(console.warn(`Skipping the ready check because INFO command fails: "${i.message}". You can disable ready check with "enableReadyCheck". More: https://github.com/luin/ioredis/wiki/Disable-ready-check.`),e(null,{})):e(i);if(typeof n!="string")return e(null,n);let o={},s=n.split(`\r
1139
+ `}}return r}stringifyArguments(){for(let e=0;e<this.args.length;++e){let r=this.args[e];typeof r=="string"||(r instanceof Buffer?this.bufferMode=!0:this.args[e]=(0,ts.toArg)(r))}}transformReply(e){this.replyEncoding&&(e=(0,ts.convertBufferToString)(e,this.replyEncoding));let r=t._transformer.reply[this.name];return r&&(e=r(e)),e}setTimeout(e){this._commandTimeoutTimer||(this._commandTimeoutTimer=setTimeout(()=>{this.isResolved||this.reject(new Error("Command timed out"))},e))}setBlockingTimeout(e){if(e<=0)return;this._blockingTimeoutTimer&&(clearTimeout(this._blockingTimeoutTimer),this._blockingTimeoutTimer=void 0);let r=Date.now();this._blockingDeadline===void 0&&(this._blockingDeadline=r+e);let i=this._blockingDeadline-r;if(i<=0){this.resolve(null);return}this._blockingTimeoutTimer=setTimeout(()=>{if(this.isResolved){this._blockingTimeoutTimer=void 0;return}this._blockingTimeoutTimer=void 0,this.resolve(null)},i)}extractBlockingTimeout(){let e=this.args;if(!e||e.length===0)return;let r=this.name.toLowerCase();if(t.checkFlag("LAST_ARG_TIMEOUT_COMMANDS",r))return(0,iw.parseSecondsArgument)(e[e.length-1]);if(t.checkFlag("FIRST_ARG_TIMEOUT_COMMANDS",r))return(0,iw.parseSecondsArgument)(e[0]);if(t.checkFlag("BLOCK_OPTION_COMMANDS",r))return(0,iw.parseBlockOption)(e)}_clearTimers(){let e=this._commandTimeoutTimer;e&&(clearTimeout(e),delete this._commandTimeoutTimer);let r=this._blockingTimeoutTimer;r&&(clearTimeout(r),delete this._blockingTimeoutTimer)}initPromise(){let e=new Promise((r,i)=>{if(!this.transformed){this.transformed=!0;let n=t._transformer.argument[this.name];n&&(this.args=n(this.args)),this.stringifyArguments()}this.resolve=this._convertValue(r),this.reject=n=>{this._clearTimers(),this.errorStack?i((0,ts.optimizeErrorStack)(n,this.errorStack.stack,__dirname)):i(n)}});this.promise=(0,sse.default)(e,this.callback)}_iterateKeys(e=r=>r){if(typeof this.keys>"u"&&(this.keys=[],(0,i$.exists)(this.name,{caseInsensitive:!0}))){let r=(0,i$.getKeyIndexes)(this.name,this.args,{nameCaseInsensitive:!0});for(let i of r)this.args[i]=e(this.args[i]),this.keys.push(this.args[i])}return this.keys}_convertValue(e){return r=>{try{this._clearTimers(),e(this.transformReply(r)),this.isResolved=!0}catch(i){this.reject(i)}return this.promise}}};sw.default=$n;$n.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"],HANDSHAKE_COMMANDS:["auth","select","client","readonly","info"],IGNORE_RECONNECT_ON_ERROR:["client"],BLOCKING_COMMANDS:["blpop","brpop","brpoplpush","blmove","bzpopmin","bzpopmax","bzmpop","blmpop","xread","xreadgroup"],LAST_ARG_TIMEOUT_COMMANDS:["blpop","brpop","brpoplpush","blmove","bzpopmin","bzpopmax"],FIRST_ARG_TIMEOUT_COMMANDS:["bzmpop","blmpop"],BLOCK_OPTION_COMMANDS:["xread","xreadgroup"]};$n._transformer={argument:{},reply:{}};var o$=function(t){if(t.length===1){if(t[0]instanceof Map)return(0,ts.convertMapToArray)(t[0]);if(typeof t[0]=="object"&&t[0]!==null)return(0,ts.convertObjectToArray)(t[0])}return t},s$=function(t){if(t.length===2){if(t[1]instanceof Map)return[t[0]].concat((0,ts.convertMapToArray)(t[1]));if(typeof t[1]=="object"&&t[1]!==null)return[t[0]].concat((0,ts.convertObjectToArray)(t[1]))}return t};$n.setArgumentTransformer("mset",o$);$n.setArgumentTransformer("msetnx",o$);$n.setArgumentTransformer("hset",s$);$n.setArgumentTransformer("hmset",s$);$n.setReplyTransformer("hgetall",function(t){if(Array.isArray(t)){let e={};for(let r=0;r<t.length;r+=2){let i=t[r],n=t[r+1];i in e?Object.defineProperty(e,i,{value:n,configurable:!0,enumerable:!0,writable:!0}):e[i]=n}return e}return t});var ow=class{constructor(){this.length=0,this.items=[]}push(e){this.length+=Buffer.byteLength(e),this.items.push(e)}toBuffer(){let e=Buffer.allocUnsafe(this.length),r=0;for(let i of this.items){let n=Buffer.byteLength(i);Buffer.isBuffer(i)?i.copy(e,r):e.write(i,r,n),r+=n}return e}}});var a$=h(aw=>{"use strict";Object.defineProperty(aw,"__esModule",{value:!0});var ase=es(),um=class extends ase.RedisError{constructor(e,r){super(e),this.lastNodeError=r,Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}};aw.default=um;um.defaultMessage="Failed to refresh slots cache."});var dm=h(cw=>{"use strict";Object.defineProperty(cw,"__esModule",{value:!0});var lse=U("stream"),lw=class extends lse.Readable{constructor(e){super(e),this.opt=e,this._redisCursor="0",this._redisDrained=!1}_read(){if(this._redisDrained){this.push(null);return}let e=[this._redisCursor];this.opt.key&&e.unshift(this.opt.key),this.opt.match&&e.push("MATCH",this.opt.match),this.opt.type&&e.push("TYPE",this.opt.type),this.opt.count&&e.push("COUNT",String(this.opt.count)),this.opt.noValues&&e.push("NOVALUES"),this.opt.redis[this.opt.command](e,(r,i)=>{if(r){this.emit("error",r);return}this._redisCursor=i[0]instanceof Buffer?i[0].toString():i[0],this._redisCursor==="0"&&(this._redisDrained=!0),this.push(i[1])})}close(){this._redisDrained=!0}};cw.default=lw});var m$=h(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.executeWithAutoPipelining=ut.getFirstValueInFlattenedArray=ut.shouldUseAutoPipelining=ut.notAllowedAutoPipelineCommands=ut.kCallbacks=ut.kExec=void 0;var u$=yf(),cse=su(),l$=Zi(),c$=Qo();ut.kExec=Symbol("exec");ut.kCallbacks=Symbol("callbacks");ut.notAllowedAutoPipelineCommands=["auth","info","script","quit","cluster","pipeline","multi","subscribe","psubscribe","unsubscribe","unpsubscribe","select","client"];function d$(t,e){if(t._runningAutoPipelines.has(e)||!t._autoPipelines.has(e))return;t._runningAutoPipelines.add(e);let r=t._autoPipelines.get(e);t._autoPipelines.delete(e);let i=r[ut.kCallbacks];r[ut.kCallbacks]=null,r.exec(function(n,o){if(t._runningAutoPipelines.delete(e),n)for(let s=0;s<i.length;s++)process.nextTick(i[s],n);else for(let s=0;s<i.length;s++)process.nextTick(i[s],...o[s]);t._autoPipelines.has(e)&&d$(t,e)})}function use(t,e,r){return e&&t.options.enableAutoPipelining&&!t.isPipeline&&!ut.notAllowedAutoPipelineCommands.includes(r)&&!t.options.autoPipeliningIgnoredCommands.includes(r)}ut.shouldUseAutoPipelining=use;function p$(t){for(let e=0;e<t.length;e++){let r=t[e];if(typeof r=="string")return r;if(Array.isArray(r)||(0,u$.isArguments)(r)){if(r.length===0)continue;return r[0]}let i=[r].flat();if(i.length>0)return i[0]}}ut.getFirstValueInFlattenedArray=p$;function f$(t,e,r,i,n){if(t.isCluster&&!t.slots.length)return t.status==="wait"&&t.connect().catch(u$.noop),(0,l$.default)(new Promise(function(c,u){t.delayUntilReady(d=>{if(d){u(d);return}f$(t,e,r,i,null).then(c,u)})}),n);let o=t.options.keyPrefix||"",s=t.isCluster?t.slots[cse(`${o}${p$(i)}`)].join(","):"main";if(t.isCluster&&t.options.scaleReads!=="master"){let c=(0,c$.exists)(r)&&(0,c$.hasFlag)(r,"readonly");s+=c?":read":":write"}if(!t._autoPipelines.has(s)){let c=t.pipeline();c[ut.kExec]=!1,c[ut.kCallbacks]=[],t._autoPipelines.set(s,c)}let a=t._autoPipelines.get(s);a[ut.kExec]||(a[ut.kExec]=!0,setImmediate(d$,t,s));let l=new Promise(function(c,u){a[ut.kCallbacks].push(function(d,f){if(d){u(d);return}c(f)}),e==="call"&&i.unshift(r),a[e](...i)});return(0,l$.default)(l,n)}ut.executeWithAutoPipelining=f$});var h$=h(dw=>{"use strict";Object.defineProperty(dw,"__esModule",{value:!0});var dse=U("crypto"),pse=pi(),fse=Zi(),uw=class{constructor(e,r=null,i="",n=!1){this.lua=e,this.numberOfKeys=r,this.keyPrefix=i,this.readOnly=n,this.sha=(0,dse.createHash)("sha1").update(e).digest("hex");let o=this.sha,s=new WeakSet;this.Command=class extends pse.default{toWritable(l){let c=this.reject;return this.reject=u=>{u.message.indexOf("NOSCRIPT")!==-1&&s.delete(l),c.call(this,u)},s.has(l)?this.name==="eval"&&(this.name="evalsha",this.args[0]=o):(s.add(l),this.name="eval",this.args[0]=e),super.toWritable(l)}}}execute(e,r,i,n){typeof this.numberOfKeys=="number"&&r.unshift(this.numberOfKeys),this.keyPrefix&&(i.keyPrefix=this.keyPrefix),this.readOnly&&(i.readOnly=!0);let o=new this.Command("evalsha",[this.sha,...r],i);return o.promise=o.promise.catch(s=>{if(s.message.indexOf("NOSCRIPT")===-1)throw s;let a=new this.Command("evalsha",[this.sha,...r],i);return(e.isPipeline?e.redis:e).sendCommand(a)}),(0,fse.default)(o.promise,n),e.sendCommand(o)}};dw.default=uw});var fm=h(fw=>{"use strict";Object.defineProperty(fw,"__esModule",{value:!0});var mse=Qo(),pm=m$(),hse=pi(),yse=h$(),fi=class{constructor(){this.options={},this.scriptsSet={},this.addedBuiltinSet=new Set}getBuiltinCommands(){return pw.slice(0)}createBuiltinCommand(e){return{string:Hi(null,e,"utf8"),buffer:Hi(null,e,null)}}addBuiltinCommand(e){this.addedBuiltinSet.add(e),this[e]=Hi(e,e,"utf8"),this[e+"Buffer"]=Hi(e+"Buffer",e,null)}defineCommand(e,r){let i=new yse.default(r.lua,r.numberOfKeys,this.options.keyPrefix,r.readOnly);this.scriptsSet[e]=i,this[e]=y$(e,e,i,"utf8"),this[e+"Buffer"]=y$(e+"Buffer",e,i,null)}sendCommand(e,r,i){throw new Error('"sendCommand" is not implemented')}},pw=mse.list.filter(t=>t!=="monitor");pw.push("sentinel");pw.forEach(function(t){fi.prototype[t]=Hi(t,t,"utf8"),fi.prototype[t+"Buffer"]=Hi(t+"Buffer",t,null)});fi.prototype.call=Hi("call","utf8");fi.prototype.callBuffer=Hi("callBuffer",null);fi.prototype.send_command=fi.prototype.call;function Hi(t,e,r){return typeof r>"u"&&(r=e,e=null),function(...i){let n=e||i.shift(),o=i[i.length-1];typeof o=="function"?i.pop():o=void 0;let s={errorStack:this.options.showFriendlyErrorStack?new Error:void 0,keyPrefix:this.options.keyPrefix,replyEncoding:r};return(0,pm.shouldUseAutoPipelining)(this,t,n)?(0,pm.executeWithAutoPipelining)(this,t,n,i,o):this.sendCommand(new hse.default(n,i,s,o))}}function y$(t,e,r,i){return function(...n){let o=typeof n[n.length-1]=="function"?n.pop():void 0,s={replyEncoding:i};return this.options.showFriendlyErrorStack&&(s.errorStack=new Error),(0,pm.shouldUseAutoPipelining)(this,t,e)?(0,pm.executeWithAutoPipelining)(this,t,e,n,o):r.execute(this,n,s,o)}}fw.default=fi});var yw=h(hw=>{"use strict";Object.defineProperty(hw,"__esModule",{value:!0});var mw=su(),g$=Qo(),b$=Zi(),gse=U("util"),bse=pi(),vse=bt(),Sse=fm();function Ese(t,e){let r=mw(e[0]),i=t._groupsBySlot[r];for(let n=1;n<e.length;n++)if(t._groupsBySlot[mw(e[n])]!==i)return-1;return r}var Yi=class extends Sse.default{constructor(e){super(),this.redis=e,this.isPipeline=!0,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(i=>{let n=e.scriptsSet[i];this._shaToScript[n.sha]=n,this[i]=e[i],this[i+"Buffer"]=e[i+"Buffer"]}),e.addedBuiltinSet.forEach(i=>{this[i]=e[i],this[i+"Buffer"]=e[i+"Buffer"]}),this.promise=new Promise((i,n)=>{this.resolve=i,this.reject=n});let r=this;Object.defineProperty(this,"length",{get:function(){return r._queue.length}})}fillResult(e,r){if(this._queue[r].name==="exec"&&Array.isArray(e[1])){let n=e[1].length;for(let o=0;o<n;o++){if(e[1][o]instanceof Error)continue;let s=this._queue[r-(n-o)];try{e[1][o]=s.transformReply(e[1][o])}catch(a){e[1][o]=a}}}if(this._result[r]=e,--this.replyPending)return;if(this.isCluster){let n=!0,o;for(let s=0;s<this._result.length;++s){let a=this._result[s][0],l=this._queue[s];if(a){if(l.name==="exec"&&a.message==="EXECABORT Transaction discarded because of previous errors.")continue;if(!o)o={name:a.name,message:a.message};else if(o.name!==a.name||o.message!==a.message){n=!1;break}}else if(!l.inTransaction&&!((0,g$.exists)(l.name,{caseInsensitive:!0})&&(0,g$.hasFlag)(l.name,"readonly",{nameCaseInsensitive:!0}))){n=!1;break}}if(o&&n){let s=this,a=o.message.split(" "),l=this._queue,c=!1;this._queue=[];for(let p=0;p<l.length;++p){if(a[0]==="ASK"&&!c&&l[p].name!=="asking"&&(!l[p-1]||l[p-1].name!=="asking")){let m=new bse.default("asking");m.ignore=!0,this.sendCommand(m)}l[p].initPromise(),this.sendCommand(l[p]),c=l[p].inTransaction}let u=!0;typeof this.leftRedirections>"u"&&(this.leftRedirections={});let d=function(){s.exec()},f=this.redis;if(f.handleError(o,this.leftRedirections,{moved:function(p,m){s.preferKey=m,f.slots[a[1]]?f.slots[a[1]][0]!==m&&(f.slots[a[1]]=[m]):f.slots[a[1]]=[m],f._groupsBySlot[a[1]]=f._groupsIds[f.slots[a[1]].join(";")],f.refreshSlotsCache(),s.exec()},ask:function(p,m){s.preferKey=m,s.exec()},tryagain:d,clusterDown:d,connectionClosed:d,maxRedirections:()=>{u=!1},defaults:()=>{u=!1}}),u)return}}let i=0;for(let n=0;n<this._queue.length-i;++n)this._queue[n+i].ignore&&(i+=1),this._result[n]=this._result[n+i];this.resolve(this._result.slice(0,this._result.length-i))}sendCommand(e){this._transactions>0&&(e.inTransaction=!0);let r=this._queue.length;return e.pipelineIndex=r,e.promise.then(i=>{this.fillResult([null,i],r)}).catch(i=>{this.fillResult([i],r)}),this._queue.push(e),this}addBatch(e){let r,i,n;for(let o=0;o<e.length;++o)r=e[o],i=r[0],n=r.slice(1),this[i].apply(this,n);return this}};hw.default=Yi;var wse=Yi.prototype.multi;Yi.prototype.multi=function(){return this._transactions+=1,wse.apply(this,arguments)};var v$=Yi.prototype.execBuffer;Yi.prototype.execBuffer=(0,gse.deprecate)(function(){return this._transactions>0&&(this._transactions-=1),v$.apply(this,arguments)},"Pipeline#execBuffer: Use Pipeline#exec instead");Yi.prototype.exec=function(t){if(this.isCluster&&!this.redis.slots.length)return this.redis.status==="wait"&&this.redis.connect().catch(vse.noop),t&&!this.nodeifiedPromise&&(this.nodeifiedPromise=!0,(0,b$.default)(this.promise,t)),this.redis.delayUntilReady(n=>{if(n){this.reject(n);return}this.exec(t)}),this.promise;if(this._transactions>0)return this._transactions-=1,v$.apply(this,arguments);this.nodeifiedPromise||(this.nodeifiedPromise=!0,(0,b$.default)(this.promise,t)),this._queue.length||this.resolve([]);let e;if(this.isCluster){let n=[];for(let o=0;o<this._queue.length;o++){let s=this._queue[o].getKeys();if(s.length&&n.push(s[0]),s.length&&mw.generateMulti(s)<0)return this.reject(new Error("All the keys in a pipeline command should belong to the same slot")),this.promise}if(n.length){if(e=Ese(this.redis,n),e<0)return this.reject(new Error("All keys in the pipeline should belong to the same slots allocation group")),this.promise}else e=Math.random()*16384|0}let r=this;return i(),this.promise;function i(){let n=r.replyPending=r._queue.length,o;r.isCluster&&(o={slot:e,redis:r.redis.connectionPool.nodes.all[r.preferKey]});let s="",a,l={isPipeline:!0,destination:r.isCluster?o:{redis:r.redis},write(c){typeof c!="string"?(a||(a=[]),s&&(a.push(Buffer.from(s,"utf8")),s=""),a.push(c)):s+=c,--n||(a?(s&&a.push(Buffer.from(s,"utf8")),l.destination.redis.stream.write(Buffer.concat(a))):l.destination.redis.stream.write(s),n=r._queue.length,s="",a=void 0)}};for(let c=0;c<r._queue.length;++c)r.redis.sendCommand(r._queue[c],l,o);return r.promise}}});var vw=h(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});mm.addTransactionSupport=void 0;var gw=bt(),bw=Zi(),S$=yw();function xse(t){t.pipeline=function(i){let n=new S$.default(this);return Array.isArray(i)&&n.addBatch(i),n};let{multi:e}=t;t.multi=function(i,n){if(typeof n>"u"&&!Array.isArray(i)&&(n=i,i=null),n&&n.pipeline===!1)return e.call(this);let o=new S$.default(this);o.multi(),Array.isArray(i)&&o.addBatch(i);let s=o.exec;o.exec=function(l){if(this.isCluster&&!this.redis.slots.length)return this.redis.status==="wait"&&this.redis.connect().catch(gw.noop),(0,bw.default)(new Promise((u,d)=>{this.redis.delayUntilReady(f=>{if(f){d(f);return}this.exec(o).then(u,d)})}),l);if(this._transactions>0&&s.call(o),this.nodeifiedPromise)return s.call(o);let c=s.call(o);return(0,bw.default)(c.then(function(u){let d=u[u.length-1];if(typeof d>"u")throw new Error("Pipeline cannot be used to send any commands when the `exec()` has been called on it.");if(d[0]){d[0].previousErrors=[];for(let f=0;f<u.length-1;++f)u[f][0]&&d[0].previousErrors.push(u[f][0]);throw d[0]}return(0,gw.wrapMultiResult)(d[1])}),l)};let{execBuffer:a}=o;return o.execBuffer=function(l){return this._transactions>0&&a.call(o),o.exec(l)},o};let{exec:r}=t;t.exec=function(i){return(0,bw.default)(r.call(this).then(function(n){return Array.isArray(n)&&(n=(0,gw.wrapMultiResult)(n)),n}),i)}}mm.addTransactionSupport=xse});var Ew=h(Sw=>{"use strict";Object.defineProperty(Sw,"__esModule",{value:!0});function Ise(t,e){Object.getOwnPropertyNames(e.prototype).forEach(r=>{Object.defineProperty(t.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r))})}Sw.default=Ise});var w$=h(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0});hm.DEFAULT_CLUSTER_OPTIONS=void 0;var E$=U("dns");hm.DEFAULT_CLUSTER_OPTIONS={clusterRetryStrategy:t=>Math.min(100+t*2,2e3),enableOfflineQueue:!0,enableReadyCheck:!0,scaleReads:"master",maxRedirections:16,retryDelayOnMoved:0,retryDelayOnFailover:100,retryDelayOnClusterDown:100,retryDelayOnTryAgain:100,slotsRefreshTimeout:1e3,useSRVRecords:!1,resolveSrv:E$.resolveSrv,dnsLookup:E$.lookup,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],shardedSubscribers:!1}});var $a=h(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.getConnectionName=Xt.weightSrvRecords=Xt.groupSrvRecords=Xt.getUniqueHostnamesFromOptions=Xt.normalizeNodeOptions=Xt.nodeKeyToRedisOptions=Xt.getNodeKey=void 0;var x$=bt(),kse=U("net");function _se(t){return t.port=t.port||6379,t.host=t.host||"127.0.0.1",t.host+":"+t.port}Xt.getNodeKey=_se;function Tse(t){let e=t.lastIndexOf(":");if(e===-1)throw new Error(`Invalid node key ${t}`);return{host:t.slice(0,e),port:Number(t.slice(e+1))}}Xt.nodeKeyToRedisOptions=Tse;function Cse(t){return t.map(e=>{let r={};if(typeof e=="object")Object.assign(r,e);else if(typeof e=="string")Object.assign(r,(0,x$.parseURL)(e));else if(typeof e=="number")r.port=e;else throw new Error("Invalid argument "+e);return typeof r.port=="string"&&(r.port=parseInt(r.port,10)),delete r.db,r.port||(r.port=6379),r.host||(r.host="127.0.0.1"),(0,x$.resolveTLSProfile)(r)})}Xt.normalizeNodeOptions=Cse;function Ose(t){let e={};return t.forEach(r=>{e[r.host]=!0}),Object.keys(e).filter(r=>!(0,kse.isIP)(r))}Xt.getUniqueHostnamesFromOptions=Ose;function Ase(t){let e={};for(let r of t)e.hasOwnProperty(r.priority)?(e[r.priority].totalWeight+=r.weight,e[r.priority].records.push(r)):e[r.priority]={totalWeight:r.weight,records:[r]};return e}Xt.groupSrvRecords=Ase;function Kse(t){if(t.records.length===1)return t.totalWeight=0,t.records.shift();let e=Math.floor(Math.random()*(t.totalWeight+t.records.length)),r=0;for(let[i,n]of t.records.entries())if(r+=1+n.weight,r>e)return t.totalWeight-=n.weight,t.records.splice(i,1),n}Xt.weightSrvRecords=Kse;function Rse(t,e){let r=`ioredis-cluster(${t})`;return e?`${r}:${e}`:r}Xt.getConnectionName=Rse});var k$=h(Iw=>{"use strict";Object.defineProperty(Iw,"__esModule",{value:!0});var I$=$a(),ww=bt(),Dse=mi(),Jn=(0,ww.Debug)("cluster:subscriber"),xw=class{constructor(e,r,i=!1){this.connectionPool=e,this.emitter=r,this.isSharded=i,this.started=!1,this.subscriber=null,this.slotRange=[],this.onSubscriberEnd=()=>{if(!this.started){Jn("subscriber has disconnected, but ClusterSubscriber is not started, so not reconnecting.");return}Jn("subscriber has disconnected, selecting a new one..."),this.selectSubscriber()},this.connectionPool.on("-node",(n,o)=>{!this.started||!this.subscriber||(0,I$.getNodeKey)(this.subscriber.options)===o&&(Jn("subscriber has left, selecting a new one..."),this.selectSubscriber())}),this.connectionPool.on("+node",()=>{!this.started||this.subscriber||(Jn("a new node is discovered and there is no subscriber, selecting a new one..."),this.selectSubscriber())})}getInstance(){return this.subscriber}associateSlotRange(e){return this.isSharded&&(this.slotRange=e),this.slotRange}start(){this.started=!0,this.selectSubscriber(),Jn("started")}stop(){this.started=!1,this.subscriber&&(this.subscriber.disconnect(),this.subscriber=null)}isStarted(){return this.started}selectSubscriber(){let e=this.lastActiveSubscriber;e&&(e.off("end",this.onSubscriberEnd),e.disconnect()),this.subscriber&&(this.subscriber.off("end",this.onSubscriberEnd),this.subscriber.disconnect());let r=(0,ww.sample)(this.connectionPool.getNodes());if(!r){Jn("selecting subscriber failed since there is no node discovered in the cluster yet"),this.subscriber=null;return}let{options:i}=r;Jn("selected a subscriber %s:%s",i.host,i.port);let n="subscriber";this.isSharded&&(n="ssubscriber"),this.subscriber=new Dse.default({port:i.port,host:i.host,username:i.username,password:i.password,enableReadyCheck:!0,connectionName:(0,I$.getConnectionName)(n,i.connectionName),lazyConnect:!0,tls:i.tls,retryStrategy:null}),this.subscriber.on("error",ww.noop),this.subscriber.on("moved",()=>{this.emitter.emit("forceRefresh")}),this.subscriber.once("end",this.onSubscriberEnd);let o={subscribe:[],psubscribe:[],ssubscribe:[]};if(e){let s=e.condition||e.prevCondition;s&&s.subscriber&&(o.subscribe=s.subscriber.channels("subscribe"),o.psubscribe=s.subscriber.channels("psubscribe"),o.ssubscribe=s.subscriber.channels("ssubscribe"))}if(o.subscribe.length||o.psubscribe.length||o.ssubscribe.length){let s=0;for(let a of["subscribe","psubscribe","ssubscribe"]){let l=o[a];if(l.length!=0)if(Jn("%s %d channels",a,l.length),a==="ssubscribe")for(let c of l)s+=1,this.subscriber[a](c).then(()=>{--s||(this.lastActiveSubscriber=this.subscriber)}).catch(()=>{Jn("failed to ssubscribe to channel: %s",c)});else s+=1,this.subscriber[a](l).then(()=>{--s||(this.lastActiveSubscriber=this.subscriber)}).catch(()=>{Jn("failed to %s %d channels",a,l.length)})}}else this.lastActiveSubscriber=this.subscriber;for(let s of["message","messageBuffer"])this.subscriber.on(s,(a,l)=>{this.emitter.emit(s,a,l)});for(let s of["pmessage","pmessageBuffer"])this.subscriber.on(s,(a,l,c)=>{this.emitter.emit(s,a,l,c)});if(this.isSharded==!0)for(let s of["smessage","smessageBuffer"])this.subscriber.on(s,(a,l)=>{this.emitter.emit(s,a,l)})}};Iw.default=xw});var _$=h(Tw=>{"use strict";Object.defineProperty(Tw,"__esModule",{value:!0});var jse=U("events"),ym=bt(),kw=$a(),Pse=mi(),au=(0,ym.Debug)("cluster:connectionPool"),_w=class extends jse.EventEmitter{constructor(e){super(),this.redisOptions=e,this.nodes={all:{},master:{},slave:{}},this.specifiedOptions={}}getNodes(e="all"){let r=this.nodes[e];return Object.keys(r).map(i=>r[i])}getInstanceByKey(e){return this.nodes.all[e]}getSampleInstance(e){let r=Object.keys(this.nodes[e]),i=(0,ym.sample)(r);return this.nodes[e][i]}addMasterNode(e){let r=(0,kw.getNodeKey)(e.options),i=this.createRedisFromOptions(e,e.options.readOnly);return e.options.readOnly?!1:(this.nodes.all[r]=i,this.nodes.master[r]=i,!0)}createRedisFromOptions(e,r){return new Pse.default((0,ym.defaults)({retryStrategy:null,enableOfflineQueue:!0,readOnly:r},e,this.redisOptions,{lazyConnect:!0}))}findOrCreate(e,r=!1){let i=(0,kw.getNodeKey)(e);r=!!r,this.specifiedOptions[i]?Object.assign(e,this.specifiedOptions[i]):this.specifiedOptions[i]=e;let n;return this.nodes.all[i]?(n=this.nodes.all[i],n.options.readOnly!==r&&(n.options.readOnly=r,au("Change role of %s to %s",i,r?"slave":"master"),n[r?"readonly":"readwrite"]().catch(ym.noop),r?(delete this.nodes.master[i],this.nodes.slave[i]=n):(delete this.nodes.slave[i],this.nodes.master[i]=n))):(au("Connecting to %s as %s",i,r?"slave":"master"),n=this.createRedisFromOptions(e,r),this.nodes.all[i]=n,this.nodes[r?"slave":"master"][i]=n,n.once("end",()=>{this.removeNode(i),this.emit("-node",n,i),Object.keys(this.nodes.all).length||this.emit("drain")}),this.emit("+node",n,i),n.on("error",function(o){this.emit("nodeError",o,i)})),n}reset(e){au("Reset with %O",e);let r={};e.forEach(i=>{let n=(0,kw.getNodeKey)(i);i.readOnly&&r[n]||(r[n]=i)}),Object.keys(this.nodes.all).forEach(i=>{r[i]||(au("Disconnect %s because the node does not hold any slot",i),this.nodes.all[i].disconnect(),this.removeNode(i))}),Object.keys(r).forEach(i=>{let n=r[i];this.findOrCreate(n,n.readOnly)})}removeNode(e){let{nodes:r}=this;r.all[e]&&(au("Remove %s from the pool",e),delete r.all[e]),delete r.master[e],delete r.slave[e]}};Tw.default=_w});var gm=h((s_e,T$)=>{"use strict";function at(t,r){var r=r||{};this._capacity=r.capacity,this._head=0,this._tail=0,Array.isArray(t)?this._fromArray(t):(this._capacityMask=3,this._list=new Array(4))}at.prototype.peekAt=function(e){var r=e;if(r===(r|0)){var i=this.size();if(!(r>=i||r<-i))return r<0&&(r+=i),r=this._head+r&this._capacityMask,this._list[r]}};at.prototype.get=function(e){return this.peekAt(e)};at.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]};at.prototype.peekFront=function(){return this.peek()};at.prototype.peekBack=function(){return this.peekAt(-1)};Object.defineProperty(at.prototype,"length",{get:function(){return this.size()}});at.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)};at.prototype.unshift=function(e){if(arguments.length===0)return this.size();var r=this._list.length;return this._head=this._head-1+r&this._capacityMask,this._list[this._head]=e,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)};at.prototype.shift=function(){var e=this._head;if(e!==this._tail){var r=this._list[e];return this._list[e]=void 0,this._head=e+1&this._capacityMask,e<2&&this._tail>1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),r}};at.prototype.push=function(e){if(arguments.length===0)return this.size();var r=this._tail;return this._list[r]=e,this._tail=r+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)};at.prototype.pop=function(){var e=this._tail;if(e!==this._head){var r=this._list.length;this._tail=e-1+r&this._capacityMask;var i=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&e>1e4&&e<=r>>>2&&this._shrinkArray(),i}};at.prototype.removeOne=function(e){var r=e;if(r===(r|0)&&this._head!==this._tail){var i=this.size(),n=this._list.length;if(!(r>=i||r<-i)){r<0&&(r+=i),r=this._head+r&this._capacityMask;var o=this._list[r],s;if(e<i/2){for(s=e;s>0;s--)this._list[r]=this._list[r=r-1+n&this._capacityMask];this._list[r]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(s=i-1-e;s>0;s--)this._list[r]=this._list[r=r+1+n&this._capacityMask];this._list[r]=void 0,this._tail=this._tail-1+n&this._capacityMask}return o}}};at.prototype.remove=function(e,r){var i=e,n,o=r;if(i===(i|0)&&this._head!==this._tail){var s=this.size(),a=this._list.length;if(!(i>=s||i<-s||r<1)){if(i<0&&(i+=s),r===1||!r)return n=new Array(1),n[0]=this.removeOne(i),n;if(i===0&&i+r>=s)return n=this.toArray(),this.clear(),n;i+r>s&&(r=s-i);var l;for(n=new Array(r),l=0;l<r;l++)n[l]=this._list[this._head+i+l&this._capacityMask];if(i=this._head+i&this._capacityMask,e+r===s){for(this._tail=this._tail-r+a&this._capacityMask,l=r;l>0;l--)this._list[i=i+1+a&this._capacityMask]=void 0;return n}if(e===0){for(this._head=this._head+r+a&this._capacityMask,l=r-1;l>0;l--)this._list[i=i+1+a&this._capacityMask]=void 0;return n}if(i<s/2){for(this._head=this._head+e+r+a&this._capacityMask,l=e;l>0;l--)this.unshift(this._list[i=i-1+a&this._capacityMask]);for(i=this._head-1+a&this._capacityMask;o>0;)this._list[i=i-1+a&this._capacityMask]=void 0,o--;e<0&&(this._tail=i)}else{for(this._tail=i,i=i+r+a&this._capacityMask,l=s-(r+e);l>0;l--)this.push(this._list[i++]);for(i=this._tail;o>0;)this._list[i=i+1+a&this._capacityMask]=void 0,o--}return this._head<2&&this._tail>1e4&&this._tail<=a>>>2&&this._shrinkArray(),n}}};at.prototype.splice=function(e,r){var i=e;if(i===(i|0)){var n=this.size();if(i<0&&(i+=n),!(i>n))if(arguments.length>2){var o,s,a,l=arguments.length,c=this._list.length,u=2;if(!n||i<n/2){for(s=new Array(i),o=0;o<i;o++)s[o]=this._list[this._head+o&this._capacityMask];for(r===0?(a=[],i>0&&(this._head=this._head+i+c&this._capacityMask)):(a=this.remove(i,r),this._head=this._head+i+c&this._capacityMask);l>u;)this.unshift(arguments[--l]);for(o=i;o>0;o--)this.unshift(s[o-1])}else{s=new Array(n-(i+r));var d=s.length;for(o=0;o<d;o++)s[o]=this._list[this._head+i+r+o&this._capacityMask];for(r===0?(a=[],i!=n&&(this._tail=this._head+i+c&this._capacityMask)):(a=this.remove(i,r),this._tail=this._tail-d+c&this._capacityMask);u<l;)this.push(arguments[u++]);for(o=0;o<d;o++)this.push(s[o])}return a}else return this.remove(i,r)}};at.prototype.clear=function(){this._list=new Array(this._list.length),this._head=0,this._tail=0};at.prototype.isEmpty=function(){return this._head===this._tail};at.prototype.toArray=function(){return this._copyArray(!1)};at.prototype._fromArray=function(e){var r=e.length,i=this._nextPowerOf2(r);this._list=new Array(i),this._capacityMask=i-1,this._tail=r;for(var n=0;n<r;n++)this._list[n]=e[n]};at.prototype._copyArray=function(e,r){var i=this._list,n=i.length,o=this.length;if(r=r|o,r==o&&this._head<this._tail)return this._list.slice(this._head,this._tail);var s=new Array(r),a=0,l;if(e||this._head>this._tail){for(l=this._head;l<n;l++)s[a++]=i[l];for(l=0;l<this._tail;l++)s[a++]=i[l]}else for(l=this._head;l<this._tail;l++)s[a++]=i[l];return s};at.prototype._growArray=function(){if(this._head!=0){var e=this._copyArray(!0,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};at.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1};at.prototype._nextPowerOf2=function(e){var r=Math.log(e)/Math.log(2),i=1<<r+1;return Math.max(i,4)};T$.exports=at});var C$=h(Ow=>{"use strict";Object.defineProperty(Ow,"__esModule",{value:!0});var Mse=bt(),Nse=gm(),Lse=(0,Mse.Debug)("delayqueue"),Cw=class{constructor(){this.queues={},this.timeouts={}}push(e,r,i){let n=i.callback||process.nextTick;this.queues[e]||(this.queues[e]=new Nse),this.queues[e].push(r),this.timeouts[e]||(this.timeouts[e]=setTimeout(()=>{n(()=>{this.timeouts[e]=null,this.execute(e)})},i.timeout))}execute(e){let r=this.queues[e];if(!r)return;let{length:i}=r;if(i)for(Lse("send %d commands in %s queue",i,e),this.queues[e]=null;r.length>0;)r.shift()()}};Ow.default=Cw});var R$=h(Kw=>{"use strict";Object.defineProperty(Kw,"__esModule",{value:!0});var O$=$a(),K$=bt(),Use=mi(),A$=(0,K$.Debug)("cluster:subscriberGroup:shardedSubscriber"),Ne={IDLE:"idle",STARTING:"starting",CONNECTED:"connected",STOPPING:"stopping",ENDED:"ended"},$se={[Ne.IDLE]:[Ne.STARTING,Ne.STOPPING,Ne.ENDED],[Ne.STARTING]:[Ne.CONNECTED,Ne.STOPPING,Ne.ENDED],[Ne.CONNECTED]:[Ne.STOPPING,Ne.ENDED],[Ne.STOPPING]:[Ne.ENDED],[Ne.ENDED]:[]},Aw=class{constructor(e,r,i){var n;this.emitter=e,this.status=Ne.IDLE,this.instance=null,this.connectPromise=null,this.messageListeners=new Map,this.onEnd=()=>{this.updateStatus(Ne.ENDED),this.emitter.emit("-node",this.instance,this.nodeKey)},this.onError=o=>{this.emitter.emit("nodeError",o,this.nodeKey)},this.onMoved=()=>{this.emitter.emit("moved")},this.instance=new Use.default((0,K$.defaults)({enableReadyCheck:!1,enableOfflineQueue:!0,connectionName:(0,O$.getConnectionName)("ssubscriber",r.connectionName),retryStrategy:null,lazyConnect:!0},r,i)),this.lazyConnect=(n=i?.lazyConnect)!==null&&n!==void 0?n:!0,this.nodeKey=(0,O$.getNodeKey)(r),this.instance.on("end",this.onEnd),this.instance.on("error",this.onError),this.instance.on("moved",this.onMoved);for(let o of["smessage","smessageBuffer"]){let s=(...a)=>{this.emitter.emit(o,...a)};this.messageListeners.set(o,s),this.instance.on(o,s)}}async start(){if(this.connectPromise)return this.connectPromise;if(!(this.status===Ne.STARTING||this.status===Ne.CONNECTED)){if(this.status===Ne.ENDED||!this.instance)throw new Error(`Sharded subscriber ${this.nodeKey} cannot be restarted once ended.`);this.updateStatus(Ne.STARTING),this.connectPromise=this.instance.connect();try{await this.connectPromise,this.updateStatus(Ne.CONNECTED)}catch(e){throw this.updateStatus(Ne.ENDED),e}finally{this.connectPromise=null}}}stop(){this.updateStatus(Ne.STOPPING),this.instance&&(this.instance.disconnect(),this.instance.removeAllListeners(),this.messageListeners.clear(),this.instance=null),this.updateStatus(Ne.ENDED),A$("stopped %s",this.nodeKey)}isStarted(){return[Ne.CONNECTED,Ne.STARTING].includes(this.status)}get subscriberStatus(){return this.status}isHealthy(){return(this.status===Ne.IDLE||this.status===Ne.CONNECTED||this.status===Ne.STARTING)&&this.instance!==null}getInstance(){return this.instance}getNodeKey(){return this.nodeKey}isLazyConnect(){return this.lazyConnect}updateStatus(e){if(this.status!==e){if(!$se[this.status].includes(e)){A$("Invalid status transition for %s: %s -> %s",this.nodeKey,this.status,e);return}this.status=e}}};Kw.default=Aw});var D$=h(Rw=>{"use strict";Object.defineProperty(Rw,"__esModule",{value:!0});var Jse=bt(),Fse=$a(),bm=su(),qse=R$(),rn=(0,Jse.Debug)("cluster:subscriberGroup"),Ja=class t{constructor(e,r){this.subscriberGroupEmitter=e,this.options=r,this.shardedSubscribers=new Map,this.clusterSlots=[],this.subscriberToSlotsIndex=new Map,this.channels=new Map,this.failedAttemptsByNode=new Map,this.isResetting=!1,this.pendingReset=null,this.handleSubscriberConnectFailed=(i,n)=>{let s=(this.failedAttemptsByNode.get(n)||0)+1;this.failedAttemptsByNode.set(n,s);let a=Math.min(s,t.MAX_RETRY_ATTEMPTS),l=Math.min(t.BASE_BACKOFF_MS*2**a,t.MAX_BACKOFF_MS),c=Math.floor((Math.random()-.5)*(l*.5)),u=Math.max(0,l+c);rn("Failed to connect subscriber for %s. Refreshing slots in %dms",n,u),this.subscriberGroupEmitter.emit("subscriberConnectFailed",{delay:u,error:i})},this.handleSubscriberConnectSucceeded=i=>{this.failedAttemptsByNode.delete(i)}}getResponsibleSubscriber(e){let r=this.clusterSlots[e][0],i=this.shardedSubscribers.get(r);return i&&i.subscriberStatus==="idle"&&i.start().then(()=>{this.handleSubscriberConnectSucceeded(i.getNodeKey())}).catch(n=>{this.handleSubscriberConnectFailed(n,i.getNodeKey())}),i}addChannels(e){let r=bm(e[0]);for(let n of e)if(bm(n)!==r)return-1;let i=this.channels.get(r);return i?this.channels.set(r,i.concat(e)):this.channels.set(r,e),Array.from(this.channels.values()).reduce((n,o)=>n+o.length,0)}removeChannels(e){let r=bm(e[0]);for(let n of e)if(bm(n)!==r)return-1;let i=this.channels.get(r);if(i){let n=i.filter(o=>!e.includes(o));this.channels.set(r,n)}return Array.from(this.channels.values()).reduce((n,o)=>n+o.length,0)}stop(){for(let e of this.shardedSubscribers.values())e.stop();this.pendingReset=null,this.shardedSubscribers.clear(),this.subscriberToSlotsIndex.clear()}start(){let e=[];for(let r of this.shardedSubscribers.values())this.shouldStartSubscriber(r)&&(e.push(r.start().then(()=>{this.handleSubscriberConnectSucceeded(r.getNodeKey())}).catch(i=>{this.handleSubscriberConnectFailed(i,r.getNodeKey())})),this.subscriberGroupEmitter.emit("+subscriber"));return Promise.all(e)}async reset(e,r){if(this.isResetting){this.pendingReset={slots:e,nodes:r};return}this.isResetting=!0;try{let i=this._refreshSlots(e),n=this.hasUnhealthySubscribers();if(!i&&!n){rn("No topology change detected or failed subscribers. Skipping reset.");return}for(let[s,a]of this.shardedSubscribers){if(this.subscriberToSlotsIndex.has(s)&&a.isHealthy()){rn("Skipping deleting subscriber for %s",s);continue}rn("Removing subscriber for %s",s),a.stop(),this.shardedSubscribers.delete(s),this.subscriberGroupEmitter.emit("-subscriber")}let o=[];for(let[s,a]of this.subscriberToSlotsIndex){let l=this.shardedSubscribers.get(s);if(l&&l.isHealthy()){rn("Skipping creating new subscriber for %s",s),!l.isStarted()&&this.shouldStartSubscriber(l)&&o.push(l.start().then(()=>{this.handleSubscriberConnectSucceeded(s)}).catch(d=>{this.handleSubscriberConnectFailed(d,s)}));continue}l&&!l.isHealthy()&&(rn("Replacing subscriber for %s",s),l.stop(),this.shardedSubscribers.delete(s),this.subscriberGroupEmitter.emit("-subscriber")),rn("Creating new subscriber for %s",s);let c=r.find(d=>(0,Fse.getNodeKey)(d.options)===s);if(!c){rn("Failed to find node for key %s",s);continue}let u=new qse.default(this.subscriberGroupEmitter,c.options,this.options.redisOptions);this.shardedSubscribers.set(s,u),this.shouldStartSubscriber(u)&&o.push(u.start().then(()=>{this.handleSubscriberConnectSucceeded(s)}).catch(d=>{this.handleSubscriberConnectFailed(d,s)})),this.subscriberGroupEmitter.emit("+subscriber")}await Promise.all(o),this._resubscribe(),this.subscriberGroupEmitter.emit("subscribersReady")}finally{if(this.isResetting=!1,this.pendingReset){let{slots:i,nodes:n}=this.pendingReset;this.pendingReset=null,await this.reset(i,n)}}}_refreshSlots(e){if(this._slotsAreEqual(e)&&this.subscriberToSlotsIndex.size>0)return rn("Nothing to refresh because the new cluster map is equal to the previous one."),!1;rn("Refreshing the slots of the subscriber group."),this.subscriberToSlotsIndex=new Map;for(let r=0;r<e.length;r++){let i=e[r][0];this.subscriberToSlotsIndex.has(i)||this.subscriberToSlotsIndex.set(i,[]),this.subscriberToSlotsIndex.get(i).push(Number(r))}return this.clusterSlots=JSON.parse(JSON.stringify(e)),!0}_resubscribe(){this.shardedSubscribers&&this.shardedSubscribers.forEach((e,r)=>{let i=this.subscriberToSlotsIndex.get(r);i&&i.forEach(n=>{let o=e.getInstance(),s=this.channels.get(n);if(s&&s.length>0){if(!o||o.status==="end")return;o.status==="ready"?o.ssubscribe(...s).catch(a=>{rn("Failed to ssubscribe on node %s: %s",r,a)}):o.once("ready",()=>{o.ssubscribe(...s).catch(a=>{rn("Failed to ssubscribe on node %s: %s",r,a)})})}})})}_slotsAreEqual(e){return this.clusterSlots===void 0?!1:JSON.stringify(this.clusterSlots)===JSON.stringify(e)}hasUnhealthySubscribers(){let e=Array.from(this.shardedSubscribers.values()).some(i=>!i.isHealthy()),r=Array.from(this.subscriberToSlotsIndex.keys()).some(i=>!this.shardedSubscribers.has(i));return e||r}shouldStartSubscriber(e){if(e.isStarted())return!1;if(!e.isLazyConnect())return!0;let r=this.subscriberToSlotsIndex.get(e.getNodeKey());return r?r.some(i=>{let n=this.channels.get(i);return!!(n&&n.length>0)}):!1}};Rw.default=Ja;Ja.MAX_RETRY_ATTEMPTS=10;Ja.MAX_BACKOFF_MS=2e3;Ja.BASE_BACKOFF_MS=100});var Pw=h(jw=>{"use strict";Object.defineProperty(jw,"__esModule",{value:!0});var j$=Qo(),Dw=U("events"),Fa=es(),P$=Zi(),M$=pi(),vm=a$(),zse=mi(),Gse=dm(),Vse=vw(),Dr=bt(),Bse=Ew(),Wse=fm(),Zse=w$(),Hse=k$(),Yse=_$(),Xse=C$(),qa=$a(),N$=gm(),Qse=D$(),Be=(0,Dr.Debug)("cluster"),L$=new WeakSet,lu=class t extends Wse.default{constructor(e,r={}){if(super(),this.slots=[],this._groupsIds={},this._groupsBySlot=Array(16384),this.isCluster=!0,this.retryAttempts=0,this.delayQueue=new Xse.default,this.offlineQueue=new N$,this.isRefreshing=!1,this._refreshSlotsCacheCallbacks=[],this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this._readyDelayedCallbacks=[],this.connectionEpoch=0,Dw.EventEmitter.call(this),this.startupNodes=e,this.options=(0,Dr.defaults)({},r,Zse.DEFAULT_CLUSTER_OPTIONS,this.options),this.options.shardedSubscribers&&this.createShardedSubscriberGroup(),this.options.redisOptions&&this.options.redisOptions.keyPrefix&&!this.options.keyPrefix&&(this.options.keyPrefix=this.options.redisOptions.keyPrefix),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 Yse.default(this.options.redisOptions),this.connectionPool.on("-node",(i,n)=>{this.emit("-node",i)}),this.connectionPool.on("+node",i=>{this.emit("+node",i)}),this.connectionPool.on("drain",()=>{this.setStatus("close")}),this.connectionPool.on("nodeError",(i,n)=>{this.emit("node error",i,n)}),this.subscriber=new Hse.default(this.connectionPool,this),this.options.scripts&&Object.entries(this.options.scripts).forEach(([i,n])=>{this.defineCommand(i,n)}),this.options.lazyConnect?this.setStatus("wait"):this.connect().catch(i=>{Be("connecting failed: %s",i)})}connect(){return new Promise((e,r)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){r(new Error("Redis is already connecting/connected"));return}let i=++this.connectionEpoch;this.setStatus("connecting"),this.resolveStartupNodeHostnames().then(n=>{if(this.connectionEpoch!==i){Be("discard connecting after resolving startup nodes because epoch not match: %d != %d",i,this.connectionEpoch),r(new Fa.RedisError("Connection is discarded because a new connection is made"));return}if(this.status!=="connecting"){Be("discard connecting after resolving startup nodes because the status changed to %s",this.status),r(new Fa.RedisError("Connection is aborted"));return}this.connectionPool.reset(n),this.options.shardedSubscribers&&this.shardedSubscribers.reset(this.slots,this.connectionPool.getNodes("all")).catch(l=>{Be("Error while starting subscribers: %s",l)});let o=()=>{this.setStatus("ready"),this.retryAttempts=0,this.executeOfflineCommands(),this.resetNodesRefreshInterval(),e()},s,a=()=>{this.invokeReadyDelayedCallbacks(void 0),this.removeListener("close",s),this.manuallyClosing=!1,this.setStatus("connect"),this.options.enableReadyCheck?this.readyCheck((l,c)=>{l||c?(Be("Ready check failed (%s). Reconnecting...",l||c),this.status==="connect"&&this.disconnect(!0)):o()}):o()};s=()=>{let l=new Error("None of startup nodes is available");this.removeListener("refresh",a),this.invokeReadyDelayedCallbacks(l),r(l)},this.once("refresh",a),this.once("close",s),this.once("close",this.handleCloseEvent.bind(this)),this.refreshSlotsCache(l=>{l&&l.message===vm.default.defaultMessage&&(zse.default.prototype.silentEmit.call(this,"error",l),this.connectionPool.reset([]))}),this.subscriber.start(),this.options.shardedSubscribers&&this.shardedSubscribers.start().catch(l=>{Be("Error while starting subscribers: %s",l)})}).catch(n=>{this.setStatus("close"),this.handleCloseEvent(n),this.invokeReadyDelayedCallbacks(n),r(n)})})}disconnect(e=!1){let r=this.status;this.setStatus("disconnecting"),e||(this.manuallyClosing=!0),this.reconnectTimeout&&!e&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null,Be("Canceled reconnecting attempts")),this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers&&this.shardedSubscribers.stop(),r==="wait"?(this.setStatus("close"),this.handleCloseEvent()):this.connectionPool.reset([])}quit(e){let r=this.status;if(this.setStatus("disconnecting"),this.manuallyClosing=!0,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers&&this.shardedSubscribers.stop(),r==="wait"){let i=(0,P$.default)(Promise.resolve("OK"),e);return setImmediate(function(){this.setStatus("close"),this.handleCloseEvent()}.bind(this)),i}return(0,P$.default)(Promise.all(this.nodes().map(i=>i.quit().catch(n=>{if(n.message===Dr.CONNECTION_CLOSED_ERROR_MSG)return"OK";throw n}))).then(()=>"OK"),e)}duplicate(e=[],r={}){let i=e.length>0?e:this.startupNodes.slice(0),n=Object.assign({},this.options,r);return new t(i,n)}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(let r of this._autoPipelines.values())e+=r.length;return e}refreshSlotsCache(e){if(e&&this._refreshSlotsCacheCallbacks.push(e),this.isRefreshing)return;this.isRefreshing=!0;let r=this,i=a=>{this.isRefreshing=!1;for(let l of this._refreshSlotsCacheCallbacks)l(a);this._refreshSlotsCacheCallbacks=[]},n=(0,Dr.shuffle)(this.connectionPool.getNodes()),o=null;function s(a){if(a===n.length){let u=new vm.default(vm.default.defaultMessage,o);return i(u)}let l=n[a],c=`${l.options.host}:${l.options.port}`;Be("getting slot cache from %s",c),r.getInfoFromNode(l,function(u){switch(r.status){case"close":case"end":return i(new Error("Cluster is disconnected."));case"disconnecting":return i(new Error("Cluster is disconnecting."))}u?(r.emit("node error",u,c),o=u,s(a+1)):(r.emit("refresh"),i())})}s(0)}sendCommand(e,r,i){if(this.status==="wait"&&this.connect().catch(Dr.noop),this.status==="end")return e.reject(new Error(Dr.CONNECTION_CLOSED_ERROR_MSG)),e.promise;let n=this.options.scaleReads;n!=="master"&&(e.isReadOnly||(0,j$.exists)(e.name)&&(0,j$.hasFlag)(e.name,"readonly")||(n="master"));let o=i?i.slot:e.getSlot(),s={},a=this;if(!i&&!L$.has(e)){L$.add(e);let c=e.reject;e.reject=function(u){let d=l.bind(null,!0);a.handleError(u,s,{moved:function(f,p){Be("command %s is moved to %s",e.name,p),o=Number(f),a.slots[f]?a.slots[f][0]=p:a.slots[f]=[p],a._groupsBySlot[f]=a._groupsIds[a.slots[f].join(";")],a.connectionPool.findOrCreate(a.natMapper(p)),l(),Be("refreshing slot caches... (triggered by MOVED error)"),a.refreshSlotsCache()},ask:function(f,p){Be("command %s is required to ask %s:%s",e.name,p);let m=a.natMapper(p);a.connectionPool.findOrCreate(m),l(!1,`${m.host}:${m.port}`)},tryagain:d,clusterDown:d,connectionClosed:d,maxRedirections:function(f){c.call(e,f)},defaults:function(){c.call(e,u)}})}}l();function l(c,u){if(a.status==="end"){e.reject(new Fa.AbortError("Cluster is ended."));return}let d;if(a.status==="ready"||e.name==="cluster"){if(i&&i.redis)d=i.redis;else if(M$.default.checkFlag("ENTER_SUBSCRIBER_MODE",e.name)||M$.default.checkFlag("EXIT_SUBSCRIBER_MODE",e.name)){if(a.options.shardedSubscribers&&(e.name=="ssubscribe"||e.name=="sunsubscribe")){let f=a.shardedSubscribers.getResponsibleSubscriber(o);if(!f){e.reject(new Fa.AbortError(`No sharded subscriber for slot: ${o}`));return}let p=-1;e.name=="ssubscribe"&&(p=a.shardedSubscribers.addChannels(e.getKeys())),e.name=="sunsubscribe"&&(p=a.shardedSubscribers.removeChannels(e.getKeys())),p!==-1?d=f.getInstance():e.reject(new Fa.AbortError("Possible CROSSSLOT error: All channels must hash to the same slot"))}else d=a.subscriber.getInstance();if(!d){e.reject(new Fa.AbortError("No subscriber for the cluster"));return}}else{if(!c){if(typeof o=="number"&&a.slots[o]){let f=a.slots[o];if(typeof n=="function"){let p=f.map(function(m){return a.connectionPool.getInstanceByKey(m)});d=n(p,e),Array.isArray(d)&&(d=(0,Dr.sample)(d)),d||(d=p[0])}else{let p;n==="all"?p=(0,Dr.sample)(f):n==="slave"&&f.length>1?p=(0,Dr.sample)(f,1):p=f[0],d=a.connectionPool.getInstanceByKey(p)}}u&&(d=a.connectionPool.getInstanceByKey(u),d.asking())}d||(d=(typeof n=="function"?null:a.connectionPool.getSampleInstance(n))||a.connectionPool.getSampleInstance("all"))}i&&!i.redis&&(i.redis=d)}d?d.sendCommand(e,r):a.options.enableOfflineQueue?a.offlineQueue.push({command:e,stream:r,node:i}):e.reject(new Error("Cluster isn't ready and enableOfflineQueue options is false"))}return e.promise}sscanStream(e,r){return this.createScanStream("sscan",{key:e,options:r})}sscanBufferStream(e,r){return this.createScanStream("sscanBuffer",{key:e,options:r})}hscanStream(e,r){return this.createScanStream("hscan",{key:e,options:r})}hscanBufferStream(e,r){return this.createScanStream("hscanBuffer",{key:e,options:r})}zscanStream(e,r){return this.createScanStream("zscan",{key:e,options:r})}zscanBufferStream(e,r){return this.createScanStream("zscanBuffer",{key:e,options:r})}handleError(e,r,i){if(typeof r.value>"u"?r.value=this.options.maxRedirections:r.value-=1,r.value<=0){i.maxRedirections(new Error("Too many Cluster redirections. Last error: "+e));return}let n=e.message.split(" ");if(n[0]==="MOVED"){let o=this.options.retryDelayOnMoved;o&&typeof o=="number"?this.delayQueue.push("moved",i.moved.bind(null,n[1],n[2]),{timeout:o}):i.moved(n[1],n[2])}else n[0]==="ASK"?i.ask(n[1],n[2]):n[0]==="TRYAGAIN"?this.delayQueue.push("tryagain",i.tryagain,{timeout:this.options.retryDelayOnTryAgain}):n[0]==="CLUSTERDOWN"&&this.options.retryDelayOnClusterDown>0?this.delayQueue.push("clusterdown",i.connectionClosed,{timeout:this.options.retryDelayOnClusterDown,callback:this.refreshSlotsCache.bind(this)}):e.message===Dr.CONNECTION_CLOSED_ERROR_MSG&&this.options.retryDelayOnFailover>0&&this.status==="ready"?this.delayQueue.push("failover",i.connectionClosed,{timeout:this.options.retryDelayOnFailover,callback:this.refreshSlotsCache.bind(this)}):i.defaults()}resetOfflineQueue(){this.offlineQueue=new N$}clearNodesRefreshInterval(){this.slotsTimer&&(clearTimeout(this.slotsTimer),this.slotsTimer=null)}resetNodesRefreshInterval(){if(this.slotsTimer||!this.options.slotsRefreshInterval)return;let e=()=>{this.slotsTimer=setTimeout(()=>{Be('refreshing slot caches... (triggered by "slotsRefreshInterval" option)'),this.refreshSlotsCache(()=>{e()})},this.options.slotsRefreshInterval)};e()}setStatus(e){Be("status: %s -> %s",this.status||"[empty]",e),this.status=e,process.nextTick(()=>{this.emit(e)})}handleCloseEvent(e){var r;e&&Be("closed because %s",e);let i;!this.manuallyClosing&&typeof this.options.clusterRetryStrategy=="function"&&(i=this.options.clusterRetryStrategy.call(this,++this.retryAttempts,e)),typeof i=="number"?(this.setStatus("reconnecting"),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,Be("Cluster is disconnected. Retrying after %dms",i),this.connect().catch(function(n){Be("Got error %s when reconnecting. Ignoring...",n)})},i)):(this.options.shardedSubscribers&&((r=this.subscriberGroupEmitter)===null||r===void 0||r.removeAllListeners()),this.setStatus("end"),this.flushQueue(new Error("None of startup nodes is available")))}flushQueue(e){let r;for(;r=this.offlineQueue.shift();)r.command.reject(e)}executeOfflineCommands(){if(this.offlineQueue.length){Be("send %d commands in offline queue",this.offlineQueue.length);let e=this.offlineQueue;this.resetOfflineQueue();let r;for(;r=e.shift();)this.sendCommand(r.command,r.stream,r.node)}}natMapper(e){let r=typeof e=="string"?e:`${e.host}:${e.port}`,i=null;return this.options.natMap&&typeof this.options.natMap=="function"?i=this.options.natMap(r):this.options.natMap&&typeof this.options.natMap=="object"&&(i=this.options.natMap[r]),i?(Be("NAT mapping %s -> %O",r,i),Object.assign({},i)):typeof e=="string"?(0,qa.nodeKeyToRedisOptions)(e):e}getInfoFromNode(e,r){if(!e)return r(new Error("Node is disconnected"));let i=e.duplicate({enableOfflineQueue:!0,enableReadyCheck:!1,retryStrategy:null,connectionName:(0,qa.getConnectionName)("refresher",this.options.redisOptions&&this.options.redisOptions.connectionName)});i.on("error",Dr.noop),i.cluster("SLOTS",(0,Dr.timeout)((n,o)=>{if(i.disconnect(),n)return Be("error encountered running CLUSTER.SLOTS: %s",n),r(n);if(this.status==="disconnecting"||this.status==="close"||this.status==="end"){Be("ignore CLUSTER.SLOTS results (count: %d) since cluster status is %s",o.length,this.status),r();return}let s=[];Be("cluster slots result count: %d",o.length);for(let l=0;l<o.length;++l){let c=o[l],u=c[0],d=c[1],f=[];for(let p=2;p<c.length;p++){if(!c[p][0])continue;let m=this.natMapper({host:c[p][0],port:c[p][1]});m.readOnly=p!==2,s.push(m),f.push(m.host+":"+m.port)}Be("cluster slots result [%d]: slots %d~%d served by %s",l,u,d,f);for(let p=u;p<=d;p++)this.slots[p]=f}this._groupsIds=Object.create(null);let a=0;for(let l=0;l<16384;l++){let c=(this.slots[l]||[]).join(";");if(!c.length){this._groupsBySlot[l]=void 0;continue}this._groupsIds[c]||(this._groupsIds[c]=++a),this._groupsBySlot[l]=this._groupsIds[c]}this.connectionPool.reset(s),this.options.shardedSubscribers&&this.shardedSubscribers.reset(this.slots,this.connectionPool.getNodes("all")).catch(l=>{Be("Error while starting subscribers: %s",l)}),r()},this.options.slotsRefreshTimeout))}invokeReadyDelayedCallbacks(e){for(let r of this._readyDelayedCallbacks)process.nextTick(r,e);this._readyDelayedCallbacks=[]}readyCheck(e){this.cluster("INFO",(r,i)=>{if(r)return e(r);if(typeof i!="string")return e();let n,o=i.split(`\r
1140
+ `);for(let s=0;s<o.length;++s){let a=o[s].split(":");if(a[0]==="cluster_state"){n=a[1];break}}n==="fail"?(Be("cluster state not ok (%s)",n),e(null,n)):e()})}resolveSrv(e){return new Promise((r,i)=>{this.options.resolveSrv(e,(n,o)=>{if(n)return i(n);let s=this,a=(0,qa.groupSrvRecords)(o),l=Object.keys(a).sort((u,d)=>parseInt(u)-parseInt(d));function c(u){if(!l.length)return i(u);let d=l[0],f=a[d],p=(0,qa.weightSrvRecords)(f);f.records.length||l.shift(),s.dnsLookup(p.name).then(m=>r({host:m,port:p.port}),c)}c()})})}dnsLookup(e){return new Promise((r,i)=>{this.options.dnsLookup(e,(n,o)=>{n?(Be("failed to resolve hostname %s to IP: %s",e,n.message),i(n)):(Be("resolved hostname %s to IP %s",e,o),r(o))})})}async resolveStartupNodeHostnames(){if(!Array.isArray(this.startupNodes)||this.startupNodes.length===0)throw new Error("`startupNodes` should contain at least one node.");let e=(0,qa.normalizeNodeOptions)(this.startupNodes),r=(0,qa.getUniqueHostnamesFromOptions)(e);if(r.length===0)return e;let i=await Promise.all(r.map((this.options.useSRVRecords?this.resolveSrv:this.dnsLookup).bind(this))),n=(0,Dr.zipMap)(r,i);return e.map(o=>{let s=n.get(o.host);return s?this.options.useSRVRecords?Object.assign({},o,s):Object.assign({},o,{host:s}):o})}createScanStream(e,{key:r,options:i={}}){return new Gse.default({objectMode:!0,key:r,redis:this,command:e,...i})}createShardedSubscriberGroup(){this.subscriberGroupEmitter=new Dw.EventEmitter,this.shardedSubscribers=new Qse.default(this.subscriberGroupEmitter,this.options);let e=r=>{r instanceof vm.default&&this.disconnect(!0)};this.subscriberGroupEmitter.on("-node",(r,i)=>{this.emit("-node",r,i),this.refreshSlotsCache(e)}),this.subscriberGroupEmitter.on("subscriberConnectFailed",({delay:r,error:i})=>{this.emit("error",i),setTimeout(()=>{this.refreshSlotsCache(e)},r)}),this.subscriberGroupEmitter.on("moved",()=>{this.refreshSlotsCache(e)}),this.subscriberGroupEmitter.on("-subscriber",()=>{this.emit("-subscriber")}),this.subscriberGroupEmitter.on("+subscriber",()=>{this.emit("+subscriber")}),this.subscriberGroupEmitter.on("nodeError",(r,i)=>{this.emit("nodeError",r,i)}),this.subscriberGroupEmitter.on("subscribersReady",()=>{this.emit("subscribersReady")});for(let r of["smessage","smessageBuffer"])this.subscriberGroupEmitter.on(r,(i,n,o)=>{this.emit(r,i,n,o)})}};(0,Bse.default)(lu,Dw.EventEmitter);(0,Vse.addTransactionSupport)(lu.prototype);jw.default=lu});var Sm=h(Nw=>{"use strict";Object.defineProperty(Nw,"__esModule",{value:!0});var eae=bt(),tae=(0,eae.Debug)("AbstractConnector"),Mw=class{constructor(e){this.connecting=!1,this.disconnectTimeout=e}check(e){return!0}disconnect(){if(this.connecting=!1,this.stream){let e=this.stream,r=setTimeout(()=>{tae("stream %s:%s still open, destroying it",e.remoteAddress,e.remotePort),e.destroy()},this.disconnectTimeout);e.on("close",()=>clearTimeout(r)),e.end()}}};Nw.default=Mw});var U$=h(Uw=>{"use strict";Object.defineProperty(Uw,"__esModule",{value:!0});var rae=U("net"),nae=U("tls"),iae=bt(),oae=Sm(),Lw=class extends oae.default{constructor(e){super(e.disconnectTimeout),this.options=e}connect(e){let{options:r}=this;this.connecting=!0;let i;return"path"in r&&r.path?i={path:r.path}:(i={},"port"in r&&r.port!=null&&(i.port=r.port),"host"in r&&r.host!=null&&(i.host=r.host),"family"in r&&r.family!=null&&(i.family=r.family)),r.tls&&Object.assign(i,r.tls),new Promise((n,o)=>{process.nextTick(()=>{if(!this.connecting){o(new Error(iae.CONNECTION_CLOSED_ERROR_MSG));return}try{r.tls?this.stream=(0,nae.connect)(i):this.stream=(0,rae.createConnection)(i)}catch(s){o(s);return}this.stream.once("error",s=>{this.firstError=s}),n(this.stream)})})}};Uw.default=Lw});var $$=h(Jw=>{"use strict";Object.defineProperty(Jw,"__esModule",{value:!0});function sae(t,e){return(t.host||"127.0.0.1")===(e.host||"127.0.0.1")&&(t.port||26379)===(e.port||26379)}var $w=class{constructor(e){this.cursor=0,this.sentinels=e.slice(0)}next(){let e=this.cursor>=this.sentinels.length;return{done:e,value:e?void 0:this.sentinels[this.cursor++]}}reset(e){e&&this.sentinels.length>1&&this.cursor!==1&&this.sentinels.unshift(...this.sentinels.splice(this.cursor-1)),this.cursor=0}add(e){for(let r=0;r<this.sentinels.length;r++)if(sae(e,this.sentinels[r]))return!1;return this.sentinels.push(e),!0}toString(){return`${JSON.stringify(this.sentinels)} @${this.cursor}`}};Jw.default=$w});var F$=h(Em=>{"use strict";Object.defineProperty(Em,"__esModule",{value:!0});Em.FailoverDetector=void 0;var aae=bt(),Fw=(0,aae.Debug)("FailoverDetector"),J$="+switch-master",qw=class{constructor(e,r){this.isDisconnected=!1,this.connector=e,this.sentinels=r}cleanup(){this.isDisconnected=!0;for(let e of this.sentinels)e.client.disconnect()}async subscribe(){Fw("Starting FailoverDetector");let e=[];for(let r of this.sentinels){let i=r.client.subscribe(J$).catch(n=>{Fw("Failed to subscribe to failover messages on sentinel %s:%s (%s)",r.address.host||"127.0.0.1",r.address.port||26739,n.message)});e.push(i),r.client.on("message",n=>{!this.isDisconnected&&n===J$&&this.disconnect()})}await Promise.all(e)}disconnect(){this.isDisconnected=!0,Fw("Failover detected, disconnecting"),this.connector.disconnect()}};Em.FailoverDetector=qw});var wm=h(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});uu.SentinelIterator=void 0;var lae=U("net"),cu=bt(),cae=U("tls"),q$=$$();uu.SentinelIterator=q$.default;var uae=Sm(),dae=mi(),pae=F$(),za=(0,cu.Debug)("SentinelConnector"),zw=class extends uae.default{constructor(e){if(super(e.disconnectTimeout),this.options=e,this.emitter=null,this.failoverDetector=null,!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 q$.default(this.options.sentinels)}check(e){let r=!e.role||this.options.role===e.role;return r||(za("role invalid, expected %s, but got %s",this.options.role,e.role),this.sentinelIterator.next(),this.sentinelIterator.next(),this.sentinelIterator.reset(!0)),r}disconnect(){super.disconnect(),this.failoverDetector&&this.failoverDetector.cleanup()}connect(e){this.connecting=!0,this.retryAttempts=0;let r,i=async()=>{let n=this.sentinelIterator.next();if(n.done){this.sentinelIterator.reset(!1);let l=typeof this.options.sentinelRetryStrategy=="function"?this.options.sentinelRetryStrategy(++this.retryAttempts):null,c=typeof l!="number"?"All sentinels are unreachable and retry is disabled.":`All sentinels are unreachable. Retrying from scratch after ${l}ms.`;r&&(c+=` Last error: ${r.message}`),za(c);let u=new Error(c);if(typeof l=="number")return e("error",u),await new Promise(d=>setTimeout(d,l)),i();throw u}let o=null,s=null;try{o=await this.resolve(n.value)}catch(l){s=l}if(!this.connecting)throw new Error(cu.CONNECTION_CLOSED_ERROR_MSG);let a=n.value.host+":"+n.value.port;if(o)return za("resolved: %s:%s from sentinel %s",o.host,o.port,a),this.options.enableTLSForSentinelMode&&this.options.tls?(Object.assign(o,this.options.tls),this.stream=(0,cae.connect)(o),this.stream.once("secureConnect",this.initFailoverDetector.bind(this))):(this.stream=(0,lae.createConnection)(o),this.stream.once("connect",this.initFailoverDetector.bind(this))),this.stream.once("error",l=>{this.firstError=l}),this.stream;{let l=s?"failed to connect to sentinel "+a+" because "+s.message:"connected to sentinel "+a+" successfully, but got an invalid reply: "+o;return za(l),e("sentinelError",new Error(l)),s&&(r=s),i()}};return i()}async updateSentinels(e){if(!this.options.updateSentinels)return;let r=await e.sentinel("sentinels",this.options.name);Array.isArray(r)&&(r.map(cu.packObject).forEach(i=>{if((i.flags?i.flags.split(","):[]).indexOf("disconnected")===-1&&i.ip&&i.port){let o=this.sentinelNatResolve(z$(i));this.sentinelIterator.add(o)&&za("adding sentinel %s:%s",o.host,o.port)}}),za("Updated internal sentinels: %s",this.sentinelIterator))}async resolveMaster(e){let r=await e.sentinel("get-master-addr-by-name",this.options.name);return await this.updateSentinels(e),this.sentinelNatResolve(Array.isArray(r)?{host:r[0],port:Number(r[1])}:null)}async resolveSlave(e){let r=await e.sentinel("slaves",this.options.name);if(!Array.isArray(r))return null;let i=r.map(cu.packObject).filter(n=>n.flags&&!n.flags.match(/(disconnected|s_down|o_down)/));return this.sentinelNatResolve(fae(i,this.options.preferredSlaves))}sentinelNatResolve(e){if(!e||!this.options.natMap)return e;let r=`${e.host}:${e.port}`,i=e;return typeof this.options.natMap=="function"?i=this.options.natMap(r)||e:typeof this.options.natMap=="object"&&(i=this.options.natMap[r]||e),i}connectToSentinel(e,r){return new dae.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?void 0:this.options.family),tls:this.options.sentinelTLS,retryStrategy:null,enableReadyCheck:!1,connectTimeout:this.options.connectTimeout,commandTimeout:this.options.sentinelCommandTimeout,...r})}async resolve(e){let r=this.connectToSentinel(e);r.on("error",mae);try{return this.options.role==="slave"?await this.resolveSlave(r):await this.resolveMaster(r)}finally{r.disconnect()}}async initFailoverDetector(){var e;if(!this.options.failoverDetector)return;this.sentinelIterator.reset(!0);let r=[];for(;r.length<this.options.sentinelMaxConnections;){let{done:i,value:n}=this.sentinelIterator.next();if(i)break;let o=this.connectToSentinel(n,{lazyConnect:!0,retryStrategy:this.options.sentinelReconnectStrategy});o.on("reconnecting",()=>{var s;(s=this.emitter)===null||s===void 0||s.emit("sentinelReconnecting")}),r.push({address:n,client:o})}this.sentinelIterator.reset(!1),this.failoverDetector&&this.failoverDetector.cleanup(),this.failoverDetector=new pae.FailoverDetector(this,r),await this.failoverDetector.subscribe(),(e=this.emitter)===null||e===void 0||e.emit("failoverSubscribed")}};uu.default=zw;function fae(t,e){if(t.length===0)return null;let r;if(typeof e=="function")r=e(t);else if(e!==null&&typeof e=="object"){let i=Array.isArray(e)?e:[e];i.sort((n,o)=>(n.prio||(n.prio=1),o.prio||(o.prio=1),n.prio<o.prio?-1:n.prio>o.prio?1:0));for(let n=0;n<i.length;n++){for(let o=0;o<t.length;o++){let s=t[o];if(s.ip===i[n].ip&&s.port===i[n].port){r=s;break}}if(r)break}}return r||(r=(0,cu.sample)(t)),z$(r)}function z$(t){return{host:t.ip,port:Number(t.port)}}function mae(){}});var G$=h(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.SentinelConnector=Ga.StandaloneConnector=void 0;var hae=U$();Ga.StandaloneConnector=hae.default;var yae=wm();Ga.SentinelConnector=yae.default});var V$=h(Vw=>{"use strict";Object.defineProperty(Vw,"__esModule",{value:!0});var gae=es(),Gw=class extends gae.AbortError{constructor(e){let r=`Reached the max retries per request limit (which is ${e}). Refer to "maxRetriesPerRequest" option for details.`;super(r),Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}};Vw.default=Gw});var B$=h(xm=>{"use strict";Object.defineProperty(xm,"__esModule",{value:!0});xm.MaxRetriesPerRequestError=void 0;var bae=V$();xm.MaxRetriesPerRequestError=bae.default});var eJ=h((v_e,Q$)=>{"use strict";var Xw=U("buffer").Buffer,vae=U("string_decoder").StringDecoder,Bw=new vae,W$=es(),Sae=W$.ReplyError,Eae=W$.ParserError,bn=Xw.allocUnsafe(32*1024),ur=0,Im=null,du=0,Ww=0;function wae(t){let e=t.buffer.length-1;var r=t.offset,i=0,n=1;for(t.buffer[r]===45&&(n=-1,r++);r<e;){let o=t.buffer[r++];if(o===13)return t.offset=r+1,n*i;i=i*10+(o-48)}}function xae(t){let e=t.buffer.length-1;var r=t.offset,i=0,n="";for(t.buffer[r]===45&&(n+="-",r++);r<e;){var o=t.buffer[r++];if(o===13)return t.offset=r+1,i!==0&&(n+=i),n;i>429496728?(n+=i*10+(o-48),i=0):o===48&&i===0?n+=0:i=i*10+(o-48)}}function Z$(t){let e=t.offset,r=t.buffer,i=r.length-1;for(var n=e;n<i;)if(r[n++]===13)return t.offset=n+1,t.optionReturnBuffers===!0?t.buffer.slice(e,n-1):t.buffer.toString("utf8",e,n-1)}function H$(t){let e=t.buffer.length-1;for(var r=t.offset,i=0;r<e;){let n=t.buffer[r++];if(n===13)return t.offset=r+1,i;i=i*10+(n-48)}}function Iae(t){return t.optionStringNumbers===!0?xae(t):wae(t)}function kae(t){let e=H$(t);if(e===void 0)return;if(e<0)return null;let r=t.offset+e;if(r+2>t.buffer.length){t.bigStrSize=r+2,t.totalChunkSize=t.buffer.length,t.bufferCache.push(t.buffer);return}let i=t.offset;return t.offset=r+2,t.optionReturnBuffers===!0?t.buffer.slice(i,r):t.buffer.toString("utf8",i,r)}function _ae(t){var e=Z$(t);if(e!==void 0)return t.optionReturnBuffers===!0&&(e=e.toString()),new Sae(e)}function Tae(t,e){let r=new Eae("Protocol error, got "+JSON.stringify(String.fromCharCode(e))+" as reply type byte",JSON.stringify(t.buffer),t.offset);t.buffer=null,t.returnFatalError(r)}function Cae(t){let e=H$(t);if(e===void 0)return;if(e<0)return null;let r=new Array(e);return Y$(t,r,0)}function Zw(t,e,r){t.arrayCache.push(e),t.arrayPos.push(r)}function Hw(t){let e=t.arrayCache.pop();var r=t.arrayPos.pop();if(t.arrayCache.length){let i=Hw(t);if(i===void 0){Zw(t,e,r);return}e[r++]=i}return Y$(t,e,r)}function Y$(t,e,r){let i=t.buffer.length;for(;r<e.length;){let n=t.offset;if(t.offset>=i){Zw(t,e,r);return}let o=X$(t,t.buffer[t.offset++]);if(o===void 0){t.arrayCache.length||t.bufferCache.length||(t.offset=n),Zw(t,e,r);return}e[r]=o,r++}return e}function X$(t,e){switch(e){case 36:return kae(t);case 43:return Z$(t);case 42:return Cae(t);case 58:return Iae(t);case 45:return _ae(t);default:return Tae(t,e)}}function Oae(){if(bn.length>50*1024)if(du===1||Ww>du*2){let t=Math.floor(bn.length/10),e=t<ur?ur:t;ur=0,bn=bn.slice(e,bn.length)}else Ww++,du--;else clearInterval(Im),du=0,Ww=0,Im=null}function Aae(t){if(bn.length<t+ur){let e=t>78643200?2:3;ur>1024*1024*111&&(ur=1024*1024*50),bn=Xw.allocUnsafe(t*e+ur),ur=0,du++,Im===null&&(Im=setInterval(Oae,50))}}function Kae(t){let e=t.bufferCache,r=t.offset;var i=e.length,n=t.bigStrSize-t.totalChunkSize;if(t.offset=n,n<=2){if(i===2)return e[0].toString("utf8",r,e[0].length+n-2);i--,n=e[e.length-2].length+n}for(var o=Bw.write(e[0].slice(r)),s=1;s<i-1;s++)o+=Bw.write(e[s]);return o+=Bw.end(e[s].slice(0,n-2)),o}function Rae(t){let e=t.bufferCache,r=t.offset,i=t.bigStrSize-r-2;var n=e.length,o=t.bigStrSize-t.totalChunkSize;if(t.offset=o,o<=2){if(n===2)return e[0].slice(r,e[0].length+o-2);n--,o=e[e.length-2].length+o}Aae(i);let s=ur;e[0].copy(bn,s,r,e[0].length),ur+=e[0].length-r;for(var a=1;a<n-1;a++)e[a].copy(bn,ur),ur+=e[a].length;return e[a].copy(bn,ur,0,o-2),ur+=o-2,bn.slice(s,ur)}var Yw=class{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){let i=this.buffer.length,n=i-this.offset,o=Xw.allocUnsafe(n+e.length);if(this.buffer.copy(o,0,this.offset,i),e.copy(o,n,0,e.length),this.buffer=o,this.offset=0,this.arrayCache.length){let s=Hw(this);if(s===void 0)return;this.returnReply(s)}}else if(this.totalChunkSize+e.length>=this.bigStrSize){this.bufferCache.push(e);var r=this.optionReturnBuffers?Rae(this):Kae(this);if(this.bigStrSize=0,this.bufferCache=[],this.buffer=e,this.arrayCache.length&&(this.arrayCache[0][this.arrayPos[0]++]=r,r=Hw(this),r===void 0))return;this.returnReply(r)}else{this.bufferCache.push(e),this.totalChunkSize+=e.length;return}for(;this.offset<this.buffer.length;){let i=this.offset,n=this.buffer[this.offset++],o=X$(this,n);if(o===void 0){this.arrayCache.length||this.bufferCache.length||(this.offset=i);return}n===45?this.returnError(o):this.returnReply(o)}this.buffer=null}};Q$.exports=Yw});var rJ=h((S_e,tJ)=>{"use strict";tJ.exports=eJ()});var nJ=h(tx=>{"use strict";Object.defineProperty(tx,"__esModule",{value:!0});var ex=class{constructor(){this.set={subscribe:{},psubscribe:{},ssubscribe:{}}}add(e,r){this.set[Qw(e)][r]=!0}del(e,r){delete this.set[Qw(e)][r]}channels(e){return Object.keys(this.set[Qw(e)])}isEmpty(){return this.channels("subscribe").length===0&&this.channels("psubscribe").length===0&&this.channels("ssubscribe").length===0}};tx.default=ex;function Qw(t){return t==="unsubscribe"?"subscribe":t==="punsubscribe"?"psubscribe":t==="sunsubscribe"?"ssubscribe":t}});var aJ=h(nx=>{"use strict";Object.defineProperty(nx,"__esModule",{value:!0});var iJ=pi(),Dae=bt(),jae=rJ(),Pae=nJ(),Mae=(0,Dae.Debug)("dataHandler"),rx=class{constructor(e,r){this.redis=e;let i=new jae({stringNumbers:r.stringNumbers,returnBuffers:!0,returnError:n=>{this.returnError(n)},returnFatalError:n=>{this.returnFatalError(n)},returnReply:n=>{this.returnReply(n)}});e.stream.prependListener("data",n=>{i.execute(n)}),e.stream.resume()}returnFatalError(e){e.message+=". Please report this.",this.redis.recoverFromFatalError(e,e,{offlineQueue:!1})}returnError(e){let r=this.shiftCommand(e);if(r){if(e.command={name:r.command.name,args:r.command.args},r.command.name=="ssubscribe"&&e.message.includes("MOVED")){this.redis.emit("moved");return}this.redis.handleReconnection(e,r)}}returnReply(e){if(this.handleMonitorReply(e)||this.handleSubscriberReply(e))return;let r=this.shiftCommand(e);r&&(iJ.default.checkFlag("ENTER_SUBSCRIBER_MODE",r.command.name)?(this.redis.condition.subscriber=new Pae.default,this.redis.condition.subscriber.add(r.command.name,e[1].toString()),oJ(r.command,e[2])||this.redis.commandQueue.unshift(r)):iJ.default.checkFlag("EXIT_SUBSCRIBER_MODE",r.command.name)?sJ(r.command,e[2])||this.redis.commandQueue.unshift(r):r.command.resolve(e))}handleSubscriberReply(e){if(!this.redis.condition.subscriber)return!1;let r=Array.isArray(e)?e[0].toString():null;switch(Mae('receive reply "%s" in subscriber mode',r),r){case"message":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":{let i=e[1].toString();this.redis.listeners("pmessage").length>0&&this.redis.emit("pmessage",i,e[2].toString(),e[3].toString()),this.redis.emit("pmessageBuffer",i,e[2],e[3]);break}case"smessage":{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":{let i=e[1].toString();this.redis.condition.subscriber.add(r,i);let n=this.shiftCommand(e);if(!n)return;oJ(n.command,e[2])||this.redis.commandQueue.unshift(n);break}case"sunsubscribe":case"unsubscribe":case"punsubscribe":{let i=e[1]?e[1].toString():null;i&&this.redis.condition.subscriber.del(r,i);let n=e[2];Number(n)===0&&(this.redis.condition.subscriber=!1);let o=this.shiftCommand(e);if(!o)return;sJ(o.command,n)||this.redis.commandQueue.unshift(o);break}default:{let i=this.shiftCommand(e);if(!i)return;i.command.resolve(e)}}return!0}handleMonitorReply(e){if(this.redis.status!=="monitoring")return!1;let r=e.toString();if(r==="OK")return!1;let i=r.indexOf(" "),n=r.slice(0,i),o=r.indexOf('"'),s=r.slice(o+1,-1).split('" "').map(l=>l.replace(/\\"/g,'"')),a=r.slice(i+2,o-2).split(" ");return this.redis.emit("monitor",n,s,a[1],a[0]),!0}shiftCommand(e){let r=this.redis.commandQueue.shift();if(!r){let i="Command queue state error. If you can reproduce this, please report it.",n=new Error(i+(e instanceof Error?` Last error: ${e.message}`:` Last reply: ${e.toString()}`));return this.redis.emit("error",n),null}return r}};nx.default=rx;var Xi=new WeakMap;function oJ(t,e){let r=Xi.has(t)?Xi.get(t):t.args.length;return r-=1,r<=0?(t.resolve(e),Xi.delete(t),!0):(Xi.set(t,r),!1)}function sJ(t,e){let r=Xi.has(t)?Xi.get(t):t.args.length;return r===0?Number(e)===0?(Xi.delete(t),t.resolve(e),!0):!1:(r-=1,r<=0?(t.resolve(e),!0):(Xi.set(t,r),!1))}});var lJ=h(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.readyHandler=nn.errorHandler=nn.closeHandler=nn.connectHandler=void 0;var Nae=es(),Lae=pi(),Uae=B$(),Fn=bt(),$ae=aJ(),Ut=(0,Fn.Debug)("connection");function Jae(t){return function(){var e;t.setStatus("connect"),t.resetCommandQueue();let r=!1,{connectionEpoch:i}=t;t.condition.auth&&t.auth(t.condition.auth,function(o){i===t.connectionEpoch&&o&&(o.message.indexOf("no password is set")!==-1?console.warn("[WARN] Redis server does not require a password, but a password was supplied."):o.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"):o.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.`):(r=!0,t.recoverFromFatalError(o,o)))}),t.condition.select&&t.select(t.condition.select).catch(o=>{t.silentEmit("error",o)}),new $ae.default(t,{stringNumbers:t.options.stringNumbers});let n=[];t.options.connectionName&&(Ut("set the connection name [%s]",t.options.connectionName),n.push(t.client("setname",t.options.connectionName).catch(Fn.noop))),t.options.disableClientInfo||(Ut("set the client info"),n.push((0,Fn.getPackageMeta)().then(o=>t.client("SETINFO","LIB-VER",o.version).catch(Fn.noop)).catch(Fn.noop)),n.push(t.client("SETINFO","LIB-NAME",!((e=t.options)===null||e===void 0)&&e.clientInfoTag?`ioredis(${t.options.clientInfoTag})`:"ioredis").catch(Fn.noop))),Promise.all(n).catch(Fn.noop).finally(()=>{t.options.enableReadyCheck||nn.readyHandler(t)(),t.options.enableReadyCheck&&t._readyCheck(function(o,s){i===t.connectionEpoch&&(o?r||t.recoverFromFatalError(new Error("Ready check failed: "+o.message),o):t.connector.check(s)?nn.readyHandler(t)():t.disconnect(!0))})})}}nn.connectHandler=Jae;function ix(t){let e=new Nae.AbortError("Command aborted due to connection close");return e.command={name:t.name,args:t.args},e}function Fae(t){var e;let r=0;for(let i=0;i<t.length;){let n=(e=t.peekAt(i))===null||e===void 0?void 0:e.command,o=n.pipelineIndex;if((o===void 0||o===0)&&(r=0),o!==void 0&&o!==r++){t.remove(i,1),n.reject(ix(n));continue}i++}}function qae(t){var e;for(let r=0;r<t.length;){let i=(e=t.peekAt(r))===null||e===void 0?void 0:e.command;if(i.name==="multi")break;if(i.name==="exec"){t.remove(r,1),i.reject(ix(i));break}i.inTransaction?(t.remove(r,1),i.reject(ix(i))):r++}}function zae(t){return function(){let r=t.status;if(t.setStatus("close"),t.commandQueue.length&&Fae(t.commandQueue),t.offlineQueue.length&&qae(t.offlineQueue),r==="ready"&&(t.prevCondition||(t.prevCondition=t.condition),t.commandQueue.length&&(t.prevCommandQueue=t.commandQueue)),t.manuallyClosing)return t.manuallyClosing=!1,Ut("skip reconnecting since the connection is manually closed."),e();if(typeof t.options.retryStrategy!="function")return Ut("skip reconnecting because `retryStrategy` is not a function"),e();let i=t.options.retryStrategy(++t.retryAttempts);if(typeof i!="number")return Ut("skip reconnecting because `retryStrategy` doesn't return a number"),e();Ut("reconnect in %sms",i),t.setStatus("reconnecting",i),t.reconnectTimeout=setTimeout(function(){t.reconnectTimeout=null,t.connect().catch(Fn.noop)},i);let{maxRetriesPerRequest:n}=t.options;typeof n=="number"&&(n<0?Ut("maxRetriesPerRequest is negative, ignoring..."):t.retryAttempts%(n+1)===0&&(Ut("reach maxRetriesPerRequest limitation, flushing command queue..."),t.flushQueue(new Uae.MaxRetriesPerRequestError(n))))};function e(){t.setStatus("end"),t.flushQueue(new Error(Fn.CONNECTION_CLOSED_ERROR_MSG))}}nn.closeHandler=zae;function Gae(t){return function(e){Ut("error: %s",e),t.silentEmit("error",e)}}nn.errorHandler=Gae;function Vae(t){return function(){if(t.setStatus("ready"),t.retryAttempts=0,t.options.monitor){t.call("monitor").then(()=>t.setStatus("monitoring"),i=>t.emit("error",i));let{sendCommand:r}=t;t.sendCommand=function(i){return Lae.default.checkFlag("VALID_IN_MONITOR_MODE",i.name)?r.call(t,i):(i.reject(new Error("Connection is in monitoring mode, can't process commands.")),i.promise)},t.once("close",function(){delete t.sendCommand});return}let e=t.prevCondition?t.prevCondition.select:t.condition.select;if(t.options.readOnly&&(Ut("set the connection to readonly mode"),t.readonly().catch(Fn.noop)),t.prevCondition){let r=t.prevCondition;if(t.prevCondition=null,r.subscriber&&t.options.autoResubscribe){t.condition.select!==e&&(Ut("connect to db [%d]",e),t.select(e));let i=r.subscriber.channels("subscribe");i.length&&(Ut("subscribe %d channels",i.length),t.subscribe(i));let n=r.subscriber.channels("psubscribe");n.length&&(Ut("psubscribe %d channels",n.length),t.psubscribe(n));let o=r.subscriber.channels("ssubscribe");if(o.length){Ut("ssubscribe %s",o.length);for(let s of o)t.ssubscribe(s)}}}if(t.prevCommandQueue)if(t.options.autoResendUnfulfilledCommands)for(Ut("resend %d unfulfilled commands",t.prevCommandQueue.length);t.prevCommandQueue.length>0;){let r=t.prevCommandQueue.shift();r.select!==t.condition.select&&r.command.name!=="select"&&t.select(r.select),t.sendCommand(r.command,r.stream)}else t.prevCommandQueue=null;if(t.offlineQueue.length){Ut("send %d commands in offline queue",t.offlineQueue.length);let r=t.offlineQueue;for(t.resetOfflineQueue();r.length>0;){let i=r.shift();i.select!==t.condition.select&&i.command.name!=="select"&&t.select(i.select),t.sendCommand(i.command,i.stream)}}t.condition.select!==e&&(Ut("connect to db [%d]",e),t.select(e))}}nn.readyHandler=Vae});var cJ=h(km=>{"use strict";Object.defineProperty(km,"__esModule",{value:!0});km.DEFAULT_REDIS_OPTIONS=void 0;km.DEFAULT_REDIS_OPTIONS={port:6379,host:"localhost",family:0,connectTimeout:1e4,disconnectTimeout:2e3,retryStrategy:function(t){return Math.min(t*50,2e3)},keepAlive:0,noDelay:!0,connectionName:null,disableClientInfo:!1,clientInfoTag:void 0,sentinels:null,name:null,role:"master",sentinelRetryStrategy:function(t){return Math.min(t*10,1e3)},sentinelReconnectStrategy:function(){return 6e4},natMap:null,enableTLSForSentinelMode:!1,updateSentinels:!0,failoverDetector:!1,username:null,password:null,db:0,enableOfflineQueue:!0,enableReadyCheck:!0,autoResubscribe:!0,autoResendUnfulfilledCommands:!0,lazyConnect:!1,keyPrefix:"",reconnectOnError:null,readOnly:!1,stringNumbers:!1,maxRetriesPerRequest:20,maxLoadingRetryTime:1e4,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],sentinelMaxConnections:10,blockingTimeoutGrace:100}});var mi=h(sx=>{"use strict";Object.defineProperty(sx,"__esModule",{value:!0});var uJ=Qo(),pJ=U("events"),ox=Zi(),Bae=Pw(),rs=pi(),Wae=G$(),Zae=wm(),Qi=lJ(),fJ=cJ(),Hae=dm(),Yae=vw(),ns=bt(),Xae=Ew(),Qae=fm(),eo=yf(),dJ=gm(),to=(0,ns.Debug)("redis"),ro=class t extends Qae.default{constructor(e,r,i){if(super(),this.status="wait",this.isCluster=!1,this.reconnectTimeout=null,this.connectionEpoch=0,this.retryAttempts=0,this.manuallyClosing=!1,this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this.parseOptions(e,r,i),pJ.EventEmitter.call(this),this.resetCommandQueue(),this.resetOfflineQueue(),this.options.Connector)this.connector=new this.options.Connector(this.options);else if(this.options.sentinels){let n=new Zae.default(this.options);n.emitter=this,this.connector=n}else this.connector=new Wae.StandaloneConnector(this.options);this.options.scripts&&Object.entries(this.options.scripts).forEach(([n,o])=>{this.defineCommand(n,o)}),this.options.lazyConnect?this.setStatus("wait"):this.connect().catch(eo.noop)}static createClient(...e){return new t(...e)}get autoPipelineQueueSize(){let e=0;for(let r of this._autoPipelines.values())e+=r.length;return e}connect(e){let r=new Promise((i,n)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){n(new Error("Redis is already connecting/connected"));return}this.connectionEpoch+=1,this.setStatus("connecting");let{options:o}=this;this.condition={select:o.db,auth:o.username?[o.username,o.password]:o.password,subscriber:!1};let s=this;(0,ox.default)(this.connector.connect(function(a,l){s.silentEmit(a,l)}),function(a,l){if(a){s.flushQueue(a),s.silentEmit("error",a),n(a),s.setStatus("end");return}let c=o.tls?"secureConnect":"connect";if("sentinels"in o&&o.sentinels&&!o.enableTLSForSentinelMode&&(c="connect"),s.stream=l,o.noDelay&&l.setNoDelay(!0),typeof o.keepAlive=="number"&&(l.connecting?l.once(c,()=>{l.setKeepAlive(!0,o.keepAlive)}):l.setKeepAlive(!0,o.keepAlive)),l.connecting){if(l.once(c,Qi.connectHandler(s)),o.connectTimeout){let f=!1;l.setTimeout(o.connectTimeout,function(){if(f)return;l.setTimeout(0),l.destroy();let p=new Error("connect ETIMEDOUT");p.errorno="ETIMEDOUT",p.code="ETIMEDOUT",p.syscall="connect",Qi.errorHandler(s)(p)}),l.once(c,function(){f=!0,l.setTimeout(0)})}}else if(l.destroyed){let f=s.connector.firstError;f&&process.nextTick(()=>{Qi.errorHandler(s)(f)}),process.nextTick(Qi.closeHandler(s))}else process.nextTick(Qi.connectHandler(s));l.destroyed||(l.once("error",Qi.errorHandler(s)),l.once("close",Qi.closeHandler(s)));let u=function(){s.removeListener("close",d),i()};var d=function(){s.removeListener("ready",u),n(new Error(ns.CONNECTION_CLOSED_ERROR_MSG))};s.once("ready",u),s.once("close",d)})});return(0,ox.default)(r,e)}disconnect(e=!1){e||(this.manuallyClosing=!0),this.reconnectTimeout&&!e&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.status==="wait"?Qi.closeHandler(this)():this.connector.disconnect()}end(){this.disconnect()}duplicate(e){return new t({...this.options,...e})}get mode(){var e;return this.options.monitor?"monitor":!((e=this.condition)===null||e===void 0)&&e.subscriber?"subscriber":"normal"}monitor(e){let r=this.duplicate({monitor:!0,lazyConnect:!1});return(0,ox.default)(new Promise(function(i,n){r.once("error",n),r.once("monitoring",function(){i(r)})}),e)}sendCommand(e,r){var i,n;if(this.status==="wait"&&this.connect().catch(eo.noop),this.status==="end")return e.reject(new Error(ns.CONNECTION_CLOSED_ERROR_MSG)),e.promise;if(!((i=this.condition)===null||i===void 0)&&i.subscriber&&!rs.default.checkFlag("VALID_IN_SUBSCRIBER_MODE",e.name))return e.reject(new Error("Connection in subscriber mode, only subscriber commands may be used")),e.promise;typeof this.options.commandTimeout=="number"&&e.setTimeout(this.options.commandTimeout);let o=this.getBlockingTimeoutInMs(e),s=this.status==="ready"||!r&&this.status==="connect"&&(0,uJ.exists)(e.name,{caseInsensitive:!0})&&((0,uJ.hasFlag)(e.name,"loading",{nameCaseInsensitive:!0})||rs.default.checkFlag("HANDSHAKE_COMMANDS",e.name));if(this.stream&&this.stream.writable?this.stream._writableState&&this.stream._writableState.ended&&(s=!1):s=!1,s)to.enabled&&to("write command[%s]: %d -> %s(%o)",this._getDescription(),(n=this.condition)===null||n===void 0?void 0:n.select,e.name,e.args),r?"isPipeline"in r&&r.isPipeline?r.write(e.toWritable(r.destination.redis.stream)):r.write(e.toWritable(r)):this.stream.write(e.toWritable(this.stream)),this.commandQueue.push({command:e,stream:r,select:this.condition.select}),o!==void 0&&e.setBlockingTimeout(o),rs.default.checkFlag("WILL_DISCONNECT",e.name)&&(this.manuallyClosing=!0),this.options.socketTimeout!==void 0&&this.socketTimeoutTimer===void 0&&this.setSocketTimeout();else{if(!this.options.enableOfflineQueue)return e.reject(new Error("Stream isn't writeable and enableOfflineQueue options is false")),e.promise;if(e.name==="quit"&&this.offlineQueue.length===0)return this.disconnect(),e.resolve(Buffer.from("OK")),e.promise;if(to.enabled&&to("queue command[%s]: %d -> %s(%o)",this._getDescription(),this.condition.select,e.name,e.args),this.offlineQueue.push({command:e,stream:r,select:this.condition.select}),rs.default.checkFlag("BLOCKING_COMMANDS",e.name)){let a=this.getConfiguredBlockingTimeout();a!==void 0&&e.setBlockingTimeout(a)}}if(e.name==="select"&&(0,ns.isInt)(e.args[0])){let a=parseInt(e.args[0],10);this.condition.select!==a&&(this.condition.select=a,this.emit("select",a),to("switch to db [%d]",this.condition.select))}return e.promise}getBlockingTimeoutInMs(e){var r;if(!rs.default.checkFlag("BLOCKING_COMMANDS",e.name))return;let i=this.getConfiguredBlockingTimeout();if(i===void 0)return;let n=e.extractBlockingTimeout();if(typeof n=="number")return n>0?n+((r=this.options.blockingTimeoutGrace)!==null&&r!==void 0?r:fJ.DEFAULT_REDIS_OPTIONS.blockingTimeoutGrace):i;if(n===null)return i}getConfiguredBlockingTimeout(){if(typeof this.options.blockingTimeout=="number"&&this.options.blockingTimeout>0)return this.options.blockingTimeout}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=void 0},this.options.socketTimeout),this.stream.once("data",()=>{clearTimeout(this.socketTimeoutTimer),this.socketTimeoutTimer=void 0,this.commandQueue.length!==0&&this.setSocketTimeout()})}scanStream(e){return this.createScanStream("scan",{options:e})}scanBufferStream(e){return this.createScanStream("scanBuffer",{options:e})}sscanStream(e,r){return this.createScanStream("sscan",{key:e,options:r})}sscanBufferStream(e,r){return this.createScanStream("sscanBuffer",{key:e,options:r})}hscanStream(e,r){return this.createScanStream("hscan",{key:e,options:r})}hscanBufferStream(e,r){return this.createScanStream("hscanBuffer",{key:e,options:r})}zscanStream(e,r){return this.createScanStream("zscan",{key:e,options:r})}zscanBufferStream(e,r){return this.createScanStream("zscanBuffer",{key:e,options:r})}silentEmit(e,r){let i;if(!(e==="error"&&(i=r,this.status==="end"||this.manuallyClosing&&i instanceof Error&&(i.message===ns.CONNECTION_CLOSED_ERROR_MSG||i.syscall==="connect"||i.syscall==="read"))))return this.listeners(e).length>0?this.emit.apply(this,arguments):(i&&i instanceof Error&&console.error("[ioredis] Unhandled error event:",i.stack),!1)}recoverFromFatalError(e,r,i){this.flushQueue(r,i),this.silentEmit("error",r),this.disconnect(!0)}handleReconnection(e,r){var i;let n=!1;switch(this.options.reconnectOnError&&!rs.default.checkFlag("IGNORE_RECONNECT_ON_ERROR",r.command.name)&&(n=this.options.reconnectOnError(e)),n){case 1:case!0:this.status!=="reconnecting"&&this.disconnect(!0),r.command.reject(e);break;case 2:this.status!=="reconnecting"&&this.disconnect(!0),((i=this.condition)===null||i===void 0?void 0:i.select)!==r.select&&r.command.name!=="select"&&this.select(r.select),this.sendCommand(r.command);break;default:r.command.reject(e)}}_getDescription(){let e;return"path"in this.options&&this.options.path?e=this.options.path:this.stream&&this.stream.remoteAddress&&this.stream.remotePort?e=this.stream.remoteAddress+":"+this.stream.remotePort:"host"in this.options&&this.options.host?e=this.options.host+":"+this.options.port:e="",this.options.connectionName&&(e+=` (${this.options.connectionName})`),e}resetCommandQueue(){this.commandQueue=new dJ}resetOfflineQueue(){this.offlineQueue=new dJ}parseOptions(...e){let r={},i=!1;for(let n=0;n<e.length;++n){let o=e[n];if(!(o===null||typeof o>"u"))if(typeof o=="object")(0,eo.defaults)(r,o);else if(typeof o=="string")(0,eo.defaults)(r,(0,ns.parseURL)(o)),o.startsWith("rediss://")&&(i=!0);else if(typeof o=="number")r.port=o;else throw new Error("Invalid argument "+o)}i&&(0,eo.defaults)(r,{tls:!0}),(0,eo.defaults)(r,t.defaultOptions),typeof r.port=="string"&&(r.port=parseInt(r.port,10)),typeof r.db=="string"&&(r.db=parseInt(r.db,10)),this.options=(0,ns.resolveTLSProfile)(r)}setStatus(e,r){to.enabled&&to("status[%s]: %s -> %s",this._getDescription(),this.status||"[empty]",e),this.status=e,process.nextTick(this.emit.bind(this,e,r))}createScanStream(e,{key:r,options:i={}}){return new Hae.default({objectMode:!0,key:r,redis:this,command:e,...i})}flushQueue(e,r){r=(0,eo.defaults)({},r,{offlineQueue:!0,commandQueue:!0});let i;if(r.offlineQueue)for(;i=this.offlineQueue.shift();)i.command.reject(e);if(r.commandQueue&&this.commandQueue.length>0)for(this.stream&&this.stream.removeAllListeners("data");i=this.commandQueue.shift();)i.command.reject(e)}_readyCheck(e){let r=this;this.info(function(i,n){if(i)return i.message&&i.message.includes("NOPERM")?(console.warn(`Skipping the ready check because INFO command fails: "${i.message}". You can disable ready check with "enableReadyCheck". More: https://github.com/luin/ioredis/wiki/Disable-ready-check.`),e(null,{})):e(i);if(typeof n!="string")return e(null,n);let o={},s=n.split(`\r
1141
1141
  `);for(let a=0;a<s.length;++a){let[l,...c]=s[a].split(":"),u=c.join(":");u&&(o[l]=u)}if(!o.loading||o.loading==="0")e(null,o);else{let a=(o.loading_eta_seconds||1)*1e3,l=r.options.maxLoadingRetryTime&&r.options.maxLoadingRetryTime<a?r.options.maxLoadingRetryTime:a;to("Redis server still loading, trying again in "+l+"ms"),setTimeout(function(){r._readyCheck(e)},l)}}).catch(eo.noop)}};ro.Cluster=Bae.default;ro.Command=rs.default;ro.defaultOptions=fJ.DEFAULT_REDIS_OPTIONS;(0,Xae.default)(ro,pJ.EventEmitter);(0,Yae.addTransactionSupport)(ro.prototype);sx.default=ro});var yJ=h((We,hJ)=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.print=We.ReplyError=We.SentinelIterator=We.SentinelConnector=We.AbstractConnector=We.Pipeline=We.ScanStream=We.Command=We.Cluster=We.Redis=We.default=void 0;We=hJ.exports=mi().default;var ele=mi();Object.defineProperty(We,"default",{enumerable:!0,get:function(){return ele.default}});var tle=mi();Object.defineProperty(We,"Redis",{enumerable:!0,get:function(){return tle.default}});var rle=Pw();Object.defineProperty(We,"Cluster",{enumerable:!0,get:function(){return rle.default}});var nle=pi();Object.defineProperty(We,"Command",{enumerable:!0,get:function(){return nle.default}});var ile=dm();Object.defineProperty(We,"ScanStream",{enumerable:!0,get:function(){return ile.default}});var ole=yw();Object.defineProperty(We,"Pipeline",{enumerable:!0,get:function(){return ole.default}});var sle=Sm();Object.defineProperty(We,"AbstractConnector",{enumerable:!0,get:function(){return sle.default}});var mJ=wm();Object.defineProperty(We,"SentinelConnector",{enumerable:!0,get:function(){return mJ.default}});Object.defineProperty(We,"SentinelIterator",{enumerable:!0,get:function(){return mJ.SentinelIterator}});We.ReplyError=es().ReplyError;Object.defineProperty(We,"Promise",{get(){return console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used."),Promise},set(t){console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.")}});function ale(t,e){console.log(t?"Error: "+t:"Reply: "+e)}We.print=ale});var gJ=h(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});_m.addDelayedJob=void 0;var lle=`--[[
1142
1142
  Adds a delayed job to the queue by doing the following:
1143
1143
  - Increases the job counter if needed.
@@ -9948,7 +9948,7 @@ elseif rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then
9948
9948
  end
9949
9949
  return ''
9950
9950
  `;wh.updateRepeatableJobMillis={name:"updateRepeatableJobMillis",content:ice,keys:1}});var mF=h(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});var Q=(Zt(),Jt(Wt));Q.__exportStar(gJ(),X);Q.__exportStar(bJ(),X);Q.__exportStar(vJ(),X);Q.__exportStar(SJ(),X);Q.__exportStar(EJ(),X);Q.__exportStar(wJ(),X);Q.__exportStar(xJ(),X);Q.__exportStar(IJ(),X);Q.__exportStar(kJ(),X);Q.__exportStar(_J(),X);Q.__exportStar(TJ(),X);Q.__exportStar(CJ(),X);Q.__exportStar(OJ(),X);Q.__exportStar(AJ(),X);Q.__exportStar(KJ(),X);Q.__exportStar(RJ(),X);Q.__exportStar(DJ(),X);Q.__exportStar(jJ(),X);Q.__exportStar(PJ(),X);Q.__exportStar(MJ(),X);Q.__exportStar(NJ(),X);Q.__exportStar(LJ(),X);Q.__exportStar(UJ(),X);Q.__exportStar($J(),X);Q.__exportStar(JJ(),X);Q.__exportStar(FJ(),X);Q.__exportStar(qJ(),X);Q.__exportStar(zJ(),X);Q.__exportStar(GJ(),X);Q.__exportStar(VJ(),X);Q.__exportStar(BJ(),X);Q.__exportStar(WJ(),X);Q.__exportStar(ZJ(),X);Q.__exportStar(HJ(),X);Q.__exportStar(YJ(),X);Q.__exportStar(XJ(),X);Q.__exportStar(QJ(),X);Q.__exportStar(eF(),X);Q.__exportStar(tF(),X);Q.__exportStar(rF(),X);Q.__exportStar(nF(),X);Q.__exportStar(iF(),X);Q.__exportStar(oF(),X);Q.__exportStar(sF(),X);Q.__exportStar(aF(),X);Q.__exportStar(lF(),X);Q.__exportStar(cF(),X);Q.__exportStar(uF(),X);Q.__exportStar(dF(),X);Q.__exportStar(pF(),X);Q.__exportStar(fF(),X)});var pu=h(xh=>{"use strict";Object.defineProperty(xh,"__esModule",{value:!0});xh.createIORedisClient=ax;xh.isIRedisClient=oce;var hF=new WeakMap;function ax(t){if(t.__bullmq_iredis===!0)return t;let e=hF.get(t);if(e)return e;let r=t.isCluster===!0,i=new Map,n=Object.create(null);n.__bullmq_iredis=!0,n.isCluster=r,n.runCommand=(s,a)=>t[s](a),n.pipeline=(...s)=>yF(t.pipeline(...s)),n.multi=(...s)=>yF(t.multi(...s)),typeof t.duplicate=="function"&&(n.duplicate=s=>{var a;if(r){let l=((a=t.options)===null||a===void 0?void 0:a.redisOptions)||{},c=s?Object.assign(Object.assign({},l),s):l;return ax(t.duplicate(void 0,{redisOptions:c}))}return ax(t.duplicate(s))}),n.hset=(s,a,...l)=>{if(typeof a=="string")return t.hset(s,a,...l);let c=[s];for(let[u,d]of Object.entries(a))c.push(u,d);return t.hset(...c)},n.set=(s,a,l,...c)=>{if(typeof l=="string"||l==null)return t.set(s,a,...l!=null?[l,...c]:[]);let u=[s,a];return l.PX!=null?u.push("PX",l.PX):l.EX!=null&&u.push("EX",l.EX),t.set(...u)},n.zrange=(s,a,l,c,...u)=>typeof c=="string"?t.zrange(s,a,l,c,...u):c?.WITHSCORES?t.zrange(s,a,l,"WITHSCORES"):t.zrange(s,a,l),n.zrevrange=(s,a,l,c,...u)=>typeof c=="string"?t.zrevrange(s,a,l,c,...u):c?.WITHSCORES?t.zrevrange(s,a,l,"WITHSCORES"):t.zrevrange(s,a,l),n.xadd=(s,a,l,...c)=>{if(typeof l=="string")return t.xadd(s,a,l,...c);let u=c[0],d=[s];u?.MAXLEN!=null&&(d.push("MAXLEN"),u.approximate!==!1&&d.push("~"),d.push(u.MAXLEN)),d.push(a);for(let[f,p]of Object.entries(l))d.push(f,p);return t.xadd(...d)},n.xread=(s,...a)=>{if(typeof s=="string")return t.xread(s,...a);let l=a[0],c=[];l?.BLOCK!=null&&c.push("BLOCK",l.BLOCK),l?.COUNT!=null&&c.push("COUNT",l.COUNT),c.push("STREAMS");for(let u of s)c.push(u.key);for(let u of s)c.push(u.id);return t.xread(...c)},n.xtrim=(s,a,l,...c)=>{if(typeof l=="string"||c.length===0)return t.xtrim(s,a,l,...c);let u=c[0],d=[s,a];return u?.approximate!==!1&&d.push("~"),d.push(l),t.xtrim(...d)},n.clientSetName=s=>t.client("SETNAME",s),n.clientList=()=>t.client("LIST"),n.scan=(s,...a)=>{if(a.length===0||typeof a[0]=="string"||typeof a[0]=="function")return t.scan(s,...a);let l=a[0],c=[s];return l?.MATCH!=null&&c.push("MATCH",l.MATCH),l?.COUNT!=null&&c.push("COUNT",l.COUNT),t.scan(...c)};let o=new Proxy(t,{get(s,a){if(a in n)return n[a];let l=Reflect.get(s,a,s);if(typeof l!="function")return l;if(Object.prototype.hasOwnProperty.call(s,a))return l.bind(s);let c=i.get(a);if(c!==void 0)return c;let u=l.bind(s);return i.set(a,u),u},set(s,a,l){return a in n?(n[a]=l,!0):(i.delete(a),Reflect.set(s,a,l))},deleteProperty(s,a){return a in n?!1:(i.delete(a),Reflect.deleteProperty(s,a))},has(s,a){return a in n||Reflect.has(s,a)}});return hF.set(t,o),o}function yF(t){let e=t;e.runCommand=function(o,s){return e[o](s),e};let r=e.hset.bind(e);e.hset=function(o,s){let a=[o];for(let[l,c]of Object.entries(s))a.push(l,c);return r(...a),e};let i=e.hscan.bind(e);e.hscan=function(o,s,a){return a?.COUNT!=null?i(o,s,"COUNT",a.COUNT):i(o,s),e};let n=e.sscan.bind(e);return e.sscan=function(o,s,a){return a?.COUNT!=null?n(o,s,"COUNT",a.COUNT):n(o,s),e},e}function oce(t){return!t||typeof t!="object"?!1:t.__bullmq_iredis===!0?!0:typeof t.runCommand=="function"&&typeof t.defineCommand=="function"&&typeof t.pipeline=="function"&&typeof t.multi=="function"&&typeof t.duplicate=="function"&&typeof t.scanStream=="function"&&typeof t.connect=="function"&&typeof t.disconnect=="function"&&typeof t.on=="function"&&typeof t.status=="string"&&typeof t.isCluster=="boolean"}});var mu=h(_h=>{"use strict";Object.defineProperty(_h,"__esModule",{value:!0});_h.RedisConnection=void 0;var sce=(Zt(),Jt(Wt)),ace=U("events"),gF=yJ(),bF=bt(),Sr=Or(),lce=tm(),cce=mF(),lx=pu(),cx=_a(),uce=["BullMQ: WARNING! Your redis options maxRetriesPerRequest must be null","and will be overridden by BullMQ."].join(" "),dce="BullMQ: Your redis options maxRetriesPerRequest must be null.",Ih=Symbol("bullmqClusterReconnectPromise"),ux=Symbol("bullmqClusterPatchedForBlocking"),kh=Symbol("bullmqClusterOriginalBzpopmin"),dx=Symbol("bullmqClusterWrappedBzpopmin"),Va=Symbol("bullmqClusterPatchRefCount"),is=Symbol("bullmqClusterClosingRefCount"),vF=3e4,fu=class t extends ace.EventEmitter{constructor(e,r){if(super(),this.extraOptions=r,this.capabilities={canDoubleTimeout:!1,canBlockFor1Ms:!0},this.status="initializing",this.dbType="redis",this.packageVersion=lce.version,this.disabledBlockingClusterReconnect=!1,this.extraOptions=Object.assign({shared:!1,blocking:!0,skipVersionCheck:!1,skipWaitingForReady:!1,clusterReconnectTimeoutMs:vF},r),!(0,Sr.isRedisInstance)(e))this.checkBlockingOptions(uce,e),this.opts=Object.assign({port:6379,host:"127.0.0.1",retryStrategy:function(i){return Math.max(Math.min(Math.exp(i),2e4),1e3)}},e),this.extraOptions.blocking&&(this.opts.maxRetriesPerRequest=null);else{if(this._client=(0,lx.isIRedisClient)(e)?e:(0,lx.createIORedisClient)(e),this._client.options.keyPrefix)throw new Error("BullMQ: ioredis does not support ioredis prefixes, use the prefix option instead.");this._client.isCluster?this.opts=this._client.options.redisOptions:this.opts=this._client.options,this.checkBlockingOptions(dce,this.opts,!0)}this.skipVersionCheck=r?.skipVersionCheck||!!(this.opts&&this.opts.skipVersionCheck),this.handleClientError=i=>{this.emit("error",i)},this.handleClientClose=()=>{this.emit("close")},this.handleClientReady=()=>{this.emit("ready")},this.initializing=this.init(),this.initializing.catch(i=>this.emit("error",i))}checkBlockingOptions(e,r,i=!1){if(this.extraOptions.blocking&&r&&r.maxRetriesPerRequest){if(i)throw new Error(e);console.error(e)}}static async waitUntilReady(e){if(e.status==="ready"||e.status==="connect"&&(0,Sr.isRedisCluster)(e))return;if(e.status==="wait")return e.connect();if(e.status==="end")throw new cx.ConnectionClosedError(bF.CONNECTION_CLOSED_ERROR_MSG);let r,i,n;try{await new Promise((o,s)=>{let a;n=l=>{a=l},r=()=>{o()},i=()=>{e.status!=="end"?s(a||new cx.ConnectionClosedError(bF.CONNECTION_CLOSED_ERROR_MSG)):a?s(a):o()},(0,Sr.increaseMaxListeners)(e,3),e.once("ready",r),e.on("end",i),e.once("error",n)})}finally{e.removeListener("end",i),e.removeListener("error",n),e.removeListener("ready",r),(0,Sr.decreaseMaxListeners)(e,3)}}get client(){return this.initializing}loadCommands(e,r){let i=r||cce;for(let n in i){let o=`${i[n].name}:${e}`;this._client[o]||this._client.defineCommand(o,{numberOfKeys:i[n].keys,lua:i[n].content})}}async init(){if(!this._client)if(t.clientFactory)this._client=t.clientFactory(this.opts);else{let e=this.opts,{url:r}=e,i=sce.__rest(e,["url"]),n=r?new gF.default(r,i):new gF.default(i);this._client=(0,lx.createIORedisClient)(n)}if((0,Sr.increaseMaxListeners)(this._client,3),this._client.on("error",this.handleClientError),this._client.on("close",this.handleClientClose),this._client.on("ready",this.handleClientReady),this.patchBlockingClusterClient(),this.extraOptions.skipWaitingForReady||await t.waitUntilReady(this._client),this.loadCommands(this.packageVersion),this._client.status!=="end"){let e=await this.getRedisVersionAndType();if(this.version=e.version,this.dbType=e.databaseType,this.skipVersionCheck!==!0&&!this.closing){if((0,Sr.isRedisVersionLowerThan)(this.version,t.minimumVersion,this.dbType))throw new Error(`Redis version needs to be greater or equal than ${t.minimumVersion} Current: ${this.version}`);(0,Sr.isRedisVersionLowerThan)(this.version,t.recommendedMinimumVersion,this.dbType)&&console.warn(`It is highly recommended to use a minimum Redis version of ${t.recommendedMinimumVersion}
9951
- Current: ${this.version}`)}this.capabilities={canDoubleTimeout:!(0,Sr.isRedisVersionLowerThan)(this.version,"6.0.0",this.dbType),canBlockFor1Ms:!(0,Sr.isRedisVersionLowerThan)(this.version,"7.0.8",this.dbType)},this.status="ready"}return this._client}patchBlockingClusterClient(){var e;let r=this._client,i=r;if(!this.extraOptions.blocking||!(0,Sr.isRedisCluster)(r)||typeof i.bzpopmin!="function")return;let n=(e=this.extraOptions.clusterReconnectTimeoutMs)!==null&&e!==void 0?e:vF;if(i[Va]=(i[Va]||0)+1,this.patchedBlockingClusterClient=i,i[ux])return;let o=i.bzpopmin,s=async(...a)=>{await t.reconnectClusterIfNeeded(i,n);try{return await o.apply(i,a)}catch(l){let c=l;if(t.shouldReconnectClusterAfterError(i,c))try{await t.reconnectCluster(i,n)}catch{}throw c}};i[kh]=o,i[dx]=s,i[ux]=!0,i.bzpopmin=s}disableBlockingClusterReconnect(){let e=this.patchedBlockingClusterClient;!e||this.disabledBlockingClusterReconnect||(e[is]=(e[is]||0)+1,this.disabledBlockingClusterReconnect=!0)}releaseBlockingClusterClientPatch(){let e=this.patchedBlockingClusterClient;if(!e)return;if(this.disabledBlockingClusterReconnect){let i=(e[is]||1)-1;i>0?e[is]=i:delete e[is],this.disabledBlockingClusterReconnect=!1}let r=(e[Va]||1)-1;if(r>0){e[Va]=r,this.patchedBlockingClusterClient=void 0;return}e[kh]&&e.bzpopmin===e[dx]&&(e.bzpopmin=e[kh]),delete e[Va],delete e[is],delete e[kh],delete e[dx],delete e[ux],this.patchedBlockingClusterClient=void 0}static isClusterWithEmptyNodes(e){return typeof e.nodes=="function"&&e.nodes().length===0}static isReconnectingDisabled(e){let r=e[Va]||0,i=e[is]||0;return r===0||i>=r||e.status==="end"||e.status==="closing"}static async reconnectClusterIfNeeded(e,r){!t.isReconnectingDisabled(e)&&t.isClusterWithEmptyNodes(e)&&await t.reconnectCluster(e,r)}static shouldReconnectClusterAfterError(e,r){var i,n;if(t.isReconnectingDisabled(e))return!1;let o=[r.message,(i=r.cause)===null||i===void 0?void 0:i.message,(n=r.lastNodeError)===null||n===void 0?void 0:n.message].join(" ");return t.isClusterWithEmptyNodes(e)||/Command timed out|Failed to refresh slots cache/i.test(o)}static async reconnectCluster(e,r){t.isReconnectingDisabled(e)||(e[Ih]||(e[Ih]=t.connectClusterWithTimeout(e,r).finally(()=>{e[Ih]=null})),await e[Ih])}static async connectClusterWithTimeout(e,r){e.disconnect(!1);let i;try{await Promise.race([e.connect(),new Promise((n,o)=>{var s;i=setTimeout(()=>{o(new cx.ConnectionClosedError(`BullMQ: cluster reconnect timed out after ${r}ms`))},r),(s=i.unref)===null||s===void 0||s.call(i)})])}finally{i&&clearTimeout(i)}}async disconnect(e=!0){let r=await this.client;if(r.status!=="end"){let i,n;if(!e)return r.disconnect();let o=new Promise((s,a)=>{(0,Sr.increaseMaxListeners)(r,2),r.once("end",s),r.once("error",a),i=s,n=a});r.disconnect();try{await o}finally{(0,Sr.decreaseMaxListeners)(r,2),r.removeListener("end",i),r.removeListener("error",n)}}}async reconnect(){return(await this.client).connect()}async close(e=!1){var r;if(!this.closing){let i=this.status;this.status="closing",this.closing=!0,this.disableBlockingClusterReconnect();try{i==="ready"&&await this.initializing,this.extraOptions.shared||(i=="initializing"||e?(this._client.disconnect(),(r=this.initializing)===null||r===void 0||r.catch(()=>{})):await this._client.quit(),this._client.status="end")}catch(n){if((0,Sr.isNotConnectionError)(n))throw n}finally{this.releaseBlockingClusterClientPatch(),this._client.off("error",this.handleClientError),this._client.off("close",this.handleClientClose),this._client.off("ready",this.handleClientReady),(0,Sr.decreaseMaxListeners)(this._client,3),this.removeAllListeners(),this.status="closed"}}}async getRedisVersionAndType(){if(this.skipVersionCheck)return{version:t.minimumVersion,databaseType:"redis"};let e=await this._client.info(),r="redis_version:",i="maxmemory_policy:",n=e.split(/\r?\n/),o,s="redis";for(let a=0;a<n.length;a++){let l=n[a];if(l.includes("dragonfly_version:")||l.includes("server:Dragonfly")?(s="dragonfly",l.indexOf("dragonfly_version:")===0&&(o=l.substr(18))):l.includes("valkey_version:")||l.includes("server:Valkey")?(s="valkey",l.indexOf("valkey_version:")===0&&(o=l.substr(15))):l.indexOf(r)===0&&(o=l.substr(r.length),s==="redis"&&(s="redis")),l.indexOf(i)===0){let c=l.substr(i.length);c!=="noeviction"&&console.warn(`IMPORTANT! Eviction policy is ${c}. It should be "noeviction"`)}}if(!o){for(let a of n)if(a.includes("version:")){let l=a.split(":");if(l.length>=2){o=l[1];break}}}return{version:o||t.minimumVersion,databaseType:s}}get redisVersion(){return this.version}get databaseType(){return this.dbType}};_h.RedisConnection=fu;fu.minimumVersion="5.0.0";fu.recommendedMinimumVersion="6.2.0"});var SF=h(Ch=>{"use strict";Object.defineProperty(Ch,"__esModule",{value:!0});Ch.FlowProducer=void 0;var pce=U("events"),no=Or(),fce=Pa(),Th=sm(),mce=mu(),qn=gr(),px=class extends pce.EventEmitter{constructor(e={connection:{}},r=mce.RedisConnection){super(),this.opts=e,this.opts=Object.assign({prefix:"bull"},e),this.connection=new r(e.connection,{shared:(0,no.isRedisInstance)(e.connection),blocking:!1,skipVersionCheck:e.skipVersionCheck,skipWaitingForReady:e.skipWaitingForReady}),this.connection.on("error",i=>this.emit("error",i)),this.connection.on("close",()=>{this.closing||this.emit("ioredis:close")}),this.queueKeys=new Th.QueueKeys(e.prefix),e?.telemetry&&(this.telemetry=e.telemetry)}emit(e,...r){return super.emit(e,...r)}off(e,r){return super.off(e,r),this}on(e,r){return super.on(e,r),this}once(e,r){return super.once(e,r),this}get client(){return this.connection.client}get Job(){return fce.Job}waitUntilReady(){return this.client}async add(e,r){var i;if(this.closing)return;let o=(await this.connection.client).multi(),s=(i=e?.opts)===null||i===void 0?void 0:i.parent,a=(0,no.getParentKey)(s),l=a?`${a}:dependencies`:void 0;return(0,no.trace)(this.telemetry,qn.SpanKind.PRODUCER,e.queueName,"addFlow",e.queueName,async c=>{c?.setAttributes({[qn.TelemetryAttributes.FlowName]:e.name});let u=await this.addNode({multi:o,node:e,queuesOpts:r?.queuesOptions,parent:{parentOpts:s,parentDependenciesKey:l}}),d=await o.exec(),[f]=d||[];if(f){let[p,m]=f;if(p)throw p;if(typeof m=="number"&&m<0)throw this.toFlowError(m,a);typeof m=="string"&&(u.job.id=m)}return u})}async getFlow(e){if(this.closing)return;let r=await this.connection.client,i=Object.assign({depth:10,maxChildren:20,prefix:this.opts.prefix},e);return this.getNode(r,i)}async addBulk(e){if(this.closing)return;let i=(await this.connection.client).multi();return(0,no.trace)(this.telemetry,qn.SpanKind.PRODUCER,"","addBulkFlows","",async n=>{n?.setAttributes({[qn.TelemetryAttributes.BulkCount]:e.length,[qn.TelemetryAttributes.BulkNames]:e.map(a=>a.name).join(",")});let o=await this.addNodes(i,e),s=await i.exec();for(let a=0;a<o.length;++a){let l=s?.[a];if(!l)continue;let[c,u]=l;!c&&typeof u=="string"&&(o[a].job.id=u)}return o})}async addNode({multi:e,node:r,parent:i,queuesOpts:n}){var o,s;let a=r.prefix||this.opts.prefix,l=this.queueFromNode(r,new Th.QueueKeys(a),a),c=n&&n[r.queueName],u=(o=c?.defaultJobOptions)!==null&&o!==void 0?o:{},d=((s=r.opts)===null||s===void 0?void 0:s.jobId)||(0,no.randomUUID)();return(0,no.trace)(this.telemetry,qn.SpanKind.PRODUCER,r.queueName,"addNode",r.queueName,async(f,p)=>{var m,y;f?.setAttributes({[qn.TelemetryAttributes.JobName]:r.name,[qn.TelemetryAttributes.JobId]:d});let w=r.opts,_=w?.telemetry;if(p&&w){let C=(m=w.telemetry)===null||m===void 0?void 0:m.omitContext,$=((y=w.telemetry)===null||y===void 0?void 0:y.metadata)||!C&&p;($||C)&&(_={metadata:$,omitContext:C})}let A=new this.Job(l,r.name,r.data,Object.assign(Object.assign(Object.assign({},u),w),{parent:i?.parentOpts,telemetry:_}),d),O=(0,no.getParentKey)(i?.parentOpts);if(r.children&&r.children.length>0){let C=d,$=new Th.QueueKeys(r.prefix||this.opts.prefix);await A.addJob(e,{parentDependenciesKey:i?.parentDependenciesKey,addToWaitingChildren:!0,parentKey:O});let re=`${$.toKey(r.queueName,C)}:dependencies`,pe=await this.addChildren({multi:e,nodes:r.children,parent:{parentOpts:{id:C,queue:$.getQueueQualifiedName(r.queueName)},parentDependenciesKey:re},queuesOpts:n});return{job:A,children:pe}}else return await A.addJob(e,{parentDependenciesKey:i?.parentDependenciesKey,parentKey:O}),{job:A}})}addNodes(e,r){return Promise.all(r.map(i=>{var n;let o=(n=i?.opts)===null||n===void 0?void 0:n.parent,s=(0,no.getParentKey)(o),a=s?`${s}:dependencies`:void 0;return this.addNode({multi:e,node:i,parent:{parentOpts:o,parentDependenciesKey:a}})}))}async getNode(e,r){let i=this.queueFromNode(r,new Th.QueueKeys(r.prefix),r.prefix),n=await this.Job.fromId(i,r.id);if(n){let{processed:o={},unprocessed:s=[],failed:a=[],ignored:l={}}=await n.getDependencies({failed:{count:r.maxChildren},processed:{count:r.maxChildren},unprocessed:{count:r.maxChildren},ignored:{count:r.maxChildren}}),c=Object.keys(o),u=Object.keys(l),d=c.length+s.length+u.length+a.length,f=r.depth-1;if(d>0&&f){let p=await this.getChildren(e,[...c,...s,...a,...u],f,r.maxChildren);return{job:n,children:p}}else return{job:n}}}addChildren({multi:e,nodes:r,parent:i,queuesOpts:n}){return Promise.all(r.map(o=>this.addNode({multi:e,node:o,parent:i,queuesOpts:n})))}getChildren(e,r,i,n){let o=s=>{let[a,l,c]=s.split(":");return this.getNode(e,{id:c,queueName:l,prefix:a,depth:i,maxChildren:n})};return Promise.all([...r.map(o)])}queueFromNode(e,r,i){return{client:this.connection.client,name:e.queueName,keys:r.getKeys(e.queueName),toKey:n=>r.toKey(e.queueName,n),opts:{prefix:i,connection:{}},qualifiedName:r.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,databaseType:this.connection.databaseType,trace:async()=>{}}}toFlowError(e,r){let i;switch(e){case qn.ErrorCode.ParentJobNotExist:i=new Error(`Missing key for parent job ${r}. addJob`);break;case qn.ErrorCode.ParentJobCannotBeReplaced:i=new Error(`The parent job ${r} cannot be replaced. addJob`);break;default:i=new Error(`Unknown code ${e} error for addJob`)}return i.code=e,i}async close(){this.closing||(this.closing=this.connection.close()),await this.closing}disconnect(){return this.connection.disconnect()}};Ch.FlowProducer=px});var wF=h(hx=>{"use strict";Object.defineProperty(hx,"__esModule",{value:!0});hx.createNodeRedisClient=vce;var hce=(Zt(),Jt(Wt)),yce=U("crypto"),gce=U("events"),bce=U("stream"),Oh=_a();function EF(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function zn(t){return t?.message==="Disconnects client"||t?.message==="The client is closed"||t?.message==="Connection is closed."}function vce(t){return new fx(t)}var fx=class t extends gce.EventEmitter{get status(){return this.statusOverride?this.statusOverride:this.raw.isReady?"ready":this.raw.isOpen?"connect":this.hasConnected?"end":"wait"}set status(e){if(e==="end"&&(this.destroying=!0,this.raw.isOpen))try{this.raw.quit().catch(()=>{})}catch{}this.statusOverride=e}get options(){var e;return(e=this.raw.options)!==null&&e!==void 0?e:{}}set options(e){}constructor(e){super(),this.raw=e,this.scripts=new Map,this.hasConnected=!1,this.destroying=!1,this.isCluster=!1,e.on("ready",()=>{this.hasConnected=!0,this.connectionName?this.raw.clientSetName(this.connectionName).then(()=>this.emit("ready"),()=>this.emit("ready")):this.emit("ready")}),e.on("error",r=>{this.destroying&&zn(r)||this.emit("error",r)}),e.on("end",()=>this.emit("close")),e.on("reconnecting",()=>this.emit("reconnecting")),e.isOpen||(this.connectPromise=e.connect().then(()=>{this.connectPromise=void 0},r=>{this.connectPromise=void 0}))}async connect(){if(this.connectPromise)return this.connectPromise;if(!this.raw.isOpen)return this.connectPromise=this.raw.connect().then(()=>{this.connectPromise=void 0},e=>{throw this.connectPromise=void 0,e}),this.connectPromise;this.raw.isReady||await new Promise((e,r)=>{let i=()=>{s(),e()},n=a=>{s(),r(a)},o=()=>{s(),r(new Error("Connection ended before ready event"))},s=()=>{this.off("ready",i),this.off("error",n),this.off("end",o)};this.once("ready",i),this.once("error",n),this.once("end",o)})}disconnect(e=!1){this.destroying=!0,e||(this.statusOverride="end");try{this.raw.isOpen&&this.raw.destroy()}catch{}this.emit("close"),e?(this.statusOverride=void 0,this.emit("reconnecting"),this.connect().catch(r=>{zn(r)||this.emit("error",r)}).finally(()=>{this.destroying=!1})):this.emit("end")}async quit(){if(this.destroying||this.statusOverride==="end")return setImmediate(()=>{this.emit("end"),this.emit("close")}),"OK";this.destroying=!0;try{if(this.raw.isOpen)try{await this.raw.quit()}catch{}}catch{}return this.statusOverride="end",setImmediate(()=>{this.emit("end"),this.emit("close")}),"OK"}duplicate(...e){let r=this.raw.duplicate(),i=new t(r);for(let[o,s]of this.scripts)i.scripts.set(o,s),i[o]=(...a)=>i.runCommand(o,a);let n=e[0];return n&&typeof n=="object"&&n.connectionName&&(i.connectionName=n.connectionName),i}defineCommand(e,r){let i=(0,yce.createHash)("sha1").update(r.lua).digest("hex");this.scripts.set(e,{sha:i,lua:r.lua,numberOfKeys:r.numberOfKeys}),this[e]=(...n)=>this.runCommand(e,n),this.raw.scriptLoad(r.lua).catch(()=>{})}async runCommand(e,r){var i,n;let o=this.scripts.get(e);if(!o)throw new Error(`BullMQ: unknown command "${e}"`);let s=EF(r),{sha:a,lua:l,numberOfKeys:c}=o,u=s.slice(0,c).map(String),d=s.slice(c).map(f=>Buffer.isBuffer(f)?f:f==null?"":String(f));try{return await this.raw.evalSha(a,{keys:u,arguments:d})}catch(f){if(this.destroying&&zn(f))return null;if(zn(f))throw new Oh.ConnectionClosedError(f.message,f);if(!((n=(i=f?.message)===null||i===void 0?void 0:i.includes)===null||n===void 0)&&n.call(i,"NOSCRIPT"))try{return await this.raw.eval(l,{keys:u,arguments:d})}catch(p){if(this.destroying&&zn(p))return null;throw zn(p)?new Oh.ConnectionClosedError(p.message,p):p}throw f}}multi(){return new mx(this.raw.multi(),this.scripts)}pipeline(){return this.multi()}async hgetall(e){let r=await this.raw.hGetAll(e);return r??{}}async hget(e,r){var i;return(i=await this.raw.hGet(e,r))!==null&&i!==void 0?i:null}async hmget(e,...r){return(await this.raw.hmGet(e,r)).map(n=>n??null)}async hset(e,r,...i){if(typeof r=="object")return await this.raw.hSet(e,r);let n={};n[r]=String(i[0]);for(let o=1;o<i.length;o+=2)n[String(i[o])]=String(i[o+1]);return await this.raw.hSet(e,n)}async hdel(e,...r){return await this.raw.hDel(e,r)}async hexists(e,r){return await this.raw.hExists(e,r)?1:0}async get(e){var r;return(r=await this.raw.get(e))!==null&&r!==void 0?r:null}async set(e,r,i){let n={};return i?.PX!=null?n.PX=i.PX:i?.EX!=null&&(n.EX=i.EX),await this.raw.set(e,String(r),n)}async del(...e){return e.length===0?0:await this.raw.del(e)}async zrange(e,r,i,n){if(n?.WITHSCORES){let o=await this.raw.zRangeWithScores(e,r,i),s=[];for(let a of o)s.push(a.value,String(a.score));return s}return await this.raw.zRange(e,r,i)}async zrevrange(e,r,i,n){if(n?.WITHSCORES){let o=await this.raw.zRangeWithScores(e,r,i,{REV:!0}),s=[];for(let a of o)s.push(a.value,String(a.score));return s}return await this.raw.zRange(e,r,i,{REV:!0})}async zcard(e){return await this.raw.zCard(e)}async zscore(e,r){let i=await this.raw.zScore(e,r);return i!=null?String(i):null}async lrange(e,r,i){return await this.raw.lRange(e,r,i)}async llen(e){return await this.raw.lLen(e)}async ltrim(e,r,i){return await this.raw.lTrim(e,r,i),"OK"}async lpos(e,r){var i;return(i=await this.raw.lPos(e,r))!==null&&i!==void 0?i:null}async smembers(e){return await this.raw.sMembers(e)}async xadd(e,r,i,n){let o={};n?.MAXLEN!=null&&(o.TRIM={strategy:"MAXLEN",threshold:n.MAXLEN,strategyModifier:n.approximate===!1?void 0:"~"});let s={};for(let[a,l]of Object.entries(i))s[a]=String(l);return await this.raw.xAdd(e,r,s,o)}async xread(e,r){let i={};r?.BLOCK!=null&&(i.BLOCK=r.BLOCK),r?.COUNT!=null&&(i.COUNT=r.COUNT);let n=e.map(s=>({key:s.key,id:s.id})),o;try{o=await this.raw.xRead(n,i)}catch(s){if(this.destroying&&zn(s))return null;throw zn(s)?new Oh.ConnectionClosedError(s.message,s):s}return o?o.map(s=>[s.name,s.messages.map(a=>[a.id,Object.entries(a.message).flat()])]):null}async xtrim(e,r,i,n){let o=n?.approximate===!1?void 0:"~";return await this.raw.xTrim(e,r,i,{strategyModifier:o})}async bzpopmin(e,r){let i;try{i=await this.raw.bzPopMin(e,r)}catch(n){if(this.destroying&&zn(n))return null;throw zn(n)?new Oh.ConnectionClosedError(n.message,n):n}return i?[i.key,i.value,String(i.score)]:null}async info(){return await this.raw.info()}async clientSetName(e){return await this.raw.clientSetName(e)}async clientList(){return await this.raw.sendCommand(["CLIENT","LIST"])}async scan(e,r){let i={};r?.MATCH&&(i.MATCH=r.MATCH),r?.COUNT&&(i.COUNT=r.COUNT);let n=await this.raw.scan(String(e),i);return[String(n.cursor),n.keys]}scanStream(e){let r=this.raw,i=this.connectPromise,n={};e.match&&(n.MATCH=e.match),e.count&&(n.COUNT=e.count);let o=new bce.Readable({objectMode:!0,async read(){var s,a,l,c;try{i&&await i;try{for(var u=!0,d=hce.__asyncValues(r.scanIterator(n)),f;f=await d.next(),s=f.done,!s;u=!0){c=f.value,u=!1;let p=c;if(!o.push(Array.isArray(p)?p:[p]))return}}catch(p){a={error:p}}finally{try{!u&&!s&&(l=d.return)&&await l.call(d)}finally{if(a)throw a.error}}o.push(null)}catch(p){o.destroy(p)}}});return o}async keys(e){return await this.raw.keys(e)}async exists(...e){return e.length===0?0:await this.raw.exists(e)}async zadd(e,...r){let i=[];for(let n=0;n<r.length;n+=2)i.push({score:Number(r[n]),value:String(r[n+1])});return await this.raw.zAdd(e,i)}async zrem(e,...r){return await this.raw.zRem(e,r)}async xlen(e){return await this.raw.xLen(e)}async xrevrange(e,r,i,...n){let o={};return n[0]==="COUNT"&&(o.COUNT=Number(n[1])),(await this.raw.xRevRange(e,r,i,o)).map(a=>[a.id,Object.entries(a.message).flat()])}async sadd(e,...r){return await this.raw.sAdd(e,r.map(String))}async scard(e){return await this.raw.sCard(e)}async lpush(e,...r){return await this.raw.lPush(e,r)}async rpop(e){return await this.raw.rPop(e)}async incr(e){return await this.raw.incr(e)}async incrby(e,r){return await this.raw.incrBy(e,r)}async flushall(){return await this.raw.flushAll()}},mx=class{constructor(e,r){this.raw=e,this.scripts=r,this.transformers=[]}addIdentityTransformer(){this.transformers.push(e=>e)}hgetall(e){return this.raw.hGetAll(e),this.addIdentityTransformer(),this}hset(e,r){return this.raw.hSet(e,r),this.addIdentityTransformer(),this}hscan(e,r,i){let n={};return i?.COUNT!=null&&(n.COUNT=i.COUNT),this.raw.hScan(e,String(r),n),this.transformers.push(o=>{if(!o)return["0",[]];let s=[];for(let a of o.entries||[])s.push(a.field,a.value);return[String(o.cursor),s]}),this}smembers(e){return this.raw.sMembers(e),this.addIdentityTransformer(),this}sscan(e,r,i){let n={};return i?.COUNT!=null&&(n.COUNT=i.COUNT),this.raw.sScan(e,String(r),n),this.transformers.push(o=>o?[String(o.cursor),o.members||[]]:["0",[]]),this}zrange(e,r,i){return this.raw.zRange(e,r,i),this.addIdentityTransformer(),this}lrange(e,r,i){return this.raw.lRange(e,r,i),this.addIdentityTransformer(),this}llen(e){return this.raw.lLen(e),this.addIdentityTransformer(),this}del(...e){return e.length>0&&(this.raw.del(e),this.addIdentityTransformer()),this}runCommand(e,r){let i=this.scripts.get(e);if(!i)throw new Error(`BullMQ: unknown command "${e}" in transaction`);let n=EF(r),{sha:o,lua:s,numberOfKeys:a}=i,l=n.slice(0,a).map(String),c=n.slice(a).map(u=>Buffer.isBuffer(u)?u:u==null?"":String(u));return this.raw.evalSha(o,{keys:l,arguments:c}),this.addIdentityTransformer(),this}async exec(){let e=await this.raw.exec();return e?e.map((r,i)=>{if(r instanceof Error)return[r,null];let n=this.transformers[i];return[null,n?n(r):r]}):null}}});var kF=h(gx=>{"use strict";Object.defineProperty(gx,"__esModule",{value:!0});gx.createBunRedisClient=Ice;var Sce=U("crypto"),Ece=U("events"),wce=U("stream"),xF=_a();function IF(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function xce(t){var e;let r=(e=t?.message)!==null&&e!==void 0?e:"";return r==="Socket closed unexpectedly"||r.startsWith("Connection closed")||r==="Connection is closed."||r==="Connection has failed"}function Ah(t){return t==null?[]:Array.isArray(t)?t.map(String):t instanceof Set?Array.from(t,e=>String(e)):[]}function Ice(t,e){return new yx(t,e)}var yx=class t extends Ece.EventEmitter{get status(){return this.statusOverride?this.statusOverride:this.closed?"end":this.raw.connected?"ready":this.hasConnected?"end":"wait"}set status(e){e==="end"&&(this.closing=!0,this.closed=!0),this.statusOverride=e}get options(){return{}}set options(e){}constructor(e,r){super(),this.raw=e,this.scripts=new Map,this.loadedScriptShas=new Set,this.hasConnected=!1,this.closed=!1,this.closing=!1,this.reconnecting=!1,this.reconnectTimer=null,this.reconnectAttempts=0,this.maxReconnectDelay=2e4,this.isCluster=!1,this._setupCallbacks(),r?.lazyConnect||this.connect().catch(()=>{})}_setupCallbacks(){this.raw.onconnect=()=>{this.hasConnected=!0,this.closed=!1,this.closing=!1,this.reconnecting=!1,this.reconnectAttempts=0,this.statusOverride=void 0,this.loadedScriptShas.clear(),this.connectionName?this.clientSetName(this.connectionName).then(()=>this.emit("ready"),()=>this.emit("ready")):this.emit("ready")},this.raw.onclose=e=>{if(this.closing){this.closed=!0,this.emit("close"),this.emit("end");return}this.closed=!0,this.emit("close"),e&&this.emit("error",e),this._scheduleReconnect()}}_scheduleReconnect(){if(this.closing||this.reconnecting)return;this.reconnecting=!0,this.reconnectAttempts++;let e=Math.max(Math.min(Math.exp(this.reconnectAttempts)*100,this.maxReconnectDelay),1e3);this.reconnectTimer=setTimeout(async()=>{if(this.reconnectTimer=null,this.closing){this.reconnecting=!1;return}try{let r=this.raw.constructor,i=new r(this.raw.url);this.raw=i,this.closed=!1,this.connecting=void 0,this._setupCallbacks(),await i.connect()}catch{this.reconnecting=!1,this.closing||this._scheduleReconnect()}},e)}async connect(){if(this.raw.connected){this.hasConnected=!0,this.closed=!1,this.closing=!1,this.statusOverride=void 0;return}if(!this.connecting){if(this.closed=!1,this.closing=!1,this.statusOverride=void 0,this.hasConnected&&!this.raw.connected){let e=this.raw.constructor;this.raw=new e(this.raw.url),this._setupCallbacks()}this.connecting=this.raw.connect().then(()=>{this.hasConnected=!0,this.closed=!1,this.closing=!1,this.statusOverride=void 0}).finally(()=>{this.connecting=void 0})}await this.connecting}_closeRaw(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnecting=!1;let e=this.raw;e.onconnect=()=>{},e.onclose=()=>{},e.onerror=()=>{},e.connected&&setImmediate(()=>{try{e.connected&&e.close()}catch{}})}disconnect(e){if(!(this.closed&&!e))if(e){this.closed=!0,this.statusOverride=void 0;let r=this.raw;r.onclose=()=>{},r.connected&&setImmediate(()=>{try{r.connected&&r.close()}catch{}}),this.emit("close"),this._scheduleReconnect()}else this.closing=!0,this.closed=!0,this.statusOverride="end",this._closeRaw(),this.emit("close"),this.emit("end")}async quit(){return this.closed?(setImmediate(()=>{this.emit("end"),this.emit("close")}),"OK"):(this.closing=!0,this.closed=!0,this.statusOverride="end",this._closeRaw(),setImmediate(()=>{this.emit("end"),this.emit("close")}),"OK")}duplicate(...e){let r=this.raw.constructor,i=new r(this.raw.url),n=new t(i);for(let[s,a]of this.scripts)n.scripts.set(s,a),n[s]=(...l)=>n.runCommand(s,l);let o=e[0];return o&&typeof o=="object"&&o.connectionName&&(n.connectionName=o.connectionName),n}defineCommand(e,r){let i=(0,Sce.createHash)("sha1").update(r.lua).digest("hex");this.scripts.set(e,{sha:i,lua:r.lua,numberOfKeys:r.numberOfKeys}),this[e]=(...n)=>this.runCommand(e,n)}async runCommand(e,r){let i=this.scripts.get(e);if(!i)throw new Error(`BullMQ: unknown command "${e}"`);let n=IF(r),{sha:o,lua:s,numberOfKeys:a}=i,l=n.slice(0,a).map(String),c=n.slice(a).map(f=>Buffer.isBuffer(f)?f:f==null?"":String(f)),u=[o,String(l.length),...l,...c];return(async()=>{var f,p;try{let m=await this.sendCommand("EVALSHA",u);return this.loadedScriptShas.add(o),m}catch(m){if(!((p=(f=m?.message)===null||f===void 0?void 0:f.includes)===null||p===void 0)&&p.call(f,"NOSCRIPT")){let y=[s,String(l.length),...l,...c],w=await this.sendCommand("EVAL",y);return this.loadedScriptShas.add(o),w}throw m}})()}async ensureScriptsLoaded(e){let r=[],i=new Set;for(let n of e)this.loadedScriptShas.has(n.sha)||i.has(n.sha)||(i.add(n.sha),r.push(n));r.length!==0&&await Promise.all(r.map(async n=>{await this.sendCommand("SCRIPT",["LOAD",n.lua]),this.loadedScriptShas.add(n.sha)}))}sendCommand(e,r){return this.closing||this.closed?Promise.reject(new xF.ConnectionClosedError("Connection is closed")):this.raw.send(e,r).catch(i=>{if(xce(i))return Promise.reject(new xF.ConnectionClosedError(this.closing||this.closed?"Connection is closed":i.message,i));throw i})}multi(){return new Kh(this.raw,this.scripts,!0,this)}pipeline(){return new Kh(this.raw,this.scripts,!1,this)}async hgetall(e){let r=await this.sendCommand("HGETALL",[e]);if(!r||Array.isArray(r)&&r.length===0)return{};if(Array.isArray(r)){let i={};for(let n=0;n<r.length;n+=2)i[String(r[n])]=String(r[n+1]);return i}return r}async hget(e,r){let i=await this.sendCommand("HGET",[e,r]);return i??null}async hmget(e,...r){return(await this.sendCommand("HMGET",[e,...r])||[]).map(n=>n??null)}async hset(e,r,...i){let n;if(typeof r=="object"){n=[e];for(let[o,s]of Object.entries(r))n.push(o,String(s))}else{n=[e,r,String(i[0])];for(let o=1;o<i.length;o+=2)n.push(String(i[o]),String(i[o+1]))}return await this.sendCommand("HSET",n)}async hdel(e,...r){return await this.sendCommand("HDEL",[e,...r])}async hexists(e,r){let i=await this.sendCommand("HEXISTS",[e,r]);return i===!0||i===1?1:0}async get(e){let r=await this.sendCommand("GET",[e]);return r??null}async set(e,r,i){let n=[e,String(r)];return i?.PX!=null?n.push("PX",String(i.PX)):i?.EX!=null&&n.push("EX",String(i.EX)),await this.sendCommand("SET",n)}async del(...e){return e.length===0?0:await this.sendCommand("DEL",e)}async zrange(e,r,i,n){let o=[e,String(r),String(i)];n?.WITHSCORES&&o.push("WITHSCORES");let s=await this.sendCommand("ZRANGE",o);return s?n?.WITHSCORES&&s.length>0&&Array.isArray(s[0])?s.flatMap(a=>[String(a[0]),String(a[1])]):s.map(String):[]}async zrevrange(e,r,i,n){let o=[e,String(r),String(i)];n?.WITHSCORES&&o.push("WITHSCORES"),o.push("REV");let s=await this.sendCommand("ZRANGE",o);return s?n?.WITHSCORES&&s.length>0&&Array.isArray(s[0])?s.flatMap(a=>[String(a[0]),String(a[1])]):s.map(String):[]}async zcard(e){return await this.sendCommand("ZCARD",[e])}async zscore(e,r){let i=await this.sendCommand("ZSCORE",[e,r]);return i!=null?String(i):null}async lrange(e,r,i){return(await this.sendCommand("LRANGE",[e,String(r),String(i)])||[]).map(String)}async llen(e){return await this.sendCommand("LLEN",[e])}async ltrim(e,r,i){return await this.sendCommand("LTRIM",[e,String(r),String(i)]),"OK"}async lpos(e,r){let i=await this.sendCommand("LPOS",[e,r]);return i??null}async smembers(e){let r=await this.sendCommand("SMEMBERS",[e]);return Ah(r)}async xadd(e,r,i,n){let o=[e];n?.MAXLEN!=null&&(o.push("MAXLEN"),n.approximate!==!1&&o.push("~"),o.push(String(n.MAXLEN))),o.push(r);for(let[s,a]of Object.entries(i))o.push(s,String(a));return await this.raw.send("XADD",o)}async xread(e,r){let i=[];r?.COUNT!=null&&i.push("COUNT",String(r.COUNT)),r?.BLOCK!=null&&i.push("BLOCK",String(r.BLOCK)),i.push("STREAMS");for(let o of e)i.push(o.key);for(let o of e)i.push(o.id);let n;try{n=await this.sendCommand("XREAD",i)}catch(o){if(this.closing)return null;throw o}return n?Array.isArray(n)?n.map(o=>{let s=String(o[0]),a=(o[1]||[]).map(l=>{let c=String(l[0]),u=(l[1]||[]).map(String);return[c,u]});return[s,a]}):Object.entries(n).map(([o,s])=>{let a=(s||[]).map(l=>{let c=String(l[0]),u=(l[1]||[]).map(String);return[c,u]});return[o,a]}):null}async xtrim(e,r,i,n){let o=[e,r];return n?.approximate!==!1&&o.push("~"),o.push(String(i)),await this.sendCommand("XTRIM",o)}async bzpopmin(e,r){let i;try{i=await this.sendCommand("BZPOPMIN",[e,String(r)])}catch(n){if(this.closing)return null;throw n}return!i||i.length===0?null:[String(i[0]),String(i[1]),String(i[2])]}async info(){return await this.sendCommand("INFO",[])}async clientSetName(e){return await this.sendCommand("CLIENT",["SETNAME",e])}async clientList(){return await this.sendCommand("CLIENT",["LIST"])}async scan(e,r){let i=[String(e)];r?.MATCH&&i.push("MATCH",r.MATCH),r?.COUNT&&i.push("COUNT",String(r.COUNT));let n=await this.sendCommand("SCAN",i),o=n[1];return[String(n[0]),Array.isArray(o)?o.map(String):[]]}scanStream(e){let r=this,i="0",n=!1,o=new wce.Readable({objectMode:!0,async read(){if(n&&i==="0"){o.push(null);return}n=!0;try{for(;;){let[s,a]=await r.scan(i,{MATCH:e.match,COUNT:e.count});if(i=s,a.length>0){o.push(a),i==="0"&&o.push(null);return}if(i==="0"){o.push(null);return}}}catch(s){o.destroy(s)}}});return o}async keys(e){return(await this.sendCommand("KEYS",[e])||[]).map(String)}async exists(...e){if(e.length===0)return 0;let r=await this.sendCommand("EXISTS",e);return typeof r=="boolean"?r?1:0:r}async zadd(e,...r){let i=[e];for(let n=0;n<r.length;n+=2)i.push(String(r[n]),String(r[n+1]));return await this.sendCommand("ZADD",i)}async zrem(e,...r){return await this.sendCommand("ZREM",[e,...r])}async xlen(e){return await this.sendCommand("XLEN",[e])}async xrevrange(e,r,i,...n){let o=[e,r,i];n[0]==="COUNT"&&o.push("COUNT",String(n[1]));let s=await this.sendCommand("XREVRANGE",o);return s?s.map(a=>[String(a[0]),(a[1]||[]).map(String)]):[]}async sadd(e,...r){return await this.sendCommand("SADD",[e,...r.map(String)])}async scard(e){return await this.sendCommand("SCARD",[e])}async lpush(e,...r){return await this.sendCommand("LPUSH",[e,...r])}async rpop(e){let r=await this.sendCommand("RPOP",[e]);return r??null}async incr(e){return await this.sendCommand("INCR",[e])}async incrby(e,r){return await this.sendCommand("INCRBY",[e,String(r)])}async flushall(){return await this.sendCommand("FLUSHALL",[])}},Kh=class{constructor(e,r,i,n){this.raw=e,this.scripts=r,this.transactional=i,this.adapter=n,this.commands=[],this.transformers=[],this.scriptsToLoad=[]}addCommand(e,r,i){this.commands.push({cmd:e,args:r}),this.transformers.push(i||(n=>n))}hgetall(e){return this.addCommand("HGETALL",[e],r=>{if(!r||Array.isArray(r)&&r.length===0)return{};if(Array.isArray(r)){let i={};for(let n=0;n<r.length;n+=2)i[String(r[n])]=String(r[n+1]);return i}return r}),this}hset(e,r){let i=[e];for(let[n,o]of Object.entries(r))i.push(n,String(o));return this.addCommand("HSET",i),this}hscan(e,r,i){let n=[e,String(r)];return i?.COUNT!=null&&n.push("COUNT",String(i.COUNT)),this.addCommand("HSCAN",n,o=>o?Array.isArray(o)?[String(o[0]),Ah(o[1])]:["0",[]]:["0",[]]),this}smembers(e){return this.addCommand("SMEMBERS",[e],r=>Ah(r)),this}sscan(e,r,i){let n=[e,String(r)];return i?.COUNT!=null&&n.push("COUNT",String(i.COUNT)),this.addCommand("SSCAN",n,o=>o?Array.isArray(o)?[String(o[0]),Ah(o[1])]:["0",[]]:["0",[]]),this}zrange(e,r,i){return this.addCommand("ZRANGE",[e,String(r),String(i)],n=>Array.isArray(n)?n.map(String):[]),this}lrange(e,r,i){return this.addCommand("LRANGE",[e,String(r),String(i)],n=>Array.isArray(n)?n.map(String):[]),this}llen(e){return this.addCommand("LLEN",[e]),this}del(...e){return e.length>0&&this.addCommand("DEL",e),this}runCommand(e,r){let i=this.scripts.get(e);if(!i)throw new Error(`BullMQ: unknown command "${e}" in transaction`);let n=IF(r),{sha:o,numberOfKeys:s}=i,a=n.slice(0,s).map(String),l=n.slice(s).map(c=>Buffer.isBuffer(c)?c:c==null?"":String(c));return this.scriptsToLoad.push(i),this.addCommand("EVALSHA",[o,String(a.length),...a,...l]),this}async exec(){if(this.commands.length===0)return[];if(this.scriptsToLoad.length>0&&await this.adapter.ensureScriptsLoaded(this.scriptsToLoad),!this.transactional)return(await Promise.allSettled(this.commands.map(({cmd:i,args:n})=>this.adapter.sendCommand(i,n)))).map((i,n)=>{if(i.status==="rejected")return[i.reason,null];let o=this.transformers[n];return[null,o?o(i.value):i.value]});let e=r=>{};try{this.raw.send("MULTI",[]).catch(e);for(let{cmd:i,args:n}of this.commands)this.raw.send(i,n).catch(e);let r=await this.raw.send("EXEC",[]);return r?r.map((i,n)=>{if(i instanceof Error)return[i,null];let o=this.transformers[n];return[null,o?o(i):i]}):null}catch(r){try{await this.raw.send("DISCARD",[])}catch{}throw r}}}});var tq=h(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});var yi=class extends Error{},Tx=class extends yi{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},Cx=class extends yi{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},Ox=class extends yi{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},so=class extends yi{},Uh=class extends yi{constructor(e){super(`Invalid unit ${e}`)}},Dt=class extends yi{},Gn=class extends yi{constructor(){super("Zone is an abstract class")}},q="numeric",En="short",Mr="long",$h={year:q,month:q,day:q},r2={year:q,month:En,day:q},kce={year:q,month:En,day:q,weekday:En},n2={year:q,month:Mr,day:q},i2={year:q,month:Mr,day:q,weekday:Mr},o2={hour:q,minute:q},s2={hour:q,minute:q,second:q},a2={hour:q,minute:q,second:q,timeZoneName:En},l2={hour:q,minute:q,second:q,timeZoneName:Mr},c2={hour:q,minute:q,hourCycle:"h23"},u2={hour:q,minute:q,second:q,hourCycle:"h23"},d2={hour:q,minute:q,second:q,hourCycle:"h23",timeZoneName:En},p2={hour:q,minute:q,second:q,hourCycle:"h23",timeZoneName:Mr},f2={year:q,month:q,day:q,hour:q,minute:q},m2={year:q,month:q,day:q,hour:q,minute:q,second:q},h2={year:q,month:En,day:q,hour:q,minute:q},y2={year:q,month:En,day:q,hour:q,minute:q,second:q},_ce={year:q,month:En,day:q,weekday:En,hour:q,minute:q},g2={year:q,month:Mr,day:q,hour:q,minute:q,timeZoneName:En},b2={year:q,month:Mr,day:q,hour:q,minute:q,second:q,timeZoneName:En},v2={year:q,month:Mr,day:q,weekday:Mr,hour:q,minute:q,timeZoneName:Mr},S2={year:q,month:Mr,day:q,weekday:Mr,hour:q,minute:q,second:q,timeZoneName:Mr},lo=class{get type(){throw new Gn}get name(){throw new Gn}get ianaName(){return this.name}get isUniversal(){throw new Gn}offsetName(e,r){throw new Gn}formatOffset(e,r){throw new Gn}offset(e){throw new Gn}equals(e){throw new Gn}get isValid(){throw new Gn}},bx=null,Su=class t extends lo{static get instance(){return bx===null&&(bx=new t),bx}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:r,locale:i}){return K2(e,r,i)}formatOffset(e,r){return vu(this.offset(e),r)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}},Ax=new Map;function Tce(t){let e=Ax.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),Ax.set(t,e)),e}var Cce={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Oce(t,e){let r=t.format(e).replace(/\u200E/g,""),i=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(r),[,n,o,s,a,l,c,u]=i;return[s,n,o,a,l,c,u]}function Ace(t,e){let r=t.formatToParts(e),i=[];for(let n=0;n<r.length;n++){let{type:o,value:s}=r[n],a=Cce[o];o==="era"?i[a]=s:ie(a)||(i[a]=parseInt(s,10))}return i}var vx=new Map,gi=class t extends lo{static create(e){let r=vx.get(e);return r===void 0&&vx.set(e,r=new t(e)),r}static resetCache(){vx.clear(),Ax.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=t.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:r,locale:i}){return K2(e,r,i,this.name)}formatOffset(e,r){return vu(this.offset(e),r)}offset(e){if(!this.valid)return NaN;let r=new Date(e);if(isNaN(r))return NaN;let i=Tce(this.name),[n,o,s,a,l,c,u]=i.formatToParts?Ace(i,r):Oce(i,r);a==="BC"&&(n=-Math.abs(n)+1);let f=Bh({year:n,month:o,day:s,hour:l===24?0:l,minute:c,second:u,millisecond:0}),p=+r,m=p%1e3;return p-=m>=0?m:1e3+m,(f-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}},_F={};function Kce(t,e={}){let r=JSON.stringify([t,e]),i=_F[r];return i||(i=new Intl.ListFormat(t,e),_F[r]=i),i}var Kx=new Map;function Rx(t,e={}){let r=JSON.stringify([t,e]),i=Kx.get(r);return i===void 0&&(i=new Intl.DateTimeFormat(t,e),Kx.set(r,i)),i}var Dx=new Map;function Rce(t,e={}){let r=JSON.stringify([t,e]),i=Dx.get(r);return i===void 0&&(i=new Intl.NumberFormat(t,e),Dx.set(r,i)),i}var jx=new Map;function Dce(t,e={}){let{base:r,...i}=e,n=JSON.stringify([t,i]),o=jx.get(n);return o===void 0&&(o=new Intl.RelativeTimeFormat(t,e),jx.set(n,o)),o}var yu=null;function jce(){return yu||(yu=new Intl.DateTimeFormat().resolvedOptions().locale,yu)}var Px=new Map;function E2(t){let e=Px.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Px.set(t,e)),e}var Mx=new Map;function Pce(t){let e=Mx.get(t);if(!e){let r=new Intl.Locale(t);e="getWeekInfo"in r?r.getWeekInfo():r.weekInfo,"minimalDays"in e||(e={...w2,...e}),Mx.set(t,e)}return e}function Mce(t){let e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));let r=t.indexOf("-u-");if(r===-1)return[t];{let i,n;try{i=Rx(t).resolvedOptions(),n=t}catch{let l=t.substring(0,r);i=Rx(l).resolvedOptions(),n=l}let{numberingSystem:o,calendar:s}=i;return[n,o,s]}}function Nce(t,e,r){return(r||e)&&(t.includes("-u-")||(t+="-u"),r&&(t+=`-ca-${r}`),e&&(t+=`-nu-${e}`)),t}function Lce(t){let e=[];for(let r=1;r<=12;r++){let i=et.utc(2009,r,1);e.push(t(i))}return e}function Uce(t){let e=[];for(let r=1;r<=7;r++){let i=et.utc(2016,11,13+r);e.push(t(i))}return e}function Rh(t,e,r,i){let n=t.listingMode();return n==="error"?null:n==="en"?r(e):i(e)}function $ce(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||E2(t.locale).numberingSystem==="latn"}var Nx=class{constructor(e,r,i){this.padTo=i.padTo||0,this.floor=i.floor||!1;let{padTo:n,floor:o,...s}=i;if(!r||Object.keys(s).length>0){let a={useGrouping:!1,...i};i.padTo>0&&(a.minimumIntegerDigits=i.padTo),this.inf=Rce(e,a)}}format(e){if(this.inf){let r=this.floor?Math.floor(e):e;return this.inf.format(r)}else{let r=this.floor?Math.floor(e):Wx(e,3);return vt(r,this.padTo)}}},Lx=class{constructor(e,r,i){this.opts=i,this.originalZone=void 0;let n;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){let s=-1*(e.offset/60),a=s>=0?`Etc/GMT+${s}`:`Etc/GMT${s}`;e.offset!==0&&gi.create(a).valid?(n=a,this.dt=e):(n="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,n=e.zone.name):(n="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);let o={...this.opts};o.timeZone=o.timeZone||n,this.dtf=Rx(r,o)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){let e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(r=>{if(r.type==="timeZoneName"){let i=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...r,value:i}}else return r}):e}resolvedOptions(){return this.dtf.resolvedOptions()}},Ux=class{constructor(e,r,i){this.opts={style:"long",...i},!r&&O2()&&(this.rtf=Dce(e,i))}format(e,r){return this.rtf?this.rtf.format(e,r):aue(r,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,r){return this.rtf?this.rtf.formatToParts(e,r):[]}},w2={firstDay:1,minimalDays:4,weekend:[6,7]},ze=class t{static fromOpts(e){return t.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,r,i,n,o=!1){let s=e||Xe.defaultLocale,a=s||(o?"en-US":jce()),l=r||Xe.defaultNumberingSystem,c=i||Xe.defaultOutputCalendar,u=Jx(n)||Xe.defaultWeekSettings;return new t(a,l,c,u,s)}static resetCache(){yu=null,Kx.clear(),Dx.clear(),jx.clear(),Px.clear(),Mx.clear()}static fromObject({locale:e,numberingSystem:r,outputCalendar:i,weekSettings:n}={}){return t.create(e,r,i,n)}constructor(e,r,i,n,o){let[s,a,l]=Mce(e);this.locale=s,this.numberingSystem=r||a||null,this.outputCalendar=i||l||null,this.weekSettings=n,this.intl=Nce(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=o,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=$ce(this)),this.fastNumbersCached}listingMode(){let e=this.isEnglish(),r=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&r?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:t.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Jx(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,r=!1){return Rh(this,e,j2,()=>{let i=this.intl==="ja"||this.intl.startsWith("ja-");r&=!i;let n=r?{month:e,day:"numeric"}:{month:e},o=r?"format":"standalone";if(!this.monthsCache[o][e]){let s=i?a=>this.dtFormatter(a,n).format():a=>this.extract(a,n,"month");this.monthsCache[o][e]=Lce(s)}return this.monthsCache[o][e]})}weekdays(e,r=!1){return Rh(this,e,N2,()=>{let i=r?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},n=r?"format":"standalone";return this.weekdaysCache[n][e]||(this.weekdaysCache[n][e]=Uce(o=>this.extract(o,i,"weekday"))),this.weekdaysCache[n][e]})}meridiems(){return Rh(this,void 0,()=>L2,()=>{if(!this.meridiemCache){let e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[et.utc(2016,11,13,9),et.utc(2016,11,13,19)].map(r=>this.extract(r,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Rh(this,e,U2,()=>{let r={era:e};return this.eraCache[e]||(this.eraCache[e]=[et.utc(-40,1,1),et.utc(2017,1,1)].map(i=>this.extract(i,r,"era"))),this.eraCache[e]})}extract(e,r,i){let n=this.dtFormatter(e,r),o=n.formatToParts(),s=o.find(a=>a.type.toLowerCase()===i);return s?s.value:null}numberFormatter(e={}){return new Nx(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,r={}){return new Lx(e,this.intl,r)}relFormatter(e={}){return new Ux(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Kce(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||E2(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:A2()?Pce(this.locale):w2}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})`}},Sx=null,Nr=class t extends lo{static get utcInstance(){return Sx===null&&(Sx=new t(0)),Sx}static instance(e){return e===0?t.utcInstance:new t(e)}static parseSpecifier(e){if(e){let r=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(r)return new t(Wh(r[1],r[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${vu(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${vu(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,r){return vu(this.fixed,r)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}},Jh=class extends lo{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function oo(t,e){if(ie(t)||t===null)return e;if(t instanceof lo)return t;if(Vce(t)){let r=t.toLowerCase();return r==="default"?e:r==="local"||r==="system"?Su.instance:r==="utc"||r==="gmt"?Nr.utcInstance:Nr.parseSpecifier(r)||gi.create(t)}else return ao(t)?Nr.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Jh(t)}var zx={arab:"[\u0660-\u0669]",arabext:"[\u06F0-\u06F9]",bali:"[\u1B50-\u1B59]",beng:"[\u09E6-\u09EF]",deva:"[\u0966-\u096F]",fullwide:"[\uFF10-\uFF19]",gujr:"[\u0AE6-\u0AEF]",hanidec:"[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",khmr:"[\u17E0-\u17E9]",knda:"[\u0CE6-\u0CEF]",laoo:"[\u0ED0-\u0ED9]",limb:"[\u1946-\u194F]",mlym:"[\u0D66-\u0D6F]",mong:"[\u1810-\u1819]",mymr:"[\u1040-\u1049]",orya:"[\u0B66-\u0B6F]",tamldec:"[\u0BE6-\u0BEF]",telu:"[\u0C66-\u0C6F]",thai:"[\u0E50-\u0E59]",tibt:"[\u0F20-\u0F29]",latn:"\\d"},TF={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]},Jce=zx.hanidec.replace(/[\[|\]]/g,"").split("");function Fce(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);if(t[r].search(zx.hanidec)!==-1)e+=Jce.indexOf(t[r]);else for(let n in TF){let[o,s]=TF[n];i>=o&&i<=s&&(e+=i-o)}}return parseInt(e,10)}else return e}var $x=new Map;function qce(){$x.clear()}function vn({numberingSystem:t},e=""){let r=t||"latn",i=$x.get(r);i===void 0&&(i=new Map,$x.set(r,i));let n=i.get(e);return n===void 0&&(n=new RegExp(`${zx[r]}${e}`),i.set(e,n)),n}var CF=()=>Date.now(),OF="system",AF=null,KF=null,RF=null,DF=60,jF,PF=null,Xe=class{static get now(){return CF}static set now(e){CF=e}static set defaultZone(e){OF=e}static get defaultZone(){return oo(OF,Su.instance)}static get defaultLocale(){return AF}static set defaultLocale(e){AF=e}static get defaultNumberingSystem(){return KF}static set defaultNumberingSystem(e){KF=e}static get defaultOutputCalendar(){return RF}static set defaultOutputCalendar(e){RF=e}static get defaultWeekSettings(){return PF}static set defaultWeekSettings(e){PF=Jx(e)}static get twoDigitCutoffYear(){return DF}static set twoDigitCutoffYear(e){DF=e%100}static get throwOnInvalid(){return jF}static set throwOnInvalid(e){jF=e}static resetCaches(){ze.resetCache(),gi.resetCache(),et.resetCache(),qce()}},Pr=class{constructor(e,r){this.reason=e,this.explanation=r}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},x2=[0,31,59,90,120,151,181,212,243,273,304,334],I2=[0,31,60,91,121,152,182,213,244,274,305,335];function sn(t,e){return new Pr("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Gx(t,e,r){let i=new Date(Date.UTC(t,e-1,r));t<100&&t>=0&&i.setUTCFullYear(i.getUTCFullYear()-1900);let n=i.getUTCDay();return n===0?7:n}function k2(t,e,r){return r+(wu(t)?I2:x2)[e-1]}function _2(t,e){let r=wu(t)?I2:x2,i=r.findIndex(o=>o<e),n=e-r[i];return{month:i+1,day:n}}function Vx(t,e){return(t-e+7)%7+1}function Fh(t,e=4,r=1){let{year:i,month:n,day:o}=t,s=k2(i,n,o),a=Vx(Gx(i,n,o),r),l=Math.floor((s-a+14-e)/7),c;return l<1?(c=i-1,l=Eu(c,e,r)):l>Eu(i,e,r)?(c=i+1,l=1):c=i,{weekYear:c,weekNumber:l,weekday:a,...Zh(t)}}function MF(t,e=4,r=1){let{weekYear:i,weekNumber:n,weekday:o}=t,s=Vx(Gx(i,1,e),r),a=Ha(i),l=n*7+o-s-7+e,c;l<1?(c=i-1,l+=Ha(c)):l>a?(c=i+1,l-=Ha(i)):c=i;let{month:u,day:d}=_2(c,l);return{year:c,month:u,day:d,...Zh(t)}}function Ex(t){let{year:e,month:r,day:i}=t,n=k2(e,r,i);return{year:e,ordinal:n,...Zh(t)}}function NF(t){let{year:e,ordinal:r}=t,{month:i,day:n}=_2(e,r);return{year:e,month:i,day:n,...Zh(t)}}function LF(t,e){if(!ie(t.localWeekday)||!ie(t.localWeekNumber)||!ie(t.localWeekYear)){if(!ie(t.weekday)||!ie(t.weekNumber)||!ie(t.weekYear))throw new so("Cannot mix locale-based week fields with ISO-based week fields");return ie(t.localWeekday)||(t.weekday=t.localWeekday),ie(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),ie(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function zce(t,e=4,r=1){let i=Vh(t.weekYear),n=an(t.weekNumber,1,Eu(t.weekYear,e,r)),o=an(t.weekday,1,7);return i?n?o?!1:sn("weekday",t.weekday):sn("week",t.weekNumber):sn("weekYear",t.weekYear)}function Gce(t){let e=Vh(t.year),r=an(t.ordinal,1,Ha(t.year));return e?r?!1:sn("ordinal",t.ordinal):sn("year",t.year)}function T2(t){let e=Vh(t.year),r=an(t.month,1,12),i=an(t.day,1,qh(t.year,t.month));return e?r?i?!1:sn("day",t.day):sn("month",t.month):sn("year",t.year)}function C2(t){let{hour:e,minute:r,second:i,millisecond:n}=t,o=an(e,0,23)||e===24&&r===0&&i===0&&n===0,s=an(r,0,59),a=an(i,0,59),l=an(n,0,999);return o?s?a?l?!1:sn("millisecond",n):sn("second",i):sn("minute",r):sn("hour",e)}function ie(t){return typeof t>"u"}function ao(t){return typeof t=="number"}function Vh(t){return typeof t=="number"&&t%1===0}function Vce(t){return typeof t=="string"}function Bce(t){return Object.prototype.toString.call(t)==="[object Date]"}function O2(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function A2(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Wce(t){return Array.isArray(t)?t:[t]}function UF(t,e,r){if(t.length!==0)return t.reduce((i,n)=>{let o=[e(n),n];return i&&r(i[0],o[0])===i[0]?i:o},null)[1]}function Zce(t,e){return e.reduce((r,i)=>(r[i]=t[i],r),{})}function Xa(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Jx(t){if(t==null)return null;if(typeof t!="object")throw new Dt("Week settings must be an object");if(!an(t.firstDay,1,7)||!an(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!an(e,1,7)))throw new Dt("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function an(t,e,r){return Vh(t)&&t>=e&&t<=r}function Hce(t,e){return t-e*Math.floor(t/e)}function vt(t,e=2){let r=t<0,i;return r?i="-"+(""+-t).padStart(e,"0"):i=(""+t).padStart(e,"0"),i}function io(t){if(!(ie(t)||t===null||t===""))return parseInt(t,10)}function os(t){if(!(ie(t)||t===null||t===""))return parseFloat(t)}function Bx(t){if(!(ie(t)||t===null||t==="")){let e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Wx(t,e,r="round"){let i=10**e;switch(r){case"expand":return t>0?Math.ceil(t*i)/i:Math.floor(t*i)/i;case"trunc":return Math.trunc(t*i)/i;case"round":return Math.round(t*i)/i;case"floor":return Math.floor(t*i)/i;case"ceil":return Math.ceil(t*i)/i;default:throw new RangeError(`Value rounding ${r} is out of range`)}}function wu(t){return t%4===0&&(t%100!==0||t%400===0)}function Ha(t){return wu(t)?366:365}function qh(t,e){let r=Hce(e-1,12)+1,i=t+(e-r)/12;return r===2?wu(i)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][r-1]}function Bh(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function $F(t,e,r){return-Vx(Gx(t,1,e),r)+e-1}function Eu(t,e=4,r=1){let i=$F(t,e,r),n=$F(t+1,e,r);return(Ha(t)-i+n)/7}function Fx(t){return t>99?t:t>Xe.twoDigitCutoffYear?1900+t:2e3+t}function K2(t,e,r,i=null){let n=new Date(t),o={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};i&&(o.timeZone=i);let s={timeZoneName:e,...o},a=new Intl.DateTimeFormat(r,s).formatToParts(n).find(l=>l.type.toLowerCase()==="timezonename");return a?a.value:null}function Wh(t,e){let r=parseInt(t,10);Number.isNaN(r)&&(r=0);let i=parseInt(e,10)||0,n=r<0||Object.is(r,-0)?-i:i;return r*60+n}function R2(t){let e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Dt(`Invalid unit value ${t}`);return e}function zh(t,e){let r={};for(let i in t)if(Xa(t,i)){let n=t[i];if(n==null)continue;r[e(i)]=R2(n)}return r}function vu(t,e){let r=Math.trunc(Math.abs(t/60)),i=Math.trunc(Math.abs(t%60)),n=t>=0?"+":"-";switch(e){case"short":return`${n}${vt(r,2)}:${vt(i,2)}`;case"narrow":return`${n}${r}${i>0?`:${i}`:""}`;case"techie":return`${n}${vt(r,2)}${vt(i,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function Zh(t){return Zce(t,["hour","minute","second","millisecond"])}var Yce=["January","February","March","April","May","June","July","August","September","October","November","December"],D2=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Xce=["J","F","M","A","M","J","J","A","S","O","N","D"];function j2(t){switch(t){case"narrow":return[...Xce];case"short":return[...D2];case"long":return[...Yce];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}}var P2=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],M2=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Qce=["M","T","W","T","F","S","S"];function N2(t){switch(t){case"narrow":return[...Qce];case"short":return[...M2];case"long":return[...P2];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var L2=["AM","PM"],eue=["Before Christ","Anno Domini"],tue=["BC","AD"],rue=["B","A"];function U2(t){switch(t){case"narrow":return[...rue];case"short":return[...tue];case"long":return[...eue];default:return null}}function nue(t){return L2[t.hour<12?0:1]}function iue(t,e){return N2(e)[t.weekday-1]}function oue(t,e){return j2(e)[t.month-1]}function sue(t,e){return U2(e)[t.year<0?0:1]}function aue(t,e,r="always",i=!1){let n={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."]},o=["hours","minutes","seconds"].indexOf(t)===-1;if(r==="auto"&&o){let d=t==="days";switch(e){case 1:return d?"tomorrow":`next ${n[t][0]}`;case-1:return d?"yesterday":`last ${n[t][0]}`;case 0:return d?"today":`this ${n[t][0]}`}}let s=Object.is(e,-0)||e<0,a=Math.abs(e),l=a===1,c=n[t],u=i?l?c[1]:c[2]||c[1]:l?n[t][0]:t;return s?`${a} ${u} ago`:`in ${a} ${u}`}function JF(t,e){let r="";for(let i of t)i.literal?r+=i.val:r+=e(i.val);return r}var lue={D:$h,DD:r2,DDD:n2,DDDD:i2,t:o2,tt:s2,ttt:a2,tttt:l2,T:c2,TT:u2,TTT:d2,TTTT:p2,f:f2,ff:h2,fff:g2,ffff:v2,F:m2,FF:y2,FFF:b2,FFFF:S2},jr=class t{static create(e,r={}){return new t(e,r)}static parseFormat(e){let r=null,i="",n=!1,o=[];for(let s=0;s<e.length;s++){let a=e.charAt(s);a==="'"?((i.length>0||n)&&o.push({literal:n||/^\s+$/.test(i),val:i===""?"'":i}),r=null,i="",n=!n):n||a===r?i+=a:(i.length>0&&o.push({literal:/^\s+$/.test(i),val:i}),i=a,r=a)}return i.length>0&&o.push({literal:n||/^\s+$/.test(i),val:i}),o}static macroTokenToFormatOpts(e){return lue[e]}constructor(e,r){this.opts=r,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,r){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...r}).format()}dtFormatter(e,r={}){return this.loc.dtFormatter(e,{...this.opts,...r})}formatDateTime(e,r){return this.dtFormatter(e,r).format()}formatDateTimeParts(e,r){return this.dtFormatter(e,r).formatToParts()}formatInterval(e,r){return this.dtFormatter(e.start,r).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,r){return this.dtFormatter(e,r).resolvedOptions()}num(e,r=0,i=void 0){if(this.opts.forceSimple)return vt(e,r);let n={...this.opts};return r>0&&(n.padTo=r),i&&(n.signDisplay=i),this.loc.numberFormatter(n).format(e)}formatDateTimeFromString(e,r){let i=this.loc.listingMode()==="en",n=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",o=(p,m)=>this.loc.extract(e,p,m),s=p=>e.isOffsetFixed&&e.offset===0&&p.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,p.format):"",a=()=>i?nue(e):o({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(p,m)=>i?oue(e,p):o(m?{month:p}:{month:p,day:"numeric"},"month"),c=(p,m)=>i?iue(e,p):o(m?{weekday:p}:{weekday:p,month:"long",day:"numeric"},"weekday"),u=p=>{let m=t.macroTokenToFormatOpts(p);return m?this.formatWithSystemDefault(e,m):p},d=p=>i?sue(e,p):o({era:p},"era"),f=p=>{switch(p){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 s({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return s({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return s({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 a();case"d":return n?o({day:"numeric"},"day"):this.num(e.day);case"dd":return n?o({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return c("short",!0);case"cccc":return c("long",!0);case"ccccc":return c("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return c("short",!1);case"EEEE":return c("long",!1);case"EEEEE":return c("narrow",!1);case"L":return n?o({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return n?o({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return n?o({month:"numeric"},"month"):this.num(e.month);case"MM":return n?o({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return n?o({year:"numeric"},"year"):this.num(e.year);case"yy":return n?o({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return n?o({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return n?o({year:"numeric"},"year"):this.num(e.year,6);case"G":return d("short");case"GG":return d("long");case"GGGGG":return d("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 u(p)}};return JF(t.parseFormat(r),f)}formatDurationFromString(e,r){let i=this.opts.signMode==="negativeLargestOnly"?-1:1,n=u=>{switch(u[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},o=(u,d)=>f=>{let p=n(f);if(p){let m=d.isNegativeDuration&&p!==d.largestUnit?i:1,y;return this.opts.signMode==="negativeLargestOnly"&&p!==d.largestUnit?y="never":this.opts.signMode==="all"?y="always":y="auto",this.num(u.get(p)*m,f.length,y)}else return f},s=t.parseFormat(r),a=s.reduce((u,{literal:d,val:f})=>d?u:u.concat(f),[]),l=e.shiftTo(...a.map(n).filter(u=>u)),c={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return JF(s,o(l,c))}},$2=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Qa(...t){let e=t.reduce((r,i)=>r+i.source,"");return RegExp(`^${e}$`)}function el(...t){return e=>t.reduce(([r,i,n],o)=>{let[s,a,l]=o(e,n);return[{...r,...s},a||i,l]},[{},null,1]).slice(0,2)}function tl(t,...e){if(t==null)return[null,null];for(let[r,i]of e){let n=r.exec(t);if(n)return i(n)}return[null,null]}function J2(...t){return(e,r)=>{let i={},n;for(n=0;n<t.length;n++)i[t[n]]=io(e[r+n]);return[i,null,r+n]}}var F2=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,cue=`(?:${F2.source}?(?:\\[(${$2.source})\\])?)?`,Zx=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,q2=RegExp(`${Zx.source}${cue}`),Hx=RegExp(`(?:[Tt]${q2.source})?`),uue=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,due=/(\d{4})-?W(\d\d)(?:-?(\d))?/,pue=/(\d{4})-?(\d{3})/,fue=J2("weekYear","weekNumber","weekDay"),mue=J2("year","ordinal"),hue=/(\d{4})-(\d\d)-(\d\d)/,z2=RegExp(`${Zx.source} ?(?:${F2.source}|(${$2.source}))?`),yue=RegExp(`(?: ${z2.source})?`);function Ya(t,e,r){let i=t[e];return ie(i)?r:io(i)}function gue(t,e){return[{year:Ya(t,e),month:Ya(t,e+1,1),day:Ya(t,e+2,1)},null,e+3]}function rl(t,e){return[{hours:Ya(t,e,0),minutes:Ya(t,e+1,0),seconds:Ya(t,e+2,0),milliseconds:Bx(t[e+3])},null,e+4]}function xu(t,e){let r=!t[e]&&!t[e+1],i=Wh(t[e+1],t[e+2]),n=r?null:Nr.instance(i);return[{},n,e+3]}function Iu(t,e){let r=t[e]?gi.create(t[e]):null;return[{},r,e+1]}var bue=RegExp(`^T?${Zx.source}$`),vue=/^-?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 Sue(t){let[e,r,i,n,o,s,a,l,c]=t,u=e[0]==="-",d=l&&l[0]==="-",f=(p,m=!1)=>p!==void 0&&(m||p&&u)?-p:p;return[{years:f(os(r)),months:f(os(i)),weeks:f(os(n)),days:f(os(o)),hours:f(os(s)),minutes:f(os(a)),seconds:f(os(l),l==="-0"),milliseconds:f(Bx(c),d)}]}var Eue={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Yx(t,e,r,i,n,o,s){let a={year:e.length===2?Fx(io(e)):io(e),month:D2.indexOf(r)+1,day:io(i),hour:io(n),minute:io(o)};return s&&(a.second=io(s)),t&&(a.weekday=t.length>3?P2.indexOf(t)+1:M2.indexOf(t)+1),a}var wue=/^(?:(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 xue(t){let[,e,r,i,n,o,s,a,l,c,u,d]=t,f=Yx(e,n,i,r,o,s,a),p;return l?p=Eue[l]:c?p=0:p=Wh(u,d),[f,new Nr(p)]}function Iue(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}var kue=/^(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$/,_ue=/^(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$/,Tue=/^(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 FF(t){let[,e,r,i,n,o,s,a]=t;return[Yx(e,n,i,r,o,s,a),Nr.utcInstance]}function Cue(t){let[,e,r,i,n,o,s,a]=t;return[Yx(e,a,r,i,n,o,s),Nr.utcInstance]}var Oue=Qa(uue,Hx),Aue=Qa(due,Hx),Kue=Qa(pue,Hx),Rue=Qa(q2),G2=el(gue,rl,xu,Iu),Due=el(fue,rl,xu,Iu),jue=el(mue,rl,xu,Iu),Pue=el(rl,xu,Iu);function Mue(t){return tl(t,[Oue,G2],[Aue,Due],[Kue,jue],[Rue,Pue])}function Nue(t){return tl(Iue(t),[wue,xue])}function Lue(t){return tl(t,[kue,FF],[_ue,FF],[Tue,Cue])}function Uue(t){return tl(t,[vue,Sue])}var $ue=el(rl);function Jue(t){return tl(t,[bue,$ue])}var Fue=Qa(hue,yue),que=Qa(z2),zue=el(rl,xu,Iu);function Gue(t){return tl(t,[Fue,G2],[que,zue])}var qF="Invalid Duration",V2={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Vue={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:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...V2},on=146097/400,Ba=146097/4800,Bue={years:{quarters:4,months:12,weeks:on/7,days:on,hours:on*24,minutes:on*24*60,seconds:on*24*60*60,milliseconds:on*24*60*60*1e3},quarters:{months:3,weeks:on/28,days:on/4,hours:on*24/4,minutes:on*24*60/4,seconds:on*24*60*60/4,milliseconds:on*24*60*60*1e3/4},months:{weeks:Ba/7,days:Ba,hours:Ba*24,minutes:Ba*24*60,seconds:Ba*24*60*60,milliseconds:Ba*24*60*60*1e3},...V2},as=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Wue=as.slice(0).reverse();function hi(t,e,r=!1){let i={values:r?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new Ot(i)}function B2(t,e){var r;let i=(r=e.milliseconds)!=null?r:0;for(let n of Wue.slice(1))e[n]&&(i+=e[n]*t[n].milliseconds);return i}function zF(t,e){let r=B2(t,e)<0?-1:1;as.reduceRight((i,n)=>{if(ie(e[n]))return i;if(i){let o=e[i]*r,s=t[n][i],a=Math.floor(o/s);e[n]+=a*r,e[i]-=a*s*r}return n},null),as.reduce((i,n)=>{if(ie(e[n]))return i;if(i){let o=e[i]%1;e[i]-=o,e[n]+=o*t[i][n]}return n},null)}function GF(t){let e={};for(let[r,i]of Object.entries(t))i!==0&&(e[r]=i);return e}var Ot=class t{constructor(e){let r=e.conversionAccuracy==="longterm"||!1,i=r?Bue:Vue;e.matrix&&(i=e.matrix),this.values=e.values,this.loc=e.loc||ze.create(),this.conversionAccuracy=r?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=i,this.isLuxonDuration=!0}static fromMillis(e,r){return t.fromObject({milliseconds:e},r)}static fromObject(e,r={}){if(e==null||typeof e!="object")throw new Dt(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new t({values:zh(e,t.normalizeUnit),loc:ze.fromObject(r),conversionAccuracy:r.conversionAccuracy,matrix:r.matrix})}static fromDurationLike(e){if(ao(e))return t.fromMillis(e);if(t.isDuration(e))return e;if(typeof e=="object")return t.fromObject(e);throw new Dt(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,r){let[i]=Uue(e);return i?t.fromObject(i,r):t.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,r){let[i]=Jue(e);return i?t.fromObject(i,r):t.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,r=null){if(!e)throw new Dt("need to specify a reason the Duration is invalid");let i=e instanceof Pr?e:new Pr(e,r);if(Xe.throwOnInvalid)throw new Ox(i);return new t({invalid:i})}static normalizeUnit(e){let r={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()];if(!r)throw new Uh(e);return r}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,r={}){let i={...r,floor:r.round!==!1&&r.floor!==!1};return this.isValid?jr.create(this.loc,i).formatDurationFromString(this,e):qF}toHuman(e={}){if(!this.isValid)return qF;let r=e.showZeros!==!1,i=as.map(n=>{let o=this.values[n];return ie(o)||o===0&&!r?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:n.slice(0,-1)}).format(o)}).filter(n=>n);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(i)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=Wx(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;let r=this.toMillis();return r<0||r>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},et.fromMillis(r,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?B2(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;let r=t.fromDurationLike(e),i={};for(let n of as)(Xa(r.values,n)||Xa(this.values,n))&&(i[n]=r.get(n)+this.get(n));return hi(this,{values:i},!0)}minus(e){if(!this.isValid)return this;let r=t.fromDurationLike(e);return this.plus(r.negate())}mapUnits(e){if(!this.isValid)return this;let r={};for(let i of Object.keys(this.values))r[i]=R2(e(this.values[i],i));return hi(this,{values:r},!0)}get(e){return this[t.normalizeUnit(e)]}set(e){if(!this.isValid)return this;let r={...this.values,...zh(e,t.normalizeUnit)};return hi(this,{values:r})}reconfigure({locale:e,numberingSystem:r,conversionAccuracy:i,matrix:n}={}){let s={loc:this.loc.clone({locale:e,numberingSystem:r}),matrix:n,conversionAccuracy:i};return hi(this,s)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return zF(this.matrix,e),hi(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=GF(this.normalize().shiftToAll().toObject());return hi(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(s=>t.normalizeUnit(s));let r={},i={},n=this.toObject(),o;for(let s of as)if(e.indexOf(s)>=0){o=s;let a=0;for(let c in i)a+=this.matrix[c][s]*i[c],i[c]=0;ao(n[s])&&(a+=n[s]);let l=Math.trunc(a);r[s]=l,i[s]=(a*1e3-l*1e3)/1e3}else ao(n[s])&&(i[s]=n[s]);for(let s in i)i[s]!==0&&(r[o]+=s===o?i[s]:i[s]/this.matrix[o][s]);return zF(this.matrix,r),hi(this,{values:r},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;let e={};for(let r of Object.keys(this.values))e[r]=this.values[r]===0?0:-this.values[r];return hi(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=GF(this.values);return hi(this,{values:e},!0)}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||!this.loc.equals(e.loc))return!1;function r(i,n){return i===void 0||i===0?n===void 0||n===0:i===n}for(let i of as)if(!r(this.values[i],e.values[i]))return!1;return!0}},Wa="Invalid Interval";function Zue(t,e){return!t||!t.isValid?cs.invalid("missing or invalid start"):!e||!e.isValid?cs.invalid("missing or invalid end"):e<t?cs.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}var cs=class t{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,r=null){if(!e)throw new Dt("need to specify a reason the Interval is invalid");let i=e instanceof Pr?e:new Pr(e,r);if(Xe.throwOnInvalid)throw new Cx(i);return new t({invalid:i})}static fromDateTimes(e,r){let i=hu(e),n=hu(r),o=Zue(i,n);return o??new t({start:i,end:n})}static after(e,r){let i=Ot.fromDurationLike(r),n=hu(e);return t.fromDateTimes(n,n.plus(i))}static before(e,r){let i=Ot.fromDurationLike(r),n=hu(e);return t.fromDateTimes(n.minus(i),n)}static fromISO(e,r){let[i,n]=(e||"").split("/",2);if(i&&n){let o,s;try{o=et.fromISO(i,r),s=o.isValid}catch{s=!1}let a,l;try{a=et.fromISO(n,r),l=a.isValid}catch{l=!1}if(s&&l)return t.fromDateTimes(o,a);if(s){let c=Ot.fromISO(n,r);if(c.isValid)return t.after(o,c)}else if(l){let c=Ot.fromISO(i,r);if(c.isValid)return t.before(a,c)}}return t.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):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",r){if(!this.isValid)return NaN;let i=this.start.startOf(e,r),n;return r!=null&&r.useLocaleWeeks?n=this.end.reconfigure({locale:i.locale}):n=this.end,n=n.startOf(e,r),Math.floor(n.diff(i,e).get(e))+(n.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:r}={}){return this.isValid?t.fromDateTimes(e||this.s,r||this.e):this}splitAt(...e){if(!this.isValid)return[];let r=e.map(hu).filter(s=>this.contains(s)).sort((s,a)=>s.toMillis()-a.toMillis()),i=[],{s:n}=this,o=0;for(;n<this.e;){let s=r[o]||this.e,a=+s>+this.e?this.e:s;i.push(t.fromDateTimes(n,a)),n=a,o+=1}return i}splitBy(e){let r=Ot.fromDurationLike(e);if(!this.isValid||!r.isValid||r.as("milliseconds")===0)return[];let{s:i}=this,n=1,o,s=[];for(;i<this.e;){let a=this.start.plus(r.mapUnits(l=>l*n));o=+a>+this.e?this.e:a,s.push(t.fromDateTimes(i,o)),i=o,n+=1}return s}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;let r=this.s>e.s?this.s:e.s,i=this.e<e.e?this.e:e.e;return r>=i?null:t.fromDateTimes(r,i)}union(e){if(!this.isValid)return this;let r=this.s<e.s?this.s:e.s,i=this.e>e.e?this.e:e.e;return t.fromDateTimes(r,i)}static merge(e){let[r,i]=e.sort((n,o)=>n.s-o.s).reduce(([n,o],s)=>o?o.overlaps(s)||o.abutsStart(s)?[n,o.union(s)]:[n.concat([o]),s]:[n,s],[[],null]);return i&&r.push(i),r}static xor(e){let r=null,i=0,n=[],o=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),s=Array.prototype.concat(...o),a=s.sort((l,c)=>l.time-c.time);for(let l of a)i+=l.type==="s"?1:-1,i===1?r=l.time:(r&&+r!=+l.time&&n.push(t.fromDateTimes(r,l.time)),r=null);return t.merge(n)}difference(...e){return t.xor([this].concat(e)).map(r=>this.intersection(r)).filter(r=>r&&!r.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} \u2013 ${this.e.toISO()})`:Wa}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=$h,r={}){return this.isValid?jr.create(this.s.loc.clone(r),e).formatInterval(this):Wa}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Wa}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Wa}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Wa}toFormat(e,{separator:r=" \u2013 "}={}){return this.isValid?`${this.s.toFormat(e)}${r}${this.e.toFormat(e)}`:Wa}toDuration(e,r){return this.isValid?this.e.diff(this.s,e,r):Ot.invalid(this.invalidReason)}mapEndpoints(e){return t.fromDateTimes(e(this.s),e(this.e))}},ls=class{static hasDST(e=Xe.defaultZone){let r=et.now().setZone(e).set({month:12});return!e.isUniversal&&r.offset!==r.set({month:6}).offset}static isValidIANAZone(e){return gi.isValidZone(e)}static normalizeZone(e){return oo(e,Xe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:r=null}={}){return(r||ze.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:r=null}={}){return(r||ze.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:r=null}={}){return(r||ze.create(e)).getWeekendDays().slice()}static months(e="long",{locale:r=null,numberingSystem:i=null,locObj:n=null,outputCalendar:o="gregory"}={}){return(n||ze.create(r,i,o)).months(e)}static monthsFormat(e="long",{locale:r=null,numberingSystem:i=null,locObj:n=null,outputCalendar:o="gregory"}={}){return(n||ze.create(r,i,o)).months(e,!0)}static weekdays(e="long",{locale:r=null,numberingSystem:i=null,locObj:n=null}={}){return(n||ze.create(r,i,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:r=null,numberingSystem:i=null,locObj:n=null}={}){return(n||ze.create(r,i,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return ze.create(e).meridiems()}static eras(e="short",{locale:r=null}={}){return ze.create(r,null,"gregory").eras(e)}static features(){return{relative:O2(),localeWeek:A2()}}};function VF(t,e){let r=n=>n.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),i=r(e)-r(t);return Math.floor(Ot.fromMillis(i).as("days"))}function Hue(t,e,r){let i=[["years",(l,c)=>c.year-l.year],["quarters",(l,c)=>c.quarter-l.quarter+(c.year-l.year)*4],["months",(l,c)=>c.month-l.month+(c.year-l.year)*12],["weeks",(l,c)=>{let u=VF(l,c);return(u-u%7)/7}],["days",VF]],n={},o=t,s,a;for(let[l,c]of i)r.indexOf(l)>=0&&(s=l,n[l]=c(t,e),a=o.plus(n),a>e?(n[l]--,t=o.plus(n),t>e&&(a=t,n[l]--,t=o.plus(n))):t=a);return[t,n,a,s]}function Yue(t,e,r,i){let[n,o,s,a]=Hue(t,e,r),l=e-n,c=r.filter(d=>["hours","minutes","seconds","milliseconds"].indexOf(d)>=0);c.length===0&&(s<e&&(s=n.plus({[a]:1})),s!==n&&(o[a]=(o[a]||0)+l/(s-n)));let u=Ot.fromObject(o,i);return c.length>0?Ot.fromMillis(l,i).shiftTo(...c).plus(u):u}var Xue="missing Intl.DateTimeFormat.formatToParts support";function Re(t,e=r=>r){return{regex:t,deser:([r])=>e(Fce(r))}}var Que="\xA0",W2=`[ ${Que}]`,Z2=new RegExp(W2,"g");function ede(t){return t.replace(/\./g,"\\.?").replace(Z2,W2)}function BF(t){return t.replace(/\./g,"").replace(Z2," ").toLowerCase()}function Sn(t,e){return t===null?null:{regex:RegExp(t.map(ede).join("|")),deser:([r])=>t.findIndex(i=>BF(r)===BF(i))+e}}function WF(t,e){return{regex:t,deser:([,r,i])=>Wh(r,i),groups:e}}function Dh(t){return{regex:t,deser:([e])=>e}}function tde(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function rde(t,e){let r=vn(e),i=vn(e,"{2}"),n=vn(e,"{3}"),o=vn(e,"{4}"),s=vn(e,"{6}"),a=vn(e,"{1,2}"),l=vn(e,"{1,3}"),c=vn(e,"{1,6}"),u=vn(e,"{1,9}"),d=vn(e,"{2,4}"),f=vn(e,"{4,6}"),p=w=>({regex:RegExp(tde(w.val)),deser:([_])=>_,literal:!0}),y=(w=>{if(t.literal)return p(w);switch(w.val){case"G":return Sn(e.eras("short"),0);case"GG":return Sn(e.eras("long"),0);case"y":return Re(c);case"yy":return Re(d,Fx);case"yyyy":return Re(o);case"yyyyy":return Re(f);case"yyyyyy":return Re(s);case"M":return Re(a);case"MM":return Re(i);case"MMM":return Sn(e.months("short",!0),1);case"MMMM":return Sn(e.months("long",!0),1);case"L":return Re(a);case"LL":return Re(i);case"LLL":return Sn(e.months("short",!1),1);case"LLLL":return Sn(e.months("long",!1),1);case"d":return Re(a);case"dd":return Re(i);case"o":return Re(l);case"ooo":return Re(n);case"HH":return Re(i);case"H":return Re(a);case"hh":return Re(i);case"h":return Re(a);case"mm":return Re(i);case"m":return Re(a);case"q":return Re(a);case"qq":return Re(i);case"s":return Re(a);case"ss":return Re(i);case"S":return Re(l);case"SSS":return Re(n);case"u":return Dh(u);case"uu":return Dh(a);case"uuu":return Re(r);case"a":return Sn(e.meridiems(),0);case"kkkk":return Re(o);case"kk":return Re(d,Fx);case"W":return Re(a);case"WW":return Re(i);case"E":case"c":return Re(r);case"EEE":return Sn(e.weekdays("short",!1),1);case"EEEE":return Sn(e.weekdays("long",!1),1);case"ccc":return Sn(e.weekdays("short",!0),1);case"cccc":return Sn(e.weekdays("long",!0),1);case"Z":case"ZZ":return WF(new RegExp(`([+-]${a.source})(?::(${i.source}))?`),2);case"ZZZ":return WF(new RegExp(`([+-]${a.source})(${i.source})?`),2);case"z":return Dh(/[a-z_+-/]{1,256}?/i);case" ":return Dh(/[^\S\n\r]/);default:return p(w)}})(t)||{invalidReason:Xue};return y.token=t,y}var nde={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 ide(t,e,r){let{type:i,value:n}=t;if(i==="literal"){let l=/^\s+$/.test(n);return{literal:!l,val:l?" ":n}}let o=e[i],s=i;i==="hour"&&(e.hour12!=null?s=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?s="hour12":s="hour24":s=r.hour12?"hour12":"hour24");let a=nde[s];if(typeof a=="object"&&(a=a[o]),a)return{literal:!1,val:a}}function ode(t){return[`^${t.map(r=>r.regex).reduce((r,i)=>`${r}(${i.source})`,"")}$`,t]}function sde(t,e,r){let i=t.match(e);if(i){let n={},o=1;for(let s in r)if(Xa(r,s)){let a=r[s],l=a.groups?a.groups+1:1;!a.literal&&a.token&&(n[a.token.val[0]]=a.deser(i.slice(o,o+l))),o+=l}return[i,n]}else return[i,{}]}function ade(t){let e=o=>{switch(o){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}},r=null,i;return ie(t.z)||(r=gi.create(t.z)),ie(t.Z)||(r||(r=new Nr(t.Z)),i=t.Z),ie(t.q)||(t.M=(t.q-1)*3+1),ie(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),ie(t.u)||(t.S=Bx(t.u)),[Object.keys(t).reduce((o,s)=>{let a=e(s);return a&&(o[a]=t[s]),o},{}),r,i]}var wx=null;function lde(){return wx||(wx=et.fromMillis(1555555555555)),wx}function cde(t,e){if(t.literal)return t;let r=jr.macroTokenToFormatOpts(t.val),i=X2(r,e);return i==null||i.includes(void 0)?t:i}function H2(t,e){return Array.prototype.concat(...t.map(r=>cde(r,e)))}var Gh=class{constructor(e,r){if(this.locale=e,this.format=r,this.tokens=H2(jr.parseFormat(r),e),this.units=this.tokens.map(i=>rde(i,e)),this.disqualifyingUnit=this.units.find(i=>i.invalidReason),!this.disqualifyingUnit){let[i,n]=ode(this.units);this.regex=RegExp(i,"i"),this.handlers=n}}explainFromTokens(e){if(this.isValid){let[r,i]=sde(e,this.regex,this.handlers),[n,o,s]=i?ade(i):[null,null,void 0];if(Xa(i,"a")&&Xa(i,"H"))throw new so("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:r,matches:i,result:n,zone:o,specificOffset:s}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}};function Y2(t,e,r){return new Gh(t,r).explainFromTokens(e)}function ude(t,e,r){let{result:i,zone:n,specificOffset:o,invalidReason:s}=Y2(t,e,r);return[i,n,o,s]}function X2(t,e){if(!t)return null;let i=jr.create(e,t).dtFormatter(lde()),n=i.formatToParts(),o=i.resolvedOptions();return n.map(s=>ide(s,t,o))}var xx="Invalid DateTime",ZF=864e13;function gu(t){return new Pr("unsupported zone",`the zone "${t.name}" is not supported`)}function Ix(t){return t.weekData===null&&(t.weekData=Fh(t.c)),t.weekData}function kx(t){return t.localWeekData===null&&(t.localWeekData=Fh(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function ss(t,e){let r={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new et({...r,...e,old:r})}function Q2(t,e,r){let i=t-e*60*1e3,n=r.offset(i);if(e===n)return[i,e];i-=(n-e)*60*1e3;let o=r.offset(i);return n===o?[i,n]:[t-Math.min(n,o)*60*1e3,Math.max(n,o)]}function jh(t,e){t+=e*60*1e3;let r=new Date(t);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:r.getUTCHours(),minute:r.getUTCMinutes(),second:r.getUTCSeconds(),millisecond:r.getUTCMilliseconds()}}function Mh(t,e,r){return Q2(Bh(t),e,r)}function HF(t,e){let r=t.o,i=t.c.year+Math.trunc(e.years),n=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,o={...t.c,year:i,month:n,day:Math.min(t.c.day,qh(i,n))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},s=Ot.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),a=Bh(o),[l,c]=Q2(a,r,t.zone);return s!==0&&(l+=s,c=t.zone.offset(l)),{ts:l,o:c}}function Za(t,e,r,i,n,o){let{setZone:s,zone:a}=r;if(t&&Object.keys(t).length!==0||e){let l=e||a,c=et.fromObject(t,{...r,zone:l,specificOffset:o});return s?c:c.setZone(a)}else return et.invalid(new Pr("unparsable",`the input "${n}" can't be parsed as ${i}`))}function Ph(t,e,r=!0){return t.isValid?jr.create(ze.create("en-US"),{allowZ:r,forceSimple:!0}).formatDateTimeFromString(t,e):null}function _x(t,e,r){let i=t.c.year>9999||t.c.year<0,n="";if(i&&t.c.year>=0&&(n+="+"),n+=vt(t.c.year,i?6:4),r==="year")return n;if(e){if(n+="-",n+=vt(t.c.month),r==="month")return n;n+="-"}else if(n+=vt(t.c.month),r==="month")return n;return n+=vt(t.c.day),n}function YF(t,e,r,i,n,o,s){let a=!r||t.c.millisecond!==0||t.c.second!==0,l="";switch(s){case"day":case"month":case"year":break;default:if(l+=vt(t.c.hour),s==="hour")break;if(e){if(l+=":",l+=vt(t.c.minute),s==="minute")break;a&&(l+=":",l+=vt(t.c.second))}else{if(l+=vt(t.c.minute),s==="minute")break;a&&(l+=vt(t.c.second))}if(s==="second")break;a&&(!i||t.c.millisecond!==0)&&(l+=".",l+=vt(t.c.millisecond,3))}return n&&(t.isOffsetFixed&&t.offset===0&&!o?l+="Z":t.o<0?(l+="-",l+=vt(Math.trunc(-t.o/60)),l+=":",l+=vt(Math.trunc(-t.o%60))):(l+="+",l+=vt(Math.trunc(t.o/60)),l+=":",l+=vt(Math.trunc(t.o%60)))),o&&(l+="["+t.zone.ianaName+"]"),l}var eq={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},dde={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},pde={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Nh=["year","month","day","hour","minute","second","millisecond"],fde=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],mde=["year","ordinal","hour","minute","second","millisecond"];function Lh(t){let e={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"}[t.toLowerCase()];if(!e)throw new Uh(t);return e}function XF(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Lh(t)}}function hde(t){if(bu===void 0&&(bu=Xe.now()),t.type!=="iana")return t.offset(bu);let e=t.name,r=qx.get(e);return r===void 0&&(r=t.offset(bu),qx.set(e,r)),r}function QF(t,e){let r=oo(e.zone,Xe.defaultZone);if(!r.isValid)return et.invalid(gu(r));let i=ze.fromObject(e),n,o;if(ie(t.year))n=Xe.now();else{for(let l of Nh)ie(t[l])&&(t[l]=eq[l]);let s=T2(t)||C2(t);if(s)return et.invalid(s);let a=hde(r);[n,o]=Mh(t,a,r)}return new et({ts:n,zone:r,loc:i,o})}function e2(t,e,r){let i=ie(r.round)?!0:r.round,n=ie(r.rounding)?"trunc":r.rounding,o=(a,l)=>(a=Wx(a,i||r.calendary?0:2,r.calendary?"round":n),e.loc.clone(r).relFormatter(r).format(a,l)),s=a=>r.calendary?e.hasSame(t,a)?0:e.startOf(a).diff(t.startOf(a),a).get(a):e.diff(t,a).get(a);if(r.unit)return o(s(r.unit),r.unit);for(let a of r.units){let l=s(a);if(Math.abs(l)>=1)return o(l,a)}return o(t>e?-0:0,r.units[r.units.length-1])}function t2(t){let e={},r;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],r=Array.from(t).slice(0,t.length-1)):r=Array.from(t),[e,r]}var bu,qx=new Map,et=class t{constructor(e){let r=e.zone||Xe.defaultZone,i=e.invalid||(Number.isNaN(e.ts)?new Pr("invalid input"):null)||(r.isValid?null:gu(r));this.ts=ie(e.ts)?Xe.now():e.ts;let n=null,o=null;if(!i)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(r))[n,o]=[e.old.c,e.old.o];else{let a=ao(e.o)&&!e.old?e.o:r.offset(this.ts);n=jh(this.ts,a),i=Number.isNaN(n.year)?new Pr("invalid input"):null,n=i?null:n,o=i?null:a}this._zone=r,this.loc=e.loc||ze.create(),this.invalid=i,this.weekData=null,this.localWeekData=null,this.c=n,this.o=o,this.isLuxonDateTime=!0}static now(){return new t({})}static local(){let[e,r]=t2(arguments),[i,n,o,s,a,l,c]=r;return QF({year:i,month:n,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static utc(){let[e,r]=t2(arguments),[i,n,o,s,a,l,c]=r;return e.zone=Nr.utcInstance,QF({year:i,month:n,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static fromJSDate(e,r={}){let i=Bce(e)?e.valueOf():NaN;if(Number.isNaN(i))return t.invalid("invalid input");let n=oo(r.zone,Xe.defaultZone);return n.isValid?new t({ts:i,zone:n,loc:ze.fromObject(r)}):t.invalid(gu(n))}static fromMillis(e,r={}){if(ao(e))return e<-ZF||e>ZF?t.invalid("Timestamp out of range"):new t({ts:e,zone:oo(r.zone,Xe.defaultZone),loc:ze.fromObject(r)});throw new Dt(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,r={}){if(ao(e))return new t({ts:e*1e3,zone:oo(r.zone,Xe.defaultZone),loc:ze.fromObject(r)});throw new Dt("fromSeconds requires a numerical input")}static fromObject(e,r={}){e=e||{};let i=oo(r.zone,Xe.defaultZone);if(!i.isValid)return t.invalid(gu(i));let n=ze.fromObject(r),o=zh(e,XF),{minDaysInFirstWeek:s,startOfWeek:a}=LF(o,n),l=Xe.now(),c=ie(r.specificOffset)?i.offset(l):r.specificOffset,u=!ie(o.ordinal),d=!ie(o.year),f=!ie(o.month)||!ie(o.day),p=d||f,m=o.weekYear||o.weekNumber;if((p||u)&&m)throw new so("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(f&&u)throw new so("Can't mix ordinal dates with month/day");let y=m||o.weekday&&!p,w,_,A=jh(l,c);y?(w=fde,_=dde,A=Fh(A,s,a)):u?(w=mde,_=pde,A=Ex(A)):(w=Nh,_=eq);let O=!1;for(let fe of w){let Ee=o[fe];ie(Ee)?O?o[fe]=_[fe]:o[fe]=A[fe]:O=!0}let C=y?zce(o,s,a):u?Gce(o):T2(o),$=C||C2(o);if($)return t.invalid($);let re=y?MF(o,s,a):u?NF(o):o,[pe,ve]=Mh(re,c,i),me=new t({ts:pe,zone:i,o:ve,loc:n});return o.weekday&&p&&e.weekday!==me.weekday?t.invalid("mismatched weekday",`you can't specify both a weekday of ${o.weekday} and a date of ${me.toISO()}`):me.isValid?me:t.invalid(me.invalid)}static fromISO(e,r={}){let[i,n]=Mue(e);return Za(i,n,r,"ISO 8601",e)}static fromRFC2822(e,r={}){let[i,n]=Nue(e);return Za(i,n,r,"RFC 2822",e)}static fromHTTP(e,r={}){let[i,n]=Lue(e);return Za(i,n,r,"HTTP",r)}static fromFormat(e,r,i={}){if(ie(e)||ie(r))throw new Dt("fromFormat requires an input string and a format");let{locale:n=null,numberingSystem:o=null}=i,s=ze.fromOpts({locale:n,numberingSystem:o,defaultToEN:!0}),[a,l,c,u]=ude(s,e,r);return u?t.invalid(u):Za(a,l,i,`format ${r}`,e,c)}static fromString(e,r,i={}){return t.fromFormat(e,r,i)}static fromSQL(e,r={}){let[i,n]=Gue(e);return Za(i,n,r,"SQL",e)}static invalid(e,r=null){if(!e)throw new Dt("need to specify a reason the DateTime is invalid");let i=e instanceof Pr?e:new Pr(e,r);if(Xe.throwOnInvalid)throw new Tx(i);return new t({invalid:i})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,r={}){let i=X2(e,ze.fromObject(r));return i?i.map(n=>n?n.val:null).join(""):null}static expandFormat(e,r={}){return H2(jr.parseFormat(e),ze.fromObject(r)).map(n=>n.val).join("")}static resetCache(){bu=void 0,qx.clear()}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?Ix(this).weekYear:NaN}get weekNumber(){return this.isValid?Ix(this).weekNumber:NaN}get weekday(){return this.isValid?Ix(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?kx(this).weekday:NaN}get localWeekNumber(){return this.isValid?kx(this).weekNumber:NaN}get localWeekYear(){return this.isValid?kx(this).weekYear:NaN}get ordinal(){return this.isValid?Ex(this.c).ordinal:NaN}get monthShort(){return this.isValid?ls.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?ls.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?ls.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?ls.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let e=864e5,r=6e4,i=Bh(this.c),n=this.zone.offset(i-e),o=this.zone.offset(i+e),s=this.zone.offset(i-n*r),a=this.zone.offset(i-o*r);if(s===a)return[this];let l=i-s*r,c=i-a*r,u=jh(l,s),d=jh(c,a);return u.hour===d.hour&&u.minute===d.minute&&u.second===d.second&&u.millisecond===d.millisecond?[ss(this,{ts:l}),ss(this,{ts:c})]:[this]}get isInLeapYear(){return wu(this.year)}get daysInMonth(){return qh(this.year,this.month)}get daysInYear(){return this.isValid?Ha(this.year):NaN}get weeksInWeekYear(){return this.isValid?Eu(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Eu(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:r,numberingSystem:i,calendar:n}=jr.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:r,numberingSystem:i,outputCalendar:n}}toUTC(e=0,r={}){return this.setZone(Nr.instance(e),r)}toLocal(){return this.setZone(Xe.defaultZone)}setZone(e,{keepLocalTime:r=!1,keepCalendarTime:i=!1}={}){if(e=oo(e,Xe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let n=this.ts;if(r||i){let o=e.offset(this.ts),s=this.toObject();[n]=Mh(s,o,e)}return ss(this,{ts:n,zone:e})}else return t.invalid(gu(e))}reconfigure({locale:e,numberingSystem:r,outputCalendar:i}={}){let n=this.loc.clone({locale:e,numberingSystem:r,outputCalendar:i});return ss(this,{loc:n})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let r=zh(e,XF),{minDaysInFirstWeek:i,startOfWeek:n}=LF(r,this.loc),o=!ie(r.weekYear)||!ie(r.weekNumber)||!ie(r.weekday),s=!ie(r.ordinal),a=!ie(r.year),l=!ie(r.month)||!ie(r.day),c=a||l,u=r.weekYear||r.weekNumber;if((c||s)&&u)throw new so("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&s)throw new so("Can't mix ordinal dates with month/day");let d;o?d=MF({...Fh(this.c,i,n),...r},i,n):ie(r.ordinal)?(d={...this.toObject(),...r},ie(r.day)&&(d.day=Math.min(qh(d.year,d.month),d.day))):d=NF({...Ex(this.c),...r});let[f,p]=Mh(d,this.o,this.zone);return ss(this,{ts:f,o:p})}plus(e){if(!this.isValid)return this;let r=Ot.fromDurationLike(e);return ss(this,HF(this,r))}minus(e){if(!this.isValid)return this;let r=Ot.fromDurationLike(e).negate();return ss(this,HF(this,r))}startOf(e,{useLocaleWeeks:r=!1}={}){if(!this.isValid)return this;let i={},n=Ot.normalizeUnit(e);switch(n){case"years":i.month=1;case"quarters":case"months":i.day=1;case"weeks":case"days":i.hour=0;case"hours":i.minute=0;case"minutes":i.second=0;case"seconds":i.millisecond=0;break}if(n==="weeks")if(r){let o=this.loc.getStartOfWeek(),{weekday:s}=this;s<o&&(i.weekNumber=this.weekNumber-1),i.weekday=o}else i.weekday=1;if(n==="quarters"){let o=Math.ceil(this.month/3);i.month=(o-1)*3+1}return this.set(i)}endOf(e,r){return this.isValid?this.plus({[e]:1}).startOf(e,r).minus(1):this}toFormat(e,r={}){return this.isValid?jr.create(this.loc.redefaultToEN(r)).formatDateTimeFromString(this,e):xx}toLocaleString(e=$h,r={}){return this.isValid?jr.create(this.loc.clone(r),e).formatDateTime(this):xx}toLocaleParts(e={}){return this.isValid?jr.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:r=!1,suppressMilliseconds:i=!1,includeOffset:n=!0,extendedZone:o=!1,precision:s="milliseconds"}={}){if(!this.isValid)return null;s=Lh(s);let a=e==="extended",l=_x(this,a,s);return Nh.indexOf(s)>=3&&(l+="T"),l+=YF(this,a,r,i,n,o,s),l}toISODate({format:e="extended",precision:r="day"}={}){return this.isValid?_x(this,e==="extended",Lh(r)):null}toISOWeekDate(){return Ph(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:r=!1,includeOffset:i=!0,includePrefix:n=!1,extendedZone:o=!1,format:s="extended",precision:a="milliseconds"}={}){return this.isValid?(a=Lh(a),(n&&Nh.indexOf(a)>=3?"T":"")+YF(this,s==="extended",r,e,i,o,a)):null}toRFC2822(){return Ph(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Ph(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?_x(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:r=!1,includeOffsetSpace:i=!0}={}){let n="HH:mm:ss.SSS";return(r||e)&&(i&&(n+=" "),r?n+="z":e&&(n+="ZZ")),Ph(this,n,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():xx}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`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{};let r={...this.c};return e.includeConfig&&(r.outputCalendar=this.outputCalendar,r.numberingSystem=this.loc.numberingSystem,r.locale=this.loc.locale),r}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,r="milliseconds",i={}){if(!this.isValid||!e.isValid)return Ot.invalid("created by diffing an invalid DateTime");let n={locale:this.locale,numberingSystem:this.numberingSystem,...i},o=Wce(r).map(Ot.normalizeUnit),s=e.valueOf()>this.valueOf(),a=s?this:e,l=s?e:this,c=Yue(a,l,o,n);return s?c.negate():c}diffNow(e="milliseconds",r={}){return this.diff(t.now(),e,r)}until(e){return this.isValid?cs.fromDateTimes(this,e):this}hasSame(e,r,i){if(!this.isValid)return!1;let n=e.valueOf(),o=this.setZone(e.zone,{keepLocalTime:!0});return o.startOf(r,i)<=n&&n<=o.endOf(r,i)}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;let r=e.base||t.fromObject({},{zone:this.zone}),i=e.padding?this<r?-e.padding:e.padding:0,n=["years","months","days","hours","minutes","seconds"],o=e.unit;return Array.isArray(e.unit)&&(n=e.unit,o=void 0),e2(r,this.plus(i),{...e,numeric:"always",units:n,unit:o})}toRelativeCalendar(e={}){return this.isValid?e2(e.base||t.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(t.isDateTime))throw new Dt("min requires all arguments be DateTimes");return UF(e,r=>r.valueOf(),Math.min)}static max(...e){if(!e.every(t.isDateTime))throw new Dt("max requires all arguments be DateTimes");return UF(e,r=>r.valueOf(),Math.max)}static fromFormatExplain(e,r,i={}){let{locale:n=null,numberingSystem:o=null}=i,s=ze.fromOpts({locale:n,numberingSystem:o,defaultToEN:!0});return Y2(s,e,r)}static fromStringExplain(e,r,i={}){return t.fromFormatExplain(e,r,i)}static buildFormatParser(e,r={}){let{locale:i=null,numberingSystem:n=null}=r,o=ze.fromOpts({locale:i,numberingSystem:n,defaultToEN:!0});return new Gh(o,e)}static fromFormatParser(e,r,i={}){if(ie(e)||ie(r))throw new Dt("fromFormatParser requires an input string and a format parser");let{locale:n=null,numberingSystem:o=null}=i,s=ze.fromOpts({locale:n,numberingSystem:o,defaultToEN:!0});if(!s.equals(r.locale))throw new Dt(`fromFormatParser called with a locale of ${s}, but the format parser was created for ${r.locale}`);let{result:a,zone:l,specificOffset:c,invalidReason:u}=r.explainFromTokens(e);return u?t.invalid(u):Za(a,l,i,`format ${r.format}`,e,c)}static get DATE_SHORT(){return $h}static get DATE_MED(){return r2}static get DATE_MED_WITH_WEEKDAY(){return kce}static get DATE_FULL(){return n2}static get DATE_HUGE(){return i2}static get TIME_SIMPLE(){return o2}static get TIME_WITH_SECONDS(){return s2}static get TIME_WITH_SHORT_OFFSET(){return a2}static get TIME_WITH_LONG_OFFSET(){return l2}static get TIME_24_SIMPLE(){return c2}static get TIME_24_WITH_SECONDS(){return u2}static get TIME_24_WITH_SHORT_OFFSET(){return d2}static get TIME_24_WITH_LONG_OFFSET(){return p2}static get DATETIME_SHORT(){return f2}static get DATETIME_SHORT_WITH_SECONDS(){return m2}static get DATETIME_MED(){return h2}static get DATETIME_MED_WITH_SECONDS(){return y2}static get DATETIME_MED_WITH_WEEKDAY(){return _ce}static get DATETIME_FULL(){return g2}static get DATETIME_FULL_WITH_SECONDS(){return b2}static get DATETIME_HUGE(){return v2}static get DATETIME_HUGE_WITH_SECONDS(){return S2}};function hu(t){if(et.isDateTime(t))return t;if(t&&t.valueOf&&ao(t.valueOf()))return et.fromJSDate(t);if(t&&typeof t=="object")return et.fromObject(t);throw new Dt(`Unknown datetime argument: ${t}, of type ${typeof t}`)}var yde="3.7.2";Lr.DateTime=et;Lr.Duration=Ot;Lr.FixedOffsetZone=Nr;Lr.IANAZone=gi;Lr.Info=ls;Lr.Interval=cs;Lr.InvalidZone=Jh;Lr.Settings=Xe;Lr.SystemZone=Su;Lr.VERSION=yde;Lr.Zone=lo});var nq=h((OTe,rq)=>{"use strict";var us=tq();ae.prototype.addYear=function(){this._date=this._date.plus({years:1})};ae.prototype.addMonth=function(){this._date=this._date.plus({months:1}).startOf("month")};ae.prototype.addDay=function(){this._date=this._date.plus({days:1}).startOf("day")};ae.prototype.addHour=function(){var t=this._date;this._date=this._date.plus({hours:1}).startOf("hour"),this._date<=t&&(this._date=this._date.plus({hours:1}))};ae.prototype.addMinute=function(){var t=this._date;this._date=this._date.plus({minutes:1}).startOf("minute"),this._date<t&&(this._date=this._date.plus({hours:1}))};ae.prototype.addSecond=function(){var t=this._date;this._date=this._date.plus({seconds:1}).startOf("second"),this._date<t&&(this._date=this._date.plus({hours:1}))};ae.prototype.subtractYear=function(){this._date=this._date.minus({years:1})};ae.prototype.subtractMonth=function(){this._date=this._date.minus({months:1}).endOf("month").startOf("second")};ae.prototype.subtractDay=function(){this._date=this._date.minus({days:1}).endOf("day").startOf("second")};ae.prototype.subtractHour=function(){var t=this._date;this._date=this._date.minus({hours:1}).endOf("hour").startOf("second"),this._date>=t&&(this._date=this._date.minus({hours:1}))};ae.prototype.subtractMinute=function(){var t=this._date;this._date=this._date.minus({minutes:1}).endOf("minute").startOf("second"),this._date>t&&(this._date=this._date.minus({hours:1}))};ae.prototype.subtractSecond=function(){var t=this._date;this._date=this._date.minus({seconds:1}).startOf("second"),this._date>t&&(this._date=this._date.minus({hours:1}))};ae.prototype.getDate=function(){return this._date.day};ae.prototype.getFullYear=function(){return this._date.year};ae.prototype.getDay=function(){var t=this._date.weekday;return t==7?0:t};ae.prototype.getMonth=function(){return this._date.month-1};ae.prototype.getHours=function(){return this._date.hour};ae.prototype.getMinutes=function(){return this._date.minute};ae.prototype.getSeconds=function(){return this._date.second};ae.prototype.getMilliseconds=function(){return this._date.millisecond};ae.prototype.getTime=function(){return this._date.valueOf()};ae.prototype.getUTCDate=function(){return this._getUTC().day};ae.prototype.getUTCFullYear=function(){return this._getUTC().year};ae.prototype.getUTCDay=function(){var t=this._getUTC().weekday;return t==7?0:t};ae.prototype.getUTCMonth=function(){return this._getUTC().month-1};ae.prototype.getUTCHours=function(){return this._getUTC().hour};ae.prototype.getUTCMinutes=function(){return this._getUTC().minute};ae.prototype.getUTCSeconds=function(){return this._getUTC().second};ae.prototype.toISOString=function(){return this._date.toUTC().toISO()};ae.prototype.toJSON=function(){return this._date.toJSON()};ae.prototype.setDate=function(t){this._date=this._date.set({day:t})};ae.prototype.setFullYear=function(t){this._date=this._date.set({year:t})};ae.prototype.setDay=function(t){this._date=this._date.set({weekday:t})};ae.prototype.setMonth=function(t){this._date=this._date.set({month:t+1})};ae.prototype.setHours=function(t){this._date=this._date.set({hour:t})};ae.prototype.setMinutes=function(t){this._date=this._date.set({minute:t})};ae.prototype.setSeconds=function(t){this._date=this._date.set({second:t})};ae.prototype.setMilliseconds=function(t){this._date=this._date.set({millisecond:t})};ae.prototype._getUTC=function(){return this._date.toUTC()};ae.prototype.toString=function(){return this.toDate().toString()};ae.prototype.toDate=function(){return this._date.toJSDate()};ae.prototype.isLastDayOfMonth=function(){var t=this._date.plus({days:1}).startOf("day");return this._date.month!==t.month};ae.prototype.isLastWeekdayOfMonth=function(){var t=this._date.plus({days:7}).startOf("day");return this._date.month!==t.month};function ae(t,e){var r={zone:e};if(t?t instanceof ae?this._date=t._date:t instanceof Date?this._date=us.DateTime.fromJSDate(t,r):typeof t=="number"?this._date=us.DateTime.fromMillis(t,r):typeof t=="string"&&(this._date=us.DateTime.fromISO(t,r),this._date.isValid||(this._date=us.DateTime.fromRFC2822(t,r)),this._date.isValid||(this._date=us.DateTime.fromSQL(t,r)),this._date.isValid||(this._date=us.DateTime.fromFormat(t,"EEE, d MMM yyyy HH:mm:ss",r))):this._date=us.DateTime.local(),!this._date||!this._date.isValid)throw new Error("CronDate: unhandled timestamp: "+JSON.stringify(t));e&&e!==this._date.zoneName&&(this._date=this._date.setZone(e))}rq.exports=ae});var sq=h((ATe,oq)=>{"use strict";function ds(t){return{start:t,count:1}}function iq(t,e){t.end=e,t.step=e-t.start,t.count=2}function Xx(t,e,r){e&&(e.count===2?(t.push(ds(e.start)),t.push(ds(e.end))):t.push(e)),r&&t.push(r)}function gde(t){for(var e=[],r=void 0,i=0;i<t.length;i++){var n=t[i];typeof n!="number"?(Xx(e,r,ds(n)),r=void 0):r?r.count===1?iq(r,n):r.step===n-r.end?(r.count++,r.end=n):r.count===2?(e.push(ds(r.start)),r=ds(r.end),iq(r,n)):(Xx(e,r),r=ds(n)):r=ds(n)}return Xx(e,r),e}oq.exports=gde});var lq=h((KTe,aq)=>{"use strict";var bde=sq();function vde(t,e,r){var i=bde(t);if(i.length===1){var n=i[0],o=n.step;if(o===1&&n.start===e&&n.end===r)return"*";if(o!==1&&n.start===e&&n.end===r-o+1)return"*/"+o}for(var s=[],a=0,l=i.length;a<l;++a){var c=i[a];if(c.count===1){s.push(c.start);continue}var o=c.step;if(c.step===1){s.push(c.start+"-"+c.end);continue}var u=c.start==0?c.count-1:c.count;c.step*u>c.end?s=s.concat(Array.from({length:c.end-c.start+1}).map(function(f,p){var m=c.start+p;return(m-c.start)%c.step===0?m:null}).filter(function(f){return f!=null})):c.end===r-c.step+1?s.push(c.start+"/"+c.step):s.push(c.start+"-"+c.end+"/"+c.step)}return s.join(",")}aq.exports=vde});var dq=h((RTe,uq)=>{"use strict";var ps=nq(),Sde=lq(),cq=1e4;function G(t,e){this._options=e,this._utc=e.utc||!1,this._tz=this._utc?"UTC":e.tz,this._currentDate=new ps(e.currentDate,this._tz),this._startDate=e.startDate?new ps(e.startDate,this._tz):null,this._endDate=e.endDate?new ps(e.endDate,this._tz):null,this._isIterator=e.iterator||!1,this._hasIterated=!1,this._nthDayOfWeek=e.nthDayOfWeek||0,this.fields=G._freezeFields(t)}G.map=["second","minute","hour","dayOfMonth","month","dayOfWeek"];G.predefined={"@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *"};G.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"]}];G.daysInMonth=[31,29,31,30,31,30,31,31,30,31,30,31];G.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}};G.parseDefaults=["0","*","*","*","*","*"];G.standardValidCharacters=/^[,*\d/-]+$/;G.dayOfWeekValidCharacters=/^[?,*\dL#/-]+$/;G.dayOfMonthValidCharacters=/^[?,*\dL/-]+$/;G.validCharacters={second:G.standardValidCharacters,minute:G.standardValidCharacters,hour:G.standardValidCharacters,dayOfMonth:G.dayOfMonthValidCharacters,month:G.standardValidCharacters,dayOfWeek:G.dayOfWeekValidCharacters};G._isValidConstraintChar=function(e,r){return typeof r!="string"?!1:e.chars.some(function(i){return r.indexOf(i)>-1})};G._parseField=function(e,r,i){switch(e){case"month":case"dayOfWeek":var n=G.aliases[e];r=r.replace(/[a-z]{3}/gi,function(l){if(l=l.toLowerCase(),typeof n[l]<"u")return n[l];throw new Error('Validation error, cannot resolve alias "'+l+'"')});break}if(!G.validCharacters[e].test(r))throw new Error("Invalid characters, got value: "+r);r.indexOf("*")!==-1?r=r.replace(/\*/g,i.min+"-"+i.max):r.indexOf("?")!==-1&&(r=r.replace(/\?/g,i.min+"-"+i.max));function o(l){var c=[];function u(m){if(m instanceof Array)for(var y=0,w=m.length;y<w;y++){var _=m[y];if(G._isValidConstraintChar(i,_)){c.push(_);continue}if(typeof _!="number"||Number.isNaN(_)||_<i.min||_>i.max)throw new Error("Constraint error, got value "+_+" expected range "+i.min+"-"+i.max);c.push(_)}else{if(G._isValidConstraintChar(i,m)){c.push(m);return}var A=+m;if(Number.isNaN(A)||A<i.min||A>i.max)throw new Error("Constraint error, got value "+m+" expected range "+i.min+"-"+i.max);e==="dayOfWeek"&&(A=A%7),c.push(A)}}var d=l.split(",");if(!d.every(function(m){return m.length>0}))throw new Error("Invalid list value format");if(d.length>1)for(var f=0,p=d.length;f<p;f++)u(s(d[f]));else u(s(l));return c.sort(G._sortCompareFn),c}function s(l){var c=1,u=l.split("/");if(u.length>2)throw new Error("Invalid repeat: "+l);return u.length>1?(u[0]==+u[0]&&(u=[u[0]+"-"+i.max,u[1]]),a(u[0],u[u.length-1])):a(l,c)}function a(l,c){var u=[],d=l.split("-");if(d.length>1){if(d.length<2)return+l;if(!d[0].length){if(!d[1].length)throw new Error("Invalid range: "+l);return+l}var f=+d[0],p=+d[1];if(Number.isNaN(f)||Number.isNaN(p)||f<i.min||p>i.max)throw new Error("Constraint error, got range "+f+"-"+p+" expected range "+i.min+"-"+i.max);if(f>p)throw new Error("Invalid range: "+l);var m=+c;if(Number.isNaN(m)||m<=0)throw new Error("Constraint error, cannot repeat at every "+m+" time.");e==="dayOfWeek"&&p%7===0&&u.push(0);for(var y=f,w=p;y<=w;y++){var _=u.indexOf(y)!==-1;!_&&m>0&&m%c===0?(m=1,u.push(y)):m++}return u}return Number.isNaN(+l)?l:+l}return o(r)};G._sortCompareFn=function(t,e){var r=typeof t=="number",i=typeof e=="number";return r&&i?t-e:!r&&i?1:r&&!i?-1:t.localeCompare(e)};G._handleMaxDaysInMonth=function(t){if(t.month.length===1){var e=G.daysInMonth[t.month[0]-1];if(t.dayOfMonth[0]>e)throw new Error("Invalid explicit day of month definition");return t.dayOfMonth.filter(function(r){return r==="L"?!0:r<=e}).sort(G._sortCompareFn)}};G._freezeFields=function(t){for(var e=0,r=G.map.length;e<r;++e){var i=G.map[e],n=t[i];t[i]=Object.freeze(n)}return Object.freeze(t)};G.prototype._applyTimezoneShift=function(t,e,r){if(r==="Month"||r==="Day"){var i=t.getTime();t[e+r]();var n=t.getTime();i===n&&(t.getMinutes()===0&&t.getSeconds()===0?t.addHour():t.getMinutes()===59&&t.getSeconds()===59&&t.subtractHour())}else{var o=t.getHours();t[e+r]();var s=t.getHours(),a=s-o;a===2?this.fields.hour.length!==24&&(this._dstStart=s):a===0&&t.getMinutes()===0&&t.getSeconds()===0&&this.fields.hour.length!==24&&(this._dstEnd=s)}};G.prototype._findSchedule=function(e){function r(_,A){for(var O=0,C=A.length;O<C;O++)if(A[O]>=_)return A[O]===_;return A[0]===_}function i(_,A){if(A<6){if(_.getDate()<8&&A===1)return!0;var O=_.getDate()%7?1:0,C=_.getDate()-_.getDate()%7,$=Math.floor(C/7)+O;return $===A}return!1}function n(_){return _.length>0&&_.some(function(A){return typeof A=="string"&&A.indexOf("L")>=0})}e=e||!1;var o=e?"subtract":"add",s=new ps(this._currentDate,this._tz),a=this._startDate,l=this._endDate,c=s.getTime(),u=0;function d(_){return _.some(function(A){if(!n([A]))return!1;var O=Number.parseInt(A[0])%7;if(Number.isNaN(O))throw new Error("Invalid last weekday of the month expression: "+A);return s.getDay()===O&&s.isLastWeekdayOfMonth()})}for(;u<cq;){if(u++,e){if(a&&s.getTime()-a.getTime()<0)throw new Error("Out of the timespan range")}else if(l&&l.getTime()-s.getTime()<0)throw new Error("Out of the timespan range");var f=r(s.getDate(),this.fields.dayOfMonth);n(this.fields.dayOfMonth)&&(f=f||s.isLastDayOfMonth());var p=r(s.getDay(),this.fields.dayOfWeek);n(this.fields.dayOfWeek)&&(p=p||d(this.fields.dayOfWeek));var m=this.fields.dayOfMonth.length>=G.daysInMonth[s.getMonth()],y=this.fields.dayOfWeek.length===G.constraints[5].max-G.constraints[5].min+1,w=s.getHours();if(!f&&(!p||y)){this._applyTimezoneShift(s,o,"Day");continue}if(!m&&y&&!f){this._applyTimezoneShift(s,o,"Day");continue}if(m&&!y&&!p){this._applyTimezoneShift(s,o,"Day");continue}if(this._nthDayOfWeek>0&&!i(s,this._nthDayOfWeek)){this._applyTimezoneShift(s,o,"Day");continue}if(!r(s.getMonth()+1,this.fields.month)){this._applyTimezoneShift(s,o,"Month");continue}if(r(w,this.fields.hour)){if(this._dstEnd===w&&!e){this._dstEnd=null,this._applyTimezoneShift(s,"add","Hour");continue}}else if(this._dstStart!==w){this._dstStart=null,this._applyTimezoneShift(s,o,"Hour");continue}else if(!r(w-1,this.fields.hour)){s[o+"Hour"]();continue}if(!r(s.getMinutes(),this.fields.minute)){this._applyTimezoneShift(s,o,"Minute");continue}if(!r(s.getSeconds(),this.fields.second)){this._applyTimezoneShift(s,o,"Second");continue}if(c===s.getTime()){o==="add"||s.getMilliseconds()===0?this._applyTimezoneShift(s,o,"Second"):s.setMilliseconds(0);continue}break}if(u>=cq)throw new Error("Invalid expression, loop limit exceeded");return this._currentDate=new ps(s,this._tz),this._hasIterated=!0,s};G.prototype.next=function(){var e=this._findSchedule();return this._isIterator?{value:e,done:!this.hasNext()}:e};G.prototype.prev=function(){var e=this._findSchedule(!0);return this._isIterator?{value:e,done:!this.hasPrev()}:e};G.prototype.hasNext=function(){var t=this._currentDate,e=this._hasIterated;try{return this._findSchedule(),!0}catch{return!1}finally{this._currentDate=t,this._hasIterated=e}};G.prototype.hasPrev=function(){var t=this._currentDate,e=this._hasIterated;try{return this._findSchedule(!0),!0}catch{return!1}finally{this._currentDate=t,this._hasIterated=e}};G.prototype.iterate=function(e,r){var i=[];if(e>=0)for(var n=0,o=e;n<o;n++)try{var s=this.next();i.push(s),r&&r(s,n)}catch{break}else for(var n=0,o=e;n>o;n--)try{var s=this.prev();i.push(s),r&&r(s,n)}catch{break}return i};G.prototype.reset=function(e){this._currentDate=new ps(e||this._options.currentDate)};G.prototype.stringify=function(e){for(var r=[],i=e?0:1,n=G.map.length;i<n;++i){var o=G.map[i],s=this.fields[o],a=G.constraints[i];o==="dayOfMonth"&&this.fields.month.length===1?a={min:1,max:G.daysInMonth[this.fields.month[0]-1]}:o==="dayOfWeek"&&(a={min:0,max:6},s=s[s.length-1]===7?s.slice(0,-1):s),r.push(Sde(s,a.min,a.max))}return r.join(" ")};G.parse=function(e,r){var i=this;typeof r=="function"&&(r={});function n(o,s){s||(s={}),typeof s.currentDate>"u"&&(s.currentDate=new ps(void 0,i._tz)),G.predefined[o]&&(o=G.predefined[o]);var a=[],l=(o+"").trim().split(/\s+/);if(l.length>6)throw new Error("Invalid cron expression");for(var c=G.map.length-l.length,u=0,d=G.map.length;u<d;++u){var f=G.map[u],p=l[l.length>d?u:u-c];if(u<c||!p)a.push(G._parseField(f,G.parseDefaults[u],G.constraints[u]));else{var m=f==="dayOfWeek"?A(p):p;a.push(G._parseField(f,m,G.constraints[u]))}}for(var y={},u=0,d=G.map.length;u<d;u++){var w=G.map[u];y[w]=a[u]}var _=G._handleMaxDaysInMonth(y);return y.dayOfMonth=_||y.dayOfMonth,new G(y,s);function A(O){var C=O.split("#");if(C.length>1){var $=+C[C.length-1];if(/,/.test(O))throw new Error("Constraint error, invalid dayOfWeek `#` and `,` special characters are incompatible");if(/\//.test(O))throw new Error("Constraint error, invalid dayOfWeek `#` and `/` special characters are incompatible");if(/-/.test(O))throw new Error("Constraint error, invalid dayOfWeek `#` and `-` special characters are incompatible");if(C.length>2||Number.isNaN($)||$<1||$>5)throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return s.nthDayOfWeek=$,C[0]}return O}}return n(e,r)};G.fieldsToExpression=function(e,r){function i(f,p,m){if(!p)throw new Error("Validation error, Field "+f+" is missing");if(p.length===0)throw new Error("Validation error, Field "+f+" contains no values");for(var y=0,w=p.length;y<w;y++){var _=p[y];if(!G._isValidConstraintChar(m,_)&&(typeof _!="number"||Number.isNaN(_)||_<m.min||_>m.max))throw new Error("Constraint error, got value "+_+" expected range "+m.min+"-"+m.max)}}for(var n={},o=0,s=G.map.length;o<s;++o){var a=G.map[o],l=e[a];i(a,l,G.constraints[o]);for(var c=[],u=-1;++u<l.length;)c[u]=l[u];if(l=c.sort(G._sortCompareFn).filter(function(f,p,m){return!p||f!==m[p-1]}),l.length!==c.length)throw new Error("Validation error, Field "+a+" contains duplicate values");n[a]=l}var d=G._handleMaxDaysInMonth(n);return n.dayOfMonth=d||n.dayOfMonth,new G(n,r||{})};uq.exports=G});var Qx=h((DTe,pq)=>{"use strict";var Hh=dq();function co(){}co._parseEntry=function(e){var r=e.split(" ");if(r.length===6)return{interval:Hh.parse(e)};if(r.length>6)return{interval:Hh.parse(r.slice(0,6).join(" ")),command:r.slice(6,r.length)};throw new Error("Invalid entry: "+e)};co.parseExpression=function(e,r){return Hh.parse(e,r)};co.fieldsToExpression=function(e,r){return Hh.fieldsToExpression(e,r)};co.parseString=function(e){for(var r=e.split(`
9951
+ Current: ${this.version}`)}this.capabilities={canDoubleTimeout:!(0,Sr.isRedisVersionLowerThan)(this.version,"6.0.0",this.dbType),canBlockFor1Ms:!(0,Sr.isRedisVersionLowerThan)(this.version,"7.0.8",this.dbType)},this.status="ready"}return this._client}patchBlockingClusterClient(){var e;let r=this._client,i=r;if(!this.extraOptions.blocking||!(0,Sr.isRedisCluster)(r)||typeof i.bzpopmin!="function")return;let n=(e=this.extraOptions.clusterReconnectTimeoutMs)!==null&&e!==void 0?e:vF;if(i[Va]=(i[Va]||0)+1,this.patchedBlockingClusterClient=i,i[ux])return;let o=i.bzpopmin,s=async(...a)=>{await t.reconnectClusterIfNeeded(i,n);try{return await o.apply(i,a)}catch(l){let c=l;if(t.shouldReconnectClusterAfterError(i,c))try{await t.reconnectCluster(i,n)}catch{}throw c}};i[kh]=o,i[dx]=s,i[ux]=!0,i.bzpopmin=s}disableBlockingClusterReconnect(){let e=this.patchedBlockingClusterClient;!e||this.disabledBlockingClusterReconnect||(e[is]=(e[is]||0)+1,this.disabledBlockingClusterReconnect=!0)}releaseBlockingClusterClientPatch(){let e=this.patchedBlockingClusterClient;if(!e)return;if(this.disabledBlockingClusterReconnect){let i=(e[is]||1)-1;i>0?e[is]=i:delete e[is],this.disabledBlockingClusterReconnect=!1}let r=(e[Va]||1)-1;if(r>0){e[Va]=r,this.patchedBlockingClusterClient=void 0;return}e[kh]&&e.bzpopmin===e[dx]&&(e.bzpopmin=e[kh]),delete e[Va],delete e[is],delete e[kh],delete e[dx],delete e[ux],this.patchedBlockingClusterClient=void 0}static isClusterWithEmptyNodes(e){return typeof e.nodes=="function"&&e.nodes().length===0}static isReconnectingDisabled(e){let r=e[Va]||0,i=e[is]||0;return r===0||i>=r||e.status==="end"||e.status==="closing"}static async reconnectClusterIfNeeded(e,r){!t.isReconnectingDisabled(e)&&t.isClusterWithEmptyNodes(e)&&await t.reconnectCluster(e,r)}static shouldReconnectClusterAfterError(e,r){var i,n;if(t.isReconnectingDisabled(e))return!1;let o=[r.message,(i=r.cause)===null||i===void 0?void 0:i.message,(n=r.lastNodeError)===null||n===void 0?void 0:n.message].join(" ");return t.isClusterWithEmptyNodes(e)||/Command timed out|Failed to refresh slots cache/i.test(o)}static async reconnectCluster(e,r){t.isReconnectingDisabled(e)||(e[Ih]||(e[Ih]=t.connectClusterWithTimeout(e,r).finally(()=>{e[Ih]=null})),await e[Ih])}static async connectClusterWithTimeout(e,r){e.disconnect(!1);let i;try{await Promise.race([e.connect(),new Promise((n,o)=>{var s;i=setTimeout(()=>{o(new cx.ConnectionClosedError(`BullMQ: cluster reconnect timed out after ${r}ms`))},r),(s=i.unref)===null||s===void 0||s.call(i)})])}finally{i&&clearTimeout(i)}}async disconnect(e=!0){let r=await this.client;if(r.status!=="end"){let i,n;if(!e)return r.disconnect();let o=new Promise((s,a)=>{(0,Sr.increaseMaxListeners)(r,2),r.once("end",s),r.once("error",a),i=s,n=a});r.disconnect();try{await o}finally{(0,Sr.decreaseMaxListeners)(r,2),r.removeListener("end",i),r.removeListener("error",n)}}}async reconnect(){return(await this.client).connect()}async close(e=!1){var r;if(!this.closing){let i=this.status;this.status="closing",this.closing=!0,this.disableBlockingClusterReconnect();try{i==="ready"&&await this.initializing,this.extraOptions.shared||(i=="initializing"||e?(this._client.disconnect(),(r=this.initializing)===null||r===void 0||r.catch(()=>{})):await this._client.quit(),this._client.status="end")}catch(n){if((0,Sr.isNotConnectionError)(n))throw n}finally{this.releaseBlockingClusterClientPatch(),this._client.off("error",this.handleClientError),this._client.off("close",this.handleClientClose),this._client.off("ready",this.handleClientReady),(0,Sr.decreaseMaxListeners)(this._client,3),this.removeAllListeners(),this.status="closed"}}}async getRedisVersionAndType(){if(this.skipVersionCheck)return{version:t.minimumVersion,databaseType:"redis"};let e=await this._client.info(),r="redis_version:",i="maxmemory_policy:",n=e.split(/\r?\n/),o,s="redis";for(let a=0;a<n.length;a++){let l=n[a];if(l.includes("dragonfly_version:")||l.includes("server:Dragonfly")?(s="dragonfly",l.indexOf("dragonfly_version:")===0&&(o=l.substr(18))):l.includes("valkey_version:")||l.includes("server:Valkey")?(s="valkey",l.indexOf("valkey_version:")===0&&(o=l.substr(15))):l.indexOf(r)===0&&(o=l.substr(r.length),s==="redis"&&(s="redis")),l.indexOf(i)===0){let c=l.substr(i.length);c!=="noeviction"&&console.warn(`IMPORTANT! Eviction policy is ${c}. It should be "noeviction"`)}}if(!o){for(let a of n)if(a.includes("version:")){let l=a.split(":");if(l.length>=2){o=l[1];break}}}return{version:o||t.minimumVersion,databaseType:s}}get redisVersion(){return this.version}get databaseType(){return this.dbType}};_h.RedisConnection=fu;fu.minimumVersion="5.0.0";fu.recommendedMinimumVersion="6.2.0"});var SF=h(Ch=>{"use strict";Object.defineProperty(Ch,"__esModule",{value:!0});Ch.FlowProducer=void 0;var pce=U("events"),no=Or(),fce=Pa(),Th=sm(),mce=mu(),qn=gr(),px=class extends pce.EventEmitter{constructor(e={connection:{}},r=mce.RedisConnection){super(),this.opts=e,this.opts=Object.assign({prefix:"bull"},e),this.connection=new r(e.connection,{shared:(0,no.isRedisInstance)(e.connection),blocking:!1,skipVersionCheck:e.skipVersionCheck,skipWaitingForReady:e.skipWaitingForReady}),this.connection.on("error",i=>this.emit("error",i)),this.connection.on("close",()=>{this.closing||this.emit("ioredis:close")}),this.queueKeys=new Th.QueueKeys(e.prefix),e?.telemetry&&(this.telemetry=e.telemetry)}emit(e,...r){return super.emit(e,...r)}off(e,r){return super.off(e,r),this}on(e,r){return super.on(e,r),this}once(e,r){return super.once(e,r),this}get client(){return this.connection.client}get Job(){return fce.Job}waitUntilReady(){return this.client}async add(e,r){var i;if(this.closing)return;let o=(await this.connection.client).multi(),s=(i=e?.opts)===null||i===void 0?void 0:i.parent,a=(0,no.getParentKey)(s),l=a?`${a}:dependencies`:void 0;return(0,no.trace)(this.telemetry,qn.SpanKind.PRODUCER,e.queueName,"addFlow",e.queueName,async c=>{c?.setAttributes({[qn.TelemetryAttributes.FlowName]:e.name});let u=await this.addNode({multi:o,node:e,queuesOpts:r?.queuesOptions,parent:{parentOpts:s,parentDependenciesKey:l}}),d=await o.exec(),[f]=d||[];if(f){let[p,m]=f;if(p)throw p;if(typeof m=="number"&&m<0)throw this.toFlowError(m,a);typeof m=="string"&&(u.job.id=m)}return u})}async getFlow(e){if(this.closing)return;let r=await this.connection.client,i=Object.assign({depth:10,maxChildren:20,prefix:this.opts.prefix},e);return this.getNode(r,i)}async addBulk(e){if(this.closing)return;let i=(await this.connection.client).multi();return(0,no.trace)(this.telemetry,qn.SpanKind.PRODUCER,"","addBulkFlows","",async n=>{n?.setAttributes({[qn.TelemetryAttributes.BulkCount]:e.length,[qn.TelemetryAttributes.BulkNames]:e.map(a=>a.name).join(",")});let o=await this.addNodes(i,e),s=await i.exec();for(let a=0;a<o.length;++a){let l=s?.[a];if(!l)continue;let[c,u]=l;!c&&typeof u=="string"&&(o[a].job.id=u)}return o})}async addNode({multi:e,node:r,parent:i,queuesOpts:n}){var o,s;let a=r.prefix||this.opts.prefix,l=this.queueFromNode(r,new Th.QueueKeys(a),a),c=n&&n[r.queueName],u=(o=c?.defaultJobOptions)!==null&&o!==void 0?o:{},d=((s=r.opts)===null||s===void 0?void 0:s.jobId)||(0,no.randomUUID)();return(0,no.trace)(this.telemetry,qn.SpanKind.PRODUCER,r.queueName,"addNode",r.queueName,async(f,p)=>{var m,y;f?.setAttributes({[qn.TelemetryAttributes.JobName]:r.name,[qn.TelemetryAttributes.JobId]:d});let w=r.opts,_=w?.telemetry;if(p&&w){let C=(m=w.telemetry)===null||m===void 0?void 0:m.omitContext,$=((y=w.telemetry)===null||y===void 0?void 0:y.metadata)||!C&&p;($||C)&&(_={metadata:$,omitContext:C})}let A=new this.Job(l,r.name,r.data,Object.assign(Object.assign(Object.assign({},u),w),{parent:i?.parentOpts,telemetry:_}),d),O=(0,no.getParentKey)(i?.parentOpts);if(r.children&&r.children.length>0){let C=d,$=new Th.QueueKeys(r.prefix||this.opts.prefix);await A.addJob(e,{parentDependenciesKey:i?.parentDependenciesKey,addToWaitingChildren:!0,parentKey:O});let re=`${$.toKey(r.queueName,C)}:dependencies`,pe=await this.addChildren({multi:e,nodes:r.children,parent:{parentOpts:{id:C,queue:$.getQueueQualifiedName(r.queueName)},parentDependenciesKey:re},queuesOpts:n});return{job:A,children:pe}}else return await A.addJob(e,{parentDependenciesKey:i?.parentDependenciesKey,parentKey:O}),{job:A}})}addNodes(e,r){return Promise.all(r.map(i=>{var n;let o=(n=i?.opts)===null||n===void 0?void 0:n.parent,s=(0,no.getParentKey)(o),a=s?`${s}:dependencies`:void 0;return this.addNode({multi:e,node:i,parent:{parentOpts:o,parentDependenciesKey:a}})}))}async getNode(e,r){let i=this.queueFromNode(r,new Th.QueueKeys(r.prefix),r.prefix),n=await this.Job.fromId(i,r.id);if(n){let{processed:o={},unprocessed:s=[],failed:a=[],ignored:l={}}=await n.getDependencies({failed:{count:r.maxChildren},processed:{count:r.maxChildren},unprocessed:{count:r.maxChildren},ignored:{count:r.maxChildren}}),c=Object.keys(o),u=Object.keys(l),d=c.length+s.length+u.length+a.length,f=r.depth-1;if(d>0&&f){let p=await this.getChildren(e,[...c,...s,...a,...u],f,r.maxChildren);return{job:n,children:p}}else return{job:n}}}addChildren({multi:e,nodes:r,parent:i,queuesOpts:n}){return Promise.all(r.map(o=>this.addNode({multi:e,node:o,parent:i,queuesOpts:n})))}getChildren(e,r,i,n){let o=s=>{let[a,l,c]=s.split(":");return this.getNode(e,{id:c,queueName:l,prefix:a,depth:i,maxChildren:n})};return Promise.all([...r.map(o)])}queueFromNode(e,r,i){return{client:this.connection.client,name:e.queueName,keys:r.getKeys(e.queueName),toKey:n=>r.toKey(e.queueName,n),opts:{prefix:i,connection:{}},qualifiedName:r.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,databaseType:this.connection.databaseType,trace:async()=>{}}}toFlowError(e,r){let i;switch(e){case qn.ErrorCode.ParentJobNotExist:i=new Error(`Missing key for parent job ${r}. addJob`);break;case qn.ErrorCode.ParentJobCannotBeReplaced:i=new Error(`The parent job ${r} cannot be replaced. addJob`);break;default:i=new Error(`Unknown code ${e} error for addJob`)}return i.code=e,i}async close(){this.closing||(this.closing=this.connection.close()),await this.closing}disconnect(){return this.connection.disconnect()}};Ch.FlowProducer=px});var wF=h(hx=>{"use strict";Object.defineProperty(hx,"__esModule",{value:!0});hx.createNodeRedisClient=vce;var hce=(Zt(),Jt(Wt)),yce=U("crypto"),gce=U("events"),bce=U("stream"),Oh=_a();function EF(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function zn(t){return t?.message==="Disconnects client"||t?.message==="The client is closed"||t?.message==="Connection is closed."}function vce(t){return new fx(t)}var fx=class t extends gce.EventEmitter{get status(){return this.statusOverride?this.statusOverride:this.raw.isReady?"ready":this.raw.isOpen?"connect":this.hasConnected?"end":"wait"}set status(e){if(e==="end"&&(this.destroying=!0,this.raw.isOpen))try{this.raw.quit().catch(()=>{})}catch{}this.statusOverride=e}get options(){var e;return(e=this.raw.options)!==null&&e!==void 0?e:{}}set options(e){}constructor(e){super(),this.raw=e,this.scripts=new Map,this.hasConnected=!1,this.destroying=!1,this.isCluster=!1,e.on("ready",()=>{this.hasConnected=!0,this.connectionName?this.raw.clientSetName(this.connectionName).then(()=>this.emit("ready"),()=>this.emit("ready")):this.emit("ready")}),e.on("error",r=>{this.destroying&&zn(r)||this.emit("error",r)}),e.on("end",()=>this.emit("close")),e.on("reconnecting",()=>this.emit("reconnecting")),e.isOpen||(this.connectPromise=e.connect().then(()=>{this.connectPromise=void 0},r=>{this.connectPromise=void 0}))}async connect(){if(this.connectPromise)return this.connectPromise;if(!this.raw.isOpen)return this.connectPromise=this.raw.connect().then(()=>{this.connectPromise=void 0},e=>{throw this.connectPromise=void 0,e}),this.connectPromise;this.raw.isReady||await new Promise((e,r)=>{let i=()=>{s(),e()},n=a=>{s(),r(a)},o=()=>{s(),r(new Error("Connection ended before ready event"))},s=()=>{this.off("ready",i),this.off("error",n),this.off("end",o)};this.once("ready",i),this.once("error",n),this.once("end",o)})}disconnect(e=!1){this.destroying=!0,e||(this.statusOverride="end");try{this.raw.isOpen&&this.raw.destroy()}catch{}this.emit("close"),e?(this.statusOverride=void 0,this.emit("reconnecting"),this.connect().catch(r=>{zn(r)||this.emit("error",r)}).finally(()=>{this.destroying=!1})):this.emit("end")}async quit(){if(this.destroying||this.statusOverride==="end")return setImmediate(()=>{this.emit("end"),this.emit("close")}),"OK";this.destroying=!0;try{if(this.raw.isOpen)try{await this.raw.quit()}catch{}}catch{}return this.statusOverride="end",setImmediate(()=>{this.emit("end"),this.emit("close")}),"OK"}duplicate(...e){let r=this.raw.duplicate(),i=new t(r);for(let[o,s]of this.scripts)i.scripts.set(o,s),i[o]=(...a)=>i.runCommand(o,a);let n=e[0];return n&&typeof n=="object"&&n.connectionName&&(i.connectionName=n.connectionName),i}defineCommand(e,r){let i=(0,yce.createHash)("sha1").update(r.lua).digest("hex");this.scripts.set(e,{sha:i,lua:r.lua,numberOfKeys:r.numberOfKeys}),this[e]=(...n)=>this.runCommand(e,n),this.raw.scriptLoad(r.lua).catch(()=>{})}async runCommand(e,r){var i,n;let o=this.scripts.get(e);if(!o)throw new Error(`BullMQ: unknown command "${e}"`);let s=EF(r),{sha:a,lua:l,numberOfKeys:c}=o,u=s.slice(0,c).map(String),d=s.slice(c).map(f=>Buffer.isBuffer(f)?f:f==null?"":String(f));try{return await this.raw.evalSha(a,{keys:u,arguments:d})}catch(f){if(this.destroying&&zn(f))return null;if(zn(f))throw new Oh.ConnectionClosedError(f.message,f);if(!((n=(i=f?.message)===null||i===void 0?void 0:i.includes)===null||n===void 0)&&n.call(i,"NOSCRIPT"))try{return await this.raw.eval(l,{keys:u,arguments:d})}catch(p){if(this.destroying&&zn(p))return null;throw zn(p)?new Oh.ConnectionClosedError(p.message,p):p}throw f}}multi(){return new mx(this.raw.multi(),this.scripts)}pipeline(){return this.multi()}async hgetall(e){let r=await this.raw.hGetAll(e);return r??{}}async hget(e,r){var i;return(i=await this.raw.hGet(e,r))!==null&&i!==void 0?i:null}async hmget(e,...r){return(await this.raw.hmGet(e,r)).map(n=>n??null)}async hset(e,r,...i){if(typeof r=="object")return await this.raw.hSet(e,r);let n={};n[r]=String(i[0]);for(let o=1;o<i.length;o+=2)n[String(i[o])]=String(i[o+1]);return await this.raw.hSet(e,n)}async hdel(e,...r){return await this.raw.hDel(e,r)}async hexists(e,r){return await this.raw.hExists(e,r)?1:0}async get(e){var r;return(r=await this.raw.get(e))!==null&&r!==void 0?r:null}async set(e,r,i){let n={};return i?.PX!=null?n.PX=i.PX:i?.EX!=null&&(n.EX=i.EX),await this.raw.set(e,String(r),n)}async del(...e){return e.length===0?0:await this.raw.del(e)}async zrange(e,r,i,n){if(n?.WITHSCORES){let o=await this.raw.zRangeWithScores(e,r,i),s=[];for(let a of o)s.push(a.value,String(a.score));return s}return await this.raw.zRange(e,r,i)}async zrevrange(e,r,i,n){if(n?.WITHSCORES){let o=await this.raw.zRangeWithScores(e,r,i,{REV:!0}),s=[];for(let a of o)s.push(a.value,String(a.score));return s}return await this.raw.zRange(e,r,i,{REV:!0})}async zcard(e){return await this.raw.zCard(e)}async zscore(e,r){let i=await this.raw.zScore(e,r);return i!=null?String(i):null}async lrange(e,r,i){return await this.raw.lRange(e,r,i)}async llen(e){return await this.raw.lLen(e)}async ltrim(e,r,i){return await this.raw.lTrim(e,r,i),"OK"}async lpos(e,r){var i;return(i=await this.raw.lPos(e,r))!==null&&i!==void 0?i:null}async smembers(e){return await this.raw.sMembers(e)}async xadd(e,r,i,n){let o={};n?.MAXLEN!=null&&(o.TRIM={strategy:"MAXLEN",threshold:n.MAXLEN,strategyModifier:n.approximate===!1?void 0:"~"});let s={};for(let[a,l]of Object.entries(i))s[a]=String(l);return await this.raw.xAdd(e,r,s,o)}async xread(e,r){let i={};r?.BLOCK!=null&&(i.BLOCK=r.BLOCK),r?.COUNT!=null&&(i.COUNT=r.COUNT);let n=e.map(s=>({key:s.key,id:s.id})),o;try{o=await this.raw.xRead(n,i)}catch(s){if(this.destroying&&zn(s))return null;throw zn(s)?new Oh.ConnectionClosedError(s.message,s):s}return o?o.map(s=>[s.name,s.messages.map(a=>[a.id,Object.entries(a.message).flat()])]):null}async xtrim(e,r,i,n){let o=n?.approximate===!1?void 0:"~";return await this.raw.xTrim(e,r,i,{strategyModifier:o})}async bzpopmin(e,r){let i;try{i=await this.raw.bzPopMin(e,r)}catch(n){if(this.destroying&&zn(n))return null;throw zn(n)?new Oh.ConnectionClosedError(n.message,n):n}return i?[i.key,i.value,String(i.score)]:null}async info(){return await this.raw.info()}async clientSetName(e){return await this.raw.clientSetName(e)}async clientList(){return await this.raw.sendCommand(["CLIENT","LIST"])}async scan(e,r){let i={};r?.MATCH&&(i.MATCH=r.MATCH),r?.COUNT&&(i.COUNT=r.COUNT);let n=await this.raw.scan(String(e),i);return[String(n.cursor),n.keys]}scanStream(e){let r=this.raw,i=this.connectPromise,n={};e.match&&(n.MATCH=e.match),e.count&&(n.COUNT=e.count);let o=new bce.Readable({objectMode:!0,async read(){var s,a,l,c;try{i&&await i;try{for(var u=!0,d=hce.__asyncValues(r.scanIterator(n)),f;f=await d.next(),s=f.done,!s;u=!0){c=f.value,u=!1;let p=c;if(!o.push(Array.isArray(p)?p:[p]))return}}catch(p){a={error:p}}finally{try{!u&&!s&&(l=d.return)&&await l.call(d)}finally{if(a)throw a.error}}o.push(null)}catch(p){o.destroy(p)}}});return o}async keys(e){return await this.raw.keys(e)}async exists(...e){return e.length===0?0:await this.raw.exists(e)}async zadd(e,...r){let i=[];for(let n=0;n<r.length;n+=2)i.push({score:Number(r[n]),value:String(r[n+1])});return await this.raw.zAdd(e,i)}async zrem(e,...r){return await this.raw.zRem(e,r)}async xlen(e){return await this.raw.xLen(e)}async xrevrange(e,r,i,...n){let o={};return n[0]==="COUNT"&&(o.COUNT=Number(n[1])),(await this.raw.xRevRange(e,r,i,o)).map(a=>[a.id,Object.entries(a.message).flat()])}async sadd(e,...r){return await this.raw.sAdd(e,r.map(String))}async scard(e){return await this.raw.sCard(e)}async lpush(e,...r){return await this.raw.lPush(e,r)}async rpop(e){return await this.raw.rPop(e)}async incr(e){return await this.raw.incr(e)}async incrby(e,r){return await this.raw.incrBy(e,r)}async flushall(){return await this.raw.flushAll()}},mx=class{constructor(e,r){this.raw=e,this.scripts=r,this.transformers=[]}addIdentityTransformer(){this.transformers.push(e=>e)}hgetall(e){return this.raw.hGetAll(e),this.addIdentityTransformer(),this}hset(e,r){return this.raw.hSet(e,r),this.addIdentityTransformer(),this}hscan(e,r,i){let n={};return i?.COUNT!=null&&(n.COUNT=i.COUNT),this.raw.hScan(e,String(r),n),this.transformers.push(o=>{if(!o)return["0",[]];let s=[];for(let a of o.entries||[])s.push(a.field,a.value);return[String(o.cursor),s]}),this}smembers(e){return this.raw.sMembers(e),this.addIdentityTransformer(),this}sscan(e,r,i){let n={};return i?.COUNT!=null&&(n.COUNT=i.COUNT),this.raw.sScan(e,String(r),n),this.transformers.push(o=>o?[String(o.cursor),o.members||[]]:["0",[]]),this}zrange(e,r,i){return this.raw.zRange(e,r,i),this.addIdentityTransformer(),this}lrange(e,r,i){return this.raw.lRange(e,r,i),this.addIdentityTransformer(),this}llen(e){return this.raw.lLen(e),this.addIdentityTransformer(),this}del(...e){return e.length>0&&(this.raw.del(e),this.addIdentityTransformer()),this}runCommand(e,r){let i=this.scripts.get(e);if(!i)throw new Error(`BullMQ: unknown command "${e}" in transaction`);let n=EF(r),{sha:o,lua:s,numberOfKeys:a}=i,l=n.slice(0,a).map(String),c=n.slice(a).map(u=>Buffer.isBuffer(u)?u:u==null?"":String(u));return this.raw.evalSha(o,{keys:l,arguments:c}),this.addIdentityTransformer(),this}async exec(){let e=await this.raw.exec();return e?e.map((r,i)=>{if(r instanceof Error)return[r,null];let n=this.transformers[i];return[null,n?n(r):r]}):null}}});var kF=h(gx=>{"use strict";Object.defineProperty(gx,"__esModule",{value:!0});gx.createBunRedisClient=Ice;var Sce=U("crypto"),Ece=U("events"),wce=U("stream"),xF=_a();function IF(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function xce(t){var e;let r=(e=t?.message)!==null&&e!==void 0?e:"";return r==="Socket closed unexpectedly"||r.startsWith("Connection closed")||r==="Connection is closed."||r==="Connection has failed"}function Ah(t){return t==null?[]:Array.isArray(t)?t.map(String):t instanceof Set?Array.from(t,e=>String(e)):[]}function Ice(t,e){return new yx(t,e)}var yx=class t extends Ece.EventEmitter{get status(){return this.statusOverride?this.statusOverride:this.closed?"end":this.raw.connected?"ready":this.hasConnected?"end":"wait"}set status(e){e==="end"&&(this.closing=!0,this.closed=!0),this.statusOverride=e}get options(){return{}}set options(e){}constructor(e,r){super(),this.raw=e,this.scripts=new Map,this.loadedScriptShas=new Set,this.hasConnected=!1,this.closed=!1,this.closing=!1,this.reconnecting=!1,this.reconnectTimer=null,this.reconnectAttempts=0,this.maxReconnectDelay=2e4,this.isCluster=!1,this._setupCallbacks(),r?.lazyConnect||this.connect().catch(()=>{})}_setupCallbacks(){this.raw.onconnect=()=>{this.hasConnected=!0,this.closed=!1,this.closing=!1,this.reconnecting=!1,this.reconnectAttempts=0,this.statusOverride=void 0,this.loadedScriptShas.clear(),this.connectionName?this.clientSetName(this.connectionName).then(()=>this.emit("ready"),()=>this.emit("ready")):this.emit("ready")},this.raw.onclose=e=>{if(this.closing){this.closed=!0,this.emit("close"),this.emit("end");return}this.closed=!0,this.emit("close"),e&&this.emit("error",e),this._scheduleReconnect()}}_scheduleReconnect(){if(this.closing||this.reconnecting)return;this.reconnecting=!0,this.reconnectAttempts++;let e=Math.max(Math.min(Math.exp(this.reconnectAttempts)*100,this.maxReconnectDelay),1e3);this.reconnectTimer=setTimeout(async()=>{if(this.reconnectTimer=null,this.closing){this.reconnecting=!1;return}try{let r=this.raw.constructor,i=new r(this.raw.url);this.raw=i,this.closed=!1,this.connecting=void 0,this._setupCallbacks(),await i.connect()}catch{this.reconnecting=!1,this.closing||this._scheduleReconnect()}},e)}async connect(){if(this.raw.connected){this.hasConnected=!0,this.closed=!1,this.closing=!1,this.statusOverride=void 0;return}if(!this.connecting){if(this.closed=!1,this.closing=!1,this.statusOverride=void 0,this.hasConnected&&!this.raw.connected){let e=this.raw.constructor;this.raw=new e(this.raw.url),this._setupCallbacks()}this.connecting=this.raw.connect().then(()=>{this.hasConnected=!0,this.closed=!1,this.closing=!1,this.statusOverride=void 0}).finally(()=>{this.connecting=void 0})}await this.connecting}_closeRaw(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnecting=!1;let e=this.raw;e.onconnect=()=>{},e.onclose=()=>{},e.onerror=()=>{},e.connected&&setImmediate(()=>{try{e.connected&&e.close()}catch{}})}disconnect(e){if(!(this.closed&&!e))if(e){this.closed=!0,this.statusOverride=void 0;let r=this.raw;r.onclose=()=>{},r.connected&&setImmediate(()=>{try{r.connected&&r.close()}catch{}}),this.emit("close"),this._scheduleReconnect()}else this.closing=!0,this.closed=!0,this.statusOverride="end",this._closeRaw(),this.emit("close"),this.emit("end")}async quit(){return this.closed?(setImmediate(()=>{this.emit("end"),this.emit("close")}),"OK"):(this.closing=!0,this.closed=!0,this.statusOverride="end",this._closeRaw(),setImmediate(()=>{this.emit("end"),this.emit("close")}),"OK")}duplicate(...e){let r=this.raw.constructor,i=new r(this.raw.url),n=new t(i);for(let[s,a]of this.scripts)n.scripts.set(s,a),n[s]=(...l)=>n.runCommand(s,l);let o=e[0];return o&&typeof o=="object"&&o.connectionName&&(n.connectionName=o.connectionName),n}defineCommand(e,r){let i=(0,Sce.createHash)("sha1").update(r.lua).digest("hex");this.scripts.set(e,{sha:i,lua:r.lua,numberOfKeys:r.numberOfKeys}),this[e]=(...n)=>this.runCommand(e,n)}async runCommand(e,r){let i=this.scripts.get(e);if(!i)throw new Error(`BullMQ: unknown command "${e}"`);let n=IF(r),{sha:o,lua:s,numberOfKeys:a}=i,l=n.slice(0,a).map(String),c=n.slice(a).map(f=>Buffer.isBuffer(f)?f:f==null?"":String(f)),u=[o,String(l.length),...l,...c];return(async()=>{var f,p;try{let m=await this.sendCommand("EVALSHA",u);return this.loadedScriptShas.add(o),m}catch(m){if(!((p=(f=m?.message)===null||f===void 0?void 0:f.includes)===null||p===void 0)&&p.call(f,"NOSCRIPT")){let y=[s,String(l.length),...l,...c],w=await this.sendCommand("EVAL",y);return this.loadedScriptShas.add(o),w}throw m}})()}async ensureScriptsLoaded(e){let r=[],i=new Set;for(let n of e)this.loadedScriptShas.has(n.sha)||i.has(n.sha)||(i.add(n.sha),r.push(n));r.length!==0&&await Promise.all(r.map(async n=>{await this.sendCommand("SCRIPT",["LOAD",n.lua]),this.loadedScriptShas.add(n.sha)}))}sendCommand(e,r){return this.closing||this.closed?Promise.reject(new xF.ConnectionClosedError("Connection is closed")):this.raw.send(e,r).catch(i=>{if(xce(i))return Promise.reject(new xF.ConnectionClosedError(this.closing||this.closed?"Connection is closed":i.message,i));throw i})}multi(){return new Kh(this.raw,this.scripts,!0,this)}pipeline(){return new Kh(this.raw,this.scripts,!1,this)}async hgetall(e){let r=await this.sendCommand("HGETALL",[e]);if(!r||Array.isArray(r)&&r.length===0)return{};if(Array.isArray(r)){let i={};for(let n=0;n<r.length;n+=2)i[String(r[n])]=String(r[n+1]);return i}return r}async hget(e,r){let i=await this.sendCommand("HGET",[e,r]);return i??null}async hmget(e,...r){return(await this.sendCommand("HMGET",[e,...r])||[]).map(n=>n??null)}async hset(e,r,...i){let n;if(typeof r=="object"){n=[e];for(let[o,s]of Object.entries(r))n.push(o,String(s))}else{n=[e,r,String(i[0])];for(let o=1;o<i.length;o+=2)n.push(String(i[o]),String(i[o+1]))}return await this.sendCommand("HSET",n)}async hdel(e,...r){return await this.sendCommand("HDEL",[e,...r])}async hexists(e,r){let i=await this.sendCommand("HEXISTS",[e,r]);return i===!0||i===1?1:0}async get(e){let r=await this.sendCommand("GET",[e]);return r??null}async set(e,r,i){let n=[e,String(r)];return i?.PX!=null?n.push("PX",String(i.PX)):i?.EX!=null&&n.push("EX",String(i.EX)),await this.sendCommand("SET",n)}async del(...e){return e.length===0?0:await this.sendCommand("DEL",e)}async zrange(e,r,i,n){let o=[e,String(r),String(i)];n?.WITHSCORES&&o.push("WITHSCORES");let s=await this.sendCommand("ZRANGE",o);return s?n?.WITHSCORES&&s.length>0&&Array.isArray(s[0])?s.flatMap(a=>[String(a[0]),String(a[1])]):s.map(String):[]}async zrevrange(e,r,i,n){let o=[e,String(r),String(i)];n?.WITHSCORES&&o.push("WITHSCORES"),o.push("REV");let s=await this.sendCommand("ZRANGE",o);return s?n?.WITHSCORES&&s.length>0&&Array.isArray(s[0])?s.flatMap(a=>[String(a[0]),String(a[1])]):s.map(String):[]}async zcard(e){return await this.sendCommand("ZCARD",[e])}async zscore(e,r){let i=await this.sendCommand("ZSCORE",[e,r]);return i!=null?String(i):null}async lrange(e,r,i){return(await this.sendCommand("LRANGE",[e,String(r),String(i)])||[]).map(String)}async llen(e){return await this.sendCommand("LLEN",[e])}async ltrim(e,r,i){return await this.sendCommand("LTRIM",[e,String(r),String(i)]),"OK"}async lpos(e,r){let i=await this.sendCommand("LPOS",[e,r]);return i??null}async smembers(e){let r=await this.sendCommand("SMEMBERS",[e]);return Ah(r)}async xadd(e,r,i,n){let o=[e];n?.MAXLEN!=null&&(o.push("MAXLEN"),n.approximate!==!1&&o.push("~"),o.push(String(n.MAXLEN))),o.push(r);for(let[s,a]of Object.entries(i))o.push(s,String(a));return await this.raw.send("XADD",o)}async xread(e,r){let i=[];r?.COUNT!=null&&i.push("COUNT",String(r.COUNT)),r?.BLOCK!=null&&i.push("BLOCK",String(r.BLOCK)),i.push("STREAMS");for(let o of e)i.push(o.key);for(let o of e)i.push(o.id);let n;try{n=await this.sendCommand("XREAD",i)}catch(o){if(this.closing)return null;throw o}return n?Array.isArray(n)?n.map(o=>{let s=String(o[0]),a=(o[1]||[]).map(l=>{let c=String(l[0]),u=(l[1]||[]).map(String);return[c,u]});return[s,a]}):Object.entries(n).map(([o,s])=>{let a=(s||[]).map(l=>{let c=String(l[0]),u=(l[1]||[]).map(String);return[c,u]});return[o,a]}):null}async xtrim(e,r,i,n){let o=[e,r];return n?.approximate!==!1&&o.push("~"),o.push(String(i)),await this.sendCommand("XTRIM",o)}async bzpopmin(e,r){let i;try{i=await this.sendCommand("BZPOPMIN",[e,String(r)])}catch(n){if(this.closing)return null;throw n}return!i||i.length===0?null:[String(i[0]),String(i[1]),String(i[2])]}async info(){return await this.sendCommand("INFO",[])}async clientSetName(e){return await this.sendCommand("CLIENT",["SETNAME",e])}async clientList(){return await this.sendCommand("CLIENT",["LIST"])}async scan(e,r){let i=[String(e)];r?.MATCH&&i.push("MATCH",r.MATCH),r?.COUNT&&i.push("COUNT",String(r.COUNT));let n=await this.sendCommand("SCAN",i),o=n[1];return[String(n[0]),Array.isArray(o)?o.map(String):[]]}scanStream(e){let r=this,i="0",n=!1,o=new wce.Readable({objectMode:!0,async read(){if(n&&i==="0"){o.push(null);return}n=!0;try{for(;;){let[s,a]=await r.scan(i,{MATCH:e.match,COUNT:e.count});if(i=s,a.length>0){o.push(a),i==="0"&&o.push(null);return}if(i==="0"){o.push(null);return}}}catch(s){o.destroy(s)}}});return o}async keys(e){return(await this.sendCommand("KEYS",[e])||[]).map(String)}async exists(...e){if(e.length===0)return 0;let r=await this.sendCommand("EXISTS",e);return typeof r=="boolean"?r?1:0:r}async zadd(e,...r){let i=[e];for(let n=0;n<r.length;n+=2)i.push(String(r[n]),String(r[n+1]));return await this.sendCommand("ZADD",i)}async zrem(e,...r){return await this.sendCommand("ZREM",[e,...r])}async xlen(e){return await this.sendCommand("XLEN",[e])}async xrevrange(e,r,i,...n){let o=[e,r,i];n[0]==="COUNT"&&o.push("COUNT",String(n[1]));let s=await this.sendCommand("XREVRANGE",o);return s?s.map(a=>[String(a[0]),(a[1]||[]).map(String)]):[]}async sadd(e,...r){return await this.sendCommand("SADD",[e,...r.map(String)])}async scard(e){return await this.sendCommand("SCARD",[e])}async lpush(e,...r){return await this.sendCommand("LPUSH",[e,...r])}async rpop(e){let r=await this.sendCommand("RPOP",[e]);return r??null}async incr(e){return await this.sendCommand("INCR",[e])}async incrby(e,r){return await this.sendCommand("INCRBY",[e,String(r)])}async flushall(){return await this.sendCommand("FLUSHALL",[])}},Kh=class{constructor(e,r,i,n){this.raw=e,this.scripts=r,this.transactional=i,this.adapter=n,this.commands=[],this.transformers=[],this.scriptsToLoad=[]}addCommand(e,r,i){this.commands.push({cmd:e,args:r}),this.transformers.push(i||(n=>n))}hgetall(e){return this.addCommand("HGETALL",[e],r=>{if(!r||Array.isArray(r)&&r.length===0)return{};if(Array.isArray(r)){let i={};for(let n=0;n<r.length;n+=2)i[String(r[n])]=String(r[n+1]);return i}return r}),this}hset(e,r){let i=[e];for(let[n,o]of Object.entries(r))i.push(n,String(o));return this.addCommand("HSET",i),this}hscan(e,r,i){let n=[e,String(r)];return i?.COUNT!=null&&n.push("COUNT",String(i.COUNT)),this.addCommand("HSCAN",n,o=>o?Array.isArray(o)?[String(o[0]),Ah(o[1])]:["0",[]]:["0",[]]),this}smembers(e){return this.addCommand("SMEMBERS",[e],r=>Ah(r)),this}sscan(e,r,i){let n=[e,String(r)];return i?.COUNT!=null&&n.push("COUNT",String(i.COUNT)),this.addCommand("SSCAN",n,o=>o?Array.isArray(o)?[String(o[0]),Ah(o[1])]:["0",[]]:["0",[]]),this}zrange(e,r,i){return this.addCommand("ZRANGE",[e,String(r),String(i)],n=>Array.isArray(n)?n.map(String):[]),this}lrange(e,r,i){return this.addCommand("LRANGE",[e,String(r),String(i)],n=>Array.isArray(n)?n.map(String):[]),this}llen(e){return this.addCommand("LLEN",[e]),this}del(...e){return e.length>0&&this.addCommand("DEL",e),this}runCommand(e,r){let i=this.scripts.get(e);if(!i)throw new Error(`BullMQ: unknown command "${e}" in transaction`);let n=IF(r),{sha:o,numberOfKeys:s}=i,a=n.slice(0,s).map(String),l=n.slice(s).map(c=>Buffer.isBuffer(c)?c:c==null?"":String(c));return this.scriptsToLoad.push(i),this.addCommand("EVALSHA",[o,String(a.length),...a,...l]),this}async exec(){if(this.commands.length===0)return[];if(this.scriptsToLoad.length>0&&await this.adapter.ensureScriptsLoaded(this.scriptsToLoad),!this.transactional)return(await Promise.allSettled(this.commands.map(({cmd:i,args:n})=>this.adapter.sendCommand(i,n)))).map((i,n)=>{if(i.status==="rejected")return[i.reason,null];let o=this.transformers[n];return[null,o?o(i.value):i.value]});let e=r=>{};try{this.raw.send("MULTI",[]).catch(e);for(let{cmd:i,args:n}of this.commands)this.raw.send(i,n).catch(e);let r=await this.raw.send("EXEC",[]);return r?r.map((i,n)=>{if(i instanceof Error)return[i,null];let o=this.transformers[n];return[null,o?o(i):i]}):null}catch(r){try{await this.raw.send("DISCARD",[])}catch{}throw r}}}});var tq=h(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});var yi=class extends Error{},Tx=class extends yi{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},Cx=class extends yi{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},Ox=class extends yi{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},so=class extends yi{},Uh=class extends yi{constructor(e){super(`Invalid unit ${e}`)}},Dt=class extends yi{},Gn=class extends yi{constructor(){super("Zone is an abstract class")}},q="numeric",En="short",Mr="long",$h={year:q,month:q,day:q},r2={year:q,month:En,day:q},kce={year:q,month:En,day:q,weekday:En},n2={year:q,month:Mr,day:q},i2={year:q,month:Mr,day:q,weekday:Mr},o2={hour:q,minute:q},s2={hour:q,minute:q,second:q},a2={hour:q,minute:q,second:q,timeZoneName:En},l2={hour:q,minute:q,second:q,timeZoneName:Mr},c2={hour:q,minute:q,hourCycle:"h23"},u2={hour:q,minute:q,second:q,hourCycle:"h23"},d2={hour:q,minute:q,second:q,hourCycle:"h23",timeZoneName:En},p2={hour:q,minute:q,second:q,hourCycle:"h23",timeZoneName:Mr},f2={year:q,month:q,day:q,hour:q,minute:q},m2={year:q,month:q,day:q,hour:q,minute:q,second:q},h2={year:q,month:En,day:q,hour:q,minute:q},y2={year:q,month:En,day:q,hour:q,minute:q,second:q},_ce={year:q,month:En,day:q,weekday:En,hour:q,minute:q},g2={year:q,month:Mr,day:q,hour:q,minute:q,timeZoneName:En},b2={year:q,month:Mr,day:q,hour:q,minute:q,second:q,timeZoneName:En},v2={year:q,month:Mr,day:q,weekday:Mr,hour:q,minute:q,timeZoneName:Mr},S2={year:q,month:Mr,day:q,weekday:Mr,hour:q,minute:q,second:q,timeZoneName:Mr},lo=class{get type(){throw new Gn}get name(){throw new Gn}get ianaName(){return this.name}get isUniversal(){throw new Gn}offsetName(e,r){throw new Gn}formatOffset(e,r){throw new Gn}offset(e){throw new Gn}equals(e){throw new Gn}get isValid(){throw new Gn}},bx=null,Su=class t extends lo{static get instance(){return bx===null&&(bx=new t),bx}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:r,locale:i}){return K2(e,r,i)}formatOffset(e,r){return vu(this.offset(e),r)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}},Ax=new Map;function Tce(t){let e=Ax.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),Ax.set(t,e)),e}var Cce={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Oce(t,e){let r=t.format(e).replace(/\u200E/g,""),i=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(r),[,n,o,s,a,l,c,u]=i;return[s,n,o,a,l,c,u]}function Ace(t,e){let r=t.formatToParts(e),i=[];for(let n=0;n<r.length;n++){let{type:o,value:s}=r[n],a=Cce[o];o==="era"?i[a]=s:ie(a)||(i[a]=parseInt(s,10))}return i}var vx=new Map,gi=class t extends lo{static create(e){let r=vx.get(e);return r===void 0&&vx.set(e,r=new t(e)),r}static resetCache(){vx.clear(),Ax.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=t.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:r,locale:i}){return K2(e,r,i,this.name)}formatOffset(e,r){return vu(this.offset(e),r)}offset(e){if(!this.valid)return NaN;let r=new Date(e);if(isNaN(r))return NaN;let i=Tce(this.name),[n,o,s,a,l,c,u]=i.formatToParts?Ace(i,r):Oce(i,r);a==="BC"&&(n=-Math.abs(n)+1);let f=Bh({year:n,month:o,day:s,hour:l===24?0:l,minute:c,second:u,millisecond:0}),p=+r,m=p%1e3;return p-=m>=0?m:1e3+m,(f-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}},_F={};function Kce(t,e={}){let r=JSON.stringify([t,e]),i=_F[r];return i||(i=new Intl.ListFormat(t,e),_F[r]=i),i}var Kx=new Map;function Rx(t,e={}){let r=JSON.stringify([t,e]),i=Kx.get(r);return i===void 0&&(i=new Intl.DateTimeFormat(t,e),Kx.set(r,i)),i}var Dx=new Map;function Rce(t,e={}){let r=JSON.stringify([t,e]),i=Dx.get(r);return i===void 0&&(i=new Intl.NumberFormat(t,e),Dx.set(r,i)),i}var jx=new Map;function Dce(t,e={}){let{base:r,...i}=e,n=JSON.stringify([t,i]),o=jx.get(n);return o===void 0&&(o=new Intl.RelativeTimeFormat(t,e),jx.set(n,o)),o}var yu=null;function jce(){return yu||(yu=new Intl.DateTimeFormat().resolvedOptions().locale,yu)}var Px=new Map;function E2(t){let e=Px.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),Px.set(t,e)),e}var Mx=new Map;function Pce(t){let e=Mx.get(t);if(!e){let r=new Intl.Locale(t);e="getWeekInfo"in r?r.getWeekInfo():r.weekInfo,"minimalDays"in e||(e={...w2,...e}),Mx.set(t,e)}return e}function Mce(t){let e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));let r=t.indexOf("-u-");if(r===-1)return[t];{let i,n;try{i=Rx(t).resolvedOptions(),n=t}catch{let l=t.substring(0,r);i=Rx(l).resolvedOptions(),n=l}let{numberingSystem:o,calendar:s}=i;return[n,o,s]}}function Nce(t,e,r){return(r||e)&&(t.includes("-u-")||(t+="-u"),r&&(t+=`-ca-${r}`),e&&(t+=`-nu-${e}`)),t}function Lce(t){let e=[];for(let r=1;r<=12;r++){let i=et.utc(2009,r,1);e.push(t(i))}return e}function Uce(t){let e=[];for(let r=1;r<=7;r++){let i=et.utc(2016,11,13+r);e.push(t(i))}return e}function Rh(t,e,r,i){let n=t.listingMode();return n==="error"?null:n==="en"?r(e):i(e)}function $ce(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||E2(t.locale).numberingSystem==="latn"}var Nx=class{constructor(e,r,i){this.padTo=i.padTo||0,this.floor=i.floor||!1;let{padTo:n,floor:o,...s}=i;if(!r||Object.keys(s).length>0){let a={useGrouping:!1,...i};i.padTo>0&&(a.minimumIntegerDigits=i.padTo),this.inf=Rce(e,a)}}format(e){if(this.inf){let r=this.floor?Math.floor(e):e;return this.inf.format(r)}else{let r=this.floor?Math.floor(e):Wx(e,3);return vt(r,this.padTo)}}},Lx=class{constructor(e,r,i){this.opts=i,this.originalZone=void 0;let n;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){let s=-1*(e.offset/60),a=s>=0?`Etc/GMT+${s}`:`Etc/GMT${s}`;e.offset!==0&&gi.create(a).valid?(n=a,this.dt=e):(n="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,n=e.zone.name):(n="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);let o={...this.opts};o.timeZone=o.timeZone||n,this.dtf=Rx(r,o)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){let e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(r=>{if(r.type==="timeZoneName"){let i=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...r,value:i}}else return r}):e}resolvedOptions(){return this.dtf.resolvedOptions()}},Ux=class{constructor(e,r,i){this.opts={style:"long",...i},!r&&O2()&&(this.rtf=Dce(e,i))}format(e,r){return this.rtf?this.rtf.format(e,r):aue(r,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,r){return this.rtf?this.rtf.formatToParts(e,r):[]}},w2={firstDay:1,minimalDays:4,weekend:[6,7]},ze=class t{static fromOpts(e){return t.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,r,i,n,o=!1){let s=e||Xe.defaultLocale,a=s||(o?"en-US":jce()),l=r||Xe.defaultNumberingSystem,c=i||Xe.defaultOutputCalendar,u=Jx(n)||Xe.defaultWeekSettings;return new t(a,l,c,u,s)}static resetCache(){yu=null,Kx.clear(),Dx.clear(),jx.clear(),Px.clear(),Mx.clear()}static fromObject({locale:e,numberingSystem:r,outputCalendar:i,weekSettings:n}={}){return t.create(e,r,i,n)}constructor(e,r,i,n,o){let[s,a,l]=Mce(e);this.locale=s,this.numberingSystem=r||a||null,this.outputCalendar=i||l||null,this.weekSettings=n,this.intl=Nce(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=o,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=$ce(this)),this.fastNumbersCached}listingMode(){let e=this.isEnglish(),r=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&r?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:t.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Jx(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,r=!1){return Rh(this,e,j2,()=>{let i=this.intl==="ja"||this.intl.startsWith("ja-");r&=!i;let n=r?{month:e,day:"numeric"}:{month:e},o=r?"format":"standalone";if(!this.monthsCache[o][e]){let s=i?a=>this.dtFormatter(a,n).format():a=>this.extract(a,n,"month");this.monthsCache[o][e]=Lce(s)}return this.monthsCache[o][e]})}weekdays(e,r=!1){return Rh(this,e,N2,()=>{let i=r?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},n=r?"format":"standalone";return this.weekdaysCache[n][e]||(this.weekdaysCache[n][e]=Uce(o=>this.extract(o,i,"weekday"))),this.weekdaysCache[n][e]})}meridiems(){return Rh(this,void 0,()=>L2,()=>{if(!this.meridiemCache){let e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[et.utc(2016,11,13,9),et.utc(2016,11,13,19)].map(r=>this.extract(r,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Rh(this,e,U2,()=>{let r={era:e};return this.eraCache[e]||(this.eraCache[e]=[et.utc(-40,1,1),et.utc(2017,1,1)].map(i=>this.extract(i,r,"era"))),this.eraCache[e]})}extract(e,r,i){let n=this.dtFormatter(e,r),o=n.formatToParts(),s=o.find(a=>a.type.toLowerCase()===i);return s?s.value:null}numberFormatter(e={}){return new Nx(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,r={}){return new Lx(e,this.intl,r)}relFormatter(e={}){return new Ux(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Kce(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||E2(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:A2()?Pce(this.locale):w2}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})`}},Sx=null,Nr=class t extends lo{static get utcInstance(){return Sx===null&&(Sx=new t(0)),Sx}static instance(e){return e===0?t.utcInstance:new t(e)}static parseSpecifier(e){if(e){let r=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(r)return new t(Wh(r[1],r[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${vu(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${vu(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,r){return vu(this.fixed,r)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}},Jh=class extends lo{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function oo(t,e){if(ie(t)||t===null)return e;if(t instanceof lo)return t;if(Vce(t)){let r=t.toLowerCase();return r==="default"?e:r==="local"||r==="system"?Su.instance:r==="utc"||r==="gmt"?Nr.utcInstance:Nr.parseSpecifier(r)||gi.create(t)}else return ao(t)?Nr.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new Jh(t)}var zx={arab:"[\u0660-\u0669]",arabext:"[\u06F0-\u06F9]",bali:"[\u1B50-\u1B59]",beng:"[\u09E6-\u09EF]",deva:"[\u0966-\u096F]",fullwide:"[\uFF10-\uFF19]",gujr:"[\u0AE6-\u0AEF]",hanidec:"[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",khmr:"[\u17E0-\u17E9]",knda:"[\u0CE6-\u0CEF]",laoo:"[\u0ED0-\u0ED9]",limb:"[\u1946-\u194F]",mlym:"[\u0D66-\u0D6F]",mong:"[\u1810-\u1819]",mymr:"[\u1040-\u1049]",orya:"[\u0B66-\u0B6F]",tamldec:"[\u0BE6-\u0BEF]",telu:"[\u0C66-\u0C6F]",thai:"[\u0E50-\u0E59]",tibt:"[\u0F20-\u0F29]",latn:"\\d"},TF={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]},Jce=zx.hanidec.replace(/[\[|\]]/g,"").split("");function Fce(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);if(t[r].search(zx.hanidec)!==-1)e+=Jce.indexOf(t[r]);else for(let n in TF){let[o,s]=TF[n];i>=o&&i<=s&&(e+=i-o)}}return parseInt(e,10)}else return e}var $x=new Map;function qce(){$x.clear()}function vn({numberingSystem:t},e=""){let r=t||"latn",i=$x.get(r);i===void 0&&(i=new Map,$x.set(r,i));let n=i.get(e);return n===void 0&&(n=new RegExp(`${zx[r]}${e}`),i.set(e,n)),n}var CF=()=>Date.now(),OF="system",AF=null,KF=null,RF=null,DF=60,jF,PF=null,Xe=class{static get now(){return CF}static set now(e){CF=e}static set defaultZone(e){OF=e}static get defaultZone(){return oo(OF,Su.instance)}static get defaultLocale(){return AF}static set defaultLocale(e){AF=e}static get defaultNumberingSystem(){return KF}static set defaultNumberingSystem(e){KF=e}static get defaultOutputCalendar(){return RF}static set defaultOutputCalendar(e){RF=e}static get defaultWeekSettings(){return PF}static set defaultWeekSettings(e){PF=Jx(e)}static get twoDigitCutoffYear(){return DF}static set twoDigitCutoffYear(e){DF=e%100}static get throwOnInvalid(){return jF}static set throwOnInvalid(e){jF=e}static resetCaches(){ze.resetCache(),gi.resetCache(),et.resetCache(),qce()}},Pr=class{constructor(e,r){this.reason=e,this.explanation=r}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},x2=[0,31,59,90,120,151,181,212,243,273,304,334],I2=[0,31,60,91,121,152,182,213,244,274,305,335];function sn(t,e){return new Pr("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Gx(t,e,r){let i=new Date(Date.UTC(t,e-1,r));t<100&&t>=0&&i.setUTCFullYear(i.getUTCFullYear()-1900);let n=i.getUTCDay();return n===0?7:n}function k2(t,e,r){return r+(wu(t)?I2:x2)[e-1]}function _2(t,e){let r=wu(t)?I2:x2,i=r.findIndex(o=>o<e),n=e-r[i];return{month:i+1,day:n}}function Vx(t,e){return(t-e+7)%7+1}function Fh(t,e=4,r=1){let{year:i,month:n,day:o}=t,s=k2(i,n,o),a=Vx(Gx(i,n,o),r),l=Math.floor((s-a+14-e)/7),c;return l<1?(c=i-1,l=Eu(c,e,r)):l>Eu(i,e,r)?(c=i+1,l=1):c=i,{weekYear:c,weekNumber:l,weekday:a,...Zh(t)}}function MF(t,e=4,r=1){let{weekYear:i,weekNumber:n,weekday:o}=t,s=Vx(Gx(i,1,e),r),a=Ha(i),l=n*7+o-s-7+e,c;l<1?(c=i-1,l+=Ha(c)):l>a?(c=i+1,l-=Ha(i)):c=i;let{month:u,day:d}=_2(c,l);return{year:c,month:u,day:d,...Zh(t)}}function Ex(t){let{year:e,month:r,day:i}=t,n=k2(e,r,i);return{year:e,ordinal:n,...Zh(t)}}function NF(t){let{year:e,ordinal:r}=t,{month:i,day:n}=_2(e,r);return{year:e,month:i,day:n,...Zh(t)}}function LF(t,e){if(!ie(t.localWeekday)||!ie(t.localWeekNumber)||!ie(t.localWeekYear)){if(!ie(t.weekday)||!ie(t.weekNumber)||!ie(t.weekYear))throw new so("Cannot mix locale-based week fields with ISO-based week fields");return ie(t.localWeekday)||(t.weekday=t.localWeekday),ie(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),ie(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function zce(t,e=4,r=1){let i=Vh(t.weekYear),n=an(t.weekNumber,1,Eu(t.weekYear,e,r)),o=an(t.weekday,1,7);return i?n?o?!1:sn("weekday",t.weekday):sn("week",t.weekNumber):sn("weekYear",t.weekYear)}function Gce(t){let e=Vh(t.year),r=an(t.ordinal,1,Ha(t.year));return e?r?!1:sn("ordinal",t.ordinal):sn("year",t.year)}function T2(t){let e=Vh(t.year),r=an(t.month,1,12),i=an(t.day,1,qh(t.year,t.month));return e?r?i?!1:sn("day",t.day):sn("month",t.month):sn("year",t.year)}function C2(t){let{hour:e,minute:r,second:i,millisecond:n}=t,o=an(e,0,23)||e===24&&r===0&&i===0&&n===0,s=an(r,0,59),a=an(i,0,59),l=an(n,0,999);return o?s?a?l?!1:sn("millisecond",n):sn("second",i):sn("minute",r):sn("hour",e)}function ie(t){return typeof t>"u"}function ao(t){return typeof t=="number"}function Vh(t){return typeof t=="number"&&t%1===0}function Vce(t){return typeof t=="string"}function Bce(t){return Object.prototype.toString.call(t)==="[object Date]"}function O2(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function A2(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Wce(t){return Array.isArray(t)?t:[t]}function UF(t,e,r){if(t.length!==0)return t.reduce((i,n)=>{let o=[e(n),n];return i&&r(i[0],o[0])===i[0]?i:o},null)[1]}function Zce(t,e){return e.reduce((r,i)=>(r[i]=t[i],r),{})}function Xa(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Jx(t){if(t==null)return null;if(typeof t!="object")throw new Dt("Week settings must be an object");if(!an(t.firstDay,1,7)||!an(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!an(e,1,7)))throw new Dt("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function an(t,e,r){return Vh(t)&&t>=e&&t<=r}function Hce(t,e){return t-e*Math.floor(t/e)}function vt(t,e=2){let r=t<0,i;return r?i="-"+(""+-t).padStart(e,"0"):i=(""+t).padStart(e,"0"),i}function io(t){if(!(ie(t)||t===null||t===""))return parseInt(t,10)}function os(t){if(!(ie(t)||t===null||t===""))return parseFloat(t)}function Bx(t){if(!(ie(t)||t===null||t==="")){let e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Wx(t,e,r="round"){let i=10**e;switch(r){case"expand":return t>0?Math.ceil(t*i)/i:Math.floor(t*i)/i;case"trunc":return Math.trunc(t*i)/i;case"round":return Math.round(t*i)/i;case"floor":return Math.floor(t*i)/i;case"ceil":return Math.ceil(t*i)/i;default:throw new RangeError(`Value rounding ${r} is out of range`)}}function wu(t){return t%4===0&&(t%100!==0||t%400===0)}function Ha(t){return wu(t)?366:365}function qh(t,e){let r=Hce(e-1,12)+1,i=t+(e-r)/12;return r===2?wu(i)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][r-1]}function Bh(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function $F(t,e,r){return-Vx(Gx(t,1,e),r)+e-1}function Eu(t,e=4,r=1){let i=$F(t,e,r),n=$F(t+1,e,r);return(Ha(t)-i+n)/7}function Fx(t){return t>99?t:t>Xe.twoDigitCutoffYear?1900+t:2e3+t}function K2(t,e,r,i=null){let n=new Date(t),o={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};i&&(o.timeZone=i);let s={timeZoneName:e,...o},a=new Intl.DateTimeFormat(r,s).formatToParts(n).find(l=>l.type.toLowerCase()==="timezonename");return a?a.value:null}function Wh(t,e){let r=parseInt(t,10);Number.isNaN(r)&&(r=0);let i=parseInt(e,10)||0,n=r<0||Object.is(r,-0)?-i:i;return r*60+n}function R2(t){let e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new Dt(`Invalid unit value ${t}`);return e}function zh(t,e){let r={};for(let i in t)if(Xa(t,i)){let n=t[i];if(n==null)continue;r[e(i)]=R2(n)}return r}function vu(t,e){let r=Math.trunc(Math.abs(t/60)),i=Math.trunc(Math.abs(t%60)),n=t>=0?"+":"-";switch(e){case"short":return`${n}${vt(r,2)}:${vt(i,2)}`;case"narrow":return`${n}${r}${i>0?`:${i}`:""}`;case"techie":return`${n}${vt(r,2)}${vt(i,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function Zh(t){return Zce(t,["hour","minute","second","millisecond"])}var Yce=["January","February","March","April","May","June","July","August","September","October","November","December"],D2=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Xce=["J","F","M","A","M","J","J","A","S","O","N","D"];function j2(t){switch(t){case"narrow":return[...Xce];case"short":return[...D2];case"long":return[...Yce];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}}var P2=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],M2=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Qce=["M","T","W","T","F","S","S"];function N2(t){switch(t){case"narrow":return[...Qce];case"short":return[...M2];case"long":return[...P2];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var L2=["AM","PM"],eue=["Before Christ","Anno Domini"],tue=["BC","AD"],rue=["B","A"];function U2(t){switch(t){case"narrow":return[...rue];case"short":return[...tue];case"long":return[...eue];default:return null}}function nue(t){return L2[t.hour<12?0:1]}function iue(t,e){return N2(e)[t.weekday-1]}function oue(t,e){return j2(e)[t.month-1]}function sue(t,e){return U2(e)[t.year<0?0:1]}function aue(t,e,r="always",i=!1){let n={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."]},o=["hours","minutes","seconds"].indexOf(t)===-1;if(r==="auto"&&o){let d=t==="days";switch(e){case 1:return d?"tomorrow":`next ${n[t][0]}`;case-1:return d?"yesterday":`last ${n[t][0]}`;case 0:return d?"today":`this ${n[t][0]}`}}let s=Object.is(e,-0)||e<0,a=Math.abs(e),l=a===1,c=n[t],u=i?l?c[1]:c[2]||c[1]:l?n[t][0]:t;return s?`${a} ${u} ago`:`in ${a} ${u}`}function JF(t,e){let r="";for(let i of t)i.literal?r+=i.val:r+=e(i.val);return r}var lue={D:$h,DD:r2,DDD:n2,DDDD:i2,t:o2,tt:s2,ttt:a2,tttt:l2,T:c2,TT:u2,TTT:d2,TTTT:p2,f:f2,ff:h2,fff:g2,ffff:v2,F:m2,FF:y2,FFF:b2,FFFF:S2},jr=class t{static create(e,r={}){return new t(e,r)}static parseFormat(e){let r=null,i="",n=!1,o=[];for(let s=0;s<e.length;s++){let a=e.charAt(s);a==="'"?((i.length>0||n)&&o.push({literal:n||/^\s+$/.test(i),val:i===""?"'":i}),r=null,i="",n=!n):n||a===r?i+=a:(i.length>0&&o.push({literal:/^\s+$/.test(i),val:i}),i=a,r=a)}return i.length>0&&o.push({literal:n||/^\s+$/.test(i),val:i}),o}static macroTokenToFormatOpts(e){return lue[e]}constructor(e,r){this.opts=r,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,r){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...r}).format()}dtFormatter(e,r={}){return this.loc.dtFormatter(e,{...this.opts,...r})}formatDateTime(e,r){return this.dtFormatter(e,r).format()}formatDateTimeParts(e,r){return this.dtFormatter(e,r).formatToParts()}formatInterval(e,r){return this.dtFormatter(e.start,r).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,r){return this.dtFormatter(e,r).resolvedOptions()}num(e,r=0,i=void 0){if(this.opts.forceSimple)return vt(e,r);let n={...this.opts};return r>0&&(n.padTo=r),i&&(n.signDisplay=i),this.loc.numberFormatter(n).format(e)}formatDateTimeFromString(e,r){let i=this.loc.listingMode()==="en",n=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",o=(p,m)=>this.loc.extract(e,p,m),s=p=>e.isOffsetFixed&&e.offset===0&&p.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,p.format):"",a=()=>i?nue(e):o({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(p,m)=>i?oue(e,p):o(m?{month:p}:{month:p,day:"numeric"},"month"),c=(p,m)=>i?iue(e,p):o(m?{weekday:p}:{weekday:p,month:"long",day:"numeric"},"weekday"),u=p=>{let m=t.macroTokenToFormatOpts(p);return m?this.formatWithSystemDefault(e,m):p},d=p=>i?sue(e,p):o({era:p},"era"),f=p=>{switch(p){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 s({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return s({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return s({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 a();case"d":return n?o({day:"numeric"},"day"):this.num(e.day);case"dd":return n?o({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return c("short",!0);case"cccc":return c("long",!0);case"ccccc":return c("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return c("short",!1);case"EEEE":return c("long",!1);case"EEEEE":return c("narrow",!1);case"L":return n?o({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return n?o({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return n?o({month:"numeric"},"month"):this.num(e.month);case"MM":return n?o({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return n?o({year:"numeric"},"year"):this.num(e.year);case"yy":return n?o({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return n?o({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return n?o({year:"numeric"},"year"):this.num(e.year,6);case"G":return d("short");case"GG":return d("long");case"GGGGG":return d("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 u(p)}};return JF(t.parseFormat(r),f)}formatDurationFromString(e,r){let i=this.opts.signMode==="negativeLargestOnly"?-1:1,n=u=>{switch(u[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},o=(u,d)=>f=>{let p=n(f);if(p){let m=d.isNegativeDuration&&p!==d.largestUnit?i:1,y;return this.opts.signMode==="negativeLargestOnly"&&p!==d.largestUnit?y="never":this.opts.signMode==="all"?y="always":y="auto",this.num(u.get(p)*m,f.length,y)}else return f},s=t.parseFormat(r),a=s.reduce((u,{literal:d,val:f})=>d?u:u.concat(f),[]),l=e.shiftTo(...a.map(n).filter(u=>u)),c={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return JF(s,o(l,c))}},$2=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Qa(...t){let e=t.reduce((r,i)=>r+i.source,"");return RegExp(`^${e}$`)}function el(...t){return e=>t.reduce(([r,i,n],o)=>{let[s,a,l]=o(e,n);return[{...r,...s},a||i,l]},[{},null,1]).slice(0,2)}function tl(t,...e){if(t==null)return[null,null];for(let[r,i]of e){let n=r.exec(t);if(n)return i(n)}return[null,null]}function J2(...t){return(e,r)=>{let i={},n;for(n=0;n<t.length;n++)i[t[n]]=io(e[r+n]);return[i,null,r+n]}}var F2=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,cue=`(?:${F2.source}?(?:\\[(${$2.source})\\])?)?`,Zx=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,q2=RegExp(`${Zx.source}${cue}`),Hx=RegExp(`(?:[Tt]${q2.source})?`),uue=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,due=/(\d{4})-?W(\d\d)(?:-?(\d))?/,pue=/(\d{4})-?(\d{3})/,fue=J2("weekYear","weekNumber","weekDay"),mue=J2("year","ordinal"),hue=/(\d{4})-(\d\d)-(\d\d)/,z2=RegExp(`${Zx.source} ?(?:${F2.source}|(${$2.source}))?`),yue=RegExp(`(?: ${z2.source})?`);function Ya(t,e,r){let i=t[e];return ie(i)?r:io(i)}function gue(t,e){return[{year:Ya(t,e),month:Ya(t,e+1,1),day:Ya(t,e+2,1)},null,e+3]}function rl(t,e){return[{hours:Ya(t,e,0),minutes:Ya(t,e+1,0),seconds:Ya(t,e+2,0),milliseconds:Bx(t[e+3])},null,e+4]}function xu(t,e){let r=!t[e]&&!t[e+1],i=Wh(t[e+1],t[e+2]),n=r?null:Nr.instance(i);return[{},n,e+3]}function Iu(t,e){let r=t[e]?gi.create(t[e]):null;return[{},r,e+1]}var bue=RegExp(`^T?${Zx.source}$`),vue=/^-?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 Sue(t){let[e,r,i,n,o,s,a,l,c]=t,u=e[0]==="-",d=l&&l[0]==="-",f=(p,m=!1)=>p!==void 0&&(m||p&&u)?-p:p;return[{years:f(os(r)),months:f(os(i)),weeks:f(os(n)),days:f(os(o)),hours:f(os(s)),minutes:f(os(a)),seconds:f(os(l),l==="-0"),milliseconds:f(Bx(c),d)}]}var Eue={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Yx(t,e,r,i,n,o,s){let a={year:e.length===2?Fx(io(e)):io(e),month:D2.indexOf(r)+1,day:io(i),hour:io(n),minute:io(o)};return s&&(a.second=io(s)),t&&(a.weekday=t.length>3?P2.indexOf(t)+1:M2.indexOf(t)+1),a}var wue=/^(?:(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 xue(t){let[,e,r,i,n,o,s,a,l,c,u,d]=t,f=Yx(e,n,i,r,o,s,a),p;return l?p=Eue[l]:c?p=0:p=Wh(u,d),[f,new Nr(p)]}function Iue(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}var kue=/^(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$/,_ue=/^(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$/,Tue=/^(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 FF(t){let[,e,r,i,n,o,s,a]=t;return[Yx(e,n,i,r,o,s,a),Nr.utcInstance]}function Cue(t){let[,e,r,i,n,o,s,a]=t;return[Yx(e,a,r,i,n,o,s),Nr.utcInstance]}var Oue=Qa(uue,Hx),Aue=Qa(due,Hx),Kue=Qa(pue,Hx),Rue=Qa(q2),G2=el(gue,rl,xu,Iu),Due=el(fue,rl,xu,Iu),jue=el(mue,rl,xu,Iu),Pue=el(rl,xu,Iu);function Mue(t){return tl(t,[Oue,G2],[Aue,Due],[Kue,jue],[Rue,Pue])}function Nue(t){return tl(Iue(t),[wue,xue])}function Lue(t){return tl(t,[kue,FF],[_ue,FF],[Tue,Cue])}function Uue(t){return tl(t,[vue,Sue])}var $ue=el(rl);function Jue(t){return tl(t,[bue,$ue])}var Fue=Qa(hue,yue),que=Qa(z2),zue=el(rl,xu,Iu);function Gue(t){return tl(t,[Fue,G2],[que,zue])}var qF="Invalid Duration",V2={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Vue={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:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...V2},on=146097/400,Ba=146097/4800,Bue={years:{quarters:4,months:12,weeks:on/7,days:on,hours:on*24,minutes:on*24*60,seconds:on*24*60*60,milliseconds:on*24*60*60*1e3},quarters:{months:3,weeks:on/28,days:on/4,hours:on*24/4,minutes:on*24*60/4,seconds:on*24*60*60/4,milliseconds:on*24*60*60*1e3/4},months:{weeks:Ba/7,days:Ba,hours:Ba*24,minutes:Ba*24*60,seconds:Ba*24*60*60,milliseconds:Ba*24*60*60*1e3},...V2},as=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Wue=as.slice(0).reverse();function hi(t,e,r=!1){let i={values:r?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new Ot(i)}function B2(t,e){var r;let i=(r=e.milliseconds)!=null?r:0;for(let n of Wue.slice(1))e[n]&&(i+=e[n]*t[n].milliseconds);return i}function zF(t,e){let r=B2(t,e)<0?-1:1;as.reduceRight((i,n)=>{if(ie(e[n]))return i;if(i){let o=e[i]*r,s=t[n][i],a=Math.floor(o/s);e[n]+=a*r,e[i]-=a*s*r}return n},null),as.reduce((i,n)=>{if(ie(e[n]))return i;if(i){let o=e[i]%1;e[i]-=o,e[n]+=o*t[i][n]}return n},null)}function GF(t){let e={};for(let[r,i]of Object.entries(t))i!==0&&(e[r]=i);return e}var Ot=class t{constructor(e){let r=e.conversionAccuracy==="longterm"||!1,i=r?Bue:Vue;e.matrix&&(i=e.matrix),this.values=e.values,this.loc=e.loc||ze.create(),this.conversionAccuracy=r?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=i,this.isLuxonDuration=!0}static fromMillis(e,r){return t.fromObject({milliseconds:e},r)}static fromObject(e,r={}){if(e==null||typeof e!="object")throw new Dt(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new t({values:zh(e,t.normalizeUnit),loc:ze.fromObject(r),conversionAccuracy:r.conversionAccuracy,matrix:r.matrix})}static fromDurationLike(e){if(ao(e))return t.fromMillis(e);if(t.isDuration(e))return e;if(typeof e=="object")return t.fromObject(e);throw new Dt(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,r){let[i]=Uue(e);return i?t.fromObject(i,r):t.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,r){let[i]=Jue(e);return i?t.fromObject(i,r):t.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,r=null){if(!e)throw new Dt("need to specify a reason the Duration is invalid");let i=e instanceof Pr?e:new Pr(e,r);if(Xe.throwOnInvalid)throw new Ox(i);return new t({invalid:i})}static normalizeUnit(e){let r={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()];if(!r)throw new Uh(e);return r}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,r={}){let i={...r,floor:r.round!==!1&&r.floor!==!1};return this.isValid?jr.create(this.loc,i).formatDurationFromString(this,e):qF}toHuman(e={}){if(!this.isValid)return qF;let r=e.showZeros!==!1,i=as.map(n=>{let o=this.values[n];return ie(o)||o===0&&!r?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:n.slice(0,-1)}).format(o)}).filter(n=>n);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(i)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=Wx(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;let r=this.toMillis();return r<0||r>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},et.fromMillis(r,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?B2(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;let r=t.fromDurationLike(e),i={};for(let n of as)(Xa(r.values,n)||Xa(this.values,n))&&(i[n]=r.get(n)+this.get(n));return hi(this,{values:i},!0)}minus(e){if(!this.isValid)return this;let r=t.fromDurationLike(e);return this.plus(r.negate())}mapUnits(e){if(!this.isValid)return this;let r={};for(let i of Object.keys(this.values))r[i]=R2(e(this.values[i],i));return hi(this,{values:r},!0)}get(e){return this[t.normalizeUnit(e)]}set(e){if(!this.isValid)return this;let r={...this.values,...zh(e,t.normalizeUnit)};return hi(this,{values:r})}reconfigure({locale:e,numberingSystem:r,conversionAccuracy:i,matrix:n}={}){let s={loc:this.loc.clone({locale:e,numberingSystem:r}),matrix:n,conversionAccuracy:i};return hi(this,s)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return zF(this.matrix,e),hi(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=GF(this.normalize().shiftToAll().toObject());return hi(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(s=>t.normalizeUnit(s));let r={},i={},n=this.toObject(),o;for(let s of as)if(e.indexOf(s)>=0){o=s;let a=0;for(let c in i)a+=this.matrix[c][s]*i[c],i[c]=0;ao(n[s])&&(a+=n[s]);let l=Math.trunc(a);r[s]=l,i[s]=(a*1e3-l*1e3)/1e3}else ao(n[s])&&(i[s]=n[s]);for(let s in i)i[s]!==0&&(r[o]+=s===o?i[s]:i[s]/this.matrix[o][s]);return zF(this.matrix,r),hi(this,{values:r},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;let e={};for(let r of Object.keys(this.values))e[r]=this.values[r]===0?0:-this.values[r];return hi(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=GF(this.values);return hi(this,{values:e},!0)}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||!this.loc.equals(e.loc))return!1;function r(i,n){return i===void 0||i===0?n===void 0||n===0:i===n}for(let i of as)if(!r(this.values[i],e.values[i]))return!1;return!0}},Wa="Invalid Interval";function Zue(t,e){return!t||!t.isValid?cs.invalid("missing or invalid start"):!e||!e.isValid?cs.invalid("missing or invalid end"):e<t?cs.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}var cs=class t{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,r=null){if(!e)throw new Dt("need to specify a reason the Interval is invalid");let i=e instanceof Pr?e:new Pr(e,r);if(Xe.throwOnInvalid)throw new Cx(i);return new t({invalid:i})}static fromDateTimes(e,r){let i=hu(e),n=hu(r),o=Zue(i,n);return o??new t({start:i,end:n})}static after(e,r){let i=Ot.fromDurationLike(r),n=hu(e);return t.fromDateTimes(n,n.plus(i))}static before(e,r){let i=Ot.fromDurationLike(r),n=hu(e);return t.fromDateTimes(n.minus(i),n)}static fromISO(e,r){let[i,n]=(e||"").split("/",2);if(i&&n){let o,s;try{o=et.fromISO(i,r),s=o.isValid}catch{s=!1}let a,l;try{a=et.fromISO(n,r),l=a.isValid}catch{l=!1}if(s&&l)return t.fromDateTimes(o,a);if(s){let c=Ot.fromISO(n,r);if(c.isValid)return t.after(o,c)}else if(l){let c=Ot.fromISO(i,r);if(c.isValid)return t.before(a,c)}}return t.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):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",r){if(!this.isValid)return NaN;let i=this.start.startOf(e,r),n;return r!=null&&r.useLocaleWeeks?n=this.end.reconfigure({locale:i.locale}):n=this.end,n=n.startOf(e,r),Math.floor(n.diff(i,e).get(e))+(n.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:r}={}){return this.isValid?t.fromDateTimes(e||this.s,r||this.e):this}splitAt(...e){if(!this.isValid)return[];let r=e.map(hu).filter(s=>this.contains(s)).sort((s,a)=>s.toMillis()-a.toMillis()),i=[],{s:n}=this,o=0;for(;n<this.e;){let s=r[o]||this.e,a=+s>+this.e?this.e:s;i.push(t.fromDateTimes(n,a)),n=a,o+=1}return i}splitBy(e){let r=Ot.fromDurationLike(e);if(!this.isValid||!r.isValid||r.as("milliseconds")===0)return[];let{s:i}=this,n=1,o,s=[];for(;i<this.e;){let a=this.start.plus(r.mapUnits(l=>l*n));o=+a>+this.e?this.e:a,s.push(t.fromDateTimes(i,o)),i=o,n+=1}return s}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;let r=this.s>e.s?this.s:e.s,i=this.e<e.e?this.e:e.e;return r>=i?null:t.fromDateTimes(r,i)}union(e){if(!this.isValid)return this;let r=this.s<e.s?this.s:e.s,i=this.e>e.e?this.e:e.e;return t.fromDateTimes(r,i)}static merge(e){let[r,i]=e.sort((n,o)=>n.s-o.s).reduce(([n,o],s)=>o?o.overlaps(s)||o.abutsStart(s)?[n,o.union(s)]:[n.concat([o]),s]:[n,s],[[],null]);return i&&r.push(i),r}static xor(e){let r=null,i=0,n=[],o=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),s=Array.prototype.concat(...o),a=s.sort((l,c)=>l.time-c.time);for(let l of a)i+=l.type==="s"?1:-1,i===1?r=l.time:(r&&+r!=+l.time&&n.push(t.fromDateTimes(r,l.time)),r=null);return t.merge(n)}difference(...e){return t.xor([this].concat(e)).map(r=>this.intersection(r)).filter(r=>r&&!r.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} \u2013 ${this.e.toISO()})`:Wa}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=$h,r={}){return this.isValid?jr.create(this.s.loc.clone(r),e).formatInterval(this):Wa}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Wa}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Wa}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Wa}toFormat(e,{separator:r=" \u2013 "}={}){return this.isValid?`${this.s.toFormat(e)}${r}${this.e.toFormat(e)}`:Wa}toDuration(e,r){return this.isValid?this.e.diff(this.s,e,r):Ot.invalid(this.invalidReason)}mapEndpoints(e){return t.fromDateTimes(e(this.s),e(this.e))}},ls=class{static hasDST(e=Xe.defaultZone){let r=et.now().setZone(e).set({month:12});return!e.isUniversal&&r.offset!==r.set({month:6}).offset}static isValidIANAZone(e){return gi.isValidZone(e)}static normalizeZone(e){return oo(e,Xe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:r=null}={}){return(r||ze.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:r=null}={}){return(r||ze.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:r=null}={}){return(r||ze.create(e)).getWeekendDays().slice()}static months(e="long",{locale:r=null,numberingSystem:i=null,locObj:n=null,outputCalendar:o="gregory"}={}){return(n||ze.create(r,i,o)).months(e)}static monthsFormat(e="long",{locale:r=null,numberingSystem:i=null,locObj:n=null,outputCalendar:o="gregory"}={}){return(n||ze.create(r,i,o)).months(e,!0)}static weekdays(e="long",{locale:r=null,numberingSystem:i=null,locObj:n=null}={}){return(n||ze.create(r,i,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:r=null,numberingSystem:i=null,locObj:n=null}={}){return(n||ze.create(r,i,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return ze.create(e).meridiems()}static eras(e="short",{locale:r=null}={}){return ze.create(r,null,"gregory").eras(e)}static features(){return{relative:O2(),localeWeek:A2()}}};function VF(t,e){let r=n=>n.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),i=r(e)-r(t);return Math.floor(Ot.fromMillis(i).as("days"))}function Hue(t,e,r){let i=[["years",(l,c)=>c.year-l.year],["quarters",(l,c)=>c.quarter-l.quarter+(c.year-l.year)*4],["months",(l,c)=>c.month-l.month+(c.year-l.year)*12],["weeks",(l,c)=>{let u=VF(l,c);return(u-u%7)/7}],["days",VF]],n={},o=t,s,a;for(let[l,c]of i)r.indexOf(l)>=0&&(s=l,n[l]=c(t,e),a=o.plus(n),a>e?(n[l]--,t=o.plus(n),t>e&&(a=t,n[l]--,t=o.plus(n))):t=a);return[t,n,a,s]}function Yue(t,e,r,i){let[n,o,s,a]=Hue(t,e,r),l=e-n,c=r.filter(d=>["hours","minutes","seconds","milliseconds"].indexOf(d)>=0);c.length===0&&(s<e&&(s=n.plus({[a]:1})),s!==n&&(o[a]=(o[a]||0)+l/(s-n)));let u=Ot.fromObject(o,i);return c.length>0?Ot.fromMillis(l,i).shiftTo(...c).plus(u):u}var Xue="missing Intl.DateTimeFormat.formatToParts support";function Re(t,e=r=>r){return{regex:t,deser:([r])=>e(Fce(r))}}var Que="\xA0",W2=`[ ${Que}]`,Z2=new RegExp(W2,"g");function ede(t){return t.replace(/\./g,"\\.?").replace(Z2,W2)}function BF(t){return t.replace(/\./g,"").replace(Z2," ").toLowerCase()}function Sn(t,e){return t===null?null:{regex:RegExp(t.map(ede).join("|")),deser:([r])=>t.findIndex(i=>BF(r)===BF(i))+e}}function WF(t,e){return{regex:t,deser:([,r,i])=>Wh(r,i),groups:e}}function Dh(t){return{regex:t,deser:([e])=>e}}function tde(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function rde(t,e){let r=vn(e),i=vn(e,"{2}"),n=vn(e,"{3}"),o=vn(e,"{4}"),s=vn(e,"{6}"),a=vn(e,"{1,2}"),l=vn(e,"{1,3}"),c=vn(e,"{1,6}"),u=vn(e,"{1,9}"),d=vn(e,"{2,4}"),f=vn(e,"{4,6}"),p=w=>({regex:RegExp(tde(w.val)),deser:([_])=>_,literal:!0}),y=(w=>{if(t.literal)return p(w);switch(w.val){case"G":return Sn(e.eras("short"),0);case"GG":return Sn(e.eras("long"),0);case"y":return Re(c);case"yy":return Re(d,Fx);case"yyyy":return Re(o);case"yyyyy":return Re(f);case"yyyyyy":return Re(s);case"M":return Re(a);case"MM":return Re(i);case"MMM":return Sn(e.months("short",!0),1);case"MMMM":return Sn(e.months("long",!0),1);case"L":return Re(a);case"LL":return Re(i);case"LLL":return Sn(e.months("short",!1),1);case"LLLL":return Sn(e.months("long",!1),1);case"d":return Re(a);case"dd":return Re(i);case"o":return Re(l);case"ooo":return Re(n);case"HH":return Re(i);case"H":return Re(a);case"hh":return Re(i);case"h":return Re(a);case"mm":return Re(i);case"m":return Re(a);case"q":return Re(a);case"qq":return Re(i);case"s":return Re(a);case"ss":return Re(i);case"S":return Re(l);case"SSS":return Re(n);case"u":return Dh(u);case"uu":return Dh(a);case"uuu":return Re(r);case"a":return Sn(e.meridiems(),0);case"kkkk":return Re(o);case"kk":return Re(d,Fx);case"W":return Re(a);case"WW":return Re(i);case"E":case"c":return Re(r);case"EEE":return Sn(e.weekdays("short",!1),1);case"EEEE":return Sn(e.weekdays("long",!1),1);case"ccc":return Sn(e.weekdays("short",!0),1);case"cccc":return Sn(e.weekdays("long",!0),1);case"Z":case"ZZ":return WF(new RegExp(`([+-]${a.source})(?::(${i.source}))?`),2);case"ZZZ":return WF(new RegExp(`([+-]${a.source})(${i.source})?`),2);case"z":return Dh(/[a-z_+-/]{1,256}?/i);case" ":return Dh(/[^\S\n\r]/);default:return p(w)}})(t)||{invalidReason:Xue};return y.token=t,y}var nde={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 ide(t,e,r){let{type:i,value:n}=t;if(i==="literal"){let l=/^\s+$/.test(n);return{literal:!l,val:l?" ":n}}let o=e[i],s=i;i==="hour"&&(e.hour12!=null?s=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?s="hour12":s="hour24":s=r.hour12?"hour12":"hour24");let a=nde[s];if(typeof a=="object"&&(a=a[o]),a)return{literal:!1,val:a}}function ode(t){return[`^${t.map(r=>r.regex).reduce((r,i)=>`${r}(${i.source})`,"")}$`,t]}function sde(t,e,r){let i=t.match(e);if(i){let n={},o=1;for(let s in r)if(Xa(r,s)){let a=r[s],l=a.groups?a.groups+1:1;!a.literal&&a.token&&(n[a.token.val[0]]=a.deser(i.slice(o,o+l))),o+=l}return[i,n]}else return[i,{}]}function ade(t){let e=o=>{switch(o){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}},r=null,i;return ie(t.z)||(r=gi.create(t.z)),ie(t.Z)||(r||(r=new Nr(t.Z)),i=t.Z),ie(t.q)||(t.M=(t.q-1)*3+1),ie(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),ie(t.u)||(t.S=Bx(t.u)),[Object.keys(t).reduce((o,s)=>{let a=e(s);return a&&(o[a]=t[s]),o},{}),r,i]}var wx=null;function lde(){return wx||(wx=et.fromMillis(1555555555555)),wx}function cde(t,e){if(t.literal)return t;let r=jr.macroTokenToFormatOpts(t.val),i=X2(r,e);return i==null||i.includes(void 0)?t:i}function H2(t,e){return Array.prototype.concat(...t.map(r=>cde(r,e)))}var Gh=class{constructor(e,r){if(this.locale=e,this.format=r,this.tokens=H2(jr.parseFormat(r),e),this.units=this.tokens.map(i=>rde(i,e)),this.disqualifyingUnit=this.units.find(i=>i.invalidReason),!this.disqualifyingUnit){let[i,n]=ode(this.units);this.regex=RegExp(i,"i"),this.handlers=n}}explainFromTokens(e){if(this.isValid){let[r,i]=sde(e,this.regex,this.handlers),[n,o,s]=i?ade(i):[null,null,void 0];if(Xa(i,"a")&&Xa(i,"H"))throw new so("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:r,matches:i,result:n,zone:o,specificOffset:s}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}};function Y2(t,e,r){return new Gh(t,r).explainFromTokens(e)}function ude(t,e,r){let{result:i,zone:n,specificOffset:o,invalidReason:s}=Y2(t,e,r);return[i,n,o,s]}function X2(t,e){if(!t)return null;let i=jr.create(e,t).dtFormatter(lde()),n=i.formatToParts(),o=i.resolvedOptions();return n.map(s=>ide(s,t,o))}var xx="Invalid DateTime",ZF=864e13;function gu(t){return new Pr("unsupported zone",`the zone "${t.name}" is not supported`)}function Ix(t){return t.weekData===null&&(t.weekData=Fh(t.c)),t.weekData}function kx(t){return t.localWeekData===null&&(t.localWeekData=Fh(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function ss(t,e){let r={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new et({...r,...e,old:r})}function Q2(t,e,r){let i=t-e*60*1e3,n=r.offset(i);if(e===n)return[i,e];i-=(n-e)*60*1e3;let o=r.offset(i);return n===o?[i,n]:[t-Math.min(n,o)*60*1e3,Math.max(n,o)]}function jh(t,e){t+=e*60*1e3;let r=new Date(t);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:r.getUTCHours(),minute:r.getUTCMinutes(),second:r.getUTCSeconds(),millisecond:r.getUTCMilliseconds()}}function Mh(t,e,r){return Q2(Bh(t),e,r)}function HF(t,e){let r=t.o,i=t.c.year+Math.trunc(e.years),n=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,o={...t.c,year:i,month:n,day:Math.min(t.c.day,qh(i,n))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},s=Ot.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),a=Bh(o),[l,c]=Q2(a,r,t.zone);return s!==0&&(l+=s,c=t.zone.offset(l)),{ts:l,o:c}}function Za(t,e,r,i,n,o){let{setZone:s,zone:a}=r;if(t&&Object.keys(t).length!==0||e){let l=e||a,c=et.fromObject(t,{...r,zone:l,specificOffset:o});return s?c:c.setZone(a)}else return et.invalid(new Pr("unparsable",`the input "${n}" can't be parsed as ${i}`))}function Ph(t,e,r=!0){return t.isValid?jr.create(ze.create("en-US"),{allowZ:r,forceSimple:!0}).formatDateTimeFromString(t,e):null}function _x(t,e,r){let i=t.c.year>9999||t.c.year<0,n="";if(i&&t.c.year>=0&&(n+="+"),n+=vt(t.c.year,i?6:4),r==="year")return n;if(e){if(n+="-",n+=vt(t.c.month),r==="month")return n;n+="-"}else if(n+=vt(t.c.month),r==="month")return n;return n+=vt(t.c.day),n}function YF(t,e,r,i,n,o,s){let a=!r||t.c.millisecond!==0||t.c.second!==0,l="";switch(s){case"day":case"month":case"year":break;default:if(l+=vt(t.c.hour),s==="hour")break;if(e){if(l+=":",l+=vt(t.c.minute),s==="minute")break;a&&(l+=":",l+=vt(t.c.second))}else{if(l+=vt(t.c.minute),s==="minute")break;a&&(l+=vt(t.c.second))}if(s==="second")break;a&&(!i||t.c.millisecond!==0)&&(l+=".",l+=vt(t.c.millisecond,3))}return n&&(t.isOffsetFixed&&t.offset===0&&!o?l+="Z":t.o<0?(l+="-",l+=vt(Math.trunc(-t.o/60)),l+=":",l+=vt(Math.trunc(-t.o%60))):(l+="+",l+=vt(Math.trunc(t.o/60)),l+=":",l+=vt(Math.trunc(t.o%60)))),o&&(l+="["+t.zone.ianaName+"]"),l}var eq={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},dde={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},pde={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Nh=["year","month","day","hour","minute","second","millisecond"],fde=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],mde=["year","ordinal","hour","minute","second","millisecond"];function Lh(t){let e={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"}[t.toLowerCase()];if(!e)throw new Uh(t);return e}function XF(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Lh(t)}}function hde(t){if(bu===void 0&&(bu=Xe.now()),t.type!=="iana")return t.offset(bu);let e=t.name,r=qx.get(e);return r===void 0&&(r=t.offset(bu),qx.set(e,r)),r}function QF(t,e){let r=oo(e.zone,Xe.defaultZone);if(!r.isValid)return et.invalid(gu(r));let i=ze.fromObject(e),n,o;if(ie(t.year))n=Xe.now();else{for(let l of Nh)ie(t[l])&&(t[l]=eq[l]);let s=T2(t)||C2(t);if(s)return et.invalid(s);let a=hde(r);[n,o]=Mh(t,a,r)}return new et({ts:n,zone:r,loc:i,o})}function e2(t,e,r){let i=ie(r.round)?!0:r.round,n=ie(r.rounding)?"trunc":r.rounding,o=(a,l)=>(a=Wx(a,i||r.calendary?0:2,r.calendary?"round":n),e.loc.clone(r).relFormatter(r).format(a,l)),s=a=>r.calendary?e.hasSame(t,a)?0:e.startOf(a).diff(t.startOf(a),a).get(a):e.diff(t,a).get(a);if(r.unit)return o(s(r.unit),r.unit);for(let a of r.units){let l=s(a);if(Math.abs(l)>=1)return o(l,a)}return o(t>e?-0:0,r.units[r.units.length-1])}function t2(t){let e={},r;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],r=Array.from(t).slice(0,t.length-1)):r=Array.from(t),[e,r]}var bu,qx=new Map,et=class t{constructor(e){let r=e.zone||Xe.defaultZone,i=e.invalid||(Number.isNaN(e.ts)?new Pr("invalid input"):null)||(r.isValid?null:gu(r));this.ts=ie(e.ts)?Xe.now():e.ts;let n=null,o=null;if(!i)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(r))[n,o]=[e.old.c,e.old.o];else{let a=ao(e.o)&&!e.old?e.o:r.offset(this.ts);n=jh(this.ts,a),i=Number.isNaN(n.year)?new Pr("invalid input"):null,n=i?null:n,o=i?null:a}this._zone=r,this.loc=e.loc||ze.create(),this.invalid=i,this.weekData=null,this.localWeekData=null,this.c=n,this.o=o,this.isLuxonDateTime=!0}static now(){return new t({})}static local(){let[e,r]=t2(arguments),[i,n,o,s,a,l,c]=r;return QF({year:i,month:n,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static utc(){let[e,r]=t2(arguments),[i,n,o,s,a,l,c]=r;return e.zone=Nr.utcInstance,QF({year:i,month:n,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static fromJSDate(e,r={}){let i=Bce(e)?e.valueOf():NaN;if(Number.isNaN(i))return t.invalid("invalid input");let n=oo(r.zone,Xe.defaultZone);return n.isValid?new t({ts:i,zone:n,loc:ze.fromObject(r)}):t.invalid(gu(n))}static fromMillis(e,r={}){if(ao(e))return e<-ZF||e>ZF?t.invalid("Timestamp out of range"):new t({ts:e,zone:oo(r.zone,Xe.defaultZone),loc:ze.fromObject(r)});throw new Dt(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,r={}){if(ao(e))return new t({ts:e*1e3,zone:oo(r.zone,Xe.defaultZone),loc:ze.fromObject(r)});throw new Dt("fromSeconds requires a numerical input")}static fromObject(e,r={}){e=e||{};let i=oo(r.zone,Xe.defaultZone);if(!i.isValid)return t.invalid(gu(i));let n=ze.fromObject(r),o=zh(e,XF),{minDaysInFirstWeek:s,startOfWeek:a}=LF(o,n),l=Xe.now(),c=ie(r.specificOffset)?i.offset(l):r.specificOffset,u=!ie(o.ordinal),d=!ie(o.year),f=!ie(o.month)||!ie(o.day),p=d||f,m=o.weekYear||o.weekNumber;if((p||u)&&m)throw new so("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(f&&u)throw new so("Can't mix ordinal dates with month/day");let y=m||o.weekday&&!p,w,_,A=jh(l,c);y?(w=fde,_=dde,A=Fh(A,s,a)):u?(w=mde,_=pde,A=Ex(A)):(w=Nh,_=eq);let O=!1;for(let fe of w){let Ee=o[fe];ie(Ee)?O?o[fe]=_[fe]:o[fe]=A[fe]:O=!0}let C=y?zce(o,s,a):u?Gce(o):T2(o),$=C||C2(o);if($)return t.invalid($);let re=y?MF(o,s,a):u?NF(o):o,[pe,ve]=Mh(re,c,i),me=new t({ts:pe,zone:i,o:ve,loc:n});return o.weekday&&p&&e.weekday!==me.weekday?t.invalid("mismatched weekday",`you can't specify both a weekday of ${o.weekday} and a date of ${me.toISO()}`):me.isValid?me:t.invalid(me.invalid)}static fromISO(e,r={}){let[i,n]=Mue(e);return Za(i,n,r,"ISO 8601",e)}static fromRFC2822(e,r={}){let[i,n]=Nue(e);return Za(i,n,r,"RFC 2822",e)}static fromHTTP(e,r={}){let[i,n]=Lue(e);return Za(i,n,r,"HTTP",r)}static fromFormat(e,r,i={}){if(ie(e)||ie(r))throw new Dt("fromFormat requires an input string and a format");let{locale:n=null,numberingSystem:o=null}=i,s=ze.fromOpts({locale:n,numberingSystem:o,defaultToEN:!0}),[a,l,c,u]=ude(s,e,r);return u?t.invalid(u):Za(a,l,i,`format ${r}`,e,c)}static fromString(e,r,i={}){return t.fromFormat(e,r,i)}static fromSQL(e,r={}){let[i,n]=Gue(e);return Za(i,n,r,"SQL",e)}static invalid(e,r=null){if(!e)throw new Dt("need to specify a reason the DateTime is invalid");let i=e instanceof Pr?e:new Pr(e,r);if(Xe.throwOnInvalid)throw new Tx(i);return new t({invalid:i})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,r={}){let i=X2(e,ze.fromObject(r));return i?i.map(n=>n?n.val:null).join(""):null}static expandFormat(e,r={}){return H2(jr.parseFormat(e),ze.fromObject(r)).map(n=>n.val).join("")}static resetCache(){bu=void 0,qx.clear()}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?Ix(this).weekYear:NaN}get weekNumber(){return this.isValid?Ix(this).weekNumber:NaN}get weekday(){return this.isValid?Ix(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?kx(this).weekday:NaN}get localWeekNumber(){return this.isValid?kx(this).weekNumber:NaN}get localWeekYear(){return this.isValid?kx(this).weekYear:NaN}get ordinal(){return this.isValid?Ex(this.c).ordinal:NaN}get monthShort(){return this.isValid?ls.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?ls.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?ls.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?ls.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let e=864e5,r=6e4,i=Bh(this.c),n=this.zone.offset(i-e),o=this.zone.offset(i+e),s=this.zone.offset(i-n*r),a=this.zone.offset(i-o*r);if(s===a)return[this];let l=i-s*r,c=i-a*r,u=jh(l,s),d=jh(c,a);return u.hour===d.hour&&u.minute===d.minute&&u.second===d.second&&u.millisecond===d.millisecond?[ss(this,{ts:l}),ss(this,{ts:c})]:[this]}get isInLeapYear(){return wu(this.year)}get daysInMonth(){return qh(this.year,this.month)}get daysInYear(){return this.isValid?Ha(this.year):NaN}get weeksInWeekYear(){return this.isValid?Eu(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Eu(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:r,numberingSystem:i,calendar:n}=jr.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:r,numberingSystem:i,outputCalendar:n}}toUTC(e=0,r={}){return this.setZone(Nr.instance(e),r)}toLocal(){return this.setZone(Xe.defaultZone)}setZone(e,{keepLocalTime:r=!1,keepCalendarTime:i=!1}={}){if(e=oo(e,Xe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let n=this.ts;if(r||i){let o=e.offset(this.ts),s=this.toObject();[n]=Mh(s,o,e)}return ss(this,{ts:n,zone:e})}else return t.invalid(gu(e))}reconfigure({locale:e,numberingSystem:r,outputCalendar:i}={}){let n=this.loc.clone({locale:e,numberingSystem:r,outputCalendar:i});return ss(this,{loc:n})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let r=zh(e,XF),{minDaysInFirstWeek:i,startOfWeek:n}=LF(r,this.loc),o=!ie(r.weekYear)||!ie(r.weekNumber)||!ie(r.weekday),s=!ie(r.ordinal),a=!ie(r.year),l=!ie(r.month)||!ie(r.day),c=a||l,u=r.weekYear||r.weekNumber;if((c||s)&&u)throw new so("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&s)throw new so("Can't mix ordinal dates with month/day");let d;o?d=MF({...Fh(this.c,i,n),...r},i,n):ie(r.ordinal)?(d={...this.toObject(),...r},ie(r.day)&&(d.day=Math.min(qh(d.year,d.month),d.day))):d=NF({...Ex(this.c),...r});let[f,p]=Mh(d,this.o,this.zone);return ss(this,{ts:f,o:p})}plus(e){if(!this.isValid)return this;let r=Ot.fromDurationLike(e);return ss(this,HF(this,r))}minus(e){if(!this.isValid)return this;let r=Ot.fromDurationLike(e).negate();return ss(this,HF(this,r))}startOf(e,{useLocaleWeeks:r=!1}={}){if(!this.isValid)return this;let i={},n=Ot.normalizeUnit(e);switch(n){case"years":i.month=1;case"quarters":case"months":i.day=1;case"weeks":case"days":i.hour=0;case"hours":i.minute=0;case"minutes":i.second=0;case"seconds":i.millisecond=0;break}if(n==="weeks")if(r){let o=this.loc.getStartOfWeek(),{weekday:s}=this;s<o&&(i.weekNumber=this.weekNumber-1),i.weekday=o}else i.weekday=1;if(n==="quarters"){let o=Math.ceil(this.month/3);i.month=(o-1)*3+1}return this.set(i)}endOf(e,r){return this.isValid?this.plus({[e]:1}).startOf(e,r).minus(1):this}toFormat(e,r={}){return this.isValid?jr.create(this.loc.redefaultToEN(r)).formatDateTimeFromString(this,e):xx}toLocaleString(e=$h,r={}){return this.isValid?jr.create(this.loc.clone(r),e).formatDateTime(this):xx}toLocaleParts(e={}){return this.isValid?jr.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:r=!1,suppressMilliseconds:i=!1,includeOffset:n=!0,extendedZone:o=!1,precision:s="milliseconds"}={}){if(!this.isValid)return null;s=Lh(s);let a=e==="extended",l=_x(this,a,s);return Nh.indexOf(s)>=3&&(l+="T"),l+=YF(this,a,r,i,n,o,s),l}toISODate({format:e="extended",precision:r="day"}={}){return this.isValid?_x(this,e==="extended",Lh(r)):null}toISOWeekDate(){return Ph(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:r=!1,includeOffset:i=!0,includePrefix:n=!1,extendedZone:o=!1,format:s="extended",precision:a="milliseconds"}={}){return this.isValid?(a=Lh(a),(n&&Nh.indexOf(a)>=3?"T":"")+YF(this,s==="extended",r,e,i,o,a)):null}toRFC2822(){return Ph(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Ph(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?_x(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:r=!1,includeOffsetSpace:i=!0}={}){let n="HH:mm:ss.SSS";return(r||e)&&(i&&(n+=" "),r?n+="z":e&&(n+="ZZ")),Ph(this,n,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():xx}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`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{};let r={...this.c};return e.includeConfig&&(r.outputCalendar=this.outputCalendar,r.numberingSystem=this.loc.numberingSystem,r.locale=this.loc.locale),r}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,r="milliseconds",i={}){if(!this.isValid||!e.isValid)return Ot.invalid("created by diffing an invalid DateTime");let n={locale:this.locale,numberingSystem:this.numberingSystem,...i},o=Wce(r).map(Ot.normalizeUnit),s=e.valueOf()>this.valueOf(),a=s?this:e,l=s?e:this,c=Yue(a,l,o,n);return s?c.negate():c}diffNow(e="milliseconds",r={}){return this.diff(t.now(),e,r)}until(e){return this.isValid?cs.fromDateTimes(this,e):this}hasSame(e,r,i){if(!this.isValid)return!1;let n=e.valueOf(),o=this.setZone(e.zone,{keepLocalTime:!0});return o.startOf(r,i)<=n&&n<=o.endOf(r,i)}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;let r=e.base||t.fromObject({},{zone:this.zone}),i=e.padding?this<r?-e.padding:e.padding:0,n=["years","months","days","hours","minutes","seconds"],o=e.unit;return Array.isArray(e.unit)&&(n=e.unit,o=void 0),e2(r,this.plus(i),{...e,numeric:"always",units:n,unit:o})}toRelativeCalendar(e={}){return this.isValid?e2(e.base||t.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(t.isDateTime))throw new Dt("min requires all arguments be DateTimes");return UF(e,r=>r.valueOf(),Math.min)}static max(...e){if(!e.every(t.isDateTime))throw new Dt("max requires all arguments be DateTimes");return UF(e,r=>r.valueOf(),Math.max)}static fromFormatExplain(e,r,i={}){let{locale:n=null,numberingSystem:o=null}=i,s=ze.fromOpts({locale:n,numberingSystem:o,defaultToEN:!0});return Y2(s,e,r)}static fromStringExplain(e,r,i={}){return t.fromFormatExplain(e,r,i)}static buildFormatParser(e,r={}){let{locale:i=null,numberingSystem:n=null}=r,o=ze.fromOpts({locale:i,numberingSystem:n,defaultToEN:!0});return new Gh(o,e)}static fromFormatParser(e,r,i={}){if(ie(e)||ie(r))throw new Dt("fromFormatParser requires an input string and a format parser");let{locale:n=null,numberingSystem:o=null}=i,s=ze.fromOpts({locale:n,numberingSystem:o,defaultToEN:!0});if(!s.equals(r.locale))throw new Dt(`fromFormatParser called with a locale of ${s}, but the format parser was created for ${r.locale}`);let{result:a,zone:l,specificOffset:c,invalidReason:u}=r.explainFromTokens(e);return u?t.invalid(u):Za(a,l,i,`format ${r.format}`,e,c)}static get DATE_SHORT(){return $h}static get DATE_MED(){return r2}static get DATE_MED_WITH_WEEKDAY(){return kce}static get DATE_FULL(){return n2}static get DATE_HUGE(){return i2}static get TIME_SIMPLE(){return o2}static get TIME_WITH_SECONDS(){return s2}static get TIME_WITH_SHORT_OFFSET(){return a2}static get TIME_WITH_LONG_OFFSET(){return l2}static get TIME_24_SIMPLE(){return c2}static get TIME_24_WITH_SECONDS(){return u2}static get TIME_24_WITH_SHORT_OFFSET(){return d2}static get TIME_24_WITH_LONG_OFFSET(){return p2}static get DATETIME_SHORT(){return f2}static get DATETIME_SHORT_WITH_SECONDS(){return m2}static get DATETIME_MED(){return h2}static get DATETIME_MED_WITH_SECONDS(){return y2}static get DATETIME_MED_WITH_WEEKDAY(){return _ce}static get DATETIME_FULL(){return g2}static get DATETIME_FULL_WITH_SECONDS(){return b2}static get DATETIME_HUGE(){return v2}static get DATETIME_HUGE_WITH_SECONDS(){return S2}};function hu(t){if(et.isDateTime(t))return t;if(t&&t.valueOf&&ao(t.valueOf()))return et.fromJSDate(t);if(t&&typeof t=="object")return et.fromObject(t);throw new Dt(`Unknown datetime argument: ${t}, of type ${typeof t}`)}var yde="3.7.2";Lr.DateTime=et;Lr.Duration=Ot;Lr.FixedOffsetZone=Nr;Lr.IANAZone=gi;Lr.Info=ls;Lr.Interval=cs;Lr.InvalidZone=Jh;Lr.Settings=Xe;Lr.SystemZone=Su;Lr.VERSION=yde;Lr.Zone=lo});var nq=h((ATe,rq)=>{"use strict";var us=tq();ae.prototype.addYear=function(){this._date=this._date.plus({years:1})};ae.prototype.addMonth=function(){this._date=this._date.plus({months:1}).startOf("month")};ae.prototype.addDay=function(){this._date=this._date.plus({days:1}).startOf("day")};ae.prototype.addHour=function(){var t=this._date;this._date=this._date.plus({hours:1}).startOf("hour"),this._date<=t&&(this._date=this._date.plus({hours:1}))};ae.prototype.addMinute=function(){var t=this._date;this._date=this._date.plus({minutes:1}).startOf("minute"),this._date<t&&(this._date=this._date.plus({hours:1}))};ae.prototype.addSecond=function(){var t=this._date;this._date=this._date.plus({seconds:1}).startOf("second"),this._date<t&&(this._date=this._date.plus({hours:1}))};ae.prototype.subtractYear=function(){this._date=this._date.minus({years:1})};ae.prototype.subtractMonth=function(){this._date=this._date.minus({months:1}).endOf("month").startOf("second")};ae.prototype.subtractDay=function(){this._date=this._date.minus({days:1}).endOf("day").startOf("second")};ae.prototype.subtractHour=function(){var t=this._date;this._date=this._date.minus({hours:1}).endOf("hour").startOf("second"),this._date>=t&&(this._date=this._date.minus({hours:1}))};ae.prototype.subtractMinute=function(){var t=this._date;this._date=this._date.minus({minutes:1}).endOf("minute").startOf("second"),this._date>t&&(this._date=this._date.minus({hours:1}))};ae.prototype.subtractSecond=function(){var t=this._date;this._date=this._date.minus({seconds:1}).startOf("second"),this._date>t&&(this._date=this._date.minus({hours:1}))};ae.prototype.getDate=function(){return this._date.day};ae.prototype.getFullYear=function(){return this._date.year};ae.prototype.getDay=function(){var t=this._date.weekday;return t==7?0:t};ae.prototype.getMonth=function(){return this._date.month-1};ae.prototype.getHours=function(){return this._date.hour};ae.prototype.getMinutes=function(){return this._date.minute};ae.prototype.getSeconds=function(){return this._date.second};ae.prototype.getMilliseconds=function(){return this._date.millisecond};ae.prototype.getTime=function(){return this._date.valueOf()};ae.prototype.getUTCDate=function(){return this._getUTC().day};ae.prototype.getUTCFullYear=function(){return this._getUTC().year};ae.prototype.getUTCDay=function(){var t=this._getUTC().weekday;return t==7?0:t};ae.prototype.getUTCMonth=function(){return this._getUTC().month-1};ae.prototype.getUTCHours=function(){return this._getUTC().hour};ae.prototype.getUTCMinutes=function(){return this._getUTC().minute};ae.prototype.getUTCSeconds=function(){return this._getUTC().second};ae.prototype.toISOString=function(){return this._date.toUTC().toISO()};ae.prototype.toJSON=function(){return this._date.toJSON()};ae.prototype.setDate=function(t){this._date=this._date.set({day:t})};ae.prototype.setFullYear=function(t){this._date=this._date.set({year:t})};ae.prototype.setDay=function(t){this._date=this._date.set({weekday:t})};ae.prototype.setMonth=function(t){this._date=this._date.set({month:t+1})};ae.prototype.setHours=function(t){this._date=this._date.set({hour:t})};ae.prototype.setMinutes=function(t){this._date=this._date.set({minute:t})};ae.prototype.setSeconds=function(t){this._date=this._date.set({second:t})};ae.prototype.setMilliseconds=function(t){this._date=this._date.set({millisecond:t})};ae.prototype._getUTC=function(){return this._date.toUTC()};ae.prototype.toString=function(){return this.toDate().toString()};ae.prototype.toDate=function(){return this._date.toJSDate()};ae.prototype.isLastDayOfMonth=function(){var t=this._date.plus({days:1}).startOf("day");return this._date.month!==t.month};ae.prototype.isLastWeekdayOfMonth=function(){var t=this._date.plus({days:7}).startOf("day");return this._date.month!==t.month};function ae(t,e){var r={zone:e};if(t?t instanceof ae?this._date=t._date:t instanceof Date?this._date=us.DateTime.fromJSDate(t,r):typeof t=="number"?this._date=us.DateTime.fromMillis(t,r):typeof t=="string"&&(this._date=us.DateTime.fromISO(t,r),this._date.isValid||(this._date=us.DateTime.fromRFC2822(t,r)),this._date.isValid||(this._date=us.DateTime.fromSQL(t,r)),this._date.isValid||(this._date=us.DateTime.fromFormat(t,"EEE, d MMM yyyy HH:mm:ss",r))):this._date=us.DateTime.local(),!this._date||!this._date.isValid)throw new Error("CronDate: unhandled timestamp: "+JSON.stringify(t));e&&e!==this._date.zoneName&&(this._date=this._date.setZone(e))}rq.exports=ae});var sq=h((KTe,oq)=>{"use strict";function ds(t){return{start:t,count:1}}function iq(t,e){t.end=e,t.step=e-t.start,t.count=2}function Xx(t,e,r){e&&(e.count===2?(t.push(ds(e.start)),t.push(ds(e.end))):t.push(e)),r&&t.push(r)}function gde(t){for(var e=[],r=void 0,i=0;i<t.length;i++){var n=t[i];typeof n!="number"?(Xx(e,r,ds(n)),r=void 0):r?r.count===1?iq(r,n):r.step===n-r.end?(r.count++,r.end=n):r.count===2?(e.push(ds(r.start)),r=ds(r.end),iq(r,n)):(Xx(e,r),r=ds(n)):r=ds(n)}return Xx(e,r),e}oq.exports=gde});var lq=h((RTe,aq)=>{"use strict";var bde=sq();function vde(t,e,r){var i=bde(t);if(i.length===1){var n=i[0],o=n.step;if(o===1&&n.start===e&&n.end===r)return"*";if(o!==1&&n.start===e&&n.end===r-o+1)return"*/"+o}for(var s=[],a=0,l=i.length;a<l;++a){var c=i[a];if(c.count===1){s.push(c.start);continue}var o=c.step;if(c.step===1){s.push(c.start+"-"+c.end);continue}var u=c.start==0?c.count-1:c.count;c.step*u>c.end?s=s.concat(Array.from({length:c.end-c.start+1}).map(function(f,p){var m=c.start+p;return(m-c.start)%c.step===0?m:null}).filter(function(f){return f!=null})):c.end===r-c.step+1?s.push(c.start+"/"+c.step):s.push(c.start+"-"+c.end+"/"+c.step)}return s.join(",")}aq.exports=vde});var dq=h((DTe,uq)=>{"use strict";var ps=nq(),Sde=lq(),cq=1e4;function G(t,e){this._options=e,this._utc=e.utc||!1,this._tz=this._utc?"UTC":e.tz,this._currentDate=new ps(e.currentDate,this._tz),this._startDate=e.startDate?new ps(e.startDate,this._tz):null,this._endDate=e.endDate?new ps(e.endDate,this._tz):null,this._isIterator=e.iterator||!1,this._hasIterated=!1,this._nthDayOfWeek=e.nthDayOfWeek||0,this.fields=G._freezeFields(t)}G.map=["second","minute","hour","dayOfMonth","month","dayOfWeek"];G.predefined={"@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *"};G.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"]}];G.daysInMonth=[31,29,31,30,31,30,31,31,30,31,30,31];G.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}};G.parseDefaults=["0","*","*","*","*","*"];G.standardValidCharacters=/^[,*\d/-]+$/;G.dayOfWeekValidCharacters=/^[?,*\dL#/-]+$/;G.dayOfMonthValidCharacters=/^[?,*\dL/-]+$/;G.validCharacters={second:G.standardValidCharacters,minute:G.standardValidCharacters,hour:G.standardValidCharacters,dayOfMonth:G.dayOfMonthValidCharacters,month:G.standardValidCharacters,dayOfWeek:G.dayOfWeekValidCharacters};G._isValidConstraintChar=function(e,r){return typeof r!="string"?!1:e.chars.some(function(i){return r.indexOf(i)>-1})};G._parseField=function(e,r,i){switch(e){case"month":case"dayOfWeek":var n=G.aliases[e];r=r.replace(/[a-z]{3}/gi,function(l){if(l=l.toLowerCase(),typeof n[l]<"u")return n[l];throw new Error('Validation error, cannot resolve alias "'+l+'"')});break}if(!G.validCharacters[e].test(r))throw new Error("Invalid characters, got value: "+r);r.indexOf("*")!==-1?r=r.replace(/\*/g,i.min+"-"+i.max):r.indexOf("?")!==-1&&(r=r.replace(/\?/g,i.min+"-"+i.max));function o(l){var c=[];function u(m){if(m instanceof Array)for(var y=0,w=m.length;y<w;y++){var _=m[y];if(G._isValidConstraintChar(i,_)){c.push(_);continue}if(typeof _!="number"||Number.isNaN(_)||_<i.min||_>i.max)throw new Error("Constraint error, got value "+_+" expected range "+i.min+"-"+i.max);c.push(_)}else{if(G._isValidConstraintChar(i,m)){c.push(m);return}var A=+m;if(Number.isNaN(A)||A<i.min||A>i.max)throw new Error("Constraint error, got value "+m+" expected range "+i.min+"-"+i.max);e==="dayOfWeek"&&(A=A%7),c.push(A)}}var d=l.split(",");if(!d.every(function(m){return m.length>0}))throw new Error("Invalid list value format");if(d.length>1)for(var f=0,p=d.length;f<p;f++)u(s(d[f]));else u(s(l));return c.sort(G._sortCompareFn),c}function s(l){var c=1,u=l.split("/");if(u.length>2)throw new Error("Invalid repeat: "+l);return u.length>1?(u[0]==+u[0]&&(u=[u[0]+"-"+i.max,u[1]]),a(u[0],u[u.length-1])):a(l,c)}function a(l,c){var u=[],d=l.split("-");if(d.length>1){if(d.length<2)return+l;if(!d[0].length){if(!d[1].length)throw new Error("Invalid range: "+l);return+l}var f=+d[0],p=+d[1];if(Number.isNaN(f)||Number.isNaN(p)||f<i.min||p>i.max)throw new Error("Constraint error, got range "+f+"-"+p+" expected range "+i.min+"-"+i.max);if(f>p)throw new Error("Invalid range: "+l);var m=+c;if(Number.isNaN(m)||m<=0)throw new Error("Constraint error, cannot repeat at every "+m+" time.");e==="dayOfWeek"&&p%7===0&&u.push(0);for(var y=f,w=p;y<=w;y++){var _=u.indexOf(y)!==-1;!_&&m>0&&m%c===0?(m=1,u.push(y)):m++}return u}return Number.isNaN(+l)?l:+l}return o(r)};G._sortCompareFn=function(t,e){var r=typeof t=="number",i=typeof e=="number";return r&&i?t-e:!r&&i?1:r&&!i?-1:t.localeCompare(e)};G._handleMaxDaysInMonth=function(t){if(t.month.length===1){var e=G.daysInMonth[t.month[0]-1];if(t.dayOfMonth[0]>e)throw new Error("Invalid explicit day of month definition");return t.dayOfMonth.filter(function(r){return r==="L"?!0:r<=e}).sort(G._sortCompareFn)}};G._freezeFields=function(t){for(var e=0,r=G.map.length;e<r;++e){var i=G.map[e],n=t[i];t[i]=Object.freeze(n)}return Object.freeze(t)};G.prototype._applyTimezoneShift=function(t,e,r){if(r==="Month"||r==="Day"){var i=t.getTime();t[e+r]();var n=t.getTime();i===n&&(t.getMinutes()===0&&t.getSeconds()===0?t.addHour():t.getMinutes()===59&&t.getSeconds()===59&&t.subtractHour())}else{var o=t.getHours();t[e+r]();var s=t.getHours(),a=s-o;a===2?this.fields.hour.length!==24&&(this._dstStart=s):a===0&&t.getMinutes()===0&&t.getSeconds()===0&&this.fields.hour.length!==24&&(this._dstEnd=s)}};G.prototype._findSchedule=function(e){function r(_,A){for(var O=0,C=A.length;O<C;O++)if(A[O]>=_)return A[O]===_;return A[0]===_}function i(_,A){if(A<6){if(_.getDate()<8&&A===1)return!0;var O=_.getDate()%7?1:0,C=_.getDate()-_.getDate()%7,$=Math.floor(C/7)+O;return $===A}return!1}function n(_){return _.length>0&&_.some(function(A){return typeof A=="string"&&A.indexOf("L")>=0})}e=e||!1;var o=e?"subtract":"add",s=new ps(this._currentDate,this._tz),a=this._startDate,l=this._endDate,c=s.getTime(),u=0;function d(_){return _.some(function(A){if(!n([A]))return!1;var O=Number.parseInt(A[0])%7;if(Number.isNaN(O))throw new Error("Invalid last weekday of the month expression: "+A);return s.getDay()===O&&s.isLastWeekdayOfMonth()})}for(;u<cq;){if(u++,e){if(a&&s.getTime()-a.getTime()<0)throw new Error("Out of the timespan range")}else if(l&&l.getTime()-s.getTime()<0)throw new Error("Out of the timespan range");var f=r(s.getDate(),this.fields.dayOfMonth);n(this.fields.dayOfMonth)&&(f=f||s.isLastDayOfMonth());var p=r(s.getDay(),this.fields.dayOfWeek);n(this.fields.dayOfWeek)&&(p=p||d(this.fields.dayOfWeek));var m=this.fields.dayOfMonth.length>=G.daysInMonth[s.getMonth()],y=this.fields.dayOfWeek.length===G.constraints[5].max-G.constraints[5].min+1,w=s.getHours();if(!f&&(!p||y)){this._applyTimezoneShift(s,o,"Day");continue}if(!m&&y&&!f){this._applyTimezoneShift(s,o,"Day");continue}if(m&&!y&&!p){this._applyTimezoneShift(s,o,"Day");continue}if(this._nthDayOfWeek>0&&!i(s,this._nthDayOfWeek)){this._applyTimezoneShift(s,o,"Day");continue}if(!r(s.getMonth()+1,this.fields.month)){this._applyTimezoneShift(s,o,"Month");continue}if(r(w,this.fields.hour)){if(this._dstEnd===w&&!e){this._dstEnd=null,this._applyTimezoneShift(s,"add","Hour");continue}}else if(this._dstStart!==w){this._dstStart=null,this._applyTimezoneShift(s,o,"Hour");continue}else if(!r(w-1,this.fields.hour)){s[o+"Hour"]();continue}if(!r(s.getMinutes(),this.fields.minute)){this._applyTimezoneShift(s,o,"Minute");continue}if(!r(s.getSeconds(),this.fields.second)){this._applyTimezoneShift(s,o,"Second");continue}if(c===s.getTime()){o==="add"||s.getMilliseconds()===0?this._applyTimezoneShift(s,o,"Second"):s.setMilliseconds(0);continue}break}if(u>=cq)throw new Error("Invalid expression, loop limit exceeded");return this._currentDate=new ps(s,this._tz),this._hasIterated=!0,s};G.prototype.next=function(){var e=this._findSchedule();return this._isIterator?{value:e,done:!this.hasNext()}:e};G.prototype.prev=function(){var e=this._findSchedule(!0);return this._isIterator?{value:e,done:!this.hasPrev()}:e};G.prototype.hasNext=function(){var t=this._currentDate,e=this._hasIterated;try{return this._findSchedule(),!0}catch{return!1}finally{this._currentDate=t,this._hasIterated=e}};G.prototype.hasPrev=function(){var t=this._currentDate,e=this._hasIterated;try{return this._findSchedule(!0),!0}catch{return!1}finally{this._currentDate=t,this._hasIterated=e}};G.prototype.iterate=function(e,r){var i=[];if(e>=0)for(var n=0,o=e;n<o;n++)try{var s=this.next();i.push(s),r&&r(s,n)}catch{break}else for(var n=0,o=e;n>o;n--)try{var s=this.prev();i.push(s),r&&r(s,n)}catch{break}return i};G.prototype.reset=function(e){this._currentDate=new ps(e||this._options.currentDate)};G.prototype.stringify=function(e){for(var r=[],i=e?0:1,n=G.map.length;i<n;++i){var o=G.map[i],s=this.fields[o],a=G.constraints[i];o==="dayOfMonth"&&this.fields.month.length===1?a={min:1,max:G.daysInMonth[this.fields.month[0]-1]}:o==="dayOfWeek"&&(a={min:0,max:6},s=s[s.length-1]===7?s.slice(0,-1):s),r.push(Sde(s,a.min,a.max))}return r.join(" ")};G.parse=function(e,r){var i=this;typeof r=="function"&&(r={});function n(o,s){s||(s={}),typeof s.currentDate>"u"&&(s.currentDate=new ps(void 0,i._tz)),G.predefined[o]&&(o=G.predefined[o]);var a=[],l=(o+"").trim().split(/\s+/);if(l.length>6)throw new Error("Invalid cron expression");for(var c=G.map.length-l.length,u=0,d=G.map.length;u<d;++u){var f=G.map[u],p=l[l.length>d?u:u-c];if(u<c||!p)a.push(G._parseField(f,G.parseDefaults[u],G.constraints[u]));else{var m=f==="dayOfWeek"?A(p):p;a.push(G._parseField(f,m,G.constraints[u]))}}for(var y={},u=0,d=G.map.length;u<d;u++){var w=G.map[u];y[w]=a[u]}var _=G._handleMaxDaysInMonth(y);return y.dayOfMonth=_||y.dayOfMonth,new G(y,s);function A(O){var C=O.split("#");if(C.length>1){var $=+C[C.length-1];if(/,/.test(O))throw new Error("Constraint error, invalid dayOfWeek `#` and `,` special characters are incompatible");if(/\//.test(O))throw new Error("Constraint error, invalid dayOfWeek `#` and `/` special characters are incompatible");if(/-/.test(O))throw new Error("Constraint error, invalid dayOfWeek `#` and `-` special characters are incompatible");if(C.length>2||Number.isNaN($)||$<1||$>5)throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return s.nthDayOfWeek=$,C[0]}return O}}return n(e,r)};G.fieldsToExpression=function(e,r){function i(f,p,m){if(!p)throw new Error("Validation error, Field "+f+" is missing");if(p.length===0)throw new Error("Validation error, Field "+f+" contains no values");for(var y=0,w=p.length;y<w;y++){var _=p[y];if(!G._isValidConstraintChar(m,_)&&(typeof _!="number"||Number.isNaN(_)||_<m.min||_>m.max))throw new Error("Constraint error, got value "+_+" expected range "+m.min+"-"+m.max)}}for(var n={},o=0,s=G.map.length;o<s;++o){var a=G.map[o],l=e[a];i(a,l,G.constraints[o]);for(var c=[],u=-1;++u<l.length;)c[u]=l[u];if(l=c.sort(G._sortCompareFn).filter(function(f,p,m){return!p||f!==m[p-1]}),l.length!==c.length)throw new Error("Validation error, Field "+a+" contains duplicate values");n[a]=l}var d=G._handleMaxDaysInMonth(n);return n.dayOfMonth=d||n.dayOfMonth,new G(n,r||{})};uq.exports=G});var Qx=h((jTe,pq)=>{"use strict";var Hh=dq();function co(){}co._parseEntry=function(e){var r=e.split(" ");if(r.length===6)return{interval:Hh.parse(e)};if(r.length>6)return{interval:Hh.parse(r.slice(0,6).join(" ")),command:r.slice(6,r.length)};throw new Error("Invalid entry: "+e)};co.parseExpression=function(e,r){return Hh.parse(e,r)};co.fieldsToExpression=function(e,r){return Hh.fieldsToExpression(e,r)};co.parseString=function(e){for(var r=e.split(`
9952
9952
  `),i={variables:{},expressions:[],errors:{}},n=0,o=r.length;n<o;n++){var s=r[n],a=null,l=s.trim();if(l.length>0){if(l.match(/^#/))continue;if(a=l.match(/^(.*)=(.*)$/))i.variables[a[1]]=a[2];else{var c=null;try{c=co._parseEntry("0 "+l),i.expressions.push(c.interval)}catch(u){i.errors[l]=u}}}}return i};co.parseFile=function(e,r){U("fs").readFile(e,function(i,n){if(i){r(i);return}return r(null,co.parseString(n.toString()))})};pq.exports=co});var uo=h(Yh=>{"use strict";Object.defineProperty(Yh,"__esModule",{value:!0});Yh.QueueBase=void 0;var Ede=U("events"),ku=Or(),wde=im(),xde=mu(),Ide=Pa(),kde=sm(),eI=class extends Ede.EventEmitter{constructor(e,r={connection:{}},i=xde.RedisConnection,n=!1){if(super(),this.name=e,this.opts=r,this.closed=!1,this.hasBlockingConnection=!1,this.hasBlockingConnection=n,this.opts=Object.assign({prefix:"bull"},r),!e)throw new Error("Queue name must be provided");if(e.includes(":"))throw new Error("Queue name cannot contain :");this.connection=new i(r.connection,{shared:(0,ku.isRedisInstance)(r.connection),blocking:n,skipVersionCheck:r.skipVersionCheck,skipWaitingForReady:r.skipWaitingForReady}),this.connection.on("error",s=>this.emit("error",s)),this.connection.on("close",()=>{this.closing||this.emit("ioredis:close")});let o=new kde.QueueKeys(r.prefix);this.qualifiedName=o.getQueueQualifiedName(e),this.keys=o.getKeys(e),this.toKey=s=>o.toKey(e,s),this.createScripts()}get client(){return this.connection.client}createScripts(){this.scripts=(0,wde.createScripts)(this)}get redisVersion(){return this.connection.redisVersion}get databaseType(){return this.connection.databaseType}get Job(){return Ide.Job}emit(e,...r){try{return super.emit(e,...r)}catch(i){try{return super.emit("error",i)}catch(n){return console.error(n),!1}}}waitUntilReady(){return this.client}base64Name(){return Buffer.from(this.name).toString("base64")}clientName(e=""){let r=this.base64Name();return`${this.opts.prefix}:${r}${e}`}async close(){this.closing||(this.closing=this.connection.close()),await this.closing,this.closed=!0}disconnect(){return this.connection.disconnect()}async checkConnectionError(e,r=ku.DELAY_TIME_5){try{return await e()}catch(i){if((0,ku.isNotConnectionError)(i)&&this.emit("error",i),!this.closing&&r)await(0,ku.delay)(r);else return}}trace(e,r,i,n,o){return(0,ku.trace)(this.opts.telemetry,e,this.name,r,i,n,o)}};Yh.QueueBase=eI});var Qh=h(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.defaultRepeatStrategy=fs.JobScheduler=void 0;var _de=(Zt(),Jt(Wt)),Tde=Qx(),Xh=Pa(),Cde=uo(),_u=gr(),Ode=Or(),tI=class extends Cde.QueueBase{constructor(e,r,i){super(e,r,i),this.repeatStrategy=r.settings&&r.settings.repeatStrategy||fs.defaultRepeatStrategy}async upsertJobScheduler(e,r,i,n,o,{override:s,producerId:a}){let{every:l,limit:c,pattern:u,offset:d}=r;if(u&&l)throw new Error("Both .pattern and .every options are defined for this repeatable job");if(!u&&!l)throw new Error("Either .pattern or .every options must be defined for this repeatable job");if(r.immediately&&r.startDate)throw new Error("Both .immediately and .startDate options are defined for this repeatable job");r.immediately&&r.every&&console.warn("Using option immediately with every does not affect the job's schedule. Job will run immediately anyway.");let f=r.count?r.count+1:1;if(typeof r.limit<"u"&&f>r.limit)return;let p=Date.now(),{endDate:m}=r;if(m&&p>new Date(m).getTime())return;let y=o.prevMillis||0;p=y<p?p:y;let{immediately:w}=r,_=_de.__rest(r,["immediately"]),A,O=l&&d?d:null;if(u&&(A=await this.repeatStrategy(p,r,i),A<p&&(A=p)),A||l)return this.trace(_u.SpanKind.PRODUCER,"add",`${this.name}.${i}`,async(C,$)=>{var re,pe;let ve=o.telemetry;if($){let fe=(re=o.telemetry)===null||re===void 0?void 0:re.omitContext,Ee=((pe=o.telemetry)===null||pe===void 0?void 0:pe.metadata)||!fe&&$;(Ee||fe)&&(ve={metadata:Ee,omitContext:fe})}let me=this.getNextJobOpts(A,e,Object.assign(Object.assign({},o),{repeat:_,telemetry:ve}),f,O);if(s){A<p&&(A=p);let[fe,Ee]=await this.scripts.addJobScheduler(e,A,JSON.stringify(typeof n>"u"?{}:n),Xh.Job.optsAsJSON(o),{name:i,startDate:r.startDate?new Date(r.startDate).getTime():void 0,endDate:m?new Date(m).getTime():void 0,tz:r.tz,pattern:u,every:l,limit:c,offset:O},Xh.Job.optsAsJSON(me),a),qr=typeof Ee=="string"?parseInt(Ee,10):Ee,E=new this.Job(this,i,n,Object.assign(Object.assign({},me),{delay:qr}),fe);return E.id=fe,C?.setAttributes({[_u.TelemetryAttributes.JobSchedulerId]:e,[_u.TelemetryAttributes.JobId]:E.id}),E}else{let fe=await this.scripts.updateJobSchedulerNextMillis(e,A,JSON.stringify(typeof n>"u"?{}:n),Xh.Job.optsAsJSON(me),a);if(fe){let Ee=new this.Job(this,i,n,me,fe);return Ee.id=fe,C?.setAttributes({[_u.TelemetryAttributes.JobSchedulerId]:e,[_u.TelemetryAttributes.JobId]:Ee.id}),Ee}}})}getNextJobOpts(e,r,i,n,o){var s,a;let l=this.getSchedulerNextJobId({jobSchedulerId:r,nextMillis:e}),c=Date.now(),u=e+o-c,d=Object.assign(Object.assign({},i),{jobId:l,delay:u<0?0:u,timestamp:c,prevMillis:e,repeatJobKey:r});return d.repeat=Object.assign(Object.assign({},i.repeat),{offset:o,count:n,startDate:!((s=i.repeat)===null||s===void 0)&&s.startDate?new Date(i.repeat.startDate).getTime():void 0,endDate:!((a=i.repeat)===null||a===void 0)&&a.endDate?new Date(i.repeat.endDate).getTime():void 0}),d}async removeJobScheduler(e){return this.scripts.removeJobScheduler(e)}async getSchedulerData(e,r,i){let n=await e.hgetall(this.toKey("repeat:"+r));return this.transformSchedulerData(r,n,i)}transformSchedulerData(e,r,i){if(r&&Object.keys(r).length>0){let n={key:e,name:r.name,next:i};return r.ic&&(n.iterationCount=parseInt(r.ic)),r.limit&&(n.limit=parseInt(r.limit)),r.startDate&&(n.startDate=parseInt(r.startDate)),r.endDate&&(n.endDate=parseInt(r.endDate)),r.tz&&(n.tz=r.tz),r.pattern&&(n.pattern=r.pattern),r.every&&(n.every=parseInt(r.every)),r.offset&&(n.offset=parseInt(r.offset)),(r.data||r.opts)&&(n.template=this.getTemplateFromJSON(r.data,r.opts)),n}if(e.includes(":"))return this.keyToData(e,i)}keyToData(e,r){let i=e.split(":"),n=i.slice(4).join(":")||null;return{key:e,name:i[0],id:i[1]||null,endDate:parseInt(i[2])||null,tz:i[3]||null,pattern:n,next:r}}async isJobScheduler(e){return await(await this.client).hexists(`${this.keys.repeat}:${e}`,"ic")===1}async getScheduler(e){let[r,i]=await this.scripts.getJobScheduler(e);return this.transformSchedulerData(e,r?(0,Ode.array2obj)(r):null,i?parseInt(i):null)}getTemplateFromJSON(e,r){let i={};return e&&(i.data=JSON.parse(e)),r&&(i.opts=Xh.Job.optsFromJSON(r)),i}async getJobSchedulers(e=0,r=-1,i=!1){let n=await this.client,o=this.keys.repeat,s=i?await n.zrange(o,e,r,{WITHSCORES:!0}):await n.zrevrange(o,e,r,{WITHSCORES:!0}),a=[];for(let l=0;l<s.length;l+=2)a.push(this.getSchedulerData(n,s[l],parseInt(s[l+1])));return Promise.all(a)}async getSchedulersCount(){let e=this.keys.repeat;return(await this.client).zcard(e)}getSchedulerNextJobId({nextMillis:e,jobSchedulerId:r}){return`repeat:${r}:${e}`}};fs.JobScheduler=tI;var Ade=(t,e)=>{let{pattern:r}=e,i=new Date(t),n=e.startDate&&new Date(e.startDate),o=n>i?n:i,s=(0,Tde.parseExpression)(r,Object.assign(Object.assign({},e),{currentDate:o}));try{return e.immediately?new Date().getTime():s.next().getTime()}catch{}};fs.defaultRepeatStrategy=Ade});var nI=h(ty=>{"use strict";Object.defineProperty(ty,"__esModule",{value:!0});ty.LockManager=void 0;var Kde=hf(),ey=gr(),rI=class{constructor(e,r){this.worker=e,this.opts=r,this.trackedJobs=new Map,this.closed=!1}start(){this.closed||this.opts.lockRenewTime>0&&this.startLockExtenderTimer()}async extendLocks(e){await this.worker.trace(ey.SpanKind.INTERNAL,"extendLocks",this.worker.name,async r=>{r?.setAttributes({[ey.TelemetryAttributes.WorkerId]:this.opts.workerId,[ey.TelemetryAttributes.WorkerName]:this.opts.workerName,[ey.TelemetryAttributes.WorkerJobsToExtendLocks]:e});try{let i=e.map(s=>{var a;return((a=this.trackedJobs.get(s))===null||a===void 0?void 0:a.token)||""}),n=await this.worker.extendJobLocks(e,i,this.opts.lockDuration);if(n.length>0){this.worker.emit("lockRenewalFailed",n);for(let s of n)this.worker.emit("error",new Error(`could not renew lock for job ${s}`))}let o=e.filter(s=>!n.includes(s));o.length>0&&this.worker.emit("locksRenewed",{count:o.length,jobIds:o})}catch(i){this.worker.emit("error",i)}})}startLockExtenderTimer(){clearTimeout(this.lockRenewalTimer),this.closed||(this.lockRenewalTimer=setTimeout(async()=>{let e=Date.now(),r=[];for(let i of this.trackedJobs.keys()){let n=this.trackedJobs.get(i),{ts:o,token:s,abortController:a}=n;if(!o){this.trackedJobs.set(i,{token:s,ts:e,abortController:a});continue}o+this.opts.lockRenewTime/2<e&&(this.trackedJobs.set(i,{token:s,ts:e,abortController:a}),r.push(i))}r.length&&await this.extendLocks(r),this.startLockExtenderTimer()},this.opts.lockRenewTime/2))}async close(){this.closed||(this.closed=!0,this.lockRenewalTimer&&(clearTimeout(this.lockRenewalTimer),this.lockRenewalTimer=void 0),this.trackedJobs.clear())}trackJob(e,r,i,n=!1){let o=n?new Kde.AbortController:void 0;return!this.closed&&e&&this.trackedJobs.set(e,{token:r,ts:i,abortController:o}),o}untrackJob(e){this.trackedJobs.delete(e)}getActiveJobCount(){return this.trackedJobs.size}isRunning(){return!this.closed&&this.lockRenewalTimer!==void 0}cancelJob(e,r){let i=this.trackedJobs.get(e);return i?.abortController?(i.abortController.abort(r),!0):!1}cancelAllJobs(e){for(let r of this.trackedJobs.values())r.abortController&&r.abortController.abort(e)}getTrackedJobIds(){return Array.from(this.trackedJobs.keys())}};ty.LockManager=rI});var hq=h(ny=>{"use strict";Object.defineProperty(ny,"__esModule",{value:!0});ny.QueueEvents=void 0;var fq=(Zt(),Jt(Wt)),ry=Or(),Rde=uo(),mq=pu(),iI=class extends Rde.QueueBase{constructor(e,r={connection:{}},i){var{connection:n,autorun:o=!0}=r,s=fq.__rest(r,["connection","autorun"]);super(e,Object.assign(Object.assign({},s),{connection:(0,ry.isRedisInstance)(n)?((0,mq.isIRedisClient)(n)?n:(0,mq.createIORedisClient)(n)).duplicate():n}),i,!0),this.running=!1,this.blocking=!1,this.opts=Object.assign({blockingTimeout:1e4},this.opts),o&&this.run().catch(a=>this.emit("error",a))}emit(e,...r){return super.emit(e,...r)}off(e,r){return super.off(e,r),this}on(e,r){return super.on(e,r),this}once(e,r){return super.once(e,r),this}async run(){if(this.running)throw new Error("Queue Events is already running.");try{this.running=!0;let e=await this.client;try{await e.clientSetName(this.clientName(ry.QUEUE_EVENT_SUFFIX))}catch(r){if(!ry.clientCommandMessageReg.test(r.message)&&!this.closing)throw r}await this.consumeEvents(e)}catch(e){throw this.running=!1,e}}async consumeEvents(e){let r=this.opts,i=this.keys.events,n=r.lastEventId||"$";for(;!this.closing;){this.blocking=!0;let o=await this.checkConnectionError(()=>e.xread([{key:i,id:n}],{BLOCK:r.blockingTimeout}));if(this.blocking=!1,o){let a=o[0][1];for(let l=0;l<a.length;l++){n=a[l][0];let c=(0,ry.array2obj)(a[l][1]);switch(c.event){case"progress":c.data=JSON.parse(c.data);break;case"completed":c.returnvalue=JSON.parse(c.returnvalue);break;case"delayed":c.delay=Number(c.delay);break}let{event:u}=c,d=fq.__rest(c,["event"]);u==="drained"?this.emit(u,n):(this.emit(u,d,n),d.jobId&&this.emit(`${u}:${d.jobId}`,d,n))}}}}async close(){return this.closing||(this.closing=(async()=>{try{(await this.client).disconnect(),await this.connection.close(this.blocking)}finally{this.closed=!0}})()),this.closing}};ny.QueueEvents=iI});var yq=h(iy=>{"use strict";Object.defineProperty(iy,"__esModule",{value:!0});iy.QueueEventsProducer=void 0;var Dde=(Zt(),Jt(Wt)),jde=uo(),oI=class extends jde.QueueBase{constructor(e,r={connection:{}},i){super(e,Object.assign({blockingConnection:!1},r),i),this.opts=r}async publishEvent(e,r=1e3){let i=await this.client,n=this.keys.events,{eventName:o}=e,s=Dde.__rest(e,["eventName"]),a=Object.assign({event:o},s);await i.xadd(n,"*",a,{MAXLEN:r,approximate:!0})}async close(){this.closing||(this.closing=this.connection.close()),await this.closing}};iy.QueueEventsProducer=oI});var lI=h(oy=>{"use strict";Object.defineProperty(oy,"__esModule",{value:!0});oy.QueueGetters=void 0;var Pde=(Zt(),Jt(Wt)),Mde=uo(),gq=Or(),sI=gr();function bq(t){return String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}var aI=class extends Mde.QueueBase{getJob(e){return this.Job.fromId(this,e)}commandByType(e,r,i){return e.map(n=>{n=n==="waiting"?"wait":n;let o=this.toKey(n);switch(n){case"completed":case"failed":case"delayed":case"prioritized":case"repeat":case"waiting-children":return i(o,r?"zcard":"zrange");case"active":case"wait":case"paused":return i(o,r?"llen":"lrange")}})}sanitizeJobTypes(e){let r=typeof e=="string"?[e]:e;if(Array.isArray(r)&&r.length>0){let i=[...r];return i.indexOf("waiting")!==-1&&i.push("paused"),[...new Set(i)]}return["active","completed","delayed","failed","paused","prioritized","waiting","waiting-children"]}async count(){return await this.getJobCountByTypes("waiting","paused","delayed","prioritized","waiting-children")}async getRateLimitTtl(e){return this.scripts.getRateLimitTtl(e)}async getDebounceJobId(e){return(await this.client).get(`${this.keys.de}:${e}`)}async getDeduplicationJobId(e){return(await this.client).get(`${this.keys.de}:${e}`)}async getGlobalConcurrency(){let r=await(await this.client).hget(this.keys.meta,"concurrency");return r?Number(r):null}async getGlobalRateLimit(){let e=await this.client,[r,i]=await e.hmget(this.keys.meta,"max","duration");return r&&i?{max:Number(r),duration:Number(i)}:null}async getJobCountByTypes(...e){let r=await this.getJobCounts(...e);return Object.values(r).reduce((i,n)=>i+n,0)}async getJobCounts(...e){let r=this.sanitizeJobTypes(e),i=await this.scripts.getCounts(r),n={};return i.forEach((o,s)=>{n[r[s]]=o||0}),n}async recordJobCountsMetric(...e){var r;let i=await this.getJobCounts(...e),n=(r=this.opts.telemetry)===null||r===void 0?void 0:r.meter;if(n&&typeof n.createGauge=="function"){let o=n.createGauge(sI.MetricNames.QueueJobsCount,{description:"Number of jobs in the queue by state",unit:"{jobs}"});for(let[s,a]of Object.entries(i))o.record(a,{[sI.TelemetryAttributes.QueueName]:this.name,[sI.TelemetryAttributes.QueueJobsState]:s})}return i}getJobState(e){return this.scripts.getState(e)}async getMeta(){let r=await(await this.client).hgetall(this.keys.meta),{concurrency:i,max:n,duration:o,paused:s,"opts.maxLenEvents":a}=r,c=Pde.__rest(r,["concurrency","max","duration","paused","opts.maxLenEvents"]);return i&&(c.concurrency=Number(i)),a&&(c.maxLenEvents=Number(a)),n&&(c.max=Number(n)),o&&(c.duration=Number(o)),c.paused=s==="1",c}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){let r=[...new Set(e)],i=await this.scripts.getCountsPerPriority(r),n={};return i.forEach((o,s)=>{n[`${r[s]}`]=o||0}),n}getWaitingCount(){return this.getJobCountByTypes("waiting")}getWaitingChildrenCount(){return this.getJobCountByTypes("waiting-children")}getWaiting(e=0,r=-1){return this.getJobs(["waiting"],e,r,!0)}getWaitingChildren(e=0,r=-1){return this.getJobs(["waiting-children"],e,r,!0)}getActive(e=0,r=-1){return this.getJobs(["active"],e,r,!0)}getDelayed(e=0,r=-1){return this.getJobs(["delayed"],e,r,!0)}getPrioritized(e=0,r=-1){return this.getJobs(["prioritized"],e,r,!0)}getCompleted(e=0,r=-1){return this.getJobs(["completed"],e,r,!1)}getFailed(e=0,r=-1){return this.getJobs(["failed"],e,r,!1)}async getDependencies(e,r,i,n){let o=this.toKey(r=="processed"?`${e}:processed`:`${e}:dependencies`),{items:s,total:a,jobs:l}=await this.scripts.paginate(o,{start:i,end:n,fetchJobs:!0});return{items:s,jobs:l,total:a}}async getRanges(e,r=0,i=1,n=!1){let o=[];this.commandByType(e,!1,(l,c)=>{switch(c){case"lrange":o.push("lrange");break;case"zrange":o.push("zrange");break}});let s=await this.scripts.getRanges(e,r,i,n),a=[];return s.forEach((l,c)=>{let u=l||[];n&&o[c]==="lrange"?a=a.concat(u.reverse()):a=a.concat(u)}),[...new Set(a)]}async getJobs(e,r=0,i=-1,n=!1){let o=this.sanitizeJobTypes(e),s=await this.getRanges(o,r,i,n);return Promise.all(s.map(a=>this.Job.fromId(this,a)))}async getJobLogs(e,r=0,i=-1,n=!0){let s=(await this.client).multi(),a=this.toKey(e+":logs");n?s.lrange(a,r,i):s.lrange(a,-(i+1),-(r+1)),s.llen(a);let l=await s.exec();return n||l[0][1].reverse(),{logs:l[0][1],count:l[1][1]}}async baseGetClients(e){let r=await this.client;try{if(r.isCluster&&typeof r.nodes=="function"){let i=r.nodes(),n=[];for(let s=0;s<i.length;s++){let a=i[s],l=typeof a.clientList=="function"?await a.clientList():await a.client("LIST"),c=this.parseClientList(l,e);n.push(c)}return n.reduce((s,a)=>s.length>a.length?s:a,[])}else{let i=await r.clientList();return this.parseClientList(i,e)}}catch(i){if(!gq.clientCommandMessageReg.test(i.message))throw i;return[{name:"GCP does not support client list"}]}}getWorkers(){let e=`${this.clientName()}`,r=`${this.clientName()}:w:`,i=n=>n&&(n===e||n.startsWith(r));return this.baseGetClients(i)}async getWorkersCount(){return(await this.getWorkers()).length}async getQueueEvents(){let e=`${this.clientName()}${gq.QUEUE_EVENT_SUFFIX}`;return this.baseGetClients(r=>r===e)}async getMetrics(e,r=0,i=-1){let[n,o,s]=await this.scripts.getMetrics(e,r,i);return{meta:{count:parseInt(n[0]||"0",10),prevTS:parseInt(n[1]||"0",10),prevCount:parseInt(n[2]||"0",10)},data:o.map(a=>+a||0),count:s}}parseClientList(e,r){let i=e.split(/\r?\n/),n=[];return i.forEach(o=>{let s={};o.split(" ").forEach(function(c){let u=c.indexOf("="),d=c.substring(0,u),f=c.substring(u+1);s[d]=f});let l=s.name;r(l)&&(s.name=this.name,s.rawname=l,n.push(s))}),n}async exportPrometheusMetrics(e){let r=await this.getJobCounts(),i=[];i.push("# HELP bullmq_job_count Number of jobs in the queue by state"),i.push("# TYPE bullmq_job_count gauge");let n=bq(this.name),o=e?Object.keys(e).reduce((l,c)=>`${l}, ${c}="${bq(e[c])}"`,""):"";for(let[l,c]of Object.entries(r))i.push(`bullmq_job_count{queue="${n}", state="${l}"${o}} ${c}`);let[s,a]=await Promise.all([this.getMetrics("completed"),this.getMetrics("failed")]);return i.push("# HELP bullmq_job_completed_total Total number of completed jobs"),i.push("# TYPE bullmq_job_completed_total counter"),i.push(`bullmq_job_completed_total{queue="${n}"${o}} ${s.meta.count}`),i.push("# HELP bullmq_job_failed_total Total number of failed jobs"),i.push("# TYPE bullmq_job_failed_total counter"),i.push(`bullmq_job_failed_total{queue="${n}"${o}} ${a.meta.count}`),i.join(`
9953
9953
  `)}};oy.QueueGetters=aI});var sy=h(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.getNextMillis=ms.Repeat=void 0;var Nde=(Zt(),Jt(Wt)),Lde=Qx(),Ude=U("crypto"),$de=uo(),cI=class extends $de.QueueBase{constructor(e,r,i){super(e,r,i),this.repeatStrategy=r.settings&&r.settings.repeatStrategy||ms.getNextMillis,this.repeatKeyHashAlgorithm=r.settings&&r.settings.repeatKeyHashAlgorithm||"md5"}async updateRepeatableJob(e,r,i,{override:n}){var o,s;let a=Object.assign({},i.repeat);(o=a.pattern)!==null&&o!==void 0||(a.pattern=a.cron),delete a.cron;let l=a.count?a.count+1:1;if(typeof a.limit<"u"&&l>a.limit)return;let c=Date.now(),{endDate:u}=a;if(u&&c>new Date(u).getTime())return;let d=i.prevMillis||0;c=d<c?c:d;let f=await this.repeatStrategy(c,a,e),{every:p,pattern:m}=a,y=!!((p||m)&&a.immediately),w=y&&p?c-f:void 0;if(f){!d&&i.jobId&&(a.jobId=i.jobId);let _=vq(e,a),A=(s=i.repeat.key)!==null&&s!==void 0?s:this.hash(_),O;if(n)O=await this.scripts.addRepeatableJob(A,f,{name:e,endDate:u?new Date(u).getTime():void 0,tz:a.tz,pattern:m,every:p},_);else{let re=await this.client;O=await this.scripts.updateRepeatableJobMillis(re,A,f,_)}let{immediately:C}=a,$=Nde.__rest(a,["immediately"]);return this.createNextJob(e,f,O,Object.assign(Object.assign({},i),{repeat:Object.assign({offset:w},$)}),r,l,y)}}async createNextJob(e,r,i,n,o,s,a){let l=this.getRepeatJobKey(e,r,i,o),c=Date.now(),u=r+(n.repeat.offset?n.repeat.offset:0)-c,d=Object.assign(Object.assign({},n),{jobId:l,delay:u<0||a?0:u,timestamp:c,prevMillis:r,repeatJobKey:i});return d.repeat=Object.assign(Object.assign({},n.repeat),{count:s}),this.Job.create(this,e,o,d)}getRepeatJobKey(e,r,i,n){return i.split(":").length>2?this.getRepeatJobId({name:e,nextMillis:r,namespace:this.hash(i),jobId:n?.id}):this.getRepeatDelayedJobId({customKey:i,nextMillis:r})}async removeRepeatable(e,r,i){var n;let o=vq(e,Object.assign(Object.assign({},r),{jobId:i})),s=(n=r.key)!==null&&n!==void 0?n:this.hash(o),a=this.getRepeatJobId({name:e,nextMillis:"",namespace:this.hash(o),jobId:i??r.jobId,key:r.key});return this.scripts.removeRepeatable(a,o,s)}async removeRepeatableByKey(e){let r=this.keyToData(e),i=this.getRepeatJobId({name:r.name,nextMillis:"",namespace:this.hash(e),jobId:r.id});return this.scripts.removeRepeatable(i,"",e)}async getRepeatableData(e,r,i){let n=await e.hgetall(this.toKey("repeat:"+r));return n?{key:r,name:n.name,endDate:parseInt(n.endDate)||null,tz:n.tz||null,pattern:n.pattern||null,every:n.every||null,next:i}:this.keyToData(r,i)}keyToData(e,r){let i=e.split(":"),n=i.slice(4).join(":")||null;return{key:e,name:i[0],id:i[1]||null,endDate:parseInt(i[2])||null,tz:i[3]||null,pattern:n,next:r}}async getRepeatableJobs(e=0,r=-1,i=!1){let n=await this.client,o=this.keys.repeat,s=i?await n.zrange(o,e,r,{WITHSCORES:!0}):await n.zrevrange(o,e,r,{WITHSCORES:!0}),a=[];for(let l=0;l<s.length;l+=2)a.push(this.getRepeatableData(n,s[l],parseInt(s[l+1])));return Promise.all(a)}async getRepeatableCount(){return(await this.client).zcard(this.toKey("repeat"))}hash(e){return(0,Ude.createHash)(this.repeatKeyHashAlgorithm).update(e).digest("hex")}getRepeatDelayedJobId({nextMillis:e,customKey:r}){return`repeat:${r}:${e}`}getRepeatJobId({name:e,nextMillis:r,namespace:i,jobId:n,key:o}){return`repeat:${o??this.hash(`${e}${n||""}${i}`)}:${r}`}};ms.Repeat=cI;function vq(t,e){let r=e.endDate?new Date(e.endDate).getTime():"",i=e.tz||"",n=e.pattern,o=n||String(e.every)||"",s=e.jobId?e.jobId:"";return`${t}:${s}:${r}:${i}:${o}`}var Jde=(t,e)=>{let r=e.pattern;if(r&&e.every)throw new Error("Both .pattern and .every options are defined for this repeatable job");if(e.every)return Math.floor(t/e.every)*e.every+(e.immediately?0:e.every);let i=e.startDate&&new Date(e.startDate)>new Date(t)?new Date(e.startDate):new Date(t),n=(0,Lde.parseExpression)(r,Object.assign(Object.assign({},e),{currentDate:i}));try{return e.immediately?new Date().getTime():n.next().getTime()}catch{}};ms.getNextMillis=Jde});var Sq=h(ay=>{"use strict";Object.defineProperty(ay,"__esModule",{value:!0});ay.Queue=void 0;var Fde=Pa(),qde=lI(),zde=sy(),ye=gr(),Gde=Qh(),Vde=tm(),Bde=Or(),uI=class extends qde.QueueGetters{constructor(e,r,i){var n;super(e,Object.assign({},r),i),this.token=(0,Bde.randomUUID)(),this.libName="bullmq",this.jobsOpts=(n=r?.defaultJobOptions)!==null&&n!==void 0?n:{},this.waitUntilReady().then(o=>{if(!this.closing&&!r?.skipMetasUpdate)return o.hset(this.keys.meta,this.metaValues)}).catch(o=>{})}emit(e,...r){return super.emit(e,...r)}off(e,r){return super.off(e,r),this}on(e,r){return super.on(e,r),this}once(e,r){return super.once(e,r),this}get defaultJobOptions(){return Object.assign({},this.jobsOpts)}get metaValues(){var e,r,i,n;return{"opts.maxLenEvents":(n=(i=(r=(e=this.opts)===null||e===void 0?void 0:e.streams)===null||r===void 0?void 0:r.events)===null||i===void 0?void 0:i.maxLen)!==null&&n!==void 0?n:1e4,version:`${this.libName}:${Vde.version}`}}async getVersion(){return await(await this.client).hget(this.keys.meta,"version")}get repeat(){return new Promise(async e=>{this._repeat||(this._repeat=new zde.Repeat(this.name,Object.assign(Object.assign({},this.opts),{connection:await this.client})),this._repeat.on("error",this.emit.bind(this,"error"))),e(this._repeat)})}get jobScheduler(){return new Promise(async e=>{this._jobScheduler||(this._jobScheduler=new Gde.JobScheduler(this.name,Object.assign(Object.assign({},this.opts),{connection:await this.client})),this._jobScheduler.on("error",this.emit.bind(this,"error"))),e(this._jobScheduler)})}async setGlobalConcurrency(e){return(await this.client).hset(this.keys.meta,{concurrency:e})}async setGlobalRateLimit(e,r){return(await this.client).hset(this.keys.meta,{max:e,duration:r})}async removeGlobalConcurrency(){return(await this.client).hdel(this.keys.meta,"concurrency")}async removeGlobalRateLimit(){return(await this.client).hdel(this.keys.meta,"max","duration")}async add(e,r,i){return this.trace(ye.SpanKind.PRODUCER,"add",`${this.name}.${e}`,async(n,o)=>{var s;if(o&&!(!((s=i?.telemetry)===null||s===void 0)&&s.omitContext)){let l={metadata:o};i=Object.assign(Object.assign({},i),{telemetry:l})}let a=await this.addJob(e,r,i);return n?.setAttributes({[ye.TelemetryAttributes.JobName]:e,[ye.TelemetryAttributes.JobId]:a.id}),a})}async addJob(e,r,i){if(i&&i.repeat){if(i.repeat.endDate&&+new Date(i.repeat.endDate)<Date.now())throw new Error("End date must be greater than current timestamp");return(await this.repeat).updateRepeatableJob(e,r,Object.assign(Object.assign({},this.jobsOpts),i),{override:!0})}else{let n=i?.jobId;if(n=="0"||n?.startsWith("0:"))throw new Error("JobId cannot be '0' or start with 0:");let o=Object.assign(Object.assign(Object.assign({},this.jobsOpts),i),{jobId:n}),s=await this.Job.create(this,e,r,o);return this.emit("waiting",s),s}}async addBulk(e){return this.trace(ye.SpanKind.PRODUCER,"addBulk",this.name,async(r,i)=>(r&&r.setAttributes({[ye.TelemetryAttributes.BulkNames]:e.map(n=>n.name),[ye.TelemetryAttributes.BulkCount]:e.length}),await this.Job.createBulk(this,e.map(n=>{var o,s,a,l,c,u;let d=(o=n.opts)===null||o===void 0?void 0:o.telemetry;if(i){let p=(a=(s=n.opts)===null||s===void 0?void 0:s.telemetry)===null||a===void 0?void 0:a.omitContext,m=((c=(l=n.opts)===null||l===void 0?void 0:l.telemetry)===null||c===void 0?void 0:c.metadata)||!p&&i;(m||p)&&(d={metadata:m,omitContext:p})}let f=Object.assign(Object.assign(Object.assign({},this.jobsOpts),n.opts),{jobId:(u=n.opts)===null||u===void 0?void 0:u.jobId,telemetry:d});return{name:n.name,data:n.data,opts:f}}))))}async upsertJobScheduler(e,r,i){var n,o;if(r.endDate&&+new Date(r.endDate)<Date.now())throw new Error("End date must be greater than current timestamp");return(await this.jobScheduler).upsertJobScheduler(e,r,(n=i?.name)!==null&&n!==void 0?n:e,(o=i?.data)!==null&&o!==void 0?o:{},Object.assign(Object.assign({},this.jobsOpts),i?.opts),{override:!0})}async pause(){await this.trace(ye.SpanKind.INTERNAL,"pause",this.name,async()=>{await this.scripts.pause(!0),this.emit("paused")})}async close(){await this.trace(ye.SpanKind.INTERNAL,"close",this.name,async()=>{this.closing||this._repeat&&await this._repeat.close(),await super.close()})}async rateLimit(e){await this.trace(ye.SpanKind.INTERNAL,"rateLimit",this.name,async r=>{r?.setAttributes({[ye.TelemetryAttributes.QueueRateLimit]:e}),await this.client.then(i=>i.set(this.keys.limiter,Number.MAX_SAFE_INTEGER,{PX:e}))})}async resume(){await this.trace(ye.SpanKind.INTERNAL,"resume",this.name,async()=>{await this.scripts.pause(!1),this.emit("resumed")})}async isPaused(){return await(await this.client).hexists(this.keys.meta,"paused")===1}isMaxed(){return this.scripts.isMaxed()}async getRepeatableJobs(e,r,i){return(await this.repeat).getRepeatableJobs(e,r,i)}async getJobScheduler(e){return(await this.jobScheduler).getScheduler(e)}async getJobSchedulers(e,r,i){return(await this.jobScheduler).getJobSchedulers(e,r,i)}async getJobSchedulersCount(){return(await this.jobScheduler).getSchedulersCount()}async removeRepeatable(e,r,i){return this.trace(ye.SpanKind.INTERNAL,"removeRepeatable",`${this.name}.${e}`,async n=>(n?.setAttributes({[ye.TelemetryAttributes.JobName]:e,[ye.TelemetryAttributes.JobId]:i}),!await(await this.repeat).removeRepeatable(e,r,i)))}async removeJobScheduler(e){return!await(await this.jobScheduler).removeJobScheduler(e)}async removeDebounceKey(e){return this.trace(ye.SpanKind.INTERNAL,"removeDebounceKey",`${this.name}`,async r=>(r?.setAttributes({[ye.TelemetryAttributes.JobKey]:e}),await(await this.client).del(`${this.keys.de}:${e}`)))}async removeDeduplicationKey(e){return this.trace(ye.SpanKind.INTERNAL,"removeDeduplicationKey",`${this.name}`,async r=>(r?.setAttributes({[ye.TelemetryAttributes.DeduplicationKey]:e}),(await this.client).del(`${this.keys.de}:${e}`)))}async removeRateLimitKey(){return(await this.client).del(this.keys.limiter)}async removeRepeatableByKey(e){return this.trace(ye.SpanKind.INTERNAL,"removeRepeatableByKey",`${this.name}`,async r=>(r?.setAttributes({[ye.TelemetryAttributes.JobKey]:e}),!await(await this.repeat).removeRepeatableByKey(e)))}async remove(e,{removeChildren:r=!0}={}){return this.trace(ye.SpanKind.INTERNAL,"remove",this.name,async i=>{i?.setAttributes({[ye.TelemetryAttributes.JobId]:e,[ye.TelemetryAttributes.JobOptions]:JSON.stringify({removeChildren:r})});let n=await this.scripts.remove(e,r);return n===1&&this.emit("removed",e),n})}async updateJobProgress(e,r){await this.trace(ye.SpanKind.INTERNAL,"updateJobProgress",this.name,async i=>{i?.setAttributes({[ye.TelemetryAttributes.JobId]:e,[ye.TelemetryAttributes.JobProgress]:JSON.stringify(r)}),await this.scripts.updateProgress(e,r),this.emit("progress",e,r)})}async addJobLog(e,r,i){return Fde.Job.addJobLog(this,e,r,i)}async drain(e=!1){await this.trace(ye.SpanKind.INTERNAL,"drain",this.name,async r=>{r?.setAttributes({[ye.TelemetryAttributes.QueueDrainDelay]:e}),await this.scripts.drain(e)})}async clean(e,r,i="completed"){return this.trace(ye.SpanKind.INTERNAL,"clean",this.name,async n=>{let o=r||1/0,s=Math.min(1e4,o),a=Date.now()-e,l=0,c=[],u=i==="waiting"?"wait":i;for(;l<o;){let d=await this.scripts.cleanJobsInSet(u,a,s);if(this.emit("cleaned",d,u),l+=d.length,c.push(...d),d.length<s)break}return n?.setAttributes({[ye.TelemetryAttributes.QueueGrace]:e,[ye.TelemetryAttributes.JobType]:i,[ye.TelemetryAttributes.QueueCleanLimit]:o,[ye.TelemetryAttributes.JobIds]:c}),c})}async obliterate(e){await this.trace(ye.SpanKind.INTERNAL,"obliterate",this.name,async()=>{await this.pause();let r=0;do r=await this.scripts.obliterate(Object.assign({force:!1,count:1e3},e));while(r)})}async retryJobs(e={}){await this.trace(ye.SpanKind.PRODUCER,"retryJobs",this.name,async r=>{r?.setAttributes({[ye.TelemetryAttributes.QueueOptions]:JSON.stringify(e)});let i=0;do i=await this.scripts.retryJobs(e.state,e.count,e.timestamp);while(i)})}async promoteJobs(e={}){await this.trace(ye.SpanKind.INTERNAL,"promoteJobs",this.name,async r=>{r?.setAttributes({[ye.TelemetryAttributes.QueueOptions]:JSON.stringify(e)});let i=0;do i=await this.scripts.promoteJobs(e.count);while(i)})}async trimEvents(e){return this.trace(ye.SpanKind.INTERNAL,"trimEvents",this.name,async r=>(r?.setAttributes({[ye.TelemetryAttributes.QueueEventMaxLength]:e}),await(await this.client).xtrim(this.keys.events,"MAXLEN",e,{approximate:!0})))}async removeDeprecatedPriorityKey(){return(await this.client).del(this.toKey("priority"))}async removeOrphanedJobs(e=1e3,r=0){let i=await this.client,n=new Set(Object.keys(this.keys)),o=Object.keys(this.keys).filter(d=>d!==""),s=["logs","dependencies","processed","failed","unsuccessful","lock"],a=this.qualifiedName+":",l=a+"*",c=0,u="0";do{let[d,f]=await i.scan(u,{MATCH:l,COUNT:e});u=d;let p=new Set;for(let y of f){let w=y.slice(a.length);if(n.has(w))continue;let _=w.indexOf(":");if(_!==-1){let O=w.slice(0,_);if(n.has(O))continue}let A=_===-1?w:w.slice(0,_);if(_!==-1){let O=w.slice(_+1);if(!s.includes(O))continue}p.add(A)}if(p.size===0)continue;let m=await this.scripts.removeOrphanedJobs([...p],o,s);if(c+=m||0,r>0&&c>=r)break}while(u!=="0");return c}};ay.Queue=uI});var pI=h(dI=>{"use strict";Object.defineProperty(dI,"__esModule",{value:!0});var St=gr(),Wde=(t,e)=>async function(i,n,o){let s,a,l,c;try{let u=new Promise((d,f)=>{(async()=>{try{l=(m,y)=>{f(new Error("Unexpected exit code: "+m+" signal: "+y))},s=await e.retain(t),s.on("exit",l),a=async m=>{var y,w,_,A,O;try{switch(m.cmd){case St.ParentCommand.Completed:d(m.value);break;case St.ParentCommand.Failed:case St.ParentCommand.Error:{let C=new Error;Object.assign(C,m.value),f(C);break}case St.ParentCommand.Progress:await i.updateProgress(m.value);break;case St.ParentCommand.Log:await i.log(m.value);break;case St.ParentCommand.MoveToDelayed:await i.moveToDelayed((y=m.value)===null||y===void 0?void 0:y.timestamp,(w=m.value)===null||w===void 0?void 0:w.token);break;case St.ParentCommand.MoveToWait:await i.moveToWait((_=m.value)===null||_===void 0?void 0:_.token);break;case St.ParentCommand.MoveToWaitingChildren:{let C=await i.moveToWaitingChildren((A=m.value)===null||A===void 0?void 0:A.token,(O=m.value)===null||O===void 0?void 0:O.opts);s.send({requestId:m.requestId,cmd:St.ChildCommand.MoveToWaitingChildrenResponse,value:C})}break;case St.ParentCommand.Update:await i.updateData(m.value);break;case St.ParentCommand.GetChildrenValues:{let C=await i.getChildrenValues();s.send({requestId:m.requestId,cmd:St.ChildCommand.GetChildrenValuesResponse,value:C})}break;case St.ParentCommand.GetIgnoredChildrenFailures:{let C=await i.getIgnoredChildrenFailures();s.send({requestId:m.requestId,cmd:St.ChildCommand.GetIgnoredChildrenFailuresResponse,value:C})}break;case St.ParentCommand.GetDependenciesCount:{let C=await i.getDependenciesCount(m.value);s.send({requestId:m.requestId,cmd:St.ChildCommand.GetDependenciesCountResponse,value:C})}break;case St.ParentCommand.GetDependencies:{let C=await i.getDependencies(m.value);s.send({requestId:m.requestId,cmd:St.ChildCommand.GetDependenciesResponse,value:C})}break}}catch(C){f(C)}},s.on("message",a),s.send({cmd:St.ChildCommand.Start,job:i.asJSONSandbox(),token:n}),o&&(c=()=>{try{s.send({cmd:St.ChildCommand.Cancel,value:o.reason})}catch{}},o.aborted?c():o.addEventListener("abort",c,{once:!0}))}catch(m){f(m)}})()});return await u,u}finally{o&&c&&o.removeEventListener("abort",c),s&&(s.off("message",a),s.off("exit",l),s.exitCode===null&&s.signalCode===null&&e.release(s))}};dI.default=Wde});var xq=h((cy,wq)=>{"use strict";Object.defineProperty(cy,"__esModule",{value:!0});cy.Worker=void 0;var ly=U("fs"),Zde=U("url"),Tu=U("path"),Hde=hf(),nl=Or(),Yde=uo(),Xde=sy(),Qde=jE(),epe=mu(),Eq=pu(),tpe=pI(),rpe=CE(),il=Mf(),ge=gr(),npe=Qh(),ipe=nI(),ope=10,fI=class extends Yde.QueueBase{static RateLimitError(){return new il.RateLimitError}constructor(e,r,i,n){if(super(e,Object.assign(Object.assign({drainDelay:5,concurrency:1,lockDuration:3e4,maximumRateLimitDelay:3e4,maxStalledCount:1,stalledInterval:3e4,autorun:!0,runRetryDelay:15e3},i),{blockingConnection:!0}),n),this.abortDelayController=null,this.blockUntil=0,this.drained=!1,this.limitUntil=0,this.processorAcceptsSignal=!1,this.stalledCheckerRunning=!1,this.waiting=null,this.running=!1,this.mainLoopRunning=null,!i||!i.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.maxStartedAttempts=="number"&&this.opts.maxStartedAttempts<0)throw new Error("maxStartedAttempts 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");if(this.concurrency=this.opts.concurrency,this.opts.lockRenewTime=this.opts.lockRenewTime||this.opts.lockDuration/2,this.id=(0,nl.randomUUID)(),this.createLockManager(),r){if(typeof r=="function")this.processFn=r,this.processorAcceptsSignal=r.length>=3;else{if(r instanceof Zde.URL){if(!ly.existsSync(r))throw new Error(`URL ${r} does not exist in the local file system`);r=r.href}else{let d=r+([".js",".ts",".flow",".cjs",".mjs"].includes(Tu.extname(r))?"":".js");if(!ly.existsSync(d))throw new Error(`File ${d} does not exist`)}let s=Tu.dirname(wq.filename||__filename),a=Tu.join(s,"main-worker.js"),l=Tu.join(s,"main.js"),c=this.opts.useWorkerThreads?a:l;try{ly.statSync(c)}catch{let d=this.opts.useWorkerThreads?"main-worker.js":"main.js";c=Tu.join(process.cwd(),`dist/cjs/classes/${d}`),ly.statSync(c)}this.childPool=new Qde.ChildPool({mainFile:c,useWorkerThreads:this.opts.useWorkerThreads,workerForkOptions:this.opts.workerForkOptions,workerThreadsOptions:this.opts.workerThreadsOptions}),this.createSandbox(r),this.processorAcceptsSignal=!0}this.opts.autorun&&this.run().catch(s=>this.emit("error",s))}let o=this.clientName()+(this.opts.name?`:w:${this.opts.name}`:"");this.blockingConnection=new epe.RedisConnection((0,nl.isRedisInstance)(i.connection)?((0,Eq.isIRedisClient)(i.connection)?i.connection:(0,Eq.createIORedisClient)(i.connection)).duplicate({connectionName:o}):Object.assign(Object.assign({},i.connection),{connectionName:o}),{shared:!1,blocking:!0,skipVersionCheck:i.skipVersionCheck}),this.blockingConnection.on("error",s=>this.emit("error",s)),this.blockingConnection.on("ready",()=>setTimeout(()=>this.emit("ready"),0))}createLockManager(){this.lockManager=new ipe.LockManager(this,{lockRenewTime:this.opts.lockRenewTime,lockDuration:this.opts.lockDuration,workerId:this.id,workerName:this.opts.name})}createSandbox(e){this.processFn=(0,tpe.default)(e,this.childPool).bind(this)}async extendJobLocks(e,r,i){return this.scripts.extendLocks(e,r,i)}emit(e,...r){return super.emit(e,...r)}off(e,r){return super.off(e,r),this}on(e,r){return super.on(e,r),this}once(e,r){return super.once(e,r),this}callProcessJob(e,r,i){return this.processFn(e,r,i)}createJob(e,r){return this.Job.fromJSON(this,e,r)}async waitUntilReady(){return await super.waitUntilReady(),this.blockingConnection.client}cancelJob(e,r){return this.lockManager.cancelJob(e,r)}cancelAllJobs(e){this.lockManager.cancelAllJobs(e)}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){let r=await this.client;this._repeat=new Xde.Repeat(this.name,Object.assign(Object.assign({},this.opts),{connection:r})),this._repeat.on("error",this.emit.bind(this,"error"))}e(this._repeat)})}get jobScheduler(){return new Promise(async e=>{if(!this._jobScheduler){let r=await this.client;this._jobScheduler=new npe.JobScheduler(this.name,Object.assign(Object.assign({},this.opts),{connection:r})),this._jobScheduler.on("error",this.emit.bind(this,"error"))}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{if(this.running=!0,this.closing||this.paused)return;await this.startStalledCheckTimer(),this.opts.skipLockRenewal||this.lockManager.start();let e=await this.client,r=await this.blockingConnection.client;this.mainLoopRunning=this.mainLoop(e,r),await this.mainLoopRunning}finally{this.running=!1}}async waitForRateLimit(){var e;let r=this.limitUntil;if(r>Date.now()){(e=this.abortDelayController)===null||e===void 0||e.abort(),this.abortDelayController=new Hde.AbortController;let i=this.getRateLimitDelay(r-Date.now());await this.delay(i,this.abortDelayController),this.drained=!1,this.limitUntil=0}}async mainLoop(e,r){let i=new rpe.AsyncFifoQueue,n=0;for(;!this.closing&&!this.paused||i.numTotal()>0;){for(;!this.closing&&!this.paused&&!this.waiting&&i.numTotal()<this._concurrency&&!this.isRateLimited();){let s=`${this.id}:${n++}`,a=this.retryIfFailed(()=>this._getNextJob(e,r,s,{block:!0}),{delayInMs:this.opts.runRetryDelay,onlyEmitError:!0});if(i.add(a),this.waiting&&i.numTotal()>1||!await a&&i.numTotal()>1||this.blockUntil)break}let o;do o=await i.fetch();while(!o&&i.numQueued()>0);if(o){let s=o.token;i.add(this.processJob(o,s,()=>i.numTotal()<=this._concurrency))}else i.numQueued()===0&&await this.waitForRateLimit()}}async getNextJob(e,{block:r=!0}={}){var i,n;let o=await this._getNextJob(await this.client,await this.blockingConnection.client,e,{block:r});return this.trace(ge.SpanKind.INTERNAL,"getNextJob",this.name,async s=>(s?.setAttributes({[ge.TelemetryAttributes.WorkerId]:this.id,[ge.TelemetryAttributes.QueueName]:this.name,[ge.TelemetryAttributes.WorkerName]:this.opts.name,[ge.TelemetryAttributes.WorkerOptions]:JSON.stringify({block:r}),[ge.TelemetryAttributes.JobId]:o?.id}),o),(n=(i=o?.opts)===null||i===void 0?void 0:i.telemetry)===null||n===void 0?void 0:n.metadata)}async _getNextJob(e,r,i,{block:n=!0}={}){if(this.paused||this.closing)return;let o;if(this.drained&&n&&!this.limitUntil&&!this.waiting){this.waiting=this.waitForJob(r,this.blockUntil);try{this.blockUntil=await this.waiting,(this.blockUntil<=0||this.blockUntil-Date.now()<1)&&(o=await this.moveToActive(e,i,this.opts.name))}finally{this.waiting=null}}else this.isRateLimited()||(o=await this.moveToActive(e,i,this.opts.name));return o&&this.emit("active",o,"waiting"),o}async rateLimit(e){await this.trace(ge.SpanKind.INTERNAL,"rateLimit",this.name,async r=>{r?.setAttributes({[ge.TelemetryAttributes.WorkerId]:this.id,[ge.TelemetryAttributes.WorkerRateLimit]:e}),await this.client.then(i=>i.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,r,i){let[n,o,s,a]=await this.scripts.moveToActive(e,r,i);return this.updateDelays(s,a),this.nextJobFromJobData(n,o,r)}async waitForJob(e,r){if(this.paused)return 1/0;let i;try{if(!this.closing&&!this.isRateLimited()){let n=this.getBlockTimeout(r);if(n>0){n=this.blockingConnection.capabilities.canDoubleTimeout?n:Math.ceil(n),i=setTimeout(async()=>{e.disconnect(!this.closing)},n*1e3+1e3),this.updateDelays();let o=await e.bzpopmin(this.keys.marker,n);if(o){let[,s,a]=o;if(s){let l=parseInt(a);return r&&l>r?r:l}}}return 0}}catch(n){(0,nl.isNotConnectionError)(n)&&this.emit("error",n),this.closing||await this.delay()}finally{clearTimeout(i)}return 1/0}getBlockTimeout(e){let r=this.opts;if(e){let i=e-Date.now();return i<=0?i:i<this.minimumBlockTimeout*1e3?this.minimumBlockTimeout:Math.min(i/1e3,ope)}else return Math.max(r.drainDelay,this.minimumBlockTimeout)}getRateLimitDelay(e){return Math.min(e,this.opts.maximumRateLimitDelay)}async delay(e,r){await(0,nl.delay)(e||nl.DELAY_TIME_1,r)}updateDelays(e=0,r=0){let i=Math.max(e,0);i>0?this.limitUntil=Date.now()+i:this.limitUntil=0,this.blockUntil=Math.max(r,0)||0}async nextJobFromJobData(e,r,i){if(!e)this.drained||(this.emit("drained"),this.drained=!0);else{this.drained=!1;let n=this.createJob(e,r);n.token=i;try{await this.retryIfFailed(async()=>{let o=!!n.repeatJobKey,s=o&&n.repeatJobKey.split(":").length>=5,a=o&&!s;s&&(a=await(await this.jobScheduler).isJobScheduler(n.repeatJobKey)),a?await(await this.jobScheduler).upsertJobScheduler(n.repeatJobKey,n.opts.repeat,n.name,n.data,n.opts,{override:!1,producerId:n.id}):n.opts.repeat&&await(await this.repeat).updateRepeatableJob(n.name,n.data,n.opts,{override:!1})},{delayInMs:this.opts.runRetryDelay})}catch(o){let s=o instanceof Error?o.message:String(o),a=new Error(`Failed to add repeatable job for next iteration: ${s}`);this.emit("error",a);return}return n}}async processJob(e,r,i=()=>!0){var n,o;let s=(o=(n=e.opts)===null||n===void 0?void 0:n.telemetry)===null||o===void 0?void 0:o.metadata;return this.trace(ge.SpanKind.CONSUMER,"process",this.name,async a=>{a?.setAttributes({[ge.TelemetryAttributes.WorkerId]:this.id,[ge.TelemetryAttributes.WorkerName]:this.opts.name,[ge.TelemetryAttributes.JobId]:e.id,[ge.TelemetryAttributes.JobName]:e.name});let l=this.lockManager.trackJob(e.id,r,e.processedOn,this.processorAcceptsSignal);try{let c=this.getUnrecoverableErrorMessage(e);if(c)return await this.retryIfFailed(()=>(this.lockManager.untrackJob(e.id),this.handleFailed(new il.UnrecoverableError(c),e,r,i,a)),{delayInMs:this.opts.runRetryDelay,span:a});let u=await this.callProcessJob(e,r,l?l.signal:void 0);return await this.retryIfFailed(()=>(this.lockManager.untrackJob(e.id),this.handleCompleted(u,e,r,i,a)),{delayInMs:this.opts.runRetryDelay,span:a})}catch(c){return await this.retryIfFailed(()=>(this.lockManager.untrackJob(e.id),this.handleFailed(c,e,r,i,a)),{delayInMs:this.opts.runRetryDelay,span:a,onlyEmitError:!0})}finally{this.lockManager.untrackJob(e.id);let c=Date.now();a?.setAttributes({[ge.TelemetryAttributes.JobFinishedTimestamp]:c,[ge.TelemetryAttributes.JobAttemptFinishedTimestamp]:e.finishedOn||c,[ge.TelemetryAttributes.JobProcessedTimestamp]:e.processedOn})}},s)}getUnrecoverableErrorMessage(e){if(e.deferredFailure)return e.deferredFailure;if(this.opts.maxStartedAttempts&&this.opts.maxStartedAttempts<e.attemptsStarted)return"job started more than allowable limit"}async handleCompleted(e,r,i,n=()=>!0,o){if(!this.connection.closing){let s=await r.moveToCompleted(e,i,n()&&!(this.closing||this.paused));if(this.emit("completed",r,e,"active"),o?.addEvent("job completed",{[ge.TelemetryAttributes.JobResult]:JSON.stringify(e)}),o?.setAttributes({[ge.TelemetryAttributes.JobAttemptsMade]:r.attemptsMade}),Array.isArray(s)){let[a,l,c,u]=s;return this.updateDelays(c,u),this.nextJobFromJobData(a,l,i)}}}async handleFailed(e,r,i,n=()=>!0,o){if(!this.connection.closing){if(e.message===il.RATE_LIMIT_ERROR){let l=await this.moveLimitedBackToWait(r,i);this.limitUntil=l>0?Date.now()+l:0;return}let s=n()&&!(this.closing||this.paused);if(e instanceof il.DelayedError||e.name=="DelayedError"||e instanceof il.WaitingError||e.name=="WaitingError"||e instanceof il.WaitingChildrenError||e.name=="WaitingChildrenError"){if(!s)return;let l=await this.client;return this.moveToActive(l,i,this.opts.name)}let a=await r.moveToFailed(e,i,s);if(this.emit("failed",r,e,"active"),o?.addEvent("job failed",{[ge.TelemetryAttributes.JobFailedReason]:e.message}),o?.setAttributes({[ge.TelemetryAttributes.JobAttemptsMade]:r.attemptsMade}),Array.isArray(a)){let[l,c,u,d]=a;return this.updateDelays(u,d),this.nextJobFromJobData(l,c,i)}}}async pause(e){await this.trace(ge.SpanKind.INTERNAL,"pause",this.name,async r=>{var i;r?.setAttributes({[ge.TelemetryAttributes.WorkerId]:this.id,[ge.TelemetryAttributes.WorkerName]:this.opts.name,[ge.TelemetryAttributes.WorkerDoNotWaitActive]:e}),this.paused||(this.paused=!0,e||await this.whenCurrentJobsFinished(),(i=this.stalledCheckStopper)===null||i===void 0||i.call(this),this.emit("paused"))})}resume(){(!this.running||this.paused)&&this.trace(ge.SpanKind.INTERNAL,"resume",this.name,e=>{e?.setAttributes({[ge.TelemetryAttributes.WorkerId]:this.id,[ge.TelemetryAttributes.WorkerName]:this.opts.name}),this.paused=!1,this.running?this.startStalledCheckTimer().catch(r=>{this.emit("error",r)}):this.processFn&&this.run(),this.emit("resumed")}).catch(e=>{this.emit("error",e)})}isPaused(){return!!this.paused}isRunning(){return this.running}async close(e=!1){return this.closing?this.closing:(this.closing=(async()=>{await this.trace(ge.SpanKind.INTERNAL,"close",this.name,async r=>{var i,n;r?.setAttributes({[ge.TelemetryAttributes.WorkerId]:this.id,[ge.TelemetryAttributes.WorkerName]:this.opts.name,[ge.TelemetryAttributes.WorkerForceClose]:e}),this.emit("closing","closing queue"),(i=this.abortDelayController)===null||i===void 0||i.abort();let o=[()=>e||this.whenCurrentJobsFinished(!1),()=>this.lockManager.close(),()=>{var s;return(s=this.childPool)===null||s===void 0?void 0:s.clean()},()=>this.blockingConnection.close(e),()=>this.connection.close(e)];for(let s of o)try{await s()}catch(a){this.emit("error",a)}(n=this.stalledCheckStopper)===null||n===void 0||n.call(this),this.closed=!0,this.emit("closed")})})(),await this.closing)}async startStalledCheckTimer(){this.opts.skipStalledCheck||!this.closing&&!this.stalledCheckerRunning&&await this.trace(ge.SpanKind.INTERNAL,"startStalledCheckTimer",this.name,async e=>{e?.setAttributes({[ge.TelemetryAttributes.WorkerId]:this.id,[ge.TelemetryAttributes.WorkerName]:this.opts.name}),this.stalledCheckerRunning=!0,this.stalledChecker().catch(r=>{this.emit("error",r)}).finally(()=>{this.stalledCheckerRunning=!1})})}async stalledChecker(){for(;!(this.closing||this.paused);)await this.checkConnectionError(()=>this.moveStalledJobsToWait()),await new Promise(e=>{let r=setTimeout(e,this.opts.stalledInterval);this.stalledCheckStopper=()=>{clearTimeout(r),e()}})}async whenCurrentJobsFinished(e=!0){this.mainLoopRunning?(await this.blockingConnection.disconnect(!0),await this.mainLoopRunning):e=!1,e&&await this.blockingConnection.reconnect()}async retryIfFailed(e,r){var i;let n=0,o=r.maxRetries||1/0;do try{return await e()}catch(s){if((i=r.span)===null||i===void 0||i.recordException(s.message),(0,nl.isNotConnectionError)(s)){if(!this.paused&&!this.closing&&this.emit("error",s),r.onlyEmitError)return;throw s}else if(r.delayInMs&&!this.closing&&!this.closed&&await this.delay(r.delayInMs,this.abortDelayController),n+1>=o)throw s}while(++n<o)}async moveStalledJobsToWait(){await this.trace(ge.SpanKind.INTERNAL,"moveStalledJobsToWait",this.name,async e=>{let r=await this.scripts.moveStalledJobsToWait();e?.setAttributes({[ge.TelemetryAttributes.WorkerId]:this.id,[ge.TelemetryAttributes.WorkerName]:this.opts.name,[ge.TelemetryAttributes.WorkerStalledJobs]:r}),r.forEach(i=>{e?.addEvent("job stalled",{[ge.TelemetryAttributes.JobId]:i}),this.emit("stalled",i,"active")})})}moveLimitedBackToWait(e,r){return e.moveToWait(r)}};cy.Worker=fI});var Iq=h(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});var tt=(Zt(),Jt(Wt));tt.__exportStar(CE(),Ze);tt.__exportStar(OE(),Ze);tt.__exportStar(KE(),Ze);tt.__exportStar(jE(),Ze);tt.__exportStar(hL(),Ze);tt.__exportStar(Mf(),Ze);tt.__exportStar(SF(),Ze);tt.__exportStar(pu(),Ze);tt.__exportStar(wF(),Ze);tt.__exportStar(kF(),Ze);tt.__exportStar(Pa(),Ze);tt.__exportStar(Qh(),Ze);tt.__exportStar(nI(),Ze);tt.__exportStar(uo(),Ze);tt.__exportStar(hq(),Ze);tt.__exportStar(yq(),Ze);tt.__exportStar(lI(),Ze);tt.__exportStar(sm(),Ze);tt.__exportStar(Sq(),Ze);tt.__exportStar(mu(),Ze);tt.__exportStar(sy(),Ze);tt.__exportStar(pI(),Ze);tt.__exportStar(z0(),Ze);tt.__exportStar(xq(),Ze)});var _q=h(kq=>{"use strict";Object.defineProperty(kq,"__esModule",{value:!0})});var Cq=h(Tq=>{"use strict";Object.defineProperty(Tq,"__esModule",{value:!0})});var Aq=h(Oq=>{"use strict";Object.defineProperty(Oq,"__esModule",{value:!0})});var Rq=h(Kq=>{"use strict";Object.defineProperty(Kq,"__esModule",{value:!0})});var jq=h(Dq=>{"use strict";Object.defineProperty(Dq,"__esModule",{value:!0})});var Mq=h(Pq=>{"use strict";Object.defineProperty(Pq,"__esModule",{value:!0})});var Lq=h(Nq=>{"use strict";Object.defineProperty(Nq,"__esModule",{value:!0})});var $q=h(Uq=>{"use strict";Object.defineProperty(Uq,"__esModule",{value:!0})});var Fq=h(Jq=>{"use strict";Object.defineProperty(Jq,"__esModule",{value:!0})});var zq=h(qq=>{"use strict";Object.defineProperty(qq,"__esModule",{value:!0})});var Vq=h(Gq=>{"use strict";Object.defineProperty(Gq,"__esModule",{value:!0})});var Wq=h(Bq=>{"use strict";Object.defineProperty(Bq,"__esModule",{value:!0})});var Hq=h(Zq=>{"use strict";Object.defineProperty(Zq,"__esModule",{value:!0})});var Xq=h(Yq=>{"use strict";Object.defineProperty(Yq,"__esModule",{value:!0})});var ez=h(Qq=>{"use strict";Object.defineProperty(Qq,"__esModule",{value:!0})});var rz=h(tz=>{"use strict";Object.defineProperty(tz,"__esModule",{value:!0})});var iz=h(nz=>{"use strict";Object.defineProperty(nz,"__esModule",{value:!0})});var sz=h(oz=>{"use strict";Object.defineProperty(oz,"__esModule",{value:!0})});var lz=h(uy=>{"use strict";Object.defineProperty(uy,"__esModule",{value:!0});uy.ClientType=void 0;var az;(function(t){t.blocking="blocking",t.normal="normal"})(az||(uy.ClientType=az={}))});var uz=h(cz=>{"use strict";Object.defineProperty(cz,"__esModule",{value:!0})});var pz=h(dz=>{"use strict";Object.defineProperty(dz,"__esModule",{value:!0})});var mz=h(fz=>{"use strict";Object.defineProperty(fz,"__esModule",{value:!0})});var yz=h(hz=>{"use strict";Object.defineProperty(hz,"__esModule",{value:!0})});var bz=h(gz=>{"use strict";Object.defineProperty(gz,"__esModule",{value:!0})});var Sz=h(vz=>{"use strict";Object.defineProperty(vz,"__esModule",{value:!0})});var wz=h(Ez=>{"use strict";Object.defineProperty(Ez,"__esModule",{value:!0})});var Iz=h(xz=>{"use strict";Object.defineProperty(xz,"__esModule",{value:!0})});var _z=h(kz=>{"use strict";Object.defineProperty(kz,"__esModule",{value:!0})});var Cz=h(Tz=>{"use strict";Object.defineProperty(Tz,"__esModule",{value:!0})});var Az=h(Oz=>{"use strict";Object.defineProperty(Oz,"__esModule",{value:!0})});var Rz=h(Kz=>{"use strict";Object.defineProperty(Kz,"__esModule",{value:!0})});var jz=h(Dz=>{"use strict";Object.defineProperty(Dz,"__esModule",{value:!0})});var Mz=h(Pz=>{"use strict";Object.defineProperty(Pz,"__esModule",{value:!0})});var Lz=h(Nz=>{"use strict";Object.defineProperty(Nz,"__esModule",{value:!0})});var Uz=h(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});var ke=(Zt(),Jt(Wt));ke.__exportStar(_q(),xe);ke.__exportStar(Cq(),xe);ke.__exportStar(Aq(),xe);ke.__exportStar(Rq(),xe);ke.__exportStar(jq(),xe);ke.__exportStar(Mq(),xe);ke.__exportStar(Lq(),xe);ke.__exportStar($q(),xe);ke.__exportStar(Fq(),xe);ke.__exportStar(zq(),xe);ke.__exportStar(Vq(),xe);ke.__exportStar(Wq(),xe);ke.__exportStar(Hq(),xe);ke.__exportStar(Xq(),xe);ke.__exportStar(ez(),xe);ke.__exportStar(rz(),xe);ke.__exportStar(iz(),xe);ke.__exportStar(sz(),xe);ke.__exportStar(lz(),xe);ke.__exportStar(uz(),xe);ke.__exportStar(pz(),xe);ke.__exportStar(mz(),xe);ke.__exportStar(yz(),xe);ke.__exportStar(bz(),xe);ke.__exportStar(Sz(),xe);ke.__exportStar(wz(),xe);ke.__exportStar(Iz(),xe);ke.__exportStar(_z(),xe);ke.__exportStar(Cz(),xe);ke.__exportStar(Az(),xe);ke.__exportStar(Rz(),xe);ke.__exportStar(jz(),xe);ke.__exportStar(Mz(),xe);ke.__exportStar(Lz(),xe)});var Jz=h($z=>{"use strict";Object.defineProperty($z,"__esModule",{value:!0})});var qz=h(Fz=>{"use strict";Object.defineProperty(Fz,"__esModule",{value:!0})});var Gz=h(zz=>{"use strict";Object.defineProperty(zz,"__esModule",{value:!0})});var Bz=h(Vz=>{"use strict";Object.defineProperty(Vz,"__esModule",{value:!0})});var Zz=h(Wz=>{"use strict";Object.defineProperty(Wz,"__esModule",{value:!0})});var Yz=h(Hz=>{"use strict";Object.defineProperty(Hz,"__esModule",{value:!0})});var Qz=h(Xz=>{"use strict";Object.defineProperty(Xz,"__esModule",{value:!0})});var t6=h(e6=>{"use strict";Object.defineProperty(e6,"__esModule",{value:!0})});var n6=h(r6=>{"use strict";Object.defineProperty(r6,"__esModule",{value:!0})});var o6=h(i6=>{"use strict";Object.defineProperty(i6,"__esModule",{value:!0})});var a6=h(s6=>{"use strict";Object.defineProperty(s6,"__esModule",{value:!0})});var l6=h(Ur=>{"use strict";Object.defineProperty(Ur,"__esModule",{value:!0});var wn=(Zt(),Jt(Wt));wn.__exportStar(Jz(),Ur);wn.__exportStar(qz(),Ur);wn.__exportStar(Gz(),Ur);wn.__exportStar(Bz(),Ur);wn.__exportStar(Zz(),Ur);wn.__exportStar(Yz(),Ur);wn.__exportStar(Qz(),Ur);wn.__exportStar(t6(),Ur);wn.__exportStar(n6(),Ur);wn.__exportStar(o6(),Ur);wn.__exportStar(a6(),Ur)});var u6=h(c6=>{"use strict";Object.defineProperty(c6,"__esModule",{value:!0})});var dy=h(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});var hs=(Zt(),Jt(Wt));hs.__exportStar(Iq(),bi);hs.__exportStar(gr(),bi);hs.__exportStar(Uz(),bi);hs.__exportStar(l6(),bi);hs.__exportStar(Or(),bi);hs.__exportStar(u6(),bi);hs.__exportStar(im(),bi)});function b(t,e,r){function i(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);let c=s.prototype,u=Object.keys(c);for(let d=0;d<u.length;d++){let f=u[d];f in a||(a[f]=c[f].bind(a))}}let n=r?.Parent??Object;class o extends n{}Object.defineProperty(o,"name",{value:t});function s(a){var l;let c=r?.Parent?new o:this;i(c,a),(l=c._zod).deferred??(l.deferred=[]);for(let u of c._zod.deferred)u();return c}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(s,"name",{value:t}),s}function dt(t){return t&&Object.assign(ys,t),ys}var d6,mI,hI,xn,po,ys,gs=S(()=>{mI=Object.freeze({status:"aborted"});hI=Symbol("zod_brand"),xn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},po=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(d6=globalThis).__zod_globalConfig??(d6.__zod_globalConfig={});ys=globalThis.__zod_globalConfig});var M={};Ce(M,{BIGINT_FORMAT_RANGES:()=>kI,Class:()=>gI,NUMBER_FORMAT_RANGES:()=>II,aborted:()=>yo,allowsEval:()=>SI,assert:()=>upe,assertEqual:()=>spe,assertIs:()=>lpe,assertNever:()=>cpe,assertNotEqual:()=>ape,assignProp:()=>mo,base64ToUint8Array:()=>f6,base64urlToUint8Array:()=>Tpe,cached:()=>sl,captureStackTrace:()=>fy,cleanEnum:()=>_pe,cleanRegex:()=>Au,clone:()=>dr,cloneDef:()=>ppe,createTransparentProxy:()=>bpe,defineLazy:()=>be,esc:()=>py,escapeRegex:()=>ln,explicitlyAborted:()=>_I,extend:()=>Epe,finalizeIssue:()=>pr,floatSafeRemainder:()=>bI,getElementAtPath:()=>fpe,getEnumValues:()=>Ou,getLengthableOrigin:()=>Du,getParsedType:()=>gpe,getSizableOrigin:()=>Ru,hexToUint8Array:()=>Ope,isObject:()=>bs,isPlainObject:()=>ho,issue:()=>al,joinValues:()=>k,jsonStringifyReplacer:()=>ol,merge:()=>xpe,mergeDefs:()=>vi,normalizeParams:()=>L,nullish:()=>fo,numKeys:()=>ype,objectClone:()=>dpe,omit:()=>Spe,optionalKeys:()=>xI,parsedType:()=>R,partial:()=>Ipe,pick:()=>vpe,prefixIssues:()=>Er,primitiveTypes:()=>wI,promiseAllObject:()=>mpe,propertyKeyTypes:()=>Ku,randomString:()=>hpe,required:()=>kpe,safeExtend:()=>wpe,shallowClone:()=>EI,slugify:()=>vI,stringifyPrimitive:()=>K,uint8ArrayToBase64:()=>m6,uint8ArrayToBase64url:()=>Cpe,uint8ArrayToHex:()=>Ape,unwrapMessage:()=>Cu});function spe(t){return t}function ape(t){return t}function lpe(t){}function cpe(t){throw new Error("Unexpected value in exhaustive check")}function upe(t){}function Ou(t){let e=Object.values(t).filter(i=>typeof i=="number");return Object.entries(t).filter(([i,n])=>e.indexOf(+i)===-1).map(([i,n])=>n)}function k(t,e="|"){return t.map(r=>K(r)).join(e)}function ol(t,e){return typeof e=="bigint"?e.toString():e}function sl(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function fo(t){return t==null}function Au(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function bI(t,e){let r=t/e,i=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-i)<n?0:r-i}function be(t,e,r){let i;Object.defineProperty(t,e,{get(){if(i!==p6)return i===void 0&&(i=p6,i=r()),i},set(n){Object.defineProperty(t,e,{value:n})},configurable:!0})}function dpe(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function mo(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function vi(...t){let e={};for(let r of t){let i=Object.getOwnPropertyDescriptors(r);Object.assign(e,i)}return Object.defineProperties({},e)}function ppe(t){return vi(t._zod.def)}function fpe(t,e){return e?e.reduce((r,i)=>r?.[i],t):t}function mpe(t){let e=Object.keys(t),r=e.map(i=>t[i]);return Promise.all(r).then(i=>{let n={};for(let o=0;o<e.length;o++)n[e[o]]=i[o];return n})}function hpe(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<t;i++)r+=e[Math.floor(Math.random()*e.length)];return r}function py(t){return JSON.stringify(t)}function vI(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function bs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ho(t){if(bs(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(bs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function EI(t){return ho(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function ype(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}function ln(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dr(t,e,r){let i=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(i._zod.parent=t),i}function L(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function bpe(t){let e;return new Proxy({},{get(r,i,n){return e??(e=t()),Reflect.get(e,i,n)},set(r,i,n,o){return e??(e=t()),Reflect.set(e,i,n,o)},has(r,i){return e??(e=t()),Reflect.has(e,i)},deleteProperty(r,i){return e??(e=t()),Reflect.deleteProperty(e,i)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,i){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,i)},defineProperty(r,i,n){return e??(e=t()),Reflect.defineProperty(e,i,n)}})}function K(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function xI(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function vpe(t,e){let r=t._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=vi(t._zod.def,{get shape(){let s={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(s[a]=r.shape[a])}return mo(this,"shape",s),s},checks:[]});return dr(t,o)}function Spe(t,e){let r=t._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=vi(t._zod.def,{get shape(){let s={...t._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete s[a]}return mo(this,"shape",s),s},checks:[]});return dr(t,o)}function Epe(t,e){if(!ho(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let o=t._zod.def.shape;for(let s in e)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=vi(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e};return mo(this,"shape",o),o}});return dr(t,n)}function wpe(t,e){if(!ho(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=vi(t._zod.def,{get shape(){let i={...t._zod.def.shape,...e};return mo(this,"shape",i),i}});return dr(t,r)}function xpe(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=vi(t._zod.def,{get shape(){let i={...t._zod.def.shape,...e._zod.def.shape};return mo(this,"shape",i),i},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return dr(t,r)}function Ipe(t,e,r){let n=e._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=vi(e._zod.def,{get shape(){let a=e._zod.def.shape,l={...a};if(r)for(let c in r){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);r[c]&&(l[c]=t?new t({type:"optional",innerType:a[c]}):a[c])}else for(let c in a)l[c]=t?new t({type:"optional",innerType:a[c]}):a[c];return mo(this,"shape",l),l},checks:[]});return dr(e,s)}function kpe(t,e,r){let i=vi(e._zod.def,{get shape(){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new t({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new t({type:"nonoptional",innerType:n[s]});return mo(this,"shape",o),o}});return dr(e,i)}function yo(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function _I(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function Er(t,e){return e.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(t),r})}function Cu(t){return typeof t=="string"?t:t?.message}function pr(t,e,r){let i=t.message?t.message:Cu(t.inst?._zod.def?.error?.(t))??Cu(e?.error?.(t))??Cu(r.customError?.(t))??Cu(r.localeError?.(t))??"Invalid input",{inst:n,continue:o,input:s,...a}=t;return a.path??(a.path=[]),a.message=i,e?.reportInput&&(a.input=s),a}function Ru(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Du(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function R(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function al(...t){let[e,r,i]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:i}:{...e}}function _pe(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function f6(t){let e=atob(t),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}function m6(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function Tpe(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return f6(e+r)}function Cpe(t){return m6(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ope(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)r[i/2]=Number.parseInt(e.slice(i,i+2),16);return r}function Ape(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var p6,fy,SI,gpe,Ku,wI,II,kI,gI,Z=S(()=>{gs();p6=Symbol("evaluating");fy="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};SI=sl(()=>{if(ys.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});gpe=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Ku=new Set(["string","number","symbol"]),wI=new Set(["string","number","bigint","boolean","symbol","undefined"]);II={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},kI={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};gI=class{constructor(...e){}}});function Pu(t,e=r=>r.message){let r={},i=[];for(let n of t.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(e(n))):i.push(e(n));return{formErrors:i,fieldErrors:r}}function Mu(t,e=r=>r.message){let r={_errors:[]},i=(n,o=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>i({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let a=[...o,...s.path];if(a.length===0)r._errors.push(e(s));else{let l=r,c=0;for(;c<a.length;){let u=a[c];c===a.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(e(s))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}}};return i(t),r}function TI(t,e=r=>r.message){let r={errors:[]},i=(n,o=[])=>{var s,a;for(let l of n.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(c=>i({issues:c},[...o,...l.path]));else if(l.code==="invalid_key")i({issues:l.issues},[...o,...l.path]);else if(l.code==="invalid_element")i({issues:l.issues},[...o,...l.path]);else{let c=[...o,...l.path];if(c.length===0){r.errors.push(e(l));continue}let u=r,d=0;for(;d<c.length;){let f=c[d],p=d===c.length-1;typeof f=="string"?(u.properties??(u.properties={}),(s=u.properties)[f]??(s[f]={errors:[]}),u=u.properties[f]):(u.items??(u.items=[]),(a=u.items)[f]??(a[f]={errors:[]}),u=u.items[f]),p&&u.errors.push(e(l)),d++}}};return i(t),r}function y6(t){let e=[],r=t.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?e.push(`[${i}]`):typeof i=="symbol"?e.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?e.push(`[${JSON.stringify(i)}]`):(e.length&&e.push("."),e.push(i));return e.join("")}function CI(t){let e=[],r=[...t.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)e.push(`\u2716 ${i.message}`),i.path?.length&&e.push(` \u2192 at ${y6(i.path)}`);return e.join(`
9954
9954
  `)}var h6,ju,wr,OI=S(()=>{gs();Z();h6=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,ol,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},ju=b("$ZodError",h6),wr=b("$ZodError",h6,{Parent:Error})});var ll,my,cl,hy,ul,AI,dl,KI,yy,Rpe,gy,Dpe,by,jpe,vy,Ppe,Sy,Mpe,Ey,Npe,wy,Lpe,xy,Upe,RI=S(()=>{gs();OI();Z();ll=t=>(e,r,i,n)=>{let o=i?{...i,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new xn;if(s.issues.length){let a=new(n?.Err??t)(s.issues.map(l=>pr(l,o,dt())));throw fy(a,n?.callee),a}return s.value},my=ll(wr),cl=t=>async(e,r,i,n)=>{let o=i?{...i,async:!0}:{async:!0},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(n?.Err??t)(s.issues.map(l=>pr(l,o,dt())));throw fy(a,n?.callee),a}return s.value},hy=cl(wr),ul=t=>(e,r,i)=>{let n=i?{...i,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},n);if(o instanceof Promise)throw new xn;return o.issues.length?{success:!1,error:new(t??ju)(o.issues.map(s=>pr(s,n,dt())))}:{success:!0,data:o.value}},AI=ul(wr),dl=t=>async(e,r,i)=>{let n=i?{...i,async:!0}:{async:!0},o=e._zod.run({value:r,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(s=>pr(s,n,dt())))}:{success:!0,data:o.value}},KI=dl(wr),yy=t=>(e,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return ll(t)(e,r,n)},Rpe=yy(wr),gy=t=>(e,r,i)=>ll(t)(e,r,i),Dpe=gy(wr),by=t=>async(e,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return cl(t)(e,r,n)},jpe=by(wr),vy=t=>async(e,r,i)=>cl(t)(e,r,i),Ppe=vy(wr),Sy=t=>(e,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return ul(t)(e,r,n)},Mpe=Sy(wr),Ey=t=>(e,r,i)=>ul(t)(e,r,i),Npe=Ey(wr),wy=t=>async(e,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return dl(t)(e,r,n)},Lpe=wy(wr),xy=t=>async(e,r,i)=>dl(t)(e,r,i),Upe=xy(wr)});var $r={};Ce($r,{base64:()=>WI,base64url:()=>Iy,bigint:()=>tk,boolean:()=>nk,browserEmail:()=>Bpe,cidrv4:()=>VI,cidrv6:()=>BI,cuid:()=>DI,cuid2:()=>jI,date:()=>YI,datetime:()=>QI,domain:()=>Hpe,duration:()=>UI,e164:()=>HI,email:()=>JI,emoji:()=>FI,extendedDuration:()=>$pe,guid:()=>$I,hex:()=>Ype,hostname:()=>Zpe,html5Email:()=>zpe,httpProtocol:()=>ZI,idnEmail:()=>Vpe,integer:()=>rk,ipv4:()=>qI,ipv6:()=>zI,ksuid:()=>NI,lowercase:()=>sk,mac:()=>GI,md5_base64:()=>Qpe,md5_base64url:()=>efe,md5_hex:()=>Xpe,nanoid:()=>LI,null:()=>ik,number:()=>ky,rfc5322Email:()=>Gpe,sha1_base64:()=>rfe,sha1_base64url:()=>nfe,sha1_hex:()=>tfe,sha256_base64:()=>ofe,sha256_base64url:()=>sfe,sha256_hex:()=>ife,sha384_base64:()=>lfe,sha384_base64url:()=>cfe,sha384_hex:()=>afe,sha512_base64:()=>dfe,sha512_base64url:()=>pfe,sha512_hex:()=>ufe,string:()=>ek,time:()=>XI,ulid:()=>PI,undefined:()=>ok,unicodeEmail:()=>g6,uppercase:()=>ak,uuid:()=>vs,uuid4:()=>Jpe,uuid6:()=>Fpe,uuid7:()=>qpe,xid:()=>MI});function FI(){return new RegExp(Wpe,"u")}function v6(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function XI(t){return new RegExp(`^${v6(t)}$`)}function QI(t){let e=v6({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${e}(?:${r.join("|")})`;return new RegExp(`^${b6}T(?:${i})$`)}function Nu(t,e){return new RegExp(`^[A-Za-z0-9+/]{${t}}${e}$`)}function Lu(t){return new RegExp(`^[A-Za-z0-9_-]{${t}}$`)}var DI,jI,PI,MI,NI,LI,UI,$pe,$I,vs,Jpe,Fpe,qpe,JI,zpe,Gpe,g6,Vpe,Bpe,Wpe,qI,zI,GI,VI,BI,WI,Iy,Zpe,Hpe,ZI,HI,b6,YI,ek,tk,rk,ky,nk,ik,ok,sk,ak,Ype,Xpe,Qpe,efe,tfe,rfe,nfe,ife,ofe,sfe,afe,lfe,cfe,ufe,dfe,pfe,_y=S(()=>{Z();DI=/^[cC][0-9a-z]{6,}$/,jI=/^[0-9a-z]+$/,PI=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,MI=/^[0-9a-vA-V]{20}$/,NI=/^[A-Za-z0-9]{27}$/,LI=/^[a-zA-Z0-9_-]{21}$/,UI=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,$pe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,$I=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,vs=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Jpe=vs(4),Fpe=vs(6),qpe=vs(7),JI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zpe=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Gpe=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,g6=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Vpe=g6,Bpe=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Wpe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";qI=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,zI=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,GI=t=>{let e=ln(t??":");return new RegExp(`^(?:[0-9A-F]{2}${e}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${e}){5}[0-9a-f]{2}$`)},VI=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,BI=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,WI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Iy=/^[A-Za-z0-9_-]*$/,Zpe=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Hpe=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,ZI=/^https?$/,HI=/^\+[1-9]\d{6,14}$/,b6="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",YI=new RegExp(`^${b6}$`);ek=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},tk=/^-?\d+n?$/,rk=/^-?\d+$/,ky=/^-?\d+(?:\.\d+)?$/,nk=/^(?:true|false)$/i,ik=/^null$/i,ok=/^undefined$/i,sk=/^[^A-Z]*$/,ak=/^[^a-z]*$/,Ype=/^[0-9a-fA-F]*$/;Xpe=/^[0-9a-fA-F]{32}$/,Qpe=Nu(22,"=="),efe=Lu(22),tfe=/^[0-9a-fA-F]{40}$/,rfe=Nu(27,"="),nfe=Lu(27),ife=/^[0-9a-fA-F]{64}$/,ofe=Nu(43,"="),sfe=Lu(43),afe=/^[0-9a-fA-F]{96}$/,lfe=Nu(64,""),cfe=Lu(64),ufe=/^[0-9a-fA-F]{128}$/,dfe=Nu(86,"=="),pfe=Lu(86)});function S6(t,e,r){t.issues.length&&e.issues.push(...Er(r,t.issues))}var Ge,E6,Ty,Cy,lk,ck,uk,dk,pk,fk,mk,hk,yk,pl,gk,bk,vk,Sk,Ek,wk,xk,Ik,kk,Oy=S(()=>{gs();_y();Z();Ge=b("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),E6={number:"number",bigint:"bigint",object:"date"},Ty=b("$ZodCheckLessThan",(t,e)=>{Ge.init(t,e);let r=E6[typeof e.value];t._zod.onattach.push(i=>{let n=i._zod.bag,o=(e.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<o&&(e.inclusive?n.maximum=e.value:n.exclusiveMaximum=e.value)}),t._zod.check=i=>{(e.inclusive?i.value<=e.value:i.value<e.value)||i.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Cy=b("$ZodCheckGreaterThan",(t,e)=>{Ge.init(t,e);let r=E6[typeof e.value];t._zod.onattach.push(i=>{let n=i._zod.bag,o=(e.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?n.minimum=e.value:n.exclusiveMinimum=e.value)}),t._zod.check=i=>{(e.inclusive?i.value>=e.value:i.value>e.value)||i.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),lk=b("$ZodCheckMultipleOf",(t,e)=>{Ge.init(t,e),t._zod.onattach.push(r=>{var i;(i=r._zod.bag).multipleOf??(i.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):bI(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),ck=b("$ZodCheckNumberFormat",(t,e)=>{Ge.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),i=r?"int":"number",[n,o]=II[e.format];t._zod.onattach.push(s=>{let a=s._zod.bag;a.format=e.format,a.minimum=n,a.maximum=o,r&&(a.pattern=rk)}),t._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:i,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort});return}}a<n&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:t,continue:!e.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:t,continue:!e.abort})}}),uk=b("$ZodCheckBigIntFormat",(t,e)=>{Ge.init(t,e);let[r,i]=kI[e.format];t._zod.onattach.push(n=>{let o=n._zod.bag;o.format=e.format,o.minimum=r,o.maximum=i}),t._zod.check=n=>{let o=n.value;o<r&&n.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:t,continue:!e.abort}),o>i&&n.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),dk=b("$ZodCheckMaxSize",(t,e)=>{var r;Ge.init(t,e),(r=t._zod.def).when??(r.when=i=>{let n=i.value;return!fo(n)&&n.size!==void 0}),t._zod.onattach.push(i=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<n&&(i._zod.bag.maximum=e.maximum)}),t._zod.check=i=>{let n=i.value;n.size<=e.maximum||i.issues.push({origin:Ru(n),code:"too_big",maximum:e.maximum,inclusive:!0,input:n,inst:t,continue:!e.abort})}}),pk=b("$ZodCheckMinSize",(t,e)=>{var r;Ge.init(t,e),(r=t._zod.def).when??(r.when=i=>{let n=i.value;return!fo(n)&&n.size!==void 0}),t._zod.onattach.push(i=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>n&&(i._zod.bag.minimum=e.minimum)}),t._zod.check=i=>{let n=i.value;n.size>=e.minimum||i.issues.push({origin:Ru(n),code:"too_small",minimum:e.minimum,inclusive:!0,input:n,inst:t,continue:!e.abort})}}),fk=b("$ZodCheckSizeEquals",(t,e)=>{var r;Ge.init(t,e),(r=t._zod.def).when??(r.when=i=>{let n=i.value;return!fo(n)&&n.size!==void 0}),t._zod.onattach.push(i=>{let n=i._zod.bag;n.minimum=e.size,n.maximum=e.size,n.size=e.size}),t._zod.check=i=>{let n=i.value,o=n.size;if(o===e.size)return;let s=o>e.size;i.issues.push({origin:Ru(n),...s?{code:"too_big",maximum:e.size}:{code:"too_small",minimum:e.size},inclusive:!0,exact:!0,input:i.value,inst:t,continue:!e.abort})}}),mk=b("$ZodCheckMaxLength",(t,e)=>{var r;Ge.init(t,e),(r=t._zod.def).when??(r.when=i=>{let n=i.value;return!fo(n)&&n.length!==void 0}),t._zod.onattach.push(i=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<n&&(i._zod.bag.maximum=e.maximum)}),t._zod.check=i=>{let n=i.value;if(n.length<=e.maximum)return;let s=Du(n);i.issues.push({origin:s,code:"too_big",maximum:e.maximum,inclusive:!0,input:n,inst:t,continue:!e.abort})}}),hk=b("$ZodCheckMinLength",(t,e)=>{var r;Ge.init(t,e),(r=t._zod.def).when??(r.when=i=>{let n=i.value;return!fo(n)&&n.length!==void 0}),t._zod.onattach.push(i=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>n&&(i._zod.bag.minimum=e.minimum)}),t._zod.check=i=>{let n=i.value;if(n.length>=e.minimum)return;let s=Du(n);i.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:n,inst:t,continue:!e.abort})}}),yk=b("$ZodCheckLengthEquals",(t,e)=>{var r;Ge.init(t,e),(r=t._zod.def).when??(r.when=i=>{let n=i.value;return!fo(n)&&n.length!==void 0}),t._zod.onattach.push(i=>{let n=i._zod.bag;n.minimum=e.length,n.maximum=e.length,n.length=e.length}),t._zod.check=i=>{let n=i.value,o=n.length;if(o===e.length)return;let s=Du(n),a=o>e.length;i.issues.push({origin:s,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:i.value,inst:t,continue:!e.abort})}}),pl=b("$ZodCheckStringFormat",(t,e)=>{var r,i;Ge.init(t,e),t._zod.onattach.push(n=>{let o=n._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:e.format,input:n.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(i=t._zod).check??(i.check=()=>{})}),gk=b("$ZodCheckRegex",(t,e)=>{pl.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),bk=b("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=sk),pl.init(t,e)}),vk=b("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=ak),pl.init(t,e)}),Sk=b("$ZodCheckIncludes",(t,e)=>{Ge.init(t,e);let r=ln(e.includes),i=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=i,t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),t._zod.check=n=>{n.value.includes(e.includes,e.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:n.value,inst:t,continue:!e.abort})}}),Ek=b("$ZodCheckStartsWith",(t,e)=>{Ge.init(t,e);let r=new RegExp(`^${ln(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(i=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),t._zod.check=i=>{i.value.startsWith(e.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:i.value,inst:t,continue:!e.abort})}}),wk=b("$ZodCheckEndsWith",(t,e)=>{Ge.init(t,e);let r=new RegExp(`.*${ln(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(i=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),t._zod.check=i=>{i.value.endsWith(e.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:i.value,inst:t,continue:!e.abort})}});xk=b("$ZodCheckProperty",(t,e)=>{Ge.init(t,e),t._zod.check=r=>{let i=e.schema._zod.run({value:r.value[e.property],issues:[]},{});if(i instanceof Promise)return i.then(n=>S6(n,r,e.property));S6(i,r,e.property)}}),Ik=b("$ZodCheckMimeType",(t,e)=>{Ge.init(t,e);let r=new Set(e.mime);t._zod.onattach.push(i=>{i._zod.bag.mime=e.mime}),t._zod.check=i=>{r.has(i.value.type)||i.issues.push({code:"invalid_value",values:e.mime,input:i.value.type,inst:t,continue:!e.abort})}}),kk=b("$ZodCheckOverwrite",(t,e)=>{Ge.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}})});var Uu,_k=S(()=>{Uu=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let i=e.split(`