@concavejs/runtime-cf-base 0.0.1-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @concavejs/runtime-cf-base might be problematic. Click here for more details.
- package/dist/adapters/cf-websocket-adapter.d.ts +38 -0
- package/dist/adapters/cf-websocket-adapter.js +83 -0
- package/dist/durable-objects/concave-do-base.d.ts +158 -0
- package/dist/durable-objects/concave-do-base.js +412 -0
- package/dist/http/dx-http.d.ts +28 -0
- package/dist/http/dx-http.js +306 -0
- package/dist/http/http-api.d.ts +1 -0
- package/dist/http/http-api.js +262 -0
- package/dist/http/index.d.ts +7 -0
- package/dist/http/index.js +7 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +25 -0
- package/dist/internal.d.ts +4 -0
- package/dist/internal.js +4 -0
- package/dist/routing/instance.d.ts +25 -0
- package/dist/routing/instance.js +101 -0
- package/dist/rpc/blobstore-proxy.d.ts +11 -0
- package/dist/rpc/blobstore-proxy.js +28 -0
- package/dist/rpc/docstore-proxy.d.ts +11 -0
- package/dist/rpc/docstore-proxy.js +72 -0
- package/dist/rpc/index.d.ts +2 -0
- package/dist/rpc/index.js +2 -0
- package/dist/sync/cf-websocket-adapter.d.ts +15 -0
- package/dist/sync/cf-websocket-adapter.js +22 -0
- package/dist/sync/concave-do-udf-executor.d.ts +37 -0
- package/dist/sync/concave-do-udf-executor.js +67 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +2 -0
- package/dist/udf/executor/do-client-executor.d.ts +14 -0
- package/dist/udf/executor/do-client-executor.js +42 -0
- package/dist/udf/executor/index.d.ts +9 -0
- package/dist/udf/executor/index.js +9 -0
- package/dist/udf/executor/inline-executor.d.ts +13 -0
- package/dist/udf/executor/inline-executor.js +25 -0
- package/dist/udf/executor/isolated-executor.d.ts +24 -0
- package/dist/udf/executor/isolated-executor.js +31 -0
- package/dist/udf/executor/shim-content.d.ts +1 -0
- package/dist/udf/executor/shim-content.js +3 -0
- package/dist/worker/create-concave-worker.d.ts +34 -0
- package/dist/worker/create-concave-worker.js +162 -0
- package/dist/worker/index.d.ts +6 -0
- package/dist/worker/index.js +6 -0
- package/dist/worker/udf-worker.d.ts +14 -0
- package/dist/worker/udf-worker.js +63 -0
- package/package.json +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SHIM_SOURCE = "// @bun\nvar Fw=Object.defineProperty;var Cw=($,J)=>{for(var w in J)Fw($,w,{get:J[w],enumerable:!0,configurable:!0,set:(Z)=>J[w]=()=>Z})};var E=($,J)=>()=>($&&(J=$($=0)),J);function G0($){if($===\"\")return new Uint8Array(0).buffer;let J=$.match(/.{1,2}/g);if(!J)throw Error(`Invalid hex string: ${$}`);return new Uint8Array(J.map((w)=>parseInt(w,16))).buffer}function E$($){return Array.from(new Uint8Array($)).map((J)=>J.toString(16).padStart(2,\"0\")).join(\"\")}function q($){let J=new TextEncoder().encode($);return E$(J.buffer)}function H$($){let J=G0($);return new TextDecoder().decode(J)}function y$($,J){return`${$}${M6}${J}`}function Q0($){if(!$)return null;for(let J of[M6,Bw]){let w=$.split(J);if(w.length===2&&w[0]&&w[1])return{table:w[0],internalId:w[1]}}return null}async function u0($){let J=await $.arrayBuffer(),w=await crypto.subtle.digest(\"SHA-256\",J),Z=new Uint8Array(w);return btoa(String.fromCharCode(...Z))}function b($){return`${$.table}:${$.internalId}`}var M6=\":\",Bw=\";\";function _w($){var J=$.length;if(J%4>0)throw Error(\"Invalid string. Length must be a multiple of 4\");var w=$.indexOf(\"=\");if(w===-1)w=J;var Z=w===J?0:4-w%4;return[w,Z]}function kw($,J,w){return(J+w)*3/4-w}function b$($){var J,w=_w($),Z=w[0],W=w[1],X=new jw(kw($,Z,W)),Y=0,G=W>0?Z-4:Z,Q;for(Q=0;Q<G;Q+=4)J=c[$.charCodeAt(Q)]<<18|c[$.charCodeAt(Q+1)]<<12|c[$.charCodeAt(Q+2)]<<6|c[$.charCodeAt(Q+3)],X[Y++]=J>>16&255,X[Y++]=J>>8&255,X[Y++]=J&255;if(W===2)J=c[$.charCodeAt(Q)]<<2|c[$.charCodeAt(Q+1)]>>4,X[Y++]=J&255;if(W===1)J=c[$.charCodeAt(Q)]<<10|c[$.charCodeAt(Q+1)]<<4|c[$.charCodeAt(Q+2)]>>2,X[Y++]=J>>8&255,X[Y++]=J&255;return X}function Nw($){return d[$>>18&63]+d[$>>12&63]+d[$>>6&63]+d[$&63]}function hw($,J,w){var Z,W=[];for(var X=J;X<w;X+=3)Z=($[X]<<16&16711680)+($[X+1]<<8&65280)+($[X+2]&255),W.push(Nw(Z));return W.join(\"\")}function m$($){var J,w=$.length,Z=w%3,W=[],X=16383;for(var Y=0,G=w-Z;Y<G;Y+=X)W.push(hw($,Y,Y+X>G?G:Y+X));if(Z===1)J=$[w-1],W.push(d[J>>2]+d[J<<4&63]+\"==\");else if(Z===2)J=($[w-2]<<8)+$[w-1],W.push(d[J>>10]+d[J>>4&63]+d[J<<2&63]+\"=\");return W.join(\"\")}var d,c,jw,d0=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",Q$,i0;var P6=E(()=>{d=[],c=[],jw=Uint8Array;for(Q$=0,i0=d0.length;Q$<i0;++Q$)d[Q$]=d0[Q$],c[d0.charCodeAt(Q$)]=Q$;c[45]=62;c[95]=63});function c$($){if($===void 0)return{};if(!t0($))throw Error(`The arguments to a Convex function must be an object. Received: ${$}`);return $}function t0($){let J=typeof $===\"object\",w=Object.getPrototypeOf($),Z=w===null||w===Object.prototype||w?.constructor?.name===\"Object\";return J&&Z}function V6($){return Number.isNaN($)||!Number.isFinite($)||Object.is($,-0)}function yw($){if($<l0)$-=L$+L$;let J=$.toString(16);if(J.length%2===1)J=\"0\"+J;let w=new Uint8Array(new ArrayBuffer(8)),Z=0;for(let W of J.match(/.{2}/g).reverse())w.set([parseInt(W,16)],Z++),$>>=fw;return m$(w)}function gw($){let J=b$($);if(J.byteLength!==8)throw Error(`Received ${J.byteLength} bytes, expected 8 for $integer`);let w=l0,Z=l0;for(let W of J)w+=BigInt(W)*xw**Z,Z++;if(w>e0)w+=L$+L$;return w}function bw($){if($<L$||e0<$)throw Error(`BigInt ${$} does not fit into a 64-bit signed integer.`);let J=new ArrayBuffer(8);return new DataView(J).setBigInt64(0,$,!0),m$(new Uint8Array(J))}function mw($){let J=b$($);if(J.byteLength!==8)throw Error(`Received ${J.byteLength} bytes, expected 8 for $integer`);return new DataView(J.buffer).getBigInt64(0,!0)}function a0($){if($.length>B6)throw Error(`Field name ${$} exceeds maximum field name length ${B6}.`);if($.startsWith(\"$\"))throw Error(`Field name ${$} starts with a '$', which is reserved.`);for(let J=0;J<$.length;J+=1){let w=$.charCodeAt(J);if(w<32||w>=127)throw Error(`Field name ${$} has invalid character '${$[J]}': Field names can only contain non-control ASCII characters`)}}function R($){if($===null)return $;if(typeof $===\"boolean\")return $;if(typeof $===\"number\")return $;if(typeof $===\"string\")return $;if(Array.isArray($))return $.map((Z)=>R(Z));if(typeof $!==\"object\")throw Error(`Unexpected type of ${$}`);let J=Object.entries($);if(J.length===1){let Z=J[0][0];if(Z===\"$bytes\"){if(typeof $.$bytes!==\"string\")throw Error(`Malformed $bytes field on ${$}`);return b$($.$bytes).buffer}if(Z===\"$integer\"){if(typeof $.$integer!==\"string\")throw Error(`Malformed $integer field on ${$}`);return pw($.$integer)}if(Z===\"$float\"){if(typeof $.$float!==\"string\")throw Error(`Malformed $float field on ${$}`);let W=b$($.$float);if(W.byteLength!==8)throw Error(`Received ${W.byteLength} bytes, expected 8 for $float`);let Y=new DataView(W.buffer).getFloat64(0,D6);if(!V6(Y))throw Error(`Float ${Y} should be encoded as a number`);return Y}if(Z===\"$set\")throw Error(\"Received a Set which is no longer supported as a Convex type.\");if(Z===\"$map\")throw Error(\"Received a Map which is no longer supported as a Convex type.\")}let w={};for(let[Z,W]of Object.entries($))a0(Z),w[Z]=R(W);return w}function S$($){return JSON.stringify($,(J,w)=>{if(w===void 0)return\"undefined\";if(typeof w===\"bigint\")return`${w.toString()}n`;return w})}function p$($,J,w,Z){if($===void 0){let Y=w&&` (present at path ${w} in original object ${S$(J)})`;throw Error(`undefined is not a valid Convex value${Y}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if($===null)return $;if(typeof $===\"bigint\"){if($<L$||e0<$)throw Error(`BigInt ${$} does not fit into a 64-bit signed integer.`);return{$integer:cw($)}}if(typeof $===\"number\")if(V6($)){let Y=new ArrayBuffer(8);return new DataView(Y).setFloat64(0,$,D6),{$float:m$(new Uint8Array(Y))}}else return $;if(typeof $===\"boolean\")return $;if(typeof $===\"string\")return $;if($ instanceof ArrayBuffer)return{$bytes:m$(new Uint8Array($))};if(Array.isArray($))return $.map((Y,G)=>p$(Y,J,w+`[${G}]`,!1));if($ instanceof Set)throw Error(r0(w,\"Set\",[...$],J));if($ instanceof Map)throw Error(r0(w,\"Map\",[...$],J));if(!t0($)){let Y=$?.constructor?.name,G=Y?`${Y} `:\"\";throw Error(r0(w,G,$,J))}let W={},X=Object.entries($);X.sort(([Y,G],[Q,K])=>Y===Q?0:Y<Q?-1:1);for(let[Y,G]of X)if(G!==void 0)a0(Y),W[Y]=p$(G,J,w+`.${Y}`,!1);else if(Z)a0(Y),W[Y]=q6(G,J,w+`.${Y}`);return W}function r0($,J,w,Z){if($)return`${J}${S$(w)} is not a supported Convex type (present at path ${$} in original object ${S$(Z)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`;else return`${J}${S$(w)} is not a supported Convex type.`}function q6($,J,w){if($===void 0)return{$undefined:null};else{if(J===void 0)throw Error(`Programming error. Current value is ${S$($)} but original value is undefined`);return p$($,J,w,!1)}}function B($){return p$($,$,\"\",!1)}function i($){return q6($,$,\"\")}function A6($){return p$($,$,\"\",!0)}var D6=!0,L$,e0,l0,fw,xw,cw,pw,B6=1024;var e=E(()=>{P6();L$=BigInt(\"-9223372036854775808\"),e0=BigInt(\"9223372036854775807\"),l0=BigInt(\"0\"),fw=BigInt(\"8\"),xw=BigInt(\"256\");cw=DataView.prototype.setBigInt64?bw:yw,pw=DataView.prototype.getBigInt64?mw:gw});class y{constructor({isOptional:$}){V(this,\"type\"),V(this,\"fieldPaths\"),V(this,\"isOptional\"),V(this,\"isConvexValidator\"),this.isOptional=$,this.isConvexValidator=!0}get optional(){return this.isOptional===\"optional\"?!0:!1}}var vw,uw=($,J,w)=>(J in $)?vw($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,V=($,J,w)=>uw($,typeof J!==\"symbol\"?J+\"\":J,w),K0,v$,u$,U0,H0,S0,O0,z0,F0,C0,M0,R0,E0;var T6=E(()=>{e();vw=Object.defineProperty;K0=class K0 extends y{constructor({isOptional:$,tableName:J}){super({isOptional:$});if(V(this,\"tableName\"),V(this,\"kind\",\"id\"),typeof J!==\"string\")throw Error(\"v.id(tableName) requires a string\");this.tableName=J}get json(){return{type:\"id\",tableName:this.tableName}}asOptional(){return new K0({isOptional:\"optional\",tableName:this.tableName})}};v$=class v$ extends y{constructor(){super(...arguments);V(this,\"kind\",\"float64\")}get json(){return{type:\"number\"}}asOptional(){return new v$({isOptional:\"optional\"})}};u$=class u$ extends y{constructor(){super(...arguments);V(this,\"kind\",\"int64\")}get json(){return{type:\"bigint\"}}asOptional(){return new u$({isOptional:\"optional\"})}};U0=class U0 extends y{constructor(){super(...arguments);V(this,\"kind\",\"boolean\")}get json(){return{type:this.kind}}asOptional(){return new U0({isOptional:\"optional\"})}};H0=class H0 extends y{constructor(){super(...arguments);V(this,\"kind\",\"bytes\")}get json(){return{type:this.kind}}asOptional(){return new H0({isOptional:\"optional\"})}};S0=class S0 extends y{constructor(){super(...arguments);V(this,\"kind\",\"string\")}get json(){return{type:this.kind}}asOptional(){return new S0({isOptional:\"optional\"})}};O0=class O0 extends y{constructor(){super(...arguments);V(this,\"kind\",\"null\")}get json(){return{type:this.kind}}asOptional(){return new O0({isOptional:\"optional\"})}};z0=class z0 extends y{constructor(){super(...arguments);V(this,\"kind\",\"any\")}get json(){return{type:this.kind}}asOptional(){return new z0({isOptional:\"optional\"})}};F0=class F0 extends y{constructor({isOptional:$,fields:J}){super({isOptional:$});V(this,\"fields\"),V(this,\"kind\",\"object\"),globalThis.Object.values(J).forEach((w)=>{if(!w.isConvexValidator)throw Error(\"v.object() entries must be validators\")}),this.fields=J}get json(){return{type:this.kind,value:globalThis.Object.fromEntries(globalThis.Object.entries(this.fields).map(([$,J])=>[$,{fieldType:J.json,optional:J.isOptional===\"optional\"?!0:!1}]))}}asOptional(){return new F0({isOptional:\"optional\",fields:this.fields})}};C0=class C0 extends y{constructor({isOptional:$,value:J}){super({isOptional:$});if(V(this,\"value\"),V(this,\"kind\",\"literal\"),typeof J!==\"string\"&&typeof J!==\"boolean\"&&typeof J!==\"number\"&&typeof J!==\"bigint\")throw Error(\"v.literal(value) must be a string, number, or boolean\");this.value=J}get json(){return{type:this.kind,value:B(this.value)}}asOptional(){return new C0({isOptional:\"optional\",value:this.value})}};M0=class M0 extends y{constructor({isOptional:$,element:J}){super({isOptional:$});V(this,\"element\"),V(this,\"kind\",\"array\"),this.element=J}get json(){return{type:this.kind,value:this.element.json}}asOptional(){return new M0({isOptional:\"optional\",element:this.element})}};R0=class R0 extends y{constructor({isOptional:$,key:J,value:w}){super({isOptional:$});if(V(this,\"key\"),V(this,\"value\"),V(this,\"kind\",\"record\"),J.isOptional===\"optional\")throw Error(\"Record validator cannot have optional keys\");if(w.isOptional===\"optional\")throw Error(\"Record validator cannot have optional values\");if(!J.isConvexValidator||!w.isConvexValidator)throw Error(\"Key and value of v.record() but be validators\");this.key=J,this.value=w}get json(){return{type:this.kind,keys:this.key.json,values:{fieldType:this.value.json,optional:!1}}}asOptional(){return new R0({isOptional:\"optional\",key:this.key,value:this.value})}};E0=class E0 extends y{constructor({isOptional:$,members:J}){super({isOptional:$});V(this,\"members\"),V(this,\"kind\",\"union\"),J.forEach((w)=>{if(!w.isConvexValidator)throw Error(\"All members of v.union() must be validators\")}),this.members=J}get json(){return{type:this.kind,value:this.members.map(($)=>$.json)}}asOptional(){return new E0({isOptional:\"optional\",members:this.members})}}});function nw($){return!!$.isConvexValidator}function L0($){if(nw($))return $;else return z.object($)}var z;var P0=E(()=>{T6();z={id:($)=>{return new K0({isOptional:\"required\",tableName:$})},null:()=>{return new O0({isOptional:\"required\"})},number:()=>{return new v$({isOptional:\"required\"})},float64:()=>{return new v$({isOptional:\"required\"})},bigint:()=>{return new u$({isOptional:\"required\"})},int64:()=>{return new u$({isOptional:\"required\"})},boolean:()=>{return new U0({isOptional:\"required\"})},string:()=>{return new S0({isOptional:\"required\"})},bytes:()=>{return new H0({isOptional:\"required\"})},literal:($)=>{return new C0({isOptional:\"required\",value:$})},array:($)=>{return new M0({isOptional:\"required\",element:$})},object:($)=>{return new F0({isOptional:\"required\",fields:$})},record:($,J)=>{return new R0({isOptional:\"required\",key:$,value:J})},union:(...$)=>{return new E0({isOptional:\"required\",members:$})},any:()=>{return new z0({isOptional:\"required\"})},optional:($)=>{return $.asOptional()}}});var sw,ow=($,J,w)=>(J in $)?sw($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,$J=($,J,w)=>ow($,typeof J!==\"symbol\"?J+\"\":J,w),j6,_6,dw,JJ;var wJ=E(()=>{e();sw=Object.defineProperty,dw=Symbol.for(\"ConvexError\");JJ=class JJ extends(_6=Error,j6=dw,_6){constructor($){super(typeof $===\"string\"?$:S$($));$J(this,\"name\",\"ConvexError\"),$J(this,\"data\"),$J(this,j6,!0),this.data=$}}});var g=E(()=>{e();P0();wJ()});var m=\"1.28.0\";function n$($,J){if(typeof Convex>\"u\"||Convex.syscall===void 0)throw Error(\"The Convex database and auth objects are being used outside of a Convex backend. Did you mean to use `useQuery` or `useMutation` to call a Convex function?\");let w=Convex.syscall($,JSON.stringify(J));return JSON.parse(w)}async function A($,J){if(typeof Convex>\"u\"||Convex.asyncSyscall===void 0)throw Error(\"The Convex database and auth objects are being used outside of a Convex backend. Did you mean to use `useQuery` or `useMutation` to call a Convex function?\");let w;try{w=await Convex.asyncSyscall($,JSON.stringify(J))}catch(Z){if(Z.data!==void 0){let W=new JJ(Z.message);throw W.data=R(Z.data),W}throw Error(Z.message)}return JSON.parse(w)}var O$=E(()=>{wJ();e()});var ZJ;var k6=E(()=>{ZJ=Symbol.for(\"functionName\")});function tw($){return $[iw]??null}function rw($){return $.startsWith(\"function://\")}function s$($){let J;if(typeof $===\"string\")if(rw($))J={functionHandle:$};else J={name:$};else if($[ZJ])J={name:$[ZJ]};else{let w=tw($);if(!w)throw Error(`${$} is not a functionReference`);J={reference:w}}return J}var iw;var WJ=E(()=>{k6();iw=Symbol.for(\"toReferencePath\")});function L($,J,w,Z){if($===void 0)throw TypeError(`Must provide arg ${J} \\`${Z}\\` to \\`${w}\\``)}function N6($,J,w,Z){if(!Number.isInteger($)||$<0)throw TypeError(`Arg ${J} \\`${Z}\\` to \\`${w}\\` must be a non-negative integer`)}function XJ($){return{getUserIdentity:async()=>{return await A(\"1.0/getUserIdentity\",{requestId:$})}}}var h6=E(()=>{O$()});class YJ{constructor(){I6(this,\"_isExpression\"),I6(this,\"_value\")}}var lw,aw=($,J,w)=>(J in $)?lw($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,I6=($,J,w)=>aw($,typeof J!==\"symbol\"?J+\"\":J,w);var f6=E(()=>{lw=Object.defineProperty});function P($){if($ instanceof N)return $.serialize();else return{$literal:i($)}}var ew,$Z=($,J,w)=>(J in $)?ew($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,JZ=($,J,w)=>$Z($,typeof J!==\"symbol\"?J+\"\":J,w),N,x6;var y6=E(()=>{e();f6();ew=Object.defineProperty;N=class N extends YJ{constructor($){super();JZ(this,\"inner\"),this.inner=$}serialize(){return this.inner}};x6={eq($,J){return new N({$eq:[P($),P(J)]})},neq($,J){return new N({$neq:[P($),P(J)]})},lt($,J){return new N({$lt:[P($),P(J)]})},lte($,J){return new N({$lte:[P($),P(J)]})},gt($,J){return new N({$gt:[P($),P(J)]})},gte($,J){return new N({$gte:[P($),P(J)]})},add($,J){return new N({$add:[P($),P(J)]})},sub($,J){return new N({$sub:[P($),P(J)]})},mul($,J){return new N({$mul:[P($),P(J)]})},div($,J){return new N({$div:[P($),P(J)]})},mod($,J){return new N({$mod:[P($),P(J)]})},neg($){return new N({$neg:P($)})},and(...$){return new N({$and:$.map(P)})},or(...$){return new N({$or:$.map(P)})},not($){return new N({$not:P($)})},field($){return new N({$field:$})}}});class GJ{constructor(){WZ(this,\"_isIndexRange\")}}var wZ,ZZ=($,J,w)=>(J in $)?wZ($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,WZ=($,J,w)=>ZZ($,typeof J!==\"symbol\"?J+\"\":J,w);var g6=E(()=>{wZ=Object.defineProperty});var XZ,YZ=($,J,w)=>(J in $)?XZ($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,b6=($,J,w)=>YZ($,typeof J!==\"symbol\"?J+\"\":J,w),$$;var m6=E(()=>{e();g6();XZ=Object.defineProperty;$$=class $$ extends GJ{constructor($){super();b6(this,\"rangeExpressions\"),b6(this,\"isConsumed\"),this.rangeExpressions=$,this.isConsumed=!1}static new(){return new $$([])}consume(){if(this.isConsumed)throw Error(\"IndexRangeBuilder has already been used! Chain your method calls like `q => q.eq(...).eq(...)`. See https://docs.convex.dev/using/indexes\");this.isConsumed=!0}eq($,J){return this.consume(),new $$(this.rangeExpressions.concat({type:\"Eq\",fieldPath:$,value:i(J)}))}gt($,J){return this.consume(),new $$(this.rangeExpressions.concat({type:\"Gt\",fieldPath:$,value:i(J)}))}gte($,J){return this.consume(),new $$(this.rangeExpressions.concat({type:\"Gte\",fieldPath:$,value:i(J)}))}lt($,J){return this.consume(),new $$(this.rangeExpressions.concat({type:\"Lt\",fieldPath:$,value:i(J)}))}lte($,J){return this.consume(),new $$(this.rangeExpressions.concat({type:\"Lte\",fieldPath:$,value:i(J)}))}export(){return this.consume(),this.rangeExpressions}}});class QJ{constructor(){KZ(this,\"_isSearchFilter\")}}var GZ,QZ=($,J,w)=>(J in $)?GZ($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,KZ=($,J,w)=>QZ($,typeof J!==\"symbol\"?J+\"\":J,w);var KJ=E(()=>{GZ=Object.defineProperty});var UZ,HZ=($,J,w)=>(J in $)?UZ($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,c6=($,J,w)=>HZ($,typeof J!==\"symbol\"?J+\"\":J,w),P$;var p6=E(()=>{e();KJ();UZ=Object.defineProperty;P$=class P$ extends QJ{constructor($){super();c6(this,\"filters\"),c6(this,\"isConsumed\"),this.filters=$,this.isConsumed=!1}static new(){return new P$([])}consume(){if(this.isConsumed)throw Error(\"SearchFilterBuilder has already been used! Chain your method calls like `q => q.search(...).eq(...)`.\");this.isConsumed=!0}search($,J){return L($,1,\"search\",\"fieldName\"),L(J,2,\"search\",\"query\"),this.consume(),new P$(this.filters.concat({type:\"Search\",fieldPath:$,value:J}))}eq($,J){if(L($,1,\"eq\",\"fieldName\"),arguments.length!==2)L(J,2,\"search\",\"value\");return this.consume(),new P$(this.filters.concat({type:\"Eq\",fieldPath:$,value:i(J)}))}export(){return this.consume(),this.filters}}});function u6($){throw Error($===\"consumed\"?\"This query is closed and can't emit any more values.\":\"This query has been chained with another operator and can't be reused.\")}var SZ,OZ=($,J,w)=>(J in $)?SZ($,J,{enumerable:!0,configurable:!0,writable:!0,value:w}):$[J]=w,UJ=($,J,w)=>OZ($,typeof J!==\"symbol\"?J+\"\":J,w),v6=256,o$,J$;var HJ=E(()=>{g();O$();y6();m6();p6();SZ=Object.defineProperty;o$=class o${constructor($){UJ(this,\"tableName\"),this.tableName=$}withIndex($,J){L($,1,\"withIndex\",\"indexName\");let w=$$.new();if(J!==void 0)w=J(w);return new J$({source:{type:\"IndexRange\",indexName:this.tableName+\".\"+$,range:w.export(),order:null},operators:[]})}withSearchIndex($,J){L($,1,\"withSearchIndex\",\"indexName\"),L(J,2,\"withSearchIndex\",\"searchFilter\");let w=P$.new();return new J$({source:{type:\"Search\",indexName:this.tableName+\".\"+$,filters:J(w).export()},operators:[]})}fullTableScan(){return new J$({source:{type:\"FullTableScan\",tableName:this.tableName,order:null},operators:[]})}order($){return this.fullTableScan().order($)}async count(){let $=await A(\"1.0/count\",{table:this.tableName});return R($)}filter($){return this.fullTableScan().filter($)}limit($){return this.fullTableScan().limit($)}collect(){return this.fullTableScan().collect()}take($){return this.fullTableScan().take($)}paginate($){return this.fullTableScan().paginate($)}first(){return this.fullTableScan().first()}unique(){return this.fullTableScan().unique()}[Symbol.asyncIterator](){return this.fullTableScan()[Symbol.asyncIterator]()}};J$=class J${constructor($){if(UJ(this,\"state\"),UJ(this,\"tableNameForErrorMessages\"),this.state={type:\"preparing\",query:$},$.source.type===\"FullTableScan\")this.tableNameForErrorMessages=$.source.tableName;else this.tableNameForErrorMessages=$.source.indexName.split(\".\")[0]}takeQuery(){if(this.state.type!==\"preparing\")throw Error(\"A query can only be chained once and can't be chained after iteration begins.\");let $=this.state.query;return this.state={type:\"closed\"},$}startQuery(){if(this.state.type===\"executing\")throw Error(\"Iteration can only begin on a query once.\");if(this.state.type===\"closed\"||this.state.type===\"consumed\")u6(this.state.type);let $=this.state.query,{queryId:J}=n$(\"1.0/queryStream\",{query:$,version:m});return this.state={type:\"executing\",queryId:J},J}closeQuery(){if(this.state.type===\"executing\"){let $=this.state.queryId;n$(\"1.0/queryCleanup\",{queryId:$})}this.state={type:\"consumed\"}}order($){L($,1,\"order\",\"order\");let J=this.takeQuery();if(J.source.type===\"Search\")throw Error(\"Search queries must always be in relevance order. Can not set order manually.\");if(J.source.order!==null)throw Error(\"Queries may only specify order at most once\");return J.source.order=$,new J$(J)}filter($){L($,1,\"filter\",\"predicate\");let J=this.takeQuery();if(J.operators.length>=v6)throw Error(`Can't construct query with more than ${v6} operators`);return J.operators.push({filter:P($(x6))}),new J$(J)}limit($){L($,1,\"limit\",\"n\");let J=this.takeQuery();return J.operators.push({limit:$}),new J$(J)}[Symbol.asyncIterator](){return this.startQuery(),this}async next(){if(this.state.type===\"closed\"||this.state.type===\"consumed\")u6(this.state.type);let $=this.state.type===\"preparing\"?this.startQuery():this.state.queryId,{value:J,done:w}=await A(\"1.0/queryStreamNext\",{queryId:$});if(w)this.closeQuery();return{value:R(J),done:w}}return(){return this.closeQuery(),Promise.resolve({done:!0,value:void 0})}async paginate($){if(L($,1,\"paginate\",\"options\"),typeof $?.numItems!==\"number\"||$.numItems<0)throw Error(`\\`options.numItems\\` must be a positive number. Received \\`${$?.numItems}\\`.`);let J=this.takeQuery(),w=$.numItems,Z=$.cursor,W=$?.endCursor??null,X=$.maximumRowsRead??null,{page:Y,isDone:G,continueCursor:Q,splitCursor:K,pageStatus:H}=await A(\"1.0/queryPage\",{query:J,cursor:Z,endCursor:W,pageSize:w,maximumRowsRead:X,maximumBytesRead:$.maximumBytesRead,version:m});return{page:Y.map((U)=>R(U)),isDone:G,continueCursor:Q,splitCursor:K,pageStatus:H}}async collect(){let $=[];for await(let J of this)$.push(J);return $}async take($){return L($,1,\"take\",\"n\"),N6($,1,\"take\",\"n\"),this.limit($).collect()}async first(){let $=await this.take(1);return $.length===0?null:$[0]}async unique(){let $=await this.take(2);if($.length===0)return null;if($.length===2)throw Error(`unique() query returned more than one result from table ${this.tableNameForErrorMessages}:\n [${$[0]._id}, ${$[1]._id}, ...]`);return $[0]}}});async function SJ($,J,w){if(L(J,1,\"get\",\"id\"),typeof J!==\"string\")throw Error(`Invalid argument \\`id\\` for \\`db.get\\`, expected string but got '${typeof J}': ${J}`);let Z={id:B(J),isSystem:w,version:m,table:$},W=await A(\"1.0/get\",Z);return R(W)}function CJ(){let $=(W=!1)=>{return{get:async(X,Y)=>{return Y!==void 0?await SJ(X,Y,W):await SJ(void 0,X,W)},query:(X)=>{return new B0(X,W).query()},normalizeId:(X,Y)=>{L(X,1,\"normalizeId\",\"tableName\"),L(Y,2,\"normalizeId\",\"id\");let G=X.startsWith(\"_\");if(G!==W)throw Error(`${G?\"System\":\"User\"} tables can only be accessed from db.${W?\"\":\"system.\"}normalizeId().`);let Q=n$(\"1.0/db/normalizeId\",{table:X,idString:Y});return R(Q).id},system:null,table:(X)=>{return new B0(X,W)}}},{system:J,...w}=$(!0),Z=$();return Z.system=w,Z}async function n6($,J){if($.startsWith(\"_\"))throw Error(\"System tables (prefixed with `_`) are read-only.\");L($,1,\"insert\",\"table\"),L(J,2,\"insert\",\"value\");let w=await A(\"1.0/insert\",{table:$,value:B(J)});return R(w)._id}async function OJ($,J,w){L(J,1,\"patch\",\"id\"),L(w,2,\"patch\",\"value\"),await A(\"1.0/shallowMerge\",{id:B(J),value:A6(w),table:$})}async function zJ($,J,w){L(J,1,\"replace\",\"id\"),L(w,2,\"replace\",\"value\"),await A(\"1.0/replace\",{id:B(J),value:B(w),table:$})}async function FJ($,J){L(J,1,\"delete\",\"id\"),await A(\"1.0/remove\",{id:B(J),table:$})}function s6(){let $=CJ();return{get:$.get,query:$.query,normalizeId:$.normalizeId,system:$.system,insert:async(J,w)=>{return await n6(J,w)},patch:async(J,w,Z)=>{return Z!==void 0?await OJ(J,w,Z):await OJ(void 0,J,w)},replace:async(J,w,Z)=>{return Z!==void 0?await zJ(J,w,Z):await zJ(void 0,J,w)},delete:async(J,w)=>{return w!==void 0?await FJ(J,w):await FJ(void 0,J)},table:(J)=>{return new o6(J,!1)}}}class B0{constructor($,J){this.tableName=$,this.isSystem=J}async get($){return SJ(this.tableName,$,this.isSystem)}query(){let $=this.tableName.startsWith(\"_\");if($!==this.isSystem)throw Error(`${$?\"System\":\"User\"} tables can only be accessed from db.${this.isSystem?\"\":\"system.\"}query().`);return new o$(this.tableName)}}var o6;var d6=E(()=>{g();O$();HJ();e();o6=class o6 extends B0{async insert($){return n6(this.tableName,$)}async patch($,J){return OJ(this.tableName,$,J)}async replace($,J){return zJ(this.tableName,$,J)}async delete($){return FJ(this.tableName,$)}}});function i6(){return{runAfter:async($,J,w)=>{let Z=zZ($,J,w);return await A(\"1.0/schedule\",Z)},runAt:async($,J,w)=>{let Z=FZ($,J,w);return await A(\"1.0/schedule\",Z)},cancel:async($)=>{L($,1,\"cancel\",\"id\");let J={id:B($)};await A(\"1.0/cancel_job\",J)}}}function zZ($,J,w){if(typeof $!==\"number\")throw Error(\"`delayMs` must be a number\");if(!isFinite($))throw Error(\"`delayMs` must be a finite number\");if($<0)throw Error(\"`delayMs` must be non-negative\");let Z=c$(w),W=s$(J),X=(Date.now()+$)/1000;return{...W,ts:X,args:B(Z),version:m}}function FZ($,J,w){let Z;if($ instanceof Date)Z=$.valueOf()/1000;else if(typeof $===\"number\")Z=$/1000;else throw Error(\"The invoke time must a Date or a timestamp\");let W=s$(J),X=c$(w);return{...W,ts:Z,args:B(X),version:m}}var t6=E(()=>{g();O$();WJ()});function MJ($){return{getUrl:async(J)=>{return L(J,1,\"getUrl\",\"storageId\"),await A(\"1.0/storageGetUrl\",{requestId:$,version:m,storageId:J})},getMetadata:async(J)=>{return await A(\"1.0/storageGetMetadata\",{requestId:$,version:m,storageId:J})}}}function r6($){let J=MJ($);return{generateUploadUrl:async()=>{return await A(\"1.0/storageGenerateUploadUrl\",{requestId:$,version:m})},delete:async(w)=>{await A(\"1.0/storageDelete\",{requestId:$,version:m,storageId:w})},getUrl:J.getUrl,getMetadata:J.getMetadata}}var l6=E(()=>{O$()});async function CZ($,J){let Z=R(JSON.parse(J)),W={db:s6(),auth:XJ(\"\"),storage:r6(\"\"),scheduler:i6(),runQuery:(Y,G)=>RJ(\"query\",Y,G),runMutation:(Y,G)=>RJ(\"mutation\",Y,G)},X=await e6($,W,Z);return a6(X),JSON.stringify(B(X===void 0?null:X))}function a6($){if($ instanceof o$||$ instanceof J$)throw Error(\"Return value is a Query. Results must be retrieved with `.collect()`, `.take(n), `.unique()`, or `.first()`.\")}async function e6($,J,w){let Z;try{Z=await Promise.resolve($(J,...w))}catch(W){throw MZ(W)}return Z}function $8($,J){return(w,Z)=>{return globalThis.console.warn(`Convex functions should not directly call other Convex functions. Consider calling a helper function instead. e.g. \\`export const foo = ${$}(...); await foo(ctx);\\` is not supported. See https://docs.convex.dev/production/best-practices/#use-helper-functions-to-write-shared-code`),J(w,Z)}}function MZ($){if(typeof $===\"object\"&&$!==null&&Symbol.for(\"ConvexError\")in $){let J=$;return J.data=JSON.stringify(B(J.data===void 0?null:J.data)),J.ConvexErrorSymbol=Symbol.for(\"ConvexError\"),J}else return $}function J8(){if(typeof window>\"u\"||window.__convexAllowFunctionsInBrowser)return;if(Object.getOwnPropertyDescriptor(globalThis,\"window\")?.get?.toString().includes(\"[native code]\")??!1)console.error(\"Convex functions should not be imported in the browser. This will throw an error in future versions of `convex`. If this is a false negative, please report it to Convex support.\")}function w8($,J){if(J===void 0)throw Error(`Cannot serialize validator value \\`undefined\\` for ${$}`);return J}function Z8($){return()=>{let J=z.any();if(typeof $===\"object\"&&$.args!==void 0)J=L0($.args);return JSON.stringify(J.json,w8)}}function W8($){return()=>{let J;if(typeof $===\"object\"&&$.returns!==void 0)J=L0($.returns);return JSON.stringify(J?J.json:null,w8)}}async function RZ($,J){let Z=R(JSON.parse(J)),W={db:CJ(),auth:XJ(\"\"),storage:MJ(\"\"),runQuery:(Y,G)=>RJ(\"query\",Y,G)},X=await e6($,W,Z);return a6(X),JSON.stringify(B(X===void 0?null:X))}async function RJ($,J,w){let Z=c$(w),W={udfType:$,args:B(Z),...s$(J)},X=await A(\"1.0/runUdf\",W);return R(X)}var EJ=($)=>{let J=typeof $===\"function\"?$:$.handler,w=$8(\"mutation\",J);return J8(),w.isMutation=!0,w.isPublic=!0,w.invokeMutation=(Z)=>CZ(J,Z),w.exportArgs=Z8($),w.exportReturns=W8($),w._handler=J,w},LJ=($)=>{let J=typeof $===\"function\"?$:$.handler,w=$8(\"query\",J);return J8(),w.isQuery=!0,w.isPublic=!0,w.invokeQuery=(Z)=>RZ(J,Z),w.exportArgs=Z8($),w.exportReturns=W8($),w._handler=J,w};var X8=E(()=>{g();h6();d6();HJ();t6();l6();O$();P0();WJ()});var T1;var Y8=E(()=>{P0();T1=z.object({numItems:z.number(),cursor:z.union(z.string(),z.null()),endCursor:z.optional(z.union(z.string(),z.null())),id:z.optional(z.number()),maximumRowsRead:z.optional(z.number()),maximumBytesRead:z.optional(z.number())})});var G8=E(()=>{X8();Y8();KJ()});function _($){return new Q8($)}function EZ($,J,w){if(typeof $!==\"object\"&&typeof $!==\"function\"||$===null)return null;let Z=!!$.isQuery,W=!!$.isMutation,X=!!$.isAction,Y;if(Z&&!W&&!X)Y=\"query\";else if(!Z&&W&&!X)Y=\"mutation\";else if(!Z&&!W&&X)Y=\"action\";else return null;let G=!!$.isPublic,Q=!!$.isInternal,K=null;if(G&&!Q)K=\"public\";else if(!G&&Q)K=\"internal\";else if(G&&Q)return console.warn(`Function ${J} is marked as both public and internal. Skipping.`),null;else if(!G&&!Q)K=null;let H=`${w}:${J}`,U=\"Unvalidated\";if(typeof $.exportArgs===\"function\")try{let O=$.exportArgs();if(typeof O!==\"string\")throw _(`${H}.exportArgs() didn't return a string.`);U=JSON.parse(O)}catch(O){throw _(`Invalid JSON returned from ${H}.exportArgs(): ${O.message}`)}else if($.exportArgs!==void 0)throw _(`${H}.exportArgs is not a function or \\`undefined\\`.`);let S=\"Unvalidated\";if(typeof $.exportReturns===\"function\")try{let O=$.exportReturns();if(typeof O!==\"string\")throw _(`${H}.exportReturns() didn't return a string.`);S=JSON.parse(O)}catch(O){throw _(`Invalid JSON returned from ${H}.exportReturns(): ${O.message}`)}else if($.exportReturns!==void 0)throw _(`${H}.exportReturns is not a function or \\`undefined\\`.`);return{name:J,udfType:Y,visibility:K,args:U,returns:S,pos:null}}function K8($,J){let w=[],Z=null,W=null;if(LZ(J)){if(!$.default)throw _(\"`convex/http.js` must have a default export of a Router.\");Z=DZ($.default)}else if(PZ(J)){if(!$.default)throw _(\"`convex/crons.js` must have a default export of a Crons object.\");W=VZ($.default)}else for(let X in $){if(!Object.hasOwn($,X))continue;let Y=EZ($[X],X,J);if(Y)w.push(Y)}if(w.sort((X,Y)=>X.name.localeCompare(Y.name)),Z)Z.routes.sort((X,Y)=>X.route.path.localeCompare(Y.route.path));return{functions:w,httpRoutes:Z,cronSpecs:W}}function LZ($){return U8($,\"http\")}function PZ($){return U8($,\"crons\")}function U8($,J){let w=BZ($);return w===J||w.endsWith(`/${J}`)}function BZ($){return $.replace(/\\\\/g,\"/\").replace(/^\\/+/,\"\").replace(/\\.(?:cjs|mjs|js|jsx|ts|tsx)$/i,\"\")}function DZ($){if(typeof $!==\"object\"||$===null)throw _(\"The default export of `convex/http.js` is not a Router.\");if(!$.isRouter)throw _(\"The default export of `convex/http.js` is not a Router.\");if(typeof $.getRoutes!==\"function\")throw _(\".getRoutes property on Router not found\");let J=$.getRoutes();if(!Array.isArray(J))throw _(\"The `getRoutes()` method of Router did not return an array.\");let w=[];for(let Z of J){if(!Array.isArray(Z)||Z.length<3)throw _(\"Invalid entry in routes array: must be [path, method, handler]\");let[W,X,Y]=Z;if(typeof W!==\"string\"||typeof X!==\"string\")throw _(\"Invalid entry in routes array: path and method must be strings.\");let G=X.toUpperCase();if(![\"GET\",\"POST\",\"PUT\",\"DELETE\",\"PATCH\",\"OPTIONS\"].includes(G))throw _(`'${X}' is not not a routable method.`);let Q=typeof Y;if(!(Q===\"object\"&&Y!==null||Q===\"function\")||!Y?.isHttp)throw _(\"Invalid entry in routes array: handler is not an HTTP action.\");w.push({route:{path:W,method:G},pos:null})}return{routes:w}}function VZ($){if(typeof $!==\"object\"||$===null)throw _(\"The default export of `convex/crons.js` is not a Crons object.\");if(!$.isCrons)throw _(\"The default export of `convex/crons.js` is not a Crons object.\");if(typeof $.export!==\"function\")throw _(\".export property on Crons object not found\");let J=$.export();if(typeof J!==\"string\")throw _(\".export() of Crons object did not return a string.\");try{return JSON.parse(J)}catch(w){throw _(`Invalid JSON returned from .export() of Crons object: ${w.message}`)}}var Q8;var H8=E(()=>{Q8=class Q8 extends Error{constructor($){super($);this.name=\"UdfAnalysisError\"}}});var PJ=E(()=>{H8();BJ()});async function O8($={}){let J=$.componentPath,Z=await(await z8()).listRegisteredModules({componentPath:J,hint:\"udf\"}),W=[];for(let X of Z){if(X.path.startsWith(\"_generated/\")||X.path.startsWith(\"_system\"))continue;try{let{analyzed:Y}=await qZ(X,J),G=X.source??F8(X.path),Q=X.componentPath??J,K=Y.functions??[],H=Y.httpRoutes?.routes??[];if(K.length===0&&H.length===0)continue;for(let U of K)W.push({name:U.name,module:X.path,path:`${X.path}:${U.name}`,type:U.udfType,visibility:U.visibility??null,args:U.args,returns:U.returns,source:G,componentPath:Q});for(let U of H){let S=U.route.method,O=U.route.path;W.push({name:`${S} ${O}`,module:X.path,path:`${X.path}:${S}:${O}`,type:\"http\",visibility:null,source:G,componentPath:Q,httpMethod:S,httpPath:O})}}catch(Y){console.warn(`Failed to analyze module \"${X.path}\":`,Y)}}return W.sort((X,Y)=>{let G=X.module.localeCompare(Y.module);if(G!==0)return G;return X.name.localeCompare(Y.name)}),W}async function z8(){if(!DJ)DJ=Promise.resolve().then(() => (B$(),M8));let $=await DJ;if(!S8)S8=$.onModuleLoadersChanged(()=>D0.clear());return $}async function qZ($,J){let w=TZ(J,$.path),Z=D0.get(w);if(!Z)Z=AZ($,J),Z.catch(()=>D0.delete(w)),D0.set(w,Z);return Z}async function AZ($,J){let Z=await(await z8()).loadConvexModule($.path,{componentPath:J,hint:$.hint??\"udf\"}),W=$.source??F8($.path),X=K8(Z,W);return{listing:{...$,source:W},analyzed:X}}function TZ($,J){return`${$??\"\"}::${J}`}function F8($){let J=$.replace(/\\\\/g,\"/\").replace(/^\\//,\"\"),w=J.startsWith(\"convex/\")?J:`convex/${J}`;return w.endsWith(\".ts\")||w.endsWith(\".js\")?w:`${w}.ts`}var D0,DJ=null,S8=null;var C8=E(()=>{PJ();D0=new Map});function L8($){let{query:J,mutation:w}=$;return{systemListTables:J({args:{},handler:async(Z)=>{let W=await R8(),X=[];if(W?.tables)X=_Z(W);else try{X=(await Z.db.system.query(\"_tables\").collect()).map((Q)=>({name:Q.name,exported:{indexes:Q.indexes||[],searchIndexes:Q.searchIndexes||[],vectorIndexes:Q.vectorIndexes||[],documentType:null}}))}catch{X=[]}return(await Promise.all(X.map(async(G)=>{let Q=await NZ(Z,G.name),K=G.exported,H=K?.searchIndexes??[],U=K?.vectorIndexes??[];return{name:G.name,documentCount:Q,indexes:E8(K?.indexes),searchIndexes:H.map((S)=>typeof S===\"string\"?S:S.indexDescriptor),vectorIndexes:U.map((S)=>typeof S===\"string\"?S:S.indexDescriptor)}}))).sort((G,Q)=>G.name.localeCompare(Q.name))}}),systemGetTableSchema:J({args:{tableName:z.string()},handler:async(Z,{tableName:W})=>{let X=await R8(),Y=X?kZ(X,W):null;if(Y?.exported){let G=Y.exported,Q=xZ(G.documentType,W);return{tableName:W,fields:Q,indexes:E8(G.indexes).map((K)=>({name:K,fields:hZ(G.indexes,K)})),searchIndexes:IZ(G.searchIndexes),vectorIndexes:fZ(G.vectorIndexes)}}try{let G=await Z.db.query(W).first(),Q=G?Object.keys(G).map((K)=>({name:K,type:typeof G[K],optional:!1})):[];return{tableName:W,fields:Q,indexes:[{name:\"by_id\",fields:[\"_id\"]},{name:\"by_creation_time\",fields:[\"_creationTime\"]}],searchIndexes:[],vectorIndexes:[]}}catch(G){return console.warn(`Failed to resolve schema for table ${W}:`,G),null}}}),systemGetTableData:J({args:{tableName:z.string(),page:z.number(),pageSize:z.number(),orderBy:z.optional(z.string()),order:z.optional(z.string())},handler:async(Z,W)=>{let X=Z.db.query(W.tableName);if(W.orderBy&&W.orderBy!==\"_creationTime\"){let U=(await X.collect()).sort((F,M)=>{let j=F[W.orderBy],T=M[W.orderBy];if(j<T)return W.order===\"desc\"?1:-1;if(j>T)return W.order===\"desc\"?-1:1;return 0}),S=(W.page-1)*W.pageSize,O=S+W.pageSize;return{data:U.slice(S,O),total:U.length,page:W.page,pageSize:W.pageSize,hasMore:O<U.length}}if(W.order===\"desc\")X=X.order(\"desc\");let Y=await X.collect(),G=(W.page-1)*W.pageSize,Q=G+W.pageSize;return{data:Y.slice(G,Q),total:Y.length,page:W.page,pageSize:W.pageSize,hasMore:Q<Y.length}}}),systemDeleteDocument:w({args:{tableName:z.string(),documentId:z.string()},handler:async(Z,{documentId:W})=>{await Z.db.delete(W)}}),systemUpdateDocument:w({args:{tableName:z.string(),documentId:z.string(),data:z.any()},handler:async(Z,{documentId:W,data:X})=>{await Z.db.patch(W,X)}}),systemGetLogs:J({args:{limit:z.number(),functionType:z.optional(z.string()),status:z.optional(z.string()),search:z.optional(z.string())},handler:async(Z,W)=>{try{return(await Z.db.system.query(\"_scheduled_functions\").order(\"desc\").take(W.limit)).map((Y)=>({id:Y._id,timestamp:Y._creationTime,functionName:Y.name||\"unknown\",functionType:\"mutation\",status:Y.state?.kind===\"success\"?\"success\":\"error\",duration:0,logLines:[],error:Y.state?.kind===\"failed\"?Y.state.error:void 0,requestId:Y._id}))}catch(X){return console.debug(\"[systemGetHistory] Failed to query system table:\",X),[]}}}),systemGetAnalytics:J({args:{timeRange:z.string()},handler:async(Z,{timeRange:W})=>{let X=Date.now(),Y={\"24h\":86400000,\"7d\":604800000,\"30d\":2592000000},G=X-(Y[W]||Y[\"24h\"]);try{let Q=await Z.db.system.query(\"_scheduled_functions\").filter((S)=>S.gte(S.field(\"_creationTime\"),G)).collect(),K=Q.filter((S)=>S.state?.kind===\"success\").length,H=Q.filter((S)=>S.state?.kind===\"failed\").length,U=Q.length;return{totalRequests:U,errorRate:U>0?H/U*100:0,p50Latency:50,p95Latency:100,p99Latency:200,activeConnections:0,requestsOverTime:[],functionCallsByType:{query:0,mutation:Q.length,action:0},tableOperations:{},storageUsed:0}}catch(Q){return console.debug(\"[systemGetAnalytics] Failed to query system tables:\",Q),{totalRequests:0,errorRate:0,p50Latency:0,p95Latency:0,p99Latency:0,activeConnections:0,requestsOverTime:[],functionCallsByType:{},tableOperations:{},storageUsed:0}}}}),systemListScheduledFunctions:J({args:{},handler:async(Z)=>{try{return(await Z.db.system.query(\"_scheduled_functions\").collect()).map((X)=>({_id:X._id,_creationTime:X._creationTime,name:X.name,args:X.args,state:X.state,scheduledTime:X.scheduledTime,completedTime:X.completedTime,error:X.state?.kind===\"failed\"?X.state.error:void 0}))}catch(W){return console.debug(\"[systemListScheduledFunctions] Failed to query scheduled functions:\",W),[]}}}),systemCancelScheduledFunction:w({args:{id:z.id(\"_scheduled_functions\")},handler:async(Z,{id:W})=>{await Z.db.system.delete(W)}}),systemListCrons:J({args:{},handler:async(Z)=>{try{return(await Z.db.system.query(\"_crons\").collect()).map((X)=>({_id:X._id,_creationTime:X._creationTime,name:X.name,schedule:X.schedule,functionPath:X.functionPath,args:X.args,componentPath:X.componentPath,lastRun:X.lastRun,nextRun:X.nextRun,lastRunState:X.lastRunState}))}catch(W){return console.debug(\"[systemListCronJobs] Failed to query cron jobs:\",W),[]}}}),systemListStorage:J({args:{page:z.number(),pageSize:z.number(),sortBy:z.optional(z.union(z.literal(\"uploadedAt\"),z.literal(\"size\"),z.literal(\"contentType\"))),sortOrder:z.optional(z.union(z.literal(\"asc\"),z.literal(\"desc\")))},handler:async(Z,W)=>{try{let X=await Z.db.system.query(\"_storage\").collect(),Y=W.sortBy||\"uploadedAt\",G=W.sortOrder||\"desc\",Q=X.sort((O,C)=>{let F=O[Y]??0,M=C[Y]??0;if(typeof F===\"string\"&&typeof M===\"string\")return G===\"asc\"?F.localeCompare(M):M.localeCompare(F);if(G===\"asc\")return F-M;else return M-F}),K=(W.page-1)*W.pageSize,H=K+W.pageSize,U=Q.slice(K,H),S=X.reduce((O,C)=>O+(C.size||0),0);return{files:U.map((O)=>({_id:O._id,_creationTime:O._creationTime,sha256:O.sha256,size:O.size,contentType:O.contentType})),total:X.length,page:W.page,pageSize:W.pageSize,hasMore:H<X.length,totalSize:S}}catch(X){return console.debug(\"[systemListStorageFiles] Failed to query storage files:\",X),{files:[],total:0,page:W.page,pageSize:W.pageSize,hasMore:!1,totalSize:0}}}}),systemDeleteStorage:w({args:{storageId:z.id(\"_storage\")},handler:async(Z,{storageId:W})=>{await Z.storage.delete(W)}}),systemGetStorageMetadata:J({args:{storageId:z.id(\"_storage\")},handler:async(Z,{storageId:W})=>{return await Z.db.system.get(W)}}),systemListFunctions:J({args:{componentPath:z.optional(z.string())},handler:async(Z,W)=>{let X=W.componentPath??Z?.componentPath??void 0;return(await O8({componentPath:X})).map((G)=>({name:G.name,path:G.path,type:G.type,module:G.module,visibility:G.visibility,args:G.args,returns:G.returns,source:G.source,componentPath:G.componentPath,httpMethod:G.httpMethod,httpPath:G.httpPath}))}}),systemExecuteFunction:w({args:{functionPath:z.string(),args:z.any(),functionType:z.union(z.literal(\"query\"),z.literal(\"mutation\"),z.literal(\"action\"),z.literal(\"http\")),componentPath:z.optional(z.string())},handler:async(Z,{functionPath:W,args:X,functionType:Y,componentPath:G})=>{if(typeof W!==\"string\"||!W.includes(\":\"))throw Error(`Invalid function path: ${W}`);let Q=X??{},K=jZ(W,G);try{switch(Y){case\"query\":return await Z.runQuery(K,Q);case\"mutation\":return await Z.runMutation(K,Q);case\"action\":return await Z.runAction(K,Q);case\"http\":throw Error(\"HTTP actions can be tested via HTTP requests but not executed directly here.\");default:throw Error(`Unsupported function type: ${Y}`)}}catch(H){let U=H?.message??String(H);throw Error(`Failed to execute ${W}: ${U}`)}}})}}function jZ($,J){if(J&&J.trim().length>0)return`function://${J.replace(/^\\/+|\\/+$/g,\"\")};${$}`;return $}async function R8(){try{return(await w$(\"schema\",{hint:\"schema\"}))?.default??null}catch($){return console.warn(\"Failed to load schema module:\",$),null}}function _Z($){return Object.entries($.tables??{}).map(([w,Z])=>({name:w,exported:typeof Z?.export===\"function\"?Z.export():null}))}function kZ($,J){let w=$.tables?.[J];if(!w)return null;return{name:J,exported:typeof w?.export===\"function\"?w.export():null}}async function NZ($,J){try{return(await $.db.query(J).collect()).length}catch(w){return console.warn(`Failed to count documents for table ${J}:`,w),0}}function E8($){let J=[\"by_id\",\"by_creation_time\"];if(!$||$.length===0)return J;let w=$.map((Z)=>{if(typeof Z===\"string\")return Z;return Z?.indexDescriptor}).filter((Z)=>typeof Z===\"string\"&&Z.length>0);return Array.from(new Set([...J,...w]))}function hZ($,J){if(J===\"by_id\")return[\"_id\"];if(J===\"by_creation_time\")return[\"_creationTime\",\"_id\"];return $?.find((Z)=>Z.indexDescriptor===J)?.fields??[]}function IZ($){if(!$)return[];return $.map((J)=>{if(typeof J===\"string\")return{name:J,searchField:\"\",filterFields:void 0};return{name:J.indexDescriptor,searchField:J.searchField,filterFields:J.filterFields}}).filter((J)=>typeof J.name===\"string\"&&J.name.length>0)}function fZ($){if(!$)return[];return $.map((J)=>{if(typeof J===\"string\")return{name:J,vectorField:\"\",dimension:void 0,filterFields:void 0};return{name:J.indexDescriptor,vectorField:J.vectorField,dimension:J.dimension,filterFields:J.filterFields}}).filter((J)=>typeof J.name===\"string\"&&J.name.length>0)}function xZ($,J){let w=[{name:\"_id\",type:`Id<${J}>`,optional:!1},{name:\"_creationTime\",type:\"number\",optional:!1}];if(!$||$.type!==\"object\"||!$.value)return w;for(let[Z,W]of Object.entries($.value)){let X=W;w.push({name:Z,type:VJ(X.fieldType),optional:Boolean(X.optional)})}return w}function VJ($){if(!$||typeof $!==\"object\")return\"unknown\";if($.type===\"object\")return`object{${($.value?Object.keys($.value):[]).join(\", \")}}`;if($.type===\"array\")return`array<${VJ($.value)}>`;if($.type===\"union\")return`union<${(Array.isArray($.value)?$.value.map(VJ):[]).join(\" | \")}>`;if($.type===\"literal\")return`literal(${JSON.stringify($.value)})`;if($.type===\"id\")return`Id<${$.tableName??\"unknown\"}>`;return $.type??\"unknown\"}var P8=E(()=>{g();B$();C8()});function B8(){return yZ}var yZ;var D8=E(()=>{G8();P8();yZ=L8({query:LJ,mutation:EJ})});var M8={};Cw(M8,{setModuleLoaderMetadata:()=>T8,setConcaveModuleLoader:()=>TJ,registerModuleLoader:()=>gZ,onModuleLoadersChanged:()=>pZ,loadConvexModule:()=>w$,listRegisteredModules:()=>cZ,getModuleRegistry:()=>D$,getModuleLoaderMetadata:()=>j8,getConcaveModuleLoader:()=>mZ,createModuleLoaderFromGlob:()=>jJ,clearModuleLoader:()=>bZ,ModuleRegistry:()=>A0});class A0{scopedLoaders=new Map;constructor($=[]){this.reset($,{suppressEmit:!0})}reset($,J={}){if(this.scopedLoaders.clear(),this.scopedLoaders.set(\"\",$.map(qJ)),!J.suppressEmit)V0()}clone(){let $=new A0;for(let[J,w]of this.scopedLoaders.entries())$.scopedLoaders.set(J,w.map(nZ));return $}setScopeLoaders($,J){let w=q0($);this.scopedLoaders.set(w,J.map(qJ)),V0()}setRootLoaders($){this.setScopeLoaders(\"\",$)}register($,J={}){let w=q0(J.componentPath??\"\"),Z=this.scopedLoaders.get(w)??[],W=qJ($);if(J.prepend)Z.unshift(W);else Z.push(W);return this.scopedLoaders.set(w,Z),V0(),()=>{let X=this.scopedLoaders.get(w);if(!X)return;let Y=X.indexOf(W);if(Y>=0)X.splice(Y,1);this.scopedLoaders.set(w,X),V0()}}async load($){let J=q8($.componentPath),w=[],Z=!1;for(let Y of J){let G=this.scopedLoaders.get(Y);if(!G||G.length===0)continue;for(let Q of G){Z=!0;try{let K=await Q.loader($.path,{...$,scope:Y||void 0});if(K!==void 0)return K}catch(K){w.push(K)}}}let W=$.componentPath?`module \"${$.path}\" for component \"${$.componentPath}\"`:`module \"${$.path}\"`;if(!Z)throw Error(`Unable to resolve ${W}. No module loaders are registered${$.componentPath?` for component \"${$.componentPath}\"`:\"\"}. Register a loader with \\`createConcaveWorker({ moduleLoader })\\`, \\`moduleLoaders\\`, or \\`configureModuleLoaders\\`.`);let X=Error(`Unable to resolve ${W}`);if(w.length>0)X.causes=w;throw X}async enumerate($={}){let J=q8($.componentPath),w=new Map;for(let Z of J){let W=this.scopedLoaders.get(Z);if(!W||W.length===0)continue;for(let X of W){let Y=X.metadata?.enumerate;if(!Y)continue;try{let G=await sZ(Y({componentPath:$.componentPath,hint:$.hint,scope:Z||void 0}));for(let Q of G){let K=oZ(Q);if(!K)continue;if(!w.has(K.path))w.set(K.path,{...K,scope:Z||void 0,componentPath:K.componentPath??(Z||void 0)})}}catch(G){console.debug(\"[ModuleLoader] Failed to enumerate modules:\",G)}}}return Array.from(w.values())}}function V0(){let $=i$();for(let J of Array.from($.listeners))try{J()}catch(w){console.error(\"Error in module loader change listener:\",w)}}function i$(){let $=globalThis,J=$[V8];if(!J){let w=[];J={registry:new A0(w),defaults:w,listeners:new Set},$[V8]=J}return J}function D$(){return i$().registry}function TJ($,J={}){let w=Array.isArray($)?$:[$],W=i$().registry;if(J.componentPath)W.setScopeLoaders(J.componentPath,w);else W.setRootLoaders(w)}function gZ($,J={}){return D$().register($,J)}function bZ(){let $=i$();$.registry.reset($.defaults)}async function w$($,J={}){let w=_8($,J);if(w.path===\"_system\")try{return await D$().load(w)}catch(Z){if(Z?.message?.includes(\"Unable to resolve\"))return B8();throw Z}return D$().load(w)}function mZ(){return async($,J)=>{let w=_8($,{componentPath:J?.componentPath,hint:J?.hint}),Z=J?.scope;if(Z)w.scope=Z;return D$().load(w)}}async function cZ($={}){return(await D$().enumerate($)).map(({scope:w,...Z})=>({...Z,componentPath:Z.componentPath??w??void 0}))}function T8($,J){$[A8]=J}function j8($){return $[A8]}function pZ($){let J=i$();return J.listeners.add($),()=>{J.listeners.delete($)}}function jJ($,J={}){let w=new Map,Z=new Map;for(let[X,Y]of Object.entries($)){let G=uZ(X,J.trimPrefix),Q=vZ(Y);w.set(G,Q),w.set(d$(G),Q);let K=d$(G);if(!Z.has(K))Z.set(K,{loader:Q,source:G})}let W=async(X)=>{let Y=k8(Z$(X)),G=w.get(Y)??w.get(d$(Y));if(!G)return;return G()};return T8(W,{enumerate:()=>Array.from(Z.entries()).map(([X,Y])=>({path:X,source:N8(Y.source)}))}),W}function vZ($){if(typeof $===\"function\"){let w;return()=>{if(!w)w=Promise.resolve($());return w}}let J=Promise.resolve($);return()=>J}function _8($,J){if(typeof $===\"string\")return{path:Z$($),componentPath:J.componentPath,hint:J.hint};return{path:Z$($.path),componentPath:$.componentPath??J.componentPath,hint:$.hint??J.hint,scope:$.scope}}function Z$($){let J=$.trim();if(!J)throw Error(\"Module path must be a non-empty string\");let w=J.replace(/\\\\/g,\"/\");while(w.startsWith(\"./\")||w.startsWith(\"../\"))w=w.startsWith(\"./\")?w.slice(2):w.slice(3);if(w.startsWith(\"convex/\"))w=w.slice(7);return w.replace(/^\\/+/,\"\")}function q0($){if(!$)return\"\";return Z$($)}function q8($){let J=[];if($){let Z=q0($).split(\"/\").filter(Boolean);for(let W=Z.length;W>0;W--)J.push(Z.slice(0,W).join(\"/\"))}return J.push(\"\"),J}function k8($){if(/\\.[a-zA-Z0-9]+$/.test($))return $;return`${$}.ts`}function d$($){return $.replace(/\\.[^.]+$/,\"\")}function uZ($,J){let w=$.replace(/\\\\/g,\"/\");while(w.startsWith(\"./\")||w.startsWith(\"../\"))w=w.startsWith(\"./\")?w.slice(2):w.slice(3);if(J){let Z=Z$(J);if(Z&&w.startsWith(Z))w=w.slice(Z.length)}if(w.startsWith(\"convex/\"))w=w.slice(7);return Z$(w)}function qJ($){return{loader:$,metadata:j8($)}}function nZ($){return{loader:$.loader,metadata:$.metadata}}async function sZ($){let J=$ instanceof Promise?await $:$;if(!J)return[];if(typeof J===\"string\"||AJ(J))return[J];if(iZ(J)){let w=[];for await(let Z of J)if(typeof Z===\"string\"||AJ(Z))w.push(Z);return w}if(dZ(J)){let w=[];for(let Z of J)if(typeof Z===\"string\"||AJ(Z))w.push(Z);return w}return[]}function oZ($){if(typeof $===\"string\")return{path:d$(Z$($))};if(!$||typeof $.path!==\"string\")return null;let J=d$(Z$($.path)),w=$.source?N8($.source):void 0;return{path:J,source:w,componentPath:$.componentPath?q0($.componentPath):void 0,hint:$.hint}}function N8($){if(!$)return;let J=k8(Z$($));return J.startsWith(\"convex/\")?J:`convex/${J}`}function AJ($){return $&&typeof $===\"object\"&&typeof $.path===\"string\"}function dZ($){return $&&typeof $[Symbol.iterator]===\"function\"}function iZ($){return $&&typeof $[Symbol.asyncIterator]===\"function\"}var V8,A8;var B$=E(()=>{D8();V8=Symbol.for(\"concave.moduleLoader.state\"),A8=Symbol.for(\"concave.moduleLoader.metadata\")});class _J{schemaCache=new Map;async loadTableSchema($){if(this.schemaCache.has($))return this.schemaCache.get($);try{let w=(await w$(\"schema\",{hint:\"schema\"})).default;if(w?.schemaValidation===!1)return null;if(!w||!w.tables||!w.tables[$])return null;let Z=w.tables[$],W;if(typeof Z.export===\"function\")W=Z.export().documentType;else if(Z.validator)W=Z.validator;else return null;return this.schemaCache.set($,W),W}catch(J){return console.warn(`Failed to load schema for table ${$}:`,J),null}}async validateDocument($,J){if($.startsWith(\"_\"))return;let w=await this.loadTableSchema($);if(!w)return;try{V$(w,tZ(J,[\"_id\",\"_creationTime\"]))}catch(Z){throw new q$(`Failed to insert or update a document in table \"${$}\" because it does not match the schema: ${Z.message}`)}}clearCache(){this.schemaCache.clear()}}function tZ($,J){return Object.fromEntries(Object.entries($).filter(([w])=>!J.includes(w)))}function V$($,J,w=\"\"){let Z=(X)=>X||\".\",W=(X)=>{if(X===null)return\"null\";if(X===void 0)return\"undefined\";if(typeof X===\"string\")return`\"${X}\"`;return String(X)};switch($.type){case\"null\":{if(J!==null)throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.null()`);return}case\"number\":{if(typeof J!==\"number\")throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.float64()`);return}case\"bigint\":{if(typeof J!==\"bigint\")throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.int64()`);return}case\"boolean\":{if(typeof J!==\"boolean\")throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.boolean()`);return}case\"string\":{if(typeof J!==\"string\")throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.string()`);return}case\"bytes\":{if(!(J instanceof ArrayBuffer))throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.bytes()`);return}case\"any\":return;case\"literal\":{if(J!==$.value)throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.literal(${W($.value)})`);return}case\"id\":{if(typeof J!==\"string\")throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.id(\"${$.tableName}\")`);if(rZ(J)!==$.tableName)throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.id(\"${$.tableName}\")`);return}case\"array\":{if(!Array.isArray(J))throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.array(...)`);for(let X=0;X<J.length;X++)V$($.value,J[X],`${w}[${X}]`);return}case\"union\":{let X=!1;for(let Y of $.value)try{V$(Y,J,w),X=!0;break}catch(G){}if(!X)throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.union(...)`);return}case\"object\":{if(typeof J!==\"object\")throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.object({...})`);if(!lZ(J))throw Error(`Value does not match validator.\nPath: ${Z(w)}\nValue: ${W(J)}\nValidator: v.object({...})`);for(let[X,{fieldType:Y,optional:G}]of Object.entries($.value))if(J[X]===void 0){if(!G){let Q=w?`${w}.${X}`:`.${X}`;throw Error(`Object is missing the required field \\`${X}\\`. Consider wrapping the field validator in \\`v.optional(...)\\` if this is expected.\n\nObject: ${JSON.stringify(J)}\nValidator: v.object({...})`)}}else{let Q=w?`${w}.${X}`:`.${X}`;V$(Y,J[X],Q)}for(let X of Object.keys(J))if($.value[X]===void 0)throw Error(`Object contains extra field \\`${X}\\` that is not in the validator.\n\nObject: ${JSON.stringify(J)}\nValidator: v.object({...})`);return}}}function rZ($){let J=Q0($);if(!J)return null;return H$(J.table)}function lZ($){let J=typeof $===\"object\",w=Object.getPrototypeOf($),Z=w===null||w===Object.prototype||w?.constructor?.name===\"Object\";return J&&Z}var q$;var BJ=E(()=>{B$();q$=class q$ extends Error{path;constructor($,J=\"\"){super($);this.path=J;this.name=\"ValidatorError\"}}});function xJ($){if($.length===0)return\"\";let J=\"\",w=0,Z=0;for(let W of $){w=w<<8|W,Z+=8;while(Z>=5){Z-=5;let X=w>>Z&31;J+=\"0123456789abcdefghjkmnpqrstvwxyz\"[X]}}if(Z>0){let W=w<<5-Z&31;J+=\"0123456789abcdefghjkmnpqrstvwxyz\"[W]}return J}function yJ($){if($.length===0)return new Uint8Array(0);let J=Math.floor($.length*5/8),w=new Uint8Array(J),Z=0,W=0,X=0;for(let Y of $){let G=t.get(Y);if(G===void 0)throw Error(`Invalid base32 character: ${Y}`);if(Z=Z<<5|G,W+=5,W>=8)W-=8,w[X++]=Z>>W&255}return w}function gJ($){for(let J of $)if(!t.has(J))return!1;return!0}var t;var bJ=E(()=>{t=new Map;for(let $=0;$<32;$++)t.set(\"0123456789abcdefghjkmnpqrstvwxyz\"[$],$),t.set(\"0123456789abcdefghjkmnpqrstvwxyz\"[$].toUpperCase(),$);t.set(\"i\",1);t.set(\"I\",1);t.set(\"l\",1);t.set(\"L\",1);t.set(\"o\",0);t.set(\"O\",0)});function mJ($){if($<0)throw Error(\"VInt cannot encode negative numbers\");if($>4294967295)throw Error(\"VInt cannot encode values larger than 2^32-1\");if($=$>>>0,$<128)return new Uint8Array([$]);if($<16512){let w=$-128;return new Uint8Array([128|w>>8&63,w&255])}if($<2113664){let w=$-16512;return new Uint8Array([192|w>>16&31,w>>8&255,w&255])}if($<270549120){let w=$-2113664;return new Uint8Array([224|w>>24&15,w>>16&255,w>>8&255,w&255])}let J=$-270549120;return new Uint8Array([240|J>>32&7,J>>24&255,J>>16&255,J>>8&255,J&255])}function cJ($,J=0){if(J>=$.length)throw Error(\"VInt decode: unexpected end of data\");let w=$[J];if((w&128)===0)return{value:w,bytesRead:1};if((w&192)===128){if(J+1>=$.length)throw Error(\"VInt decode: truncated 2-byte encoding\");return{value:128+((w&63)<<8|$[J+1]),bytesRead:2}}if((w&224)===192){if(J+2>=$.length)throw Error(\"VInt decode: truncated 3-byte encoding\");return{value:16512+((w&31)<<16|$[J+1]<<8|$[J+2]),bytesRead:3}}if((w&240)===224){if(J+3>=$.length)throw Error(\"VInt decode: truncated 4-byte encoding\");return{value:2113664+((w&15)<<24|$[J+1]<<16|$[J+2]<<8|$[J+3])>>>0,bytesRead:4}}if((w&248)===240){if(J+4>=$.length)throw Error(\"VInt decode: truncated 5-byte encoding\");let Z=w&7,W=($[J+1]<<24|$[J+2]<<16|$[J+3]<<8|$[J+4])>>>0;return{value:270549120+Z*4294967296+W>>>0,bytesRead:5}}throw Error(\"VInt decode: invalid prefix\")}function _0($){let J=0,w=0;for(let Z of $)J=(J+Z)%255,w=(w+J)%255;return new Uint8Array([J,w])}function pJ($,J){if(J.length!==2)return!1;let w=_0($);return w[0]===J[0]&&w[1]===J[1]}function F$($,J){if(J.length!==r)throw Error(`Internal ID must be exactly ${r} bytes, got ${J.length}`);if($<1||$>4294967295)throw Error(`Table number must be between 1 and 2^32-1, got ${$}`);let w=mJ($),Z=new Uint8Array(w.length+r);Z.set(w,0),Z.set(J,w.length);let W=_0(Z),X=new Uint8Array(Z.length+2);return X.set(Z,0),X.set(W,Z.length),xJ(X)}function a$($){if($.length<vJ||$.length>uJ)throw Error(`Invalid document ID length: ${$.length} (expected ${vJ}-${uJ})`);if(!gJ($))throw Error(\"Invalid document ID: contains invalid base32 characters\");let J=yJ($);if(J.length<19)throw Error(`Invalid document ID: decoded to ${J.length} bytes (minimum 19)`);let w=J.slice(J.length-2),Z=J.slice(0,J.length-2);if(!pJ(Z,w))throw Error(\"Invalid document ID: checksum verification failed\");let{value:W,bytesRead:X}=cJ(Z,0),Y=Z.slice(X,X+r);if(Y.length!==r)throw Error(`Invalid document ID: internal ID is ${Y.length} bytes (expected ${r})`);return{tableNumber:W,internalId:Y}}function k0($){try{return a$($),!0}catch{return!1}}function KW($){let J=new Uint8Array($);return QW(J),J}function N0(){return KW(r)}function W$($){let J=\"\";for(let w=0;w<$.length;w++)J+=$[w].toString(16).padStart(2,\"0\");return J}var r=16,vJ=31,uJ=37,QW;var nJ=E(()=>{bJ();QW=crypto.getRandomValues.bind(crypto)});import{AsyncLocalStorage as AW}from\"async_hooks\";var Y$=()=>{};function v0($){return{syscall:(J,w)=>{return Y$(\"CfConvex::syscall\",J,w),$.syscall(J,w)},asyncSyscall:async(J,w)=>{return Y$(\"CfConvex::asyncSyscall\",J,w),$.asyncSyscall(J,w)},jsSyscall:async(J,w)=>{return Y$(\"CfConvex::jsSyscall\",J,w),$.jsSyscall(J,w)},op:(J,...w)=>{return Y$(\"CfConvex::op\",J,w),$.op(J,...w)}}}class C6{syscall($,J){return Y$(\"CfConvex::syscall\",$,J),\"{}\"}asyncSyscall($,J){return Y$(\"CfConvex::asyncSyscall\",$,J),Promise.resolve(JSON.stringify({done:!0,value:{}}))}async jsSyscall($,J){return Y$(\"CfConvex::jsSyscall\",$,J),Promise.resolve({})}op($,...J){return Y$(\"CfConvex::op\",$,J),{}}}var rW=new C6;function Mw($){let J=1779033703,w=3144134277,Z=1013904242,W=2773480762;for(let X=0;X<$.length;X++){let Y=$.charCodeAt(X);J=w^Math.imul(J^Y,597399067),w=Z^Math.imul(w^Y,2869860233),Z=W^Math.imul(Z^Y,951274213),W=J^Math.imul(W^Y,2716044179)}return J=Math.imul(Z^J>>>18,597399067),w=Math.imul(W^w>>>22,2869860233),Z=Math.imul(J^Z>>>17,951274213),W=Math.imul(w^W>>>19,2716044179),J^=w^Z^W,w^=J,Z^=J,W^=J,[J>>>0,w>>>0,Z>>>0,W>>>0]}function Rw($,J,w,Z){return()=>{$|=0,J|=0,w|=0,Z|=0;let W=($+J|0)+Z|0;return Z=Z+1|0,$=J^J>>>9,J=w+(w<<3)|0,w=w<<21|w>>>11,w=w+W|0,(W>>>0)/4294967296}}function Ew($){return()=>$()}function Lw($){return()=>{let J=new Uint8Array(16);for(let Z=0;Z<16;Z++)J[Z]=Math.floor($()*256);J[6]=J[6]&15|64,J[8]=J[8]&63|128;let w=Array.from(J,(Z)=>Z.toString(16).padStart(2,\"0\")).join(\"\");return`${w.slice(0,8)}-${w.slice(8,12)}-${w.slice(12,16)}-${w.slice(16,20)}-${w.slice(20)}`}}function Pw($){return(J)=>{let w=new Uint8Array(J.buffer);for(let Z=0;Z<w.length;Z++)w[Z]=Math.floor($()*256);return J}}function x$($){let[J,w,Z,W]=Mw($),X=Rw(J,w,Z,W);return{mathRandom:Ew(X),cryptoRandomUUID:Lw(X),cryptoGetRandomValues:Pw(X)}}function Dw($){let J=new ArrayBuffer(8);new DataView(J).setFloat64(0,$,!1);let Z=new Uint8Array(J);if($>=0)Z[0]^=128;else for(let W=0;W<8;W++)Z[W]^=255;return Z}function Vw($){let J=-(2n**63n),w=2n**63n-1n;if($<J)$=J;if($>w)$=w;let Z=new ArrayBuffer(8),W=new DataView(Z),X=$<0n?$+2n**64n:$;W.setBigUint64(0,X,!1);let Y=new Uint8Array(Z);return Y[0]^=128,Y}function qw($){let w=new TextEncoder().encode($),Z=0;for(let Y of w)if(Y===0)Z++;let W=new Uint8Array(w.length+Z+2),X=0;for(let Y of w)if(Y===0)W[X++]=0,W[X++]=1;else W[X++]=Y;return W[X++]=0,W[X++]=0,W}function Aw($){if($===null||$===void 0)return new Uint8Array([0]);if(typeof $===\"boolean\")return new Uint8Array([$?17:16]);if(typeof $===\"number\"){if(Number.isNaN($))return new Uint8Array([38]);if(!Number.isFinite($))return new Uint8Array([$===-1/0?32:37]);if($===0)return new Uint8Array([Object.is($,-0)?34:35]);let J=$>0?36:33,w=Dw($),Z=new Uint8Array(1+w.length);return Z[0]=J,Z.set(w,1),Z}if(typeof $===\"bigint\"){if($===0n)return new Uint8Array([49]);let J=$>0n?50:48,w=Vw($),Z=new Uint8Array(1+w.length);return Z[0]=J,Z.set(w,1),Z}if(typeof $===\"string\"){let J=qw($),w=new Uint8Array(1+J.length);return w[0]=64,w.set(J,1),w}if($ instanceof ArrayBuffer||$ instanceof Uint8Array){let J=$ instanceof Uint8Array?$:new Uint8Array($),w=new Uint8Array(1+J.length+2);return w[0]=80,w.set(J,1),w[w.length-2]=0,w[w.length-1]=0,w}throw Error(`Cannot encode value of type ${typeof $} in index key`)}function G$($){if($.length===0)return new ArrayBuffer(0);let J=$.map(Aw),w=J.reduce((X,Y)=>X+Y.length,0),Z=new Uint8Array(w),W=0;for(let X of J)Z.set(X,W),W+=X.length;return Z.buffer}function n0($,J){let w=new Uint8Array($),Z=new Uint8Array(J),W=Math.min(w.length,Z.length);for(let X=0;X<W;X++){if(w[X]<Z[X])return-1;if(w[X]>Z[X])return 1}if(w.length<Z.length)return-1;if(w.length>Z.length)return 1;return 0}function R6($,J){return n0($,J)===0}function s0($){return G$($)}function o0($){if($.length===0)return null;let J=G$($),w=new Uint8Array(J.byteLength+1);return w.set(new Uint8Array(J),0),w[J.byteLength]=255,w.buffer}function Tw($,J){let w=J.split(\".\"),Z=$;for(let W of w){if(Z===null||Z===void 0)return;if(typeof Z!==\"object\"||Array.isArray(Z))return;Z=Z[W]}return Z}function E6($,J){let w=[];for(let Z of J){let W=Tw($,Z);if(W===void 0)return null;w.push(W)}return G$(w)}function g$($,J,w,Z,W){let X=[],Y=q($);for(let G of W){let Q=q(`${$}:${G.name}`),K=Z!==null?E6(Z,G.fields):null,H=w!==null?E6(w,G.fields):null;if(!(K===null&&H!==null||K!==null&&H===null||K!==null&&H!==null&&!R6(K,H)))continue;if(K!==null)X.push({index_id:Q,key:K,value:{type:\"Deleted\"}});if(H!==null)X.push({index_id:Q,key:H,value:{type:\"NonClustered\",doc_id:J}})}return X}function L6(){return[{name:\"by_creation_time\",fields:[\"_creationTime\",\"_id\"]},{name:\"by_id\",fields:[\"_id\"]}]}BJ();B$();class kJ{cachedSchemaDefinition=void 0;tableCache=new Map;schemaValidator=new _J;async validate($,J){try{await this.schemaValidator.validateDocument($,J)}catch(w){if(w instanceof q$)throw Error(w.message);throw w}}async getTableSchema($){if(this.tableCache.has($))return this.tableCache.get($)??null;let w=(await this.getSchemaDefinition())?.tables?.[$]??null;return this.tableCache.set($,w),w}async getIndexFieldsForTable($,J){if(J===\"by_creation_time\")return[\"_creationTime\",\"_id\"];if(J===\"by_id\")return[\"_id\"];let W=(await this.getTableSchema($))?.indexes?.find((X)=>X.indexDescriptor===J);if(!W)return null;return[...W.fields,\"_creationTime\",\"_id\"]}async getAllIndexesForTable($){let J=[...L6()],Z=(await this.getTableSchema($))?.indexes;if(Z)for(let W of Z)J.push({name:W.indexDescriptor,fields:[...W.fields,\"_creationTime\",\"_id\"]});return J}async getSearchIndexConfig($,J){return(await this.getTableSchema($))?.searchIndexes?.find((W)=>W.indexDescriptor===J)??null}async getVectorIndexConfig($,J){return(await this.getTableSchema($))?.vectorIndexes?.find((W)=>W.indexDescriptor===J)??null}async getAllVectorIndexes(){let $=await this.getSchemaDefinition();if(!$?.tables)return[];let J=[];for(let[w,Z]of Object.entries($.tables)){let W=Z?.vectorIndexes;if(W)for(let X of W)J.push({tableName:w,indexDescriptor:X.indexDescriptor,vectorField:X.vectorField,filterFields:X.filterFields??[]})}return J}async getAllSearchIndexes(){let $=await this.getSchemaDefinition();if(!$?.tables)return[];let J=[];for(let[w,Z]of Object.entries($.tables)){let W=Z?.searchIndexes;if(W)for(let X of W)J.push({tableName:w,indexDescriptor:X.indexDescriptor,searchField:X.searchField,filterFields:X.filterFields??[]})}return J}async getTableNames(){let $=await this.getSchemaDefinition();if(!$?.tables)return[];return Object.keys($.tables)}async getSchemaDefinition(){if(this.cachedSchemaDefinition!==void 0)return this.cachedSchemaDefinition;try{let $=await w$(\"schema\",{hint:\"schema\"});this.cachedSchemaDefinition=$.default??null}catch($){console.warn(\"Failed to load Convex schema definition:\",$),this.cachedSchemaDefinition=null}return this.cachedSchemaDefinition}}class NJ{persistence;mutationTransaction;context;constructor($,J){this.persistence=$;this.mutationTransaction=J}attachContext($){this.context=$}getTransaction(){return this.mutationTransaction}hasTransaction(){return!!this.mutationTransaction}getTimestampOracle(){return this.persistence.timestampOracle}computeSnapshotTimestamp($,J){if(this.mutationTransaction)return this.mutationTransaction.getSnapshotTimestamp();let Z=this.getTimestampOracle()?.getCurrentTimestamp()??0n,W=BigInt(Date.now()),X=Z>W?Z:W;return $??J??X}allocateTimestamp(){let $=this.getTimestampOracle();if($)return $.allocateTimestamp();return BigInt(Date.now())}async fetchLatestDocument($,J){if(this.mutationTransaction)return this.mutationTransaction.getLatest($);return this.persistence.get($,J)}async fetchTable($,J){if(this.mutationTransaction)return this.mutationTransaction.scanTable($);return this.persistence.scan($,J)}async applyWrites($,J,w){if(this.mutationTransaction){this.mutationTransaction.stageWrite($,J,w);return}for(let{update:Z}of J)this.context?.recordIndexWrite(Z.index_id,Z.key);await this.persistence.write($,J,w)}getPersistence(){return this.persistence}}g();function x($,J){return h8(t$($),t$(J))}function h8($,J){if($[0]===J[0])return aZ($[1],J[1]);else if($[0]<J[0])return-1;return 1}function aZ($,J){if($===void 0||$===null)return 0;if(typeof $===\"bigint\"||typeof $===\"number\"||typeof $===\"boolean\"||typeof $===\"string\")return $<J?-1:$===J?0:1;if(!Array.isArray($)||!Array.isArray(J))throw Error(`Unexpected type ${$}`);for(let w=0;w<$.length&&w<J.length;w++){let Z=h8($[w],J[w]);if(Z!==0)return Z}if($.length<J.length)return-1;if($.length>J.length)return 1;return 0}function t$($){if($===void 0)return[0,void 0];if($===null)return[1,null];if(typeof $===\"bigint\")return[2,$];if(typeof $===\"number\"){if(Number.isNaN($))return[3.5,0];return[3,$]}if(typeof $===\"boolean\")return[4,$];if(typeof $===\"string\")return[5,$];if($ instanceof ArrayBuffer)return[6,Array.from(new Uint8Array($)).map(t$)];if(Array.isArray($))return[7,$.map(t$)];return[8,Object.keys($).sort().map((Z)=>[Z,$[Z]]).map(t$)]}g();function I8($,J){let w={type:\"index\",id:$,indexKey:J.map((Z)=>B(Z))};return Buffer.from(JSON.stringify(w),\"utf-8\").toString(\"base64\")}function f8($){try{let J=Buffer.from($,\"base64\").toString(\"utf-8\"),w=JSON.parse(J);if(w.type===\"index\"&&w.id&&Array.isArray(w.indexKey))return{type:\"index\",id:w.id,indexKey:w.indexKey.map((Z)=>R(Z))}}catch(J){}return{type:\"simple\",id:$}}function x8($){return $.id}function hJ($,J){let w=[],Z=null,W=null,X=!0,Y=!1;for(let H=0;H<$.length;H++){let U=$[H],S=U.fieldPath.join(\".\"),O=J[H];if(S!==O)break;switch(U.type){case\"Eq\":w.push(U.value);break;case\"Gt\":Z=U.value,X=!1;break;case\"Gte\":Z=U.value,X=!0;break;case\"Lt\":W=U.value,Y=!1;break;case\"Lte\":W=U.value,Y=!0;break}if(U.type!==\"Eq\")break}let G=[...w];if(Z!==null)G.push(Z);let Q=s0(G),K;if(W!==null){let H=[...w,W];K=Y?o0(H):s0(H)}else if(w.length>0)K=o0(w);else K=null;return{start:Q,end:K}}async function y8($,J,w,Z,W,X,Y,G,Q){let K=q(J),H=q(`${J}:${w}`),U=X===\"asc\"?\"Asc\":\"Desc\",{start:S,end:O}=hJ(W,Z),C={start:S,end:O},F=Q,M=null,j=null;if(G){let f=f8(G);if(j=x8(f),f.type===\"index\")M=G$(f.indexKey)}let T=[],D=Y!==null?Y+1:Number.MAX_SAFE_INTEGER,I=0,k=G!==null;try{let f=$.index_scan(H,K,F,C,U);for await(let[o,R$]of f){let f$=R$.value.value;if(k){if(M){let Y0=n0(o,M);if(Y0<0||Y0===0&&f$._id<=j)continue}else if(f$._id<=j)continue;k=!1}if(T.push({doc:f$,indexKey:o}),I++,I>=D)break}}catch(f){throw Error(`Index scan failed for ${J}:${w}: ${f.message}`)}let p=Y!==null&&T.length>Y;if(p)T.pop();let a=null;if(p&&T.length>0){let o=T[T.length-1].doc,R$=[];for(let f$ of Z){let Y0=o[f$];R$.push(Y0)}a=I8(o._id,R$)}return{documents:T.map((f)=>f.doc),nextCursor:a,hasMore:p}}function T0($,J){let w=$;for(let Z of J.fieldPath){if(w===null||w===void 0)return!1;w=w[Z]}switch(J.type){case\"Eq\":return w===J.value;case\"Gt\":return w>J.value;case\"Gte\":return w>=J.value;case\"Lt\":return w<J.value;case\"Lte\":return w<=J.value;default:return!1}}var b8={$add:{apply:($,J)=>$+J},$sub:{apply:($,J)=>$-J},$mul:{apply:($,J)=>$*J},$div:{apply:($,J)=>$/J,disallowZeroRight:!0},$mod:{apply:($,J)=>$%J,disallowZeroRight:!0}},m8={$neg:($)=>-$},c8={$eq:($,J)=>$===J,$neq:($,J)=>$!==J,$lt:($,J)=>$!=null&&J!=null?$<J:!1,$lte:($,J)=>$!=null&&J!=null?$<=J:!1,$gt:($,J)=>$!=null&&J!=null?$>J:!1,$gte:($,J)=>$!=null&&J!=null?$>=J:!1};function IJ($,J){let w=Object.keys($);if(w.length===1&&J(w[0]))return w[0];return w.find((Z)=>J(Z))}function $W($){return $ in b8}function JW($){return $ in m8}function g8($){return $ in c8}function wW($){return typeof $===\"string\"||typeof $===\"number\"||typeof $===\"boolean\"||$===null}function ZW($){return console.warn(\"Invalid filter:\",$),!0}function r$($){return console.warn(\"Unsupported filter type:\",$),!0}function j0($){if(!(typeof $===\"object\"&&$!==null))return!1;let w=Object.getPrototypeOf($);return w===null||w===Object.prototype||w?.constructor?.name===\"Object\"}function WW($,J,w){if(!Array.isArray(w)||w.length!==2)return null;let[Z,W]=w,X=l$($,Z),Y=l$($,W);if(typeof X!==\"number\"||typeof Y!==\"number\")return null;let G=b8[J];if(G.disallowZeroRight&&Y===0)return null;return G.apply(X,Y)}function XW($,J,w){let Z=l$($,w);return typeof Z===\"number\"?m8[J](Z):null}function YW($,J,w){if(!Array.isArray(w)||w.length!==2)return;let[Z,W]=w,X=l$($,Z),Y=l$($,W);return c8[J](X,Y)}function A$($,J){let w=$.split(\".\"),Z=J;for(let W of w){if(Z==null)return;if(!j0(Z))return;Z=Z[W]}return Z}function l$($,J){if(wW(J))return J;if(!j0(J))return J;if(\"$field\"in J)return A$(J.$field,$);if(\"$literal\"in J){let W=J.$literal;if(j0(W)&&\"$undefined\"in W)return;return W}let w=IJ(J,$W);if(w)return WW($,w,J[w]);let Z=IJ(J,JW);if(Z)return XW($,Z,J[Z]);return J}function z$($,J){if(!j0(J))return ZW(J);let w=IJ(J,(W)=>g8(W)||W===\"$and\"||W===\"$or\"||W===\"$not\");if(!w)return r$(J);let Z=J[w];if(g8(w))return YW($,w,Z)??r$(J);if(w===\"$and\"){if(!Array.isArray(Z))return r$(J);return Z.every((W)=>z$($,W))}if(w===\"$or\"){if(!Array.isArray(Z))return r$(J);return Z.some((W)=>z$($,W))}if(w===\"$not\")return!z$($,Z);return r$(J)}function fJ($,J,w){let{tableName:Z,tableId:W,expressions:X=[],indexFields:Y=[],order:G=\"asc\"}=w;if(!J||!J.hasWrites())return p8($,Y,G);let Q=new Map;for(let H of $)Q.set(H._id,H);let K=J.getTableWrites(W,Z);for(let[H,U]of K.entries())if(U===null)Q.delete(H);else if(X.length===0||X.every((O)=>T0(U,O)))Q.set(H,U);else Q.delete(H);return p8(Array.from(Q.values()),Y,G)}function p8($,J,w){let Z=w===\"asc\"?1:-1;if(J.length===0)return $.sort((W,X)=>{let Y=x(W._creationTime,X._creationTime);if(Y!==0)return Y*Z;return Y=x(W._id,X._id),Y*Z});return $.sort((W,X)=>{for(let Y of J){let G=A$(Y,W),Q=A$(Y,X),K=x(G,Q);if(K!==0)return K*Z}return 0})}bJ();nJ();nJ();function h($){if(k0($))try{let w=a$($);return{table:`#${w.tableNumber}`,internalId:W$(w.internalId),tableNumber:w.tableNumber}}catch{}let J=Q0($);if(!J)return null;return{table:J.table,internalId:J.internalId}}function sJ($){return $.startsWith(\"#\")}class u{mutationTransaction;localWrites;constructor($,J){this.mutationTransaction=$;this.localWrites=J}static fromTransaction($){return new u($,void 0)}static fromLocalWrites($){return new u(void 0,$)}static fromContext($,J){if($)return u.fromTransaction($);if(J.size>0)return u.fromLocalWrites(J);return null}hasWrites(){if(this.mutationTransaction)return this.mutationTransaction.getPendingDocuments().size>0;return(this.localWrites?.size??0)>0}getTableWrites($,J){let w=new Map;if(this.mutationTransaction){let Z=this.mutationTransaction.getPendingDocuments();for(let[W,X]of Z.entries()){if(X===null)continue;if(X.value.id.table===$){let Y=X.value.value._id;w.set(Y,X.value.value)}}}else if(this.localWrites){for(let[Z,W]of this.localWrites.entries())if(W.table===J)w.set(Z,W.value)}return w}getDocumentWrite($){if(this.mutationTransaction){let J=h($);if(!J)return;let w=b(J),W=this.mutationTransaction.getPendingDocuments().get(w);if(W===void 0)return;if(W===null)return null;return W.value.value}if(this.localWrites){let J=this.localWrites.get($);if(J===void 0)return;return J.value}return}applyToVisibilityMap($,J){if(this.mutationTransaction){let w=this.mutationTransaction.getPendingDocuments();for(let[Z,W]of w.entries())if(W===null)$.delete(Z);else if(W.value.id.table===J)$.set(Z,W)}else if(this.localWrites)for(let[w,Z]of this.localWrites.entries()){let W=h(w);if(!W||W.table!==J)continue;let X=b(W);if(Z.value===null)$.delete(X);else{let Y={ts:0n,value:{id:W,value:Z.value},prev_ts:null};$.set(X,Y)}}}}class oJ{context;docStore;schema;constructor($,J,w){this.context=$;this.docStore=J;this.schema=w}async evaluate($){return this.evaluatePaginated($,null,null).then((J)=>J.documents)}async evaluatePaginated($,J,w){let Z=$.source,W;if(Z.type===\"FullTableScan\")W=await this.handleTableScan($,J,w);else if(Z.type===\"IndexRange\")W=await this.handleIndexRange($,J,w);else if(Z.type===\"Search\")W=await this.handleSearch($,J,w);else throw Error(`Unsupported query source type: ${Z.type}`);let X=w===null;return{documents:this.applyQueryOperators(W.documents,$,X),nextCursor:W.nextCursor,hasMore:W.hasMore}}async handleTableScan($,J,w){let Z=$.source.tableName;this.context.recordTableRead(Z);let X=await this.getVisibleDocumentsForTable(Z);if($.operators){let U=$.operators.filter((S)=>S&&(\"filter\"in S)).map((S)=>S.filter);if(U.length>0)X=X.filter((S)=>U.every((O)=>z$(S,O)))}let G=($.source.order??\"asc\")===\"asc\"?1:-1;if(X.sort((U,S)=>{let O=x(U._creationTime,S._creationTime);if(O!==0)return O*G;return x(U._id,S._id)*G}),w===null)return{documents:X,nextCursor:null,hasMore:!1};let Q=0;if(J){let U=X.findIndex((S)=>S._id===J);if(U>=0)Q=U+1;else Q=X.length}let K=Q+w,H=X.slice(Q,K);return{documents:H,nextCursor:H.length>0&&K<X.length?H[H.length-1]._id:null,hasMore:K<X.length}}async handleIndexRange($,J,w){let{tableName:Z,indexDescriptor:W}=h0($.source.indexName);await this.ensureIndexRangeIsValid(Z,W,$.source);let X=await this.schema.getIndexFieldsForTable(Z,W);if(!X)throw Error(`Index ${W} not found on table ${Z}`);let Y=[];if($.source.range&&Array.isArray($.source.range))for(let K of $.source.range){let H=HW(K);if(H)Y.push(H)}if(!this.docStore.hasTransaction()){let{start:K,end:H}=hJ(Y,X);this.context.recordIndexRange(Z,W,K,H)}let G=$.source.order??\"asc\",Q;try{let K=await y8(this.docStore.getPersistence(),Z,W,X,Y,G,w,J,this.context.snapshotTimestamp),H=u.fromContext(this.docStore.getTransaction(),this.context.getLocalWrites());if(H){let U=q(Z),S=fJ(K.documents,H,{tableName:Z,tableId:U,expressions:Y,indexFields:X,order:G});if(w!==null){let O=J?S.findIndex((M)=>M._id===J)+1:0,C=Math.min(O+w,S.length),F=S.slice(O,C);Q={documents:F,nextCursor:C<S.length?F[F.length-1]._id:null,hasMore:C<S.length}}else Q={documents:S,nextCursor:null,hasMore:!1}}else Q=K}catch(K){console.debug(\"[QueryRuntime] Index query failed, falling back to full table scan:\",K);let H=await this.getVisibleDocumentsForTable(Z),U=H;if(Y.length>0)U=H.filter((O)=>Y.every((C)=>T0(O,C)));let S=G===\"asc\"?1:-1;if(U.sort((O,C)=>{for(let M of X){let j=M.split(\".\"),T=O,D=C;for(let k of j)T=T?.[k],D=D?.[k];let I=x(T,D);if(I!==0)return I*S}let F=x(O._creationTime,C._creationTime);if(F!==0)return F*S;return x(O._id,C._id)*S}),w!==null){let O=J?U.findIndex((M)=>M._id===J)+1:0,C=O+w,F=U.slice(O,C);Q={documents:F,nextCursor:F.length>0&&C<U.length?F[F.length-1]._id:null,hasMore:C<U.length}}else Q={documents:U,nextCursor:null,hasMore:!1}}return Q}async handleSearch($,J,w){let{tableName:Z,indexDescriptor:W}=h0($.source.indexName);if(this.context.recordTableRead(Z),!await this.schema.getSearchIndexConfig(Z,W))throw Error(`Cannot use search index \"${W}\" for table \"${Z}\" because it is not declared in the schema.`);let Y=Array.isArray($.source.filters)?$.source.filters:[],{searchTerm:G,filterMap:Q}=zW(Y),K=q(`${Z}:${W}`),U=$.operators?.find((F)=>(\"limit\"in F))?.limit,S=typeof w===\"number\"&&w>0?U&&U>0?Math.min(w,U):w:U&&U>0?U:void 0;return{documents:(await this.docStore.getPersistence().search(K,G,Q,{limit:S})).filter(({doc:F})=>F.ts<=this.context.snapshotTimestamp).map(({doc:F,score:M})=>({...F.value.value,_score:M})),nextCursor:null,hasMore:!1}}async getVisibleDocumentsForTable($){let J=q($),w=await this.docStore.fetchTable(J,this.context.snapshotTimestamp),Z=[];for(let X of w)if(X.ts<=this.context.snapshotTimestamp)Z.push(X.value.value);let W=u.fromContext(this.docStore.getTransaction(),this.context.getLocalWrites());return fJ(Z,W,{tableName:$,tableId:J,expressions:[],indexFields:[\"_creationTime\",\"_id\"],order:\"asc\"})}async getVisibleDocumentById($,J){let w=u.fromContext(this.docStore.getTransaction(),this.context.getLocalWrites());if(w){let W=w.getDocumentWrite($);if(W!==void 0)return W}let Z=await this.docStore.fetchLatestDocument(J,this.context.snapshotTimestamp);if(!Z||!Z.value)return null;if(Z.ts>this.context.snapshotTimestamp)return null;return Z.value.value}async ensureIndexRangeIsValid($,J,w){let Z=await this.schema.getIndexFieldsForTable($,J);if(!Z)throw Error(`Cannot use index \"${J}\" for table \"${$}\" because it is not declared in the schema.`);OW(w,Z)}applyQueryOperators($,J,w=!0){if(!J.operators&&!J.source.order)return $.sort((W,X)=>x(W._creationTime,X._creationTime));let Z=[...$];if(J.operators){let W=J.operators.filter((X)=>X&&(\"filter\"in X)).map((X)=>X.filter);if(W.length>0)Z=Z.filter((X)=>W.every((Y)=>z$(X,Y)))}if(J.source.type!==\"Search\"){let X=(J.source.order??\"asc\")===\"asc\"?1:-1;Z.sort((Y,G)=>{let Q=x(Y._creationTime,G._creationTime);if(Q!==0)return Q*X;if(Q=x(Y._id,G._id),Q!==0)return Q*X;return 0})}if(w&&J.operators){let W=J.operators.find((X)=>X&&((\"limit\"in X)||(\"take\"in X)));if(W){let X=W.limit??W.take;if(typeof X===\"number\")Z=Z.slice(0,X)}}return Z}async runVectorSearchAction($){let{tableName:J,indexDescriptor:w}=h0($.indexName);this.context.recordTableRead(J);let Z=await this.schema.getVectorIndexConfig(J,w);if(!Z)throw Error(`Cannot use vector index \"${w}\" for table \"${J}\" because it is not declared in the schema.`);let W=q(J),X=await this.docStore.fetchTable(W,this.context.snapshotTimestamp),Y=$.expressions?Array.isArray($.expressions)?$.expressions:[$.expressions]:[],G=X.map((K)=>K.value.value).filter((K)=>Y.every((H)=>z$(K,H))).map((K)=>{let H=A$(Z.vectorField,K);if(!Array.isArray(H))return null;return{doc:K,score:FW($.vector,H)}}).filter((K)=>K!==null).sort((K,H)=>{let U=H.score-K.score;if(U!==0)return U;let S=x(K.doc._creationTime,H.doc._creationTime);if(S!==0)return S;return x(K.doc._id,H.doc._id)}),Q=typeof $.limit===\"number\"&&$.limit>0?$.limit:G.length;return{results:G.slice(0,Q).map(({doc:K,score:H})=>({...K,_score:H}))}}async runSearchAction($){let{tableName:J,indexDescriptor:w}=h0($.indexName);if(this.context.recordTableRead(J),!await this.schema.getSearchIndexConfig(J,w))throw Error(`Cannot use search index \"${w}\" for table \"${J}\" because it is not declared in the schema.`);let W=new Map;if($.filter&&typeof $.filter===\"object\")for(let[Q,K]of Object.entries($.filter))W.set(Q,K);let X=q(`${J}:${w}`),Y=typeof $.search===\"string\"?$.search:\"\";return{results:(await this.docStore.getPersistence().search(X,Y,W)).map(({doc:Q,score:K})=>({...Q.value.value,_score:K}))}}}function h0($){let J=$.includes(\":\")?\":\":\".\",[w,Z]=$.split(J);if(!w||!Z)throw Error(`Invalid index name: ${$}`);return{tableName:w,indexDescriptor:Z}}function HW($){if(!$.type||!$.fieldPath)return null;return{type:$.type,fieldPath:$.fieldPath.split(\".\"),value:SW($.value)}}function SW($){if(typeof $===\"object\"&&$!==null&&\"$undefined\"in $)return;return R($)}function OW($,J){let w=0,Z=\"eq\";for(let[W,X]of $.range.entries()){if(Z===\"done\"){let G=X.type===\"Gt\"||X.type===\"Gte\"?\"lower\":\"upper\",Q=X.type===\"Gt\"?\">\":X.type===\"Gte\"?\">=\":X.type===\"Lt\"?\"<\":\"<=\";throw Error(`Already defined ${G} bound in index range. Can't add \"${X.fieldPath}\" ${Q} ${JSON.stringify(X.value)}.`)}let Y=X.type===\"Gt\"||X.type===\"Gte\"?\"gt\":X.type===\"Lt\"||X.type===\"Lte\"?\"lt\":\"eq\";switch(`${Z}|${Y}`){case\"eq|eq\":case\"eq|gt\":case\"eq|lt\":if(X.fieldPath===J[w]){w+=1,Z=Y;continue}throw Error(`Incorrect field used in \\`withIndex\\`, expected \"${J[w]}\", got \"${X.fieldPath}\"`);case\"lt|gt\":case\"gt|lt\":if(w>0&&X.fieldPath===J[w-1]){Z=\"done\";continue}throw Error(`Incorrect field used in \\`withIndex\\`, \\`.gt\\` and \\`.lt\\` must operate on the same field, expected \"${J[w-1]}\", got \"${X.fieldPath}\"`);default:{let G=X.type===\"Gt\"||X.type===\"Gte\"?\"lower\":\"upper\",Q=X.type===\"Gt\"?\">\":X.type===\"Gte\"?\">=\":X.type===\"Lt\"?\"<\":\"<=\";throw Error(`Already defined ${G} bound in index range. Can't add \"${X.fieldPath}\" ${Q} ${JSON.stringify(X.value)}.`)}}}}function zW($){let J=[],w=new Map;for(let W of $)if(W.type===\"Search\"){if(typeof W.value===\"string\"&&W.value.length>0)J.push(W.value)}else if(W.type===\"Eq\")w.set(W.fieldPath,W.value);return{searchTerm:J.join(\" \").trim(),filterMap:w}}function FW($,J){let w=0,Z=0,W=0,X=Math.min($.length,J.length);for(let Y=0;Y<X;Y++)w+=$[Y]*J[Y],Z+=$[Y]*$[Y],W+=J[Y]*J[Y];if(Z===0||W===0)return 0;return w/(Math.sqrt(Z)*Math.sqrt(W))}var v8=\"table\",u8=\"index\";function dJ($){return encodeURIComponent($)}function iJ($){return decodeURIComponent($)}function n8($){return{kind:\"table\",table:$}}function s8($,J){return{kind:\"index\",table:$,index:J}}function o8($){if($.kind===\"table\")return`${v8}:${dJ($.table)}`;return`${u8}:${dJ($.table)}:${dJ($.index)}`}function tJ($){return o8(n8($))}function T$($,J){return o8(s8($,J))}function d8($){let J=$.split(\":\");if(J.length<2)throw Error(`Invalid keyspace id: ${$}`);let w=J[0];if(w===v8){if(J.length!==2)throw Error(`Invalid table keyspace id: ${$}`);return n8(iJ(J[1]))}if(w===u8){if(J.length!==3)throw Error(`Invalid index keyspace id: ${$}`);return s8(iJ(J[1]),iJ(J[2]))}throw Error(`Unknown keyspace prefix: ${w}`)}function e$($){let J=(()=>{try{return H$($)}catch{return $}})(),w=J.indexOf(\":\");if(w===-1)throw Error(`Invalid persisted index id: ${$}`);return{table:J.slice(0,w),index:J.slice(w+1)}}class C${ranges=new Map;addDocument($){let J=G0($.internalId),w=G$([J]),Z={tableId:tJ($.table),startKey:w,endKey:w,isPoint:!0};this.addRange(Z)}addIndexRange($,J,w,Z){let W={tableId:T$($,J),startKey:w,endKey:Z,isPoint:!1};this.addRange(W)}addTableScan($){let J=new ArrayBuffer(0),w={tableId:tJ($),startKey:J,endKey:null,isPoint:!1};this.addRange(w)}addRange($){let J=this.ranges.get($.tableId);if(!J)J=[],this.ranges.set($.tableId,J);J.push($)}getRanges(){let $=[];for(let J of this.ranges.values())$.push(...J);return $}getRangesByTable(){return new Map(this.ranges)}isEmpty(){return this.ranges.size===0}size(){let $=0;for(let J of this.ranges.values())$+=J.length;return $}clear(){this.ranges.clear()}clone(){let $=new C$;for(let[J,w]of this.ranges.entries())$.ranges.set(J,w.map((Z)=>({tableId:Z.tableId,startKey:Z.startKey.slice(0),endKey:Z.endKey?Z.endKey.slice(0):null,isPoint:Z.isPoint})));return $}replaceWith($){this.ranges.clear();for(let[J,w]of $.ranges.entries())this.ranges.set(J,w.map((Z)=>({tableId:Z.tableId,startKey:Z.startKey.slice(0),endKey:Z.endKey?Z.endKey.slice(0):null,isPoint:Z.isPoint})))}getTables(){return new Set(this.ranges.keys())}}var i8=E$,t8=G0;function K$($){return{tableId:$.tableId,startKey:i8($.startKey),endKey:$.endKey?i8($.endKey):null,isPoint:$.isPoint}}function r8($){return{tableId:$.tableId,startKey:t8($.startKey),endKey:$.endKey?t8($.endKey):null,isPoint:$.isPoint}}class I0{ranges=new C$;addDocument($){this.ranges.addDocument($)}addTableScan($){this.ranges.addTableScan(q($))}addIndexRange($,J,w,Z){this.ranges.addIndexRange($,J,w,Z)}addSerializedRanges($){for(let J of $)this.ranges.addRange(r8(J))}clear(){this.ranges.clear()}serialize(){return this.ranges.getRanges().map(K$)}}var f0={_tables:1,_scheduled_functions:2,_storage:3,_crons:4},rJ=100;function lJ($,J){if(!J||J===\"\")return $;return`${J}/${$}`}function l8($){return $.startsWith(\"_\")}class a8{tablesByName=new Map;tablesByNumber=new Map;nextTableNumber=rJ;constructor(){this.registerSystemTables()}registerSystemTables(){for(let[$,J]of Object.entries(f0)){let w={tableNumber:J,name:$,componentPath:\"\",fullName:$,isSystem:!0,createdAt:Date.now()};this.tablesByName.set($,w),this.tablesByNumber.set(J,w)}}async getOrAllocateTableNumber($,J=\"\"){let w=lJ($,J),Z=this.tablesByName.get(w);if(Z)return Z.tableNumber;if(l8($)&&J===\"\"){let Y=f0[$];if(Y!==void 0)return Y}let W=this.nextTableNumber++,X={tableNumber:W,name:$,componentPath:J,fullName:w,isSystem:!1,createdAt:Date.now()};return this.tablesByName.set(w,X),this.tablesByNumber.set(W,X),W}async getTableInfo($){return this.tablesByNumber.get($)??null}async getTableInfoByName($,J=\"\"){let w=lJ($,J);return this.tablesByName.get(w)??null}async listTables($){let J=Array.from(this.tablesByNumber.values());if($===void 0)return J;return J.filter((w)=>w.componentPath===$)}async hasAccess($,J){let w=await this.getTableInfo($);if(!w)return!1;if(w.isSystem)return!0;return w.componentPath===J}getSystemTableNumber($){return f0[$]}reset(){this.tablesByName.clear(),this.tablesByNumber.clear(),this.nextTableNumber=rJ,this.registerSystemTables()}getState(){return{tableCount:this.tablesByNumber.size,nextNumber:this.nextTableNumber}}}var aJ=null;function e8(){if(!aJ)aJ=new a8;return aJ}class eJ{authContext;componentPath;snapshotTimestamp;mutationTransaction;tableRegistry;useConvexIdFormat;readLog=new I0;writeLog=new I0;localWrites=new Map;subrequestCounter=0;constructor($){this.snapshotTimestamp=$.snapshotTimestamp,this.authContext=$.authContext,this.componentPath=$.componentPath??\"\",this.mutationTransaction=$.mutationTransaction,this.tableRegistry=$.tableRegistry??e8(),this.useConvexIdFormat=$.useConvexIdFormat??!1}async getTableNumber($){return this.tableRegistry.getOrAllocateTableNumber($,this.componentPath)}nextSubrequestId($,J){return`${$}:${J}:${Date.now()}:${Math.random()}:${this.subrequestCounter++}`}clearAccessLogs(){if(this.mutationTransaction)return;this.readLog.clear(),this.writeLog.clear()}recordTableRead($){if(this.mutationTransaction){this.mutationTransaction.recordTableScan(q($),[]);return}this.readLog.addTableScan($)}recordDocumentRead($){if(this.mutationTransaction)return;this.readLog.addDocument($)}recordIndexRange($,J,w,Z){if(this.mutationTransaction){let W=T$($,J);this.mutationTransaction.recordIndexRangeScan(W,w,Z,[]);return}this.readLog.addIndexRange($,J,w,Z)}recordIndexWrite($,J){if(this.mutationTransaction)return;let{table:w,index:Z}=e$($),W=J.slice(0);this.writeLog.addIndexRange(w,Z,W,W)}recordDocumentWrite($){if(this.mutationTransaction)return;this.writeLog.addDocument($)}recordLocalWrite($,J,w,Z){if(this.localWrites.set($,{table:J,value:w}),Z){this.recordDocumentWrite(Z);return}let W=h($);if(W)this.recordDocumentWrite(W)}getLocalWrite($){return this.localWrites.get($)}getLocalWrites(){return this.localWrites}mergeReadRanges($){if(!$||this.mutationTransaction)return;this.readLog.addSerializedRanges($)}mergeWriteRanges($){if(!$||this.mutationTransaction)return;this.writeLog.addSerializedRanges($)}getTrackedReadRanges(){if(this.mutationTransaction)return this.mutationTransaction.getReadRanges().map(K$);return this.readLog.serialize()}getTrackedWriteRanges(){if(this.mutationTransaction)return this.mutationTransaction.getWrittenRanges().map(K$);return this.writeLog.serialize()}}var CW=()=>{if(typeof globalThis<\"u\"&&globalThis.AsyncLocalStorage)return globalThis.AsyncLocalStorage;try{let $=Function(\"return typeof require !== 'undefined' ? require : undefined\")();if(!$)return;return $(\"node:async_hooks\").AsyncLocalStorage}catch{return}},$w=CW();class $0{als;stack=[];constructor(){if($w)this.als=new $w}getStore(){if(this.als)return this.als.getStore()??void 0;return this.stack.length>0?this.stack[this.stack.length-1]:void 0}run($,J){if(this.als)return this.als.run($,J);this.stack.push($);let w=J();if(w&&typeof w.then===\"function\")return w.finally(()=>{this.stack.pop()});return this.stack.pop(),w}}var j$=new $0,_$=new $0,M$=new $0;var J0=new TextDecoder;function Jw($){if(Uint8Array.fromBase64)return Uint8Array.fromBase64($);let J=atob($),w=new Uint8Array(J.length);for(let Z=0;Z<J.length;Z++)w[Z]=J.charCodeAt(Z);return w}function ww($){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof $===\"string\"?$:J0.decode($),{alphabet:\"base64url\"});let J=$;if(J instanceof Uint8Array)J=J0.decode(J);J=J.replace(/-/g,\"+\").replace(/_/g,\"/\").replace(/\\s/g,\"\");try{return Jw(J)}catch{throw TypeError(\"The input to be decoded is not correctly encoded.\")}}class Zw extends Error{static code=\"ERR_JOSE_GENERIC\";code=\"ERR_JOSE_GENERIC\";constructor($,J){super($,J);this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class X$ extends Zw{static code=\"ERR_JWT_INVALID\";code=\"ERR_JWT_INVALID\"}function EW($){return typeof $===\"object\"&&$!==null}var Ww=($)=>{if(!EW($)||Object.prototype.toString.call($)!==\"[object Object]\")return!1;if(Object.getPrototypeOf($)===null)return!0;let J=$;while(Object.getPrototypeOf(J)!==null)J=Object.getPrototypeOf(J);return Object.getPrototypeOf($)===J};function x0($){if(typeof $!==\"string\")throw new X$(\"JWTs must use Compact JWS serialization, JWT must be a string\");let{1:J,length:w}=$.split(\".\");if(w===5)throw new X$(\"Only JWTs using Compact JWS serialization can be decoded\");if(w!==3)throw new X$(\"Invalid JWT\");if(!J)throw new X$(\"JWTs must contain a payload\");let Z;try{Z=ww(J)}catch{throw new X$(\"Failed to base64url decode the payload\")}let W;try{W=JSON.parse(J0.decode(Z))}catch{throw new X$(\"Failed to parse the decoded payload as JSON\")}if(!Ww(W))throw new X$(\"Invalid JWT Claims Set\");return W}function $6($){let{sub:J,iss:w,name:Z,given_name:W,family_name:X,nickname:Y,preferred_username:G,profile:Q,picture:K,email:H,email_verified:U,gender:S,birthdate:O,zoneinfo:C,locale:F,phone_number:M,phone_number_verified:j,address:T,updated_at:D,jti:I,aud:k,exp:p,iat:a,nbf:f,...o}=$;return{tokenIdentifier:`${J}@${w}`,subject:J,issuer:w,name:Z,givenName:W,familyName:X,nickname:Y,preferredUsername:G,profileUrl:Q,pictureUrl:K,email:H,emailVerified:U,gender:S,birthday:O,timezone:C,language:F,phoneNumber:M,phoneNumberVerified:j,address:T,updatedAt:D,...o}}g();import{AsyncLocalStorage as LW}from\"async_hooks\";var w0=new LW;function Xw(){let $=w0.getStore();return $?.caller===\"client\"||$===void 0}async function J6($,J){return w0.run({caller:\"server\",functionPath:J},$)}g();class w6{syncSyscalls=new Map;asyncSyscalls=new Map;registerSync($,J){if(this.syncSyscalls.has($))throw Error(`Duplicate sync syscall registration for ${$}`);this.syncSyscalls.set($,J)}registerAsync($,J,w){if(this.asyncSyscalls.has($))throw Error(`Duplicate async syscall registration for ${$}`);this.asyncSyscalls.set($,{handler:J,argsFormat:w?.argsFormat??\"json\"})}dispatchSync($,J){let w=this.syncSyscalls.get($);if(!w)throw Error(`Unknown syscall: ${$}`);let Z=JSON.parse(J),W=w(Z);return JSON.stringify(W)}async dispatchAsync($,J){let w=this.asyncSyscalls.get($);if(!w)throw Error(`Unknown async syscall: ${$}`);let Z=JSON.parse(J),W=w.argsFormat===\"convex\"?R(Z):Z,X=await w.handler(W);return JSON.stringify(B(X))}}g();async function Z0($,J){if($.tableNumber!==void 0){let w=await J.getTableInfo($.tableNumber);if(w)return w.name;if(!sJ($.table))return H$($.table);throw Error(`Unknown table number: ${$.tableNumber}`)}if(sJ($.table))throw Error(`Cannot resolve table name from placeholder without tableNumber: ${$.table}`);return H$($.table)}function y0($){if(Array.isArray($)&&$.length>0)return $[0];if(typeof $===\"object\"&&$!==null)return $;return{}}function N$($,J){if($&&typeof $.udfPath===\"string\")return{udfPath:$.udfPath,componentPath:k$($.componentPath)};if($&&typeof $.functionHandle===\"string\")return PW($.functionHandle);if($&&typeof $.reference===\"string\")return BW($.reference,J);if($&&typeof $.name===\"string\")return{udfPath:$.name,componentPath:k$($.componentPath)};throw Error(\"Unable to resolve function target from call arguments\")}function PW($){if(!$.startsWith(\"function://\"))return{udfPath:$};let J=$.slice(11),w=J.indexOf(\";\");if(w===-1)throw Error(`Invalid function handle: ${$}`);let Z=J.slice(0,w);return{udfPath:J.slice(w+1),componentPath:k$(Z)}}function BW($,J){let w=$.split(\"/\").filter((W)=>W.length>0);if(w.length<2||w[0]!==\"_reference\")throw Error(`Unsupported function reference: ${$}`);let Z=w[1];if(Z===\"childComponent\"){let W=w[2],X=w.slice(3);if(X.length===0)throw Error(`Invalid child component reference: ${$}`);let Y=X[X.length-1],G=X.slice(0,-1);if(G.length===0)throw Error(`Unable to resolve module path from reference: ${$}`);let Q=G.join(\"/\"),K=DW(J,W);return{udfPath:`${Q}:${Y}`,componentPath:K}}if(Z===\"currentSystemUdfInComponent\"){let W=w.slice(2);if(W.length===0)throw Error(`Invalid system component reference: ${$}`);let X=W[W.length-1],Y=W.slice(0,-1);if(Y.length===0)throw Error(`Unable to resolve module path from reference: ${$}`);return{udfPath:`${Y.join(\"/\")}:${X}`,componentPath:k$(J)}}throw Error(`Unsupported function reference scope: ${$}`)}function DW($,J){if(!$)return J;if(!J)return $;return`${$}/${J}`}function k$($){if(!$)return;return $.length>0?$:void 0}function Yw($,J){return`function://${$??\"\"};${J}`}function Z6($){if(typeof $===\"object\"&&$!==null&&\"$undefined\"in $)return;return R($)}class W6{resources;router=new w6;nextQueryId=1;queryResults={};pendingQueries={};constructor($){this.resources=$;this.registerSyscalls()}syscall($,J){return this.router.dispatchSync($,J)}async asyncSyscall($,J){return this.router.dispatchAsync($,J)}async jsSyscall($,J){switch($){case\"storage/storeBlob\":{let{blob:w}=J;if(!this.resources.storage)throw Error(\"Storage not configured\");let Z=await u0(w),W=\"_storage\",X=q(W),Y=this.resources.idGenerator(),G=W$(Y),Q=await this.resources.context.getTableNumber(W),K={table:X,internalId:G,tableNumber:Q},H=this.resources.context.useConvexIdFormat?F$(Q,Y):y$(X,G),U=this.resources.docStore.allocateTimestamp();await this.resources.storage.store(w,{contentType:w.type||\"application/octet-stream\",storageId:G});let S={size:w.size,sha256:Z},O={id:K,value:{...S,_id:H,_creationTime:Number(U)}},C={ts:U,id:K,value:O,prev_ts:null};return await this.resources.docStore.applyWrites([C],new Set,\"Error\"),this.resources.context.recordLocalWrite(H,W,O.value,K),H}case\"storage/getBlob\":{let{storageId:w}=J;if(!this.resources.storage)return null;let Z=h(w);if(!Z)return null;if(!await this.resources.queryRuntime.getVisibleDocumentById(w,Z))return null;let X=await this.resources.storage.get(Z.internalId);if(!X)return null;return X instanceof Blob?X:new Blob([X])}case\"storage/getUrl\":{let{storageId:w}=J;if(!this.resources.storage)return null;let Z=h(w);if(!Z)return null;if(!await this.resources.queryRuntime.getVisibleDocumentById(w,Z))return null;return await this.resources.storage.getUrl(Z.internalId)??`/api/storage/${w}`}case\"storage/generateUploadUrl\":{if(!this.resources.storage)throw Error(\"Storage not configured\");return`https://upload.concave.dev/${crypto.randomUUID()}`}case\"storage/delete\":{let{storageId:w}=J;if(!this.resources.storage)throw Error(\"Storage not configured\");let Z=h(w);if(!Z)return;let W=await this.resources.docStore.fetchLatestDocument(Z,this.resources.context.snapshotTimestamp);if(!W||W.ts>this.resources.context.snapshotTimestamp)return;await this.resources.storage.delete(Z.internalId);let Y={ts:this.resources.docStore.allocateTimestamp(),id:Z,value:null,prev_ts:W.ts};await this.resources.docStore.applyWrites([Y],new Set,\"Error\"),this.resources.context.recordLocalWrite(w,\"_storage\",null,Z);return}case\"storage/store\":{let{blob:w}=J;if(!this.resources.storage)throw Error(\"Storage not configured\");let Z=await u0(w),W=\"_storage\",X=q(W),Y=this.resources.idGenerator(),G=W$(Y),Q=await this.resources.context.getTableNumber(W),K={table:X,internalId:G,tableNumber:Q},H=this.resources.context.useConvexIdFormat?F$(Q,Y):y$(X,G),U=this.resources.docStore.allocateTimestamp();await this.resources.storage.store(w,{contentType:w.type||\"application/octet-stream\",storageId:G});let S={size:w.size,sha256:Z},O={id:K,value:{...S,_id:H,_creationTime:Number(U)}},C={ts:U,id:K,value:O,prev_ts:null};return await this.resources.docStore.applyWrites([C],new Set,\"Error\"),this.resources.context.recordLocalWrite(H,W,O.value,K),H}case\"storage/get\":{let{storageId:w}=J;if(!this.resources.storage)return null;let Z=h(w);if(!Z)return null;if(!await this.resources.queryRuntime.getVisibleDocumentById(w,Z))return null;let X=await this.resources.storage.get(Z.internalId);if(!X)return null;return X instanceof Blob?X:new Blob([X])}default:return{}}}registerSyscalls(){this.router.registerSync(\"1.0/queryStream\",($)=>this.handleQueryStream($)),this.router.registerSync(\"1.0/queryCleanup\",($)=>this.handleQueryCleanup($)),this.router.registerSync(\"1.0/db/normalizeId\",($)=>this.handleNormalizeId($)),this.router.registerAsync(\"1.0/queryStreamNext\",($)=>this.handleQueryStreamNext($)),this.router.registerAsync(\"1.0/count\",($)=>this.handleCount($)),this.router.registerAsync(\"1.0/insert\",($)=>this.handleInsert($)),this.router.registerAsync(\"1.0/get\",($)=>this.handleGet($)),this.router.registerAsync(\"1.0/remove\",($)=>this.handleRemove($)),this.router.registerAsync(\"1.0/shallowMerge\",($)=>this.handleShallowMerge($)),this.router.registerAsync(\"1.0/replace\",($)=>this.handleReplace($)),this.router.registerAsync(\"1.0/actions/query\",($)=>this.handleActionQuery($),{argsFormat:\"convex\"}),this.router.registerAsync(\"1.0/actions/action\",($)=>this.handleActionCall($,\"action\"),{argsFormat:\"convex\"}),this.router.registerAsync(\"1.0/actions/mutation\",($)=>this.handleActionCall($,\"mutation\"),{argsFormat:\"convex\"}),this.router.registerAsync(\"1.0/actions/vectorSearch\",($)=>this.handleVectorSearch($)),this.router.registerAsync(\"1.0/actions/search\",($)=>this.handleSearchAction($)),this.router.registerAsync(\"1.0/schedule\",($)=>this.handleSchedule($,!1),{argsFormat:\"convex\"}),this.router.registerAsync(\"1.0/actions/schedule\",($)=>this.handleSchedule($,!0),{argsFormat:\"convex\"}),this.router.registerAsync(\"1.0/actions/cancel_job\",($)=>this.handleCancelJob($,!0)),this.router.registerAsync(\"1.0/cancel_job\",($)=>this.handleCancelJob($,!1)),this.router.registerAsync(\"1.0/storageDelete\",($)=>this.handleStorageDelete($)),this.router.registerAsync(\"1.0/storageGenerateUploadUrl\",async()=>this.handleStorageGenerateUploadUrl()),this.router.registerAsync(\"1.0/storageGetUrl\",($)=>this.handleStorageGetUrl($)),this.router.registerAsync(\"1.0/queryPage\",($)=>this.handleQueryPage($)),this.router.registerAsync(\"1.0/runUdf\",($)=>this.handleRunUdf($),{argsFormat:\"convex\"}),this.router.registerAsync(\"1.0/createFunctionHandle\",($)=>this.handleCreateFunctionHandle($)),this.router.registerAsync(\"1.0/getUserIdentity\",async()=>this.handleGetUserIdentity())}handleQueryStream($){let{query:J}=$,w=this.nextQueryId++;return this.pendingQueries[w]=J,{queryId:w}}handleQueryCleanup($){let{queryId:J}=$;return delete this.pendingQueries[J],delete this.queryResults[J],{}}handleNormalizeId($){let{table:J,idString:w}=$;if(typeof w!==\"string\"||typeof J!==\"string\")return{id:null};let Z=h(w);if(!Z)return{id:null};if(Z.tableNumber!==void 0)return{id:w};if(Z.table===q(J))return{id:w};return{id:null}}async handleQueryStreamNext($){let{queryId:J}=$;if(this.pendingQueries[J]){let W=this.pendingQueries[J];delete this.pendingQueries[J];let X=await this.resources.queryRuntime.evaluate(W);this.queryResults[J]=X}let w=this.queryResults[J];if(!w)return{value:null,done:!0};if(w.length===0)return delete this.queryResults[J],{value:null,done:!0};return{value:w.shift(),done:!1}}async handleCount($){let{table:J}=$;if(typeof J!==\"string\")throw Error(\"`table` argument for `count` must be a string.\");return this.resources.context.recordTableRead(J),(await this.resources.queryRuntime.getVisibleDocumentsForTable(J)).length}async handleInsert($){let{table:J,value:w}=$;if(typeof J!==\"string\")throw Error(\"`table` argument for `insert` must be a string.\");let Z=R(w);if(typeof Z!==\"object\"||Z===null||Array.isArray(Z))throw Error(\"The document value for `insert` must be an object.\");await this.resources.schemaService.validate(J,Z);let W=this.resources.idGenerator(),X=W$(W),Y=q(J),G=await this.resources.context.getTableNumber(J),Q={table:Y,internalId:X,tableNumber:G},K=this.resources.context.useConvexIdFormat?F$(G,W):y$(Y,X),H=this.resources.docStore.allocateTimestamp(),U={id:Q,value:{...Z,_id:K,_creationTime:Number(H)}},S={ts:H,id:Q,value:U,prev_ts:null},O=await this.resources.schemaService.getAllIndexesForTable(J),C=g$(J,Q,U.value,null,O),F=new Set(C.map((M)=>({ts:H,update:M})));return await this.resources.docStore.applyWrites([S],F,\"Error\"),this.resources.context.recordLocalWrite(K,J,U.value,Q),{_id:K}}async handleGet($){let{id:J}=$;if(typeof J!==\"string\")throw Error(\"`id` argument for `get` must be a string.\");let w=h(J);if(!w)return null;return this.resources.context.recordDocumentRead(w),await this.resources.queryRuntime.getVisibleDocumentById(J,w)??null}async handleRemove($){let{id:J}=$;if(typeof J!==\"string\")throw Error(\"`id` argument for `remove` must be a string.\");let w=h(J);if(!w)throw Error(`Document with id ${J} not found.`);let Z=await Z0(w,this.resources.context.tableRegistry),W=await this.resources.docStore.fetchLatestDocument(w,this.resources.context.snapshotTimestamp);if(!W)throw Error(`Document with id ${J} not found.`);let X=this.resources.docStore.allocateTimestamp(),Y={ts:X,id:w,value:null,prev_ts:W.ts},G=await this.resources.schemaService.getAllIndexesForTable(Z),Q=g$(Z,w,null,W.value.value,G),K=new Set(Q.map((H)=>({ts:X,update:H})));return await this.resources.docStore.applyWrites([Y],K,\"Error\"),this.resources.context.recordLocalWrite(J,Z,null,w),{}}async handleShallowMerge($){let{id:J,value:w}=$;if(typeof J!==\"string\")throw Error(\"`id` argument for `shallowMerge` must be a string.\");let Z=h(J);if(!Z)throw Error(`Document with id ${J} not found.`);let W=await Z0(Z,this.resources.context.tableRegistry);if(w&&typeof w===\"object\"){if(\"_id\"in w)throw Error(\"System field `_id` cannot be modified in a patch operation.\");if(\"_creationTime\"in w)throw Error(\"System field `_creationTime` cannot be modified in a patch operation.\")}let X=await this.resources.docStore.fetchLatestDocument(Z,this.resources.context.snapshotTimestamp);if(!X)throw Error(`Document with id ${J} not found.`);let Y=X.value.value,G={...Y};if(typeof w===\"object\"&&w!==null&&\"$undefined\"in w){let C=w.$undefined;if(Array.isArray(C))for(let F of C)delete G[F];for(let[F,M]of Object.entries(w))if(F!==\"$undefined\")G[F]=Z6(M)}else for(let[C,F]of Object.entries(w??{}))if(F===\"$undefined\"||F===void 0)delete G[C];else if(F===null)G[C]=null;else G[C]=Z6(F);await this.resources.schemaService.validate(W,G);let Q={id:Z,value:G},K=this.resources.docStore.allocateTimestamp(),H={ts:K,id:Z,value:Q,prev_ts:X.ts},U=await this.resources.schemaService.getAllIndexesForTable(W),S=g$(W,Z,Q.value,Y,U),O=new Set(S.map((C)=>({ts:K,update:C})));return await this.resources.docStore.applyWrites([H],O,\"Error\"),this.resources.context.recordLocalWrite(J,W,Q.value,Z),{}}async handleReplace($){let{id:J,value:w}=$;if(typeof J!==\"string\")throw Error(\"`id` argument for `replace` must be a string.\");let Z=h(J);if(!Z)throw Error(`Document with id ${J} not found.`);let W=await Z0(Z,this.resources.context.tableRegistry),X=R(w);if(typeof X!==\"object\"||X===null||Array.isArray(X))throw Error(\"The replacement value for `replace` must be an object.\");let Y=await this.resources.docStore.fetchLatestDocument(Z,this.resources.context.snapshotTimestamp);if(!Y)throw Error(`Document with id ${J} not found.`);let{_id:G,_creationTime:Q}=Y.value.value,K={...X,_id:G,_creationTime:Q};await this.resources.schemaService.validate(W,K);let H={id:Z,value:K},U=this.resources.docStore.allocateTimestamp(),S={ts:U,id:Z,value:H,prev_ts:Y.ts},O=await this.resources.schemaService.getAllIndexesForTable(W),C=g$(W,Z,H.value,Y.value.value,O),F=new Set(C.map((M)=>({ts:U,update:M})));return await this.resources.docStore.applyWrites([S],F,\"Error\"),this.resources.context.recordLocalWrite(J,W,K,Z),{}}async handleVectorSearch($){let{query:J}=$;return this.resources.queryRuntime.runVectorSearchAction(J)}async handleSearchAction($){let{query:J}=$;return this.resources.queryRuntime.runSearchAction(J)}async handleSchedule($,J){if(J){let{name:Y,args:G,ts:Q}=$;if(typeof Y!==\"string\"||G===void 0||typeof Q!==\"number\")throw Error(\"`name` (string), `args` (any), and `ts` (number) are required for schedule.\");return this.createScheduledJob(Y,G,Q,void 0)}let w=N$($,this.resources.context.componentPath),{args:Z,ts:W}=$;if(Z===void 0||typeof W!==\"number\")throw Error(\"`args` (any) and `ts` (number) are required for schedule.\");let X=k$(w.componentPath??this.resources.context.componentPath);return this.createScheduledJob(w.udfPath,Z,W,X)}async createScheduledJob($,J,w,Z){let X=q(\"_scheduled_functions\"),Y=this.resources.idGenerator(),G=W$(Y),Q=await this.resources.context.getTableNumber(\"_scheduled_functions\"),K={table:X,internalId:G,tableNumber:Q},H=this.resources.context.useConvexIdFormat?F$(Q,Y):y$(X,G),U=this.resources.docStore.allocateTimestamp(),S=(()=>{try{return R(J)}catch{return J}})(),C={name:$.replace(/\\.(js|ts|mjs|mts|cjs|cts):/g,\":\"),args:[S],scheduledTime:w*1000,state:{kind:\"pending\"}};if(Z)C.componentPath=Z;let F={id:K,value:{...C,_id:H,_creationTime:Number(U)}},M={ts:U,id:K,value:F,prev_ts:null};return await this.resources.docStore.applyWrites([M],new Set,\"Error\"),this.resources.context.recordLocalWrite(H,\"_scheduled_functions\",F.value,K),H}async handleCancelJob($,J){let{id:w,state:Z}=$;if(typeof w!==\"string\")throw Error(\"`id` argument for `cancel_job` must be a string.\");let W=h(w);if(!W)throw Error(`Scheduled job with id ${w} not found.`);let X=await this.resources.docStore.fetchLatestDocument(W,this.resources.context.snapshotTimestamp);if(!X)throw Error(`Scheduled job with id ${w} not found.`);let Y={...X.value.value,state:Z??{kind:\"canceled\"}},G={id:W,value:Y},K={ts:this.resources.docStore.allocateTimestamp(),id:W,value:G,prev_ts:X.ts};await this.resources.docStore.applyWrites([K],new Set,\"Error\");let H=await Z0(W,this.resources.context.tableRegistry);return this.resources.context.recordLocalWrite(w,H,G.value,W),{}}async handleStorageDelete($){if(!this.resources.storage)throw Error(\"Storage not configured\");let J=$.storageId||$.id;if(typeof J!==\"string\")throw Error(\"`storageId` argument for `storageDelete` must be a string.\");return await this.jsSyscall(\"storage/delete\",{storageId:J}),{}}handleStorageGenerateUploadUrl(){if(!this.resources.storage)throw Error(\"Storage not configured\");let Z=process.env.CONVEX_CLOUD_URL||\"http://localhost:8799\";return`${Z}/api/storage/upload`}async handleStorageGetUrl($){let{storageId:J}=$;if(!this.resources.storage)return null;let w=h(J);if(!w)return null;if(!await this.resources.queryRuntime.getVisibleDocumentById(J,w))return null;let W=await this.resources.storage.getUrl(J),X=process.env.CONVEX_CLOUD_URL||\"http://localhost:8799\";return W??`${X}/api/storage/${J}`}async handleQueryPage($){let{query:J,cursor:w,pageSize:Z}=$;if(w===\"_end_cursor\")return{page:[],isDone:!0,continueCursor:\"_end_cursor\"};let W=await this.resources.queryRuntime.evaluatePaginated(J,w,Z);return{page:W.documents,isDone:!W.hasMore,continueCursor:W.hasMore?W.nextCursor:\"_end_cursor\"}}async handleActionQuery($){let J=N$($,this.resources.context.componentPath),w=y0($.args);return await this.executeUdf(J.udfPath,w,\"query\",J.componentPath)}async handleActionCall($,J){let w=N$($,this.resources.context.componentPath),Z=y0($.args);return await this.executeUdf(w.udfPath,Z,J,w.componentPath)}async handleRunUdf($){let J=N$($,this.resources.context.componentPath),w=y0($.args),Z=$.udfType??$.type??\"mutation\";return await this.executeUdf(J.udfPath,w,Z,J.componentPath)}handleCreateFunctionHandle($){let J=N$($,this.resources.context.componentPath);return{handle:Yw(J.componentPath??\"\",J.udfPath)}}handleGetUserIdentity(){let $=this.resources.context.authContext;if(!$)return null;switch($.tokenType){case\"User\":try{let J=x0($.token);return $6(J)}catch(J){return console.error(\"Failed to decode user token (length:\",$.token?.length??0,\"):\",J),null}case\"Admin\":if($.userIdentity)return $.userIdentity;try{let J=x0($.token);return $6(J)}catch(J){try{return JSON.parse(atob($.token))}catch(w){return console.error(\"Failed to decode admin token:\",w),null}}default:return null}}async executeUdf($,J,w,Z){if(!this.resources.udfExecutor)throw Error(`Cannot execute nested UDF ${w} ${$}: no UDF executor configured`);let W=this.resources.context.nextSubrequestId(w,$);return await J6(()=>this.invokeUdf($,J,w,Z,W),$)}async invokeUdf($,J,w,Z,W){let X=Z??this.resources.context.componentPath,Y=await this.resources.udfExecutor.execute($,J,w,this.resources.context.authContext,X,W);return this.resources.context.mergeReadRanges(Y.readRanges),this.resources.context.mergeWriteRanges(Y.writtenRanges),Y.result}}class g0{context;syscalls;constructor($,J,w,Z,W,X,Y,G){let Q=W??_$.getStore()??void 0,K=new NJ($,Q),H=j$.getStore()??null,U=K.computeSnapshotTimestamp(Z,H);this.context=new eJ({snapshotTimestamp:U,authContext:J,componentPath:Y,mutationTransaction:K.getTransaction()}),K.attachContext(this.context);let S=new kJ,O=new oJ(this.context,K,S);this.syscalls=new W6({context:this.context,docStore:K,schemaService:S,queryRuntime:O,storage:w,udfExecutor:X,idGenerator:G??N0})}clearAccessLogs(){this.context.clearAccessLogs()}getTrackedReadRanges(){return this.context.getTrackedReadRanges()}getTrackedWriteRanges(){return this.context.getTrackedWriteRanges()}getSnapshotTimestamp(){return this.context.snapshotTimestamp}syscall($,J){return this.syscalls.syscall($,J)}async asyncSyscall($,J){return this.syscalls.asyncSyscall($,J)}async jsSyscall($,J){return this.syscalls.jsSyscall($,J)}op($,...J){return{}}}class n extends Error{constructor($=\"Transaction conflict detected\"){super($);this.name=\"ConflictError\"}}class X6{persistence;stagedDocuments=new Map;stagedIndexes=new Map;readSet=new Map;snapshotTimestamp;pendingDocuments=new Map;readRanges=new C$;writeRanges=new C$;constructor($,J){this.persistence=$,this.snapshotTimestamp=J}getSnapshotTimestamp(){return this.snapshotTimestamp}recordDocumentRead($,J){let w=b($);if(!this.readSet.has(w)){let Z=J?J.ts:null;this.readSet.set(w,{version:Z,type:\"document\"}),this.readRanges.addDocument($)}return J}recordDocumentReadForOccOnly($,J){let w=b($);if(!this.readSet.has(w)){let Z=J?J.ts:null;this.readSet.set(w,{version:Z,type:\"document\"})}return J}makeIndexKey($){return`${$.index_id}:${E$($.key)}`}stageWrite($,J,w){if(w!==\"Error\")throw Error(`Unsupported conflict strategy: ${w}`);for(let Z of $){let W=b(Z.id),X=this.stagedDocuments.get(W);if(X)Z.prev_ts=X.prev_ts;this.stagedDocuments.set(W,Z);let Y=this.stagedDocuments.get(W);if(this.writeRanges.addDocument(Y.id),Y.value===null)this.pendingDocuments.set(W,null);else{let G={ts:Y.ts,value:Y.value,prev_ts:Y.prev_ts};this.pendingDocuments.set(W,G)}}for(let Z of J){let W=this.makeIndexKey(Z.update);this.stagedIndexes.set(W,Z),this.trackIndexWrite(Z.update)}}getStagedDocuments(){return Array.from(this.stagedDocuments.values())}getStagedIndexes(){return new Set(this.stagedIndexes.values())}clearWrites(){this.stagedDocuments.clear(),this.stagedIndexes.clear()}clearReads(){this.readSet.clear()}trackIndexWrite($){let{table:J,index:w}=e$($.index_id),Z=$.key.slice(0),W={tableId:T$(J,w),startKey:Z,endKey:Z,isPoint:!0};this.writeRanges.addRange(W)}async getLatest($){let J=b($);if(this.pendingDocuments.has(J)){let Z=this.pendingDocuments.get(J);return this.recordDocumentRead($,Z),Z}let w=await this.persistence.get($,this.snapshotTimestamp);return this.recordDocumentRead($,w)}createSavepoint(){return{stagedDocuments:new Map(this.stagedDocuments),stagedIndexes:new Map(this.stagedIndexes),readSet:new Map(this.readSet),pendingDocuments:new Map(this.pendingDocuments),readRanges:this.readRanges.clone(),writeRanges:this.writeRanges.clone()}}restoreSavepoint($){this.stagedDocuments.clear();for(let[J,w]of $.stagedDocuments.entries())this.stagedDocuments.set(J,w);this.stagedIndexes.clear();for(let[J,w]of $.stagedIndexes.entries())this.stagedIndexes.set(J,w);this.readSet.clear();for(let[J,w]of $.readSet.entries())this.readSet.set(J,w);this.pendingDocuments.clear();for(let[J,w]of $.pendingDocuments.entries())this.pendingDocuments.set(J,w);this.readRanges.replaceWith($.readRanges),this.writeRanges.replaceWith($.writeRanges)}recordTableScan($,J){let w=`table_scan:${$}`,Z=new Set;for(let W of J)Z.add(b(W.value.id));this.readSet.set(w,{type:\"table_scan\",tableId:$,readTimestamp:this.snapshotTimestamp,documentIds:Z}),this.readRanges.addTableScan($)}recordIndexRangeScan($,J,w,Z){let W=`index_range:${$}:${E$(J)}`,X=new Set;for(let G of Z)X.add(b(G.value.id));this.readSet.set(W,{type:\"index_range\",indexId:$,startKey:J,endKey:w,readTimestamp:this.snapshotTimestamp,documentIds:X});let Y=d8($);if(Y.kind!==\"index\")throw Error(`Expected index keyspace, got ${Y.kind}: ${$}`);this.readRanges.addIndexRange(Y.table,Y.index,J,w)}async scanTable($){let J=await this.persistence.scan($,this.snapshotTimestamp),w=new Map;this.recordTableScan($,J);for(let W of J){let X=W.value.id;this.recordDocumentReadForOccOnly(X,W);let Y=b(X);w.set(Y,W)}return u.fromTransaction(this).applyToVisibilityMap(w,$),Array.from(w.values())}getPendingDocuments(){return this.pendingDocuments}getReadSet(){return new Map(this.readSet)}getReadRanges(){return this.readRanges.getRanges()}getWrittenRanges(){return this.writeRanges.getRanges()}async commit(){if(this.stagedDocuments.size===0&&this.stagedIndexes.size===0)return;let $=this.getStagedDocuments(),J=new Set(this.stagedIndexes.values()),w=Array.from(this.readSet.entries()),Z=new Set(this.stagedDocuments.keys()),W,X=async()=>{for(let[G,Q]of w)if(Q.type===\"document\"){if(Z.has(G))continue;let K=G.indexOf(\":\");if(K===-1)throw Error(`Invalid document key format: ${G}`);let H=G.substring(0,K),U=G.substring(K+1);if(!H||!U)throw Error(`Invalid document key format: ${G}`);let S=await this.persistence.get({table:H,internalId:U});if(Q.version===null){if(S!==null)throw new n(`Transaction conflict: document ${G} was absent but now exists`)}else if(!S||S.ts!==Q.version)throw new n(`Transaction conflict: document ${G} version changed from ${Q.version} to ${S?.ts??\"null\"}`)}else if(Q.type===\"table_scan\"){let K=await this.persistence.scan(Q.tableId),H=new Set;for(let U of K)H.add(b(U.value.id));for(let U of H)if(!Q.documentIds.has(U)&&!Z.has(U))throw new n(`Transaction conflict: phantom read detected - new document ${U} appeared in table ${Q.tableId}`);for(let U of Q.documentIds)if(!H.has(U)&&!Z.has(U))throw new n(`Transaction conflict: document ${U} was deleted from table ${Q.tableId}`)}else if(Q.type===\"index_range\"){let{table:K}=e$(Q.indexId),H={start:Q.startKey,end:Q.endKey},U=new Set;for await(let[,S]of this.persistence.index_scan(Q.indexId,K,BigInt(Date.now()),H,\"Asc\"))U.add(b(S.value.id));for(let S of U)if(!Q.documentIds.has(S)&&!Z.has(S))throw new n(`Transaction conflict: phantom read detected - new document ${S} appeared in index range`);for(let S of Q.documentIds)if(!U.has(S)&&!Z.has(S))throw new n(`Transaction conflict: document ${S} was removed from index range`)}W=this.persistence.timestampOracle.allocateTimestamp();for(let G of $)G.ts=W;for(let G of J)G.ts=W;if($.length>0||J.size>0)await this.persistence.write($,J,\"Error\")},Y=this.persistence.state?.storage;try{if(Y&&typeof Y.transaction===\"function\")await Y.transaction(X);else await X()}catch(G){if(G instanceof n)throw G;throw G}return W}}import{AsyncLocalStorage as VW}from\"async_hooks\";var qW=new VW;function Y6(){return qW.getStore()}var l=new AW,TW=globalThis.Math.random,jW=globalThis.Date.now,_W=globalThis.fetch,kW=globalThis.setInterval,NW=globalThis.setTimeout,G6=globalThis.console,b0=globalThis.crypto,hW=b0.randomUUID.bind(b0),IW=b0.getRandomValues.bind(b0),fW=new Proxy(G6,{get($,J,w){let W=l.getStore()?.console??G6,X=W[J];if(typeof X===\"function\")return X.bind(W);return Reflect.get(W,J,w)}}),xW=()=>{return(l.getStore()?.dateNow??jW)()},yW=($,J)=>{return(l.getStore()?.fetch??_W)($,J)},gW=()=>{return(l.getStore()?.mathRandom??TW)()},bW=($,J)=>{return(l.getStore()?.setInterval??kW)($,J??0)},mW=($,J)=>{return(l.getStore()?.setTimeout??NW)($,J??0)},cW=()=>{return(l.getStore()?.cryptoRandomUUID??hW)()},pW=($)=>{return(l.getStore()?.cryptoGetRandomValues??IW)($)};function vW(){if(Object.hasOwn(globalThis,\"Convex\"))return;globalThis.Date.now=xW,globalThis.fetch=yW,globalThis.Math.random=gW,globalThis.setInterval=bW,globalThis.setTimeout=mW;let $=globalThis;$.crypto.randomUUID=cW,$.crypto.getRandomValues=pW,$.console=fW,Object.defineProperty(globalThis,\"Convex\",{get:()=>{return l.getStore()?.convex}})}function Gw($,J){return vW(),l.run($,J)}function U$($){return async(...J)=>{throw new Qw($)}}function m0($){let J=x$(`${$}:internal-id`);return()=>{let w=new Uint8Array(r);return J.cryptoGetRandomValues(w),w}}class Qw extends Error{constructor($){super(`Can't use ${$} in queries and mutations. Please consider using an action. See https://docs.convex.dev/functions/actions for more details.`);this.name=\"ForbiddenInQueriesOrMutations\"}}async function c0($,J,w,Z,W,X,Y,G,Q,K){let H=Y6(),U;if(Z&&typeof Z===\"object\"&&\"tokenType\"in Z){let D=Z;U={...D,userIdentity:D.userIdentity??H}}else U=H??Z;let S=j$.getStore()??null,C=M$.getStore()??void 0??(Y?m0(Y):void 0),F=new g0($,U,X,S,G,Q,K,C);F.clearAccessLogs();let M=[],j=(D)=>{return(...I)=>{M.push(`[${D.toUpperCase()}] ${I.map((k)=>typeof k===\"string\"?k:JSON.stringify(k)).join(\" \")}`),G6[D](...I)}},T={log:j(\"log\"),warn:j(\"warn\"),error:j(\"error\"),info:j(\"info\"),debug:j(\"log\"),assert:(D,...I)=>{if(!D)j(\"error\")(\"Assertion failed:\",...I)},time:()=>{},timeEnd:()=>{},timeLog:()=>{},trace:()=>{},dir:()=>{},dirxml:()=>{},table:()=>{},count:()=>{},countReset:()=>{},clear:()=>{},group:()=>{},groupCollapsed:()=>{},groupEnd:()=>{},profile:()=>{},profileEnd:()=>{},timeStamp:()=>{}};try{let D=F.getSnapshotTimestamp(),I=await j$.run(D,async()=>{return await Gw({...w,console:T,convex:v0(F)},J)}),k=F.getTrackedReadRanges(),p=F.getTrackedWriteRanges(),a=F.getSnapshotTimestamp();return{result:I,readRanges:k,writtenRanges:p,logLines:M,snapshotTimestamp:a}}finally{}}function Kw($,J,w,Z,W,X,Y){let G=Date.now(),Q=W||`udf:${G}:${Math.random()}`,K=x$(Q);return c0($,J,{mathRandom:K.mathRandom,cryptoRandomUUID:K.cryptoRandomUUID,cryptoGetRandomValues:U$(\"crypto.getRandomValues\"),dateNow:()=>G,fetch:U$(\"fetch\"),setInterval:U$(\"setInterval\"),setTimeout:U$(\"setTimeout\")},w,\"query\",Z,Q,void 0,X,Y)}function Uw($,J,w,Z,W,X,Y){let G=Date.now(),Q=W||`udf:${G}:${Math.random()}`,K=x$(Q),H={mathRandom:K.mathRandom,dateNow:()=>G,cryptoRandomUUID:K.cryptoRandomUUID,cryptoGetRandomValues:U$(\"crypto.getRandomValues\"),fetch:U$(\"fetch\"),setInterval:U$(\"setInterval\"),setTimeout:U$(\"setTimeout\")},U=5,S=10,O=1000,C=async(M)=>{let j=$.timestampOracle,T=j?j.beginSnapshot():BigInt(Date.now()),D=new X6($,T),I=m0(Q);try{return await _$.run(D,async()=>M$.run(I,async()=>{let k=await c0($,J,H,w,\"mutation\",Z,Q,D,X,Y),p=D.getReadRanges(),a=D.getWrittenRanges(),f=await D.commit();return k.readRanges=p.map(K$),k.writtenRanges=a.map(K$),k.commitTimestamp=f,k}))}catch(k){if(k instanceof n&&M<5){let p=Math.min(10*2**M,1000),a=Math.random()*p*0.5,f=p+a;await new Promise((R$)=>setTimeout(R$,f));let o=w0.getStore();if(o)return w0.run(o,()=>C(M+1));else return C(M+1)}throw k}},F=_$.getStore();if(F){let M=F.createSavepoint(),T=M$.getStore()??m0(Q);return _$.run(F,()=>M$.run(T,()=>c0($,J,H,w,\"mutation\",Z,Q,F,X,Y))).catch((D)=>{throw F.restoreSavepoint(M),D})}return C(1)}function Hw($,J,w,Z,W,X,Y){let G=Date.now(),Q=W||`udf:${G}:${Math.random()}`,K=x$(Q);return c0($,J,{mathRandom:K.mathRandom,dateNow:()=>G,cryptoRandomUUID:null,cryptoGetRandomValues:null,fetch:null,setInterval:null,setTimeout:null},w,\"action\",Z,Q,void 0,X,Y)}async function Sw($,J,w,Z,W,X){let Y=Date.now(),G=W||`udf:${Y}:${Math.random()}`,Q=m0(G),K=Y6()??w,H=new g0($,K,Z,void 0,void 0,X,void 0,Q);H.clearAccessLogs();let U={mathRandom:null,dateNow:null,cryptoRandomUUID:null,cryptoGetRandomValues:null,console:null,fetch:null,setInterval:null,setTimeout:null,convex:v0(H)},S=H.getSnapshotTimestamp();return j$.run(S,()=>Gw(U,J))}PJ();B$();g();function uW($,J){return`${$}:${J}:${Date.now()}`}class Q6{persistence;storage;logger;requestIdFactory;constructor($){this.persistence=$.persistence,this.storage=$.storage,this.logger=$.logger??console,this.requestIdFactory=$.requestIdFactory??uW}async execute($,J,w,Z,W,X){let[Y,G]=this.parseUdfPath($),Q=X??this.requestIdFactory(w,$),K=async()=>{let U=(await this.loadModule(Y,W))?.[G];this.assertFunctionExport(G,Y,U,w),this.validateArgs(U,J);let S=JSON.stringify(B([J]));if(U.isQuery)return JSON.parse(await U.invokeQuery(S));if(U.isMutation)return JSON.parse(await U.invokeMutation(S));if(U.isAction)return JSON.parse(await U.invokeAction(Q,S));throw Error(`Function \"${G}\" has no valid type`)};switch(w){case\"query\":return Kw(this.persistence,K,Z,this.storage,Q,this,W);case\"mutation\":return Uw(this.persistence,K,Z,this.storage,Q,this,W);case\"action\":return Hw(this.persistence,K,Z,this.storage,Q,this,W);default:throw Error(`Unknown UDF type: ${w}`)}}async executeHttp($,J,w){let Z=new URL($.url),W=async()=>{let G=(await this.loadModule(\"http\",$.url))?.default;if(!G?.isRouter||typeof G.lookup!==\"function\")throw Error(\"convex/http.ts must export a default httpRouter()\");let Q=G.lookup(Z.pathname,$.method);if(!Q)return new Response(\"Not found\",{status:404});let[K]=Q;if(!K||typeof K.invokeHttpAction!==\"function\")throw Error(\"Matched route is not a Convex HTTP action\");return K.invokeHttpAction($)},X=w??this.requestIdFactory(\"http\",`${$.method}:${Z.pathname}`);return Sw(this.persistence,W,J,this.storage,X,this)}async loadModule($,J){try{return await w$($,{componentPath:J})}catch(w){let Z=w?.message?.toLowerCase();if(Z&&(Z.includes(\"module not found\")||Z.includes(\"failed to load convex module\")))throw Error(`UDF module not found: ${$}`);throw w}}parseUdfPath($){let J=$.split(\":\");if(J.length!==2)throw Error(`Invalid UDF path: ${$}`);return[J[0],J[1]]}assertFunctionExport($,J,w,Z){if(typeof w!==\"function\")throw Error(`Function \"${$}\" not found in module \"${J}\"`);if(Z===\"query\"&&!w.isQuery)throw Error(`Function \"${$}\" is not a query`);if(Z===\"mutation\"&&!w.isMutation)throw Error(`Function \"${$}\" is not a mutation`);if(Z===\"action\"&&!w.isAction)throw Error(`Function \"${$}\" is not an action`);if(w.isInternal&&Xw())throw Error(`Could not find public function for '${$}'. Did you forget to run \\`npx convex dev\\` or \\`npx convex deploy\\`?`)}validateArgs($,J){if(typeof $.exportArgs!==\"function\")return;try{let w=$.exportArgs(),Z=JSON.parse(w);V$(Z,J)}catch(w){if(w instanceof q$)throw Error(`ArgumentValidationError: ${w.message}`);if(w instanceof Error)throw Error(`ArgumentValidationError: ${w.message}`);throw w}}}class s{low;high;__isUnsignedLong__;static isLong($){return $?.__isUnsignedLong__===!0}constructor($,J){this.low=$|0,this.high=J|0,this.__isUnsignedLong__=!0}static fromBytesLE($){return new s($[0]|$[1]<<8|$[2]<<16|$[3]<<24,$[4]|$[5]<<8|$[6]<<16|$[7]<<24)}toBytesLE(){let $=this.high,J=this.low;return[J&255,J>>>8&255,J>>>16&255,J>>>24,$&255,$>>>8&255,$>>>16&255,$>>>24]}static fromNumber($){if(Number.isNaN($))return Ow;if($<0)return Ow;if($>=nW)return sW;return new s($%W0|0,$/W0|0)}toString(){return(BigInt(this.high)*BigInt(W0)+BigInt(this.low)).toString()}equals($){if(!s.isLong($))$=s.fromValue($);if(this.high>>>31===1&&$.high>>>31===1)return!1;return this.high===$.high&&this.low===$.low}notEquals($){return!this.equals($)}comp($){if(!s.isLong($))$=s.fromValue($);if(this.equals($))return 0;return $.high>>>0>this.high>>>0||$.high===this.high&&$.low>>>0>this.low>>>0?-1:1}lessThanOrEqual($){return this.comp($)<=0}static fromValue($){if(typeof $===\"number\")return s.fromNumber($);return new s($.low,$.high)}}var Ow=new s(0,0),zw=65536,W0=zw*zw,nW=W0*W0,sW=new s(-1,-1);class oW{logicalClock;allocationQueue=Promise.resolve();constructor($=0n){this.logicalClock=$}getCurrentTimestamp(){return this.logicalClock}allocateTimestamp(){let $=BigInt(Date.now());return this.logicalClock=this.logicalClock>=$?this.logicalClock+1n:$,this.logicalClock}async allocateTimestampAsync(){let $=this.allocationQueue.then(()=>{return this.allocateTimestamp()});return this.allocationQueue=$.then(()=>{},()=>{}),$}beginSnapshot(){if(this.logicalClock===0n)return BigInt(Date.now());return this.logicalClock}observeTimestamp($){if($>this.logicalClock)this.logicalClock=$}reset($=0n){this.logicalClock=$}}g();function K6($){let J=h$($);return B(J)}function U6($){let J=R($);return I$(J)}function h$($){if($===void 0)return null;if($ instanceof Set)return{__type:\"Set\",value:Array.from($).map((J)=>h$(J))};if($ instanceof Map)return{__type:\"Map\",value:Array.from($.entries()).map(([J,w])=>[h$(J),h$(w)])};if(Array.isArray($))return $.map((J)=>h$(J));if($&&typeof $===\"object\"&&!($ instanceof Date)&&!($ instanceof ArrayBuffer)){let J={};for(let[w,Z]of Object.entries($))J[w]=h$(Z);return J}return $}function I$($){if($&&typeof $===\"object\"&&!Array.isArray($)){if($.__type===\"Set\"&&Array.isArray($.value))return new Set($.value.map((w)=>I$(w)));if($.__type===\"Map\"&&Array.isArray($.value))return new Map($.value.map(([w,Z])=>[I$(w),I$(Z)]));let J={};for(let[w,Z]of Object.entries($))J[w]=I$(Z);return J}if(Array.isArray($))return $.map((J)=>I$(J));return $}class X0 extends Error{status;code;requestId;constructor($,J,w,Z){super($);this.name=\"DocStoreTransportError\",this.status=J,this.code=w,this.requestId=Z}}class H6{fetcher;endpoint;constructor($,J=\"http://syscall/docstore\"){this.fetcher=$,this.endpoint=J}async call($,J){let w={\"Content-Type\":\"application/json\",\"X-Concave-Project-Id\":J.projectId,\"x-concave-instance\":J.instance,\"X-Concave-DocStore-Version\":\"1\"};if(J.secret)w[\"X-Concave-Secret\"]=J.secret;if($.requestId)w[\"X-Concave-Request-Id\"]=$.requestId;let Z=await this.fetcher.fetch(this.endpoint,{method:\"POST\",headers:w,body:JSON.stringify({method:$.method,args:K6($.args)})}),W=Z.headers.get(\"X-Concave-Request-Id\")??$.requestId;if(!Z.ok)throw await this.buildError($.method,Z,W);let X=await Z.json();if(X&&typeof X===\"object\"&&\"error\"in X){let G=X.error;throw new X0(G.message??\"DocStore request failed\",Z.status,G.code,W)}let Y=X&&typeof X===\"object\"&&\"result\"in X?X.result:X;return U6(Y)}async buildError($,J,w){try{let W=await J.json();if(W&&typeof W===\"object\"&&\"error\"in W){let X=W.error;return new X0(X.message??`DocStore ${$} failed`,J.status,X.code,w)}}catch(W){}let Z=await J.text();return new X0(`DocStore ${$} failed: ${Z}`,J.status,void 0,w)}}class p0{service;constructor($){this.service=$}async call($,J){let w=await this.service.docstore({...$,args:K6($.args)},J);if(w.error)throw new X0(w.error.message??\"DocStore request failed\",500,w.error.code,w.requestId??$.requestId);return U6(w.result)}}class S6{transport;projectId;secret;instance;requestIdFactory;timestampOracle;constructor($,J,w,Z=\"singleton\",W){this.transport=W?.transport??dW($),this.projectId=J,this.secret=w,this.instance=Z,this.requestIdFactory=W?.requestIdFactory,this.timestampOracle={observeTimestamp:(X)=>{},allocateTimestamp:()=>BigInt(Date.now()),getCurrentTimestamp:()=>BigInt(Date.now()),beginSnapshot:()=>BigInt(Date.now())}}async call($,J){return this.transport.call({method:$,args:J,requestId:this.requestIdFactory?.()},{projectId:this.projectId,instance:this.instance,secret:this.secret})}async setupSchema($){return this.call(\"setupSchema\",[$])}async write($,J,w){return this.call(\"write\",[$,J,w])}async*index_scan($,J,w,Z,W){let X=await this.call(\"index_scan\",[$,J,w,Z,W]);for(let[Y,G]of X)yield[Y,G]}async*load_documents($,J){let w=await this.call(\"load_documents\",[$,J]);for(let Z of w)yield Z}async getPersistenceGlobal($){return this.call(\"getPersistenceGlobal\",[$])}async writePersistenceGlobal($,J){return this.call(\"writePersistenceGlobal\",[$,J])}async previous_revisions($){let J=await this.call(\"previous_revisions\",[$]);return new Map(J)}async previous_revisions_of_documents($){let J=await this.call(\"previous_revisions_of_documents\",[$]);return new Map(J)}async count($){return this.call(\"count\",[$])}async get($,J){return this.call(\"get\",[$,J])}async scan($,J){return this.call(\"scan\",[$,J])}async scanPaginated($,J,w,Z,W){return this.call(\"scanPaginated\",[$,J,w,Z,W])}async search($,J,w,Z){return this.call(\"search\",[$,J,w,Z])}async vectorSearch($,J,w,Z){return this.call(\"vectorSearch\",[$,J,w,Z])}}function dW($){if(typeof $.docstore===\"function\")return new p0($);let J=$.rpc;if(J&&typeof J.docstore===\"function\")return new p0(J);return new H6($)}class O6{bucket;projectId;prefix;constructor($,J,w=\"projects\"){this.bucket=$,this.projectId=J,this.prefix=`${w}/${J}/`.replace(/\\/+/g,\"/\")}async get($){let J=this.prefixKey($);return this.bucket.get(J)}async put($,J,w){let Z=this.prefixKey($);return this.bucket.put(Z,J,w)}async delete($){let J=this.prefixKey($);await this.bucket.delete(J)}async list($){let J={...$,prefix:$?.prefix?this.prefixKey($.prefix):this.prefix},w=await this.bucket.list(J);return{...w,objects:w.objects.map((Z)=>({...Z,key:this.unprefixKey(Z.key)}))}}async head($){let J=this.prefixKey($);return this.bucket.head(J)}prefixKey($){let J=$.replace(/^\\/+/,\"\");if(J.startsWith(this.prefix))return J;return`${this.prefix}${J}`}unprefixKey($){if($.startsWith(this.prefix))return $.slice(this.prefix.length);return $}getProjectId(){return this.projectId}getPrefix(){return this.prefix}isOwnedByProject($){return $.startsWith(this.prefix)}async getUsageBytes(){return(await this.list()).objects.reduce((J,w)=>J+w.size,0)}async deleteAll(){let $=await this.list(),J=0;for(let w of $.objects)await this.delete(w.key),J++;return J}}class z6{bucket;metadataPrefix=\"_metadata/\";publicUrlPrefix;constructor($,J=\"https://storage.concave.dev\"){this.bucket=$,this.publicUrlPrefix=J.endsWith(\"/\")?J.slice(0,-1):J}get bucketInstance(){return this.bucket}generateStorageId(){return crypto.randomUUID()}getMetadataKey($){return`${this.metadataPrefix}${$}`}getObjectKey($){return`objects/${$}`}async calculateSha256($){let J=await crypto.subtle.digest(\"SHA-256\",$),w=new Uint8Array(J);return btoa(String.fromCharCode(...w))}async store($,J){let w=$ instanceof Blob?$:new Blob([$],{type:J?.contentType||\"application/octet-stream\"}),Z=J?.storageId??this.generateStorageId(),W=this.getObjectKey(Z),X=this.getMetadataKey(Z),Y=await w.arrayBuffer(),G=await this.calculateSha256(Y);await this.bucket.put(W,Y,{httpMetadata:{contentType:w.type||J?.contentType||\"application/octet-stream\"}});let Q={_id:Z,sha256:G,size:w.size,contentType:w.type||J?.contentType||\"application/octet-stream\",uploadedAt:Date.now()};return await this.bucket.put(X,JSON.stringify(Q),{httpMetadata:{contentType:\"application/json\"}}),Q}async get($){let J=this.getObjectKey($);try{return(await this.bucket.get(J))?.arrayBuffer()??null}catch(w){return console.error(\"Error getting object from R2:\",w),null}}async delete($){let J=this.getObjectKey($),w=this.getMetadataKey($);try{await Promise.all([this.bucket.delete(J),this.bucket.delete(w)])}catch(Z){throw console.error(\"Error deleting object from R2:\",Z),Z}}async getUrl($){let J=this.getObjectKey($);return`${this.publicUrlPrefix}/${J}`}}g();import*as F6 from\"user-code\";function iW(){if(F6.modules){let $=jJ(F6.modules);TJ($)}else console.warn(\"[Shim] UserCode does not export 'modules'. Attempting to use UserCode as modules map.\")}iW();var pG={async fetch($,J,w){let Z=new URL($.url);if(Z.pathname===\"/health\")return new Response(\"OK\",{status:200});let W;if(J.CLOUD_SERVICE)W=new S6(J.CLOUD_SERVICE,J.PROJECT_ID,void 0,J.CONCAVE_INSTANCE);else if(J.PERSISTENCE)W=J.PERSISTENCE;else console.warn(\"[Shim] No persistence binding found. UDFs requiring data will fail.\");let X=void 0;if(J.STORAGE)if(typeof J.STORAGE.store===\"function\")X=J.STORAGE;else{let G=new O6(J.STORAGE,J.PROJECT_ID);X=new z6(G,J.R2_PUBLIC_URL)}let Y=new Q6({persistence:W,storage:X});if(Z.pathname===\"/execute\"){if($.method!==\"POST\")return new Response(\"Method not allowed\",{status:405});try{let{path:G,args:Q,type:K,auth:H,componentPath:U,requestId:S}=await $.json(),O=R(Q),C=await Y.execute(G,O,K,H,U,S);return new Response(JSON.stringify(C),{headers:{\"Content-Type\":\"application/json\"}})}catch(G){return console.error(\"[Shim] Execution failed:\",G),new Response(G.message,{status:500})}}if(Z.pathname===\"/http\"){if($.method!==\"POST\")return new Response(\"Method not allowed\",{status:405});let G=$.headers.get(\"X-Concave-Http-Url\")??$.url,Q=$.headers.get(\"X-Concave-Http-Method\")??$.method,K=new Headers($.headers);K.delete(\"X-Concave-Http-Url\"),K.delete(\"X-Concave-Http-Method\");let H={method:Q,headers:K};if(Q!==\"GET\"&&Q!==\"HEAD\")H.body=$.body;let U=new Request(G,H);return Y.executeHttp(U)}return new Response(\"Not found\",{status:404})}};export{pG as default};\n";
|