diff --git a/.last_build_id b/.last_build_id index 5079f86..1049a8a 100644 --- a/.last_build_id +++ b/.last_build_id @@ -1 +1 @@ -fde5941ed1fa5b6dd20d9a1798e95c09 \ No newline at end of file +1409cdf187973ff3449901eff2f59c3f \ No newline at end of file diff --git a/assets/AssetManifest.bin b/assets/AssetManifest.bin index a5aadde..d51f333 100644 --- a/assets/AssetManifest.bin +++ b/assets/AssetManifest.bin @@ -1 +1 @@ - 1packages/surrealdb_js/assets/js/index.bundled.mjs  asset1packages/surrealdb_js/assets/js/index.bundled.mjspackages/surrealdb_wasm/assets/wasm/surrealdb/index.bundled.js  asset>packages/surrealdb_wasm/assets/wasm/surrealdb/index.bundled.js6packages/surrealdb_wasm/assets/wasm/surrealdb/index.js  asset6packages/surrealdb_wasm/assets/wasm/surrealdb/index.js;packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm  asset;packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm:packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.js  asset:packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.js?packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz  asset?packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz?packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.js  asset?packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.jsCpackages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js  assetCpackages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.jsFpackages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js.gz  assetFpackages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js.gz \ No newline at end of file diff --git a/assets/AssetManifest.bin.json b/assets/AssetManifest.bin.json index c35e26c..d5a21a9 100644 --- a/assets/AssetManifest.bin.json +++ b/assets/AssetManifest.bin.json @@ -1 +1 @@ -"DQkHMXBhY2thZ2VzL3N1cnJlYWxkYl9qcy9hc3NldHMvanMvaW5kZXguYnVuZGxlZC5tanMMAQ0BBwVhc3NldAcxcGFja2FnZXMvc3VycmVhbGRiX2pzL2Fzc2V0cy9qcy9pbmRleC5idW5kbGVkLm1qcwc8cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL2VzbS5idW5kbGVkLmpzDAENAQcFYXNzZXQHPHBhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9lc20uYnVuZGxlZC5qcwc2cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL2luZGV4LmpzDAENAQcFYXNzZXQHNnBhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9pbmRleC5qcwc7cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL2luZGV4X2JnLndhc20MAQ0BBwVhc3NldAc7cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL2luZGV4X2JnLndhc20HOnBhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9zdXJyZWFsZGIuanMMAQ0BBwVhc3NldAc6cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL3N1cnJlYWxkYi5qcwc/cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL3N1cnJlYWxkYi53YXNtLmd6DAENAQcFYXNzZXQHP3BhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9zdXJyZWFsZGIud2FzbS5negc/cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL3N1cnJlYWxkYl93YXNtLmpzDAENAQcFYXNzZXQHP3BhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9zdXJyZWFsZGJfd2FzbS5qcwdDcGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL3N1cnJlYWxkYl93YXNtLm1pbi5qcwwBDQEHBWFzc2V0B0NwYWNrYWdlcy9zdXJyZWFsZGJfd2FzbS9hc3NldHMvd2FzbS9zdXJyZWFsZGIvc3VycmVhbGRiX3dhc20ubWluLmpzB0ZwYWNrYWdlcy9zdXJyZWFsZGJfd2FzbS9hc3NldHMvd2FzbS9zdXJyZWFsZGIvc3VycmVhbGRiX3dhc20ubWluLmpzLmd6DAENAQcFYXNzZXQHRnBhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9zdXJyZWFsZGJfd2FzbS5taW4uanMuZ3o=" \ No newline at end of file +"DQkHMXBhY2thZ2VzL3N1cnJlYWxkYl9qcy9hc3NldHMvanMvaW5kZXguYnVuZGxlZC5tanMMAQ0BBwVhc3NldAcxcGFja2FnZXMvc3VycmVhbGRiX2pzL2Fzc2V0cy9qcy9pbmRleC5idW5kbGVkLm1qcwc+cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL2luZGV4LmJ1bmRsZWQuanMMAQ0BBwVhc3NldAc+cGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL2luZGV4LmJ1bmRsZWQuanMHNnBhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9pbmRleC5qcwwBDQEHBWFzc2V0BzZwYWNrYWdlcy9zdXJyZWFsZGJfd2FzbS9hc3NldHMvd2FzbS9zdXJyZWFsZGIvaW5kZXguanMHO3BhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9pbmRleF9iZy53YXNtDAENAQcFYXNzZXQHO3BhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9pbmRleF9iZy53YXNtBzpwYWNrYWdlcy9zdXJyZWFsZGJfd2FzbS9hc3NldHMvd2FzbS9zdXJyZWFsZGIvc3VycmVhbGRiLmpzDAENAQcFYXNzZXQHOnBhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9zdXJyZWFsZGIuanMHP3BhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9zdXJyZWFsZGIud2FzbS5negwBDQEHBWFzc2V0Bz9wYWNrYWdlcy9zdXJyZWFsZGJfd2FzbS9hc3NldHMvd2FzbS9zdXJyZWFsZGIvc3VycmVhbGRiLndhc20uZ3oHP3BhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9zdXJyZWFsZGJfd2FzbS5qcwwBDQEHBWFzc2V0Bz9wYWNrYWdlcy9zdXJyZWFsZGJfd2FzbS9hc3NldHMvd2FzbS9zdXJyZWFsZGIvc3VycmVhbGRiX3dhc20uanMHQ3BhY2thZ2VzL3N1cnJlYWxkYl93YXNtL2Fzc2V0cy93YXNtL3N1cnJlYWxkYi9zdXJyZWFsZGJfd2FzbS5taW4uanMMAQ0BBwVhc3NldAdDcGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL3N1cnJlYWxkYl93YXNtLm1pbi5qcwdGcGFja2FnZXMvc3VycmVhbGRiX3dhc20vYXNzZXRzL3dhc20vc3VycmVhbGRiL3N1cnJlYWxkYl93YXNtLm1pbi5qcy5negwBDQEHBWFzc2V0B0ZwYWNrYWdlcy9zdXJyZWFsZGJfd2FzbS9hc3NldHMvd2FzbS9zdXJyZWFsZGIvc3VycmVhbGRiX3dhc20ubWluLmpzLmd6" \ No newline at end of file diff --git a/assets/AssetManifest.json b/assets/AssetManifest.json index ed93c75..1055955 100644 --- a/assets/AssetManifest.json +++ b/assets/AssetManifest.json @@ -1 +1 @@ -{"packages/surrealdb_js/assets/js/index.bundled.mjs":["packages/surrealdb_js/assets/js/index.bundled.mjs"],"packages/surrealdb_wasm/assets/wasm/surrealdb/esm.bundled.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/esm.bundled.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/index.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/index.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm":["packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js.gz":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js.gz"]} \ No newline at end of file +{"packages/surrealdb_js/assets/js/index.bundled.mjs":["packages/surrealdb_js/assets/js/index.bundled.mjs"],"packages/surrealdb_wasm/assets/wasm/surrealdb/index.bundled.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/index.bundled.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/index.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/index.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm":["packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js"],"packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js.gz":["packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js.gz"]} \ No newline at end of file diff --git a/assets/NOTICES b/assets/NOTICES index a33d067..87c3e4f 100644 --- a/assets/NOTICES +++ b/assets/NOTICES @@ -28869,6 +28869,36 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- +json_annotation + +Copyright 2017, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + -------------------------------------------------------------------------------- khronos diff --git a/assets/packages/surrealdb_js/assets/js/index.bundled.mjs b/assets/packages/surrealdb_js/assets/js/index.bundled.mjs index 1f21a3c..32cb767 100644 --- a/assets/packages/surrealdb_js/assets/js/index.bundled.mjs +++ b/assets/packages/surrealdb_js/assets/js/index.bundled.mjs @@ -1,4 +1,4 @@ -var __defProp=Object.defineProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})};var Emitter=class{collectable={};listeners={};interceptors;constructor({interceptors}={}){this.interceptors=interceptors??{}}subscribe(event,listener,historic=!1){if(this.listeners[event]||(this.listeners[event]=[]),!this.isSubscribed(event,listener)&&(this.listeners[event]?.push(listener),historic&&this.collectable[event])){let buffer=this.collectable[event];this.collectable[event]=[];for(let args of buffer)listener(...args)}}subscribeOnce(event,historic=!1){return new Promise(resolve=>{let resolved=!1,listener=(...args)=>{resolved||(resolved=!0,this.unSubscribe(event,listener),resolve(args))};this.subscribe(event,listener,historic)})}unSubscribe(event,listener){if(this.listeners[event]){let index=this.listeners[event]?.findIndex(v=>v===listener);index&&this.listeners[event]?.splice(index,1)}}isSubscribed(event,listener){return!!this.listeners[event]?.includes(listener)}async emit(event,args,collectable=!1){let interceptor=this.interceptors[event],computedArgs=interceptor?await interceptor(...args):args;this.listeners[event]?.length===0&&collectable&&(this.collectable[event]||(this.collectable[event]=[]),this.collectable[event]?.push(args));for(let listener of this.listeners[event]??[])listener(...computedArgs)}reset({collectable,listeners}){if(Array.isArray(collectable))for(let k of collectable)delete this.collectable[k];else typeof collectable=="string"?delete this.collectable[collectable]:collectable!==!1&&(this.collectable={});if(Array.isArray(listeners))for(let k of listeners)delete this.listeners[k];else typeof listeners=="string"?delete this.listeners[listeners]:listeners!==!1&&(this.listeners={})}scanListeners(filter){let listeners=Object.keys(this.listeners);return filter&&(listeners=listeners.filter(filter)),listeners}};var cbor_exports={};__export(cbor_exports,{CborBreak:()=>CborBreak,CborError:()=>CborError,CborFillMissing:()=>CborFillMissing,CborInvalidMajorError:()=>CborInvalidMajorError,CborNumberError:()=>CborNumberError,CborPartialDisabled:()=>CborPartialDisabled,CborRangeError:()=>CborRangeError,Encoded:()=>Encoded,Gap:()=>Gap,POW_2_53:()=>POW_2_53,POW_2_64:()=>POW_2_64,PartiallyEncoded:()=>PartiallyEncoded,Reader:()=>Reader,Tagged:()=>Tagged,Writer:()=>Writer,decode:()=>decode,encode:()=>encode,infiniteBytes:()=>infiniteBytes,partiallyEncodeObject:()=>partiallyEncodeObject});var POW_2_53=9007199254740992,POW_2_64=BigInt(18446744073709552e3);var Encoded=class{constructor(encoded){this.encoded=encoded}};var SurrealDbError=class extends Error{},NoActiveSocket=class extends SurrealDbError{name="NoActiveSocket";message="No socket is currently connected to a SurrealDB instance. Please call the .connect() method first!"},NoConnectionDetails=class extends SurrealDbError{name="NoConnectionDetails";message="No connection details for the HTTP api have been provided. Please call the .connect() method first!"},UnexpectedResponse=class extends SurrealDbError{name="UnexpectedResponse";message="The returned response from the SurrealDB instance is in an unexpected format. Unable to process response!"},InvalidURLProvided=class extends SurrealDbError{name="InvalidURLProvided";message="The provided string is either not a URL or is a URL but with an invalid protocol!"},EngineDisconnected=class extends SurrealDbError{name="EngineDisconnected";message="The engine reported the connection to SurrealDB has dropped"},UnexpectedServerResponse=class extends SurrealDbError{constructor(response){super();this.response=response;this.message=`${response}`}name="UnexpectedServerResponse"},UnexpectedConnectionError=class extends SurrealDbError{constructor(error){super();this.error=error;this.message=`${error}`}name="UnexpectedConnectionError"},UnsupportedEngine=class extends SurrealDbError{constructor(engine){super();this.engine=engine}name="UnsupportedEngine";message="The engine you are trying to connect to is not supported or configured."},ConnectionUnavailable=class extends SurrealDbError{name="ConnectionUnavailable";message="There is no connection available at this moment."},MissingNamespaceDatabase=class extends SurrealDbError{name="MissingNamespaceDatabase";message="There are no namespace and/or database configured."},HttpConnectionError=class extends SurrealDbError{constructor(message,status,statusText,buffer){super();this.message=message;this.status=status;this.statusText=statusText;this.buffer=buffer}name="HttpConnectionError"},ResponseError=class extends SurrealDbError{constructor(message){super();this.message=message}name="ResponseError"},NoNamespaceSpecified=class extends SurrealDbError{name="NoNamespaceSpecified";message="Please specify a namespace to use."},NoDatabaseSpecified=class extends SurrealDbError{name="NoDatabaseSpecified";message="Please specify a database to use."},NoTokenReturned=class extends SurrealDbError{name="NoTokenReturned";message="Did not receive an authentication token."},UnsupportedVersion=class extends SurrealDbError{name="UnsupportedVersion";version;supportedRange;constructor(version,supportedRange){super(),this.version=version,this.supportedRange=supportedRange,this.message=`The version "${version}" reported by the engine is not supported by this library, expected a version that satisfies "${supportedRange}".`}},VersionRetrievalFailure=class extends SurrealDbError{constructor(error){super();this.error=error}name="VersionRetrievalFailure";message="Failed to retrieve remote version. If the server is behind a proxy, make sure it's configured correctly."};var CborError=class extends SurrealDbError{message;constructor(message){super(),this.message=message}},CborNumberError=class extends CborError{name="CborNumberError"},CborRangeError=class extends CborError{name="CborRangeError"},CborInvalidMajorError=class extends CborError{name="CborInvalidMajorError"},CborBreak=class extends CborError{name="CborBreak";constructor(){super("Came across a break which was not intercepted by the decoder")}},CborPartialDisabled=class extends CborError{name="CborPartialDisabled";constructor(){super("Tried to insert a Gap into a CBOR value, while partial mode is not enabled")}},CborFillMissing=class extends CborError{name="CborFillMissing";constructor(){super("Fill for a gap is missing, and gap has no default")}};var Gap=class{args=[];constructor(...args){this.args=args}fill(value){return[this,value]}hasDefault(){return this.args.length===1}get default(){return this.args[0]}};var Writer=class{constructor(byteLength=256){this.byteLength=byteLength;this._buf=new ArrayBuffer(this.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf)}_chunks=[];_pos=0;_buf;_view;_byte;chunk(gap){this._chunks.push([this._buf.slice(0,this._pos),gap]),this._buf=new ArrayBuffer(this.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._pos=0}get chunks(){return this._chunks}get buffer(){return this._buf.slice(0,this._pos)}claim(length){let pos=this._pos;if(this._pos+=length,this._pos<=this._buf.byteLength)return pos;let newLen=this._buf.byteLength<<1;for(;newLenthis._buf.byteLength){let oldb=this._byte;this._buf=new ArrayBuffer(newLen),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._byte.set(oldb)}return pos}writeUint8(value){let pos=this.claim(1);this._view.setUint8(pos,value)}writeUint16(value){let pos=this.claim(2);this._view.setUint16(pos,value)}writeUint32(value){let pos=this.claim(4);this._view.setUint32(pos,value)}writeUint64(value){let pos=this.claim(8);this._view.setBigUint64(pos,value)}writeUint8Array(data){if(data.byteLength===0)return;let pos=this.claim(data.byteLength);this._byte.set(data,pos)}writeArrayBuffer(data){data.byteLength!==0&&this.writeUint8Array(new Uint8Array(data))}writePartiallyEncoded(data){for(let[buf,gap]of data.chunks)this.writeArrayBuffer(buf),this.chunk(gap);this.writeArrayBuffer(data.end)}writeFloat32(value){let pos=this.claim(4);this._view.setFloat32(pos,value)}writeFloat64(value){let pos=this.claim(8);this._view.setFloat64(pos,value)}writeMajor(type,length){let base=type<<5;length<24?this.writeUint8(base+Number(length)):length<256?(this.writeUint8(base+24),this.writeUint8(Number(length))):length<65536?(this.writeUint8(base+25),this.writeUint16(Number(length))):length<4294967296?(this.writeUint8(base+26),this.writeUint32(Number(length))):(this.writeUint8(base+27),this.writeUint64(BigInt(length)))}output(partial,replacer2){return partial?new PartiallyEncoded(this._chunks,this.buffer,replacer2):this.buffer}};var PartiallyEncoded=class{constructor(chunks,end,replacer2){this.chunks=chunks;this.end=end;this.replacer=replacer2}build(fills,partial){let writer=new Writer,map=new Map(fills);for(let[buffer,gap]of this.chunks){let hasValue=map.has(gap)||gap.hasDefault();if(!partial&&!hasValue)throw new CborFillMissing;if(writer.writeArrayBuffer(buffer),hasValue){let data=map.get(gap)??gap.default;encode(data,{writer,replacer:this.replacer})}else writer.chunk(gap)}return writer.writeArrayBuffer(this.end),writer.output(!!partial,this.replacer)}};function partiallyEncodeObject(object,options){return Object.fromEntries(Object.entries(object).map(([k,v])=>[k,encode(v,{...options,partial:!0})]))}var Tagged=class{constructor(tag,value){this.tag=tag;this.value=value}};var textEncoder;function encode(input,options={}){let w=options.writer??new Writer,fillsMap=new Map(options.fills??[]);function inner(input2){let value=options.replacer?options.replacer(input2):input2;if(value===void 0)return w.writeUint8(247);if(value===null)return w.writeUint8(246);if(value===!0)return w.writeUint8(245);if(value===!1)return w.writeUint8(244);switch(typeof value){case"number":{if(Number.isInteger(value))if(value>=0&&value<=9007199254740992)w.writeMajor(0,value);else if(value<0&&value>=-9007199254740992)w.writeMajor(1,-(value+1));else throw new CborNumberError("Number too big to be encoded");else w.writeUint8(251),w.writeFloat64(value);return}case"bigint":{if(value>=0&&value=-POW_2_64)w.writeMajor(1,-(value+1n));else throw new CborNumberError("BigInt too big to be encoded");return}case"string":{textEncoder??=new TextEncoder;let encoded=textEncoder.encode(value);w.writeMajor(3,encoded.byteLength),w.writeUint8Array(encoded);return}default:{if(Array.isArray(value)){w.writeMajor(4,value.length);for(let v of value)inner(v);return}if(value instanceof Tagged){w.writeMajor(6,value.tag),inner(value.value);return}if(value instanceof Encoded){w.writeArrayBuffer(value.encoded);return}if(value instanceof Gap){if(fillsMap.has(value))inner(fillsMap.get(value));else{if(!options.partial)throw new CborPartialDisabled;w.chunk(value)}return}if(value instanceof PartiallyEncoded){let res=value.build(options.fills??[],options.partial);options.partial?w.writePartiallyEncoded(res):w.writeArrayBuffer(res);return}if(value instanceof Uint8Array||value instanceof Uint16Array||value instanceof Uint32Array||value instanceof Int8Array||value instanceof Int16Array||value instanceof Int32Array||value instanceof Float32Array||value instanceof Float64Array||value instanceof ArrayBuffer){let v=new Uint8Array(value);w.writeMajor(2,v.byteLength),w.writeUint8Array(v);return}let entries=value instanceof Map?Array.from(value.entries()):Object.entries(value);w.writeMajor(5,entries.length);for(let v of entries.flat())inner(v)}}}return inner(input),w.output(!!options.partial,options.replacer)}var Reader=class{_buf;_view;_byte;_pos=0;constructor(buffer){this._buf=new ArrayBuffer(buffer.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._byte.set(new Uint8Array(buffer))}read(amount,res){return this._pos+=amount,res}readUint8(){try{return this.read(1,this._view.getUint8(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint16(){try{return this.read(2,this._view.getUint16(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint32(){try{return this.read(4,this._view.getUint32(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint64(){try{return this.read(8,this._view.getBigUint64(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readFloat16(){let bytes=this.readUint16(),s=(bytes&32768)>>15,e=(bytes&31744)>>10,f2=bytes&1023;return e===0?(s?-1:1)*2**-14*(f2/2**10):e===31?f2?Number.NaN:(s?-1:1)*Number.POSITIVE_INFINITY:(s?-1:1)*2**(e-15)*(1+f2/2**10)}readFloat32(){try{return this.read(4,this._view.getFloat32(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readFloat64(){try{return this.read(8,this._view.getFloat64(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readBytes(amount){let available=this._byte.length-this._pos;if(available>5;if(major<0||major>7)throw new CborInvalidMajorError("Received invalid major type");return[major,byte&31]}readMajorLength(length){if(length<=23)return length;switch(length){case 24:return this.readUint8();case 25:return this.readUint16();case 26:return this.readUint32();case 27:{let read=this.readUint64();return read>9007199254740992?read:Number(read)}}throw new CborRangeError("Expected a final length")}};function infiniteBytes(r,forMajor){let w=new Writer;for(;;){let[major,len]=r.readMajor();if(major===7&&len===31)break;if(major!==forMajor)throw new CborInvalidMajorError(`Expected a resource of the same major (${forMajor}) while processing an infinite resource`);if(len===31)throw new CborRangeError("Expected a finite resource while processing an infinite resource");w.writeUint8Array(r.readBytes(Number(r.readMajorLength(len))))}return w.buffer}var textDecoder;function decode(input,options={}){let r=input instanceof Reader?input:new Reader(input);function inner(){let[major,len]=r.readMajor();switch(major){case 0:return r.readMajorLength(len);case 1:{let l=r.readMajorLength(len);return typeof l=="bigint"?-(l+1n):-(l+1)}case 2:return len===31?infiniteBytes(r,2):r.readBytes(Number(r.readMajorLength(len))).buffer;case 3:{let encoded=len===31?infiniteBytes(r,3):r.readBytes(Number(r.readMajorLength(len)));return textDecoder??=new TextDecoder,textDecoder.decode(encoded)}case 4:{if(len===31){let arr2=[];for(;;)try{arr2.push(decode2())}catch(e){if(e instanceof CborBreak)break;throw e}return arr2}let l=r.readMajorLength(len),arr=Array(l);for(let i=0;i(map.set(size,unit),map),new Map),durationPartRegex=new RegExp(`^(\\d+)(${Array.from(units.keys()).join("|")})`),Duration=class _Duration{_milliseconds;constructor(input){input instanceof _Duration?this._milliseconds=input._milliseconds:typeof input=="string"?this._milliseconds=_Duration.parseString(input):this._milliseconds=input}static fromCompact([s,ns]){s=s??0,ns=ns??0;let ms=s*1e3+ns/1e6;return new _Duration(ms)}toCompact(){let s=Math.floor(this._milliseconds/1e3),ns=Math.floor((this._milliseconds-s*1e3)*1e6);return ns>0?[s,ns]:s>0?[s]:[]}toString(){let left=this._milliseconds,result="";function scrap(size){let num=Math.floor(left/size);return num>0&&(left=left%size),num}for(let[size,unit]of Array.from(unitsReverse).reverse()){let scrapped=scrap(size);scrapped>0&&(result+=`${scrapped}${unit}`)}return result}toJSON(){return this.toString()}static parseString(input){let ms=0,left=input;for(;left!=="";){let match=left.match(durationPartRegex);if(match){let amount=Number.parseInt(match[1]),factor=units.get(match[2]);if(factor===void 0)throw new SurrealDbError(`Invalid duration unit: ${match[2]}`);ms+=amount*factor,left=left.slice(match[0].length);continue}throw new SurrealDbError("Could not match a next duration part")}return ms}static nanoseconds(nanoseconds){return new _Duration(Math.floor(nanoseconds*nanosecond))}static microseconds(microseconds){return new _Duration(Math.floor(microseconds*microsecond))}static milliseconds(milliseconds){return new _Duration(milliseconds)}static seconds(seconds){return new _Duration(seconds*second)}static minutes(minutes){return new _Duration(minutes*minute)}static hours(hours){return new _Duration(hours*hour)}static days(days){return new _Duration(days*day)}static weeks(weeks){return new _Duration(weeks*week)}get microseconds(){return Math.floor(this._milliseconds/microsecond)}get nanoseconds(){return Math.floor(this._milliseconds/nanosecond)}get milliseconds(){return Math.floor(this._milliseconds)}get seconds(){return Math.floor(this._milliseconds/second)}get minutes(){return Math.floor(this._milliseconds/minute)}get hours(){return Math.floor(this._milliseconds/hour)}get days(){return Math.floor(this._milliseconds/day)}get weeks(){return Math.floor(this._milliseconds/week)}};var Geometry=class{};function f(num){return num instanceof Decimal?Number.parseFloat(num.decimal):num}var GeometryPoint=class _GeometryPoint extends Geometry{point;constructor(point){super(),point instanceof _GeometryPoint?this.point=point.clone().point:this.point=[f(point[0]),f(point[1])]}toJSON(){return{type:"Point",coordinates:this.coordinates}}get coordinates(){return this.point}is(geometry){return geometry instanceof _GeometryPoint?this.point[0]===geometry.point[0]&&this.point[1]===geometry.point[1]:!1}clone(){return new _GeometryPoint([...this.point])}},GeometryLine=class _GeometryLine extends Geometry{line;constructor(line){super(),this.line=line instanceof _GeometryLine?line.clone().line:line}toJSON(){return{type:"LineString",coordinates:this.coordinates}}get coordinates(){return this.line.map(g=>g.coordinates)}close(){this.line[0].is(this.line.at(-1))||this.line.push(this.line[0])}is(geometry){if(!(geometry instanceof _GeometryLine)||this.line.length!==geometry.line.length)return!1;for(let i=0;ip.clone()))}},GeometryPolygon=class _GeometryPolygon extends Geometry{polygon;constructor(polygon){super(),this.polygon=polygon instanceof _GeometryPolygon?polygon.clone().polygon:polygon.map(l=>{let line=l.clone();return line.close(),line})}toJSON(){return{type:"Polygon",coordinates:this.coordinates}}get coordinates(){return this.polygon.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryPolygon)||this.polygon.length!==geometry.polygon.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiPoint=class _GeometryMultiPoint extends Geometry{points;constructor(points){super(),this.points=points instanceof _GeometryMultiPoint?points.points:points}toJSON(){return{type:"MultiPoint",coordinates:this.coordinates}}get coordinates(){return this.points.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiPoint)||this.points.length!==geometry.points.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiLine=class _GeometryMultiLine extends Geometry{lines;constructor(lines){super(),this.lines=lines instanceof _GeometryMultiLine?lines.lines:lines}toJSON(){return{type:"MultiLineString",coordinates:this.coordinates}}get coordinates(){return this.lines.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiLine)||this.lines.length!==geometry.lines.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiPolygon=class _GeometryMultiPolygon extends Geometry{polygons;constructor(polygons){super(),this.polygons=polygons instanceof _GeometryMultiPolygon?polygons.polygons:polygons}toJSON(){return{type:"MultiPolygon",coordinates:this.coordinates}}get coordinates(){return this.polygons.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiPolygon)||this.polygons.length!==geometry.polygons.length)return!1;for(let i=0;ip.clone()))}},GeometryCollection=class _GeometryCollection extends Geometry{collection;constructor(collection){super(),this.collection=collection instanceof _GeometryCollection?collection.collection:collection}toJSON(){return{type:"GeometryCollection",geometries:this.geometries}}get geometries(){return this.collection.map(g=>g.toJSON())}is(geometry){if(!(geometry instanceof _GeometryCollection)||this.collection.length!==geometry.collection.length)return!1;for(let i=0;ip.clone()))}};var MAX_i64=9223372036854775807n,RecordId=class{tb;id;constructor(tb,id2){if(typeof tb!="string")throw new SurrealDbError("TB part is not valid");if(!isValidIsPart(id2))throw new SurrealDbError("ID part is not valid");this.tb=tb,this.id=id2}toJSON(){return this.toString()}toString(){let tb=escape_ident(this.tb),id2=typeof this.id=="string"?escape_ident(this.id):typeof this.id=="bigint"||typeof this.id=="number"?escape_number(this.id):JSON.stringify(this.id);return`${tb}:${id2}`}},StringRecordId=class{rid;constructor(rid){if(typeof rid!="string")throw new SurrealDbError("String Record ID must be a string");this.rid=rid}toJSON(){return this.rid}toString(){return this.rid}};function escape_number(num){return num<=MAX_i64?num.toString():`\u27E8${num}\u27E9`}function escape_ident(str){if(isOnlyNumbers(str))return`\u27E8${str}\u27E9`;let code,i,len;for(i=0,len=str.length;i47&&code<58)&&!(code>64&&code<91)&&!(code>96&&code<123)&&code!==95)return`\u27E8${str.replaceAll("\u27E9","\u27E9")}\u27E9`;return str}function isOnlyNumbers(str){let parsed=Number.parseInt(str);return!Number.isNaN(parsed)&&parsed.toString()===str}function isValidIsPart(v){switch(typeof v){case"string":case"number":case"bigint":return!0;case"object":return Array.isArray(v)||v!==null;default:return!1}}var Table=class{tb;constructor(tb){if(typeof tb!="string")throw new SurrealDbError("Table must be a string");this.tb=tb}toJSON(){return this.tb}toString(){return this.tb}};var DIGITS="0123456789abcdef",UUID=class _UUID{constructor(bytes){this.bytes=bytes}static ofInner(bytes){if(bytes.length!==16)throw new TypeError("not 128-bit length");return new _UUID(bytes)}static fromFieldsV7(unixTsMs,randA,randBHi,randBLo){if(!Number.isInteger(unixTsMs)||!Number.isInteger(randA)||!Number.isInteger(randBHi)||!Number.isInteger(randBLo)||unixTsMs<0||randA<0||randBHi<0||randBLo<0||unixTsMs>0xffffffffffff||randA>4095||randBHi>1073741823||randBLo>4294967295)throw new RangeError("invalid field value");let bytes=new Uint8Array(16);return bytes[0]=unixTsMs/2**40,bytes[1]=unixTsMs/2**32,bytes[2]=unixTsMs/2**24,bytes[3]=unixTsMs/2**16,bytes[4]=unixTsMs/2**8,bytes[5]=unixTsMs,bytes[6]=112|randA>>>8,bytes[7]=randA,bytes[8]=128|randBHi>>>24,bytes[9]=randBHi>>>16,bytes[10]=randBHi>>>8,bytes[11]=randBHi,bytes[12]=randBLo>>>24,bytes[13]=randBLo>>>16,bytes[14]=randBLo>>>8,bytes[15]=randBLo,new _UUID(bytes)}static parse(uuid){var _a,_b,_c,_d;let hex;switch(uuid.length){case 32:hex=(_a=/^[0-9a-f]{32}$/i.exec(uuid))===null||_a===void 0?void 0:_a[0];break;case 36:hex=(_b=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid))===null||_b===void 0?void 0:_b.slice(1,6).join("");break;case 38:hex=(_c=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid))===null||_c===void 0?void 0:_c.slice(1,6).join("");break;case 45:hex=(_d=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid))===null||_d===void 0?void 0:_d.slice(1,6).join("");break;default:break}if(hex){let inner=new Uint8Array(16);for(let i=0;i<16;i+=4){let n=parseInt(hex.substring(2*i,2*i+8),16);inner[i+0]=n>>>24,inner[i+1]=n>>>16,inner[i+2]=n>>>8,inner[i+3]=n}return new _UUID(inner)}else throw new SyntaxError("could not parse UUID string")}toString(){let text="";for(let i=0;i>>4),text+=DIGITS.charAt(this.bytes[i]&15),(i===3||i===5||i===7||i===9)&&(text+="-");return text}toHex(){let text="";for(let i=0;i>>4),text+=DIGITS.charAt(this.bytes[i]&15);return text}toJSON(){return this.toString()}getVariant(){let n=this.bytes[8]>>>4;if(n<0)throw new Error("unreachable");if(n<=7)return this.bytes.every(e=>e===0)?"NIL":"VAR_0";if(n<=11)return"VAR_10";if(n<=13)return"VAR_110";if(n<=15)return this.bytes.every(e=>e===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new _UUID(this.bytes.slice(0))}equals(other){return this.compareTo(other)===0}compareTo(other){for(let i=0;i<16;i++){let diff=this.bytes[i]-other.bytes[i];if(diff!==0)return Math.sign(diff)}return 0}},V7Generator=class{constructor(randomNumberGenerator){this.timestamp=0,this.counter=0,this.random=randomNumberGenerator??getDefaultRandom()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(unixTsMs,rollbackAllowance){let value=this.generateOrAbortCore(unixTsMs,rollbackAllowance);return value===void 0&&(this.timestamp=0,value=this.generateOrAbortCore(unixTsMs,rollbackAllowance)),value}generateOrAbortCore(unixTsMs,rollbackAllowance){if(!Number.isInteger(unixTsMs)||unixTsMs<1||unixTsMs>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(rollbackAllowance<0||rollbackAllowance>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(unixTsMs>this.timestamp)this.timestamp=unixTsMs,this.resetCounter();else if(unixTsMs+rollbackAllowance>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return UUID.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let bytes=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return bytes[6]=64|bytes[6]>>>4,bytes[8]=128|bytes[8]>>>2,UUID.ofInner(bytes)}},getDefaultRandom=()=>{if(typeof crypto<"u"&&typeof crypto.getRandomValues<"u")return new BufferedCryptoRandom;if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");return{nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}},BufferedCryptoRandom=class{constructor(){this.buffer=new Uint32Array(8),this.cursor=65535}nextUint32(){return this.cursor>=this.buffer.length&&(crypto.getRandomValues(this.buffer),this.cursor=0),this.buffer[this.cursor++]}},defaultGenerator;var uuidv7obj=()=>(defaultGenerator||(defaultGenerator=new V7Generator)).generate();var uuidv4obj=()=>(defaultGenerator||(defaultGenerator=new V7Generator)).generateV4();var Uuid=class _Uuid{inner;constructor(uuid){uuid instanceof ArrayBuffer?this.inner=UUID.ofInner(new Uint8Array(uuid)):uuid instanceof Uint8Array?this.inner=UUID.ofInner(uuid):uuid instanceof _Uuid?this.inner=uuid.inner:uuid instanceof UUID?this.inner=uuid:this.inner=UUID.parse(uuid)}toString(){return this.inner.toString()}toJSON(){return this.inner.toString()}toUint8Array(){return this.inner.bytes}toBuffer(){return this.inner.bytes.buffer}static v4(){return new _Uuid(uuidv4obj())}static v7(){return new _Uuid(uuidv7obj())}};var TAG_SPEC_DATETIME=0,TAG_SPEC_UUID=37,TAG_NONE=6,TAG_TABLE=7,TAG_RECORDID=8,TAG_STRING_UUID=9,TAG_STRING_DECIMAL=10,TAG_CUSTOM_DATETIME=12,TAG_STRING_DURATION=13,TAG_CUSTOM_DURATION=14,TAG_GEOMETRY_POINT=88,TAG_GEOMETRY_LINE=89,TAG_GEOMETRY_POLYGON=90,TAG_GEOMETRY_MULTIPOINT=91,TAG_GEOMETRY_MULTILINE=92,TAG_GEOMETRY_MULTIPOLYGON=93,TAG_GEOMETRY_COLLECTION=94,replacer={encode(v){return v instanceof Date?new Tagged(TAG_CUSTOM_DATETIME,dateToCborCustomDate(v)):v===void 0?new Tagged(TAG_NONE,null):v instanceof Uuid?new Tagged(TAG_SPEC_UUID,v.toBuffer()):v instanceof Decimal?new Tagged(TAG_STRING_DECIMAL,v.toString()):v instanceof Duration?new Tagged(TAG_CUSTOM_DURATION,v.toCompact()):v instanceof RecordId?new Tagged(TAG_RECORDID,[v.tb,v.id]):v instanceof StringRecordId?new Tagged(TAG_RECORDID,v.rid):v instanceof Table?new Tagged(TAG_TABLE,v.tb):v instanceof GeometryPoint?new Tagged(TAG_GEOMETRY_POINT,v.point):v instanceof GeometryLine?new Tagged(TAG_GEOMETRY_LINE,v.line):v instanceof GeometryPolygon?new Tagged(TAG_GEOMETRY_POLYGON,v.polygon):v instanceof GeometryMultiPoint?new Tagged(TAG_GEOMETRY_MULTIPOINT,v.points):v instanceof GeometryMultiLine?new Tagged(TAG_GEOMETRY_MULTILINE,v.lines):v instanceof GeometryMultiPolygon?new Tagged(TAG_GEOMETRY_MULTIPOLYGON,v.polygons):v instanceof GeometryCollection?new Tagged(TAG_GEOMETRY_COLLECTION,v.collection):v},decode(v){if(!(v instanceof Tagged))return v;switch(v.tag){case TAG_SPEC_DATETIME:return new Date(v.value);case TAG_SPEC_UUID:case TAG_STRING_UUID:return new Uuid(v.value);case TAG_CUSTOM_DATETIME:return cborCustomDateToDate(v.value);case TAG_NONE:return;case TAG_STRING_DECIMAL:return new Decimal(v.value);case TAG_STRING_DURATION:return new Duration(v.value);case TAG_CUSTOM_DURATION:return Duration.fromCompact(v.value);case TAG_TABLE:return new Table(v.value);case TAG_RECORDID:return new RecordId(v.value[0],v.value[1]);case TAG_GEOMETRY_POINT:return new GeometryPoint(v.value);case TAG_GEOMETRY_LINE:return new GeometryLine(v.value);case TAG_GEOMETRY_POLYGON:return new GeometryPolygon(v.value);case TAG_GEOMETRY_MULTIPOINT:return new GeometryMultiPoint(v.value);case TAG_GEOMETRY_MULTILINE:return new GeometryMultiLine(v.value);case TAG_GEOMETRY_MULTIPOLYGON:return new GeometryMultiPolygon(v.value);case TAG_GEOMETRY_COLLECTION:return new GeometryCollection(v.value)}}};Object.freeze(replacer);function encodeCbor(data){return encode(data,{replacer:replacer.encode})}function decodeCbor(data){return decode(data,{replacer:replacer.decode})}var PreparedQuery=class{query;bindings;constructor(query,bindings,convert){this.query=new Encoded(encode(query)),this.bindings=partiallyEncodeObject(bindings??{},{replacer:replacer.encode})}build(gaps){return encode([this.query,this.bindings])}};function surrealql(query_raw,...values){let mapped_bindings=values.map((v,i)=>[`bind___${i}`,v]),bindings=mapped_bindings.reduce((prev,[k,v])=>(prev[k]=v,prev),{}),query=query_raw.flatMap((segment,i)=>{let variable=mapped_bindings[i]?.[0];return[segment,...variable?[`$${variable}`]:[]]}).join("");return new PreparedQuery(query,bindings)}function convertAuth(params){let result={},convertString=(a,b,optional)=>{if(a in params)result[b]=`${params[a]}`,delete result[a];else if(optional!==!0)throw new SurrealDbError(`Key ${a} is missing from the authentication parameters`)};return"scope"in params?(result={...params},convertString("scope","sc"),convertString("namespace","ns"),convertString("database","db")):"variables"in params?(result={...params.variables},convertString("access","ac"),convertString("namespace","ns"),convertString("database","db")):(convertString("access","ac",!0),convertString("database","db",!0),convertString("namespace","ns",!("database"in params)),convertString("username","user"),convertString("password","pass")),result}var liveActions=["CREATE","UPDATE","DELETE"];function isLiveResult(v){return!(typeof v!="object"||v===null||!("id"in v&&"action"in v&&"result"in v)||!(v.id instanceof Uuid)||!liveActions.includes(v.action)||typeof v.result!="object"||v.result===null)}function jsonify(input){if(typeof input=="object"){if(input===null)return null;if(input instanceof Date||input instanceof Uuid||input instanceof Decimal||input instanceof Duration||input instanceof StringRecordId||input instanceof RecordId||input instanceof Geometry||input instanceof Table)return input.toJSON();switch(Object.getPrototypeOf(input)){case Object.prototype:{let mapped=Object.entries(input).map(([k,v])=>[k,jsonify(v)]).filter(([_,v])=>v!==void 0);return Object.fromEntries(mapped)}case Map.prototype:{let mapped=Array.from(input).map(([k,v])=>[k,jsonify(v)]).filter(([_,v])=>v!==void 0);return new Map(mapped)}case Array.prototype:return input.map(jsonify);case Set.prototype:return new Set([...input].map(jsonify))}}return input}var defaultVersionCheckTimeout=5e3,supportedSurrealDbVersionMin="1.4.2",supportedSurrealDbVersionUntil="3.0.0",supportedSurrealDbVersionRange=`>= ${supportedSurrealDbVersionMin} < ${supportedSurrealDbVersionUntil}`;function versionCheck(version,min=supportedSurrealDbVersionMin,until=supportedSurrealDbVersionUntil){if(!isVersionSupported(version,min,until))throw new UnsupportedVersion(version,`>= ${min} < ${until}`);return!0}function isVersionSupported(version,min=supportedSurrealDbVersionMin,until=supportedSurrealDbVersionUntil){return min.localeCompare(version,void 0,{numeric:!0})<=0&&until.localeCompare(version,void 0,{numeric:!0})===1}async function retrieveRemoteVersion(url,timeout){let protocol={"ws:":"http:","wss:":"https:","http:":"http:","https:":"https:"}[url.protocol];if(protocol){let basepath=url.pathname.slice(0,-4);url=new URL(url),url.pathname=`${basepath}/version`,url.protocol=protocol;let controller=new AbortController,id2=setTimeout(()=>controller.abort(),timeout??defaultVersionCheckTimeout),versionPrefix="surrealdb-";return await fetch(url,{signal:controller.signal}).then(res=>res.text()).then(version2=>version2.slice(versionPrefix.length)).catch(e=>{throw new VersionRetrievalFailure(e)}).finally(()=>{clearTimeout(id2)})}throw new VersionRetrievalFailure}var id=0;function getIncrementalID(){return id=(id+1)%Number.MAX_SAFE_INTEGER,id.toString()}var ConnectionStatus=(ConnectionStatus2=>(ConnectionStatus2.Disconnected="disconnected",ConnectionStatus2.Connecting="connecting",ConnectionStatus2.Connected="connected",ConnectionStatus2.Error="error",ConnectionStatus2))(ConnectionStatus||{}),EngineContext=class{emitter;encodeCbor;decodeCbor;constructor({emitter,encodeCbor:encodeCbor2,decodeCbor:decodeCbor2}){this.emitter=emitter,this.encodeCbor=encodeCbor2,this.decodeCbor=decodeCbor2}},AbstractEngine=class{context;ready;status="disconnected";connection={url:void 0,namespace:void 0,database:void 0,token:void 0};constructor(context){this.context=context}get emitter(){return this.context.emitter}get encodeCbor(){return this.context.encodeCbor}get decodeCbor(){return this.context.decodeCbor}};function processAuthVars(vars,fallback){if("scope"in vars||"access"in vars&&"variables"in vars&&vars.variables){if(!vars.namespace){if(!fallback?.namespace)throw new NoNamespaceSpecified;vars.namespace=fallback.namespace}if(!vars.database){if(!fallback?.database)throw new NoDatabaseSpecified;vars.database=fallback.database}}return vars}var HttpEngine=class extends AbstractEngine{connection={url:void 0,namespace:void 0,database:void 0,token:void 0,variables:{}};setStatus(status,...args){this.status=status,this.emitter.emit(status,args)}version(url,timeout){return retrieveRemoteVersion(url,timeout)}connect(url){return this.setStatus("connecting"),this.connection.url=url,this.setStatus("connected"),this.ready=new Promise(r=>r()),this.ready}disconnect(){return this.connection={url:void 0,namespace:void 0,database:void 0,token:void 0,variables:{}},this.ready=void 0,this.setStatus("disconnected"),new Promise(r=>r())}async rpc(request){if(await this.ready,!this.connection.url)throw new ConnectionUnavailable;if(request.method==="use"){let[ns,db]=request.params;return ns===null&&(this.connection.namespace=void 0),db===null&&(this.connection.database=void 0),ns&&(this.connection.namespace=ns),db&&(this.connection.database=db),{result:!0}}if(request.method==="let"){let[key,value]=request.params;return this.connection.variables[key]=value,{result:!0}}if(request.method==="unset"){let[key]=request.params;return delete this.connection.variables[key],{result:!0}}if(request.method==="query"&&(request.params=[request.params?.[0],{...this.connection.variables,...request.params?.[1]??{}}]),!this.connection.namespace||!this.connection.database)throw new MissingNamespaceDatabase;let id2=getIncrementalID(),raw=await fetch(`${this.connection.url}`,{method:"POST",headers:{"Content-Type":"application/cbor",Accept:"application/cbor","Surreal-NS":this.connection.namespace,"Surreal-DB":this.connection.database,...this.connection.token?{Authorization:`Bearer ${this.connection.token}`}:{}},body:this.encodeCbor({id:id2,...request})}),buffer=await raw.arrayBuffer();if(raw.status===200){let response=this.decodeCbor(buffer);if("result"in response)switch(request.method){case"signin":case"signup":{this.connection.token=response.result;break}case"authenticate":{let[token]=request.params;this.connection.token=token;break}case"invalidate":{this.connection.token=void 0;break}}return this.emitter.emit(`rpc-${id2}`,[response]),response}let dec=new TextDecoder("utf-8");throw new HttpConnectionError(dec.decode(buffer),raw.status,raw.statusText,buffer)}get connected(){return!!this.connection.url}};function getNativeWebSocket(){if(typeof WebSocket<"u")return WebSocket;if(typeof global.WebSocket<"u")return global.WebSocket;if(typeof window.WebSocket<"u")return window.WebSocket;if(typeof self.WebSocket<"u")return self.WebSocket;throw new Error("`WebSocket` is not supported in this environment")}var WebSocket2=getNativeWebSocket();var WebsocketEngine=class extends AbstractEngine{pinger;socket;constructor(context){super(context),this.emitter.subscribe("disconnected",()=>this.pinger?.stop())}setStatus(status,...args){this.status=status,this.emitter.emit(status,args)}async requireStatus(status){return this.status!==status&&await this.emitter.subscribeOnce(status),!0}version(url,timeout){return retrieveRemoteVersion(url,timeout)}async connect(url){this.connection.url=url,this.setStatus("connecting");let socket=new WebSocket2(url.toString(),"cbor"),ready=new Promise((resolve,reject)=>{socket.addEventListener("open",()=>{this.setStatus("connected"),resolve()}),socket.addEventListener("error",e=>{let error=new UnexpectedConnectionError("error"in e?e.error:"An unexpected error occurred");this.setStatus("error",error),reject(error)}),socket.addEventListener("close",()=>{this.setStatus("disconnected")}),socket.addEventListener("message",async({data})=>{try{let decoded=this.decodeCbor(data instanceof Blob?await data.arrayBuffer():data.buffer.slice(data.byteOffset,data.byteOffset+data.byteLength));if(typeof decoded=="object"&&decoded!=null&&Object.getPrototypeOf(decoded)===Object.prototype)this.handleRpcResponse(decoded);else throw new UnexpectedServerResponse(decoded)}catch(detail){socket.dispatchEvent(new CustomEvent("error",{detail}))}})});return this.ready=ready,await ready.then(()=>{this.socket=socket,this.pinger?.stop(),this.pinger=new Pinger(3e4),this.pinger.start(()=>this.rpc({method:"ping"}))})}async disconnect(){this.connection={url:void 0,namespace:void 0,database:void 0,token:void 0},await this.ready?.catch(()=>{}),this.socket?.close(),this.ready=void 0,this.socket=void 0,await Promise.any([this.requireStatus("disconnected"),this.requireStatus("error")])}async rpc(request){if(await this.ready,!this.socket)throw new ConnectionUnavailable;let id2=getIncrementalID(),response=this.emitter.subscribeOnce(`rpc-${id2}`);this.socket.send(this.encodeCbor({id:id2,...request}));let[res]=await response;if(res instanceof EngineDisconnected)throw res;if("result"in res)switch(request.method){case"use":{let[ns,db]=request.params;ns===null&&(this.connection.namespace=void 0),db===null&&(this.connection.database=void 0),ns&&(this.connection.namespace=ns),db&&(this.connection.database=db);break}case"signin":case"signup":{this.connection.token=res.result;break}case"authenticate":{let[token]=request.params;this.connection.token=token;break}case"invalidate":{this.connection.token=void 0;break}}return res}handleRpcResponse({id:id2,...res}){if(id2)this.emitter.emit(`rpc-${id2}`,[res]);else if(res.error)this.setStatus("error",new ResponseError(res.error));else if(isLiveResult(res.result)){let{id:id3,action,result}=res.result;this.emitter.emit(`live-${id3}`,[action,result],!0)}else this.setStatus("error",new UnexpectedServerResponse({id:id2,...res}))}get connected(){return!!this.socket}},Pinger=class{pinger;interval;constructor(interval=3e4){this.interval=interval}start(callback){this.pinger=setInterval(callback,this.interval)}stop(){clearInterval(this.pinger)}};var Surreal=class{connection;ready;emitter;engines={ws:WebsocketEngine,wss:WebsocketEngine,http:HttpEngine,https:HttpEngine};constructor({engines}={}){this.emitter=new Emitter,this.emitter.subscribe("disconnected",()=>this.clean()),this.emitter.subscribe("error",()=>this.close()),engines&&(this.engines={...this.engines,...engines})}async connect(url,opts={}){url=new URL(url),url.pathname.endsWith("/rpc")||(url.pathname.endsWith("/")||(url.pathname+="/"),url.pathname+="rpc");let engineName=url.protocol.slice(0,-1),engine=this.engines[engineName];if(!engine)throw new UnsupportedEngine(engineName);let{prepare,auth,namespace,database}=opts;await this.close();let context=new EngineContext({emitter:this.emitter,encodeCbor,decodeCbor}),connection=new engine(context);if(opts.versionCheck!==!1){let version=await connection.version(url,opts.versionCheckTimeout);versionCheck(version)}return this.connection=connection,this.ready=new Promise((resolve,reject)=>connection.connect(url).then(async()=>{(namespace||database)&&await this.use({namespace,database}),typeof auth=="string"?await this.authenticate(auth):auth&&await this.signin(auth),await prepare?.(this),resolve()}).catch(reject)),await this.ready,!0}async close(){return this.clean(),await this.connection?.disconnect(),!0}clean(){let pending=this.emitter.scanListeners(k=>k.startsWith("rpc-"));pending.map(k=>this.emitter.emit(k,[new EngineDisconnected]));let live=this.emitter.scanListeners(k=>k.startsWith("live-"));live.map(k=>this.emitter.emit(k,["CLOSE","disconnected"])),this.emitter.reset({collectable:!0,listeners:[...pending,...live]})}get status(){return this.connection?.status??"disconnected"}async ping(){let{error}=await this.rpc("ping");if(error)throw new ResponseError(error.message);return!0}async use({namespace,database}){if(!this.connection)throw new NoActiveSocket;if(namespace===null&&database!==null)throw new SurrealDbError("Cannot unset namespace without unsetting database");let{error}=await this.rpc("use",[namespace,database]);if(error)throw new ResponseError(error.message);return!0}async info(){await this.ready;let res=await this.rpc("info");if(res.error)throw new ResponseError(res.error.message);return res.result??void 0}async signup(vars){if(!this.connection)throw new NoActiveSocket;let parsed=processAuthVars(vars,this.connection.connection),converted=convertAuth(parsed),res=await this.rpc("signup",[converted]);if(res.error)throw new ResponseError(res.error.message);if(!res.result)throw new NoTokenReturned;return res.result}async signin(vars){if(!this.connection)throw new NoActiveSocket;let parsed=processAuthVars(vars,this.connection.connection),converted=convertAuth(parsed),res=await this.rpc("signin",[converted]);if(res.error)throw new ResponseError(res.error.message);if(!res.result)throw new NoTokenReturned;return res.result}async authenticate(token){let res=await this.rpc("authenticate",[token]);if(res.error)throw new ResponseError(res.error.message);return!0}async invalidate(){let res=await this.rpc("invalidate");if(res.error)throw new ResponseError(res.error.message);return!0}async let(variable,value){let res=await this.rpc("let",[variable,value]);if(res.error)throw new ResponseError(res.error.message);return!0}async unset(variable){let res=await this.rpc("unset",[variable]);if(res.error)throw new ResponseError(res.error.message);return!0}async live(table,callback,diff){await this.ready;let res=await this.rpc("live",[table,diff]);if(res.error)throw new ResponseError(res.error.message);return callback&&this.subscribeLive(res.result,callback),res.result}async subscribeLive(queryUuid,callback){if(await this.ready,!this.connection)throw new NoActiveSocket;this.connection.emitter.subscribe(`live-${queryUuid}`,callback,!0)}async unSubscribeLive(queryUuid,callback){if(await this.ready,!this.connection)throw new NoActiveSocket;this.connection.emitter.unSubscribe(`live-${queryUuid}`,callback)}async kill(queryUuid){if(await this.ready,!this.connection)throw new NoActiveSocket;if(Array.isArray(queryUuid)){await Promise.all(queryUuid.map(u=>this.rpc("kill",[u])));let toBeKilled=queryUuid.map(u=>`live-${u}`);toBeKilled.map(k=>this.emitter.emit(k,["CLOSE","killed"])),this.connection.emitter.reset({collectable:toBeKilled,listeners:toBeKilled})}else await this.rpc("kill",[queryUuid]),this.emitter.emit(`live-${queryUuid}`,["CLOSE","killed"]),this.connection.emitter.reset({collectable:`live-${queryUuid}`,listeners:`live-${queryUuid}`})}async query(...args){return(await this.query_raw(...args)).map(({status,result})=>{if(status==="ERR")throw new ResponseError(result);return result})}async query_raw(...[q,b]){let params=q instanceof PreparedQuery?[q.query,partiallyEncodeObject(q.bindings,{fills:b,replacer:replacer.encode})]:[q,b];await this.ready;let res=await this.rpc("query",params);if(res.error)throw new ResponseError(res.error.message);return res.result}async select(thing){await this.ready;let res=await this.rpc("select",[thing]);if(res.error)throw new ResponseError(res.error.message);return res.result}async create(thing,data){await this.ready;let res=await this.rpc("create",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return res.result}async insert(thing,data){await this.ready;let res=await this.rpc("insert",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return res.result}async update(thing,data){await this.ready;let res=await this.rpc("update",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return res.result}async upsert(thing,data){await this.ready;let res=await this.rpc("upsert",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return res.result}async merge(thing,data){await this.ready;let res=await this.rpc("merge",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return res.result}async patch(thing,data,diff){await this.ready;let res=await this.rpc("patch",[thing,data,diff]);if(res.error)throw new ResponseError(res.error.message);return res.result}async delete(thing){await this.ready;let res=await this.rpc("delete",[thing]);if(res.error)throw new ResponseError(res.error.message);return res.result}async version(){await this.ready;let res=await this.rpc("version");if(res.error)throw new ResponseError(res.error.message);return res.result}async run(name,arg2,arg3){await this.ready;let[version,args]=Array.isArray(arg2)?[void 0,arg2]:[arg2,arg3],res=await this.rpc("run",[name,version,args]);if(res.error)throw new ResponseError(res.error.message);return res.result}async relate(from,thing,to,data){await this.ready;let res=await this.rpc("relate",[from,thing,to,data]);if(res.error)throw new ResponseError(res.error.message);return res.result}rpc(method,params){if(!this.connection)throw new NoActiveSocket;return this.connection.rpc({method,params})}};export{AbstractEngine,CborBreak,CborError,CborFillMissing,CborInvalidMajorError,CborNumberError,CborPartialDisabled,CborRangeError,ConnectionStatus,ConnectionUnavailable,Decimal,Duration,Emitter,EngineDisconnected,Gap,Geometry,GeometryCollection,GeometryLine,GeometryMultiLine,GeometryMultiPoint,GeometryMultiPolygon,GeometryPoint,GeometryPolygon,HttpConnectionError,InvalidURLProvided,MissingNamespaceDatabase,NoActiveSocket,NoConnectionDetails,NoDatabaseSpecified,NoNamespaceSpecified,NoTokenReturned,PreparedQuery,RecordId,ResponseError,StringRecordId,Surreal,SurrealDbError,Table,UnexpectedConnectionError,UnexpectedResponse,UnexpectedServerResponse,UnsupportedEngine,UnsupportedVersion,Uuid,VersionRetrievalFailure,cbor_exports as cbor,convertAuth,decodeCbor,Surreal as default,defaultVersionCheckTimeout,encodeCbor,escape_ident,getIncrementalID,isLiveResult,isVersionSupported,jsonify,liveActions,retrieveRemoteVersion,supportedSurrealDbVersionMin,supportedSurrealDbVersionRange,supportedSurrealDbVersionUntil,surrealql as surql,surrealql,versionCheck}; +var __defProp=Object.defineProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})};var Emitter=class{collectable={};listeners={};interceptors;constructor({interceptors}={}){this.interceptors=interceptors??{}}subscribe(event,listener,historic=!1){if(this.listeners[event]||(this.listeners[event]=[]),!this.isSubscribed(event,listener)&&(this.listeners[event]?.push(listener),historic&&this.collectable[event])){let buffer=this.collectable[event];this.collectable[event]=[];for(let args of buffer)listener(...args)}}subscribeOnce(event,historic=!1){return new Promise(resolve=>{let resolved=!1,listener=(...args)=>{resolved||(resolved=!0,this.unSubscribe(event,listener),resolve(args))};this.subscribe(event,listener,historic)})}unSubscribe(event,listener){if(this.listeners[event]){let index=this.listeners[event]?.findIndex(v=>v===listener);index&&this.listeners[event]?.splice(index,1)}}isSubscribed(event,listener){return!!this.listeners[event]?.includes(listener)}async emit(event,args,collectable=!1){let interceptor=this.interceptors[event],computedArgs=interceptor?await interceptor(...args):args;this.listeners[event]?.length===0&&collectable&&(this.collectable[event]||(this.collectable[event]=[]),this.collectable[event]?.push(args));for(let listener of this.listeners[event]??[])listener(...computedArgs)}reset({collectable,listeners}){if(Array.isArray(collectable))for(let k of collectable)delete this.collectable[k];else typeof collectable=="string"?delete this.collectable[collectable]:collectable!==!1&&(this.collectable={});if(Array.isArray(listeners))for(let k of listeners)delete this.listeners[k];else typeof listeners=="string"?delete this.listeners[listeners]:listeners!==!1&&(this.listeners={})}scanListeners(filter){let listeners=Object.keys(this.listeners);return filter&&(listeners=listeners.filter(filter)),listeners}};var cbor_exports={};__export(cbor_exports,{CborBreak:()=>CborBreak,CborError:()=>CborError,CborFillMissing:()=>CborFillMissing,CborInvalidMajorError:()=>CborInvalidMajorError,CborNumberError:()=>CborNumberError,CborPartialDisabled:()=>CborPartialDisabled,CborRangeError:()=>CborRangeError,Encoded:()=>Encoded,Gap:()=>Gap,POW_2_53:()=>POW_2_53,POW_2_64:()=>POW_2_64,PartiallyEncoded:()=>PartiallyEncoded,Reader:()=>Reader,Tagged:()=>Tagged,Writer:()=>Writer,decode:()=>decode,encode:()=>encode,infiniteBytes:()=>infiniteBytes,partiallyEncodeObject:()=>partiallyEncodeObject});var POW_2_53=9007199254740992,POW_2_64=BigInt(18446744073709552e3);var Encoded=class{constructor(encoded){this.encoded=encoded}};var SurrealDbError=class extends Error{},NoActiveSocket=class extends SurrealDbError{name="NoActiveSocket";message="No socket is currently connected to a SurrealDB instance. Please call the .connect() method first!"},NoConnectionDetails=class extends SurrealDbError{name="NoConnectionDetails";message="No connection details for the HTTP api have been provided. Please call the .connect() method first!"},UnexpectedResponse=class extends SurrealDbError{name="UnexpectedResponse";message="The returned response from the SurrealDB instance is in an unexpected format. Unable to process response!"},InvalidURLProvided=class extends SurrealDbError{name="InvalidURLProvided";message="The provided string is either not a URL or is a URL but with an invalid protocol!"},EngineDisconnected=class extends SurrealDbError{name="EngineDisconnected";message="The engine reported the connection to SurrealDB has dropped"},UnexpectedServerResponse=class extends SurrealDbError{constructor(response){super();this.response=response;this.message=`${response}`}name="UnexpectedServerResponse"},UnexpectedConnectionError=class extends SurrealDbError{constructor(error){super();this.error=error;this.message=`${error}`}name="UnexpectedConnectionError"},UnsupportedEngine=class extends SurrealDbError{constructor(engine){super();this.engine=engine}name="UnsupportedEngine";message="The engine you are trying to connect to is not supported or configured."},ConnectionUnavailable=class extends SurrealDbError{name="ConnectionUnavailable";message="There is no connection available at this moment."},MissingNamespaceDatabase=class extends SurrealDbError{name="MissingNamespaceDatabase";message="There is no namespace and/or database selected."},HttpConnectionError=class extends SurrealDbError{constructor(message,status,statusText,buffer){super();this.message=message;this.status=status;this.statusText=statusText;this.buffer=buffer}name="HttpConnectionError"},ResponseError=class extends SurrealDbError{constructor(message){super();this.message=message}name="ResponseError"},NoNamespaceSpecified=class extends SurrealDbError{name="NoNamespaceSpecified";message="Please specify a namespace to use."},NoDatabaseSpecified=class extends SurrealDbError{name="NoDatabaseSpecified";message="Please specify a database to use."},NoTokenReturned=class extends SurrealDbError{name="NoTokenReturned";message="Did not receive an authentication token."},UnsupportedVersion=class extends SurrealDbError{name="UnsupportedVersion";version;supportedRange;constructor(version,supportedRange){super(),this.version=version,this.supportedRange=supportedRange,this.message=`The version "${version}" reported by the engine is not supported by this library, expected a version that satisfies "${supportedRange}".`}},VersionRetrievalFailure=class extends SurrealDbError{constructor(error){super();this.error=error}name="VersionRetrievalFailure";message="Failed to retrieve remote version. If the server is behind a proxy, make sure it's configured correctly."};var CborError=class extends SurrealDbError{message;constructor(message){super(),this.message=message}},CborNumberError=class extends CborError{name="CborNumberError"},CborRangeError=class extends CborError{name="CborRangeError"},CborInvalidMajorError=class extends CborError{name="CborInvalidMajorError"},CborBreak=class extends CborError{name="CborBreak";constructor(){super("Came across a break which was not intercepted by the decoder")}},CborPartialDisabled=class extends CborError{name="CborPartialDisabled";constructor(){super("Tried to insert a Gap into a CBOR value, while partial mode is not enabled")}},CborFillMissing=class extends CborError{name="CborFillMissing";constructor(){super("Fill for a gap is missing, and gap has no default")}};var Gap=class{args=[];constructor(...args){this.args=args}fill(value){return[this,value]}hasDefault(){return this.args.length===1}get default(){return this.args[0]}};var Writer=class{constructor(byteLength=256){this.byteLength=byteLength;this._buf=new ArrayBuffer(this.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf)}_chunks=[];_pos=0;_buf;_view;_byte;chunk(gap){this._chunks.push([this._buf.slice(0,this._pos),gap]),this._buf=new ArrayBuffer(this.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._pos=0}get chunks(){return this._chunks}get buffer(){return this._buf.slice(0,this._pos)}claim(length){let pos=this._pos;if(this._pos+=length,this._pos<=this._buf.byteLength)return pos;let newLen=this._buf.byteLength<<1;for(;newLenthis._buf.byteLength){let oldb=this._byte;this._buf=new ArrayBuffer(newLen),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._byte.set(oldb)}return pos}writeUint8(value){let pos=this.claim(1);this._view.setUint8(pos,value)}writeUint16(value){let pos=this.claim(2);this._view.setUint16(pos,value)}writeUint32(value){let pos=this.claim(4);this._view.setUint32(pos,value)}writeUint64(value){let pos=this.claim(8);this._view.setBigUint64(pos,value)}writeUint8Array(data){if(data.byteLength===0)return;let pos=this.claim(data.byteLength);this._byte.set(data,pos)}writeArrayBuffer(data){data.byteLength!==0&&this.writeUint8Array(new Uint8Array(data))}writePartiallyEncoded(data){for(let[buf,gap]of data.chunks)this.writeArrayBuffer(buf),this.chunk(gap);this.writeArrayBuffer(data.end)}writeFloat32(value){let pos=this.claim(4);this._view.setFloat32(pos,value)}writeFloat64(value){let pos=this.claim(8);this._view.setFloat64(pos,value)}writeMajor(type,length){let base=type<<5;length<24?this.writeUint8(base+Number(length)):length<256?(this.writeUint8(base+24),this.writeUint8(Number(length))):length<65536?(this.writeUint8(base+25),this.writeUint16(Number(length))):length<4294967296?(this.writeUint8(base+26),this.writeUint32(Number(length))):(this.writeUint8(base+27),this.writeUint64(BigInt(length)))}output(partial,replacer2){return partial?new PartiallyEncoded(this._chunks,this.buffer,replacer2):this.buffer}};var PartiallyEncoded=class{constructor(chunks,end,replacer2){this.chunks=chunks;this.end=end;this.replacer=replacer2}build(fills,partial){let writer=new Writer,map=new Map(fills);for(let[buffer,gap]of this.chunks){let hasValue=map.has(gap)||gap.hasDefault();if(!partial&&!hasValue)throw new CborFillMissing;if(writer.writeArrayBuffer(buffer),hasValue){let data=map.get(gap)??gap.default;encode(data,{writer,replacer:this.replacer})}else writer.chunk(gap)}return writer.writeArrayBuffer(this.end),writer.output(!!partial,this.replacer)}};function partiallyEncodeObject(object,options){return Object.fromEntries(Object.entries(object).map(([k,v])=>[k,encode(v,{...options,partial:!0})]))}var Tagged=class{constructor(tag,value){this.tag=tag;this.value=value}};var textEncoder;function encode(input,options={}){let w=options.writer??new Writer,fillsMap=new Map(options.fills??[]);function inner(input2){let value=options.replacer?options.replacer(input2):input2;if(value===void 0)return w.writeUint8(247);if(value===null)return w.writeUint8(246);if(value===!0)return w.writeUint8(245);if(value===!1)return w.writeUint8(244);switch(typeof value){case"number":{if(Number.isInteger(value))if(value>=0&&value<=9007199254740992)w.writeMajor(0,value);else if(value<0&&value>=-9007199254740992)w.writeMajor(1,-(value+1));else throw new CborNumberError("Number too big to be encoded");else w.writeUint8(251),w.writeFloat64(value);return}case"bigint":{if(value>=0&&value=-POW_2_64)w.writeMajor(1,-(value+1n));else throw new CborNumberError("BigInt too big to be encoded");return}case"string":{textEncoder??=new TextEncoder;let encoded=textEncoder.encode(value);w.writeMajor(3,encoded.byteLength),w.writeUint8Array(encoded);return}default:{if(Array.isArray(value)){w.writeMajor(4,value.length);for(let v of value)inner(v);return}if(value instanceof Tagged){w.writeMajor(6,value.tag),inner(value.value);return}if(value instanceof Encoded){w.writeArrayBuffer(value.encoded);return}if(value instanceof Gap){if(fillsMap.has(value))inner(fillsMap.get(value));else{if(!options.partial)throw new CborPartialDisabled;w.chunk(value)}return}if(value instanceof PartiallyEncoded){let res=value.build(options.fills??[],options.partial);options.partial?w.writePartiallyEncoded(res):w.writeArrayBuffer(res);return}if(value instanceof Uint8Array||value instanceof Uint16Array||value instanceof Uint32Array||value instanceof Int8Array||value instanceof Int16Array||value instanceof Int32Array||value instanceof Float32Array||value instanceof Float64Array||value instanceof ArrayBuffer){let v=new Uint8Array(value);w.writeMajor(2,v.byteLength),w.writeUint8Array(v);return}let entries=value instanceof Map?Array.from(value.entries()):Object.entries(value);w.writeMajor(5,entries.length);for(let v of entries.flat())inner(v)}}}return inner(input),w.output(!!options.partial,options.replacer)}var Reader=class{_buf;_view;_byte;_pos=0;constructor(buffer){this._buf=new ArrayBuffer(buffer.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._byte.set(new Uint8Array(buffer))}read(amount,res){return this._pos+=amount,res}readUint8(){try{return this.read(1,this._view.getUint8(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint16(){try{return this.read(2,this._view.getUint16(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint32(){try{return this.read(4,this._view.getUint32(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint64(){try{return this.read(8,this._view.getBigUint64(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readFloat16(){let bytes=this.readUint16(),s2=(bytes&32768)>>15,e=(bytes&31744)>>10,f2=bytes&1023;return e===0?(s2?-1:1)*2**-14*(f2/2**10):e===31?f2?Number.NaN:(s2?-1:1)*Number.POSITIVE_INFINITY:(s2?-1:1)*2**(e-15)*(1+f2/2**10)}readFloat32(){try{return this.read(4,this._view.getFloat32(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readFloat64(){try{return this.read(8,this._view.getFloat64(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readBytes(amount){let available=this._byte.length-this._pos;if(available>5;if(major<0||major>7)throw new CborInvalidMajorError("Received invalid major type");return[major,byte&31]}readMajorLength(length){if(length<=23)return length;switch(length){case 24:return this.readUint8();case 25:return this.readUint16();case 26:return this.readUint32();case 27:{let read=this.readUint64();return read>9007199254740992?read:Number(read)}}throw new CborRangeError("Expected a final length")}};function infiniteBytes(r2,forMajor){let w=new Writer;for(;;){let[major,len]=r2.readMajor();if(major===7&&len===31)break;if(major!==forMajor)throw new CborInvalidMajorError(`Expected a resource of the same major (${forMajor}) while processing an infinite resource`);if(len===31)throw new CborRangeError("Expected a finite resource while processing an infinite resource");w.writeUint8Array(r2.readBytes(Number(r2.readMajorLength(len))))}return w.buffer}var textDecoder;function decode(input,options={}){let r2=input instanceof Reader?input:new Reader(input);function inner(){let[major,len]=r2.readMajor();switch(major){case 0:return r2.readMajorLength(len);case 1:{let l=r2.readMajorLength(len);return typeof l=="bigint"?-(l+1n):-(l+1)}case 2:return len===31?infiniteBytes(r2,2):r2.readBytes(Number(r2.readMajorLength(len))).buffer;case 3:{let encoded=len===31?infiniteBytes(r2,3):r2.readBytes(Number(r2.readMajorLength(len)));return textDecoder??=new TextDecoder,textDecoder.decode(encoded)}case 4:{if(len===31){let arr2=[];for(;;)try{arr2.push(decode2())}catch(e){if(e instanceof CborBreak)break;throw e}return arr2}let l=r2.readMajorLength(len),arr=Array(l);for(let i=0;i(map.set(size,unit),map),new Map),durationPartRegex=new RegExp(`^(\\d+)(${Array.from(units.keys()).join("|")})`),Duration=class _Duration{_milliseconds;constructor(input){input instanceof _Duration?this._milliseconds=input._milliseconds:typeof input=="string"?this._milliseconds=_Duration.parseString(input):this._milliseconds=input}static fromCompact([s2,ns]){s2=s2??0,ns=ns??0;let ms=s2*1e3+ns/1e6;return new _Duration(ms)}toCompact(){let s2=Math.floor(this._milliseconds/1e3),ns=Math.floor((this._milliseconds-s2*1e3)*1e6);return ns>0?[s2,ns]:s2>0?[s2]:[]}toString(){let left=this._milliseconds,result="";function scrap(size){let num=Math.floor(left/size);return num>0&&(left=left%size),num}for(let[size,unit]of Array.from(unitsReverse).reverse()){let scrapped=scrap(size);scrapped>0&&(result+=`${scrapped}${unit}`)}return result}toJSON(){return this.toString()}static parseString(input){let ms=0,left=input;for(;left!=="";){let match=left.match(durationPartRegex);if(match){let amount=Number.parseInt(match[1]),factor=units.get(match[2]);if(factor===void 0)throw new SurrealDbError(`Invalid duration unit: ${match[2]}`);ms+=amount*factor,left=left.slice(match[0].length);continue}throw new SurrealDbError("Could not match a next duration part")}return ms}static nanoseconds(nanoseconds){return new _Duration(Math.floor(nanoseconds*nanosecond))}static microseconds(microseconds){return new _Duration(Math.floor(microseconds*microsecond))}static milliseconds(milliseconds){return new _Duration(milliseconds)}static seconds(seconds){return new _Duration(seconds*second)}static minutes(minutes){return new _Duration(minutes*minute)}static hours(hours){return new _Duration(hours*hour)}static days(days){return new _Duration(days*day)}static weeks(weeks){return new _Duration(weeks*week)}get microseconds(){return Math.floor(this._milliseconds/microsecond)}get nanoseconds(){return Math.floor(this._milliseconds/nanosecond)}get milliseconds(){return Math.floor(this._milliseconds)}get seconds(){return Math.floor(this._milliseconds/second)}get minutes(){return Math.floor(this._milliseconds/minute)}get hours(){return Math.floor(this._milliseconds/hour)}get days(){return Math.floor(this._milliseconds/day)}get weeks(){return Math.floor(this._milliseconds/week)}};var Future=class{constructor(inner){this.inner=inner}toJSON(){return this.toString()}toString(){return` { ${this.inner} }`}};var Geometry=class{};function f(num){return num instanceof Decimal?Number.parseFloat(num.decimal):num}var GeometryPoint=class _GeometryPoint extends Geometry{point;constructor(point){super(),point instanceof _GeometryPoint?this.point=point.clone().point:this.point=[f(point[0]),f(point[1])]}toJSON(){return{type:"Point",coordinates:this.coordinates}}get coordinates(){return this.point}is(geometry){return geometry instanceof _GeometryPoint?this.point[0]===geometry.point[0]&&this.point[1]===geometry.point[1]:!1}clone(){return new _GeometryPoint([...this.point])}},GeometryLine=class _GeometryLine extends Geometry{line;constructor(line){super(),this.line=line instanceof _GeometryLine?line.clone().line:line}toJSON(){return{type:"LineString",coordinates:this.coordinates}}get coordinates(){return this.line.map(g=>g.coordinates)}close(){this.line[0].is(this.line.at(-1))||this.line.push(this.line[0])}is(geometry){if(!(geometry instanceof _GeometryLine)||this.line.length!==geometry.line.length)return!1;for(let i=0;ip.clone()))}},GeometryPolygon=class _GeometryPolygon extends Geometry{polygon;constructor(polygon){super(),this.polygon=polygon instanceof _GeometryPolygon?polygon.clone().polygon:polygon.map(l=>{let line=l.clone();return line.close(),line})}toJSON(){return{type:"Polygon",coordinates:this.coordinates}}get coordinates(){return this.polygon.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryPolygon)||this.polygon.length!==geometry.polygon.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiPoint=class _GeometryMultiPoint extends Geometry{points;constructor(points){super(),this.points=points instanceof _GeometryMultiPoint?points.points:points}toJSON(){return{type:"MultiPoint",coordinates:this.coordinates}}get coordinates(){return this.points.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiPoint)||this.points.length!==geometry.points.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiLine=class _GeometryMultiLine extends Geometry{lines;constructor(lines){super(),this.lines=lines instanceof _GeometryMultiLine?lines.lines:lines}toJSON(){return{type:"MultiLineString",coordinates:this.coordinates}}get coordinates(){return this.lines.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiLine)||this.lines.length!==geometry.lines.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiPolygon=class _GeometryMultiPolygon extends Geometry{polygons;constructor(polygons){super(),this.polygons=polygons instanceof _GeometryMultiPolygon?polygons.polygons:polygons}toJSON(){return{type:"MultiPolygon",coordinates:this.coordinates}}get coordinates(){return this.polygons.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiPolygon)||this.polygons.length!==geometry.polygons.length)return!1;for(let i=0;ip.clone()))}},GeometryCollection=class _GeometryCollection extends Geometry{collection;constructor(collection){super(),this.collection=collection instanceof _GeometryCollection?collection.collection:collection}toJSON(){return{type:"GeometryCollection",geometries:this.geometries}}get geometries(){return this.collection.map(g=>g.toJSON())}is(geometry){if(!(geometry instanceof _GeometryCollection)||this.collection.length!==geometry.collection.length)return!1;for(let i=0;ip.clone()))}};var MAX_i64=9223372036854775807n,RecordId=class{tb;id;constructor(tb,id2){if(typeof tb!="string")throw new SurrealDbError("TB part is not valid");if(!isValidIdPart(id2))throw new SurrealDbError("ID part is not valid");this.tb=tb,this.id=id2}toJSON(){return this.toString()}toString(){let tb=escape_ident(this.tb),id2=escape_id_part(this.id);return`${tb}:${id2}`}},StringRecordId=class{rid;constructor(rid){if(typeof rid!="string")throw new SurrealDbError("String Record ID must be a string");this.rid=rid}toJSON(){return this.rid}toString(){return this.rid}};function escape_number(num){return num<=MAX_i64?num.toString():`\u27E8${num}\u27E9`}function escape_ident(str){if(isOnlyNumbers(str))return`\u27E8${str}\u27E9`;let code,i,len;for(i=0,len=str.length;i47&&code<58)&&!(code>64&&code<91)&&!(code>96&&code<123)&&code!==95)return`\u27E8${str.replaceAll("\u27E9","\u27E9")}\u27E9`;return str}function isOnlyNumbers(str){let parsed=Number.parseInt(str);return!Number.isNaN(parsed)&&parsed.toString()===str}function isValidIdPart(v){if(v instanceof Uuid)return!0;switch(typeof v){case"string":case"number":case"bigint":return!0;case"object":return Array.isArray(v)||v!==null;default:return!1}}function escape_id_part(id2){return id2 instanceof Uuid?`d"${id2}"`:typeof id2=="string"?escape_ident(id2):typeof id2=="bigint"||typeof id2=="number"?escape_number(id2):JSON.stringify(id2)}var DIGITS="0123456789abcdef",UUID=class _UUID{constructor(bytes){this.bytes=bytes}static ofInner(bytes){if(bytes.length!==16)throw new TypeError("not 128-bit length");return new _UUID(bytes)}static fromFieldsV7(unixTsMs,randA,randBHi,randBLo){if(!Number.isInteger(unixTsMs)||!Number.isInteger(randA)||!Number.isInteger(randBHi)||!Number.isInteger(randBLo)||unixTsMs<0||randA<0||randBHi<0||randBLo<0||unixTsMs>0xffffffffffff||randA>4095||randBHi>1073741823||randBLo>4294967295)throw new RangeError("invalid field value");let bytes=new Uint8Array(16);return bytes[0]=unixTsMs/2**40,bytes[1]=unixTsMs/2**32,bytes[2]=unixTsMs/2**24,bytes[3]=unixTsMs/2**16,bytes[4]=unixTsMs/2**8,bytes[5]=unixTsMs,bytes[6]=112|randA>>>8,bytes[7]=randA,bytes[8]=128|randBHi>>>24,bytes[9]=randBHi>>>16,bytes[10]=randBHi>>>8,bytes[11]=randBHi,bytes[12]=randBLo>>>24,bytes[13]=randBLo>>>16,bytes[14]=randBLo>>>8,bytes[15]=randBLo,new _UUID(bytes)}static parse(uuid){var _a,_b,_c,_d;let hex;switch(uuid.length){case 32:hex=(_a=/^[0-9a-f]{32}$/i.exec(uuid))===null||_a===void 0?void 0:_a[0];break;case 36:hex=(_b=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid))===null||_b===void 0?void 0:_b.slice(1,6).join("");break;case 38:hex=(_c=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid))===null||_c===void 0?void 0:_c.slice(1,6).join("");break;case 45:hex=(_d=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid))===null||_d===void 0?void 0:_d.slice(1,6).join("");break;default:break}if(hex){let inner=new Uint8Array(16);for(let i=0;i<16;i+=4){let n=parseInt(hex.substring(2*i,2*i+8),16);inner[i+0]=n>>>24,inner[i+1]=n>>>16,inner[i+2]=n>>>8,inner[i+3]=n}return new _UUID(inner)}else throw new SyntaxError("could not parse UUID string")}toString(){let text="";for(let i=0;i>>4),text+=DIGITS.charAt(this.bytes[i]&15),(i===3||i===5||i===7||i===9)&&(text+="-");return text}toHex(){let text="";for(let i=0;i>>4),text+=DIGITS.charAt(this.bytes[i]&15);return text}toJSON(){return this.toString()}getVariant(){let n=this.bytes[8]>>>4;if(n<0)throw new Error("unreachable");if(n<=7)return this.bytes.every(e=>e===0)?"NIL":"VAR_0";if(n<=11)return"VAR_10";if(n<=13)return"VAR_110";if(n<=15)return this.bytes.every(e=>e===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new _UUID(this.bytes.slice(0))}equals(other){return this.compareTo(other)===0}compareTo(other){for(let i=0;i<16;i++){let diff=this.bytes[i]-other.bytes[i];if(diff!==0)return Math.sign(diff)}return 0}},V7Generator=class{constructor(randomNumberGenerator){this.timestamp=0,this.counter=0,this.random=randomNumberGenerator??getDefaultRandom()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(unixTsMs,rollbackAllowance){let value=this.generateOrAbortCore(unixTsMs,rollbackAllowance);return value===void 0&&(this.timestamp=0,value=this.generateOrAbortCore(unixTsMs,rollbackAllowance)),value}generateOrAbortCore(unixTsMs,rollbackAllowance){if(!Number.isInteger(unixTsMs)||unixTsMs<1||unixTsMs>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(rollbackAllowance<0||rollbackAllowance>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(unixTsMs>this.timestamp)this.timestamp=unixTsMs,this.resetCounter();else if(unixTsMs+rollbackAllowance>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return UUID.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let bytes=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return bytes[6]=64|bytes[6]>>>4,bytes[8]=128|bytes[8]>>>2,UUID.ofInner(bytes)}},getDefaultRandom=()=>{if(typeof crypto<"u"&&typeof crypto.getRandomValues<"u")return new BufferedCryptoRandom;if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");return{nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}},BufferedCryptoRandom=class{constructor(){this.buffer=new Uint32Array(8),this.cursor=65535}nextUint32(){return this.cursor>=this.buffer.length&&(crypto.getRandomValues(this.buffer),this.cursor=0),this.buffer[this.cursor++]}},defaultGenerator;var uuidv7obj=()=>(defaultGenerator||(defaultGenerator=new V7Generator)).generate();var uuidv4obj=()=>(defaultGenerator||(defaultGenerator=new V7Generator)).generateV4();var Uuid=class _Uuid{inner;constructor(uuid){uuid instanceof ArrayBuffer?this.inner=UUID.ofInner(new Uint8Array(uuid)):uuid instanceof Uint8Array?this.inner=UUID.ofInner(uuid):uuid instanceof _Uuid?this.inner=uuid.inner:uuid instanceof UUID?this.inner=uuid:this.inner=UUID.parse(uuid)}toString(){return this.inner.toString()}toJSON(){return this.inner.toString()}toUint8Array(){return this.inner.bytes}toBuffer(){return this.inner.bytes.buffer}static v4(){return new _Uuid(uuidv4obj())}static v7(){return new _Uuid(uuidv7obj())}};var Table=class{tb;constructor(tb){if(typeof tb!="string")throw new SurrealDbError("Table must be a string");this.tb=tb}toJSON(){return this.tb}toString(){return this.tb}};function toSurrealqlString(input){if(typeof input=="object"){if(input===null)return"NULL";if(input===void 0)return"NONE";if(input instanceof Date)return`d${JSON.stringify(input.toISOString())}`;if(input instanceof Uuid)return`u${JSON.stringify(input.toString())}`;if(input instanceof RecordId||input instanceof StringRecordId)return`r${JSON.stringify(input.toString())}`;if(typeof input=="string")return`s${JSON.stringify(input)}`;if(input instanceof Geometry)return toSurrealqlString(input.toJSON());if(input instanceof Decimal||input instanceof Duration||input instanceof Future||input instanceof Range||input instanceof Table)return input.toJSON();switch(Object.getPrototypeOf(input)){case Object.prototype:{let output2="{ ";for(let[k,v]of Object.entries(input))output2+=`${JSON.stringify(k)}: ${toSurrealqlString(v)},`;return output2+=" }",output2}case Map.prototype:{let output2="{ ";for(let[k,v]of input.entries())output2+=`${JSON.stringify(k)}: ${toSurrealqlString(v)},`;return output2+=" }",output2}case Array.prototype:{let output2="[ ";for(let v of input)output2+=`${toSurrealqlString(v)},`;return output2+=" ]",output2}case Set.prototype:return`[ ${[...new Set([...input].map(toSurrealqlString))].join(", ")} ]`}}return`${input}`}var Range=class{constructor(beg,end){this.beg=beg;this.end=end}toJSON(){return this.toString()}toString(){let beg=escape_range_bound(this.beg),end=escape_range_bound(this.end);return`${beg}${getRangeJoin(this.beg,this.end)}${end}`}},BoundIncluded=class{constructor(value){this.value=value}},BoundExcluded=class{constructor(value){this.value=value}},RecordIdRange=class{constructor(tb,beg,end){this.tb=tb;this.beg=beg;this.end=end;if(typeof tb!="string")throw new SurrealDbError("TB part is not valid");if(!isValidIdBound(beg))throw new SurrealDbError("Beg part is not valid");if(!isValidIdBound(end))throw new SurrealDbError("End part is not valid")}toJSON(){return this.toString()}toString(){let tb=escape_ident(this.tb),beg=escape_id_bound(this.beg),end=escape_id_bound(this.end);return`${tb}:${beg}${getRangeJoin(this.beg,this.end)}${end}`}};function getRangeJoin(beg,end){let output2="";return beg instanceof BoundExcluded&&(output2+=">"),output2+="..",end instanceof BoundIncluded&&(output2+="="),output2}function isValidIdBound(bound){return bound instanceof BoundIncluded||bound instanceof BoundExcluded?isValidIdPart(bound.value):!0}function escape_id_bound(bound){return bound instanceof BoundIncluded||bound instanceof BoundExcluded?escape_id_part(bound.value):""}function escape_range_bound(bound){if(bound===void 0)return"";let value=bound.value;return bound instanceof Range?`(${toSurrealqlString(value)})`:toSurrealqlString(value)}function rangeToCbor([beg,end]){function encodeBound(bound){return bound instanceof BoundIncluded?new Tagged(TAG_BOUND_INCLUDED,bound.value):bound instanceof BoundExcluded?new Tagged(TAG_BOUND_EXCLUDED,bound.value):null}return[encodeBound(beg),encodeBound(end)]}function cborToRange(range){function decodeBound(bound){if(bound!==null){if(bound.tag===TAG_BOUND_INCLUDED)return new BoundIncluded(bound.value);if(bound.tag===TAG_BOUND_EXCLUDED)return new BoundExcluded(bound.value);throw new SurrealDbError("Invalid bound tag")}}return[decodeBound(range[0]),decodeBound(range[1])]}var TAG_SPEC_DATETIME=0,TAG_SPEC_UUID=37,TAG_NONE=6,TAG_TABLE=7,TAG_RECORDID=8,TAG_STRING_UUID=9,TAG_STRING_DECIMAL=10,TAG_CUSTOM_DATETIME=12,TAG_STRING_DURATION=13,TAG_CUSTOM_DURATION=14,TAG_FUTURE=15,TAG_RANGE2=49,TAG_BOUND_INCLUDED=50,TAG_BOUND_EXCLUDED=51,TAG_GEOMETRY_POINT=88,TAG_GEOMETRY_LINE=89,TAG_GEOMETRY_POLYGON=90,TAG_GEOMETRY_MULTIPOINT=91,TAG_GEOMETRY_MULTILINE=92,TAG_GEOMETRY_MULTIPOLYGON=93,TAG_GEOMETRY_COLLECTION=94,replacer={encode(v){return v instanceof Date?new Tagged(TAG_CUSTOM_DATETIME,dateToCborCustomDate(v)):v===void 0?new Tagged(TAG_NONE,null):v instanceof Uuid?new Tagged(TAG_SPEC_UUID,v.toBuffer()):v instanceof Decimal?new Tagged(TAG_STRING_DECIMAL,v.toString()):v instanceof Duration?new Tagged(TAG_CUSTOM_DURATION,v.toCompact()):v instanceof RecordId?new Tagged(TAG_RECORDID,[v.tb,v.id]):v instanceof StringRecordId?new Tagged(TAG_RECORDID,v.rid):v instanceof RecordIdRange?new Tagged(TAG_RECORDID,[v.tb,new Tagged(TAG_RANGE2,rangeToCbor([v.beg,v.end]))]):v instanceof Table?new Tagged(TAG_TABLE,v.tb):v instanceof Future?new Tagged(TAG_FUTURE,v.inner):v instanceof Range?new Tagged(TAG_RANGE2,rangeToCbor([v.beg,v.end])):v instanceof GeometryPoint?new Tagged(TAG_GEOMETRY_POINT,v.point):v instanceof GeometryLine?new Tagged(TAG_GEOMETRY_LINE,v.line):v instanceof GeometryPolygon?new Tagged(TAG_GEOMETRY_POLYGON,v.polygon):v instanceof GeometryMultiPoint?new Tagged(TAG_GEOMETRY_MULTIPOINT,v.points):v instanceof GeometryMultiLine?new Tagged(TAG_GEOMETRY_MULTILINE,v.lines):v instanceof GeometryMultiPolygon?new Tagged(TAG_GEOMETRY_MULTIPOLYGON,v.polygons):v instanceof GeometryCollection?new Tagged(TAG_GEOMETRY_COLLECTION,v.collection):v},decode(v){if(!(v instanceof Tagged))return v;switch(v.tag){case TAG_SPEC_DATETIME:return new Date(v.value);case TAG_SPEC_UUID:case TAG_STRING_UUID:return new Uuid(v.value);case TAG_CUSTOM_DATETIME:return cborCustomDateToDate(v.value);case TAG_NONE:return;case TAG_STRING_DECIMAL:return new Decimal(v.value);case TAG_STRING_DURATION:return new Duration(v.value);case TAG_CUSTOM_DURATION:return Duration.fromCompact(v.value);case TAG_TABLE:return new Table(v.value);case TAG_FUTURE:return new Future(v.value);case TAG_RANGE2:return new Range(...cborToRange(v.value));case TAG_RECORDID:return v.value[1]instanceof Range?new RecordIdRange(v.value[0],v.value[1].beg,v.value[1].end):new RecordId(v.value[0],v.value[1]);case TAG_GEOMETRY_POINT:return new GeometryPoint(v.value);case TAG_GEOMETRY_LINE:return new GeometryLine(v.value);case TAG_GEOMETRY_POLYGON:return new GeometryPolygon(v.value);case TAG_GEOMETRY_MULTIPOINT:return new GeometryMultiPoint(v.value);case TAG_GEOMETRY_MULTILINE:return new GeometryMultiLine(v.value);case TAG_GEOMETRY_MULTIPOLYGON:return new GeometryMultiPolygon(v.value);case TAG_GEOMETRY_COLLECTION:return new GeometryCollection(v.value)}}};Object.freeze(replacer);function encodeCbor(data){return encode(data,{replacer:replacer.encode})}function decodeCbor(data){return decode(data,{replacer:replacer.decode})}var textEncoder2,PreparedQuery=class{_query;_bindings;length;constructor(query,bindings){textEncoder2??=new TextEncoder,this._query=textEncoder2.encode(query),this._bindings=partiallyEncodeObject(bindings??{},{replacer:replacer.encode}),this.length=Object.keys(this._bindings).length}get query(){let w=new Writer(this._query.byteLength+9);return w.writeMajor(3,this._query.byteLength),w.writeUint8Array(this._query),new Encoded(w.output(!1))}get bindings(){return this._bindings}build(fills){return encode([this.query,this.bindings],{fills})}append(query_raw,...values){let base=this.length;this.length+=values.length;let mapped_bindings=values.map((v,i)=>[`bind___${base+i}`,v]);for(let[k,v]of mapped_bindings)this._bindings[k]=encode(v,{replacer:replacer.encode,partial:!0});let query=query_raw.flatMap((segment,i)=>{let variable=mapped_bindings[i]?.[0];return[segment,...variable?[`$${variable}`]:[]]}).join("");textEncoder2??=new TextEncoder;let current=new Uint8Array(this._query),added=textEncoder2.encode(query);return this._query=new Uint8Array(current.byteLength+added.byteLength),this._query.set(current),this._query.set(added,current.byteLength),this}};function surrealql(query_raw,...values){let mapped_bindings=values.map((v,i)=>[`bind___${i}`,v]),bindings=mapped_bindings.reduce((prev,[k,v])=>(prev[k]=v,prev),{}),query=query_raw.flatMap((segment,i)=>{let variable=mapped_bindings[i]?.[0];return[segment,...variable?[`$${variable}`]:[]]}).join("");return new PreparedQuery(query,bindings)}function convertAuth(params){let result={},convertString=(a,b,optional)=>{if(a in params)result[b]=`${params[a]}`,delete result[a];else if(optional!==!0)throw new SurrealDbError(`Key ${a} is missing from the authentication parameters`)};return"scope"in params?(result={...params},convertString("scope","sc"),convertString("namespace","ns"),convertString("database","db")):"variables"in params?(result={...params.variables},convertString("access","ac"),convertString("namespace","ns"),convertString("database","db")):(convertString("access","ac",!0),convertString("database","db",!0),convertString("namespace","ns",!("database"in params)),convertString("username","user"),convertString("password","pass")),result}var liveActions=["CREATE","UPDATE","DELETE"];function isLiveResult(v){return!(typeof v!="object"||v===null||!("id"in v&&"action"in v&&"result"in v)||!(v.id instanceof Uuid)||!liveActions.includes(v.action)||typeof v.result!="object"||v.result===null)}function jsonify(input){if(typeof input=="object"){if(input===null)return null;if(input instanceof Date||input instanceof Uuid||input instanceof Decimal||input instanceof Duration||input instanceof Future||input instanceof Range||input instanceof StringRecordId||input instanceof RecordIdRange||input instanceof RecordId||input instanceof Geometry||input instanceof Table)return input.toJSON();switch(Object.getPrototypeOf(input)){case Object.prototype:{let mapped=Object.entries(input).map(([k,v])=>[k,jsonify(v)]).filter(([_,v])=>v!==void 0);return Object.fromEntries(mapped)}case Map.prototype:{let mapped=Array.from(input).map(([k,v])=>[k,jsonify(v)]).filter(([_,v])=>v!==void 0);return new Map(mapped)}case Array.prototype:return input.map(jsonify);case Set.prototype:return new Set([...input].map(jsonify))}}return input}var defaultVersionCheckTimeout=5e3,supportedSurrealDbVersionMin="1.4.2",supportedSurrealDbVersionUntil="3.0.0",supportedSurrealDbVersionRange=`>= ${supportedSurrealDbVersionMin} < ${supportedSurrealDbVersionUntil}`;function versionCheck(version,min=supportedSurrealDbVersionMin,until=supportedSurrealDbVersionUntil){if(!isVersionSupported(version,min,until))throw new UnsupportedVersion(version,`>= ${min} < ${until}`);return!0}function isVersionSupported(version,min=supportedSurrealDbVersionMin,until=supportedSurrealDbVersionUntil){return min.localeCompare(version,void 0,{numeric:!0})<=0&&until.localeCompare(version,void 0,{numeric:!0})===1}async function retrieveRemoteVersion(url,timeout){let protocol={"ws:":"http:","wss:":"https:","http:":"http:","https:":"https:"}[url.protocol];if(protocol){let basepath=url.pathname.slice(0,-4);url=new URL(url),url.pathname=`${basepath}/version`,url.protocol=protocol;let controller=new AbortController,id2=setTimeout(()=>controller.abort(),timeout??defaultVersionCheckTimeout),versionPrefix="surrealdb-";return await fetch(url,{signal:controller.signal}).then(res=>res.text()).then(version2=>version2.slice(versionPrefix.length)).catch(e=>{throw new VersionRetrievalFailure(e)}).finally(()=>{clearTimeout(id2)})}throw new VersionRetrievalFailure}var id=0;function getIncrementalID(){return id=(id+1)%Number.MAX_SAFE_INTEGER,id.toString()}function s(string,...values){return string.reduce((prev,curr,i)=>`${prev}${curr}${values[i]??""}`,"")}function d(string,...values){return new Date(s(string,values))}function r(string,...values){return new StringRecordId(s(string,values))}function u(string,...values){return new Uuid(s(string,values))}var ConnectionStatus=(ConnectionStatus2=>(ConnectionStatus2.Disconnected="disconnected",ConnectionStatus2.Connecting="connecting",ConnectionStatus2.Connected="connected",ConnectionStatus2.Error="error",ConnectionStatus2))(ConnectionStatus||{}),EngineContext=class{emitter;encodeCbor;decodeCbor;constructor({emitter,encodeCbor:encodeCbor2,decodeCbor:decodeCbor2}){this.emitter=emitter,this.encodeCbor=encodeCbor2,this.decodeCbor=decodeCbor2}},AbstractEngine=class{context;ready;status="disconnected";connection={url:void 0,namespace:void 0,database:void 0,token:void 0};constructor(context){this.context=context}get emitter(){return this.context.emitter}get encodeCbor(){return this.context.encodeCbor}get decodeCbor(){return this.context.decodeCbor}};function processAuthVars(vars,fallback){if("scope"in vars||"access"in vars&&"variables"in vars&&vars.variables){if(!vars.namespace){if(!fallback?.namespace)throw new NoNamespaceSpecified;vars.namespace=fallback.namespace}if(!vars.database){if(!fallback?.database)throw new NoDatabaseSpecified;vars.database=fallback.database}}return vars}var ALWAYS_ALLOW=new Set(["signin","signup","authenticate","invalidate","version","use","let","unset","query"]),HttpEngine=class extends AbstractEngine{connection={url:void 0,namespace:void 0,database:void 0,token:void 0,variables:{}};setStatus(status,...args){this.status=status,this.emitter.emit(status,args)}version(url,timeout){return retrieveRemoteVersion(url,timeout)}connect(url){return this.setStatus("connecting"),this.connection.url=url,this.setStatus("connected"),this.ready=new Promise(r2=>r2()),this.ready}disconnect(){return this.connection={url:void 0,namespace:void 0,database:void 0,token:void 0,variables:{}},this.ready=void 0,this.setStatus("disconnected"),new Promise(r2=>r2())}async rpc(request){if(await this.ready,!this.connection.url)throw new ConnectionUnavailable;if((!this.connection.namespace||!this.connection.database)&&!ALWAYS_ALLOW.has(request.method))throw new MissingNamespaceDatabase;if(request.method==="use"){let[ns,db]=request.params;return ns===null&&(this.connection.namespace=void 0),db===null&&(this.connection.database=void 0),ns&&(this.connection.namespace=ns),db&&(this.connection.database=db),{result:!0}}if(request.method==="let"){let[key,value]=request.params;return this.connection.variables[key]=value,{result:!0}}if(request.method==="unset"){let[key]=request.params;return delete this.connection.variables[key],{result:!0}}request.method==="query"&&(request.params=[request.params?.[0],{...this.connection.variables,...request.params?.[1]??{}}]);let id2=getIncrementalID(),headers={"Content-Type":"application/cbor",Accept:"application/cbor"};this.connection.namespace&&(headers["Surreal-NS"]=this.connection.namespace),this.connection.database&&(headers["Surreal-DB"]=this.connection.database),this.connection.token&&(headers.Authorization=`Bearer ${this.connection.token}`);let raw=await fetch(`${this.connection.url}`,{method:"POST",headers,body:this.encodeCbor({id:id2,...request})}),buffer=await raw.arrayBuffer();if(raw.status===200){let response=this.decodeCbor(buffer);if("result"in response)switch(request.method){case"signin":case"signup":{this.connection.token=response.result;break}case"authenticate":{let[token]=request.params;this.connection.token=token;break}case"invalidate":{this.connection.token=void 0;break}}return this.emitter.emit(`rpc-${id2}`,[response]),response}let dec=new TextDecoder("utf-8");throw new HttpConnectionError(dec.decode(buffer),raw.status,raw.statusText,buffer)}get connected(){return!!this.connection.url}};function getNativeWebSocket(){if(typeof WebSocket<"u")return WebSocket;if(typeof global.WebSocket<"u")return global.WebSocket;if(typeof window.WebSocket<"u")return window.WebSocket;if(typeof self.WebSocket<"u")return self.WebSocket;throw new Error("`WebSocket` is not supported in this environment")}var WebSocket2=getNativeWebSocket();var WebsocketEngine=class extends AbstractEngine{pinger;socket;constructor(context){super(context),this.emitter.subscribe("disconnected",()=>this.pinger?.stop())}setStatus(status,...args){this.status=status,this.emitter.emit(status,args)}async requireStatus(status){return this.status!==status&&await this.emitter.subscribeOnce(status),!0}version(url,timeout){return retrieveRemoteVersion(url,timeout)}async connect(url){this.connection.url=url,this.setStatus("connecting");let socket=new WebSocket2(url.toString(),"cbor"),ready=new Promise((resolve,reject)=>{socket.addEventListener("open",()=>{this.setStatus("connected"),resolve()}),socket.addEventListener("error",e=>{let error=new UnexpectedConnectionError("error"in e?e.error:"An unexpected error occurred");this.setStatus("error",error),reject(error)}),socket.addEventListener("close",()=>{this.setStatus("disconnected")}),socket.addEventListener("message",async({data})=>{try{let decoded=this.decodeCbor(data instanceof Blob?await data.arrayBuffer():data.buffer.slice(data.byteOffset,data.byteOffset+data.byteLength));if(typeof decoded=="object"&&decoded!=null&&Object.getPrototypeOf(decoded)===Object.prototype)this.handleRpcResponse(decoded);else throw new UnexpectedServerResponse(decoded)}catch(detail){socket.dispatchEvent(new CustomEvent("error",{detail}))}})});return this.ready=ready,await ready.then(()=>{this.socket=socket,this.pinger?.stop(),this.pinger=new Pinger(3e4),this.pinger.start(()=>this.rpc({method:"ping"}))})}async disconnect(){this.connection={url:void 0,namespace:void 0,database:void 0,token:void 0},await this.ready?.catch(()=>{}),this.socket?.close(),this.ready=void 0,this.socket=void 0,await Promise.any([this.requireStatus("disconnected"),this.requireStatus("error")])}async rpc(request){if(await this.ready,!this.socket)throw new ConnectionUnavailable;let id2=getIncrementalID(),response=this.emitter.subscribeOnce(`rpc-${id2}`);this.socket.send(this.encodeCbor({id:id2,...request}));let[res]=await response;if(res instanceof EngineDisconnected)throw res;if("result"in res)switch(request.method){case"use":{let[ns,db]=request.params;ns===null&&(this.connection.namespace=void 0),db===null&&(this.connection.database=void 0),ns&&(this.connection.namespace=ns),db&&(this.connection.database=db);break}case"signin":case"signup":{this.connection.token=res.result;break}case"authenticate":{let[token]=request.params;this.connection.token=token;break}case"invalidate":{this.connection.token=void 0;break}}return res}handleRpcResponse({id:id2,...res}){if(id2)this.emitter.emit(`rpc-${id2}`,[res]);else if(res.error)this.setStatus("error",new ResponseError(res.error));else if(isLiveResult(res.result)){let{id:id3,action,result}=res.result;this.emitter.emit(`live-${id3}`,[action,result],!0)}else this.setStatus("error",new UnexpectedServerResponse({id:id2,...res}))}get connected(){return!!this.socket}},Pinger=class{pinger;interval;constructor(interval=3e4){this.interval=interval}start(callback){this.pinger=setInterval(callback,this.interval)}stop(){clearInterval(this.pinger)}};var Surreal=class{connection;ready;emitter;engines={ws:WebsocketEngine,wss:WebsocketEngine,http:HttpEngine,https:HttpEngine};constructor({engines}={}){this.emitter=new Emitter,this.emitter.subscribe("disconnected",()=>this.clean()),this.emitter.subscribe("error",()=>this.close()),engines&&(this.engines={...this.engines,...engines})}async connect(url,opts={}){url=new URL(url),url.pathname.endsWith("/rpc")||(url.pathname.endsWith("/")||(url.pathname+="/"),url.pathname+="rpc");let engineName=url.protocol.slice(0,-1),engine=this.engines[engineName];if(!engine)throw new UnsupportedEngine(engineName);let{prepare,auth,namespace,database}=opts;await this.close();let context=new EngineContext({emitter:this.emitter,encodeCbor,decodeCbor}),connection=new engine(context);if(opts.versionCheck!==!1){let version=await connection.version(url,opts.versionCheckTimeout);versionCheck(version)}return this.connection=connection,this.ready=new Promise((resolve,reject)=>connection.connect(url).then(async()=>{(namespace||database)&&await this.use({namespace,database}),typeof auth=="string"?await this.authenticate(auth):auth&&await this.signin(auth),await prepare?.(this),resolve()}).catch(reject)),await this.ready,!0}async close(){return this.clean(),await this.connection?.disconnect(),!0}clean(){let pending=this.emitter.scanListeners(k=>k.startsWith("rpc-"));pending.map(k=>this.emitter.emit(k,[new EngineDisconnected]));let live=this.emitter.scanListeners(k=>k.startsWith("live-"));live.map(k=>this.emitter.emit(k,["CLOSE","disconnected"])),this.emitter.reset({collectable:!0,listeners:[...pending,...live]})}get status(){return this.connection?.status??"disconnected"}async ping(){let{error}=await this.rpc("ping");if(error)throw new ResponseError(error.message);return!0}async use({namespace,database}){if(!this.connection)throw new NoActiveSocket;if(namespace===null&&database!==null)throw new SurrealDbError("Cannot unset namespace without unsetting database");let{error}=await this.rpc("use",[namespace,database]);if(error)throw new ResponseError(error.message);return!0}async info(){await this.ready;let res=await this.rpc("info");if(res.error)throw new ResponseError(res.error.message);return res.result??void 0}async signup(vars){if(!this.connection)throw new NoActiveSocket;let parsed=processAuthVars(vars,this.connection.connection),converted=convertAuth(parsed),res=await this.rpc("signup",[converted]);if(res.error)throw new ResponseError(res.error.message);if(!res.result)throw new NoTokenReturned;return res.result}async signin(vars){if(!this.connection)throw new NoActiveSocket;let parsed=processAuthVars(vars,this.connection.connection),converted=convertAuth(parsed),res=await this.rpc("signin",[converted]);if(res.error)throw new ResponseError(res.error.message);if(!res.result)throw new NoTokenReturned;return res.result}async authenticate(token){let res=await this.rpc("authenticate",[token]);if(res.error)throw new ResponseError(res.error.message);return!0}async invalidate(){let res=await this.rpc("invalidate");if(res.error)throw new ResponseError(res.error.message);return!0}async let(variable,value){let res=await this.rpc("let",[variable,value]);if(res.error)throw new ResponseError(res.error.message);return!0}async unset(variable){let res=await this.rpc("unset",[variable]);if(res.error)throw new ResponseError(res.error.message);return!0}async live(table,callback,diff){await this.ready;let res=await this.rpc("live",[table,diff]);if(res.error)throw new ResponseError(res.error.message);return callback&&this.subscribeLive(res.result,callback),res.result}async subscribeLive(queryUuid,callback){if(await this.ready,!this.connection)throw new NoActiveSocket;this.connection.emitter.subscribe(`live-${queryUuid}`,callback,!0)}async unSubscribeLive(queryUuid,callback){if(await this.ready,!this.connection)throw new NoActiveSocket;this.connection.emitter.unSubscribe(`live-${queryUuid}`,callback)}async kill(queryUuid){if(await this.ready,!this.connection)throw new NoActiveSocket;if(Array.isArray(queryUuid)){await Promise.all(queryUuid.map(u2=>this.rpc("kill",[u2])));let toBeKilled=queryUuid.map(u2=>`live-${u2}`);toBeKilled.map(k=>this.emitter.emit(k,["CLOSE","killed"])),this.connection.emitter.reset({collectable:toBeKilled,listeners:toBeKilled})}else await this.rpc("kill",[queryUuid]),this.emitter.emit(`live-${queryUuid}`,["CLOSE","killed"]),this.connection.emitter.reset({collectable:`live-${queryUuid}`,listeners:`live-${queryUuid}`})}async query(...args){return(await this.query_raw(...args)).map(({status,result})=>{if(status==="ERR")throw new ResponseError(result);return result})}async query_raw(...[q,b]){let params=q instanceof PreparedQuery?[q.query,partiallyEncodeObject(q.bindings,{fills:b,replacer:replacer.encode})]:[q,b];await this.ready;let res=await this.rpc("query",params);if(res.error)throw new ResponseError(res.error.message);return res.result}async select(thing){await this.ready;let res=await this.rpc("select",[thing]);if(res.error)throw new ResponseError(res.error.message);return output(thing,res.result)}async create(thing,data){await this.ready;let res=await this.rpc("create",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return output(thing,res.result)}async insert(arg1,arg2){await this.ready;let[table,data]=typeof arg1=="string"||arg1 instanceof Table?[arg1,arg2]:[void 0,arg1],res=await this.rpc("insert",[table,data]);if(res.error)throw new ResponseError(res.error.message);return res.result}async insert_relation(arg1,arg2){await this.ready;let[table,data]=typeof arg1=="string"||arg1 instanceof Table?[arg1,arg2]:[void 0,arg1],res=await this.rpc("insert_relation",[table,data]);if(res.error)throw new ResponseError(res.error.message);return res.result}async update(thing,data){await this.ready;let res=await this.rpc("update",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return output(thing,res.result)}async upsert(thing,data){await this.ready;let res=await this.rpc("upsert",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return output(thing,res.result)}async merge(thing,data){await this.ready;let res=await this.rpc("merge",[thing,data]);if(res.error)throw new ResponseError(res.error.message);return output(thing,res.result)}async patch(thing,data,diff){await this.ready;let res=await this.rpc("patch",[thing,data,diff]);if(res.error)throw new ResponseError(res.error.message);return diff?res.result:output(thing,res.result)}async delete(thing){await this.ready;let res=await this.rpc("delete",[thing]);if(res.error)throw new ResponseError(res.error.message);return output(thing,res.result)}async version(){await this.ready;let res=await this.rpc("version");if(res.error)throw new ResponseError(res.error.message);return res.result}async run(name,arg2,arg3){await this.ready;let[version,args]=Array.isArray(arg2)?[void 0,arg2]:[arg2,arg3],res=await this.rpc("run",[name,version,args]);if(res.error)throw new ResponseError(res.error.message);return res.result}async relate(from,thing,to,data){await this.ready;let res=await this.rpc("relate",[from,thing,to,data]);if(res.error)throw new ResponseError(res.error.message);return output(thing,res.result)}rpc(method,params){if(!this.connection)throw new NoActiveSocket;return this.connection.rpc({method,params})}};function output(subject,input){return subject instanceof RecordId||subject instanceof StringRecordId?Array.isArray(input)?input[0]:input:Array.isArray(input)?input:[input]}export{AbstractEngine,BoundExcluded,BoundIncluded,CborBreak,CborError,CborFillMissing,CborInvalidMajorError,CborNumberError,CborPartialDisabled,CborRangeError,ConnectionStatus,ConnectionUnavailable,Decimal,Duration,Emitter,EngineDisconnected,Future,Gap,Geometry,GeometryCollection,GeometryLine,GeometryMultiLine,GeometryMultiPoint,GeometryMultiPolygon,GeometryPoint,GeometryPolygon,HttpConnectionError,InvalidURLProvided,MissingNamespaceDatabase,NoActiveSocket,NoConnectionDetails,NoDatabaseSpecified,NoNamespaceSpecified,NoTokenReturned,PreparedQuery,Range,RecordId,RecordIdRange,ResponseError,StringRecordId,Surreal,SurrealDbError,Table,UnexpectedConnectionError,UnexpectedResponse,UnexpectedServerResponse,UnsupportedEngine,UnsupportedVersion,Uuid,VersionRetrievalFailure,cbor_exports as cbor,convertAuth,d,decodeCbor,Surreal as default,defaultVersionCheckTimeout,encodeCbor,escape_ident,getIncrementalID,isLiveResult,isVersionSupported,jsonify,liveActions,r,retrieveRemoteVersion,s,supportedSurrealDbVersionMin,supportedSurrealDbVersionRange,supportedSurrealDbVersionUntil,surrealql as surql,surrealql,toSurrealqlString,u,versionCheck}; /*! Bundled license information: uuidv7/dist/index.js: diff --git a/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/esm.bundled.js b/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/esm.bundled.js deleted file mode 100644 index d2255fb..0000000 --- a/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/esm.bundled.js +++ /dev/null @@ -1,13 +0,0 @@ -var Deno=globalThis.Deno??(typeof global>"u"?void 0:{readFile:(await import("node:fs")).readFileSync}),module=await(async()=>{let crypto2=globalThis.crypto??await import("node:crypto");return{require:string=>{if(string!=="crypto")throw new Error("Unexpected require "+string);return crypto2}}})(),heap=new Array(128).fill(void 0);heap.push(void 0,null,!0,!1);function getObject(idx){return heap[idx]}var cachedTextDecoder=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&cachedTextDecoder.decode();var cachedUint8Memory0=null;function getUint8Memory0(){return(cachedUint8Memory0===null||cachedUint8Memory0.byteLength===0)&&(cachedUint8Memory0=new Uint8Array(wasm.memory.buffer)),cachedUint8Memory0}function getStringFromWasm0(ptr,len){return ptr=ptr>>>0,cachedTextDecoder.decode(getUint8Memory0().subarray(ptr,ptr+len))}var heap_next=heap.length;function addHeapObject(obj){heap_next===heap.length&&heap.push(heap.length+1);let idx=heap_next;return heap_next=heap[idx],heap[idx]=obj,idx}function dropObject(idx){idx<132||(heap[idx]=heap_next,heap_next=idx)}function takeObject(idx){let ret=getObject(idx);return dropObject(idx),ret}function isLikeNone(x){return x==null}var cachedFloat64Memory0=null;function getFloat64Memory0(){return(cachedFloat64Memory0===null||cachedFloat64Memory0.byteLength===0)&&(cachedFloat64Memory0=new Float64Array(wasm.memory.buffer)),cachedFloat64Memory0}var cachedInt32Memory0=null;function getInt32Memory0(){return(cachedInt32Memory0===null||cachedInt32Memory0.byteLength===0)&&(cachedInt32Memory0=new Int32Array(wasm.memory.buffer)),cachedInt32Memory0}var WASM_VECTOR_LEN=0,cachedTextEncoder=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},encodeString=function(arg,view){return cachedTextEncoder.encodeInto(arg,view)};function passStringToWasm0(arg,malloc,realloc){if(realloc===void 0){let buf=cachedTextEncoder.encode(arg),ptr2=malloc(buf.length,1)>>>0;return getUint8Memory0().subarray(ptr2,ptr2+buf.length).set(buf),WASM_VECTOR_LEN=buf.length,ptr2}let len=arg.length,ptr=malloc(len,1)>>>0,mem=getUint8Memory0(),offset=0;for(;offset127)break;mem[ptr+offset]=code}if(offset!==len){offset!==0&&(arg=arg.slice(offset)),ptr=realloc(ptr,len,len=offset+arg.length*3,1)>>>0;let view=getUint8Memory0().subarray(ptr+offset,ptr+len),ret=encodeString(arg,view);offset+=ret.written,ptr=realloc(ptr,len,offset,1)>>>0}return WASM_VECTOR_LEN=offset,ptr}var cachedBigInt64Memory0=null;function getBigInt64Memory0(){return(cachedBigInt64Memory0===null||cachedBigInt64Memory0.byteLength===0)&&(cachedBigInt64Memory0=new BigInt64Array(wasm.memory.buffer)),cachedBigInt64Memory0}function debugString(val){let type=typeof val;if(type=="number"||type=="boolean"||val==null)return`${val}`;if(type=="string")return`"${val}"`;if(type=="symbol"){let description=val.description;return description==null?"Symbol":`Symbol(${description})`}if(type=="function"){let name=val.name;return typeof name=="string"&&name.length>0?`Function(${name})`:"Function"}if(Array.isArray(val)){let length=val.length,debug="[";length>0&&(debug+=debugString(val[0]));for(let i=1;i1)className=builtInMatches[1];else return toString.call(val);if(className=="Object")try{return"Object("+JSON.stringify(val)+")"}catch{return"Object"}return val instanceof Error?`${val.name}: ${val.message} -${val.stack}`:className}var CLOSURE_DTORS=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(state=>{wasm.__wbindgen_export_2.get(state.dtor)(state.a,state.b)});function makeMutClosure(arg0,arg1,dtor,f2){let state={a:arg0,b:arg1,cnt:1,dtor},real=(...args)=>{state.cnt++;let a=state.a;state.a=0;try{return f2(a,state.b,...args)}finally{--state.cnt===0?(wasm.__wbindgen_export_2.get(state.dtor)(a,state.b),CLOSURE_DTORS.unregister(state)):state.a=a}};return real.original=state,CLOSURE_DTORS.register(real,state,state),real}function __wbg_adapter_52(arg0,arg1,arg2){try{let retptr=wasm.__wbindgen_add_to_stack_pointer(-16);wasm.__wbindgen_export_3(retptr,arg0,arg1,addHeapObject(arg2));var r0=getInt32Memory0()[retptr/4+0],r1=getInt32Memory0()[retptr/4+1];if(r1)throw takeObject(r0)}finally{wasm.__wbindgen_add_to_stack_pointer(16)}}function __wbg_adapter_55(arg0,arg1){wasm.__wbindgen_export_4(arg0,arg1)}function __wbg_adapter_58(arg0,arg1,arg2){wasm.__wbindgen_export_5(arg0,arg1,addHeapObject(arg2))}function handleError(f2,args){try{return f2.apply(this,args)}catch(e){wasm.__wbindgen_export_7(addHeapObject(e))}}function __wbg_adapter_307(arg0,arg1,arg2,arg3){wasm.__wbindgen_export_8(arg0,arg1,addHeapObject(arg2),addHeapObject(arg3))}var IntoUnderlyingByteSourceFinalization=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(ptr=>wasm.__wbg_intounderlyingbytesource_free(ptr>>>0));var IntoUnderlyingSinkFinalization=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(ptr=>wasm.__wbg_intounderlyingsink_free(ptr>>>0));var IntoUnderlyingSourceFinalization=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(ptr=>wasm.__wbg_intounderlyingsource_free(ptr>>>0)),IntoUnderlyingSource=class{static __wrap(ptr){ptr=ptr>>>0;let obj=Object.create(IntoUnderlyingSource.prototype);return obj.__wbg_ptr=ptr,IntoUnderlyingSourceFinalization.register(obj,obj.__wbg_ptr,obj),obj}__destroy_into_raw(){let ptr=this.__wbg_ptr;return this.__wbg_ptr=0,IntoUnderlyingSourceFinalization.unregister(this),ptr}free(){let ptr=this.__destroy_into_raw();wasm.__wbg_intounderlyingsource_free(ptr)}pull(controller){let ret=wasm.intounderlyingsource_pull(this.__wbg_ptr,addHeapObject(controller));return takeObject(ret)}cancel(){let ptr=this.__destroy_into_raw();wasm.intounderlyingsource_cancel(ptr)}},SurrealWasmEngineFinalization=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(ptr=>wasm.__wbg_surrealwasmengine_free(ptr>>>0)),SurrealWasmEngine=class{static __wrap(ptr){ptr=ptr>>>0;let obj=Object.create(SurrealWasmEngine.prototype);return obj.__wbg_ptr=ptr,SurrealWasmEngineFinalization.register(obj,obj.__wbg_ptr,obj),obj}__destroy_into_raw(){let ptr=this.__wbg_ptr;return this.__wbg_ptr=0,SurrealWasmEngineFinalization.unregister(this),ptr}free(){let ptr=this.__destroy_into_raw();wasm.__wbg_surrealwasmengine_free(ptr)}execute(data){let ret=wasm.surrealwasmengine_execute(this.__wbg_ptr,addHeapObject(data));return takeObject(ret)}notifications(){try{let retptr=wasm.__wbindgen_add_to_stack_pointer(-16);wasm.surrealwasmengine_notifications(retptr,this.__wbg_ptr);var r0=getInt32Memory0()[retptr/4+0],r1=getInt32Memory0()[retptr/4+1],r2=getInt32Memory0()[retptr/4+2];if(r2)throw takeObject(r1);return takeObject(r0)}finally{wasm.__wbindgen_add_to_stack_pointer(16)}}static connect(endpoint,opts){let ptr0=passStringToWasm0(endpoint,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len0=WASM_VECTOR_LEN,ret=wasm.surrealwasmengine_connect(ptr0,len0,isLikeNone(opts)?0:addHeapObject(opts));return takeObject(ret)}static version(){let deferred2_0,deferred2_1;try{let retptr=wasm.__wbindgen_add_to_stack_pointer(-16);wasm.surrealwasmengine_version(retptr);var r0=getInt32Memory0()[retptr/4+0],r1=getInt32Memory0()[retptr/4+1],r2=getInt32Memory0()[retptr/4+2],r3=getInt32Memory0()[retptr/4+3],ptr1=r0,len1=r1;if(r3)throw ptr1=0,len1=0,takeObject(r2);return deferred2_0=ptr1,deferred2_1=len1,getStringFromWasm0(ptr1,len1)}finally{wasm.__wbindgen_add_to_stack_pointer(16),wasm.__wbindgen_export_6(deferred2_0,deferred2_1,1)}}},imports={__wbindgen_placeholder__:{__wbindgen_is_undefined:function(arg0){return getObject(arg0)===void 0},__wbindgen_in:function(arg0,arg1){return getObject(arg0)in getObject(arg1)},__wbindgen_boolean_get:function(arg0){let v=getObject(arg0);return typeof v=="boolean"?v?1:0:2},__wbindgen_is_object:function(arg0){let val=getObject(arg0);return typeof val=="object"&&val!==null},__wbindgen_error_new:function(arg0,arg1){let ret=new Error(getStringFromWasm0(arg0,arg1));return addHeapObject(ret)},__wbindgen_jsval_eq:function(arg0,arg1){return getObject(arg0)===getObject(arg1)},__wbindgen_object_drop_ref:function(arg0){takeObject(arg0)},__wbindgen_string_new:function(arg0,arg1){let ret=getStringFromWasm0(arg0,arg1);return addHeapObject(ret)},__wbindgen_is_bigint:function(arg0){return typeof getObject(arg0)=="bigint"},__wbindgen_number_get:function(arg0,arg1){let obj=getObject(arg1),ret=typeof obj=="number"?obj:void 0;getFloat64Memory0()[arg0/8+1]=isLikeNone(ret)?0:ret,getInt32Memory0()[arg0/4+0]=!isLikeNone(ret)},__wbindgen_bigint_from_i64:function(arg0){return addHeapObject(arg0)},__wbindgen_string_get:function(arg0,arg1){let obj=getObject(arg1),ret=typeof obj=="string"?obj:void 0;var ptr1=isLikeNone(ret)?0:passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getInt32Memory0()[arg0/4+1]=len1,getInt32Memory0()[arg0/4+0]=ptr1},__wbindgen_bigint_from_u64:function(arg0){let ret=BigInt.asUintN(64,arg0);return addHeapObject(ret)},__wbg_surrealwasmengine_new:function(arg0){let ret=SurrealWasmEngine.__wrap(arg0);return addHeapObject(ret)},__wbindgen_object_clone_ref:function(arg0){let ret=getObject(arg0);return addHeapObject(ret)},__wbindgen_jsval_loose_eq:function(arg0,arg1){return getObject(arg0)==getObject(arg1)},__wbindgen_as_number:function(arg0){return+getObject(arg0)},__wbg_String_b9412f8799faab3e:function(arg0,arg1){let ret=String(getObject(arg1)),ptr1=passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getInt32Memory0()[arg0/4+1]=len1,getInt32Memory0()[arg0/4+0]=ptr1},__wbindgen_number_new:function(arg0){return addHeapObject(arg0)},__wbg_getwithrefkey_edc2c8960f0f1191:function(arg0,arg1){let ret=getObject(arg0)[getObject(arg1)];return addHeapObject(ret)},__wbindgen_cb_drop:function(arg0){let obj=takeObject(arg0).original;return obj.cnt--==1?(obj.a=0,!0):!1},__wbindgen_is_falsy:function(arg0){return!getObject(arg0)},__wbg_new_abda76e883ba8a5f:function(){let ret=new Error;return addHeapObject(ret)},__wbg_stack_658279fe44541cf6:function(arg0,arg1){let ret=getObject(arg1).stack,ptr1=passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getInt32Memory0()[arg0/4+1]=len1,getInt32Memory0()[arg0/4+0]=ptr1},__wbg_error_f851667af71bcfc6:function(arg0,arg1){let deferred0_0,deferred0_1;try{deferred0_0=arg0,deferred0_1=arg1,console.error(getStringFromWasm0(arg0,arg1))}finally{wasm.__wbindgen_export_6(deferred0_0,deferred0_1,1)}},__wbg_fetch_bc7c8e27076a5c84:function(arg0){let ret=fetch(getObject(arg0));return addHeapObject(ret)},__wbg_sethighWaterMark_ea50ed3ec2143088:function(arg0,arg1){getObject(arg0).highWaterMark=arg1},__wbg_newwithintounderlyingsource_a03a82aa1bbbb292:function(arg0,arg1){let ret=new ReadableStream(IntoUnderlyingSource.__wrap(arg0),takeObject(arg1));return addHeapObject(ret)},__wbg_signal_a61f78a3478fd9bc:function(arg0){let ret=getObject(arg0).signal;return addHeapObject(ret)},__wbg_new_0d76b0581eca6298:function(){return handleError(function(){let ret=new AbortController;return addHeapObject(ret)},arguments)},__wbg_abort_2aa7521d5690750e:function(arg0){getObject(arg0).abort()},__wbg_newwithu8arraysequenceandoptions_366f462e1b363808:function(){return handleError(function(arg0,arg1){let ret=new Blob(getObject(arg0),getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_length_9ae5daf9a690cba9:function(arg0){return getObject(arg0).length},__wbg_contains_c65b44400b549286:function(arg0,arg1,arg2){return getObject(arg0).contains(getStringFromWasm0(arg1,arg2))},__wbg_get_910bbb94abdcf488:function(arg0,arg1,arg2){let ret=getObject(arg1)[arg2>>>0];var ptr1=isLikeNone(ret)?0:passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getInt32Memory0()[arg0/4+1]=len1,getInt32Memory0()[arg0/4+0]=ptr1},__wbg_target_2fc177e386c8b7b0:function(arg0){let ret=getObject(arg0).target;return isLikeNone(ret)?0:addHeapObject(ret)},__wbg_new_d4ab7daa4cb33d5f:function(){return handleError(function(){let ret=new FormData;return addHeapObject(ret)},arguments)},__wbg_append_056476f73715b602:function(){return handleError(function(arg0,arg1,arg2,arg3){getObject(arg0).append(getStringFromWasm0(arg1,arg2),getObject(arg3))},arguments)},__wbg_append_9fd018eae44ea54a:function(){return handleError(function(arg0,arg1,arg2,arg3,arg4,arg5){getObject(arg0).append(getStringFromWasm0(arg1,arg2),getObject(arg3),getStringFromWasm0(arg4,arg5))},arguments)},__wbg_append_9c9890ca2ce97dba:function(){return handleError(function(arg0,arg1,arg2,arg3,arg4){getObject(arg0).append(getStringFromWasm0(arg1,arg2),getStringFromWasm0(arg3,arg4))},arguments)},__wbg_new_ab6fd82b10560829:function(){return handleError(function(){let ret=new Headers;return addHeapObject(ret)},arguments)},__wbg_append_7bfcb4937d1d5e29:function(){return handleError(function(arg0,arg1,arg2,arg3,arg4){getObject(arg0).append(getStringFromWasm0(arg1,arg2),getStringFromWasm0(arg3,arg4))},arguments)},__wbg_key_7a534de95a1f5fbf:function(){return handleError(function(arg0){let ret=getObject(arg0).key;return addHeapObject(ret)},arguments)},__wbg_advance_e211280146391e9c:function(){return handleError(function(arg0,arg1){getObject(arg0).advance(arg1>>>0)},arguments)},__wbg_continue_f1c3e0815924de62:function(){return handleError(function(arg0){getObject(arg0).continue()},arguments)},__wbg_value_86d3334f5075b232:function(){return handleError(function(arg0){let ret=getObject(arg0).value;return addHeapObject(ret)},arguments)},__wbg_objectStoreNames_588b5924274239fd:function(arg0){let ret=getObject(arg0).objectStoreNames;return addHeapObject(ret)},__wbg_createObjectStore_f494613cd1a00d43:function(){return handleError(function(arg0,arg1,arg2,arg3){let ret=getObject(arg0).createObjectStore(getStringFromWasm0(arg1,arg2),getObject(arg3));return addHeapObject(ret)},arguments)},__wbg_deleteObjectStore_1732efdd0f8a351d:function(){return handleError(function(arg0,arg1,arg2){getObject(arg0).deleteObjectStore(getStringFromWasm0(arg1,arg2))},arguments)},__wbg_transaction_b39e2665b40b6324:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).transaction(getObject(arg1),takeObject(arg2));return addHeapObject(ret)},arguments)},__wbg_instanceof_IdbFactory_c70f8c7294f93655:function(arg0){let result;try{result=getObject(arg0)instanceof IDBFactory}catch{result=!1}return result},__wbg_open_f0d7259fd7e689ce:function(){return handleError(function(arg0,arg1,arg2,arg3){let ret=getObject(arg0).open(getStringFromWasm0(arg1,arg2),arg3>>>0);return addHeapObject(ret)},arguments)},__wbg_open_a05198d687357536:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).open(getStringFromWasm0(arg1,arg2));return addHeapObject(ret)},arguments)},__wbg_bound_25385469508e98c7:function(){return handleError(function(arg0,arg1,arg2,arg3){let ret=IDBKeyRange.bound(getObject(arg0),getObject(arg1),arg2!==0,arg3!==0);return addHeapObject(ret)},arguments)},__wbg_indexNames_fd89e01c0b29fe18:function(arg0){let ret=getObject(arg0).indexNames;return addHeapObject(ret)},__wbg_add_a3b44bfbb3d40345:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).add(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_add_1dac52a28ed73a3a:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).add(getObject(arg1),getObject(arg2));return addHeapObject(ret)},arguments)},__wbg_createIndex_d786564b37de8e73:function(){return handleError(function(arg0,arg1,arg2,arg3,arg4){let ret=getObject(arg0).createIndex(getStringFromWasm0(arg1,arg2),getObject(arg3),getObject(arg4));return addHeapObject(ret)},arguments)},__wbg_delete_f60bba7d0ae59a4f:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).delete(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_deleteIndex_cbeab45ca61aff12:function(){return handleError(function(arg0,arg1,arg2){getObject(arg0).deleteIndex(getStringFromWasm0(arg1,arg2))},arguments)},__wbg_get_5361b64cac0d0826:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).get(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_openCursor_30d58ae27a327629:function(){return handleError(function(arg0){let ret=getObject(arg0).openCursor();return addHeapObject(ret)},arguments)},__wbg_openCursor_611b1e488c393dd8:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).openCursor(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_openCursor_2df5d7cb6c41ac04:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).openCursor(getObject(arg1),takeObject(arg2));return addHeapObject(ret)},arguments)},__wbg_put_0a0d7ca0f7fa8f83:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).put(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_put_22792e17580ca18b:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).put(getObject(arg1),getObject(arg2));return addHeapObject(ret)},arguments)},__wbg_setonupgradeneeded_ad7645373c7d5e1b:function(arg0,arg1){getObject(arg0).onupgradeneeded=getObject(arg1)},__wbg_result_6cedf5f78600a79c:function(){return handleError(function(arg0){let ret=getObject(arg0).result;return addHeapObject(ret)},arguments)},__wbg_error_685b20024dc2d6ca:function(){return handleError(function(arg0){let ret=getObject(arg0).error;return isLikeNone(ret)?0:addHeapObject(ret)},arguments)},__wbg_transaction_9c6c3c7e1f9283c7:function(arg0){let ret=getObject(arg0).transaction;return isLikeNone(ret)?0:addHeapObject(ret)},__wbg_setonsuccess_632ce0a1460455c2:function(arg0,arg1){getObject(arg0).onsuccess=getObject(arg1)},__wbg_setonerror_8479b33e7568a904:function(arg0,arg1){getObject(arg0).onerror=getObject(arg1)},__wbg_setonabort_523135fd9168ae8b:function(arg0,arg1){getObject(arg0).onabort=getObject(arg1)},__wbg_setoncomplete_d8e4236665cbf1e2:function(arg0,arg1){getObject(arg0).oncomplete=getObject(arg1)},__wbg_setonerror_da071ec94e148397:function(arg0,arg1){getObject(arg0).onerror=getObject(arg1)},__wbg_abort_5e21246d2bf821aa:function(){return handleError(function(arg0){getObject(arg0).abort()},arguments)},__wbg_objectStore_da468793bd9df17b:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).objectStore(getStringFromWasm0(arg1,arg2));return addHeapObject(ret)},arguments)},__wbg_now_4e659b3d15f470d9:function(arg0){return getObject(arg0).now()},__wbg_byobRequest_72fca99f9c32c193:function(arg0){let ret=getObject(arg0).byobRequest;return isLikeNone(ret)?0:addHeapObject(ret)},__wbg_close_184931724d961ccc:function(){return handleError(function(arg0){getObject(arg0).close()},arguments)},__wbg_view_7f0ce470793a340f:function(arg0){let ret=getObject(arg0).view;return isLikeNone(ret)?0:addHeapObject(ret)},__wbg_respond_b1a43b2e3a06d525:function(){return handleError(function(arg0,arg1){getObject(arg0).respond(arg1>>>0)},arguments)},__wbg_close_a994f9425dab445c:function(){return handleError(function(arg0){getObject(arg0).close()},arguments)},__wbg_enqueue_ea194723156c0cc2:function(){return handleError(function(arg0,arg1){getObject(arg0).enqueue(getObject(arg1))},arguments)},__wbg_newwithstrandinit_3fd6fba4083ff2d0:function(){return handleError(function(arg0,arg1,arg2){let ret=new Request(getStringFromWasm0(arg0,arg1),getObject(arg2));return addHeapObject(ret)},arguments)},__wbg_instanceof_Response_849eb93e75734b6e:function(arg0){let result;try{result=getObject(arg0)instanceof Response}catch{result=!1}return result},__wbg_url_5f6dc4009ac5f99d:function(arg0,arg1){let ret=getObject(arg1).url,ptr1=passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getInt32Memory0()[arg0/4+1]=len1,getInt32Memory0()[arg0/4+0]=ptr1},__wbg_status_61a01141acd3cf74:function(arg0){return getObject(arg0).status},__wbg_headers_9620bfada380764a:function(arg0){let ret=getObject(arg0).headers;return addHeapObject(ret)},__wbg_arrayBuffer_29931d52c7206b02:function(){return handleError(function(arg0){let ret=getObject(arg0).arrayBuffer();return addHeapObject(ret)},arguments)},__wbg_text_450a059667fd91fd:function(){return handleError(function(arg0){let ret=getObject(arg0).text();return addHeapObject(ret)},arguments)},__wbg_fetch_921fad6ef9e883dd:function(arg0,arg1){let ret=getObject(arg0).fetch(getObject(arg1));return addHeapObject(ret)},__wbg_now_e7e620e94c8426dd:function(){return handleError(function(){return Date.now()},arguments)},__wbg_performance_1430613edb72ce03:function(arg0){let ret=getObject(arg0).performance;return addHeapObject(ret)},__wbg_now_eab901b1d3b8a295:function(arg0){return getObject(arg0).now()},__wbg_setTimeout_fba1b48a90e30862:function(){return handleError(function(arg0,arg1,arg2){return getObject(arg0).setTimeout(getObject(arg1),arg2)},arguments)},__wbg_queueMicrotask_3cbae2ec6b6cd3d6:function(arg0){let ret=getObject(arg0).queueMicrotask;return addHeapObject(ret)},__wbindgen_is_function:function(arg0){return typeof getObject(arg0)=="function"},__wbg_queueMicrotask_481971b0d87f3dd4:function(arg0){queueMicrotask(getObject(arg0))},__wbg_crypto_d05b68a3572bb8ca:function(arg0){let ret=getObject(arg0).crypto;return addHeapObject(ret)},__wbg_process_b02b3570280d0366:function(arg0){let ret=getObject(arg0).process;return addHeapObject(ret)},__wbg_versions_c1cb42213cedf0f5:function(arg0){let ret=getObject(arg0).versions;return addHeapObject(ret)},__wbg_node_43b1089f407e4ec2:function(arg0){let ret=getObject(arg0).node;return addHeapObject(ret)},__wbindgen_is_string:function(arg0){return typeof getObject(arg0)=="string"},__wbg_require_9a7e0f667ead4995:function(){return handleError(function(){let ret=module.require;return addHeapObject(ret)},arguments)},__wbg_msCrypto_10fc94afee92bd76:function(arg0){let ret=getObject(arg0).msCrypto;return addHeapObject(ret)},__wbg_randomFillSync_b70ccbdf4926a99d:function(){return handleError(function(arg0,arg1){getObject(arg0).randomFillSync(takeObject(arg1))},arguments)},__wbg_getRandomValues_7e42b4fb8779dc6d:function(){return handleError(function(arg0,arg1){getObject(arg0).getRandomValues(getObject(arg1))},arguments)},__wbg_self_ce0dbfc45cf2f5be:function(){return handleError(function(){let ret=self.self;return addHeapObject(ret)},arguments)},__wbg_window_c6fb939a7f436783:function(){return handleError(function(){let ret=window.window;return addHeapObject(ret)},arguments)},__wbg_globalThis_d1e6af4856ba331b:function(){return handleError(function(){let ret=globalThis.globalThis;return addHeapObject(ret)},arguments)},__wbg_global_207b558942527489:function(){return handleError(function(){let ret=global.global;return addHeapObject(ret)},arguments)},__wbg_newnoargs_e258087cd0daa0ea:function(arg0,arg1){let ret=new Function(getStringFromWasm0(arg0,arg1));return addHeapObject(ret)},__wbg_length_cd7af8117672b8b8:function(arg0){return getObject(arg0).length},__wbg_new_16b304a2cfa7ff4a:function(){let ret=new Array;return addHeapObject(ret)},__wbg_next_40fc327bfc8770e6:function(arg0){let ret=getObject(arg0).next;return addHeapObject(ret)},__wbg_value_d93c65011f51a456:function(arg0){let ret=getObject(arg0).value;return addHeapObject(ret)},__wbg_iterator_2cee6dadfd956dfa:function(){return addHeapObject(Symbol.iterator)},__wbg_new_72fb9a18b5ae2624:function(){let ret=new Object;return addHeapObject(ret)},__wbg_get_bd8e338fbd5f5cc8:function(arg0,arg1){let ret=getObject(arg0)[arg1>>>0];return addHeapObject(ret)},__wbg_isArray_2ab64d95e09ea0ae:function(arg0){return Array.isArray(getObject(arg0))},__wbg_push_a5b05aedc7234f9f:function(arg0,arg1){return getObject(arg0).push(getObject(arg1))},__wbg_instanceof_ArrayBuffer_836825be07d4c9d2:function(arg0){let result;try{result=getObject(arg0)instanceof ArrayBuffer}catch{result=!1}return result},__wbg_new_28c511d9baebfa89:function(arg0,arg1){let ret=new Error(getStringFromWasm0(arg0,arg1));return addHeapObject(ret)},__wbg_toString_ffe4c9ea3b3532e9:function(arg0){let ret=getObject(arg0).toString();return addHeapObject(ret)},__wbg_call_27c0f87801dedf93:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).call(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_call_b3ca7c6051f9bec1:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).call(getObject(arg1),getObject(arg2));return addHeapObject(ret)},arguments)},__wbg_instanceof_Map_87917e0a7aaf4012:function(arg0){let result;try{result=getObject(arg0)instanceof Map}catch{result=!1}return result},__wbg_next_196c84450b364254:function(){return handleError(function(arg0){let ret=getObject(arg0).next();return addHeapObject(ret)},arguments)},__wbg_done_298b57d23c0fc80c:function(arg0){return getObject(arg0).done},__wbg_isSafeInteger_f7b04ef02296c4d2:function(arg0){return Number.isSafeInteger(getObject(arg0))},__wbg_getTime_2bc4375165f02d15:function(arg0){return getObject(arg0).getTime()},__wbg_getTimezoneOffset_38257122e236c190:function(arg0){return getObject(arg0).getTimezoneOffset()},__wbg_new_cf3ec55744a78578:function(arg0){let ret=new Date(getObject(arg0));return addHeapObject(ret)},__wbg_new0_7d84e5b2cd9fdc73:function(){return addHeapObject(new Date)},__wbg_now_3014639a94423537:function(){return Date.now()},__wbg_entries_95cc2c823b285a09:function(arg0){let ret=Object.entries(getObject(arg0));return addHeapObject(ret)},__wbg_get_e3c254076557e348:function(){return handleError(function(arg0,arg1){let ret=Reflect.get(getObject(arg0),getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_has_0af94d20077affa2:function(){return handleError(function(arg0,arg1){return Reflect.has(getObject(arg0),getObject(arg1))},arguments)},__wbg_set_1f9b04f170055d33:function(){return handleError(function(arg0,arg1,arg2){return Reflect.set(getObject(arg0),getObject(arg1),getObject(arg2))},arguments)},__wbg_buffer_12d079cc21e14bdb:function(arg0){let ret=getObject(arg0).buffer;return addHeapObject(ret)},__wbg_stringify_8887fe74e1c50d81:function(){return handleError(function(arg0){let ret=JSON.stringify(getObject(arg0));return addHeapObject(ret)},arguments)},__wbg_new_81740750da40724f:function(arg0,arg1){try{var state0={a:arg0,b:arg1},cb0=(arg02,arg12)=>{let a=state0.a;state0.a=0;try{return __wbg_adapter_307(a,state0.b,arg02,arg12)}finally{state0.a=a}};let ret=new Promise(cb0);return addHeapObject(ret)}finally{state0.a=state0.b=0}},__wbg_resolve_b0083a7967828ec8:function(arg0){let ret=Promise.resolve(getObject(arg0));return addHeapObject(ret)},__wbg_then_0c86a60e8fcfe9f6:function(arg0,arg1){let ret=getObject(arg0).then(getObject(arg1));return addHeapObject(ret)},__wbg_then_a73caa9a87991566:function(arg0,arg1,arg2){let ret=getObject(arg0).then(getObject(arg1),getObject(arg2));return addHeapObject(ret)},__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb:function(arg0,arg1,arg2){let ret=new Uint8Array(getObject(arg0),arg1>>>0,arg2>>>0);return addHeapObject(ret)},__wbg_new_63b92bc8671ed464:function(arg0){let ret=new Uint8Array(getObject(arg0));return addHeapObject(ret)},__wbg_instanceof_Uint8Array_2b3bbecd033d19f6:function(arg0){let result;try{result=getObject(arg0)instanceof Uint8Array}catch{result=!1}return result},__wbg_newwithlength_e9b4878cebadb3d3:function(arg0){let ret=new Uint8Array(arg0>>>0);return addHeapObject(ret)},__wbg_buffer_dd7f74bc60f1faab:function(arg0){let ret=getObject(arg0).buffer;return addHeapObject(ret)},__wbg_subarray_a1f73cd4b5b42fe1:function(arg0,arg1,arg2){let ret=getObject(arg0).subarray(arg1>>>0,arg2>>>0);return addHeapObject(ret)},__wbg_length_c20a40f15020d68a:function(arg0){return getObject(arg0).length},__wbg_byteLength_58f7b4fab1919d44:function(arg0){return getObject(arg0).byteLength},__wbg_byteOffset_81d60f7392524f62:function(arg0){return getObject(arg0).byteOffset},__wbg_set_a47bac70306a19a7:function(arg0,arg1,arg2){getObject(arg0).set(getObject(arg1),arg2>>>0)},__wbindgen_bigint_get_as_i64:function(arg0,arg1){let v=getObject(arg1),ret=typeof v=="bigint"?v:void 0;getBigInt64Memory0()[arg0/8+1]=isLikeNone(ret)?BigInt(0):ret,getInt32Memory0()[arg0/4+0]=!isLikeNone(ret)},__wbindgen_debug_string:function(arg0,arg1){let ret=debugString(getObject(arg1)),ptr1=passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getInt32Memory0()[arg0/4+1]=len1,getInt32Memory0()[arg0/4+0]=ptr1},__wbindgen_throw:function(arg0,arg1){throw new Error(getStringFromWasm0(arg0,arg1))},__wbindgen_memory:function(){let ret=wasm.memory;return addHeapObject(ret)},__wbindgen_closure_wrapper30695:function(arg0,arg1,arg2){let ret=makeMutClosure(arg0,arg1,1408,__wbg_adapter_52);return addHeapObject(ret)},__wbindgen_closure_wrapper40565:function(arg0,arg1,arg2){let ret=makeMutClosure(arg0,arg1,2704,__wbg_adapter_55);return addHeapObject(ret)},__wbindgen_closure_wrapper40748:function(arg0,arg1,arg2){let ret=makeMutClosure(arg0,arg1,2723,__wbg_adapter_58);return addHeapObject(ret)}}},wasm_url=new URL("index_bg.wasm",import.meta.url),wasmCode="";switch(wasm_url.protocol){case"file:":wasmCode=await Deno.readFile(wasm_url);break;case"tauri:":case"https:":case"http:":wasmCode=await(await fetch(wasm_url)).arrayBuffer();break;default:throw new Error(`Unsupported protocol: ${wasm_url.protocol}`)}var wasmInstance=(await WebAssembly.instantiate(wasmCode,imports)).instance,wasm=wasmInstance.exports;var DIGITS="0123456789abcdef",UUID=class{constructor(bytes){this.bytes=bytes}static ofInner(bytes){if(bytes.length!==16)throw new TypeError("not 128-bit length");return new UUID(bytes)}static fromFieldsV7(unixTsMs,randA,randBHi,randBLo){if(!Number.isInteger(unixTsMs)||!Number.isInteger(randA)||!Number.isInteger(randBHi)||!Number.isInteger(randBLo)||unixTsMs<0||randA<0||randBHi<0||randBLo<0||unixTsMs>0xffffffffffff||randA>4095||randBHi>1073741823||randBLo>4294967295)throw new RangeError("invalid field value");let bytes=new Uint8Array(16);return bytes[0]=unixTsMs/2**40,bytes[1]=unixTsMs/2**32,bytes[2]=unixTsMs/2**24,bytes[3]=unixTsMs/2**16,bytes[4]=unixTsMs/2**8,bytes[5]=unixTsMs,bytes[6]=112|randA>>>8,bytes[7]=randA,bytes[8]=128|randBHi>>>24,bytes[9]=randBHi>>>16,bytes[10]=randBHi>>>8,bytes[11]=randBHi,bytes[12]=randBLo>>>24,bytes[13]=randBLo>>>16,bytes[14]=randBLo>>>8,bytes[15]=randBLo,new UUID(bytes)}static parse(uuid){var _a,_b,_c,_d;let hex;switch(uuid.length){case 32:hex=(_a=/^[0-9a-f]{32}$/i.exec(uuid))===null||_a===void 0?void 0:_a[0];break;case 36:hex=(_b=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid))===null||_b===void 0?void 0:_b.slice(1,6).join("");break;case 38:hex=(_c=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid))===null||_c===void 0?void 0:_c.slice(1,6).join("");break;case 45:hex=(_d=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid))===null||_d===void 0?void 0:_d.slice(1,6).join("");break;default:break}if(hex){let inner=new Uint8Array(16);for(let i=0;i<16;i+=4){let n=parseInt(hex.substring(2*i,2*i+8),16);inner[i+0]=n>>>24,inner[i+1]=n>>>16,inner[i+2]=n>>>8,inner[i+3]=n}return new UUID(inner)}else throw new SyntaxError("could not parse UUID string")}toString(){let text="";for(let i=0;i>>4),text+=DIGITS.charAt(this.bytes[i]&15),(i===3||i===5||i===7||i===9)&&(text+="-");return text}toHex(){let text="";for(let i=0;i>>4),text+=DIGITS.charAt(this.bytes[i]&15);return text}toJSON(){return this.toString()}getVariant(){let n=this.bytes[8]>>>4;if(n<0)throw new Error("unreachable");if(n<=7)return this.bytes.every(e=>e===0)?"NIL":"VAR_0";if(n<=11)return"VAR_10";if(n<=13)return"VAR_110";if(n<=15)return this.bytes.every(e=>e===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new UUID(this.bytes.slice(0))}equals(other){return this.compareTo(other)===0}compareTo(other){for(let i=0;i<16;i++){let diff=this.bytes[i]-other.bytes[i];if(diff!==0)return Math.sign(diff)}return 0}},V7Generator=class{constructor(randomNumberGenerator){this.timestamp=0,this.counter=0,this.random=randomNumberGenerator??getDefaultRandom()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(unixTsMs,rollbackAllowance){let value=this.generateOrAbortCore(unixTsMs,rollbackAllowance);return value===void 0&&(this.timestamp=0,value=this.generateOrAbortCore(unixTsMs,rollbackAllowance)),value}generateOrAbortCore(unixTsMs,rollbackAllowance){if(!Number.isInteger(unixTsMs)||unixTsMs<1||unixTsMs>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(rollbackAllowance<0||rollbackAllowance>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(unixTsMs>this.timestamp)this.timestamp=unixTsMs,this.resetCounter();else if(unixTsMs+rollbackAllowance>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return UUID.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let bytes=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return bytes[6]=64|bytes[6]>>>4,bytes[8]=128|bytes[8]>>>2,UUID.ofInner(bytes)}},getDefaultRandom=()=>{if(typeof crypto<"u"&&typeof crypto.getRandomValues<"u")return new BufferedCryptoRandom;if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");return{nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}},BufferedCryptoRandom=class{constructor(){this.buffer=new Uint32Array(8),this.cursor=65535}nextUint32(){return this.cursor>=this.buffer.length&&(crypto.getRandomValues(this.buffer),this.cursor=0),this.buffer[this.cursor++]}},defaultGenerator;var uuidv7obj=()=>(defaultGenerator||(defaultGenerator=new V7Generator)).generate();var uuidv4obj=()=>(defaultGenerator||(defaultGenerator=new V7Generator)).generateV4();var __defProp=Object.defineProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})};var cbor_exports={};__export(cbor_exports,{CborBreak:()=>CborBreak,CborError:()=>CborError,CborFillMissing:()=>CborFillMissing,CborInvalidMajorError:()=>CborInvalidMajorError,CborNumberError:()=>CborNumberError,CborPartialDisabled:()=>CborPartialDisabled,CborRangeError:()=>CborRangeError,Encoded:()=>Encoded,Gap:()=>Gap,POW_2_53:()=>POW_2_53,POW_2_64:()=>POW_2_64,PartiallyEncoded:()=>PartiallyEncoded,Reader:()=>Reader,Tagged:()=>Tagged,Writer:()=>Writer,decode:()=>decode,encode:()=>encode,infiniteBytes:()=>infiniteBytes,partiallyEncodeObject:()=>partiallyEncodeObject});var POW_2_53=9007199254740992,POW_2_64=BigInt(18446744073709552e3),Encoded=class{constructor(encoded){this.encoded=encoded}},SurrealDbError=class extends Error{};var UnexpectedConnectionError=class extends SurrealDbError{constructor(error){super(),this.error=error,this.message=`${error}`}name="UnexpectedConnectionError"};var ConnectionUnavailable=class extends SurrealDbError{name="ConnectionUnavailable";message="There is no connection available at this moment."};var CborError=class extends SurrealDbError{message;constructor(message){super(),this.message=message}},CborNumberError=class extends CborError{name="CborNumberError"},CborRangeError=class extends CborError{name="CborRangeError"},CborInvalidMajorError=class extends CborError{name="CborInvalidMajorError"},CborBreak=class extends CborError{name="CborBreak";constructor(){super("Came across a break which was not intercepted by the decoder")}},CborPartialDisabled=class extends CborError{name="CborPartialDisabled";constructor(){super("Tried to insert a Gap into a CBOR value, while partial mode is not enabled")}},CborFillMissing=class extends CborError{name="CborFillMissing";constructor(){super("Fill for a gap is missing, and gap has no default")}},Gap=class{args=[];constructor(...args){this.args=args}fill(value){return[this,value]}hasDefault(){return this.args.length===1}get default(){return this.args[0]}},Writer=class{constructor(byteLength=256){this.byteLength=byteLength,this._buf=new ArrayBuffer(this.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf)}_chunks=[];_pos=0;_buf;_view;_byte;chunk(gap){this._chunks.push([this._buf.slice(0,this._pos),gap]),this._buf=new ArrayBuffer(this.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._pos=0}get chunks(){return this._chunks}get buffer(){return this._buf.slice(0,this._pos)}claim(length){let pos=this._pos;if(this._pos+=length,this._pos<=this._buf.byteLength)return pos;let newLen=this._buf.byteLength<<1;for(;newLenthis._buf.byteLength){let oldb=this._byte;this._buf=new ArrayBuffer(newLen),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._byte.set(oldb)}return pos}writeUint8(value){let pos=this.claim(1);this._view.setUint8(pos,value)}writeUint16(value){let pos=this.claim(2);this._view.setUint16(pos,value)}writeUint32(value){let pos=this.claim(4);this._view.setUint32(pos,value)}writeUint64(value){let pos=this.claim(8);this._view.setBigUint64(pos,value)}writeUint8Array(data){if(data.byteLength===0)return;let pos=this.claim(data.byteLength);this._byte.set(data,pos)}writeArrayBuffer(data){data.byteLength!==0&&this.writeUint8Array(new Uint8Array(data))}writePartiallyEncoded(data){for(let[buf,gap]of data.chunks)this.writeArrayBuffer(buf),this.chunk(gap);this.writeArrayBuffer(data.end)}writeFloat32(value){let pos=this.claim(4);this._view.setFloat32(pos,value)}writeFloat64(value){let pos=this.claim(8);this._view.setFloat64(pos,value)}writeMajor(type,length){let base=type<<5;length<24?this.writeUint8(base+Number(length)):length<256?(this.writeUint8(base+24),this.writeUint8(Number(length))):length<65536?(this.writeUint8(base+25),this.writeUint16(Number(length))):length<4294967296?(this.writeUint8(base+26),this.writeUint32(Number(length))):(this.writeUint8(base+27),this.writeUint64(BigInt(length)))}output(partial,replacer2){return partial?new PartiallyEncoded(this._chunks,this.buffer,replacer2):this.buffer}},PartiallyEncoded=class{constructor(chunks,end,replacer2){this.chunks=chunks,this.end=end,this.replacer=replacer2}build(fills,partial){let writer=new Writer,map=new Map(fills);for(let[buffer,gap]of this.chunks){let hasValue=map.has(gap)||gap.hasDefault();if(!partial&&!hasValue)throw new CborFillMissing;if(writer.writeArrayBuffer(buffer),hasValue){let data=map.get(gap)??gap.default;encode(data,{writer,replacer:this.replacer})}else writer.chunk(gap)}return writer.writeArrayBuffer(this.end),writer.output(!!partial,this.replacer)}};function partiallyEncodeObject(object,options){return Object.fromEntries(Object.entries(object).map(([k,v])=>[k,encode(v,{...options,partial:!0})]))}var Tagged=class{constructor(tag,value){this.tag=tag,this.value=value}},textEncoder;function encode(input,options={}){let w=options.writer??new Writer,fillsMap=new Map(options.fills??[]);function inner(input2){let value=options.replacer?options.replacer(input2):input2;if(value===void 0)return w.writeUint8(247);if(value===null)return w.writeUint8(246);if(value===!0)return w.writeUint8(245);if(value===!1)return w.writeUint8(244);switch(typeof value){case"number":{if(Number.isInteger(value))if(value>=0&&value<=9007199254740992)w.writeMajor(0,value);else if(value<0&&value>=-9007199254740992)w.writeMajor(1,-(value+1));else throw new CborNumberError("Number too big to be encoded");else w.writeUint8(251),w.writeFloat64(value);return}case"bigint":{if(value>=0&&value=-POW_2_64)w.writeMajor(1,-(value+1n));else throw new CborNumberError("BigInt too big to be encoded");return}case"string":{textEncoder??=new TextEncoder;let encoded=textEncoder.encode(value);w.writeMajor(3,encoded.byteLength),w.writeUint8Array(encoded);return}default:{if(Array.isArray(value)){w.writeMajor(4,value.length);for(let v of value)inner(v);return}if(value instanceof Tagged){w.writeMajor(6,value.tag),inner(value.value);return}if(value instanceof Encoded){w.writeArrayBuffer(value.encoded);return}if(value instanceof Gap){if(fillsMap.has(value))inner(fillsMap.get(value));else{if(!options.partial)throw new CborPartialDisabled;w.chunk(value)}return}if(value instanceof PartiallyEncoded){let res=value.build(options.fills??[],options.partial);options.partial?w.writePartiallyEncoded(res):w.writeArrayBuffer(res);return}if(value instanceof Uint8Array||value instanceof Uint16Array||value instanceof Uint32Array||value instanceof Int8Array||value instanceof Int16Array||value instanceof Int32Array||value instanceof Float32Array||value instanceof Float64Array||value instanceof ArrayBuffer){let v=new Uint8Array(value);w.writeMajor(2,v.byteLength),w.writeUint8Array(v);return}let entries=value instanceof Map?Array.from(value.entries()):Object.entries(value);w.writeMajor(5,entries.length);for(let v of entries.flat())inner(v)}}}return inner(input),w.output(!!options.partial,options.replacer)}var Reader=class{_buf;_view;_byte;_pos=0;constructor(buffer){this._buf=new ArrayBuffer(buffer.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._byte.set(new Uint8Array(buffer))}read(amount,res){return this._pos+=amount,res}readUint8(){try{return this.read(1,this._view.getUint8(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint16(){try{return this.read(2,this._view.getUint16(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint32(){try{return this.read(4,this._view.getUint32(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint64(){try{return this.read(8,this._view.getBigUint64(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readFloat16(){let bytes=this.readUint16(),s=(bytes&32768)>>15,e=(bytes&31744)>>10,f2=bytes&1023;return e===0?(s?-1:1)*2**-14*(f2/2**10):e===31?f2?Number.NaN:(s?-1:1)*Number.POSITIVE_INFINITY:(s?-1:1)*2**(e-15)*(1+f2/2**10)}readFloat32(){try{return this.read(4,this._view.getFloat32(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readFloat64(){try{return this.read(8,this._view.getFloat64(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readBytes(amount){let available=this._byte.length-this._pos;if(available>5;if(major<0||major>7)throw new CborInvalidMajorError("Received invalid major type");return[major,byte&31]}readMajorLength(length){if(length<=23)return length;switch(length){case 24:return this.readUint8();case 25:return this.readUint16();case 26:return this.readUint32();case 27:{let read=this.readUint64();return read>9007199254740992?read:Number(read)}}throw new CborRangeError("Expected a final length")}};function infiniteBytes(r,forMajor){let w=new Writer;for(;;){let[major,len]=r.readMajor();if(major===7&&len===31)break;if(major!==forMajor)throw new CborInvalidMajorError(`Expected a resource of the same major (${forMajor}) while processing an infinite resource`);if(len===31)throw new CborRangeError("Expected a finite resource while processing an infinite resource");w.writeUint8Array(r.readBytes(Number(r.readMajorLength(len))))}return w.buffer}var textDecoder;function decode(input,options={}){let r=input instanceof Reader?input:new Reader(input);function inner(){let[major,len]=r.readMajor();switch(major){case 0:return r.readMajorLength(len);case 1:{let l=r.readMajorLength(len);return typeof l=="bigint"?-(l+1n):-(l+1)}case 2:return len===31?infiniteBytes(r,2):r.readBytes(Number(r.readMajorLength(len))).buffer;case 3:{let encoded=len===31?infiniteBytes(r,3):r.readBytes(Number(r.readMajorLength(len)));return textDecoder??=new TextDecoder,textDecoder.decode(encoded)}case 4:{if(len===31){let arr2=[];for(;;)try{arr2.push(decode2())}catch(e){if(e instanceof CborBreak)break;throw e}return arr2}let l=r.readMajorLength(len),arr=Array(l);for(let i=0;i(map.set(size,unit),map),new Map),durationPartRegex=new RegExp(`^(\\d+)(${Array.from(units.keys()).join("|")})`),Duration=class _Duration{_milliseconds;constructor(input){input instanceof _Duration?this._milliseconds=input._milliseconds:typeof input=="string"?this._milliseconds=_Duration.parseString(input):this._milliseconds=input}static fromCompact([s,ns]){s=s??0,ns=ns??0;let ms=s*1e3+ns/1e6;return new _Duration(ms)}toCompact(){let s=Math.floor(this._milliseconds/1e3),ns=Math.floor((this._milliseconds-s*1e3)*1e6);return ns>0?[s,ns]:s>0?[s]:[]}toString(){let left=this._milliseconds,result="";function scrap(size){let num=Math.floor(left/size);return num>0&&(left=left%size),num}for(let[size,unit]of Array.from(unitsReverse).reverse()){let scrapped=scrap(size);scrapped>0&&(result+=`${scrapped}${unit}`)}return result}toJSON(){return this.toString()}static parseString(input){let ms=0,left=input;for(;left!=="";){let match=left.match(durationPartRegex);if(match){let amount=Number.parseInt(match[1]),factor=units.get(match[2]);if(factor===void 0)throw new SurrealDbError(`Invalid duration unit: ${match[2]}`);ms+=amount*factor,left=left.slice(match[0].length);continue}throw new SurrealDbError("Could not match a next duration part")}return ms}static nanoseconds(nanoseconds){return new _Duration(Math.floor(nanoseconds*nanosecond))}static microseconds(microseconds){return new _Duration(Math.floor(microseconds*microsecond))}static milliseconds(milliseconds){return new _Duration(milliseconds)}static seconds(seconds){return new _Duration(seconds*second)}static minutes(minutes){return new _Duration(minutes*minute)}static hours(hours){return new _Duration(hours*hour)}static days(days){return new _Duration(days*day)}static weeks(weeks){return new _Duration(weeks*week)}get microseconds(){return Math.floor(this._milliseconds/microsecond)}get nanoseconds(){return Math.floor(this._milliseconds/nanosecond)}get milliseconds(){return Math.floor(this._milliseconds)}get seconds(){return Math.floor(this._milliseconds/second)}get minutes(){return Math.floor(this._milliseconds/minute)}get hours(){return Math.floor(this._milliseconds/hour)}get days(){return Math.floor(this._milliseconds/day)}get weeks(){return Math.floor(this._milliseconds/week)}},Geometry=class{};function f(num){return num instanceof Decimal?Number.parseFloat(num.decimal):num}var GeometryPoint=class _GeometryPoint extends Geometry{point;constructor(point){super(),point instanceof _GeometryPoint?this.point=point.clone().point:this.point=[f(point[0]),f(point[1])]}toJSON(){return{type:"Point",coordinates:this.coordinates}}get coordinates(){return this.point}is(geometry){return geometry instanceof _GeometryPoint?this.point[0]===geometry.point[0]&&this.point[1]===geometry.point[1]:!1}clone(){return new _GeometryPoint([...this.point])}},GeometryLine=class _GeometryLine extends Geometry{line;constructor(line){super(),this.line=line instanceof _GeometryLine?line.clone().line:line}toJSON(){return{type:"LineString",coordinates:this.coordinates}}get coordinates(){return this.line.map(g=>g.coordinates)}close(){this.line[0].is(this.line.at(-1))||this.line.push(this.line[0])}is(geometry){if(!(geometry instanceof _GeometryLine)||this.line.length!==geometry.line.length)return!1;for(let i=0;ip.clone()))}},GeometryPolygon=class _GeometryPolygon extends Geometry{polygon;constructor(polygon){super(),this.polygon=polygon instanceof _GeometryPolygon?polygon.clone().polygon:polygon.map(l=>{let line=l.clone();return line.close(),line})}toJSON(){return{type:"Polygon",coordinates:this.coordinates}}get coordinates(){return this.polygon.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryPolygon)||this.polygon.length!==geometry.polygon.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiPoint=class _GeometryMultiPoint extends Geometry{points;constructor(points){super(),this.points=points instanceof _GeometryMultiPoint?points.points:points}toJSON(){return{type:"MultiPoint",coordinates:this.coordinates}}get coordinates(){return this.points.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiPoint)||this.points.length!==geometry.points.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiLine=class _GeometryMultiLine extends Geometry{lines;constructor(lines){super(),this.lines=lines instanceof _GeometryMultiLine?lines.lines:lines}toJSON(){return{type:"MultiLineString",coordinates:this.coordinates}}get coordinates(){return this.lines.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiLine)||this.lines.length!==geometry.lines.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiPolygon=class _GeometryMultiPolygon extends Geometry{polygons;constructor(polygons){super(),this.polygons=polygons instanceof _GeometryMultiPolygon?polygons.polygons:polygons}toJSON(){return{type:"MultiPolygon",coordinates:this.coordinates}}get coordinates(){return this.polygons.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiPolygon)||this.polygons.length!==geometry.polygons.length)return!1;for(let i=0;ip.clone()))}},GeometryCollection=class _GeometryCollection extends Geometry{collection;constructor(collection){super(),this.collection=collection instanceof _GeometryCollection?collection.collection:collection}toJSON(){return{type:"GeometryCollection",geometries:this.geometries}}get geometries(){return this.collection.map(g=>g.toJSON())}is(geometry){if(!(geometry instanceof _GeometryCollection)||this.collection.length!==geometry.collection.length)return!1;for(let i=0;ip.clone()))}},MAX_i64=9223372036854775807n,RecordId=class{tb;id;constructor(tb,id2){if(typeof tb!="string")throw new SurrealDbError("TB part is not valid");if(!isValidIsPart(id2))throw new SurrealDbError("ID part is not valid");this.tb=tb,this.id=id2}toJSON(){return this.toString()}toString(){let tb=escape_ident(this.tb),id2=typeof this.id=="string"?escape_ident(this.id):typeof this.id=="bigint"||typeof this.id=="number"?escape_number(this.id):JSON.stringify(this.id);return`${tb}:${id2}`}},StringRecordId=class{rid;constructor(rid){if(typeof rid!="string")throw new SurrealDbError("String Record ID must be a string");this.rid=rid}toJSON(){return this.rid}toString(){return this.rid}};function escape_number(num){return num<=MAX_i64?num.toString():`\u27E8${num}\u27E9`}function escape_ident(str){if(isOnlyNumbers(str))return`\u27E8${str}\u27E9`;let code,i,len;for(i=0,len=str.length;i47&&code<58)&&!(code>64&&code<91)&&!(code>96&&code<123)&&code!==95)return`\u27E8${str.replaceAll("\u27E9","\u27E9")}\u27E9`;return str}function isOnlyNumbers(str){let parsed=Number.parseInt(str);return!Number.isNaN(parsed)&&parsed.toString()===str}function isValidIsPart(v){switch(typeof v){case"string":case"number":case"bigint":return!0;case"object":return Array.isArray(v)||v!==null;default:return!1}}var Table=class{tb;constructor(tb){if(typeof tb!="string")throw new SurrealDbError("Table must be a string");this.tb=tb}toJSON(){return this.tb}toString(){return this.tb}},Uuid=class _Uuid{inner;constructor(uuid){uuid instanceof ArrayBuffer?this.inner=UUID.ofInner(new Uint8Array(uuid)):uuid instanceof Uint8Array?this.inner=UUID.ofInner(uuid):uuid instanceof _Uuid?this.inner=uuid.inner:uuid instanceof UUID?this.inner=uuid:this.inner=UUID.parse(uuid)}toString(){return this.inner.toString()}toJSON(){return this.inner.toString()}toUint8Array(){return this.inner.bytes}toBuffer(){return this.inner.bytes.buffer}static v4(){return new _Uuid(uuidv4obj())}static v7(){return new _Uuid(uuidv7obj())}},TAG_SPEC_DATETIME=0,TAG_SPEC_UUID=37,TAG_NONE=6,TAG_TABLE=7,TAG_RECORDID=8,TAG_STRING_UUID=9,TAG_STRING_DECIMAL=10,TAG_CUSTOM_DATETIME=12,TAG_STRING_DURATION=13,TAG_CUSTOM_DURATION=14,TAG_GEOMETRY_POINT=88,TAG_GEOMETRY_LINE=89,TAG_GEOMETRY_POLYGON=90,TAG_GEOMETRY_MULTIPOINT=91,TAG_GEOMETRY_MULTILINE=92,TAG_GEOMETRY_MULTIPOLYGON=93,TAG_GEOMETRY_COLLECTION=94,replacer={encode(v){return v instanceof Date?new Tagged(TAG_CUSTOM_DATETIME,dateToCborCustomDate(v)):v===void 0?new Tagged(TAG_NONE,null):v instanceof Uuid?new Tagged(TAG_SPEC_UUID,v.toBuffer()):v instanceof Decimal?new Tagged(TAG_STRING_DECIMAL,v.toString()):v instanceof Duration?new Tagged(TAG_CUSTOM_DURATION,v.toCompact()):v instanceof RecordId?new Tagged(TAG_RECORDID,[v.tb,v.id]):v instanceof StringRecordId?new Tagged(TAG_RECORDID,v.rid):v instanceof Table?new Tagged(TAG_TABLE,v.tb):v instanceof GeometryPoint?new Tagged(TAG_GEOMETRY_POINT,v.point):v instanceof GeometryLine?new Tagged(TAG_GEOMETRY_LINE,v.line):v instanceof GeometryPolygon?new Tagged(TAG_GEOMETRY_POLYGON,v.polygon):v instanceof GeometryMultiPoint?new Tagged(TAG_GEOMETRY_MULTIPOINT,v.points):v instanceof GeometryMultiLine?new Tagged(TAG_GEOMETRY_MULTILINE,v.lines):v instanceof GeometryMultiPolygon?new Tagged(TAG_GEOMETRY_MULTIPOLYGON,v.polygons):v instanceof GeometryCollection?new Tagged(TAG_GEOMETRY_COLLECTION,v.collection):v},decode(v){if(!(v instanceof Tagged))return v;switch(v.tag){case TAG_SPEC_DATETIME:return new Date(v.value);case TAG_SPEC_UUID:case TAG_STRING_UUID:return new Uuid(v.value);case TAG_CUSTOM_DATETIME:return cborCustomDateToDate(v.value);case TAG_NONE:return;case TAG_STRING_DECIMAL:return new Decimal(v.value);case TAG_STRING_DURATION:return new Duration(v.value);case TAG_CUSTOM_DURATION:return Duration.fromCompact(v.value);case TAG_TABLE:return new Table(v.value);case TAG_RECORDID:return new RecordId(v.value[0],v.value[1]);case TAG_GEOMETRY_POINT:return new GeometryPoint(v.value);case TAG_GEOMETRY_LINE:return new GeometryLine(v.value);case TAG_GEOMETRY_POLYGON:return new GeometryPolygon(v.value);case TAG_GEOMETRY_MULTIPOINT:return new GeometryMultiPoint(v.value);case TAG_GEOMETRY_MULTILINE:return new GeometryMultiLine(v.value);case TAG_GEOMETRY_MULTIPOLYGON:return new GeometryMultiPolygon(v.value);case TAG_GEOMETRY_COLLECTION:return new GeometryCollection(v.value)}}};Object.freeze(replacer);var supportedSurrealDbVersionMin="1.4.2",supportedSurrealDbVersionUntil="3.0.0",supportedSurrealDbVersionRange=`>= ${supportedSurrealDbVersionMin} < ${supportedSurrealDbVersionUntil}`;var id=0;function getIncrementalID(){return id=(id+1)%Number.MAX_SAFE_INTEGER,id.toString()}var ConnectionStatus=(ConnectionStatus2=>(ConnectionStatus2.Disconnected="disconnected",ConnectionStatus2.Connecting="connecting",ConnectionStatus2.Connected="connected",ConnectionStatus2.Error="error",ConnectionStatus2))(ConnectionStatus||{});var AbstractEngine=class{context;ready;status="disconnected";connection={url:void 0,namespace:void 0,database:void 0,token:void 0};constructor(context){this.context=context}get emitter(){return this.context.emitter}get encodeCbor(){return this.context.encodeCbor}get decodeCbor(){return this.context.decodeCbor}};function surrealdbWasmEngines(opts){class WasmEmbeddedEngine extends AbstractEngine{ready=void 0;reader;status=ConnectionStatus.Disconnected;db;async version(){return SurrealWasmEngine.version()}setStatus(status,...args){this.status=status,this.emitter.emit(status,args)}async connect(url){this.connection.url=url,this.setStatus(ConnectionStatus.Connecting);let ready=(async(resolve,reject)=>{let db=await SurrealWasmEngine.connect(url.toString(),opts).catch(e=>{console.log(e);let error=new UnexpectedConnectionError(typeof e=="string"?e:"error"in e?e.error:"An unexpected error occurred");throw this.setStatus(ConnectionStatus.Error,error),e});this.db=db,this.setStatus(ConnectionStatus.Connected),this.reader=(async()=>{let reader=db.notifications().getReader();for(;this.connected;){let{done,value}=await reader.read();if(done)break;let raw=value,{id:id2,action,result}=this.decodeCbor(raw.buffer);id2&&this.emitter.emit(`live-${id2.toString()}`,[action,result],!0)}})()})();return this.ready=ready,await ready}async disconnect(){this.connection={url:void 0,namespace:void 0,database:void 0,token:void 0},await this.ready,this.ready=void 0,this.db?.free(),this.db=void 0,await this.reader,this.reader=void 0,this.status!==ConnectionStatus.Disconnected&&this.setStatus(ConnectionStatus.Disconnected)}async rpc(request){if(await this.ready,!this.db)throw new ConnectionUnavailable;let id2=getIncrementalID(),res=await this.db.execute(new Uint8Array(this.encodeCbor({id:id2,...request}))).then(raw=>({result:this.decodeCbor(raw.buffer)})).catch(message=>({error:{code:-1,message}}));if("result"in res)switch(request.method){case"use":{this.connection.namespace=request.params?.[0],this.connection.database=request.params?.[1];break}case"signin":case"signup":{this.connection.token=res.result;break}case"authenticate":{this.connection.token=request.params?.[0];break}case"invalidate":{this.connection.token=void 0;break}}return res}get connected(){return!!this.db}}return{mem:WasmEmbeddedEngine,indxdb:WasmEmbeddedEngine}}export{surrealdbWasmEngines}; -/*! Bundled license information: - -uuidv7/dist/index.js: - (** - * uuidv7: A JavaScript implementation of UUID version 7 - * - * @license Apache-2.0 - * @copyright 2021-2024 LiosK - * @packageDocumentation - *) -*/ diff --git a/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index.bundled.js b/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index.bundled.js new file mode 100644 index 0000000..c9c0925 --- /dev/null +++ b/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index.bundled.js @@ -0,0 +1,14 @@ +var Deno=globalThis.Deno??(typeof global>"u"?void 0:{readFile:(await import("node:fs")).readFileSync}),module=await(async()=>{let crypto2=globalThis.crypto??await import("node:crypto");return{require:string=>{if(string!=="crypto")throw new Error("Unexpected require "+string);return crypto2}}})(),heap=new Array(128).fill(void 0);heap.push(void 0,null,!0,!1);function getObject(idx){return heap[idx]}var cachedTextDecoder=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&cachedTextDecoder.decode();var cachedUint8ArrayMemory0=null;function getUint8ArrayMemory0(){return(cachedUint8ArrayMemory0===null||cachedUint8ArrayMemory0.byteLength===0)&&(cachedUint8ArrayMemory0=new Uint8Array(wasm.memory.buffer)),cachedUint8ArrayMemory0}function getStringFromWasm0(ptr,len){return ptr=ptr>>>0,cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr,ptr+len))}var heap_next=heap.length;function addHeapObject(obj){heap_next===heap.length&&heap.push(heap.length+1);let idx=heap_next;return heap_next=heap[idx],heap[idx]=obj,idx}function dropObject(idx){idx<132||(heap[idx]=heap_next,heap_next=idx)}function takeObject(idx){let ret=getObject(idx);return dropObject(idx),ret}function isLikeNone(x){return x==null}var cachedDataViewMemory0=null;function getDataViewMemory0(){return(cachedDataViewMemory0===null||cachedDataViewMemory0.buffer.detached===!0||cachedDataViewMemory0.buffer.detached===void 0&&cachedDataViewMemory0.buffer!==wasm.memory.buffer)&&(cachedDataViewMemory0=new DataView(wasm.memory.buffer)),cachedDataViewMemory0}var WASM_VECTOR_LEN=0,cachedTextEncoder=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},encodeString=function(arg,view){return cachedTextEncoder.encodeInto(arg,view)};function passStringToWasm0(arg,malloc,realloc){if(realloc===void 0){let buf=cachedTextEncoder.encode(arg),ptr2=malloc(buf.length,1)>>>0;return getUint8ArrayMemory0().subarray(ptr2,ptr2+buf.length).set(buf),WASM_VECTOR_LEN=buf.length,ptr2}let len=arg.length,ptr=malloc(len,1)>>>0,mem=getUint8ArrayMemory0(),offset=0;for(;offset127)break;mem[ptr+offset]=code}if(offset!==len){offset!==0&&(arg=arg.slice(offset)),ptr=realloc(ptr,len,len=offset+arg.length*3,1)>>>0;let view=getUint8ArrayMemory0().subarray(ptr+offset,ptr+len),ret=encodeString(arg,view);offset+=ret.written,ptr=realloc(ptr,len,offset,1)>>>0}return WASM_VECTOR_LEN=offset,ptr}function debugString(val){let type=typeof val;if(type=="number"||type=="boolean"||val==null)return`${val}`;if(type=="string")return`"${val}"`;if(type=="symbol"){let description=val.description;return description==null?"Symbol":`Symbol(${description})`}if(type=="function"){let name=val.name;return typeof name=="string"&&name.length>0?`Function(${name})`:"Function"}if(Array.isArray(val)){let length=val.length,debug="[";length>0&&(debug+=debugString(val[0]));for(let i=1;i1)className=builtInMatches[1];else return toString.call(val);if(className=="Object")try{return"Object("+JSON.stringify(val)+")"}catch{return"Object"}return val instanceof Error?`${val.name}: ${val.message} +${val.stack}`:className}var CLOSURE_DTORS=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(state=>{wasm.__wbindgen_export_2.get(state.dtor)(state.a,state.b)});function makeMutClosure(arg0,arg1,dtor,f2){let state={a:arg0,b:arg1,cnt:1,dtor},real=(...args)=>{state.cnt++;let a=state.a;state.a=0;try{return f2(a,state.b,...args)}finally{--state.cnt===0?(wasm.__wbindgen_export_2.get(state.dtor)(a,state.b),CLOSURE_DTORS.unregister(state)):state.a=a}};return real.original=state,CLOSURE_DTORS.register(real,state,state),real}function __wbg_adapter_52(arg0,arg1,arg2){try{let retptr=wasm.__wbindgen_add_to_stack_pointer(-16);wasm.__wbindgen_export_3(retptr,arg0,arg1,addHeapObject(arg2));var r0=getDataViewMemory0().getInt32(retptr+4*0,!0),r1=getDataViewMemory0().getInt32(retptr+4*1,!0);if(r1)throw takeObject(r0)}finally{wasm.__wbindgen_add_to_stack_pointer(16)}}function __wbg_adapter_55(arg0,arg1){wasm.__wbindgen_export_4(arg0,arg1)}function __wbg_adapter_58(arg0,arg1,arg2){wasm.__wbindgen_export_5(arg0,arg1,addHeapObject(arg2))}function handleError(f2,args){try{return f2.apply(this,args)}catch(e){wasm.__wbindgen_export_7(addHeapObject(e))}}function __wbg_adapter_327(arg0,arg1,arg2,arg3){wasm.__wbindgen_export_8(arg0,arg1,addHeapObject(arg2),addHeapObject(arg3))}var IntoUnderlyingByteSourceFinalization=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(ptr=>wasm.__wbg_intounderlyingbytesource_free(ptr>>>0,1));var IntoUnderlyingSinkFinalization=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(ptr=>wasm.__wbg_intounderlyingsink_free(ptr>>>0,1));var IntoUnderlyingSourceFinalization=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(ptr=>wasm.__wbg_intounderlyingsource_free(ptr>>>0,1)),IntoUnderlyingSource=class{static __wrap(ptr){ptr=ptr>>>0;let obj=Object.create(IntoUnderlyingSource.prototype);return obj.__wbg_ptr=ptr,IntoUnderlyingSourceFinalization.register(obj,obj.__wbg_ptr,obj),obj}__destroy_into_raw(){let ptr=this.__wbg_ptr;return this.__wbg_ptr=0,IntoUnderlyingSourceFinalization.unregister(this),ptr}free(){let ptr=this.__destroy_into_raw();wasm.__wbg_intounderlyingsource_free(ptr,0)}pull(controller){let ret=wasm.intounderlyingsource_pull(this.__wbg_ptr,addHeapObject(controller));return takeObject(ret)}cancel(){let ptr=this.__destroy_into_raw();wasm.intounderlyingsource_cancel(ptr)}},SurrealWasmEngineFinalization=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(ptr=>wasm.__wbg_surrealwasmengine_free(ptr>>>0,1)),SurrealWasmEngine=class{static __wrap(ptr){ptr=ptr>>>0;let obj=Object.create(SurrealWasmEngine.prototype);return obj.__wbg_ptr=ptr,SurrealWasmEngineFinalization.register(obj,obj.__wbg_ptr,obj),obj}__destroy_into_raw(){let ptr=this.__wbg_ptr;return this.__wbg_ptr=0,SurrealWasmEngineFinalization.unregister(this),ptr}free(){let ptr=this.__destroy_into_raw();wasm.__wbg_surrealwasmengine_free(ptr,0)}execute(data){let ret=wasm.surrealwasmengine_execute(this.__wbg_ptr,addHeapObject(data));return takeObject(ret)}notifications(){try{let retptr=wasm.__wbindgen_add_to_stack_pointer(-16);wasm.surrealwasmengine_notifications(retptr,this.__wbg_ptr);var r0=getDataViewMemory0().getInt32(retptr+4*0,!0),r1=getDataViewMemory0().getInt32(retptr+4*1,!0),r2=getDataViewMemory0().getInt32(retptr+4*2,!0);if(r2)throw takeObject(r1);return takeObject(r0)}finally{wasm.__wbindgen_add_to_stack_pointer(16)}}static connect(endpoint,opts){let ptr0=passStringToWasm0(endpoint,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len0=WASM_VECTOR_LEN,ret=wasm.surrealwasmengine_connect(ptr0,len0,isLikeNone(opts)?0:addHeapObject(opts));return takeObject(ret)}static version(){let deferred2_0,deferred2_1;try{let retptr=wasm.__wbindgen_add_to_stack_pointer(-16);wasm.surrealwasmengine_version(retptr);var r0=getDataViewMemory0().getInt32(retptr+4*0,!0),r1=getDataViewMemory0().getInt32(retptr+4*1,!0),r2=getDataViewMemory0().getInt32(retptr+4*2,!0),r3=getDataViewMemory0().getInt32(retptr+4*3,!0),ptr1=r0,len1=r1;if(r3)throw ptr1=0,len1=0,takeObject(r2);return deferred2_0=ptr1,deferred2_1=len1,getStringFromWasm0(ptr1,len1)}finally{wasm.__wbindgen_add_to_stack_pointer(16),wasm.__wbindgen_export_6(deferred2_0,deferred2_1,1)}}},imports={__wbindgen_placeholder__:{__wbindgen_is_undefined:function(arg0){return getObject(arg0)===void 0},__wbindgen_in:function(arg0,arg1){return getObject(arg0)in getObject(arg1)},__wbindgen_boolean_get:function(arg0){let v=getObject(arg0);return typeof v=="boolean"?v?1:0:2},__wbindgen_is_object:function(arg0){let val=getObject(arg0);return typeof val=="object"&&val!==null},__wbindgen_error_new:function(arg0,arg1){let ret=new Error(getStringFromWasm0(arg0,arg1));return addHeapObject(ret)},__wbindgen_jsval_eq:function(arg0,arg1){return getObject(arg0)===getObject(arg1)},__wbindgen_object_drop_ref:function(arg0){takeObject(arg0)},__wbindgen_string_new:function(arg0,arg1){let ret=getStringFromWasm0(arg0,arg1);return addHeapObject(ret)},__wbindgen_is_bigint:function(arg0){return typeof getObject(arg0)=="bigint"},__wbindgen_number_get:function(arg0,arg1){let obj=getObject(arg1),ret=typeof obj=="number"?obj:void 0;getDataViewMemory0().setFloat64(arg0+8*1,isLikeNone(ret)?0:ret,!0),getDataViewMemory0().setInt32(arg0+4*0,!isLikeNone(ret),!0)},__wbindgen_bigint_from_i64:function(arg0){return addHeapObject(arg0)},__wbindgen_string_get:function(arg0,arg1){let obj=getObject(arg1),ret=typeof obj=="string"?obj:void 0;var ptr1=isLikeNone(ret)?0:passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(arg0+4*1,len1,!0),getDataViewMemory0().setInt32(arg0+4*0,ptr1,!0)},__wbindgen_bigint_from_u64:function(arg0){let ret=BigInt.asUintN(64,arg0);return addHeapObject(ret)},__wbg_surrealwasmengine_new:function(arg0){let ret=SurrealWasmEngine.__wrap(arg0);return addHeapObject(ret)},__wbindgen_object_clone_ref:function(arg0){let ret=getObject(arg0);return addHeapObject(ret)},__wbindgen_jsval_loose_eq:function(arg0,arg1){return getObject(arg0)==getObject(arg1)},__wbindgen_as_number:function(arg0){return+getObject(arg0)},__wbg_String_b9412f8799faab3e:function(arg0,arg1){let ret=String(getObject(arg1)),ptr1=passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(arg0+4*1,len1,!0),getDataViewMemory0().setInt32(arg0+4*0,ptr1,!0)},__wbindgen_number_new:function(arg0){return addHeapObject(arg0)},__wbg_getwithrefkey_edc2c8960f0f1191:function(arg0,arg1){let ret=getObject(arg0)[getObject(arg1)];return addHeapObject(ret)},__wbindgen_cb_drop:function(arg0){let obj=takeObject(arg0).original;return obj.cnt--==1?(obj.a=0,!0):!1},__wbindgen_is_falsy:function(arg0){return!getObject(arg0)},__wbg_new_abda76e883ba8a5f:function(){let ret=new Error;return addHeapObject(ret)},__wbg_stack_658279fe44541cf6:function(arg0,arg1){let ret=getObject(arg1).stack,ptr1=passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(arg0+4*1,len1,!0),getDataViewMemory0().setInt32(arg0+4*0,ptr1,!0)},__wbg_error_f851667af71bcfc6:function(arg0,arg1){let deferred0_0,deferred0_1;try{deferred0_0=arg0,deferred0_1=arg1,console.error(getStringFromWasm0(arg0,arg1))}finally{wasm.__wbindgen_export_6(deferred0_0,deferred0_1,1)}},__wbg_performance_1430613edb72ce03:function(arg0){let ret=getObject(arg0).performance;return addHeapObject(ret)},__wbg_now_eab901b1d3b8a295:function(arg0){return getObject(arg0).now()},__wbg_setTimeout_fba1b48a90e30862:function(){return handleError(function(arg0,arg1,arg2){return getObject(arg0).setTimeout(getObject(arg1),arg2)},arguments)},__wbg_fetch_25e3a297f7b04639:function(arg0){let ret=fetch(getObject(arg0));return addHeapObject(ret)},__wbg_sethighWaterMark_ea50ed3ec2143088:function(arg0,arg1){getObject(arg0).highWaterMark=arg1},__wbg_newwithintounderlyingsource_a03a82aa1bbbb292:function(arg0,arg1){let ret=new ReadableStream(IntoUnderlyingSource.__wrap(arg0),takeObject(arg1));return addHeapObject(ret)},__wbg_queueMicrotask_48421b3cc9052b68:function(arg0){let ret=getObject(arg0).queueMicrotask;return addHeapObject(ret)},__wbindgen_is_function:function(arg0){return typeof getObject(arg0)=="function"},__wbg_queueMicrotask_12a30234db4045d3:function(arg0){queueMicrotask(getObject(arg0))},__wbg_signal_41e46ccad44bb5e2:function(arg0){let ret=getObject(arg0).signal;return addHeapObject(ret)},__wbg_new_ebf2727385ee825c:function(){return handleError(function(){let ret=new AbortController;return addHeapObject(ret)},arguments)},__wbg_abort_8659d889a7877ae3:function(arg0){getObject(arg0).abort()},__wbg_newwithu8arraysequenceandoptions_c8bc456a23f02fca:function(){return handleError(function(arg0,arg1){let ret=new Blob(getObject(arg0),getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_settype_b6ab7b74bd1908a1:function(arg0,arg1,arg2){getObject(arg0).type=getStringFromWasm0(arg1,arg2)},__wbg_length_82021578cc4f0d2c:function(arg0){return getObject(arg0).length},__wbg_contains_a3146787308ac83e:function(arg0,arg1,arg2){return getObject(arg0).contains(getStringFromWasm0(arg1,arg2))},__wbg_get_913f8df8566b2d82:function(arg0,arg1,arg2){let ret=getObject(arg1)[arg2>>>0];var ptr1=isLikeNone(ret)?0:passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(arg0+4*1,len1,!0),getDataViewMemory0().setInt32(arg0+4*0,ptr1,!0)},__wbg_target_b7cb1739bee70928:function(arg0){let ret=getObject(arg0).target;return isLikeNone(ret)?0:addHeapObject(ret)},__wbg_new_f9f1d655d855a601:function(){return handleError(function(){let ret=new FormData;return addHeapObject(ret)},arguments)},__wbg_append_876bddfd2c8b42fb:function(){return handleError(function(arg0,arg1,arg2,arg3){getObject(arg0).append(getStringFromWasm0(arg1,arg2),getObject(arg3))},arguments)},__wbg_append_fc486ec9757bf1c1:function(){return handleError(function(arg0,arg1,arg2,arg3,arg4,arg5){getObject(arg0).append(getStringFromWasm0(arg1,arg2),getObject(arg3),getStringFromWasm0(arg4,arg5))},arguments)},__wbg_append_b10805b72af15312:function(){return handleError(function(arg0,arg1,arg2,arg3,arg4){getObject(arg0).append(getStringFromWasm0(arg1,arg2),getStringFromWasm0(arg3,arg4))},arguments)},__wbg_new_e27c93803e1acc42:function(){return handleError(function(){let ret=new Headers;return addHeapObject(ret)},arguments)},__wbg_append_f3a4426bb50622c5:function(){return handleError(function(arg0,arg1,arg2,arg3,arg4){getObject(arg0).append(getStringFromWasm0(arg1,arg2),getStringFromWasm0(arg3,arg4))},arguments)},__wbg_key_37c613728ba0b769:function(){return handleError(function(arg0){let ret=getObject(arg0).key;return addHeapObject(ret)},arguments)},__wbg_advance_0922866a23942467:function(){return handleError(function(arg0,arg1){getObject(arg0).advance(arg1>>>0)},arguments)},__wbg_continue_a92b4c9f17458897:function(){return handleError(function(arg0){getObject(arg0).continue()},arguments)},__wbg_value_d4be628e515b251f:function(){return handleError(function(arg0){let ret=getObject(arg0).value;return addHeapObject(ret)},arguments)},__wbg_objectStoreNames_2fc72464aff4baed:function(arg0){let ret=getObject(arg0).objectStoreNames;return addHeapObject(ret)},__wbg_createObjectStore_cfb780710dbc3ad2:function(){return handleError(function(arg0,arg1,arg2,arg3){let ret=getObject(arg0).createObjectStore(getStringFromWasm0(arg1,arg2),getObject(arg3));return addHeapObject(ret)},arguments)},__wbg_deleteObjectStore_745da9b507613eca:function(){return handleError(function(arg0,arg1,arg2){getObject(arg0).deleteObjectStore(getStringFromWasm0(arg1,arg2))},arguments)},__wbg_transaction_66168ca19ab39a78:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).transaction(getObject(arg1),["readonly","readwrite","versionchange","readwriteflush","cleanup"][arg2]);return addHeapObject(ret)},arguments)},__wbg_instanceof_IdbFactory_9c1359c26643add1:function(arg0){let result;try{result=getObject(arg0)instanceof IDBFactory}catch{result=!1}return result},__wbg_open_a89af1720976a433:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).open(getStringFromWasm0(arg1,arg2));return addHeapObject(ret)},arguments)},__wbg_open_e8f45f3526088828:function(){return handleError(function(arg0,arg1,arg2,arg3){let ret=getObject(arg0).open(getStringFromWasm0(arg1,arg2),arg3>>>0);return addHeapObject(ret)},arguments)},__wbg_setmultientry_a4c0f50fb1bb8977:function(arg0,arg1){getObject(arg0).multiEntry=arg1!==0},__wbg_setunique_6f46c3f803001492:function(arg0,arg1){getObject(arg0).unique=arg1!==0},__wbg_bound_f24ae26594f11d12:function(){return handleError(function(arg0,arg1,arg2,arg3){let ret=IDBKeyRange.bound(getObject(arg0),getObject(arg1),arg2!==0,arg3!==0);return addHeapObject(ret)},arguments)},__wbg_indexNames_f6708f233630e491:function(arg0){let ret=getObject(arg0).indexNames;return addHeapObject(ret)},__wbg_add_534cfd1b901a15b4:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).add(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_add_4d2791d6295ba9ec:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).add(getObject(arg1),getObject(arg2));return addHeapObject(ret)},arguments)},__wbg_createIndex_6d4c3e20ee0f1066:function(){return handleError(function(arg0,arg1,arg2,arg3,arg4){let ret=getObject(arg0).createIndex(getStringFromWasm0(arg1,arg2),getObject(arg3),getObject(arg4));return addHeapObject(ret)},arguments)},__wbg_delete_34764ece57bdc720:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).delete(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_deleteIndex_86b1a90a771f3fd2:function(){return handleError(function(arg0,arg1,arg2){getObject(arg0).deleteIndex(getStringFromWasm0(arg1,arg2))},arguments)},__wbg_get_88b5e79e9daccb9f:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).get(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_openCursor_728ede41c2e2d7ec:function(){return handleError(function(arg0){let ret=getObject(arg0).openCursor();return addHeapObject(ret)},arguments)},__wbg_openCursor_8ca06744434102da:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).openCursor(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_openCursor_3193d7a663a8bc61:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).openCursor(getObject(arg1),["next","nextunique","prev","prevunique"][arg2]);return addHeapObject(ret)},arguments)},__wbg_put_b697dfdbcfb0598f:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).put(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_put_f83d95662936dee7:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).put(getObject(arg1),getObject(arg2));return addHeapObject(ret)},arguments)},__wbg_setautoincrement_56aa89e6d3e15210:function(arg0,arg1){getObject(arg0).autoIncrement=arg1!==0},__wbg_setkeypath_e6a7c50640d3005a:function(arg0,arg1){getObject(arg0).keyPath=getObject(arg1)},__wbg_setonupgradeneeded_8f3f0ac5d7130a6f:function(arg0,arg1){getObject(arg0).onupgradeneeded=getObject(arg1)},__wbg_result_fd2dae625828961d:function(){return handleError(function(arg0){let ret=getObject(arg0).result;return addHeapObject(ret)},arguments)},__wbg_error_1221bc1f1d0b14d3:function(){return handleError(function(arg0){let ret=getObject(arg0).error;return isLikeNone(ret)?0:addHeapObject(ret)},arguments)},__wbg_transaction_0549f2d854da77a6:function(arg0){let ret=getObject(arg0).transaction;return isLikeNone(ret)?0:addHeapObject(ret)},__wbg_setonsuccess_962c293b6e38a5d5:function(arg0,arg1){getObject(arg0).onsuccess=getObject(arg1)},__wbg_setonerror_bd61d0a61808ca40:function(arg0,arg1){getObject(arg0).onerror=getObject(arg1)},__wbg_setonabort_aedc77f0151af20c:function(arg0,arg1){getObject(arg0).onabort=getObject(arg1)},__wbg_setoncomplete_a9e0ec1d6568a6d9:function(arg0,arg1){getObject(arg0).oncomplete=getObject(arg1)},__wbg_setonerror_00500154a07e987d:function(arg0,arg1){getObject(arg0).onerror=getObject(arg1)},__wbg_abort_91c8863e70a93d96:function(){return handleError(function(arg0){getObject(arg0).abort()},arguments)},__wbg_objectStore_80724f9f6d33ab5b:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).objectStore(getStringFromWasm0(arg1,arg2));return addHeapObject(ret)},arguments)},__wbg_now_a69647afb1f66247:function(arg0){return getObject(arg0).now()},__wbg_byobRequest_b32c77640da946ac:function(arg0){let ret=getObject(arg0).byobRequest;return isLikeNone(ret)?0:addHeapObject(ret)},__wbg_close_aca7442e6619206b:function(){return handleError(function(arg0){getObject(arg0).close()},arguments)},__wbg_view_2a901bda0727aeb3:function(arg0){let ret=getObject(arg0).view;return isLikeNone(ret)?0:addHeapObject(ret)},__wbg_respond_a799bab31a44f2d7:function(){return handleError(function(arg0,arg1){getObject(arg0).respond(arg1>>>0)},arguments)},__wbg_close_cef2400b120c9c73:function(){return handleError(function(arg0){getObject(arg0).close()},arguments)},__wbg_enqueue_6f3d433b5e457aea:function(){return handleError(function(arg0,arg1){getObject(arg0).enqueue(getObject(arg1))},arguments)},__wbg_newwithstrandinit_a31c69e4cc337183:function(){return handleError(function(arg0,arg1,arg2){let ret=new Request(getStringFromWasm0(arg0,arg1),getObject(arg2));return addHeapObject(ret)},arguments)},__wbg_setbody_734cb3d7ee8e6e96:function(arg0,arg1){getObject(arg0).body=getObject(arg1)},__wbg_setcredentials_2b67800db3f7b621:function(arg0,arg1){getObject(arg0).credentials=["omit","same-origin","include"][arg1]},__wbg_setheaders_be10a5ab566fd06f:function(arg0,arg1){getObject(arg0).headers=getObject(arg1)},__wbg_setmethod_dc68a742c2db5c6a:function(arg0,arg1,arg2){getObject(arg0).method=getStringFromWasm0(arg1,arg2)},__wbg_setmode_a781aae2bd3df202:function(arg0,arg1){getObject(arg0).mode=["same-origin","no-cors","cors","navigate"][arg1]},__wbg_setsignal_91c4e8ebd04eb935:function(arg0,arg1){getObject(arg0).signal=getObject(arg1)},__wbg_instanceof_Response_e91b7eb7c611a9ae:function(arg0){let result;try{result=getObject(arg0)instanceof Response}catch{result=!1}return result},__wbg_url_1bf85c8abeb8c92d:function(arg0,arg1){let ret=getObject(arg1).url,ptr1=passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(arg0+4*1,len1,!0),getDataViewMemory0().setInt32(arg0+4*0,ptr1,!0)},__wbg_status_ae8de515694c5c7c:function(arg0){return getObject(arg0).status},__wbg_headers_5e283e8345689121:function(arg0){let ret=getObject(arg0).headers;return addHeapObject(ret)},__wbg_arrayBuffer_a5fbad63cc7e663b:function(){return handleError(function(arg0){let ret=getObject(arg0).arrayBuffer();return addHeapObject(ret)},arguments)},__wbg_text_a94b91ea8700357a:function(){return handleError(function(arg0){let ret=getObject(arg0).text();return addHeapObject(ret)},arguments)},__wbg_fetch_ba7fe179e527d942:function(arg0,arg1){let ret=getObject(arg0).fetch(getObject(arg1));return addHeapObject(ret)},__wbg_now_28a6b413aca4a96a:function(){return handleError(function(){return Date.now()},arguments)},__wbg_crypto_1d1f22824a6a080c:function(arg0){let ret=getObject(arg0).crypto;return addHeapObject(ret)},__wbg_process_4a72847cc503995b:function(arg0){let ret=getObject(arg0).process;return addHeapObject(ret)},__wbg_versions_f686565e586dd935:function(arg0){let ret=getObject(arg0).versions;return addHeapObject(ret)},__wbg_node_104a2ff8d6ea03a2:function(arg0){let ret=getObject(arg0).node;return addHeapObject(ret)},__wbindgen_is_string:function(arg0){return typeof getObject(arg0)=="string"},__wbg_require_cca90b1a94a0255b:function(){return handleError(function(){let ret=module.require;return addHeapObject(ret)},arguments)},__wbg_msCrypto_eb05e62b530a1508:function(arg0){let ret=getObject(arg0).msCrypto;return addHeapObject(ret)},__wbg_randomFillSync_5c9c955aa56b6049:function(){return handleError(function(arg0,arg1){getObject(arg0).randomFillSync(takeObject(arg1))},arguments)},__wbg_getRandomValues_3aa56aa6edec874c:function(){return handleError(function(arg0,arg1){getObject(arg0).getRandomValues(getObject(arg1))},arguments)},__wbg_self_3093d5d1f7bcb682:function(){return handleError(function(){let ret=self.self;return addHeapObject(ret)},arguments)},__wbg_window_3bcfc4d31bc012f8:function(){return handleError(function(){let ret=window.window;return addHeapObject(ret)},arguments)},__wbg_globalThis_86b222e13bdf32ed:function(){return handleError(function(){let ret=globalThis.globalThis;return addHeapObject(ret)},arguments)},__wbg_global_e5a3fe56f8be9485:function(){return handleError(function(){let ret=global.global;return addHeapObject(ret)},arguments)},__wbg_newnoargs_76313bd6ff35d0f2:function(arg0,arg1){let ret=new Function(getStringFromWasm0(arg0,arg1));return addHeapObject(ret)},__wbg_length_ae22078168b726f5:function(arg0){return getObject(arg0).length},__wbg_new_a220cf903aa02ca2:function(){let ret=new Array;return addHeapObject(ret)},__wbg_next_de3e9db4440638b2:function(arg0){let ret=getObject(arg0).next;return addHeapObject(ret)},__wbg_value_6d39332ab4788d86:function(arg0){let ret=getObject(arg0).value;return addHeapObject(ret)},__wbg_iterator_888179a48810a9fe:function(){return addHeapObject(Symbol.iterator)},__wbg_new_525245e2b9901204:function(){let ret=new Object;return addHeapObject(ret)},__wbg_get_3baa728f9d58d3f6:function(arg0,arg1){let ret=getObject(arg0)[arg1>>>0];return addHeapObject(ret)},__wbg_isArray_8364a5371e9737d8:function(arg0){return Array.isArray(getObject(arg0))},__wbg_push_37c89022f34c01ca:function(arg0,arg1){return getObject(arg0).push(getObject(arg1))},__wbg_instanceof_ArrayBuffer_61dfc3198373c902:function(arg0){let result;try{result=getObject(arg0)instanceof ArrayBuffer}catch{result=!1}return result},__wbg_new_796382978dfd4fb0:function(arg0,arg1){let ret=new Error(getStringFromWasm0(arg0,arg1));return addHeapObject(ret)},__wbg_toString_9d18e102ca933e68:function(arg0){let ret=getObject(arg0).toString();return addHeapObject(ret)},__wbg_call_1084a111329e68ce:function(){return handleError(function(arg0,arg1){let ret=getObject(arg0).call(getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_call_89af060b4e1523f2:function(){return handleError(function(arg0,arg1,arg2){let ret=getObject(arg0).call(getObject(arg1),getObject(arg2));return addHeapObject(ret)},arguments)},__wbg_instanceof_Map_763ce0e95960d55e:function(arg0){let result;try{result=getObject(arg0)instanceof Map}catch{result=!1}return result},__wbg_next_f9cb570345655b9a:function(){return handleError(function(arg0){let ret=getObject(arg0).next();return addHeapObject(ret)},arguments)},__wbg_done_bfda7aa8f252b39f:function(arg0){return getObject(arg0).done},__wbg_isSafeInteger_7f1ed56200d90674:function(arg0){return Number.isSafeInteger(getObject(arg0))},__wbg_getTime_91058879093a1589:function(arg0){return getObject(arg0).getTime()},__wbg_getTimezoneOffset_c9929a3cc94500fe:function(arg0){return getObject(arg0).getTimezoneOffset()},__wbg_new_7982fb43cfca37ae:function(arg0){let ret=new Date(getObject(arg0));return addHeapObject(ret)},__wbg_new0_65387337a95cf44d:function(){return addHeapObject(new Date)},__wbg_now_b7a162010a9e75b4:function(){return Date.now()},__wbg_entries_7a0e06255456ebcd:function(arg0){let ret=Object.entries(getObject(arg0));return addHeapObject(ret)},__wbg_get_224d16597dbbfd96:function(){return handleError(function(arg0,arg1){let ret=Reflect.get(getObject(arg0),getObject(arg1));return addHeapObject(ret)},arguments)},__wbg_has_4bfbc01db38743f7:function(){return handleError(function(arg0,arg1){return Reflect.has(getObject(arg0),getObject(arg1))},arguments)},__wbg_buffer_b7b08af79b0b0974:function(arg0){let ret=getObject(arg0).buffer;return addHeapObject(ret)},__wbg_stringify_bbf45426c92a6bf5:function(){return handleError(function(arg0){let ret=JSON.stringify(getObject(arg0));return addHeapObject(ret)},arguments)},__wbg_new_b85e72ed1bfd57f9:function(arg0,arg1){try{var state0={a:arg0,b:arg1},cb0=(arg02,arg12)=>{let a=state0.a;state0.a=0;try{return __wbg_adapter_327(a,state0.b,arg02,arg12)}finally{state0.a=a}};let ret=new Promise(cb0);return addHeapObject(ret)}finally{state0.a=state0.b=0}},__wbg_resolve_570458cb99d56a43:function(arg0){let ret=Promise.resolve(getObject(arg0));return addHeapObject(ret)},__wbg_then_95e6edc0f89b73b1:function(arg0,arg1){let ret=getObject(arg0).then(getObject(arg1));return addHeapObject(ret)},__wbg_then_876bb3c633745cc6:function(arg0,arg1,arg2){let ret=getObject(arg0).then(getObject(arg1),getObject(arg2));return addHeapObject(ret)},__wbg_newwithbyteoffsetandlength_8a2cb9ca96b27ec9:function(arg0,arg1,arg2){let ret=new Uint8Array(getObject(arg0),arg1>>>0,arg2>>>0);return addHeapObject(ret)},__wbg_new_ea1883e1e5e86686:function(arg0){let ret=new Uint8Array(getObject(arg0));return addHeapObject(ret)},__wbg_instanceof_Uint8Array_247a91427532499e:function(arg0){let result;try{result=getObject(arg0)instanceof Uint8Array}catch{result=!1}return result},__wbg_newwithlength_ec548f448387c968:function(arg0){let ret=new Uint8Array(arg0>>>0);return addHeapObject(ret)},__wbg_buffer_0710d1b9dbe2eea6:function(arg0){let ret=getObject(arg0).buffer;return addHeapObject(ret)},__wbg_subarray_7c2e3576afe181d1:function(arg0,arg1,arg2){let ret=getObject(arg0).subarray(arg1>>>0,arg2>>>0);return addHeapObject(ret)},__wbg_length_8339fcf5d8ecd12e:function(arg0){return getObject(arg0).length},__wbg_byteLength_850664ef28f3e42f:function(arg0){return getObject(arg0).byteLength},__wbg_byteOffset_ea14c35fa6de38cc:function(arg0){return getObject(arg0).byteOffset},__wbg_set_d1e79e2388520f18:function(arg0,arg1,arg2){getObject(arg0).set(getObject(arg1),arg2>>>0)},__wbindgen_bigint_get_as_i64:function(arg0,arg1){let v=getObject(arg1),ret=typeof v=="bigint"?v:void 0;getDataViewMemory0().setBigInt64(arg0+8*1,isLikeNone(ret)?BigInt(0):ret,!0),getDataViewMemory0().setInt32(arg0+4*0,!isLikeNone(ret),!0)},__wbindgen_debug_string:function(arg0,arg1){let ret=debugString(getObject(arg1)),ptr1=passStringToWasm0(ret,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),len1=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(arg0+4*1,len1,!0),getDataViewMemory0().setInt32(arg0+4*0,ptr1,!0)},__wbindgen_throw:function(arg0,arg1){throw new Error(getStringFromWasm0(arg0,arg1))},__wbindgen_memory:function(){let ret=wasm.memory;return addHeapObject(ret)},__wbindgen_closure_wrapper22305:function(arg0,arg1,arg2){let ret=makeMutClosure(arg0,arg1,1798,__wbg_adapter_52);return addHeapObject(ret)},__wbindgen_closure_wrapper23690:function(arg0,arg1,arg2){let ret=makeMutClosure(arg0,arg1,1936,__wbg_adapter_55);return addHeapObject(ret)},__wbindgen_closure_wrapper28771:function(arg0,arg1,arg2){let ret=makeMutClosure(arg0,arg1,2506,__wbg_adapter_58);return addHeapObject(ret)}}},wasm_url=new URL("index_bg.wasm",import.meta.url),wasmCode="";switch(wasm_url.protocol){case"file:":wasmCode=await Deno.readFile(wasm_url);break;case"tauri:":case"https:":case"http:":wasmCode=await(await fetch(wasm_url)).arrayBuffer();break;default:throw new Error(`Unsupported protocol: ${wasm_url.protocol}`)}var wasmInstance=(await WebAssembly.instantiate(wasmCode,imports)).instance,wasm=wasmInstance.exports;var DIGITS="0123456789abcdef",UUID=class{constructor(bytes){this.bytes=bytes}static ofInner(bytes){if(bytes.length!==16)throw new TypeError("not 128-bit length");return new UUID(bytes)}static fromFieldsV7(unixTsMs,randA,randBHi,randBLo){if(!Number.isInteger(unixTsMs)||!Number.isInteger(randA)||!Number.isInteger(randBHi)||!Number.isInteger(randBLo)||unixTsMs<0||randA<0||randBHi<0||randBLo<0||unixTsMs>0xffffffffffff||randA>4095||randBHi>1073741823||randBLo>4294967295)throw new RangeError("invalid field value");let bytes=new Uint8Array(16);return bytes[0]=unixTsMs/2**40,bytes[1]=unixTsMs/2**32,bytes[2]=unixTsMs/2**24,bytes[3]=unixTsMs/2**16,bytes[4]=unixTsMs/2**8,bytes[5]=unixTsMs,bytes[6]=112|randA>>>8,bytes[7]=randA,bytes[8]=128|randBHi>>>24,bytes[9]=randBHi>>>16,bytes[10]=randBHi>>>8,bytes[11]=randBHi,bytes[12]=randBLo>>>24,bytes[13]=randBLo>>>16,bytes[14]=randBLo>>>8,bytes[15]=randBLo,new UUID(bytes)}static parse(uuid){var _a,_b,_c,_d;let hex;switch(uuid.length){case 32:hex=(_a=/^[0-9a-f]{32}$/i.exec(uuid))===null||_a===void 0?void 0:_a[0];break;case 36:hex=(_b=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid))===null||_b===void 0?void 0:_b.slice(1,6).join("");break;case 38:hex=(_c=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid))===null||_c===void 0?void 0:_c.slice(1,6).join("");break;case 45:hex=(_d=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid))===null||_d===void 0?void 0:_d.slice(1,6).join("");break;default:break}if(hex){let inner=new Uint8Array(16);for(let i=0;i<16;i+=4){let n=parseInt(hex.substring(2*i,2*i+8),16);inner[i+0]=n>>>24,inner[i+1]=n>>>16,inner[i+2]=n>>>8,inner[i+3]=n}return new UUID(inner)}else throw new SyntaxError("could not parse UUID string")}toString(){let text="";for(let i=0;i>>4),text+=DIGITS.charAt(this.bytes[i]&15),(i===3||i===5||i===7||i===9)&&(text+="-");return text}toHex(){let text="";for(let i=0;i>>4),text+=DIGITS.charAt(this.bytes[i]&15);return text}toJSON(){return this.toString()}getVariant(){let n=this.bytes[8]>>>4;if(n<0)throw new Error("unreachable");if(n<=7)return this.bytes.every(e=>e===0)?"NIL":"VAR_0";if(n<=11)return"VAR_10";if(n<=13)return"VAR_110";if(n<=15)return this.bytes.every(e=>e===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new UUID(this.bytes.slice(0))}equals(other){return this.compareTo(other)===0}compareTo(other){for(let i=0;i<16;i++){let diff=this.bytes[i]-other.bytes[i];if(diff!==0)return Math.sign(diff)}return 0}},V7Generator=class{constructor(randomNumberGenerator){this.timestamp=0,this.counter=0,this.random=randomNumberGenerator??getDefaultRandom()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(unixTsMs,rollbackAllowance){let value=this.generateOrAbortCore(unixTsMs,rollbackAllowance);return value===void 0&&(this.timestamp=0,value=this.generateOrAbortCore(unixTsMs,rollbackAllowance)),value}generateOrAbortCore(unixTsMs,rollbackAllowance){if(!Number.isInteger(unixTsMs)||unixTsMs<1||unixTsMs>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(rollbackAllowance<0||rollbackAllowance>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(unixTsMs>this.timestamp)this.timestamp=unixTsMs,this.resetCounter();else if(unixTsMs+rollbackAllowance>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return UUID.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let bytes=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return bytes[6]=64|bytes[6]>>>4,bytes[8]=128|bytes[8]>>>2,UUID.ofInner(bytes)}},getDefaultRandom=()=>{if(typeof crypto<"u"&&typeof crypto.getRandomValues<"u")return new BufferedCryptoRandom;if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");return{nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}},BufferedCryptoRandom=class{constructor(){this.buffer=new Uint32Array(8),this.cursor=65535}nextUint32(){return this.cursor>=this.buffer.length&&(crypto.getRandomValues(this.buffer),this.cursor=0),this.buffer[this.cursor++]}},defaultGenerator;var uuidv7obj=()=>(defaultGenerator||(defaultGenerator=new V7Generator)).generate();var uuidv4obj=()=>(defaultGenerator||(defaultGenerator=new V7Generator)).generateV4();var __defProp=Object.defineProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})};var cbor_exports={};__export(cbor_exports,{CborBreak:()=>CborBreak,CborError:()=>CborError,CborFillMissing:()=>CborFillMissing,CborInvalidMajorError:()=>CborInvalidMajorError,CborNumberError:()=>CborNumberError,CborPartialDisabled:()=>CborPartialDisabled,CborRangeError:()=>CborRangeError,Encoded:()=>Encoded,Gap:()=>Gap,POW_2_53:()=>POW_2_53,POW_2_64:()=>POW_2_64,PartiallyEncoded:()=>PartiallyEncoded,Reader:()=>Reader,Tagged:()=>Tagged,Writer:()=>Writer,decode:()=>decode,encode:()=>encode,infiniteBytes:()=>infiniteBytes,partiallyEncodeObject:()=>partiallyEncodeObject});var POW_2_53=9007199254740992,POW_2_64=BigInt(18446744073709552e3),Encoded=class{constructor(encoded){this.encoded=encoded}},SurrealDbError=class extends Error{};var UnexpectedConnectionError=class extends SurrealDbError{constructor(error){super(),this.error=error,this.message=`${error}`}name="UnexpectedConnectionError"};var ConnectionUnavailable=class extends SurrealDbError{name="ConnectionUnavailable";message="There is no connection available at this moment."};var CborError=class extends SurrealDbError{message;constructor(message){super(),this.message=message}},CborNumberError=class extends CborError{name="CborNumberError"},CborRangeError=class extends CborError{name="CborRangeError"},CborInvalidMajorError=class extends CborError{name="CborInvalidMajorError"},CborBreak=class extends CborError{name="CborBreak";constructor(){super("Came across a break which was not intercepted by the decoder")}},CborPartialDisabled=class extends CborError{name="CborPartialDisabled";constructor(){super("Tried to insert a Gap into a CBOR value, while partial mode is not enabled")}},CborFillMissing=class extends CborError{name="CborFillMissing";constructor(){super("Fill for a gap is missing, and gap has no default")}},Gap=class{args=[];constructor(...args){this.args=args}fill(value){return[this,value]}hasDefault(){return this.args.length===1}get default(){return this.args[0]}},Writer=class{constructor(byteLength=256){this.byteLength=byteLength,this._buf=new ArrayBuffer(this.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf)}_chunks=[];_pos=0;_buf;_view;_byte;chunk(gap){this._chunks.push([this._buf.slice(0,this._pos),gap]),this._buf=new ArrayBuffer(this.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._pos=0}get chunks(){return this._chunks}get buffer(){return this._buf.slice(0,this._pos)}claim(length){let pos=this._pos;if(this._pos+=length,this._pos<=this._buf.byteLength)return pos;let newLen=this._buf.byteLength<<1;for(;newLenthis._buf.byteLength){let oldb=this._byte;this._buf=new ArrayBuffer(newLen),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._byte.set(oldb)}return pos}writeUint8(value){let pos=this.claim(1);this._view.setUint8(pos,value)}writeUint16(value){let pos=this.claim(2);this._view.setUint16(pos,value)}writeUint32(value){let pos=this.claim(4);this._view.setUint32(pos,value)}writeUint64(value){let pos=this.claim(8);this._view.setBigUint64(pos,value)}writeUint8Array(data){if(data.byteLength===0)return;let pos=this.claim(data.byteLength);this._byte.set(data,pos)}writeArrayBuffer(data){data.byteLength!==0&&this.writeUint8Array(new Uint8Array(data))}writePartiallyEncoded(data){for(let[buf,gap]of data.chunks)this.writeArrayBuffer(buf),this.chunk(gap);this.writeArrayBuffer(data.end)}writeFloat32(value){let pos=this.claim(4);this._view.setFloat32(pos,value)}writeFloat64(value){let pos=this.claim(8);this._view.setFloat64(pos,value)}writeMajor(type,length){let base=type<<5;length<24?this.writeUint8(base+Number(length)):length<256?(this.writeUint8(base+24),this.writeUint8(Number(length))):length<65536?(this.writeUint8(base+25),this.writeUint16(Number(length))):length<4294967296?(this.writeUint8(base+26),this.writeUint32(Number(length))):(this.writeUint8(base+27),this.writeUint64(BigInt(length)))}output(partial,replacer2){return partial?new PartiallyEncoded(this._chunks,this.buffer,replacer2):this.buffer}},PartiallyEncoded=class{constructor(chunks,end,replacer2){this.chunks=chunks,this.end=end,this.replacer=replacer2}build(fills,partial){let writer=new Writer,map=new Map(fills);for(let[buffer,gap]of this.chunks){let hasValue=map.has(gap)||gap.hasDefault();if(!partial&&!hasValue)throw new CborFillMissing;if(writer.writeArrayBuffer(buffer),hasValue){let data=map.get(gap)??gap.default;encode(data,{writer,replacer:this.replacer})}else writer.chunk(gap)}return writer.writeArrayBuffer(this.end),writer.output(!!partial,this.replacer)}};function partiallyEncodeObject(object,options){return Object.fromEntries(Object.entries(object).map(([k,v])=>[k,encode(v,{...options,partial:!0})]))}var Tagged=class{constructor(tag,value){this.tag=tag,this.value=value}},textEncoder;function encode(input,options={}){let w=options.writer??new Writer,fillsMap=new Map(options.fills??[]);function inner(input2){let value=options.replacer?options.replacer(input2):input2;if(value===void 0)return w.writeUint8(247);if(value===null)return w.writeUint8(246);if(value===!0)return w.writeUint8(245);if(value===!1)return w.writeUint8(244);switch(typeof value){case"number":{if(Number.isInteger(value))if(value>=0&&value<=9007199254740992)w.writeMajor(0,value);else if(value<0&&value>=-9007199254740992)w.writeMajor(1,-(value+1));else throw new CborNumberError("Number too big to be encoded");else w.writeUint8(251),w.writeFloat64(value);return}case"bigint":{if(value>=0&&value=-POW_2_64)w.writeMajor(1,-(value+1n));else throw new CborNumberError("BigInt too big to be encoded");return}case"string":{textEncoder??=new TextEncoder;let encoded=textEncoder.encode(value);w.writeMajor(3,encoded.byteLength),w.writeUint8Array(encoded);return}default:{if(Array.isArray(value)){w.writeMajor(4,value.length);for(let v of value)inner(v);return}if(value instanceof Tagged){w.writeMajor(6,value.tag),inner(value.value);return}if(value instanceof Encoded){w.writeArrayBuffer(value.encoded);return}if(value instanceof Gap){if(fillsMap.has(value))inner(fillsMap.get(value));else{if(!options.partial)throw new CborPartialDisabled;w.chunk(value)}return}if(value instanceof PartiallyEncoded){let res=value.build(options.fills??[],options.partial);options.partial?w.writePartiallyEncoded(res):w.writeArrayBuffer(res);return}if(value instanceof Uint8Array||value instanceof Uint16Array||value instanceof Uint32Array||value instanceof Int8Array||value instanceof Int16Array||value instanceof Int32Array||value instanceof Float32Array||value instanceof Float64Array||value instanceof ArrayBuffer){let v=new Uint8Array(value);w.writeMajor(2,v.byteLength),w.writeUint8Array(v);return}let entries=value instanceof Map?Array.from(value.entries()):Object.entries(value);w.writeMajor(5,entries.length);for(let v of entries.flat())inner(v)}}}return inner(input),w.output(!!options.partial,options.replacer)}var Reader=class{_buf;_view;_byte;_pos=0;constructor(buffer){this._buf=new ArrayBuffer(buffer.byteLength),this._view=new DataView(this._buf),this._byte=new Uint8Array(this._buf),this._byte.set(new Uint8Array(buffer))}read(amount,res){return this._pos+=amount,res}readUint8(){try{return this.read(1,this._view.getUint8(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint16(){try{return this.read(2,this._view.getUint16(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint32(){try{return this.read(4,this._view.getUint32(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readUint64(){try{return this.read(8,this._view.getBigUint64(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readFloat16(){let bytes=this.readUint16(),s2=(bytes&32768)>>15,e=(bytes&31744)>>10,f2=bytes&1023;return e===0?(s2?-1:1)*2**-14*(f2/2**10):e===31?f2?Number.NaN:(s2?-1:1)*Number.POSITIVE_INFINITY:(s2?-1:1)*2**(e-15)*(1+f2/2**10)}readFloat32(){try{return this.read(4,this._view.getFloat32(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readFloat64(){try{return this.read(8,this._view.getFloat64(this._pos))}catch(e){throw e instanceof RangeError?new CborRangeError(e.message):e}}readBytes(amount){let available=this._byte.length-this._pos;if(available>5;if(major<0||major>7)throw new CborInvalidMajorError("Received invalid major type");return[major,byte&31]}readMajorLength(length){if(length<=23)return length;switch(length){case 24:return this.readUint8();case 25:return this.readUint16();case 26:return this.readUint32();case 27:{let read=this.readUint64();return read>9007199254740992?read:Number(read)}}throw new CborRangeError("Expected a final length")}};function infiniteBytes(r2,forMajor){let w=new Writer;for(;;){let[major,len]=r2.readMajor();if(major===7&&len===31)break;if(major!==forMajor)throw new CborInvalidMajorError(`Expected a resource of the same major (${forMajor}) while processing an infinite resource`);if(len===31)throw new CborRangeError("Expected a finite resource while processing an infinite resource");w.writeUint8Array(r2.readBytes(Number(r2.readMajorLength(len))))}return w.buffer}var textDecoder;function decode(input,options={}){let r2=input instanceof Reader?input:new Reader(input);function inner(){let[major,len]=r2.readMajor();switch(major){case 0:return r2.readMajorLength(len);case 1:{let l=r2.readMajorLength(len);return typeof l=="bigint"?-(l+1n):-(l+1)}case 2:return len===31?infiniteBytes(r2,2):r2.readBytes(Number(r2.readMajorLength(len))).buffer;case 3:{let encoded=len===31?infiniteBytes(r2,3):r2.readBytes(Number(r2.readMajorLength(len)));return textDecoder??=new TextDecoder,textDecoder.decode(encoded)}case 4:{if(len===31){let arr2=[];for(;;)try{arr2.push(decode2())}catch(e){if(e instanceof CborBreak)break;throw e}return arr2}let l=r2.readMajorLength(len),arr=Array(l);for(let i=0;i(map.set(size,unit),map),new Map),durationPartRegex=new RegExp(`^(\\d+)(${Array.from(units.keys()).join("|")})`),Duration=class _Duration{_milliseconds;constructor(input){input instanceof _Duration?this._milliseconds=input._milliseconds:typeof input=="string"?this._milliseconds=_Duration.parseString(input):this._milliseconds=input}static fromCompact([s2,ns]){s2=s2??0,ns=ns??0;let ms=s2*1e3+ns/1e6;return new _Duration(ms)}toCompact(){let s2=Math.floor(this._milliseconds/1e3),ns=Math.floor((this._milliseconds-s2*1e3)*1e6);return ns>0?[s2,ns]:s2>0?[s2]:[]}toString(){let left=this._milliseconds,result="";function scrap(size){let num=Math.floor(left/size);return num>0&&(left=left%size),num}for(let[size,unit]of Array.from(unitsReverse).reverse()){let scrapped=scrap(size);scrapped>0&&(result+=`${scrapped}${unit}`)}return result}toJSON(){return this.toString()}static parseString(input){let ms=0,left=input;for(;left!=="";){let match=left.match(durationPartRegex);if(match){let amount=Number.parseInt(match[1]),factor=units.get(match[2]);if(factor===void 0)throw new SurrealDbError(`Invalid duration unit: ${match[2]}`);ms+=amount*factor,left=left.slice(match[0].length);continue}throw new SurrealDbError("Could not match a next duration part")}return ms}static nanoseconds(nanoseconds){return new _Duration(Math.floor(nanoseconds*nanosecond))}static microseconds(microseconds){return new _Duration(Math.floor(microseconds*microsecond))}static milliseconds(milliseconds){return new _Duration(milliseconds)}static seconds(seconds){return new _Duration(seconds*second)}static minutes(minutes){return new _Duration(minutes*minute)}static hours(hours){return new _Duration(hours*hour)}static days(days){return new _Duration(days*day)}static weeks(weeks){return new _Duration(weeks*week)}get microseconds(){return Math.floor(this._milliseconds/microsecond)}get nanoseconds(){return Math.floor(this._milliseconds/nanosecond)}get milliseconds(){return Math.floor(this._milliseconds)}get seconds(){return Math.floor(this._milliseconds/second)}get minutes(){return Math.floor(this._milliseconds/minute)}get hours(){return Math.floor(this._milliseconds/hour)}get days(){return Math.floor(this._milliseconds/day)}get weeks(){return Math.floor(this._milliseconds/week)}},Future=class{constructor(inner){this.inner=inner}toJSON(){return this.toString()}toString(){return` { ${this.inner} }`}},Geometry=class{};function f(num){return num instanceof Decimal?Number.parseFloat(num.decimal):num}var GeometryPoint=class _GeometryPoint extends Geometry{point;constructor(point){super(),point instanceof _GeometryPoint?this.point=point.clone().point:this.point=[f(point[0]),f(point[1])]}toJSON(){return{type:"Point",coordinates:this.coordinates}}get coordinates(){return this.point}is(geometry){return geometry instanceof _GeometryPoint?this.point[0]===geometry.point[0]&&this.point[1]===geometry.point[1]:!1}clone(){return new _GeometryPoint([...this.point])}},GeometryLine=class _GeometryLine extends Geometry{line;constructor(line){super(),this.line=line instanceof _GeometryLine?line.clone().line:line}toJSON(){return{type:"LineString",coordinates:this.coordinates}}get coordinates(){return this.line.map(g=>g.coordinates)}close(){this.line[0].is(this.line.at(-1))||this.line.push(this.line[0])}is(geometry){if(!(geometry instanceof _GeometryLine)||this.line.length!==geometry.line.length)return!1;for(let i=0;ip.clone()))}},GeometryPolygon=class _GeometryPolygon extends Geometry{polygon;constructor(polygon){super(),this.polygon=polygon instanceof _GeometryPolygon?polygon.clone().polygon:polygon.map(l=>{let line=l.clone();return line.close(),line})}toJSON(){return{type:"Polygon",coordinates:this.coordinates}}get coordinates(){return this.polygon.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryPolygon)||this.polygon.length!==geometry.polygon.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiPoint=class _GeometryMultiPoint extends Geometry{points;constructor(points){super(),this.points=points instanceof _GeometryMultiPoint?points.points:points}toJSON(){return{type:"MultiPoint",coordinates:this.coordinates}}get coordinates(){return this.points.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiPoint)||this.points.length!==geometry.points.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiLine=class _GeometryMultiLine extends Geometry{lines;constructor(lines){super(),this.lines=lines instanceof _GeometryMultiLine?lines.lines:lines}toJSON(){return{type:"MultiLineString",coordinates:this.coordinates}}get coordinates(){return this.lines.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiLine)||this.lines.length!==geometry.lines.length)return!1;for(let i=0;ip.clone()))}},GeometryMultiPolygon=class _GeometryMultiPolygon extends Geometry{polygons;constructor(polygons){super(),this.polygons=polygons instanceof _GeometryMultiPolygon?polygons.polygons:polygons}toJSON(){return{type:"MultiPolygon",coordinates:this.coordinates}}get coordinates(){return this.polygons.map(g=>g.coordinates)}is(geometry){if(!(geometry instanceof _GeometryMultiPolygon)||this.polygons.length!==geometry.polygons.length)return!1;for(let i=0;ip.clone()))}},GeometryCollection=class _GeometryCollection extends Geometry{collection;constructor(collection){super(),this.collection=collection instanceof _GeometryCollection?collection.collection:collection}toJSON(){return{type:"GeometryCollection",geometries:this.geometries}}get geometries(){return this.collection.map(g=>g.toJSON())}is(geometry){if(!(geometry instanceof _GeometryCollection)||this.collection.length!==geometry.collection.length)return!1;for(let i=0;ip.clone()))}},MAX_i64=9223372036854775807n,RecordId=class{tb;id;constructor(tb,id2){if(typeof tb!="string")throw new SurrealDbError("TB part is not valid");if(!isValidIdPart(id2))throw new SurrealDbError("ID part is not valid");this.tb=tb,this.id=id2}toJSON(){return this.toString()}toString(){let tb=escape_ident(this.tb),id2=escape_id_part(this.id);return`${tb}:${id2}`}},StringRecordId=class{rid;constructor(rid){if(typeof rid!="string")throw new SurrealDbError("String Record ID must be a string");this.rid=rid}toJSON(){return this.rid}toString(){return this.rid}};function escape_number(num){return num<=MAX_i64?num.toString():`\u27E8${num}\u27E9`}function escape_ident(str){if(isOnlyNumbers(str))return`\u27E8${str}\u27E9`;let code,i,len;for(i=0,len=str.length;i47&&code<58)&&!(code>64&&code<91)&&!(code>96&&code<123)&&code!==95)return`\u27E8${str.replaceAll("\u27E9","\u27E9")}\u27E9`;return str}function isOnlyNumbers(str){let parsed=Number.parseInt(str);return!Number.isNaN(parsed)&&parsed.toString()===str}function isValidIdPart(v){if(v instanceof Uuid)return!0;switch(typeof v){case"string":case"number":case"bigint":return!0;case"object":return Array.isArray(v)||v!==null;default:return!1}}function escape_id_part(id2){return id2 instanceof Uuid?`d"${id2}"`:typeof id2=="string"?escape_ident(id2):typeof id2=="bigint"||typeof id2=="number"?escape_number(id2):JSON.stringify(id2)}var Uuid=class _Uuid{inner;constructor(uuid){uuid instanceof ArrayBuffer?this.inner=UUID.ofInner(new Uint8Array(uuid)):uuid instanceof Uint8Array?this.inner=UUID.ofInner(uuid):uuid instanceof _Uuid?this.inner=uuid.inner:uuid instanceof UUID?this.inner=uuid:this.inner=UUID.parse(uuid)}toString(){return this.inner.toString()}toJSON(){return this.inner.toString()}toUint8Array(){return this.inner.bytes}toBuffer(){return this.inner.bytes.buffer}static v4(){return new _Uuid(uuidv4obj())}static v7(){return new _Uuid(uuidv7obj())}},Table=class{tb;constructor(tb){if(typeof tb!="string")throw new SurrealDbError("Table must be a string");this.tb=tb}toJSON(){return this.tb}toString(){return this.tb}};function toSurrealqlString(input){if(typeof input=="object"){if(input===null)return"NULL";if(input===void 0)return"NONE";if(input instanceof Date)return`d${JSON.stringify(input.toISOString())}`;if(input instanceof Uuid)return`u${JSON.stringify(input.toString())}`;if(input instanceof RecordId||input instanceof StringRecordId)return`r${JSON.stringify(input.toString())}`;if(typeof input=="string")return`s${JSON.stringify(input)}`;if(input instanceof Geometry)return toSurrealqlString(input.toJSON());if(input instanceof Decimal||input instanceof Duration||input instanceof Future||input instanceof Range||input instanceof Table)return input.toJSON();switch(Object.getPrototypeOf(input)){case Object.prototype:{let output2="{ ";for(let[k,v]of Object.entries(input))output2+=`${JSON.stringify(k)}: ${toSurrealqlString(v)},`;return output2+=" }",output2}case Map.prototype:{let output2="{ ";for(let[k,v]of input.entries())output2+=`${JSON.stringify(k)}: ${toSurrealqlString(v)},`;return output2+=" }",output2}case Array.prototype:{let output2="[ ";for(let v of input)output2+=`${toSurrealqlString(v)},`;return output2+=" ]",output2}case Set.prototype:return`[ ${[...new Set([...input].map(toSurrealqlString))].join(", ")} ]`}}return`${input}`}var Range=class{constructor(beg,end){this.beg=beg,this.end=end}toJSON(){return this.toString()}toString(){let beg=escape_range_bound(this.beg),end=escape_range_bound(this.end);return`${beg}${getRangeJoin(this.beg,this.end)}${end}`}},BoundIncluded=class{constructor(value){this.value=value}},BoundExcluded=class{constructor(value){this.value=value}},RecordIdRange=class{constructor(tb,beg,end){if(this.tb=tb,this.beg=beg,this.end=end,typeof tb!="string")throw new SurrealDbError("TB part is not valid");if(!isValidIdBound(beg))throw new SurrealDbError("Beg part is not valid");if(!isValidIdBound(end))throw new SurrealDbError("End part is not valid")}toJSON(){return this.toString()}toString(){let tb=escape_ident(this.tb),beg=escape_id_bound(this.beg),end=escape_id_bound(this.end);return`${tb}:${beg}${getRangeJoin(this.beg,this.end)}${end}`}};function getRangeJoin(beg,end){let output2="";return beg instanceof BoundExcluded&&(output2+=">"),output2+="..",end instanceof BoundIncluded&&(output2+="="),output2}function isValidIdBound(bound){return bound instanceof BoundIncluded||bound instanceof BoundExcluded?isValidIdPart(bound.value):!0}function escape_id_bound(bound){return bound instanceof BoundIncluded||bound instanceof BoundExcluded?escape_id_part(bound.value):""}function escape_range_bound(bound){if(bound===void 0)return"";let value=bound.value;return bound instanceof Range?`(${toSurrealqlString(value)})`:toSurrealqlString(value)}function rangeToCbor([beg,end]){function encodeBound(bound){return bound instanceof BoundIncluded?new Tagged(TAG_BOUND_INCLUDED,bound.value):bound instanceof BoundExcluded?new Tagged(TAG_BOUND_EXCLUDED,bound.value):null}return[encodeBound(beg),encodeBound(end)]}function cborToRange(range){function decodeBound(bound){if(bound!==null){if(bound.tag===TAG_BOUND_INCLUDED)return new BoundIncluded(bound.value);if(bound.tag===TAG_BOUND_EXCLUDED)return new BoundExcluded(bound.value);throw new SurrealDbError("Invalid bound tag")}}return[decodeBound(range[0]),decodeBound(range[1])]}var TAG_SPEC_DATETIME=0,TAG_SPEC_UUID=37,TAG_NONE=6,TAG_TABLE=7,TAG_RECORDID=8,TAG_STRING_UUID=9,TAG_STRING_DECIMAL=10,TAG_CUSTOM_DATETIME=12,TAG_STRING_DURATION=13,TAG_CUSTOM_DURATION=14,TAG_FUTURE=15,TAG_RANGE2=49,TAG_BOUND_INCLUDED=50,TAG_BOUND_EXCLUDED=51,TAG_GEOMETRY_POINT=88,TAG_GEOMETRY_LINE=89,TAG_GEOMETRY_POLYGON=90,TAG_GEOMETRY_MULTIPOINT=91,TAG_GEOMETRY_MULTILINE=92,TAG_GEOMETRY_MULTIPOLYGON=93,TAG_GEOMETRY_COLLECTION=94,replacer={encode(v){return v instanceof Date?new Tagged(TAG_CUSTOM_DATETIME,dateToCborCustomDate(v)):v===void 0?new Tagged(TAG_NONE,null):v instanceof Uuid?new Tagged(TAG_SPEC_UUID,v.toBuffer()):v instanceof Decimal?new Tagged(TAG_STRING_DECIMAL,v.toString()):v instanceof Duration?new Tagged(TAG_CUSTOM_DURATION,v.toCompact()):v instanceof RecordId?new Tagged(TAG_RECORDID,[v.tb,v.id]):v instanceof StringRecordId?new Tagged(TAG_RECORDID,v.rid):v instanceof RecordIdRange?new Tagged(TAG_RECORDID,[v.tb,new Tagged(TAG_RANGE2,rangeToCbor([v.beg,v.end]))]):v instanceof Table?new Tagged(TAG_TABLE,v.tb):v instanceof Future?new Tagged(TAG_FUTURE,v.inner):v instanceof Range?new Tagged(TAG_RANGE2,rangeToCbor([v.beg,v.end])):v instanceof GeometryPoint?new Tagged(TAG_GEOMETRY_POINT,v.point):v instanceof GeometryLine?new Tagged(TAG_GEOMETRY_LINE,v.line):v instanceof GeometryPolygon?new Tagged(TAG_GEOMETRY_POLYGON,v.polygon):v instanceof GeometryMultiPoint?new Tagged(TAG_GEOMETRY_MULTIPOINT,v.points):v instanceof GeometryMultiLine?new Tagged(TAG_GEOMETRY_MULTILINE,v.lines):v instanceof GeometryMultiPolygon?new Tagged(TAG_GEOMETRY_MULTIPOLYGON,v.polygons):v instanceof GeometryCollection?new Tagged(TAG_GEOMETRY_COLLECTION,v.collection):v},decode(v){if(!(v instanceof Tagged))return v;switch(v.tag){case TAG_SPEC_DATETIME:return new Date(v.value);case TAG_SPEC_UUID:case TAG_STRING_UUID:return new Uuid(v.value);case TAG_CUSTOM_DATETIME:return cborCustomDateToDate(v.value);case TAG_NONE:return;case TAG_STRING_DECIMAL:return new Decimal(v.value);case TAG_STRING_DURATION:return new Duration(v.value);case TAG_CUSTOM_DURATION:return Duration.fromCompact(v.value);case TAG_TABLE:return new Table(v.value);case TAG_FUTURE:return new Future(v.value);case TAG_RANGE2:return new Range(...cborToRange(v.value));case TAG_RECORDID:return v.value[1]instanceof Range?new RecordIdRange(v.value[0],v.value[1].beg,v.value[1].end):new RecordId(v.value[0],v.value[1]);case TAG_GEOMETRY_POINT:return new GeometryPoint(v.value);case TAG_GEOMETRY_LINE:return new GeometryLine(v.value);case TAG_GEOMETRY_POLYGON:return new GeometryPolygon(v.value);case TAG_GEOMETRY_MULTIPOINT:return new GeometryMultiPoint(v.value);case TAG_GEOMETRY_MULTILINE:return new GeometryMultiLine(v.value);case TAG_GEOMETRY_MULTIPOLYGON:return new GeometryMultiPolygon(v.value);case TAG_GEOMETRY_COLLECTION:return new GeometryCollection(v.value)}}};Object.freeze(replacer);var supportedSurrealDbVersionMin="1.4.2",supportedSurrealDbVersionUntil="3.0.0",supportedSurrealDbVersionRange=`>= ${supportedSurrealDbVersionMin} < ${supportedSurrealDbVersionUntil}`;var id=0;function getIncrementalID(){return id=(id+1)%Number.MAX_SAFE_INTEGER,id.toString()}var ConnectionStatus=(ConnectionStatus2=>(ConnectionStatus2.Disconnected="disconnected",ConnectionStatus2.Connecting="connecting",ConnectionStatus2.Connected="connected",ConnectionStatus2.Error="error",ConnectionStatus2))(ConnectionStatus||{});var AbstractEngine=class{context;ready;status="disconnected";connection={url:void 0,namespace:void 0,database:void 0,token:void 0};constructor(context){this.context=context}get emitter(){return this.context.emitter}get encodeCbor(){return this.context.encodeCbor}get decodeCbor(){return this.context.decodeCbor}};function surrealdbWasmEngines(opts){class WasmEmbeddedEngine extends AbstractEngine{ready=void 0;reader;status=ConnectionStatus.Disconnected;queue=[];processing=!1;db;async version(){return SurrealWasmEngine.version()}setStatus(status,...args){this.status=status,this.emitter.emit(status,args)}async connect(url){this.connection.url=url,this.setStatus(ConnectionStatus.Connecting);let ready=(async()=>{let db=await SurrealWasmEngine.connect(url.toString(),opts).catch(e=>{console.log(e);let error=new UnexpectedConnectionError(typeof e=="string"?e:"error"in e?e.error:"An unexpected error occurred");throw this.setStatus(ConnectionStatus.Error,error),e});this.db=db,this.setStatus(ConnectionStatus.Connected),this.reader=(async()=>{let reader=db.notifications().getReader();for(;this.connected;){let{done,value}=await reader.read();if(done)break;let raw=value,{id:id2,action,result}=this.decodeCbor(raw.buffer);id2&&this.emitter.emit(`live-${id2.toString()}`,[action,result],!0)}})()})();return this.ready=ready,await ready}async disconnect(){this.connection={url:void 0,namespace:void 0,database:void 0,token:void 0},await this.ready,this.ready=void 0,this.db?.free(),this.db=void 0,await this.reader,this.reader=void 0,this.status!==ConnectionStatus.Disconnected&&this.setStatus(ConnectionStatus.Disconnected)}async rpc(request){if(await this.ready,!this.db)throw new ConnectionUnavailable;return new Promise((resolve,reject)=>{this.queue.push(async()=>{try{let result=await this.execute(request);resolve(result)}catch(error){reject(error)}}),this.processQueue()})}get connected(){return!!this.db}async processQueue(){if(!this.processing){for(this.processing=!0;this.queue.length>0;){let task=this.queue.shift();if(task)try{await task()}catch(error){console.error("Query execution failed",error)}}this.processing=!1}}async execute(request){let id2=getIncrementalID(),res=await this.db.execute(new Uint8Array(this.encodeCbor({id:id2,...request}))).then(raw=>({result:this.decodeCbor(raw.buffer)})).catch(message=>({error:{code:-1,message}}));if("result"in res)switch(request.method){case"use":{this.connection.namespace=request.params?.[0],this.connection.database=request.params?.[1];break}case"signin":case"signup":{this.connection.token=res.result;break}case"authenticate":{this.connection.token=request.params?.[0];break}case"invalidate":{this.connection.token=void 0;break}}return res}}return{mem:WasmEmbeddedEngine,indxdb:WasmEmbeddedEngine}}export{surrealdbWasmEngines}; +/*! Bundled license information: + +uuidv7/dist/index.js: + (** + * uuidv7: A JavaScript implementation of UUID version 7 + * + * Copyright 2021-2024 LiosK + * + * @license Apache-2.0 + * @packageDocumentation + *) +*/ diff --git a/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm b/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm index bc50a4b..a6dff33 100644 Binary files a/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm and b/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm differ diff --git a/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz b/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz index d635c5f..e7fa6dd 100644 Binary files a/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz and b/assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz differ diff --git a/flutter_bootstrap.js b/flutter_bootstrap.js index 87f58c4..63ded45 100644 --- a/flutter_bootstrap.js +++ b/flutter_bootstrap.js @@ -6,11 +6,11 @@ Read more: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts if (!window._flutter) { window._flutter = {}; } -_flutter.buildConfig = {"engineRevision":"c9b9d5780da342eb3f0f5e439a7db06f7d112575","builds":[{"compileTarget":"dart2js","renderer":"canvaskit","mainJsPath":"main.dart.js"}]}; +_flutter.buildConfig = {"engineRevision":"36335019a8eab588c3c2ea783c618d90505be233","builds":[{"compileTarget":"dart2js","renderer":"canvaskit","mainJsPath":"main.dart.js"}]}; _flutter.loader.load({ serviceWorkerSettings: { - serviceWorkerVersion: "1147410324" + serviceWorkerVersion: "3838824583" } }); diff --git a/flutter_service_worker.js b/flutter_service_worker.js index 2833908..89d341a 100644 --- a/flutter_service_worker.js +++ b/flutter_service_worker.js @@ -3,44 +3,44 @@ const MANIFEST = 'flutter-app-manifest'; const TEMP = 'flutter-temp-cache'; const CACHE_NAME = 'flutter-app-cache'; -const RESOURCES = {"icons/Icon-maskable-512.png": "301a7604d45b3e739efc881eb04896ea", -"icons/Icon-192.png": "ac9a721a12bbc803b44f645561ecb1e1", -"icons/Icon-512.png": "96e752610906ba2a93c65f8abe1645f1", -"icons/Icon-maskable-192.png": "c457ef57daa1d16f64b27b786ec2ea3c", -"assets/FontManifest.json": "7b2a36307916a9721811788013e65289", -"assets/AssetManifest.bin.json": "a5d158ed6810632fc1666631284eb093", +const RESOURCES = {"assets/AssetManifest.json": "e9c1bd6d118a645ce1cdf303991700f9", +"assets/AssetManifest.bin.json": "5ba7df82ce510508280b9211671e820c", "assets/shaders/ink_sparkle.frag": "ecc85a2e95f5e9f53123dcaf8cb9b6ce", +"assets/AssetManifest.bin": "6b2081c9d1c10c80a6bd41677a48170e", +"assets/FontManifest.json": "7b2a36307916a9721811788013e65289", +"assets/NOTICES": "6ec7cf595e9d69589cdffb49ee4635a7", "assets/fonts/MaterialIcons-Regular.otf": "0db35ae7a415370b89e807027510caf0", -"assets/AssetManifest.bin": "ad00da286e52febfdc49e9b7a890fbb1", -"assets/packages/surrealdb_wasm/assets/wasm/surrealdb/esm.bundled.js": "77bb3fc1186f22f0b99d94c861a217ef", -"assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz": "97b5219e81b588702abd3d1d8925cbb4", -"assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.js": "3c614289ebced54274cce45388daf9a2", "assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index.js": "d5d2c8dec61f6c85e6e98a520d72d8ac", -"assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm": "32707553ace50d9b06cefd863168f33c", "assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js.gz": "c4df3e7316d680bb077ef6c36e8799c6", "assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.min.js": "4dcc2d106028f4d4093f06b0ad559c54", +"assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index_bg.wasm": "9f30c6f95997bbcb14ff3922d1f2c7de", "assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb_wasm.js": "8e000c8a00f7f048abb711a6573085ca", -"assets/packages/surrealdb_js/assets/js/index.bundled.mjs": "af013dbfb0432e80da76153c0198a395", -"assets/AssetManifest.json": "178c2038b4197d31407a167f50849246", -"assets/NOTICES": "57bb93f0787a8d84c0326770068e7dd1", -"index.html": "a30b7461dc75d5f5e0cefb31e12624d2", -"/": "a30b7461dc75d5f5e0cefb31e12624d2", -"main.dart.js": "82c1ca6f98d69286d6e98f49f570cb20", -"favicon.png": "5dcef449791fa27946b3d35ad8803796", -"version.json": "10480ab669b41b140cc75519feb448ba", -"flutter_bootstrap.js": "07460359b24f4243638c4f98612fde05", -"canvaskit/skwasm.js.symbols": "262f4827a1317abb59d71d6c587a93e2", -"canvaskit/skwasm.wasm": "9f0c0c02b82a910d12ce0543ec130e60", -"canvaskit/chromium/canvaskit.wasm": "b1ac05b29c127d86df4bcfbf50dd902a", -"canvaskit/chromium/canvaskit.js.symbols": "a012ed99ccba193cf96bb2643003f6fc", -"canvaskit/chromium/canvaskit.js": "671c6b4f8fcc199dcc551c7bb125f239", -"canvaskit/canvaskit.wasm": "1f237a213d7370cf95f443d896176460", +"assets/packages/surrealdb_wasm/assets/wasm/surrealdb/index.bundled.js": "0c792a29c562ac8ac49e2df01e7b97ac", +"assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.js": "3c614289ebced54274cce45388daf9a2", +"assets/packages/surrealdb_wasm/assets/wasm/surrealdb/surrealdb.wasm.gz": "94f6f128af7a0675cf7ecf8d85e879e3", +"assets/packages/surrealdb_js/assets/js/index.bundled.mjs": "3f9df585e369c21a2f6ef21d82787b26", "canvaskit/canvaskit.js.symbols": "48c83a2ce573d9692e8d970e288d75f7", -"canvaskit/canvaskit.js": "66177750aff65a66cb07bb44b8c6422b", "canvaskit/skwasm.worker.js": "89990e8c92bcb123999aa81f7e203b1c", +"canvaskit/canvaskit.js": "66177750aff65a66cb07bb44b8c6422b", +"canvaskit/skwasm.wasm": "9f0c0c02b82a910d12ce0543ec130e60", +"canvaskit/canvaskit.wasm": "1f237a213d7370cf95f443d896176460", "canvaskit/skwasm.js": "694fda5704053957c2594de355805228", -"manifest.json": "f5e7a2cbf54c9e9b1e9008d89b378047", -"flutter.js": "f393d3c16b631f36852323de8e583132"}; +"canvaskit/chromium/canvaskit.js.symbols": "a012ed99ccba193cf96bb2643003f6fc", +"canvaskit/chromium/canvaskit.js": "671c6b4f8fcc199dcc551c7bb125f239", +"canvaskit/chromium/canvaskit.wasm": "b1ac05b29c127d86df4bcfbf50dd902a", +"canvaskit/skwasm.js.symbols": "262f4827a1317abb59d71d6c587a93e2", +"main.dart.js": "a00a847d23f5699d71efc54ce92ada1d", +"icons/Icon-512.png": "96e752610906ba2a93c65f8abe1645f1", +"icons/Icon-192.png": "ac9a721a12bbc803b44f645561ecb1e1", +"icons/Icon-maskable-512.png": "301a7604d45b3e739efc881eb04896ea", +"icons/Icon-maskable-192.png": "c457ef57daa1d16f64b27b786ec2ea3c", +"flutter_bootstrap.js": "28cbf40f60cc0a15badb18fb1e0a9a34", +"favicon.png": "5dcef449791fa27946b3d35ad8803796", +"flutter.js": "f393d3c16b631f36852323de8e583132", +"index.html": "ddfe02e39a1b8b217a5ff74b872cb822", +"/": "ddfe02e39a1b8b217a5ff74b872cb822", +"version.json": "10480ab669b41b140cc75519feb448ba", +"manifest.json": "f5e7a2cbf54c9e9b1e9008d89b378047"}; // The application shell files that are downloaded before a service worker can // start. const CORE = ["main.dart.js", diff --git a/index.html b/index.html index 9120b96..22bf575 100644 --- a/index.html +++ b/index.html @@ -37,11 +37,11 @@