@instantdb/resumable-stream 1.0.23-branch-codex-cli-args-combinators.25393207850.1 → 1.0.23-branch-codex-cli-args-combinators.25394030897.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @instantdb/resumable-stream@1.0.23-branch-codex-cli-args-combinators.
|
|
2
|
+
> @instantdb/resumable-stream@1.0.23-branch-codex-cli-args-combinators.25394030897.1 build /home/runner/work/instant/instant/client/packages/resumable-stream
|
|
3
3
|
> rm -rf dist; npm run build:tshy && npm run build:standalone && npm run check-exports
|
|
4
4
|
|
|
5
5
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
6
6
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
7
7
|
|
|
8
|
-
> @instantdb/resumable-stream@1.0.23-branch-codex-cli-args-combinators.
|
|
8
|
+
> @instantdb/resumable-stream@1.0.23-branch-codex-cli-args-combinators.25394030897.1 build:tshy
|
|
9
9
|
> tshy
|
|
10
10
|
|
|
11
11
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
12
12
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
13
13
|
|
|
14
|
-
> @instantdb/resumable-stream@1.0.23-branch-codex-cli-args-combinators.
|
|
14
|
+
> @instantdb/resumable-stream@1.0.23-branch-codex-cli-args-combinators.25394030897.1 build:standalone
|
|
15
15
|
> vite build
|
|
16
16
|
|
|
17
17
|
[36mvite v5.4.14 [32mbuilding for production...[36m[39m
|
|
@@ -21,15 +21,15 @@ rendering chunks...
|
|
|
21
21
|
computing gzip size...
|
|
22
22
|
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m68.76 kB[22m[1m[22m[2m │ gzip: 21.65 kB[22m
|
|
23
23
|
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m109.30 kB[22m[1m[22m[2m │ gzip: 28.66 kB[22m
|
|
24
|
-
[32m✓ built in 1.
|
|
24
|
+
[32m✓ built in 1.09s[39m
|
|
25
25
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
26
26
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
27
27
|
|
|
28
|
-
> @instantdb/resumable-stream@1.0.23-branch-codex-cli-args-combinators.
|
|
28
|
+
> @instantdb/resumable-stream@1.0.23-branch-codex-cli-args-combinators.25394030897.1 check-exports
|
|
29
29
|
> attw --pack .
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@instantdb/resumable-stream v1.0.23-branch-codex-cli-args-combinators.
|
|
32
|
+
@instantdb/resumable-stream v1.0.23-branch-codex-cli-args-combinators.25394030897.1
|
|
33
33
|
|
|
34
34
|
Build tools:
|
|
35
35
|
- @arethetypeswrong/cli@^0.17.4
|
package/dist/standalone/index.js
CHANGED
|
@@ -834,7 +834,7 @@ class ve extends H {
|
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
836
|
typeof window < "u" && typeof window.localStorage < "u" && (window.localStorage.getItem("devBackend"), window.localStorage.getItem("__instantLogging"), window.localStorage.getItem("__devtoolLocalDash"));
|
|
837
|
-
const Me = "v1.0.23-branch-codex-cli-args-combinators.
|
|
837
|
+
const Me = "v1.0.23-branch-codex-cli-args-combinators.25394030897.1";
|
|
838
838
|
class ce {
|
|
839
839
|
constructor(t, n, s, r = { indexed: !1, unique: !1 }) {
|
|
840
840
|
f(this, "valueType");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(E,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(E=typeof globalThis<"u"?globalThis:E||self,k(E.instant={}))})(this,function(E){"use strict";var Bs=Object.defineProperty;var $n=E=>{throw TypeError(E)};var qs=(E,k,R)=>k in E?Bs(E,k,{enumerable:!0,configurable:!0,writable:!0,value:R}):E[k]=R;var f=(E,k,R)=>qs(E,typeof k!="symbol"?k+"":k,R),Ut=(E,k,R)=>k.has(E)||$n("Cannot "+R);var g=(E,k,R)=>(Ut(E,k,"read from private field"),R?R.call(E):k.get(E)),ee=(E,k,R)=>k.has(E)?$n("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(E):k.set(E,R),de=(E,k,R,M)=>(Ut(E,k,"write to private field"),M?M.call(E,R):k.set(E,R),R),te=(E,k,R)=>(Ut(E,k,"access private method"),R);var je,z,Ee,G,H,L,_n,at,Cn,xn,Tn,nt,st,it,Nt,Rn,rt;const k=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function R(e){return typeof e=="string"&&k.test(e)}const M=[];for(let e=0;e<256;++e)M.push((e+256).toString(16).slice(1));function Pn(e,t=0){return(M[e[t+0]]+M[e[t+1]]+M[e[t+2]]+M[e[t+3]]+"-"+M[e[t+4]]+M[e[t+5]]+"-"+M[e[t+6]]+M[e[t+7]]+"-"+M[e[t+8]]+M[e[t+9]]+"-"+M[e[t+10]]+M[e[t+11]]+M[e[t+12]]+M[e[t+13]]+M[e[t+14]]+M[e[t+15]]).toLowerCase()}let ct;const An=new Uint8Array(16);function Mn(){if(!ct){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ct=crypto.getRandomValues.bind(crypto)}return ct(An)}const Dt={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function jn(e,t,n){var i;if(Dt.randomUUID&&!e)return Dt.randomUUID();e=e||{};const s=e.random??((i=e.rng)==null?void 0:i.call(e))??Mn();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Pn(s)}const D={Remove:"remove",Replace:"replace",Add:"add"},Lt=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),Qe=Symbol.iterator,ne={mutable:"mutable",immutable:"immutable"},ut={};function Ne(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Wt(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const s=Reflect.getOwnPropertyDescriptor(n,t);if(s)return s;n=Reflect.getPrototypeOf(n)}}}function Ft(e){return Object.getPrototypeOf(e)===Set.prototype}function zt(e){return Object.getPrototypeOf(e)===Map.prototype}function X(e){var t;return(t=e.copy)!==null&&t!==void 0?t:e.original}function ft(e){return!!$(e)}function $(e){return typeof e!="object"?null:e==null?void 0:e[Lt]}function lt(e){var t;const n=$(e);return n?(t=n.copy)!==null&&t!==void 0?t:n.original:e}function we(e,t){if(!e||typeof e!="object")return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(t!=null&&t.mark)&&((n=t.mark(e,ne))===ne.immutable||typeof n=="function")}function Vt(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,s=$(he(n,e.key));if(s!==null&&(s==null?void 0:s.original)!==e.original)return null;const i=e.parent.type===3,r=i?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(i&&n.size>r||Ne(n,r)))return null;t.push(r)}if(e.parent)return Vt(e.parent,t);t.reverse();try{Un(e.copy,t)}catch{return null}return t}function De(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function he(e,t){return De(e)===2?e.get(t):e[t]}function dt(e,t,n){De(e)===2?e.set(t,n):e[t]=n}function ht(e,t){const n=$(e);return(n?X(n):e)[t]}function Se(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ie(e,t){return t?e:[""].concat(e).map(n=>{const s=`${n}`;return s.indexOf("/")===-1&&s.indexOf("~")===-1?s:s.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Un(e,t){for(let n=0;n<t.length-1;n+=1){const s=t[n];if(e=he(De(e)===3?Array.from(e):e,s),typeof e!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return e}function Nn(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach(n=>{let s=Reflect.getOwnPropertyDescriptor(e,n);if(s.enumerable&&s.configurable&&s.writable){t[n]=e[n];return}s.writable||(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(s={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[n]}),Reflect.defineProperty(t,n,s)}),t}const Dn=Object.prototype.propertyIsEnumerable;function Ln(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set){if(!Ft(e)){const s=Object.getPrototypeOf(e).constructor;return new s(e.values())}return Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values())}else if(e instanceof Map){if(!zt(e)){const s=Object.getPrototypeOf(e).constructor;return new s(e)}return new Map(e)}else if(t!=null&&t.mark&&(n=t.mark(e,ne),n!==void 0)&&n!==ne.mutable){if(n===ne.immutable)return Nn(e);if(typeof n=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}else if(typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype){const s={};return Object.keys(e).forEach(i=>{s[i]=e[i]}),Object.getOwnPropertySymbols(e).forEach(i=>{Dn.call(e,i)&&(s[i]=e[i])}),s}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function Q(e){e.copy||(e.copy=Ln(e.original,e.options))}function Le(e){if(!we(e))return lt(e);if(Array.isArray(e))return e.map(Le);if(e instanceof Map){const n=Array.from(e.entries()).map(([s,i])=>[s,Le(i)]);if(!zt(e)){const s=Object.getPrototypeOf(e).constructor;return new s(n)}return new Map(n)}if(e instanceof Set){const n=Array.from(e).map(Le);if(!Ft(e)){const s=Object.getPrototypeOf(e).constructor;return new s(n)}return new Set(n)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=Le(e[n]);return t}function Ge(e){return ft(e)?Le(e):e}function ae(e){var t;e.assignedMap=(t=e.assignedMap)!==null&&t!==void 0?t:new Map,e.operated||(e.operated=!0,e.parent&&ae(e.parent))}function Wn(e,t){const n=De(e);if(n===0)Reflect.ownKeys(e).forEach(s=>{t(s,e[s],e)});else if(n===1){let s=0;for(const i of e)t(s,i,e),s+=1}else e.forEach((s,i)=>t(i,s,e))}function Jt(e,t,n){if(ft(e)||!we(e,n)||t.has(e)||Object.isFrozen(e))return;const s=e instanceof Set,i=s?new Map:void 0;if(t.add(e),Wn(e,(r,o)=>{var a;if(ft(o)){const c=$(o);Q(c);const u=!((a=c.assignedMap)===null||a===void 0)&&a.size||c.operated?c.copy:c.original;dt(s?i:e,r,u)}else Jt(o,t,n)}),i){const r=e,o=Array.from(r);r.clear(),o.forEach(a=>{r.add(i.has(a)?i.get(a):a)})}}function Fn(e,t){const n=e.type===3?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&Jt(he(n,t),e.finalities.handledSet,e.options)}function pt(e){e.type===3&&e.copy&&(e.copy.clear(),e.setMap.forEach(t=>{e.copy.add(lt(t))}))}function mt(e,t,n,s){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&s){const r=Vt(e);r&&t(e,r,n,s)}e.finalized=!0}}function yt(e,t,n,s){const i=$(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((r,o)=>{var a;const c=e.type===3?e.setMap:e.copy;if(Se(he(c,t),n)){let u=i.original;i.copy&&(u=i.copy),pt(e),mt(e,s,r,o),e.options.enableAutoFreeze&&(e.options.updatedValues=(a=e.options.updatedValues)!==null&&a!==void 0?a:new WeakMap,e.options.updatedValues.set(u,i.original)),dt(c,t,u)}}),e.options.enableAutoFreeze&&i.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),we(n,e.options)&&e.finalities.draft.push(()=>{const r=e.type===3?e.setMap:e.copy;Se(he(r,t),n)&&Fn(e,t)})}function zn(e,t,n,s,i){let{original:r,assignedMap:o,options:a}=e,c=e.copy;c.length<r.length&&([r,c]=[c,r],[n,s]=[s,n]);for(let u=0;u<r.length;u+=1)if(o.get(u.toString())&&c[u]!==r[u]){const l=t.concat([u]),d=Ie(l,i);n.push({op:D.Replace,path:d,value:Ge(c[u])}),s.push({op:D.Replace,path:d,value:Ge(r[u])})}for(let u=r.length;u<c.length;u+=1){const l=t.concat([u]),d=Ie(l,i);n.push({op:D.Add,path:d,value:Ge(c[u])})}if(r.length<c.length){const{arrayLengthAssignment:u=!0}=a.enablePatches;if(u){const l=t.concat(["length"]),d=Ie(l,i);s.push({op:D.Replace,path:d,value:r.length})}else for(let l=c.length;r.length<l;l-=1){const d=t.concat([l-1]),p=Ie(d,i);s.push({op:D.Remove,path:p})}}}function Vn({original:e,copy:t,assignedMap:n},s,i,r,o){n.forEach((a,c)=>{const u=he(e,c),l=Ge(he(t,c)),d=a?Ne(e,c)?D.Replace:D.Add:D.Remove;if(Se(u,l)&&d===D.Replace)return;const p=s.concat(c),y=Ie(p,o);i.push(d===D.Remove?{op:d,path:y}:{op:d,path:y,value:l}),r.push(d===D.Add?{op:D.Remove,path:y}:d===D.Remove?{op:D.Add,path:y,value:u}:{op:D.Replace,path:y,value:u})})}function Jn({original:e,copy:t},n,s,i,r){let o=0;e.forEach(a=>{if(!t.has(a)){const c=n.concat([o]),u=Ie(c,r);s.push({op:D.Remove,path:u,value:a}),i.unshift({op:D.Add,path:u,value:a})}o+=1}),o=0,t.forEach(a=>{if(!e.has(a)){const c=n.concat([o]),u=Ie(c,r);s.push({op:D.Add,path:u,value:a}),i.unshift({op:D.Remove,path:u,value:a})}o+=1})}function We(e,t,n,s){const{pathAsArray:i=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return Vn(e,t,n,s,i);case 1:return zn(e,t,n,s,i);case 3:return Jn(e,t,n,s,i)}}const He=(e,t,n=!1)=>{if(typeof e=="object"&&e!==null&&(!we(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},bt={get size(){return X($(this)).size},has(e){return X($(this)).has(e)},set(e,t){const n=$(this),s=X(n);return(!s.has(e)||!Se(s.get(e),t))&&(Q(n),ae(n),n.assignedMap.set(e,!0),n.copy.set(e,t),yt(n,e,t,We)),this},delete(e){if(!this.has(e))return!1;const t=$(this);return Q(t),ae(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=$(this);if(this.size){Q(e),ae(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){const n=$(this);X(n).forEach((s,i)=>{e.call(t,this.get(i),i,this)})},get(e){var t,n;const s=$(this),i=X(s).get(e),r=((n=(t=s.options).mark)===null||n===void 0?void 0:n.call(t,i,ne))===ne.mutable;if(s.options.strict&&He(i,s.options,r),r||s.finalized||!we(i,s.options)||i!==s.original.get(e))return i;const o=ut.createDraft({original:i,parentDraft:s,key:e,finalities:s.finalities,options:s.options});return Q(s),s.copy.set(e,o),o},keys(){return X($(this)).keys()},values(){const e=this.keys();return{[Qe]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[Qe]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[Qe](){return this.entries()}},Qn=Reflect.ownKeys(bt),Qt=(e,t,{isValuesIterator:n})=>()=>{var s,i;const r=t.next();if(r.done)return r;const o=r.value;let a=e.setMap.get(o);const c=$(a),u=((i=(s=e.options).mark)===null||i===void 0?void 0:i.call(s,a,ne))===ne.mutable;if(e.options.strict&&He(o,e.options,u),!u&&!c&&we(o,e.options)&&!e.finalized&&e.original.has(o)){const l=ut.createDraft({original:o,parentDraft:e,key:o,finalities:e.finalities,options:e.options});e.setMap.set(o,l),a=l}else c&&(a=c.proxy);return{done:!1,value:n?a:[a,a]}},Be={get size(){return $(this).setMap.size},has(e){const t=$(this);if(t.setMap.has(e))return!0;Q(t);const n=$(e);return!!(n&&t.setMap.has(n.original))},add(e){const t=$(this);return this.has(e)||(Q(t),ae(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),yt(t,e,e,We)),this},delete(e){if(!this.has(e))return!1;const t=$(this);Q(t),ae(t);const n=$(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=$(this);Q(e),ae(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=$(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:Qt(e,t,{isValuesIterator:!0})}},entries(){const e=$(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:Qt(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[Qe](){return this.values()},forEach(e,t){const n=this.values();let s=n.next();for(;!s.done;)e.call(t,s.value,s.value,this),s=n.next()}};Set.prototype.difference&&Object.assign(Be,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const Gn=Reflect.ownKeys(Be),Gt=new WeakSet,Ht={get(e,t,n){var s,i;const r=(s=e.copy)===null||s===void 0?void 0:s[t];if(r&&Gt.has(r))return r;if(t===Lt)return e;let o;if(e.options.mark){const u=t==="size"&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(o=e.options.mark(u,ne),o===ne.mutable)return e.options.strict&&He(u,e.options,!0),u}const a=X(e);if(a instanceof Map&&Qn.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(bt,"size").get.call(e.proxy);const u=bt[t];if(u)return u.bind(e.proxy)}if(a instanceof Set&&Gn.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Be,"size").get.call(e.proxy);const u=Be[t];if(u)return u.bind(e.proxy)}if(!Ne(a,t)){const u=Wt(a,t);return u?"value"in u?u.value:(i=u.get)===null||i===void 0?void 0:i.call(e.proxy):void 0}const c=a[t];if(e.options.strict&&He(c,e.options),e.finalized||!we(c,e.options))return c;if(c===ht(e.original,t)){if(Q(e),e.copy[t]=Bt({original:e.original[t],parentDraft:e,key:e.type===1?Number(t):t,finalities:e.finalities,options:e.options}),typeof o=="function"){const u=$(e.copy[t]);return Q(u),ae(u),u.copy}return e.copy[t]}return c},set(e,t,n){var s;if(e.type===3||e.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(e.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const r=Wt(X(e),t);if(r!=null&&r.set)return r.set.call(e.proxy,n),!0;const o=ht(X(e),t),a=$(o);return a&&Se(a.original,n)?(e.copy[t]=n,e.assignedMap=(s=e.assignedMap)!==null&&s!==void 0?s:new Map,e.assignedMap.set(t,!1),!0):(Se(n,o)&&(n!==void 0||Ne(e.original,t))||(Q(e),ae(e),Ne(e.original,t)&&Se(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,yt(e,t,n,We)),!0)},has(e,t){return t in X(e)},ownKeys(e){return Reflect.ownKeys(X(e))},getOwnPropertyDescriptor(e,t){const n=X(e),s=Reflect.getOwnPropertyDescriptor(n,t);return s&&{writable:!0,configurable:e.type!==1||t!=="length",enumerable:s.enumerable,value:n[t]}},getPrototypeOf(e){return Reflect.getPrototypeOf(e.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return e.type===1?Ht.set.call(this,e,t,void 0,e.proxy):(ht(e.original,t)!==void 0||t in e.original?(Q(e),ae(e),e.assignedMap.set(t,!1)):(e.assignedMap=(n=e.assignedMap)!==null&&n!==void 0?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function Bt(e){const{original:t,parentDraft:n,key:s,finalities:i,options:r}=e,o=De(t),a={type:o,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:i,options:r,setMap:o===3?new Map(t.entries()):void 0};(s||"key"in e)&&(a.key=s);const{proxy:c,revoke:u}=Proxy.revocable(o===1?Object.assign([],a):a,Ht);if(i.revoke.push(u),Gt.add(c),a.proxy=c,n){const l=n;l.finalities.draft.push((d,p)=>{var y,v;const b=$(c);let h=l.type===3?l.setMap:l.copy;const I=he(h,s),O=$(I);if(O){let V=O.original;O.operated&&(V=lt(I)),pt(O),mt(O,We,d,p),l.options.enableAutoFreeze&&(l.options.updatedValues=(y=l.options.updatedValues)!==null&&y!==void 0?y:new WeakMap,l.options.updatedValues.set(V,O.original)),dt(h,s,V)}(v=b.callbacks)===null||v===void 0||v.forEach(V=>{V(d,p)})})}else{const l=$(c);l.finalities.draft.push((d,p)=>{pt(l),mt(l,We,d,p)})}return c}ut.createDraft=Bt,Object.prototype.constructor.toString();function _e(){return jn()}function Hn(e,t){return e.localeCompare(t)}function Bn(){let e=Hn;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{e=Intl.Collator("en-US").compare}catch{}return e}Bn();function qn(){const t={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(t))}const Kn=qn();function qe(e,t,n){const s={__etype:e,__ops:n};return new Proxy(s,{get:(i,r)=>{if(r==="__ops")return n;if(r==="__etype")return e;if(Kn.has(r))return(o,a)=>qe(e,t,[...n,a?[r,e,t,o,a]:[r,e,t,o]])}})}function Xn(e,t){return`lookup__${e}__${JSON.stringify(t)}`}function qt(e){return e.startsWith("lookup__")}function Kt(e){const[t,n,...s]=e.split("__");return[n,JSON.parse(s.join("__"))]}function Yn(e){return new Proxy({__etype:e},{get(t,n){if(n==="lookup")return(i,r)=>qe(e,Kt(Xn(i,r)),[]);if(n==="__etype")return e;const s=n;return qt(s)?qe(e,Kt(s),[]):qe(e,s,[])}})}function Xt(){return new Proxy({},{get(e,t){return Yn(t)}})}Xt();function Zn(e){return e.__ops}class B extends Error{constructor(n,s,i){super(n);f(this,"hint");f(this,"traceId");this.hint=s,i&&(this.traceId=i);const r=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,r),Error.captureStackTrace&&Error.captureStackTrace(this,B),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class ve extends B{constructor(n){var r;const s=((r=n.body)==null?void 0:r.message)||`API Error (${n.status})`;super(s,n.body.hint,n.body["trace-id"]);f(this,"body");f(this,"status");const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,ve),this.name="InstantAPIError",this.status=n.status,this.body=n.body}get[Symbol.toStringTag](){return"InstantAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const Ce="v1.0.23-branch-codex-cli-args-combinators.25393207850.1";class ce{constructor(t,n,s,i={indexed:!1,unique:!1}){f(this,"valueType");f(this,"required");f(this,"isIndexed");f(this,"config");f(this,"metadata",{});this.valueType=t,this.required=n,this.isIndexed=s,this.config=i}clientRequired(){return new ce(this.valueType,!1,this.isIndexed,this.config)}optional(){return new ce(this.valueType,!1,this.isIndexed,this.config)}unique(){return new ce(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new ce(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class x extends Error{constructor(t,n){const s=n?`At path '${n}': ${t}`:t;super(s),this.name="QueryValidationError"}}const Yt=["where","order","limit","last","first","offset","after","afterInclusive","before","beforeInclusive","fields","aggregate"],es=e=>e.valueType||"unknown",Zt=(e,t,n=!1)=>{if(n||e==null)return!0;switch(t){case"string":return typeof e=="string";case"number":return typeof e=="number"&&!isNaN(e);case"boolean":return typeof e=="boolean";case"date":return e instanceof Date||typeof e=="string"||typeof e=="number";default:return!0}},ts=(e,t,n,s,i,r,o)=>{const a=r.valueType==="json",c=(u,l,d)=>{if(!Zt(d,l,a))throw new x(`Invalid value for operator '${u}' on attribute '${s}' in entity '${i}'. Expected ${l}, but received: ${typeof d}`,o)};switch(e){case"in":case"$in":if(!Array.isArray(t))throw new x(`Operator '${e}' for attribute '${s}' in entity '${i}' must be an array, but received: ${typeof t}`,o);for(const u of t)c(e,n,u);break;case"$not":case"$ne":case"$gt":case"$lt":case"$gte":case"$lte":c(e,n,t);break;case"$like":case"$ilike":if(c(e,"string",t),e==="$ilike"&&!r.isIndexed)throw new x(`Operator '${e}' can only be used with indexed attributes, but '${s}' in entity '${i}' is not indexed`,o);break;case"$isNull":c(e,"boolean",t);break;default:throw new x(`Unknown operator '${e}' for attribute '${s}' in entity '${i}'`,o)}},xe=(e,t,n,s,i)=>{const r=es(n),o=n.valueType==="json";if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(o)return;const c=e;for(const[u,l]of Object.entries(c))ts(u,l,r,t,s,n,`${i}.${u}`)}else if(!Zt(e,r,o))throw new x(`Invalid value for attribute '${t}' in entity '${s}'. Expected ${r}, but received: ${typeof e}`,i)},ns=(e,t,n,s,i)=>{const r=e.split(".");if(r.length<2)throw new x(`Invalid dot notation path '${e}'. Must contain at least one dot.`,i);let o=n;for(let l=0;l<r.length-1;l++){const d=r[l],p=s.entities[o];if(!p)throw new x(`Entity '${o}' does not exist in schema while traversing dot notation path '${e}'.`,i);const y=p.links[d];if(!y){const v=Object.keys(p.links);throw new x(`Link '${d}' does not exist on entity '${o}' in dot notation path '${e}'. Available links: ${v.length>0?v.join(", "):"none"}`,i)}o=y.entityName}const a=r[r.length-1],c=s.entities[o];if(!c)throw new x(`Target entity '${o}' does not exist in schema for dot notation path '${e}'.`,i);if(a==="id"){if(typeof t=="string"&&!R(t))throw new x(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${t}`,i);xe(t,e,new ce("string",!1,!0),n,i);return}const u=c.attrs[a];if(Object.keys(c.links).includes(a)){if(typeof t=="string"&&!R(t))throw new x(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${t}`,i);xe(t,e,new ce("string",!1,!0),n,i);return}if(!u){const l=Object.keys(c.attrs);throw new x(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${e}'. Available attributes: ${l.length>0?l.join(", ")+", id":"id"}`,i)}xe(t,e,u,n,i)},en=(e,t,n,s)=>{for(const[i,r]of Object.entries(e)){if(i==="or"||i==="and"){if(Array.isArray(r))for(const u of r)typeof u=="object"&&u!==null&&en(u,t,n,`${s}.${i}[${u}]`);continue}if(i==="id"){xe(r,"id",new ce("string",!1,!0),t,`${s}.id`);continue}if(i.includes(".")){ns(i,r,t,n,`${s}.${i}`);continue}const o=n.entities[t];if(!o)continue;const a=o.attrs[i],c=o.links[i];if(!a&&!c){const u=Object.keys(o.attrs),l=Object.keys(o.links);throw new x(`Attribute or link '${i}' does not exist on entity '${t}'. Available attributes: ${u.length>0?u.join(", "):"none"}. Available links: ${l.length>0?l.join(", "):"none"}`,`${s}.${i}`)}if(a)xe(r,i,a,t,`${s}.${i}`);else if(c){if(typeof r=="string"&&!R(r))throw new x(`Invalid value for link '${i}' in entity '${t}'. Expected a UUID, but received: ${r}`,`${s}.${i}`);const u=new ce("string",!1,!0);xe(r,i,u,t,`${s}.${i}`)}}},ss=(e,t,n,s,i=0)=>{for(const o of Object.keys(e))if(!Yt.includes(o))throw new x(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Yt.join(", ")}. Found: ${o}`,s);const r=["offset","before","beforeInclusive","after","afterInclusive","first","last"];for(const o of r)if(e[o]!==void 0&&i>0)throw new x(`'${o}' can only be used on top-level namespaces. It cannot be used in nested queries.`,s);if(e.where&&n){if(typeof e.where!="object"||e.where===null)throw new x(`'where' clause must be an object in entity '${t}', but received: ${typeof e.where}`,s?`${s}.where`:void 0);en(e.where,t,n,s?`${s}.where`:"where")}},tn=(e,t,n,s,i=0)=>{var r;if(!e||typeof e!="object")throw new x(`Query part for entity '${t}' must be an object, but received: ${typeof e}`,s);for(const o of Object.keys(e))if(o!=="$"){if(n&&!(o in n.entities[t].links)){const c=Object.keys(n.entities[t].links);throw new x(`Link '${o}' does not exist on entity '${t}'. Available links: ${c.length>0?c.join(", "):"none"}`,`${s}.${o}`)}const a=e[o];if(typeof a=="object"&&a!==null){const c=(r=n==null?void 0:n.entities[t].links[o])==null?void 0:r.entityName;c&&tn(a,c,n,`${s}.${o}`,i+1)}}else{const a=e[o];if(typeof a!="object"||a===null)throw new x(`Query parameter '$' must be an object in entity '${t}', but received: ${typeof a}`,`${s}.$`);ss(a,t,n,`${s}.$`,i)}},nn=(e,t)=>{if(typeof e!="object"||e===null)throw new x(`Query must be an object, but received: ${typeof e}${e===null?" (null)":""}`);if(Array.isArray(e))throw new x(`Query must be an object, but received: ${typeof e}`);const n=e;for(const s of Object.keys(n)){if(Array.isArray(e[s]))throw new x(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(typeof s!="string")throw new x(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(s!=="$$ruleParams"){if(t&&!t.entities[s]){const i=Object.keys(t.entities);throw new x(`Entity '${s}' does not exist in schema. Available entities: ${i.length>0?i.join(", "):"none"}`,s)}tn(n[s],s,t,s,0)}}},sn=e=>typeof e!="string"?!1:qt(e)?!0:R(e);class Y extends Error{constructor(t){super(t),this.name="TransactionValidationError"}}const rn=e=>e.length>0?e.join(", "):"none",is=(e,t)=>new Y(`Entity '${e}' does not exist in schema. Available entities: ${rn(t)}`),gt={string:e=>typeof e=="string",number:e=>typeof e=="number"&&!isNaN(e),boolean:e=>typeof e=="boolean",date:e=>e instanceof Date||typeof e=="string"||typeof e=="number",json:()=>!0},rs=(e,t)=>{var n;return e==null?!0:((n=gt[t.valueType])==null?void 0:n.call(gt,e))??!1},on=(e,t)=>{const n=t.entities[e];if(!n)throw is(e,Object.keys(t.entities));return n},wt=(e,t,n)=>{const s=on(e,n);if(typeof t!="object"||t===null)throw new Y(`Arguments for data operation on entity '${e}' must be an object, but received: ${typeof t}`);for(const[i,r]of Object.entries(t)){if(i==="id")continue;const o=s.attrs[i];if(o&&!rs(r,o))throw new Y(`Invalid value for attribute '${i}' in entity '${e}'. Expected ${o.valueType}, but received: ${typeof r}`)}},an=(e,t,n)=>{const s=on(e,n);if(typeof t!="object"||t===null)throw new Y(`Arguments for link operation on entity '${e}' must be an object, but received: ${typeof t}`);for(const[i,r]of Object.entries(t)){if(!s.links[i]){const a=Object.keys(s.links);throw new Y(`Link '${i}' does not exist on entity '${e}'. Available links: ${rn(a)}`)}if(r!=null){if(Array.isArray(r)){for(const a of r)if(!sn(a))throw new Y(`Invalid entity ID in link '${i}' for entity '${e}'. Expected a UUID or a lookup, but received: ${a}`)}else if(!sn(r))throw new Y(`Invalid UUID in link '${i}' for entity '${e}'. Expected a UUID, but received: ${r}`)}}},os={create:wt,update:wt,merge:wt,link:an,unlink:an,delete:()=>{}},as=(e,t)=>{if(!t)return;const[n,s,i,r]=e;if(!Array.isArray(i)&&!R(i))throw new Y(`Invalid id for entity '${s}'. Expected a UUID, but received: ${i}`);if(typeof s!="string")throw new Y(`Entity name must be a string, but received: ${typeof s}`);const o=os[n];o&&r!==void 0&&o(s,r,t)},cs=(e,t)=>{const n=Array.isArray(e)?e:[e];for(const s of n){if(!s||typeof s!="object")throw new Y(`Transaction chunk must be an object, but received: ${typeof s}`);if(!Array.isArray(s.__ops))throw new Y(`Transaction chunk must have __ops array, but received: ${typeof s.__ops}`);for(const i of s.__ops){if(!Array.isArray(i))throw new Y(`Transaction operation must be an array, but received: ${typeof i}`);as(i,t)}}};let us=0;class fs{constructor(t,n,s){f(this,"type","sse");f(this,"initParams",null);f(this,"sendQueue",[]);f(this,"sendPromise");f(this,"closeFired",!1);f(this,"sseInitTimeout");f(this,"ES");f(this,"messageUrl");f(this,"conn");f(this,"url");f(this,"id");f(this,"onopen");f(this,"onmessage");f(this,"onclose");f(this,"onerror");this.id=`${this.type}_${us++}`,this.url=n,this.messageUrl=s||this.url,this.ES=t,this.conn=new t(n),this.sseInitTimeout=setTimeout(()=>{this.initParams||this.handleError()},1e4),this.conn.onmessage=i=>{const r=JSON.parse(i.data);if(Array.isArray(r))for(const o of r)this.handleMessage(o);else this.handleMessage(r)},this.conn.onerror=i=>{this.handleError()}}handleMessage(t){if(t.op==="sse-init"){this.initParams={machineId:t["machine-id"],sessionId:t["session-id"],sseToken:t["sse-token"]},this.onopen&&this.onopen({target:this}),clearTimeout(this.sseInitTimeout);return}this.onmessage&&this.onmessage({target:this,message:t})}handleError(){try{this.onerror&&this.onerror({target:this})}finally{this.handleClose()}}handleClose(){this.conn.close(),this.onclose&&!this.closeFired&&(this.closeFired=!0,this.onclose({target:this}))}async postMessages(t){var n,s,i;try{(await fetch(this.messageUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({machine_id:(n=this.initParams)==null?void 0:n.machineId,session_id:(s=this.initParams)==null?void 0:s.sessionId,sse_token:(i=this.initParams)==null?void 0:i.sseToken,messages:t})})).ok||this.handleError()}catch{this.handleError()}}async flushQueue(){if(this.sendPromise||!this.sendQueue.length)return;const t=this.sendQueue;this.sendQueue=[];const n=this.postMessages(t);this.sendPromise=n,n.then(()=>{this.sendPromise=null,this.flushQueue()})}send(t){if(!this.isOpen()||!this.initParams)throw this.isConnecting()?new Error("Failed to execute 'send' on 'EventSource': Still in CONNECTING state."):this.conn.readyState===this.ES.CLOSED?new Error("EventSource is already in CLOSING or CLOSED state."):new Error("EventSource is in invalid state.");this.sendQueue.push(t),this.flushQueue()}isOpen(){return this.conn.readyState===this.ES.OPEN&&this.initParams!==null}isConnecting(){return this.conn.readyState===this.ES.CONNECTING||this.conn.readyState===this.ES.OPEN&&this.initParams===null}close(){this.handleClose()}}var cn;(function(e){e.InitialSyncBatch="InitialSyncBatch",e.InitialSyncComplete="InitialSyncComplete",e.LoadFromStorage="LoadFromStorage",e.SyncTransaction="SyncTransaction",e.Error="Error"})(cn||(cn={}));function ls({WStream:e,opts:t,startStream:n,appendStream:s,registerStream:i}){const r=t.clientId;let o=null,a=null,c=null;const u=_e();let l=!1,d=!1;const p=[],y=[],v=[];let b=!1,h=0,I=0;const O=[],V=new TextEncoder;function $e(){d=!0;for(const m of p)m(a??void 0)}function Mt(m){return p.push(m),d&&m(a??void 0),()=>{const w=p.indexOf(m);w!==-1&&p.splice(w,1)}}function On(m){return v.push(m),()=>{const w=v.indexOf(m);w!==-1&&v.splice(w,1)}}t.waitUntil&&t.waitUntil(new Promise(m=>{v.push(m)}));function P(){for(const m of v)try{m()}catch{}}function _(m){return y.push(m),o&&m(o),()=>{const w=y.indexOf(m);w!==-1&&y.splice(w,1)}}function re(m){o=m;for(const w of y)w(o)}function C(){b=!0}function W(m){let w=h,F=0,K=0;for(const{byteLen:oe}of O){const le=w+oe;if(le>m)break;w=le,F++,K+=oe}F>0&&(h+=K,I-=K,O.splice(0,F))}function N(m,w){a=w,$e(),m.error(w),P()}async function Z(){const m=await n({clientId:r,reconnectToken:u,ruleParams:t.ruleParams});switch(m.type){case"ok":{const{streamId:w,offset:F}=m;o=w,W(F),O.length&&s({streamId:w,chunks:O.map(K=>K.chunk),offset:h}),b=!1;break}case"disconnect":{C();break}case"error":{c&&N(c,m.error);break}}}function J(){C(),Z()}function ot({offset:m,done:w}){W(m),w&&(l=!0,P())}function En(m){return l?(N(m,new B("Stream has been closed.")),null):o||(N(m,new B("Stream has not been initialized.")),null)}async function Ue(m){c=m;let w=!0,F=0;for(;w;){let K=Date.now()+Math.min(15e3,500*(F-1));w=!1;const oe=await n({clientId:t.clientId,reconnectToken:u,ruleParams:t.ruleParams});switch(oe.type){case"ok":{const{streamId:le,offset:jt}=oe;if(jt!==0){const ke=new B("Write stream is corrupted");N(m,ke);return}re(le),i(le,{onDisconnect:C,onFlush:ot,onConnectionReconnect:Z,onAppendFailed:J}),b=!1;return}case"disconnect":{w=!0,C(),F++,await new Promise(le=>{setTimeout(le,Math.max(0,K-Date.now()))});break}case"error":{N(m,oe.error);return}}}}class be extends e{constructor(w,F){super(w,F)}async streamId(){return o||new Promise((w,F)=>{const K=[],oe=()=>{for(const ke of K)ke()},le=ke=>{w(ke),oe()},jt=ke=>{F(ke||new B("Stream is closed.")),oe()};K.push(_(le)),K.push(Mt(jt))})}}return{stream:new be({async start(m){try{await Ue(m)}catch(w){N(m,w)}},write(m,w){const F=En(w);if(F){const K=V.encode(m).length;O.push({chunk:m,byteLen:K});const oe=h+I;I+=K,b||s({streamId:F,chunks:[m],offset:oe})}},close(){o?s({streamId:o,chunks:[],offset:h+I,isDone:!0}):P(),$e()},abort(m){o?s({streamId:o,chunks:[],offset:h+I,isDone:!0,abortReason:m}):P(),$e()}}),addCompleteCb:On,closed(){return d}}}class ds{constructor(){f(this,"items",[]);f(this,"resolvers",[]);f(this,"isClosed",!1)}push(t){if(this.isClosed)return;const n=this.resolvers.shift();n?n({value:t,done:!1}):this.items.push(t)}close(){for(this.isClosed=!0;this.resolvers.length>0;)this.resolvers.shift()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){for(;;)if(this.items.length>0)yield this.items.shift();else{if(this.isClosed)return;{const{value:t,done:n}=await new Promise(s=>{this.resolvers.push(s)});if(n||!t)return;yield t}}}}function hs({RStream:e,opts:t,startStream:n,cancelStream:s}){let i=t.byteOffset||0,r=!1;const o=new TextDecoder("utf-8"),a=new TextEncoder;let c,u=!1;const l=[],d=[];let p=null,y=null;function v(P){u=!0;for(const _ of l)_(P)}function b(P){return l.push(P),()=>{const _=l.indexOf(P);_!==-1&&l.splice(_,1)}}function h(P){return d.push(P),p&&P(p),()=>{const _=d.indexOf(P);_!==-1&&d.splice(_,1)}}function I(P,_){y=_,P.error(_),v(_)}let O=0;async function V(P,_){c=_e();const re={...P||{},eventId:c};for await(const C of n(re)){if(r)return;if(C.type==="reconnect")return{retry:!0};if(C.type==="error"){I(_,C.error);return}if(C.offset>i){I(_,new B("Stream is corrupted.")),r=!0;return}p=C.streamId;for(const N of d)N(p);let W=i-C.offset;if(C.files&&C.files.length){const N=new AbortController;let Z=fetch(C.files[0].url,{signal:N.signal});for(let J=0;J<C.files.length;J++){const ot=C.files[J+1],Ue=await Z;if(ot&&(Z=fetch(ot.url,{signal:N.signal})),!Ue.ok){if(O++,O>10){I(_,new B("Unable to process stream."));return}return{retry:!0}}if(Ue.body){const be=Ue.body.getReader();try{for(;;){const{done:ge,value:m}=await be.read();if(ge)break;if(r){N.abort();return}let w=m;if(W>0&&(w=m.subarray(W),W-=m.length-w.length),!w.length)continue;i+=w.length;const F=o.decode(w);_.enqueue(F)}}finally{be.releaseLock()}}else{const be=await Ue.arrayBuffer();let ge=be;if(r){N.abort();return}if(W>0&&(ge=new Uint8Array(be).subarray(W),W-=be.byteLength-ge.length),!ge.byteLength)continue;i+=ge.byteLength;const m=o.decode(ge);_.enqueue(m)}}}if(O=0,C.content){let N=C.content,Z=a.encode(C.content);if(W>0){const J=Z.subarray(W);if(W-=Z.length-J.length,!J.length)continue;Z=J,N=o.decode(J)}i+=Z.length,_.enqueue(N)}}}async function $e(P){let _=!0,re=0;for(;_;){_=!1;let C=Date.now()+Math.min(15e3,500*(re-1));const W=await V({...t,offset:i},P);W!=null&&W.retry&&(_=!0,re++,C<Date.now()-3e5&&(re=0),await new Promise(N=>{setTimeout(N,Math.max(0,C-Date.now()))}))}!r&&!u&&(P.close(),v())}class Mt extends e{constructor(_,re){super(_,re)}async streamId(){if(p)return p;if(y)throw y;return new Promise((_,re)=>{const C=[],W=()=>{for(const J of C)J()},N=J=>{_(J),W()},Z=J=>{re(J||new B("Stream is closed.")),W()};C.push(h(N)),C.push(b(Z))})}}return{stream:new Mt({start(P){$e(P)},cancel(P){r=!0,c&&s({eventId:c}),v()}}),addCloseCb:b,closed(){return u}}}class ps{constructor({WStream:t,RStream:n,trySend:s,log:i}){f(this,"trySend");f(this,"WStream");f(this,"RStream");f(this,"writeStreams",{});f(this,"startWriteStreamCbs",{});f(this,"readStreamIterators",{});f(this,"log");f(this,"activeStreams",new Set);this.WStream=t,this.RStream=n,this.trySend=s,this.log=i}createWriteStream(t){const{stream:n,addCompleteCb:s}=ls({WStream:this.WStream,startStream:this.startWriteStream.bind(this),appendStream:this.appendStream.bind(this),registerStream:this.registerWriteStream.bind(this),opts:t});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}createReadStream(t){const{stream:n,addCloseCb:s}=hs({RStream:this.RStream,opts:t,startStream:this.startReadStream.bind(this),cancelStream:this.cancelReadStream.bind(this)});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}startWriteStream(t){const n=_e();let s=null;const i=new Promise(o=>{s=o});this.startWriteStreamCbs[n]=s;const r={op:"start-stream","client-id":t.clientId,"reconnect-token":t.reconnectToken};return t.ruleParams&&(r["rule-params"]=t.ruleParams),this.trySend(n,r),i}registerWriteStream(t,n){this.writeStreams[t]=n}appendStream({streamId:t,chunks:n,isDone:s,offset:i,abortReason:r}){const o={op:"append-stream","stream-id":t,chunks:n,offset:i,done:!!s};r&&(o["abort-reason"]=r),this.trySend(_e(),o)}onAppendFailed(t){const n=this.writeStreams[t["stream-id"]];n&&n.onAppendFailed()}onStartStreamOk(t){const n=this.startWriteStreamCbs[t["client-event-id"]];if(!n){this.log.info("No stream for start-stream-ok",t);return}n({type:"ok",streamId:t["stream-id"],offset:t.offset}),delete this.startWriteStreamCbs[t["client-event-id"]]}onStreamFlushed(t){const n=t["stream-id"],s=this.writeStreams[n];if(!s){this.log.info("No stream cbs for stream-flushed",t);return}s.onFlush({offset:t.offset,done:t.done}),t.done&&delete this.writeStreams[n]}startReadStream({eventId:t,clientId:n,streamId:s,offset:i,ruleParams:r}){const o={op:"subscribe-stream"};if(!s&&!n)throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");s&&(o["stream-id"]=s),n&&(o["client-id"]=n),i&&(o.offset=i),r&&(o["rule-params"]=r);const a=new ds;return this.readStreamIterators[t]=a,this.trySend(t,o),a}cancelReadStream({eventId:t}){const n={op:"unsubscribe-stream","subscribe-event-id":t};this.trySend(_e(),n),delete this.readStreamIterators[t]}onStreamAppend(t){const n=t["client-event-id"],s=this.readStreamIterators[n];if(!s){this.log.info("No iterator for read stream",t);return}if(t.error){t.retry?s.push({type:"reconnect"}):s.push({type:"error",error:new B(t.error)}),s.close(),delete this.readStreamIterators[n];return}s.push({type:"append",offset:t.offset,files:t.files,content:t.content,streamId:t["stream-id"]}),t.done&&(s.close(),delete this.readStreamIterators[n])}onConnectionStatusChange(t){for(const n of Object.values(this.startWriteStreamCbs))n({type:"disconnect"});if(this.startWriteStreamCbs={},t!==ms.AUTHENTICATED)for(const{onDisconnect:n}of Object.values(this.writeStreams))n();else{for(const{onConnectionReconnect:n}of Object.values(this.writeStreams))n();for(const n of Object.values(this.readStreamIterators))n.push({type:"reconnect"}),n.close();this.readStreamIterators={}}}onRecieveError(t){const n=t["original-event"];switch(n.op){case"append-stream":{const s=n["stream-id"],i=this.writeStreams[s];i==null||i.onAppendFailed();break}case"start-stream":{const s=t["client-event-id"],i=this.startWriteStreamCbs[s];i&&(i({type:"error",error:new B(t.message||"Unknown error",t.hint)}),delete this.startWriteStreamCbs[s]);break}case"subscribe-stream":{const s=t["client-event-id"],i=this.readStreamIterators[s];i&&(i.push({type:"error",error:new B(t.message||"Unknown error",t.hint)}),i.close(),delete this.readStreamIterators[s]);break}}}hasActiveStreams(){return this.activeStreams.size>0}}const ms={AUTHENTICATED:"authenticated"};function ys(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function bs(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}bs(),ys();class un extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function St(e){}function gs(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=St,onError:n=St,onRetry:s=St,onComment:i}=e;let r="",o=!0,a,c="",u="";function l(b){const h=o?b.replace(/^\xEF\xBB\xBF/,""):b,[I,O]=ws(`${r}${h}`);for(const V of I)d(V);r=O,o=!1}function d(b){if(b===""){y();return}if(b.startsWith(":")){i&&i(b.slice(b.startsWith(": ")?2:1));return}const h=b.indexOf(":");if(h!==-1){const I=b.slice(0,h),O=b[h+1]===" "?2:1,V=b.slice(h+O);p(I,V,b);return}p(b,"",b)}function p(b,h,I){switch(b){case"event":u=h;break;case"data":c=`${c}${h}
|
|
1
|
+
(function(E,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(E=typeof globalThis<"u"?globalThis:E||self,k(E.instant={}))})(this,function(E){"use strict";var Bs=Object.defineProperty;var $n=E=>{throw TypeError(E)};var qs=(E,k,R)=>k in E?Bs(E,k,{enumerable:!0,configurable:!0,writable:!0,value:R}):E[k]=R;var f=(E,k,R)=>qs(E,typeof k!="symbol"?k+"":k,R),Ut=(E,k,R)=>k.has(E)||$n("Cannot "+R);var g=(E,k,R)=>(Ut(E,k,"read from private field"),R?R.call(E):k.get(E)),ee=(E,k,R)=>k.has(E)?$n("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(E):k.set(E,R),de=(E,k,R,M)=>(Ut(E,k,"write to private field"),M?M.call(E,R):k.set(E,R),R),te=(E,k,R)=>(Ut(E,k,"access private method"),R);var je,z,Ee,G,H,L,_n,at,Cn,xn,Tn,nt,st,it,Nt,Rn,rt;const k=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function R(e){return typeof e=="string"&&k.test(e)}const M=[];for(let e=0;e<256;++e)M.push((e+256).toString(16).slice(1));function Pn(e,t=0){return(M[e[t+0]]+M[e[t+1]]+M[e[t+2]]+M[e[t+3]]+"-"+M[e[t+4]]+M[e[t+5]]+"-"+M[e[t+6]]+M[e[t+7]]+"-"+M[e[t+8]]+M[e[t+9]]+"-"+M[e[t+10]]+M[e[t+11]]+M[e[t+12]]+M[e[t+13]]+M[e[t+14]]+M[e[t+15]]).toLowerCase()}let ct;const An=new Uint8Array(16);function Mn(){if(!ct){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ct=crypto.getRandomValues.bind(crypto)}return ct(An)}const Dt={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function jn(e,t,n){var i;if(Dt.randomUUID&&!e)return Dt.randomUUID();e=e||{};const s=e.random??((i=e.rng)==null?void 0:i.call(e))??Mn();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Pn(s)}const D={Remove:"remove",Replace:"replace",Add:"add"},Lt=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),Qe=Symbol.iterator,ne={mutable:"mutable",immutable:"immutable"},ut={};function Ne(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Wt(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const s=Reflect.getOwnPropertyDescriptor(n,t);if(s)return s;n=Reflect.getPrototypeOf(n)}}}function Ft(e){return Object.getPrototypeOf(e)===Set.prototype}function zt(e){return Object.getPrototypeOf(e)===Map.prototype}function X(e){var t;return(t=e.copy)!==null&&t!==void 0?t:e.original}function ft(e){return!!$(e)}function $(e){return typeof e!="object"?null:e==null?void 0:e[Lt]}function lt(e){var t;const n=$(e);return n?(t=n.copy)!==null&&t!==void 0?t:n.original:e}function we(e,t){if(!e||typeof e!="object")return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(t!=null&&t.mark)&&((n=t.mark(e,ne))===ne.immutable||typeof n=="function")}function Vt(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,s=$(he(n,e.key));if(s!==null&&(s==null?void 0:s.original)!==e.original)return null;const i=e.parent.type===3,r=i?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(i&&n.size>r||Ne(n,r)))return null;t.push(r)}if(e.parent)return Vt(e.parent,t);t.reverse();try{Un(e.copy,t)}catch{return null}return t}function De(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function he(e,t){return De(e)===2?e.get(t):e[t]}function dt(e,t,n){De(e)===2?e.set(t,n):e[t]=n}function ht(e,t){const n=$(e);return(n?X(n):e)[t]}function Se(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ie(e,t){return t?e:[""].concat(e).map(n=>{const s=`${n}`;return s.indexOf("/")===-1&&s.indexOf("~")===-1?s:s.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Un(e,t){for(let n=0;n<t.length-1;n+=1){const s=t[n];if(e=he(De(e)===3?Array.from(e):e,s),typeof e!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return e}function Nn(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach(n=>{let s=Reflect.getOwnPropertyDescriptor(e,n);if(s.enumerable&&s.configurable&&s.writable){t[n]=e[n];return}s.writable||(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(s={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[n]}),Reflect.defineProperty(t,n,s)}),t}const Dn=Object.prototype.propertyIsEnumerable;function Ln(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set){if(!Ft(e)){const s=Object.getPrototypeOf(e).constructor;return new s(e.values())}return Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values())}else if(e instanceof Map){if(!zt(e)){const s=Object.getPrototypeOf(e).constructor;return new s(e)}return new Map(e)}else if(t!=null&&t.mark&&(n=t.mark(e,ne),n!==void 0)&&n!==ne.mutable){if(n===ne.immutable)return Nn(e);if(typeof n=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}else if(typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype){const s={};return Object.keys(e).forEach(i=>{s[i]=e[i]}),Object.getOwnPropertySymbols(e).forEach(i=>{Dn.call(e,i)&&(s[i]=e[i])}),s}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function Q(e){e.copy||(e.copy=Ln(e.original,e.options))}function Le(e){if(!we(e))return lt(e);if(Array.isArray(e))return e.map(Le);if(e instanceof Map){const n=Array.from(e.entries()).map(([s,i])=>[s,Le(i)]);if(!zt(e)){const s=Object.getPrototypeOf(e).constructor;return new s(n)}return new Map(n)}if(e instanceof Set){const n=Array.from(e).map(Le);if(!Ft(e)){const s=Object.getPrototypeOf(e).constructor;return new s(n)}return new Set(n)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=Le(e[n]);return t}function Ge(e){return ft(e)?Le(e):e}function ae(e){var t;e.assignedMap=(t=e.assignedMap)!==null&&t!==void 0?t:new Map,e.operated||(e.operated=!0,e.parent&&ae(e.parent))}function Wn(e,t){const n=De(e);if(n===0)Reflect.ownKeys(e).forEach(s=>{t(s,e[s],e)});else if(n===1){let s=0;for(const i of e)t(s,i,e),s+=1}else e.forEach((s,i)=>t(i,s,e))}function Jt(e,t,n){if(ft(e)||!we(e,n)||t.has(e)||Object.isFrozen(e))return;const s=e instanceof Set,i=s?new Map:void 0;if(t.add(e),Wn(e,(r,o)=>{var a;if(ft(o)){const c=$(o);Q(c);const u=!((a=c.assignedMap)===null||a===void 0)&&a.size||c.operated?c.copy:c.original;dt(s?i:e,r,u)}else Jt(o,t,n)}),i){const r=e,o=Array.from(r);r.clear(),o.forEach(a=>{r.add(i.has(a)?i.get(a):a)})}}function Fn(e,t){const n=e.type===3?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&Jt(he(n,t),e.finalities.handledSet,e.options)}function pt(e){e.type===3&&e.copy&&(e.copy.clear(),e.setMap.forEach(t=>{e.copy.add(lt(t))}))}function mt(e,t,n,s){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&s){const r=Vt(e);r&&t(e,r,n,s)}e.finalized=!0}}function yt(e,t,n,s){const i=$(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((r,o)=>{var a;const c=e.type===3?e.setMap:e.copy;if(Se(he(c,t),n)){let u=i.original;i.copy&&(u=i.copy),pt(e),mt(e,s,r,o),e.options.enableAutoFreeze&&(e.options.updatedValues=(a=e.options.updatedValues)!==null&&a!==void 0?a:new WeakMap,e.options.updatedValues.set(u,i.original)),dt(c,t,u)}}),e.options.enableAutoFreeze&&i.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),we(n,e.options)&&e.finalities.draft.push(()=>{const r=e.type===3?e.setMap:e.copy;Se(he(r,t),n)&&Fn(e,t)})}function zn(e,t,n,s,i){let{original:r,assignedMap:o,options:a}=e,c=e.copy;c.length<r.length&&([r,c]=[c,r],[n,s]=[s,n]);for(let u=0;u<r.length;u+=1)if(o.get(u.toString())&&c[u]!==r[u]){const l=t.concat([u]),d=Ie(l,i);n.push({op:D.Replace,path:d,value:Ge(c[u])}),s.push({op:D.Replace,path:d,value:Ge(r[u])})}for(let u=r.length;u<c.length;u+=1){const l=t.concat([u]),d=Ie(l,i);n.push({op:D.Add,path:d,value:Ge(c[u])})}if(r.length<c.length){const{arrayLengthAssignment:u=!0}=a.enablePatches;if(u){const l=t.concat(["length"]),d=Ie(l,i);s.push({op:D.Replace,path:d,value:r.length})}else for(let l=c.length;r.length<l;l-=1){const d=t.concat([l-1]),p=Ie(d,i);s.push({op:D.Remove,path:p})}}}function Vn({original:e,copy:t,assignedMap:n},s,i,r,o){n.forEach((a,c)=>{const u=he(e,c),l=Ge(he(t,c)),d=a?Ne(e,c)?D.Replace:D.Add:D.Remove;if(Se(u,l)&&d===D.Replace)return;const p=s.concat(c),y=Ie(p,o);i.push(d===D.Remove?{op:d,path:y}:{op:d,path:y,value:l}),r.push(d===D.Add?{op:D.Remove,path:y}:d===D.Remove?{op:D.Add,path:y,value:u}:{op:D.Replace,path:y,value:u})})}function Jn({original:e,copy:t},n,s,i,r){let o=0;e.forEach(a=>{if(!t.has(a)){const c=n.concat([o]),u=Ie(c,r);s.push({op:D.Remove,path:u,value:a}),i.unshift({op:D.Add,path:u,value:a})}o+=1}),o=0,t.forEach(a=>{if(!e.has(a)){const c=n.concat([o]),u=Ie(c,r);s.push({op:D.Add,path:u,value:a}),i.unshift({op:D.Remove,path:u,value:a})}o+=1})}function We(e,t,n,s){const{pathAsArray:i=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return Vn(e,t,n,s,i);case 1:return zn(e,t,n,s,i);case 3:return Jn(e,t,n,s,i)}}const He=(e,t,n=!1)=>{if(typeof e=="object"&&e!==null&&(!we(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},bt={get size(){return X($(this)).size},has(e){return X($(this)).has(e)},set(e,t){const n=$(this),s=X(n);return(!s.has(e)||!Se(s.get(e),t))&&(Q(n),ae(n),n.assignedMap.set(e,!0),n.copy.set(e,t),yt(n,e,t,We)),this},delete(e){if(!this.has(e))return!1;const t=$(this);return Q(t),ae(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=$(this);if(this.size){Q(e),ae(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){const n=$(this);X(n).forEach((s,i)=>{e.call(t,this.get(i),i,this)})},get(e){var t,n;const s=$(this),i=X(s).get(e),r=((n=(t=s.options).mark)===null||n===void 0?void 0:n.call(t,i,ne))===ne.mutable;if(s.options.strict&&He(i,s.options,r),r||s.finalized||!we(i,s.options)||i!==s.original.get(e))return i;const o=ut.createDraft({original:i,parentDraft:s,key:e,finalities:s.finalities,options:s.options});return Q(s),s.copy.set(e,o),o},keys(){return X($(this)).keys()},values(){const e=this.keys();return{[Qe]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[Qe]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[Qe](){return this.entries()}},Qn=Reflect.ownKeys(bt),Qt=(e,t,{isValuesIterator:n})=>()=>{var s,i;const r=t.next();if(r.done)return r;const o=r.value;let a=e.setMap.get(o);const c=$(a),u=((i=(s=e.options).mark)===null||i===void 0?void 0:i.call(s,a,ne))===ne.mutable;if(e.options.strict&&He(o,e.options,u),!u&&!c&&we(o,e.options)&&!e.finalized&&e.original.has(o)){const l=ut.createDraft({original:o,parentDraft:e,key:o,finalities:e.finalities,options:e.options});e.setMap.set(o,l),a=l}else c&&(a=c.proxy);return{done:!1,value:n?a:[a,a]}},Be={get size(){return $(this).setMap.size},has(e){const t=$(this);if(t.setMap.has(e))return!0;Q(t);const n=$(e);return!!(n&&t.setMap.has(n.original))},add(e){const t=$(this);return this.has(e)||(Q(t),ae(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),yt(t,e,e,We)),this},delete(e){if(!this.has(e))return!1;const t=$(this);Q(t),ae(t);const n=$(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=$(this);Q(e),ae(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=$(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:Qt(e,t,{isValuesIterator:!0})}},entries(){const e=$(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:Qt(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[Qe](){return this.values()},forEach(e,t){const n=this.values();let s=n.next();for(;!s.done;)e.call(t,s.value,s.value,this),s=n.next()}};Set.prototype.difference&&Object.assign(Be,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const Gn=Reflect.ownKeys(Be),Gt=new WeakSet,Ht={get(e,t,n){var s,i;const r=(s=e.copy)===null||s===void 0?void 0:s[t];if(r&&Gt.has(r))return r;if(t===Lt)return e;let o;if(e.options.mark){const u=t==="size"&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(o=e.options.mark(u,ne),o===ne.mutable)return e.options.strict&&He(u,e.options,!0),u}const a=X(e);if(a instanceof Map&&Qn.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(bt,"size").get.call(e.proxy);const u=bt[t];if(u)return u.bind(e.proxy)}if(a instanceof Set&&Gn.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Be,"size").get.call(e.proxy);const u=Be[t];if(u)return u.bind(e.proxy)}if(!Ne(a,t)){const u=Wt(a,t);return u?"value"in u?u.value:(i=u.get)===null||i===void 0?void 0:i.call(e.proxy):void 0}const c=a[t];if(e.options.strict&&He(c,e.options),e.finalized||!we(c,e.options))return c;if(c===ht(e.original,t)){if(Q(e),e.copy[t]=Bt({original:e.original[t],parentDraft:e,key:e.type===1?Number(t):t,finalities:e.finalities,options:e.options}),typeof o=="function"){const u=$(e.copy[t]);return Q(u),ae(u),u.copy}return e.copy[t]}return c},set(e,t,n){var s;if(e.type===3||e.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(e.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const r=Wt(X(e),t);if(r!=null&&r.set)return r.set.call(e.proxy,n),!0;const o=ht(X(e),t),a=$(o);return a&&Se(a.original,n)?(e.copy[t]=n,e.assignedMap=(s=e.assignedMap)!==null&&s!==void 0?s:new Map,e.assignedMap.set(t,!1),!0):(Se(n,o)&&(n!==void 0||Ne(e.original,t))||(Q(e),ae(e),Ne(e.original,t)&&Se(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,yt(e,t,n,We)),!0)},has(e,t){return t in X(e)},ownKeys(e){return Reflect.ownKeys(X(e))},getOwnPropertyDescriptor(e,t){const n=X(e),s=Reflect.getOwnPropertyDescriptor(n,t);return s&&{writable:!0,configurable:e.type!==1||t!=="length",enumerable:s.enumerable,value:n[t]}},getPrototypeOf(e){return Reflect.getPrototypeOf(e.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return e.type===1?Ht.set.call(this,e,t,void 0,e.proxy):(ht(e.original,t)!==void 0||t in e.original?(Q(e),ae(e),e.assignedMap.set(t,!1)):(e.assignedMap=(n=e.assignedMap)!==null&&n!==void 0?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function Bt(e){const{original:t,parentDraft:n,key:s,finalities:i,options:r}=e,o=De(t),a={type:o,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:i,options:r,setMap:o===3?new Map(t.entries()):void 0};(s||"key"in e)&&(a.key=s);const{proxy:c,revoke:u}=Proxy.revocable(o===1?Object.assign([],a):a,Ht);if(i.revoke.push(u),Gt.add(c),a.proxy=c,n){const l=n;l.finalities.draft.push((d,p)=>{var y,v;const b=$(c);let h=l.type===3?l.setMap:l.copy;const I=he(h,s),O=$(I);if(O){let V=O.original;O.operated&&(V=lt(I)),pt(O),mt(O,We,d,p),l.options.enableAutoFreeze&&(l.options.updatedValues=(y=l.options.updatedValues)!==null&&y!==void 0?y:new WeakMap,l.options.updatedValues.set(V,O.original)),dt(h,s,V)}(v=b.callbacks)===null||v===void 0||v.forEach(V=>{V(d,p)})})}else{const l=$(c);l.finalities.draft.push((d,p)=>{pt(l),mt(l,We,d,p)})}return c}ut.createDraft=Bt,Object.prototype.constructor.toString();function _e(){return jn()}function Hn(e,t){return e.localeCompare(t)}function Bn(){let e=Hn;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{e=Intl.Collator("en-US").compare}catch{}return e}Bn();function qn(){const t={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(t))}const Kn=qn();function qe(e,t,n){const s={__etype:e,__ops:n};return new Proxy(s,{get:(i,r)=>{if(r==="__ops")return n;if(r==="__etype")return e;if(Kn.has(r))return(o,a)=>qe(e,t,[...n,a?[r,e,t,o,a]:[r,e,t,o]])}})}function Xn(e,t){return`lookup__${e}__${JSON.stringify(t)}`}function qt(e){return e.startsWith("lookup__")}function Kt(e){const[t,n,...s]=e.split("__");return[n,JSON.parse(s.join("__"))]}function Yn(e){return new Proxy({__etype:e},{get(t,n){if(n==="lookup")return(i,r)=>qe(e,Kt(Xn(i,r)),[]);if(n==="__etype")return e;const s=n;return qt(s)?qe(e,Kt(s),[]):qe(e,s,[])}})}function Xt(){return new Proxy({},{get(e,t){return Yn(t)}})}Xt();function Zn(e){return e.__ops}class B extends Error{constructor(n,s,i){super(n);f(this,"hint");f(this,"traceId");this.hint=s,i&&(this.traceId=i);const r=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,r),Error.captureStackTrace&&Error.captureStackTrace(this,B),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class ve extends B{constructor(n){var r;const s=((r=n.body)==null?void 0:r.message)||`API Error (${n.status})`;super(s,n.body.hint,n.body["trace-id"]);f(this,"body");f(this,"status");const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,ve),this.name="InstantAPIError",this.status=n.status,this.body=n.body}get[Symbol.toStringTag](){return"InstantAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const Ce="v1.0.23-branch-codex-cli-args-combinators.25394030897.1";class ce{constructor(t,n,s,i={indexed:!1,unique:!1}){f(this,"valueType");f(this,"required");f(this,"isIndexed");f(this,"config");f(this,"metadata",{});this.valueType=t,this.required=n,this.isIndexed=s,this.config=i}clientRequired(){return new ce(this.valueType,!1,this.isIndexed,this.config)}optional(){return new ce(this.valueType,!1,this.isIndexed,this.config)}unique(){return new ce(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new ce(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class x extends Error{constructor(t,n){const s=n?`At path '${n}': ${t}`:t;super(s),this.name="QueryValidationError"}}const Yt=["where","order","limit","last","first","offset","after","afterInclusive","before","beforeInclusive","fields","aggregate"],es=e=>e.valueType||"unknown",Zt=(e,t,n=!1)=>{if(n||e==null)return!0;switch(t){case"string":return typeof e=="string";case"number":return typeof e=="number"&&!isNaN(e);case"boolean":return typeof e=="boolean";case"date":return e instanceof Date||typeof e=="string"||typeof e=="number";default:return!0}},ts=(e,t,n,s,i,r,o)=>{const a=r.valueType==="json",c=(u,l,d)=>{if(!Zt(d,l,a))throw new x(`Invalid value for operator '${u}' on attribute '${s}' in entity '${i}'. Expected ${l}, but received: ${typeof d}`,o)};switch(e){case"in":case"$in":if(!Array.isArray(t))throw new x(`Operator '${e}' for attribute '${s}' in entity '${i}' must be an array, but received: ${typeof t}`,o);for(const u of t)c(e,n,u);break;case"$not":case"$ne":case"$gt":case"$lt":case"$gte":case"$lte":c(e,n,t);break;case"$like":case"$ilike":if(c(e,"string",t),e==="$ilike"&&!r.isIndexed)throw new x(`Operator '${e}' can only be used with indexed attributes, but '${s}' in entity '${i}' is not indexed`,o);break;case"$isNull":c(e,"boolean",t);break;default:throw new x(`Unknown operator '${e}' for attribute '${s}' in entity '${i}'`,o)}},xe=(e,t,n,s,i)=>{const r=es(n),o=n.valueType==="json";if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(o)return;const c=e;for(const[u,l]of Object.entries(c))ts(u,l,r,t,s,n,`${i}.${u}`)}else if(!Zt(e,r,o))throw new x(`Invalid value for attribute '${t}' in entity '${s}'. Expected ${r}, but received: ${typeof e}`,i)},ns=(e,t,n,s,i)=>{const r=e.split(".");if(r.length<2)throw new x(`Invalid dot notation path '${e}'. Must contain at least one dot.`,i);let o=n;for(let l=0;l<r.length-1;l++){const d=r[l],p=s.entities[o];if(!p)throw new x(`Entity '${o}' does not exist in schema while traversing dot notation path '${e}'.`,i);const y=p.links[d];if(!y){const v=Object.keys(p.links);throw new x(`Link '${d}' does not exist on entity '${o}' in dot notation path '${e}'. Available links: ${v.length>0?v.join(", "):"none"}`,i)}o=y.entityName}const a=r[r.length-1],c=s.entities[o];if(!c)throw new x(`Target entity '${o}' does not exist in schema for dot notation path '${e}'.`,i);if(a==="id"){if(typeof t=="string"&&!R(t))throw new x(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${t}`,i);xe(t,e,new ce("string",!1,!0),n,i);return}const u=c.attrs[a];if(Object.keys(c.links).includes(a)){if(typeof t=="string"&&!R(t))throw new x(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${t}`,i);xe(t,e,new ce("string",!1,!0),n,i);return}if(!u){const l=Object.keys(c.attrs);throw new x(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${e}'. Available attributes: ${l.length>0?l.join(", ")+", id":"id"}`,i)}xe(t,e,u,n,i)},en=(e,t,n,s)=>{for(const[i,r]of Object.entries(e)){if(i==="or"||i==="and"){if(Array.isArray(r))for(const u of r)typeof u=="object"&&u!==null&&en(u,t,n,`${s}.${i}[${u}]`);continue}if(i==="id"){xe(r,"id",new ce("string",!1,!0),t,`${s}.id`);continue}if(i.includes(".")){ns(i,r,t,n,`${s}.${i}`);continue}const o=n.entities[t];if(!o)continue;const a=o.attrs[i],c=o.links[i];if(!a&&!c){const u=Object.keys(o.attrs),l=Object.keys(o.links);throw new x(`Attribute or link '${i}' does not exist on entity '${t}'. Available attributes: ${u.length>0?u.join(", "):"none"}. Available links: ${l.length>0?l.join(", "):"none"}`,`${s}.${i}`)}if(a)xe(r,i,a,t,`${s}.${i}`);else if(c){if(typeof r=="string"&&!R(r))throw new x(`Invalid value for link '${i}' in entity '${t}'. Expected a UUID, but received: ${r}`,`${s}.${i}`);const u=new ce("string",!1,!0);xe(r,i,u,t,`${s}.${i}`)}}},ss=(e,t,n,s,i=0)=>{for(const o of Object.keys(e))if(!Yt.includes(o))throw new x(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Yt.join(", ")}. Found: ${o}`,s);const r=["offset","before","beforeInclusive","after","afterInclusive","first","last"];for(const o of r)if(e[o]!==void 0&&i>0)throw new x(`'${o}' can only be used on top-level namespaces. It cannot be used in nested queries.`,s);if(e.where&&n){if(typeof e.where!="object"||e.where===null)throw new x(`'where' clause must be an object in entity '${t}', but received: ${typeof e.where}`,s?`${s}.where`:void 0);en(e.where,t,n,s?`${s}.where`:"where")}},tn=(e,t,n,s,i=0)=>{var r;if(!e||typeof e!="object")throw new x(`Query part for entity '${t}' must be an object, but received: ${typeof e}`,s);for(const o of Object.keys(e))if(o!=="$"){if(n&&!(o in n.entities[t].links)){const c=Object.keys(n.entities[t].links);throw new x(`Link '${o}' does not exist on entity '${t}'. Available links: ${c.length>0?c.join(", "):"none"}`,`${s}.${o}`)}const a=e[o];if(typeof a=="object"&&a!==null){const c=(r=n==null?void 0:n.entities[t].links[o])==null?void 0:r.entityName;c&&tn(a,c,n,`${s}.${o}`,i+1)}}else{const a=e[o];if(typeof a!="object"||a===null)throw new x(`Query parameter '$' must be an object in entity '${t}', but received: ${typeof a}`,`${s}.$`);ss(a,t,n,`${s}.$`,i)}},nn=(e,t)=>{if(typeof e!="object"||e===null)throw new x(`Query must be an object, but received: ${typeof e}${e===null?" (null)":""}`);if(Array.isArray(e))throw new x(`Query must be an object, but received: ${typeof e}`);const n=e;for(const s of Object.keys(n)){if(Array.isArray(e[s]))throw new x(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(typeof s!="string")throw new x(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(s!=="$$ruleParams"){if(t&&!t.entities[s]){const i=Object.keys(t.entities);throw new x(`Entity '${s}' does not exist in schema. Available entities: ${i.length>0?i.join(", "):"none"}`,s)}tn(n[s],s,t,s,0)}}},sn=e=>typeof e!="string"?!1:qt(e)?!0:R(e);class Y extends Error{constructor(t){super(t),this.name="TransactionValidationError"}}const rn=e=>e.length>0?e.join(", "):"none",is=(e,t)=>new Y(`Entity '${e}' does not exist in schema. Available entities: ${rn(t)}`),gt={string:e=>typeof e=="string",number:e=>typeof e=="number"&&!isNaN(e),boolean:e=>typeof e=="boolean",date:e=>e instanceof Date||typeof e=="string"||typeof e=="number",json:()=>!0},rs=(e,t)=>{var n;return e==null?!0:((n=gt[t.valueType])==null?void 0:n.call(gt,e))??!1},on=(e,t)=>{const n=t.entities[e];if(!n)throw is(e,Object.keys(t.entities));return n},wt=(e,t,n)=>{const s=on(e,n);if(typeof t!="object"||t===null)throw new Y(`Arguments for data operation on entity '${e}' must be an object, but received: ${typeof t}`);for(const[i,r]of Object.entries(t)){if(i==="id")continue;const o=s.attrs[i];if(o&&!rs(r,o))throw new Y(`Invalid value for attribute '${i}' in entity '${e}'. Expected ${o.valueType}, but received: ${typeof r}`)}},an=(e,t,n)=>{const s=on(e,n);if(typeof t!="object"||t===null)throw new Y(`Arguments for link operation on entity '${e}' must be an object, but received: ${typeof t}`);for(const[i,r]of Object.entries(t)){if(!s.links[i]){const a=Object.keys(s.links);throw new Y(`Link '${i}' does not exist on entity '${e}'. Available links: ${rn(a)}`)}if(r!=null){if(Array.isArray(r)){for(const a of r)if(!sn(a))throw new Y(`Invalid entity ID in link '${i}' for entity '${e}'. Expected a UUID or a lookup, but received: ${a}`)}else if(!sn(r))throw new Y(`Invalid UUID in link '${i}' for entity '${e}'. Expected a UUID, but received: ${r}`)}}},os={create:wt,update:wt,merge:wt,link:an,unlink:an,delete:()=>{}},as=(e,t)=>{if(!t)return;const[n,s,i,r]=e;if(!Array.isArray(i)&&!R(i))throw new Y(`Invalid id for entity '${s}'. Expected a UUID, but received: ${i}`);if(typeof s!="string")throw new Y(`Entity name must be a string, but received: ${typeof s}`);const o=os[n];o&&r!==void 0&&o(s,r,t)},cs=(e,t)=>{const n=Array.isArray(e)?e:[e];for(const s of n){if(!s||typeof s!="object")throw new Y(`Transaction chunk must be an object, but received: ${typeof s}`);if(!Array.isArray(s.__ops))throw new Y(`Transaction chunk must have __ops array, but received: ${typeof s.__ops}`);for(const i of s.__ops){if(!Array.isArray(i))throw new Y(`Transaction operation must be an array, but received: ${typeof i}`);as(i,t)}}};let us=0;class fs{constructor(t,n,s){f(this,"type","sse");f(this,"initParams",null);f(this,"sendQueue",[]);f(this,"sendPromise");f(this,"closeFired",!1);f(this,"sseInitTimeout");f(this,"ES");f(this,"messageUrl");f(this,"conn");f(this,"url");f(this,"id");f(this,"onopen");f(this,"onmessage");f(this,"onclose");f(this,"onerror");this.id=`${this.type}_${us++}`,this.url=n,this.messageUrl=s||this.url,this.ES=t,this.conn=new t(n),this.sseInitTimeout=setTimeout(()=>{this.initParams||this.handleError()},1e4),this.conn.onmessage=i=>{const r=JSON.parse(i.data);if(Array.isArray(r))for(const o of r)this.handleMessage(o);else this.handleMessage(r)},this.conn.onerror=i=>{this.handleError()}}handleMessage(t){if(t.op==="sse-init"){this.initParams={machineId:t["machine-id"],sessionId:t["session-id"],sseToken:t["sse-token"]},this.onopen&&this.onopen({target:this}),clearTimeout(this.sseInitTimeout);return}this.onmessage&&this.onmessage({target:this,message:t})}handleError(){try{this.onerror&&this.onerror({target:this})}finally{this.handleClose()}}handleClose(){this.conn.close(),this.onclose&&!this.closeFired&&(this.closeFired=!0,this.onclose({target:this}))}async postMessages(t){var n,s,i;try{(await fetch(this.messageUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({machine_id:(n=this.initParams)==null?void 0:n.machineId,session_id:(s=this.initParams)==null?void 0:s.sessionId,sse_token:(i=this.initParams)==null?void 0:i.sseToken,messages:t})})).ok||this.handleError()}catch{this.handleError()}}async flushQueue(){if(this.sendPromise||!this.sendQueue.length)return;const t=this.sendQueue;this.sendQueue=[];const n=this.postMessages(t);this.sendPromise=n,n.then(()=>{this.sendPromise=null,this.flushQueue()})}send(t){if(!this.isOpen()||!this.initParams)throw this.isConnecting()?new Error("Failed to execute 'send' on 'EventSource': Still in CONNECTING state."):this.conn.readyState===this.ES.CLOSED?new Error("EventSource is already in CLOSING or CLOSED state."):new Error("EventSource is in invalid state.");this.sendQueue.push(t),this.flushQueue()}isOpen(){return this.conn.readyState===this.ES.OPEN&&this.initParams!==null}isConnecting(){return this.conn.readyState===this.ES.CONNECTING||this.conn.readyState===this.ES.OPEN&&this.initParams===null}close(){this.handleClose()}}var cn;(function(e){e.InitialSyncBatch="InitialSyncBatch",e.InitialSyncComplete="InitialSyncComplete",e.LoadFromStorage="LoadFromStorage",e.SyncTransaction="SyncTransaction",e.Error="Error"})(cn||(cn={}));function ls({WStream:e,opts:t,startStream:n,appendStream:s,registerStream:i}){const r=t.clientId;let o=null,a=null,c=null;const u=_e();let l=!1,d=!1;const p=[],y=[],v=[];let b=!1,h=0,I=0;const O=[],V=new TextEncoder;function $e(){d=!0;for(const m of p)m(a??void 0)}function Mt(m){return p.push(m),d&&m(a??void 0),()=>{const w=p.indexOf(m);w!==-1&&p.splice(w,1)}}function On(m){return v.push(m),()=>{const w=v.indexOf(m);w!==-1&&v.splice(w,1)}}t.waitUntil&&t.waitUntil(new Promise(m=>{v.push(m)}));function P(){for(const m of v)try{m()}catch{}}function _(m){return y.push(m),o&&m(o),()=>{const w=y.indexOf(m);w!==-1&&y.splice(w,1)}}function re(m){o=m;for(const w of y)w(o)}function C(){b=!0}function W(m){let w=h,F=0,K=0;for(const{byteLen:oe}of O){const le=w+oe;if(le>m)break;w=le,F++,K+=oe}F>0&&(h+=K,I-=K,O.splice(0,F))}function N(m,w){a=w,$e(),m.error(w),P()}async function Z(){const m=await n({clientId:r,reconnectToken:u,ruleParams:t.ruleParams});switch(m.type){case"ok":{const{streamId:w,offset:F}=m;o=w,W(F),O.length&&s({streamId:w,chunks:O.map(K=>K.chunk),offset:h}),b=!1;break}case"disconnect":{C();break}case"error":{c&&N(c,m.error);break}}}function J(){C(),Z()}function ot({offset:m,done:w}){W(m),w&&(l=!0,P())}function En(m){return l?(N(m,new B("Stream has been closed.")),null):o||(N(m,new B("Stream has not been initialized.")),null)}async function Ue(m){c=m;let w=!0,F=0;for(;w;){let K=Date.now()+Math.min(15e3,500*(F-1));w=!1;const oe=await n({clientId:t.clientId,reconnectToken:u,ruleParams:t.ruleParams});switch(oe.type){case"ok":{const{streamId:le,offset:jt}=oe;if(jt!==0){const ke=new B("Write stream is corrupted");N(m,ke);return}re(le),i(le,{onDisconnect:C,onFlush:ot,onConnectionReconnect:Z,onAppendFailed:J}),b=!1;return}case"disconnect":{w=!0,C(),F++,await new Promise(le=>{setTimeout(le,Math.max(0,K-Date.now()))});break}case"error":{N(m,oe.error);return}}}}class be extends e{constructor(w,F){super(w,F)}async streamId(){return o||new Promise((w,F)=>{const K=[],oe=()=>{for(const ke of K)ke()},le=ke=>{w(ke),oe()},jt=ke=>{F(ke||new B("Stream is closed.")),oe()};K.push(_(le)),K.push(Mt(jt))})}}return{stream:new be({async start(m){try{await Ue(m)}catch(w){N(m,w)}},write(m,w){const F=En(w);if(F){const K=V.encode(m).length;O.push({chunk:m,byteLen:K});const oe=h+I;I+=K,b||s({streamId:F,chunks:[m],offset:oe})}},close(){o?s({streamId:o,chunks:[],offset:h+I,isDone:!0}):P(),$e()},abort(m){o?s({streamId:o,chunks:[],offset:h+I,isDone:!0,abortReason:m}):P(),$e()}}),addCompleteCb:On,closed(){return d}}}class ds{constructor(){f(this,"items",[]);f(this,"resolvers",[]);f(this,"isClosed",!1)}push(t){if(this.isClosed)return;const n=this.resolvers.shift();n?n({value:t,done:!1}):this.items.push(t)}close(){for(this.isClosed=!0;this.resolvers.length>0;)this.resolvers.shift()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){for(;;)if(this.items.length>0)yield this.items.shift();else{if(this.isClosed)return;{const{value:t,done:n}=await new Promise(s=>{this.resolvers.push(s)});if(n||!t)return;yield t}}}}function hs({RStream:e,opts:t,startStream:n,cancelStream:s}){let i=t.byteOffset||0,r=!1;const o=new TextDecoder("utf-8"),a=new TextEncoder;let c,u=!1;const l=[],d=[];let p=null,y=null;function v(P){u=!0;for(const _ of l)_(P)}function b(P){return l.push(P),()=>{const _=l.indexOf(P);_!==-1&&l.splice(_,1)}}function h(P){return d.push(P),p&&P(p),()=>{const _=d.indexOf(P);_!==-1&&d.splice(_,1)}}function I(P,_){y=_,P.error(_),v(_)}let O=0;async function V(P,_){c=_e();const re={...P||{},eventId:c};for await(const C of n(re)){if(r)return;if(C.type==="reconnect")return{retry:!0};if(C.type==="error"){I(_,C.error);return}if(C.offset>i){I(_,new B("Stream is corrupted.")),r=!0;return}p=C.streamId;for(const N of d)N(p);let W=i-C.offset;if(C.files&&C.files.length){const N=new AbortController;let Z=fetch(C.files[0].url,{signal:N.signal});for(let J=0;J<C.files.length;J++){const ot=C.files[J+1],Ue=await Z;if(ot&&(Z=fetch(ot.url,{signal:N.signal})),!Ue.ok){if(O++,O>10){I(_,new B("Unable to process stream."));return}return{retry:!0}}if(Ue.body){const be=Ue.body.getReader();try{for(;;){const{done:ge,value:m}=await be.read();if(ge)break;if(r){N.abort();return}let w=m;if(W>0&&(w=m.subarray(W),W-=m.length-w.length),!w.length)continue;i+=w.length;const F=o.decode(w);_.enqueue(F)}}finally{be.releaseLock()}}else{const be=await Ue.arrayBuffer();let ge=be;if(r){N.abort();return}if(W>0&&(ge=new Uint8Array(be).subarray(W),W-=be.byteLength-ge.length),!ge.byteLength)continue;i+=ge.byteLength;const m=o.decode(ge);_.enqueue(m)}}}if(O=0,C.content){let N=C.content,Z=a.encode(C.content);if(W>0){const J=Z.subarray(W);if(W-=Z.length-J.length,!J.length)continue;Z=J,N=o.decode(J)}i+=Z.length,_.enqueue(N)}}}async function $e(P){let _=!0,re=0;for(;_;){_=!1;let C=Date.now()+Math.min(15e3,500*(re-1));const W=await V({...t,offset:i},P);W!=null&&W.retry&&(_=!0,re++,C<Date.now()-3e5&&(re=0),await new Promise(N=>{setTimeout(N,Math.max(0,C-Date.now()))}))}!r&&!u&&(P.close(),v())}class Mt extends e{constructor(_,re){super(_,re)}async streamId(){if(p)return p;if(y)throw y;return new Promise((_,re)=>{const C=[],W=()=>{for(const J of C)J()},N=J=>{_(J),W()},Z=J=>{re(J||new B("Stream is closed.")),W()};C.push(h(N)),C.push(b(Z))})}}return{stream:new Mt({start(P){$e(P)},cancel(P){r=!0,c&&s({eventId:c}),v()}}),addCloseCb:b,closed(){return u}}}class ps{constructor({WStream:t,RStream:n,trySend:s,log:i}){f(this,"trySend");f(this,"WStream");f(this,"RStream");f(this,"writeStreams",{});f(this,"startWriteStreamCbs",{});f(this,"readStreamIterators",{});f(this,"log");f(this,"activeStreams",new Set);this.WStream=t,this.RStream=n,this.trySend=s,this.log=i}createWriteStream(t){const{stream:n,addCompleteCb:s}=ls({WStream:this.WStream,startStream:this.startWriteStream.bind(this),appendStream:this.appendStream.bind(this),registerStream:this.registerWriteStream.bind(this),opts:t});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}createReadStream(t){const{stream:n,addCloseCb:s}=hs({RStream:this.RStream,opts:t,startStream:this.startReadStream.bind(this),cancelStream:this.cancelReadStream.bind(this)});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}startWriteStream(t){const n=_e();let s=null;const i=new Promise(o=>{s=o});this.startWriteStreamCbs[n]=s;const r={op:"start-stream","client-id":t.clientId,"reconnect-token":t.reconnectToken};return t.ruleParams&&(r["rule-params"]=t.ruleParams),this.trySend(n,r),i}registerWriteStream(t,n){this.writeStreams[t]=n}appendStream({streamId:t,chunks:n,isDone:s,offset:i,abortReason:r}){const o={op:"append-stream","stream-id":t,chunks:n,offset:i,done:!!s};r&&(o["abort-reason"]=r),this.trySend(_e(),o)}onAppendFailed(t){const n=this.writeStreams[t["stream-id"]];n&&n.onAppendFailed()}onStartStreamOk(t){const n=this.startWriteStreamCbs[t["client-event-id"]];if(!n){this.log.info("No stream for start-stream-ok",t);return}n({type:"ok",streamId:t["stream-id"],offset:t.offset}),delete this.startWriteStreamCbs[t["client-event-id"]]}onStreamFlushed(t){const n=t["stream-id"],s=this.writeStreams[n];if(!s){this.log.info("No stream cbs for stream-flushed",t);return}s.onFlush({offset:t.offset,done:t.done}),t.done&&delete this.writeStreams[n]}startReadStream({eventId:t,clientId:n,streamId:s,offset:i,ruleParams:r}){const o={op:"subscribe-stream"};if(!s&&!n)throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");s&&(o["stream-id"]=s),n&&(o["client-id"]=n),i&&(o.offset=i),r&&(o["rule-params"]=r);const a=new ds;return this.readStreamIterators[t]=a,this.trySend(t,o),a}cancelReadStream({eventId:t}){const n={op:"unsubscribe-stream","subscribe-event-id":t};this.trySend(_e(),n),delete this.readStreamIterators[t]}onStreamAppend(t){const n=t["client-event-id"],s=this.readStreamIterators[n];if(!s){this.log.info("No iterator for read stream",t);return}if(t.error){t.retry?s.push({type:"reconnect"}):s.push({type:"error",error:new B(t.error)}),s.close(),delete this.readStreamIterators[n];return}s.push({type:"append",offset:t.offset,files:t.files,content:t.content,streamId:t["stream-id"]}),t.done&&(s.close(),delete this.readStreamIterators[n])}onConnectionStatusChange(t){for(const n of Object.values(this.startWriteStreamCbs))n({type:"disconnect"});if(this.startWriteStreamCbs={},t!==ms.AUTHENTICATED)for(const{onDisconnect:n}of Object.values(this.writeStreams))n();else{for(const{onConnectionReconnect:n}of Object.values(this.writeStreams))n();for(const n of Object.values(this.readStreamIterators))n.push({type:"reconnect"}),n.close();this.readStreamIterators={}}}onRecieveError(t){const n=t["original-event"];switch(n.op){case"append-stream":{const s=n["stream-id"],i=this.writeStreams[s];i==null||i.onAppendFailed();break}case"start-stream":{const s=t["client-event-id"],i=this.startWriteStreamCbs[s];i&&(i({type:"error",error:new B(t.message||"Unknown error",t.hint)}),delete this.startWriteStreamCbs[s]);break}case"subscribe-stream":{const s=t["client-event-id"],i=this.readStreamIterators[s];i&&(i.push({type:"error",error:new B(t.message||"Unknown error",t.hint)}),i.close(),delete this.readStreamIterators[s]);break}}}hasActiveStreams(){return this.activeStreams.size>0}}const ms={AUTHENTICATED:"authenticated"};function ys(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function bs(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}bs(),ys();class un extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function St(e){}function gs(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=St,onError:n=St,onRetry:s=St,onComment:i}=e;let r="",o=!0,a,c="",u="";function l(b){const h=o?b.replace(/^\xEF\xBB\xBF/,""):b,[I,O]=ws(`${r}${h}`);for(const V of I)d(V);r=O,o=!1}function d(b){if(b===""){y();return}if(b.startsWith(":")){i&&i(b.slice(b.startsWith(": ")?2:1));return}const h=b.indexOf(":");if(h!==-1){const I=b.slice(0,h),O=b[h+1]===" "?2:1,V=b.slice(h+O);p(I,V,b);return}p(b,"",b)}function p(b,h,I){switch(b){case"event":u=h;break;case"data":c=`${c}${h}
|
|
2
2
|
`;break;case"id":a=h.includes("\0")?void 0:h;break;case"retry":/^\d+$/.test(h)?s(parseInt(h,10)):n(new un(`Invalid \`retry\` value: "${h}"`,{type:"invalid-retry",value:h,line:I}));break;default:n(new un(`Unknown field "${b.length>20?`${b.slice(0,20)}…`:b}"`,{type:"unknown-field",field:b,value:h,line:I}));break}}function y(){c.length>0&&t({id:a,event:u||void 0,data:c.endsWith(`
|
|
3
3
|
`)?c.slice(0,-1):c}),a=void 0,c="",u=""}function v(b={}){r&&b.consume&&d(r),o=!0,a=void 0,c="",u="",r=""}return{feed:l,reset:v}}function ws(e){const t=[];let n="",s=0;for(;s<e.length;){const i=e.indexOf("\r",s),r=e.indexOf(`
|
|
4
4
|
`,s);let o=-1;if(i!==-1&&r!==-1?o=Math.min(i,r):i!==-1?i===e.length-1?o=-1:o=i:r!==-1&&(o=r),o===-1){n=e.slice(s);break}else{const a=e.slice(s,o);t.push(a),s=o+1,e[s-1]==="\r"&&e[s]===`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantdb/resumable-stream",
|
|
3
|
-
"version": "1.0.23-branch-codex-cli-args-combinators.
|
|
3
|
+
"version": "1.0.23-branch-codex-cli-args-combinators.25394030897.1",
|
|
4
4
|
"description": "Instant's drop-in replacement for Vercel's resumable-stream package.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/resumable-stream",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"vitest": "^1.6.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@instantdb/admin": "1.0.23-branch-codex-cli-args-combinators.
|
|
54
|
+
"@instantdb/admin": "1.0.23-branch-codex-cli-args-combinators.25394030897.1"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"test": "vitest",
|