From e326c28d6165a14e3c462ffeec474e1f98cce02c Mon Sep 17 00:00:00 2001 From: limcheekin Date: Fri, 27 Sep 2024 09:04:12 +0800 Subject: [PATCH] chore: fix cp: cannot stat './dist/embedded/esm.bundled.js': No such file or directory --- .github/workflows/build-wasm-js.yaml | 4 ++-- assets/wasm/surrealdb/esm.bundled.js | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 assets/wasm/surrealdb/esm.bundled.js diff --git a/.github/workflows/build-wasm-js.yaml b/.github/workflows/build-wasm-js.yaml index 8962b41..46385c3 100644 --- a/.github/workflows/build-wasm-js.yaml +++ b/.github/workflows/build-wasm-js.yaml @@ -36,8 +36,8 @@ jobs: run: | cd surrealdb.wasm make build - cp ./dist/embedded/esm.bundled.js ../assets/wasm/surrealdb - cp ./dist/embedded/index_bg.wasm ../assets/wasm/surrealdb + cp ./dist/surreal/index.bundled.js ../assets/wasm/surrealdb + cp ./dist/surreal/index_bg.wasm ../assets/wasm/surrealdb #- name: "Minify and compress JavaScript files" # run: pnpm run package diff --git a/assets/wasm/surrealdb/esm.bundled.js b/assets/wasm/surrealdb/esm.bundled.js deleted file mode 100644 index d2255fb..0000000 --- a/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 - *) -*/