@overlayed/app 0.14.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Module, Type } from "arktype";
3
3
  import EventEmitter$1 from "events";
4
4
  import "xior";
5
5
  import * as electron0 from "electron";
6
- import { BrowserWindow } from "electron";
6
+ import { BrowserWindow, BrowserWindowConstructorOptions } from "electron";
7
7
  import * as arktype_internal_methods_object_ts0 from "arktype/internal/methods/object.ts";
8
8
  import { Process } from "@overlayed-gg/native-interface";
9
9
  import { AccessLevel, KeyboardKeyEvent, MouseButtonEvent, RenderInterface, RenderInterface as RenderInterface$1, RenderWindow, RenderWindow as RenderWindow$1, RenderWindowConstructorOptions, RenderWindowConstructorOptions as RenderWindowConstructorOptions$1, VirtualKey, WindowEvent } from "@overlayed-gg/render-interface";
@@ -359,7 +359,8 @@ type OverlayedAppKeybindModule<TKeybind extends string> = Record<TKeybind, {
359
359
  updateKeybinds: (keybinds: Partial<OverlayedAppKeybindsConfig<TKeybind>>) => void;
360
360
  };
361
361
  interface OverlayedAppWindowsModule extends Pick<RenderInterface$1, "on" | "off" | "once" | "addListener" | "prependListener" | "prependOnceListener" | "removeListener" | "removeAllListeners"> {
362
- createWindow(options: RenderWindowConstructorOptions$1): RenderWindow$1;
362
+ createWindow(options: BrowserWindowConstructorOptions): BrowserWindow;
363
+ createInGameWindow(options: RenderWindowConstructorOptions$1): RenderWindow$1;
363
364
  getActiveGameInfo: () => ActiveGameInfo;
364
365
  }
365
366
  type OverlayedAppInputModuleRaw = {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{createRequire as e}from"node:module";import t from"mitt";import{Type as n,type as r}from"arktype";import i,{createWriteStream as a,existsSync as o,mkdirSync as s,readdirSync as c,unlinkSync as l,writeFileSync as u}from"fs";import{ensureFileSync as d}from"fs-extra";import{join as f}from"path";import p,{resolve as ee}from"node:path";import te from"events";import{copyFileSync as ne,createReadStream as re,existsSync as m,mkdirSync as ie,readFileSync as h,readdirSync as ae,writeFileSync as oe}from"node:fs";import"glob";import"jiti";import g from"xior";import _ from"fs/promises";import v from"jszip";import{createHash as se}from"node:crypto";import ce,{app as y}from"electron";var le=Object.create,b=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyNames,fe=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty,me=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),he=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=de(t),a=0,o=i.length,s;a<o;a++)s=i[a],!pe.call(e,s)&&s!==n&&b(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ue(t,s))||r.enumerable});return e},ge=(e,t,n)=>(n=e==null?{}:le(fe(e)),he(t||!e||!e.__esModule?b(n,`default`,{value:e,enumerable:!0}):n,e)),_e=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)}}},x=class{emitter;constructor(){this.emitter=t()}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}emit(e,t){this.emitter.emit(e,t)}removeAllListeners(){this.emitter.all.clear()}},ve=class{listeners;constructor(){this.listeners=new Map}on(e,t){let n=this.listeners.get(e)||new Set;n.add(t),this.listeners.set(e,n)}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}async emit(e,...t){let n=this.listeners.get(e)||new Set,r=this.listeners.get(`*`)||new Set,i=[...Array.from(n),...Array.from(r)];if(i.length===0)return[];let a=await Promise.all(i.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}}));return a}removeAllListeners(){this.listeners.clear()}};function S(e,...t){let n=class extends e{static _instance;static getInstance(){return this._instance||(this._instance=new e(...t)),this._instance}static clearInstance(){this._instance=void 0}};return n}var ye=class extends x{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()})}};const C=S(ye);var be=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(){return this.data?this.data:this.load()}getKey(e){let t=this.get();return t[e]}save(e){let t=this.onBeforeSave(e);try{d(this.getFilePath()),i.writeFileSync(this.getFilePath(),JSON.stringify(t,void 0,2))}catch{return}return this.data=t}load(){if(!this.fileExists(this.getFilePath())||!this.canReadWriteFile(this.getFilePath())){this.save(this._defaultValue);let e=this.onAfterLoad(this._defaultValue);return this.data=e,e}try{let e=i.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`),n=t(e);if(n instanceof r.errors)return this._defaultValue;let i=this._schema[`~standard`].validate(n);if(i instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);return i.issues?this.migrate(n,this._defaultValue):this.migrate(i.value,this._defaultValue)}catch{return this._defaultValue}}canReadWriteFile(e){try{return i.accessSync(e,i.constants.R_OK|i.constants.W_OK),!0}catch{return!1}}fileExists(e){try{return i.accessSync(e,i.constants.F_OK),!0}catch{return!1}}migrate(e,t){let n={...e};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;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){C.getInstance().error(`Invalid config file`,`INVALID_CONFIG_FILE`,{issues:e.map(e=>e.message),filePath:this._path,data:this.data})}},xe=class e extends x{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(`log`,...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)}getFileName(e){return`${this.baseFileName}-${e}.log`}ensureLogDirectory(){try{s(this.logPath,{recursive:!0})}catch(e){throw console.error(`Failed to create log directory ${this.logPath}:`,e),e}}ensureLogFile(){let e=f(this.logPath,this.getFileName(this.currentDate));if(!o(e))try{u(e,``,`utf8`)}catch(t){throw console.error(`Failed to create log file ${e}:`,t),t}}getDateString(e){return e.toISOString().split(`T`)[0]}createStream(){let e=f(this.logPath,this.getFileName(this.currentDate));return a(e,{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=c(this.logPath),t=new Date;t.setDate(t.getDate()-3),e.filter(e=>e.startsWith(this.baseFileName)&&e.endsWith(`.log`)).filter(e=>{let n=e.replace(`${this.baseFileName}-`,``).replace(`.log`,``),r=new Date(n);return r<t}).forEach(e=>{try{l(f(this.logPath,e))}catch(t){console.error(`Failed to delete old log file ${e}:`,t)}})}write(e,...t){let n=new Date,r=n.toISOString().replace(`T`,` `).replace(/\.\d+Z$/,``)+`.${n.getMilliseconds().toString().padStart(3,`0`)}`,i=t.map(e=>typeof e==`object`?JSON.stringify(e,void 0,2):String(e)).join(` `),a=`[${r}] [${e}] ${i}\n`;this.stream.write(a,e=>{e?this.emit(`error`,e):this.emit(`write`,a)})}};const w=()=>p.join(process.env.APPDATA??``,`overlayed`),Se=()=>p.join(w(),`logs`),T=e=>p.join(w(),`apps`,e),E=e=>p.join(T(e),`logs`);var D=class{fileLogger;path;appId;messageQueue=new _e;fileName;constructor(e){this.fileName=e}init(e){this.appId=e,this.path=E(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=`[${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)}}error(...e){this.handle(`error`,...e)}warn(...e){this.handle(`warn`,...e)}info(...e){this.handle(`log`,...e)}debug(...e){this.handle(`debug`,...e)}log(...e){this.handle(`log`,...e)}handle(e,...t){console[e](...t),this.fileLogger?this.fileLogger[e](...t):this.messageQueue.add({type:e,args:t})}};const O=S(D,`main.log`);var Ce=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=5,i=new Map,a=new Set,o=new Set,s=[];for(let e=0;e<n;e++)s.push(e);let c=async n=>{let c=n*t,l=Math.min(c+t,this.blob.size),u=this.blob.slice(c,l);try{await e(u,n),o.add(n),this.emit(`chunkComplete`,n),a.delete(n)}catch(e){let t=i.get(n)||0;t<r?(i.set(n,t+1),await new Promise(e=>setTimeout(e,(t+1)*1e3)),s.push(n)):(o.add(n),this.emit(`error`,e),this.shouldStop=!0,a.delete(n))}},l=[],u=async()=>{for(;(s.length>0||a.size>0)&&!this.shouldStop;){if(s.length===0){await new Promise(e=>setTimeout(e,10));continue}let e=s.shift();o.has(e)||a.has(e)||(a.add(e),await c(e))}};for(let e=0;e<this.maxConcurrent;e++)l.push(u());await Promise.all(l)}};function k(e){return m(e)?ae(e).map(t=>[e,t]):[]}function we(e){return e}const Te=e(import.meta.url),{PipeEventServer:Ee,PipeEventClient:De,PipeEventBase:Oe,ProcessMonitor:ke,Process:Ae,InjectionMethod:je,AccessLevel:Me,HardwareInterface:Ne}=Te(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`);var Pe=class extends x{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(),this.server=null)}init(){this.server=new Ee(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.server.on(`disconnected`,()=>{this._hasConnection=!1})}};const A=S(Pe,`stats-cc`);var j=class{logger;initialized=!1;constructor(e){this.logger=O.getInstance().scope(e)}init(){this.logger.log(`Initializing`),this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1}},M=class extends x{logger;initialized=!1;constructor(e){super(),this.logger=O.getInstance().scope(e)}init(){this.logger.log(`Initializing`),this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}},Fe=class extends ve{logger;initialized=!1;constructor(e){super(),this.logger=O.getInstance().scope(e)}init(){this.logger.log(`Initializing`),this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}};const N=g.create({baseURL:`https://updater.stats.cc`,headers:{Accept:`application/json`,"Accept-Encoding":`gzip, deflate, br`}});let P;function Ie(e){P=e}N.interceptors.request.use(e=>{let t=P?.();return t?(e.headers??={},e.headers.Authorization=t,e):e});const F=g.create({baseURL:`https://api.overlayed.gg`,headers:{Accept:`application/json`,"Accept-Encoding":`gzip, deflate, br`}});let Le,Re;F.interceptors.request.use(e=>{let t=Le?.(),n=Re?.();return e.headers??={},t&&(e.headers.Authorization=t),n&&(e.headers[`X-Api-Key`]=n),e});function ze(e){return e}function I(e){return e?t=>(e(t),t):ze}I(),I();function Be(e){return F.get(`/v1/public/applications/${e}`)}I();function Ve(e,t){return N.get(`/v1/native/${L(e)}/version.txt`,{params:{channel:t},responseType:`text`})}function He(e,t){return N.get(`/v1/native/${L(e)}/files`,{params:{channel:t},responseType:`arraybuffer`})}function L(e){return e===`01JXPFK6YQ3N00N2Y9JHFNG55D`||e===`01JZEBPGHT5M4Y6SGY4P7Q9EZT`?`siege-game-module`:e}function Ue(){return F.get(`/v1/public/raven/config`)}const We=I();function Ge(e,t){return F.get(`/v1/public/raven/games/${e}/builds/${t}`)}function Ke(e,t){return F.post(`/v1/public/raven/games/${e}/builds/upload`,null,{params:t})}function qe(e,t){let n=new FormData;return n.append(`file`,t.chunk),F.patch(`/v1/public/raven/games/${e}/builds/upload`,n,{params:t})}function Je(e){return e instanceof Error&&(e.name===`XiorError`||e.name===`XiorTimeoutError`)}function Ye(e){return!!(e&&`kind`in e.data&&`message`in e.data)}let R;function Xe(e){R=e}var Ze=class extends M{UPDATE_CHECK_INTERVAL_MS=1e3*60*5;targetDir;updateInterval;constructor(){super(`NativeModuleManager`),this.targetDir=p.join(w(),`resources`),this.logger.log(`Target directory`,this.targetDir)}async initWithDlls(e){super.init(),await _.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),this.updateInterval=void 0),super.destroy()}async getCurrentVersion(e){try{let t=p.join(this.targetDir,e,`version.txt`);return await _.readFile(t,`utf-8`)}catch{return null}}getTargetPath(e){return p.join(this.targetDir,e)}getTargetVersionPath(e,t){return p.join(this.getTargetPath(e),t)}async checkForUpdates(e){let t=global.OVERLAYED.APP_BUILD_CHANNEL;if(this.logger.log(`Checking for updates`),!t){this.logger.error(`Invalid VITE_BUILD_CHANNEL`);return}await R?.();for(let n of e)try{let{data:e}=await Ve(n,t),r=await this.getCurrentVersion(n);this.logger.log(`${n} > Update Check. current: ${r}, latest: ${e}`);let i=e!==r;this.logger.log(`${n} > Update found: ${r} -> ${e}`),await this.downloadAndExtractDll(n,e,t,i),this.logger.log(`${n} > Downloaded and extracted`),i&&(this.logger.log(`${n} > Cleaning up versions older than ${e}`),await this.cleanupOldVersions(n,e)),this.emit(`dllUpdated`,{identifier:n,version:e})}catch(e){this.logger.error(`${n} > Error checking/updating`,e)}}async downloadAndExtractDll(e,t,n,r){let{data:i}=await He(e,n),a=this.getTargetPath(e),o=this.getTargetVersionPath(e,t);await _.mkdir(o,{recursive:!0});let s=new v;await s.loadAsync(i);let c=Object.keys(s.files).map(async t=>{let n=s.files[t];if(n&&!n.dir){let i=p.join(o,t);if(!r)try{await _.access(i,_.constants.F_OK);return}catch{this.logger.warn(`${e} > File missing, re-downloading: ${i}`)}let a=await n.async(`nodebuffer`);await _.writeFile(i,a)}});await Promise.all(c);let l=p.join(a,`version.txt`);this.logger.log(`Saving version file`,l),await _.writeFile(l,t)}async cleanupOldVersions(e,t){let n=p.join(this.targetDir,e),r=await _.readdir(n,{withFileTypes:!0});for(let e of r)e.isDirectory()&&e.name!==t&&await _.rm(p.join(n,e.name),{recursive:!0,force:!0})}};const z=S(Ze);var Qe=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),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),z.getInstance().destroy(),super.destroy()}async fetchRavenConfig(){try{let e=await Ue(),t={games:[...e.data.games,{name:`Valorant`,identifier:We(`valorant`),executables:[`VALORANT-Win64-Shipping.exe`],modules:[]}]};this._ravenConfig=t,this.resetState();let n=new Set;for(let e of this._ravenConfig.games){for(let t of e.executables){let n=t.toLowerCase();this._executableToGameMap.set(n,e),this._executablesArray.push(n)}e.modules.forEach(e=>n.add(e))}await z.getInstance().initWithDlls(Array.from(n)),this.logger.log(`Raven updated`,this._ravenConfig),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=[]}};const B=S(Qe),$e=e(import.meta.url),{PipeEventServer:et,PipeEventClient:tt,PipeEventBase:nt,ProcessMonitor:rt,Process:V,InjectionMethod:it,AccessLevel:at,HardwareInterface:H}=$e(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`);var ot=class extends M{_processMonitor;_processes=new Map;boundOnRavenManagerExecutablesUpdated=this.onRavenManagerExecutablesUpdated.bind(this);constructor(){super(`ProcessManager`),this._processMonitor=new rt}get hasAnyActiveProcesses(){return this.activeProcesses.length>0}get activeProcesses(){return Array.from(this._processes.values()).flat().filter(e=>!e.destroyedAt)}init(){super.init(),B.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(){B.getInstance().off(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processes.clear(),this._processMonitor.removeAllListeners(),super.destroy()}isProcessRunning(e){let t=this._processes.get(e);return t?.some(e=>!e.destroyedAt)??!1}onRavenManagerExecutablesUpdated(e){e.executables.forEach(e=>{this.logger.log(`Monitoring process`,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),n=t?.filter(t=>t.id!==e.id)??[];n.length===0?this._processes.delete(e.name):this._processes.set(e.name,n)}};const U=S(ot),st=e(import.meta.url),{RenderInterface:ct,renderHookPath:lt}=st(`@overlayed/app/dist/render-interface/build/overlayed_render_interface_x64.node`);var ut=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}}},dt=class{interfaces={};constructor(){}createInterface(e){return this.interfaces[e]||(this.interfaces[e]=new ut(new ct(e,{access:1}))),this.interfaces[e]}getInterface(e){return this.interfaces[e]?this.interfaces[e]:this.createInterface(e)}};const W=S(dt);var ft=class{_clientId=null;_userId=null;options;eventQueue;set clientId(e){this._clientId=e}set userId(e){this._userId=e}constructor(e){this.options=this.resolveOptions(e),this.eventQueue=new _e,this.setupFlushInterval()}track(e,t){this.eventQueue.add({name:e,data:t,createdAt:new Date().toISOString()})}flush(){let e=Array.from(this.eventQueue.flush()),t=e.concat({name:`ping`,data:{},createdAt:new Date().toISOString()});return t}setupFlushInterval(){setInterval(()=>{this.flush()},this.options.batchIntervalSeconds*1e3)}resolveOptions(e){return{batchIntervalSeconds:e?.batchIntervalSeconds??15}}};const G=S(ft),pt=e(import.meta.url),mt=pt.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x64.dll`);var ht=class extends Fe{boundOnProcessCreate=this.onProcessCreate.bind(this);boundOnProcessDestroy=this.onProcessDestroy.bind(this);subscribedGames=new Set;constructor(){super(`GameLaunchManager`)}setSubscribedGames(e){this.subscribedGames=new Set(e)}init(){super.init(),W.getInstance().createInterface(`OGG_SIEGE`),U.getInstance().on(`create`,this.boundOnProcessCreate),U.getInstance().on(`destroy`,this.boundOnProcessDestroy)}destroy(){U.getInstance().off(`create`,this.boundOnProcessCreate),U.getInstance().off(`destroy`,this.boundOnProcessDestroy),super.destroy()}async onProcessCreate({process:e}){let t=this.getRavenGame(e);if(!t)return;if(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;if(this.logger.log(`Game Launched`,t),this.logger.log(`Process is elevated: `,e.isElevated),this.logger.log(`Current process is elevated: `,V.currentProcess.isElevated),e.isElevated&&!V.currentProcess.isElevated){C.getInstance().fatal(`Game is elevated but the App is not`,`ELEVATION_MISMATCH`,{appElevated:!!V.currentProcess.isElevated,gameElevated:!!e.isElevated}),this.logger.log(`Game elevated but App is not`,{appElevated:V.currentProcess.isElevated,gameElevated:e.isElevated});return}let r=this.copyDll(mt);if(r)try{await e.injectDll(r),this.logger.log(`Render Interface Injection Successful`,r)}catch(e){this.logger.error(`Render Interface Injection Failed`,e),this.logger.error(`Render Interface Injection Failed`,{renderInterfacePath:r})}let i=t?.modules.map(async t=>{let n=await z.getInstance().getCurrentVersion(t);if(!n)return this.logger.error(`No version found for DLL`,{identifier:t}),Promise.resolve();let r=z.getInstance().getTargetVersionPath(t,n);this.logger.log(`DLL Path`,r);let i=await this.getDllFiles(r);return this.logger.log(`DLL Files`,i),Promise.all(i.map(async t=>{let n=p.basename(t),i=p.join(r,n);if(!i)return Promise.resolve();this.logger.log(`Injecting: `,i);try{return e.injectDll(i).then(()=>{this.logger.log(`Injection Successful`,i)}).catch(e=>{this.logger.error(`Injection Failed [1]`,{targetPath:i},e)})}catch(e){return this.logger.error(`Injection Failed [2]`,{targetPath:i},e),Promise.reject(e)}}))});await Promise.allSettled(i),this.emit(`gameReadyInternal`,{ravenGame:t,process:e}),this.emit(`gameReady`,{game:t.identifier}),G.getInstance().track(`game_launch`,{game:t.identifier})}copyDll(e){let t=p.basename(e),n=ee(e),r=p.join(w(),`resources`),i=p.join(r,t);this.logger.info(`Copying`,n,`to`,i);try{m(r)||ie(r,{recursive:!0});let e=h(n);oe(i,e),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 getDllFiles(e){try{let t=await _.readdir(e);return t.filter(e=>e.endsWith(`.dll`)).map(t=>p.join(e,t))}catch(t){return this.logger.error(`Failed to read DLL directory`,t),this.logger.error(`Failed to read DLL directory`,{dllPath:e}),[]}}onProcessDestroy({process:e}){let t=this.getRavenGame(e);t&&(this.emit(`gameCloseInternal`,{ravenGame:t,process:e}),this.emit(`gameClose`,{game:t.identifier}),G.getInstance().track(`game_close`,{game:t.identifier}))}getRavenGame(e){if(!e.name)return;let t=B.getInstance().getExecutableData(e.name);if(!t){this.logger.error(`No raven game found for process`,{process:e});return}return t}};const K=S(ht);var gt=class extends j{boundOnGameLaunch=this.onGameLaunch.bind(this);constructor(){super(`GameBuildManager`)}init(){super.init(),K.getInstance().on(`gameReadyInternal`,this.boundOnGameLaunch)}destroy(){K.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=h(n.path),i=se(`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{let e=await Ge(t.identifier,i);a=e.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 v;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 Ce(s,{chunkSizeMb:25,maxConcurrent:1}),n=await Ke(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 qe(t.identifier,{chunk:e,build_hash:i,chunk_index:r,upload_token:n.data.upload_token})}),this.logger.log(`Build uploaded successfully`)}catch(e){Je(e)?Ye(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)}}};const q=S(gt);function _t(e=[]){return p.normalize(p.join(T(global.OVERLAYED.APPLICATION_ID),...e))}const vt=r({game:`string`,type:`string`,creation_time:`number`});var J=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}(J||{});const Y=new Map([[J.LeftButton,`LeftButton`],[J.RightButton,`RightButton`],[J.Cancel,`Cancel`],[J.MiddleButton,`MiddleButton`],[J.ExtraButton1,`ExtraButton1`],[J.ExtraButton2,`ExtraButton2`],[J.Back,`Backspace`],[J.Tab,`Tab`],[J.Clear,`Clear`],[J.Return,`Enter`],[J.Shift,`ShiftLeft`],[J.Control,`ControlLeft`],[J.Menu,`AltLeft`],[J.Pause,`Pause`],[J.CapsLock,`CapsLock`],[J.Kana,`KanaMode`],[J.Junja,`JunjaMode`],[J.Final,`Finalize`],[J.Hanja,`HanjaMode`],[J.Escape,`Escape`],[J.Convert,`Convert`],[J.NonConvert,`NonConvert`],[J.Accept,`Accept`],[J.ModeChange,`ModeChange`],[J.Space,`Space`],[J.Prior,`PageUp`],[J.Next,`PageDown`],[J.End,`End`],[J.Home,`Home`],[J.Left,`ArrowLeft`],[J.Up,`ArrowUp`],[J.Right,`ArrowRight`],[J.Down,`ArrowDown`],[J.Select,`Select`],[J.Print,`PrintScreen`],[J.Execute,`Execute`],[J.Snapshot,`Snapshot`],[J.Insert,`Insert`],[J.Delete,`Delete`],[J.Help,`Help`],[J.N0,`Digit0`],[J.N1,`Digit1`],[J.N2,`Digit2`],[J.N3,`Digit3`],[J.N4,`Digit4`],[J.N5,`Digit5`],[J.N6,`Digit6`],[J.N7,`Digit7`],[J.N8,`Digit8`],[J.N9,`Digit9`],[J.A,`KeyA`],[J.B,`KeyB`],[J.C,`KeyC`],[J.D,`KeyD`],[J.E,`KeyE`],[J.F,`KeyF`],[J.G,`KeyG`],[J.H,`KeyH`],[J.I,`KeyI`],[J.J,`KeyJ`],[J.K,`KeyK`],[J.L,`KeyL`],[J.M,`KeyM`],[J.N,`KeyN`],[J.O,`KeyO`],[J.P,`KeyP`],[J.Q,`KeyQ`],[J.R,`KeyR`],[J.S,`KeyS`],[J.T,`KeyT`],[J.U,`KeyU`],[J.V,`KeyV`],[J.W,`KeyW`],[J.X,`KeyX`],[J.Y,`KeyY`],[J.Z,`KeyZ`],[J.LeftWindows,`MetaLeft`],[J.RightWindows,`MetaRight`],[J.Application,`ContextMenu`],[J.Sleep,`Sleep`],[J.Numpad0,`Numpad0`],[J.Numpad1,`Numpad1`],[J.Numpad2,`Numpad2`],[J.Numpad3,`Numpad3`],[J.Numpad4,`Numpad4`],[J.Numpad5,`Numpad5`],[J.Numpad6,`Numpad6`],[J.Numpad7,`Numpad7`],[J.Numpad8,`Numpad8`],[J.Numpad9,`Numpad9`],[J.Multiply,`NumpadMultiply`],[J.Add,`NumpadAdd`],[J.Separator,`NumpadSeparator`],[J.Subtract,`NumpadSubtract`],[J.Decimal,`NumpadDecimal`],[J.Divide,`NumpadDivide`],[J.F1,`F1`],[J.F2,`F2`],[J.F3,`F3`],[J.F4,`F4`],[J.F5,`F5`],[J.F6,`F6`],[J.F7,`F7`],[J.F8,`F8`],[J.F9,`F9`],[J.F10,`F10`],[J.F11,`F11`],[J.F12,`F12`],[J.F13,`F13`],[J.F14,`F14`],[J.F15,`F15`],[J.F16,`F16`],[J.F17,`F17`],[J.F18,`F18`],[J.F19,`F19`],[J.F20,`F20`],[J.F21,`F21`],[J.F22,`F22`],[J.F23,`F23`],[J.F24,`F24`],[J.NumLock,`NumLock`],[J.ScrollLock,`ScrollLock`],[J.NEC_Equal,`NEC_Equal`],[J.Fujitsu_Masshou,`Fujitsu_Masshou`],[J.Fujitsu_Touroku,`Fujitsu_Touroku`],[J.Fujitsu_Loya,`Fujitsu_Loya`],[J.Fujitsu_Roya,`Fujitsu_Roya`],[J.LeftShift,`ShiftLeft`],[J.RightShift,`ShiftRight`],[J.LeftControl,`ControlLeft`],[J.RightControl,`ControlRight`],[J.LeftMenu,`AltLeft`],[J.RightMenu,`AltRight`],[J.BrowserBack,`BrowserBack`],[J.BrowserForward,`BrowserForward`],[J.BrowserRefresh,`BrowserRefresh`],[J.BrowserStop,`BrowserStop`],[J.BrowserSearch,`BrowserSearch`],[J.BrowserFavorites,`BrowserFavorites`],[J.BrowserHome,`BrowserHome`],[J.VolumeMute,`VolumeMute`],[J.VolumeDown,`VolumeDown`],[J.VolumeUp,`VolumeUp`],[J.MediaNextTrack,`MediaTrackNext`],[J.MediaPrevTrack,`MediaTrackPrevious`],[J.MediaStop,`MediaStop`],[J.MediaPlayPause,`MediaPlayPause`],[J.LaunchMail,`LaunchMail`],[J.LaunchMediaSelect,`LaunchMediaSelect`],[J.LaunchApplication1,`LaunchApplication1`],[J.LaunchApplication2,`LaunchApplication2`],[J.OEM1,`OEM_1`],[J.OEMPlus,`Equal`],[J.OEMComma,`Comma`],[J.OEMMinus,`Minus`],[J.OEMPeriod,`Period`],[J.OEM2,`Slash`],[J.OEM3,`Backquote`],[J.OEM4,`BracketLeft`],[J.OEM5,`Backslash`],[J.OEM6,`BracketRight`],[J.OEM7,`Quote`],[J.OEM8,`IntlRo`],[J.OEMAX,`OEM_AX`],[J.OEM102,`IntlBackslash`],[J.ICOHelp,`ICO_HELP`],[J.ICO00,`ICO_00`],[J.ProcessKey,`Process`],[J.ICOClear,`ICO_CLEAR`],[J.Packet,`Packet`],[J.OEMReset,`OEM_Reset`],[J.OEMJump,`OEM_Jump`],[J.OEMPA1,`OEM_PA1`],[J.OEMPA2,`OEM_PA2`],[J.OEMPA3,`OEM_PA3`],[J.OEMWSCtrl,`OEM_WS_Ctrl`],[J.OEMCUSel,`OEM_CU_Sel`],[J.OEMATTN,`OEM_ATTN`],[J.OEMFinish,`OEM_Finish`],[J.OEMCopy,`OEM_Copy`],[J.OEMAuto,`OEM_Auto`],[J.OEMENLW,`OEM_ENLW`],[J.OEMBackTab,`BackTab`],[J.ATTN,`ATTN`],[J.CRSel,`CRSel`],[J.EXSel,`EXSel`],[J.EREOF,`EREOF`],[J.Play,`MediaPlay`],[J.Zoom,`Zoom`],[J.Noname,`Noname`],[J.PA1,`PA1`],[J.OEMClear,`OEM_Clear`]]),yt=new Map(Y.entries().map(([e,t])=>[t,e])),bt=r({"[string]":{keys:`string[]`,mode:r(`'toggle' | 'hold'`).pipe(e=>e??`toggle`)}});var xt=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 be({path:_t([`keybinds.json`]),schema:bt,default:e})}init(){super.init();let e=W.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)||{};n.toggle=t,this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindDown(e,t){let n=this.preferencesKeybindToCallbacks.get(e)||{};n.down=t,this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindUp(e,t){let n=this.preferencesKeybindToCallbacks.get(e)||{};n.up=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=W.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=Y.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=Y.get(e.key);if(!t)return;this.pressedKeys.delete(t);let n=this.keybindsFile.get();for(let[e]of this.preferencesKeybindToCallbacks.entries()){let r=n[e];r.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)continue;let r=e[t];this.activeKeybinds.has(t)&&r.keys.some(e=>!this.pressedKeys.has(e))&&(this.activeKeybinds.delete(t),n.up(),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],i=r.keys.length===this.pressedKeys.size&&r.keys.every(e=>yt.has(e)?this.pressedKeys.has(e):!1);if(i){this.triggerKeybind(r,n,t);return}}for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t],i=r.keys.every(e=>yt.has(e)?this.pressedKeys.has(e):(this.logger.error(`Unknown key`,e,r),!1));i&&this.triggerKeybind(r,n,t)}}triggerKeybind(e,t,n){let r=e.mode;if(r===`toggle`&&t.toggle&&!this.triggeredToggleKeybinds.has(n)){let r=t.toggle();this.triggeredToggleKeybinds.add(n),this.logger.log(r?`Keybind pressed rejected: ${r}`:`Keybind pressed accepted`,this.getKeybindToString(e))}if(r===`hold`&&t.down&&!this.activeKeybinds.has(n)){let r=t.down();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}`:``})`}},St=class extends j{renderInterface;globalCursorOverrideCount=new Set;globalMouseBlockCount=new Set;globalKeyboardBlockCount=new Set;keyInputBlocks={};constructor(e){super(`OverridesManager`),this.renderInterface=W.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)}};const Ct=S(St,`OGG_SIEGE`);var wt=me((exports,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`){let t={KEYDOWN:256,LBUTTONUP:514,MBUTTONUP:520,RBUTTONUP:517,XBUTTONUP:524,TOUCH:576};for(let n of Object.values(t))e.hookWindowMessage(n,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}}),Tt=ge(wt(),1);let X=!1,Z;function Et(e){let{init:t=!0}=e;if(Dt(e),O.getInstance().init(e.applicationId),X)return Z;function n(){Vt(e);let t=new Map,r=At(e.modules,t),i=jt(),a=Nt(e.keybinds),o=Pt(),s=Ft(),c=Lt(),l=It(),u=Rt();Ot(e),Mt(e,t),X=!0,Z={...r,...i,ads:c,keybinds:a,windows:o,input:s,cortex:l,hasAnyActiveProcesses:()=>U.getInstance().hasAnyActiveProcesses,init:n,log:u,initialized:X}}return t?(n(),Z):new Proxy({init:n},{get:(e,t)=>{if(t!==`init`&&!X)throw Error(`overlayed was called before initialized: ${t}`);return t===`init`?e[t]:Z[t]}})}global.OVERLAYED=new Proxy({},{get:()=>{throw Error(`function overlayed was not called`)}});function Dt(e){global.OVERLAYED={APPLICATION_ID:e.applicationId,APP_BUILD_CHANNEL:e.channel??`alpha`,APP_VERSION:e.version??y.getVersion(),electron:e.electron}}function Ot(e){let t=e.universal?[`*`]:e.modules.map(e=>e.key);K.getInstance().setSubscribedGames(t),q.getInstance().init(),K.getInstance().init(),U.getInstance().init(),B.getInstance().init();async function n(){let e=Be(global.OVERLAYED.APPLICATION_ID).then(e=>e.data),t=H.generateUniqueIdentifier();O.getInstance().log(`userId`,t);let n={...await e,userId:t};return O.getInstance().log(`appInfo`,n),n}let r;global.OVERLAYED.electron.ipcMain.handle(`getAppInfo`,async()=>(r=r??n(),r)),y.on(`quit`,()=>{kt()})}function kt(){B.getInstance().destroy(),K.getInstance().destroy(),q.getInstance().destroy(),U.getInstance().destroy(),W.getInstance().getInterface(`OGG_SIEGE`).destroy(),A.getInstance().destroy(),C.getInstance().destroy()}function At(e,t){return e.reduce((e,n)=>{let r=n.key;return e[r]={on(e,n){let i=Q(r,e),a=t.get(i)??new Set;a.add(n),t.set(i,a)},onAny(e){let n=Q(r,`*`),i=t.get(n)??new Set;i.add(e),t.set(n,i)},off(e,n){let i=Q(r,e),a=t.get(i)??new Set;a.delete(n),t.set(i,a)},offAny(e){let n=Q(r,`*`),i=t.get(n)??new Set;i.delete(e),t.set(n,i)}},e},{})}function jt(){let e=C.getInstance(),t=K.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]})}}}}function Q(e,t){return`${e}:${t}`}function Mt(e,t){let n=A.getInstance();function i(n){let i=vt(n);if(i instanceof r.errors){C.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:i.summary});return}let a=e.modules.find(e=>e.key===i.game),o=a?.events.event;if(!o)return;let s=o(n);if(s instanceof r.errors){C.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:s.summary});return}let c=Q(a.key,s.type),l=Q(a.key,`*`),u=t.get(c),d=t.get(l),f=[...Array.from(u??[]),...Array.from(d??[])];f.length!==0&&f.forEach(e=>{e(s)})}return n.on(`data`,e=>e.forEach(i)),n.on(`error`,e=>{C.getInstance().error(`Pipe server error`,`PIPE_SERVER_ERROR`,{error:e})}),n}function Nt(e){let t=new xt(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(),y.on(`quit`,()=>{t.destroy()}),r}function Pt(){return{createWindow:e=>$().instance.newWindowInternal(ce.BrowserWindow,e),on:(e,t)=>$().instance.on(e,t),off:(e,t)=>$().instance.off(e,t),once:(e,t)=>$().instance.once(e,t),addListener:(e,t)=>$().instance.addListener(e,t),removeListener:(e,t)=>$().instance.removeListener(e,t),removeAllListeners:()=>$().instance.removeAllListeners(),prependListener:(e,t)=>$().instance.prependListener(e,t),prependOnceListener:(e,t)=>$().instance.prependOnceListener(e,t),getActiveGameInfo:()=>{let e=$(),t=A.getInstance();return{resolution:e.resolution,isConnected:t.hasConnection}}}}function Ft(){return{scope:e=>Ct.getInstance().scope(e),raw:{setGlobalMouseBlock:e=>$().instance.setGlobalMouseBlock(e),setGlobalKeyboardBlock:e=>$().instance.setGlobalKeyboardBlock(e),setGlobalCursorOverride:e=>$().instance.setGlobalCursorOverride(e),setKeyInputBlock:(e,t)=>$().instance.setKeyInputBlock(e,t),getGlobalMouseBlock:()=>$().instance.getGlobalMouseBlock(),getGlobalKeyboardBlock:()=>$().instance.getGlobalKeyboardBlock(),getGlobalCursorOverride:()=>$().instance.getGlobalCursorOverride(),getKeyInputBlock:e=>$().instance.getKeyInputBlock(e)}}}function It(){return{track:(e,t)=>G.getInstance().track(`custom__${e}`,t)}}function Lt(){return{registerWindow:e=>{(0,Tt.setupRevUtils)(e,global.OVERLAYED.electron)}}}function Rt(){let e=new D(`app.log`);return e.init(global.OVERLAYED.APPLICATION_ID),{scope:t=>e.scope(t),info:t=>e.info(t),warn:t=>e.warn(t),error:t=>e.error(t),submitBugReport:async(e,t)=>{try{let n=zt(t),r=await n.generateAsync({type:`base64`}),i=await Bt(e,r);return i?[void 0,{message:`Failed to submit bug report`,error:i}]:[!0,void 0]}catch(e){return[void 0,{message:`Failed to generate logs zip`,error:e}]}}}}function zt(e){let t=E(global.OVERLAYED.APPLICATION_ID),n=k(t),r=Se(),i=k(r);O.getInstance().info(`Logs path: `,t),O.getInstance().info(`Overlayed logs path: `,r);let a=new v;return[...n,...i].forEach(([e,t])=>{O.getInstance().info(`Zipping: `,e,t);let n=`${e}/${t}`,r=re(n);a.file(t,r,{compression:`DEFLATE`})}),Object.entries(e?.additionalFiles??{}).forEach(([e,t])=>{O.getInstance().info(`Zipping extra file: `,e),a.file(e,t,{compression:`DEFLATE`})}),a}async function Bt(e,t){let n={...e,version:`${global.OVERLAYED.APP_VERSION}@${global.OVERLAYED.APP_BUILD_CHANNEL}`,log_zip:`data:application/zip;base64,${t}`},r;return await fetch(`https://api.stats.cc/v1/overlay/contact`,{method:`POST`,body:JSON.stringify(n),redirect:`follow`,headers:{"Content-Type":`application/json`}}).then(async e=>{e.status>=300&&(r=await e.text())}).catch(e=>{r=e.message}),r}function Vt(e){G.getInstance().clientId=e.applicationId,G.getInstance().userId=H.generateUniqueIdentifier(),C.getInstance().on(`fatal`,e=>{G.getInstance().track(`fatal`,{message:e.message,code:e.code,data:e.data})}),C.getInstance().on(`error`,e=>{G.getInstance().track(`error`,{message:e.message,code:e.code,data:e.data})}),C.getInstance().on(`warning`,e=>{G.getInstance().track(`warning`,{message:e.message,code:e.code,data:e.data})})}function $(){return W.getInstance().getInterface(`OGG_SIEGE`)}export{we as defineConfig,Et as overlayed,Xe as setFetchLatestTokenCallback,Ie as setUpdaterTokenResolver};
1
+ import{createRequire as e}from"node:module";import t from"mitt";import{Type as n,type as r}from"arktype";import i,{createWriteStream as a,existsSync as o,mkdirSync as s,readdirSync as c,unlinkSync as l,writeFileSync as u}from"fs";import{ensureFileSync as d}from"fs-extra";import{join as f}from"path";import p,{resolve as ee}from"node:path";import te from"events";import{copyFileSync as ne,createReadStream as re,existsSync as ie,mkdirSync as ae,readFileSync as m,readdirSync as oe,writeFileSync as se}from"node:fs";import"glob";import"jiti";import h from"xior";import g from"fs/promises";import _ from"jszip";import{createHash as ce}from"node:crypto";import{BrowserWindow as le,app as v}from"electron";var ue=Object.create,y=Object.defineProperty,de=Object.getOwnPropertyDescriptor,fe=Object.getOwnPropertyNames,pe=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,he=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ge=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=fe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!me.call(e,s)&&s!==n&&y(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=de(t,s))||r.enumerable});return e},_e=(e,t,n)=>(n=e==null?{}:ue(pe(e)),ge(t||!e||!e.__esModule?y(n,`default`,{value:e,enumerable:!0}):n,e)),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)}}},b=class{emitter;constructor(){this.emitter=t()}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}emit(e,t){this.emitter.emit(e,t)}removeAllListeners(){this.emitter.all.clear()}},ye=class{listeners;constructor(){this.listeners=new Map}on(e,t){let n=this.listeners.get(e)||new Set;n.add(t),this.listeners.set(e,n)}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}async emit(e,...t){let n=this.listeners.get(e)||new Set,r=this.listeners.get(`*`)||new Set,i=[...Array.from(n),...Array.from(r)];if(i.length===0)return[];let a=await Promise.all(i.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}}));return a}removeAllListeners(){this.listeners.clear()}};function x(e,...t){let n=class extends e{static _instance;static getInstance(){return this._instance||(this._instance=new e(...t)),this._instance}static clearInstance(){this._instance=void 0}};return n}var be=class extends b{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()})}};const S=x(be);var xe=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(){return this.data?this.data:this.load()}getKey(e){let t=this.get();return t[e]}save(e){let t=this.onBeforeSave(e);try{d(this.getFilePath()),i.writeFileSync(this.getFilePath(),JSON.stringify(t,void 0,2))}catch{return}return this.data=t}load(){if(!this.fileExists(this.getFilePath())||!this.canReadWriteFile(this.getFilePath())){this.save(this._defaultValue);let e=this.onAfterLoad(this._defaultValue);return this.data=e,e}try{let e=i.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`),n=t(e);if(n instanceof r.errors)return this._defaultValue;let i=this._schema[`~standard`].validate(n);if(i instanceof Promise)throw Error(`StructuredConfigFile does not support async validation`);return i.issues?this.migrate(n,this._defaultValue):this.migrate(i.value,this._defaultValue)}catch{return this._defaultValue}}canReadWriteFile(e){try{return i.accessSync(e,i.constants.R_OK|i.constants.W_OK),!0}catch{return!1}}fileExists(e){try{return i.accessSync(e,i.constants.F_OK),!0}catch{return!1}}migrate(e,t){let n={...e};for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;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){S.getInstance().error(`Invalid config file`,`INVALID_CONFIG_FILE`,{issues:e.map(e=>e.message),filePath:this._path,data:this.data})}},Se=class e extends b{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(`log`,...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)}getFileName(e){return`${this.baseFileName}-${e}.log`}ensureLogDirectory(){try{s(this.logPath,{recursive:!0})}catch(e){throw console.error(`Failed to create log directory ${this.logPath}:`,e),e}}ensureLogFile(){let e=f(this.logPath,this.getFileName(this.currentDate));if(!o(e))try{u(e,``,`utf8`)}catch(t){throw console.error(`Failed to create log file ${e}:`,t),t}}getDateString(e){return e.toISOString().split(`T`)[0]}createStream(){let e=f(this.logPath,this.getFileName(this.currentDate));return a(e,{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=c(this.logPath),t=new Date;t.setDate(t.getDate()-3),e.filter(e=>e.startsWith(this.baseFileName)&&e.endsWith(`.log`)).filter(e=>{let n=e.replace(`${this.baseFileName}-`,``).replace(`.log`,``),r=new Date(n);return r<t}).forEach(e=>{try{l(f(this.logPath,e))}catch(t){console.error(`Failed to delete old log file ${e}:`,t)}})}write(e,...t){let n=new Date,r=n.toISOString().replace(`T`,` `).replace(/\.\d+Z$/,``)+`.${n.getMilliseconds().toString().padStart(3,`0`)}`,i=t.map(e=>typeof e==`object`?JSON.stringify(e,void 0,2):String(e)).join(` `),a=`[${r}] [${e}] ${i}\n`;this.stream.write(a,e=>{e?this.emit(`error`,e):this.emit(`write`,a)})}};const C=()=>p.join(process.env.APPDATA??``,`overlayed`),Ce=()=>p.join(C(),`logs`),w=e=>p.join(C(),`apps`,e),T=e=>p.join(w(e),`logs`);var E=class{fileLogger;path;appId;messageQueue=new ve;fileName;constructor(e){this.fileName=e}init(e){this.appId=e,this.path=T(e),this.fileLogger=new Se(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=`[${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)}}error(...e){this.handle(`error`,...e)}warn(...e){this.handle(`warn`,...e)}info(...e){this.handle(`log`,...e)}debug(...e){this.handle(`debug`,...e)}log(...e){this.handle(`log`,...e)}handle(e,...t){console[e](...t),this.fileLogger?this.fileLogger[e](...t):this.messageQueue.add({type:e,args:t})}};const D=x(E,`main.log`);var we=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=5,i=new Map,a=new Set,o=new Set,s=[];for(let e=0;e<n;e++)s.push(e);let c=async n=>{let c=n*t,l=Math.min(c+t,this.blob.size),u=this.blob.slice(c,l);try{await e(u,n),o.add(n),this.emit(`chunkComplete`,n),a.delete(n)}catch(e){let t=i.get(n)||0;t<r?(i.set(n,t+1),await new Promise(e=>setTimeout(e,(t+1)*1e3)),s.push(n)):(o.add(n),this.emit(`error`,e),this.shouldStop=!0,a.delete(n))}},l=[],u=async()=>{for(;(s.length>0||a.size>0)&&!this.shouldStop;){if(s.length===0){await new Promise(e=>setTimeout(e,10));continue}let e=s.shift();o.has(e)||a.has(e)||(a.add(e),await c(e))}};for(let e=0;e<this.maxConcurrent;e++)l.push(u());await Promise.all(l)}};function O(e){return ie(e)?oe(e).map(t=>[e,t]):[]}function Te(e){return e}const Ee=e(import.meta.url),{PipeEventServer:De,PipeEventClient:Oe,PipeEventBase:ke,ProcessMonitor:Ae,Process:je,InjectionMethod:Me,AccessLevel:Ne,HardwareInterface:Pe}=Ee(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`);var Fe=class extends b{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(),this.server=null)}init(){this.server=new De(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.server.on(`disconnected`,()=>{this._hasConnection=!1})}};const k=x(Fe,`stats-cc`);var Ie=class{logger;initialized=!1;constructor(e){this.logger=D.getInstance().scope(e)}init(){this.logger.log(`Initializing`),this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1}},A=class extends b{logger;initialized=!1;constructor(e){super(),this.logger=D.getInstance().scope(e)}init(){this.logger.log(`Initializing`),this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}},Le=class extends ye{logger;initialized=!1;constructor(e){super(),this.logger=D.getInstance().scope(e)}init(){this.logger.log(`Initializing`),this.initialized=!0}destroy(){this.logger.log(`Destroying`),this.initialized=!1,this.removeAllListeners()}};const j=h.create({baseURL:`https://updater.stats.cc`,headers:{Accept:`application/json`,"Accept-Encoding":`gzip, deflate, br`}});let M;function Re(e){M=e}j.interceptors.request.use(e=>{let t=M?.();return t?(e.headers??={},e.headers.Authorization=t,e):e});const N=h.create({baseURL:`https://api.overlayed.gg`,headers:{Accept:`application/json`,"Accept-Encoding":`gzip, deflate, br`}});let ze,Be;N.interceptors.request.use(e=>{let t=ze?.(),n=Be?.();return e.headers??={},t&&(e.headers.Authorization=t),n&&(e.headers[`X-Api-Key`]=n),e});function Ve(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 He(e){return e}function P(e){return e?t=>(e(t),t):He}P();const Ue=P();function We(e){return N.get(`/v1/public/applications/${e}`)}P();function Ge(e,t){return j.get(`/v1/native/${F(e)}/version.txt`,{params:{channel:t},responseType:`text`})}function Ke(e,t){return j.get(`/v1/native/${F(e)}/files`,{params:{channel:t},responseType:`arraybuffer`})}function F(e){return e===`01JXPFK6YQ3N00N2Y9JHFNG55D`||e===`01JZEBPGHT5M4Y6SGY4P7Q9EZT`?`siege-game-module`:e}function qe(){return N.get(`/v1/public/raven/config`)}const Je=P();function Ye(e,t){return N.get(`/v1/public/raven/games/${e}/builds/${t}`)}function Xe(e,t){return N.post(`/v1/public/raven/games/${e}/builds/upload`,null,{params:t})}function Ze(e,t){let n=new FormData;return n.append(`file`,t.chunk),N.patch(`/v1/public/raven/games/${e}/builds/upload`,n,{params:t})}const Qe=250;function $e(e){let t=Ve(e.messages,Qe),n=Promise.all(t.map(async t=>N.post(`/v1/public/cortex/events`,{...e,messages:t})));return n}function et(e){return e instanceof Error&&(e.name===`XiorError`||e.name===`XiorTimeoutError`)}function tt(e){return!!(e&&`kind`in e.data&&`message`in e.data)}let I;function nt(e){I=e}var rt=class extends A{UPDATE_CHECK_INTERVAL_MS=1e3*60*5;targetDir;updateInterval;constructor(){super(`NativeModuleManager`),this.targetDir=p.join(C(),`resources`),this.logger.log(`Target directory`,this.targetDir)}async initWithDlls(e){super.init(),await g.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),this.updateInterval=void 0),super.destroy()}async getCurrentVersion(e){try{let t=p.join(this.targetDir,e,`version.txt`);return this.logger.log(`Version Path`,t),await g.readFile(t,`utf-8`)}catch{return null}}getTargetPath(e){return p.join(this.targetDir,e)}getTargetVersionPath(e,t){return p.join(this.getTargetPath(e),t)}async checkForUpdates(e){let t=global.OVERLAYED.APP_BUILD_CHANNEL;if(this.logger.log(`Checking for updates`),!t){this.logger.error(`Invalid VITE_BUILD_CHANNEL`);return}await I?.();for(let n of e)try{let{data:e}=await Ge(n,t),r=await this.getCurrentVersion(n);this.logger.log(`${n} > Update Check. current: ${r}, latest: ${e}`);let i=e!==r;this.logger.log(`${n} > Update found: ${r} -> ${e}`),await this.downloadAndExtractDll(n,e,t,i),this.logger.log(`${n} > Downloaded and extracted`),i&&(this.logger.log(`${n} > Cleaning up versions older than ${e}`),await this.cleanupOldVersions(n,e)),this.emit(`dllUpdated`,{identifier:n,version:e})}catch(e){this.logger.error(`${n} > Error checking/updating`,e)}}async downloadAndExtractDll(e,t,n,r){let{data:i}=await Ke(e,n),a=this.getTargetPath(e),o=this.getTargetVersionPath(e,t);await g.mkdir(o,{recursive:!0});let s=new _;await s.loadAsync(i);let c=Object.keys(s.files).map(async t=>{let n=s.files[t];if(n&&!n.dir){let i=p.join(o,t);if(!r)try{await g.access(i,g.constants.F_OK);return}catch{this.logger.warn(`${e} > File missing, re-downloading: ${i}`)}let a=await n.async(`nodebuffer`);await g.writeFile(i,a)}});await Promise.all(c);let l=p.join(a,`version.txt`);this.logger.log(`Saving version file`,l),await g.writeFile(l,t)}async cleanupOldVersions(e,t){let n=p.join(this.targetDir,e),r=await g.readdir(n,{withFileTypes:!0});for(let e of r)e.isDirectory()&&e.name!==t&&await g.rm(p.join(n,e.name),{recursive:!0,force:!0})}};const L=x(rt);var it=class extends A{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),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),L.getInstance().destroy(),super.destroy()}async fetchRavenConfig(){try{let e=await qe(),t={games:[...e.data.games,{name:`Valorant`,identifier:Je(`valorant`),executables:[`VALORANT-Win64-Shipping.exe`],modules:[]}]};this._ravenConfig=t,this.resetState();let n=new Set;for(let e of this._ravenConfig.games){for(let t of e.executables){let n=t.toLowerCase();this._executableToGameMap.set(n,e),this._executablesArray.push(n)}e.modules.forEach(e=>n.add(e))}await L.getInstance().initWithDlls(Array.from(n)),this.logger.log(`Raven updated`,this._ravenConfig),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=[]}};const R=x(it),at=e(import.meta.url),{PipeEventServer:ot,PipeEventClient:st,PipeEventBase:ct,ProcessMonitor:lt,Process:z,InjectionMethod:ut,AccessLevel:dt,HardwareInterface:B}=at(`@overlayed/app/dist/native-interface/build/overlayed_native_interface_x64.node`);var ft=class extends A{_processMonitor;_processes=new Map;boundOnRavenManagerExecutablesUpdated=this.onRavenManagerExecutablesUpdated.bind(this);constructor(){super(`ProcessManager`),this._processMonitor=new lt}get hasAnyActiveProcesses(){return this.activeProcesses.length>0}get activeProcesses(){return Array.from(this._processes.values()).flat().filter(e=>!e.destroyedAt)}init(){super.init(),R.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(){R.getInstance().off(`executablesUpdated`,this.boundOnRavenManagerExecutablesUpdated),this._processes.clear(),this._processMonitor.removeAllListeners(),super.destroy()}isProcessRunning(e){let t=this._processes.get(e);return t?.some(e=>!e.destroyedAt)??!1}onRavenManagerExecutablesUpdated(e){e.executables.forEach(e=>{this.logger.log(`Monitoring process`,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),n=t?.filter(t=>t.id!==e.id)??[];n.length===0?this._processes.delete(e.name):this._processes.set(e.name,n)}};const V=x(ft),pt=e(import.meta.url),{RenderInterface:mt,renderHookPath:ht}=pt(`@overlayed/app/dist/render-interface/build/overlayed_render_interface_x64.node`);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}}},_t=class{interfaces={};constructor(){}createInterface(e){return this.interfaces[e]||(this.interfaces[e]=new gt(new mt(e,{access:1}))),this.interfaces[e]}getInterface(e){return this.interfaces[e]?this.interfaces[e]:this.createInterface(e)}};const H=x(_t);var vt=class{options;eventQueue;_meta=null;set meta(e){this._meta=e}constructor(e){this.options=this.resolveOptions(e),this.eventQueue=new ve,this.setupFlushInterval()}track(e,t){this.eventQueue.add({type:e,properties:t,created_at:new Date().toISOString()})}flush(){let e=Array.from(this.eventQueue.flush()),t=e.concat({type:`ping`,properties:{},created_at:new Date().toISOString()});if(!this._meta)throw Error(`Tried to flush Cortex events before meta was set`);try{$e({...this._meta,messages:t})}catch{}return t}setupFlushInterval(){setInterval(()=>{this.flush()},this.options.batchIntervalSeconds*1e3)}resolveOptions(e){return{batchIntervalSeconds:e?.batchIntervalSeconds??15}}};const U=x(vt),yt=e(import.meta.url),bt=yt.resolve(`@overlayed/app/dist/render-interface/build/overlayed_render_hook_x64.dll`);var xt=class extends Le{boundOnProcessCreate=this.onProcessCreate.bind(this);boundOnProcessDestroy=this.onProcessDestroy.bind(this);subscribedGames=new Set;constructor(){super(`GameLaunchManager`)}setSubscribedGames(e){this.subscribedGames=new Set(e)}init(){super.init(),H.getInstance().createInterface(`OGG_SIEGE`),V.getInstance().on(`create`,this.boundOnProcessCreate),V.getInstance().on(`destroy`,this.boundOnProcessDestroy)}destroy(){V.getInstance().off(`create`,this.boundOnProcessCreate),V.getInstance().off(`destroy`,this.boundOnProcessDestroy),super.destroy()}async onProcessCreate({process:e}){let t=this.getRavenGame(e);if(!t)return;if(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;if(this.logger.log(`Game Launched`,t),this.logger.log(`Process is elevated: `,e.isElevated),this.logger.log(`Current process is elevated: `,z.currentProcess.isElevated),e.isElevated&&!z.currentProcess.isElevated){S.getInstance().fatal(`Game is elevated but the App is not`,`ELEVATION_MISMATCH`,{appElevated:!!z.currentProcess.isElevated,gameElevated:!!e.isElevated}),this.logger.log(`Game elevated but App is not`,{appElevated:z.currentProcess.isElevated,gameElevated:e.isElevated});return}let r=this.copyDll(bt);if(r)try{await e.injectDll(r),this.logger.log(`Render Interface Injection Successful`,r)}catch(e){this.logger.error(`Render Interface Injection Failed`,e),this.logger.error(`Render Interface Injection Failed`,{renderInterfacePath:r})}let i=t?.modules.map(async t=>{let n=await L.getInstance().getCurrentVersion(t);if(!n)return this.logger.error(`No version found for DLL`,{identifier:t}),Promise.resolve();let r=L.getInstance().getTargetVersionPath(t,n);this.logger.log(`DLL Path`,r);let i=await this.getDllFiles(r);return this.logger.log(`DLL Files`,i),Promise.all(i.map(async t=>{let n=p.basename(t),i=p.join(r,n);if(!i)return Promise.resolve();this.logger.log(`Injecting: `,i);try{return e.injectDll(i).then(()=>{this.logger.log(`Injection Successful`,i)}).catch(e=>{this.logger.error(`Injection Failed [1]`,{targetPath:i},e)})}catch(e){return this.logger.error(`Injection Failed [2]`,{targetPath:i},e),Promise.reject(e)}}))});await Promise.allSettled(i),this.emit(`gameReadyInternal`,{ravenGame:t,process:e}),this.emit(`gameReady`,{game:t.identifier}),U.getInstance().track(`game_launch`,{game:t.identifier})}copyDll(e){let t=p.basename(e),n=ee(e),r=p.join(C(),`resources`),i=p.join(r,t);this.logger.info(`Copying`,n,`to`,i);try{ie(r)||ae(r,{recursive:!0});let e=m(n);se(i,e),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 getDllFiles(e){try{let t=await g.readdir(e);return t.filter(e=>e.endsWith(`.dll`)).map(t=>p.join(e,t))}catch(t){return this.logger.error(`Failed to read DLL directory`,t),this.logger.error(`Failed to read DLL directory`,{dllPath:e}),[]}}onProcessDestroy({process:e}){let t=this.getRavenGame(e);t&&(this.emit(`gameCloseInternal`,{ravenGame:t,process:e}),this.emit(`gameClose`,{game:t.identifier}),U.getInstance().track(`game_close`,{game:t.identifier}))}getRavenGame(e){if(!e.name)return;let t=R.getInstance().getExecutableData(e.name);if(!t){this.logger.error(`No raven game found for process`,{process:e});return}return t}};const W=x(xt);var St=class extends Ie{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=m(n.path),i=ce(`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{let e=await Ye(t.identifier,i);a=e.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 _;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 we(s,{chunkSizeMb:25,maxConcurrent:1}),n=await Xe(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 Ze(t.identifier,{chunk:e,build_hash:i,chunk_index:r,upload_token:n.data.upload_token})}),this.logger.log(`Build uploaded successfully`)}catch(e){et(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)}}};const G=x(St);function Ct(e=[]){return p.normalize(p.join(w(global.OVERLAYED.APPLICATION_ID),...e))}const wt=r({game:`string`,type:`string`,creation_time:`number`});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 q=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`]]),J=new Map(q.entries().map(([e,t])=>[t,e])),Tt=r({"[string]":{keys:`string[]`,mode:r(`'toggle' | 'hold'`).pipe(e=>e??`toggle`)}});var Et=class extends A{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 xe({path:Ct([`keybinds.json`]),schema:Tt,default:e})}init(){super.init();let e=H.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)||{};n.toggle=t,this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindDown(e,t){let n=this.preferencesKeybindToCallbacks.get(e)||{};n.down=t,this.preferencesKeybindToCallbacks.set(e,n)}async onKeybindUp(e,t){let n=this.preferencesKeybindToCallbacks.get(e)||{};n.up=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=H.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=q.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=q.get(e.key);if(!t)return;this.pressedKeys.delete(t);let n=this.keybindsFile.get();for(let[e]of this.preferencesKeybindToCallbacks.entries()){let r=n[e];r.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)continue;let r=e[t];this.activeKeybinds.has(t)&&r.keys.some(e=>!this.pressedKeys.has(e))&&(this.activeKeybinds.delete(t),n.up(),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],i=r.keys.length===this.pressedKeys.size&&r.keys.every(e=>J.has(e)?this.pressedKeys.has(e):!1);if(i){this.triggerKeybind(r,n,t);return}}for(let[t,n]of this.preferencesKeybindToCallbacks.entries()){let r=e[t],i=r.keys.every(e=>J.has(e)?this.pressedKeys.has(e):(this.logger.error(`Unknown key`,e,r),!1));i&&this.triggerKeybind(r,n,t)}}triggerKeybind(e,t,n){let r=e.mode;if(r===`toggle`&&t.toggle&&!this.triggeredToggleKeybinds.has(n)){let r=t.toggle();this.triggeredToggleKeybinds.add(n),this.logger.log(r?`Keybind pressed rejected: ${r}`:`Keybind pressed accepted`,this.getKeybindToString(e))}if(r===`hold`&&t.down&&!this.activeKeybinds.has(n)){let r=t.down();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}`:``})`}},Dt=class extends Ie{renderInterface;globalCursorOverrideCount=new Set;globalMouseBlockCount=new Set;globalKeyboardBlockCount=new Set;keyInputBlocks={};constructor(e){super(`OverridesManager`),this.renderInterface=H.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)}};const Ot=x(Dt,`OGG_SIEGE`);var kt=he((exports,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`){let t={KEYDOWN:256,LBUTTONUP:514,MBUTTONUP:520,RBUTTONUP:517,XBUTTONUP:524,TOUCH:576};for(let n of Object.values(t))e.hookWindowMessage(n,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}}),At=_e(kt(),1);let Y=!1,X;function jt(e){let{init:t=!0}=e;if(Mt(e),D.getInstance().init(e.applicationId),Y)return X;function n(){Gt();let t=new Map,r=Pt(e.modules,t),i=Ft(),a=Lt(e.keybinds),o=Rt(),s=zt(),c=Vt(),l=Bt(),u=Ht();Nt(e),It(e,t),Y=!0,X={...r,...i,ads:c,keybinds:a,windows:o,input:s,cortex:l,hasAnyActiveProcesses:()=>V.getInstance().hasAnyActiveProcesses,init:n,log:u,initialized:Y}}return t?(n(),X):new Proxy({init:n},{get:(e,t)=>{if(t!==`init`&&!Y)throw Error(`overlayed was called before initialized: ${t}`);return t===`init`?e[t]:X[t]}})}global.OVERLAYED=new Proxy({},{get:()=>{throw Error(`function overlayed was not called`)}});function Mt(e){global.OVERLAYED={APPLICATION_ID:Ue(e.applicationId),APP_BUILD_CHANNEL:e.channel??`alpha`,APP_VERSION:e.version??v.getVersion(),PACKAGE_VERSION:`0.15.0`,FRONTEND_VERSION:`0.0.0`,sessionId:crypto.randomUUID(),electron:e.electron}}function Nt(e){let t=e.universal?[`*`]:e.modules.map(e=>e.key);W.getInstance().setSubscribedGames(t),G.getInstance().init(),W.getInstance().init(),V.getInstance().init(),R.getInstance().init();async function n(){let e=We(global.OVERLAYED.APPLICATION_ID).then(e=>e.data),t=B.generateUniqueIdentifier();D.getInstance().log(`userId`,t);let n={...await e,userId:t};return D.getInstance().log(`appInfo`,n),n}let r;global.OVERLAYED.electron.ipcMain.handle(`getAppInfo`,async()=>(r=r??n(),r)),U.getInstance().track(`start`,{}),v.on(`quit`,()=>{U.getInstance().track(`electron_quit`,{}),Z()}),process.on(`exit`,()=>{U.getInstance().track(`exit`,{}),Z()})}async function Z(){await U.getInstance().flush(),R.getInstance().destroy(),W.getInstance().destroy(),G.getInstance().destroy(),V.getInstance().destroy(),H.getInstance().getInterface(`OGG_SIEGE`).destroy(),k.getInstance().destroy(),S.getInstance().destroy()}function Pt(e,t){return e.reduce((e,n)=>{let r=n.key;return e[r]={on(e,n){let i=Q(r,e),a=t.get(i)??new Set;a.add(n),t.set(i,a)},onAny(e){let n=Q(r,`*`),i=t.get(n)??new Set;i.add(e),t.set(n,i)},off(e,n){let i=Q(r,e),a=t.get(i)??new Set;a.delete(n),t.set(i,a)},offAny(e){let n=Q(r,`*`),i=t.get(n)??new Set;i.delete(e),t.set(n,i)}},e},{})}function Ft(){let e=S.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]})}}}}function Q(e,t){return`${e}:${t}`}function It(e,t){let n=k.getInstance();function i(n){let i=wt(n);if(i instanceof r.errors){U.getInstance().track(`invalid_game_event`,{}),S.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:i.summary});return}let a=e.modules.find(e=>e.key===i.game),o=a?.events.event;if(!o)return;let s=o(n);if(s instanceof r.errors){U.getInstance().track(`invalid_game_event`,{game:i.game,type:i.type}),S.getInstance().warn(`Invalid event`,`INVALID_EVENT`,{summary:s.summary});return}U.getInstance().track(`game_event`,{game:i.game,type:s.type});let c=Q(a.key,s.type),l=Q(a.key,`*`),u=t.get(c),d=t.get(l),f=[...Array.from(u??[]),...Array.from(d??[])];f.length!==0&&f.forEach(e=>{e(s)})}return n.on(`data`,e=>e.forEach(i)),n.on(`error`,e=>{S.getInstance().error(`Pipe server error`,`PIPE_SERVER_ERROR`,{error:e})}),n}function Lt(e){let t=new Et(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(),v.on(`quit`,()=>{t.destroy()}),r}function Rt(){function e(e,t){return e.once(`closed`,()=>{U.getInstance().track(`window_closed`,{url:e.webContents.getURL(),in_game:t})}),e.on(`unresponsive`,()=>{U.getInstance().track(`window_unresponsive`,{url:e.webContents.getURL(),in_game:t})}),U.getInstance().track(`window_created`,{url:e.webContents.getURL(),in_game:t}),e}return{createWindow:t=>e(new global.OVERLAYED.electron.BrowserWindow(t),!1),createInGameWindow:t=>e($().instance.newWindowInternal(global.OVERLAYED.electron.BrowserWindow,t),!0),on:(e,t)=>$().instance.on(e,t),off:(e,t)=>$().instance.off(e,t),once:(e,t)=>$().instance.once(e,t),addListener:(e,t)=>$().instance.addListener(e,t),removeListener:(e,t)=>$().instance.removeListener(e,t),removeAllListeners:()=>$().instance.removeAllListeners(),prependListener:(e,t)=>$().instance.prependListener(e,t),prependOnceListener:(e,t)=>$().instance.prependOnceListener(e,t),getActiveGameInfo:()=>{let e=$(),t=k.getInstance();return{resolution:e.resolution,isConnected:t.hasConnection}}}}function zt(){return{scope:e=>Ot.getInstance().scope(e),raw:{setGlobalMouseBlock:e=>$().instance.setGlobalMouseBlock(e),setGlobalKeyboardBlock:e=>$().instance.setGlobalKeyboardBlock(e),setGlobalCursorOverride:e=>$().instance.setGlobalCursorOverride(e),setKeyInputBlock:(e,t)=>$().instance.setKeyInputBlock(e,t),getGlobalMouseBlock:()=>$().instance.getGlobalMouseBlock(),getGlobalKeyboardBlock:()=>$().instance.getGlobalKeyboardBlock(),getGlobalCursorOverride:()=>$().instance.getGlobalCursorOverride(),getKeyInputBlock:e=>$().instance.getKeyInputBlock(e)}}}function Bt(){return{track:(e,t)=>U.getInstance().track(`custom__${e}`,t)}}function Vt(){return{registerWindow:e=>{(0,At.setupRevUtils)(e,global.OVERLAYED.electron)}}}function Ht(){let e=new E(`app.log`);return e.init(global.OVERLAYED.APPLICATION_ID),{scope:t=>e.scope(t),info:t=>e.info(t),warn:t=>e.warn(t),error:t=>e.error(t),submitBugReport:async(e,t)=>{U.getInstance().track(`bug_report_submitted`,{version:e.version,category:e.category});try{let n=Ut(t),r=await n.generateAsync({type:`base64`}),i=await Wt(e,r);return i?[void 0,{message:`Failed to submit bug report`,error:i}]:[!0,void 0]}catch(e){return[void 0,{message:`Failed to generate logs zip`,error:e}]}}}}function Ut(e){let t=T(global.OVERLAYED.APPLICATION_ID),n=O(t),r=Ce(),i=O(r);D.getInstance().info(`Logs path: `,t),D.getInstance().info(`Overlayed logs path: `,r);let a=new _;return[...n,...i].forEach(([e,t])=>{D.getInstance().info(`Zipping: `,e,t);let n=`${e}/${t}`,r=re(n);a.file(t,r,{compression:`DEFLATE`})}),Object.entries(e?.additionalFiles??{}).forEach(([e,t])=>{D.getInstance().info(`Zipping extra file: `,e),a.file(e,t,{compression:`DEFLATE`})}),a}async function Wt(e,t){let n={...e,version:`${global.OVERLAYED.APP_VERSION}@${global.OVERLAYED.APP_BUILD_CHANNEL}`,log_zip:`data:application/zip;base64,${t}`},r;return await fetch(`https://api.stats.cc/v1/overlay/contact`,{method:`POST`,body:JSON.stringify(n),redirect:`follow`,headers:{"Content-Type":`application/json`}}).then(async e=>{e.status>=300&&(r=await e.text())}).catch(e=>{r=e.message}),r}function Gt(){U.getInstance().meta={app_id:global.OVERLAYED.APPLICATION_ID,user_id:B.generateUniqueIdentifier(),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,session_id:global.OVERLAYED.sessionId},S.getInstance().on(`fatal`,e=>{U.getInstance().track(`fatal`,{message:e.message,code:e.code,data:e.data})}),S.getInstance().on(`error`,e=>{U.getInstance().track(`error`,{message:e.message,code:e.code,data:e.data})}),S.getInstance().on(`warning`,e=>{U.getInstance().track(`warning`,{message:e.message,code:e.code,data:e.data})})}function $(){return H.getInstance().getInterface(`OGG_SIEGE`)}export{Te as defineConfig,jt as overlayed,nt as setFetchLatestTokenCallback,Re as setUpdaterTokenResolver};
package/dist/siege.d.ts CHANGED
@@ -1321,6 +1321,7 @@ declare const TranslationSchema: <T extends AnyBrand | number = number>() => Typ
1321
1321
  id: T;
1322
1322
  value: string;
1323
1323
  }>;
1324
+ type Translation<T extends AnyBrand | number = number> = ReturnType<typeof TranslationSchema<T>>["infer"];
1324
1325
  declare const PlayerMatchStatsDataSchema: arktype_internal_methods_object_ts0.ObjectType<{
1325
1326
  kills: number;
1326
1327
  deaths: number;
@@ -2627,4 +2628,4 @@ type SiegeEventType = SiegeEvent["type"];
2627
2628
 
2628
2629
  //#endregion
2629
2630
  //#endregion
2630
- export { BaseEvent, type DefuserDroppedEvent, type DefuserPickedUpEvent, type DefuserPlantedEvent, type DefuserSabotagedEvent, type LocalPlayerEvent, type MapChangedEvent, MapData, MapDataSchema, type MatchEndedEvent, MatchRoundData, MatchRoundDataSchema, type MatchStartedEvent, type ModuleLoadedEvent, type ModuleUnloadedEvent, type OperatorBannedEvent, type PhaseChangedEvent, PlayerDamageData, PlayerDamageDataSchema, type PlayerDiedEvent, type PlayerDownedEvent, type PlayerJoinedEvent, type PlayerLeftEvent, type PlayerLifeStateChangedEvent, type PlayerLocationChangedEvent, PlayerMatchStatsData, PlayerMatchStatsDataSchema, type PlayerOperatorChangedEvent, type PlayerPingIdChangedEvent, type PlayerPingUpdatedEvent, type PlayerSideChangedEvent, type PlayerStatsChangedEvent, type PlayerTeamChangedEvent, RoundEndData, RoundEndDataSchema, RoundEndPlayerData, RoundEndPlayerDataSchema, type RoundEndedEvent, SIEGE_BOT_ID, SIEGE_DAMAGE_TEAM_TYPES, SIEGE_DAMAGE_TYPES, SIEGE_GAME_MODE_PHASES, SIEGE_GAME_MODE_TYPES_TO_ID, SIEGE_GAME_MODE_TYPE_LABELS, SIEGE_MAP_LABELS, SIEGE_MAP_TO_ID, SIEGE_OPERATOR_LABELS, SIEGE_OPERATOR_META, SIEGE_OPERATOR_TO_ID, SIEGE_PLAYER_LIFE_STATES, SIEGE_ROUND_STATES_TO_ID, SIEGE_ROUND_STATE_LABELS, SIEGE_SIDES, SIEGE_SIDE_OPERATORS, SIEGE_TEAMS, SiegeDamageTeamType, SiegeDamageTeamTypeSchema, SiegeDamageType, SiegeDamageTypeSchema, SiegeEvent, SiegeEventType, SiegeGameModePhase, SiegeGameModePhaseSchema, SiegeGameModeTypeNameId, SiegeItemObjectId, SiegeMapNameId, SiegeMatchId, SiegeOperatorMeta, SiegeOperatorMetaFull, SiegeOperatorNameId, SiegePlayerId, SiegePlayerLifeState, SiegePlayerLifeStateSchema, SiegeProfileId, SiegeRoundState, SiegeSide, SiegeSideSchema, SiegeTeam, SiegeTeamSchema, type StartedQueuingEvent, type StoppedQueueingEvent, TranslationSchema, type UnsupportedGameVersionEvent, events, isSiegeRoundStateCompleted, isSiegeRoundStateVictory, module };
2631
+ export { BaseEvent, type DefuserDroppedEvent, type DefuserPickedUpEvent, type DefuserPlantedEvent, type DefuserSabotagedEvent, type LocalPlayerEvent, type MapChangedEvent, MapData, MapDataSchema, type MatchEndedEvent, MatchRoundData, MatchRoundDataSchema, type MatchStartedEvent, type ModuleLoadedEvent, type ModuleUnloadedEvent, type OperatorBannedEvent, type PhaseChangedEvent, PlayerDamageData, PlayerDamageDataSchema, type PlayerDiedEvent, type PlayerDownedEvent, type PlayerJoinedEvent, type PlayerLeftEvent, type PlayerLifeStateChangedEvent, type PlayerLocationChangedEvent, PlayerMatchStatsData, PlayerMatchStatsDataSchema, type PlayerOperatorChangedEvent, type PlayerPingIdChangedEvent, type PlayerPingUpdatedEvent, type PlayerSideChangedEvent, type PlayerStatsChangedEvent, type PlayerTeamChangedEvent, RoundEndData, RoundEndDataSchema, RoundEndPlayerData, RoundEndPlayerDataSchema, type RoundEndedEvent, SIEGE_BOT_ID, SIEGE_DAMAGE_TEAM_TYPES, SIEGE_DAMAGE_TYPES, SIEGE_GAME_MODE_PHASES, SIEGE_GAME_MODE_TYPES_TO_ID, SIEGE_GAME_MODE_TYPE_LABELS, SIEGE_MAP_LABELS, SIEGE_MAP_TO_ID, SIEGE_OPERATOR_LABELS, SIEGE_OPERATOR_META, SIEGE_OPERATOR_TO_ID, SIEGE_PLAYER_LIFE_STATES, SIEGE_ROUND_STATES_TO_ID, SIEGE_ROUND_STATE_LABELS, SIEGE_SIDES, SIEGE_SIDE_OPERATORS, SIEGE_TEAMS, SiegeDamageTeamType, SiegeDamageTeamTypeSchema, SiegeDamageType, SiegeDamageTypeSchema, SiegeEvent, SiegeEventType, SiegeGameModePhase, SiegeGameModePhaseSchema, SiegeGameModeTypeNameId, SiegeItemObjectId, SiegeMapNameId, SiegeMatchId, SiegeOperatorMeta, SiegeOperatorMetaFull, SiegeOperatorNameId, SiegePlayerId, SiegePlayerLifeState, SiegePlayerLifeStateSchema, SiegeProfileId, SiegeRoundState, SiegeSide, SiegeSideSchema, SiegeTeam, SiegeTeamSchema, type StartedQueuingEvent, type StoppedQueueingEvent, Translation, TranslationSchema, type UnsupportedGameVersionEvent, events, isSiegeRoundStateCompleted, isSiegeRoundStateVictory, module };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@overlayed/app",
3
3
  "author": "overlayed.gg",
4
4
  "homepage": "https://overlayed.gg",
5
- "version": "0.14.1",
5
+ "version": "0.15.0",
6
6
  "description": "Overlayed app",
7
7
  "license": "SEE LICENSE IN LICENSE.md",
8
8
  "repository": {