UNPKG

@tonk/keepsync

Version:

A reactive sync engine framework for use with Tonk apps

1,832 lines 3.65 MB
var So = Object.defineProperty; var rB = (A) => { throw TypeError(A); }; var qo = (A, I, g) => I in A ? So(A, I, { enumerable: !0, configurable: !0, writable: !0, value: g }) : A[I] = g; var DA = (A, I, g) => qo(A, typeof I != "symbol" ? I + "" : I, g), cC = (A, I, g) => I.has(A) || rB("Cannot " + g); var h = (A, I, g) => (cC(A, I, "read from private field"), g ? g.call(A) : I.get(A)), b = (A, I, g) => I.has(A) ? rB("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(A) : I.set(A, g), IA = (A, I, g, Q) => (cC(A, I, "write to private field"), Q ? Q.call(A, g) : I.set(A, g), g), W = (A, I, g) => (cC(A, I, "access private method"), g); var fB = (A, I, g, Q) => ({ set _(C) { IA(A, I, C, g); }, get _() { return h(A, I, Q); } }); import dg from "chalk"; const gC = Symbol.for("_am_meta"), xg = Symbol.for("_am_trace"), Tg = Symbol.for("_am_objectId"), YB = Symbol.for("_am_isProxy"), XE = Symbol.for("_am_clearCache"), Lo = Symbol.for("_am_uint"), Ho = Symbol.for("_am_int"), po = Symbol.for("_am_f64"), xE = Symbol.for("_am_counter"), TE = Symbol.for("_am_immutableString"); class eC { constructor(I) { this.value = I || 0, Reflect.defineProperty(this, xE, { value: !0 }); } /** * A peculiar JavaScript language feature from its early days: if the object * `x` has a `valueOf()` method that returns a number, you can use numerical * operators on the object `x` directly, such as `x + 1` or `x < 4`. * This method is also called when coercing a value to a string by * concatenating it with another string, as in `x + ''`. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf */ valueOf() { return this.value; } /** * Returns the counter value as a decimal string. If `x` is a counter object, * this method is called e.g. when you do `['value: ', x].join('')` or when * you use string interpolation: `value: ${x}`. */ toString() { return this.valueOf().toString(); } /** * Returns the counter value, so that a JSON serialization of an Automerge * document represents the counter simply as an integer. */ toJSON() { return this.value; } /** * Increases the value of the counter by `delta`. If `delta` is not given, * increases the value of the counter by 1. * * Will throw an error if used outside of a change callback. */ increment(I) { throw new Error("Counters should not be incremented outside of a change callback"); } /** * Decreases the value of the counter by `delta`. If `delta` is not given, * decreases the value of the counter by 1. * * Will throw an error if used outside of a change callback. */ decrement(I) { throw new Error("Counters should not be decremented outside of a change callback"); } } class to extends eC { constructor(I, g, Q, C, B) { super(I), this.context = g, this.path = Q, this.objectId = C, this.key = B; } /** * Increases the value of the counter by `delta`. If `delta` is not given, * increases the value of the counter by 1. */ increment(I) { return I = typeof I == "number" ? I : 1, this.context.increment(this.objectId, this.key, I), this.value += I, this.value; } /** * Decreases the value of the counter by `delta`. If `delta` is not given, * decreases the value of the counter by 1. */ decrement(I) { return this.increment(typeof I == "number" ? -I : -1); } } function Zo(A, I, g, Q, C) { return new to(A, I, g, Q, C); } var rE; class fE { constructor(I) { this[rE] = !0, this.val = I; } /** * Returns the content of the ImmutableString object as a simple string */ toString() { return this.val; } toJSON() { return this.val; } } rE = TE; function KI(A) { if (typeof A == "string" && /^[0-9]+$/.test(A) && (A = parseInt(A, 10)), typeof A != "number") return A; if (A < 0 || isNaN(A) || A === 1 / 0 || A === -1 / 0) throw new RangeError("A list index must be positive, but you passed " + A); return A; } function bA(A, I) { const { context: g, objectId: Q, path: C } = A, B = g.getWithType(Q, I); if (B === null) return; const E = B[0], D = B[1]; switch (E) { case void 0: return; case "map": return iQ(g, D, [...C, I]); case "list": return CC(g, D, [...C, I]); case "text": return g.text(D); case "str": return new fE(D); case "uint": return D; case "int": return D; case "f64": return D; case "boolean": return D; case "null": return null; case "bytes": return D; case "timestamp": return D; case "counter": return Zo(D, g, C, Q, I); default: throw RangeError(`datatype ${E} unimplemented`); } } function jQ(A, I, g) { const Q = typeof A; switch (Q) { case "object": if (A == null) return [null, "null"]; if (A[Lo]) return [A.value, "uint"]; if (A[Ho]) return [A.value, "int"]; if (A[po]) return [A.value, "f64"]; if (A[xE]) return [A.value, "counter"]; if (A instanceof Date) return [A.getTime(), "timestamp"]; if (zE(A)) return [A.toString(), "str"]; if (A instanceof Uint8Array) return [A, "bytes"]; if (A instanceof Array) return [A, "list"]; if (Object.prototype.toString.call(A) === "[object Object]") return [A, "map"]; throw QC(A, g) ? new RangeError("Cannot create a reference to an existing document object") : new RangeError(`Cannot assign unknown object: ${A}`); case "boolean": return [A, "boolean"]; case "number": return Number.isInteger(A) ? [A, "int"] : [A, "f64"]; case "string": return [A, "text"]; case "undefined": throw new RangeError([ `Cannot assign undefined value at ${zB(I)}, `, "because `undefined` is not a valid JSON data type. ", "You might consider setting the property's value to `null`, ", "or using `delete` to remove it altogether." ].join("")); default: throw new RangeError([ `Cannot assign ${Q} value at ${zB(I)}. `, "All JSON primitive datatypes (object, array, string, number, boolean, null) ", `are supported in an Automerge document; ${Q} values are not. ` ].join("")); } } function QC(A, I) { var g, Q; return A instanceof Date ? !1 : !!(A && ((Q = (g = A[gC]) === null || g === void 0 ? void 0 : g.handle) === null || Q === void 0 ? void 0 : Q.__wbg_ptr) === I.__wbg_ptr); } const Oo = { get(A, I) { const { context: g, objectId: Q, cache: C } = A; return I === Symbol.toStringTag ? A[Symbol.toStringTag] : I === Tg ? Q : I === YB ? !0 : I === xg ? A.trace : I === gC ? { handle: g } : (C[I] || (C[I] = bA(A, I)), C[I]); }, set(A, I, g) { const { context: Q, objectId: C, path: B } = A; if (A.cache = {}, QC(g, Q)) throw new RangeError("Cannot create a reference to an existing document object"); if (I === xg) return A.trace = g, !0; if (I === XE) return !0; const [E, D] = jQ(g, [...B, I], Q); switch (D) { case "list": { const i = Q.putObject(C, I, []), w = CC(Q, i, [...B, I]); for (let o = 0; o < E.length; o++) w[o] = E[o]; break; } case "text": { Q.putObject(C, I, E); break; } case "map": { const i = Q.putObject(C, I, {}), w = iQ(Q, i, [...B, I]); for (const o in E) w[o] = E[o]; break; } default: Q.put(C, I, E, D); } return !0; }, deleteProperty(A, I) { const { context: g, objectId: Q } = A; return A.cache = {}, g.delete(Q, I), !0; }, has(A, I) { return this.get(A, I) !== void 0; }, getOwnPropertyDescriptor(A, I) { const g = this.get(A, I); if (typeof g < "u") return { configurable: !0, enumerable: !0, value: g }; }, ownKeys(A) { const { context: I, objectId: g } = A, Q = I.keys(g); return [...new Set(Q)]; } }, eo = { get(A, I) { const { context: g, objectId: Q } = A; return I = KI(I), I === Symbol.hasInstance ? (C) => Array.isArray(C) : I === Symbol.toStringTag ? A[Symbol.toStringTag] : I === Tg ? Q : I === YB ? !0 : I === xg ? A.trace : I === gC ? { handle: g } : I === "length" ? g.length(Q) : typeof I == "number" ? bA(A, I) : jo(A)[I]; }, set(A, I, g) { const { context: Q, objectId: C, path: B } = A; if (I = KI(I), QC(g, Q)) throw new RangeError("Cannot create a reference to an existing document object"); if (I === XE) return !0; if (I === xg) return A.trace = g, !0; if (typeof I == "string") throw new RangeError("list index must be a number"); const [E, D] = jQ(g, [...B, I], Q); switch (D) { case "list": { let i; I >= Q.length(C) ? i = Q.insertObject(C, I, []) : i = Q.putObject(C, I, []), CC(Q, i, [...B, I]).splice(0, 0, ...E); break; } case "text": { I >= Q.length(C) ? Q.insertObject(C, I, E) : Q.putObject(C, I, E); break; } case "map": { let i; I >= Q.length(C) ? i = Q.insertObject(C, I, {}) : i = Q.putObject(C, I, {}); const w = iQ(Q, i, [...B, I]); for (const o in E) w[o] = E[o]; break; } default: I >= Q.length(C) ? Q.insert(C, I, E, D) : Q.put(C, I, E, D); } return !0; }, deleteProperty(A, I) { const { context: g, objectId: Q } = A; I = KI(I); const C = g.get(Q, I); if (C != null && C[0] == "counter") throw new TypeError("Unsupported operation: deleting a counter from a list"); return g.delete(Q, I), !0; }, has(A, I) { const { context: g, objectId: Q } = A; return I = KI(I), typeof I == "number" ? I < g.length(Q) : I === "length"; }, getOwnPropertyDescriptor(A, I) { const { context: g, objectId: Q } = A; return I === "length" ? { writable: !0, value: g.length(Q) } : I === Tg ? { configurable: !1, enumerable: !1, value: Q } : (I = KI(I), { configurable: !0, enumerable: !0, value: bA(A, I) }); }, getPrototypeOf(A) { return Object.getPrototypeOf(A); }, ownKeys() { const A = []; return A.push("length"), A; } }; function iQ(A, I, g) { const Q = { context: A, objectId: I, path: g || [], cache: {} }, C = {}; return Object.assign(C, Q), new Proxy(C, Oo); } function CC(A, I, g) { const Q = { context: A, objectId: I, path: g || [], cache: {} }, C = []; return Object.assign(C, Q), new Proxy(C, eo); } function lo(A) { return iQ(A, "_root", []); } function jo(A) { const { context: I, objectId: g, path: Q } = A; return { at(B) { return bA(A, B); }, deleteAt(B, E) { return typeof E == "number" ? I.splice(g, B, E) : I.delete(g, B), this; }, fill(B, E, D) { const [i, w] = jQ(B, [...Q, E], I), o = I.length(g); E = KI(E || 0), D = KI(D || o); for (let G = E; G < Math.min(D, o); G++) w === "list" || w === "map" || w === "text" ? I.putObject(g, G, i) : I.put(g, G, i, w); return this; }, indexOf(B, E = 0) { const D = I.length(g); for (let i = E; i < D; i++) { const w = I.getWithType(g, i); if (!w) continue; const [o, G] = w; if (!["map", "list", "text"].includes(o)) { if (G === B) return i; continue; } if (o === "text" && typeof B == "string" && B === bA(A, i) || B[Tg] === G) return i; } return -1; }, insertAt(B, ...E) { return this.splice(B, 0, ...E), this; }, pop() { const B = I.length(g); if (B == 0) return; const E = bA(A, B - 1); return I.delete(g, B - 1), E; }, push(...B) { const E = I.length(g); return this.splice(E, 0, ...B), I.length(g); }, shift() { if (I.length(g) == 0) return; const B = bA(A, 0); return I.delete(g, 0), B; }, splice(B, E, ...D) { B = KI(B), typeof E != "number" && (E = I.length(g) - B), E = KI(E); for (const o of D) if (QC(o, I)) throw new RangeError("Cannot create a reference to an existing document object"); const i = []; for (let o = 0; o < E; o++) { const G = bA(A, B); G !== void 0 && i.push(G), I.delete(g, B); } const w = D.map((o, G) => { try { return jQ(o, [...Q], I); } catch (k) { throw k instanceof RangeError ? new RangeError(`${k.message} (at index ${G} in the input)`) : k; } }); for (const [o, G] of w) { switch (G) { case "list": { const k = I.insertObject(g, B, []); CC(I, k, [...Q, B]).splice(0, 0, ...o); break; } case "text": { I.insertObject(g, B, o); break; } case "map": { const k = I.insertObject(g, B, {}), N = iQ(I, k, [...Q, B]); for (const F in o) N[F] = o[F]; break; } default: I.insert(g, B, o, G); } B += 1; } return i; }, unshift(...B) { return this.splice(0, 0, ...B), I.length(g); }, entries() { let B = 0; return { next: () => { const D = bA(A, B); return D === void 0 ? { value: void 0, done: !0 } : { value: [B++, D], done: !1 }; }, [Symbol.iterator]() { return this; } }; }, keys() { let B = 0; const E = I.length(g); return { next: () => B < E ? { value: B++, done: !1 } : { value: void 0, done: !0 }, [Symbol.iterator]() { return this; } }; }, values() { let B = 0; return { next: () => { const D = bA(A, B++); return D === void 0 ? { value: void 0, done: !0 } : { value: D, done: !1 }; }, [Symbol.iterator]() { return this; } }; }, toArray() { const B = []; let E; do E = bA(A, B.length), E !== void 0 && B.push(E); while (E !== void 0); return B; }, map(B) { return this.toArray().map(B); }, toString() { return this.toArray().toString(); }, toLocaleString() { return this.toArray().toLocaleString(); }, forEach(B) { return this.toArray().forEach(B); }, // todo: real concat function is different concat(B) { return this.toArray().concat(B); }, every(B) { return this.toArray().every(B); }, filter(B) { return this.toArray().filter(B); }, find(B) { let E = 0; for (const D of this) { if (B(D, E)) return D; E += 1; } }, findIndex(B) { let E = 0; for (const D of this) { if (B(D, E)) return E; E += 1; } return -1; }, includes(B) { return this.find((E) => E === B) !== void 0; }, join(B) { return this.toArray().join(B); }, reduce(B, E) { return this.toArray().reduce(B, E); }, reduceRight(B, E) { return this.toArray().reduceRight(B, E); }, lastIndexOf(B, E = 1 / 0) { return this.toArray().lastIndexOf(B, E); }, slice(B, E) { return this.toArray().slice(B, E); }, some(B) { let E = 0; for (const D of this) { if (B(D, E)) return !0; E += 1; } return !1; }, [Symbol.iterator]: function* () { let B = 0, E = bA(A, B); for (; E !== void 0; ) yield E, B += 1, E = bA(A, B); } }; } function zB(A) { const I = A.map((g) => { if (typeof g == "number") return g.toString(); if (typeof g == "string") return g.replace(/~/g, "~0").replace(/\//g, "~1"); }); return A.length === 0 ? "" : "/" + I.join("/"); } function zE(A) { return typeof A == "object" && A !== null && Object.prototype.hasOwnProperty.call(A, TE); } let U, _A = 0, mg = null; function Vg() { return (mg === null || mg.byteLength === 0) && (mg = new Uint8Array(U.memory.buffer)), mg; } const KQ = typeof TextEncoder < "u" ? new TextEncoder("utf-8") : { encode: () => { throw Error("TextEncoder not available"); } }, mo = typeof KQ.encodeInto == "function" ? function(A, I) { return KQ.encodeInto(A, I); } : function(A, I) { const g = KQ.encode(A); return I.set(g), { read: A.length, written: g.length }; }; function FI(A, I, g) { if (g === void 0) { const D = KQ.encode(A), i = I(D.length, 1) >>> 0; return Vg().subarray(i, i + D.length).set(D), _A = D.length, i; } let Q = A.length, C = I(Q, 1) >>> 0; const B = Vg(); let E = 0; for (; E < Q; E++) { const D = A.charCodeAt(E); if (D > 127) break; B[C + E] = D; } if (E !== Q) { E !== 0 && (A = A.slice(E)), C = g(C, Q, Q = E + A.length * 3, 1) >>> 0; const D = Vg().subarray(C + E, C + Q), i = mo(A, D); E += i.written, C = g(C, Q, E, 1) >>> 0; } return _A = E, C; } let bI = null; function fA() { return (bI === null || bI.buffer.detached === !0 || bI.buffer.detached === void 0 && bI.buffer !== U.memory.buffer) && (bI = new DataView(U.memory.buffer)), bI; } function SA(A) { const I = U.__externref_table_alloc(); return U.__wbindgen_export_4.set(I, A), I; } function cI(A, I) { try { return A.apply(this, I); } catch (g) { const Q = SA(g); U.__wbindgen_exn_store(Q); } } const uE = typeof TextDecoder < "u" ? new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }) : { decode: () => { throw Error("TextDecoder not available"); } }; typeof TextDecoder < "u" && uE.decode(); function uA(A, I) { return A = A >>> 0, uE.decode(Vg().subarray(A, A + I)); } function no(A, I) { return A = A >>> 0, Vg().subarray(A / 1, A / 1 + I); } function lC(A) { const I = typeof A; if (I == "number" || I == "boolean" || A == null) return `${A}`; if (I == "string") return `"${A}"`; if (I == "symbol") { const C = A.description; return C == null ? "Symbol" : `Symbol(${C})`; } if (I == "function") { const C = A.name; return typeof C == "string" && C.length > 0 ? `Function(${C})` : "Function"; } if (Array.isArray(A)) { const C = A.length; let B = "["; C > 0 && (B += lC(A[0])); for (let E = 1; E < C; E++) B += ", " + lC(A[E]); return B += "]", B; } const g = /\[object ([^\]]+)\]/.exec(toString.call(A)); let Q; if (g && g.length > 1) Q = g[1]; else return toString.call(A); if (Q == "Object") try { return "Object(" + JSON.stringify(A) + ")"; } catch { return "Object"; } return A instanceof Error ? `${A.name}: ${A.message} ${A.stack}` : Q; } function QA(A) { return A == null; } function t(A) { const I = U.__wbindgen_export_4.get(A); return U.__externref_table_dealloc(A), I; } function xI(A, I) { if (!(A instanceof I)) throw new Error(`expected instance of ${I.name}`); } function Wo(A) { const I = U.create(A); if (I[2]) throw t(I[1]); return hI.__wrap(I[0]); } function bo(A, I) { const g = U.load(A, I); if (g[2]) throw t(g[1]); return hI.__wrap(g[0]); } function Vo(A) { const I = U.encodeChange(A); if (I[2]) throw t(I[1]); return t(I[0]); } function Xo(A) { const I = U.decodeChange(A); if (I[2]) throw t(I[1]); return t(I[0]); } function xo() { const A = U.initSyncState(); return $A.__wrap(A); } function To(A) { const I = U.importSyncState(A); if (I[2]) throw t(I[1]); return $A.__wrap(I[0]); } function ro(A) { return xI(A, $A), U.exportSyncState(A.__wbg_ptr); } function fo(A) { const I = U.encodeSyncMessage(A); if (I[2]) throw t(I[1]); return t(I[0]); } function zo(A) { const I = U.decodeSyncMessage(A); if (I[2]) throw t(I[1]); return t(I[0]); } function uo(A) { return xI(A, $A), U.encodeSyncState(A.__wbg_ptr); } function Po(A) { const I = U.decodeSyncState(A); if (I[2]) throw t(I[1]); return $A.__wrap(I[0]); } const uB = typeof FinalizationRegistry > "u" ? { register: () => { }, unregister: () => { } } : new FinalizationRegistry((A) => U.__wbg_automerge_free(A >>> 0, 1)); class hI { static __wrap(I) { I = I >>> 0; const g = Object.create(hI.prototype); return g.__wbg_ptr = I, uB.register(g, g.__wbg_ptr, g), g; } __destroy_into_raw() { const I = this.__wbg_ptr; return this.__wbg_ptr = 0, uB.unregister(this), I; } free() { const I = this.__destroy_into_raw(); U.__wbg_automerge_free(I, 0); } /** * @param {string | null} [actor] * @returns {Automerge} */ static new(I) { var g = QA(I) ? 0 : FI(I, U.__wbindgen_malloc, U.__wbindgen_realloc), Q = _A; const C = U.automerge_new(g, Q); if (C[2]) throw t(C[1]); return hI.__wrap(C[0]); } /** * @param {string | null} [actor] * @returns {Automerge} */ clone(I) { var g = QA(I) ? 0 : FI(I, U.__wbindgen_malloc, U.__wbindgen_realloc), Q = _A; const C = U.automerge_clone(this.__wbg_ptr, g, Q); if (C[2]) throw t(C[1]); return hI.__wrap(C[0]); } /** * @param {string | null | undefined} actor * @param {any} heads * @returns {Automerge} */ fork(I, g) { var Q = QA(I) ? 0 : FI(I, U.__wbindgen_malloc, U.__wbindgen_realloc), C = _A; const B = U.automerge_fork(this.__wbg_ptr, Q, C, g); if (B[2]) throw t(B[1]); return hI.__wrap(B[0]); } /** * @returns {number} */ pendingOps() { return U.automerge_pendingOps(this.__wbg_ptr); } /** * @param {string | null} [message] * @param {number | null} [time] * @returns {Hash | null} */ commit(I, g) { var Q = QA(I) ? 0 : FI(I, U.__wbindgen_malloc, U.__wbindgen_realloc), C = _A; return U.automerge_commit(this.__wbg_ptr, Q, C, !QA(g), QA(g) ? 0 : g); } /** * @param {Automerge} other * @returns {Heads} */ merge(I) { xI(I, hI); const g = U.automerge_merge(this.__wbg_ptr, I.__wbg_ptr); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @returns {number} */ rollback() { return U.automerge_rollback(this.__wbg_ptr); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {Array<any>} */ keys(I, g) { const Q = U.automerge_keys(this.__wbg_ptr, I, QA(g) ? 0 : SA(g)); if (Q[2]) throw t(Q[1]); return t(Q[0]); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {string} */ text(I, g) { let Q, C; try { const D = U.automerge_text(this.__wbg_ptr, I, QA(g) ? 0 : SA(g)); var B = D[0], E = D[1]; if (D[3]) throw B = 0, E = 0, t(D[2]); return Q = B, C = E, uA(B, E); } finally { U.__wbindgen_free(Q, C, 1); } } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {Array<any>} */ spans(I, g) { const Q = U.automerge_spans(this.__wbg_ptr, I, QA(g) ? 0 : SA(g)); if (Q[2]) throw t(Q[1]); return t(Q[0]); } /** * @param {any} obj * @param {number} start * @param {number} delete_count * @param {any} text */ splice(I, g, Q, C) { const B = U.automerge_splice(this.__wbg_ptr, I, g, Q, C); if (B[1]) throw t(B[0]); } /** * @param {ObjID} obj * @param {string} new_text */ updateText(I, g) { const Q = U.automerge_updateText(this.__wbg_ptr, I, g); if (Q[1]) throw t(Q[0]); } /** * @param {ObjID} obj * @param {Span[]} args * @param {UpdateSpansConfig | undefined | null} config */ updateSpans(I, g, Q) { const C = U.automerge_updateSpans(this.__wbg_ptr, I, g, Q); if (C[1]) throw t(C[0]); } /** * @param {any} obj * @param {any} value * @param {any} datatype */ push(I, g, Q) { const C = U.automerge_push(this.__wbg_ptr, I, g, Q); if (C[1]) throw t(C[0]); } /** * @param {ObjID} obj * @param {ObjType} value * @returns {ObjID} */ pushObject(I, g) { let Q, C; try { const D = U.automerge_pushObject(this.__wbg_ptr, I, g); var B = D[0], E = D[1]; if (D[3]) throw B = 0, E = 0, t(D[2]); return Q = B, C = E, uA(B, E); } finally { U.__wbindgen_free(Q, C, 1); } } /** * @param {any} obj * @param {number} index * @param {any} value * @param {any} datatype */ insert(I, g, Q, C) { const B = U.automerge_insert(this.__wbg_ptr, I, g, Q, C); if (B[1]) throw t(B[0]); } /** * @param {ObjID} obj * @param {number} index * @param {{[key: string]: MaterializeValue}} block */ splitBlock(I, g, Q) { const C = U.automerge_splitBlock(this.__wbg_ptr, I, g, Q); if (C[1]) throw t(C[0]); } /** * @param {ObjID} obj * @param {number} index */ joinBlock(I, g) { const Q = U.automerge_joinBlock(this.__wbg_ptr, I, g); if (Q[1]) throw t(Q[0]); } /** * @param {ObjID} obj * @param {number} index * @param {{[key: string]: MaterializeValue}} block */ updateBlock(I, g, Q) { const C = U.automerge_updateBlock(this.__wbg_ptr, I, g, Q); if (C[1]) throw t(C[0]); } /** * @param {any} text * @param {number} index * @param {Array<any> | null} [heads] * @returns {any} */ getBlock(I, g, Q) { const C = U.automerge_getBlock(this.__wbg_ptr, I, g, QA(Q) ? 0 : SA(Q)); if (C[2]) throw t(C[1]); return t(C[0]); } /** * @param {ObjID} obj * @param {number} index * @param {ObjType} value * @returns {ObjID} */ insertObject(I, g, Q) { let C, B; try { const i = U.automerge_insertObject(this.__wbg_ptr, I, g, Q); var E = i[0], D = i[1]; if (i[3]) throw E = 0, D = 0, t(i[2]); return C = E, B = D, uA(E, D); } finally { U.__wbindgen_free(C, B, 1); } } /** * @param {any} obj * @param {any} prop * @param {any} value * @param {any} datatype */ put(I, g, Q, C) { const B = U.automerge_put(this.__wbg_ptr, I, g, Q, C); if (B[1]) throw t(B[0]); } /** * @param {ObjID} obj * @param {Prop} prop * @param {ObjType} value * @returns {ObjID} */ putObject(I, g, Q) { const C = U.automerge_putObject(this.__wbg_ptr, I, g, Q); if (C[2]) throw t(C[1]); return t(C[0]); } /** * @param {ObjID} obj * @param {Prop} prop * @param {number} value */ increment(I, g, Q) { const C = U.automerge_increment(this.__wbg_ptr, I, g, Q); if (C[1]) throw t(C[0]); } /** * @param {any} obj * @param {any} prop * @param {Array<any> | null} [heads] * @returns {any} */ get(I, g, Q) { const C = U.automerge_get(this.__wbg_ptr, I, g, QA(Q) ? 0 : SA(Q)); if (C[2]) throw t(C[1]); return t(C[0]); } /** * @param {any} obj * @param {any} prop * @param {Array<any> | null} [heads] * @returns {any} */ getWithType(I, g, Q) { const C = U.automerge_getWithType(this.__wbg_ptr, I, g, QA(Q) ? 0 : SA(Q)); if (C[2]) throw t(C[1]); return t(C[0]); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {object} */ objInfo(I, g) { const Q = U.automerge_objInfo(this.__wbg_ptr, I, QA(g) ? 0 : SA(g)); if (Q[2]) throw t(Q[1]); return t(Q[0]); } /** * @param {any} obj * @param {any} arg * @param {Array<any> | null} [heads] * @returns {Array<any>} */ getAll(I, g, Q) { const C = U.automerge_getAll(this.__wbg_ptr, I, g, QA(Q) ? 0 : SA(Q)); if (C[2]) throw t(C[1]); return t(C[0]); } /** * @param {boolean} enable * @returns {boolean} */ enableFreeze(I) { const g = U.automerge_enableFreeze(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return g[0] !== 0; } /** * @param {string} datatype * @param {Function} construct * @param {(arg: any) => any | undefined} deconstruct */ registerDatatype(I, g, Q) { const C = U.automerge_registerDatatype(this.__wbg_ptr, I, g, Q); if (C[1]) throw t(C[0]); } /** * @param {any} object * @param {any} meta * @returns {any} */ applyPatches(I, g) { const Q = U.automerge_applyPatches(this.__wbg_ptr, I, g); if (Q[2]) throw t(Q[1]); return t(Q[0]); } /** * @param {any} object * @param {any} meta * @returns {any} */ applyAndReturnPatches(I, g) { const Q = U.automerge_applyAndReturnPatches(this.__wbg_ptr, I, g); if (Q[2]) throw t(Q[1]); return t(Q[0]); } /** * @returns {Patch[]} */ diffIncremental() { const I = U.automerge_diffIncremental(this.__wbg_ptr); if (I[2]) throw t(I[1]); return t(I[0]); } updateDiffCursor() { U.automerge_updateDiffCursor(this.__wbg_ptr); } resetDiffCursor() { U.automerge_resetDiffCursor(this.__wbg_ptr); } /** * @param {Heads} before * @param {Heads} after * @returns {Patch[]} */ diff(I, g) { const Q = U.automerge_diff(this.__wbg_ptr, I, g); if (Q[2]) throw t(Q[1]); return t(Q[0]); } /** * @param {Heads} heads */ isolate(I) { const g = U.automerge_isolate(this.__wbg_ptr, I); if (g[1]) throw t(g[0]); } integrate() { U.automerge_integrate(this.__wbg_ptr); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {number} */ length(I, g) { const Q = U.automerge_length(this.__wbg_ptr, I, QA(g) ? 0 : SA(g)); if (Q[2]) throw t(Q[1]); return Q[0]; } /** * @param {ObjID} obj * @param {Prop} prop */ delete(I, g) { const Q = U.automerge_delete(this.__wbg_ptr, I, g); if (Q[1]) throw t(Q[0]); } /** * @returns {Uint8Array} */ save() { return U.automerge_save(this.__wbg_ptr); } /** * @returns {Uint8Array} */ saveIncremental() { return U.automerge_saveIncremental(this.__wbg_ptr); } /** * @param {Heads} heads * @returns {Uint8Array} */ saveSince(I) { const g = U.automerge_saveSince(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @returns {Uint8Array} */ saveNoCompress() { return U.automerge_saveNoCompress(this.__wbg_ptr); } /** * @returns {Uint8Array} */ saveAndVerify() { const I = U.automerge_saveAndVerify(this.__wbg_ptr); if (I[2]) throw t(I[1]); return t(I[0]); } /** * @param {Uint8Array} data * @returns {number} */ loadIncremental(I) { const g = U.automerge_loadIncremental(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return g[0]; } /** * @param {Change[]} changes */ applyChanges(I) { const g = U.automerge_applyChanges(this.__wbg_ptr, I); if (g[1]) throw t(g[0]); } /** * @param {Heads} have_deps * @returns {Change[]} */ getChanges(I) { const g = U.automerge_getChanges(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @param {Heads} have_deps * @returns {ChangeMetadata[]} */ getChangesMeta(I) { const g = U.automerge_getChangesMeta(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @param {Hash} hash * @returns {Change | null} */ getChangeByHash(I) { const g = U.automerge_getChangeByHash(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @param {Hash} hash * @returns {ChangeMetadata | null} */ getChangeMetaByHash(I) { const g = U.automerge_getChangeMetaByHash(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @param {Hash} hash * @returns {DecodedChange | null} */ getDecodedChangeByHash(I) { const g = U.automerge_getDecodedChangeByHash(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @param {Automerge} other * @returns {Change[]} */ getChangesAdded(I) { return xI(I, hI), U.automerge_getChangesAdded(this.__wbg_ptr, I.__wbg_ptr); } /** * @returns {Heads} */ getHeads() { return U.automerge_getHeads(this.__wbg_ptr); } /** * @returns {Actor} */ getActorId() { let I, g; try { const Q = U.automerge_getActorId(this.__wbg_ptr); return I = Q[0], g = Q[1], uA(Q[0], Q[1]); } finally { U.__wbindgen_free(I, g, 1); } } /** * @returns {Change | null} */ getLastLocalChange() { return U.automerge_getLastLocalChange(this.__wbg_ptr); } dump() { U.automerge_dump(this.__wbg_ptr); } /** * @param {Array<any> | null} [heads] * @returns {Array<any>} */ getMissingDeps(I) { const g = U.automerge_getMissingDeps(this.__wbg_ptr, QA(I) ? 0 : SA(I)); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @param {SyncState} state * @param {SyncMessage} message */ receiveSyncMessage(I, g) { xI(I, $A); const Q = U.automerge_receiveSyncMessage(this.__wbg_ptr, I.__wbg_ptr, g); if (Q[1]) throw t(Q[0]); } /** * @param {SyncState} state * @returns {SyncMessage | null} */ generateSyncMessage(I) { return xI(I, $A), U.automerge_generateSyncMessage(this.__wbg_ptr, I.__wbg_ptr); } /** * @param {any} meta * @returns {MaterializeValue} */ toJS(I) { const g = U.automerge_toJS(this.__wbg_ptr, I); if (g[2]) throw t(g[1]); return t(g[0]); } /** * @param {any} obj * @param {Array<any> | null | undefined} heads * @param {any} meta * @returns {any} */ materialize(I, g, Q) { const C = U.automerge_materialize(this.__wbg_ptr, I, QA(g) ? 0 : SA(g), Q); if (C[2]) throw t(C[1]); return t(C[0]); } /** * @param {any} obj * @param {any} position * @param {Array<any> | null | undefined} heads * @param {any} move_cursor * @returns {string} */ getCursor(I, g, Q, C) { let B, E; try { const w = U.automerge_getCursor(this.__wbg_ptr, I, g, QA(Q) ? 0 : SA(Q), C); var D = w[0], i = w[1]; if (w[3]) throw D = 0, i = 0, t(w[2]); return B = D, E = i, uA(D, i); } finally { U.__wbindgen_free(B, E, 1); } } /** * @param {any} obj * @param {any} cursor * @param {Array<any> | null} [heads] * @returns {number} */ getCursorPosition(I, g, Q) { const C = U.automerge_getCursorPosition(this.__wbg_ptr, I, g, QA(Q) ? 0 : SA(Q)); if (C[2]) throw t(C[1]); return C[0]; } /** * @param {string | null} [message] * @param {number | null} [time] * @returns {Hash} */ emptyChange(I, g) { var Q = QA(I) ? 0 : FI(I, U.__wbindgen_malloc, U.__wbindgen_realloc), C = _A; return U.automerge_emptyChange(this.__wbg_ptr, Q, C, !QA(g), QA(g) ? 0 : g); } /** * @param {any} obj * @param {any} range * @param {any} name * @param {any} value * @param {any} datatype */ mark(I, g, Q, C, B) { const E = U.automerge_mark(this.__wbg_ptr, I, g, Q, C, B); if (E[1]) throw t(E[0]); } /** * @param {ObjID} obj * @param {MarkRange} range * @param {string} name */ unmark(I, g, Q) { const C = U.automerge_unmark(this.__wbg_ptr, I, g, Q); if (C[1]) throw t(C[0]); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {any} */ marks(I, g) { const Q = U.automerge_marks(this.__wbg_ptr, I, QA(g) ? 0 : SA(g)); if (Q[2]) throw t(Q[1]); return t(Q[0]); } /** * @param {any} obj * @param {number} index * @param {Array<any> | null} [heads] * @returns {object} */ marksAt(I, g, Q) { const C = U.automerge_marksAt(this.__wbg_ptr, I, g, QA(Q) ? 0 : SA(Q)); if (C[2]) throw t(C[1]); return t(C[0]); } /** * @param {SyncState} state * @returns {boolean} */ hasOurChanges(I) { return xI(I, $A), U.automerge_hasOurChanges(this.__wbg_ptr, I.__wbg_ptr) !== 0; } /** * @returns {Hash[]} */ topoHistoryTraversal() { return U.automerge_topoHistoryTraversal(this.__wbg_ptr); } /** * @returns {Stats} */ stats() { return U.automerge_stats(this.__wbg_ptr); } } const PB = typeof FinalizationRegistry > "u" ? { register: () => { }, unregister: () => { } } : new FinalizationRegistry((A) => U.__wbg_syncstate_free(A >>> 0, 1)); class $A { static __wrap(I) { I = I >>> 0; const g = Object.create($A.prototype); return g.__wbg_ptr = I, PB.register(g, g.__wbg_ptr, g), g; } __destroy_into_raw() { const I = this.__wbg_ptr; return this.__wbg_ptr = 0, PB.unregister(this), I; } free() { const I = this.__destroy_into_raw(); U.__wbg_syncstate_free(I, 0); } /** * @returns {Heads} */ get sharedHeads() { return U.syncstate_sharedHeads(this.__wbg_ptr); } /** * @returns {Heads} */ get lastSentHeads() { return U.syncstate_lastSentHeads(this.__wbg_ptr); } /** * @param {Heads} heads */ set lastSentHeads(I) { const g = U.syncstate_set_lastSentHeads(this.__wbg_ptr, I); if (g[1]) throw t(g[0]); } /** * @param {Heads} hashes */ set sentHashes(I) { const g = U.syncstate_set_sentHashes(this.__wbg_ptr, I); if (g[1]) throw t(g[0]); } /** * @returns {SyncState} */ clone() { const I = U.syncstate_clone(this.__wbg_ptr); return $A.__wrap(I); } } async function vo(A, I) { if (typeof Response == "function" && A instanceof Response) { if (typeof WebAssembly.instantiateStreaming == "function") try { return await WebAssembly.instantiateStreaming(A, I); } catch (Q) { if (A.headers.get("Content-Type") != "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", Q); else throw Q; } const g = await A.arrayBuffer(); return await WebAssembly.instantiate(g, I); } else { const g = await WebAssembly.instantiate(A, I); return g instanceof WebAssembly.Instance ? { instance: g, module: A } : g; } } function PE() { const A = {}; return A.wbg = {}, A.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(I, g) { const Q = String(g), C = FI(Q, U.__wbindgen_malloc, U.__wbindgen_realloc), B = _A; fA().setInt32(I + 4 * 1, B, !0), fA().setInt32(I + 4 * 0, C, !0); }, A.wbg.__wbg_apply_eb9e9b97497f91e4 = function() { return cI(function(I, g, Q) { return Reflect.apply(I, g, Q); }, arguments); }, A.wbg.__wbg_assign_3627b8559449930a = function(I, g) { return Object.assign(I, g); }, A.wbg.__wbg_buffer_609cc3eee51ed158 = function(I) { return I.buffer; }, A.wbg.__wbg_call_672a4d21634d4a24 = function() { return cI(function(I, g) { return I.call(g); }, arguments); }, A.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return cI(function(I, g, Q) { return I.call(g, Q); }, arguments); }, A.wbg.__wbg_concat_9de968491c4340cf = function(I, g) { return I.concat(g); }, A.wbg.__wbg_defineProperty_a3ddad9901e2d29e = function(I, g, Q) { return Object.defineProperty(I, g, Q); }, A.wbg.__wbg_deleteProperty_96363d4a1d977c97 = function() { return cI(function(I, g) { return Reflect.deleteProperty(I, g); }, arguments); }, A.wbg.__wbg_done_769e5ede4b31c67b = function(I) { return I.done; }, A.wbg.__wbg_entries_3265d4158b33e5dc = function(I) { return Object.entries(I); }, A.wbg.__wbg_error_7534b8e9a36f1ab4 = function(I, g) { let Q, C; try { Q = I, C = g, console.error(uA(I, g)); } finally { U.__wbindgen_free(Q, C, 1); } }, A.wbg.__wbg_for_4ff07bddd743c5e7 = function(I, g) { return Symbol.for(uA(I, g)); }, A.wbg.__wbg_freeze_ef6d70cf38e8d948 = function(I) { return Object.freeze(I); }, A.wbg.__wbg_from_2a5d3e218e67aa85 = function(I) { return Array.from(I); }, A.wbg.__wbg_getRandomValues_3c9c0d586e575a16 = function() { return cI(function(I, g) { globalThis.crypto.getRandomValues(no(I, g)); }, arguments); }, A.wbg.__wbg_getTime_46267b1c24877e30 = function(I) { return I.getTime(); }, A.wbg.__wbg_get_67b2ba62fc30de12 = function() { return cI(function(I, g) { return Reflect.get(I, g); }, arguments); }, A.wbg.__wbg_get_b9b93047fe3cf45b = function(I, g) { return I[g >>> 0]; }, A.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(I) { let g; try { g = I instanceof ArrayBuffer; } catch { g = !1; } return g; }, A.wbg.__wbg_instanceof_Date_e9a9be8b9cea7890 = function(I) { let g; try { g = I instanceof Date; } catch { g = !1; } return g; }, A.wbg.__wbg_instanceof_Object_7f2dcef8f78644a4 = function(I) { let g; try { g = I instanceof Object; } catch { g = !1; } return g; }, A.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(I) { let g; try { g = I instanceof Uint8Array; } catch { g = !1; } return g; }, A.wbg.__wbg_isArray_a1eab7e0d067391b = function(I) { return Array.isArray(I); }, A.wbg.__wbg_iterator_9a24c88df860dc65 = function() { return Symbol.iterator; }, A.wbg.__wbg_keys_5c77a08ddc2fb8a6 = function(I) { return Object.keys(I); }, A.wbg.__wbg_length_a446193dc22c12f8 = function(I) { return I.length; }, A.wbg.__wbg_length_d56737991078581b = function(I) { return I.length; }, A.wbg.__wbg_length_e2d2a49132c1b256 = function(I) { return I.length; }, A.wbg.__wbg_log_1ae1e9f741096e91 = function(I, g) { console.log(I, g); }, A.wbg.__wbg_log_c222819a41e063d3 = function(I) { console.log(I); }, A.wbg.__wbg_new_1ab78df5e132f715 = function(I, g) { return new RangeError(uA(I, g)); }, A.wbg.__wbg_new_31a97dac4f10fab7 = function(I) { return new Date(I); }, A.wbg.__wbg_new_405e22f390576ce2 = function() { return new Object(); }, A.wbg.__wbg_new_78feb108b6472713 = function() { return new Array(); }, A.wbg.__wbg_new_8a6f238a6ece86ea = function() { return new Error(); }, A.wbg.__wbg_new_a12002a7f91c75be = function(I) { return new Uint8Array(I); }, A.wbg.__wbg_new_c68d7209be747379 = function(I, g) { return new Error(uA(I, g)); }, A.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(I, g, Q) { return new Uint8Array(I, g >>> 0, Q >>> 0); }, A.wbg.__wbg_next_25feadfc0913fea9 = function(I) { return I.next; }, A.wbg.__wbg_next_6574e1a8a62d1055 = function() { return cI(function(I) { return I.next(); }, arguments); }, A.wbg.__wbg_ownKeys_3930041068756f1f = function() { return cI(function(I) { return Reflect.ownKeys(I); }, arguments); }, A.wbg.__wbg_push_737cfc8c1432c2c6 = function(I, g) { return I.push(g); }, A.wbg.__wbg_set_37837023f3d740e8 = function(I, g, Q) { I[g >>> 0] = Q; }, A.wbg.__wbg_set_3f1d0b984ed272ed = function(I, g, Q) { I[g] = Q; }, A.wbg.__wbg_set_65595bdd868b3009 = function(I, g, Q) { I.set(g, Q >>> 0); }, A.wbg.__wbg_set_bb8cecf6a62b9f46 = function() { return cI(function(I, g, Q) { return Reflect.set(I, g, Q); }, arguments); }, A.wbg.__wbg_slice_972c243648c9fd2e = function(I, g, Q) { return I.slice(g >>> 0, Q >>> 0); }, A.wbg.__wbg_stack_0ed75d68575b0f3c = function(I, g) { const Q = g.stack, C = FI(Q, U.__wbindgen_malloc, U.__wbindgen_realloc), B = _A; fA().setInt32(I + 4 * 1, B, !0), fA().setInt32(I + 4 * 0, C, !0); }, A.wbg.__wbg_toString_66ab719c2a98bdf1 = function(I) { return I.toString(); }, A.wbg.__wbg_unshift_c290010f73f04fb1 = function(I, g) { return I.unshift(g); }, A.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(I) { return I.value; }, A.wbg.__wbg_values_fcb8ba8c0aad8b58 = function(I) { return Object.values(I); }, A.wbg.__wbindgen_bigint_from_i64 = function(I) { return I; }, A.wbg.__wbindgen_bigint_from_u64 = function(I) { return BigInt.asUintN(64, I); }, A.wbg.__wbindgen_boolean_get = function(I) { const g = I; return typeof g == "boolean" ? g ? 1 : 0 : 2; }, A.wbg.__wbindgen_debug_string = function(I, g) { const Q = lC(g), C = FI(Q, U.__wbindgen_malloc, U.__wbindgen_realloc), B = _A; fA().setInt32(I + 4 * 1, B, !0), fA().setInt32(I + 4 * 0, C, !0); }, A.wbg.__wbindgen_error_new = function(I, g) { return new Error(uA(I, g)); }, A.wbg.__wbindgen_init_externref_table = function() { const I = U.__wbindgen_export_4, g = I.grow(4); I.set(0, void 0), I.set(g + 0, void 0), I.set(g + 1, null), I.set(g + 2, !0), I.set(g + 3, !1); }, A.wbg.__wbindgen_is_array = function(I) { return Array.isArray(I); }, A.wbg.__wbindgen_is_function = function(I) { return typeof I == "function"; }, A.wbg.__wbindgen_is_null = function(I) { return I === null; }, A.wbg.__wbindgen_is_object = function(I) { const g = I; return typeof g == "object" && g !== null; }, A.wbg.__wbindgen_is_string = function(I) { return typeof I == "string"; }, A.wbg.__wbindgen_is_undefined = function(I) { return I === void 0; }, A.wbg.__wbindgen_json_serialize = function(I, g) { const Q = g, C = JSON.stringify(Q === void 0 ? null : Q), B = FI(C, U.__wbindgen_malloc, U.__wbindgen_realloc), E = _A; fA().setInt32(I + 4 * 1, E, !0), fA().setInt32(I + 4 * 0, B, !0); }, A.wbg.__wbindgen_jsval_loose_eq = function(I, g) { return I == g; }, A.wbg.__wbindgen_memory = function() { return U.memory; }, A.wbg.__wbindgen_number_get = function(I, g) { const Q = g, C = typeof Q == "number" ? Q : void 0; fA().setFloat64(I + 8 * 1, QA(C) ? 0 : C, !0), fA().setInt32(I + 4 * 0, !QA(C), !0); }, A.wbg.__wbindgen_number_new = function(I) { return I; }, A.wbg.__wbindgen_string_get = function(I, g) { const Q = g, C = typeof Q == "string" ? Q : void 0; var B = QA(C) ? 0 : FI(C, U.__wbindgen_malloc, U.__wbindgen_realloc), E = _A; fA().setInt32(I + 4 * 1, E, !0), fA().setInt32(I + 4 * 0, B, !0); }, A.wbg.__wbindgen_string_new = function(I, g) { return uA(I, g); }, A.wbg.__wbindgen_throw = function(I, g) { throw new Error(uA(I, g)); }, A; } function vE(A, I) { return U = A.exports, MB.__wbindgen_wasm_module = I, bI = null, mg = null, U.__wbindgen_start(), U; } function _o(A) { if (U !== void 0) return U; typeof A < "u" && (Object.getPrototypeOf(A) === Object.prototype ? { module: A } = A : console.warn("using deprecated parameters for `initSync()`; pass a single object instead")); const I = PE(); A instanceof WebAssembly.Module || (A = new WebAssembly.Module(A)); const g = new WebAssembly.Instance(A, I); return vE(g, A); } async function MB(A) { if (U !== void 0) return U; typeof A < "u" && (Object.getPrototypeOf(A) === Object.prototype ? { module_or_path: A } = A : console.warn("using deprecated parameters for the initialization function; pass a single object instead")), typeof A > "u" && (A = new /* @vite-ignore */ URL("automerge_wasm_bg.wasm", import.meta.url)); const I = PE(); (typeof A == "string" || typeof Request == "function" && A instanceof Request || typeof URL == "function" && A instanceof URL) && (A = fetch(A)); const { instance: g, module: Q } = await vo(await A, I); return vE(g, Q); } const $o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, Automerge: hI, SyncState: $A, create: Wo, decodeChange: Xo, decodeSyncMessage: zo, decodeSyncState: Po, default: MB, encodeChange: Vo, encodeSyncMessage: fo, encodeSyncState: uo, exportSyncState: ro, importSyncState: To, initSync: _o, initSyncState: xo, load: bo }, Symbol.toStringTag, { value: "Module" })); let AG = []; function IG(A) { for (const I in A) mA[I] = A[I]; for (const I of AG) I(); } const mA = { create(A) { throw new RangeError("Automerge.use() not called"); }, load(A, I) { throw new RangeError("Automerge.use() not called (load)"); }, encodeChange(A) { throw new RangeError("Automerge.use() not called (encodeChange)"); }, decodeChange(A) { throw new RangeError("Automerge.use() not called (decodeChange)"); }, initSyncState() { throw new RangeError("Automerge.use() not called (initSyncState)"); }, encodeSyncMessage(A) { throw new RangeError("Automerge.use() not called (encodeSyncMessage)"); }, decodeSyncMessage(A) { throw new RangeError("Automerge.use() not called (decodeSyncMessage)"); }, encodeSyncState(A) { throw new RangeError("Automerge.use() not called (encodeSyncState)"); }, decodeSyncState(A) { throw new RangeError("Automerge.use() not called (decodeSyncState)"); }, exportSyncState(A) { throw new RangeError("Automerge.use() not called (exportSyncState)"); }, importSyncState(A) { throw new RangeError("Automerge.use() not called (importSyncState)"); } }; function gG(A) { return MB({ module_or_path: A }).then((I) => { IG($o); }); } function RA(A, I = !0) { if (typeof A != "object") throw new RangeError("must be the document root"); const g = Reflect.get(A, gC); if (g === void 0 || g == null || I && QG(A) !== "_root") throw new RangeError("must be the document root"); return g; } function _E(A) { return Reflect.get(A, xg); } function QG(A) { return typeof A != "object" || A === null ? null : Reflect.get(A, Tg); } function BC(A) { return !!Reflect.get(A, YB); } var CG = function(A, I) { var g = {}; for (var Q in A) Object.prototype.hasOwnPropert