@overlayed/app 1.3.3 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +10 -2
- package/package.json +4 -5
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{Type as t,scope as n,type as r}from"arktype";import i from"mitt";import a,{createWriteStream as o,existsSync as s,mkdirSync as c,readdirSync as l,unlinkSync as u,writeFileSync as d}from"fs";import{ensureFileSync as f}from"fs-extra";import p,{join as m}from"path";import*as h from"node:path";import g,{basename as _,resolve as ee}from"node:path";import v from"picocolors";import te from"events";import*as y from"node:fs";import{copyFileSync as ne,createReadStream as re,existsSync as b,mkdirSync as ie,readFileSync as ae,readdirSync as oe,writeFileSync as se}from"node:fs";import"glob";import"jiti";import ce from"xior";import x from"fs/promises";import le from"jszip";import{createHash as ue}from"node:crypto";import*as S from"node:fs/promises";import{BrowserWindow as de,app as C}from"electron";import*as fe from"node:os";import pe from"systeminformation";import me from"electron-updater";import"electron-updater/out/providers/Provider.js";var he=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);function ge(e){return e}function w(e){return e?Array.isArray(e)?e:[e]:[]}function _e(e){return typeof e==`string`&&/^01[0-9A-HJKMNP-TV-Z]{24}$/.test(e)}var ve=class{data=[];constructor(){}get size(){return this.data.length}add(e){this.data.push(e)}next(){return this.data.shift()}clear(){this.data.length=0}*flush(){for(;this.size>0;){let e=this.next();e&&(yield e)}}},T=class{emitter;constructor(){this.emitter=i()}on(e,t){w(e).forEach(e=>{this.emitter.on(e,t)})}off(e,t){w(e).forEach(e=>{this.emitter.off(e,t)})}emit(e,t){w(e).forEach(e=>{this.emitter.emit(e,t)})}removeAllListeners(){this.emitter.all.clear()}},ye=class{listeners;constructor(){this.listeners=new Map}on(e,t){w(e).forEach(e=>{let n=this.listeners.get(e)||new Set;n.add(t),this.listeners.set(e,n)})}off(e,t){w(e).forEach(e=>{let n=this.listeners.get(e);n&&n.delete(t)})}async emit(e,...t){let n=w(e).flatMap(e=>{let t=this.listeners.get(e)||new Set,n=this.listeners.get(`*`)||new Set;return[...Array.from(t),...Array.from(n)]});return n.length===0?[]:await Promise.all(n.map(async n=>{try{let e=n(...t);return e instanceof Promise?await e:e}catch(t){console.error(`Error in event listener for ${String(e)}:`,t);return}}))}removeAllListeners(){this.listeners.clear()}};function E(e,...t){return class extends e{static _instance;static getInstance(){return this._instance||=new e(...t),this._instance}static clearInstance(){this._instance=void 0}}}const D=E(class extends T{destroy(){this.removeAllListeners()}fatal(e,t,n){this.emit(`fatal`,{code:t,message:e,data:n,timestamp:Date.now()})}error(e,t,n){this.emit(`error`,{code:t,message:e,data:n,timestamp:Date.now()})}warn(e,t,n){this.emit(`warning`,{code:t,message:e,data:n,timestamp:Date.now()})}});var O=class{data;_schema;_defaultValue;_path;constructor(e){let{schema:t,default:n,path:r}=e;this._schema=t,this._defaultValue=n,this._path=r}set(e){let t=this._schema[`~standard`].validate(e);if(t instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);if(t.issues){this.reportInvalidConfigFile(t.issues);return}this.data=this.onBeforeSave(e),this.save(e)}get(e={}){return this.data?this.data:this.load(e)}getKey(e,t={}){return this.get(t)[e]}save(e){let t=this.onBeforeSave(e);try{f(this.getFilePath()),a.writeFileSync(this.getFilePath(),JSON.stringify(t,void 0,2))}catch{return}return this.data=t}load(e={}){let{createIfMissing:t=!0}=e;if(!this.fileExists(this.getFilePath())||!this.canReadWriteFile(this.getFilePath())){t&&this.save(this._defaultValue);let e=this.onAfterLoad(this._defaultValue);return t&&(this.data=e),e}try{let e=a.readFileSync(this.getFilePath(),`utf8`),t=this.onAfterLoad(this.parseStoredData(e));return this.data=t,t}catch{return this.data=this._defaultValue}}onBeforeSave(e){return e}onAfterLoad(e){return e}getFilePath(){return this._path}parseStoredData(e){try{let t=r(`string.json.parse`).to(`object`)(e);if(t instanceof r.errors)return this._defaultValue;let n=this._schema[`~standard`].validate(t);if(n instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);return n.issues?this.migrate(t,this._defaultValue):this.migrate(n.value,this._defaultValue)}catch{return this._defaultValue}}canReadWriteFile(e){try{return a.accessSync(e,a.constants.R_OK|a.constants.W_OK),!0}catch{return!1}}fileExists(e){try{return a.accessSync(e,a.constants.F_OK),!0}catch{return!1}}migrate(e,t){let n={...e};for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(r in e?e[r]!==null&&t[r]!==null&&typeof e[r]==`object`&&typeof t[r]==`object`&&!Array.isArray(e[r])&&!Array.isArray(t[r])?n[r]=this.migrate(e[r],t[r]):Array.isArray(t[r])&&(n[r]=e[r]):n[r]=t[r]);return n}reportInvalidConfigFile(e){D.getInstance().error(`Invalid config file`,`INVALID_CONFIG_FILE`,{issues:e.map(e=>e.message),filePath:this._path,data:this.data})}};function be(e,t,n){return typeof e!=`object`||!e?String(e):e instanceof Error?JSON.stringify(e,(e,t)=>{if(t instanceof Error){let e={};for(let n of Object.getOwnPropertyNames(t))e[n]=t[n];return e}return t},n):e instanceof Map?JSON.stringify(Object.fromEntries(e.entries()),t,n):e instanceof Set?JSON.stringify(Array.from(e),t,n):JSON.stringify(e,t,n)}const xe=/\x1b\[[0-9;]*m/g;function Se(e){return e.replace(xe,``)}var Ce=class e extends T{stream;logPath;baseFileName;currentDate;rotationCheckInterval;isRotating=!1;constructor(e,t){super(),this.logPath=e,this.baseFileName=t.replace(`.log`,``),this.currentDate=this.getDateString(new Date),this.ensureLogDirectory(),this.ensureLogFile(),this.stream=this.createStream(),this.rotationCheckInterval=this.startRotationCheck(),this.cleanupOldLogs()}static scope(t,n){return new e(t,n)}log(...e){this.write(`info`,...e)}error(...e){this.write(`error`,...e)}warn(...e){this.write(`warn`,...e)}info(...e){this.write(`info`,...e)}debug(...e){this.write(`debug`,...e)}async close(){clearInterval(this.rotationCheckInterval),await new Promise(e=>{this.stream.end(()=>e())})}getCurrentFileName(){return this.getFileName(this.currentDate)}static getMessageElements(e,...t){let n=new Date;return{timestamp:n.toISOString().replace(`T`,` `).replace(/\.\d+Z$/,``)+`.${n.getUTCMilliseconds().toString().padStart(3,`0`)}`,level:e,message:t.map(e=>be(e)).join(` `)}}getFileName(e){return`${this.baseFileName}-${e}.log`}ensureLogDirectory(){try{c(this.logPath,{recursive:!0})}catch(e){throw console.error(`Failed to create log directory ${this.logPath}:`,e),e}}ensureLogFile(){let e=m(this.logPath,this.getFileName(this.currentDate));if(!s(e))try{d(e,``,`utf8`)}catch(t){throw console.error(`Failed to create log file ${e}:`,t),t}}getDateString(e){return`${e.getUTCFullYear()}-${(e.getUTCMonth()+1).toString().padStart(2,`0`)}-${e.getUTCDate().toString().padStart(2,`0`)}`}createStream(){return o(m(this.logPath,this.getFileName(this.currentDate)),{flags:`a`,encoding:`utf8`})}async rotateLogs(){if(this.isRotating)return;this.isRotating=!0;let e=this.getDateString(new Date);e!==this.currentDate&&await new Promise(t=>{this.stream.end(()=>{this.currentDate=e,this.stream=this.createStream(),this.cleanupOldLogs(),t()})}),this.isRotating=!1}startRotationCheck(){return setInterval(()=>this.rotateLogs(),6e4)}cleanupOldLogs(){let e=l(this.logPath),t=new Date,n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()-7));e.filter(e=>e.startsWith(this.baseFileName)&&e.endsWith(`.log`)).filter(e=>{let[t,r,i]=e.replace(`${this.baseFileName}-`,``).replace(`.log`,``).split(`-`).map(Number);return new Date(Date.UTC(t,r-1,i))<=n}).forEach(e=>{try{u(m(this.logPath,e))}catch(t){console.error(`Failed to delete old log file ${e}:`,t)}})}ensureStreamValid(){if(!this.stream.writable||this.stream.destroyed)try{this.stream=this.createStream()}catch(e){this.emit(`error`,e instanceof Error?e:Error(String(e)))}}write(t,...n){let{timestamp:r,message:i}=e.getMessageElements(t,...n),a=`[${r}] [${t}] ${Se(i)}\n`;this.ensureStreamValid(),this.stream.write(a,e=>{if(e)if(e.code===`ERR_STREAM_WRITE_AFTER_END`||!this.stream.writable)try{this.stream=this.createStream(),this.stream.write(a,e=>{e?this.emit(`error`,e):this.emit(`write`,a)})}catch(e){this.emit(`error`,e instanceof Error?e:Error(String(e)))}else this.emit(`error`,e);else this.emit(`write`,a)})}};const k=()=>g.join(process.env.APPDATA??``,`overlayed`),we=()=>g.join(k(),`logs`),Te=e=>g.join(k(),`apps`,e),Ee=e=>g.join(Te(e),`logs`),De=()=>g.join(k(),`meta.json`),Oe=()=>g.join(k(),`crash-dumps`);var ke=class{fileLogger;path;appId;messageQueue=new ve;fileName;_debug=!1;silent=!1;forceSilent=!1;constructor(e){this.fileName=e}init(e,t=!1,n=!1,r=!1){this.appId=e,this._debug=t,this.silent=n,this.forceSilent=r,this.path=Ee(e),this.fileLogger=new Ce(this.path,this.fileName),this.messageQueue.flush().forEach(e=>{this.fileLogger?.[e.type](...e.args)})}scope(e){if(!this.appId||!this.path)throw Error(`Logger not initialized`);let t=v.cyan(`[${e}]`);return{scope:e=>this.scope(e),error:(...e)=>this.error(t,...e),warn:(...e)=>this.warn(t,...e),info:(...e)=>this.info(t,...e),log:(...e)=>this.log(t,...e),debug:(...e)=>this.debug(t,...e)}}error(...e){this.handle(`error`,...e)}warn(...e){this.handle(`warn`,...e)}info(...e){this.handle(`log`,...e)}debug(...e){this._debug&&this.handle(`debug`,...e)}log(...e){this.handle(`log`,...e)}handle(e,...t){this.logToConsole(e,...t),this.fileLogger?this.fileLogger[e](...t):this.messageQueue.add({type:e,args:t})}logToConsole(e,...t){let n={error:v.red,warn:v.yellow,debug:v.blue,log:v.white};if(this.forceSilent||this.silent&&!this._debug)return;let{timestamp:r,message:i}=Ce.getMessageElements(e,...t),a=console[e],o=n[e];a(`${v.gray(r)} ${o(i)}`)}};const A=E(ke,`overlayed.log`);var Ae=class extends te{blob;chunkSizeMb;maxConcurrent;shouldStop=!1;constructor(e,t){super(),this.blob=e,this.chunkSizeMb=t.chunkSizeMb,this.maxConcurrent=t.maxConcurrent??3}get totalChunks(){return Math.ceil(this.blob.size/(this.chunkSizeMb*1024*1024))}async chunk(e){let t=this.chunkSizeMb*1024*1024,n=this.totalChunks;if(n===0)return;let r=new Map,i=new Set,a=new Set,o=[];for(let e=0;e<n;e++)o.push(e);let s=async n=>{let s=n*t,c=Math.min(s+t,this.blob.size),l=this.blob.slice(s,c);try{await e(l,n),a.add(n),this.emit(`chunkComplete`,n),i.delete(n)}catch(e){let t=r.get(n)||0;t<5?(r.set(n,t+1),await new Promise(e=>setTimeout(e,(t+1)*1e3)),o.push(n)):(a.add(n),this.emit(`error`,e),this.shouldStop=!0,i.delete(n))}},c=[],l=async()=>{for(;(o.length>0||i.size>0)&&!this.shouldStop;){if(o.length===0){await new Promise(e=>setTimeout(e,10));continue}let e=o.shift();a.has(e)||i.has(e)||(i.add(e),await s(e))}};for(let e=0;e<this.maxConcurrent;e++)c.push(l());await Promise.all(c)}};function je(e,t){let{recursive:n}=Me(t);return b(e)?n?Ne(e).map(t=>[e,t]):oe(e).map(t=>[e,t]):[]}function Me(e){return{recursive:e?.recursive??!0}}function Ne(e){return oe(e,{withFileTypes:!0}).flatMap(t=>{let n=g.join(e,t.name);return t.isDirectory()?Ne(n):[n]})}function Pe(e){return Fe(e),e}function Fe(e){if(!_e(e.applicationId))throw Error(`Invalid applicationId, must be a valid ULID.`)}function Ie(e,t){let n=t?.cwd??process.cwd(),r=h.join(n,`.overlayed`);y.existsSync(r)||y.mkdirSync(r,{recursive:!0});let i={application:{id:e.id,name:e.name,slug:e.slug,siteUrl:e.siteUrl},release:{id:null,channel:`local`,version:`0.0.0`}},a=h.join(r,`meta.json`);return y.writeFileSync(a,JSON.stringify(i,null,2)),i}const{PipeEventServer:Le,PipeEventClient:Re,PipeEventBase:ze,ProcessMonitor:Be,Process:Ve,HardwareInterface:He}=e(import.meta.url)(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`),Ue=E(class extends T{server=null;_hasConnection=!1;pipeId;get hasConnection(){return this._hasConnection}constructor(e){super(),this.pipeId=e,this.init()}destroy(){this.server&&=(this._hasConnection=!1,this.server?.removeAllListeners(),null)}init(){this.server=new Le(this.pipeId,{clientCount:1,access:1}),this.server.on(`event`,e=>{try{let t=JSON.parse(e);this.emit(`data`,[t])}catch(e){this.emit(`error`,e)}}),this.server.on(`connected`,()=>{this._hasConnection=!0,this.emit(`connected`,void 0)}),this.server.on(`disconnected`,()=>{this._hasConnection=!1,this.emit(`disconnected`,void 0)})}},`overlayed-event-server`),{RenderInterface:We,renderHookPath:Ge}=e(import.meta.url)(`@overlayed/app/dist/render-interface/build/overlayed_render_interface_x64.node`);let Ke=function(e){return e[e.LeftButton=1]=`LeftButton`,e[e.RightButton=2]=`RightButton`,e[e.Cancel=3]=`Cancel`,e[e.MiddleButton=4]=`MiddleButton`,e[e.ExtraButton1=5]=`ExtraButton1`,e[e.ExtraButton2=6]=`ExtraButton2`,e[e.Back=8]=`Back`,e[e.Tab=9]=`Tab`,e[e.Clear=12]=`Clear`,e[e.Return=13]=`Return`,e[e.Shift=16]=`Shift`,e[e.Control=17]=`Control`,e[e.Menu=18]=`Menu`,e[e.Pause=19]=`Pause`,e[e.CapsLock=20]=`CapsLock`,e[e.Kana=21]=`Kana`,e[e.Hangeul=21]=`Hangeul`,e[e.Hangul=21]=`Hangul`,e[e.Junja=23]=`Junja`,e[e.Final=24]=`Final`,e[e.Hanja=25]=`Hanja`,e[e.Kanji=25]=`Kanji`,e[e.Escape=27]=`Escape`,e[e.Convert=28]=`Convert`,e[e.NonConvert=29]=`NonConvert`,e[e.Accept=30]=`Accept`,e[e.ModeChange=31]=`ModeChange`,e[e.Space=32]=`Space`,e[e.Prior=33]=`Prior`,e[e.Next=34]=`Next`,e[e.End=35]=`End`,e[e.Home=36]=`Home`,e[e.Left=37]=`Left`,e[e.Up=38]=`Up`,e[e.Right=39]=`Right`,e[e.Down=40]=`Down`,e[e.Select=41]=`Select`,e[e.Print=42]=`Print`,e[e.Execute=43]=`Execute`,e[e.Snapshot=44]=`Snapshot`,e[e.Insert=45]=`Insert`,e[e.Delete=46]=`Delete`,e[e.Help=47]=`Help`,e[e.N0=48]=`N0`,e[e.N1=49]=`N1`,e[e.N2=50]=`N2`,e[e.N3=51]=`N3`,e[e.N4=52]=`N4`,e[e.N5=53]=`N5`,e[e.N6=54]=`N6`,e[e.N7=55]=`N7`,e[e.N8=56]=`N8`,e[e.N9=57]=`N9`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.LeftWindows=91]=`LeftWindows`,e[e.RightWindows=92]=`RightWindows`,e[e.Application=93]=`Application`,e[e.Sleep=95]=`Sleep`,e[e.Numpad0=96]=`Numpad0`,e[e.Numpad1=97]=`Numpad1`,e[e.Numpad2=98]=`Numpad2`,e[e.Numpad3=99]=`Numpad3`,e[e.Numpad4=100]=`Numpad4`,e[e.Numpad5=101]=`Numpad5`,e[e.Numpad6=102]=`Numpad6`,e[e.Numpad7=103]=`Numpad7`,e[e.Numpad8=104]=`Numpad8`,e[e.Numpad9=105]=`Numpad9`,e[e.Multiply=106]=`Multiply`,e[e.Add=107]=`Add`,e[e.Separator=108]=`Separator`,e[e.Subtract=109]=`Subtract`,e[e.Decimal=110]=`Decimal`,e[e.Divide=111]=`Divide`,e[e.F1=112]=`F1`,e[e.F2=113]=`F2`,e[e.F3=114]=`F3`,e[e.F4=115]=`F4`,e[e.F5=116]=`F5`,e[e.F6=117]=`F6`,e[e.F7=118]=`F7`,e[e.F8=119]=`F8`,e[e.F9=120]=`F9`,e[e.F10=121]=`F10`,e[e.F11=122]=`F11`,e[e.F12=123]=`F12`,e[e.F13=124]=`F13`,e[e.F14=125]=`F14`,e[e.F15=126]=`F15`,e[e.F16=127]=`F16`,e[e.F17=128]=`F17`,e[e.F18=129]=`F18`,e[e.F19=130]=`F19`,e[e.F20=131]=`F20`,e[e.F21=132]=`F21`,e[e.F22=133]=`F22`,e[e.F23=134]=`F23`,e[e.F24=135]=`F24`,e[e.NumLock=144]=`NumLock`,e[e.ScrollLock=145]=`ScrollLock`,e[e.NEC_Equal=146]=`NEC_Equal`,e[e.Fujitsu_Jisho=146]=`Fujitsu_Jisho`,e[e.Fujitsu_Masshou=147]=`Fujitsu_Masshou`,e[e.Fujitsu_Touroku=148]=`Fujitsu_Touroku`,e[e.Fujitsu_Loya=149]=`Fujitsu_Loya`,e[e.Fujitsu_Roya=150]=`Fujitsu_Roya`,e[e.LeftShift=160]=`LeftShift`,e[e.RightShift=161]=`RightShift`,e[e.LeftControl=162]=`LeftControl`,e[e.RightControl=163]=`RightControl`,e[e.LeftMenu=164]=`LeftMenu`,e[e.RightMenu=165]=`RightMenu`,e[e.BrowserBack=166]=`BrowserBack`,e[e.BrowserForward=167]=`BrowserForward`,e[e.BrowserRefresh=168]=`BrowserRefresh`,e[e.BrowserStop=169]=`BrowserStop`,e[e.BrowserSearch=170]=`BrowserSearch`,e[e.BrowserFavorites=171]=`BrowserFavorites`,e[e.BrowserHome=172]=`BrowserHome`,e[e.VolumeMute=173]=`VolumeMute`,e[e.VolumeDown=174]=`VolumeDown`,e[e.VolumeUp=175]=`VolumeUp`,e[e.MediaNextTrack=176]=`MediaNextTrack`,e[e.MediaPrevTrack=177]=`MediaPrevTrack`,e[e.MediaStop=178]=`MediaStop`,e[e.MediaPlayPause=179]=`MediaPlayPause`,e[e.LaunchMail=180]=`LaunchMail`,e[e.LaunchMediaSelect=181]=`LaunchMediaSelect`,e[e.LaunchApplication1=182]=`LaunchApplication1`,e[e.LaunchApplication2=183]=`LaunchApplication2`,e[e.OEM1=186]=`OEM1`,e[e.OEMPlus=187]=`OEMPlus`,e[e.OEMComma=188]=`OEMComma`,e[e.OEMMinus=189]=`OEMMinus`,e[e.OEMPeriod=190]=`OEMPeriod`,e[e.OEM2=191]=`OEM2`,e[e.OEM3=192]=`OEM3`,e[e.OEM4=219]=`OEM4`,e[e.OEM5=220]=`OEM5`,e[e.OEM6=221]=`OEM6`,e[e.OEM7=222]=`OEM7`,e[e.OEM8=223]=`OEM8`,e[e.OEMAX=225]=`OEMAX`,e[e.OEM102=226]=`OEM102`,e[e.ICOHelp=227]=`ICOHelp`,e[e.ICO00=228]=`ICO00`,e[e.ProcessKey=229]=`ProcessKey`,e[e.ICOClear=230]=`ICOClear`,e[e.Packet=231]=`Packet`,e[e.OEMReset=233]=`OEMReset`,e[e.OEMJump=234]=`OEMJump`,e[e.OEMPA1=235]=`OEMPA1`,e[e.OEMPA2=236]=`OEMPA2`,e[e.OEMPA3=237]=`OEMPA3`,e[e.OEMWSCtrl=238]=`OEMWSCtrl`,e[e.OEMCUSel=239]=`OEMCUSel`,e[e.OEMATTN=240]=`OEMATTN`,e[e.OEMFinish=241]=`OEMFinish`,e[e.OEMCopy=242]=`OEMCopy`,e[e.OEMAuto=243]=`OEMAuto`,e[e.OEMENLW=244]=`OEMENLW`,e[e.OEMBackTab=245]=`OEMBackTab`,e[e.ATTN=246]=`ATTN`,e[e.CRSel=247]=`CRSel`,e[e.EXSel=248]=`EXSel`,e[e.EREOF=249]=`EREOF`,e[e.Play=250]=`Play`,e[e.Zoom=251]=`Zoom`,e[e.Noname=252]=`Noname`,e[e.PA1=253]=`PA1`,e[e.OEMClear=254]=`OEMClear`,e}({});const j=r({game:`string`,type:`string`,creation_time:`number`}).and({game:`'siege' | 'tft'`}),qe=j.and({type:`'logged_in'`,content:{account_id:`string`}}),Je=j.and({type:`'module_loaded'`,content:{game_version:`string`,process_hash:`string`}}),Ye=j.and({type:`'module_unloaded'`}),Xe=j.and({type:`'unsupported_game_version'`,content:{game_version:`string`,process_hash:`string`}}),Ze=n({"#event1":`logged_in | module_loaded | module_unloaded | unsupported_game_version`,event:`event1`,logged_in:qe,module_loaded:Je,module_unloaded:Ye,unsupported_game_version:Xe}).export(),Qe=Object.keys(Ze).filter(e=>e!==`event`);function $e(){return{key:`universal`,events:Ze}}var et=class{options=null;logger;initialized=!1;constructor(e){this.logger=A.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1}},M=class extends T{options=null;logger;initialized=!1;constructor(e){super(),this.logger=A.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}},tt=class extends ye{options=null;logger;initialized=!1;constructor(e){super(),this.logger=A.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}};const N=ce.create({baseURL:`https://api.overlayed.gg`,headers:{Accept:`application/json`,"Accept-Encoding":`gzip, deflate, br`}});let nt;function rt(e){nt=e}let it;function at(e){it=e}function ot(e){return`overlayed/app (${Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `)})`}N.interceptors.request.use(e=>{let t=nt?.();e.headers??={},t&&(e.headers[`X-Api-Key`]=t);let n=it?.();return n&&(e.headers[`User-Agent`]=ot(n)),e});function st(e,t){if(t<=0)throw Error(`Chunk size must be greater than 0`);if(e.length===0)return[];let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function ct(e){return e}function lt(e){return e?t=>(e(t),t):ct}const ut=lt();function dt(e){return N.get(`/v1/public/applications/${e}`)}function ft(e,t){return N.get(`/v1/public/applications/${e}/releases/check`,{params:t})}function pt(e,t){return N.post(`/v1/public/applications/${e}/game-crash-reports`,t)}function mt(e,t,n){return N.post(`/v1/public/applications/${e}/game-crash-reports/${t}/confirm`,n)}function ht(e,t){let n=new FormData;return n.append(`file`,new Blob([t.file],{type:`application/zip`}),`logs.zip`),n.append(`data`,JSON.stringify(t.data)),N.post(`/v1/public/applications/${e}/feedbacks`,n)}function gt(e,t){return N.get(`/v1/public/applications/${e}/feature-flags`,{params:t})}function _t(e,t){return N.get(`/v1/public/applications/${e}/notices`,{params:t})}const P=lt();function vt(e,t){return N.get(`/v1/public/modules/${e}/release`,{params:{cortex_user_id:t}})}function yt(e,t,n){return N.post(`/v1/public/modules/${e}/releases/${t}/download`,n)}async function bt(e,t){if(e.method!==`GET`)throw Error(`Unsupported presigned request method: ${e.method}`);let n=await fetch(e.url,{method:e.method,headers:e.headers,signal:t?.signal});if(!n.ok){let e=await St(n);throw Error(`Presigned download failed (${n.status} ${n.statusText})${e?`: ${e}`:``}`)}let r=await n.arrayBuffer();return new Uint8Array(r)}async function xt(e,t){if(e.method!==`PUT`)throw Error(`Unsupported presigned request method: ${e.method}`);let n=await fetch(e.url,{method:e.method,headers:{...e.headers,"Content-Length":t.byteLength.toString()},body:t});if(!n.ok){let e=await St(n);throw Error(`Presigned upload failed (${n.status} ${n.statusText})${e?`: ${e}`:``}`)}}async function St(e){try{let t=(await e.text()).trim();if(t.length===0)return;let n=2048;return t.length>n?`${t.slice(0,n)}…`:t}catch{return}}function Ct(){return N.get(`/v1/public/raven/config`)}const wt=lt();function Tt(e,t){return N.get(`/v1/public/raven/games/${e}/builds/${t}`)}function Et(e,t){return N.post(`/v1/public/raven/games/${e}/builds/upload`,null,{params:t})}function Dt(e,t){let n=new FormData;return n.append(`file`,t.chunk),N.patch(`/v1/public/raven/games/${e}/builds/upload`,n,{params:t})}function Ot(e){let t=Date.now(),n=e.messages.filter(e=>t-e.created_at.getTime()<6e5),r=e.messages.length-n.length;r>0&&console.warn(`Dropped ${r} cortex event(s) older than 600s`);let i=st(n.map(e=>kt(t,e)),50),a=Promise.all(i.map(async t=>N.post(`/v1/public/cortex/events`,{...e,messages:t})));return a.catch(e=>{let t=e?.response?.data||e?.message||e;console.error(`Failed to submit cortex events`,t)}),a}function kt(e,t){let n=e-t.created_at.getTime(),r=Math.max(0,Math.floor(n/1e3));return{properties:t.properties,type:t.type,seconds_offset:r}}function At(e){return e instanceof Error&&(e.name===`XiorError`||e.name===`XiorTimeoutError`)}function jt(e){return!!(e&&`kind`in e.data&&`message`in e.data)}const{PipeEventServer:Mt,PipeEventClient:Nt,PipeEventBase:Pt,ProcessMonitor:Ft,Process:It,HardwareInterface:Lt}=e(import.meta.url)(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`);function Rt(e=[]){return g.normalize(g.join(Te(global.OVERLAYED.APPLICATION_ID),...e))}const zt=r({game:`string`,type:`string`,creation_time:`number`}),F=new O({path:De(),schema:r({userId:`string | undefined`,sessionId:`string | undefined`,sessionLastUsed:`number | undefined`,accessToken:`string | undefined`,"debug?":{"ri_disabled?":`boolean`,"gm_disabled?":`boolean`}}),default:{userId:void 0,sessionId:void 0,sessionLastUsed:void 0,accessToken:void 0}});function Bt(){let{debug:e}=F.get();return e?{ri_disabled:e.ri_disabled??!1,gm_disabled:e.gm_disabled??!1}:{ri_disabled:!1,gm_disabled:!1}}function I(){let e=F.get().userId;if(e)return e;let t=Ut();return F.set({...F.get(),userId:t}),t}function Vt(){let e=F.get();if(e.sessionId&&typeof e.sessionLastUsed==`number`&&Date.now()-e.sessionLastUsed<=300*1e3)return e.sessionId;let t=crypto.randomUUID();return F.set({...e,sessionId:t,sessionLastUsed:Date.now()}),t}function Ht(){try{let e=F.get();F.set({...e,sessionLastUsed:Date.now()})}catch(e){A.getInstance().log(`Failed to update sessionLastUsed`,e)}}function L(){return F.get().accessToken}function R(e){try{let t=F.get();F.set({...t,accessToken:e??void 0})}catch(e){A.getInstance().log(`Failed to set accessToken`,e)}}function Ut(){try{return Lt.generateUniqueIdentifier()}catch{return crypto.randomUUID()}}const Wt=E(class extends M{UPDATE_CHECK_INTERVAL_MS=1e3*60*5;targetDir;updateInterval;constructor(){super(`NativeModuleManager`),this.targetDir=g.join(k(),`resources`),this.logger.log(`Target directory`,this.targetDir)}async initWithDlls(e){super.init(),await x.mkdir(this.targetDir,{recursive:!0}),await this.checkForUpdates(e),clearInterval(this.updateInterval),this.updateInterval=setInterval(()=>this.checkForUpdates(e),this.UPDATE_CHECK_INTERVAL_MS)}destroy(){this.updateInterval&&=(clearInterval(this.updateInterval),void 0),super.destroy()}async getDllFile(e){let t=await this.getCurrentBuildInfo(e);if(!t){this.logger.error(`No build found for module`,{moduleId:e});return}let n=this.getBuildPath(e,t.buildId);if(!b(n)){this.logger.error(`No build file found for module`,{moduleId:e});return}let r=g.join(n,t.buildFileName);if(!b(r)){this.logger.error(`No DLL file found for module`,{moduleId:e});return}return r}async getCurrentBuildInfo(e){try{let t=g.join(this.targetDir,e,`build.json`),n=await x.readFile(t,`utf-8`);return JSON.parse(n)}catch{return null}}getModulePath(e){return g.join(this.targetDir,e)}getBuildPath(e,t){return g.join(this.getModulePath(e),t)}async checkForUpdates(e){this.logger.log(`Checking for updates`);let t=I();if(!t){this.logger.error(`Failed to resolve cortex user id`);return}this.logger.log(`Cortex User ID`,t);for(let n of e)try{let{data:e}=await vt(n,t);this.logger.log(`Release`,e);let r=(await this.getCurrentBuildInfo(n))?.buildId||null;this.logger.log(`${n} > Performing update check. current: ${r}, requested: ${e.build_id}`),e.build_id!==r||await this.isDownloadCorrupted(this.getBuildPath(n,e.build_id),e)?(this.logger.log(`${n} > Update found. current: ${r}, requested: ${e.build_id}`),this.logger.log(`${n} > Downloading and extracting DLLs`),await this.downloadAndExtractDll(n,e),this.logger.log(`${n} > Cleaning up other builds`),await this.cleanupExistingBuilds(n,e.build_id),this.emit(`dllUpdated`,{moduleId:n,buildId:e.build_id,releaseId:e.release_id})):this.logger.log(`${n} > No update found`)}catch(e){this.logger.error(`${n} > Error checking/updating`,e)}}async downloadAndExtractDll(e,t){this.logger.log(`${e} > Requesting download for build ${t.build_id}`);let n=I();if(!n){this.logger.error(`Failed to resolve cortex user id`);return}let{data:r}=await yt(e,t.release_id,{download_token:t.download_token,cortex_user_id:n});this.logger.log(`${e} > Downloading DLLs for build ${t.build_id}`);let i=await bt(r,{signal:AbortSignal.timeout(1e3*60*5)});this.logger.log(`${e} > Downloaded zip file for build ${t.build_id}`);let a=this.getBuildPath(e,t.build_id);await x.mkdir(a,{recursive:!0});let o=new le;await o.loadAsync(i);let s=Object.keys(o.files).map(e=>({name:e,file:o.files[e]})).filter(({file:e})=>!e.dir);if(s.length!==1){this.logger.error(`${e} > Zip must contain exactly 1 file, got ${s.length}`);return}let c=s[0],l=g.basename(c.name),u=g.normalize(l),d=g.isAbsolute(u),f=u.startsWith(`..`)||u.includes(`..${g.sep}`);if(l===``||l===`.`||l===`..`){this.logger.error(`${e} > Zip contained an invalid file name: ${c.name}`);return}if(!l.toLowerCase().endsWith(`.dll`)){this.logger.error(`${e} > Zip contained a non-dll file: ${c.name}`);return}if(d||f){this.logger.error(`${e} > Zip entry path is unsafe: ${c.name}`);return}let p=g.join(a,u),m=await c.file.async(`nodebuffer`);await x.writeFile(p,m),this.logger.log(`${e} > Extracted 1 file to ${p}`);let h={buildId:t.build_id,buildFileName:t.build_file_name},_=g.join(this.getModulePath(e),`build.json`);await x.writeFile(_,JSON.stringify(h),`utf-8`),this.logger.log(`${e} > Saved buildId to file: ${t.build_id}`)}async cleanupExistingBuilds(e,t){let n=this.getModulePath(e),r=this.getBuildPath(e,t),i=await x.readdir(n,{withFileTypes:!0});for(let t of i)t.isDirectory()&&g.join(n,t.name)!==r&&(await x.rm(g.join(n,t.name),{recursive:!0,force:!0}),this.logger.log(`${e} > Cleaned up build: ${t.name}`))}async hasPathAccess(e){try{return await x.access(e,x.constants.F_OK),!0}catch{return!1}}async isDownloadCorrupted(e,t){if(!await this.hasPathAccess(e))return this.logger.error(`Download is corrupted. Path does not exist: ${e}`),!0;let n=t.build_file_name,r=g.join(e,n);if(!b(r))return this.logger.error(`Download is corrupted. Build file not found: ${r}`),!0;if(t.build_hash){let e=await x.readFile(r),i=ue(`sha256`).update(e).digest(`hex`);if(i.toLowerCase()!==t.build_hash.toLowerCase())return this.logger.error(`Download is corrupted. Build file hash mismatch: ${n} ${i.toLowerCase()} !== ${t.build_hash.toLowerCase()}`),!0}return!1}}),z=E(class extends M{REFETCH_INTERVAL=1e3*60*5;FAILED_REFETCH_INTERVAL=1e3*30;_ravenConfig;_executableToGameMap=new Map;_executablesArray=[];_refetchIntervalHandler=null;_failedRefetchTimeoutHandler=null;constructor(){super(`RavenManager`)}init(){super.init(),this.fetchRavenConfig(),this._refetchIntervalHandler=setInterval(()=>{this._failedRefetchTimeoutHandler&&=(clearTimeout(this._failedRefetchTimeoutHandler),null),this.fetchRavenConfig()},this.REFETCH_INTERVAL)}getExecutableData(e){return this._executableToGameMap.get(e.toLowerCase())??null}get executables(){return this._executablesArray}get executablesMap(){return this._executableToGameMap}destroy(){this._refetchIntervalHandler&&clearInterval(this._refetchIntervalHandler),this._failedRefetchTimeoutHandler&&clearTimeout(this._failedRefetchTimeoutHandler),Wt.getInstance().destroy(),super.destroy()}async fetchRavenConfig(){try{this._ravenConfig={games:(await Ct()).data.games},this.resetState();let e=new Set;for(let t of this._ravenConfig.games){for(let e of t.executables){let n=e.toLowerCase();this._executableToGameMap.set(n,t),this._executablesArray.push(n)}t.modules.forEach(t=>e.add(t))}await Wt.getInstance().initWithDlls(Array.from(e)),this.logger.log(`Raven updated, monitoring ${this._executableToGameMap.size} executables`),this.emit(`executablesUpdated`,{executables:this.executables,map:this._executableToGameMap})}catch(e){this.logger.error(`Failed to fetch Raven config`,e),this._failedRefetchTimeoutHandler=setTimeout(()=>this.fetchRavenConfig(),this.FAILED_REFETCH_INTERVAL)}}resetState(){this._executableToGameMap.clear(),this._executablesArray=[]}}),B=E(class extends M{_processMonitor;_processes=new Map;boundOnRavenManagerExecutablesUpdated=this.onRavenManagerExecutablesUpdated.bind(this);constructor(){super(`ProcessManager`),this._processMonitor=new Ft}get hasAnyActiveProcesses(){return this.activeProcesses.length>0}get activeProcesses(){return Array.from(this._processes.values()).flat().filter(e=>!e.destroyedAt)}init(){super.init(),z.getInstance().on(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processMonitor.on(`create`,e=>{this.logger.log(`Process created`,e),this.addProcess(e),this.logger.log(`Active Process Count: ${this._processes.size}`),this.emit(`create`,{process:e})}),this._processMonitor.on(`destroy`,e=>{this.logger.log(`Process destroyed`,e),this.deleteProcess(e),this.logger.log(`Active Process Count: ${this._processes.size}`),this.emit(`destroy`,{process:e})})}destroy(){z.getInstance().off(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processes.clear(),this._processMonitor.removeAllListeners(),super.destroy()}isProcessRunning(e){return this._processes.get(e)?.some(e=>!e.destroyedAt)??!1}onRavenManagerExecutablesUpdated(e){this.logger.log(`Monitoring ${e.executables.length} processes`),e.executables.forEach(e=>{this._processMonitor.isProcessRegistered(e)||this._processMonitor.registerProcess(e)})}addProcess(e){if(!e.name)return;let t=this._processes.get(e.name);if(!t){this._processes.set(e.name,[e]);return}this._processes.set(e.name,t.concat(e))}deleteProcess(e){if(!e.name)return;let t=this._processes.get(e.name)?.filter(t=>t.id!==e.id)??[];t.length===0?this._processes.delete(e.name):this._processes.set(e.name,t)}});var Gt=class{_instance;_resolution;boundOnResolutionChanged=this.onResolutionChanged.bind(this);constructor(e){this._instance=e,this._resolution={width:0,height:0},this._instance.on(`resolution`,this.boundOnResolutionChanged)}destroy(){this._instance.off(`resolution`,this.boundOnResolutionChanged)}get instance(){return this._instance}get resolution(){return this._resolution}onResolutionChanged(e,t){this._resolution={width:e,height:t}}};const V=E(class{interfaces={};constructor(){}createInterface(e){return this.interfaces[e]||(this.interfaces[e]=new Gt(new We(e,{access:1}))),this.interfaces[e]}getInterface(e){return this.interfaces[e]?this.interfaces[e]:this.createInterface(e)}}),H=E(class{options;eventQueue;meta=null;enabled=!0;constructor(e){this.options=this.resolveOptions(e),this.eventQueue=new ve,this.setupFlushInterval()}track(e,t){this.enabled&&this.eventQueue.add({type:e,properties:t,created_at:new Date})}flush(){if(!this.enabled)return[];let e=Array.from(this.eventQueue.flush()).concat({type:`ping`,properties:{},created_at:new Date});if(!this.meta)throw Error(`Tried to flush Cortex events before meta was set`);try{Ot({...this.meta,messages:e})}catch{}return e}setupFlushInterval(){this.enabled&&setInterval(()=>{this.flush()},this.options.batchIntervalSeconds*1e3)}resolveOptions(e){return{batchIntervalSeconds:e?.batchIntervalSeconds??15}}}),U=e(import.meta.url),Kt=U.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x64.dll`),qt=U.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x86.dll`),Jt=U.resolve(`@overlayed/app/dist/native-interface/build/overlayed_injector_x64.exe`),Yt=U.resolve(`@overlayed/app/dist/native-interface/build/overlayed_injector_x86.exe`),W=E(class extends tt{boundOnProcessCreate=this.onProcessCreate.bind(this);boundOnProcessDestroy=this.onProcessDestroy.bind(this);subscribedGames=new Set;_activeReadyRavenGames={};get isInGame(){return Object.keys(this._activeReadyRavenGames).length>0}constructor(){super(`GameLaunchManager`)}setSubscribedGames(e){this.subscribedGames=new Set(e)}getActiveGames(){return Object.keys(this._activeReadyRavenGames)}init(){super.init(),V.getInstance().createInterface(`OGG_SIEGE`),B.getInstance().on(`create`,this.boundOnProcessCreate),B.getInstance().on(`destroy`,this.boundOnProcessDestroy)}destroy(){B.getInstance().off(`create`,this.boundOnProcessCreate),B.getInstance().off(`destroy`,this.boundOnProcessDestroy),super.destroy()}on(e,t){super.on(e,t);let n=w(e);if(!(n.includes(`gameReady`)||n.includes(`*`))||Object.keys(this._activeReadyRavenGames).length===0)return;let r=t;for(let e of Object.values(this._activeReadyRavenGames))this.logger.log(`Late calling gameReady callback for game`,e.game),r(e)}async onProcessCreate({process:e}){this.logger.log(`On process create`,e);let t=this.getRavenGame(e);if(!t)return;if(this.logger.log(`Raven game found`,t),t.command_line_regex){this.logger.log(`Performing command line regex check`,{regex:t.command_line_regex});try{let n=e.commandLine;this.logger.log(`Process command line`,n);let r=new RegExp(t.command_line_regex);if(!e.commandLine||!r.test(e.commandLine)){this.logger.log(`Process command line does not match regex, skipping`,{commandLine:e.commandLine,regex:t.command_line_regex});return}}catch(e){this.logger.error(`Failed to check command line`,e);return}}if(H.getInstance().track(`game_launch`,{game:t.identifier}),this.subscribedGames.size===0){this.logger.warn(`No subscribed games, skipping`);return}if(!this.subscribedGames.has(t.identifier)&&!this.subscribedGames.has(`*`))return;let n=new AbortController;if(await this.emit(`gameLaunch`,{game:t.identifier,reject:()=>n.abort()}),n.signal.aborted)return;let r=It.currentProcess;if(this.logger.log(`Game Launched`,t),this.logger.log(`Process is elevated: `,e.isElevated),this.logger.log(`Current process is elevated: `,r.isElevated),e.isElevated&&!r.isElevated){D.getInstance().fatal(`Game is elevated but the App is not`,`ELEVATION_MISMATCH`,{appElevated:!!r.isElevated,gameElevated:!!e.isElevated}),this.logger.log(`Game elevated but App is not`,{appElevated:r.isElevated,gameElevated:e.isElevated});return}let i=e.createdAt||new Date,a=Math.floor((new Date().getTime()-i.getTime())/1e3);this.logger.log(`Process created ${a}s ago`),a<30&&(this.logger.log(`Delaying injection for 45 seconds to allow game to be ready`),await new Promise(e=>setTimeout(e,1e3*45)));let{ri_disabled:o,gm_disabled:s}=Bt(),c=!1;!o&&t.has_render_support&&t.allow_dll_injections?c=await this.injectRenderInterface(e):this.logger.log(`Skipping render interface injection`,{has_render_support:t.has_render_support,allow_dll_injections:t.allow_dll_injections,ri_disabled:o}),!s&&t.allow_dll_injections?await this.injectGameModules(t,e):this.logger.log(`Skipping game module(s) injection`,{allow_dll_injections:t.allow_dll_injections,gm_disabled:s});let l={game:t.identifier,inGameRenderingSupported:c};this._activeReadyRavenGames[t.identifier]=l,this.logger.debug(`Active ready raven games`,Object.keys(this._activeReadyRavenGames).join(`, `)),this.logger.log(`Game Ready`),this.emit(`gameReadyInternal`,{ravenGame:t,process:e}),this.emit(`gameReady`,l),H.getInstance().track(`game_ready`,{game:t.identifier})}copyInjectors(){let e=this.copyDll(Jt),t=this.copyDll(Yt);return!e||!t?(this.logger.error(`Failed to copy injector executables`),!1):g.dirname(e)}copyDll(e){let t=g.basename(e),n=ee(e),r=g.join(k(),`resources`),i=g.join(r,t);this.logger.info(`Copying`,n,`to`,i);try{b(r)||ie(r,{recursive:!0}),se(i,ae(n)),ne(n,i)}catch(e){return e.code===`EBUSY`?i:(this.logger.error(`Failed to copy`,e),this.logger.error(`Failed to copy`,{originalPath:n,targetPath:i}),!1)}return i}async injectRenderInterface(e){this.logger.log(`Injecting render interface`,{is32Bit:e.is32Bit,process:e});let t=e.is32Bit?qt:Kt;this.logger.log(`Render hook path`,t);let n=this.copyDll(t);if(!n)return this.logger.error(`Failed to copy render hook DLL`,{renderHookPath:t}),!1;let r=this.copyInjectors();if(!r)return!1;this.logger.log(`Resolved injector path`,r);try{return this.logger.log(`Injecting render interface`,n),await e.injectDll(n,r),this.logger.log(`Render Interface Injection Successful`,n),!0}catch(e){return this.logger.error(`Render Interface Injection Failed`,e),this.logger.error(`Render Interface Injection Failed`,{renderHookPathCopied:n}),!1}}async injectGameModules(e,t){let n=this.copyInjectors();if(n){this.logger.log(`Resolved injector path`,n);for(let r of e.modules){let e=await Wt.getInstance().getDllFile(r);if(!e){this.logger.error(`No DLL file found for module`,{moduleId:r});continue}try{this.logger.log(`Injecting game module`,e),await t.injectDll(e,n),this.logger.log(`Injection Successful`,e)}catch(t){this.logger.error(`Injection Failed`,{dllFile:e},t)}}}}onProcessDestroy({process:e}){let t=this.getRavenGame(e);t&&(delete this._activeReadyRavenGames[t.identifier],this.logger.debug(`Active ready raven games`,Object.keys(this._activeReadyRavenGames).join(`, `)),this.emit(`gameCloseInternal`,{ravenGame:t,process:e}),this.emit(`gameClose`,{game:t.identifier}),H.getInstance().track(`game_close`,{game:t.identifier}))}getRavenGame(e){if(!e.name)return;let t=z.getInstance().getExecutableData(e.name);if(!t){this.logger.error(`No raven game found for process`,{process:e});return}return t}}),Xt=E(class extends et{boundOnGameLaunch=this.onGameLaunch.bind(this);constructor(){super(`GameBuildManager`)}init(){super.init(),W.getInstance().on(`gameReadyInternal`,this.boundOnGameLaunch)}destroy(){W.getInstance().off(`gameReadyInternal`,this.boundOnGameLaunch),super.destroy()}async onGameLaunch(...e){let[{ravenGame:t,process:n}]=e;if(!n.path||!n.name){this.logger.error(`Process path or name not found, could not check for build hash`,void 0,n);return}let r=ae(n.path),i=ue(`sha256`).update(r).digest(`hex`);this.logger.log(`Process Path`,n.path),this.logger.log(`Process Name`,n.name),this.logger.log(`Build Hash`,i);let a=!1;try{a=(await Tt(t.identifier,i)).data.upload}catch(e){this.logger.error(`Error checking game build hash`,e);return}if(!a){this.logger.log(`Build hash already exists, skipping upload`);return}let o=new le;o.file(n.name,r);let s=await o.generateAsync({type:`blob`});try{this.logger.log(`Uploading build (size: `,s.size,` bytes)`);let e=new Ae(s,{chunkSizeMb:25,maxConcurrent:1}),n=await Et(t.identifier,{build_hash:i,chunk_count:e.totalChunks,file_size_bytes:s.size});await e.chunk(async(e,r)=>{this.logger.log(`Uploading chunk`,r),await Dt(t.identifier,{chunk:e,build_hash:i,chunk_index:r,upload_token:n.data.upload_token})}),this.logger.log(`Build uploaded successfully`)}catch(e){At(e)?jt(e.response)?this.logger.error(`Error uploading build hash, api error`,e):this.logger.error(`Error uploading build hash, request error`,e):this.logger.error(`Error uploading build hash, unknown error`,e)}}}),Zt=E(class extends et{constructor(){super(`CampaignManager`)}async check(e){let t=g.join(Te(e),`campaign_code.txt`);try{let e=(await S.readFile(t,`utf-8`)).trim().replace(/ \(\d+\)/g,``);e&&(this.logger.log(`UTM campaign code found`,e),H.getInstance().track(`utm_attribution`,{campaign_code:e}),H.getInstance().flush())}catch{}}}),Qt=new O({path:p.normalize(`${process.env.APPDATA||process.env.HOME||`.`}/.overlayed/config.json`),default:void 0,schema:n({Account:r({email:`string`,apiKey:`string`})}).type({currentAccount:`Account | undefined`,accounts:`Account[]`}).or(`undefined`)});function G(e,t){return`${e}:${t}`}function $t(e,t,n){return e.reduce((e,r)=>{let i=r.key;return e[i]={on(e,n){let r=G(i,e),a=t.get(r)??new Set;a.add(n),t.set(r,a)},onAny(e){let n=G(i,`*`),r=t.get(n)??new Set;r.add(e),t.set(n,r)},off(e,n){let r=G(i,e),a=t.get(r);a&&(a.delete(n),a.size===0&&t.delete(r))},offAny(e){let n=G(i,`*`),r=t.get(n);r&&(r.delete(e),r.size===0&&t.delete(n))},readyForGameEvents:()=>{n.emit(`flushEvents`,i)}},e},{})}function en(){let e=D.getInstance(),t=W.getInstance();return{on:(n,r)=>{switch(n){case`fatal`:e.on(`fatal`,r);break;case`error`:e.on(`error`,r);break;case`warning`:e.on(`warning`,r);break;case`gameLaunch`:t.on(`gameLaunch`,r);break;case`gameClose`:t.on(`gameClose`,r);break;case`gameReady`:t.on(`gameReady`,r);break;default:throw Error(`Event type not implemented ${n}`,{cause:[n,r]})}},off:(n,r)=>{switch(n){case`fatal`:e.off(`fatal`,r);break;case`error`:e.off(`error`,r);break;case`warning`:e.off(`warning`,r);break;case`gameLaunch`:t.off(`gameLaunch`,r);break;case`gameClose`:t.off(`gameClose`,r);break;case`gameReady`:t.off(`gameReady`,r);break;default:throw Error(`Event type not implemented ${n}`,{cause:[n,r]})}}}}var K=function(e){return e[e.LeftButton=1]=`LeftButton`,e[e.RightButton=2]=`RightButton`,e[e.Cancel=3]=`Cancel`,e[e.MiddleButton=4]=`MiddleButton`,e[e.ExtraButton1=5]=`ExtraButton1`,e[e.ExtraButton2=6]=`ExtraButton2`,e[e.Back=8]=`Back`,e[e.Tab=9]=`Tab`,e[e.Clear=12]=`Clear`,e[e.Return=13]=`Return`,e[e.Shift=16]=`Shift`,e[e.Control=17]=`Control`,e[e.Menu=18]=`Menu`,e[e.Pause=19]=`Pause`,e[e.CapsLock=20]=`CapsLock`,e[e.Kana=21]=`Kana`,e[e.Hangeul=21]=`Hangeul`,e[e.Hangul=21]=`Hangul`,e[e.Junja=23]=`Junja`,e[e.Final=24]=`Final`,e[e.Hanja=25]=`Hanja`,e[e.Kanji=25]=`Kanji`,e[e.Escape=27]=`Escape`,e[e.Convert=28]=`Convert`,e[e.NonConvert=29]=`NonConvert`,e[e.Accept=30]=`Accept`,e[e.ModeChange=31]=`ModeChange`,e[e.Space=32]=`Space`,e[e.Prior=33]=`Prior`,e[e.Next=34]=`Next`,e[e.End=35]=`End`,e[e.Home=36]=`Home`,e[e.Left=37]=`Left`,e[e.Up=38]=`Up`,e[e.Right=39]=`Right`,e[e.Down=40]=`Down`,e[e.Select=41]=`Select`,e[e.Print=42]=`Print`,e[e.Execute=43]=`Execute`,e[e.Snapshot=44]=`Snapshot`,e[e.Insert=45]=`Insert`,e[e.Delete=46]=`Delete`,e[e.Help=47]=`Help`,e[e.N0=48]=`N0`,e[e.N1=49]=`N1`,e[e.N2=50]=`N2`,e[e.N3=51]=`N3`,e[e.N4=52]=`N4`,e[e.N5=53]=`N5`,e[e.N6=54]=`N6`,e[e.N7=55]=`N7`,e[e.N8=56]=`N8`,e[e.N9=57]=`N9`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.LeftWindows=91]=`LeftWindows`,e[e.RightWindows=92]=`RightWindows`,e[e.Application=93]=`Application`,e[e.Sleep=95]=`Sleep`,e[e.Numpad0=96]=`Numpad0`,e[e.Numpad1=97]=`Numpad1`,e[e.Numpad2=98]=`Numpad2`,e[e.Numpad3=99]=`Numpad3`,e[e.Numpad4=100]=`Numpad4`,e[e.Numpad5=101]=`Numpad5`,e[e.Numpad6=102]=`Numpad6`,e[e.Numpad7=103]=`Numpad7`,e[e.Numpad8=104]=`Numpad8`,e[e.Numpad9=105]=`Numpad9`,e[e.Multiply=106]=`Multiply`,e[e.Add=107]=`Add`,e[e.Separator=108]=`Separator`,e[e.Subtract=109]=`Subtract`,e[e.Decimal=110]=`Decimal`,e[e.Divide=111]=`Divide`,e[e.F1=112]=`F1`,e[e.F2=113]=`F2`,e[e.F3=114]=`F3`,e[e.F4=115]=`F4`,e[e.F5=116]=`F5`,e[e.F6=117]=`F6`,e[e.F7=118]=`F7`,e[e.F8=119]=`F8`,e[e.F9=120]=`F9`,e[e.F10=121]=`F10`,e[e.F11=122]=`F11`,e[e.F12=123]=`F12`,e[e.F13=124]=`F13`,e[e.F14=125]=`F14`,e[e.F15=126]=`F15`,e[e.F16=127]=`F16`,e[e.F17=128]=`F17`,e[e.F18=129]=`F18`,e[e.F19=130]=`F19`,e[e.F20=131]=`F20`,e[e.F21=132]=`F21`,e[e.F22=133]=`F22`,e[e.F23=134]=`F23`,e[e.F24=135]=`F24`,e[e.NumLock=144]=`NumLock`,e[e.ScrollLock=145]=`ScrollLock`,e[e.NEC_Equal=146]=`NEC_Equal`,e[e.Fujitsu_Jisho=146]=`Fujitsu_Jisho`,e[e.Fujitsu_Masshou=147]=`Fujitsu_Masshou`,e[e.Fujitsu_Touroku=148]=`Fujitsu_Touroku`,e[e.Fujitsu_Loya=149]=`Fujitsu_Loya`,e[e.Fujitsu_Roya=150]=`Fujitsu_Roya`,e[e.LeftShift=160]=`LeftShift`,e[e.RightShift=161]=`RightShift`,e[e.LeftControl=162]=`LeftControl`,e[e.RightControl=163]=`RightControl`,e[e.LeftMenu=164]=`LeftMenu`,e[e.RightMenu=165]=`RightMenu`,e[e.BrowserBack=166]=`BrowserBack`,e[e.BrowserForward=167]=`BrowserForward`,e[e.BrowserRefresh=168]=`BrowserRefresh`,e[e.BrowserStop=169]=`BrowserStop`,e[e.BrowserSearch=170]=`BrowserSearch`,e[e.BrowserFavorites=171]=`BrowserFavorites`,e[e.BrowserHome=172]=`BrowserHome`,e[e.VolumeMute=173]=`VolumeMute`,e[e.VolumeDown=174]=`VolumeDown`,e[e.VolumeUp=175]=`VolumeUp`,e[e.MediaNextTrack=176]=`MediaNextTrack`,e[e.MediaPrevTrack=177]=`MediaPrevTrack`,e[e.MediaStop=178]=`MediaStop`,e[e.MediaPlayPause=179]=`MediaPlayPause`,e[e.LaunchMail=180]=`LaunchMail`,e[e.LaunchMediaSelect=181]=`LaunchMediaSelect`,e[e.LaunchApplication1=182]=`LaunchApplication1`,e[e.LaunchApplication2=183]=`LaunchApplication2`,e[e.OEM1=186]=`OEM1`,e[e.OEMPlus=187]=`OEMPlus`,e[e.OEMComma=188]=`OEMComma`,e[e.OEMMinus=189]=`OEMMinus`,e[e.OEMPeriod=190]=`OEMPeriod`,e[e.OEM2=191]=`OEM2`,e[e.OEM3=192]=`OEM3`,e[e.OEM4=219]=`OEM4`,e[e.OEM5=220]=`OEM5`,e[e.OEM6=221]=`OEM6`,e[e.OEM7=222]=`OEM7`,e[e.OEM8=223]=`OEM8`,e[e.OEMAX=225]=`OEMAX`,e[e.OEM102=226]=`OEM102`,e[e.ICOHelp=227]=`ICOHelp`,e[e.ICO00=228]=`ICO00`,e[e.ProcessKey=229]=`ProcessKey`,e[e.ICOClear=230]=`ICOClear`,e[e.Packet=231]=`Packet`,e[e.OEMReset=233]=`OEMReset`,e[e.OEMJump=234]=`OEMJump`,e[e.OEMPA1=235]=`OEMPA1`,e[e.OEMPA2=236]=`OEMPA2`,e[e.OEMPA3=237]=`OEMPA3`,e[e.OEMWSCtrl=238]=`OEMWSCtrl`,e[e.OEMCUSel=239]=`OEMCUSel`,e[e.OEMATTN=240]=`OEMATTN`,e[e.OEMFinish=241]=`OEMFinish`,e[e.OEMCopy=242]=`OEMCopy`,e[e.OEMAuto=243]=`OEMAuto`,e[e.OEMENLW=244]=`OEMENLW`,e[e.OEMBackTab=245]=`OEMBackTab`,e[e.ATTN=246]=`ATTN`,e[e.CRSel=247]=`CRSel`,e[e.EXSel=248]=`EXSel`,e[e.EREOF=249]=`EREOF`,e[e.Play=250]=`Play`,e[e.Zoom=251]=`Zoom`,e[e.Noname=252]=`Noname`,e[e.PA1=253]=`PA1`,e[e.OEMClear=254]=`OEMClear`,e}(K||{});const tn=new Map([[K.LeftButton,`LeftButton`],[K.RightButton,`RightButton`],[K.Cancel,`Cancel`],[K.MiddleButton,`MiddleButton`],[K.ExtraButton1,`ExtraButton1`],[K.ExtraButton2,`ExtraButton2`],[K.Back,`Backspace`],[K.Tab,`Tab`],[K.Clear,`Clear`],[K.Return,`Enter`],[K.Shift,`ShiftLeft`],[K.Control,`ControlLeft`],[K.Menu,`AltLeft`],[K.Pause,`Pause`],[K.CapsLock,`CapsLock`],[K.Kana,`KanaMode`],[K.Junja,`JunjaMode`],[K.Final,`Finalize`],[K.Hanja,`HanjaMode`],[K.Escape,`Escape`],[K.Convert,`Convert`],[K.NonConvert,`NonConvert`],[K.Accept,`Accept`],[K.ModeChange,`ModeChange`],[K.Space,`Space`],[K.Prior,`PageUp`],[K.Next,`PageDown`],[K.End,`End`],[K.Home,`Home`],[K.Left,`ArrowLeft`],[K.Up,`ArrowUp`],[K.Right,`ArrowRight`],[K.Down,`ArrowDown`],[K.Select,`Select`],[K.Print,`PrintScreen`],[K.Execute,`Execute`],[K.Snapshot,`Snapshot`],[K.Insert,`Insert`],[K.Delete,`Delete`],[K.Help,`Help`],[K.N0,`Digit0`],[K.N1,`Digit1`],[K.N2,`Digit2`],[K.N3,`Digit3`],[K.N4,`Digit4`],[K.N5,`Digit5`],[K.N6,`Digit6`],[K.N7,`Digit7`],[K.N8,`Digit8`],[K.N9,`Digit9`],[K.A,`KeyA`],[K.B,`KeyB`],[K.C,`KeyC`],[K.D,`KeyD`],[K.E,`KeyE`],[K.F,`KeyF`],[K.G,`KeyG`],[K.H,`KeyH`],[K.I,`KeyI`],[K.J,`KeyJ`],[K.K,`KeyK`],[K.L,`KeyL`],[K.M,`KeyM`],[K.N,`KeyN`],[K.O,`KeyO`],[K.P,`KeyP`],[K.Q,`KeyQ`],[K.R,`KeyR`],[K.S,`KeyS`],[K.T,`KeyT`],[K.U,`KeyU`],[K.V,`KeyV`],[K.W,`KeyW`],[K.X,`KeyX`],[K.Y,`KeyY`],[K.Z,`KeyZ`],[K.LeftWindows,`MetaLeft`],[K.RightWindows,`MetaRight`],[K.Application,`ContextMenu`],[K.Sleep,`Sleep`],[K.Numpad0,`Numpad0`],[K.Numpad1,`Numpad1`],[K.Numpad2,`Numpad2`],[K.Numpad3,`Numpad3`],[K.Numpad4,`Numpad4`],[K.Numpad5,`Numpad5`],[K.Numpad6,`Numpad6`],[K.Numpad7,`Numpad7`],[K.Numpad8,`Numpad8`],[K.Numpad9,`Numpad9`],[K.Multiply,`NumpadMultiply`],[K.Add,`NumpadAdd`],[K.Separator,`NumpadSeparator`],[K.Subtract,`NumpadSubtract`],[K.Decimal,`NumpadDecimal`],[K.Divide,`NumpadDivide`],[K.F1,`F1`],[K.F2,`F2`],[K.F3,`F3`],[K.F4,`F4`],[K.F5,`F5`],[K.F6,`F6`],[K.F7,`F7`],[K.F8,`F8`],[K.F9,`F9`],[K.F10,`F10`],[K.F11,`F11`],[K.F12,`F12`],[K.F13,`F13`],[K.F14,`F14`],[K.F15,`F15`],[K.F16,`F16`],[K.F17,`F17`],[K.F18,`F18`],[K.F19,`F19`],[K.F20,`F20`],[K.F21,`F21`],[K.F22,`F22`],[K.F23,`F23`],[K.F24,`F24`],[K.NumLock,`NumLock`],[K.ScrollLock,`ScrollLock`],[K.NEC_Equal,`NEC_Equal`],[K.Fujitsu_Masshou,`Fujitsu_Masshou`],[K.Fujitsu_Touroku,`Fujitsu_Touroku`],[K.Fujitsu_Loya,`Fujitsu_Loya`],[K.Fujitsu_Roya,`Fujitsu_Roya`],[K.LeftShift,`ShiftLeft`],[K.RightShift,`ShiftRight`],[K.LeftControl,`ControlLeft`],[K.RightControl,`ControlRight`],[K.LeftMenu,`AltLeft`],[K.RightMenu,`AltRight`],[K.BrowserBack,`BrowserBack`],[K.BrowserForward,`BrowserForward`],[K.BrowserRefresh,`BrowserRefresh`],[K.BrowserStop,`BrowserStop`],[K.BrowserSearch,`BrowserSearch`],[K.BrowserFavorites,`BrowserFavorites`],[K.BrowserHome,`BrowserHome`],[K.VolumeMute,`VolumeMute`],[K.VolumeDown,`VolumeDown`],[K.VolumeUp,`VolumeUp`],[K.MediaNextTrack,`MediaTrackNext`],[K.MediaPrevTrack,`MediaTrackPrevious`],[K.MediaStop,`MediaStop`],[K.MediaPlayPause,`MediaPlayPause`],[K.LaunchMail,`LaunchMail`],[K.LaunchMediaSelect,`LaunchMediaSelect`],[K.LaunchApplication1,`LaunchApplication1`],[K.LaunchApplication2,`LaunchApplication2`],[K.OEM1,`OEM_1`],[K.OEMPlus,`Equal`],[K.OEMComma,`Comma`],[K.OEMMinus,`Minus`],[K.OEMPeriod,`Period`],[K.OEM2,`Slash`],[K.OEM3,`Backquote`],[K.OEM4,`BracketLeft`],[K.OEM5,`Backslash`],[K.OEM6,`BracketRight`],[K.OEM7,`Quote`],[K.OEM8,`IntlRo`],[K.OEMAX,`OEM_AX`],[K.OEM102,`IntlBackslash`],[K.ICOHelp,`ICO_HELP`],[K.ICO00,`ICO_00`],[K.ProcessKey,`Process`],[K.ICOClear,`ICO_CLEAR`],[K.Packet,`Packet`],[K.OEMReset,`OEM_Reset`],[K.OEMJump,`OEM_Jump`],[K.OEMPA1,`OEM_PA1`],[K.OEMPA2,`OEM_PA2`],[K.OEMPA3,`OEM_PA3`],[K.OEMWSCtrl,`OEM_WS_Ctrl`],[K.OEMCUSel,`OEM_CU_Sel`],[K.OEMATTN,`OEM_ATTN`],[K.OEMFinish,`OEM_Finish`],[K.OEMCopy,`OEM_Copy`],[K.OEMAuto,`OEM_Auto`],[K.OEMENLW,`OEM_ENLW`],[K.OEMBackTab,`BackTab`],[K.ATTN,`ATTN`],[K.CRSel,`CRSel`],[K.EXSel,`EXSel`],[K.EREOF,`EREOF`],[K.Play,`MediaPlay`],[K.Zoom,`Zoom`],[K.Noname,`Noname`],[K.PA1,`PA1`],[K.OEMClear,`OEM_Clear`]]),nn=new Map(tn.entries().map(([e,t])=>[t,e])),rn=r({"[string]":{keys:`string[]`,mode:r(`'toggle' | 'hold'`).pipe(e=>e??`toggle`)}});var an=class extends M{preferencesKeybindToCallbacks=new Map;pressedKeys=new Set;activeKeybinds=new Set;triggeredToggleKeybinds=new Set;boundHandleKeyboardFocus=this.handleKeyboardFocus.bind(this);boundHandleKeyDown=this.handleKeyDown.bind(this);boundHandleKeyUp=this.handleKeyUp.bind(this);keybindsFile;keybindListeningPaused=!1;constructor(e){super(`KeybindManager`),this.keybindsFile=new O({path:Rt([`keybinds.json`]),schema:rn,default:e})}init(){super.init();let e=V.getInstance().getInterface(`OGG_SIEGE`);e.instance.on(`keyboardFocus`,this.boundHandleKeyboardFocus),e.instance.on(`keyDown`,this.boundHandleKeyDown),e.instance.on(`keyUp`,this.boundHandleKeyUp)}async onKeybindToggled(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.toggle.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindDown(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.down.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindUp(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.up.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async updateKeybind(e,t){this.keybindsFile.set({[e]:t})}async updateKeybinds(e){let t=Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0));this.keybindsFile.set({...this.keybindsFile.get(),...t})}getConfig(){return this.keybindsFile.get()}destroy(){let e=V.getInstance().getInterface(`OGG_SIEGE`);e.instance.off(`keyboardFocus`,this.boundHandleKeyboardFocus),e.instance.off(`keyDown`,this.boundHandleKeyDown),e.instance.off(`keyUp`,this.boundHandleKeyUp),super.destroy()}handleKeyDown(e){if(this.keybindListeningPaused)return;let t=tn.get(e.key);if(!t){this.logger.error(`Unknown key down`,e);return}this.pressedKeys.add(t),this.checkKeybindings()}handleKeyboardFocus(){this.pressedKeys.clear(),this.activeKeybinds.clear(),this.triggeredToggleKeybinds.clear()}async handleKeyUp(e){if(this.keybindListeningPaused)return;let t=tn.get(e.key);if(!t)return;this.pressedKeys.delete(t);let n=this.keybindsFile.get();for(let[e]of this.preferencesKeybindToCallbacks.entries())n[e].keys.includes(t)&&this.triggeredToggleKeybinds.delete(e);this.checkKeybindUps()}async checkKeybindUps(){let e=this.keybindsFile.get();for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){if(!n.up||n.up.length===0)continue;let r=e[t];if(this.activeKeybinds.has(t)&&r.keys.some(e=>!this.pressedKeys.has(e))){this.activeKeybinds.delete(t);for(let e of n.up)e();this.logger.log(`Keybind up triggered`,this.getKeybindToString(r))}}}async checkKeybindings(){let e=this.keybindsFile.get();for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t];if(r.keys.length===this.pressedKeys.size&&r.keys.every(e=>nn.has(e)?this.pressedKeys.has(e):!1)){this.triggerKeybind(r,n,t);return}}for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t];r.keys.every(e=>nn.has(e)?this.pressedKeys.has(e):(this.logger.error(`Unknown key`,e,r),!1))&&this.triggerKeybind(r,n,t)}}triggerKeybind(e,t,n){let r=e.mode;if(r===`toggle`&&t.toggle&&t.toggle.length>0&&!this.triggeredToggleKeybinds.has(n)){let r;for(let e of t.toggle){let t=e();typeof t==`string`&&r===void 0&&(r=t)}this.triggeredToggleKeybinds.add(n),this.logger.log(r?`Keybind pressed rejected: ${r}`:`Keybind pressed accepted`,this.getKeybindToString(e))}if(r===`hold`&&t.down&&t.down.length>0&&!this.activeKeybinds.has(n)){let r;for(let e of t.down){let t=e();if(typeof t==`string`){r=t;break}}r?this.logger.log(`Keybind down rejected: ${r}`,this.getKeybindToString(e)):(this.activeKeybinds.add(n),this.logger.log(`Keybind down accepted`,this.getKeybindToString(e)))}}getKeybindToString(e){return`(${e.keys.join(`+`)}${e.mode?` ${e.mode}`:``})`}};function on(e){let t=new an(e),n={};for(let r in e)n[r]={on:(e,n)=>{switch(e){case`down`:t.onKeybindDown(r,n);break;case`up`:t.onKeybindUp(r,n);break;case`toggle`:t.onKeybindToggled(r,n);break;default:throw Error(`Event type not implemented ${e}`,{cause:[e,n]})}}};let r={...n,getConfig:()=>t.getConfig(),pauseKeybindListening:()=>{t.keybindListeningPaused=!0},resumeKeybindListening:()=>{t.keybindListeningPaused=!1},updateKeybind:(e,n)=>{t.updateKeybind(e,n)},updateKeybinds:e=>{t.updateKeybinds(e)}};return t.init(),C.on(`quit`,()=>{t.destroy()}),r}function q(){return V.getInstance().getInterface(`OGG_SIEGE`)}function sn(){let e=W.getInstance(),t=D.getInstance(),n=H.getInstance();if(!C.isPackaged){A.getInstance().info(`Cortex is disabled in development`),n.enabled=!1;return}try{n.meta=cn()}catch(e){A.getInstance().error(`Failed to setup cortex`,e);return}e.on([`gameReady`,`gameClose`],()=>{n.meta||=cn(),n.meta.in_game=e.isInGame}),t.on(`fatal`,e=>{n.track(`fatal`,{message:e.message,code:e.code,data:JSON.stringify(e.data)})}),t.on(`error`,e=>{n.track(`error`,{code:e.code,message:e.message,data:JSON.stringify(e.data)})}),t.on(`warning`,e=>{n.track(`warning`,{message:e.message,code:e.code,data:JSON.stringify(e.data)})})}function cn(){if(!global.OVERLAYED_META.release.id)throw Error(`Release ID is required`);return{app_id:global.OVERLAYED.APPLICATION_ID,user_id:I(),release_id:global.OVERLAYED_META.release.id,app_channel:global.OVERLAYED.APP_BUILD_CHANNEL,app_version:global.OVERLAYED.APP_VERSION,package_version:global.OVERLAYED.PACKAGE_VERSION,frontend_version:global.OVERLAYED.FRONTEND_VERSION,frontend_release_id:global.OVERLAYED.FRONTEND_RELEASE_ID,session_id:global.OVERLAYED.sessionId,in_game:!1}}const J=E(class extends M{CHECK_INTERVAL=1e3*60*15;RETRY_INTERVAL=1e3*15;_updateCheckInterval=null;_latestCheckResponse=null;_activeCheckResponse=null;initialReleaseId=null;get manualUpdatesEnabled(){return this.options?.manualUpdates??!1}get activeReleaseId(){return this._activeCheckResponse?.release_id??this.initialReleaseId}constructor(){super(`SiteManager`)}init(e){super.init(e),e?.manualUpdates&&this.enableManualUpdates()}destroy(){super.destroy(),this._updateCheckInterval&&=(clearInterval(this._updateCheckInterval),null)}allowSiteUpdateOnNextLoad(){if(!this.options?.manualUpdates){this.logger.warn(`allowSiteUpdateOnNextLoad called but manual updates are disabled`);return}if(!this._latestCheckResponse){this.logger.warn(`allowSiteUpdateOnNextLoad called but no update has been checked yet`);return}if(this._activeCheckResponse?.release_id===this._latestCheckResponse.release_id){this.logger.warn(`allowSiteUpdateOnNextLoad called but theres no update available`);return}this._activeCheckResponse=this._latestCheckResponse,H.getInstance().track(`site_update_applied`,{version:this._latestCheckResponse.version,release_id:this._latestCheckResponse.release_id}),this.setFrontendCortexMeta(this._latestCheckResponse.release_id,this._latestCheckResponse.version)}setFrontendCortexMeta(e,t){let n=H.getInstance();n.meta||=cn(),e&&(global.OVERLAYED.FRONTEND_RELEASE_ID=e,n.meta.frontend_release_id=e),t&&(global.OVERLAYED.FRONTEND_VERSION=t,n.meta.frontend_version=t),e&&t&&n.track(`frontend_version_changed`,{version:t,release_id:e})}enableManualUpdates(){this.logger.log(`Enabling manual site updates`),this.checkForUpdates(),this._updateCheckInterval=setInterval(()=>{this.checkForUpdates(!0)},this.CHECK_INTERVAL)}async checkForUpdates(e=!1){let t=global.OVERLAYED_META?.application?.siteUrl;if(!t){this.logger.log(`No siteUrl configured, skipping check`);return}H.getInstance().track(`site_check_for_update`,{});try{let n=new URL(`/check`,t).toString();this.logger.log(`Checking site URL`,n);let r={"Overlayed-User-Agent":ot({package_version:global.OVERLAYED.PACKAGE_VERSION,application_id:global.OVERLAYED.APPLICATION_ID,application_version:global.OVERLAYED.APP_VERSION}),"Overlayed-Cortex-User-Id":global.OVERLAYED_RUNTIME.userId},i=L();i&&(r[`Overlayed-Access-Token`]=i);let a=global.OVERLAYED_META.release.channelId;a&&(r[`Overlayed-Channel-Id`]=a);let o=await fetch(n,{headers:r});if(!o.ok){this.logger.warn(`Site check failed with status`,o.status),H.getInstance().track(`site_check_error`,{status:o.status}),e&&this.scheduleRetry();return}let s=await o.json();if(this.logger.log(`Site check response`,s),!s.release_id){this.logger.error(`Site check response missing release_id`);return}if(!this._latestCheckResponse){this._latestCheckResponse=s;return}return this._latestCheckResponse.release_id===s.release_id?void 0:(this.logger.log(`New site version detected`,s),this._latestCheckResponse=s,H.getInstance().track(`site_update_ready`,{version:s.version,release_id:s.release_id}),this.emit(`siteUpdateReady`,{releaseId:s.release_id,version:s.version}),s)}catch(e){let t=e instanceof Error?e.message:String(e);H.getInstance().track(`site_check_error`,{message:t}),this.logger.error(`Site check failed`,{error:e,message:t}),this.scheduleRetry()}}scheduleRetry(){setTimeout(()=>{this.checkForUpdates()},this.RETRY_INTERVAL)}}),ln=E(ke,`browser-windows.log`);let un;function dn(){return un||(un=class e extends global.OVERLAYED.electron.BrowserWindow{static session=void 0;constructor(t){let n=e.resolveCustomOptions(t);super(n)}static resolveCustomOptions(t){let n=global.OVERLAYED_META,r=global.OVERLAYED_RUNTIME;return{...t,webPreferences:{...t.webPreferences,session:e.getSession(),additionalArguments:[...t.webPreferences?.additionalArguments||[],...global.OVERLAYED.electron.app.isPackaged?[]:[`--overlayed-meta=${JSON.stringify(n)}`],`--overlayed-runtime=${JSON.stringify(r)}`]}}}static getSession(){if(!global.OVERLAYED_META?.application?.siteUrl)return;if(e.session)return e.session;e.session=global.OVERLAYED.electron.session.fromPartition(`persist:overlayed-${global.OVERLAYED.APPLICATION_ID}`);let t=J.getInstance(),n=ot({package_version:global.OVERLAYED.PACKAGE_VERSION,application_id:global.OVERLAYED.APPLICATION_ID,application_version:global.OVERLAYED.APP_VERSION}),r={urls:[global.OVERLAYED_META.application.siteUrl+`/*`]},i=global.OVERLAYED_RUNTIME.userId;return e.session.webRequest.onBeforeSendHeaders(r,(e,r)=>{let a=L();a&&(e.requestHeaders[`Overlayed-Access-Token`]=a);let o=global.OVERLAYED_META.release.channelId;o&&(e.requestHeaders[`Overlayed-Channel-Id`]=o),t.manualUpdatesEnabled&&t.activeReleaseId&&(e.requestHeaders[`Overlayed-Release-Id`]=t.activeReleaseId),e.requestHeaders[`Overlayed-Cortex-User-Id`]=i,e.requestHeaders[`Overlayed-User-Agent`]=n,r({requestHeaders:e.requestHeaders})}),t.manualUpdatesEnabled&&e.session.webRequest.onHeadersReceived(r,(e,n)=>{if(t.initialReleaseId){n(e);return}let r=e.responseHeaders?.[`Overlayed-Release-Id`]?.[0];r&&(t.initialReleaseId=P(r));let i=e.responseHeaders?.[`Overlayed-Release-Version`]?.[0];t.setFrontendCortexMeta(r,i),n(e)}),e.session}},un)}function fn(){function e(e,t){let n=ln.getInstance();return e.once(`closed`,()=>{e.isDestroyed()||H.getInstance().track(`window_closed`,{url:e.webContents.getURL(),in_game:t})}),e.on(`unresponsive`,()=>{e.isDestroyed()||H.getInstance().track(`window_unresponsive`,{url:e.webContents.getURL(),in_game:t})}),e.webContents.on(`console-message`,(t,r,i,a,o)=>{let s=e.isDestroyed()?`destroyed`:e.webContents.getURL();n[r===3?`error`:r===2?`warn`:`log`](`[${s}] [${o}:${a}] ${i}`)}),H.getInstance().track(`window_created`,{url:e.webContents.getURL(),in_game:t}),e}return{getProductionSiteUrl:()=>{let e=global.OVERLAYED_META.application.siteUrl;return URL.canParse(e)?new URL(e):new URL(`https://default.overlayedapps.com`)},createWindow:t=>e(new(dn())(t),!1),createInGameWindow:t=>{let n=dn();return e(q().instance.newWindowInternal(n,t),!0)},on:(e,t)=>q().instance.on(e,t),off:(e,t)=>q().instance.off(e,t),once:(e,t)=>q().instance.once(e,t),addListener:(e,t)=>q().instance.addListener(e,t),removeListener:(e,t)=>q().instance.removeListener(e,t),removeAllListeners:()=>q().instance.removeAllListeners(),prependListener:(e,t)=>q().instance.prependListener(e,t),prependOnceListener:(e,t)=>q().instance.prependOnceListener(e,t),getActiveGameInfo:()=>{let e=q(),t=Ue.getInstance();return{resolution:e.resolution,isConnected:t.hasConnection}}}}const pn=E(class extends et{renderInterface;globalCursorOverrideCount=new Set;globalMouseBlockCount=new Set;globalKeyboardBlockCount=new Set;keyInputBlocks={};constructor(e){super(`OverridesManager`),this.renderInterface=V.getInstance().getInterface(e)}scope(e){return{setGlobalCursorOverride:t=>this.setGlobalCursorOverride(e,t),setGlobalMouseBlock:t=>this.setGlobalMouseBlock(e,t),setGlobalKeyboardBlock:t=>this.setGlobalKeyboardBlock(e,t),setKeyInputBlock:(t,n)=>this.setKeyInputBlock(e,t,n)}}setGlobalCursorOverride(e,t){t?this.globalCursorOverrideCount.add(e):this.globalCursorOverrideCount.delete(e),t&&this.globalCursorOverrideCount.size===1?this.renderInterface.instance.setGlobalCursorOverride(!0):!t&&this.globalCursorOverrideCount.size===0&&this.renderInterface.instance.setGlobalCursorOverride(!1)}setGlobalMouseBlock(e,t){t?this.globalMouseBlockCount.add(e):this.globalMouseBlockCount.delete(e),t&&this.globalMouseBlockCount.size===1?this.renderInterface.instance.setGlobalMouseBlock(!0):!t&&this.globalMouseBlockCount.size===0&&this.renderInterface.instance.setGlobalMouseBlock(!1)}setGlobalKeyboardBlock(e,t){t?this.globalKeyboardBlockCount.add(e):this.globalKeyboardBlockCount.delete(e),t&&this.globalKeyboardBlockCount.size===1?this.renderInterface.instance.setGlobalKeyboardBlock(!0):!t&&this.globalKeyboardBlockCount.size===0&&this.renderInterface.instance.setGlobalKeyboardBlock(!1)}setKeyInputBlock(e,t,n){this.keyInputBlocks[t]||(this.keyInputBlocks[t]=new Set),n?this.keyInputBlocks[t].add(e):this.keyInputBlocks[t].delete(e),n&&this.keyInputBlocks[t].size===1?this.renderInterface.instance.setKeyInputBlock(t,!0):!n&&this.keyInputBlocks[t].size===0&&this.renderInterface.instance.setKeyInputBlock(t,!1)}},`OGG_SIEGE`);function mn(){return{scope:e=>pn.getInstance().scope(e),raw:{setGlobalMouseBlock:e=>q().instance.setGlobalMouseBlock(e),setGlobalKeyboardBlock:e=>q().instance.setGlobalKeyboardBlock(e),setGlobalCursorOverride:e=>q().instance.setGlobalCursorOverride(e),setKeyInputBlock:(e,t)=>q().instance.setKeyInputBlock(e,t),getGlobalMouseBlock:()=>q().instance.getGlobalMouseBlock(),getGlobalKeyboardBlock:()=>q().instance.getGlobalKeyboardBlock(),getGlobalCursorOverride:()=>q().instance.getGlobalCursorOverride(),getKeyInputBlock:e=>q().instance.getKeyInputBlock(e)}}}function hn(){return{track:(e,t)=>{H.getInstance().track(`custom__${String(e)}`,t)}}}var gn=he(((e,t)=>{var n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),r=n((e,t)=>{var n=new Set([`mouseDown`,`mouseUp`,`pointerDown`,`pointerUp`]),r=new WeakSet;function i(e,t,{allowHosts:i}={}){let{shell:a}=t;if(r.has(e))return;r.add(e);let o=e.webContents;function s(e){return!!(!c(e)||i?.includes(e.host))}function c(e){return new URL(o.getURL()).origin!==e.origin}let l=0;function u(){l=Date.now()}function d(){let e=Date.now()-l,t=e<150;return t||console.warn(`was not recently active`,e),t}if(process.platform===`win32`)for(let t of Object.values({KEYDOWN:256,LBUTTONUP:514,MBUTTONUP:520,RBUTTONUP:517,XBUTTONUP:524,TOUCH:576}))e.hookWindowMessage(t,u);o.on(`input-event`,(e,t)=>{n.has(t.type)&&u()}),o.on(`will-navigate`,(e,t)=>{let n=e.url||t;if(console.log(`will-navigate`,n),!n)return;let r=new URL(n);if(!s(r)){if(!d()){console.log(`blocked navigation`,n),e.preventDefault();return}c(r)&&(console.log(`external navigation`,n),e.preventDefault(),a.openExternal(n))}}),o.session.on(`will-download`,(e,t)=>{let n=t.getURL();/^blob:/.test(n)||e.preventDefault()}),o.setWindowOpenHandler(e=>{console.log(`window-open`,e.url);let{url:t}=e,n=new URL(t);if(!s(n))return d()?(c(n)&&a.openExternal(e.url),{action:`deny`}):(console.log(`blocked navigation`,t),{action:`deny`})})}t.exports=i}),i=n((e,t)=>{var n=new Set([`Mozilla`,`AppleWebKit`,`Chrome`,`Safari`,`Gecko`,`Firefox`,`OPR`,`Edg`,`Version`,`Mobile`,`curl`,`PostmanRuntime`]);async function r(e,t,r){let{webContents:i}=e,a=await i.executeJavaScript(`navigator.userAgent`);a=a.match(/[^\/]+\/[^\s]+( \([^\)]+\))?/g).map(e=>e.trim()).filter(e=>{let[t]=e.split(`/`,1);return n.has(t)}).join(` `),i.setUserAgent(a),t.app.userAgentFallback=a}t.exports=r}),a=r(),o=i();function s(e,t,n={}){a(e,t,n.linkHandler),o(e,t,n.userAgent)}t.exports={setupRevUtils:s,setupLinkHandler:a,setUserAgent:o}}))();function _n(){return{registerWindow:e=>{(0,gn.setupRevUtils)(e,global.OVERLAYED.electron)}}}const vn=/(\d{4})-(\d{2})-(\d{2})\.log$/;function yn(e){let t=e.match(vn);if(!t)return!1;let[,n,r,i]=t,a=Number(n),o=Number(r),s=Number(i);if(o<1||o>12||s<1||s>31)return!1;let c=new Date(a,o-1,s);if(isNaN(c.getTime())||c.getFullYear()!==a||c.getMonth()!==o-1||c.getDate()!==s)return!1;let l=new Date;return l.setDate(l.getDate()-7),l.setHours(0,0,0,0),c>=l}function bn(e){let{silent:t=!1,additionalFiles:n}=e??{},r=Ee(global.OVERLAYED.APPLICATION_ID),i=je(r,{recursive:!0}),a=we(),o=je(a,{recursive:!0});t||(A.getInstance().info(`Logs path: `,r),A.getInstance().info(`Overlayed logs path: `,a));let s=new le;return i.forEach(([e,n])=>{t||A.getInstance().info(`Zipping: `,n);let r=re(n);s.file(_(n),r,{compression:`DEFLATE`})}),o.forEach(([e,n])=>{if(!yn(_(n))){t||A.getInstance().info(`Skipping old/unrecognized log: `,n);return}t||A.getInstance().info(`Zipping: `,n);let r=re(n);s.file(_(n),r,{compression:`DEFLATE`})}),n&&Object.entries(n).forEach(([e,n])=>{t||A.getInstance().info(`Zipping extra file: `,e),s.file(e,n,{compression:`DEFLATE`})}),s}async function xn(e,t,n){let r=global.OVERLAYED_META.release.id?P(global.OVERLAYED_META.release.id):void 0,i=I();return ht(global.OVERLAYED.APPLICATION_ID,{file:Buffer.from(n,`base64`),data:{release_id:r,type:e,cortex_user_id:i,...t}}).then(e=>(A.getInstance().info(`Feedback submitted`,e),e.data.id)).catch(e=>{console.error(JSON.stringify(e,null,2)),A.getInstance().error(`Failed to submit feedback`,e)})}function Sn(e){let t=new ke(`app.log`);return t.init(global.OVERLAYED.APPLICATION_ID,e.debug),{scope:e=>t.scope(e),info:e=>t.info(e),warn:e=>t.warn(e),error:e=>t.error(e),debug:e=>t.debug(e),submitFeedback:async(e,t,n)=>{let r=global.OVERLAYED_META.release.id?P(global.OVERLAYED_META.release.id):void 0;return r&&C.isPackaged&&H.getInstance().track(e===`bug_report`?`bug_report_submitted`:`suggestion_submitted`,{release_id:r}),await xn(e,t,await bn(n).generateAsync({type:`base64`}))},getLogsZip:e=>bn(e)}}const Cn=1e3;function wn(e,t,n,i,a){let o=Ue.getInstance(),s=A.getInstance().scope(`SetupPipeServer`);s.log(`Initializing`);function c(e,t){let r=n.get(t);if(!r)n.set(t,[e]);else{if(r.length>=Cn){D.getInstance().warn(`Event buffer full, removing oldest event`,`EVENT_BUFFER_FULL`,{summary:`Event buffer overflow for module ${t}. Buffer size: ${r.length}, max: ${Cn}`});return}r.push(e)}}function l(n){s.info(n);let i=zt(n);if(i instanceof r.errors){H.getInstance().track(`invalid_game_event`,{}),D.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:i.summary});return}let o=Qe.includes(i.type),l=e.modules.find(e=>e.key===`universal`),u=o?l:e.modules.find(e=>e.key===i.game);if(!u){s.warn(`Invalid module`,{module:o?`universal`:i.game});return}let d=u.events.event,f=d(n);if(f instanceof r.errors){if(`type`in f.byPath)return;s.warn(`Invalid event`,{summary:f.summary}),H.getInstance().track(`invalid_game_event`,{game:i.game,type:i.type,summary:f.summary}),D.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:f.summary});return}if(!a[u.key]){c(f,u.key);return}if(f.type===`unsupported_game_version`){let{content:e}=f;H.getInstance().track(`unsupported_game_version`,{game:f.game,hash:e.process_hash,version:e.game_version})}let p=G(u.key,f.type),m=G(u.key,`*`),h=t.get(p),g=t.get(m),_=[...Array.from(h??[]),...Array.from(g??[])];if(_.length===0){s.info(`No handlers found for event`,{event:f});return}_.forEach(e=>{e(f)})}return i.on(`flushEvents`,e=>{if(a[e])return;a[e]=!0;let t=n.get(e);t&&(A.getInstance().info(`Flushing ${t.length} events for module ${e}`),t.forEach(e=>l(e)),n.delete(e))}),o.on(`data`,e=>e.forEach(l)),o.on(`error`,e=>{s.error(`Pipe server error`,e),D.getInstance().error(`Pipe server error`,`PIPE_SERVER_ERROR`,{error:e})}),o.on(`connected`,()=>{s.log(`Pipe server connected`)}),o.on(`disconnected`,()=>{s.log(`Pipe server disconnected`)}),o}const Tn=E(class extends M{FETCH_INTERVAL=1e3*60*10;_fetchInterval=null;_flags=new Map;_overrides=new Map;_defaults=new Map;_boundOnGameReady=this.onGameEvent.bind(this);_boundOnGameClose=this.onGameEvent.bind(this);_readyResolve;ready;constructor(){super(`FeatureFlagManager`),this.ready=new Promise(e=>{this._readyResolve=e}),this.fetchFlags(),this.setupInterval(),W.getInstance().on(`gameReady`,this._boundOnGameReady),W.getInstance().on(`gameClose`,this._boundOnGameClose)}destroy(){this._fetchInterval&&=(clearInterval(this._fetchInterval),null),W.getInstance().off(`gameReady`,this._boundOnGameReady),W.getInstance().off(`gameClose`,this._boundOnGameClose),super.destroy()}setDefaults(e){this._defaults=new Map(Object.entries(e))}async refresh(){await this.fetchFlags()}override(e,t){let n=this.get(e);this._overrides.set(e,t),n!==t&&(this.emit(e,t),this.emit(`updated`,!0))}clearOverride(e){if(!this._overrides.has(e))return;let t=this.get(e);this._overrides.delete(e);let n=this.get(e);t!==n&&(this.emit(e,n),this.emit(`updated`,!0))}clearOverrides(){if(this._overrides.size===0)return;let e=new Map;for(let t of this._overrides.keys())e.set(t,this.get(t));this._overrides.clear();let t=!1;for(let[n,r]of e){let e=this.get(n);r!==e&&(this.emit(n,e),t=!0)}t&&this.emit(`updated`,!0)}isOverridden(e){return this._overrides.has(e)}getAllOverrides(){return Object.fromEntries(this._overrides)}inspect(e){let t=this._overrides.get(e),n=this._flags.get(e),r=this._defaults.get(e);return{effective:t??n??r??!1,override:t,actual:n,default:r}}get(e){let t=this._overrides.get(e),n=this._flags.get(e),r=this._defaults.get(e);return t??n??r??!1}getAll(){let e=Object.fromEntries(this._defaults);for(let[t,n]of this._flags)e[t]=n;for(let[t,n]of this._overrides)e[t]=n;return e}onGameEvent(){this.fetchFlags()}setupInterval(){this._fetchInterval=setInterval(()=>{this.fetchFlags()},this.FETCH_INTERVAL)}async fetchFlags(){try{let e=W.getInstance().getActiveGames(),{data:t}=await gt(global.OVERLAYED.APPLICATION_ID,{cortex_user_id:global.OVERLAYED_RUNTIME.userId,release_id:global.OVERLAYED_META.release.id??void 0,channel_id:global.OVERLAYED_META.release.channelId??void 0,active_games:e.map(e=>e.toString())??void 0}),n=new Map;for(let e of t)n.set(e.name,e.enabled);for(let[e,t]of n){if(this._overrides.has(e))continue;let n=this._flags.get(e);n!==void 0&&n!==t&&this.emit(e,t)}for(let[e]of this._flags)this._overrides.has(e)||n.has(e)||this.emit(e,this._defaults.get(e)??!1);this._flags=n;for(let e of this._defaults.keys())this._flags.has(e)||this.logger.warn(`Registered feature flag "${e}" was not found in the API response`);this.emit(`updated`,!0)}catch(e){this.logger.error(`Failed to fetch feature flags`,e)}finally{this._readyResolve()}}});function En(e){let t=Tn.getInstance();return e&&t.setDefaults(e),{on:(e,n)=>t.on(e,n),off:(e,n)=>t.off(e,n),ready:t.ready,get:e=>t.get(e),getAll:()=>t.getAll(),refresh:()=>t.refresh(),override:(e,n)=>t.override(e,n),clearOverride:e=>t.clearOverride(e),clearOverrides:()=>t.clearOverrides(),isOverridden:e=>t.isOverridden(e),getAllOverrides:()=>t.getAllOverrides(),inspect:e=>t.inspect(e)}}function Dn(){let e=J.getInstance();return{on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},allowSiteUpdateOnNextLoad:()=>{e.allowSiteUpdateOnNextLoad()}}}const On=r({dismissedNotices:ge(r.string).array()}),kn=E(class extends M{NOTICE_FETCH_INTERVAL=1e3*60*10;MAX_DISMISSED_NOTICES=100;_noticeFetchInterval=null;_notices=[];_noticesFile;_boundOnGameReady=this.onGameReady.bind(this);get notices(){let e=this._noticesFile.get().dismissedNotices;return this._notices.filter(t=>!e.includes(t.id))}constructor(){super(`NoticeManager`),this._noticesFile=this.getNoticesFile(),this._noticesFile.load(),this.fetchNotices(),this.setupNoticeInterval(),W.getInstance().on(`gameReady`,this._boundOnGameReady)}destroy(){this._noticeFetchInterval&&=(clearInterval(this._noticeFetchInterval),null),W.getInstance().off(`gameReady`,this._boundOnGameReady),super.destroy()}dismissNotice(e){let t=this._notices.find(t=>t.id===e);if(!t||!t.dismissible)return;let n=this._noticesFile.get().dismissedNotices;n.unshift(e),this._noticesFile.set({dismissedNotices:n.slice(0,this.MAX_DISMISSED_NOTICES)}),this.emitNoticesUpdated()}onGameReady(){this.fetchNotices()}setupNoticeInterval(){this._noticeFetchInterval=setInterval(()=>{this.fetchNotices()},this.NOTICE_FETCH_INTERVAL)}getNoticesFile(){return new O({path:Rt([`notices.json`]),schema:On,default:{dismissedNotices:[]}})}async fetchNotices(){let e=W.getInstance().getActiveGames();try{let{data:t}=await _t(global.OVERLAYED.APPLICATION_ID,{release_id:global.OVERLAYED_META.release.id?P(global.OVERLAYED_META.release.id):void 0,channel:global.OVERLAYED_META.release.channel,version:global.OVERLAYED_META.release.version,games:e});this._notices=t,this.emitNoticesUpdated()}catch(e){this.logger.error(`Failed to fetch notices`,e)}}emitNoticesUpdated(){this.emit(`noticesUpdated`,{notices:this.notices})}});function An(){let e=kn.getInstance();return{on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},dismissNotice:t=>{e.dismissNotice(t)},getNotices:()=>e.notices}}const{Provider:jn}=me;var Mn=class extends jn{logger=A.getInstance().scope(`OverlayedProvider`);constructor(e,t,n){super(n),this.options=e,this.updater=t}async getLatestVersion(){try{let e=await ft(this.options.application_id,{release_id:this.options.release_id,cortex_user_id:this.options.cortex_user_id,access_token:this.options.access_token,requested_channel:this.options.requested_channel});return this.logger.log(`checkApplicationRelease response`,e.data),H.getInstance().track(`update_release_check_success`,{version:e.data.release.version,channel:e.data.release.channel,fallback:!!e.data.fallback}),e.data.fallback&&this.logger.warn(`Update fallback detected, switching to default channel`),{path:``,sha512:e.data.download_hash??``,version:`${e.data.release.version}-${e.data.release.channel}`,releaseName:e.data.release.id,releaseDate:e.data.release.created_at,files:[{url:e.data.download_url,sha512:e.data.download_hash??``}]}}catch(e){let t=e instanceof Error?e.stack||e.message:String(e);throw H.getInstance().track(`update_release_check_error`,{message:t}),Error(`Unable to find the latest version (${this.options.release_id}), please ensure release exists. ${t}`)}}resolveFiles(e){return[{info:e.files[0],url:new URL(e.files[0].url)}]}};function Nn(e){return{provider:`custom`,updateProvider:Mn,...e}}const Y=me.autoUpdater,Pn=E(class extends M{DEFAULT_CHANNEL=`public`;TOKEN_REFRESH_INTERVAL=1e3*60*15;accessTokenFetcher=void 0;_tokenRefreshInterval=null;_downloadStarted=!1;constructor(){super(`UpdateManager`)}init(){super.init(),this.registerListenerForwarders(),this.setupTokenRefreshInterval(),Y.disableDifferentialDownload=!0}destroy(){Y.removeAllListeners(),this._tokenRefreshInterval&&=(clearInterval(this._tokenRefreshInterval),null),super.destroy()}setupTokenRefreshInterval(){this._tokenRefreshInterval=setInterval(()=>{this.checkAndRefreshToken()},this.TOKEN_REFRESH_INTERVAL)}async checkAndRefreshToken(){let e=global.OVERLAYED_META.release.channel;e!==this.DEFAULT_CHANNEL&&(this.logger.log(`Refreshing access token for channel`,e),await this.setAndGetLatestAccessToken(e))}async checkForUpdates(e){this.logger.log(`Starting checkForUpdates`);let t=e??global.OVERLAYED_META.release.channel;return H.getInstance().track(`check_for_update`,{channel:t}),this._downloadStarted=!1,await this.setAndGetLatestAccessToken(t),e?(Y.allowDowngrade=!0,Y.channel=e,this.setFeedUrl({requestedChannel:e})):(Y.allowDowngrade=!1,Y.channel=global.OVERLAYED_META.release.channel,this.setFeedUrl({})),this.logger.log(`Checking for updates`),Y.checkForUpdates()}async switchChannel(e){return this.logger.log(`Switching channel`,e),H.getInstance().track(`update_channel_switch`,{from_channel:global.OVERLAYED_META.release.channel,to_channel:e}),this._downloadStarted=!1,await this.setAndGetLatestAccessToken(e),Y.allowDowngrade=!0,Y.channel=e,this.setFeedUrl({requestedChannel:e}),Y.checkForUpdates()}quitAndInstall(e,t){this.logger.log(`quitAndInstall`,{isSilent:e,isForceRunAfter:t});let[n,r]=this.canUpdate();if(!n)throw this.logger.warn(`Cannot update`,{denialReason:r}),H.getInstance().track(`update_install_blocked`,{reason:r}),Error(r);return this.logger.log(`Quitting and installing`),H.getInstance().track(`update_install`,{}),Y.quitAndInstall(e,t)}canUpdate(){return W.getInstance().isInGame?[!1,`User is in game`]:[!0,null]}downloadUpdate(e){return Y.downloadUpdate(e)}setAccessTokenFetcher(e){this.accessTokenFetcher=e}async setAndGetLatestAccessToken(e){if(this.logger.log(`Fetching new token`),!this.accessTokenFetcher)return this.logger.warn(`accessTokenFetcher is not set, private channels will not work.`),R(null),null;if(this.logger.log(`Setting and getting latest access token for channel`,e),e===this.DEFAULT_CHANNEL)return this.logger.log(`Default channel, skipping`),R(null),null;if(e!==global.OVERLAYED_META.release.channel)return this.forceFetchNewAccessToken(e);this.logger.log(`Access token exists, checking expiration`);let t=L();if(t){let e=this.getAccessTokenExpirationDate(t);if(!e)this.logger.log(`Invalid token, setting to null`),R(null);else if(e.getTime()>=Date.now()+300*1e3)return this.logger.log(`Token is not expired, using it.`),t}return this.forceFetchNewAccessToken(e)}async forceFetchNewAccessToken(e){this.accessTokenFetcher||this.logger.warn(`accessTokenFetcher is not set [2], private channels will not work.`);try{let t=await this.accessTokenFetcher?.(e)??null;this.logger.log(`New token fetched`,t?.slice(0,5)+`...`);let n=L();if(t==null||n===t){H.getInstance().track(`update_token_invalid`,{channel:e}),this.emit(`authTokenInvalid`,{}),R(null);return}return R(t),t}catch(e){let t=e instanceof Error?e.message:String(e);return H.getInstance().track(`update_token_fetch_error`,{message:t}),this.logger.error(`Error fetching new token`,{error:e,message:t}),R(null),null}}setFeedUrl(e){if(!global.OVERLAYED_META.release.id){this.logger.warn(`Tried to set feed URL in development mode`);return}Y.setFeedURL(Nn({application_id:global.OVERLAYED.APPLICATION_ID,release_id:global.OVERLAYED_META.release.id,cortex_user_id:global.OVERLAYED_RUNTIME.userId,access_token:L(),requested_channel:e.requestedChannel}))}registerListenerForwarders(){Y.on(`checking-for-update`,()=>{this.logger.info(`Checking for updates`),this.emit(`checkingForUpdates`,{})}),Y.on(`download-progress`,e=>{this._downloadStarted||(this._downloadStarted=!0,H.getInstance().track(`update_download_started`,{version:Y.currentVersion?.version??``})),this.emit(`downloadProgress`,{info:e});let t=`Download speed: ${e.bytesPerSecond} - Downloaded ${e.percent}%`;t+=` (${e.transferred}/${e.total})`,this.logger.log(t)}),Y.on(`error`,(e,t)=>{this.logger.error(`Error`,e,t),H.getInstance().track(`update_download_error`,{message:t??e.message}),this.emit(`error`,{error:e,message:t})}),Y.on(`update-not-available`,e=>{this.logger.info(`Update not available`,e),H.getInstance().track(`update_not_available`,{version:e.version}),this.emit(`updateNotAvailable`,{info:e})}),Y.on(`update-available`,e=>{this.logger.info(`Update available`,e),H.getInstance().track(`update_available`,{version:e.version,channel:Y.channel??``}),this.emit(`updateAvailable`,{info:e})}),Y.on(`update-downloaded`,e=>{this.logger.info(`Update downloaded`,e),H.getInstance().track(`update_download_complete`,{version:e.version}),this.emit(`updateDownloaded`,{event:e})}),Y.on(`update-cancelled`,e=>{this.logger.info(`Update cancelled`,e),H.getInstance().track(`update_cancelled`,{version:e.version}),this.emit(`updateCancelled`,{info:e})})}getAccessTokenExpirationDate(e){try{let t=e.split(`.`)[1];if(!t)return null;let n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),r=JSON.parse(n);return r.exp?new Date(r.exp*1e3):null}catch{return null}}});function Fn(){let e=Pn.getInstance();return{site:Dn(),on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},setAccessTokenFetcher:t=>e.setAccessTokenFetcher(t),checkForUpdates:()=>e.checkForUpdates(),switchChannel:t=>e.checkForUpdates(t),quitAndInstall:(t,n)=>e.quitAndInstall(t,n),canUpdate:()=>e.canUpdate(),downloadUpdate:t=>e.downloadUpdate(t)}}function In(){return{getChannel:()=>global.OVERLAYED_META.release.channel,getVersion:()=>global.OVERLAYED_META.release.version,getReleaseId:()=>global.OVERLAYED_META.release.id}}const X=E(class extends M{_knownModificationTimes=new Map;_confirmedDumps=new Set;_pendingReports=new Map;_snapshotTimestamp=0;boundOnGameReady=this.onGameReady.bind(this);boundOnGameClose=this.onGameClose.bind(this);constructor(){super(`CrashDumpManager`)}init(){super.init(),this.logger.debug(`init() registering game event listeners`),W.getInstance().on(`gameReadyInternal`,this.boundOnGameReady),W.getInstance().on(`gameCloseInternal`,this.boundOnGameClose),this.logger.debug(`init() complete`)}destroy(){this.logger.debug(`destroy() called`,{pendingReports:this._pendingReports.size,confirmedDumps:this._confirmedDumps.size,knownModificationTimes:this._knownModificationTimes.size}),W.getInstance().off(`gameReadyInternal`,this.boundOnGameReady),W.getInstance().off(`gameCloseInternal`,this.boundOnGameClose),this._knownModificationTimes.clear(),this._confirmedDumps.clear(),this._pendingReports.clear(),this._snapshotTimestamp=0,this.logger.debug(`destroy() cleanup complete`),super.destroy()}async submit(e){this.logger.debug(`submit() called`,{id:e,pendingCount:this._pendingReports.size});let t=this._pendingReports.get(e);if(!t){this.logger.warn(`submit called with unknown id`,e);return}let{response:n,dumpPath:r}=t;this.logger.debug(`Resolved pending report for submission`,{id:e,dumpPath:r});let i=global.OVERLAYED.APPLICATION_ID,a=I();if(this.logger.debug(`Resolved identifiers for submission`,{applicationId:i,cortexUserId:a}),n.crash_dump_upload_request)try{this.logger.debug(`Reading crash dump file`,{dumpPath:r});let t=await S.readFile(r);this.logger.debug(`Uploading crash dump`,{dumpPath:r,size:t.byteLength}),await xt(n.crash_dump_upload_request,new Uint8Array(t)),this.logger.debug(`Crash dump uploaded, confirming`,{id:e}),await mt(i,e,{cortex_user_id:a,file_type:`crash_dump`}),this.logger.debug(`Crash dump confirmed`,{id:e})}catch(e){this.logger.error(`Failed to upload crash dump`,{dumpPath:r,error:e})}else this.logger.warn(`No crash dump upload request in response`,{id:e});this._pendingReports.delete(e),this._confirmedDumps.add(r),this.logger.debug(`Report state updated, attempting dump file cleanup`,{id:e,dumpPath:r});try{await S.unlink(r),this.logger.debug(`Dump file cleaned up successfully`,{dumpPath:r})}catch(e){this.logger.warn(`Failed to clean up dump file after submission`,{dumpPath:r,error:e})}this.logger.log(`Crash report submitted successfully`,r)}async onGameReady({ravenGame:e}){this.logger.debug(`onGameReady() fired`,{game:e.identifier}),await this.snapshotModificationTimes(),this.logger.debug(`onGameReady() snapshot complete`,{game:e.identifier})}async onGameClose({ravenGame:e}){this.logger.debug(`onGameClose() fired`,{game:e.identifier}),await this.scanForNewDumps(wt(e.identifier)),this.logger.debug(`onGameClose() scan complete`,{game:e.identifier})}async snapshotModificationTimes(){let e=Oe();this._snapshotTimestamp=Date.now(),this.logger.debug(`snapshotModificationTimes() called`,{crashDumpsPath:e,snapshotTimestamp:this._snapshotTimestamp});try{await S.access(e)}catch{this.logger.debug(`Crash dumps directory does not exist, skipping snapshot`,{crashDumpsPath:e});return}let t=await this.findAllDumps(e);this.logger.debug(`Found dumps for snapshot`,{count:t.length});for(let e of t)try{let t=await S.stat(e);if(t.mtimeMs>=this._snapshotTimestamp-3e4){this.logger.debug(`Skipping recent dump from snapshot`,{dumpPath:e,mtimeMs:t.mtimeMs,snapshotTimestamp:this._snapshotTimestamp});continue}this._knownModificationTimes.set(e,t.mtimeMs),this.logger.debug(`Recorded modification time`,{dumpPath:e,mtimeMs:t.mtimeMs})}catch(t){this.logger.warn(`Failed to stat dump file during snapshot`,{dumpPath:e,error:t})}this.logger.debug(`Snapshot complete`,{totalTracked:this._knownModificationTimes.size})}async scanForNewDumps(e){let t=Oe();this.logger.debug(`scanForNewDumps() called`,{game:e,crashDumpsPath:t});try{await S.access(t)}catch{this.logger.debug(`Crash dumps directory does not exist, skipping scan`,{crashDumpsPath:t});return}let n=new Set([...this._pendingReports.values()].map(e=>e.dumpPath)),r=await this.findAllDumps(t);this.logger.debug(`Scan found dumps`,{total:r.length,pendingCount:n.size,confirmedCount:this._confirmedDumps.size});for(let t of r){if(this._confirmedDumps.has(t)){this.logger.debug(`Skipping already confirmed dump`,{dumpPath:t});continue}if(n.has(t)){this.logger.debug(`Skipping already pending dump`,{dumpPath:t});continue}let r;try{r=await S.stat(t)}catch(e){this.logger.warn(`Failed to stat dump file during scan`,{dumpPath:t,error:e});continue}let i=r.mtimeMs,a=this._knownModificationTimes.get(t);if(this.logger.debug(`Comparing modification times`,{dumpPath:t,modificationTime:i,knownModificationTime:a}),a===void 0||i>a){this.logger.debug(`Dump is new or modified`,{dumpPath:t,isNew:a===void 0});try{let n=r.size,i=h.basename(h.dirname(t)),a=h.basename(t,h.extname(t));this.logger.debug(`Preparing crash report`,{dumpPath:t,crashDumpSize:n,crashSource:i});let o=(await bn().generateAsync({type:`uint8array`})).byteLength,s=global.OVERLAYED.APPLICATION_ID,c=I(),l=global.OVERLAYED_META.release.id;this.logger.debug(`Creating game crash report via API`,{applicationId:s,cortexUserId:c,game:e,crashSource:i,crashDumpSize:n,logsSize:o});let{data:u}=await pt(s,{cortex_user_id:c,game:e,crash_source:i,crash_identifier:a,release_id:l,logs_size:o,crash_dump_size:n});this._pendingReports.set(u.id,{response:u,dumpPath:t}),this.logger.debug(`Crash report created, emitting 'new' event`,{id:u.id,game:e}),this.logger.log(`New crash dump detected`,{dumpPath:t,game:e,id:u.id}),this.emit(`new`,{id:u.id,game:e})}catch(e){this.logger.error(`Failed to create game crash report`,{dumpPath:t,error:e})}}else this.logger.debug(`Dump unchanged, skipping`,{dumpPath:t});this._knownModificationTimes.set(t,i)}this.logger.debug(`scanForNewDumps() complete`,{game:e,pendingReports:this._pendingReports.size})}async findAllDumps(e){this.logger.debug(`findAllDumps() called`,{basePath:e});let t=[],n;try{n=await S.readdir(e,{withFileTypes:!0})}catch(n){return this.logger.warn(`Failed to read crash dumps directory`,{basePath:e,error:n}),t}this.logger.debug(`Top-level entries in crash dumps directory`,{count:n.length,directories:n.filter(e=>e.isDirectory()).map(e=>e.name)});for(let r of n)if(r.isDirectory()){let n=h.join(e,r.name),i;try{i=await S.readdir(n,{withFileTypes:!0})}catch(e){this.logger.warn(`Failed to read crash dump subdirectory`,{subPath:n,error:e});continue}let a=i.filter(e=>e.isFile()&&e.name.endsWith(`.dmp`));this.logger.debug(`Scanned subdirectory`,{subPath:n,totalEntries:i.length,dmpCount:a.length});for(let e of a)t.push(h.join(n,e.name))}return this.logger.debug(`findAllDumps() complete`,{totalFound:t.length}),t}});let Z=!1,Ln={},Q,Rn=new T,$;function zn(e){Vn(e);let t=Bn(e),{init:n=!0,debug:r=!1,silent:i=!0}=t;if(Hn(e),A.getInstance().init(e.applicationId,r,i),ln.getInstance().init(e.applicationId,r,!0,!0),Gn(ut(e.applicationId),!1).catch(()=>{}),Z)return Q;function a(){if(Z){A.getInstance().warn(`Overlayed already initialized`);return}sn();let e=Qt.get({createIfMissing:!1})?.currentAccount;e&&rt(()=>e.apiKey);let n=new Map,r=new Map,i=Fn(),o=$t(t.modules,n,Rn),s=en(),c=on(t.keybinds),l=fn(),u=mn(),d=_n(),f=hn(),p=Sn(t),m=An(),h=En(t.featureFlags),g=In();A.getInstance().log(`Overlayed initialized`),Un(t),wn(t,n,r,Rn,Ln),Z=!0,Q={...o,...s,ads:d,keybinds:c,windows:l,input:u,cortex:f,hasAnyActiveProcesses:()=>B.getInstance().hasAnyActiveProcesses,hasAnyActiveGames:()=>W.getInstance().isInGame,init:a,log:p,initialized:Z,notices:m,featureFlags:h,updater:i,application:g,crashDumps:{on:(e,t)=>X.getInstance().on(e,t),off:(e,t)=>X.getInstance().off(e,t),submit:e=>X.getInstance().submit(e)}},Q.universal.on(`logged_in`,e=>{H.getInstance().track(`account_id`,{account_id:e.content.account_id,game:e.game})})}return n?(a(),Q):new Proxy({init:a},{get:(e,t)=>{if(t!==`init`&&!Z)throw Error(`overlayed was called before initialized: ${t}`);return t===`init`?e[t]:Q[t]}})}function Bn(e){return{...e,modules:[...e.modules,$e()]}}global.OVERLAYED=new Proxy({},{get:()=>{throw Error(`function overlayed was not called`)}});function Vn(e){if(!_e(e.applicationId))throw Error(`Invalid applicationId, must be a valid ULID.`)}function Hn(e){let t=Wn(),n=`1.3.3`,r=ut(e.applicationId);function i(){return{package_version:n,application_id:r,application_version:t?.release.version??`0.0.0`}}if(A.getInstance().log(`ua object`,i()),at(()=>i()),t===null){Gn(r,!0);return}global.OVERLAYED={APPLICATION_ID:r,APP_BUILD_CHANNEL:t.release.channel,APP_VERSION:t.release.version,PACKAGE_VERSION:n,FRONTEND_VERSION:`0.0.0`,sessionId:Vt(),electron:e.electron},global.OVERLAYED_META=t,global.OVERLAYED_RUNTIME={userId:I()},A.getInstance().log(`meta`,t)}function Un(e){A.getInstance().warn(`Bootstrapping`);let t=e.universal?[`*`]:e.modules.map(e=>e.key);W.getInstance().setSubscribedGames(t),A.getInstance().warn(`Initializing update manager`),Pn.getInstance().init(),A.getInstance().warn(`Initialized update manager`),J.getInstance().init({manualUpdates:e.site?.manualUpdates??!1}),Xt.getInstance().init(),W.getInstance().init(),X.getInstance().init(),B.getInstance().init(),z.getInstance().init(),H.getInstance().track(`start`,{}),Zt.getInstance().check(e.applicationId);try{$&&clearInterval($),$=setInterval(()=>{try{Ht()}catch{}},3e4),$.unref()}catch(e){A.getInstance().log(`failed to start sessionLastUsed interval`,e)}async function n(){let e={};e.os=fe.platform().trim(),e.os_version=process.getSystemVersion().trim(),e.architecture=fe.arch().trim();let t=fe.cpus();t.length>0?(e.cpu=t[0].model.trim(),e.cpu_cores=t.length,e.cpu_speed=t[0].speed):A.getInstance().warn(`Failed to collect CPU info`);let n=await pe.graphics();A.getInstance().info(`GPU info`,n);let r=n.controllers.sort((e,t)=>(t.vram??0)-(e.vram??0))[0];r?(e.gpu=r.model.trim(),e.gpu_memory=r.vram??0):A.getInstance().warn(`Failed to find primary GPU`),e.display_count=n.displays.length;let i=n.displays.find(e=>e.main)??n.displays[0];i?(e.primary_display_resolution_x=i.resolutionX??void 0,e.primary_display_resolution_y=i.resolutionY??void 0,e.primary_display_refresh_rate=i.currentRefreshRate??void 0):A.getInstance().warn(`Failed to find main display`),e.ram=process.getSystemMemoryInfo().total;let a=fe.homedir(),o=await S.statfs(a);return o&&`blocks`in o&&`bsize`in o&&`bavail`in o?(e.disk=o.blocks*o.bsize,e.disk_free=o.bavail*o.bsize):A.getInstance().warn(`Failed to collect disk info`),A.getInstance().log(`Retrieved system information`,e),e}C.on(`ready`,()=>{n().then(e=>{H.getInstance().track(`system_info`,e)}).catch(e=>{A.getInstance().log(`Failed to retrieve system information`,e)})}),C.on(`quit`,()=>{H.getInstance().track(`electron_quit`,{}),Kn()}),process.on(`exit`,()=>{H.getInstance().track(`exit`,{}),Kn()})}function Wn(){if(C.isPackaged)try{let e=h.join(process.resourcesPath,`meta.json`);return JSON.parse(y.readFileSync(e,`utf-8`))}catch(e){throw Error(`Failed to read application metadata from resources/meta.json`,{cause:e})}else{let e=h.join(process.cwd(),`.overlayed`,`meta.json`);return y.existsSync(e)?JSON.parse(y.readFileSync(e,`utf-8`)):null}}async function Gn(e,t=!1){if(!C.isPackaged)try{A.getInstance().log(`Fetching application metadata from API...`);let n=Ie({...(await dt(e)).data,siteUrl:``});t&&(A.getInstance().log(v.yellowBright(`Uninitialized development environment detected. Created .overlayed folder. In the future, run ${v.bold(`overlayed init`)} to do so. \n\nThe process will now exit to load the cached metadata.\n\n${v.italic(`Note: This will never happen in a packaged application, and will only happen once in local development so long as the .overlayed folder exists.`)}`)),process.exit(0)),global.OVERLAYED_META=n}catch(e){A.getInstance().error(`Failed to fetch application meta`,e),t&&(console.error(`
|
|
1
|
+
import{createRequire as e}from"node:module";import{Type as t,scope as n,type as r}from"arktype";import i from"mitt";import a,{createWriteStream as o,existsSync as s,mkdirSync as c,readdirSync as l,unlinkSync as u,writeFileSync as d}from"fs";import{ensureFileSync as f}from"fs-extra";import p,{join as m}from"path";import*as h from"node:path";import g,{basename as _,resolve as v}from"node:path";import y from"picocolors";import b from"events";import*as x from"node:fs";import{copyFileSync as S,createReadStream as ee,existsSync as C,mkdirSync as te,readFileSync as ne,readdirSync as w,writeFileSync as re}from"node:fs";import"glob";import*as ie from"node:os";import{createHash as ae}from"node:crypto";import oe from"xior";import T from"fs/promises";import se from"jszip";import*as E from"node:fs/promises";import{BrowserWindow as ce,app as le}from"electron";import ue from"systeminformation";import de from"electron-updater";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;var fe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),D=e(import.meta.url);function pe(e){return e}function me(e){return e?Array.isArray(e)?e:[e]:[]}function he(e){return typeof e==`string`&&/^01[0-9A-HJKMNP-TV-Z]{24}$/.test(e)}var ge=class{data=[];constructor(){}get size(){return this.data.length}add(e){this.data.push(e)}next(){return this.data.shift()}clear(){this.data.length=0}*flush(){for(;this.size>0;){let e=this.next();e&&(yield e)}}};fe(((e,t)=>{(()=>{var e={"./node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist lazy recursive":function(e){function t(e){return Promise.resolve().then(function(){var t=Error(`Cannot find module '`+e+`'`);throw t.code=`MODULE_NOT_FOUND`,t})}t.keys=()=>[],t.resolve=t,t.id=`./node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist lazy recursive`,e.exports=t}},n={};function r(t){var i=n[t];if(i!==void 0)return i.exports;var a=n[t]={exports:{}};return e[t](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i={};(()=>{r.d(i,{default:()=>Gr});let e=D(`node:os`);var t=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],n=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],a=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,o={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},s=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,c={5:s,"5module":s+` export import`,6:s+` const class extends export import super`},l=/^in(stanceof)?$/,u=RegExp(`[`+a+`]`),d=RegExp(`[`+a+`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・]`);function f(e,t){for(var n=65536,r=0;r<t.length;r+=2){if((n+=t[r])>e)return!1;if((n+=t[r+1])>=e)return!0}return!1}function p(e,t){return e<65?e===36:e<91||(e<97?e===95:e<123||(e<=65535?e>=170&&u.test(String.fromCharCode(e)):!1!==t&&f(e,n)))}function m(e,r){return e<48?e===36:e<58||!(e<65)&&(e<91||(e<97?e===95:e<123||(e<=65535?e>=170&&d.test(String.fromCharCode(e)):!1!==r&&(f(e,n)||f(e,t)))))}var h=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function g(e,t){return new h(e,{beforeExpr:!0,binop:t})}var _={beforeExpr:!0},v={startsExpr:!0},y={};function b(e,t){return t===void 0&&(t={}),t.keyword=e,y[e]=new h(e,t)}var x={num:new h(`num`,v),regexp:new h(`regexp`,v),string:new h(`string`,v),name:new h(`name`,v),privateId:new h(`privateId`,v),eof:new h(`eof`),bracketL:new h(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new h(`]`),braceL:new h(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new h(`}`),parenL:new h(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new h(`)`),comma:new h(`,`,_),semi:new h(`;`,_),colon:new h(`:`,_),dot:new h(`.`),question:new h(`?`,_),questionDot:new h(`?.`),arrow:new h(`=>`,_),template:new h(`template`),invalidTemplate:new h(`invalidTemplate`),ellipsis:new h(`...`,_),backQuote:new h("`",v),dollarBraceL:new h("${",{beforeExpr:!0,startsExpr:!0}),eq:new h(`=`,{beforeExpr:!0,isAssign:!0}),assign:new h(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new h(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new h(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:g(`||`,1),logicalAND:g(`&&`,2),bitwiseOR:g(`|`,3),bitwiseXOR:g(`^`,4),bitwiseAND:g(`&`,5),equality:g(`==/!=/===/!==`,6),relational:g(`</>/<=/>=`,7),bitShift:g(`<</>>/>>>`,8),plusMin:new h(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:g(`%`,10),star:g(`*`,10),slash:g(`/`,10),starstar:new h(`**`,{beforeExpr:!0}),coalesce:g(`??`,1),_break:b(`break`),_case:b(`case`,_),_catch:b(`catch`),_continue:b(`continue`),_debugger:b(`debugger`),_default:b(`default`,_),_do:b(`do`,{isLoop:!0,beforeExpr:!0}),_else:b(`else`,_),_finally:b(`finally`),_for:b(`for`,{isLoop:!0}),_function:b(`function`,v),_if:b(`if`),_return:b(`return`,_),_switch:b(`switch`),_throw:b(`throw`,_),_try:b(`try`),_var:b(`var`),_const:b(`const`),_while:b(`while`,{isLoop:!0}),_with:b(`with`),_new:b(`new`,{beforeExpr:!0,startsExpr:!0}),_this:b(`this`,v),_super:b(`super`,v),_class:b(`class`,v),_extends:b(`extends`,_),_export:b(`export`),_import:b(`import`,v),_null:b(`null`,v),_true:b(`true`,v),_false:b(`false`,v),_in:b(`in`,{beforeExpr:!0,binop:7}),_instanceof:b(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:b(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:b(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:b(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},S=/\r\n?|\n|\u2028|\u2029/,ee=new RegExp(S.source,`g`);function C(e){return e===10||e===13||e===8232||e===8233}function te(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(C(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var ne=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,w=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,re=Object.prototype,ie=re.hasOwnProperty,ae=re.toString,oe=Object.hasOwn||function(e,t){return ie.call(e,t)},T=Array.isArray||function(e){return ae.call(e)===`[object Array]`},se=Object.create(null);function E(e){return se[e]||(se[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function ce(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var le=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ue=function(e,t){this.line=e,this.column=t};ue.prototype.offset=function(e){return new ue(this.line,this.column+e)};var de=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function fe(e,t){for(var n=1,r=0;;){var i=te(e,r,t);if(i<0)return new ue(n,t-r);++n,r=i}}var pe={ecmaVersion:null,sourceType:`script`,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},me=!1;function he(e){var t={};for(var n in pe)t[n]=e&&oe(e,n)?e[n]:pe[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!me&&typeof console==`object`&&console.warn&&(me=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
+
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??=t.ecmaVersion<5,e&&e.allowHashBang!=null||(t.allowHashBang=t.ecmaVersion>=14),T(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}return T(t.onComment)&&(t.onComment=function(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new de(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}(t,t.onComment)),t}var ge=256,_e=259;function ve(e,t){return 2|(e?4:0)|(t?8:0)}var O=function(e,t,n){this.options=e=he(e),this.sourceFile=e.sourceFile,this.keywords=E(c[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;!0!==e.allowReserved&&(r=o[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=E(r);var i=(r?r+` `:``)+o.strict;this.reservedWordsStrict=E(i),this.reservedWordsStrictBind=E(i+` `+o.strictBind),this.input=String(t),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf(`
|
|
3
|
+
`,n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(S).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=x.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(1),this.regexpState=null,this.privateNameStack=[]},k={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};O.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)},k.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},k.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0},k.inAsync.get=function(){return(4&this.currentVarScope().flags)>0},k.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t)return!1;if(2&t)return(4&t)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},k.allowSuper.get=function(){return(64&this.currentThisScope().flags)>0||this.options.allowSuperOutsideMethod},k.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},k.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},k.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t||2&t&&!(16&t))return!0}return!1},k.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ge)>0},O.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},O.parse=function(e,t){return new this(t,e).parse()},O.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},O.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(O.prototype,k);var A=O.prototype,ye=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;A.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){w.lastIndex=e,e+=w.exec(this.input)[0].length;var t=ye.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){w.lastIndex=e+t[0].length;var n=w.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||S.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`)}e+=t[0].length,w.lastIndex=e,e+=w.exec(this.input)[0].length,this.input[e]===`;`&&e++}},A.eat=function(e){return this.type===e&&(this.next(),!0)},A.isContextual=function(e){return this.type===x.name&&this.value===e&&!this.containsEsc},A.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},A.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},A.canInsertSemicolon=function(){return this.type===x.eof||this.type===x.braceR||S.test(this.input.slice(this.lastTokEnd,this.start))},A.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},A.semicolon=function(){this.eat(x.semi)||this.insertSemicolon()||this.unexpected()},A.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},A.expect=function(e){this.eat(e)||this.unexpected()},A.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var be=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};A.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},A.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},A.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},A.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var j=O.prototype;j.parseTopLevel=function(e){var t=Object.create(null);for(e.body||=[];this.type!==x.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,`Program`)};var xe={kind:`loop`},Se={kind:`switch`};j.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;w.lastIndex=this.pos;var t=w.exec(this.input),n=this.pos+t[0].length,r=this.input.charCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(p(r,!0)){for(var i=n+1;m(r=this.input.charCodeAt(i),!0);)++i;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(n,i);if(!l.test(a))return!0}return!1},j.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;w.lastIndex=this.pos;var e,t=w.exec(this.input),n=this.pos+t[0].length;return!(S.test(this.input.slice(this.pos,n))||this.input.slice(n,n+8)!==`function`||n+8!==this.input.length&&(m(e=this.input.charCodeAt(n+8))||e>55295&&e<56320))},j.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;w.lastIndex=this.pos;var n=w.exec(this.input),r=this.pos+n[0].length;if(S.test(this.input.slice(this.pos,r)))return!1;if(e){var i,a=r+5;if(this.input.slice(r,a)!==`using`||a===this.input.length||m(i=this.input.charCodeAt(a))||i>55295&&i<56320)return!1;w.lastIndex=a;var o=w.exec(this.input);if(o&&S.test(this.input.slice(a,a+o[0].length)))return!1}if(t){var s,c=r+2;if(!(this.input.slice(r,c)!==`of`||c!==this.input.length&&(m(s=this.input.charCodeAt(c))||s>55295&&s<56320)))return!1}var l=this.input.charCodeAt(r);return p(l,!0)||l===92},j.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},j.isUsing=function(e){return this.isUsingKeyword(!1,e)},j.parseStatement=function(e,t,n){var r,i=this.type,a=this.startNode();switch(this.isLet(e)&&(i=x._var,r=`let`),i){case x._break:case x._continue:return this.parseBreakContinueStatement(a,i.keyword);case x._debugger:return this.parseDebuggerStatement(a);case x._do:return this.parseDoStatement(a);case x._for:return this.parseForStatement(a);case x._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(a,!1,!e);case x._class:return e&&this.unexpected(),this.parseClass(a,!0);case x._if:return this.parseIfStatement(a);case x._return:return this.parseReturnStatement(a);case x._switch:return this.parseSwitchStatement(a);case x._throw:return this.parseThrowStatement(a);case x._try:return this.parseTryStatement(a);case x._const:case x._var:return r||=this.value,e&&r!==`var`&&this.unexpected(),this.parseVarStatement(a,r);case x._while:return this.parseWhileStatement(a);case x._with:return this.parseWithStatement(a);case x.braceL:return this.parseBlock(!0,a);case x.semi:return this.parseEmptyStatement(a);case x._export:case x._import:if(this.options.ecmaVersion>10&&i===x._import){w.lastIndex=this.pos;var o=w.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(a,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),i===x._import?this.parseImport(a):this.parseExport(a,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(a,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return t&&this.options.sourceType===`script`&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(a,!1,l),this.semicolon(),this.finishNode(a,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return i===x.name&&d.type===`Identifier`&&this.eat(x.colon)?this.parseLabeledStatement(a,u,d,e):this.parseExpressionStatement(a,d)}},j.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(x.semi)||this.insertSemicolon()?e.label=null:this.type===x.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},j.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},j.parseDoStatement=function(e){return this.next(),this.labels.push(xe),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(x._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(x.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},j.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(xe),this.enterScope(0),this.expect(x.parenL),this.type===x.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===x._var||this.type===x._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&this.next(),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new be,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===x._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===x._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start!==d||l||f.type!==`Identifier`||f.name!==`async`?this.options.ecmaVersion>=9&&(e.await=!1):this.unexpected()),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},j.parseForAfterInit=function(e,t,n){return(this.type===x._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===x._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},j.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,we|(n?0:Te),!1,t)},j.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(x._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},j.parseReturnStatement=function(e){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(x.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},j.parseSwitchStatement=function(e){var t;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(x.braceL),this.labels.push(Se),this.enterScope(0);for(var n=!1;this.type!==x.braceR;)if(this.type===x._case||this.type===x._default){var r=this.type===x._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(x.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},j.parseThrowStatement=function(e){return this.next(),S.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var Ce=[];j.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?32:0),this.checkLValPattern(e,t?4:2),this.expect(x.parenR),e},j.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===x._catch){var t=this.startNode();this.next(),this.eat(x.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(x._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},j.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},j.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(xe),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},j.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},j.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},j.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===x._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart!==e.start)break;c.statementStart=this.start,c.kind=o}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},j.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},j.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(x.braceL),e&&this.enterScope(0);this.type!==x.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},j.parseFor=function(e,t){return e.init=t,this.expect(x.semi),e.test=this.type===x.semi?null:this.parseExpression(),this.expect(x.semi),e.update=this.type===x.parenR?null:this.parseExpression(),this.expect(x.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},j.parseForIn=function(e,t){var n=this.type===x._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(x.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},j.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(x.eq)?i.init=this.parseMaybeAssign(t):r||n!==`const`||this.type===x._in||this.options.ecmaVersion>=6&&this.isContextual(`of`)?r||n!==`using`&&n!==`await using`||!(this.options.ecmaVersion>=17)||this.type===x._in||this.isContextual(`of`)?r||i.id.type===`Identifier`||t&&(this.type===x._in||this.isContextual(`of`))?i.init=null:this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):this.unexpected(),e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(x.comma))break}return e},j.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?1:2,!1)};var we=1,Te=2;function Ee(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type!==`MethodDefinition`||t.kind!==`get`&&t.kind!==`set`||(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):!!r||(e[n]=i,!1)}function De(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}j.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===x.star&&t&Te&&this.unexpected(),e.generator=this.eat(x.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&we&&(e.id=4&t&&this.type!==x.name?null:this.parseIdent(),!e.id||t&Te||this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?1:2:3));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(ve(e.async,e.generator)),t&we||(e.id=this.type===x.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&we?`FunctionDeclaration`:`FunctionExpression`)},j.parseFunctionParams=function(e){this.expect(x.parenL),e.params=this.parseBindingList(x.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},j.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(x.braceL);this.type!==x.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Ee(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},j.parseClassElement=function(e){if(this.eat(x.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(x.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===x.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&(!this.isClassElementNameStart()&&this.type!==x.star||this.canInsertSemicolon()?r=`async`:a=!0),!r&&(t>=9||!a)&&this.eat(x.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===x.parenL||o!==`method`||i||a){var l=!n.static&&De(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},j.isClassElementNameStart=function(){return this.type===x.name||this.type===x.privateId||this.type===x.num||this.type===x.string||this.type===x.bracketL||this.type.keyword},j.parseClassElementName=function(e){this.type===x.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},j.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&De(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},j.parseClassField=function(e){return De(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&De(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(x.eq)?(this.enterScope(576),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},j.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(320);this.type!==x.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},j.parseClassId=function(e,t){this.type===x.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,2,!1)):(!0===t&&this.unexpected(),e.id=null)},j.parseClassSuper=function(e){e.superClass=this.eat(x._extends)?this.parseExprSubscripts(null,!1):null},j.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},j.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];oe(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}},j.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==x.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},j.parseExport=function(e,t){if(this.next(),this.eat(x.star))return this.parseExportAllDeclaration(e,t);if(this.eat(x._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==x.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},j.parseExportDeclaration=function(e){return this.parseStatement(null)},j.parseExportDefaultDeclaration=function(){var e;if(this.type===x._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,4|we,!1,e)}if(this.type===x._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}var r=this.parseMaybeAssign();return this.semicolon(),r},j.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),oe(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},j.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},j.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},j.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},j.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},j.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(x.braceL);!this.eat(x.braceR);){if(n)n=!1;else if(this.expect(x.comma),this.afterTrailingComma(x.braceR))break;t.push(this.parseExportSpecifier(e))}return t},j.parseImport=function(e){return this.next(),this.type===x.string?(e.specifiers=Ce,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===x.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},j.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,2),this.finishNode(e,`ImportSpecifier`)},j.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,`ImportDefaultSpecifier`)},j.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,`ImportNamespaceSpecifier`)},j.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===x.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(x.comma)))return e;if(this.type===x.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(x.braceL);!this.eat(x.braceR);){if(t)t=!1;else if(this.expect(x.comma),this.afterTrailingComma(x.braceR))break;e.push(this.parseImportSpecifier())}return e},j.parseWithClause=function(){var e=[];if(!this.eat(x._with))return e;this.expect(x.braceL);for(var t={},n=!0;!this.eat(x.braceR);){if(n)n=!1;else if(this.expect(x.comma),this.afterTrailingComma(x.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;oe(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},j.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===x.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(x.colon),this.type!==x.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},j.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===x.string){var e=this.parseLiteral(this.value);return le.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},j.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},j.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`"`||this.input[e.start]===`'`)};var M=O.prototype;M.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type!==`RestElement`||a.argument.type!==`ArrayPattern`&&a.argument.type!==`ObjectPattern`||this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},M.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},M.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},M.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==x.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},M.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case x.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(x.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case x.braceL:return this.parseObj(!0)}return this.parseIdent()},M.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(x.comma),t&&this.type===x.comma)i.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===x.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===x.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}i.push(this.parseAssignableListItem(r))}return i},M.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},M.parseBindingListItem=function(e){return e},M.parseMaybeDefault=function(e,t,n){if(n||=this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(x.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},M.checkLValSimple=function(e,t,n){t===void 0&&(t=0);var r=t!==0;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===2&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(oe(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==5&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},M.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=0),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},M.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=0),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var N=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},P={b_stat:new N(`{`,!1),b_expr:new N(`{`,!0),b_tmpl:new N("${",!1),p_stat:new N(`(`,!1),p_expr:new N(`(`,!0),q_tmpl:new N("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new N(`function`,!1),f_expr:new N(`function`,!0),f_expr_gen:new N(`function`,!0,!1,null,!0),f_gen:new N(`function`,!1,!1,null,!0)},Oe=O.prototype;Oe.initialContext=function(){return[P.b_stat]},Oe.curContext=function(){return this.context[this.context.length-1]},Oe.braceIsBlock=function(e){var t=this.curContext();return t===P.f_expr||t===P.f_stat||(e!==x.colon||t!==P.b_stat&&t!==P.b_expr?e===x._return||e===x.name&&this.exprAllowed?S.test(this.input.slice(this.lastTokEnd,this.start)):e===x._else||e===x.semi||e===x.eof||e===x.parenR||e===x.arrow||(e===x.braceL?t===P.b_stat:e!==x._var&&e!==x._const&&e!==x.name&&!this.exprAllowed):!t.isExpr)},Oe.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},Oe.updateContext=function(e){var t,n=this.type;n.keyword&&e===x.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Oe.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},x.parenR.updateContext=x.braceR.updateContext=function(){if(this.context.length!==1){var e=this.context.pop();e===P.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},x.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?P.b_stat:P.b_expr),this.exprAllowed=!0},x.dollarBraceL.updateContext=function(){this.context.push(P.b_tmpl),this.exprAllowed=!0},x.parenL.updateContext=function(e){var t=e===x._if||e===x._for||e===x._with||e===x._while;this.context.push(t?P.p_stat:P.p_expr),this.exprAllowed=!0},x.incDec.updateContext=function(){},x._function.updateContext=x._class.updateContext=function(e){!e.beforeExpr||e===x._else||e===x.semi&&this.curContext()!==P.p_stat||e===x._return&&S.test(this.input.slice(this.lastTokEnd,this.start))||(e===x.colon||e===x.braceL)&&this.curContext()===P.b_stat?this.context.push(P.f_stat):this.context.push(P.f_expr),this.exprAllowed=!1},x.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},x.backQuote.updateContext=function(){this.curContext()===P.q_tmpl?this.context.pop():this.context.push(P.q_tmpl),this.exprAllowed=!1},x.star.updateContext=function(e){if(e===x._function){var t=this.context.length-1;this.context[t]===P.f_expr?this.context[t]=P.f_expr_gen:this.context[t]=P.f_gen}this.exprAllowed=!0},x.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==x.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var F=O.prototype;function ke(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&ke(e.expression)}function Ae(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&Ae(e.expression)||e.type===`ParenthesizedExpression`&&Ae(e.expression)}F.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r,i=e.key;switch(i.type){case`Identifier`:r=i.name;break;case`Literal`:r=String(i.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6)r===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=i.start):this.raiseRecoverable(i.start,`Redefinition of __proto__ property`)),t.proto=!0);else{var o=t[r=`$`+r];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(i.start,`Redefinition of property`):o=t[r]={init:!1,get:!1,set:!1},o[a]=!0}}},F.parseExpression=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===x.comma){var a=this.startNodeAt(n,r);for(a.expressions=[i];this.eat(x.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,`SequenceExpression`)}return i},F.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new be,r=!0);var s=this.start,c=this.startLoc;this.type!==x.parenL&&this.type!==x.name||(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===x.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===x.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},F.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(x.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(x.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},F.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},F.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==x._in)&&a>r){var o=this.type===x.logicalOR||this.type===x.logicalAND,s=this.type===x.coalesce;s&&(a=x.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===x.coalesce||s&&(this.type===x.logicalOR||this.type===x.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},F.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},F.parseMaybeUnary=function(e,t,n,r){var i,a=this.start,o=this.startLoc;if(this.isContextual(`await`)&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===x.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&ke(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&Ae(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,i=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(t||this.type!==x.privateId){if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(a,o);l.operator=this.value,l.prefix=!1,l.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(l,`UpdateExpression`)}}else (r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==x._in&&this.unexpected();return n||!this.eat(x.starstar)?i:t?void this.unexpected(this.lastTokStart):this.buildBinary(a,o,i,this.parseMaybeUnary(null,!1,!1,r),`**`,!1)},F.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprAtom(e,t);if(i.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return i;var a=this.parseSubscripts(i,n,r,!1,t);return e&&a.type===`MemberExpression`&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a},F.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s===e||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s}},F.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(x.arrow)},F.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},F.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(x.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(x.bracketL);if(l||c&&this.type!==x.parenL&&this.type!==x.backQuote||this.eat(x.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(x.bracketR)):this.type===x.privateId&&e.type!==`Super`?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(x.parenL)){var d=new be,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(x.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===x.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},F.parseExprAtom=function(e,t,n){this.type===x.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case x._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type!==x.parenL||this.allowDirectSuper||this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==x.dot&&this.type!==x.bracketL&&this.type!==x.parenL&&this.unexpected(),this.finishNode(r,`Super`);case x._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case x.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(x._function))return this.overrideContext(P.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(x.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===x.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(x.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case x.regexp:var l=this.value;return(r=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},r;case x.num:case x.string:return this.parseLiteral(this.value);case x._null:case x._true:case x._false:return(r=this.startNode()).value=this.type===x._null?null:this.type===x._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case x.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case x.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(x.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case x.braceL:return this.overrideContext(P.b_expr),this.parseObj(!1,e);case x._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case x._class:return this.parseClass(this.startNode(),!1);case x._new:return this.parseNew();case x.backQuote:return this.parseTemplate();case x._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},F.parseExprAtomDefault=function(){this.unexpected()},F.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===x.parenL&&!e)return this.parseDynamicImport(t);if(this.type===x.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}this.unexpected()},F.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(x.parenR)?e.options=null:(this.expect(x.comma),this.afterTrailingComma(x.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(x.parenR)||(this.expect(x.comma),this.afterTrailingComma(x.parenR)||this.unexpected())));else if(!this.eat(x.parenR)){var t=this.start;this.eat(x.comma)&&this.eat(x.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},F.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType===`module`||this.options.allowImportExportEverywhere||this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},F.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},F.parseParenExpression=function(){this.expect(x.parenL);var e=this.parseExpression();return this.expect(x.parenR),e},F.shouldParseArrow=function(e){return!this.canInsertSemicolon()},F.parseParenAndDistinguishExpression=function(e,t){var n,r=this.start,i=this.startLoc,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o,s=this.start,c=this.startLoc,l=[],u=!0,d=!1,f=new be,p=this.yieldPos,m=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==x.parenR;){if(u?u=!1:this.expect(x.comma),a&&this.afterTrailingComma(x.parenR,!0)){d=!0;break}if(this.type===x.ellipsis){o=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===x.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}l.push(this.parseMaybeAssign(!1,f,this.parseParenItem))}var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(x.parenR),e&&this.shouldParseArrow(l)&&this.eat(x.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=p,this.awaitPos=m,this.parseParenArrowList(r,i,l,t);l.length&&!d||this.unexpected(this.lastTokStart),o&&this.unexpected(o),this.checkExpressionErrors(f,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=m||this.awaitPos,l.length>1?((n=this.startNodeAt(s,c)).expressions=l,this.finishNodeAt(n,`SequenceExpression`,h,g)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(r,i);return _.expression=n,this.finishNode(_,`ParenthesizedExpression`)}return n},F.parseParenItem=function(e){return e},F.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var je=[];F.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===x.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),this.eat(x.parenL)?e.arguments=this.parseExprList(x.parenR,this.options.ecmaVersion>=8,!1):e.arguments=je,this.finishNode(e,`NewExpression`)},F.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===x.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
+
`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
5
|
+
`),cooked:this.value},this.next(),n.tail=this.type===x.backQuote,this.finishNode(n,`TemplateElement`)},F.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===x.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(x.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(x.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},F.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===x.name||this.type===x.num||this.type===x.string||this.type===x.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===x.star)&&!S.test(this.input.slice(this.lastTokEnd,this.start))},F.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(x.braceR);){if(r)r=!1;else if(this.expect(x.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(x.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},F.parseProperty=function(e,t){var n,r,i,a,o=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(x.ellipsis))return e?(o.argument=this.parseIdent(!1),this.type===x.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(o,`RestElement`)):(o.argument=this.parseMaybeAssign(!1,t),this.type===x.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(o,`SpreadElement`));this.options.ecmaVersion>=6&&(o.method=!1,o.shorthand=!1,(e||t)&&(i=this.start,a=this.startLoc),e||(n=this.eat(x.star)));var s=this.containsEsc;return this.parsePropertyName(o),!e&&!s&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(o)?(r=!0,n=this.options.ecmaVersion>=9&&this.eat(x.star),this.parsePropertyName(o)):r=!1,this.parsePropertyValue(o,e,n,r,i,a,t,s),this.finishNode(o,`Property`)},F.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},F.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===x.colon&&this.unexpected(),this.eat(x.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===x.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):t||s||!(this.options.ecmaVersion>=5)||e.computed||e.key.type!==`Identifier`||e.key.name!==`get`&&e.key.name!==`set`||this.type===x.comma||this.type===x.braceR||this.type===x.eq?this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name!==`await`||this.awaitIdentPos||(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===x.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected():((n||r)&&this.unexpected(),this.parseGetterSetter(e))},F.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(x.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(x.bracketR),e.key;e.computed=!1}return e.key=this.type===x.num||this.type===x.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},F.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},F.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(64|ve(t,r.generator)|(n?128:0)),this.expect(x.parenL),r.params=this.parseBindingList(x.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},F.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(16|ve(n,!1)),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},F.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==x.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);a&&!s||(o=this.strictDirective(this.end))&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`);var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,5),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},F.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},F.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,1,t?null:n)}},F.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(x.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===x.comma?o=null:this.type===x.ellipsis?(o=this.parseSpread(r),r&&this.type===x.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},F.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;(this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),this.currentThisScope().flags&_e||r!==`arguments`||this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),!this.inClassStaticBlock||r!==`arguments`&&r!==`await`||this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\`)!==-1)||(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(this.inAsync||r!==`await`||this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},F.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name!==`await`||this.awaitIdentPos||(this.awaitIdentPos=t.start)),t},F.parseIdentNode=function(){var e=this.startNode();return this.type===x.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,e.name!==`class`&&e.name!==`function`||this.lastTokEnd===this.lastTokStart+1&&this.input.charCodeAt(this.lastTokStart)===46||this.context.pop(),this.type=x.name):this.unexpected(),e},F.parsePrivateIdent=function(){var e=this.startNode();return this.type===x.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},F.parseYield=function(e){this.yieldPos||=this.start;var t=this.startNode();return this.next(),this.type===x.semi||this.canInsertSemicolon()||this.type!==x.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(x.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},F.parseAwait=function(e){this.awaitPos||=this.start;var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var Me=O.prototype;Me.raise=function(e,t){var n=fe(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},Me.raiseRecoverable=Me.raise,Me.curPosition=function(){if(this.options.locations)return new ue(this.curLine,this.pos-this.lineStart)};var I=O.prototype,Ne=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};I.enterScope=function(e){this.scopeStack.push(new Ne(e))},I.exitScope=function(){this.scopeStack.pop()},I.treatFunctionsAsVarInScope=function(e){return 2&e.flags||!this.inModule&&1&e.flags},I.declareName=function(e,t,n){var r=!1;if(t===2){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&1&i.flags&&delete this.undefinedExports[e]}else if(t===4)this.currentScope().lexical.push(e);else if(t===3){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(32&s.flags&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&1&s.flags&&delete this.undefinedExports[e],s.flags&_e)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},I.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},I.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},I.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags)return t}},I.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags&&!(16&t.flags))return t}};var Pe=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new de(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Fe=O.prototype;function Ie(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}Fe.startNode=function(){return new Pe(this,this.start,this.startLoc)},Fe.startNodeAt=function(e,t){return new Pe(this,e,t)},Fe.finishNode=function(e,t){return Ie.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Fe.finishNodeAt=function(e,t,n,r){return Ie.call(this,e,t,n,r)},Fe.copyNode=function(e){var t=new Pe(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Le=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,Re=Le+` Extended_Pictographic`,ze=Re+` EBase EComp EMod EPres ExtPict`,Be={9:Le,10:Re,11:Re,12:ze,13:ze,14:ze},Ve={9:``,10:``,11:``,12:``,13:``,14:`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`},He=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,Ue=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,We=Ue+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,Ge=We+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,Ke=Ge+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,qe=Ke+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,Je={9:Ue,10:We,11:Ge,12:Ke,13:qe,14:qe+` Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz`},Ye={};function Xe(e){var t=Ye[e]={binary:E(Be[e]+` `+He),binaryOfStrings:E(Ve[e]),nonBinary:{General_Category:E(He),Script:E(Je[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var L=0,Ze=[9,10,11,12,13,14];L<Ze.length;L+=1)Xe(Ze[L]);var R=O.prototype,Qe=function(e,t){this.parent=e,this.base=t||this};Qe.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},Qe.prototype.sibling=function(){return new Qe(this.parent,this.base)};var z=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=Ye[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};function $e(e){return e===105||e===109||e===115}function et(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}function tt(e){return e>=65&&e<=90||e>=97&&e<=122}z.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=0|e,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},z.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},z.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!t&&!this.switchU||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},z.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i,a=n.charCodeAt(e);return!t&&!this.switchU||a<=55295||a>=57344||e+1>=r||(i=n.charCodeAt(e+1))<56320||i>57343?e+1:e+2},z.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},z.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},z.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},z.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},z.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},R.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)},R.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&function(e){for(var t in e)return!0;return!1}(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},R.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},R.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Qe(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},R.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},R.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):!!(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))&&(this.regexp_eatQuantifier(e),!0)},R.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},R.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},R.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},R.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},R.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},R.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},R.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);n||o||e.current()!==58||e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},R.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},R.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&$e(n);)t+=ce(n),e.advance();return t},R.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},R.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},R.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!et(t)&&(e.lastIntValue=t,e.advance(),!0)},R.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!et(n);)e.advance();return e.pos!==t},R.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return!(t===-1||t===36||t>=40&&t<=43||t===46||t===63||t===91||t===94||t===124)&&(e.advance(),!0)},R.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`);t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},R.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},R.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=ce(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=ce(e.lastIntValue);return!0}return!1},R.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),function(e){return p(e,!0)||e===36||e===95}(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)},R.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),function(e){return m(e,!0)||e===36||e===95||e===8204||e===8205}(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)},R.regexp_eatAtomEscape=function(e){return!!(this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e))||(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},R.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},R.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},R.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},R.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},R.regexp_eatZero=function(e){return e.current()===48&&!it(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},R.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114&&(e.lastIntValue=13,e.advance(),!0)},R.regexp_eatControlLetter=function(e){var t=e.current();return!!tt(t)&&(e.lastIntValue=t%32,e.advance(),!0)},R.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n,r=e.pos,i=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var a=e.lastIntValue;if(i&&a>=55296&&a<=56319){var o=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(s>=56320&&s<=57343)return e.lastIntValue=1024*(a-55296)+(s-56320)+65536,!0}e.pos=o,e.lastIntValue=a}return!0}if(i&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&(n=e.lastIntValue)>=0&&n<=1114111)return!0;i&&e.raise(`Invalid unicode escape`),e.pos=r}return!1},R.regexp_eatIdentityEscape=function(e){if(e.switchU)return!!this.regexp_eatSyntaxCharacter(e)||!!e.eat(47)&&(e.lastIntValue=47,!0);var t=e.current();return!(t===99||e.switchN&&t===107)&&(e.lastIntValue=t,e.advance(),!0)},R.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};function nt(e){return tt(e)||e===95}function rt(e){return nt(e)||it(e)}function it(e){return e>=48&&e<=57}function at(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function ot(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function st(e){return e>=48&&e<=55}R.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(function(e){return e===100||e===68||e===115||e===83||e===119||e===87}(t))return e.lastIntValue=-1,e.advance(),1;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){var r;if(e.lastIntValue=-1,e.advance(),e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===2&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return 0},R.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),1}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return 0},R.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){oe(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},R.regexp_validateUnicodePropertyNameOrValue=function(e,t){return e.unicodeProperties.binary.test(t)?1:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?2:void e.raise(`Invalid property name`)},R.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;nt(t=e.current());)e.lastStringValue+=ce(t),e.advance();return e.lastStringValue!==``},R.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;rt(t=e.current());)e.lastStringValue+=ce(t),e.advance();return e.lastStringValue!==``},R.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},R.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===2&&e.raise(`Negated character class may contain strings`),!0}return!1},R.regexp_classContents=function(e){return e.current()===93?1:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),1)},R.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;!e.switchU||t!==-1&&n!==-1||e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},R.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||st(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r!==93&&(e.lastIntValue=r,e.advance(),!0)},R.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},R.regexp_classSetExpression=function(e){var t,n=1;if(!this.regexp_eatClassSetRange(e))if(t=this.regexp_eatClassSetOperand(e)){t===2&&(n=2);for(var r=e.pos;e.eatChars([38,38]);)e.current()!==38&&(t=this.regexp_eatClassSetOperand(e))?t!==2&&(n=1):e.raise(`Invalid character in character class`);if(r!==e.pos)return n;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return n}else e.raise(`Invalid character in character class`);for(;;)if(!this.regexp_eatClassSetRange(e)){if(!(t=this.regexp_eatClassSetOperand(e)))return n;t===2&&(n=2)}},R.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},R.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?1:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},R.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===2&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},R.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},R.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===2&&(t=2);return t},R.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?1:2},R.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return!(!this.regexp_eatCharacterEscape(e)&&!this.regexp_eatClassSetReservedPunctuator(e))||(e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1));var n=e.current();return!(n<0||n===e.lookahead()&&function(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}(n))&&!function(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}(n)&&(e.advance(),e.lastIntValue=n,!0)},R.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!function(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}(t)&&(e.lastIntValue=t,e.advance(),!0)},R.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!it(t)&&t!==95)&&(e.lastIntValue=t%32,e.advance(),!0)},R.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},R.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;it(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t},R.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;at(n=e.current());)e.lastIntValue=16*e.lastIntValue+ot(n),e.advance();return e.pos!==t},R.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*n+e.lastIntValue:e.lastIntValue=8*t+n}else e.lastIntValue=t;return!0}return!1},R.regexp_eatOctalDigit=function(e){var t=e.current();return st(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},R.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!at(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+ot(i),e.advance()}return!0};var ct=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new de(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},B=O.prototype;function lt(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}B.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new ct(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},B.getToken=function(){return this.next(),new ct(this)},typeof Symbol<`u`&&(B[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===x.eof,value:t}}}}),B.nextToken=function(){var e=this.curContext();return e&&e.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(x.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},B.readToken=function(e){return p(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},B.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},B.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=te(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},B.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!C(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},B.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(!(e>8&&e<14||e>=5760&&ne.test(String.fromCharCode(e))))break e;++this.pos}}},B.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},B.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(x.ellipsis)):(++this.pos,this.finishToken(x.dot))},B.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(x.assign,2):this.finishOp(x.slash,1)},B.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?x.star:x.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=x.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(x.assign,n+1):this.finishOp(r,n)},B.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(x.assign,3):this.finishOp(e===124?x.logicalOR:x.logicalAND,2):t===61?this.finishOp(x.assign,2):this.finishOp(e===124?x.bitwiseOR:x.bitwiseAND,1)},B.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(x.assign,2):this.finishOp(x.bitwiseXOR,1)},B.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t!==45||this.inModule||this.input.charCodeAt(this.pos+2)!==62||this.lastTokEnd!==0&&!S.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(x.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):t===61?this.finishOp(x.assign,2):this.finishOp(x.plusMin,1)},B.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(x.assign,n+1):this.finishOp(x.bitShift,n)):t!==33||e!==60||this.inModule||this.input.charCodeAt(this.pos+2)!==45||this.input.charCodeAt(this.pos+3)!==45?(t===61&&(n=2),this.finishOp(x.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},B.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(x.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(x.arrow)):this.finishOp(e===61?x.eq:x.prefix,1)},B.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(x.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(x.assign,3):this.finishOp(x.coalesce,2)}return this.finishOp(x.question,1)},B.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,p(e=this.fullCharCodeAtPos(),!0)||e===92))return this.finishToken(x.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+ce(e)+`'`)},B.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(x.parenL);case 41:return++this.pos,this.finishToken(x.parenR);case 59:return++this.pos,this.finishToken(x.semi);case 44:return++this.pos,this.finishToken(x.comma);case 91:return++this.pos,this.finishToken(x.bracketL);case 93:return++this.pos,this.finishToken(x.bracketR);case 123:return++this.pos,this.finishToken(x.braceL);case 125:return++this.pos,this.finishToken(x.braceR);case 58:return++this.pos,this.finishToken(x.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(x.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(x.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+ce(e)+`'`)},B.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},B.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(S.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||=new z(this);s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(x.regexp,{pattern:i,flags:o,value:c})},B.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95)i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;else{if((d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0)>=e)break;s=u,o=o*e+d}}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o},B.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=lt(this.input.slice(t,this.pos)),++this.pos):p(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(x.num,n)},B.readNumber=function(e){var t=this.pos;e||this.readInt(10,void 0,!0)!==null||this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=lt(this.input.slice(t,this.pos));return++this.pos,p(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(x.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r!==46||n||(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),r!==69&&r!==101||n||((r=this.input.charCodeAt(++this.pos))!==43&&r!==45||++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),p(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a,o=(a=this.input.slice(t,this.pos),n?parseInt(a,8):parseFloat(a.replace(/_/g,``)));return this.finishToken(x.num,o)},B.readCodePoint=function(){var e;if(this.input.charCodeAt(this.pos)===123){this.options.ecmaVersion<6&&this.unexpected();var t=++this.pos;e=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(t,`Code point out of bounds`)}else e=this.readHexChar(4);return e},B.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(C(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(x.string,t)};var ut={};B.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==ut)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},B.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw ut;this.raise(e,t)},B.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos!==this.start||this.type!==x.template&&this.type!==x.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(x.template,e)):n===36?(this.pos+=2,this.finishToken(x.dollarBraceL)):(++this.pos,this.finishToken(x.backQuote));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(C(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
6
|
+
`;break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else ++this.pos}},B.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case"`":return this.finishToken(x.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
|
|
7
|
+
`&&++this.pos;case`
|
|
8
|
+
`:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,`Unterminated template`)},B.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
9
|
+
`;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return ce(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),r===`0`&&t!==56&&t!==57||!this.strict&&!e||this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return C(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},B.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},B.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(m(i,r))this.pos+=i<=65535?1:2;else{if(i!==92)break;this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?p:m)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=ce(o),n=this.pos}t=!1}return e+this.input.slice(n,this.pos)},B.readWord=function(){var e=this.readWord1(),t=x.name;return this.keywords.test(e)&&(t=y[e]),this.finishToken(t,e)},O.acorn={Parser:O,version:`8.15.0`,defaultOptions:pe,Position:ue,SourceLocation:de,getLineInfo:fe,Node:Pe,TokenType:h,tokTypes:x,keywordTypes:y,TokContext:N,tokContexts:P,isIdentifierChar:m,isIdentifierStart:p,Token:ct,isNewLine:C,lineBreak:S,lineBreakG:ee,nonASCIIwhitespace:ne};let dt=D(`node:module`),V=D(`node:fs`);String.fromCharCode;let ft=/\/$|\/\?|\/#/,pt=/^\.?\//;function mt(e=``,t){return t?ft.test(e):e.endsWith(`/`)}function ht(e=``,t){if(!t)return e.endsWith(`/`)?e:e+`/`;if(mt(e,!0))return e||`/`;let n=e,r=``,i=e.indexOf(`#`);if(i!==-1&&(n=e.slice(0,i),r=e.slice(i),!n))return r;let[a,...o]=n.split(`?`);return a+`/`+(o.length>0?`?${o.join(`?`)}`:``)+r}function gt(e){return e&&e!==`/`}function _t(e,...t){let n=e||``;for(let e of t.filter(e=>gt(e)))if(n){let t=e.replace(pt,``);n=ht(n)+t}else n=e;return n}let vt=/^[A-Za-z]:\//;function yt(e=``){return e&&e.replace(/\\/g,`/`).replace(vt,e=>e.toUpperCase())}let bt=/^[/\\]{2}/,xt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,St=/^[A-Za-z]:$/,Ct=/.(\.[^./]+|\.)$/,wt=function(e){if(e.length===0)return`.`;let t=(e=yt(e)).match(bt),n=kt(e),r=e[e.length-1]===`/`;return(e=Ot(e,!n)).length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),St.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!kt(e)?`/${e}`:e)},Tt=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;t+=e&&r?n.slice(1):e||r?n:`/${n}`}else t+=n;return wt(t)};function Et(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}let Dt=function(...e){let t=``,n=!1;for(let r=(e=e.map(e=>yt(e))).length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:Et();i&&i.length!==0&&(t=`${i}/${t}`,n=kt(i))}return t=Ot(t,!n),n&&!kt(t)?`/${t}`:t.length>0?t:`.`};function Ot(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else{if(o===`/`)break;o=`/`}if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}let kt=function(e){return xt.test(e)},At=function(e){if(e===`..`)return``;let t=Ct.exec(yt(e));return t&&t[1]||``},jt=function(e){let t=yt(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&St.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(kt(e)?`/`:`.`)},Mt=function(e,t){let n=yt(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r},H=D(`node:url`),U=D(`node:assert`),Nt=D(`node:process`),W=D(`node:path`),Pt=D(`node:v8`),Ft=D(`node:util`),It=new Set(dt.builtinModules);function Lt(e){return e.replace(/\\/g,`/`)}let Rt={}.hasOwnProperty,zt=/^([A-Z][a-z\d]*)+$/,Bt=new Set([`string`,`function`,`number`,`object`,`Function`,`Object`,`boolean`,`bigint`,`symbol`]),G={};function Vt(e,t=`and`){return e.length<3?e.join(` ${t} `):`${e.slice(0,-1).join(`, `)}, ${t} ${e[e.length-1]}`}let Ht=new Map,K;function q(e,t,n){return Ht.set(e,t),function(e,t){return n;function n(...n){let r=Error.stackTraceLimit;Ut()&&(Error.stackTraceLimit=0);let i=new e;Ut()&&(Error.stackTraceLimit=r);let a=function(e,t,n){let r=Ht.get(e);if(U(r!==void 0,"expected `message` to be found"),typeof r==`function`)return U(r.length<=t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${r.length}).`),Reflect.apply(r,n,t);let i=/%[dfijoOs]/g,a=0;for(;i.exec(r)!==null;)a++;return U(a===t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${a}).`),t.length===0?r:(t.unshift(r),Reflect.apply(Ft.format,null,t))}(t,n,i);return Object.defineProperties(i,{message:{value:a,enumerable:!1,writable:!0,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},enumerable:!1,writable:!0,configurable:!0}}),Wt(i),i.code=t,i}}(n,e)}function Ut(){try{if(Pt.startupSnapshot.isBuildingSnapshot())return!1}catch{}let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Rt.call(e,`writable`)&&e.writable!==void 0?e.writable:e.set!==void 0}G.ERR_INVALID_ARG_TYPE=q(`ERR_INVALID_ARG_TYPE`,(e,t,n)=>{U(typeof e==`string`,`'name' must be a string`),Array.isArray(t)||(t=[t]);let r=`The `;if(e.endsWith(` argument`))r+=`${e} `;else{let t=e.includes(`.`)?`property`:`argument`;r+=`"${e}" ${t} `}r+=`must be `;let i=[],a=[],o=[];for(let e of t)U(typeof e==`string`,`All expected entries have to be of type string`),Bt.has(e)?i.push(e.toLowerCase()):zt.exec(e)===null?(U(e!==`object`,`The value "object" should be written as "Object"`),o.push(e)):a.push(e);if(a.length>0){let e=i.indexOf(`object`);e!==-1&&(i.slice(e,1),a.push(`Object`))}return i.length>0&&(r+=`${i.length>1?`one of type`:`of type`} ${Vt(i,`or`)}`,(a.length>0||o.length>0)&&(r+=` or `)),a.length>0&&(r+=`an instance of ${Vt(a,`or`)}`,o.length>0&&(r+=` or `)),o.length>0&&(o.length>1?r+=`one of ${Vt(o,`or`)}`:(o[0].toLowerCase()!==o[0]&&(r+=`an `),r+=`${o[0]}`)),r+=`. Received ${function(e){if(e==null)return String(e);if(typeof e==`function`&&e.name)return`function ${e.name}`;if(typeof e==`object`)return e.constructor&&e.constructor.name?`an instance of ${e.constructor.name}`:`${(0,Ft.inspect)(e,{depth:-1})}`;let t=(0,Ft.inspect)(e,{colors:!1});return t.length>28&&(t=`${t.slice(0,25)}...`),`type ${typeof e} (${t})`}(n)}`,r},TypeError),G.ERR_INVALID_MODULE_SPECIFIER=q(`ERR_INVALID_MODULE_SPECIFIER`,(e,t,n=void 0)=>`Invalid module "${e}" ${t}${n?` imported from ${n}`:``}`,TypeError),G.ERR_INVALID_PACKAGE_CONFIG=q(`ERR_INVALID_PACKAGE_CONFIG`,(e,t,n)=>`Invalid package config ${e}${t?` while importing ${t}`:``}${n?`. ${n}`:``}`,Error),G.ERR_INVALID_PACKAGE_TARGET=q(`ERR_INVALID_PACKAGE_TARGET`,(e,t,n,r=!1,i=void 0)=>{let a=typeof n==`string`&&!r&&n.length>0&&!n.startsWith(`./`);return t===`.`?(U(!1===r),`Invalid "exports" main target ${JSON.stringify(n)} defined in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`):`Invalid "${r?`imports`:`exports`}" target ${JSON.stringify(n)} defined for '${t}' in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`},Error),G.ERR_MODULE_NOT_FOUND=q(`ERR_MODULE_NOT_FOUND`,(e,t,n=!1)=>`Cannot find ${n?`module`:`package`} '${e}' imported from ${t}`,Error),G.ERR_NETWORK_IMPORT_DISALLOWED=q(`ERR_NETWORK_IMPORT_DISALLOWED`,`import of '%s' by %s is not supported: %s`,Error),G.ERR_PACKAGE_IMPORT_NOT_DEFINED=q(`ERR_PACKAGE_IMPORT_NOT_DEFINED`,(e,t,n)=>`Package import specifier "${e}" is not defined${t?` in package ${t}package.json`:``} imported from ${n}`,TypeError),G.ERR_PACKAGE_PATH_NOT_EXPORTED=q(`ERR_PACKAGE_PATH_NOT_EXPORTED`,(e,t,n=void 0)=>t===`.`?`No "exports" main defined in ${e}package.json${n?` imported from ${n}`:``}`:`Package subpath '${t}' is not defined by "exports" in ${e}package.json${n?` imported from ${n}`:``}`,Error),G.ERR_UNSUPPORTED_DIR_IMPORT=q(`ERR_UNSUPPORTED_DIR_IMPORT`,`Directory import '%s' is not supported resolving ES modules imported from %s`,Error),G.ERR_UNSUPPORTED_RESOLVE_REQUEST=q(`ERR_UNSUPPORTED_RESOLVE_REQUEST`,`Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.`,TypeError),G.ERR_UNKNOWN_FILE_EXTENSION=q(`ERR_UNKNOWN_FILE_EXTENSION`,(e,t)=>`Unknown file extension "${e}" for ${t}`,TypeError),G.ERR_INVALID_ARG_VALUE=q(`ERR_INVALID_ARG_VALUE`,(e,t,n=`is invalid`)=>{let r=(0,Ft.inspect)(t);return r.length>128&&(r=`${r.slice(0,128)}...`),`The ${e.includes(`.`)?`property`:`argument`} '${e}' ${n}. Received ${r}`},TypeError);let Wt=function(e){let t=`__node_internal_`+e.name;return Object.defineProperty(e,`name`,{value:t}),e}(function(e){let t=Ut();return t&&(K=Error.stackTraceLimit,Error.stackTraceLimit=1/0),Error.captureStackTrace(e),t&&(Error.stackTraceLimit=K),e}),Gt={}.hasOwnProperty,{ERR_INVALID_PACKAGE_CONFIG:Kt}=G,J=new Map;function qt(e,{base:t,specifier:n}){let r=J.get(e);if(r)return r;let i;try{i=V.readFileSync(W.toNamespacedPath(e),`utf8`)}catch(e){let t=e;if(t.code!==`ENOENT`)throw t}let a={exists:!1,pjsonPath:e,main:void 0,name:void 0,type:`none`,exports:void 0,imports:void 0};if(i!==void 0){let r;try{r=JSON.parse(i)}catch(r){let i=r,a=new Kt(e,(t?`"${n}" from `:``)+(0,H.fileURLToPath)(t||n),i.message);throw a.cause=i,a}a.exists=!0,Gt.call(r,`name`)&&typeof r.name==`string`&&(a.name=r.name),Gt.call(r,`main`)&&typeof r.main==`string`&&(a.main=r.main),Gt.call(r,`exports`)&&(a.exports=r.exports),Gt.call(r,`imports`)&&(a.imports=r.imports),!Gt.call(r,`type`)||r.type!==`commonjs`&&r.type!==`module`||(a.type=r.type)}return J.set(e,a),a}function Jt(e){let t=new URL(`package.json`,e);for(;!t.pathname.endsWith(`node_modules/package.json`);){let n=qt((0,H.fileURLToPath)(t),{specifier:e});if(n.exists)return n;let r=t;if(t=new URL(`../package.json`,t),t.pathname===r.pathname)break}return{pjsonPath:(0,H.fileURLToPath)(t),exists:!1,type:`none`}}function Yt(e){return Jt(e).type}let{ERR_UNKNOWN_FILE_EXTENSION:Xt}=G,Zt={}.hasOwnProperty,Qt={__proto__:null,".cjs":`commonjs`,".js":`module`,".json":`json`,".mjs":`module`},Y={__proto__:null,"data:":function(e){let{1:t}=/^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(e.pathname)||[null,null,null];return function(e){return e&&/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(e)?`module`:e===`application/json`?`json`:null}(t)},"file:":function(e,t,n){let r=function(e){let t=e.pathname,n=t.length;for(;n--;){let e=t.codePointAt(n);if(e===47)return``;if(e===46)return t.codePointAt(n-1)===47?``:t.slice(n)}return``}(e);if(r===`.js`){let t=Yt(e);return t===`none`?`commonjs`:t}if(r===``){let t=Yt(e);return t===`none`||t===`commonjs`?`commonjs`:`module`}let i=Qt[r];if(i)return i;if(!n)throw new Xt(r,(0,H.fileURLToPath)(e))},"http:":$t,"https:":$t,"node:":()=>`builtin`};function $t(){}let en=RegExp.prototype[Symbol.replace],{ERR_INVALID_MODULE_SPECIFIER:tn,ERR_INVALID_PACKAGE_CONFIG:nn,ERR_INVALID_PACKAGE_TARGET:rn,ERR_MODULE_NOT_FOUND:X,ERR_PACKAGE_IMPORT_NOT_DEFINED:an,ERR_PACKAGE_PATH_NOT_EXPORTED:on,ERR_UNSUPPORTED_DIR_IMPORT:sn,ERR_UNSUPPORTED_RESOLVE_REQUEST:cn}=G,ln={}.hasOwnProperty,un=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i,dn=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i,fn=/^\.|%|\\/,pn=/\*/g,mn=/%2f|%5c/i,hn=new Set,gn=/[/\\]{2}/;function _n(e,t,n,r,i,a,o){if(Nt.noDeprecation)return;let s=(0,H.fileURLToPath)(r),c=gn.exec(o?e:t)!==null;Nt.emitWarning(`Use of deprecated ${c?`double slash`:`leading or trailing slash matching`} resolving "${e}" for module request "${t}" ${t===n?``:`matched to "${n}" `}in the "${i?`imports`:`exports`}" field module resolution of the package at ${s}${a?` imported from ${(0,H.fileURLToPath)(a)}`:``}.`,`DeprecationWarning`,`DEP0166`)}function vn(e,t,n,r){if(Nt.noDeprecation||function(e,t){let n=e.protocol;return Zt.call(Y,n)&&Y[n](e,t,!0)||null}(e,{parentURL:n.href})!==`module`)return;let i=(0,H.fileURLToPath)(e.href),a=(0,H.fileURLToPath)(new H.URL(`.`,t)),o=(0,H.fileURLToPath)(n);r?W.resolve(a,r)!==i&&Nt.emitWarning(`Package ${a} has a "main" field set to "${r}", excluding the full filename and extension to the resolved file at "${i.slice(a.length)}", imported from ${o}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`):Nt.emitWarning(`No "main" or "exports" field defined in the package.json for ${a} resolving the main entry point "${i.slice(a.length)}", imported from ${o}.\nDefault "index" lookups for the main are deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`)}function yn(e){try{return(0,V.statSync)(e)}catch{}}function bn(e){let t=(0,V.statSync)(e,{throwIfNoEntry:!1}),n=t?t.isFile():void 0;return n!=null&&n}function xn(e,t,n){let r;if(t.main!==void 0){if(r=new H.URL(t.main,e),bn(r))return r;let i=[`./${t.main}.js`,`./${t.main}.json`,`./${t.main}.node`,`./${t.main}/index.js`,`./${t.main}/index.json`,`./${t.main}/index.node`],a=-1;for(;++a<i.length&&(r=new H.URL(i[a],e),!bn(r));)r=void 0;if(r)return vn(r,e,n,t.main),r}let i=[`./index.js`,`./index.json`,`./index.node`],a=-1;for(;++a<i.length&&(r=new H.URL(i[a],e),!bn(r));)r=void 0;if(r)return vn(r,e,n,t.main),r;throw new X((0,H.fileURLToPath)(new H.URL(`.`,e)),(0,H.fileURLToPath)(n))}function Sn(e,t,n){return new on((0,H.fileURLToPath)(new H.URL(`.`,t)),e,n&&(0,H.fileURLToPath)(n))}function Cn(e,t,n,r,i){return t=typeof t==`object`&&t?JSON.stringify(t,null,``):`${t}`,new rn((0,H.fileURLToPath)(new H.URL(`.`,n)),e,t,r,i&&(0,H.fileURLToPath)(i))}function wn(e,t,n,r,i,a,o,s,c){if(t!==``&&!a&&e[e.length-1]!==`/`)throw Cn(n,e,r,o,i);if(!e.startsWith(`./`)){if(o&&!e.startsWith(`../`)&&!e.startsWith(`/`)){let n=!1;try{new H.URL(e),n=!0}catch{}if(!n)return jn(a?en.call(pn,e,()=>t):e+t,r,c)}throw Cn(n,e,r,o,i)}if(un.exec(e.slice(2))!==null){if(dn.exec(e.slice(2))!==null)throw Cn(n,e,r,o,i);if(!s){let s=a?n.replace(`*`,()=>t):n+t;_n(a?en.call(pn,e,()=>t):e,s,n,r,o,i,!0)}}let l=new H.URL(e,r),u=l.pathname,d=new H.URL(`.`,r).pathname;if(!u.startsWith(d))throw Cn(n,e,r,o,i);if(t===``)return l;if(un.exec(t)!==null){let c=a?n.replace(`*`,()=>t):n+t;dn.exec(t)===null?s||_n(a?en.call(pn,e,()=>t):e,c,n,r,o,i,!1):(function(e,t,n,r,i){throw new tn(e,`request is not a valid match in pattern "${t}" for the "${r?`imports`:`exports`}" resolution of ${(0,H.fileURLToPath)(n)}`,i&&(0,H.fileURLToPath)(i))})(c,n,r,o,i)}return a?new H.URL(en.call(pn,l.href,()=>t)):new H.URL(t,l)}function Tn(e){let t=Number(e);return`${t}`===e&&t>=0&&t<4294967295}function En(e,t,n,r,i,a,o,s,c){if(typeof t==`string`)return wn(t,n,r,e,i,a,o,s,c);if(Array.isArray(t)){let l=t;if(l.length===0)return null;let u,d=-1;for(;++d<l.length;){let t=l[d],f;try{f=En(e,t,n,r,i,a,o,s,c)}catch(e){if(u=e,e.code===`ERR_INVALID_PACKAGE_TARGET`)continue;throw e}if(f!==void 0){if(f!==null)return f;u=null}}if(u==null)return null;throw u}if(typeof t==`object`&&t){let l=Object.getOwnPropertyNames(t),u=-1;for(;++u<l.length;)if(Tn(l[u]))throw new nn((0,H.fileURLToPath)(e),i,`"exports" cannot contain numeric property keys.`);for(u=-1;++u<l.length;){let d=l[u];if(d===`default`||c&&c.has(d)){let l=En(e,t[d],n,r,i,a,o,s,c);if(l===void 0)continue;return l}}return null}if(t===null)return null;throw Cn(r,t,e,o,i)}function Dn(e,t,n){if(Nt.noDeprecation)return;let r=(0,H.fileURLToPath)(t);hn.has(r+`|`+e)||(hn.add(r+`|`+e),Nt.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${r}${n?` imported from ${(0,H.fileURLToPath)(n)}`:``}. Mapping specifiers ending in "/" is no longer supported.`,`DeprecationWarning`,`DEP0155`))}function On(e,t,n,r,i){let a=n.exports;if(function(e,t,n){if(typeof e==`string`||Array.isArray(e))return!0;if(typeof e!=`object`||!e)return!1;let r=Object.getOwnPropertyNames(e),i=!1,a=0,o=-1;for(;++o<r.length;){let e=r[o],s=e===``||e[0]!==`.`;if(a++===0)i=s;else if(i!==s)throw new nn((0,H.fileURLToPath)(t),n,`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`)}return i}(a,e,r)&&(a={".":a}),ln.call(a,t)&&!t.includes(`*`)&&!t.endsWith(`/`)){let n=En(e,a[t],``,t,r,!1,!1,!1,i);if(n==null)throw Sn(t,e,r);return n}let o=``,s=``,c=Object.getOwnPropertyNames(a),l=-1;for(;++l<c.length;){let n=c[l],i=n.indexOf(`*`);if(i!==-1&&t.startsWith(n.slice(0,i))){t.endsWith(`/`)&&Dn(t,e,r);let a=n.slice(i+1);t.length>=n.length&&t.endsWith(a)&&kn(o,n)===1&&n.lastIndexOf(`*`)===i&&(o=n,s=t.slice(i,t.length-a.length))}}if(o){let n=En(e,a[o],s,o,r,!0,!1,t.endsWith(`/`),i);if(n==null)throw Sn(t,e,r);return n}throw Sn(t,e,r)}function kn(e,t){let n=e.indexOf(`*`),r=t.indexOf(`*`),i=n===-1?e.length:n+1,a=r===-1?t.length:r+1;return i>a?-1:a>i||n===-1?1:r===-1||e.length>t.length?-1:t.length>e.length?1:0}function An(e,t,n){if(e===`#`||e.startsWith(`#/`)||e.endsWith(`/`))throw new tn(e,`is not a valid internal imports specifier name`,(0,H.fileURLToPath)(t));let r,i=Jt(t);if(i.exists){r=(0,H.pathToFileURL)(i.pjsonPath);let a=i.imports;if(a)if(ln.call(a,e)&&!e.includes(`*`)){let i=En(r,a[e],``,e,t,!1,!0,!1,n);if(i!=null)return i}else{let i=``,o=``,s=Object.getOwnPropertyNames(a),c=-1;for(;++c<s.length;){let t=s[c],n=t.indexOf(`*`);if(n!==-1&&e.startsWith(t.slice(0,-1))){let r=t.slice(n+1);e.length>=t.length&&e.endsWith(r)&&kn(i,t)===1&&t.lastIndexOf(`*`)===n&&(i=t,o=e.slice(n,e.length-r.length))}}if(i){let e=En(r,a[i],o,i,t,!0,!0,!1,n);if(e!=null)return e}}}throw function(e,t,n){return new an(e,t&&(0,H.fileURLToPath)(new H.URL(`.`,t)),(0,H.fileURLToPath)(n))}(e,r,t)}function jn(e,t,n){if(dt.builtinModules.includes(e))return new H.URL(`node:`+e);let{packageName:r,packageSubpath:i,isScoped:a}=function(e,t){let n=e.indexOf(`/`),r=!0,i=!1;e[0]===`@`&&(i=!0,n===-1||e.length===0?r=!1:n=e.indexOf(`/`,n+1));let a=n===-1?e:e.slice(0,n);if(fn.exec(a)!==null&&(r=!1),!r)throw new tn(e,`is not a valid package name`,(0,H.fileURLToPath)(t));return{packageName:a,packageSubpath:`.`+(n===-1?``:e.slice(n)),isScoped:i}}(e,t),o=Jt(t);if(o.exists){let e=(0,H.pathToFileURL)(o.pjsonPath);if(o.name===r&&o.exports!==void 0&&o.exports!==null)return On(e,i,o,t,n)}let s,c=new H.URL(`./node_modules/`+r+`/package.json`,t),l=(0,H.fileURLToPath)(c);do{let o=yn(l.slice(0,-13));if(!o||!o.isDirectory()){s=l,c=new H.URL((a?`../../../../node_modules/`:`../../../node_modules/`)+r+`/package.json`,c),l=(0,H.fileURLToPath)(c);continue}let u=qt(l,{base:t,specifier:e});return u.exports!==void 0&&u.exports!==null?On(c,i,u,t,n):i===`.`?xn(c,u,t):new H.URL(i,c)}while(l.length!==s.length);throw new X(r,(0,H.fileURLToPath)(t),!1)}function Mn(e,t,n,r){let i=t.protocol,a=i===`data:`||i===`http:`||i===`https:`,o;if(function(e){return e!==``&&(e[0]===`/`||function(e){return e[0]===`.`&&(e.length===1||e[1]===`/`||e[1]===`.`&&(e.length===2||e[2]===`/`))}(e))}(e))try{o=new H.URL(e,t)}catch(n){let r=new cn(e,t);throw r.cause=n,r}else if(i===`file:`&&e[0]===`#`)o=An(e,t,n);else try{o=new H.URL(e)}catch(r){if(a&&!dt.builtinModules.includes(e)){let n=new cn(e,t);throw n.cause=r,n}o=jn(e,t,n)}return U(o!==void 0,`expected to be defined`),o.protocol===`file:`?function(e,t){if(mn.exec(e.pathname)!==null)throw new tn(e.pathname,`must not include encoded "/" or "\\" characters`,(0,H.fileURLToPath)(t));let n;try{n=(0,H.fileURLToPath)(e)}catch(n){let r=n;throw Object.defineProperty(r,`input`,{value:String(e)}),Object.defineProperty(r,`module`,{value:String(t)}),r}let r=yn(n.endsWith(`/`)?n.slice(-1):n);if(r&&r.isDirectory()){let r=new sn(n,(0,H.fileURLToPath)(t));throw r.url=String(e),r}if(!r||!r.isFile()){let r=new X(n||e.pathname,t&&(0,H.fileURLToPath)(t),!0);throw r.url=String(e),r}{let t=(0,V.realpathSync)(n),{search:r,hash:i}=e;(e=(0,H.pathToFileURL)(t+(n.endsWith(W.sep)?`/`:``))).search=r,e.hash=i}return e}(o,t):o}function Z(e){return typeof e!=`string`||e.startsWith(`file://`)?Lt((0,H.fileURLToPath)(e)):Lt(e)}function Nn(e){return(0,H.pathToFileURL)(Z(e)).toString()}let Pn=new Set([`node`,`import`]),Fn=[`.mjs`,`.cjs`,`.js`,`.json`],In=new Set([`ERR_MODULE_NOT_FOUND`,`ERR_UNSUPPORTED_DIR_IMPORT`,`MODULE_NOT_FOUND`,`ERR_PACKAGE_PATH_NOT_EXPORTED`]);function Ln(e,t,n){try{return Mn(e,t,n)}catch(e){if(!In.has(e?.code))throw e}}function Rn(e,t={}){if(typeof e!=`string`){if(!(e instanceof URL))throw TypeError("input must be a `string` or `URL`");e=Z(e)}if(/(?:node|data|http|https):/.test(e))return e;if(It.has(e))return`node:`+e;if(e.startsWith(`file://`)&&(e=Z(e)),kt(e))try{if((0,V.statSync)(e).isFile())return Nn(e)}catch(e){if(e?.code!==`ENOENT`)throw e}let n=t.conditions?new Set(t.conditions):Pn,r=(Array.isArray(t.url)?t.url:[t.url]).filter(Boolean).map(e=>new URL(function(e){return typeof e!=`string`&&(e=e.toString()),/(?:node|data|http|https|file):/.test(e)?e:It.has(e)?`node:`+e:`file://`+encodeURI(Lt(e))}(e.toString())));r.length===0&&r.push(new URL(Nn(process.cwd())));let i=[...r];for(let e of r)e.protocol===`file:`&&i.push(new URL(`./`,e),new URL(_t(e.pathname,`_index.js`),e),new URL(`node_modules`,e));let a;for(let r of i){if(a=Ln(e,r,n),a)break;for(let i of[``,`/index`]){for(let o of t.extensions||Fn)if(a=Ln(_t(e,i)+o,r,n),a)break;if(a)break}if(a)break}if(!a){let t=Error(`Cannot find module ${e} imported from ${i.join(`, `)}`);throw t.code=`ERR_MODULE_NOT_FOUND`,t}return Nn(a)}function zn(e,t){return Rn(e,t)}function Bn(e,t){return Z(zn(e,t))}let Vn=/(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m,Hn=/\/\*.+?\*\/|\/\/.*(?=[nr])/g;function Un(e,t={}){return t.stripComments&&(e=e.replace(Hn,``)),Vn.test(e)}function Wn(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}let Gn=new Set([`/`,`\\`,void 0]),Kn=Symbol.for(`pathe:normalizedAlias`),qn=/[/\\]/;function Jn(e){if(e[Kn])return e;let t=Object.fromEntries(Object.entries(e).sort(([e],[t])=>function(e,t){return t.split(`/`).length-e.split(`/`).length}(e,t)));for(let e in t)for(let n in t)n===e||e.startsWith(n)||t[e]?.startsWith(n)&&Gn.has(t[e][n.length])&&(t[e]=t[n]+t[e].slice(n.length));return Object.defineProperty(t,Kn,{value:!0,enumerable:!1}),t}function Yn(e=`/`){let t=e[e.length-1];return t===`/`||t===`\\`}var Xn={rE:`2.6.1`};let Zn=D(`node:crypto`);var Qn=r.n(Zn);let $n=Object.create(null),er=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?$n:globalThis),tr=new Proxy($n,{get:(e,t)=>er()[t]??$n[t],has:(e,t)=>t in er()||t in $n,set:(e,t,n)=>(er(!0)[t]=n,!0),deleteProperty(e,t){return t?(delete er(!0)[t],!0):!1},ownKeys(){let e=er(!0);return Object.keys(e)}}),nr=typeof process<`u`&&process.env&&process.env.NODE_ENV||``,rr=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CLOUDFLARE_WORKERS`,`WORKERS_CI`,{ci:!0}],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`HUDSON`,`HUDSON_URL`],[`JENKINS`,`JENKINS_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}]],ir=function(){if(globalThis.process?.env)for(let e of rr){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL===`/bin/jsh`&&globalThis.process?.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}();ir.name;function ar(e){return!!e&&e!==`false`}let or=globalThis.process?.platform||``;ar(tr.CI)||ir.ci;let sr=ar(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY);tr.DEBUG,nr===`test`||tr.TEST;let cr=(tr.MINIMAL,/^win/i.test(or)),lr=(/^linux/i.test(or),/^darwin/i.test(or),!ar(tr.NO_COLOR)&&(ar(tr.FORCE_COLOR)||(sr||cr)&&tr.TERM),(globalThis.process?.versions?.node||``).replace(/^v/,``)||null),ur=(Number(lr?.split(`.`)[0]),globalThis.process||Object.create(null)),dr={versions:{}},fr=(new Proxy(ur,{get:(e,t)=>t===`env`?tr:t in e?e[t]:t in dr?dr[t]:void 0}),globalThis.process?.release?.name===`node`),pr=!!globalThis.Bun||!!globalThis.process?.versions?.bun,mr=!!globalThis.Deno,hr=!!globalThis.fastly,gr=[[!!globalThis.Netlify,`netlify`],[!!globalThis.EdgeRuntime,`edge-light`],[globalThis.navigator?.userAgent===`Cloudflare-Workers`,`workerd`],[hr,`fastly`],[mr,`deno`],[pr,`bun`],[fr,`node`]];(function(){let e=gr.find(e=>e[0]);e&&e[1]})();let _r=D(`node:tty`)?.WriteStream?.prototype?.hasColors?.()??!1,Q=(e,t)=>{if(!_r)return e=>e;let n=`[${e}m`,r=`[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}},vr=(Q(0,0),Q(1,22),Q(2,22),Q(3,23),Q(4,24),Q(53,55),Q(7,27),Q(8,28),Q(9,29),Q(30,39),Q(31,39)),yr=Q(32,39),br=Q(33,39),xr=Q(34,39),Sr=(Q(35,39),Q(36,39)),Cr=(Q(37,39),Q(90,39));Q(40,49),Q(41,49),Q(42,49),Q(43,49),Q(44,49),Q(45,49),Q(46,49),Q(47,49),Q(100,49),Q(91,39),Q(92,39),Q(93,39),Q(94,39),Q(95,39),Q(96,39),Q(97,39),Q(101,49),Q(102,49),Q(103,49),Q(104,49),Q(105,49),Q(106,49),Q(107,49);function wr(e){if(typeof e!=`string`||e.startsWith(`file://`))return!1;try{return(0,V.lstatSync)(e).isDirectory()}catch{return!1}}function Tr(e,t=8){return(function(){if(Or!==void 0)return Or;try{return Or=!!Qn().getFips?.(),Or}catch{return Or=!1,Or}}()?Qn().createHash(`sha256`):Qn().createHash(`md5`)).update(e).digest(`hex`).slice(0,t)}let Er={true:yr(`true`),false:br(`false`),"[rebuild]":br(`[rebuild]`),"[esm]":xr(`[esm]`),"[cjs]":yr(`[cjs]`),"[import]":xr(`[import]`),"[require]":yr(`[require]`),"[native]":Sr(`[native]`),"[transpile]":br(`[transpile]`),"[fallback]":vr(`[fallback]`),"[unknown]":vr(`[unknown]`),"[hit]":yr(`[hit]`),"[miss]":br(`[miss]`),"[json]":yr(`[json]`),"[data]":yr(`[data]`)};function $(e,...t){if(!e.opts.debug)return;let n=process.cwd();console.log(Cr([`[jiti]`,...t.map(e=>e in Er?Er[e]:typeof e==`string`?e.replace(n,`.`):JSON.stringify(e))].join(` `)))}function Dr(e,t){return e.opts.interopDefault?function(e){let t=typeof e;if(e===null||t!==`object`&&t!==`function`)return e;let n=e.default,r=typeof n,i=n==null,a=r===`object`||r===`function`;return i&&e instanceof Promise?e:new Proxy(e,{get(t,r,o){if(r===`__esModule`)return!0;if(r===`default`)return i?e:typeof n?.default==`function`&&e.__esModule?n.default:n;if(Reflect.has(t,r))return Reflect.get(t,r,o);if(a&&!(n instanceof Promise)){let e=Reflect.get(n,r,o);return typeof e==`function`&&(e=e.bind(n)),e}},apply:(e,t,i)=>typeof e==`function`?Reflect.apply(e,t,i):r===`function`?Reflect.apply(n,t,i):void 0})}(t):t}let Or;function kr(e,t){return!!Ar(e,t)}function Ar(e,t){let n=process.env[e];if(!(e in process.env))return t;try{return JSON.parse(n)}catch{return t}}let jr=/\.(c|m)?j(sx?)$/,Mr=/\.(c|m)?t(sx?)$/;function Nr(e,t,n){let r,i;if(e.isNativeRe.test(t))return t;e.alias&&(t=function(e,t){let n=yt(e);t=Jn(t);for(let[e,r]of Object.entries(t))if(n.startsWith(e)&&Yn(n[(Yn(e)?e.slice(0,-1):e).length]))return Tt(r,n.slice(e.length));return n}(t,e.alias));let a=n?.parentURL||e.url;wr(a)&&(a=Tt(a,`_index.js`));let o=(n?.async?[n?.conditions,[`node`,`import`],[`node`,`require`]]:[n?.conditions,[`node`,`require`],[`node`,`import`]]).filter(Boolean);for(let n of o){try{r=Bn(t,{url:a,conditions:n,extensions:e.opts.extensions})}catch(e){i=e}if(r)return r}try{return e.nativeRequire.resolve(t,{paths:n.paths})}catch(e){i=e}for(let i of e.additionalExts)if(r=Pr(e,t+i,a,n)||Pr(e,t+`/index`+i,a,n),r||(Mr.test(e.filename)||Mr.test(e.parentModule?.filename||``)||jr.test(t))&&(r=Pr(e,t.replace(jr,`.$1t$2`),a,n),r))return r;if(!n?.try)throw i}function Pr(e,t,n,r){try{return e.nativeRequire.resolve(t,{...r,paths:[jt(Z(n)),...r?.paths||[]]})}catch{}}let Fr=D(`node:perf_hooks`),Ir=D(`node:vm`);var Lr=r.n(Ir);function Rr(e,t,n){let r=e.parentCache||{};if(t.startsWith(`node:`))return zr(e,t,n.async);if(t.startsWith(`file:`))t=(0,H.fileURLToPath)(t);else if(t.startsWith(`data:`)){if(!n.async)throw Error("`data:` URLs are only supported in ESM context. Use `import` or `jiti.import` instead.");return $(e,`[native]`,`[data]`,`[import]`,t),zr(e,t,!0)}if(dt.builtinModules.includes(t)||t===`.pnp.js`)return zr(e,t,n.async);if(e.opts.tryNative&&!e.opts.transformOptions)try{if(!(t=Nr(e,t,n))&&n.try)return;if($(e,`[try-native]`,n.async&&e.nativeImport?`[import]`:`[require]`,t),n.async&&e.nativeImport)return e.nativeImport(t).then(n=>(!1===e.opts.moduleCache&&delete e.nativeRequire.cache[t],Dr(e,n)));{let n=e.nativeRequire(t);return!1===e.opts.moduleCache&&delete e.nativeRequire.cache[t],Dr(e,n)}}catch(n){$(e,`[try-native] Using fallback for ${t} because of an error:`,n)}let i=Nr(e,t,n);if(!i&&n.try)return;let a=At(i);if(a===`.json`){$(e,`[json]`,i);let t=e.nativeRequire(i);return t&&!(`default`in t)&&Object.defineProperty(t,`default`,{value:t,enumerable:!1}),t}if(a&&!e.opts.extensions.includes(a))return $(e,`[native]`,`[unknown]`,n.async?`[import]`:`[require]`,i),zr(e,i,n.async);if(e.isNativeRe.test(i))return $(e,`[native]`,n.async?`[import]`:`[require]`,i),zr(e,i,n.async);if(r[i])return Dr(e,r[i]?.exports);if(e.opts.moduleCache){let t=e.nativeRequire.cache[i];if(t?.loaded)return Dr(e,t.exports)}return Ur(e,(0,V.readFileSync)(i,`utf8`),{id:t,filename:i,ext:a,cache:r,async:n.async})}function zr(e,t,n){return n&&e.nativeImport?e.nativeImport(function(e){return cr&&kt(e)?Nn(e):e}(t)).then(t=>Dr(e,t)):Dr(e,e.nativeRequire(t))}function Br(e,t,n){if(!e.opts.fsCache||!t.filename)return n();let r=` /* v9-${Tr(t.source,16)} */\n`,i=`${Mt(jt(t.filename))}-${function(e){let t=e.split(qn).pop();if(!t)return;let n=t.lastIndexOf(`.`);return n<=0?t:t.slice(0,n)}(t.filename)}`+(e.opts.sourceMaps?`+map`:``)+(t.interopDefault?`.i`:``)+`.${Tr(t.filename)}`+(t.async?`.mjs`:`.cjs`);t.jsx&&t.filename.endsWith(`x`)&&(i+=`x`);let a=e.opts.fsCache,o=Tt(a,i);if(!e.opts.rebuildFsCache&&(0,V.existsSync)(o)){let n=(0,V.readFileSync)(o,`utf8`);if(n.endsWith(r))return $(e,`[cache]`,`[hit]`,t.filename,`~>`,o),n}$(e,`[cache]`,`[miss]`,t.filename);let s=n();return s.includes(`__JITI_ERROR__`)||((0,V.writeFileSync)(o,s+r,`utf8`),$(e,`[cache]`,`[store]`,t.filename,`~>`,o)),s}function Vr(t){if(!0===t.opts.fsCache&&(t.opts.fsCache=function(t){let n=t.filename&&Dt(t.filename,`../node_modules`);if(n&&(0,V.existsSync)(n))return Tt(n,`.cache/jiti`);let r=(0,e.tmpdir)();if(process.env.TMPDIR&&r===process.cwd()&&!process.env.JITI_RESPECT_TMPDIR_ENV){let t=process.env.TMPDIR;delete process.env.TMPDIR,r=(0,e.tmpdir)(),process.env.TMPDIR=t}return Tt(r,`jiti`)}(t)),t.opts.fsCache)try{if((0,V.mkdirSync)(t.opts.fsCache,{recursive:!0}),!function(e){try{return(0,V.accessSync)(e,V.constants.W_OK),!0}catch{return!1}}(t.opts.fsCache))throw Error(`directory is not writable!`)}catch(e){$(t,`Error creating cache directory at `,t.opts.fsCache,e),t.opts.fsCache=!1}}function Hr(e,t){let n=Br(e,t,()=>{let n=e.opts.transform({...e.opts.transformOptions,babel:{...e.opts.sourceMaps?{sourceFileName:t.filename,sourceMaps:`inline`}:{},...e.opts.transformOptions?.babel},interopDefault:e.opts.interopDefault,...t});return n.error&&e.opts.debug&&$(e,n.error),n.code});return n.startsWith(`#!`)&&(n=`// `+n),n}function Ur(e,t,n={}){let r=n.id||(n.filename?Mt(n.filename):`_jitiEval.${n.ext||(n.async?`mjs`:`js`)}`),i=n.filename||Nr(e,r,{async:n.async}),a=n.ext||At(i),o=n.cache||e.parentCache||{},s=/\.[cm]?tsx?$/.test(a),c=a===`.mjs`||a===`.js`&&function(e){for(;e&&e!==`.`&&e!==`/`;){e=Tt(e,`..`);try{let t=(0,V.readFileSync)(Tt(e,`package.json`),`utf8`);try{return JSON.parse(t)}catch{}break}catch{}}}(i)?.type===`module`,l=a===`.cjs`,u=n.forceTranspile??(!l&&!(c&&n.async)&&(s||c||e.isTransformRe.test(i)||Un(t))),d=Fr.performance.now();if(u){t=Hr(e,{filename:i,source:t,ts:s,async:n.async??!1,jsx:e.opts.jsx});let r=Math.round(1e3*(Fr.performance.now()-d))/1e3;$(e,`[transpile]`,n.async?`[esm]`:`[cjs]`,i,`(${r}ms)`)}else{if($(e,`[native]`,n.async?`[import]`:`[require]`,i),n.async)return Promise.resolve(zr(e,i,n.async)).catch(r=>($(e,`Native import error:`,r),$(e,`[fallback]`,i),Ur(e,t,{...n,forceTranspile:!0})));try{return zr(e,i,n.async)}catch(r){$(e,`Native require error:`,r),$(e,`[fallback]`,i),t=Hr(e,{filename:i,source:t,ts:s,async:n.async??!1,jsx:e.opts.jsx})}}let f=new dt.Module(i);f.filename=i,e.parentModule&&(f.parent=e.parentModule,Array.isArray(e.parentModule.children)&&!e.parentModule.children.includes(f)&&e.parentModule.children.push(f));let p=Gr(i,e.opts,{parentModule:f,parentCache:o,nativeImport:e.nativeImport,onError:e.onError,createRequire:e.createRequire},!0),m;f.require=p,f.path=jt(i),f.paths=dt.Module._nodeModulePaths(f.path),o[i]=f,e.opts.moduleCache&&(e.nativeRequire.cache[i]=f);let h=function(e,t){return`(${t?.async?`async `:``}function (exports, require, module, __filename, __dirname, jitiImport, jitiESMResolve) { ${e}\n});`}(t,{async:n.async});try{m=Lr().runInThisContext(h,{filename:i,lineOffset:0,displayErrors:!1})}catch(t){t.name===`SyntaxError`&&n.async&&e.nativeImport?($(e,`[esm]`,`[import]`,`[fallback]`,i),m=function(e,t){let n=`data:text/javascript;base64,${Buffer.from(`export default ${e}`).toString(`base64`)}`;return(...e)=>t(n).then(t=>t.default(...e))}(h,e.nativeImport)):(e.opts.moduleCache&&delete e.nativeRequire.cache[i],e.onError(t))}let g;try{g=m(f.exports,f.require,f,f.filename,jt(f.filename),p.import,p.esmResolve)}catch(t){e.opts.moduleCache&&delete e.nativeRequire.cache[i],e.onError(t)}function _(){if(f.exports&&f.exports.__JITI_ERROR__){let{filename:t,line:n,column:r,code:i,message:a}=f.exports.__JITI_ERROR__,o=Error(`${i}: ${a} \n ${`${t}:${n}:${r}`}`);Error.captureStackTrace(o,Rr),e.onError(o)}return f.loaded=!0,Dr(e,f.exports)}return n.async?Promise.resolve(g).then(_):_()}let Wr=(0,e.platform)()===`win32`;function Gr(e,t={},n,r=!1){let i=r?t:function(e){let t={fsCache:kr(`JITI_FS_CACHE`,kr(`JITI_CACHE`,!0)),rebuildFsCache:kr(`JITI_REBUILD_FS_CACHE`,!1),moduleCache:kr(`JITI_MODULE_CACHE`,kr(`JITI_REQUIRE_CACHE`,!0)),debug:kr(`JITI_DEBUG`,!1),sourceMaps:kr(`JITI_SOURCE_MAPS`,!1),interopDefault:kr(`JITI_INTEROP_DEFAULT`,!0),extensions:Ar(`JITI_EXTENSIONS`,[`.js`,`.mjs`,`.cjs`,`.ts`,`.tsx`,`.mts`,`.cts`,`.mtsx`,`.ctsx`]),alias:Ar(`JITI_ALIAS`,{}),nativeModules:Ar(`JITI_NATIVE_MODULES`,[]),transformModules:Ar(`JITI_TRANSFORM_MODULES`,[]),tryNative:Ar(`JITI_TRY_NATIVE`,`Bun`in globalThis),jsx:kr(`JITI_JSX`,!1)};t.jsx&&t.extensions.push(`.jsx`,`.tsx`);let n={};return e.cache!==void 0&&(n.fsCache=e.cache),e.requireCache!==void 0&&(n.moduleCache=e.requireCache),{...t,...n,...e}}(t),a=i.alias&&Object.keys(i.alias).length>0?Jn(i.alias||{}):void 0,o=[`typescript`,`jiti`,...i.nativeModules||[]],s=RegExp(`node_modules/(${o.map(e=>Wn(e)).join(`|`)})/`),c=[...i.transformModules||[]],l=RegExp(`node_modules/(${c.map(e=>Wn(e)).join(`|`)})/`);e||=process.cwd(),!r&&wr(e)&&(e=Tt(e,`_index.js`));let u=Nn(e),d=[...i.extensions].filter(e=>e!==`.js`),f=n.createRequire(Wr?e.replace(/\//g,`\\`):e),p={filename:e,url:u,opts:i,alias:a,nativeModules:o,transformModules:c,isNativeRe:s,isTransformRe:l,additionalExts:d,nativeRequire:f,onError:n.onError,parentModule:n.parentModule,parentCache:n.parentCache,nativeImport:n.nativeImport,createRequire:n.createRequire};return r||$(p,`[init]`,...[[`version:`,Xn.rE],[`module-cache:`,i.moduleCache],[`fs-cache:`,i.fsCache],[`rebuild-fs-cache:`,i.rebuildFsCache],[`interop-defaults:`,i.interopDefault]].flat()),r||Vr(p),Object.assign(function(e){return Rr(p,e,{async:!1})},{cache:i.moduleCache?f.cache:Object.create(null),extensions:f.extensions,main:f.main,options:i,resolve:Object.assign(function(e){return Nr(p,e,{async:!1})},{paths:f.resolve.paths}),transform:e=>Hr(p,e),evalModule:(e,t)=>Ur(p,e,t),async import(e,t){let n=await Rr(p,e,{...t,async:!0});return t?.default?n?.default??n:n},esmResolve(e,t){typeof t==`string`&&(t={parentURL:t});let n=Nr(p,e,{parentURL:u,...t,async:!0});return!n||typeof n!=`string`||n.startsWith(`file://`)?n:Nn(n)}})}})(),t.exports=i.default})()}))();var _e=class{emitter;constructor(){this.emitter=i()}on(e,t){me(e).forEach(e=>{this.emitter.on(e,t)})}off(e,t){me(e).forEach(e=>{this.emitter.off(e,t)})}emit(e,t){me(e).forEach(e=>{this.emitter.emit(e,t)})}removeAllListeners(){this.emitter.all.clear()}},ve=class{listeners;constructor(){this.listeners=new Map}on(e,t){me(e).forEach(e=>{let n=this.listeners.get(e)||new Set;n.add(t),this.listeners.set(e,n)})}off(e,t){me(e).forEach(e=>{let n=this.listeners.get(e);n&&n.delete(t)})}async emit(e,...t){let n=me(e).flatMap(e=>{let t=this.listeners.get(e)||new Set,n=this.listeners.get(`*`)||new Set;return[...Array.from(t),...Array.from(n)]});return n.length===0?[]:await Promise.all(n.map(async n=>{try{let e=n(...t);return e instanceof Promise?await e:e}catch(t){console.error(`Error in event listener for ${String(e)}:`,t);return}}))}removeAllListeners(){this.listeners.clear()}};function O(e,...t){return class extends e{static _instance;static getInstance(){return this._instance||=new e(...t),this._instance}static clearInstance(){this._instance=void 0}}}const k=O(class extends _e{destroy(){this.removeAllListeners()}fatal(e,t,n){this.emit(`fatal`,{code:t,message:e,data:n,timestamp:Date.now()})}error(e,t,n){this.emit(`error`,{code:t,message:e,data:n,timestamp:Date.now()})}warn(e,t,n){this.emit(`warning`,{code:t,message:e,data:n,timestamp:Date.now()})}});var A=class{data;_schema;_defaultValue;_path;constructor(e){let{schema:t,default:n,path:r}=e;this._schema=t,this._defaultValue=n,this._path=r}set(e){let t=this._schema[`~standard`].validate(e);if(t instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);if(t.issues){this.reportInvalidConfigFile(t.issues);return}this.data=this.onBeforeSave(e),this.save(e)}get(e={}){return this.data?this.data:this.load(e)}getKey(e,t={}){return this.get(t)[e]}save(e){let t=this.onBeforeSave(e);try{f(this.getFilePath()),a.writeFileSync(this.getFilePath(),JSON.stringify(t,void 0,2))}catch{return}return this.data=t}load(e={}){let{createIfMissing:t=!0}=e;if(!this.fileExists(this.getFilePath())||!this.canReadWriteFile(this.getFilePath())){t&&this.save(this._defaultValue);let e=this.onAfterLoad(this._defaultValue);return t&&(this.data=e),e}try{let e=a.readFileSync(this.getFilePath(),`utf8`),t=this.onAfterLoad(this.parseStoredData(e));return this.data=t,t}catch{return this.data=this._defaultValue}}onBeforeSave(e){return e}onAfterLoad(e){return e}getFilePath(){return this._path}parseStoredData(e){try{let t=r(`string.json.parse`).to(`object`)(e);if(t instanceof r.errors)return this._defaultValue;let n=this._schema[`~standard`].validate(t);if(n instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);return n.issues?this.migrate(t,this._defaultValue):this.migrate(n.value,this._defaultValue)}catch{return this._defaultValue}}canReadWriteFile(e){try{return a.accessSync(e,a.constants.R_OK|a.constants.W_OK),!0}catch{return!1}}fileExists(e){try{return a.accessSync(e,a.constants.F_OK),!0}catch{return!1}}migrate(e,t){let n={...e};for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(r in e?e[r]!==null&&t[r]!==null&&typeof e[r]==`object`&&typeof t[r]==`object`&&!Array.isArray(e[r])&&!Array.isArray(t[r])?n[r]=this.migrate(e[r],t[r]):Array.isArray(t[r])&&(n[r]=e[r]):n[r]=t[r]);return n}reportInvalidConfigFile(e){k.getInstance().error(`Invalid config file`,`INVALID_CONFIG_FILE`,{issues:e.map(e=>e.message),filePath:this._path,data:this.data})}};function ye(e,t,n){return typeof e!=`object`||!e?String(e):e instanceof Error?JSON.stringify(e,(e,t)=>{if(t instanceof Error){let e={};for(let n of Object.getOwnPropertyNames(t))e[n]=t[n];return e}return t},n):e instanceof Map?JSON.stringify(Object.fromEntries(e.entries()),t,n):e instanceof Set?JSON.stringify(Array.from(e),t,n):JSON.stringify(e,t,n)}const be=/\x1b\[[0-9;]*m/g;function j(e){return e.replace(be,``)}var xe=class e extends _e{stream;logPath;baseFileName;currentDate;rotationCheckInterval;isRotating=!1;constructor(e,t){super(),this.logPath=e,this.baseFileName=t.replace(`.log`,``),this.currentDate=this.getDateString(new Date),this.ensureLogDirectory(),this.ensureLogFile(),this.stream=this.createStream(),this.rotationCheckInterval=this.startRotationCheck(),this.cleanupOldLogs()}static scope(t,n){return new e(t,n)}log(...e){this.write(`info`,...e)}error(...e){this.write(`error`,...e)}warn(...e){this.write(`warn`,...e)}info(...e){this.write(`info`,...e)}debug(...e){this.write(`debug`,...e)}async close(){clearInterval(this.rotationCheckInterval),await new Promise(e=>{this.stream.end(()=>e())})}getCurrentFileName(){return this.getFileName(this.currentDate)}static getMessageElements(e,...t){let n=new Date;return{timestamp:n.toISOString().replace(`T`,` `).replace(/\.\d+Z$/,``)+`.${n.getUTCMilliseconds().toString().padStart(3,`0`)}`,level:e,message:t.map(e=>ye(e)).join(` `)}}getFileName(e){return`${this.baseFileName}-${e}.log`}ensureLogDirectory(){try{c(this.logPath,{recursive:!0})}catch(e){throw console.error(`Failed to create log directory ${this.logPath}:`,e),e}}ensureLogFile(){let e=m(this.logPath,this.getFileName(this.currentDate));if(!s(e))try{d(e,``,`utf8`)}catch(t){throw console.error(`Failed to create log file ${e}:`,t),t}}getDateString(e){return`${e.getUTCFullYear()}-${(e.getUTCMonth()+1).toString().padStart(2,`0`)}-${e.getUTCDate().toString().padStart(2,`0`)}`}createStream(){return o(m(this.logPath,this.getFileName(this.currentDate)),{flags:`a`,encoding:`utf8`})}async rotateLogs(){if(this.isRotating)return;this.isRotating=!0;let e=this.getDateString(new Date);e!==this.currentDate&&await new Promise(t=>{this.stream.end(()=>{this.currentDate=e,this.stream=this.createStream(),this.cleanupOldLogs(),t()})}),this.isRotating=!1}startRotationCheck(){return setInterval(()=>this.rotateLogs(),6e4)}cleanupOldLogs(){let e=l(this.logPath),t=new Date,n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()-7));e.filter(e=>e.startsWith(this.baseFileName)&&e.endsWith(`.log`)).filter(e=>{let[t,r,i]=e.replace(`${this.baseFileName}-`,``).replace(`.log`,``).split(`-`).map(Number);return new Date(Date.UTC(t,r-1,i))<=n}).forEach(e=>{try{u(m(this.logPath,e))}catch(t){console.error(`Failed to delete old log file ${e}:`,t)}})}ensureStreamValid(){if(!this.stream.writable||this.stream.destroyed)try{this.stream=this.createStream()}catch(e){this.emit(`error`,e instanceof Error?e:Error(String(e)))}}write(t,...n){let{timestamp:r,message:i}=e.getMessageElements(t,...n),a=`[${r}] [${t}] ${j(i)}\n`;this.ensureStreamValid(),this.stream.write(a,e=>{if(e)if(e.code===`ERR_STREAM_WRITE_AFTER_END`||!this.stream.writable)try{this.stream=this.createStream(),this.stream.write(a,e=>{e?this.emit(`error`,e):this.emit(`write`,a)})}catch(e){this.emit(`error`,e instanceof Error?e:Error(String(e)))}else this.emit(`error`,e);else this.emit(`write`,a)})}};const Se=()=>g.join(process.env.APPDATA??``,`overlayed`),Ce=()=>g.join(Se(),`logs`),we=e=>g.join(Se(),`apps`,e),Te=e=>g.join(we(e),`logs`),Ee=()=>g.join(Se(),`meta.json`),De=()=>g.join(Se(),`crash-dumps`);var M=class{fileLogger;path;appId;messageQueue=new ge;fileName;_debug=!1;silent=!1;forceSilent=!1;constructor(e){this.fileName=e}init(e,t=!1,n=!1,r=!1){this.appId=e,this._debug=t,this.silent=n,this.forceSilent=r,this.path=Te(e),this.fileLogger=new xe(this.path,this.fileName),this.messageQueue.flush().forEach(e=>{this.fileLogger?.[e.type](...e.args)})}scope(e){if(!this.appId||!this.path)throw Error(`Logger not initialized`);let t=y.cyan(`[${e}]`);return{scope:e=>this.scope(e),error:(...e)=>this.error(t,...e),warn:(...e)=>this.warn(t,...e),info:(...e)=>this.info(t,...e),log:(...e)=>this.log(t,...e),debug:(...e)=>this.debug(t,...e)}}error(...e){this.handle(`error`,...e)}warn(...e){this.handle(`warn`,...e)}info(...e){this.handle(`log`,...e)}debug(...e){this._debug&&this.handle(`debug`,...e)}log(...e){this.handle(`log`,...e)}handle(e,...t){this.logToConsole(e,...t),this.fileLogger?this.fileLogger[e](...t):this.messageQueue.add({type:e,args:t})}logToConsole(e,...t){let n={error:y.red,warn:y.yellow,debug:y.blue,log:y.white};if(this.forceSilent||this.silent&&!this._debug)return;let{timestamp:r,message:i}=xe.getMessageElements(e,...t),a=console[e],o=n[e];a(`${y.gray(r)} ${o(i)}`)}};const N=O(M,`overlayed.log`);var P=class extends b{blob;chunkSizeMb;maxConcurrent;shouldStop=!1;constructor(e,t){super(),this.blob=e,this.chunkSizeMb=t.chunkSizeMb,this.maxConcurrent=t.maxConcurrent??3}get totalChunks(){return Math.ceil(this.blob.size/(this.chunkSizeMb*1024*1024))}async chunk(e){let t=this.chunkSizeMb*1024*1024,n=this.totalChunks;if(n===0)return;let r=new Map,i=new Set,a=new Set,o=[];for(let e=0;e<n;e++)o.push(e);let s=async n=>{let s=n*t,c=Math.min(s+t,this.blob.size),l=this.blob.slice(s,c);try{await e(l,n),a.add(n),this.emit(`chunkComplete`,n),i.delete(n)}catch(e){let t=r.get(n)||0;t<5?(r.set(n,t+1),await new Promise(e=>setTimeout(e,(t+1)*1e3)),o.push(n)):(a.add(n),this.emit(`error`,e),this.shouldStop=!0,i.delete(n))}},c=[],l=async()=>{for(;(o.length>0||i.size>0)&&!this.shouldStop;){if(o.length===0){await new Promise(e=>setTimeout(e,10));continue}let e=o.shift();a.has(e)||i.has(e)||(i.add(e),await s(e))}};for(let e=0;e<this.maxConcurrent;e++)c.push(l());await Promise.all(c)}};function Oe(e,t){let{recursive:n}=F(t);return C(e)?n?ke(e).map(t=>[e,t]):w(e).map(t=>[e,t]):[]}function F(e){return{recursive:e?.recursive??!0}}function ke(e){return w(e,{withFileTypes:!0}).flatMap(t=>{let n=g.join(e,t.name);return t.isDirectory()?ke(n):[n]})}function Ae(e){return je(e),e}function je(e){if(!he(e.applicationId))throw Error(`Invalid applicationId, must be a valid ULID.`)}function Me(e,t){let n=t?.cwd??process.cwd(),r=h.join(n,`.overlayed`);x.existsSync(r)||x.mkdirSync(r,{recursive:!0});let i={application:{id:e.id,name:e.name,slug:e.slug,siteUrl:e.siteUrl},release:{id:null,channel:`local`,version:`0.0.0`}},a=h.join(r,`meta.json`);return x.writeFileSync(a,JSON.stringify(i,null,2)),i}const{PipeEventServer:I,PipeEventClient:Ne,PipeEventBase:Pe,ProcessMonitor:Fe,Process:Ie,HardwareInterface:Le}=e(import.meta.url)(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`),Re=O(class extends _e{server=null;_hasConnection=!1;pipeId;get hasConnection(){return this._hasConnection}constructor(e){super(),this.pipeId=e,this.init()}destroy(){this.server&&=(this._hasConnection=!1,this.server?.removeAllListeners(),null)}init(){this.server=new I(this.pipeId,{clientCount:1,access:1}),this.server.on(`event`,e=>{try{let t=JSON.parse(e);this.emit(`data`,[t])}catch(e){this.emit(`error`,e)}}),this.server.on(`connected`,()=>{this._hasConnection=!0,this.emit(`connected`,void 0)}),this.server.on(`disconnected`,()=>{this._hasConnection=!1,this.emit(`disconnected`,void 0)})}},`overlayed-event-server`),{RenderInterface:ze,renderHookPath:Be}=e(import.meta.url)(`@overlayed/app/dist/render-interface/build/overlayed_render_interface_x64.node`);let Ve=function(e){return e[e.LeftButton=1]=`LeftButton`,e[e.RightButton=2]=`RightButton`,e[e.Cancel=3]=`Cancel`,e[e.MiddleButton=4]=`MiddleButton`,e[e.ExtraButton1=5]=`ExtraButton1`,e[e.ExtraButton2=6]=`ExtraButton2`,e[e.Back=8]=`Back`,e[e.Tab=9]=`Tab`,e[e.Clear=12]=`Clear`,e[e.Return=13]=`Return`,e[e.Shift=16]=`Shift`,e[e.Control=17]=`Control`,e[e.Menu=18]=`Menu`,e[e.Pause=19]=`Pause`,e[e.CapsLock=20]=`CapsLock`,e[e.Kana=21]=`Kana`,e[e.Hangeul=21]=`Hangeul`,e[e.Hangul=21]=`Hangul`,e[e.Junja=23]=`Junja`,e[e.Final=24]=`Final`,e[e.Hanja=25]=`Hanja`,e[e.Kanji=25]=`Kanji`,e[e.Escape=27]=`Escape`,e[e.Convert=28]=`Convert`,e[e.NonConvert=29]=`NonConvert`,e[e.Accept=30]=`Accept`,e[e.ModeChange=31]=`ModeChange`,e[e.Space=32]=`Space`,e[e.Prior=33]=`Prior`,e[e.Next=34]=`Next`,e[e.End=35]=`End`,e[e.Home=36]=`Home`,e[e.Left=37]=`Left`,e[e.Up=38]=`Up`,e[e.Right=39]=`Right`,e[e.Down=40]=`Down`,e[e.Select=41]=`Select`,e[e.Print=42]=`Print`,e[e.Execute=43]=`Execute`,e[e.Snapshot=44]=`Snapshot`,e[e.Insert=45]=`Insert`,e[e.Delete=46]=`Delete`,e[e.Help=47]=`Help`,e[e.N0=48]=`N0`,e[e.N1=49]=`N1`,e[e.N2=50]=`N2`,e[e.N3=51]=`N3`,e[e.N4=52]=`N4`,e[e.N5=53]=`N5`,e[e.N6=54]=`N6`,e[e.N7=55]=`N7`,e[e.N8=56]=`N8`,e[e.N9=57]=`N9`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.LeftWindows=91]=`LeftWindows`,e[e.RightWindows=92]=`RightWindows`,e[e.Application=93]=`Application`,e[e.Sleep=95]=`Sleep`,e[e.Numpad0=96]=`Numpad0`,e[e.Numpad1=97]=`Numpad1`,e[e.Numpad2=98]=`Numpad2`,e[e.Numpad3=99]=`Numpad3`,e[e.Numpad4=100]=`Numpad4`,e[e.Numpad5=101]=`Numpad5`,e[e.Numpad6=102]=`Numpad6`,e[e.Numpad7=103]=`Numpad7`,e[e.Numpad8=104]=`Numpad8`,e[e.Numpad9=105]=`Numpad9`,e[e.Multiply=106]=`Multiply`,e[e.Add=107]=`Add`,e[e.Separator=108]=`Separator`,e[e.Subtract=109]=`Subtract`,e[e.Decimal=110]=`Decimal`,e[e.Divide=111]=`Divide`,e[e.F1=112]=`F1`,e[e.F2=113]=`F2`,e[e.F3=114]=`F3`,e[e.F4=115]=`F4`,e[e.F5=116]=`F5`,e[e.F6=117]=`F6`,e[e.F7=118]=`F7`,e[e.F8=119]=`F8`,e[e.F9=120]=`F9`,e[e.F10=121]=`F10`,e[e.F11=122]=`F11`,e[e.F12=123]=`F12`,e[e.F13=124]=`F13`,e[e.F14=125]=`F14`,e[e.F15=126]=`F15`,e[e.F16=127]=`F16`,e[e.F17=128]=`F17`,e[e.F18=129]=`F18`,e[e.F19=130]=`F19`,e[e.F20=131]=`F20`,e[e.F21=132]=`F21`,e[e.F22=133]=`F22`,e[e.F23=134]=`F23`,e[e.F24=135]=`F24`,e[e.NumLock=144]=`NumLock`,e[e.ScrollLock=145]=`ScrollLock`,e[e.NEC_Equal=146]=`NEC_Equal`,e[e.Fujitsu_Jisho=146]=`Fujitsu_Jisho`,e[e.Fujitsu_Masshou=147]=`Fujitsu_Masshou`,e[e.Fujitsu_Touroku=148]=`Fujitsu_Touroku`,e[e.Fujitsu_Loya=149]=`Fujitsu_Loya`,e[e.Fujitsu_Roya=150]=`Fujitsu_Roya`,e[e.LeftShift=160]=`LeftShift`,e[e.RightShift=161]=`RightShift`,e[e.LeftControl=162]=`LeftControl`,e[e.RightControl=163]=`RightControl`,e[e.LeftMenu=164]=`LeftMenu`,e[e.RightMenu=165]=`RightMenu`,e[e.BrowserBack=166]=`BrowserBack`,e[e.BrowserForward=167]=`BrowserForward`,e[e.BrowserRefresh=168]=`BrowserRefresh`,e[e.BrowserStop=169]=`BrowserStop`,e[e.BrowserSearch=170]=`BrowserSearch`,e[e.BrowserFavorites=171]=`BrowserFavorites`,e[e.BrowserHome=172]=`BrowserHome`,e[e.VolumeMute=173]=`VolumeMute`,e[e.VolumeDown=174]=`VolumeDown`,e[e.VolumeUp=175]=`VolumeUp`,e[e.MediaNextTrack=176]=`MediaNextTrack`,e[e.MediaPrevTrack=177]=`MediaPrevTrack`,e[e.MediaStop=178]=`MediaStop`,e[e.MediaPlayPause=179]=`MediaPlayPause`,e[e.LaunchMail=180]=`LaunchMail`,e[e.LaunchMediaSelect=181]=`LaunchMediaSelect`,e[e.LaunchApplication1=182]=`LaunchApplication1`,e[e.LaunchApplication2=183]=`LaunchApplication2`,e[e.OEM1=186]=`OEM1`,e[e.OEMPlus=187]=`OEMPlus`,e[e.OEMComma=188]=`OEMComma`,e[e.OEMMinus=189]=`OEMMinus`,e[e.OEMPeriod=190]=`OEMPeriod`,e[e.OEM2=191]=`OEM2`,e[e.OEM3=192]=`OEM3`,e[e.OEM4=219]=`OEM4`,e[e.OEM5=220]=`OEM5`,e[e.OEM6=221]=`OEM6`,e[e.OEM7=222]=`OEM7`,e[e.OEM8=223]=`OEM8`,e[e.OEMAX=225]=`OEMAX`,e[e.OEM102=226]=`OEM102`,e[e.ICOHelp=227]=`ICOHelp`,e[e.ICO00=228]=`ICO00`,e[e.ProcessKey=229]=`ProcessKey`,e[e.ICOClear=230]=`ICOClear`,e[e.Packet=231]=`Packet`,e[e.OEMReset=233]=`OEMReset`,e[e.OEMJump=234]=`OEMJump`,e[e.OEMPA1=235]=`OEMPA1`,e[e.OEMPA2=236]=`OEMPA2`,e[e.OEMPA3=237]=`OEMPA3`,e[e.OEMWSCtrl=238]=`OEMWSCtrl`,e[e.OEMCUSel=239]=`OEMCUSel`,e[e.OEMATTN=240]=`OEMATTN`,e[e.OEMFinish=241]=`OEMFinish`,e[e.OEMCopy=242]=`OEMCopy`,e[e.OEMAuto=243]=`OEMAuto`,e[e.OEMENLW=244]=`OEMENLW`,e[e.OEMBackTab=245]=`OEMBackTab`,e[e.ATTN=246]=`ATTN`,e[e.CRSel=247]=`CRSel`,e[e.EXSel=248]=`EXSel`,e[e.EREOF=249]=`EREOF`,e[e.Play=250]=`Play`,e[e.Zoom=251]=`Zoom`,e[e.Noname=252]=`Noname`,e[e.PA1=253]=`PA1`,e[e.OEMClear=254]=`OEMClear`,e}({});const He=r({game:`string`,type:`string`,creation_time:`number`}).and({game:`'siege' | 'tft'`}),Ue=He.and({type:`'logged_in'`,content:{account_id:`string`}}),We=He.and({type:`'module_loaded'`,content:{game_version:`string`,process_hash:`string`}}),Ge=He.and({type:`'module_unloaded'`}),Ke=He.and({type:`'unsupported_game_version'`,content:{game_version:`string`,process_hash:`string`}}),qe=n({"#event1":`logged_in | module_loaded | module_unloaded | unsupported_game_version`,event:`event1`,logged_in:Ue,module_loaded:We,module_unloaded:Ge,unsupported_game_version:Ke}).export(),Je=Object.keys(qe).filter(e=>e!==`event`);function Ye(){return{key:`universal`,events:qe}}var Xe=class{options=null;logger;initialized=!1;constructor(e){this.logger=N.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1}},L=class extends _e{options=null;logger;initialized=!1;constructor(e){super(),this.logger=N.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}},Ze=class extends ve{options=null;logger;initialized=!1;constructor(e){super(),this.logger=N.getInstance().scope(e)}init(e){this.logger.log(`Initializing`),this.options=e||null,this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}};const R=oe.create({baseURL:`https://api.overlayed.gg`,headers:{Accept:`application/json`,"Accept-Encoding":`gzip, deflate, br`}});let Qe;function z(e){Qe=e}let $e;function et(e){$e=e}function tt(e){return`overlayed/app (${Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `)})`}R.interceptors.request.use(e=>{let t=Qe?.();e.headers??={},t&&(e.headers[`X-Api-Key`]=t);let n=$e?.();return n&&(e.headers[`User-Agent`]=tt(n)),e});function nt(e,t){if(t<=0)throw Error(`Chunk size must be greater than 0`);if(e.length===0)return[];let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function rt(e){return e}function it(e){return e?t=>(e(t),t):rt}const at=it();function ot(e){return R.get(`/v1/public/applications/${e}`)}function st(e,t){return R.get(`/v1/public/applications/${e}/releases/check`,{params:t})}function ct(e,t){return R.post(`/v1/public/applications/${e}/game-crash-reports`,t)}function B(e,t,n){return R.post(`/v1/public/applications/${e}/game-crash-reports/${t}/confirm`,n)}function lt(e,t){let n=new FormData;return n.append(`file`,new Blob([t.file],{type:`application/zip`}),`logs.zip`),n.append(`data`,JSON.stringify(t.data)),R.post(`/v1/public/applications/${e}/feedbacks`,n)}function ut(e,t){return R.get(`/v1/public/applications/${e}/feature-flags`,{params:t})}function dt(e,t){return R.get(`/v1/public/applications/${e}/notices`,{params:t})}const V=it();function ft(e,t){return R.get(`/v1/public/modules/${e}/release`,{params:{cortex_user_id:t}})}function pt(e,t,n){return R.post(`/v1/public/modules/${e}/releases/${t}/download`,n)}async function mt(e,t){if(e.method!==`GET`)throw Error(`Unsupported presigned request method: ${e.method}`);let n=await fetch(e.url,{method:e.method,headers:e.headers,signal:t?.signal});if(!n.ok){let e=await gt(n);throw Error(`Presigned download failed (${n.status} ${n.statusText})${e?`: ${e}`:``}`)}let r=await n.arrayBuffer();return new Uint8Array(r)}async function ht(e,t){if(e.method!==`PUT`)throw Error(`Unsupported presigned request method: ${e.method}`);let n=await fetch(e.url,{method:e.method,headers:{...e.headers,"Content-Length":t.byteLength.toString()},body:t});if(!n.ok){let e=await gt(n);throw Error(`Presigned upload failed (${n.status} ${n.statusText})${e?`: ${e}`:``}`)}}async function gt(e){try{let t=(await e.text()).trim();if(t.length===0)return;let n=2048;return t.length>n?`${t.slice(0,n)}…`:t}catch{return}}function _t(){return R.get(`/v1/public/raven/config`)}const vt=it();function yt(e,t){return R.get(`/v1/public/raven/games/${e}/builds/${t}`)}function bt(e,t){return R.post(`/v1/public/raven/games/${e}/builds/upload`,null,{params:t})}function xt(e,t){let n=new FormData;return n.append(`file`,t.chunk),R.patch(`/v1/public/raven/games/${e}/builds/upload`,n,{params:t})}function St(e){let t=Date.now(),n=e.messages.filter(e=>t-e.created_at.getTime()<6e5),r=e.messages.length-n.length;r>0&&console.warn(`Dropped ${r} cortex event(s) older than 600s`);let i=nt(n.map(e=>Ct(t,e)),50),a=Promise.all(i.map(async t=>R.post(`/v1/public/cortex/events`,{...e,messages:t})));return a.catch(e=>{let t=e?.response?.data||e?.message||e;console.error(`Failed to submit cortex events`,t)}),a}function Ct(e,t){let n=e-t.created_at.getTime(),r=Math.max(0,Math.floor(n/1e3));return{properties:t.properties,type:t.type,seconds_offset:r}}function wt(e){return e instanceof Error&&(e.name===`XiorError`||e.name===`XiorTimeoutError`)}function Tt(e){return!!(e&&`kind`in e.data&&`message`in e.data)}const{PipeEventServer:Et,PipeEventClient:Dt,PipeEventBase:Ot,ProcessMonitor:kt,Process:At,HardwareInterface:jt}=e(import.meta.url)(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`);function Mt(e=[]){return g.normalize(g.join(we(global.OVERLAYED.APPLICATION_ID),...e))}const H=r({game:`string`,type:`string`,creation_time:`number`}),U=new A({path:Ee(),schema:r({userId:`string | undefined`,sessionId:`string | undefined`,sessionLastUsed:`number | undefined`,accessToken:`string | undefined`,"debug?":{"ri_disabled?":`boolean`,"gm_disabled?":`boolean`}}),default:{userId:void 0,sessionId:void 0,sessionLastUsed:void 0,accessToken:void 0}});function Nt(){let{debug:e}=U.get();return e?{ri_disabled:e.ri_disabled??!1,gm_disabled:e.gm_disabled??!1}:{ri_disabled:!1,gm_disabled:!1}}function W(){let e=U.get().userId;if(e)return e;let t=Rt();return U.set({...U.get(),userId:t}),t}function Pt(){let e=U.get();if(e.sessionId&&typeof e.sessionLastUsed==`number`&&Date.now()-e.sessionLastUsed<=300*1e3)return e.sessionId;let t=crypto.randomUUID();return U.set({...e,sessionId:t,sessionLastUsed:Date.now()}),t}function Ft(){try{let e=U.get();U.set({...e,sessionLastUsed:Date.now()})}catch(e){N.getInstance().log(`Failed to update sessionLastUsed`,e)}}function It(){return U.get().accessToken}function Lt(e){try{let t=U.get();U.set({...t,accessToken:e??void 0})}catch(e){N.getInstance().log(`Failed to set accessToken`,e)}}function Rt(){try{return jt.generateUniqueIdentifier()}catch{return crypto.randomUUID()}}const zt=O(class extends L{UPDATE_CHECK_INTERVAL_MS=1e3*60*5;targetDir;updateInterval;constructor(){super(`NativeModuleManager`),this.targetDir=g.join(Se(),`resources`),this.logger.log(`Target directory`,this.targetDir)}async initWithDlls(e){super.init(),await T.mkdir(this.targetDir,{recursive:!0}),await this.checkForUpdates(e),clearInterval(this.updateInterval),this.updateInterval=setInterval(()=>this.checkForUpdates(e),this.UPDATE_CHECK_INTERVAL_MS)}destroy(){this.updateInterval&&=(clearInterval(this.updateInterval),void 0),super.destroy()}async getDllFile(e){let t=await this.getCurrentBuildInfo(e);if(!t){this.logger.error(`No build found for module`,{moduleId:e});return}let n=this.getBuildPath(e,t.buildId);if(!C(n)){this.logger.error(`No build file found for module`,{moduleId:e});return}let r=g.join(n,t.buildFileName);if(!C(r)){this.logger.error(`No DLL file found for module`,{moduleId:e});return}return r}async getCurrentBuildInfo(e){try{let t=g.join(this.targetDir,e,`build.json`),n=await T.readFile(t,`utf-8`);return JSON.parse(n)}catch{return null}}getModulePath(e){return g.join(this.targetDir,e)}getBuildPath(e,t){return g.join(this.getModulePath(e),t)}async checkForUpdates(e){this.logger.log(`Checking for updates`);let t=W();if(!t){this.logger.error(`Failed to resolve cortex user id`);return}this.logger.log(`Cortex User ID`,t);for(let n of e)try{let{data:e}=await ft(n,t);this.logger.log(`Release`,e);let r=(await this.getCurrentBuildInfo(n))?.buildId||null;this.logger.log(`${n} > Performing update check. current: ${r}, requested: ${e.build_id}`),e.build_id!==r||await this.isDownloadCorrupted(this.getBuildPath(n,e.build_id),e)?(this.logger.log(`${n} > Update found. current: ${r}, requested: ${e.build_id}`),this.logger.log(`${n} > Downloading and extracting DLLs`),await this.downloadAndExtractDll(n,e),this.logger.log(`${n} > Cleaning up other builds`),await this.cleanupExistingBuilds(n,e.build_id),this.emit(`dllUpdated`,{moduleId:n,buildId:e.build_id,releaseId:e.release_id})):this.logger.log(`${n} > No update found`)}catch(e){this.logger.error(`${n} > Error checking/updating`,e)}}async downloadAndExtractDll(e,t){this.logger.log(`${e} > Requesting download for build ${t.build_id}`);let n=W();if(!n){this.logger.error(`Failed to resolve cortex user id`);return}let{data:r}=await pt(e,t.release_id,{download_token:t.download_token,cortex_user_id:n});this.logger.log(`${e} > Downloading DLLs for build ${t.build_id}`);let i=await mt(r,{signal:AbortSignal.timeout(1e3*60*5)});this.logger.log(`${e} > Downloaded zip file for build ${t.build_id}`);let a=this.getBuildPath(e,t.build_id);await T.mkdir(a,{recursive:!0});let o=new se;await o.loadAsync(i);let s=Object.keys(o.files).map(e=>({name:e,file:o.files[e]})).filter(({file:e})=>!e.dir);if(s.length!==1){this.logger.error(`${e} > Zip must contain exactly 1 file, got ${s.length}`);return}let c=s[0],l=g.basename(c.name),u=g.normalize(l),d=g.isAbsolute(u),f=u.startsWith(`..`)||u.includes(`..${g.sep}`);if(l===``||l===`.`||l===`..`){this.logger.error(`${e} > Zip contained an invalid file name: ${c.name}`);return}if(!l.toLowerCase().endsWith(`.dll`)){this.logger.error(`${e} > Zip contained a non-dll file: ${c.name}`);return}if(d||f){this.logger.error(`${e} > Zip entry path is unsafe: ${c.name}`);return}let p=g.join(a,u),m=await c.file.async(`nodebuffer`);await T.writeFile(p,m),this.logger.log(`${e} > Extracted 1 file to ${p}`);let h={buildId:t.build_id,buildFileName:t.build_file_name},_=g.join(this.getModulePath(e),`build.json`);await T.writeFile(_,JSON.stringify(h),`utf-8`),this.logger.log(`${e} > Saved buildId to file: ${t.build_id}`)}async cleanupExistingBuilds(e,t){let n=this.getModulePath(e),r=this.getBuildPath(e,t),i=await T.readdir(n,{withFileTypes:!0});for(let t of i)t.isDirectory()&&g.join(n,t.name)!==r&&(await T.rm(g.join(n,t.name),{recursive:!0,force:!0}),this.logger.log(`${e} > Cleaned up build: ${t.name}`))}async hasPathAccess(e){try{return await T.access(e,T.constants.F_OK),!0}catch{return!1}}async isDownloadCorrupted(e,t){if(!await this.hasPathAccess(e))return this.logger.error(`Download is corrupted. Path does not exist: ${e}`),!0;let n=t.build_file_name,r=g.join(e,n);if(!C(r))return this.logger.error(`Download is corrupted. Build file not found: ${r}`),!0;if(t.build_hash){let e=await T.readFile(r),i=ae(`sha256`).update(e).digest(`hex`);if(i.toLowerCase()!==t.build_hash.toLowerCase())return this.logger.error(`Download is corrupted. Build file hash mismatch: ${n} ${i.toLowerCase()} !== ${t.build_hash.toLowerCase()}`),!0}return!1}}),Bt=O(class extends L{REFETCH_INTERVAL=1e3*60*5;FAILED_REFETCH_INTERVAL=1e3*30;_ravenConfig;_executableToGameMap=new Map;_executablesArray=[];_refetchIntervalHandler=null;_failedRefetchTimeoutHandler=null;constructor(){super(`RavenManager`)}init(){super.init(),this.fetchRavenConfig(),this._refetchIntervalHandler=setInterval(()=>{this._failedRefetchTimeoutHandler&&=(clearTimeout(this._failedRefetchTimeoutHandler),null),this.fetchRavenConfig()},this.REFETCH_INTERVAL)}getExecutableData(e){return this._executableToGameMap.get(e.toLowerCase())??null}get executables(){return this._executablesArray}get executablesMap(){return this._executableToGameMap}destroy(){this._refetchIntervalHandler&&clearInterval(this._refetchIntervalHandler),this._failedRefetchTimeoutHandler&&clearTimeout(this._failedRefetchTimeoutHandler),zt.getInstance().destroy(),super.destroy()}async fetchRavenConfig(){try{this._ravenConfig={games:(await _t()).data.games},this.resetState();let e=new Set;for(let t of this._ravenConfig.games){for(let e of t.executables){let n=e.toLowerCase();this._executableToGameMap.set(n,t),this._executablesArray.push(n)}t.modules.forEach(t=>e.add(t))}await zt.getInstance().initWithDlls(Array.from(e)),this.logger.log(`Raven updated, monitoring ${this._executableToGameMap.size} executables`),this.emit(`executablesUpdated`,{executables:this.executables,map:this._executableToGameMap})}catch(e){this.logger.error(`Failed to fetch Raven config`,e),this._failedRefetchTimeoutHandler=setTimeout(()=>this.fetchRavenConfig(),this.FAILED_REFETCH_INTERVAL)}}resetState(){this._executableToGameMap.clear(),this._executablesArray=[]}}),G=O(class extends L{_processMonitor;_processes=new Map;boundOnRavenManagerExecutablesUpdated=this.onRavenManagerExecutablesUpdated.bind(this);constructor(){super(`ProcessManager`),this._processMonitor=new kt}get hasAnyActiveProcesses(){return this.activeProcesses.length>0}get activeProcesses(){return Array.from(this._processes.values()).flat().filter(e=>!e.destroyedAt)}init(){super.init(),Bt.getInstance().on(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processMonitor.on(`create`,e=>{this.logger.log(`Process created`,e),this.addProcess(e),this.logger.log(`Active Process Count: ${this._processes.size}`),this.emit(`create`,{process:e})}),this._processMonitor.on(`destroy`,e=>{this.logger.log(`Process destroyed`,e),this.deleteProcess(e),this.logger.log(`Active Process Count: ${this._processes.size}`),this.emit(`destroy`,{process:e})})}destroy(){Bt.getInstance().off(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processes.clear(),this._processMonitor.removeAllListeners(),super.destroy()}isProcessRunning(e){return this._processes.get(e)?.some(e=>!e.destroyedAt)??!1}onRavenManagerExecutablesUpdated(e){this.logger.log(`Monitoring ${e.executables.length} processes`),e.executables.forEach(e=>{this._processMonitor.isProcessRegistered(e)||this._processMonitor.registerProcess(e)})}addProcess(e){if(!e.name)return;let t=this._processes.get(e.name);if(!t){this._processes.set(e.name,[e]);return}this._processes.set(e.name,t.concat(e))}deleteProcess(e){if(!e.name)return;let t=this._processes.get(e.name)?.filter(t=>t.id!==e.id)??[];t.length===0?this._processes.delete(e.name):this._processes.set(e.name,t)}});var Vt=class{_instance;_resolution;boundOnResolutionChanged=this.onResolutionChanged.bind(this);constructor(e){this._instance=e,this._resolution={width:0,height:0},this._instance.on(`resolution`,this.boundOnResolutionChanged)}destroy(){this._instance.off(`resolution`,this.boundOnResolutionChanged)}get instance(){return this._instance}get resolution(){return this._resolution}onResolutionChanged(e,t){this._resolution={width:e,height:t}}};const Ht=O(class{interfaces={};constructor(){}createInterface(e){return this.interfaces[e]||(this.interfaces[e]=new Vt(new ze(e,{access:1}))),this.interfaces[e]}getInterface(e){return this.interfaces[e]?this.interfaces[e]:this.createInterface(e)}}),K=O(class{options;eventQueue;meta=null;enabled=!0;constructor(e){this.options=this.resolveOptions(e),this.eventQueue=new ge,this.setupFlushInterval()}track(e,t){this.enabled&&this.eventQueue.add({type:e,properties:t,created_at:new Date})}flush(){if(!this.enabled)return[];let e=Array.from(this.eventQueue.flush()).concat({type:`ping`,properties:{},created_at:new Date});if(!this.meta)throw Error(`Tried to flush Cortex events before meta was set`);try{St({...this.meta,messages:e})}catch{}return e}setupFlushInterval(){this.enabled&&setInterval(()=>{this.flush()},this.options.batchIntervalSeconds*1e3)}resolveOptions(e){return{batchIntervalSeconds:e?.batchIntervalSeconds??15}}}),q=e(import.meta.url),Ut=q.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x64.dll`),Wt=q.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x86.dll`),Gt=q.resolve(`@overlayed/app/dist/native-interface/build/overlayed_injector_x64.exe`),Kt=q.resolve(`@overlayed/app/dist/native-interface/build/overlayed_injector_x86.exe`),J=O(class extends Ze{boundOnProcessCreate=this.onProcessCreate.bind(this);boundOnProcessDestroy=this.onProcessDestroy.bind(this);subscribedGames=new Set;_activeReadyRavenGames={};get isInGame(){return Object.keys(this._activeReadyRavenGames).length>0}constructor(){super(`GameLaunchManager`)}setSubscribedGames(e){this.subscribedGames=new Set(e)}getActiveGames(){return Object.keys(this._activeReadyRavenGames)}init(){super.init(),Ht.getInstance().createInterface(`OGG_SIEGE`),G.getInstance().on(`create`,this.boundOnProcessCreate),G.getInstance().on(`destroy`,this.boundOnProcessDestroy)}destroy(){G.getInstance().off(`create`,this.boundOnProcessCreate),G.getInstance().off(`destroy`,this.boundOnProcessDestroy),super.destroy()}on(e,t){super.on(e,t);let n=me(e);if(!(n.includes(`gameReady`)||n.includes(`*`))||Object.keys(this._activeReadyRavenGames).length===0)return;let r=t;for(let e of Object.values(this._activeReadyRavenGames))this.logger.log(`Late calling gameReady callback for game`,e.game),r(e)}async onProcessCreate({process:e}){this.logger.log(`On process create`,e);let t=this.getRavenGame(e);if(!t)return;if(this.logger.log(`Raven game found`,t),t.command_line_regex){this.logger.log(`Performing command line regex check`,{regex:t.command_line_regex});try{let n=e.commandLine;this.logger.log(`Process command line`,n);let r=new RegExp(t.command_line_regex);if(!e.commandLine||!r.test(e.commandLine)){this.logger.log(`Process command line does not match regex, skipping`,{commandLine:e.commandLine,regex:t.command_line_regex});return}}catch(e){this.logger.error(`Failed to check command line`,e);return}}if(K.getInstance().track(`game_launch`,{game:t.identifier}),this.subscribedGames.size===0){this.logger.warn(`No subscribed games, skipping`);return}if(!this.subscribedGames.has(t.identifier)&&!this.subscribedGames.has(`*`))return;let n=new AbortController;if(await this.emit(`gameLaunch`,{game:t.identifier,reject:()=>n.abort()}),n.signal.aborted)return;let r=At.currentProcess;if(this.logger.log(`Game Launched`,t),this.logger.log(`Process is elevated: `,e.isElevated),this.logger.log(`Current process is elevated: `,r.isElevated),e.isElevated&&!r.isElevated){k.getInstance().fatal(`Game is elevated but the App is not`,`ELEVATION_MISMATCH`,{appElevated:!!r.isElevated,gameElevated:!!e.isElevated}),this.logger.log(`Game elevated but App is not`,{appElevated:r.isElevated,gameElevated:e.isElevated});return}let i=e.createdAt||new Date,a=Math.floor((new Date().getTime()-i.getTime())/1e3);this.logger.log(`Process created ${a}s ago`),a<30&&(this.logger.log(`Delaying injection for 45 seconds to allow game to be ready`),await new Promise(e=>setTimeout(e,1e3*45)));let{ri_disabled:o,gm_disabled:s}=Nt(),c=!1;!o&&t.has_render_support&&t.allow_dll_injections?c=await this.injectRenderInterface(e):this.logger.log(`Skipping render interface injection`,{has_render_support:t.has_render_support,allow_dll_injections:t.allow_dll_injections,ri_disabled:o}),!s&&t.allow_dll_injections?await this.injectGameModules(t,e):this.logger.log(`Skipping game module(s) injection`,{allow_dll_injections:t.allow_dll_injections,gm_disabled:s});let l={game:t.identifier,inGameRenderingSupported:c};this._activeReadyRavenGames[t.identifier]=l,this.logger.debug(`Active ready raven games`,Object.keys(this._activeReadyRavenGames).join(`, `)),this.logger.log(`Game Ready`),this.emit(`gameReadyInternal`,{ravenGame:t,process:e}),this.emit(`gameReady`,l),K.getInstance().track(`game_ready`,{game:t.identifier})}copyInjectors(){let e=this.copyDll(Gt),t=this.copyDll(Kt);return!e||!t?(this.logger.error(`Failed to copy injector executables`),!1):g.dirname(e)}copyDll(e){let t=g.basename(e),n=v(e),r=g.join(Se(),`resources`),i=g.join(r,t);this.logger.info(`Copying`,n,`to`,i);try{C(r)||te(r,{recursive:!0}),re(i,ne(n)),S(n,i)}catch(e){return e.code===`EBUSY`?i:(this.logger.error(`Failed to copy`,e),this.logger.error(`Failed to copy`,{originalPath:n,targetPath:i}),!1)}return i}async injectRenderInterface(e){this.logger.log(`Injecting render interface`,{is32Bit:e.is32Bit,process:e});let t=e.is32Bit?Wt:Ut;this.logger.log(`Render hook path`,t);let n=this.copyDll(t);if(!n)return this.logger.error(`Failed to copy render hook DLL`,{renderHookPath:t}),!1;let r=this.copyInjectors();if(!r)return!1;this.logger.log(`Resolved injector path`,r);try{return this.logger.log(`Injecting render interface`,n),await e.injectDll(n,r),this.logger.log(`Render Interface Injection Successful`,n),!0}catch(e){return this.logger.error(`Render Interface Injection Failed`,e),this.logger.error(`Render Interface Injection Failed`,{renderHookPathCopied:n}),!1}}async injectGameModules(e,t){let n=this.copyInjectors();if(n){this.logger.log(`Resolved injector path`,n);for(let r of e.modules){let e=await zt.getInstance().getDllFile(r);if(!e){this.logger.error(`No DLL file found for module`,{moduleId:r});continue}try{this.logger.log(`Injecting game module`,e),await t.injectDll(e,n),this.logger.log(`Injection Successful`,e)}catch(t){this.logger.error(`Injection Failed`,{dllFile:e},t)}}}}onProcessDestroy({process:e}){let t=this.getRavenGame(e);t&&(delete this._activeReadyRavenGames[t.identifier],this.logger.debug(`Active ready raven games`,Object.keys(this._activeReadyRavenGames).join(`, `)),this.emit(`gameCloseInternal`,{ravenGame:t,process:e}),this.emit(`gameClose`,{game:t.identifier}),K.getInstance().track(`game_close`,{game:t.identifier}))}getRavenGame(e){if(!e.name)return;let t=Bt.getInstance().getExecutableData(e.name);if(!t){this.logger.error(`No raven game found for process`,{process:e});return}return t}}),qt=O(class extends Xe{boundOnGameLaunch=this.onGameLaunch.bind(this);constructor(){super(`GameBuildManager`)}init(){super.init(),J.getInstance().on(`gameReadyInternal`,this.boundOnGameLaunch)}destroy(){J.getInstance().off(`gameReadyInternal`,this.boundOnGameLaunch),super.destroy()}async onGameLaunch(...e){let[{ravenGame:t,process:n}]=e;if(!n.path||!n.name){this.logger.error(`Process path or name not found, could not check for build hash`,void 0,n);return}let r=ne(n.path),i=ae(`sha256`).update(r).digest(`hex`);this.logger.log(`Process Path`,n.path),this.logger.log(`Process Name`,n.name),this.logger.log(`Build Hash`,i);let a=!1;try{a=(await yt(t.identifier,i)).data.upload}catch(e){this.logger.error(`Error checking game build hash`,e);return}if(!a){this.logger.log(`Build hash already exists, skipping upload`);return}let o=new se;o.file(n.name,r);let s=await o.generateAsync({type:`blob`});try{this.logger.log(`Uploading build (size: `,s.size,` bytes)`);let e=new P(s,{chunkSizeMb:25,maxConcurrent:1}),n=await bt(t.identifier,{build_hash:i,chunk_count:e.totalChunks,file_size_bytes:s.size});await e.chunk(async(e,r)=>{this.logger.log(`Uploading chunk`,r),await xt(t.identifier,{chunk:e,build_hash:i,chunk_index:r,upload_token:n.data.upload_token})}),this.logger.log(`Build uploaded successfully`)}catch(e){wt(e)?Tt(e.response)?this.logger.error(`Error uploading build hash, api error`,e):this.logger.error(`Error uploading build hash, request error`,e):this.logger.error(`Error uploading build hash, unknown error`,e)}}}),Jt=O(class extends Xe{constructor(){super(`CampaignManager`)}async check(e){let t=g.join(we(e),`campaign_code.txt`);try{let e=(await E.readFile(t,`utf-8`)).trim().replace(/ \(\d+\)/g,``);e&&(this.logger.log(`UTM campaign code found`,e),K.getInstance().track(`utm_attribution`,{campaign_code:e}),K.getInstance().flush())}catch{}}}),Yt=new A({path:p.normalize(`${process.env.APPDATA||process.env.HOME||`.`}/.overlayed/config.json`),default:void 0,schema:n({Account:r({email:`string`,apiKey:`string`})}).type({currentAccount:`Account | undefined`,accounts:`Account[]`}).or(`undefined`)});function Xt(e,t){return`${e}:${t}`}function Zt(e,t,n){return e.reduce((e,r)=>{let i=r.key;return e[i]={on(e,n){let r=Xt(i,e),a=t.get(r)??new Set;a.add(n),t.set(r,a)},onAny(e){let n=Xt(i,`*`),r=t.get(n)??new Set;r.add(e),t.set(n,r)},off(e,n){let r=Xt(i,e),a=t.get(r);a&&(a.delete(n),a.size===0&&t.delete(r))},offAny(e){let n=Xt(i,`*`),r=t.get(n);r&&(r.delete(e),r.size===0&&t.delete(n))},readyForGameEvents:()=>{n.emit(`flushEvents`,i)}},e},{})}function Qt(){let e=k.getInstance(),t=J.getInstance();return{on:(n,r)=>{switch(n){case`fatal`:e.on(`fatal`,r);break;case`error`:e.on(`error`,r);break;case`warning`:e.on(`warning`,r);break;case`gameLaunch`:t.on(`gameLaunch`,r);break;case`gameClose`:t.on(`gameClose`,r);break;case`gameReady`:t.on(`gameReady`,r);break;default:throw Error(`Event type not implemented ${n}`,{cause:[n,r]})}},off:(n,r)=>{switch(n){case`fatal`:e.off(`fatal`,r);break;case`error`:e.off(`error`,r);break;case`warning`:e.off(`warning`,r);break;case`gameLaunch`:t.off(`gameLaunch`,r);break;case`gameClose`:t.off(`gameClose`,r);break;case`gameReady`:t.off(`gameReady`,r);break;default:throw Error(`Event type not implemented ${n}`,{cause:[n,r]})}}}}var Y=function(e){return e[e.LeftButton=1]=`LeftButton`,e[e.RightButton=2]=`RightButton`,e[e.Cancel=3]=`Cancel`,e[e.MiddleButton=4]=`MiddleButton`,e[e.ExtraButton1=5]=`ExtraButton1`,e[e.ExtraButton2=6]=`ExtraButton2`,e[e.Back=8]=`Back`,e[e.Tab=9]=`Tab`,e[e.Clear=12]=`Clear`,e[e.Return=13]=`Return`,e[e.Shift=16]=`Shift`,e[e.Control=17]=`Control`,e[e.Menu=18]=`Menu`,e[e.Pause=19]=`Pause`,e[e.CapsLock=20]=`CapsLock`,e[e.Kana=21]=`Kana`,e[e.Hangeul=21]=`Hangeul`,e[e.Hangul=21]=`Hangul`,e[e.Junja=23]=`Junja`,e[e.Final=24]=`Final`,e[e.Hanja=25]=`Hanja`,e[e.Kanji=25]=`Kanji`,e[e.Escape=27]=`Escape`,e[e.Convert=28]=`Convert`,e[e.NonConvert=29]=`NonConvert`,e[e.Accept=30]=`Accept`,e[e.ModeChange=31]=`ModeChange`,e[e.Space=32]=`Space`,e[e.Prior=33]=`Prior`,e[e.Next=34]=`Next`,e[e.End=35]=`End`,e[e.Home=36]=`Home`,e[e.Left=37]=`Left`,e[e.Up=38]=`Up`,e[e.Right=39]=`Right`,e[e.Down=40]=`Down`,e[e.Select=41]=`Select`,e[e.Print=42]=`Print`,e[e.Execute=43]=`Execute`,e[e.Snapshot=44]=`Snapshot`,e[e.Insert=45]=`Insert`,e[e.Delete=46]=`Delete`,e[e.Help=47]=`Help`,e[e.N0=48]=`N0`,e[e.N1=49]=`N1`,e[e.N2=50]=`N2`,e[e.N3=51]=`N3`,e[e.N4=52]=`N4`,e[e.N5=53]=`N5`,e[e.N6=54]=`N6`,e[e.N7=55]=`N7`,e[e.N8=56]=`N8`,e[e.N9=57]=`N9`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.LeftWindows=91]=`LeftWindows`,e[e.RightWindows=92]=`RightWindows`,e[e.Application=93]=`Application`,e[e.Sleep=95]=`Sleep`,e[e.Numpad0=96]=`Numpad0`,e[e.Numpad1=97]=`Numpad1`,e[e.Numpad2=98]=`Numpad2`,e[e.Numpad3=99]=`Numpad3`,e[e.Numpad4=100]=`Numpad4`,e[e.Numpad5=101]=`Numpad5`,e[e.Numpad6=102]=`Numpad6`,e[e.Numpad7=103]=`Numpad7`,e[e.Numpad8=104]=`Numpad8`,e[e.Numpad9=105]=`Numpad9`,e[e.Multiply=106]=`Multiply`,e[e.Add=107]=`Add`,e[e.Separator=108]=`Separator`,e[e.Subtract=109]=`Subtract`,e[e.Decimal=110]=`Decimal`,e[e.Divide=111]=`Divide`,e[e.F1=112]=`F1`,e[e.F2=113]=`F2`,e[e.F3=114]=`F3`,e[e.F4=115]=`F4`,e[e.F5=116]=`F5`,e[e.F6=117]=`F6`,e[e.F7=118]=`F7`,e[e.F8=119]=`F8`,e[e.F9=120]=`F9`,e[e.F10=121]=`F10`,e[e.F11=122]=`F11`,e[e.F12=123]=`F12`,e[e.F13=124]=`F13`,e[e.F14=125]=`F14`,e[e.F15=126]=`F15`,e[e.F16=127]=`F16`,e[e.F17=128]=`F17`,e[e.F18=129]=`F18`,e[e.F19=130]=`F19`,e[e.F20=131]=`F20`,e[e.F21=132]=`F21`,e[e.F22=133]=`F22`,e[e.F23=134]=`F23`,e[e.F24=135]=`F24`,e[e.NumLock=144]=`NumLock`,e[e.ScrollLock=145]=`ScrollLock`,e[e.NEC_Equal=146]=`NEC_Equal`,e[e.Fujitsu_Jisho=146]=`Fujitsu_Jisho`,e[e.Fujitsu_Masshou=147]=`Fujitsu_Masshou`,e[e.Fujitsu_Touroku=148]=`Fujitsu_Touroku`,e[e.Fujitsu_Loya=149]=`Fujitsu_Loya`,e[e.Fujitsu_Roya=150]=`Fujitsu_Roya`,e[e.LeftShift=160]=`LeftShift`,e[e.RightShift=161]=`RightShift`,e[e.LeftControl=162]=`LeftControl`,e[e.RightControl=163]=`RightControl`,e[e.LeftMenu=164]=`LeftMenu`,e[e.RightMenu=165]=`RightMenu`,e[e.BrowserBack=166]=`BrowserBack`,e[e.BrowserForward=167]=`BrowserForward`,e[e.BrowserRefresh=168]=`BrowserRefresh`,e[e.BrowserStop=169]=`BrowserStop`,e[e.BrowserSearch=170]=`BrowserSearch`,e[e.BrowserFavorites=171]=`BrowserFavorites`,e[e.BrowserHome=172]=`BrowserHome`,e[e.VolumeMute=173]=`VolumeMute`,e[e.VolumeDown=174]=`VolumeDown`,e[e.VolumeUp=175]=`VolumeUp`,e[e.MediaNextTrack=176]=`MediaNextTrack`,e[e.MediaPrevTrack=177]=`MediaPrevTrack`,e[e.MediaStop=178]=`MediaStop`,e[e.MediaPlayPause=179]=`MediaPlayPause`,e[e.LaunchMail=180]=`LaunchMail`,e[e.LaunchMediaSelect=181]=`LaunchMediaSelect`,e[e.LaunchApplication1=182]=`LaunchApplication1`,e[e.LaunchApplication2=183]=`LaunchApplication2`,e[e.OEM1=186]=`OEM1`,e[e.OEMPlus=187]=`OEMPlus`,e[e.OEMComma=188]=`OEMComma`,e[e.OEMMinus=189]=`OEMMinus`,e[e.OEMPeriod=190]=`OEMPeriod`,e[e.OEM2=191]=`OEM2`,e[e.OEM3=192]=`OEM3`,e[e.OEM4=219]=`OEM4`,e[e.OEM5=220]=`OEM5`,e[e.OEM6=221]=`OEM6`,e[e.OEM7=222]=`OEM7`,e[e.OEM8=223]=`OEM8`,e[e.OEMAX=225]=`OEMAX`,e[e.OEM102=226]=`OEM102`,e[e.ICOHelp=227]=`ICOHelp`,e[e.ICO00=228]=`ICO00`,e[e.ProcessKey=229]=`ProcessKey`,e[e.ICOClear=230]=`ICOClear`,e[e.Packet=231]=`Packet`,e[e.OEMReset=233]=`OEMReset`,e[e.OEMJump=234]=`OEMJump`,e[e.OEMPA1=235]=`OEMPA1`,e[e.OEMPA2=236]=`OEMPA2`,e[e.OEMPA3=237]=`OEMPA3`,e[e.OEMWSCtrl=238]=`OEMWSCtrl`,e[e.OEMCUSel=239]=`OEMCUSel`,e[e.OEMATTN=240]=`OEMATTN`,e[e.OEMFinish=241]=`OEMFinish`,e[e.OEMCopy=242]=`OEMCopy`,e[e.OEMAuto=243]=`OEMAuto`,e[e.OEMENLW=244]=`OEMENLW`,e[e.OEMBackTab=245]=`OEMBackTab`,e[e.ATTN=246]=`ATTN`,e[e.CRSel=247]=`CRSel`,e[e.EXSel=248]=`EXSel`,e[e.EREOF=249]=`EREOF`,e[e.Play=250]=`Play`,e[e.Zoom=251]=`Zoom`,e[e.Noname=252]=`Noname`,e[e.PA1=253]=`PA1`,e[e.OEMClear=254]=`OEMClear`,e}(Y||{});const $t=new Map([[Y.LeftButton,`LeftButton`],[Y.RightButton,`RightButton`],[Y.Cancel,`Cancel`],[Y.MiddleButton,`MiddleButton`],[Y.ExtraButton1,`ExtraButton1`],[Y.ExtraButton2,`ExtraButton2`],[Y.Back,`Backspace`],[Y.Tab,`Tab`],[Y.Clear,`Clear`],[Y.Return,`Enter`],[Y.Shift,`ShiftLeft`],[Y.Control,`ControlLeft`],[Y.Menu,`AltLeft`],[Y.Pause,`Pause`],[Y.CapsLock,`CapsLock`],[Y.Kana,`KanaMode`],[Y.Junja,`JunjaMode`],[Y.Final,`Finalize`],[Y.Hanja,`HanjaMode`],[Y.Escape,`Escape`],[Y.Convert,`Convert`],[Y.NonConvert,`NonConvert`],[Y.Accept,`Accept`],[Y.ModeChange,`ModeChange`],[Y.Space,`Space`],[Y.Prior,`PageUp`],[Y.Next,`PageDown`],[Y.End,`End`],[Y.Home,`Home`],[Y.Left,`ArrowLeft`],[Y.Up,`ArrowUp`],[Y.Right,`ArrowRight`],[Y.Down,`ArrowDown`],[Y.Select,`Select`],[Y.Print,`PrintScreen`],[Y.Execute,`Execute`],[Y.Snapshot,`Snapshot`],[Y.Insert,`Insert`],[Y.Delete,`Delete`],[Y.Help,`Help`],[Y.N0,`Digit0`],[Y.N1,`Digit1`],[Y.N2,`Digit2`],[Y.N3,`Digit3`],[Y.N4,`Digit4`],[Y.N5,`Digit5`],[Y.N6,`Digit6`],[Y.N7,`Digit7`],[Y.N8,`Digit8`],[Y.N9,`Digit9`],[Y.A,`KeyA`],[Y.B,`KeyB`],[Y.C,`KeyC`],[Y.D,`KeyD`],[Y.E,`KeyE`],[Y.F,`KeyF`],[Y.G,`KeyG`],[Y.H,`KeyH`],[Y.I,`KeyI`],[Y.J,`KeyJ`],[Y.K,`KeyK`],[Y.L,`KeyL`],[Y.M,`KeyM`],[Y.N,`KeyN`],[Y.O,`KeyO`],[Y.P,`KeyP`],[Y.Q,`KeyQ`],[Y.R,`KeyR`],[Y.S,`KeyS`],[Y.T,`KeyT`],[Y.U,`KeyU`],[Y.V,`KeyV`],[Y.W,`KeyW`],[Y.X,`KeyX`],[Y.Y,`KeyY`],[Y.Z,`KeyZ`],[Y.LeftWindows,`MetaLeft`],[Y.RightWindows,`MetaRight`],[Y.Application,`ContextMenu`],[Y.Sleep,`Sleep`],[Y.Numpad0,`Numpad0`],[Y.Numpad1,`Numpad1`],[Y.Numpad2,`Numpad2`],[Y.Numpad3,`Numpad3`],[Y.Numpad4,`Numpad4`],[Y.Numpad5,`Numpad5`],[Y.Numpad6,`Numpad6`],[Y.Numpad7,`Numpad7`],[Y.Numpad8,`Numpad8`],[Y.Numpad9,`Numpad9`],[Y.Multiply,`NumpadMultiply`],[Y.Add,`NumpadAdd`],[Y.Separator,`NumpadSeparator`],[Y.Subtract,`NumpadSubtract`],[Y.Decimal,`NumpadDecimal`],[Y.Divide,`NumpadDivide`],[Y.F1,`F1`],[Y.F2,`F2`],[Y.F3,`F3`],[Y.F4,`F4`],[Y.F5,`F5`],[Y.F6,`F6`],[Y.F7,`F7`],[Y.F8,`F8`],[Y.F9,`F9`],[Y.F10,`F10`],[Y.F11,`F11`],[Y.F12,`F12`],[Y.F13,`F13`],[Y.F14,`F14`],[Y.F15,`F15`],[Y.F16,`F16`],[Y.F17,`F17`],[Y.F18,`F18`],[Y.F19,`F19`],[Y.F20,`F20`],[Y.F21,`F21`],[Y.F22,`F22`],[Y.F23,`F23`],[Y.F24,`F24`],[Y.NumLock,`NumLock`],[Y.ScrollLock,`ScrollLock`],[Y.NEC_Equal,`NEC_Equal`],[Y.Fujitsu_Masshou,`Fujitsu_Masshou`],[Y.Fujitsu_Touroku,`Fujitsu_Touroku`],[Y.Fujitsu_Loya,`Fujitsu_Loya`],[Y.Fujitsu_Roya,`Fujitsu_Roya`],[Y.LeftShift,`ShiftLeft`],[Y.RightShift,`ShiftRight`],[Y.LeftControl,`ControlLeft`],[Y.RightControl,`ControlRight`],[Y.LeftMenu,`AltLeft`],[Y.RightMenu,`AltRight`],[Y.BrowserBack,`BrowserBack`],[Y.BrowserForward,`BrowserForward`],[Y.BrowserRefresh,`BrowserRefresh`],[Y.BrowserStop,`BrowserStop`],[Y.BrowserSearch,`BrowserSearch`],[Y.BrowserFavorites,`BrowserFavorites`],[Y.BrowserHome,`BrowserHome`],[Y.VolumeMute,`VolumeMute`],[Y.VolumeDown,`VolumeDown`],[Y.VolumeUp,`VolumeUp`],[Y.MediaNextTrack,`MediaTrackNext`],[Y.MediaPrevTrack,`MediaTrackPrevious`],[Y.MediaStop,`MediaStop`],[Y.MediaPlayPause,`MediaPlayPause`],[Y.LaunchMail,`LaunchMail`],[Y.LaunchMediaSelect,`LaunchMediaSelect`],[Y.LaunchApplication1,`LaunchApplication1`],[Y.LaunchApplication2,`LaunchApplication2`],[Y.OEM1,`OEM_1`],[Y.OEMPlus,`Equal`],[Y.OEMComma,`Comma`],[Y.OEMMinus,`Minus`],[Y.OEMPeriod,`Period`],[Y.OEM2,`Slash`],[Y.OEM3,`Backquote`],[Y.OEM4,`BracketLeft`],[Y.OEM5,`Backslash`],[Y.OEM6,`BracketRight`],[Y.OEM7,`Quote`],[Y.OEM8,`IntlRo`],[Y.OEMAX,`OEM_AX`],[Y.OEM102,`IntlBackslash`],[Y.ICOHelp,`ICO_HELP`],[Y.ICO00,`ICO_00`],[Y.ProcessKey,`Process`],[Y.ICOClear,`ICO_CLEAR`],[Y.Packet,`Packet`],[Y.OEMReset,`OEM_Reset`],[Y.OEMJump,`OEM_Jump`],[Y.OEMPA1,`OEM_PA1`],[Y.OEMPA2,`OEM_PA2`],[Y.OEMPA3,`OEM_PA3`],[Y.OEMWSCtrl,`OEM_WS_Ctrl`],[Y.OEMCUSel,`OEM_CU_Sel`],[Y.OEMATTN,`OEM_ATTN`],[Y.OEMFinish,`OEM_Finish`],[Y.OEMCopy,`OEM_Copy`],[Y.OEMAuto,`OEM_Auto`],[Y.OEMENLW,`OEM_ENLW`],[Y.OEMBackTab,`BackTab`],[Y.ATTN,`ATTN`],[Y.CRSel,`CRSel`],[Y.EXSel,`EXSel`],[Y.EREOF,`EREOF`],[Y.Play,`MediaPlay`],[Y.Zoom,`Zoom`],[Y.Noname,`Noname`],[Y.PA1,`PA1`],[Y.OEMClear,`OEM_Clear`]]),en=new Map($t.entries().map(([e,t])=>[t,e])),tn=r({"[string]":{keys:`string[]`,mode:r(`'toggle' | 'hold'`).pipe(e=>e??`toggle`)}});var nn=class extends L{preferencesKeybindToCallbacks=new Map;pressedKeys=new Set;activeKeybinds=new Set;triggeredToggleKeybinds=new Set;boundHandleKeyboardFocus=this.handleKeyboardFocus.bind(this);boundHandleKeyDown=this.handleKeyDown.bind(this);boundHandleKeyUp=this.handleKeyUp.bind(this);keybindsFile;keybindListeningPaused=!1;constructor(e){super(`KeybindManager`),this.keybindsFile=new A({path:Mt([`keybinds.json`]),schema:tn,default:e})}init(){super.init();let e=Ht.getInstance().getInterface(`OGG_SIEGE`);e.instance.on(`keyboardFocus`,this.boundHandleKeyboardFocus),e.instance.on(`keyDown`,this.boundHandleKeyDown),e.instance.on(`keyUp`,this.boundHandleKeyUp)}async onKeybindToggled(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.toggle.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindDown(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.down.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindUp(e,t){let n=this.preferencesKeybindToCallbacks.get(e)??{toggle:[],down:[],up:[]};n.up.push(t),this.preferencesKeybindToCallbacks.set(e,n)}async updateKeybind(e,t){this.keybindsFile.set({[e]:t})}async updateKeybinds(e){let t=Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0));this.keybindsFile.set({...this.keybindsFile.get(),...t})}getConfig(){return this.keybindsFile.get()}destroy(){let e=Ht.getInstance().getInterface(`OGG_SIEGE`);e.instance.off(`keyboardFocus`,this.boundHandleKeyboardFocus),e.instance.off(`keyDown`,this.boundHandleKeyDown),e.instance.off(`keyUp`,this.boundHandleKeyUp),super.destroy()}handleKeyDown(e){if(this.keybindListeningPaused)return;let t=$t.get(e.key);if(!t){this.logger.error(`Unknown key down`,e);return}this.pressedKeys.add(t),this.checkKeybindings()}handleKeyboardFocus(){this.pressedKeys.clear(),this.activeKeybinds.clear(),this.triggeredToggleKeybinds.clear()}async handleKeyUp(e){if(this.keybindListeningPaused)return;let t=$t.get(e.key);if(!t)return;this.pressedKeys.delete(t);let n=this.keybindsFile.get();for(let[e]of this.preferencesKeybindToCallbacks.entries())n[e].keys.includes(t)&&this.triggeredToggleKeybinds.delete(e);this.checkKeybindUps()}async checkKeybindUps(){let e=this.keybindsFile.get();for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){if(!n.up||n.up.length===0)continue;let r=e[t];if(this.activeKeybinds.has(t)&&r.keys.some(e=>!this.pressedKeys.has(e))){this.activeKeybinds.delete(t);for(let e of n.up)e();this.logger.log(`Keybind up triggered`,this.getKeybindToString(r))}}}async checkKeybindings(){let e=this.keybindsFile.get();for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t];if(r.keys.length===this.pressedKeys.size&&r.keys.every(e=>en.has(e)?this.pressedKeys.has(e):!1)){this.triggerKeybind(r,n,t);return}}for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t];r.keys.every(e=>en.has(e)?this.pressedKeys.has(e):(this.logger.error(`Unknown key`,e,r),!1))&&this.triggerKeybind(r,n,t)}}triggerKeybind(e,t,n){let r=e.mode;if(r===`toggle`&&t.toggle&&t.toggle.length>0&&!this.triggeredToggleKeybinds.has(n)){let r;for(let e of t.toggle){let t=e();typeof t==`string`&&r===void 0&&(r=t)}this.triggeredToggleKeybinds.add(n),this.logger.log(r?`Keybind pressed rejected: ${r}`:`Keybind pressed accepted`,this.getKeybindToString(e))}if(r===`hold`&&t.down&&t.down.length>0&&!this.activeKeybinds.has(n)){let r;for(let e of t.down){let t=e();if(typeof t==`string`){r=t;break}}r?this.logger.log(`Keybind down rejected: ${r}`,this.getKeybindToString(e)):(this.activeKeybinds.add(n),this.logger.log(`Keybind down accepted`,this.getKeybindToString(e)))}}getKeybindToString(e){return`(${e.keys.join(`+`)}${e.mode?` ${e.mode}`:``})`}};function rn(e){let t=new nn(e),n={};for(let r in e)n[r]={on:(e,n)=>{switch(e){case`down`:t.onKeybindDown(r,n);break;case`up`:t.onKeybindUp(r,n);break;case`toggle`:t.onKeybindToggled(r,n);break;default:throw Error(`Event type not implemented ${e}`,{cause:[e,n]})}}};let r={...n,getConfig:()=>t.getConfig(),pauseKeybindListening:()=>{t.keybindListeningPaused=!0},resumeKeybindListening:()=>{t.keybindListeningPaused=!1},updateKeybind:(e,n)=>{t.updateKeybind(e,n)},updateKeybinds:e=>{t.updateKeybinds(e)}};return t.init(),le.on(`quit`,()=>{t.destroy()}),r}function X(){return Ht.getInstance().getInterface(`OGG_SIEGE`)}function an(){let e=J.getInstance(),t=k.getInstance(),n=K.getInstance();if(!le.isPackaged){N.getInstance().info(`Cortex is disabled in development`),n.enabled=!1;return}try{n.meta=on()}catch(e){N.getInstance().error(`Failed to setup cortex`,e);return}e.on([`gameReady`,`gameClose`],()=>{n.meta||=on(),n.meta.in_game=e.isInGame}),t.on(`fatal`,e=>{n.track(`fatal`,{message:e.message,code:e.code,data:JSON.stringify(e.data)})}),t.on(`error`,e=>{n.track(`error`,{code:e.code,message:e.message,data:JSON.stringify(e.data)})}),t.on(`warning`,e=>{n.track(`warning`,{message:e.message,code:e.code,data:JSON.stringify(e.data)})})}function on(){if(!global.OVERLAYED_META.release.id)throw Error(`Release ID is required`);return{app_id:global.OVERLAYED.APPLICATION_ID,user_id:W(),release_id:global.OVERLAYED_META.release.id,app_channel:global.OVERLAYED.APP_BUILD_CHANNEL,app_version:global.OVERLAYED.APP_VERSION,package_version:global.OVERLAYED.PACKAGE_VERSION,frontend_version:global.OVERLAYED.FRONTEND_VERSION,frontend_release_id:global.OVERLAYED.FRONTEND_RELEASE_ID,session_id:global.OVERLAYED.sessionId,in_game:!1}}const sn=O(class extends L{CHECK_INTERVAL=1e3*60*15;RETRY_INTERVAL=1e3*15;_updateCheckInterval=null;_latestCheckResponse=null;_activeCheckResponse=null;initialReleaseId=null;get manualUpdatesEnabled(){return this.options?.manualUpdates??!1}get activeReleaseId(){return this._activeCheckResponse?.release_id??this.initialReleaseId}constructor(){super(`SiteManager`)}init(e){super.init(e),e?.manualUpdates&&this.enableManualUpdates()}destroy(){super.destroy(),this._updateCheckInterval&&=(clearInterval(this._updateCheckInterval),null)}allowSiteUpdateOnNextLoad(){if(!this.options?.manualUpdates){this.logger.warn(`allowSiteUpdateOnNextLoad called but manual updates are disabled`);return}if(!this._latestCheckResponse){this.logger.warn(`allowSiteUpdateOnNextLoad called but no update has been checked yet`);return}if(this._activeCheckResponse?.release_id===this._latestCheckResponse.release_id){this.logger.warn(`allowSiteUpdateOnNextLoad called but theres no update available`);return}this._activeCheckResponse=this._latestCheckResponse,K.getInstance().track(`site_update_applied`,{version:this._latestCheckResponse.version,release_id:this._latestCheckResponse.release_id}),this.setFrontendCortexMeta(this._latestCheckResponse.release_id,this._latestCheckResponse.version)}setFrontendCortexMeta(e,t){let n=K.getInstance();n.meta||=on(),e&&(global.OVERLAYED.FRONTEND_RELEASE_ID=e,n.meta.frontend_release_id=e),t&&(global.OVERLAYED.FRONTEND_VERSION=t,n.meta.frontend_version=t),e&&t&&n.track(`frontend_version_changed`,{version:t,release_id:e})}enableManualUpdates(){this.logger.log(`Enabling manual site updates`),this.checkForUpdates(),this._updateCheckInterval=setInterval(()=>{this.checkForUpdates(!0)},this.CHECK_INTERVAL)}async checkForUpdates(e=!1){let t=global.OVERLAYED_META?.application?.siteUrl;if(!t){this.logger.log(`No siteUrl configured, skipping check`);return}K.getInstance().track(`site_check_for_update`,{});try{let n=new URL(`/check`,t).toString();this.logger.log(`Checking site URL`,n);let r={"Overlayed-User-Agent":tt({package_version:global.OVERLAYED.PACKAGE_VERSION,application_id:global.OVERLAYED.APPLICATION_ID,application_version:global.OVERLAYED.APP_VERSION}),"Overlayed-Cortex-User-Id":global.OVERLAYED_RUNTIME.userId},i=It();i&&(r[`Overlayed-Access-Token`]=i);let a=global.OVERLAYED_META.release.channelId;a&&(r[`Overlayed-Channel-Id`]=a);let o=await fetch(n,{headers:r});if(!o.ok){this.logger.warn(`Site check failed with status`,o.status),K.getInstance().track(`site_check_error`,{status:o.status}),e&&this.scheduleRetry();return}let s=await o.json();if(this.logger.log(`Site check response`,s),!s.release_id){this.logger.error(`Site check response missing release_id`);return}if(!this._latestCheckResponse){this._latestCheckResponse=s;return}return this._latestCheckResponse.release_id===s.release_id?void 0:(this.logger.log(`New site version detected`,s),this._latestCheckResponse=s,K.getInstance().track(`site_update_ready`,{version:s.version,release_id:s.release_id}),this.emit(`siteUpdateReady`,{releaseId:s.release_id,version:s.version}),s)}catch(e){let t=e instanceof Error?e.message:String(e);K.getInstance().track(`site_check_error`,{message:t}),this.logger.error(`Site check failed`,{error:e,message:t}),this.scheduleRetry()}}scheduleRetry(){setTimeout(()=>{this.checkForUpdates()},this.RETRY_INTERVAL)}}),cn=O(M,`browser-windows.log`);let ln;function un(){return ln||(ln=class e extends global.OVERLAYED.electron.BrowserWindow{static session=void 0;constructor(t){let n=e.resolveCustomOptions(t);super(n)}static resolveCustomOptions(t){let n=global.OVERLAYED_META,r=global.OVERLAYED_RUNTIME;return{...t,webPreferences:{...t.webPreferences,session:e.getSession(),additionalArguments:[...t.webPreferences?.additionalArguments||[],...global.OVERLAYED.electron.app.isPackaged?[]:[`--overlayed-meta=${JSON.stringify(n)}`],`--overlayed-runtime=${JSON.stringify(r)}`]}}}static getSession(){if(!global.OVERLAYED_META?.application?.siteUrl)return;if(e.session)return e.session;e.session=global.OVERLAYED.electron.session.fromPartition(`persist:overlayed-${global.OVERLAYED.APPLICATION_ID}`);let t=sn.getInstance(),n=tt({package_version:global.OVERLAYED.PACKAGE_VERSION,application_id:global.OVERLAYED.APPLICATION_ID,application_version:global.OVERLAYED.APP_VERSION}),r={urls:[global.OVERLAYED_META.application.siteUrl+`/*`]},i=global.OVERLAYED_RUNTIME.userId;return e.session.webRequest.onBeforeSendHeaders(r,(e,r)=>{let a=It();a&&(e.requestHeaders[`Overlayed-Access-Token`]=a);let o=global.OVERLAYED_META.release.channelId;o&&(e.requestHeaders[`Overlayed-Channel-Id`]=o),t.manualUpdatesEnabled&&t.activeReleaseId&&(e.requestHeaders[`Overlayed-Release-Id`]=t.activeReleaseId),e.requestHeaders[`Overlayed-Cortex-User-Id`]=i,e.requestHeaders[`Overlayed-User-Agent`]=n,r({requestHeaders:e.requestHeaders})}),t.manualUpdatesEnabled&&e.session.webRequest.onHeadersReceived(r,(e,n)=>{if(t.initialReleaseId){n(e);return}let r=e.responseHeaders?.[`Overlayed-Release-Id`]?.[0];r&&(t.initialReleaseId=V(r));let i=e.responseHeaders?.[`Overlayed-Release-Version`]?.[0];t.setFrontendCortexMeta(r,i),n(e)}),e.session}},ln)}function dn(){function e(e,t){let n=cn.getInstance();return e.once(`closed`,()=>{e.isDestroyed()||K.getInstance().track(`window_closed`,{url:e.webContents.getURL(),in_game:t})}),e.on(`unresponsive`,()=>{e.isDestroyed()||K.getInstance().track(`window_unresponsive`,{url:e.webContents.getURL(),in_game:t})}),e.webContents.on(`console-message`,(t,r,i,a,o)=>{let s=e.isDestroyed()?`destroyed`:e.webContents.getURL();n[r===3?`error`:r===2?`warn`:`log`](`[${s}] [${o}:${a}] ${i}`)}),K.getInstance().track(`window_created`,{url:e.webContents.getURL(),in_game:t}),e}return{getProductionSiteUrl:()=>{let e=global.OVERLAYED_META.application.siteUrl;return URL.canParse(e)?new URL(e):new URL(`https://default.overlayedapps.com`)},createWindow:t=>e(new(un())(t),!1),createInGameWindow:t=>{let n=un();return e(X().instance.newWindowInternal(n,t),!0)},on:(e,t)=>X().instance.on(e,t),off:(e,t)=>X().instance.off(e,t),once:(e,t)=>X().instance.once(e,t),addListener:(e,t)=>X().instance.addListener(e,t),removeListener:(e,t)=>X().instance.removeListener(e,t),removeAllListeners:()=>X().instance.removeAllListeners(),prependListener:(e,t)=>X().instance.prependListener(e,t),prependOnceListener:(e,t)=>X().instance.prependOnceListener(e,t),getActiveGameInfo:()=>{let e=X(),t=Re.getInstance();return{resolution:e.resolution,isConnected:t.hasConnection}}}}const fn=O(class extends Xe{renderInterface;globalCursorOverrideCount=new Set;globalMouseBlockCount=new Set;globalKeyboardBlockCount=new Set;keyInputBlocks={};constructor(e){super(`OverridesManager`),this.renderInterface=Ht.getInstance().getInterface(e)}scope(e){return{setGlobalCursorOverride:t=>this.setGlobalCursorOverride(e,t),setGlobalMouseBlock:t=>this.setGlobalMouseBlock(e,t),setGlobalKeyboardBlock:t=>this.setGlobalKeyboardBlock(e,t),setKeyInputBlock:(t,n)=>this.setKeyInputBlock(e,t,n)}}setGlobalCursorOverride(e,t){t?this.globalCursorOverrideCount.add(e):this.globalCursorOverrideCount.delete(e),t&&this.globalCursorOverrideCount.size===1?this.renderInterface.instance.setGlobalCursorOverride(!0):!t&&this.globalCursorOverrideCount.size===0&&this.renderInterface.instance.setGlobalCursorOverride(!1)}setGlobalMouseBlock(e,t){t?this.globalMouseBlockCount.add(e):this.globalMouseBlockCount.delete(e),t&&this.globalMouseBlockCount.size===1?this.renderInterface.instance.setGlobalMouseBlock(!0):!t&&this.globalMouseBlockCount.size===0&&this.renderInterface.instance.setGlobalMouseBlock(!1)}setGlobalKeyboardBlock(e,t){t?this.globalKeyboardBlockCount.add(e):this.globalKeyboardBlockCount.delete(e),t&&this.globalKeyboardBlockCount.size===1?this.renderInterface.instance.setGlobalKeyboardBlock(!0):!t&&this.globalKeyboardBlockCount.size===0&&this.renderInterface.instance.setGlobalKeyboardBlock(!1)}setKeyInputBlock(e,t,n){this.keyInputBlocks[t]||(this.keyInputBlocks[t]=new Set),n?this.keyInputBlocks[t].add(e):this.keyInputBlocks[t].delete(e),n&&this.keyInputBlocks[t].size===1?this.renderInterface.instance.setKeyInputBlock(t,!0):!n&&this.keyInputBlocks[t].size===0&&this.renderInterface.instance.setKeyInputBlock(t,!1)}},`OGG_SIEGE`);function pn(){return{scope:e=>fn.getInstance().scope(e),raw:{setGlobalMouseBlock:e=>X().instance.setGlobalMouseBlock(e),setGlobalKeyboardBlock:e=>X().instance.setGlobalKeyboardBlock(e),setGlobalCursorOverride:e=>X().instance.setGlobalCursorOverride(e),setKeyInputBlock:(e,t)=>X().instance.setKeyInputBlock(e,t),getGlobalMouseBlock:()=>X().instance.getGlobalMouseBlock(),getGlobalKeyboardBlock:()=>X().instance.getGlobalKeyboardBlock(),getGlobalCursorOverride:()=>X().instance.getGlobalCursorOverride(),getKeyInputBlock:e=>X().instance.getKeyInputBlock(e)}}}function mn(){return{track:(e,t)=>{K.getInstance().track(`custom__${String(e)}`,t)}}}var hn=fe(((e,t)=>{var n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),r=n((e,t)=>{var n=new Set([`mouseDown`,`mouseUp`,`pointerDown`,`pointerUp`]),r=new WeakSet;function i(e,t,{allowHosts:i}={}){let{shell:a}=t;if(r.has(e))return;r.add(e);let o=e.webContents;function s(e){return!!(!c(e)||i?.includes(e.host))}function c(e){return new URL(o.getURL()).origin!==e.origin}let l=0;function u(){l=Date.now()}function d(){let e=Date.now()-l,t=e<150;return t||console.warn(`was not recently active`,e),t}if(process.platform===`win32`)for(let t of Object.values({KEYDOWN:256,LBUTTONUP:514,MBUTTONUP:520,RBUTTONUP:517,XBUTTONUP:524,TOUCH:576}))e.hookWindowMessage(t,u);o.on(`input-event`,(e,t)=>{n.has(t.type)&&u()}),o.on(`will-navigate`,(e,t)=>{let n=e.url||t;if(console.log(`will-navigate`,n),!n)return;let r=new URL(n);if(!s(r)){if(!d()){console.log(`blocked navigation`,n),e.preventDefault();return}c(r)&&(console.log(`external navigation`,n),e.preventDefault(),a.openExternal(n))}}),o.session.on(`will-download`,(e,t)=>{let n=t.getURL();/^blob:/.test(n)||e.preventDefault()}),o.setWindowOpenHandler(e=>{console.log(`window-open`,e.url);let{url:t}=e,n=new URL(t);if(!s(n))return d()?(c(n)&&a.openExternal(e.url),{action:`deny`}):(console.log(`blocked navigation`,t),{action:`deny`})})}t.exports=i}),i=n((e,t)=>{var n=new Set([`Mozilla`,`AppleWebKit`,`Chrome`,`Safari`,`Gecko`,`Firefox`,`OPR`,`Edg`,`Version`,`Mobile`,`curl`,`PostmanRuntime`]);async function r(e,t,r){let{webContents:i}=e,a=await i.executeJavaScript(`navigator.userAgent`);a=a.match(/[^\/]+\/[^\s]+( \([^\)]+\))?/g).map(e=>e.trim()).filter(e=>{let[t]=e.split(`/`,1);return n.has(t)}).join(` `),i.setUserAgent(a),t.app.userAgentFallback=a}t.exports=r}),a=r(),o=i();function s(e,t,n={}){a(e,t,n.linkHandler),o(e,t,n.userAgent)}t.exports={setupRevUtils:s,setupLinkHandler:a,setUserAgent:o}}))();function gn(){return{registerWindow:e=>{(0,hn.setupRevUtils)(e,global.OVERLAYED.electron)}}}const _n=/(\d{4})-(\d{2})-(\d{2})\.log$/;function vn(e){let t=e.match(_n);if(!t)return!1;let[,n,r,i]=t,a=Number(n),o=Number(r),s=Number(i);if(o<1||o>12||s<1||s>31)return!1;let c=new Date(a,o-1,s);if(isNaN(c.getTime())||c.getFullYear()!==a||c.getMonth()!==o-1||c.getDate()!==s)return!1;let l=new Date;return l.setDate(l.getDate()-7),l.setHours(0,0,0,0),c>=l}function yn(e){let{silent:t=!1,additionalFiles:n}=e??{},r=Te(global.OVERLAYED.APPLICATION_ID),i=Oe(r,{recursive:!0}),a=Ce(),o=Oe(a,{recursive:!0});t||(N.getInstance().info(`Logs path: `,r),N.getInstance().info(`Overlayed logs path: `,a));let s=new se;return i.forEach(([e,n])=>{t||N.getInstance().info(`Zipping: `,n);let r=ee(n);s.file(_(n),r,{compression:`DEFLATE`})}),o.forEach(([e,n])=>{if(!vn(_(n))){t||N.getInstance().info(`Skipping old/unrecognized log: `,n);return}t||N.getInstance().info(`Zipping: `,n);let r=ee(n);s.file(_(n),r,{compression:`DEFLATE`})}),n&&Object.entries(n).forEach(([e,n])=>{t||N.getInstance().info(`Zipping extra file: `,e),s.file(e,n,{compression:`DEFLATE`})}),s}async function bn(e,t,n){let r=global.OVERLAYED_META.release.id?V(global.OVERLAYED_META.release.id):void 0,i=W();return lt(global.OVERLAYED.APPLICATION_ID,{file:Buffer.from(n,`base64`),data:{release_id:r,type:e,cortex_user_id:i,...t}}).then(e=>(N.getInstance().info(`Feedback submitted`,e),e.data.id)).catch(e=>{console.error(JSON.stringify(e,null,2)),N.getInstance().error(`Failed to submit feedback`,e)})}function xn(e){let t=new M(`app.log`);return t.init(global.OVERLAYED.APPLICATION_ID,e.debug),{scope:e=>t.scope(e),info:e=>t.info(e),warn:e=>t.warn(e),error:e=>t.error(e),debug:e=>t.debug(e),submitFeedback:async(e,t,n)=>{let r=global.OVERLAYED_META.release.id?V(global.OVERLAYED_META.release.id):void 0;return r&&le.isPackaged&&K.getInstance().track(e===`bug_report`?`bug_report_submitted`:`suggestion_submitted`,{release_id:r}),await bn(e,t,await yn(n).generateAsync({type:`base64`}))},getLogsZip:e=>yn(e)}}const Sn=1e3;function Cn(e,t,n,i,a){let o=Re.getInstance(),s=N.getInstance().scope(`SetupPipeServer`);s.log(`Initializing`);function c(e,t){let r=n.get(t);if(!r)n.set(t,[e]);else{if(r.length>=Sn){k.getInstance().warn(`Event buffer full, removing oldest event`,`EVENT_BUFFER_FULL`,{summary:`Event buffer overflow for module ${t}. Buffer size: ${r.length}, max: ${Sn}`});return}r.push(e)}}function l(n){s.info(n);let i=H(n);if(i instanceof r.errors){K.getInstance().track(`invalid_game_event`,{}),k.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:i.summary});return}let o=Je.includes(i.type),l=e.modules.find(e=>e.key===`universal`),u=o?l:e.modules.find(e=>e.key===i.game);if(!u){s.warn(`Invalid module`,{module:o?`universal`:i.game});return}let d=u.events.event,f=d(n);if(f instanceof r.errors){if(`type`in f.byPath)return;s.warn(`Invalid event`,{summary:f.summary}),K.getInstance().track(`invalid_game_event`,{game:i.game,type:i.type,summary:f.summary}),k.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:f.summary});return}if(!a[u.key]){c(f,u.key);return}if(f.type===`unsupported_game_version`){let{content:e}=f;K.getInstance().track(`unsupported_game_version`,{game:f.game,hash:e.process_hash,version:e.game_version})}let p=Xt(u.key,f.type),m=Xt(u.key,`*`),h=t.get(p),g=t.get(m),_=[...Array.from(h??[]),...Array.from(g??[])];if(_.length===0){s.info(`No handlers found for event`,{event:f});return}_.forEach(e=>{e(f)})}return i.on(`flushEvents`,e=>{if(a[e])return;a[e]=!0;let t=n.get(e);t&&(N.getInstance().info(`Flushing ${t.length} events for module ${e}`),t.forEach(e=>l(e)),n.delete(e))}),o.on(`data`,e=>e.forEach(l)),o.on(`error`,e=>{s.error(`Pipe server error`,e),k.getInstance().error(`Pipe server error`,`PIPE_SERVER_ERROR`,{error:e})}),o.on(`connected`,()=>{s.log(`Pipe server connected`)}),o.on(`disconnected`,()=>{s.log(`Pipe server disconnected`)}),o}const wn=O(class extends L{FETCH_INTERVAL=1e3*60*10;_fetchInterval=null;_flags=new Map;_overrides=new Map;_defaults=new Map;_boundOnGameReady=this.onGameEvent.bind(this);_boundOnGameClose=this.onGameEvent.bind(this);_readyResolve;ready;constructor(){super(`FeatureFlagManager`),this.ready=new Promise(e=>{this._readyResolve=e}),this.fetchFlags(),this.setupInterval(),J.getInstance().on(`gameReady`,this._boundOnGameReady),J.getInstance().on(`gameClose`,this._boundOnGameClose)}destroy(){this._fetchInterval&&=(clearInterval(this._fetchInterval),null),J.getInstance().off(`gameReady`,this._boundOnGameReady),J.getInstance().off(`gameClose`,this._boundOnGameClose),super.destroy()}setDefaults(e){this._defaults=new Map(Object.entries(e))}async refresh(){await this.fetchFlags()}override(e,t){let n=this.get(e);this._overrides.set(e,t),n!==t&&(this.emit(e,t),this.emit(`updated`,!0))}clearOverride(e){if(!this._overrides.has(e))return;let t=this.get(e);this._overrides.delete(e);let n=this.get(e);t!==n&&(this.emit(e,n),this.emit(`updated`,!0))}clearOverrides(){if(this._overrides.size===0)return;let e=new Map;for(let t of this._overrides.keys())e.set(t,this.get(t));this._overrides.clear();let t=!1;for(let[n,r]of e){let e=this.get(n);r!==e&&(this.emit(n,e),t=!0)}t&&this.emit(`updated`,!0)}isOverridden(e){return this._overrides.has(e)}getAllOverrides(){return Object.fromEntries(this._overrides)}inspect(e){let t=this._overrides.get(e),n=this._flags.get(e),r=this._defaults.get(e);return{effective:t??n??r??!1,override:t,actual:n,default:r}}get(e){let t=this._overrides.get(e),n=this._flags.get(e),r=this._defaults.get(e);return t??n??r??!1}getAll(){let e=Object.fromEntries(this._defaults);for(let[t,n]of this._flags)e[t]=n;for(let[t,n]of this._overrides)e[t]=n;return e}onGameEvent(){this.fetchFlags()}setupInterval(){this._fetchInterval=setInterval(()=>{this.fetchFlags()},this.FETCH_INTERVAL)}async fetchFlags(){try{let e=J.getInstance().getActiveGames(),{data:t}=await ut(global.OVERLAYED.APPLICATION_ID,{cortex_user_id:global.OVERLAYED_RUNTIME.userId,release_id:global.OVERLAYED_META.release.id??void 0,channel_id:global.OVERLAYED_META.release.channelId??void 0,active_games:e.map(e=>e.toString())??void 0}),n=new Map;for(let e of t)n.set(e.name,e.enabled);for(let[e,t]of n){if(this._overrides.has(e))continue;let n=this._flags.get(e);n!==void 0&&n!==t&&this.emit(e,t)}for(let[e]of this._flags)this._overrides.has(e)||n.has(e)||this.emit(e,this._defaults.get(e)??!1);this._flags=n;for(let e of this._defaults.keys())this._flags.has(e)||this.logger.warn(`Registered feature flag "${e}" was not found in the API response`);this.emit(`updated`,!0)}catch(e){this.logger.error(`Failed to fetch feature flags`,e)}finally{this._readyResolve()}}});function Tn(e){let t=wn.getInstance();return e&&t.setDefaults(e),{on:(e,n)=>t.on(e,n),off:(e,n)=>t.off(e,n),ready:t.ready,get:e=>t.get(e),getAll:()=>t.getAll(),refresh:()=>t.refresh(),override:(e,n)=>t.override(e,n),clearOverride:e=>t.clearOverride(e),clearOverrides:()=>t.clearOverrides(),isOverridden:e=>t.isOverridden(e),getAllOverrides:()=>t.getAllOverrides(),inspect:e=>t.inspect(e)}}function En(){let e=sn.getInstance();return{on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},allowSiteUpdateOnNextLoad:()=>{e.allowSiteUpdateOnNextLoad()}}}const Dn=r({dismissedNotices:pe(r.string).array()}),On=O(class extends L{NOTICE_FETCH_INTERVAL=1e3*60*10;MAX_DISMISSED_NOTICES=100;_noticeFetchInterval=null;_notices=[];_noticesFile;_boundOnGameReady=this.onGameReady.bind(this);get notices(){let e=this._noticesFile.get().dismissedNotices;return this._notices.filter(t=>!e.includes(t.id))}constructor(){super(`NoticeManager`),this._noticesFile=this.getNoticesFile(),this._noticesFile.load(),this.fetchNotices(),this.setupNoticeInterval(),J.getInstance().on(`gameReady`,this._boundOnGameReady)}destroy(){this._noticeFetchInterval&&=(clearInterval(this._noticeFetchInterval),null),J.getInstance().off(`gameReady`,this._boundOnGameReady),super.destroy()}dismissNotice(e){let t=this._notices.find(t=>t.id===e);if(!t||!t.dismissible)return;let n=this._noticesFile.get().dismissedNotices;n.unshift(e),this._noticesFile.set({dismissedNotices:n.slice(0,this.MAX_DISMISSED_NOTICES)}),this.emitNoticesUpdated()}onGameReady(){this.fetchNotices()}setupNoticeInterval(){this._noticeFetchInterval=setInterval(()=>{this.fetchNotices()},this.NOTICE_FETCH_INTERVAL)}getNoticesFile(){return new A({path:Mt([`notices.json`]),schema:Dn,default:{dismissedNotices:[]}})}async fetchNotices(){let e=J.getInstance().getActiveGames();try{let{data:t}=await dt(global.OVERLAYED.APPLICATION_ID,{release_id:global.OVERLAYED_META.release.id?V(global.OVERLAYED_META.release.id):void 0,channel:global.OVERLAYED_META.release.channel,version:global.OVERLAYED_META.release.version,games:e});this._notices=t,this.emitNoticesUpdated()}catch(e){this.logger.error(`Failed to fetch notices`,e)}}emitNoticesUpdated(){this.emit(`noticesUpdated`,{notices:this.notices})}});function kn(){let e=On.getInstance();return{on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},dismissNotice:t=>{e.dismissNotice(t)},getNotices:()=>e.notices}}const{Provider:An}=de;var jn=class extends An{logger=N.getInstance().scope(`OverlayedProvider`);constructor(e,t,n){super(n),this.options=e,this.updater=t}async getLatestVersion(){try{let e=await st(this.options.application_id,{release_id:this.options.release_id,cortex_user_id:this.options.cortex_user_id,access_token:this.options.access_token,requested_channel:this.options.requested_channel});return this.logger.log(`checkApplicationRelease response`,e.data),K.getInstance().track(`update_release_check_success`,{version:e.data.release.version,channel:e.data.release.channel,fallback:!!e.data.fallback}),e.data.fallback&&this.logger.warn(`Update fallback detected, switching to default channel`),{path:``,sha512:e.data.download_hash??``,version:`${e.data.release.version}-${e.data.release.channel}`,releaseName:e.data.release.id,releaseDate:e.data.release.created_at,files:[{url:e.data.download_url,sha512:e.data.download_hash??``}]}}catch(e){let t=e instanceof Error?e.stack||e.message:String(e);throw K.getInstance().track(`update_release_check_error`,{message:t}),Error(`Unable to find the latest version (${this.options.release_id}), please ensure release exists. ${t}`)}}resolveFiles(e){return[{info:e.files[0],url:new URL(e.files[0].url)}]}};function Mn(e){return{provider:`custom`,updateProvider:jn,...e}}function Z(){return de.autoUpdater}const Nn=O(class extends L{DEFAULT_CHANNEL=`public`;TOKEN_REFRESH_INTERVAL=1e3*60*15;accessTokenFetcher=void 0;_tokenRefreshInterval=null;_downloadStarted=!1;constructor(){super(`UpdateManager`)}init(){super.init(),this.registerListenerForwarders(),this.setupTokenRefreshInterval(),Z().disableDifferentialDownload=!0}destroy(){Z().removeAllListeners(),this._tokenRefreshInterval&&=(clearInterval(this._tokenRefreshInterval),null),super.destroy()}setupTokenRefreshInterval(){this._tokenRefreshInterval=setInterval(()=>{this.checkAndRefreshToken()},this.TOKEN_REFRESH_INTERVAL)}async checkAndRefreshToken(){let e=global.OVERLAYED_META.release.channel;e!==this.DEFAULT_CHANNEL&&(this.logger.log(`Refreshing access token for channel`,e),await this.setAndGetLatestAccessToken(e))}async checkForUpdates(e){this.logger.log(`Starting checkForUpdates`);let t=e??global.OVERLAYED_META.release.channel;return K.getInstance().track(`check_for_update`,{channel:t}),this._downloadStarted=!1,await this.setAndGetLatestAccessToken(t),e?(Z().allowDowngrade=!0,Z().channel=e,this.setFeedUrl({requestedChannel:e})):(Z().allowDowngrade=!1,Z().channel=global.OVERLAYED_META.release.channel,this.setFeedUrl({})),this.logger.log(`Checking for updates`),Z().checkForUpdates()}async switchChannel(e){return this.logger.log(`Switching channel`,e),K.getInstance().track(`update_channel_switch`,{from_channel:global.OVERLAYED_META.release.channel,to_channel:e}),this._downloadStarted=!1,await this.setAndGetLatestAccessToken(e),Z().allowDowngrade=!0,Z().channel=e,this.setFeedUrl({requestedChannel:e}),Z().checkForUpdates()}quitAndInstall(e,t){this.logger.log(`quitAndInstall`,{isSilent:e,isForceRunAfter:t});let[n,r]=this.canUpdate();if(!n)throw this.logger.warn(`Cannot update`,{denialReason:r}),K.getInstance().track(`update_install_blocked`,{reason:r}),Error(r);return this.logger.log(`Quitting and installing`),K.getInstance().track(`update_install`,{}),Z().quitAndInstall(e,t)}canUpdate(){return J.getInstance().isInGame?[!1,`User is in game`]:[!0,null]}downloadUpdate(e){return Z().downloadUpdate(e)}setAccessTokenFetcher(e){this.accessTokenFetcher=e}async setAndGetLatestAccessToken(e){if(this.logger.log(`Fetching new token`),!this.accessTokenFetcher)return this.logger.warn(`accessTokenFetcher is not set, private channels will not work.`),Lt(null),null;if(this.logger.log(`Setting and getting latest access token for channel`,e),e===this.DEFAULT_CHANNEL)return this.logger.log(`Default channel, skipping`),Lt(null),null;if(e!==global.OVERLAYED_META.release.channel)return this.forceFetchNewAccessToken(e);this.logger.log(`Access token exists, checking expiration`);let t=It();if(t){let e=this.getAccessTokenExpirationDate(t);if(!e)this.logger.log(`Invalid token, setting to null`),Lt(null);else if(e.getTime()>=Date.now()+300*1e3)return this.logger.log(`Token is not expired, using it.`),t}return this.forceFetchNewAccessToken(e)}async forceFetchNewAccessToken(e){this.accessTokenFetcher||this.logger.warn(`accessTokenFetcher is not set [2], private channels will not work.`);try{let t=await this.accessTokenFetcher?.(e)??null;this.logger.log(`New token fetched`,t?.slice(0,5)+`...`);let n=It();if(t==null||n===t){K.getInstance().track(`update_token_invalid`,{channel:e}),this.emit(`authTokenInvalid`,{}),Lt(null);return}return Lt(t),t}catch(e){let t=e instanceof Error?e.message:String(e);return K.getInstance().track(`update_token_fetch_error`,{message:t}),this.logger.error(`Error fetching new token`,{error:e,message:t}),Lt(null),null}}setFeedUrl(e){if(!global.OVERLAYED_META.release.id){this.logger.warn(`Tried to set feed URL in development mode`);return}Z().setFeedURL(Mn({application_id:global.OVERLAYED.APPLICATION_ID,release_id:global.OVERLAYED_META.release.id,cortex_user_id:global.OVERLAYED_RUNTIME.userId,access_token:It(),requested_channel:e.requestedChannel}))}registerListenerForwarders(){Z().on(`checking-for-update`,()=>{this.logger.info(`Checking for updates`),this.emit(`checkingForUpdates`,{})}),Z().on(`download-progress`,e=>{this._downloadStarted||(this._downloadStarted=!0,K.getInstance().track(`update_download_started`,{version:Z().currentVersion?.version??``})),this.emit(`downloadProgress`,{info:e});let t=`Download speed: ${e.bytesPerSecond} - Downloaded ${e.percent}%`;t+=` (${e.transferred}/${e.total})`,this.logger.log(t)}),Z().on(`error`,(e,t)=>{this.logger.error(`Error`,e,t),K.getInstance().track(`update_download_error`,{message:t??e.message}),this.emit(`error`,{error:e,message:t})}),Z().on(`update-not-available`,e=>{this.logger.info(`Update not available`,e),K.getInstance().track(`update_not_available`,{version:e.version}),this.emit(`updateNotAvailable`,{info:e})}),Z().on(`update-available`,e=>{this.logger.info(`Update available`,e),K.getInstance().track(`update_available`,{version:e.version,channel:Z().channel??``}),this.emit(`updateAvailable`,{info:e})}),Z().on(`update-downloaded`,e=>{this.logger.info(`Update downloaded`,e),K.getInstance().track(`update_download_complete`,{version:e.version}),this.emit(`updateDownloaded`,{event:e})}),Z().on(`update-cancelled`,e=>{this.logger.info(`Update cancelled`,e),K.getInstance().track(`update_cancelled`,{version:e.version}),this.emit(`updateCancelled`,{info:e})})}getAccessTokenExpirationDate(e){try{let t=e.split(`.`)[1];if(!t)return null;let n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),r=JSON.parse(n);return r.exp?new Date(r.exp*1e3):null}catch{return null}}});function Pn(){let e=Nn.getInstance();return{site:En(),on:(t,n)=>{e.on(t,n)},off:(t,n)=>{e.off(t,n)},setAccessTokenFetcher:t=>e.setAccessTokenFetcher(t),checkForUpdates:()=>e.checkForUpdates(),switchChannel:t=>e.checkForUpdates(t),quitAndInstall:(t,n)=>e.quitAndInstall(t,n),canUpdate:()=>e.canUpdate(),downloadUpdate:t=>e.downloadUpdate(t)}}function Fn(){return{getChannel:()=>global.OVERLAYED_META.release.channel,getVersion:()=>global.OVERLAYED_META.release.version,getReleaseId:()=>global.OVERLAYED_META.release.id}}const In=O(class extends L{_knownModificationTimes=new Map;_confirmedDumps=new Set;_pendingReports=new Map;_snapshotTimestamp=0;boundOnGameReady=this.onGameReady.bind(this);boundOnGameClose=this.onGameClose.bind(this);constructor(){super(`CrashDumpManager`)}init(){super.init(),this.logger.debug(`init() registering game event listeners`),J.getInstance().on(`gameReadyInternal`,this.boundOnGameReady),J.getInstance().on(`gameCloseInternal`,this.boundOnGameClose),this.logger.debug(`init() complete`)}destroy(){this.logger.debug(`destroy() called`,{pendingReports:this._pendingReports.size,confirmedDumps:this._confirmedDumps.size,knownModificationTimes:this._knownModificationTimes.size}),J.getInstance().off(`gameReadyInternal`,this.boundOnGameReady),J.getInstance().off(`gameCloseInternal`,this.boundOnGameClose),this._knownModificationTimes.clear(),this._confirmedDumps.clear(),this._pendingReports.clear(),this._snapshotTimestamp=0,this.logger.debug(`destroy() cleanup complete`),super.destroy()}async submit(e){this.logger.debug(`submit() called`,{id:e,pendingCount:this._pendingReports.size});let t=this._pendingReports.get(e);if(!t){this.logger.warn(`submit called with unknown id`,e);return}let{response:n,dumpPath:r}=t;this.logger.debug(`Resolved pending report for submission`,{id:e,dumpPath:r});let i=global.OVERLAYED.APPLICATION_ID,a=W();if(this.logger.debug(`Resolved identifiers for submission`,{applicationId:i,cortexUserId:a}),n.crash_dump_upload_request)try{this.logger.debug(`Reading crash dump file`,{dumpPath:r});let t=await E.readFile(r);this.logger.debug(`Uploading crash dump`,{dumpPath:r,size:t.byteLength}),await ht(n.crash_dump_upload_request,new Uint8Array(t)),this.logger.debug(`Crash dump uploaded, confirming`,{id:e}),await B(i,e,{cortex_user_id:a,file_type:`crash_dump`}),this.logger.debug(`Crash dump confirmed`,{id:e})}catch(e){this.logger.error(`Failed to upload crash dump`,{dumpPath:r,error:e})}else this.logger.warn(`No crash dump upload request in response`,{id:e});this._pendingReports.delete(e),this._confirmedDumps.add(r),this.logger.debug(`Report state updated, attempting dump file cleanup`,{id:e,dumpPath:r});try{await E.unlink(r),this.logger.debug(`Dump file cleaned up successfully`,{dumpPath:r})}catch(e){this.logger.warn(`Failed to clean up dump file after submission`,{dumpPath:r,error:e})}this.logger.log(`Crash report submitted successfully`,r)}async onGameReady({ravenGame:e}){this.logger.debug(`onGameReady() fired`,{game:e.identifier}),await this.snapshotModificationTimes(),this.logger.debug(`onGameReady() snapshot complete`,{game:e.identifier})}async onGameClose({ravenGame:e}){this.logger.debug(`onGameClose() fired`,{game:e.identifier}),await this.scanForNewDumps(vt(e.identifier)),this.logger.debug(`onGameClose() scan complete`,{game:e.identifier})}async snapshotModificationTimes(){let e=De();this._snapshotTimestamp=Date.now(),this.logger.debug(`snapshotModificationTimes() called`,{crashDumpsPath:e,snapshotTimestamp:this._snapshotTimestamp});try{await E.access(e)}catch{this.logger.debug(`Crash dumps directory does not exist, skipping snapshot`,{crashDumpsPath:e});return}let t=await this.findAllDumps(e);this.logger.debug(`Found dumps for snapshot`,{count:t.length});for(let e of t)try{let t=await E.stat(e);if(t.mtimeMs>=this._snapshotTimestamp-3e4){this.logger.debug(`Skipping recent dump from snapshot`,{dumpPath:e,mtimeMs:t.mtimeMs,snapshotTimestamp:this._snapshotTimestamp});continue}this._knownModificationTimes.set(e,t.mtimeMs),this.logger.debug(`Recorded modification time`,{dumpPath:e,mtimeMs:t.mtimeMs})}catch(t){this.logger.warn(`Failed to stat dump file during snapshot`,{dumpPath:e,error:t})}this.logger.debug(`Snapshot complete`,{totalTracked:this._knownModificationTimes.size})}async scanForNewDumps(e){let t=De();this.logger.debug(`scanForNewDumps() called`,{game:e,crashDumpsPath:t});try{await E.access(t)}catch{this.logger.debug(`Crash dumps directory does not exist, skipping scan`,{crashDumpsPath:t});return}let n=new Set([...this._pendingReports.values()].map(e=>e.dumpPath)),r=await this.findAllDumps(t);this.logger.debug(`Scan found dumps`,{total:r.length,pendingCount:n.size,confirmedCount:this._confirmedDumps.size});for(let t of r){if(this._confirmedDumps.has(t)){this.logger.debug(`Skipping already confirmed dump`,{dumpPath:t});continue}if(n.has(t)){this.logger.debug(`Skipping already pending dump`,{dumpPath:t});continue}let r;try{r=await E.stat(t)}catch(e){this.logger.warn(`Failed to stat dump file during scan`,{dumpPath:t,error:e});continue}let i=r.mtimeMs,a=this._knownModificationTimes.get(t);if(this.logger.debug(`Comparing modification times`,{dumpPath:t,modificationTime:i,knownModificationTime:a}),a===void 0||i>a){this.logger.debug(`Dump is new or modified`,{dumpPath:t,isNew:a===void 0});try{let n=r.size,i=h.basename(h.dirname(t)),a=h.basename(t,h.extname(t));this.logger.debug(`Preparing crash report`,{dumpPath:t,crashDumpSize:n,crashSource:i});let o=(await yn().generateAsync({type:`uint8array`})).byteLength,s=global.OVERLAYED.APPLICATION_ID,c=W(),l=global.OVERLAYED_META.release.id;this.logger.debug(`Creating game crash report via API`,{applicationId:s,cortexUserId:c,game:e,crashSource:i,crashDumpSize:n,logsSize:o});let{data:u}=await ct(s,{cortex_user_id:c,game:e,crash_source:i,crash_identifier:a,release_id:l,logs_size:o,crash_dump_size:n});this._pendingReports.set(u.id,{response:u,dumpPath:t}),this.logger.debug(`Crash report created, emitting 'new' event`,{id:u.id,game:e}),this.logger.log(`New crash dump detected`,{dumpPath:t,game:e,id:u.id}),this.emit(`new`,{id:u.id,game:e})}catch(e){this.logger.error(`Failed to create game crash report`,{dumpPath:t,error:e})}}else this.logger.debug(`Dump unchanged, skipping`,{dumpPath:t});this._knownModificationTimes.set(t,i)}this.logger.debug(`scanForNewDumps() complete`,{game:e,pendingReports:this._pendingReports.size})}async findAllDumps(e){this.logger.debug(`findAllDumps() called`,{basePath:e});let t=[],n;try{n=await E.readdir(e,{withFileTypes:!0})}catch(n){return this.logger.warn(`Failed to read crash dumps directory`,{basePath:e,error:n}),t}this.logger.debug(`Top-level entries in crash dumps directory`,{count:n.length,directories:n.filter(e=>e.isDirectory()).map(e=>e.name)});for(let r of n)if(r.isDirectory()){let n=h.join(e,r.name),i;try{i=await E.readdir(n,{withFileTypes:!0})}catch(e){this.logger.warn(`Failed to read crash dump subdirectory`,{subPath:n,error:e});continue}let a=i.filter(e=>e.isFile()&&e.name.endsWith(`.dmp`));this.logger.debug(`Scanned subdirectory`,{subPath:n,totalEntries:i.length,dmpCount:a.length});for(let e of a)t.push(h.join(n,e.name))}return this.logger.debug(`findAllDumps() complete`,{totalFound:t.length}),t}});let Ln=!1,Rn={},zn,Bn=new _e,Vn;function Hn(e){Wn(e);let t=Un(e),{init:n=!0,debug:r=!1,silent:i=!0}=t;if(Gn(e),N.getInstance().init(e.applicationId,r,i),cn.getInstance().init(e.applicationId,r,!0,!0),Jn(at(e.applicationId),!1).catch(()=>{}),Ln)return zn;function a(){if(Ln){N.getInstance().warn(`Overlayed already initialized`);return}an();let e=Yt.get({createIfMissing:!1})?.currentAccount;e&&z(()=>e.apiKey);let n=new Map,r=new Map,i=Pn(),o=Zt(t.modules,n,Bn),s=Qt(),c=rn(t.keybinds),l=dn(),u=pn(),d=gn(),f=mn(),p=xn(t),m=kn(),h=Tn(t.featureFlags),g=Fn();N.getInstance().log(`Overlayed initialized`),Kn(t),Cn(t,n,r,Bn,Rn),Ln=!0,zn={...o,...s,ads:d,keybinds:c,windows:l,input:u,cortex:f,hasAnyActiveProcesses:()=>G.getInstance().hasAnyActiveProcesses,hasAnyActiveGames:()=>J.getInstance().isInGame,init:a,log:p,initialized:Ln,notices:m,featureFlags:h,updater:i,application:g,crashDumps:{on:(e,t)=>In.getInstance().on(e,t),off:(e,t)=>In.getInstance().off(e,t),submit:e=>In.getInstance().submit(e)}},zn.universal.on(`logged_in`,e=>{K.getInstance().track(`account_id`,{account_id:e.content.account_id,game:e.game})})}return n?(a(),zn):new Proxy({init:a},{get:(e,t)=>{if(t!==`init`&&!Ln)throw Error(`overlayed was called before initialized: ${t}`);return t===`init`?e[t]:zn[t]}})}function Un(e){return{...e,modules:[...e.modules,Ye()]}}global.OVERLAYED=new Proxy({},{get:()=>{throw Error(`function overlayed was not called`)}});function Wn(e){if(!he(e.applicationId))throw Error(`Invalid applicationId, must be a valid ULID.`)}function Gn(e){let t=qn(),n=`1.3.5`,r=at(e.applicationId);function i(){return{package_version:n,application_id:r,application_version:t?.release.version??`0.0.0`}}if(N.getInstance().log(`ua object`,i()),et(()=>i()),t===null){Jn(r,!0);return}global.OVERLAYED={APPLICATION_ID:r,APP_BUILD_CHANNEL:t.release.channel,APP_VERSION:t.release.version,PACKAGE_VERSION:n,FRONTEND_VERSION:`0.0.0`,sessionId:Pt(),electron:e.electron},global.OVERLAYED_META=t,global.OVERLAYED_RUNTIME={userId:W()},N.getInstance().log(`meta`,t)}function Kn(e){N.getInstance().warn(`Bootstrapping`);let t=e.universal?[`*`]:e.modules.map(e=>e.key);J.getInstance().setSubscribedGames(t),N.getInstance().warn(`Initializing update manager`),Nn.getInstance().init(),N.getInstance().warn(`Initialized update manager`),sn.getInstance().init({manualUpdates:e.site?.manualUpdates??!1}),qt.getInstance().init(),J.getInstance().init(),In.getInstance().init(),G.getInstance().init(),Bt.getInstance().init(),K.getInstance().track(`start`,{}),Jt.getInstance().check(e.applicationId);try{Vn&&clearInterval(Vn),Vn=setInterval(()=>{try{Ft()}catch{}},3e4),Vn.unref()}catch(e){N.getInstance().log(`failed to start sessionLastUsed interval`,e)}async function n(){let e={};e.os=ie.platform().trim(),e.os_version=process.getSystemVersion().trim(),e.architecture=ie.arch().trim();let t=ie.cpus();t.length>0?(e.cpu=t[0].model.trim(),e.cpu_cores=t.length,e.cpu_speed=t[0].speed):N.getInstance().warn(`Failed to collect CPU info`);let n=await ue.graphics();N.getInstance().info(`GPU info`,n);let r=n.controllers.sort((e,t)=>(t.vram??0)-(e.vram??0))[0];r?(e.gpu=r.model.trim(),e.gpu_memory=r.vram??0):N.getInstance().warn(`Failed to find primary GPU`),e.display_count=n.displays.length;let i=n.displays.find(e=>e.main)??n.displays[0];i?(e.primary_display_resolution_x=i.resolutionX??void 0,e.primary_display_resolution_y=i.resolutionY??void 0,e.primary_display_refresh_rate=i.currentRefreshRate??void 0):N.getInstance().warn(`Failed to find main display`),e.ram=process.getSystemMemoryInfo().total;let a=ie.homedir(),o=await E.statfs(a);return o&&`blocks`in o&&`bsize`in o&&`bavail`in o?(e.disk=o.blocks*o.bsize,e.disk_free=o.bavail*o.bsize):N.getInstance().warn(`Failed to collect disk info`),N.getInstance().log(`Retrieved system information`,e),e}le.on(`ready`,()=>{n().then(e=>{K.getInstance().track(`system_info`,e)}).catch(e=>{N.getInstance().log(`Failed to retrieve system information`,e)})}),le.on(`quit`,()=>{K.getInstance().track(`electron_quit`,{}),Yn()}),process.on(`exit`,()=>{K.getInstance().track(`exit`,{}),Yn()})}function qn(){if(le.isPackaged)try{let e=h.join(process.resourcesPath,`meta.json`);return JSON.parse(x.readFileSync(e,`utf-8`))}catch(e){throw Error(`Failed to read application metadata from resources/meta.json`,{cause:e})}else{let e=h.join(process.cwd(),`.overlayed`,`meta.json`);return x.existsSync(e)?JSON.parse(x.readFileSync(e,`utf-8`)):null}}async function Jn(e,t=!1){if(!le.isPackaged)try{N.getInstance().log(`Fetching application metadata from API...`);let n=Me({...(await ot(e)).data,siteUrl:``});t&&(N.getInstance().log(y.yellowBright(`Uninitialized development environment detected. Created .overlayed folder. In the future, run ${y.bold(`overlayed init`)} to do so. \n\nThe process will now exit to load the cached metadata.\n\n${y.italic(`Note: This will never happen in a packaged application, and will only happen once in local development so long as the .overlayed folder exists.`)}`)),process.exit(0)),global.OVERLAYED_META=n}catch(e){N.getInstance().error(`Failed to fetch application meta`,e),t&&(console.error(`
|
|
2
10
|
Failed to fetch application metadata. Please ensure you're authenticated with 'overlayed login'.
|
|
3
|
-
`),process.exit(1))}}async function
|
|
11
|
+
`),process.exit(1))}}async function Yn(){try{Ft()}catch{}try{Vn&&clearInterval(Vn),Vn=void 0}catch{}await K.getInstance().flush(),Bt.getInstance().destroy(),In.getInstance().destroy(),J.getInstance().destroy(),qt.getInstance().destroy(),G.getInstance().destroy(),Ht.getInstance().getInterface(`OGG_SIEGE`).destroy(),Re.getInstance().destroy(),k.getInstance().destroy(),Nn.getInstance().destroy(),sn.getInstance().destroy(),wn.getInstance().destroy()}export{ze as RenderInterface,Ve as VirtualKey,Ae as defineConfig,Hn as overlayed};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overlayed/app",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Overlayed app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"electron-updater": "^6.7.3",
|
|
63
63
|
"fs-extra": "^11.3.2",
|
|
64
64
|
"glob": "^11.1.0",
|
|
65
|
-
"jiti": "^2.6.1",
|
|
66
65
|
"jszip": "^3.10.1",
|
|
67
66
|
"mitt": "^3.0.1",
|
|
68
67
|
"picocolors": "^1.1.1",
|
|
@@ -80,14 +79,14 @@
|
|
|
80
79
|
"vite": "^7.3.0",
|
|
81
80
|
"vitest": "^3.2.4",
|
|
82
81
|
"@overlayed/api": "0.0.6",
|
|
83
|
-
"@overlayed/cortex-client": "0.0.6",
|
|
84
82
|
"@overlayed/events": "0.0.4",
|
|
83
|
+
"@overlayed/cortex-client": "0.0.6",
|
|
85
84
|
"@overlayed/native-managers": "0.0.4",
|
|
86
85
|
"@overlayed/shared-node": "0.0.4",
|
|
87
86
|
"@overlayed/siege": "0.0.5",
|
|
88
87
|
"@overlayed/universal": "0.0.0",
|
|
89
|
-
"@overlayed/utils
|
|
90
|
-
"@overlayed/utils": "0.0.4"
|
|
88
|
+
"@overlayed/utils": "0.0.4",
|
|
89
|
+
"@overlayed/utils-node": "0.0.4"
|
|
91
90
|
},
|
|
92
91
|
"peerDependencies": {
|
|
93
92
|
"electron": "33.3.0"
|