OverviewFilesCommitsIssuesDocsReleasesPeers

keet-cli / keet-core-4.14.4-pretty / schema / spec / local / hyperdb / index.js

1766 lines · javascript ref:
const { IndexEncoder: e, c: n, b4a: t } = require("hyperdb/runtime"),
  { version: o, getEncoding: r, setVersion: c } = require("./messages.js"),
  l = { schema: o, db: 5 },
  d = require("../../../../lib/core/hyperdb/local/local.js"),
  s = new e([], { prefix: 0 })
function u(e) {
  return []
}
const i = r("@local/stats")
function a(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return i.decode(o)
}
function f(e) {
  return {}
}
const y = {
    name: "@local/stats",
    id: 0,
    version: 0,
    encodeKey: (e) => s.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      s.encodeRange({
        gt: e ? u(e) : null,
        lt: n ? u(n) : null,
        gte: t ? u(t) : null,
        lte: o ? u(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (i.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), i.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: a,
    reconstructKey: f,
    indexes: [],
    decodedVersion: 0,
  },
  g = new e([], { prefix: 1 })
function p(e) {
  return []
}
const b = r("@local/migration-status")
function m(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return b.decode(o)
}
function K(e) {
  return {}
}
const v = {
    name: "@local/migrations",
    id: 1,
    version: 0,
    encodeKey: (e) => g.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      g.encodeRange({
        gt: e ? p(e) : null,
        lt: n ? p(n) : null,
        gte: t ? p(t) : null,
        lte: o ? p(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (b.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), b.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: m,
    reconstructKey: K,
    indexes: [],
    decodedVersion: 0,
  },
  x = new e([], { prefix: 2 })
function h(e) {
  return []
}
const R = r("@local/room-migration-stats")
function U(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return R.decode(o)
}
function w(e) {
  return {}
}
const F = {
    name: "@local/room-migration-stats",
    id: 2,
    version: 0,
    encodeKey: (e) => x.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      x.encodeRange({
        gt: e ? h(e) : null,
        lt: n ? h(n) : null,
        gte: t ? h(t) : null,
        lte: o ? h(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (R.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), R.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: U,
    reconstructKey: w,
    indexes: [],
    decodedVersion: 0,
  },
  V = new e([e.BUFFER], { prefix: 3 })
function k(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const B = r("@local/room-migration/hyperdb#3"),
  I = d.roomMigrationsTrigger
function E(e, n, t) {
  const o = V.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = B.decode(r)
  return ((l.roomKey = o[0]), l)
}
function T(e) {
  return { roomKey: V.decode(e)[0] }
}
const L = {
    name: "@local/room-migrations",
    id: 3,
    version: 0,
    encodeKey(e) {
      const n = [e.roomKey]
      return V.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      V.encodeRange({
        gt: e ? k(e) : null,
        lt: n ? k(n) : null,
        gte: t ? k(t) : null,
        lte: o ? k(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (B.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), B.encode(r, o), r.buffer)
    },
    trigger: I,
    reconstruct: E,
    reconstructKey: T,
    indexes: [],
    decodedVersion: 0,
  },
  N = new e([e.UINT, e.BUFFER], { prefix: 4 })
function D(e) {
  const n = [],
    t = e.priority
  if (void 0 === t) return n
  n.push(t)
  const o = e.roomKey
  return (void 0 === o || n.push(o), n)
}
const A = {
  name: "@local/room-migrations-by-priority",
  version: 0,
  id: 4,
  encodeKey: (e) => N.encode(D(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    N.encodeRange({
      gt: e ? D(e) : null,
      lt: n ? D(n) : null,
      gte: t ? D(t) : null,
      lte: o ? D(o) : null,
    }),
  encodeValue: (e) => A.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [N.encode([e.priority, e.roomKey])],
  reconstruct: (e, n) => n,
  offset: L.indexes.length,
  collection: L,
}
L.indexes.push(A)
const P = new e([], { prefix: 5 })
function M(e) {
  return []
}
const O = r("@local/identity-record")
function G(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return O.decode(o)
}
function S(e) {
  return {}
}
const q = {
    name: "@local/identity",
    id: 5,
    version: 0,
    encodeKey: (e) => P.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      P.encodeRange({
        gt: e ? M(e) : null,
        lt: n ? M(n) : null,
        gte: t ? M(t) : null,
        lte: o ? M(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (O.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), O.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: G,
    reconstructKey: S,
    indexes: [],
    decodedVersion: 0,
  },
  C = new e([e.BUFFER], { prefix: 6 })
function j(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const W = r("@local/room/hyperdb#6"),
  z = d.roomsTrigger
function H(e, n, t) {
  const o = C.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = W.decode(r)
  return ((l.roomKey = o[0]), (Q.decodedVersion = l.version), l)
}
function J(e) {
  return { roomKey: C.decode(e)[0] }
}
const Q = {
    name: "@local/rooms",
    id: 6,
    version: 3,
    encodeKey(e) {
      const n = [e.roomKey]
      return C.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      C.encodeRange({
        gt: e ? j(e) : null,
        lt: n ? j(n) : null,
        gte: t ? j(t) : null,
        lte: o ? j(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (
        (o.version = n),
        W.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        W.encode(r, o),
        r.buffer
      )
    },
    trigger: z,
    reconstruct: H,
    reconstructKey: J,
    indexes: [],
    decodedVersion: 0,
  },
  X = new e([e.BUFFER], { prefix: 7 })
function Y(e) {
  const n = e.discoveryKey
  return void 0 === n ? [] : [n]
}
const Z = {
  name: "@local/rooms-by-discovery-key",
  version: 0,
  id: 7,
  encodeKey: (e) => X.encode(Y(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    X.encodeRange({
      gt: e ? Y(e) : null,
      lt: n ? Y(n) : null,
      gte: t ? Y(t) : null,
      lte: o ? Y(o) : null,
    }),
  encodeValue: (e) => Z.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [X.encode([e.discoveryKey])],
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(Z)
const $ = new e([e.UINT, e.BUFFER], { prefix: 8 }),
  _ = d.roomsByTimestampMap
function ee(e) {
  const n = e.timestamp
  return void 0 === n ? [] : [n]
}
const ne = {
  name: "@local/rooms-by-timestamp",
  version: 0,
  id: 8,
  encodeKey: (e) => $.encode(ee(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    $.encodeRange({
      gt: e ? ee(e) : null,
      lt: n ? ee(n) : null,
      gte: t ? ee(t) : null,
      lte: o ? ee(o) : null,
    }),
  encodeValue: (e) => ne.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = _(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = $.encode([r.timestamp, e.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(ne)
const te = new e([e.UINT, e.UINT, e.BUFFER], { prefix: 9 }),
  oe = d.roomsByTypeAndTimestampMap
function re(e) {
  const n = [],
    t = e.type
  if (void 0 === t) return n
  n.push(t)
  const o = e.timestamp
  return (void 0 === o || n.push(o), n)
}
const ce = {
  name: "@local/rooms-by-type-and-timestamp",
  version: 0,
  id: 9,
  encodeKey: (e) => te.encode(re(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    te.encodeRange({
      gt: e ? re(e) : null,
      lt: n ? re(n) : null,
      gte: t ? re(t) : null,
      lte: o ? re(o) : null,
    }),
  encodeValue: (e) => ce.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = oe(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = te.encode([r.type, r.timestamp, e.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(ce)
const le = new e([e.BUFFER], { prefix: 10 })
function de(e) {
  const n = e.capabilities?.wakeupTopic
  return void 0 === n ? [] : [n]
}
const se = {
  name: "@local/rooms-by-wakeup-topic",
  version: 0,
  id: 10,
  encodeKey: (e) => le.encode(de(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    le.encodeRange({
      gt: e ? de(e) : null,
      lt: n ? de(n) : null,
      gte: t ? de(t) : null,
      lte: o ? de(o) : null,
    }),
  encodeValue: (e) => se.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [le.encode([e.capabilities.wakeupTopic])],
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(se)
const ue = new e([e.BUFFER], { prefix: 11 })
function ie(e) {
  const n = e.capabilities?.mailboxKeyPair?.publicKey
  return void 0 === n ? [] : [n]
}
const ae = {
  name: "@local/rooms-by-mailbox",
  version: 0,
  id: 11,
  encodeKey: (e) => ue.encode(ie(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    ue.encodeRange({
      gt: e ? ie(e) : null,
      lt: n ? ie(n) : null,
      gte: t ? ie(t) : null,
      lte: o ? ie(o) : null,
    }),
  encodeValue: (e) => ae.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [ue.encode([e.capabilities.mailboxKeyPair.publicKey])],
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(ae)
const fe = new e([e.BUFFER], { prefix: 12 })
function ye(e) {
  const n = e.capabilities?.discoveryKeyPair?.publicKey
  return void 0 === n ? [] : [n]
}
const ge = {
  name: "@local/rooms-by-discovery",
  version: 0,
  id: 12,
  encodeKey: (e) => fe.encode(ye(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    fe.encodeRange({
      gt: e ? ye(e) : null,
      lt: n ? ye(n) : null,
      gte: t ? ye(t) : null,
      lte: o ? ye(o) : null,
    }),
  encodeValue: (e) => ge.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [fe.encode([e.capabilities.discoveryKeyPair.publicKey])],
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(ge)
const pe = new e([e.BUFFER], { prefix: 13 })
function be(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const me = r("@local/room-preferences/hyperdb#13")
function Ke(e, n, t) {
  const o = pe.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = me.decode(r)
  return ((l.roomKey = o[0]), l)
}
function ve(e) {
  return { roomKey: pe.decode(e)[0] }
}
const xe = {
    name: "@local/room-preferences",
    id: 13,
    version: 0,
    encodeKey(e) {
      const n = [e.roomKey]
      return pe.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      pe.encodeRange({
        gt: e ? be(e) : null,
        lt: n ? be(n) : null,
        gte: t ? be(t) : null,
        lte: o ? be(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (me.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), me.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Ke,
    reconstructKey: ve,
    indexes: [],
    decodedVersion: 0,
  },
  he = new e([e.BUFFER], { prefix: 14 })
function Re(e) {
  const n = e.mailbox
  return void 0 === n ? [] : [n]
}
const Ue = r("@local/writer/hyperdb#14")
function we(e, n, t) {
  const o = he.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Ue.decode(r)
  return ((l.mailbox = o[0]), l)
}
function Fe(e) {
  return { mailbox: he.decode(e)[0] }
}
const Ve = {
    name: "@local/writers",
    id: 14,
    version: 0,
    encodeKey(e) {
      const n = [e.mailbox]
      return he.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      he.encodeRange({
        gt: e ? Re(e) : null,
        lt: n ? Re(n) : null,
        gte: t ? Re(t) : null,
        lte: o ? Re(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Ue.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Ue.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: we,
    reconstructKey: Fe,
    indexes: [],
    decodedVersion: 0,
  },
  ke = new e([e.BUFFER], { prefix: 15 }),
  Be = d.writersByWakeupTopicMap
function Ie(e) {
  const n = e.wakeupTopic
  return void 0 === n ? [] : [n]
}
const Ee = {
  name: "@local/writers-by-wakeup-topic",
  version: 0,
  id: 15,
  encodeKey: (e) => ke.encode(Ie(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    ke.encodeRange({
      gt: e ? Ie(e) : null,
      lt: n ? Ie(n) : null,
      gte: t ? Ie(t) : null,
      lte: o ? Ie(o) : null,
    }),
  encodeValue: (e) => Ee.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = Be(e, n),
      o = new Array(t.length)
    for (let e = 0; e < t.length; e++) {
      const n = t[e]
      o[e] = ke.encode([n.wakeupTopic])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Ve.indexes.length,
  collection: Ve,
}
Ve.indexes.push(Ee)
const Te = new e([e.BUFFER], { prefix: 16 }),
  Le = d.writersByRoomKeyMap
function Ne(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const De = {
  name: "@local/writers-by-room-key",
  version: 0,
  id: 16,
  encodeKey: (e) => Te.encode(Ne(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Te.encodeRange({
      gt: e ? Ne(e) : null,
      lt: n ? Ne(n) : null,
      gte: t ? Ne(t) : null,
      lte: o ? Ne(o) : null,
    }),
  encodeValue: (e) => De.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = Le(e, n),
      o = new Array(t.length)
    for (let e = 0; e < t.length; e++) {
      const n = t[e]
      o[e] = Te.encode([n.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Ve.indexes.length,
  collection: Ve,
}
Ve.indexes.push(De)
const Ae = new e([e.BUFFER], { prefix: 17 })
function Pe(e) {
  const n = e.key
  return void 0 === n ? [] : [n]
}
const Me = r("@local/member/hyperdb#17")
function Oe(e, n, t) {
  const o = Ae.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Me.decode(r)
  return ((l.key = o[0]), l)
}
function Ge(e) {
  return { key: Ae.decode(e)[0] }
}
const Se = {
    name: "@local/members",
    id: 17,
    version: 0,
    encodeKey(e) {
      const n = [e.key]
      return Ae.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Ae.encodeRange({
        gt: e ? Pe(e) : null,
        lt: n ? Pe(n) : null,
        gte: t ? Pe(t) : null,
        lte: o ? Pe(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Me.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Me.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Oe,
    reconstructKey: Ge,
    indexes: [],
    decodedVersion: 0,
  },
  qe = new e([e.BUFFER], { prefix: 18 })
function Ce(e) {
  const n = e.device?.key
  return void 0 === n ? [] : [n]
}
const je = r("@local/device/hyperdb#18")
function We(e, n, t) {
  const o = qe.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = je.decode(r)
  return ((l.device.key = o[0]), l)
}
function ze(e) {
  return { device: { key: qe.decode(e)[0] } }
}
const He = {
    name: "@local/devices",
    id: 18,
    version: 0,
    encodeKey(e) {
      const n = [e.device.key]
      return qe.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      qe.encodeRange({
        gt: e ? Ce(e) : null,
        lt: n ? Ce(n) : null,
        gte: t ? Ce(t) : null,
        lte: o ? Ce(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (je.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), je.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: We,
    reconstructKey: ze,
    indexes: [],
    decodedVersion: 0,
  },
  Je = new e([e.BUFFER], { prefix: 19 })
function Qe(e) {
  const n = e.memberKey
  return void 0 === n ? [] : [n]
}
const Xe = r("@keet-private-id/contact/hyperdb#19")
function Ye(e, n, t) {
  const o = Je.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Xe.decode(r)
  return ((l.memberKey = o[0]), l)
}
function Ze(e) {
  return { memberKey: Je.decode(e)[0] }
}
const $e = {
    name: "@local/contacts",
    id: 19,
    version: 0,
    encodeKey(e) {
      const n = [e.memberKey]
      return Je.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Je.encodeRange({
        gt: e ? Qe(e) : null,
        lt: n ? Qe(n) : null,
        gte: t ? Qe(t) : null,
        lte: o ? Qe(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Xe.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Xe.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Ye,
    reconstructKey: Ze,
    indexes: [],
    decodedVersion: 0,
  },
  _e = new e([e.BUFFER], { prefix: 20 }),
  en = d.blockedContactsMap
function nn(e) {
  const n = e.memberKey
  return void 0 === n ? [] : [n]
}
const tn = {
  name: "@local/blocked-contacts",
  version: 0,
  id: 20,
  encodeKey: (e) => _e.encode(nn(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    _e.encodeRange({
      gt: e ? nn(e) : null,
      lt: n ? nn(n) : null,
      gte: t ? nn(t) : null,
      lte: o ? nn(o) : null,
    }),
  encodeValue: (e) => tn.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = en(e, n),
      o = new Array(t.length)
    for (let e = 0; e < t.length; e++) {
      const n = t[e]
      o[e] = _e.encode([n.memberKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: $e.indexes.length,
  collection: $e,
}
$e.indexes.push(tn)
const on = new e([e.UINT, e.UINT, e.UINT, e.BUFFER], { prefix: 21 })
function rn(e) {
  const n = [],
    t = e.priority
  if (void 0 === t) return n
  n.push(t)
  const o = e.timestamp
  if (void 0 === o) return n
  n.push(o)
  const r = e.type
  if (void 0 === r) return n
  n.push(r)
  const c = e.discoveryKey
  return (void 0 === c || n.push(c), n)
}
const cn = r("@local/task/hyperdb#21")
function ln(e, n, t) {
  const o = on.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = cn.decode(r)
  return ((l.priority = o[0]), (l.timestamp = o[1]), (l.type = o[2]), (l.discoveryKey = o[3]), l)
}
function dn(e) {
  const n = on.decode(e)
  return { priority: n[0], timestamp: n[1], type: n[2], discoveryKey: n[3] }
}
const sn = {
    name: "@local/tasks",
    id: 21,
    version: 0,
    encodeKey(e) {
      const n = [e.priority, e.timestamp, e.type, e.discoveryKey]
      return on.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      on.encodeRange({
        gt: e ? rn(e) : null,
        lt: n ? rn(n) : null,
        gte: t ? rn(t) : null,
        lte: o ? rn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (cn.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), cn.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: ln,
    reconstructKey: dn,
    indexes: [],
    decodedVersion: 0,
  },
  un = new e([e.UINT, e.BUFFER], { prefix: 22 })
function an(e) {
  const n = [],
    t = e.type
  if (void 0 === t) return n
  n.push(t)
  const o = e.discoveryKey
  return (void 0 === o || n.push(o), n)
}
const fn = {
  name: "@local/tasks-by-type",
  version: 0,
  id: 22,
  encodeKey: (e) => un.encode(an(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    un.encodeRange({
      gt: e ? an(e) : null,
      lt: n ? an(n) : null,
      gte: t ? an(t) : null,
      lte: o ? an(o) : null,
    }),
  encodeValue: (e) => fn.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [un.encode([e.type, e.discoveryKey])],
  reconstruct: (e, n) => n,
  offset: sn.indexes.length,
  collection: sn,
}
sn.indexes.push(fn)
const yn = new e([e.BUFFER, e.UINT], { prefix: 23 })
function gn(e) {
  const n = [],
    t = e.file?.pointer?.externalBlob?.key
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalBlob?.blob?.blockOffset
  return (void 0 === o || n.push(o), n)
}
const pn = r("@local/file/hyperdb#23")
function bn(e, n, t) {
  const o = yn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = pn.decode(r)
  return (
    (l.file.pointer.externalBlob.key = o[0]),
    (l.file.pointer.externalBlob.blob.blockOffset = o[1]),
    (Kn.decodedVersion = l.version),
    l
  )
}
function mn(e) {
  return { file: { pointer: { externalBlob: { blob: { blockOffset: yn.decode(e)[1] } } } } }
}
const Kn = {
    name: "@local/blob-files",
    id: 23,
    version: 4,
    encodeKey(e) {
      const n = [e.file.pointer.externalBlob.key, e.file.pointer.externalBlob.blob.blockOffset]
      return yn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      yn.encodeRange({
        gt: e ? gn(e) : null,
        lt: n ? gn(n) : null,
        gte: t ? gn(t) : null,
        lte: o ? gn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (
        (o.version = n),
        pn.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        pn.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: bn,
    reconstructKey: mn,
    indexes: [],
    decodedVersion: 0,
  },
  vn = new e([e.BUFFER, e.STRING, e.UINT], { prefix: 24 })
function xn(e) {
  const n = [],
    t = e.file?.pointer?.externalDrive?.key
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalDrive?.path
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalDrive?.version
  return (void 0 === r || n.push(r), n)
}
const hn = r("@local/file/hyperdb#24")
function Rn(e, n, t) {
  const o = vn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = hn.decode(r)
  return (
    (l.file.pointer.externalDrive.key = o[0]),
    (l.file.pointer.externalDrive.path = o[1]),
    (l.file.pointer.externalDrive.version = o[2]),
    (wn.decodedVersion = l.version),
    l
  )
}
function Un(e) {
  return { file: { pointer: { externalDrive: { version: vn.decode(e)[2] } } } }
}
const wn = {
    name: "@local/drive-files",
    id: 24,
    version: 4,
    encodeKey(e) {
      const n = [
        e.file.pointer.externalDrive.key,
        e.file.pointer.externalDrive.path,
        e.file.pointer.externalDrive.version,
      ]
      return vn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      vn.encodeRange({
        gt: e ? xn(e) : null,
        lt: n ? xn(n) : null,
        gte: t ? xn(t) : null,
        lte: o ? xn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (
        (o.version = n),
        hn.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        hn.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: Rn,
    reconstructKey: Un,
    indexes: [],
    decodedVersion: 0,
  },
  Fn = new e([e.BUFFER, e.BUFFER, e.UINT], { prefix: 25 })
function Vn(e) {
  const n = [],
    t = e.roomKey
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalBlob?.key
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalBlob?.blob?.blockOffset
  return (void 0 === r || n.push(r), n)
}
const kn = {
  name: "@local/blob-files-by-room",
  version: 0,
  id: 25,
  encodeKey: (e) => Fn.encode(Vn(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Fn.encodeRange({
      gt: e ? Vn(e) : null,
      lt: n ? Vn(n) : null,
      gte: t ? Vn(t) : null,
      lte: o ? Vn(o) : null,
    }),
  encodeValue: (e) => kn.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [
    Fn.encode([
      e.roomKey,
      e.file.pointer.externalBlob.key,
      e.file.pointer.externalBlob.blob.blockOffset,
    ]),
  ],
  reconstruct: (e, n) => n,
  offset: Kn.indexes.length,
  collection: Kn,
}
Kn.indexes.push(kn)
const Bn = new e([e.BUFFER, e.BUFFER, e.STRING, e.UINT], { prefix: 26 })
function In(e) {
  const n = [],
    t = e.roomKey
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalDrive?.key
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalDrive?.path
  if (void 0 === r) return n
  n.push(r)
  const c = e.file?.pointer?.externalDrive?.version
  return (void 0 === c || n.push(c), n)
}
const En = {
  name: "@local/drive-files-by-room",
  version: 0,
  id: 26,
  encodeKey: (e) => Bn.encode(In(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Bn.encodeRange({
      gt: e ? In(e) : null,
      lt: n ? In(n) : null,
      gte: t ? In(t) : null,
      lte: o ? In(o) : null,
    }),
  encodeValue: (e) => En.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [
    Bn.encode([
      e.roomKey,
      e.file.pointer.externalDrive.key,
      e.file.pointer.externalDrive.path,
      e.file.pointer.externalDrive.version,
    ]),
  ],
  reconstruct: (e, n) => n,
  offset: wn.indexes.length,
  collection: wn,
}
wn.indexes.push(En)
const Tn = new e([e.BUFFER], { prefix: 27 })
function Ln(e) {
  const n = e.discoveryPublicKey
  return void 0 === n ? [] : [n]
}
const Nn = r("@local/background-sync-room/hyperdb#27")
function Dn(e, n, t) {
  const o = Tn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Nn.decode(r)
  return ((l.discoveryPublicKey = o[0]), l)
}
function An(e) {
  return { discoveryPublicKey: Tn.decode(e)[0] }
}
const Pn = {
    name: "@local/background-sync",
    id: 27,
    version: 0,
    encodeKey(e) {
      const n = [e.discoveryPublicKey]
      return Tn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Tn.encodeRange({
        gt: e ? Ln(e) : null,
        lt: n ? Ln(n) : null,
        gte: t ? Ln(t) : null,
        lte: o ? Ln(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Nn.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Nn.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Dn,
    reconstructKey: An,
    indexes: [],
    decodedVersion: 0,
  },
  Mn = new e([e.UINT, e.BUFFER], { prefix: 28 }),
  On = d.dirtyByTimestampMap
function Gn(e) {
  const n = e.timestamp
  return void 0 === n ? [] : [n]
}
const Sn = {
  name: "@local/background-sync-by-dirty",
  version: 0,
  id: 28,
  encodeKey: (e) => Mn.encode(Gn(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Mn.encodeRange({
      gt: e ? Gn(e) : null,
      lt: n ? Gn(n) : null,
      gte: t ? Gn(t) : null,
      lte: o ? Gn(o) : null,
    }),
  encodeValue: (e) => Sn.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = On(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = Mn.encode([r.timestamp, e.discoveryPublicKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Pn.indexes.length,
  collection: Pn,
}
Pn.indexes.push(Sn)
const qn = new e([e.BUFFER, e.BUFFER], { prefix: 29 })
function Cn(e) {
  const n = [],
    t = e.key
  if (void 0 === t) return n
  n.push(t)
  const o = e.responsePublicKey
  return (void 0 === o || n.push(o), n)
}
const jn = r("@local/writer-append/hyperdb#29")
function Wn(e, n, t) {
  const o = qn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = jn.decode(r)
  return ((l.key = o[0]), (l.responsePublicKey = o[1]), l)
}
function zn(e) {
  const n = qn.decode(e)
  return { key: n[0], responsePublicKey: n[1] }
}
const Hn = {
    name: "@local/writer-appends",
    id: 29,
    version: 0,
    encodeKey(e) {
      const n = [e.key, e.responsePublicKey]
      return qn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      qn.encodeRange({
        gt: e ? Cn(e) : null,
        lt: n ? Cn(n) : null,
        gte: t ? Cn(t) : null,
        lte: o ? Cn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (jn.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), jn.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Wn,
    reconstructKey: zn,
    indexes: [],
    decodedVersion: 0,
  },
  Jn = new e([e.BUFFER], { prefix: 30 })
function Qn(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const Xn = r("@local/room-metadata/hyperdb#30")
function Yn(e, n, t) {
  const o = Jn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Xn.decode(r)
  return ((l.roomKey = o[0]), l)
}
function Zn(e) {
  return { roomKey: Jn.decode(e)[0] }
}
const $n = {
    name: "@local/room-metadata",
    id: 30,
    version: 0,
    encodeKey(e) {
      const n = [e.roomKey]
      return Jn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Jn.encodeRange({
        gt: e ? Qn(e) : null,
        lt: n ? Qn(n) : null,
        gte: t ? Qn(t) : null,
        lte: o ? Qn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Xn.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Xn.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Yn,
    reconstructKey: Zn,
    indexes: [],
    decodedVersion: 0,
  },
  _n = new e([], { prefix: 31 })
function et(e) {
  return []
}
const nt = r("@local/debug")
function tt(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return nt.decode(o)
}
function ot(e) {
  return {}
}
const rt = {
    name: "@local/debug",
    id: 31,
    version: 0,
    encodeKey: (e) => _n.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      _n.encodeRange({
        gt: e ? et(e) : null,
        lt: n ? et(n) : null,
        gte: t ? et(t) : null,
        lte: o ? et(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (nt.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), nt.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: tt,
    reconstructKey: ot,
    indexes: [],
    decodedVersion: 0,
  },
  ct = new e([e.BUFFER, e.BUFFER], { prefix: 32 }),
  lt = d.roomsByContactMap
function dt(e) {
  const n = e.contact
  return void 0 === n ? [] : [n]
}
const st = {
  name: "@local/rooms-by-contact",
  version: 1,
  id: 32,
  encodeKey: (e) => ct.encode(dt(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    ct.encodeRange({
      gt: e ? dt(e) : null,
      lt: n ? dt(n) : null,
      gte: t ? dt(t) : null,
      lte: o ? dt(o) : null,
    }),
  encodeValue: (e) => st.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = lt(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = ct.encode([r.contact, e.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(st)
const ut = new e([e.BUFFER], { prefix: 33 })
function it(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const at = r("@local/unread/hyperdb#33")
function ft(e, n, t) {
  const o = ut.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = at.decode(r)
  return ((l.roomKey = o[0]), l)
}
function yt(e) {
  return { roomKey: ut.decode(e)[0] }
}
const gt = {
    name: "@local/unreads",
    id: 33,
    version: 0,
    encodeKey(e) {
      const n = [e.roomKey]
      return ut.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      ut.encodeRange({
        gt: e ? it(e) : null,
        lt: n ? it(n) : null,
        gte: t ? it(t) : null,
        lte: o ? it(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (at.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), at.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: ft,
    reconstructKey: yt,
    indexes: [],
    decodedVersion: 0,
  },
  pt = new e([], { prefix: 34 })
function bt(e) {
  return []
}
const mt = r("@local/hyperdht-record")
function Kt(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return mt.decode(o)
}
function vt(e) {
  return {}
}
const xt = {
    name: "@local/hyperdht",
    id: 34,
    version: 0,
    encodeKey: (e) => pt.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      pt.encodeRange({
        gt: e ? bt(e) : null,
        lt: n ? bt(n) : null,
        gte: t ? bt(t) : null,
        lte: o ? bt(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (mt.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), mt.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Kt,
    reconstructKey: vt,
    indexes: [],
    decodedVersion: 0,
  },
  ht = new e([e.UINT], { prefix: 35 })
function Rt(e) {
  const n = e.timestamp
  return void 0 === n ? [] : [n]
}
const Ut = r("@local/error-record/hyperdb#35")
function wt(e, n, t) {
  const o = ht.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Ut.decode(r)
  return ((l.timestamp = o[0]), l)
}
function Ft(e) {
  return { timestamp: ht.decode(e)[0] }
}
const Vt = {
    name: "@local/errors",
    id: 35,
    version: 0,
    encodeKey(e) {
      const n = [e.timestamp]
      return ht.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      ht.encodeRange({
        gt: e ? Rt(e) : null,
        lt: n ? Rt(n) : null,
        gte: t ? Rt(t) : null,
        lte: o ? Rt(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Ut.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Ut.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: wt,
    reconstructKey: Ft,
    indexes: [],
    decodedVersion: 0,
  },
  kt = new e([e.STRING, e.UINT], { prefix: 36 })
function Bt(e) {
  const n = [],
    t = e.code
  if (void 0 === t) return n
  n.push(t)
  const o = e.timestamp
  return (void 0 === o || n.push(o), n)
}
const It = {
  name: "@local/errors-by-code",
  version: 0,
  id: 36,
  encodeKey: (e) => kt.encode(Bt(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    kt.encodeRange({
      gt: e ? Bt(e) : null,
      lt: n ? Bt(n) : null,
      gte: t ? Bt(t) : null,
      lte: o ? Bt(o) : null,
    }),
  encodeValue: (e) => It.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [kt.encode([e.code, e.timestamp])],
  reconstruct: (e, n) => n,
  offset: Vt.indexes.length,
  collection: Vt,
}
Vt.indexes.push(It)
const Et = new e([e.BUFFER], { prefix: 37 })
function Tt(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const Lt = r("@local/file-stats/hyperdb#37")
function Nt(e, t, o) {
  const r = Et.decode(t)
  c(e)
  const l = { start: 0, end: o.byteLength, buffer: o },
    d = n.uint.decode(l)
  if (0 !== d) throw new Error("Unknown collection type: " + d)
  At.decodedVersion = n.uint.decode(l)
  const s = Lt.decode(l)
  return ((s.roomKey = r[0]), s)
}
function Dt(e) {
  return { roomKey: Et.decode(e)[0] }
}
const At = {
    name: "@local/file-stats",
    id: 37,
    version: 2,
    encodeKey(e) {
      const n = [e.roomKey]
      return Et.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Et.encodeRange({
        gt: e ? Tt(e) : null,
        lt: n ? Tt(n) : null,
        gte: t ? Tt(t) : null,
        lte: o ? Tt(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 2, buffer: null }
      return (
        Lt.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        (r.buffer[r.start++] = 0),
        (r.buffer[r.start++] = n),
        Lt.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: Nt,
    reconstructKey: Dt,
    indexes: [],
    decodedVersion: 0,
  },
  Pt = new e([e.UINT, e.BUFFER], { prefix: 38 }),
  Mt = d.roomsByFavoriteAndTimestampMap
function Ot(e) {
  const n = e.timestamp
  return void 0 === n ? [] : [n]
}
const Gt = {
  name: "@local/rooms-by-favorite-and-timestamp",
  version: 3,
  id: 38,
  encodeKey: (e) => Pt.encode(Ot(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Pt.encodeRange({
      gt: e ? Ot(e) : null,
      lt: n ? Ot(n) : null,
      gte: t ? Ot(t) : null,
      lte: o ? Ot(o) : null,
    }),
  encodeValue: (e) => Gt.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = Mt(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = Pt.encode([r.timestamp, e.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(Gt)
const St = new e([e.UINT, e.BUFFER, e.UINT], { prefix: 39 })
function qt(e) {
  const n = [],
    t = e.lastAccessed
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalBlob?.key
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalBlob?.blob?.blockOffset
  return (void 0 === r || n.push(r), n)
}
const Ct = {
  name: "@local/blob-files-by-last-accessed",
  version: 4,
  id: 39,
  encodeKey: (e) => St.encode(qt(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    St.encodeRange({
      gt: e ? qt(e) : null,
      lt: n ? qt(n) : null,
      gte: t ? qt(t) : null,
      lte: o ? qt(o) : null,
    }),
  encodeValue: (e) => Ct.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [
    St.encode([
      e.lastAccessed,
      e.file.pointer.externalBlob.key,
      e.file.pointer.externalBlob.blob.blockOffset,
    ]),
  ],
  reconstruct: (e, n) => n,
  offset: Kn.indexes.length,
  collection: Kn,
}
Kn.indexes.push(Ct)
const jt = new e([e.UINT, e.BUFFER, e.STRING, e.UINT], { prefix: 40 })
function Wt(e) {
  const n = [],
    t = e.lastAccessed
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalDrive?.key
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalDrive?.path
  if (void 0 === r) return n
  n.push(r)
  const c = e.file?.pointer?.externalDrive?.version
  return (void 0 === c || n.push(c), n)
}
const zt = {
  name: "@local/drive-files-by-last-accessed",
  version: 4,
  id: 40,
  encodeKey: (e) => jt.encode(Wt(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    jt.encodeRange({
      gt: e ? Wt(e) : null,
      lt: n ? Wt(n) : null,
      gte: t ? Wt(t) : null,
      lte: o ? Wt(o) : null,
    }),
  encodeValue: (e) => zt.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [
    jt.encode([
      e.lastAccessed,
      e.file.pointer.externalDrive.key,
      e.file.pointer.externalDrive.path,
      e.file.pointer.externalDrive.version,
    ]),
  ],
  reconstruct: (e, n) => n,
  offset: wn.indexes.length,
  collection: wn,
}
wn.indexes.push(zt)
const Ht = new e([], { prefix: 41 })
function Jt(e) {
  return []
}
const Qt = r("@local/file-gc-info")
function Xt(e, t, o) {
  c(e)
  const r = { start: 0, end: o.byteLength, buffer: o },
    l = n.uint.decode(r)
  if (0 !== l) throw new Error("Unknown collection type: " + l)
  return ((Zt.decodedVersion = n.uint.decode(r)), Qt.decode(r))
}
function Yt(e) {
  return {}
}
const Zt = {
    name: "@local/file-gc-info",
    id: 41,
    version: 4,
    encodeKey: (e) => Ht.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Ht.encodeRange({
        gt: e ? Jt(e) : null,
        lt: n ? Jt(n) : null,
        gte: t ? Jt(t) : null,
        lte: o ? Jt(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 2, buffer: null }
      return (
        Qt.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        (r.buffer[r.start++] = 0),
        (r.buffer[r.start++] = n),
        Qt.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: Xt,
    reconstructKey: Yt,
    indexes: [],
    decodedVersion: 0,
  },
  $t = new e([], { prefix: 42 })
function _t(e) {
  return []
}
const eo = r("@local/environment-record")
function no(e, t, o) {
  c(e)
  const r = { start: 0, end: o.byteLength, buffer: o },
    l = n.uint.decode(r)
  if (0 !== l) throw new Error("Unknown collection type: " + l)
  return ((oo.decodedVersion = n.uint.decode(r)), eo.decode(r))
}
function to(e) {
  return {}
}
const oo = {
    name: "@local/environment",
    id: 42,
    version: 5,
    encodeKey: (e) => $t.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      $t.encodeRange({
        gt: e ? _t(e) : null,
        lt: n ? _t(n) : null,
        gte: t ? _t(t) : null,
        lte: o ? _t(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 2, buffer: null }
      return (
        eo.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        (r.buffer[r.start++] = 0),
        (r.buffer[r.start++] = n),
        eo.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: no,
    reconstructKey: to,
    indexes: [],
    decodedVersion: 0,
  },
  ro = [y, v, F, L, q, Q, xe, Ve, Se, He, $e, sn, Kn, wn, Pn, Hn, $n, rt, gt, xt, Vt, At, Zt, oo],
  co = [A, Z, ne, ce, se, ae, ge, Ee, De, tn, fn, kn, En, Sn, st, It, Gt, Ct, zt]
function lo(e) {
  switch (e) {
    case "@local/stats":
      return y
    case "@local/migrations":
      return v
    case "@local/room-migration-stats":
      return F
    case "@local/room-migrations":
      return L
    case "@local/identity":
      return q
    case "@local/rooms":
      return Q
    case "@local/room-preferences":
      return xe
    case "@local/writers":
      return Ve
    case "@local/members":
      return Se
    case "@local/devices":
      return He
    case "@local/contacts":
      return $e
    case "@local/tasks":
      return sn
    case "@local/blob-files":
      return Kn
    case "@local/drive-files":
      return wn
    case "@local/background-sync":
      return Pn
    case "@local/writer-appends":
      return Hn
    case "@local/room-metadata":
      return $n
    case "@local/debug":
      return rt
    case "@local/unreads":
      return gt
    case "@local/hyperdht":
      return xt
    case "@local/errors":
      return Vt
    case "@local/file-stats":
      return At
    case "@local/file-gc-info":
      return Zt
    case "@local/environment":
      return oo
    default:
      return null
  }
}
function so(e) {
  switch (e) {
    case "@local/room-migrations-by-priority":
      return A
    case "@local/rooms-by-discovery-key":
      return Z
    case "@local/rooms-by-timestamp":
      return ne
    case "@local/rooms-by-type-and-timestamp":
      return ce
    case "@local/rooms-by-wakeup-topic":
      return se
    case "@local/rooms-by-mailbox":
      return ae
    case "@local/rooms-by-discovery":
      return ge
    case "@local/writers-by-wakeup-topic":
      return Ee
    case "@local/writers-by-room-key":
      return De
    case "@local/blocked-contacts":
      return tn
    case "@local/tasks-by-type":
      return fn
    case "@local/blob-files-by-room":
      return kn
    case "@local/drive-files-by-room":
      return En
    case "@local/background-sync-by-dirty":
      return Sn
    case "@local/rooms-by-contact":
      return st
    case "@local/errors-by-code":
      return It
    case "@local/rooms-by-favorite-and-timestamp":
      return Gt
    case "@local/blob-files-by-last-accessed":
      return Ct
    case "@local/drive-files-by-last-accessed":
      return zt
    default:
      return null
  }
}
module.exports = {
  versions: l,
  collections: ro,
  indexes: co,
  resolveCollection: lo,
  resolveIndex: so,
}