fiverunner 1.2.2 → 1.3.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.
@@ -6,7 +6,7 @@ ${this._constructorStack}
6
6
  Lifetime used`):new Ht(`Lifetime not alive`)}},un=class extends ln{constructor(e,t){super(e,void 0,void 0,t)}get dupable(){return!0}dup(){return this}dispose(){}},dn=class extends ln{constructor(e,t,n,r){super(e,t,n,r)}dispose(){this._alive=!1}};function fn(e,t){let n;try{e.dispose()}catch(e){n=e}if(t&&n)throw Object.assign(t,{message:`${t.message}
7
7
  Then, failed to dispose scope: ${n.message}`,disposeError:n}),t;if(t||n)throw t||n}var pn=class e extends on{constructor(){super(...arguments),this._disposables=new ln(/* @__PURE__ */ new Set),this.manage=e=>(this._disposables.value.add(e),e)}static withScope(t){let n=new e,r;try{return t(n)}catch(e){throw r=e,e}finally{fn(n,r)}}static withScopeMaybeAsync(t,n){return rn(void 0,function*(r){let i=new e,a;try{return yield*r.of(n.call(t,r,i))}catch(e){throw a=e,e}finally{fn(i,a)}})}static async withScopeAsync(t){let n=new e,r;try{return await t(n)}catch(e){throw r=e,e}finally{fn(n,r)}}get alive(){return this._disposables.alive}dispose(){let e=Array.from(this._disposables.value.values()).reverse();for(let t of e)t.alive&&t.dispose();this._disposables.dispose()}};function mn(e){let t=e?Array.from(e):[];function n(){return t.forEach(e=>e.alive?e.dispose():void 0)}function r(){return t.some(e=>e.alive)}return Object.defineProperty(t,sn,{configurable:!0,enumerable:!1,value:n}),Object.defineProperty(t,"dispose",{configurable:!0,enumerable:!1,value:n}),Object.defineProperty(t,"alive",{configurable:!0,enumerable:!1,get:r}),t}function hn(e){return!!(e&&(typeof e==`object`||typeof e==`function`)&&`alive`in e&&typeof e.alive==`boolean`&&`dispose`in e&&typeof e.dispose==`function`)}var gn=class e extends on{static success(e){return new _n(e)}static fail(e,t){return new vn(e,t)}static is(t){return t instanceof e}},_n=class extends gn{constructor(e){super(),this.value=e}get alive(){return!hn(this.value)||this.value.alive}dispose(){hn(this.value)&&this.value.dispose()}unwrap(){return this.value}unwrapOr(e){return this.value}},vn=class extends gn{constructor(e,t){super(),this.error=e,this.onUnwrap=t}get alive(){return!hn(this.error)||this.error.alive}dispose(){hn(this.error)&&this.error.dispose()}unwrap(){throw this.onUnwrap(this),this.error}unwrapOr(e){return e}},yn=gn,bn=class extends on{constructor(e){super(),this.resolve=e=>{this.resolveHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.resolveHandle,this.context.undefined,e||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.reject=e=>{this.rejectHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.rejectHandle,this.context.undefined,e||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.dispose=()=>{this.handle.alive&&this.handle.dispose(),this.disposeResolvers()},this.context=e.context,this.owner=e.context.runtime,this.handle=e.promiseHandle,this.settled=new Promise(e=>{this.onSettled=e}),this.resolveHandle=e.resolveHandle,this.rejectHandle=e.rejectHandle}get alive(){return this.handle.alive||this.resolveHandle.alive||this.rejectHandle.alive}disposeResolvers(){this.resolveHandle.alive&&this.resolveHandle.dispose(),this.rejectHandle.alive&&this.rejectHandle.dispose()}},xn=class{constructor(e){this.module=e}toPointerArray(e){let t=new Int32Array(e.map(e=>e.value)),n=t.length*t.BYTES_PER_ELEMENT,r=this.module._malloc(n);return new Uint8Array(this.module.HEAPU8.buffer,r,n).set(new Uint8Array(t.buffer)),new ln(r,void 0,e=>this.module._free(e))}newTypedArray(e,t){let n=new e(Array(t).fill(0)),r=n.length*n.BYTES_PER_ELEMENT,i=this.module._malloc(r),a=new e(this.module.HEAPU8.buffer,i,t);return a.set(n),new ln({typedArray:a,ptr:i},void 0,e=>this.module._free(e.ptr))}newMutablePointerArray(e){return this.newTypedArray(Int32Array,e)}newHeapCharPointer(e){let t=this.module.lengthBytesUTF8(e),n=t+1,r=this.module._malloc(n);return this.module.stringToUTF8(e,r,n),new ln({ptr:r,strlen:t},void 0,e=>this.module._free(e.ptr))}newHeapBufferPointer(e){let t=e.byteLength,n=this.module._malloc(t);return this.module.HEAPU8.set(e,n),new ln({pointer:n,numBytes:t},void 0,e=>this.module._free(e.pointer))}consumeHeapCharPointer(e){let t=this.module.UTF8ToString(e);return this.module._free(e),t}};Object.freeze({BaseObjects:!0,Date:!0,Eval:!0,StringNormalize:!0,RegExp:!0,JSON:!0,Proxy:!0,MapSet:!0,TypedArrays:!0,Promise:!0});function Sn(e){if(!e)return 0;let t=0;for(let[n,r]of Object.entries(e)){if(!(n in Ft))throw new Jt(n);r&&(t|=Ft[n])}return t}function Cn(e){if(typeof e==`number`)return e;if(e===void 0)return 0;let{type:t,strict:n,strip:r,compileOnly:i,backtraceBarrier:a}=e,o=0;return t===`global`&&(o|=Pt.JS_EVAL_TYPE_GLOBAL),t===`module`&&(o|=Pt.JS_EVAL_TYPE_MODULE),n&&(o|=Pt.JS_EVAL_FLAG_STRICT),r&&(o|=Pt.JS_EVAL_FLAG_STRIP),i&&(o|=Pt.JS_EVAL_FLAG_COMPILE_ONLY),a&&(o|=Pt.JS_EVAL_FLAG_BACKTRACE_BARRIER),o}function wn(e){if(typeof e==`number`)return e;if(e===void 0)return 0;let{strings:t,symbols:n,quickjsPrivate:r,onlyEnumerable:i,numbers:a,numbersAsStrings:o}=e,s=0;return t&&(s|=Lt.JS_GPN_STRING_MASK),n&&(s|=Lt.JS_GPN_SYMBOL_MASK),r&&(s|=Lt.JS_GPN_PRIVATE_MASK),i&&(s|=Lt.JS_GPN_ENUM_ONLY),a&&(s|=Lt.QTS_GPN_NUMBER_MASK),o&&(s|=Lt.QTS_STANDARD_COMPLIANT_NUMBER),s}function Tn(...e){let t=[];for(let n of e)n!==void 0&&(t=t.concat(n));return t}var En=class extends on{constructor(e,t){super(),this.handle=e,this.context=t,this._isDone=!1,this.owner=t.runtime}[Symbol.iterator](){return this}next(e){if(!this.alive||this._isDone)return{done:!0,value:void 0};let t=this._next??=this.context.getProp(this.handle,`next`);return this.callIteratorMethod(t,e)}return(e){if(!this.alive)return{done:!0,value:void 0};let t=this.context.getProp(this.handle,`return`);if(t===this.context.undefined&&e===void 0)return this.dispose(),{done:!0,value:void 0};let n=this.callIteratorMethod(t,e);return t.dispose(),this.dispose(),n}throw(e){if(!this.alive)return{done:!0,value:void 0};let t=e instanceof ln?e:this.context.newError(e),n=this.context.getProp(this.handle,`throw`),r=this.callIteratorMethod(n,e);return t.alive&&t.dispose(),n.dispose(),this.dispose(),r}get alive(){return this.handle.alive}dispose(){this._isDone=!0,this.handle.dispose(),this._next?.dispose()}callIteratorMethod(e,t){let n=t?this.context.callFunction(e,this.handle,t):this.context.callFunction(e,this.handle);if(n.error)return this.dispose(),{value:n};let r=this.context.getProp(n.value,`done`).consume(e=>this.context.dump(e)),i=this.context.getProp(n.value,`value`);return n.value.dispose(),r&&this.dispose(),{value:yn.success(i),done:r}}},Dn=-2147483648,On=2147483647,kn=0;function An(e){return e>>8}var jn=class{constructor(){this.nextId=Dn,this.freelist=[],this.groups=/* @__PURE__ */ new Map}put(e){let t=this.allocateId(),n=An(t),r=this.groups.get(n);return r||(r=/* @__PURE__ */ new Map,this.groups.set(n,r)),r.set(t,e),t}get(e){if(e===kn)throw new Qt(`no host reference id defined`);let t=An(e),n=this.groups.get(t);if(!n)throw new Qt(`host reference id ${e} is not defined`);let r=n.get(e);if(!r)throw new Qt(`host reference id ${e} is not defined`);return r}delete(e){if(e===kn)throw new Qt(`no host reference id defined`);let t=An(e),n=this.groups.get(t);if(!n)throw new Qt(`host reference id ${e} is not defined`);n.delete(e),n.size===0&&this.groups.delete(t),this.freelist.push(e)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===kn&&this.nextId++,this.nextId>On)throw new Zt(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${On-Dn}`);return this.nextId++}},Mn=class extends on{constructor(e,t,n){if(n===kn)throw new Qt(`cannot create HostRef with undefined id`);super(),this.runtime=e,this.handle=t,this.id=n}get alive(){return this.handle.alive}dispose(){this.handle.dispose()}get value(){return this.runtime.hostRefs.get(this.id)}},Nn=class extends xn{constructor(e){super(e.module),this.scope=new pn,this.copyJSValue=e=>this.ffi.QTS_DupValuePointer(this.ctx.value,e),this.freeJSValue=e=>{this.ffi.QTS_FreeValuePointer(this.ctx.value,e)},e.ownedLifetimes?.forEach(e=>this.scope.manage(e)),this.owner=e.owner,this.module=e.module,this.ffi=e.ffi,this.rt=e.rt,this.ctx=this.scope.manage(e.ctx)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}[Symbol.dispose](){return this.dispose()}manage(e){return this.scope.manage(e)}consumeJSCharPointer(e){let t=this.module.UTF8ToString(e);return this.ffi.QTS_FreeCString(this.ctx.value,e),t}heapValueHandle(e,t){let n=t?e=>{t(),this.freeJSValue(e)}:this.freeJSValue;return new ln(e,this.copyJSValue,n,this.owner)}staticHeapValueHandle(e){return this.manage(this.heapValueHandle(e)),new un(e,this.owner)}},Pn=class extends on{constructor(e){super(),this._undefined=void 0,this._null=void 0,this._false=void 0,this._true=void 0,this._global=void 0,this._BigInt=void 0,this._Symbol=void 0,this._SymbolIterator=void 0,this._SymbolAsyncIterator=void 0,this.cToHostCallbacks={callFunction:(e,t,n,r,i)=>{if(e!==this.ctx.value)throw Error(`QuickJSContext instance received C -> JS call with mismatched ctx`);let a=this.getFunction(i);return pn.withScopeMaybeAsync(this,function*(e,i){let o=i.manage(new dn(t,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime)),s=Array(n);for(let e=0;e<n;e++){let t=this.ffi.QTS_ArgvGetJSValueConstPointer(r,e);s[e]=i.manage(new dn(t,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime))}try{let t=yield*e(a.apply(o,s));if(t){if(`error`in t&&t.error)throw this.runtime.debugLog(`throw error`,t.error),t.error;let e=i.manage(t instanceof ln?t:t.value);return this.ffi.QTS_DupValuePointer(this.ctx.value,e.value)}return 0}catch(e){return this.errorToHandle(e).consume(e=>this.ffi.QTS_Throw(this.ctx.value,e.value))}})}},this.runtime=e.runtime,this.module=e.module,this.ffi=e.ffi,this.rt=e.rt,this.ctx=e.ctx,this.memory=new Nn({...e,owner:this.runtime}),e.callbacks.setContextCallbacks(this.ctx.value,this.cToHostCallbacks),this.dump=this.dump.bind(this),this.getString=this.getString.bind(this),this.getNumber=this.getNumber.bind(this),this.resolvePromise=this.resolvePromise.bind(this),this.uint32Out=this.memory.manage(this.memory.newTypedArray(Uint32Array,1))}get alive(){return this.memory.alive}dispose(){this.memory.dispose()}get undefined(){if(this._undefined)return this._undefined;let e=this.ffi.QTS_GetUndefined();return this._undefined=new un(e)}get null(){if(this._null)return this._null;let e=this.ffi.QTS_GetNull();return this._null=new un(e)}get true(){if(this._true)return this._true;let e=this.ffi.QTS_GetTrue();return this._true=new un(e)}get false(){if(this._false)return this._false;let e=this.ffi.QTS_GetFalse();return this._false=new un(e)}get global(){if(this._global)return this._global;let e=this.ffi.QTS_GetGlobalObject(this.ctx.value);return this._global=this.memory.staticHeapValueHandle(e),this._global}newNumber(e){return this.memory.heapValueHandle(this.ffi.QTS_NewFloat64(this.ctx.value,e))}newString(e){let t=this.memory.newHeapCharPointer(e).consume(e=>this.ffi.QTS_NewString(this.ctx.value,e.value.ptr));return this.memory.heapValueHandle(t)}newUniqueSymbol(e){let t=(typeof e==`symbol`?e.description:e)??``,n=this.memory.newHeapCharPointer(t).consume(e=>this.ffi.QTS_NewSymbol(this.ctx.value,e.value.ptr,0));return this.memory.heapValueHandle(n)}newSymbolFor(e){let t=(typeof e==`symbol`?e.description:e)??``,n=this.memory.newHeapCharPointer(t).consume(e=>this.ffi.QTS_NewSymbol(this.ctx.value,e.value.ptr,1));return this.memory.heapValueHandle(n)}getWellKnownSymbol(e){return this._Symbol??=this.memory.manage(this.getProp(this.global,`Symbol`)),this.getProp(this._Symbol,e)}newBigInt(e){if(!this._BigInt){let e=this.getProp(this.global,`BigInt`);this.memory.manage(e),this._BigInt=new un(e.value,this.runtime)}let t=this._BigInt,n=String(e);return this.newString(n).consume(e=>this.unwrapResult(this.callFunction(t,this.undefined,e)))}newObject(e){e&&this.runtime.assertOwned(e);let t=e?this.ffi.QTS_NewObjectProto(this.ctx.value,e.value):this.ffi.QTS_NewObject(this.ctx.value);return this.memory.heapValueHandle(t)}newArray(){let e=this.ffi.QTS_NewArray(this.ctx.value);return this.memory.heapValueHandle(e)}newArrayBuffer(e){let t=new Uint8Array(e),n=this.memory.newHeapBufferPointer(t),r=this.ffi.QTS_NewArrayBuffer(this.ctx.value,n.value.pointer,t.length);return this.memory.heapValueHandle(r)}newPromise(e){let t=pn.withScope(e=>{let t=e.manage(this.memory.newMutablePointerArray(2)),n=this.ffi.QTS_NewPromiseCapability(this.ctx.value,t.value.ptr),r=this.memory.heapValueHandle(n),[i,a]=Array.from(t.value.typedArray).map(e=>this.memory.heapValueHandle(e));return new bn({context:this,promiseHandle:r,resolveHandle:i,rejectHandle:a})});return e&&typeof e==`function`&&(e=new Promise(e)),e&&Promise.resolve(e).then(t.resolve,e=>e instanceof ln?t.reject(e):this.newError(e).consume(t.reject)),t}newFunction(e,t){let n=typeof e==`function`?e:t;if(!n)throw TypeError(`Expected a function`);return this.newFunctionWithOptions({name:typeof e==`string`?e:void 0,length:n.length,isConstructor:!1,fn:n})}newConstructorFunction(e,t){let n=typeof e==`function`?e:t;if(!n)throw TypeError(`Expected a function`);return this.newFunctionWithOptions({name:typeof e==`string`?e:void 0,length:n.length,isConstructor:!0,fn:n})}newFunctionWithOptions(e){let{name:t,length:n,isConstructor:r,fn:i}=e,a=this.runtime.hostRefs.put(i);try{return this.memory.heapValueHandle(this.ffi.QTS_NewFunction(this.ctx.value,t??``,n,r,a))}catch(e){throw this.runtime.hostRefs.delete(a),e}}newError(e){let t=this.memory.heapValueHandle(this.ffi.QTS_NewError(this.ctx.value));return e&&typeof e==`object`?(e.name!==void 0&&this.newString(e.name).consume(e=>this.setProp(t,`name`,e)),e.message!==void 0&&this.newString(e.message).consume(e=>this.setProp(t,`message`,e))):typeof e==`string`?this.newString(e).consume(e=>this.setProp(t,`message`,e)):e!==void 0&&this.newString(String(e)).consume(e=>this.setProp(t,`message`,e)),t}newHostRef(e){let t=this.runtime.hostRefs.put(e);try{let e=this.memory.heapValueHandle(this.ffi.QTS_NewHostRef(this.ctx.value,t));return new Mn(this.runtime,e,t)}catch(e){throw this.runtime.hostRefs.delete(t),e}}toHostRef(e){let t=this.ffi.QTS_GetHostRefId(e.value);if(t!==0)return this.runtime.hostRefs.get(t),new Mn(this.runtime,e.dup(),t)}unwrapHostRef(e){let t=this.ffi.QTS_GetHostRefId(e.value);if(t===0)throw new Qt(`handle is not a HostRef`);return this.runtime.hostRefs.get(t)}typeof(e){return this.runtime.assertOwned(e),this.memory.consumeHeapCharPointer(this.ffi.QTS_Typeof(this.ctx.value,e.value))}getNumber(e){return this.runtime.assertOwned(e),this.ffi.QTS_GetFloat64(this.ctx.value,e.value)}getString(e){return this.runtime.assertOwned(e),this.memory.consumeJSCharPointer(this.ffi.QTS_GetString(this.ctx.value,e.value))}getSymbol(e){this.runtime.assertOwned(e);let t=this.memory.consumeJSCharPointer(this.ffi.QTS_GetSymbolDescriptionOrKey(this.ctx.value,e.value));return this.ffi.QTS_IsGlobalSymbol(this.ctx.value,e.value)?Symbol.for(t):Symbol(t)}getBigInt(e){this.runtime.assertOwned(e);let t=this.getString(e);return BigInt(t)}getArrayBuffer(e){this.runtime.assertOwned(e);let t=this.ffi.QTS_GetArrayBufferLength(this.ctx.value,e.value),n=this.ffi.QTS_GetArrayBuffer(this.ctx.value,e.value);if(!n)throw Error(`Couldn't allocate memory to get ArrayBuffer`);return new ln(this.module.HEAPU8.subarray(n,n+t),void 0,()=>this.module._free(n))}getPromiseState(e){this.runtime.assertOwned(e);let t=this.ffi.QTS_PromiseState(this.ctx.value,e.value);if(t<0)return{type:`fulfilled`,value:e,notAPromise:!0};if(t===It.Pending)return{type:`pending`,get error(){return new Yt(`Cannot unwrap a pending promise`)}};let n=this.ffi.QTS_PromiseResult(this.ctx.value,e.value),r=this.memory.heapValueHandle(n);if(t===It.Fulfilled)return{type:`fulfilled`,value:r};if(t===It.Rejected)return{type:`rejected`,error:r};throw r.dispose(),/* @__PURE__ */ Error(`Unknown JSPromiseStateEnum: ${t}`)}resolvePromise(e){this.runtime.assertOwned(e);let t=pn.withScope(t=>{let n=t.manage(this.getProp(this.global,`Promise`)),r=t.manage(this.getProp(n,`resolve`));return this.callFunction(r,n,e)});return t.error?Promise.resolve(t):new Promise(e=>{pn.withScope(n=>{let r=n.manage(this.newFunction(`resolve`,t=>{e(this.success(t&&t.dup()))})),i=n.manage(this.newFunction(`reject`,t=>{e(this.fail(t&&t.dup()))})),a=n.manage(t.value),o=n.manage(this.getProp(a,`then`));this.callFunction(o,a,r,i).unwrap().dispose()})})}isEqual(e,t,n=Rt.IsStrictlyEqual){if(e===t)return!0;this.runtime.assertOwned(e),this.runtime.assertOwned(t);let r=this.ffi.QTS_IsEqual(this.ctx.value,e.value,t.value,n);if(r===-1)throw new Ut(`WASM variant does not expose equality`);return!!r}eq(e,t){return this.isEqual(e,t,Rt.IsStrictlyEqual)}sameValue(e,t){return this.isEqual(e,t,Rt.IsSameValue)}sameValueZero(e,t){return this.isEqual(e,t,Rt.IsSameValueZero)}getProp(e,t){this.runtime.assertOwned(e);let n;return n=typeof t==`number`&&t>=0?this.ffi.QTS_GetPropNumber(this.ctx.value,e.value,t):this.borrowPropertyKey(t).consume(t=>this.ffi.QTS_GetProp(this.ctx.value,e.value,t.value)),this.memory.heapValueHandle(n)}getLength(e){if(this.runtime.assertOwned(e),!(this.ffi.QTS_GetLength(this.ctx.value,this.uint32Out.value.ptr,e.value)<0))return this.uint32Out.value.typedArray[0]}getOwnPropertyNames(e,t={strings:!0,numbersAsStrings:!0}){this.runtime.assertOwned(e),e.value;let n=wn(t);if(n===0)throw new Xt(`No options set, will return an empty array`);return pn.withScope(t=>{let r=t.manage(this.memory.newMutablePointerArray(1)),i=this.ffi.QTS_GetOwnPropertyNames(this.ctx.value,r.value.ptr,this.uint32Out.value.ptr,e.value,n);if(i)return this.fail(this.memory.heapValueHandle(i));let a=this.uint32Out.value.typedArray[0],o=r.value.typedArray[0],s=new Uint32Array(this.module.HEAP8.buffer,o,a),c=Array.from(s).map(e=>this.memory.heapValueHandle(e));return this.ffi.QTS_FreeVoidPointer(this.ctx.value,o),this.success(mn(c))})}getIterator(e){let t=this._SymbolIterator??=this.memory.manage(this.getWellKnownSymbol(`iterator`));return pn.withScope(n=>{let r=n.manage(this.getProp(e,t)),i=this.callFunction(r,e);return i.error?i:this.success(new En(i.value,this))})}setProp(e,t,n){this.runtime.assertOwned(e),this.borrowPropertyKey(t).consume(t=>this.ffi.QTS_SetProp(this.ctx.value,e.value,t.value,n.value))}defineProp(e,t,n){this.runtime.assertOwned(e),pn.withScope(r=>{let i=r.manage(this.borrowPropertyKey(t)),a=n.value||this.undefined,o=!!n.configurable,s=!!n.enumerable,c=!!n.value,l=n.get?r.manage(this.newFunction(n.get.name,n.get)):this.undefined,u=n.set?r.manage(this.newFunction(n.set.name,n.set)):this.undefined;this.ffi.QTS_DefineProp(this.ctx.value,e.value,i.value,a.value,l.value,u.value,o,s,c)})}callFunction(e,t,...n){this.runtime.assertOwned(e);let r,i=n[0];r=i===void 0||Array.isArray(i)?i??[]:n;let a=this.memory.toPointerArray(r).consume(n=>this.ffi.QTS_Call(this.ctx.value,e.value,t.value,r.length,n.value)),o=this.ffi.QTS_ResolveException(this.ctx.value,a);return o?(this.ffi.QTS_FreeValuePointer(this.ctx.value,a),this.fail(this.memory.heapValueHandle(o))):this.success(this.memory.heapValueHandle(a))}callMethod(e,t,n=[]){return this.getProp(e,t).consume(t=>this.callFunction(t,e,n))}evalCode(e,t=`eval.js`,n){let r=+(n===void 0),i=Cn(n),a=this.memory.newHeapCharPointer(e).consume(e=>this.ffi.QTS_Eval(this.ctx.value,e.value.ptr,e.value.strlen,t,r,i)),o=this.ffi.QTS_ResolveException(this.ctx.value,a);return o?(this.ffi.QTS_FreeValuePointer(this.ctx.value,a),this.fail(this.memory.heapValueHandle(o))):this.success(this.memory.heapValueHandle(a))}throw(e){return this.errorToHandle(e).consume(e=>this.ffi.QTS_Throw(this.ctx.value,e.value))}borrowPropertyKey(e){return typeof e==`number`?this.newNumber(e):typeof e==`string`?this.newString(e):new un(e.value,this.runtime)}getMemory(e){if(e===this.rt.value)return this.memory;throw Error(`Private API. Cannot get memory from a different runtime`)}dump(e){this.runtime.assertOwned(e);let t=this.typeof(e);if(t===`string`)return this.getString(e);if(t===`number`)return this.getNumber(e);if(t===`bigint`)return this.getBigInt(e);if(t===`undefined`)return;if(t===`symbol`)return this.getSymbol(e);let n=this.getPromiseState(e);if(n.type===`fulfilled`&&!n.notAPromise)return e.dispose(),{type:n.type,value:n.value.consume(this.dump)};if(n.type===`pending`)return e.dispose(),{type:n.type};if(n.type===`rejected`)return e.dispose(),{type:n.type,error:n.error.consume(this.dump)};let r=this.memory.consumeJSCharPointer(this.ffi.QTS_Dump(this.ctx.value,e.value));try{return JSON.parse(r)}catch{return r}}unwrapResult(e){if(e.error){let t=`context`in e.error?e.error.context:this,n=e.error.consume(e=>this.dump(e));if(n&&typeof n==`object`&&typeof n.message==`string`){let{message:e,name:r,stack:i,...a}=n,o=new Bt(n,t);typeof r==`string`&&(o.name=n.name),o.message=e;let s=o.stack;throw typeof i==`string`&&(o.stack=`${r}: ${e}
8
8
  ${n.stack}Host: ${s}`),Object.assign(o,a),o}throw new Bt(n)}return e.value}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.alive?`${this.constructor.name} { ctx: ${this.ctx.value} rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getFunction(e){let t=this.runtime.hostRefs.get(e);if(typeof t!=`function`)throw Error(`Host reference ${e} is not a function`);return t}errorToHandle(e){return e instanceof ln?e:this.newError(e)}encodeBinaryJSON(e){let t=this.ffi.QTS_bjson_encode(this.ctx.value,e.value);return this.memory.heapValueHandle(t)}decodeBinaryJSON(e){let t=this.ffi.QTS_bjson_decode(this.ctx.value,e.value);return this.memory.heapValueHandle(t)}success(e){return yn.success(e)}fail(e){return yn.fail(e,e=>this.unwrapResult(e))}},Fn=class extends on{constructor(e){super(),this.scope=new pn,this.contextMap=/* @__PURE__ */ new Map,this.hostRefs=new jn,this._debugMode=!1,this.cToHostCallbacks={freeHostRef:(e,t)=>{if(e!==this.rt.value)throw Error(`Runtime pointer mismatch`);this.hostRefs.delete(t)},shouldInterrupt:e=>{if(e!==this.rt.value)throw Error(`QuickJSContext instance received C -> JS interrupt with mismatched rt`);let t=this.interruptHandler;if(!t)throw Error(`QuickJSContext had no interrupt handler`);return+!!t(this)},loadModuleSource:nn(this,function*(e,t,n,r){let i=this.moduleLoader;if(!i)throw Error(`Runtime has no module loader`);if(t!==this.rt.value)throw Error(`Runtime pointer mismatch`);let a=this.contextMap.get(n)??this.newContext({contextPointer:n});try{let t=yield*e(i(r,a));if(typeof t==`object`&&`error`in t&&t.error)throw this.debugLog(`cToHostLoadModule: loader returned error`,t.error),t.error;let n=typeof t==`string`?t:`value`in t?t.value:t;return this.memory.newHeapCharPointer(n).value.ptr}catch(e){return this.debugLog(`cToHostLoadModule: caught error`,e),a.throw(e),0}}),normalizeModule:nn(this,function*(e,t,n,r,i){let a=this.moduleNormalizer;if(!a)throw Error(`Runtime has no module normalizer`);if(t!==this.rt.value)throw Error(`Runtime pointer mismatch`);let o=this.contextMap.get(n)??this.newContext({contextPointer:n});try{let t=yield*e(a(r,i,o));if(typeof t==`object`&&`error`in t&&t.error)throw this.debugLog(`cToHostNormalizeModule: normalizer returned error`,t.error),t.error;let n=typeof t==`string`?t:t.value;return o.getMemory(this.rt.value).newHeapCharPointer(n).value.ptr}catch(e){return this.debugLog(`normalizeModule: caught error`,e),o.throw(e),0}})},e.ownedLifetimes?.forEach(e=>this.scope.manage(e)),this.module=e.module,this.memory=new xn(this.module),this.ffi=e.ffi,this.rt=e.rt,this.callbacks=e.callbacks,this.scope.manage(this.rt),this.callbacks.setRuntimeCallbacks(this.rt.value,this.cToHostCallbacks),this.executePendingJobs=this.executePendingJobs.bind(this)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}newContext(e={}){let t=Sn(e.intrinsics),n=new ln(e.contextPointer||this.ffi.QTS_NewContext(this.rt.value,t),void 0,e=>{this.contextMap.delete(e),this.callbacks.deleteContext(e),this.ffi.QTS_FreeContext(e)}),r=new Pn({module:this.module,ctx:n,ffi:this.ffi,rt:this.rt,ownedLifetimes:e.ownedLifetimes,runtime:this,callbacks:this.callbacks});return this.contextMap.set(n.value,r),r}setModuleLoader(e,t){this.moduleLoader=e,this.moduleNormalizer=t,this.ffi.QTS_RuntimeEnableModuleLoader(this.rt.value,+!!this.moduleNormalizer)}removeModuleLoader(){this.moduleLoader=void 0,this.ffi.QTS_RuntimeDisableModuleLoader(this.rt.value)}hasPendingJob(){return!!this.ffi.QTS_IsJobPending(this.rt.value)}setInterruptHandler(e){let t=this.interruptHandler;this.interruptHandler=e,t||this.ffi.QTS_RuntimeEnableInterruptHandler(this.rt.value)}removeInterruptHandler(){this.interruptHandler&&=(this.ffi.QTS_RuntimeDisableInterruptHandler(this.rt.value),void 0)}executePendingJobs(e=-1){let t=this.memory.newMutablePointerArray(1),n=this.ffi.QTS_ExecutePendingJob(this.rt.value,e??-1,t.value.ptr),r=t.value.typedArray[0];if(t.dispose(),r===0)return this.ffi.QTS_FreeValuePointerRuntime(this.rt.value,n),yn.success(0);let i=this.contextMap.get(r)??this.newContext({contextPointer:r}),a=i.getMemory(this.rt.value).heapValueHandle(n);if(i.typeof(a)===`number`){let e=i.getNumber(a);return a.dispose(),yn.success(e)}{let e=Object.assign(a,{context:i});return yn.fail(e,e=>i.unwrapResult(e))}}setMemoryLimit(e){if(e<0&&e!==-1)throw Error(`Cannot set memory limit to negative number. To unset, pass -1`);this.ffi.QTS_RuntimeSetMemoryLimit(this.rt.value,e)}computeMemoryUsage(){let e=this.getSystemContext().getMemory(this.rt.value);return e.heapValueHandle(this.ffi.QTS_RuntimeComputeMemoryUsage(this.rt.value,e.ctx.value))}dumpMemoryUsage(){return this.memory.consumeHeapCharPointer(this.ffi.QTS_RuntimeDumpMemoryUsage(this.rt.value))}setMaxStackSize(e){if(e<0)throw Error(`Cannot set memory limit to negative number. To unset, pass 0.`);this.ffi.QTS_RuntimeSetMaxStackSize(this.rt.value,e)}assertOwned(e){if(e.owner&&e.owner.rt!==this.rt)throw new Vt(`Handle is not owned by this runtime: ${e.owner.rt.value} != ${this.rt.value}`)}setDebugMode(e){this._debugMode=e,this.ffi.DEBUG&&this.rt.alive&&this.ffi.QTS_SetDebugLogEnabled(this.rt.value,+!!e)}isDebugMode(){return this._debugMode}debugLog(...e){this._debugMode&&console.log(`quickjs-emscripten:`,...e)}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.alive?`${this.constructor.name} { rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getSystemContext(){return this.context||=this.scope.manage(this.newContext()),this.context}},In=class{constructor(e){this.freeHostRef=e.freeHostRef,this.callFunction=e.callFunction,this.shouldInterrupt=e.shouldInterrupt,this.loadModuleSource=e.loadModuleSource,this.normalizeModule=e.normalizeModule}},Ln=class{constructor(e){this.contextCallbacks=/* @__PURE__ */ new Map,this.runtimeCallbacks=/* @__PURE__ */ new Map,this.suspendedCount=0,this.cToHostCallbacks=new In({freeHostRef:(e,t,n)=>{let r=this.runtimeCallbacks.get(t);if(!r)throw Error(`QuickJSRuntime(rt = ${t}) not found when trying to free HostRef(id = ${n})`);r.freeHostRef(t,n)},callFunction:(e,t,n,r,i,a)=>this.handleAsyncify(e,()=>{try{let e=this.contextCallbacks.get(t);if(!e)throw Error(`QuickJSContext(ctx = ${t}) not found for C function call "${a}"`);return e.callFunction(t,n,r,i,a)}catch(e){return console.error(`[C to host error: returning null]`,e),0}}),shouldInterrupt:(e,t)=>this.handleAsyncify(e,()=>{try{let e=this.runtimeCallbacks.get(t);if(!e)throw Error(`QuickJSRuntime(rt = ${t}) not found for C interrupt`);return e.shouldInterrupt(t)}catch(e){return console.error(`[C to host interrupt: returning error]`,e),1}}),loadModuleSource:(e,t,n,r)=>this.handleAsyncify(e,()=>{try{let e=this.runtimeCallbacks.get(t);if(!e)throw Error(`QuickJSRuntime(rt = ${t}) not found for C module loader`);let i=e.loadModuleSource;if(!i)throw Error(`QuickJSRuntime(rt = ${t}) does not support module loading`);return i(t,n,r)}catch(e){return console.error(`[C to host module loader error: returning null]`,e),0}}),normalizeModule:(e,t,n,r,i)=>this.handleAsyncify(e,()=>{try{let e=this.runtimeCallbacks.get(t);if(!e)throw Error(`QuickJSRuntime(rt = ${t}) not found for C module loader`);let a=e.normalizeModule;if(!a)throw Error(`QuickJSRuntime(rt = ${t}) does not support module loading`);return a(t,n,r,i)}catch(e){return console.error(`[C to host module loader error: returning null]`,e),0}})}),this.module=e,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(e,t){this.runtimeCallbacks.set(e,t)}deleteRuntime(e){this.runtimeCallbacks.delete(e)}setContextCallbacks(e,t){this.contextCallbacks.set(e,t)}deleteContext(e){this.contextCallbacks.delete(e)}handleAsyncify(e,t){if(e)return e.handleSleep(e=>{try{let n=t();if(!(n instanceof Promise)){e(n);return}if(this.suspended)throw new Wt(`Already suspended at: ${this.suspended.stack}
9
- Attempted to suspend at:`);this.suspended=new Gt(`(${this.suspendedCount++})`),this.suspended,n.then(t=>{this.suspended=void 0,e(t)},e=>{console.error(`QuickJS: cannot handle error in suspended function`,e),this.suspended=void 0})}catch(e){throw this.suspended=void 0,e}});let n=t();if(n instanceof Promise)throw Error(`Promise return value not supported in non-asyncify context.`);return n}};function Rn(e,t){t.interruptHandler&&e.setInterruptHandler(t.interruptHandler),t.maxStackSizeBytes!==void 0&&e.setMaxStackSize(t.maxStackSizeBytes),t.memoryLimitBytes!==void 0&&e.setMemoryLimit(t.memoryLimitBytes)}function zn(e,t){t.moduleLoader&&e.setModuleLoader(t.moduleLoader),t.shouldInterrupt&&e.setInterruptHandler(t.shouldInterrupt),t.memoryLimitBytes!==void 0&&e.setMemoryLimit(t.memoryLimitBytes),t.maxStackSizeBytes!==void 0&&e.setMaxStackSize(t.maxStackSizeBytes)}var Bn=class{constructor(e,t){this.module=e,this.ffi=t,this.callbacks=new Ln(e)}newRuntime(e={}){let t=new ln(this.ffi.QTS_NewRuntime(),void 0,e=>{this.ffi.QTS_FreeRuntime(e),this.callbacks.deleteRuntime(e)}),n=new Fn({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:t});return Rn(n,e),e.moduleLoader&&n.setModuleLoader(e.moduleLoader),n}newContext(e={}){let t=this.newRuntime(),n=t.newContext({...e,ownedLifetimes:Tn(t,e.ownedLifetimes)});return t.context=n,n}evalCode(e,t={}){return pn.withScope(n=>{let r=n.manage(this.newContext());zn(r.runtime,t);let i=r.evalCode(e,`eval.js`);if(t.memoryLimitBytes!==void 0&&r.runtime.setMemoryLimit(-1),i.error)throw r.dump(n.manage(i.error));return r.dump(n.manage(i.value))})}getWasmMemory(){let e=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!e)throw Error(`Variant does not support getting WebAssembly.Memory`);return e}getFFI(){return this.ffi}};async function Vn(e){let t=Hn(await e),[n,r,{QuickJSWASMModule:i}]=await Promise.all([t.importModuleLoader().then(Hn),t.importFFI(),import(`./module-ES6BEMUI-B3C8EMJw.js`).then(Hn)]),a=await n();return a.type=`sync`,new i(a,new r(a))}function Hn(e){return e&&`default`in e&&e.default?e.default&&`default`in e.default&&e.default.default?e.default.default:e.default:e}function Un(e,t){return{...e,async importModuleLoader(){let n=Hn(await e.importModuleLoader());return async function(){let e=t.emscriptenModule?{...t.emscriptenModule}:{},r=t.log??((...e)=>([...e],void 0)),i=(e,t)=>(r(...e,t),t),a=e=>typeof e==`function`?e():e;(t.wasmLocation||t.wasmSourceMapLocation||t.locateFile)&&(e.locateFile=(e,n)=>{let r={fileName:e,relativeTo:n};if(e.endsWith(`.wasm`)&&t.wasmLocation!==void 0)return i([`locateFile .wasm: provide wasmLocation`,r],t.wasmLocation);if(e.endsWith(`.map`)){if(t.wasmSourceMapLocation!==void 0)return i([`locateFile .map: provide wasmSourceMapLocation`,r],t.wasmSourceMapLocation);if(t.wasmLocation&&!t.locateFile)return i([`locateFile .map: infer from wasmLocation`,r],t.wasmLocation+`.map`)}return t.locateFile?i([`locateFile: use provided fn`,r],t.locateFile(e,n)):i([`locateFile: unhandled, passthrough`,r],e)}),t.wasmBinary&&(e.wasmBinary=await a(t.wasmBinary)),t.wasmMemory&&(e.wasmMemory=await a(t.wasmMemory));let o=t.wasmModule,s;o&&(e.instantiateWasm=async(e,t)=>{s??=Promise.resolve(a(o));let n=await s;if(!n)throw new qt(`options.wasmModule returned ${String(n)}`);let r=await WebAssembly.instantiate(n,e);return t(r),r.exports}),e.monitorRunDependencies=e=>{r(`monitorRunDependencies:`,e)},e.quickjsEmscriptenInit=()=>Wn(r);let c=n(e),l=e.quickjsEmscriptenInit?.(r);if(o&&l?.receiveWasmOffsetConverter&&!l.existingWasmOffsetConverter){let e=await a(t.wasmBinary)??/* @__PURE__ */ new ArrayBuffer(0);s??=Promise.resolve(a(o));let n=await s;if(!n)throw new qt(`options.wasmModule returned ${String(n)}`);l.receiveWasmOffsetConverter(e,n)}if(l?.receiveSourceMapJSON){let e=await a(t.wasmSourceMapData);typeof e==`string`?l.receiveSourceMapJSON(JSON.parse(e)):e?l.receiveSourceMapJSON(e):l.receiveSourceMapJSON({version:3,names:[],sources:[],mappings:``})}return c}}}}function Wn(e){let t=`mock called, emscripten module may not be initialized yet`;return{mock:!0,removeRunDependency(n){e(`${t}: removeRunDependency called:`,n)},receiveSourceMapJSON(n){e(`${t}: receiveSourceMapJSON called:`,n)},WasmOffsetConverter:void 0,receiveWasmOffsetConverter(n,r){e(`${t}: receiveWasmOffsetConverter called:`,n,r)}}}function Gn(e){return[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``)}function Kn(e,t,n,r){let i=e.length+1+n,a=Math.ceil(i/t)*t,o=new Uint8Array(a);o.set(e),o[e.length]=128;let s=new DataView(o.buffer),c=BigInt(e.length)*8n;return r?s.setBigUint64(a-8,c,!0):s.setBigUint64(a-8,c,!1),o}const qn=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21],Jn=Array.from({length:64},(e,t)=>Math.floor(Math.abs(Math.sin(t+1))*2**32)>>>0);function Yn(e){let t=Kn(e,64,8,!0),n=new DataView(t.buffer),r=1732584193,i=4023233417,a=2562383102,o=271733878;for(let e=0;e<t.length;e+=64){let t=r,s=i,c=a,l=o;for(let r=0;r<64;r++){let i,a;r<16?(i=s&c|~s&l,a=r):r<32?(i=l&s|~l&c,a=(5*r+1)%16):r<48?(i=s^c^l,a=(3*r+5)%16):(i=c^(s|~l),a=7*r%16);let o=qn[(r>>4)*4+r%4],u=t+i+Jn[r]+n.getUint32(e+a*4,!0)>>>0;t=l,l=c,c=s,s=s+(u<<o|u>>>32-o)>>>0}r=r+t>>>0,i=i+s>>>0,a=a+c>>>0,o=o+l>>>0}let s=/* @__PURE__ */ new Uint8Array(16),c=new DataView(s.buffer);return[r,i,a,o].forEach((e,t)=>c.setUint32(t*4,e,!0)),Gn(s)}function Xn(e,t){return(e<<t|e>>>32-t)>>>0}function Zn(e){let t=Kn(e,64,8,!1),n=new DataView(t.buffer),r=[1732584193,4023233417,2562383102,271733878,3285377520],i=/* @__PURE__ */ new Uint32Array(80);for(let e=0;e<t.length;e+=64){for(let t=0;t<16;t++)i[t]=n.getUint32(e+t*4);for(let e=16;e<80;e++)i[e]=Xn(i[e-3]^i[e-8]^i[e-14]^i[e-16],1);let[t,a,o,s,c]=r;for(let e=0;e<80;e++){let n,r;e<20?(n=a&o|~a&s,r=1518500249):e<40?(n=a^o^s,r=1859775393):e<60?(n=a&o|a&s|o&s,r=2400959708):(n=a^o^s,r=3395469782);let l=Xn(t,5)+n+c+r+i[e]>>>0;c=s,s=o,o=Xn(a,30),a=t,t=l}r[0]=r[0]+t>>>0,r[1]=r[1]+a>>>0,r[2]=r[2]+o>>>0,r[3]=r[3]+s>>>0,r[4]=r[4]+c>>>0}return r.map(e=>e.toString(16).padStart(8,`0`)).join(``)}const Qn=/* @__PURE__ */ new Uint32Array(64),$n=[];{let e=[];for(let t=2;e.length<80;t++)e.every(e=>t%e!==0)&&e.push(t);e.forEach((e,t)=>{let n=er(e,3);t<64&&(Qn[t]=Number(n>>32n)),$n.push(n)})}function er(e,t){let n=BigInt(e)<<BigInt(64*t),r=0n,i=1n<<70n;for(;r<i;){let e=r+i+1n>>1n;e**BigInt(t)<=n?r=e:i=e-1n}return r&(1n<<64n)-1n}function tr(e,t){return(e>>>t|e<<32-t)>>>0}function nr(e,t,n){let r=Kn(e,64,8,!1),i=new DataView(r.buffer),a=[...t],o=/* @__PURE__ */ new Uint32Array(64);for(let e=0;e<r.length;e+=64){for(let t=0;t<16;t++)o[t]=i.getUint32(e+t*4);for(let e=16;e<64;e++){let t=tr(o[e-15],7)^tr(o[e-15],18)^o[e-15]>>>3,n=tr(o[e-2],17)^tr(o[e-2],19)^o[e-2]>>>10;o[e]=o[e-16]+t+o[e-7]+n>>>0}let[t,n,r,s,c,l,u,d]=a;for(let e=0;e<64;e++){let i=tr(c,6)^tr(c,11)^tr(c,25),a=c&l^~c&u,f=d+i+a+Qn[e]+o[e]>>>0,p=(tr(t,2)^tr(t,13)^tr(t,22))+(t&n^t&r^n&r)>>>0;d=u,u=l,l=c,c=s+f>>>0,s=r,r=n,n=t,t=f+p>>>0}[t,n,r,s,c,l,u,d].forEach((e,t)=>a[t]=a[t]+e>>>0)}return a.slice(0,n).map(e=>e.toString(16).padStart(8,`0`)).join(``)}const rr=(1n<<64n)-1n;function ir(e,t){return(e>>t|e<<64n-t)&rr}function ar(e,t,n){let r=Kn(e,128,16,!1),i=new DataView(r.buffer),a=[...t],o=Array(80);for(let e=0;e<r.length;e+=128){for(let t=0;t<16;t++)o[t]=i.getBigUint64(e+t*8);for(let e=16;e<80;e++){let t=ir(o[e-15],1n)^ir(o[e-15],8n)^o[e-15]>>7n,n=ir(o[e-2],19n)^ir(o[e-2],61n)^o[e-2]>>6n;o[e]=o[e-16]+t+o[e-7]+n&rr}let[t,n,r,s,c,l,u,d]=a;for(let e=0;e<80;e++){let i=ir(c,14n)^ir(c,18n)^ir(c,41n),a=c&l^~c&rr&u,f=d+i+a+$n[e]+o[e]&rr,p=(ir(t,28n)^ir(t,34n)^ir(t,39n))+(t&n^t&r^n&r)&rr;d=u,u=l,l=c,c=s+f&rr,s=r,r=n,n=t,t=f+p&rr}[t,n,r,s,c,l,u,d].forEach((e,t)=>a[t]=a[t]+e&rr)}return a.map(e=>e.toString(16).padStart(16,`0`)).join(``).slice(0,n*16)}const or=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],sr=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],cr=[7640891576956012808n,13503953896175478587n,4354685564936845355n,11912009170470909681n,5840696475078001361n,11170449401992604703n,2270897969802886507n,6620516959819538809n],lr=[14680500436340154072n,7105036623409894663n,10473403895298186519n,1526699215303891257n,7436329637833083697n,10282925794625328401n,15784041429090275239n,5167115440072839076n];function ur(e,t){switch(t){case 224:return nr(e,sr,7);case 0:case 256:return nr(e,or,8);case 384:return ar(e,lr,6);case 512:return ar(e,cr,8);default:return}}const dr=Array.from({length:256},(e,t)=>{let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function fr(e){let t=4294967295;for(let n of e)t=dr[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function C(e){let t=e.replace(/^[\t-\r ]+|[\t-\r ]+$/g,``).replaceAll(`\\`,`/`),n=/^[A-Za-z]:/.exec(t)?.[0]??``,r=t.slice(n.length),i=r.startsWith(`//`)?`//`:r.startsWith(`/`)?`/`:``,a=[],o=0;for(let e of r.slice(i.length).split(`/`))e!==``&&e!==`.`&&(e===`..`&&o>0?(a.pop(),o--):e===`..`?a.push(e):(a.push(e),o++));return n+i+a.join(`/`)}function pr(e,t,n){if(n===``)return{files:[],found:!0};if(n.startsWith(`@`))return{files:[n],found:!0};let r=C(t),i={found:!0},a=[];return mr(e,`${r}/${n}`,i,a),{files:[...new Set(a)].filter(e=>e.length>=r.length+1).map(e=>e.slice(r.length+1)).sort(p),found:i.found}}function mr(e,t,n,r){let i=C(t),a=i.indexOf(`*`),o=_r(a===-1?i:i.slice(0,a)),s=a===-1?-1:i.indexOf(`/`,a),c=s===-1?``:i.slice(s+1);if(a!==-1&&i[a+1]===`*`&&(a===0||i[a-1]===`/`)){for(let t of[1,2])mr(e,i.slice(0,a)+i.slice(a+t),n,r);for(let{name:t,directory:s}of hr(e,i.slice(0,a+1),n))s&&mr(e,`${o}/${t}/${i.slice(a)}`,n,r)}else for(let{name:t,directory:a}of hr(e,s===-1?i:i.slice(0,s-1),n)){if(s!==-1&&!a)continue;let i=`${o}/${t}`;c===``?a||r.push(i):mr(e,`${i}/${c}`,n,r)}}function hr(e,t,n){let r=t.lastIndexOf(`/`),i=r===-1?t:t.slice(0,r),a=t.slice(r+1),o=e.list(i),s=gr(a);if(s===void 0)return[];let c=o===void 0?[]:o.filter(e=>e.name!==`.`&&e.name!==`..`&&s.test(e.name));return n.found&&=(o===void 0?s.test(``):c.length>0)||(a.startsWith(`*`)||a.startsWith(`.`))&&o!==void 0,c}function gr(e){let t=``;for(let n of e)n===`?`?t+=`.`:n===`*`?t+=`.*`:`\\^.$|()[]+/`.includes(n)?t+=`\\${n}`:t+=n;try{return RegExp(`^${t}$`)}catch{return}}function _r(e){let t=e.lastIndexOf(`/`);return t===-1?`.`:e.slice(0,t)}var vr=`/*
9
+ Attempted to suspend at:`);this.suspended=new Gt(`(${this.suspendedCount++})`),this.suspended,n.then(t=>{this.suspended=void 0,e(t)},e=>{console.error(`QuickJS: cannot handle error in suspended function`,e),this.suspended=void 0})}catch(e){throw this.suspended=void 0,e}});let n=t();if(n instanceof Promise)throw Error(`Promise return value not supported in non-asyncify context.`);return n}};function Rn(e,t){t.interruptHandler&&e.setInterruptHandler(t.interruptHandler),t.maxStackSizeBytes!==void 0&&e.setMaxStackSize(t.maxStackSizeBytes),t.memoryLimitBytes!==void 0&&e.setMemoryLimit(t.memoryLimitBytes)}function zn(e,t){t.moduleLoader&&e.setModuleLoader(t.moduleLoader),t.shouldInterrupt&&e.setInterruptHandler(t.shouldInterrupt),t.memoryLimitBytes!==void 0&&e.setMemoryLimit(t.memoryLimitBytes),t.maxStackSizeBytes!==void 0&&e.setMaxStackSize(t.maxStackSizeBytes)}var Bn=class{constructor(e,t){this.module=e,this.ffi=t,this.callbacks=new Ln(e)}newRuntime(e={}){let t=new ln(this.ffi.QTS_NewRuntime(),void 0,e=>{this.ffi.QTS_FreeRuntime(e),this.callbacks.deleteRuntime(e)}),n=new Fn({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:t});return Rn(n,e),e.moduleLoader&&n.setModuleLoader(e.moduleLoader),n}newContext(e={}){let t=this.newRuntime(),n=t.newContext({...e,ownedLifetimes:Tn(t,e.ownedLifetimes)});return t.context=n,n}evalCode(e,t={}){return pn.withScope(n=>{let r=n.manage(this.newContext());zn(r.runtime,t);let i=r.evalCode(e,`eval.js`);if(t.memoryLimitBytes!==void 0&&r.runtime.setMemoryLimit(-1),i.error)throw r.dump(n.manage(i.error));return r.dump(n.manage(i.value))})}getWasmMemory(){let e=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!e)throw Error(`Variant does not support getting WebAssembly.Memory`);return e}getFFI(){return this.ffi}};async function Vn(e){let t=Hn(await e),[n,r,{QuickJSWASMModule:i}]=await Promise.all([t.importModuleLoader().then(Hn),t.importFFI(),import(`./module-ES6BEMUI-Cb1CmwRT.js`).then(Hn)]),a=await n();return a.type=`sync`,new i(a,new r(a))}function Hn(e){return e&&`default`in e&&e.default?e.default&&`default`in e.default&&e.default.default?e.default.default:e.default:e}function Un(e,t){return{...e,async importModuleLoader(){let n=Hn(await e.importModuleLoader());return async function(){let e=t.emscriptenModule?{...t.emscriptenModule}:{},r=t.log??((...e)=>([...e],void 0)),i=(e,t)=>(r(...e,t),t),a=e=>typeof e==`function`?e():e;(t.wasmLocation||t.wasmSourceMapLocation||t.locateFile)&&(e.locateFile=(e,n)=>{let r={fileName:e,relativeTo:n};if(e.endsWith(`.wasm`)&&t.wasmLocation!==void 0)return i([`locateFile .wasm: provide wasmLocation`,r],t.wasmLocation);if(e.endsWith(`.map`)){if(t.wasmSourceMapLocation!==void 0)return i([`locateFile .map: provide wasmSourceMapLocation`,r],t.wasmSourceMapLocation);if(t.wasmLocation&&!t.locateFile)return i([`locateFile .map: infer from wasmLocation`,r],t.wasmLocation+`.map`)}return t.locateFile?i([`locateFile: use provided fn`,r],t.locateFile(e,n)):i([`locateFile: unhandled, passthrough`,r],e)}),t.wasmBinary&&(e.wasmBinary=await a(t.wasmBinary)),t.wasmMemory&&(e.wasmMemory=await a(t.wasmMemory));let o=t.wasmModule,s;o&&(e.instantiateWasm=async(e,t)=>{s??=Promise.resolve(a(o));let n=await s;if(!n)throw new qt(`options.wasmModule returned ${String(n)}`);let r=await WebAssembly.instantiate(n,e);return t(r),r.exports}),e.monitorRunDependencies=e=>{r(`monitorRunDependencies:`,e)},e.quickjsEmscriptenInit=()=>Wn(r);let c=n(e),l=e.quickjsEmscriptenInit?.(r);if(o&&l?.receiveWasmOffsetConverter&&!l.existingWasmOffsetConverter){let e=await a(t.wasmBinary)??/* @__PURE__ */ new ArrayBuffer(0);s??=Promise.resolve(a(o));let n=await s;if(!n)throw new qt(`options.wasmModule returned ${String(n)}`);l.receiveWasmOffsetConverter(e,n)}if(l?.receiveSourceMapJSON){let e=await a(t.wasmSourceMapData);typeof e==`string`?l.receiveSourceMapJSON(JSON.parse(e)):e?l.receiveSourceMapJSON(e):l.receiveSourceMapJSON({version:3,names:[],sources:[],mappings:``})}return c}}}}function Wn(e){let t=`mock called, emscripten module may not be initialized yet`;return{mock:!0,removeRunDependency(n){e(`${t}: removeRunDependency called:`,n)},receiveSourceMapJSON(n){e(`${t}: receiveSourceMapJSON called:`,n)},WasmOffsetConverter:void 0,receiveWasmOffsetConverter(n,r){e(`${t}: receiveWasmOffsetConverter called:`,n,r)}}}function Gn(e){return[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``)}function Kn(e,t,n,r){let i=e.length+1+n,a=Math.ceil(i/t)*t,o=new Uint8Array(a);o.set(e),o[e.length]=128;let s=new DataView(o.buffer),c=BigInt(e.length)*8n;return r?s.setBigUint64(a-8,c,!0):s.setBigUint64(a-8,c,!1),o}const qn=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21],Jn=Array.from({length:64},(e,t)=>Math.floor(Math.abs(Math.sin(t+1))*2**32)>>>0);function Yn(e){let t=Kn(e,64,8,!0),n=new DataView(t.buffer),r=1732584193,i=4023233417,a=2562383102,o=271733878;for(let e=0;e<t.length;e+=64){let t=r,s=i,c=a,l=o;for(let r=0;r<64;r++){let i,a;r<16?(i=s&c|~s&l,a=r):r<32?(i=l&s|~l&c,a=(5*r+1)%16):r<48?(i=s^c^l,a=(3*r+5)%16):(i=c^(s|~l),a=7*r%16);let o=qn[(r>>4)*4+r%4],u=t+i+Jn[r]+n.getUint32(e+a*4,!0)>>>0;t=l,l=c,c=s,s=s+(u<<o|u>>>32-o)>>>0}r=r+t>>>0,i=i+s>>>0,a=a+c>>>0,o=o+l>>>0}let s=/* @__PURE__ */ new Uint8Array(16),c=new DataView(s.buffer);return[r,i,a,o].forEach((e,t)=>c.setUint32(t*4,e,!0)),Gn(s)}function Xn(e,t){return(e<<t|e>>>32-t)>>>0}function Zn(e){let t=Kn(e,64,8,!1),n=new DataView(t.buffer),r=[1732584193,4023233417,2562383102,271733878,3285377520],i=/* @__PURE__ */ new Uint32Array(80);for(let e=0;e<t.length;e+=64){for(let t=0;t<16;t++)i[t]=n.getUint32(e+t*4);for(let e=16;e<80;e++)i[e]=Xn(i[e-3]^i[e-8]^i[e-14]^i[e-16],1);let[t,a,o,s,c]=r;for(let e=0;e<80;e++){let n,r;e<20?(n=a&o|~a&s,r=1518500249):e<40?(n=a^o^s,r=1859775393):e<60?(n=a&o|a&s|o&s,r=2400959708):(n=a^o^s,r=3395469782);let l=Xn(t,5)+n+c+r+i[e]>>>0;c=s,s=o,o=Xn(a,30),a=t,t=l}r[0]=r[0]+t>>>0,r[1]=r[1]+a>>>0,r[2]=r[2]+o>>>0,r[3]=r[3]+s>>>0,r[4]=r[4]+c>>>0}return r.map(e=>e.toString(16).padStart(8,`0`)).join(``)}const Qn=/* @__PURE__ */ new Uint32Array(64),$n=[];{let e=[];for(let t=2;e.length<80;t++)e.every(e=>t%e!==0)&&e.push(t);e.forEach((e,t)=>{let n=er(e,3);t<64&&(Qn[t]=Number(n>>32n)),$n.push(n)})}function er(e,t){let n=BigInt(e)<<BigInt(64*t),r=0n,i=1n<<70n;for(;r<i;){let e=r+i+1n>>1n;e**BigInt(t)<=n?r=e:i=e-1n}return r&(1n<<64n)-1n}function tr(e,t){return(e>>>t|e<<32-t)>>>0}function nr(e,t,n){let r=Kn(e,64,8,!1),i=new DataView(r.buffer),a=[...t],o=/* @__PURE__ */ new Uint32Array(64);for(let e=0;e<r.length;e+=64){for(let t=0;t<16;t++)o[t]=i.getUint32(e+t*4);for(let e=16;e<64;e++){let t=tr(o[e-15],7)^tr(o[e-15],18)^o[e-15]>>>3,n=tr(o[e-2],17)^tr(o[e-2],19)^o[e-2]>>>10;o[e]=o[e-16]+t+o[e-7]+n>>>0}let[t,n,r,s,c,l,u,d]=a;for(let e=0;e<64;e++){let i=tr(c,6)^tr(c,11)^tr(c,25),a=c&l^~c&u,f=d+i+a+Qn[e]+o[e]>>>0,p=(tr(t,2)^tr(t,13)^tr(t,22))+(t&n^t&r^n&r)>>>0;d=u,u=l,l=c,c=s+f>>>0,s=r,r=n,n=t,t=f+p>>>0}[t,n,r,s,c,l,u,d].forEach((e,t)=>a[t]=a[t]+e>>>0)}return a.slice(0,n).map(e=>e.toString(16).padStart(8,`0`)).join(``)}const rr=(1n<<64n)-1n;function ir(e,t){return(e>>t|e<<64n-t)&rr}function ar(e,t,n){let r=Kn(e,128,16,!1),i=new DataView(r.buffer),a=[...t],o=Array(80);for(let e=0;e<r.length;e+=128){for(let t=0;t<16;t++)o[t]=i.getBigUint64(e+t*8);for(let e=16;e<80;e++){let t=ir(o[e-15],1n)^ir(o[e-15],8n)^o[e-15]>>7n,n=ir(o[e-2],19n)^ir(o[e-2],61n)^o[e-2]>>6n;o[e]=o[e-16]+t+o[e-7]+n&rr}let[t,n,r,s,c,l,u,d]=a;for(let e=0;e<80;e++){let i=ir(c,14n)^ir(c,18n)^ir(c,41n),a=c&l^~c&rr&u,f=d+i+a+$n[e]+o[e]&rr,p=(ir(t,28n)^ir(t,34n)^ir(t,39n))+(t&n^t&r^n&r)&rr;d=u,u=l,l=c,c=s+f&rr,s=r,r=n,n=t,t=f+p&rr}[t,n,r,s,c,l,u,d].forEach((e,t)=>a[t]=a[t]+e&rr)}return a.map(e=>e.toString(16).padStart(16,`0`)).join(``).slice(0,n*16)}const or=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],sr=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],cr=[7640891576956012808n,13503953896175478587n,4354685564936845355n,11912009170470909681n,5840696475078001361n,11170449401992604703n,2270897969802886507n,6620516959819538809n],lr=[14680500436340154072n,7105036623409894663n,10473403895298186519n,1526699215303891257n,7436329637833083697n,10282925794625328401n,15784041429090275239n,5167115440072839076n];function ur(e,t){switch(t){case 224:return nr(e,sr,7);case 0:case 256:return nr(e,or,8);case 384:return ar(e,lr,6);case 512:return ar(e,cr,8);default:return}}const dr=Array.from({length:256},(e,t)=>{let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function fr(e){let t=4294967295;for(let n of e)t=dr[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function C(e){let t=e.replace(/^[\t-\r ]+|[\t-\r ]+$/g,``).replaceAll(`\\`,`/`),n=/^[A-Za-z]:/.exec(t)?.[0]??``,r=t.slice(n.length),i=r.startsWith(`//`)?`//`:r.startsWith(`/`)?`/`:``,a=[],o=0;for(let e of r.slice(i.length).split(`/`))e!==``&&e!==`.`&&(e===`..`&&o>0?(a.pop(),o--):e===`..`?a.push(e):(a.push(e),o++));return n+i+a.join(`/`)}function pr(e,t,n){if(n===``)return{files:[],found:!0};if(n.startsWith(`@`))return{files:[n],found:!0};let r=C(t),i={found:!0},a=[];return mr(e,`${r}/${n}`,i,a),{files:[...new Set(a)].filter(e=>e.length>=r.length+1).map(e=>e.slice(r.length+1)).sort(p),found:i.found}}function mr(e,t,n,r){let i=C(t),a=i.indexOf(`*`),o=_r(a===-1?i:i.slice(0,a)),s=a===-1?-1:i.indexOf(`/`,a),c=s===-1?``:i.slice(s+1);if(a!==-1&&i[a+1]===`*`&&(a===0||i[a-1]===`/`)){for(let t of[1,2])mr(e,i.slice(0,a)+i.slice(a+t),n,r);for(let{name:t,directory:s}of hr(e,i.slice(0,a+1),n))s&&mr(e,`${o}/${t}/${i.slice(a)}`,n,r)}else for(let{name:t,directory:a}of hr(e,s===-1?i:i.slice(0,s-1),n)){if(s!==-1&&!a)continue;let i=`${o}/${t}`;c===``?a||r.push(i):mr(e,`${i}/${c}`,n,r)}}function hr(e,t,n){let r=t.lastIndexOf(`/`),i=r===-1?t:t.slice(0,r),a=t.slice(r+1),o=e.list(i),s=gr(a);if(s===void 0)return[];let c=o===void 0?[]:o.filter(e=>e.name!==`.`&&e.name!==`..`&&s.test(e.name));return n.found&&=(o===void 0?s.test(``):c.length>0)||(a.startsWith(`*`)||a.startsWith(`.`))&&o!==void 0,c}function gr(e){let t=``;for(let n of e)n===`?`?t+=`.`:n===`*`?t+=`.*`:`\\^.$|()[]+/`.includes(n)?t+=`\\${n}`:t+=n;try{return RegExp(`^${t}$`)}catch{return}}function _r(e){let t=e.lastIndexOf(`/`);return t===-1?`.`:e.slice(0,t)}var vr=`/*
10
10
  * FiveRunner's runtime of JavaScript resources, which runs in their QuickJS
11
11
  * contexts, before their scripts: the natives, which load as scripts first
12
12
  * name them, msgpack, function references, events, exports, timers, the
@@ -4805,7 +4805,7 @@ return function(chunk)
4805
4805
  setmetatable(_G, nil)
4806
4806
  end
4807
4807
  `,Fo=class extends Error{name=`ManifestError`;missing;entries;constructor(e,t=!1,n=[]){super(e),this.missing=t,this.entries=n}};const Io=v.base|v.table|v.string|v.math|v.debug|v.coroutine|v.utf8|v.json,Lo=[`fxmanifest.lua`,`__resource.lua`],Ro=[``,`adamant`,`bodacious`,`cerulean`];function zo(e,t){let n=Ro.indexOf(e.find(([e])=>e===`fx_version`)?.[1]??``);return n!==-1&&n>=Ro.indexOf(t)}const Bo=/* @__PURE__ */ new Map([[`client_scripts`,`client_script`],[`server_scripts`,`server_script`],[`shared_scripts`,`shared_script`],[`files`,`file`],[`exports`,`export`],[`server_exports`,`server_export`],[`dependencies`,`dependency`],[`provides`,`provide`],[`games`,`game`]]);function Vo(e){return e.flatMap(e=>{let t=Bo.get(e[0]);return t===void 0?[]:[[e,t]]})}const Ho=[`00000000-0000-0000-0000-000000000000`,`77731fab-63ca-442c-a67b-abc70f28dfa5`,`f15e72ec-3972-4fe4-9c7d-afc5394ae207`,`44febabe-d386-4d18-afbe-5e627f4af937`,`05cfa83c-a124-4cfa-a768-c24a5811d8f9`],Uo=[[`natives_21e43a33.lua`,Ho[0]],[`natives_0193d0af.lua`,`f15e72ec-3972-4fe4-9c7d-afc5394ae207`],[`natives_universal.lua`,`44febabe-d386-4d18-afbe-5e627f4af937`]];function Wo(e){let t=e.slice(0,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)?t.toLowerCase():Ho[0]}function Go(e,t){let n=e.find(([e])=>e===`resource_manifest_version`)?.[1];return Ho.indexOf(Wo(n??``))>=Ho.indexOf(t)}function Ko(e,t){let n=e=>e.filter(([e])=>!e.endsWith(`_extra`)).sort(([e],[t])=>p(e,t)).map(([e,t])=>[e,t]),[r,i]=[n(e),n(t)];return r.length===i.length&&r.every(([e,t],n)=>e===i[n][0]&&t===i[n][1])}function qo(e){if(zo(e,`adamant`))return`natives_universal.lua`;let t=e.find(([e])=>e===`resource_manifest_version`)?.[1],n=Ho.indexOf(Wo(t??``)),r=Uo[0][0];for(let[e,t]of Uo)n>=Ho.indexOf(t)&&(r=e);return r}function Jo(e,t,n){let r=[],i=e.newState({libs:Io});try{let e=i.hostFunction(e=>{let n=String(e.get(1));if(n.toLowerCase()===`is_cfxv2`)return;let i=String(e.get(2)),a=e.get(3);if(typeof a!=`string`){r.push([n,i]);return}let o=a.startsWith(`@`)?`${t}/${a.slice(1)}`:String(e.get(4));r.push([n,i,{file:o,line:Number(e.get(5))}])}),[a]=i.run(Po,`@fiverunner:/manifest.lua`,e);if(!(a instanceof xe))throw Error(`The manifest prelude did not return a function`);for(let e of[`dofile`,`load`,`loadfile`])i.setGlobal(e,null);for(let e of Lo){let o=n(e);if(o===void 0)continue;let s=`${t}/${e}`,c;try{c=i.load(o,`@${Yo(s)}`)}catch(e){throw new Fo(`Could not parse resource metadata file ${s}: ${Xo(e)}`)}try{i.call(a,c)}catch(e){let t=e instanceof ue?e.luaTraceback:void 0;throw new Fo(`Could not execute resource metadata file ${s}: ${Xo(e)}`+(t===void 0?``:`\n${t}`),!1,r)}finally{c.release()}return e===`fxmanifest.lua`&&r.push([`is_cfxv2`,`true`]),r}throw new Fo(`Could not open resource metadata file - no such file.`,!0)}finally{i.close()}}function Yo(e){let t=e.lastIndexOf(`/`);if(t<=0)return e;let n=e.lastIndexOf(`/`,t-1);return n===-1?e:e.slice(n+1)}function Xo(e){return e instanceof Error?e.message:String(e)}const Zo={prefix:``,root:``};function Qo(e,t){let n=/^@[^/]*\//.exec(t)?.[0];if(n===void 0)return Zo;let r=e.getResource(n.slice(1,-1),!1);return r===void 0?Zo:{prefix:n,root:`${C(r.path)}/`}}function $o(e,t){return C(e.root+t.slice(e.prefix.length))}function es(e,t){let n=C(t);for(let t of e.resources){let e=`${C(t.path)}/`;if(!n.startsWith(e))continue;let r=`@${t.name}/`;return{mount:{prefix:r,root:e},path:r+n.slice(e.length)}}}function ts(e,t,n){let[r,...i]=n.slice(1).split(/[\\/]/);return i.every(e=>e===``)?!1:r===t||e.filesystemPermissions.mayWrite(t,r)}function ns(e,t){return t.startsWith(`@`)?{mount:Qo(e,t),path:t}:es(e,t)}function rs(e){return`${e.replaceAll(`\\`,`/`)}/`}function is(e,t){return e.files.list(t)?.map(e=>e.name).sort(ko)}function as(e,t){let{files:n,openFiles:r}=e;return{createDirectory(t){let r=rs(t),i=$o(Qo(e,r),r);return n.list(i)===void 0?n.list(Ao(i))===void 0||n.size(i)!==void 0?`failed`:(n.makeDirectory(i),`created`):`exists`},remove(i){let a=ns(e,i);if(a===void 0||!ts(e,t,a.path))return!1;let o=$o(a.mount,a.path);return!r.inUse(o)&&n.remove(o)},rename(i,a){let o=ns(e,i),s=ns(e,a);if(o===void 0||s===void 0||!ts(e,t,o.path)||!ts(e,t,s.path))return!1;let c=$o(o.mount,o.path);return!r.inUse(c)&&n.rename(c,$o(o.mount,s.path))}}}function os(e,t){let{openFiles:n}=e;return{open(r,i){if(r.split(/[\\/]/).includes(`..`))return;let a=ns(e,r);if(a===void 0)return;let o=ts(e,t,a.path),s=i.write&&o,c=i.append?`append`:`write`,l=$o(a.mount,a.path);return i.create&&o?n.createNew(l,c)??n.openExisting(l,c):n.openExisting(l,s?c:`read`)??(s?n.createNew(l,c):void 0)},readDirectory(t){let n=rs(t);return is(e,$o(Qo(e,n),n))??[]},listCommand(t){let n=es(e,t);if(n===void 0)return;let r=is(e,$o(n.mount,n.path));return r===void 0?[]:[`.`,`..`,...r]}}}var ss=class{name;manager;path;categories;handledEvents=/* @__PURE__ */ new Set;cpuTime=0;onBeforeStart=new Ni;onStart=new Ni;onStop=new Ni;#e;#t;#n=`stopped`;#r=null;#i=null;#a=null;#o=/* @__PURE__ */ new Map;#s=/* @__PURE__ */ new Set;#c;constructor(e,t,n){this.manager=e,this.name=t,this.path=n.path??(e.side===`client`?`resources:/${t}/`:`resources/${t}`),this.#e=C(this.path),this.categories=us(this.path);let r=n.files===void 0?void 0:this.#u(n.files),i=r??e.files;this.#t=n.metadata??Jo(e.lua,this.path,e=>i.read(`${this.#e}/${e}`)),this.#l(),r!==void 0&&this.#d(r),e.events.attach(this),this.onStart.connect(()=>this.#m()),this.onStop.connect(()=>this.#g()),e.nui?.attach(this),e.side===`server`&&this.onStart.connect(()=>this.#f(),500),e.httpServer?.attach(this)}get state(){return this.#n}get metadata(){return this.#t}get packedForClients(){return this.#c}reloadMetadata(e){let{files:t,lua:n,output:r}=this.manager,i=C(e),a;try{a=Jo(n,e,e=>t.read(`${i}/${e}`))}catch(e){if(!(e instanceof Fo))throw e;r.diagnose(this.name,`The manifest of ${this.name} no longer loads, and FiveM keeps the entries it added before it failed without saying so: ${e.message}`),a=e.entries}let o=!Ko(this.#t,a);return this.#t=a,o&&this.#l(),o}destroy(){this.#n=`uninitialized`}get runtime(){return this.#r}get runtimes(){return[this.#r,this.#i].filter(e=>e!==null)}entries(e){return this.metadata.filter(([t])=>t===e).map(([,e])=>e)}globEntries(e){return this.entries(e).flatMap(e=>pr(this.manager.files,this.#e,e).files)}missingEntries(e){return this.metadata.filter(([t])=>t===e).flatMap(([,e,t])=>{let{files:n,found:r}=pr(this.manager.files,this.#e,e);return n.length===0?[{value:e,location:t,found:r}]:[]})}get scripts(){return[...this.globEntries(`shared_script`),...this.globEntries(`${this.manager.side}_script`)]}file(e){return this.manager.files.read(`${this.#e}/${e}`)}start(){return this.#n!==`started`&&(this.#n!==`starting`&&(this.#n=`starting`,!this.onBeforeStart.run())||!this.onStart.run())?this.#p():(this.#n=`started`,!0)}stop(){if(this.#n!==`stopped`){if(!this.onStop.run())return!1;this.#n=`stopped`}return!0}handleEvent(e,t,n){if(this.handledEvents.has(e)||this.handledEvents.has(`*`))for(let r of this.runtimes)this.enter(()=>r.triggerEvent(e,t,n),r)}enter(e,t=this.runtimes[0]??null){this.manager.pushCall(this,t),t!==null&&this.#o.set(t,(this.#o.get(t)??0)+1);try{return e()}finally{if(this.manager.popCall(),t!==null){let e=this.#o.get(t)-1;e>0?this.#o.set(t,e):(this.#o.delete(t),this.#s.delete(t)&&this.#_(t))}}}#l(){for(let[[e,t,n],r]of Vo(this.#t)){let i=n===void 0?``:` (defined in ${n.file.slice(n.file.lastIndexOf(`/`)+1)}:${n.line})`;this.manager.output.diagnose(this.name,`${this.name}'s manifest adds ${e} \`${t}\`${i}, which FiveM does not read: ${e} drops its final s only for tables, so FiveM reads what ${r} '...' and ${e} { '...' } add, but not ${e} '...'.`)}}#u(e){let t=new Eo;for(let[n,r]of Object.entries(e))Oo(t,C(`${this.#e}/${n}`),r);return t}#d(e){let{files:t,side:n}=this.manager,r=n===`client`?ds(e,this.#e,this.metadata):void 0;t.makeDirectory(this.#e);let i=n=>{for(let{name:a,directory:o}of e.list(n)??[]){let s=`${n}/${a}`;o?i(s):(r===void 0||r.has(s.slice(this.#e.length+1)))&&Oo(t,s,e.read(s))}};i(this.#e)}#f(){let{files:e}=this.manager,t={};for(let n of ds(e,this.#e,this.#t)){let r=e.read(`${this.#e}/${n}`);r!==void 0&&(t[n]=r)}let n=`fxmanifest.lua`in t||`__resource.lua`in t;this.#c=n?{files:t}:{files:t,metadata:this.#t}}#p(){return this.#n!==`started`&&(this.#n=`stopped`),!1}get emulatesOxmysql(){return this.name===`oxmysql`&&this.manager.oxmysql!==void 0}#m(){if(this.#r!==null){this.manager.output.diagnose(this.name,`${this.name} was started while it started. FiveM would then create another runtime for it and load its scripts again in both runtimes, which FiveRunner does not emulate: it keeps the runtime it has.`);return}let e=this.emulatesOxmysql,{javascript:t}=this.manager,n=this.scripts.filter(n=>n.includes(`.lua`)||n.includes(`.js`)&&t!==void 0&&!e?!0:(this.manager.output.diagnose(this.name,e?`FiveRunner skips ${n}, and runs its own emulation of oxmysql in its place, which gives oxmysql's exports.`:`FiveRunner runs only Lua and JavaScript scripts, so it skips ${n}.`),!1)),r=n.some(e=>e.includes(`.lua`))||e,i=n.some(e=>!e.includes(`.lua`));if(!r&&!i)return;if(this.manager.trace(`citizen-scripting-core`,`Creating script environments for ${this.name}\n`),r&&this.manager.side===`client`){let e=qo(this.metadata);e!==`natives_universal.lua`&&this.manager.output.diagnose(this.name,`FiveM would give the scripts of ${this.name} the natives of ${e}, by the versions its manifest names, which FiveRunner does not have: it gives them those of natives_universal.lua, as FiveM does for resources with fx_version 'adamant' or later.`)}r&&(this.#r=this.enter(()=>yi.create(this.manager.lua,this.#v()))),i&&(this.#i=this.enter(()=>wi.create(t,this.#v()))),this.manager.addRuntime(this);let a=this.runtimes,{runtime:o}=this;e&&this.enter(()=>o.runBuiltin(`oxmysql.lua`,No));for(let e of n){if(this.runtimes.length!==a.length)break;let t=e.includes(`.lua`)?this.#r:this.#i,n=this.#h(e);n!==void 0&&ps(n)?this.manager.output.diagnose(this.name,`FiveRunner skips ${e}, which asset escrow encrypted: only FiveM opens it.`):n!==void 0&&this.enter(()=>t.runFile(e,n),t)||this.manager.trace(`citizen-scripting-core`,`Failed to load script ${e}.\n`)}}#h(e){let t=e.indexOf(`/`);return e.length>1&&e.startsWith(`@`)&&t!==-1?this.manager.getResource(e.slice(1,t))?.file(C(e.slice(t+1))):this.file(C(e))}#g(){let e=this.runtimes;if(e.length!==0){this.emulatesOxmysql&&this.manager.oxmysql.stopped(),this.#r=null,this.#i=null,this.#a=null,this.manager.removeRuntime(this);for(let t of e)this.#o.has(t)?this.#s.add(t):this.#_(t)}}#_(e){this.manager.pushCall(this,e);try{e.close()}finally{this.manager.popCall()}}#v(){let{manager:e,name:t}=this;return{resource:t,instanceId:e.instanceId(),exports:this.entries(e.side===`server`?`server_export`:`export`),...e.watchdog===void 0?{}:{watchdog:e.watchdog},natives:{client:e.side===`client`,load:t=>e.nativeWrapper(t),invoke:(t,n)=>e.natives.invoke(this.#y(t),n),find:t=>cs(e.natives.byName(t)),invokeDirectly:(t,n,r)=>e.natives.invokeDirectly(this.#y(t),n,r)},...e.side===`client`?{}:{io:os(e,t),os:{wallClock:()=>e.wallClock(),timeZone:e.timeZone,processTime:()=>e.time(),steadyClock:()=>e.clock(),nextTemporaryName:()=>e.nextTemporaryName(),...as(e,t)}},clock:()=>e.clock(),trace:n=>e.log(`script:${t}`,n),warn:n=>e.output.warn(t,n),log:(t,n)=>e.log(t,n),wallClock:()=>e.wallClock(),files:e.files,resourcePath:this.path,database:()=>e.oxmysql?.scriptConnection(),...e.lines===void 0?{}:{lines:e.lines},diagnose:n=>e.output.diagnose(t,n),submitBoundary:(t,n)=>e.submitBoundary(t,n),formatStackTrace:()=>e.formatStackTrace(null)??``,invokeFunctionReference:(t,n)=>e.invokeFunctionReference(t,n)}}#y(e){return this.#a?.runtime!==e&&(this.#a=new Mt(e,this)),this.#a}};function cs(e){if(e===void 0)return;let{paramTypes:t}=e,n=t.filter(e=>e.pointer).length===1&&t.at(-1).pointer;return{native:e,kinds:t.filter(e=>!e.pointer||n).map(e=>e.kind===`func`?`f`:e.kind===`object`?`o`:`-`).join(``),object:e.result!==`void`&&e.result!==`Any*`&&Fe(e.result).kind===`object`}}function ls(e){return e.startsWith(`[`)&&e.endsWith(`]`)}function us(e){let t=e.split(/[\\/]/).filter(e=>e!==``);t.pop();let n=t.length;for(;n>0&&ls(t[n-1]);)n--;return t.slice(n)}function ds(e,t,n){let r=[n.some(([e])=>e===`is_cfxv2`)?`fxmanifest.lua`:`__resource.lua`];for(let i of[`file`,`client_script`,`shared_script`,`map`])for(let[a,o]of n)if(a===i)for(let n of pr(e,t,o).files)n.startsWith(`@`)||r.push(n);return new Set(r.filter(e=>!fs(e)))}function fs(e){let t=e.indexOf(`.`);if(!e.startsWith(`stream/`)||t===-1)return!1;let n=e.slice(t);return n[1]===`y`&&n!==`.ytyp`}function ps(e){return(typeof e==`string`?e:String.fromCharCode(...e.subarray(0,5))).startsWith(`FXAP`)}function ms(e){let{commands:t}=e.console,n=t=>e.trace(`citizen-server-impl`,t),r=(t,n)=>e.console.executeDirect([t,n]),i=t=>{let r=e.getResource(t);return r===void 0&&n(`^3Couldn't find resource ${t}.^7\n`),r},a=t=>{let r=e.resourcesInCategory(t);return r.length===0&&n(`^3Couldn't find resource category ${t}.^7\n`),r};t.add(`start`,[`string`],e=>{if(e===``)return;if(ls(e)){for(let t of a(e))r(`start`,t);return}let t=i(e);t!==void 0&&!t.start()&&t.state===`stopped`&&n(`^3Couldn't start resource ${e}.^7\n`)}),t.add(`stop`,[`string`],e=>{if(e===``)return;if(ls(e)){for(let t of a(e))r(`stop`,t);return}let t=i(e);t!==void 0&&!t.stop()&&t.state!==`stopped`&&n(`^3Couldn't stop resource ${e}.^7\n`)}),t.add(`restart`,[`string`],e=>{let t=i(e);t!==void 0&&(t.state===`started`?(r(`stop`,e),r(`start`,e)):n(`Can't restart a stopped resource.
4808
- `))});let o=t=>{let n=i(t);return n!==void 0&&(e.configured&&n.state===`started`&&r(`stop`,t),r(`start`,t),!0)};t.add(`ensure`,[`string`],e=>{if(!ls(e))o(e);else for(let t of a(e))if(!o(t))break}),t.add(`refresh`,[],()=>e.scanResources())}var hs=class{#e;#t=/* @__PURE__ */ new Map;#n=/* @__PURE__ */ new Map;#r=/* @__PURE__ */ new Set;constructor(e){this.#e=e}attach(e){e.onBeforeStart.connect(()=>this.#i(e),-9999),e.onStart.connect(()=>this.#o(e),9999999),e.onStop.connect(()=>this.#s(e),Mi)}#i(e){let t=[];return this.#a(e,`dependency`,t)&&this.#a(e,`dependencie`,t)&&t.length===0?!0:(t.length>0&&(this.#c(`Resource '${e.name}' can't run:\n`),t.forEach((e,t)=>this.#c(`${` ${t+1}`.padStart(3)}. ${e}\n`))),!1)}#a(e,t,n){for(let r of e.entries(t)){let t=this.#e.constraints.match(r);if(t!==`none`){t!==`pass`&&n.push(t.error);continue}let i=this.#e.getResource(r);if(i===void 0)return this.#c(`Could not find dependency ${r} for resource ${e.name}.\n`),!1;if(gs(this.#t,i.name,e.name),i.state!==`starting`&&i.state!==`started`&&!i.start())return this.#c(`Could not start dependency ${r} for resource ${e.name}.\n`),gs(this.#n,i.name,e.name),!1}return!0}#o(e){for(let t of _s(this.#n.get(e.name)))this.#e.getResource(t)?.start();this.#n.delete(e.name)}#s(e){this.#r.add(e);try{for(let t of _s(this.#t.get(e.name))){let n=this.#e.getResource(t);n!==void 0&&n.name!==e.name&&(this.#r.has(n)?this.#e.output.diagnose(n.name,`${n.name} depends on ${e.name}, which is stopping while ${n.name} stops the resources that depend on it, as happens when resources depend on each other. FiveM would stop ${n.name} again, and so on until its stack overflows, which FiveRunner does not emulate: it stops ${n.name} once.`):n.stop())}}finally{this.#r.delete(e)}this.#t.delete(e.name)}#c(e){this.#e.trace(`citizen-resources-core`,e)}};function gs(e,t,n){let r=e.get(t);r===void 0?e.set(t,/* @__PURE__ */ new Set([n])):r.add(n)}function _s(e){return[...e??[]].sort(p)}var vs=class{onTrigger=new Ni;#e;#t=/* @__PURE__ */ new Map;#n=[];#r=!1;#i=[];#a=!1;constructor(e){this.#e=e}attach(e){let t=this.#e.side===`server`?`Server`:`Client`,n=()=>E([e.name]);e.onBeforeStart.connect(()=>this.trigger(`onResourceStarting`,n()),-1e4),e.onStart.connect(()=>this.queue(`on${t}ResourceStart`,n())),e.onStart.connect(()=>{this.trigger(`onResourceStart`,n())},99999),e.onStop.connect(()=>this.queue(`on${t}ResourceStop`,n())),e.onStop.connect(()=>{this.trigger(`onResourceStop`,n())},-99999)}register(e,t){let n=this.#t.get(t);n===void 0?this.#t.set(t,[e]):n.includes(e)||n.unshift(e)}trigger(e,t,n=``,r){let i={canceled:!1};this.#n.push(i);try{if(this.#a&&e===`onResourceStop`)return!0;if(this.onTrigger.run(e,t,n),r!==void 0)r.handleEvent(e,t,n);else if(!e.startsWith(`__cfx_nui:`))for(let r of[`*`,e])for(let i of[...this.#t.get(r)??[]])this.#e.getResource(i,!1)?.handleEvent(e,t,n)}finally{this.#n.pop(),this.#r=i.canceled}return!i.canceled}holdingResourceStops(e){this.#a=!0;try{e()}finally{this.#a=!1}}queue(e,t,n=``,r){this.#i.push({name:e,payload:t,source:n,target:r})}cancel(){let e=this.#n.at(-1);e!==void 0&&(e.canceled=!0)}get lastCanceled(){return this.#r}tick(){for(let e=this.#i.shift();e!==void 0;e=this.#i.shift())this.trigger(e.name,e.payload,e.source,e.target)}};const ys={1:`Unsupported protocol`,3:`URL using bad/illegal format or missing URL`,6:`Couldn't resolve host name`,7:`Couldn't connect to server`,28:`Timeout was reached`,35:`SSL connect error`,42:`Operation was aborted by an application callback`,52:`Server returned nothing (no headers, no data)`,55:`Failed sending data to the peer`,56:`Failure when receiving data from the peer`};function bs({code:e,message:t}){return`${t} - CURL error code ${e} (${ys[e]??`Unknown error`})`}function xs(e){return/^[\t\n\v\f\r ]*$/.test(e)}function Ss(e,t){let n=new Set(e.map(([e])=>e.toLowerCase())),r=[];n.has(`user-agent`)||r.push([`User-Agent`,`FXServer/PerformHttpRequest`]),n.has(`accept`)||r.push([`Accept`,`*/*`]);for(let t of e)xs(t[1])||r.push(t);return t&&!n.has(`content-type`)&&r.push([`Content-Type`,`application/x-www-form-urlencoded`]),r}function Cs(e,t){let n=e.indexOf(`://`);if(n===-1)return e;let r=n+3,i=e.indexOf(`/`,r),a=i===-1?e.length:i,o=e.slice(r,a),s=o.indexOf(`:`),c=s===-1?o:o.slice(0,s);return c.length<=13||!c.endsWith(`.users.cfx.re`)?e:`http://localhost:${t}${e.slice(a)}`}const ws=new TextDecoder;function Ts(e){return ws.decode(Uint8Array.from(e,e=>e.charCodeAt(0)))}function Es(e){let t=e instanceof Error?e.cause:void 0;return typeof t==`object`&&t&&`code`in t?t.code:void 0}function Ds(e,t,n){if(e instanceof Error&&e.name===`AbortError`)return{code:42,message:`Callback aborted`};let r=t.port===``?t.protocol===`https:`?443:80:Number(t.port);switch(Es(e)){case`ENOTFOUND`:case`EAI_AGAIN`:return{code:6,message:`Could not resolve host: ${t.hostname}`};case`ECONNREFUSED`:return{code:7,message:`Failed to connect to ${t.hostname} port ${r} after ${n} ms: Couldn't connect to server`};case`ECONNRESET`:return{code:56,message:`Recv failure: Connection reset by peer`};case`UND_ERR_SOCKET`:return{code:52,message:`Empty reply from server`};default:{let t=e instanceof Error&&e.cause instanceof Error?e.cause:e;return{code:56,message:t instanceof Error?t.message:String(t)}}}}const Os=async e=>{let t=e.url.includes(`://`)?e.url:`http://${e.url}`,n;try{n=new URL(t)}catch{return{code:3,message:`URL rejected: Malformed input to a URL function`}}if(n.protocol!==`http:`&&n.protocol!==`https:`)return{code:1,message:`Protocol "${n.protocol.slice(0,-1)}" not supported`};let r=e.method.toUpperCase(),i=r!==`GET`&&r!==`HEAD`,a=new AbortController,o=setTimeout(()=>a.abort(),e.timeout),s=Date.now();try{let t=await fetch(n,{method:e.method,headers:e.headers.map(([e,t])=>[e,t]),body:i?e.body.slice():null,redirect:e.followLocation?`follow`:`manual`,signal:a.signal});clearTimeout(o);let r=[];for(let[e,n]of t.headers)r.push([e,Ts(n)]);return{status:t.status,headers:r,body:new Uint8Array(await t.arrayBuffer())}}catch(e){return Ds(e,n,Date.now()-s)}finally{clearTimeout(o)}};var ks=class extends Error{};const As={nil:`nil`,boolean:`a boolean`,positive:`an integer`,negative:`an integer`,float32:`a float`,float64:`a float`,str:`a string`,bin:`a binary`,array:`an array`,map:`a map`,ext:`an extension`};function js(e){let t=Za(e);if(t===void 0)throw new ks(`${As[e.type]}, which msgpack fails to convert to a string`);return t}function Ms(e){if(e.type===`str`||e.type===`bin`)return e.bytes;throw new ks(`${As[e.type]}, which msgpack fails to convert to a string`)}function Ns(e){if(e.type!==`positive`&&e.type!==`negative`)throw new ks(`${As[e.type]}, which msgpack fails to convert to an int`);if(e.value<-2147483648n||e.value>2147483647n)throw new ks(`an integer that an int does not hold, which msgpack fails to convert`);return Number(e.value)}function Ps(e){if(e.type===`array`)return e.items;throw new ks(`arguments that are no array, which msgpack fails to convert to a vector`)}function Fs(e){if(e.type!==`map`)throw new ks(`${As[e.type]}, which msgpack fails to convert to a map`);let t=/* @__PURE__ */ new Map;for(let[n,r]of e.entries){let e=Za(n);if(e===void 0)throw new ks(`a map with ${As[n.type]} for a key, which msgpack fails to convert to a string`);t.set(e,r)}return[...t].sort(([e],[t])=>p(e,t))}const Is=new TextEncoder,Ls=new TextDecoder;function Rs(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function zs(e,t){let n=Rs(e),r=Rs(t);return n<r?-1:+(n>r)}var Bs=class{#e=[];get entries(){return this.#e}get(e){return this.#e.find(([t])=>zs(t,e)===0)?.[1]}add(e,t){let n=this.#e.findIndex(([t])=>zs(t,e)>0);this.#e.splice(n===-1?this.#e.length:n,0,[e,t])}set(e,t){this.delete(e);for(let n of t)this.add(e,n)}delete(e){for(let t=this.#e.length-1;t>=0;t--)zs(this.#e[t][0],e)===0&&this.#e.splice(t,1)}},Vs=class{#e;#t=!1;get closed(){return this.#t}setCloseHandler(e){let t=this.#e;this.#e=e,t?.drop()}close(){this.#t=!0;let e=this.#e;this.#e=void 0,e?.run()}},Hs=class{status=200;headers=new Bs;#e;#t;#n;#r=!1;#i=!1;constructor(e,t,n){this.#e=e.get(`host`)??``,this.#t=t,this.#n=n}writeHead(e){this.#o(e,0)}write(e){this.#o(this.status,e.length),e.length>0&&this.#a&&this.#t.write(e)}end(e){e!==void 0&&this.write(e),this.#n.setCloseHandler(void 0),this.#r&&(this.#a&&this.#t.end(),this.#i=!0)}get#a(){return!this.#i&&!this.#n.closed}#o(e,t){this.#r||(this.#e.includes(`rockstargames.com`)||(this.headers.get(`transfer-encoding`)??``).includes(`identity`)?(this.headers.get(`content-length`)===void 0&&this.headers.set(`Content-Length`,[String(t)]),this.headers.delete(`transfer-encoding`)):(this.headers.set(`Transfer-Encoding`,[`chunked`]),this.headers.delete(`content-length`)),this.#r=!0,this.#a&&this.#t.head(e,[...this.headers.entries]))}};function Us(e,t){return e===`/`?t===`/`:Rs(t.slice(0,e.length))===Rs(e)||e.endsWith(`/`)&&t===e.slice(0,-1)}function Ws(e){return{type:`str`,bytes:typeof e==`string`?Is.encode(e):e}}function Gs(e){return{type:`ext`,extension:e}}function Ks(e){if(e?.type===`ext`&&[10,11].includes(e.extension.type))return Ls.decode(e.extension.data)}var qs=class{#e;#t=/* @__PURE__ */ new Map;#n=/* @__PURE__ */ new Map;constructor(e){this.#e=e,this.add(`/`,(e,t)=>this.#r(t))}add(e,t){this.#t.has(e)||this.#t.set(e,t)}remove(e){this.#t.delete(e)}request(e,t){let n=new Vs,r=new Bs;for(let[t,n]of e.headers)r.add(t,n);let i=new Hs(r,t,n),a=[...this.#t.keys()].sort(p).find(t=>Us(t,e.path));return a===void 0?(i.status=404,i.end(Is.encode(`Route ${e.path} not found.`))):this.#t.get(a)(e,i,n),n}setHandler(e,t){this.#n.set(e,t)}attach(e){let t=``;e.onStart.connect(()=>{let n=this.#e.console.variables.find(`monitorMode`)?.value;t=n!==void 0&&n!==`0`&&e.name===`monitor`?``:`/${e.name}/`,this.add(t,(n,r,i)=>this.#i(e,t,n,r,i))},9999),e.onStop.connect(()=>{t!==``&&this.remove(t)},-9999)}#r(e){let t=this.#e.console.variables.find(`web_baseUrl`)?.value??``,n=t.indexOf(`.users.cfx.re`),r=n===-1?-1:t.lastIndexOf(`-`,n);r===-1?e.end(Is.encode(JSON.stringify({version:h}))):(e.status=302,e.headers.set(`Location`,[`https://cfx.re/join/${t.slice(r+1,n)}`]),e.end(Is.encode(`Redirecting...`)))}#i(e,t,n,r,i){if(!this.#n.has(e)){r.status=404,r.headers.set(`Content-Type`,[`text/plain; charset=utf-8`]),r.end(Is.encode(`Not found.`));return}let a=t.endsWith(`/`)?t.length:t.length+1,o=`/${n.path.slice(a)}`;this.#e.receive(()=>this.#a(e,n,o,r,i))}#a(e,t,n,r,i){let a=this.#e,o=/* @__PURE__ */ new Map;for(let[e,n]of t.headers)o.has(e)||o.set(e,n);let s=[...o.keys()].sort(p),c=t.body.length>0?t.body:void 0,l={type:`map`,entries:[[Ws(`headers`),{type:`map`,entries:s.map(e=>[Ws(e),Ws(o.get(e))])}],[Ws(`method`),Ws(t.method)],[Ws(`address`),Ws(t.address)],[Ws(`path`),Ws(n)],[Ws(`setDataHandler`),Ys(a,`request.setDataHandler`,e=>{let t=Ks(e[0]);if(e.length>1&&js(e[1]),t===void 0||c===void 0)return;let n=c;c=void 0,a.duplicateFunctionReference(t),a.invokeFunctionReference(t,Ga({type:`array`,items:[Ws(n)]})),a.deleteFunctionReference(t)})],[Ws(`setCancelHandler`),Ys(a,`request.setCancelHandler`,e=>{let t=Ks(e[0]);t!==void 0&&(a.duplicateFunctionReference(t),i.setCloseHandler({run:()=>a.receive(()=>{a.invokeFunctionReference(t,Ga({type:`array`,items:[]})),a.deleteFunctionReference(t)}),drop:()=>a.deleteFunctionReference(t)}))})]]},u={type:`map`,entries:[[Ws(`write`),Ys(a,`response.write`,e=>r.write(Ms(e[0]??Js)))],[Ws(`writeHead`),Ys(a,`response.writeHead`,e=>{if(e.length!==1)for(let[t,n]of Fs(e[1]??Js)){let e=n.type===`array`?n.items:[n];r.headers.set(t,e.map(js))}r.status=Ns(e[0]??Js),r.writeHead(r.status)})],[Ws(`send`),Ys(a,`response.send`,e=>{r.end(e.length===0?void 0:Ms(e[0]))})]]},d=this.#n.get(e);a.invokeFunctionReference(d,Ga({type:`array`,items:[l,u]}))}};const Js={type:`nil`};function Ys(e,t,n){return Gs(e.callbacks.create(r=>{try{n(Ps(r))}catch(n){if(!(n instanceof ks))throw n;e.output.diagnose(e.currentResource?.name??``,`${t} was given ${n.message}: msgpack throws then, which FiveRunner does not emulate, and it ignores the rest of the call.`)}}))}var Xs=class{#e=/* @__PURE__ */ new Map;get(e){return this.#e.get(e)}set(e,t){this.#e.set(e,t)}delete(e){this.#e.delete(e)}keysWith(e){return[...this.#e.keys()].filter(t=>t.startsWith(e)).sort()}};function Zs(e){let{length:t}=e,n=t<32?[160|t]:t<256?[217,t]:t<65536?[218,t>>8,t&255]:[219,t>>>24,t>>16&255,t>>8&255,t&255],r=new Uint8Array(n.length+t);return r.set(n),r.set(e,n.length),r}function Qs(e){if(e>=-32&&e<128)return Uint8Array.of(e&255);let[t,n]=e<0?e>=-128?[208,1]:e>=-32768?[209,2]:[210,4]:e<256?[204,1]:e<65536?[205,2]:[206,4],r=new Uint8Array(1+n);r[0]=t;for(let t=0;t<n;t++)r[n-t]=e>>8*t&255;return r}function $s(e){let t=/* @__PURE__ */ new Uint8Array(5);return t[0]=202,new DataView(t.buffer).setFloat32(1,e),t}function ec(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=e[0],r=e=>({type:`int`,value:e}),i=(t,n)=>({type:`string`,bytes:e.subarray(t,t+n)});if(n<128)return r(n);if(n>=224)return r(n-256);if(n>>5==5)return i(1,n&31);switch(n){case 204:return r(t.getUint8(1));case 205:return r(t.getUint16(1));case 206:return r(t.getUint32(1));case 208:return r(t.getInt8(1));case 209:return r(t.getInt16(1));case 210:return r(t.getInt32(1));case 202:return{type:`float`,value:t.getFloat32(1)};case 217:return i(2,t.getUint8(1));case 218:return i(3,t.getUint16(1));case 219:return i(5,t.getUint32(1))}throw Error(`The KVP natives store no value that starts with ${n}`)}const tc=2047;var nc=class{#e;#t=[];#n;constructor(e){this.#e=e}send(e,t,n,r){let i=this.#e,a=n<=0?25e3:n,o=new TextEncoder().encode(e).length+2+t.length;if(o>=134152192){i.trace(`citizen-resources-core`,`Event ${e} is too large to be sent. Total size: ${o}, max size: 134152192.\n`);return}let s=i.time();a>=1e7&&t.length>=5e7&&(this.#n===void 0||s-this.#n>=5e3)&&(i.trace(`citizen-resources-core`,`Warning: sending large event ${e} (${t.length} bytes) with almost unrestricted bitrate (${a} b/s). This may cause performance issues. Consider decreasing objects sizes or bitrate.\n`),this.#n=s);let c=Math.ceil(o/tc),l=Math.trunc(1e3/(a/tc));for(let e of r)this.#t.push({delay:(c-1)*l,start:void 0,deliver:e})}tick(){let e=this.#e.time();for(let t of[...this.#t])t.start??=e,!(e-t.start<t.delay)&&(this.#t.splice(this.#t.indexOf(t),1),t.deliver())}},rc={source:`mime@2.4.0`,types:{"*3gpp":`audio/3gpp`,"*jpm":`video/jpm`,"*mp3":`audio/mp3`,"*rtf":`text/rtf`,"*wav":`audio/wave`,"*xml":`text/xml`,"3g2":`video/3gpp2`,"3gp":`video/3gpp`,"3gpp":`video/3gpp`,ac:`application/pkix-attr-cert`,adp:`audio/adpcm`,ai:`application/postscript`,apng:`image/apng`,appcache:`text/cache-manifest`,asc:`application/pgp-signature`,atom:`application/atom+xml`,atomcat:`application/atomcat+xml`,atomsvc:`application/atomsvc+xml`,au:`audio/basic`,aw:`application/applixware`,bdoc:`application/bdoc`,bin:`application/octet-stream`,bmp:`image/bmp`,bpk:`application/octet-stream`,buffer:`application/octet-stream`,ccxml:`application/ccxml+xml`,cdmia:`application/cdmi-capability`,cdmic:`application/cdmi-container`,cdmid:`application/cdmi-domain`,cdmio:`application/cdmi-object`,cdmiq:`application/cdmi-queue`,cer:`application/pkix-cert`,cgm:`image/cgm`,class:`application/java-vm`,coffee:`text/coffeescript`,conf:`text/plain`,cpt:`application/mac-compactpro`,crl:`application/pkix-crl`,css:`text/css`,csv:`text/csv`,cu:`application/cu-seeme`,davmount:`application/davmount+xml`,dbk:`application/docbook+xml`,deb:`application/octet-stream`,def:`text/plain`,deploy:`application/octet-stream`,"disposition-notification":`message/disposition-notification`,dist:`application/octet-stream`,distz:`application/octet-stream`,dll:`application/octet-stream`,dmg:`application/octet-stream`,dms:`application/octet-stream`,doc:`application/msword`,dot:`application/msword`,drle:`image/dicom-rle`,dssc:`application/dssc+der`,dtd:`application/xml-dtd`,dump:`application/octet-stream`,ear:`application/java-archive`,ecma:`application/ecmascript`,elc:`application/octet-stream`,emf:`image/emf`,eml:`message/rfc822`,emma:`application/emma+xml`,eps:`application/postscript`,epub:`application/epub+zip`,es:`application/ecmascript`,exe:`application/octet-stream`,exi:`application/exi`,exr:`image/aces`,ez:`application/andrew-inset`,fits:`image/fits`,g3:`image/g3fax`,gbr:`application/rpki-ghostbusters`,geojson:`application/geo+json`,gif:`image/gif`,glb:`model/gltf-binary`,gltf:`model/gltf+json`,gml:`application/gml+xml`,gpx:`application/gpx+xml`,gram:`application/srgs`,grxml:`application/srgs+xml`,gxf:`application/gxf`,gz:`application/gzip`,h261:`video/h261`,h263:`video/h263`,h264:`video/h264`,heic:`image/heic`,heics:`image/heic-sequence`,heif:`image/heif`,heifs:`image/heif-sequence`,hjson:`application/hjson`,hlp:`application/winhlp`,hqx:`application/mac-binhex40`,htm:`text/html`,html:`text/html`,ics:`text/calendar`,ief:`image/ief`,ifb:`text/calendar`,iges:`model/iges`,igs:`model/iges`,img:`application/octet-stream`,in:`text/plain`,ini:`text/plain`,ink:`application/inkml+xml`,inkml:`application/inkml+xml`,ipfix:`application/ipfix`,iso:`application/octet-stream`,jade:`text/jade`,jar:`application/java-archive`,jls:`image/jls`,jp2:`image/jp2`,jpe:`image/jpeg`,jpeg:`image/jpeg`,jpf:`image/jpx`,jpg:`image/jpeg`,jpg2:`image/jp2`,jpgm:`video/jpm`,jpgv:`video/jpeg`,jpm:`image/jpm`,jpx:`image/jpx`,js:`application/javascript`,json:`application/json`,json5:`application/json5`,jsonld:`application/ld+json`,jsonml:`application/jsonml+json`,jsx:`text/jsx`,kar:`audio/midi`,ktx:`image/ktx`,less:`text/less`,list:`text/plain`,litcoffee:`text/coffeescript`,log:`text/plain`,lostxml:`application/lost+xml`,lrf:`application/octet-stream`,m1v:`video/mpeg`,m21:`application/mp21`,m2a:`audio/mpeg`,m2v:`video/mpeg`,m3a:`audio/mpeg`,m4a:`audio/mp4`,m4p:`application/mp4`,ma:`application/mathematica`,mads:`application/mads+xml`,man:`text/troff`,manifest:`text/cache-manifest`,map:`application/json`,mar:`application/octet-stream`,markdown:`text/markdown`,mathml:`application/mathml+xml`,mb:`application/mathematica`,mbox:`application/mbox`,md:`text/markdown`,me:`text/troff`,mesh:`model/mesh`,meta4:`application/metalink4+xml`,metalink:`application/metalink+xml`,mets:`application/mets+xml`,mft:`application/rpki-manifest`,mid:`audio/midi`,midi:`audio/midi`,mime:`message/rfc822`,mj2:`video/mj2`,mjp2:`video/mj2`,mjs:`application/javascript`,mml:`text/mathml`,mods:`application/mods+xml`,mov:`video/quicktime`,mp2:`audio/mpeg`,mp21:`application/mp21`,mp2a:`audio/mpeg`,mp3:`audio/mpeg`,mp4:`video/mp4`,mp4a:`audio/mp4`,mp4s:`application/mp4`,mp4v:`video/mp4`,mpd:`application/dash+xml`,mpe:`video/mpeg`,mpeg:`video/mpeg`,mpg:`video/mpeg`,mpg4:`video/mp4`,mpga:`audio/mpeg`,mrc:`application/marc`,mrcx:`application/marcxml+xml`,ms:`text/troff`,mscml:`application/mediaservercontrol+xml`,msh:`model/mesh`,msi:`application/octet-stream`,msm:`application/octet-stream`,msp:`application/octet-stream`,mxf:`application/mxf`,mxml:`application/xv+xml`,n3:`text/n3`,nb:`application/mathematica`,oda:`application/oda`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,ogx:`application/ogg`,omdoc:`application/omdoc+xml`,onepkg:`application/onenote`,onetmp:`application/onenote`,onetoc:`application/onenote`,onetoc2:`application/onenote`,opf:`application/oebps-package+xml`,otf:`font/otf`,owl:`application/rdf+xml`,oxps:`application/oxps`,p10:`application/pkcs10`,p7c:`application/pkcs7-mime`,p7m:`application/pkcs7-mime`,p7s:`application/pkcs7-signature`,p8:`application/pkcs8`,pdf:`application/pdf`,pfr:`application/font-tdpfr`,pgp:`application/pgp-encrypted`,pkg:`application/octet-stream`,pki:`application/pkixcmp`,pkipath:`application/pkix-pkipath`,pls:`application/pls+xml`,png:`image/png`,prf:`application/pics-rules`,ps:`application/postscript`,pskcxml:`application/pskc+xml`,qt:`video/quicktime`,raml:`application/raml+yaml`,rdf:`application/rdf+xml`,rif:`application/reginfo+xml`,rl:`application/resource-lists+xml`,rld:`application/resource-lists-diff+xml`,rmi:`audio/midi`,rnc:`application/relax-ng-compact-syntax`,rng:`application/xml`,roa:`application/rpki-roa`,roff:`text/troff`,rq:`application/sparql-query`,rs:`application/rls-services+xml`,rsd:`application/rsd+xml`,rss:`application/rss+xml`,rtf:`application/rtf`,rtx:`text/richtext`,s3m:`audio/s3m`,sbml:`application/sbml+xml`,scq:`application/scvp-cv-request`,scs:`application/scvp-cv-response`,sdp:`application/sdp`,ser:`application/java-serialized-object`,setpay:`application/set-payment-initiation`,setreg:`application/set-registration-initiation`,sgi:`image/sgi`,sgm:`text/sgml`,sgml:`text/sgml`,shex:`text/shex`,shf:`application/shf+xml`,shtml:`text/html`,sig:`application/pgp-signature`,sil:`audio/silk`,silo:`model/mesh`,slim:`text/slim`,slm:`text/slim`,smi:`application/smil+xml`,smil:`application/smil+xml`,snd:`audio/basic`,so:`application/octet-stream`,spp:`application/scvp-vp-response`,spq:`application/scvp-vp-request`,spx:`audio/ogg`,sru:`application/sru+xml`,srx:`application/sparql-results+xml`,ssdl:`application/ssdl+xml`,ssml:`application/ssml+xml`,stk:`application/hyperstudio`,styl:`text/stylus`,stylus:`text/stylus`,svg:`image/svg+xml`,svgz:`image/svg+xml`,t:`text/troff`,t38:`image/t38`,tei:`application/tei+xml`,teicorpus:`application/tei+xml`,text:`text/plain`,tfi:`application/thraud+xml`,tfx:`image/tiff-fx`,tif:`image/tiff`,tiff:`image/tiff`,tr:`text/troff`,ts:`video/mp2t`,tsd:`application/timestamped-data`,tsv:`text/tab-separated-values`,ttc:`font/collection`,ttf:`font/ttf`,ttl:`text/turtle`,txt:`text/plain`,u8dsn:`message/global-delivery-status`,u8hdr:`message/global-headers`,u8mdn:`message/global-disposition-notification`,u8msg:`message/global`,uri:`text/uri-list`,uris:`text/uri-list`,urls:`text/uri-list`,vcard:`text/vcard`,vrml:`model/vrml`,vtt:`text/vtt`,vxml:`application/voicexml+xml`,war:`application/java-archive`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,webmanifest:`application/manifest+json`,webp:`image/webp`,wgt:`application/widget`,wmf:`image/wmf`,woff:`font/woff`,woff2:`font/woff2`,wrl:`model/vrml`,wsdl:`application/wsdl+xml`,wspolicy:`application/wspolicy+xml`,x3d:`model/x3d+xml`,x3db:`model/x3d+binary`,x3dbz:`model/x3d+binary`,x3dv:`model/x3d+vrml`,x3dvz:`model/x3d+vrml`,x3dz:`model/x3d+xml`,xaml:`application/xaml+xml`,xdf:`application/xcap-diff+xml`,xdssc:`application/dssc+xml`,xenc:`application/xenc+xml`,xer:`application/patch-ops-error+xml`,xht:`application/xhtml+xml`,xhtml:`application/xhtml+xml`,xhvml:`application/xv+xml`,xm:`audio/xm`,xml:`application/xml`,xop:`application/xop+xml`,xpl:`application/xproc+xml`,xsd:`application/xml`,xsl:`application/xml`,xslt:`application/xslt+xml`,xspf:`application/xspf+xml`,xvm:`application/xv+xml`,xvml:`application/xv+xml`,yaml:`text/yaml`,yang:`application/yang`,yin:`application/yin+xml`,yml:`text/yaml`,zip:`application/zip`}};const ic=`nui-resources`,ac=`A NUI callback answered with what FiveM fails to convert, which throws in FiveM, and leaves the request unanswered in FiveRunner.`,oc=new TextEncoder,sc={type:`nil`},cc=new Map(Object.entries(rc.types)),lc=/* @__PURE__ */ new Set([`text/html`,`text/css`,`application/javascript`]);var uc=class{onCreate=new Ni;onDestroy=new Ni;onMessage=new Ni;onFrameFocus=new Ni;onFocus=new Ni;onKeepInput=new Ni;onZIndex=new Ni;cursor={x:0,y:0};#e;#t=/* @__PURE__ */ new WeakMap;#n=/* @__PURE__ */ new Set;#r=/* @__PURE__ */ new Set;#i=/* @__PURE__ */ new Set;#a=/* @__PURE__ */ new Set;#o=!1;#s=!1;#c=!1;constructor(e){this.#e=e}attach(e){let t={callbacks:/* @__PURE__ */ new Map,frame:void 0,dead:!1,strict:!1};this.#t.set(e,t),e.onStart.connect(()=>this.#u(e,t)),e.onStop.connect(()=>{t.dead=!0,t.frame!==void 0&&(t.frame=void 0,this.onDestroy.run(e.name)),this.#n.delete(e.name),this.#r.delete(e.name),this.#i.delete(e.name),this.#f()})}get frames(){let e=[];for(let t of this.#e.resources){let n=this.#t.get(t)?.frame;n!==void 0&&e.push(n)}return e}get focused(){return this.#o}get cursorShown(){return this.#s}get keepingInput(){return this.#c}request(e,t){return new Promise(n=>{let r=this.#l(e),i=r===void 0?void 0:this.#t.get(r),a=t.path.slice(1),o=i?.callbacks.has(a)===!0?a:a.split(`/`,1)[0],s=i?.callbacks.get(o)?.slice();if(r===void 0||i===void 0||s===void 0){n(gc(404,[],/* @__PURE__ */ new Uint8Array));return}let c=hc(t.headers);if(i.strict&&c!==r.name){this.#e.trace(ic,`ResourceUI::InvokeCallback: call to '${r.name}/${a}' from '${c??`(null)`}' has been blocked by NUI Callback Strict Mode\n`),n(gc(404,[],/* @__PURE__ */ new Uint8Array));return}let l=t.method===`POST`?t.body:/* @__PURE__ */ new Uint8Array;this.#e.enqueue(()=>{if(!i.dead)for(let e of s)this.#d(r,o,e,{...t,body:l},a,c,n)})})}file(e,t){let n=this.#l(e.startsWith(`cfx-nui-`)?e.slice(8):e),r=n===void 0||t.includes(`..`)||fc(n,t)?void 0:this.#e.files.read(C(`${n.path}/${t}`)),i=r===void 0?`text/html`:cc.get(t.slice(t.lastIndexOf(`.`)+1))??`text/html`;return{status:r===void 0?404:200,headers:mc([[`content-type`,lc.has(i)?`${i}; charset=utf-8`:i],[`access-control-allow-origin`,`*`],[`access-control-allow-methods`,`GET, OPTIONS`],[`cache-control`,`no-cache, must-revalidate`]]),body:r??/* @__PURE__ */ new Uint8Array}}register(e,t,n){let r=this.#t.get(e).callbacks,i=r.get(t);i===void 0?r.set(t,[n]):i.push(n)}unregister(e,t){this.#t.get(e).callbacks.delete(t)}send(e,t){if(this.#t.get(e)?.frame===void 0)return this.#e.trace(ic,`SEND_NUI_MESSAGE: resource ${e.name} has no UI frame\n`),!1;if(t===null)return this.#e.output.diagnose(e.name,`SendNuiMessage was given no JSON: FiveM would read it from nowhere, and crash. FiveRunner sends nothing.`),!1;let n=ya(t);return`error`in n?(this.#e.trace(ic,`SEND_NUI_MESSAGE: invalid JSON passed in frame (rapidjson error code ${n.error})\n`),!1):(e.name.includes(`"`)||this.onMessage.run(e.name,n.json),!0)}setFocus(e,t,n){this.#t.get(e)?.frame===void 0||e.name.includes(`"`)||(this.onFrameFocus.run(e.name,t),dc(this.#n,e.name,t),dc(this.#r,e.name,n),this.#f())}setKeepInput(e,t){dc(this.#i,e.name,t),this.#f()}setZIndex(e,t){this.#t.get(e)?.frame===void 0||e.name.includes(`"`)||this.onZIndex.run(e.name,t)}takes(e,t){let n=f(t),r=e===`https`&&n.startsWith(`cfx-nui-`)?n.slice(8):n;return this.#a.has(r)}#l(e){let t;for(let n of this.#e.resources)f(n.name)===f(e)&&(t=n);return t}#u(e,t){t.dead=!1,this.#a.add(f(e.name));let n=e.entries(`ui_page`);if(n.length===0)return;if(n.length>1){this.#e.trace(ic,`ResourceUI::Create: more than one ui_page in resource ${e.name}\n`);return}let r=n[0],i=zo(e.metadata,`cerulean`)?`https://cfx-nui-`:`nui://`;t.frame={resource:e.name,url:r.includes(`://`)?r:`${i}${e.name}/${r}`},e.entries(`nui_callback_strict_mode`)[0]===`true`&&(t.strict=!0),this.onCreate.run(t.frame)}#d(e,t,n,r,i,a,o){let s=this.#e;if(n.kind===`raw`){let c=s.callbacks.create(t=>{let n=t.type===`array`?t.items:[];if(n.length!==1)return;let r=vc(n[0]);r===void 0?s.output.diagnose(e.name,ac):o(r)}),l=_c(r,i.slice(t.length)+(r.query===``?``:`?${r.query}`),a);s.invokeFunctionReference(n.ref,Ga({type:`array`,items:[l,{type:`ext`,extension:c}]}));return}let c=r.body.length===0?sc:va(r.body);if(c===void 0)return;let l=Ga({type:`array`,items:[c,{type:`ext`,extension:s.callbacks.create(t=>{let n=t.type===`array`?t.items:[];if(n.length!==1)return;let r;try{r=Qa(n[0])}catch(t){if(!(t instanceof TypeError))throw t;s.output.diagnose(e.name,ac);return}r!==void 0&&o(gc(200,[[`Content-Type`,`application/json; charset=utf-8`]],oc.encode(r)))})}]});n.kind===`event`?s.events.queue(`__cfx_nui:${t}`,l,`nui`,e):s.invokeFunctionReference(n.ref,l)}#f(){let e=this.#n.size>0,t=this.#r.size>0;(e!==this.#o||t!==this.#s)&&(this.#o=e,this.#s=t,this.onFocus.run(e,t));let n=!1;for(let e of this.#i)(this.#n.has(e)||this.#r.has(e))&&(n=!0);n!==this.#c&&(this.#c=n,this.onKeepInput.run(n))}};function dc(e,t,n){n?e.add(t):e.delete(t)}function fc(e,t){let n=t.replace(/^\/+|\/(?=\/)/g,``);return pc(n,`fxmanifest.lua`)||pc(n,`__resource.lua`)?!0:e.globEntries(`client_script`).some(e=>pc(n,e))&&!e.globEntries(`file`).some(e=>pc(n,e))}function pc(e,t){return e===t||e.startsWith(`${t}/`)}function mc(e){return e.sort(([e],[t])=>p(e,t))}function hc(e){let t=e.find(([e])=>e===`Origin`)?.[1];for(let e of[`nui://`,`https://cfx-nui-`])if(t?.startsWith(e))return t.slice(e.length)}function gc(e,t,n){let r=e=>t.some(([t])=>f(t)===e),i=[...t];return r(`content-type`)||i.push([`content-type`,`application/json`]),i.push([`cache-control`,`no-cache, must-revalidate`]),r(`access-control-allow-origin`)||i.push([`access-control-allow-origin`,`*`]),r(`access-control-allow-methods`)||i.push([`access-control-allow-methods`,`POST, GET, OPTIONS`]),{status:e,headers:mc(i),body:n}}function _c(e,t,n){let r=e=>({type:`str`,bytes:typeof e==`string`?oc.encode(e):e}),i=mc([...e.headers]),a=/* @__PURE__ */ new Map;for(let[e,t]of i)a.has(e)||a.set(e,t);return{type:`map`,entries:[[r(`headers`),{type:`map`,entries:[...a].map(([e,t])=>[r(e),r(t)])}],[r(`rawHeaders`),{type:`array`,items:i.map(([e,t])=>({type:`map`,entries:[[r(`key`),r(e)],[r(`value`),r(t)]]}))}],[r(`method`),r(e.body.length===0?`GET`:`POST`)],[r(`path`),r(t)],[r(`body`),r(e.body)],[r(`resource`),n===void 0?sc:r(n)]]}}function vc(e){if(e.type!==`map`)return;let t=200,n=/* @__PURE__ */ new Uint8Array,r=[];for(let[i,a]of e.entries){let e=Za(i);if(e===void 0)return;if(e===`status`){if(a.type!==`positive`&&a.type!==`negative`||a.value<-2147483648n||a.value>2147483647n)return;t=Number(a.value)}else if(e===`body`){if(a.type!==`str`&&a.type!==`bin`)return;n=a.bytes}else if(e===`headers`&&a.type!==`array`){if(a.type!==`map`)return;for(let[e,t]of a.entries){let n=Za(e);if(n===void 0)return;for(let e of t.type===`array`?t.items:[t]){let t=Za(e);if(t===void 0)return;r.push([f(n),t])}}}}return gc(t,r,n)}const yc=new TextDecoder,bc=new TextEncoder,xc=/* @__PURE__ */ new Set([10,11]);function Sc(e){let t=(()=>{throw Error(`FiveRunner calls no functions of other runtimes from JavaScript`)});return Object.defineProperty(t,"reference",{value:e}),t}function Cc(e){switch(e.type){case`nil`:return null;case`boolean`:return e.value;case`positive`:case`negative`:return Number(e.value);case`float32`:case`float64`:return e.value;case`str`:return yc.decode(e.bytes);case`bin`:{let t=new ArrayBuffer(e.bytes.length);return new Uint8Array(t).set(e.bytes),t}case`array`:return e.items.map(Cc);case`map`:{let t={};for(let[n,r]of e.entries)t[String(Cc(n))]=Cc(r);return t}case`ext`:return xc.has(e.extension.type)?Sc(e.extension):{}}}function wc(e){return e<0?{type:`negative`,value:BigInt(e)}:{type:`positive`,value:BigInt(e)}}function Tc(e){if(e==null)return{type:`nil`};switch(typeof e){case`boolean`:return{type:`boolean`,value:e};case`number`:return(e|0)===e?wc(e|0):{type:`float64`,value:e};case`string`:return{type:`str`,bytes:bc.encode(e)};case`function`:{let t=e.reference;return t===void 0?{type:`nil`}:{type:`ext`,extension:t}}}return e instanceof Uint8Array?{type:`bin`,bytes:e}:e instanceof ArrayBuffer?{type:`bin`,bytes:new Uint8Array(e)}:Array.isArray(e)?{type:`array`,items:e.map(Tc)}:{type:`map`,entries:Object.keys(e).map(t=>[{type:`str`,bytes:bc.encode(t)},Tc(e[t])])}}function Ec(e){return JSON.stringify(e)??`undefined`}function Dc(e){return typeof e==`function`}var O=class extends Error{name=`SqlError`;errno;sqlState;constructor(e,t,n){super(n),this.errno=e,this.sqlState=t}};const Oc=[`<=>`,`->>`,`<<`,`>>`,`<=`,`>=`,`<>`,`!=`,`||`,`&&`,`:=`,`->`],kc={0:`\0`,b:`\b`,n:`
4808
+ `))});let o=t=>{let n=i(t);return n!==void 0&&(e.configured&&n.state===`started`&&r(`stop`,t),r(`start`,t),!0)};t.add(`ensure`,[`string`],e=>{if(!ls(e))o(e);else for(let t of a(e))if(!o(t))break}),t.add(`refresh`,[],()=>e.scanResources())}var hs=class{#e;#t=/* @__PURE__ */ new Map;#n=/* @__PURE__ */ new Map;#r=/* @__PURE__ */ new Set;constructor(e){this.#e=e}attach(e){e.onBeforeStart.connect(()=>this.#i(e),-9999),e.onStart.connect(()=>this.#o(e),9999999),e.onStop.connect(()=>this.#s(e),Mi)}#i(e){let t=[];return this.#a(e,`dependency`,t)&&this.#a(e,`dependencie`,t)&&t.length===0?!0:(t.length>0&&(this.#c(`Resource '${e.name}' can't run:\n`),t.forEach((e,t)=>this.#c(`${` ${t+1}`.padStart(3)}. ${e}\n`))),!1)}#a(e,t,n){for(let r of e.entries(t)){let t=this.#e.constraints.match(r);if(t!==`none`){t!==`pass`&&n.push(t.error);continue}let i=this.#e.getResource(r);if(i===void 0)return this.#c(`Could not find dependency ${r} for resource ${e.name}.\n`),!1;if(gs(this.#t,i.name,e.name),i.state!==`starting`&&i.state!==`started`&&!i.start())return this.#c(`Could not start dependency ${r} for resource ${e.name}.\n`),gs(this.#n,i.name,e.name),!1}return!0}#o(e){for(let t of _s(this.#n.get(e.name)))this.#e.getResource(t)?.start();this.#n.delete(e.name)}#s(e){this.#r.add(e);try{for(let t of _s(this.#t.get(e.name))){let n=this.#e.getResource(t);n!==void 0&&n.name!==e.name&&(this.#r.has(n)?this.#e.output.diagnose(n.name,`${n.name} depends on ${e.name}, which is stopping while ${n.name} stops the resources that depend on it, as happens when resources depend on each other. FiveM would stop ${n.name} again, and so on until its stack overflows, which FiveRunner does not emulate: it stops ${n.name} once.`):n.stop())}}finally{this.#r.delete(e)}this.#t.delete(e.name)}#c(e){this.#e.trace(`citizen-resources-core`,e)}};function gs(e,t,n){let r=e.get(t);r===void 0?e.set(t,/* @__PURE__ */ new Set([n])):r.add(n)}function _s(e){return[...e??[]].sort(p)}var vs=class{onTrigger=new Ni;#e;#t=/* @__PURE__ */ new Map;#n=[];#r=!1;#i=[];#a=!1;constructor(e){this.#e=e}attach(e){let t=this.#e.side===`server`?`Server`:`Client`,n=()=>E([e.name]);e.onBeforeStart.connect(()=>this.trigger(`onResourceStarting`,n()),-1e4),e.onStart.connect(()=>this.queue(`on${t}ResourceStart`,n())),e.onStart.connect(()=>{this.trigger(`onResourceStart`,n())},99999),e.onStop.connect(()=>this.queue(`on${t}ResourceStop`,n())),e.onStop.connect(()=>{this.trigger(`onResourceStop`,n())},-99999)}register(e,t){let n=this.#t.get(t);n===void 0?this.#t.set(t,[e]):n.includes(e)||n.unshift(e)}registered(){return[...this.#t].map(([e,t])=>[e,[...t]])}trigger(e,t,n=``,r){let i={canceled:!1};this.#n.push(i);try{if(this.#a&&e===`onResourceStop`)return!0;if(this.onTrigger.run(e,t,n),r!==void 0)r.handleEvent(e,t,n);else if(!e.startsWith(`__cfx_nui:`))for(let r of[`*`,e])for(let i of[...this.#t.get(r)??[]])this.#e.getResource(i,!1)?.handleEvent(e,t,n)}finally{this.#n.pop(),this.#r=i.canceled}return!i.canceled}holdingResourceStops(e){this.#a=!0;try{e()}finally{this.#a=!1}}queue(e,t,n=``,r){this.#i.push({name:e,payload:t,source:n,target:r})}cancel(){let e=this.#n.at(-1);e!==void 0&&(e.canceled=!0)}get lastCanceled(){return this.#r}tick(){for(let e=this.#i.shift();e!==void 0;e=this.#i.shift())this.trigger(e.name,e.payload,e.source,e.target)}};const ys={1:`Unsupported protocol`,3:`URL using bad/illegal format or missing URL`,6:`Couldn't resolve host name`,7:`Couldn't connect to server`,28:`Timeout was reached`,35:`SSL connect error`,42:`Operation was aborted by an application callback`,52:`Server returned nothing (no headers, no data)`,55:`Failed sending data to the peer`,56:`Failure when receiving data from the peer`};function bs({code:e,message:t}){return`${t} - CURL error code ${e} (${ys[e]??`Unknown error`})`}function xs(e){return/^[\t\n\v\f\r ]*$/.test(e)}function Ss(e,t){let n=new Set(e.map(([e])=>e.toLowerCase())),r=[];n.has(`user-agent`)||r.push([`User-Agent`,`FXServer/PerformHttpRequest`]),n.has(`accept`)||r.push([`Accept`,`*/*`]);for(let t of e)xs(t[1])||r.push(t);return t&&!n.has(`content-type`)&&r.push([`Content-Type`,`application/x-www-form-urlencoded`]),r}function Cs(e,t){let n=e.indexOf(`://`);if(n===-1)return e;let r=n+3,i=e.indexOf(`/`,r),a=i===-1?e.length:i,o=e.slice(r,a),s=o.indexOf(`:`),c=s===-1?o:o.slice(0,s);return c.length<=13||!c.endsWith(`.users.cfx.re`)?e:`http://localhost:${t}${e.slice(a)}`}const ws=new TextDecoder;function Ts(e){return ws.decode(Uint8Array.from(e,e=>e.charCodeAt(0)))}function Es(e){let t=e instanceof Error?e.cause:void 0;return typeof t==`object`&&t&&`code`in t?t.code:void 0}function Ds(e,t,n){if(e instanceof Error&&e.name===`AbortError`)return{code:42,message:`Callback aborted`};let r=t.port===``?t.protocol===`https:`?443:80:Number(t.port);switch(Es(e)){case`ENOTFOUND`:case`EAI_AGAIN`:return{code:6,message:`Could not resolve host: ${t.hostname}`};case`ECONNREFUSED`:return{code:7,message:`Failed to connect to ${t.hostname} port ${r} after ${n} ms: Couldn't connect to server`};case`ECONNRESET`:return{code:56,message:`Recv failure: Connection reset by peer`};case`UND_ERR_SOCKET`:return{code:52,message:`Empty reply from server`};default:{let t=e instanceof Error&&e.cause instanceof Error?e.cause:e;return{code:56,message:t instanceof Error?t.message:String(t)}}}}const Os=async e=>{let t=e.url.includes(`://`)?e.url:`http://${e.url}`,n;try{n=new URL(t)}catch{return{code:3,message:`URL rejected: Malformed input to a URL function`}}if(n.protocol!==`http:`&&n.protocol!==`https:`)return{code:1,message:`Protocol "${n.protocol.slice(0,-1)}" not supported`};let r=e.method.toUpperCase(),i=r!==`GET`&&r!==`HEAD`,a=new AbortController,o=setTimeout(()=>a.abort(),e.timeout),s=Date.now();try{let t=await fetch(n,{method:e.method,headers:e.headers.map(([e,t])=>[e,t]),body:i?e.body.slice():null,redirect:e.followLocation?`follow`:`manual`,signal:a.signal});clearTimeout(o);let r=[];for(let[e,n]of t.headers)r.push([e,Ts(n)]);return{status:t.status,headers:r,body:new Uint8Array(await t.arrayBuffer())}}catch(e){return Ds(e,n,Date.now()-s)}finally{clearTimeout(o)}};var ks=class extends Error{};const As={nil:`nil`,boolean:`a boolean`,positive:`an integer`,negative:`an integer`,float32:`a float`,float64:`a float`,str:`a string`,bin:`a binary`,array:`an array`,map:`a map`,ext:`an extension`};function js(e){let t=Za(e);if(t===void 0)throw new ks(`${As[e.type]}, which msgpack fails to convert to a string`);return t}function Ms(e){if(e.type===`str`||e.type===`bin`)return e.bytes;throw new ks(`${As[e.type]}, which msgpack fails to convert to a string`)}function Ns(e){if(e.type!==`positive`&&e.type!==`negative`)throw new ks(`${As[e.type]}, which msgpack fails to convert to an int`);if(e.value<-2147483648n||e.value>2147483647n)throw new ks(`an integer that an int does not hold, which msgpack fails to convert`);return Number(e.value)}function Ps(e){if(e.type===`array`)return e.items;throw new ks(`arguments that are no array, which msgpack fails to convert to a vector`)}function Fs(e){if(e.type!==`map`)throw new ks(`${As[e.type]}, which msgpack fails to convert to a map`);let t=/* @__PURE__ */ new Map;for(let[n,r]of e.entries){let e=Za(n);if(e===void 0)throw new ks(`a map with ${As[n.type]} for a key, which msgpack fails to convert to a string`);t.set(e,r)}return[...t].sort(([e],[t])=>p(e,t))}const Is=new TextEncoder,Ls=new TextDecoder;function Rs(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function zs(e,t){let n=Rs(e),r=Rs(t);return n<r?-1:+(n>r)}var Bs=class{#e=[];get entries(){return this.#e}get(e){return this.#e.find(([t])=>zs(t,e)===0)?.[1]}add(e,t){let n=this.#e.findIndex(([t])=>zs(t,e)>0);this.#e.splice(n===-1?this.#e.length:n,0,[e,t])}set(e,t){this.delete(e);for(let n of t)this.add(e,n)}delete(e){for(let t=this.#e.length-1;t>=0;t--)zs(this.#e[t][0],e)===0&&this.#e.splice(t,1)}},Vs=class{#e;#t=!1;get closed(){return this.#t}setCloseHandler(e){let t=this.#e;this.#e=e,t?.drop()}close(){this.#t=!0;let e=this.#e;this.#e=void 0,e?.run()}},Hs=class{status=200;headers=new Bs;#e;#t;#n;#r=!1;#i=!1;constructor(e,t,n){this.#e=e.get(`host`)??``,this.#t=t,this.#n=n}writeHead(e){this.#o(e,0)}write(e){this.#o(this.status,e.length),e.length>0&&this.#a&&this.#t.write(e)}end(e){e!==void 0&&this.write(e),this.#n.setCloseHandler(void 0),this.#r&&(this.#a&&this.#t.end(),this.#i=!0)}get#a(){return!this.#i&&!this.#n.closed}#o(e,t){this.#r||(this.#e.includes(`rockstargames.com`)||(this.headers.get(`transfer-encoding`)??``).includes(`identity`)?(this.headers.get(`content-length`)===void 0&&this.headers.set(`Content-Length`,[String(t)]),this.headers.delete(`transfer-encoding`)):(this.headers.set(`Transfer-Encoding`,[`chunked`]),this.headers.delete(`content-length`)),this.#r=!0,this.#a&&this.#t.head(e,[...this.headers.entries]))}};function Us(e,t){return e===`/`?t===`/`:Rs(t.slice(0,e.length))===Rs(e)||e.endsWith(`/`)&&t===e.slice(0,-1)}function Ws(e){return{type:`str`,bytes:typeof e==`string`?Is.encode(e):e}}function Gs(e){return{type:`ext`,extension:e}}function Ks(e){if(e?.type===`ext`&&[10,11].includes(e.extension.type))return Ls.decode(e.extension.data)}var qs=class{#e;#t=/* @__PURE__ */ new Map;#n=/* @__PURE__ */ new Map;constructor(e){this.#e=e,this.add(`/`,(e,t)=>this.#r(t))}add(e,t){this.#t.has(e)||this.#t.set(e,t)}remove(e){this.#t.delete(e)}request(e,t){let n=new Vs,r=new Bs;for(let[t,n]of e.headers)r.add(t,n);let i=new Hs(r,t,n),a=[...this.#t.keys()].sort(p).find(t=>Us(t,e.path));return a===void 0?(i.status=404,i.end(Is.encode(`Route ${e.path} not found.`))):this.#t.get(a)(e,i,n),n}setHandler(e,t){this.#n.set(e,t)}attach(e){let t=``;e.onStart.connect(()=>{let n=this.#e.console.variables.find(`monitorMode`)?.value;t=n!==void 0&&n!==`0`&&e.name===`monitor`?``:`/${e.name}/`,this.add(t,(n,r,i)=>this.#i(e,t,n,r,i))},9999),e.onStop.connect(()=>{t!==``&&this.remove(t)},-9999)}#r(e){let t=this.#e.console.variables.find(`web_baseUrl`)?.value??``,n=t.indexOf(`.users.cfx.re`),r=n===-1?-1:t.lastIndexOf(`-`,n);r===-1?e.end(Is.encode(JSON.stringify({version:h}))):(e.status=302,e.headers.set(`Location`,[`https://cfx.re/join/${t.slice(r+1,n)}`]),e.end(Is.encode(`Redirecting...`)))}#i(e,t,n,r,i){if(!this.#n.has(e)){r.status=404,r.headers.set(`Content-Type`,[`text/plain; charset=utf-8`]),r.end(Is.encode(`Not found.`));return}let a=t.endsWith(`/`)?t.length:t.length+1,o=`/${n.path.slice(a)}`;this.#e.receive(()=>this.#a(e,n,o,r,i))}#a(e,t,n,r,i){let a=this.#e,o=/* @__PURE__ */ new Map;for(let[e,n]of t.headers)o.has(e)||o.set(e,n);let s=[...o.keys()].sort(p),c=t.body.length>0?t.body:void 0,l={type:`map`,entries:[[Ws(`headers`),{type:`map`,entries:s.map(e=>[Ws(e),Ws(o.get(e))])}],[Ws(`method`),Ws(t.method)],[Ws(`address`),Ws(t.address)],[Ws(`path`),Ws(n)],[Ws(`setDataHandler`),Ys(a,`request.setDataHandler`,e=>{let t=Ks(e[0]);if(e.length>1&&js(e[1]),t===void 0||c===void 0)return;let n=c;c=void 0,a.duplicateFunctionReference(t),a.invokeFunctionReference(t,Ga({type:`array`,items:[Ws(n)]})),a.deleteFunctionReference(t)})],[Ws(`setCancelHandler`),Ys(a,`request.setCancelHandler`,e=>{let t=Ks(e[0]);t!==void 0&&(a.duplicateFunctionReference(t),i.setCloseHandler({run:()=>a.receive(()=>{a.invokeFunctionReference(t,Ga({type:`array`,items:[]})),a.deleteFunctionReference(t)}),drop:()=>a.deleteFunctionReference(t)}))})]]},u={type:`map`,entries:[[Ws(`write`),Ys(a,`response.write`,e=>r.write(Ms(e[0]??Js)))],[Ws(`writeHead`),Ys(a,`response.writeHead`,e=>{if(e.length!==1)for(let[t,n]of Fs(e[1]??Js)){let e=n.type===`array`?n.items:[n];r.headers.set(t,e.map(js))}r.status=Ns(e[0]??Js),r.writeHead(r.status)})],[Ws(`send`),Ys(a,`response.send`,e=>{r.end(e.length===0?void 0:Ms(e[0]))})]]},d=this.#n.get(e);a.invokeFunctionReference(d,Ga({type:`array`,items:[l,u]}))}};const Js={type:`nil`};function Ys(e,t,n){return Gs(e.callbacks.create(r=>{try{n(Ps(r))}catch(n){if(!(n instanceof ks))throw n;e.output.diagnose(e.currentResource?.name??``,`${t} was given ${n.message}: msgpack throws then, which FiveRunner does not emulate, and it ignores the rest of the call.`)}}))}var Xs=class{#e=/* @__PURE__ */ new Map;get(e){return this.#e.get(e)}set(e,t){this.#e.set(e,t)}delete(e){this.#e.delete(e)}keysWith(e){return[...this.#e.keys()].filter(t=>t.startsWith(e)).sort()}};function Zs(e){let{length:t}=e,n=t<32?[160|t]:t<256?[217,t]:t<65536?[218,t>>8,t&255]:[219,t>>>24,t>>16&255,t>>8&255,t&255],r=new Uint8Array(n.length+t);return r.set(n),r.set(e,n.length),r}function Qs(e){if(e>=-32&&e<128)return Uint8Array.of(e&255);let[t,n]=e<0?e>=-128?[208,1]:e>=-32768?[209,2]:[210,4]:e<256?[204,1]:e<65536?[205,2]:[206,4],r=new Uint8Array(1+n);r[0]=t;for(let t=0;t<n;t++)r[n-t]=e>>8*t&255;return r}function $s(e){let t=/* @__PURE__ */ new Uint8Array(5);return t[0]=202,new DataView(t.buffer).setFloat32(1,e),t}function ec(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=e[0],r=e=>({type:`int`,value:e}),i=(t,n)=>({type:`string`,bytes:e.subarray(t,t+n)});if(n<128)return r(n);if(n>=224)return r(n-256);if(n>>5==5)return i(1,n&31);switch(n){case 204:return r(t.getUint8(1));case 205:return r(t.getUint16(1));case 206:return r(t.getUint32(1));case 208:return r(t.getInt8(1));case 209:return r(t.getInt16(1));case 210:return r(t.getInt32(1));case 202:return{type:`float`,value:t.getFloat32(1)};case 217:return i(2,t.getUint8(1));case 218:return i(3,t.getUint16(1));case 219:return i(5,t.getUint32(1))}throw Error(`The KVP natives store no value that starts with ${n}`)}const tc=2047;var nc=class{#e;#t=[];#n;constructor(e){this.#e=e}send(e,t,n,r){let i=this.#e,a=n<=0?25e3:n,o=new TextEncoder().encode(e).length+2+t.length;if(o>=134152192){i.trace(`citizen-resources-core`,`Event ${e} is too large to be sent. Total size: ${o}, max size: 134152192.\n`);return}let s=i.time();a>=1e7&&t.length>=5e7&&(this.#n===void 0||s-this.#n>=5e3)&&(i.trace(`citizen-resources-core`,`Warning: sending large event ${e} (${t.length} bytes) with almost unrestricted bitrate (${a} b/s). This may cause performance issues. Consider decreasing objects sizes or bitrate.\n`),this.#n=s);let c=Math.ceil(o/tc),l=Math.trunc(1e3/(a/tc));for(let e of r)this.#t.push({delay:(c-1)*l,start:void 0,deliver:e})}tick(){let e=this.#e.time();for(let t of[...this.#t])t.start??=e,!(e-t.start<t.delay)&&(this.#t.splice(this.#t.indexOf(t),1),t.deliver())}},rc={source:`mime@2.4.0`,types:{"*3gpp":`audio/3gpp`,"*jpm":`video/jpm`,"*mp3":`audio/mp3`,"*rtf":`text/rtf`,"*wav":`audio/wave`,"*xml":`text/xml`,"3g2":`video/3gpp2`,"3gp":`video/3gpp`,"3gpp":`video/3gpp`,ac:`application/pkix-attr-cert`,adp:`audio/adpcm`,ai:`application/postscript`,apng:`image/apng`,appcache:`text/cache-manifest`,asc:`application/pgp-signature`,atom:`application/atom+xml`,atomcat:`application/atomcat+xml`,atomsvc:`application/atomsvc+xml`,au:`audio/basic`,aw:`application/applixware`,bdoc:`application/bdoc`,bin:`application/octet-stream`,bmp:`image/bmp`,bpk:`application/octet-stream`,buffer:`application/octet-stream`,ccxml:`application/ccxml+xml`,cdmia:`application/cdmi-capability`,cdmic:`application/cdmi-container`,cdmid:`application/cdmi-domain`,cdmio:`application/cdmi-object`,cdmiq:`application/cdmi-queue`,cer:`application/pkix-cert`,cgm:`image/cgm`,class:`application/java-vm`,coffee:`text/coffeescript`,conf:`text/plain`,cpt:`application/mac-compactpro`,crl:`application/pkix-crl`,css:`text/css`,csv:`text/csv`,cu:`application/cu-seeme`,davmount:`application/davmount+xml`,dbk:`application/docbook+xml`,deb:`application/octet-stream`,def:`text/plain`,deploy:`application/octet-stream`,"disposition-notification":`message/disposition-notification`,dist:`application/octet-stream`,distz:`application/octet-stream`,dll:`application/octet-stream`,dmg:`application/octet-stream`,dms:`application/octet-stream`,doc:`application/msword`,dot:`application/msword`,drle:`image/dicom-rle`,dssc:`application/dssc+der`,dtd:`application/xml-dtd`,dump:`application/octet-stream`,ear:`application/java-archive`,ecma:`application/ecmascript`,elc:`application/octet-stream`,emf:`image/emf`,eml:`message/rfc822`,emma:`application/emma+xml`,eps:`application/postscript`,epub:`application/epub+zip`,es:`application/ecmascript`,exe:`application/octet-stream`,exi:`application/exi`,exr:`image/aces`,ez:`application/andrew-inset`,fits:`image/fits`,g3:`image/g3fax`,gbr:`application/rpki-ghostbusters`,geojson:`application/geo+json`,gif:`image/gif`,glb:`model/gltf-binary`,gltf:`model/gltf+json`,gml:`application/gml+xml`,gpx:`application/gpx+xml`,gram:`application/srgs`,grxml:`application/srgs+xml`,gxf:`application/gxf`,gz:`application/gzip`,h261:`video/h261`,h263:`video/h263`,h264:`video/h264`,heic:`image/heic`,heics:`image/heic-sequence`,heif:`image/heif`,heifs:`image/heif-sequence`,hjson:`application/hjson`,hlp:`application/winhlp`,hqx:`application/mac-binhex40`,htm:`text/html`,html:`text/html`,ics:`text/calendar`,ief:`image/ief`,ifb:`text/calendar`,iges:`model/iges`,igs:`model/iges`,img:`application/octet-stream`,in:`text/plain`,ini:`text/plain`,ink:`application/inkml+xml`,inkml:`application/inkml+xml`,ipfix:`application/ipfix`,iso:`application/octet-stream`,jade:`text/jade`,jar:`application/java-archive`,jls:`image/jls`,jp2:`image/jp2`,jpe:`image/jpeg`,jpeg:`image/jpeg`,jpf:`image/jpx`,jpg:`image/jpeg`,jpg2:`image/jp2`,jpgm:`video/jpm`,jpgv:`video/jpeg`,jpm:`image/jpm`,jpx:`image/jpx`,js:`application/javascript`,json:`application/json`,json5:`application/json5`,jsonld:`application/ld+json`,jsonml:`application/jsonml+json`,jsx:`text/jsx`,kar:`audio/midi`,ktx:`image/ktx`,less:`text/less`,list:`text/plain`,litcoffee:`text/coffeescript`,log:`text/plain`,lostxml:`application/lost+xml`,lrf:`application/octet-stream`,m1v:`video/mpeg`,m21:`application/mp21`,m2a:`audio/mpeg`,m2v:`video/mpeg`,m3a:`audio/mpeg`,m4a:`audio/mp4`,m4p:`application/mp4`,ma:`application/mathematica`,mads:`application/mads+xml`,man:`text/troff`,manifest:`text/cache-manifest`,map:`application/json`,mar:`application/octet-stream`,markdown:`text/markdown`,mathml:`application/mathml+xml`,mb:`application/mathematica`,mbox:`application/mbox`,md:`text/markdown`,me:`text/troff`,mesh:`model/mesh`,meta4:`application/metalink4+xml`,metalink:`application/metalink+xml`,mets:`application/mets+xml`,mft:`application/rpki-manifest`,mid:`audio/midi`,midi:`audio/midi`,mime:`message/rfc822`,mj2:`video/mj2`,mjp2:`video/mj2`,mjs:`application/javascript`,mml:`text/mathml`,mods:`application/mods+xml`,mov:`video/quicktime`,mp2:`audio/mpeg`,mp21:`application/mp21`,mp2a:`audio/mpeg`,mp3:`audio/mpeg`,mp4:`video/mp4`,mp4a:`audio/mp4`,mp4s:`application/mp4`,mp4v:`video/mp4`,mpd:`application/dash+xml`,mpe:`video/mpeg`,mpeg:`video/mpeg`,mpg:`video/mpeg`,mpg4:`video/mp4`,mpga:`audio/mpeg`,mrc:`application/marc`,mrcx:`application/marcxml+xml`,ms:`text/troff`,mscml:`application/mediaservercontrol+xml`,msh:`model/mesh`,msi:`application/octet-stream`,msm:`application/octet-stream`,msp:`application/octet-stream`,mxf:`application/mxf`,mxml:`application/xv+xml`,n3:`text/n3`,nb:`application/mathematica`,oda:`application/oda`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,ogx:`application/ogg`,omdoc:`application/omdoc+xml`,onepkg:`application/onenote`,onetmp:`application/onenote`,onetoc:`application/onenote`,onetoc2:`application/onenote`,opf:`application/oebps-package+xml`,otf:`font/otf`,owl:`application/rdf+xml`,oxps:`application/oxps`,p10:`application/pkcs10`,p7c:`application/pkcs7-mime`,p7m:`application/pkcs7-mime`,p7s:`application/pkcs7-signature`,p8:`application/pkcs8`,pdf:`application/pdf`,pfr:`application/font-tdpfr`,pgp:`application/pgp-encrypted`,pkg:`application/octet-stream`,pki:`application/pkixcmp`,pkipath:`application/pkix-pkipath`,pls:`application/pls+xml`,png:`image/png`,prf:`application/pics-rules`,ps:`application/postscript`,pskcxml:`application/pskc+xml`,qt:`video/quicktime`,raml:`application/raml+yaml`,rdf:`application/rdf+xml`,rif:`application/reginfo+xml`,rl:`application/resource-lists+xml`,rld:`application/resource-lists-diff+xml`,rmi:`audio/midi`,rnc:`application/relax-ng-compact-syntax`,rng:`application/xml`,roa:`application/rpki-roa`,roff:`text/troff`,rq:`application/sparql-query`,rs:`application/rls-services+xml`,rsd:`application/rsd+xml`,rss:`application/rss+xml`,rtf:`application/rtf`,rtx:`text/richtext`,s3m:`audio/s3m`,sbml:`application/sbml+xml`,scq:`application/scvp-cv-request`,scs:`application/scvp-cv-response`,sdp:`application/sdp`,ser:`application/java-serialized-object`,setpay:`application/set-payment-initiation`,setreg:`application/set-registration-initiation`,sgi:`image/sgi`,sgm:`text/sgml`,sgml:`text/sgml`,shex:`text/shex`,shf:`application/shf+xml`,shtml:`text/html`,sig:`application/pgp-signature`,sil:`audio/silk`,silo:`model/mesh`,slim:`text/slim`,slm:`text/slim`,smi:`application/smil+xml`,smil:`application/smil+xml`,snd:`audio/basic`,so:`application/octet-stream`,spp:`application/scvp-vp-response`,spq:`application/scvp-vp-request`,spx:`audio/ogg`,sru:`application/sru+xml`,srx:`application/sparql-results+xml`,ssdl:`application/ssdl+xml`,ssml:`application/ssml+xml`,stk:`application/hyperstudio`,styl:`text/stylus`,stylus:`text/stylus`,svg:`image/svg+xml`,svgz:`image/svg+xml`,t:`text/troff`,t38:`image/t38`,tei:`application/tei+xml`,teicorpus:`application/tei+xml`,text:`text/plain`,tfi:`application/thraud+xml`,tfx:`image/tiff-fx`,tif:`image/tiff`,tiff:`image/tiff`,tr:`text/troff`,ts:`video/mp2t`,tsd:`application/timestamped-data`,tsv:`text/tab-separated-values`,ttc:`font/collection`,ttf:`font/ttf`,ttl:`text/turtle`,txt:`text/plain`,u8dsn:`message/global-delivery-status`,u8hdr:`message/global-headers`,u8mdn:`message/global-disposition-notification`,u8msg:`message/global`,uri:`text/uri-list`,uris:`text/uri-list`,urls:`text/uri-list`,vcard:`text/vcard`,vrml:`model/vrml`,vtt:`text/vtt`,vxml:`application/voicexml+xml`,war:`application/java-archive`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,webmanifest:`application/manifest+json`,webp:`image/webp`,wgt:`application/widget`,wmf:`image/wmf`,woff:`font/woff`,woff2:`font/woff2`,wrl:`model/vrml`,wsdl:`application/wsdl+xml`,wspolicy:`application/wspolicy+xml`,x3d:`model/x3d+xml`,x3db:`model/x3d+binary`,x3dbz:`model/x3d+binary`,x3dv:`model/x3d+vrml`,x3dvz:`model/x3d+vrml`,x3dz:`model/x3d+xml`,xaml:`application/xaml+xml`,xdf:`application/xcap-diff+xml`,xdssc:`application/dssc+xml`,xenc:`application/xenc+xml`,xer:`application/patch-ops-error+xml`,xht:`application/xhtml+xml`,xhtml:`application/xhtml+xml`,xhvml:`application/xv+xml`,xm:`audio/xm`,xml:`application/xml`,xop:`application/xop+xml`,xpl:`application/xproc+xml`,xsd:`application/xml`,xsl:`application/xml`,xslt:`application/xslt+xml`,xspf:`application/xspf+xml`,xvm:`application/xv+xml`,xvml:`application/xv+xml`,yaml:`text/yaml`,yang:`application/yang`,yin:`application/yin+xml`,yml:`text/yaml`,zip:`application/zip`}};const ic=`nui-resources`,ac=`A NUI callback answered with what FiveM fails to convert, which throws in FiveM, and leaves the request unanswered in FiveRunner.`,oc=new TextEncoder,sc={type:`nil`},cc=new Map(Object.entries(rc.types)),lc=/* @__PURE__ */ new Set([`text/html`,`text/css`,`application/javascript`]);var uc=class{onCreate=new Ni;onDestroy=new Ni;onMessage=new Ni;onFrameFocus=new Ni;onFocus=new Ni;onKeepInput=new Ni;onZIndex=new Ni;cursor={x:0,y:0};#e;#t=/* @__PURE__ */ new WeakMap;#n=/* @__PURE__ */ new Set;#r=/* @__PURE__ */ new Set;#i=/* @__PURE__ */ new Set;#a=/* @__PURE__ */ new Set;#o=!1;#s=!1;#c=!1;constructor(e){this.#e=e}attach(e){let t={callbacks:/* @__PURE__ */ new Map,frame:void 0,dead:!1,strict:!1};this.#t.set(e,t),e.onStart.connect(()=>this.#u(e,t)),e.onStop.connect(()=>{t.dead=!0,t.frame!==void 0&&(t.frame=void 0,this.onDestroy.run(e.name)),this.#n.delete(e.name),this.#r.delete(e.name),this.#i.delete(e.name),this.#f()})}get frames(){let e=[];for(let t of this.#e.resources){let n=this.#t.get(t)?.frame;n!==void 0&&e.push(n)}return e}get focused(){return this.#o}get cursorShown(){return this.#s}get keepingInput(){return this.#c}request(e,t){return new Promise(n=>{let r=this.#l(e),i=r===void 0?void 0:this.#t.get(r),a=t.path.slice(1),o=i?.callbacks.has(a)===!0?a:a.split(`/`,1)[0],s=i?.callbacks.get(o)?.slice();if(r===void 0||i===void 0||s===void 0){n(gc(404,[],/* @__PURE__ */ new Uint8Array));return}let c=hc(t.headers);if(i.strict&&c!==r.name){this.#e.trace(ic,`ResourceUI::InvokeCallback: call to '${r.name}/${a}' from '${c??`(null)`}' has been blocked by NUI Callback Strict Mode\n`),n(gc(404,[],/* @__PURE__ */ new Uint8Array));return}let l=t.method===`POST`?t.body:/* @__PURE__ */ new Uint8Array;this.#e.enqueue(()=>{if(!i.dead)for(let e of s)this.#d(r,o,e,{...t,body:l},a,c,n)})})}file(e,t){let n=this.#l(e.startsWith(`cfx-nui-`)?e.slice(8):e),r=n===void 0||t.includes(`..`)||fc(n,t)?void 0:this.#e.files.read(C(`${n.path}/${t}`)),i=r===void 0?`text/html`:cc.get(t.slice(t.lastIndexOf(`.`)+1))??`text/html`;return{status:r===void 0?404:200,headers:mc([[`content-type`,lc.has(i)?`${i}; charset=utf-8`:i],[`access-control-allow-origin`,`*`],[`access-control-allow-methods`,`GET, OPTIONS`],[`cache-control`,`no-cache, must-revalidate`]]),body:r??/* @__PURE__ */ new Uint8Array}}register(e,t,n){let r=this.#t.get(e).callbacks,i=r.get(t);i===void 0?r.set(t,[n]):i.push(n)}unregister(e,t){this.#t.get(e).callbacks.delete(t)}send(e,t){if(this.#t.get(e)?.frame===void 0)return this.#e.trace(ic,`SEND_NUI_MESSAGE: resource ${e.name} has no UI frame\n`),!1;if(t===null)return this.#e.output.diagnose(e.name,`SendNuiMessage was given no JSON: FiveM would read it from nowhere, and crash. FiveRunner sends nothing.`),!1;let n=ya(t);return`error`in n?(this.#e.trace(ic,`SEND_NUI_MESSAGE: invalid JSON passed in frame (rapidjson error code ${n.error})\n`),!1):(e.name.includes(`"`)||this.onMessage.run(e.name,n.json),!0)}setFocus(e,t,n){this.#t.get(e)?.frame===void 0||e.name.includes(`"`)||(this.onFrameFocus.run(e.name,t),dc(this.#n,e.name,t),dc(this.#r,e.name,n),this.#f())}setKeepInput(e,t){dc(this.#i,e.name,t),this.#f()}setZIndex(e,t){this.#t.get(e)?.frame===void 0||e.name.includes(`"`)||this.onZIndex.run(e.name,t)}takes(e,t){let n=f(t),r=e===`https`&&n.startsWith(`cfx-nui-`)?n.slice(8):n;return this.#a.has(r)}#l(e){let t;for(let n of this.#e.resources)f(n.name)===f(e)&&(t=n);return t}#u(e,t){t.dead=!1,this.#a.add(f(e.name));let n=e.entries(`ui_page`);if(n.length===0)return;if(n.length>1){this.#e.trace(ic,`ResourceUI::Create: more than one ui_page in resource ${e.name}\n`);return}let r=n[0],i=zo(e.metadata,`cerulean`)?`https://cfx-nui-`:`nui://`;t.frame={resource:e.name,url:r.includes(`://`)?r:`${i}${e.name}/${r}`},e.entries(`nui_callback_strict_mode`)[0]===`true`&&(t.strict=!0),this.onCreate.run(t.frame)}#d(e,t,n,r,i,a,o){let s=this.#e;if(n.kind===`raw`){let c=s.callbacks.create(t=>{let n=t.type===`array`?t.items:[];if(n.length!==1)return;let r=vc(n[0]);r===void 0?s.output.diagnose(e.name,ac):o(r)}),l=_c(r,i.slice(t.length)+(r.query===``?``:`?${r.query}`),a);s.invokeFunctionReference(n.ref,Ga({type:`array`,items:[l,{type:`ext`,extension:c}]}));return}let c=r.body.length===0?sc:va(r.body);if(c===void 0)return;let l=Ga({type:`array`,items:[c,{type:`ext`,extension:s.callbacks.create(t=>{let n=t.type===`array`?t.items:[];if(n.length!==1)return;let r;try{r=Qa(n[0])}catch(t){if(!(t instanceof TypeError))throw t;s.output.diagnose(e.name,ac);return}r!==void 0&&o(gc(200,[[`Content-Type`,`application/json; charset=utf-8`]],oc.encode(r)))})}]});n.kind===`event`?s.events.queue(`__cfx_nui:${t}`,l,`nui`,e):s.invokeFunctionReference(n.ref,l)}#f(){let e=this.#n.size>0,t=this.#r.size>0;(e!==this.#o||t!==this.#s)&&(this.#o=e,this.#s=t,this.onFocus.run(e,t));let n=!1;for(let e of this.#i)(this.#n.has(e)||this.#r.has(e))&&(n=!0);n!==this.#c&&(this.#c=n,this.onKeepInput.run(n))}};function dc(e,t,n){n?e.add(t):e.delete(t)}function fc(e,t){let n=t.replace(/^\/+|\/(?=\/)/g,``);return pc(n,`fxmanifest.lua`)||pc(n,`__resource.lua`)?!0:e.globEntries(`client_script`).some(e=>pc(n,e))&&!e.globEntries(`file`).some(e=>pc(n,e))}function pc(e,t){return e===t||e.startsWith(`${t}/`)}function mc(e){return e.sort(([e],[t])=>p(e,t))}function hc(e){let t=e.find(([e])=>e===`Origin`)?.[1];for(let e of[`nui://`,`https://cfx-nui-`])if(t?.startsWith(e))return t.slice(e.length)}function gc(e,t,n){let r=e=>t.some(([t])=>f(t)===e),i=[...t];return r(`content-type`)||i.push([`content-type`,`application/json`]),i.push([`cache-control`,`no-cache, must-revalidate`]),r(`access-control-allow-origin`)||i.push([`access-control-allow-origin`,`*`]),r(`access-control-allow-methods`)||i.push([`access-control-allow-methods`,`POST, GET, OPTIONS`]),{status:e,headers:mc(i),body:n}}function _c(e,t,n){let r=e=>({type:`str`,bytes:typeof e==`string`?oc.encode(e):e}),i=mc([...e.headers]),a=/* @__PURE__ */ new Map;for(let[e,t]of i)a.has(e)||a.set(e,t);return{type:`map`,entries:[[r(`headers`),{type:`map`,entries:[...a].map(([e,t])=>[r(e),r(t)])}],[r(`rawHeaders`),{type:`array`,items:i.map(([e,t])=>({type:`map`,entries:[[r(`key`),r(e)],[r(`value`),r(t)]]}))}],[r(`method`),r(e.body.length===0?`GET`:`POST`)],[r(`path`),r(t)],[r(`body`),r(e.body)],[r(`resource`),n===void 0?sc:r(n)]]}}function vc(e){if(e.type!==`map`)return;let t=200,n=/* @__PURE__ */ new Uint8Array,r=[];for(let[i,a]of e.entries){let e=Za(i);if(e===void 0)return;if(e===`status`){if(a.type!==`positive`&&a.type!==`negative`||a.value<-2147483648n||a.value>2147483647n)return;t=Number(a.value)}else if(e===`body`){if(a.type!==`str`&&a.type!==`bin`)return;n=a.bytes}else if(e===`headers`&&a.type!==`array`){if(a.type!==`map`)return;for(let[e,t]of a.entries){let n=Za(e);if(n===void 0)return;for(let e of t.type===`array`?t.items:[t]){let t=Za(e);if(t===void 0)return;r.push([f(n),t])}}}}return gc(t,r,n)}const yc=new TextDecoder,bc=new TextEncoder,xc=/* @__PURE__ */ new Set([10,11]);function Sc(e){let t=(()=>{throw Error(`FiveRunner calls no functions of other runtimes from JavaScript`)});return Object.defineProperty(t,"reference",{value:e}),t}function Cc(e){switch(e.type){case`nil`:return null;case`boolean`:return e.value;case`positive`:case`negative`:return Number(e.value);case`float32`:case`float64`:return e.value;case`str`:return yc.decode(e.bytes);case`bin`:{let t=new ArrayBuffer(e.bytes.length);return new Uint8Array(t).set(e.bytes),t}case`array`:return e.items.map(Cc);case`map`:{let t={};for(let[n,r]of e.entries)t[String(Cc(n))]=Cc(r);return t}case`ext`:return xc.has(e.extension.type)?Sc(e.extension):{}}}function wc(e){return e<0?{type:`negative`,value:BigInt(e)}:{type:`positive`,value:BigInt(e)}}function Tc(e){if(e==null)return{type:`nil`};switch(typeof e){case`boolean`:return{type:`boolean`,value:e};case`number`:return(e|0)===e?wc(e|0):{type:`float64`,value:e};case`string`:return{type:`str`,bytes:bc.encode(e)};case`function`:{let t=e.reference;return t===void 0?{type:`nil`}:{type:`ext`,extension:t}}}return e instanceof Uint8Array?{type:`bin`,bytes:e}:e instanceof ArrayBuffer?{type:`bin`,bytes:new Uint8Array(e)}:Array.isArray(e)?{type:`array`,items:e.map(Tc)}:{type:`map`,entries:Object.keys(e).map(t=>[{type:`str`,bytes:bc.encode(t)},Tc(e[t])])}}function Ec(e){return JSON.stringify(e)??`undefined`}function Dc(e){return typeof e==`function`}var O=class extends Error{name=`SqlError`;errno;sqlState;constructor(e,t,n){super(n),this.errno=e,this.sqlState=t}};const Oc=[`<=>`,`->>`,`<<`,`>>`,`<=`,`>=`,`<>`,`!=`,`||`,`&&`,`:=`,`->`],kc={0:`\0`,b:`\b`,n:`
4809
4809
  `,r:`\r`,t:` `,Z:``,"%":`\\%`,_:`\\_`},Ac=/[A-Za-z0-9_$]|[^\x00-\x7f]/,jc=/[0-9]/,Mc=/[0-9a-fA-F]/,Nc=/[\s]/;function Pc(e){let t=[],n=0,r=!1;for(;n<e.length;){let i=e[n],a=e[n+1]??``;if(r&&i===`*`&&a===`/`)r=!1,n+=2;else if(Nc.test(i))n++;else if(i===`#`||i===`-`&&a===`-`&&Fc(e[n+2])){let t=e.indexOf(`
4810
4810
  `,n);n=t===-1?e.length:t+1}else if(i===`/`&&a===`*`){let t=/^\/\*(M?)!(\d{5,6})?/.exec(e.slice(n,n+10)),i=t?.[2];if(t!==null&&!r&&(i===void 0||Number(i)<=110400)){r=!0,n+=t[0].length;continue}let a=e.indexOf(`*/`,n+2);if(a===-1)throw Bc(e,n);n=a+2}else if(i===`'`||i===`"`){let r=Rc(e,n);t.push({kind:`string`,text:r.text,quote:i,start:n,end:r.end}),n=r.end}else if(i==="`"){let r=``,i=n+1;for(;;){let t=e.indexOf("`",i);if(t===-1)throw Bc(e,n);if(r+=e.slice(i,t),i=t+1,e[i]!=="`")break;r+="`",i++}t.push({kind:`ident`,text:r,start:n,end:i}),n=i}else if((i===`x`||i===`X`||i===`b`||i===`B`)&&a===`'`){let r=e.indexOf(`'`,n+2);if(r===-1)throw Bc(e,n);let a=e.slice(n+2,r),o=i===`x`||i===`X`;if(o?a.length%2!=0||!/^[0-9a-fA-F]*$/.test(a):!/^[01]*$/.test(a))throw Bc(e,n);t.push(o?{kind:`hex`,digits:a,start:n,end:r+1}:{kind:`bits`,digits:a,start:n,end:r+1}),n=r+1}else if(i===`0`&&(a===`x`||a===`b`)&&Ic(e,n+2,a===`x`?Mc:/[01]/)){let r=n+2;for(;r<e.length&&(a===`x`?Mc:/[01]/).test(e[r]);)r++;let i=e.slice(n+2,r);t.push(a===`x`?{kind:`hex`,digits:i.length%2==0?i:`0${i}`,start:n,end:r}:{kind:`bits`,digits:i,start:n,end:r}),n=r}else if(jc.test(i)||i===`.`&&jc.test(a)&&!Lc(t,n)){let r=n;for(;r<e.length&&jc.test(e[r]);)r++;if(e[r]===`.`)for(r++;r<e.length&&jc.test(e[r]);)r++;if((e[r]===`e`||e[r]===`E`)&&(jc.test(e[r+1]??``)||/[+-]/.test(e[r+1]??``)&&jc.test(e[r+2]??``)))for(r+=2;r<e.length&&jc.test(e[r]);)r++;if(r<e.length&&Ac.test(e[r])&&!e.slice(n,r).includes(`.`)){for(;r<e.length&&Ac.test(e[r]);)r++;t.push({kind:`word`,text:e.slice(n,r),start:n,end:r})}else t.push({kind:`number`,text:e.slice(n,r),start:n,end:r});n=r}else if(Ac.test(i)){let r=n+1;for(;r<e.length&&Ac.test(e[r]);)r++;t.push({kind:`word`,text:e.slice(n,r),start:n,end:r}),n=r}else if(i===`@`){let r=a===`@`,i=n+(r?2:1),o;if(e[i]==="`"||e[i]===`'`||e[i]===`"`){let t=e[i],n=t==="`"?e.indexOf("`",i+1):-2;if(n===-1)throw Bc(e,i);let r=t==="`"?{text:e.slice(i+1,n),end:n+1}:Rc(e,i);o=r.text,i=r.end}else{let t=i;for(;i<e.length&&(/[A-Za-z0-9_$.]/.test(e[i])||/[^\x00-\x7f]/.test(e[i]));)i++;o=e.slice(t,i)}t.push({kind:`variable`,text:o,system:r,start:n,end:i}),n=i}else if(i===`?`)t.push({kind:`param`,start:n,end:n+1}),n++;else{let r=Oc.find(t=>e.startsWith(t,n))??i;t.push({kind:`op`,text:r,start:n,end:n+r.length}),n+=r.length}}if(r)throw Bc(e,e.length);return t.push({kind:`end`,start:e.length,end:e.length}),t}function Fc(e){return e===void 0||e<=` `}function Ic(e,t,n){let r=t;for(;r<e.length&&n.test(e[r]);)r++;return r>t&&(r===e.length||!Ac.test(e[r]))}function Lc(e,t){let n=e.at(-1);return n!==void 0&&n.end===t&&(n.kind===`word`||n.kind===`ident`)}function Rc(e,t){let n=e[t],r=``,i=t+1;for(;i<e.length;){let t=e[i];if(t===`\\`&&i+1<e.length){let t=e[i+1];r+=kc[t]??t,i+=2}else if(t===n){if(e[i+1]!==n)return{text:r,end:i+1};r+=n,i+=2}else r+=t,i++}throw Bc(e,t)}function zc(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e[r]===`
4811
4811
  `&&n++;return n}function Bc(e,t){return new O(1064,`42000`,`You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '${[...e.slice(t)].slice(0,80).join(``)}' at line ${zc(e,t)}`)}const Vc={INT1:`TINYINT`,INT2:`SMALLINT`,INT3:`MEDIUMINT`,MIDDLEINT:`MEDIUMINT`,INT4:`INT`,INTEGER:`INT`,INT8:`BIGINT`,DEC:`DECIMAL`,NUMERIC:`DECIMAL`,FIXED:`DECIMAL`,REAL:`DOUBLE`,FLOAT8:`DOUBLE`,FLOAT4:`FLOAT`,CHARACTER:`CHAR`,NCHAR:`CHAR`,NVARCHAR:`VARCHAR`,VARCHARACTER:`VARCHAR`},Hc=/* @__PURE__ */ new Set([`TINYINT`,`SMALLINT`,`MEDIUMINT`,`INT`,`BIGINT`]),Uc=/* @__PURE__ */ new Set([`CHAR`,`VARCHAR`,`BINARY`,`VARBINARY`,`TINYTEXT`,`TEXT`,`MEDIUMTEXT`,`LONGTEXT`,`TINYBLOB`,`BLOB`,`MEDIUMBLOB`,`LONGBLOB`,`ENUM`,`SET`,`JSON`]),Wc=/* @__PURE__ */ new Set([`GEOMETRY`,`POINT`,`LINESTRING`,`POLYGON`,`MULTIPOINT`,`MULTILINESTRING`,`MULTIPOLYGON`,`GEOMETRYCOLLECTION`]);function Gc(e){let t=e.next();t.kind!==`word`&&e.fail(t);let n=t.text.toUpperCase(),r=!1,i=!1,a,o,s,c,l;if(n===`NATIONAL`){let t=e.next();t.kind!==`word`&&e.fail(t),n=t.text.toUpperCase()}if(n===`BOOL`||n===`BOOLEAN`)return{name:`TINYINT`,length:1};if(n===`SERIAL`)return{name:`BIGINT`,unsigned:!0};if(n===`DOUBLE`&&e.acceptWord(`PRECISION`),n===`LONG`&&(e.acceptWord(`VARBINARY`)?n=`MEDIUMBLOB`:(e.acceptOneOf(`VARCHAR`,`VARCHARACTER`),n=`MEDIUMTEXT`)),(n===`CHAR`||n===`CHARACTER`)&&e.acceptWord(`VARYING`)&&(n=`VARCHAR`),n=Vc[n]??n,Wc.has(n))throw k(`the type ${n}`);if(Hc.has(n)||Uc.has(n)||[`DECIMAL`,`FLOAT`,`DOUBLE`,`BIT`,`DATE`,`TIME`,`DATETIME`,`TIMESTAMP`,`YEAR`,`UUID`,`INET4`,`INET6`].includes(n)||e.fail(t),n===`ENUM`||n===`SET`){for(e.expectOp(`(`),s=[e.string()];e.acceptOp(`,`);)s.push(e.string());e.expectOp(`)`)}else e.acceptOp(`(`)&&(a=e.integer(),e.acceptOp(`,`)&&(o=e.integer()),e.expectOp(`)`));for((n===`VARCHAR`||n===`VARBINARY`)&&a===void 0&&e.fail(),n===`FLOAT`&&a!==void 0&&o===void 0&&(a>24&&(n=`DOUBLE`),a=void 0);;)if(e.acceptWord(`UNSIGNED`))r=!0;else if(e.acceptWord(`SIGNED`))r=!1;else if(e.acceptWord(`ZEROFILL`))i=!0,r=!0;else if(e.acceptWord(`CHARACTER`,`SET`)||e.acceptWord(`CHARSET`))c=e.nameOrString();else if(e.acceptWord(`ASCII`))c=`latin1`;else if(e.acceptWord(`UNICODE`))c=`ucs2`;else if(e.acceptWord(`BYTE`))c=`binary`;else if(e.acceptWord(`COLLATE`))l=e.nameOrString();else if(e.isWord(`BINARY`)&&!e.isOp(`(`,1))e.next(),l??=`utf8mb4_bin`;else break;return{name:n,...a===void 0?{}:{length:a},...o===void 0?{}:{scale:o},...r?{unsigned:r}:{},...i?{zerofill:i}:{},...s===void 0?{}:{values:s},...c===void 0?{}:{charset:c},...l===void 0?{}:{collation:l}}}function Kc(e){let t=e.name(),n=e.isWord(`SERIAL`),r=Gc(e),i,a,o,s=!1,c,l,u,d,f,p=r.collation,m=r.charset;for(;;)if(e.acceptWord(`NOT`,`NULL`))i=!1;else if(e.acceptWord(`NULL`))i=!0;else if(e.acceptWord(`DEFAULT`))a=qc(e);else if(e.acceptWord(`ON`,`UPDATE`))o=qc(e);else if(e.acceptWord(`AUTO_INCREMENT`))s=!0;else if(e.acceptWord(`UNIQUE`))e.acceptWord(`KEY`),c??=`UNIQUE`;else if(e.acceptWord(`PRIMARY`,`KEY`)||e.acceptWord(`KEY`))c=`PRIMARY`;else if(e.acceptWord(`COMMENT`))l=e.string();else if(e.acceptWord(`COLLATE`))p=e.nameOrString();else if(e.acceptWord(`CHARACTER`,`SET`)||e.acceptWord(`CHARSET`))m=e.nameOrString();else if(e.isWord(`CONSTRAINT`)||e.isWord(`CHECK`))e.acceptWord(`CONSTRAINT`)&&!e.isWord(`CHECK`)&&e.name(),e.expectWord(`CHECK`),e.expectOp(`(`),u=e.expression(),e.expectOp(`)`);else if(e.isWord(`REFERENCES`))d=Jc(e);else if(e.isWord(`GENERATED`)||e.isWord(`AS`)){e.acceptWord(`GENERATED`)&&e.expectWord(`ALWAYS`),e.expectWord(`AS`),e.expectOp(`(`);let t=e.expression();e.expectOp(`)`);let n=e.acceptOneOf(`VIRTUAL`,`PERSISTENT`,`STORED`);f={expr:t,stored:n===`PERSISTENT`||n===`STORED`}}else if(e.acceptOneOf(`INVISIBLE`,`VISIBLE`)===void 0){if(e.acceptWord(`COLUMN_FORMAT`)||e.acceptWord(`STORAGE`))e.next();else if(e.acceptWord(`SERIAL`,`DEFAULT`,`VALUE`))s=!0,i=!1,c??=`UNIQUE`;else break}return n&&(s=!0,i=!1,c??=`UNIQUE`),{name:t,type:{...r,...m===void 0?{}:{charset:m},...p===void 0?{}:{collation:p}},...i===void 0?{}:{nullable:i},...a===void 0?{}:{default:a},...o===void 0?{}:{onUpdate:o},autoIncrement:s,...c===void 0?{}:{key:c},...l===void 0?{}:{comment:l},...u===void 0?{}:{check:u},...d===void 0?{}:{references:d},...f===void 0?{}:{generated:f}}}function qc(e){let t=e.position,n=e.isOp(`-`)?`-`:e.isOp(`+`)?`+`:void 0;if(n!==void 0){e.next();let r=qc(e);return{kind:`unary`,op:n,operand:r,start:t,end:r.end}}if(e.isOp(`(`)){e.next();let n=e.expression();return e.expectOp(`)`),{...n,start:t,end:e.last}}let r=e.peek();if(r.kind===`word`&&![`NULL`,`TRUE`,`FALSE`].includes(r.text.toUpperCase())&&!e.isOp(`(`,1)){let t=r.text.toUpperCase();[`CURRENT_TIMESTAMP`,`LOCALTIME`,`LOCALTIMESTAMP`,`CURRENT_DATE`,`CURRENT_TIME`,`NOW`].includes(t)||e.fail()}return e.primaryExpression()}function Jc(e){e.expectWord(`REFERENCES`);let t=e.tableName(),n=e.nameList();e.acceptWord(`MATCH`)&&e.acceptOneOf(`FULL`,`PARTIAL`,`SIMPLE`);let r,i;for(;;)if(e.acceptWord(`ON`,`DELETE`))r=Yc(e);else if(e.acceptWord(`ON`,`UPDATE`))i=Yc(e);else break;return{table:t,columns:n,...r===void 0?{}:{onDelete:r},...i===void 0?{}:{onUpdate:i}}}function Yc(e){if(e.acceptWord(`RESTRICT`))return`RESTRICT`;if(e.acceptWord(`CASCADE`))return`CASCADE`;if(e.acceptWord(`SET`,`NULL`))return`SET NULL`;if(e.acceptWord(`SET`,`DEFAULT`))return`SET DEFAULT`;if(e.acceptWord(`NO`,`ACTION`))return`NO ACTION`;e.fail()}function Xc(e){e.expectOp(`(`);let t=[];do{if(e.isOp(`(`))throw k(`keys of expressions`);let n=e.name(),r;e.acceptOp(`(`)&&(r=e.integer(),e.expectOp(`)`));let i=e.acceptOneOf(`ASC`,`DESC`);t.push({column:n,...r===void 0?{}:{length:r},descending:i===`DESC`})}while(e.acceptOp(`,`));return e.expectOp(`)`),t}function Zc(e){for(;;)if(e.acceptWord(`USING`))e.acceptOneOf(`BTREE`,`HASH`,`RTREE`)===void 0&&e.fail();else if(e.acceptWord(`KEY_BLOCK_SIZE`))e.optionalEquals(),e.integer();else if(e.acceptWord(`COMMENT`))e.string();else if(e.acceptWord(`WITH`,`PARSER`))e.name();else if(e.acceptOneOf(`VISIBLE`,`INVISIBLE`,`IGNORED`)===void 0&&!e.acceptWord(`NOT`,`IGNORED`)){if(e.acceptWord(`CLUSTERING`))e.optionalEquals(),e.next();else return}}function Qc(e){return e.isName()&&!e.isWord(`USING`)?e.name():void 0}function $c(e){let t;e.acceptWord(`CONSTRAINT`)&&(!e.isWord(`PRIMARY`)&&!e.isWord(`UNIQUE`)&&!e.isWord(`FOREIGN`)&&!e.isWord(`CHECK`)&&(t=e.name()),!e.isWord(`PRIMARY`)&&!e.isWord(`UNIQUE`)&&!e.isWord(`FOREIGN`)&&!e.isWord(`CHECK`)&&e.fail());let n=()=>e.acceptWord(`IF`,`NOT`,`EXISTS`);if(e.acceptWord(`PRIMARY`,`KEY`)){Zc(e);let n=Xc(e);return Zc(e),{constraint:{kind:`PRIMARY`,...t===void 0?{}:{name:t},parts:n},ifNotExists:!1}}if(e.acceptWord(`UNIQUE`)){e.acceptOneOf(`INDEX`,`KEY`);let r=n(),i=Qc(e)??t;Zc(e);let a=Xc(e);return Zc(e),{constraint:{kind:`UNIQUE`,...i===void 0?{}:{name:i},parts:a},ifNotExists:r}}if(e.acceptWord(`FOREIGN`,`KEY`)){let r=n(),i=Qc(e)??t,a=e.nameList(),o=Jc(e);return{constraint:{kind:`FOREIGN`,...i===void 0?{}:{name:i},columns:a,references:o},ifNotExists:r}}if(e.acceptWord(`CHECK`)){e.expectOp(`(`);let n=e.expression();return e.expectOp(`)`),{constraint:{kind:`CHECK`,...t===void 0?{}:{name:t},expr:n},ifNotExists:!1}}t!==void 0&&e.fail();let r=e.isWord(`FULLTEXT`)?`FULLTEXT`:e.isWord(`SPATIAL`)?`SPATIAL`:e.isWord(`INDEX`)||e.isWord(`KEY`)?`INDEX`:void 0;if(r===void 0)return;e.next(),r!==`INDEX`&&e.acceptOneOf(`INDEX`,`KEY`);let i=n(),a=Qc(e);Zc(e);let o=Xc(e);return Zc(e),{constraint:{kind:r,...a===void 0?{}:{name:a},parts:o},ifNotExists:i}}function el(e,t){let n={};for(;;)if(t&&e.acceptOp(`,`),e.acceptWord(`ENGINE`)||e.acceptWord(`TYPE`))e.optionalEquals(),n.engine=e.nameOrString();else if(e.acceptWord(`DEFAULT`,`CHARACTER`,`SET`)||e.acceptWord(`CHARACTER`,`SET`)||e.acceptWord(`DEFAULT`,`CHARSET`)||e.acceptWord(`CHARSET`))e.optionalEquals(),n.charset=e.nameOrString();else if(e.acceptWord(`DEFAULT`,`COLLATE`)||e.acceptWord(`COLLATE`))e.optionalEquals(),n.collation=e.nameOrString();else if(e.acceptWord(`AUTO_INCREMENT`))e.optionalEquals(),n.autoIncrement=e.integer();else if(e.acceptWord(`COMMENT`))e.optionalEquals(),n.comment=e.string();else if(e.acceptOneOf(`ROW_FORMAT`,`KEY_BLOCK_SIZE`,`AVG_ROW_LENGTH`,`CHECKSUM`,`TABLE_CHECKSUM`,`DELAY_KEY_WRITE`,`PACK_KEYS`,`STATS_AUTO_RECALC`,`STATS_PERSISTENT`,`STATS_SAMPLE_PAGES`,`MAX_ROWS`,`MIN_ROWS`,`PAGE_CHECKSUM`,`PAGE_COMPRESSED`,`PAGE_COMPRESSION_LEVEL`,`TRANSACTIONAL`,`INSERT_METHOD`,`ENCRYPTED`,`ENCRYPTION_KEY_ID`,`IETF_QUOTES`,`SEQUENCE`,`COMPRESSION`,`TABLESPACE`,`STORAGE`,`CONNECTION`,`PASSWORD`)!==void 0)e.optionalEquals(),e.next();else if(e.acceptWord(`DATA`,`DIRECTORY`)||e.acceptWord(`INDEX`,`DIRECTORY`))e.optionalEquals(),e.string();else if(e.acceptWord(`UNION`))for(e.optionalEquals(),e.expectOp(`(`);!e.acceptOp(`)`);)e.next();else if(e.acceptWord(`WITH`,`SYSTEM`,`VERSIONING`))throw k(`system-versioned tables`);else if(e.isWord(`PARTITION`))throw k(`partitioning`);else return n}function tl(e){let t=e.next().start,n=e.acceptWord(`OR`,`REPLACE`),r=e.acceptWord(`TEMPORARY`);if(e.acceptWord(`TABLE`))return il(e,t,n,r);r&&e.fail();let i=e.acceptOneOf(`UNIQUE`,`FULLTEXT`,`SPATIAL`);if(e.acceptWord(`INDEX`)){let r=e.acceptWord(`IF`,`NOT`,`EXISTS`),a=e.name();Zc(e),e.expectWord(`ON`);let o=e.tableName(),s=Xc(e);for(Zc(e);e.acceptOneOf(`ALGORITHM`,`LOCK`)!==void 0;)e.optionalEquals(),e.next();return{kind:`createIndex`,orReplace:n,ifNotExists:r,unique:i===`UNIQUE`,name:a,table:o,parts:s,start:t,end:e.last}}for(i!==void 0&&e.fail();;)if(e.acceptWord(`ALGORITHM`))e.expectOp(`=`),e.next();else if(e.acceptWord(`DEFINER`))e.expectOp(`=`),nl(e);else if(e.acceptWord(`SQL`,`SECURITY`))e.acceptOneOf(`DEFINER`,`INVOKER`);else break;if(e.acceptWord(`VIEW`)){let r=e.acceptWord(`IF`,`NOT`,`EXISTS`),i=e.tableName(),a=e.isOp(`(`)?e.nameList():void 0;e.expectWord(`AS`);let o=e.select();return e.acceptWord(`WITH`)&&(e.acceptOneOf(`CASCADED`,`LOCAL`),e.expectWord(`CHECK`,`OPTION`)),{kind:`createView`,orReplace:n,ifNotExists:r,view:i,...a===void 0?{}:{columns:a},select:o,start:t,end:e.last}}if(e.acceptOneOf(`DATABASE`,`SCHEMA`)!==void 0){let n=e.acceptWord(`IF`,`NOT`,`EXISTS`),r=e.name();return rl(e),{kind:`createDatabase`,ifNotExists:n,name:r,start:t,end:e.last}}let a=e.peek();if(a.kind===`word`){let e=a.text.toUpperCase();if([`TRIGGER`,`PROCEDURE`,`FUNCTION`,`EVENT`].includes(e))throw k(`${e.toLowerCase()}s`);if([`USER`,`ROLE`,`SEQUENCE`,`SERVER`,`TABLESPACE`,`AGGREGATE`,`PACKAGE`].includes(e))throw k(`CREATE ${e}`)}e.fail()}function nl(e){e.acceptWord(`CURRENT_USER`)?e.acceptOp(`(`)&&e.expectOp(`)`):(e.nameOrString(),e.peek().kind===`variable`&&e.next())}function rl(e){for(;;)if(e.acceptWord(`DEFAULT`),e.acceptWord(`CHARACTER`,`SET`)||e.acceptWord(`CHARSET`)||e.acceptWord(`COLLATE`))e.optionalEquals(),e.nameOrString();else if(e.acceptWord(`COMMENT`))e.optionalEquals(),e.string();else return}function il(e,t,n,r){let i=e.acceptWord(`IF`,`NOT`,`EXISTS`),a=e.tableName(),o=[],s=[],c;if(e.acceptWord(`LIKE`))c=e.tableName();else if(e.isOp(`(`)&&e.isWord(`LIKE`,1))e.next(),e.next(),c=e.tableName(),e.expectOp(`)`);else if(e.isOp(`(`)&&!e.isWord(`SELECT`,1)&&!e.isWord(`WITH`,1)){e.next();do{let t=$c(e);if(t!==void 0)s.push(t.constraint);else if(e.isWord(`PERIOD`)&&e.isWord(`FOR`,1))throw k(`PERIOD FOR`);else o.push(Kc(e))}while(e.acceptOp(`,`));e.expectOp(`)`)}let l=c===void 0?el(e,!0):{},u;if(c===void 0&&(e.acceptOneOf(`IGNORE`,`REPLACE`),e.acceptWord(`AS`),(e.isWord(`SELECT`)||e.isWord(`WITH`)||e.isOp(`(`))&&(u=e.select())),c===void 0&&u===void 0&&o.length===0)throw new O(1113,`42000`,`A table must have at least 1 column`);return{kind:`createTable`,temporary:r,orReplace:n,ifNotExists:i,table:a,columns:o,constraints:s,options:l,...c===void 0?{}:{like:c},...u===void 0?{}:{select:u},start:t,end:e.last}}function al(e){if(e.acceptWord(`FIRST`))return{first:!0};if(e.acceptWord(`AFTER`))return{after:e.name()}}function ol(e){let t=e.next().start;if(e.acceptWord(`ONLINE`),e.acceptWord(`IGNORE`),e.acceptOneOf(`DATABASE`,`SCHEMA`)!==void 0)return!e.isWord(`DEFAULT`)&&!e.isWord(`CHARACTER`)&&!e.isWord(`CHARSET`)&&!e.isWord(`COLLATE`)&&!e.isWord(`COMMENT`)&&e.name(),rl(e),{kind:`noop`,start:t,end:e.last};if(!e.acceptWord(`TABLE`)){let t=e.peek();throw k(`ALTER ${t.kind===`word`?t.text.toUpperCase():``}`.trim())}let n=e.acceptWord(`IF`,`EXISTS`),r=e.tableName();e.acceptWord(`WAIT`)?e.integer():e.acceptWord(`NOWAIT`);let i=[];if(e.peek().kind!==`end`&&!e.isOp(`;`))do i.push(...sl(e));while(e.acceptOp(`,`));return{kind:`alterTable`,ifExists:n,table:r,actions:i,start:t,end:e.last}}function sl(e){if(e.acceptWord(`ADD`)){let t=$c(e);if(t!==void 0)return[{kind:`addConstraint`,...t}];e.acceptWord(`COLUMN`);let n=e.acceptWord(`IF`,`NOT`,`EXISTS`);if(e.acceptOp(`(`)){let t=[];do{let r=$c(e);t.push(r===void 0?{kind:`addColumn`,ifNotExists:n,column:Kc(e)}:{kind:`addConstraint`,...r})}while(e.acceptOp(`,`));return e.expectOp(`)`),t}let r=Kc(e),i=al(e);return[{kind:`addColumn`,ifNotExists:n,column:r,...i===void 0?{}:{position:i}}]}return[cl(e)]}function cl(e){if(e.acceptWord(`CHANGE`)){e.acceptWord(`COLUMN`);let t=e.acceptWord(`IF`,`EXISTS`),n=e.name(),r=Kc(e),i=al(e);return{kind:`changeColumn`,ifExists:t,name:n,column:r,...i===void 0?{}:{position:i}}}if(e.acceptWord(`MODIFY`)){e.acceptWord(`COLUMN`);let t=e.acceptWord(`IF`,`EXISTS`),n=Kc(e),r=al(e);return{kind:`changeColumn`,ifExists:t,name:n.name,column:n,...r===void 0?{}:{position:r}}}if(e.acceptWord(`ALTER`)){e.acceptWord(`COLUMN`);let t=e.name();return e.acceptWord(`SET`,`DEFAULT`)?{kind:`alterDefault`,name:t,default:qc(e)}:(e.expectWord(`DROP`,`DEFAULT`),{kind:`alterDefault`,name:t})}if(e.acceptWord(`DROP`)){if(e.acceptWord(`PRIMARY`,`KEY`))return{kind:`dropPrimaryKey`};if(e.acceptOneOf(`INDEX`,`KEY`)!==void 0)return{kind:`dropIndex`,ifExists:e.acceptWord(`IF`,`EXISTS`),name:e.name()};if(e.acceptWord(`FOREIGN`,`KEY`))return{kind:`dropForeignKey`,ifExists:e.acceptWord(`IF`,`EXISTS`),name:e.name()};if(e.acceptOneOf(`CONSTRAINT`,`CHECK`)!==void 0)return{kind:`dropConstraint`,ifExists:e.acceptWord(`IF`,`EXISTS`),name:e.name()};e.acceptWord(`COLUMN`);let t=e.acceptWord(`IF`,`EXISTS`),n=e.name();return e.acceptOneOf(`RESTRICT`,`CASCADE`),{kind:`dropColumn`,ifExists:t,name:n}}if(e.acceptWord(`RENAME`)){if(e.acceptOneOf(`INDEX`,`KEY`)!==void 0){let t=e.name();return e.expectWord(`TO`),{kind:`renameIndex`,from:t,to:e.name()}}if(e.acceptWord(`COLUMN`)){let t=e.name();return e.expectWord(`TO`),{kind:`renameColumn`,from:t,to:e.name()}}return e.acceptOneOf(`TO`,`AS`),{kind:`renameTable`,to:e.tableName()}}if(e.acceptWord(`CONVERT`,`TO`)){e.acceptWord(`CHARACTER`,`SET`)||e.expectWord(`CHARSET`);let t=e.nameOrString(),n=e.acceptWord(`COLLATE`)?e.nameOrString():void 0;return{kind:`options`,options:{charset:t,...n===void 0?{}:{collation:n}}}}if(e.acceptOneOf(`DISABLE`,`ENABLE`)!==void 0)return e.expectWord(`KEYS`),{kind:`none`};if(e.acceptWord(`FORCE`))return{kind:`none`};if(e.acceptOneOf(`ALGORITHM`,`LOCK`)!==void 0)return e.optionalEquals(),e.next(),{kind:`none`};if(e.acceptWord(`ORDER`,`BY`))return e.orderList(),{kind:`none`};let t=el(e,!1);return Object.keys(t).length===0&&!e.isOp(`,`)&&e.peek().kind!==`end`&&!e.isOp(`;`)&&e.fail(),{kind:`options`,options:t}}function ll(e){let t=e.next().start,n=e.acceptWord(`TEMPORARY`);if(e.acceptWord(`TABLE`)||!n&&e.acceptWord(`TABLES`)){let r=e.acceptWord(`IF`,`EXISTS`),i=[e.tableName()];for(;e.acceptOp(`,`);)i.push(e.tableName());return e.acceptOneOf(`RESTRICT`,`CASCADE`),{kind:`dropTable`,temporary:n,ifExists:r,tables:i,start:t,end:e.last}}if(n&&e.fail(),e.acceptWord(`INDEX`)){let n=e.acceptWord(`IF`,`EXISTS`),r=e.acceptWord(`PRIMARY`)?`PRIMARY`:e.name();return e.expectWord(`ON`),{kind:`dropIndex`,ifExists:n,name:r,table:e.tableName(),start:t,end:e.last}}if(e.acceptWord(`VIEW`)){let n=e.acceptWord(`IF`,`EXISTS`),r=[e.tableName()];for(;e.acceptOp(`,`);)r.push(e.tableName());return e.acceptOneOf(`RESTRICT`,`CASCADE`),{kind:`dropView`,ifExists:n,views:r,start:t,end:e.last}}if(e.acceptOneOf(`DATABASE`,`SCHEMA`)!==void 0)return{kind:`dropDatabase`,ifExists:e.acceptWord(`IF`,`EXISTS`),name:e.name(),start:t,end:e.last};let r=e.acceptOneOf(`TRIGGER`,`PROCEDURE`,`FUNCTION`,`EVENT`);if(r!==void 0){let n=e.acceptWord(`IF`,`EXISTS`),i=e.tableName();if(n)return{kind:`noop`,start:t,end:e.last};throw r===`TRIGGER`?new O(1360,`HY000`,`Trigger does not exist`):r===`EVENT`?new O(1539,`HY000`,`Unknown event '${i.name}'`):new O(1305,`42000`,`${r} ${i.schema??``}${i.schema===void 0?``:`.`}${i.name} does not exist`)}let i=e.peek();throw k(`DROP ${i.kind===`word`?i.text.toUpperCase():``}`.trim())}function ul(e){let t=e.next().start;return e.acceptWord(`TABLE`),{kind:`truncate`,table:e.tableName(),start:t,end:e.last}}function dl(e){let t=e.next().start;if(!e.acceptWord(`TABLE`)&&!e.acceptWord(`TABLES`)){let t=e.peek();throw k(`RENAME ${t.kind===`word`?t.text.toUpperCase():``}`.trim())}let n=[];do{let t=e.tableName();e.expectWord(`TO`),n.push({from:t,to:e.tableName()})}while(e.acceptOp(`,`));return{kind:`renameTable`,renames:n,start:t,end:e.last}}const fl=new Set(`ACCESSIBLE ADD ALL ALTER ANALYZE AND AS ASC ASENSITIVE BEFORE BETWEEN BIGINT BINARY BLOB BOTH BY
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>FiveRunner</title>
7
7
  <link rel="icon" type="image/svg+xml" href="/__fiverunner/logo.svg" />
8
- <script type="module" crossorigin src="/__fiverunner/assets/index-BUYlg8Xi.js"></script>
8
+ <script type="module" crossorigin src="/__fiverunner/assets/index-D8mhkemk.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/__fiverunner/assets/routes-DFIWFSAi.js">
10
10
  <link rel="stylesheet" crossorigin href="/__fiverunner/assets/index-BrojKg9W.css">
11
11
  </head>