const e = require("compact-encoding"),
i = {
preencode(i, c) {
;(i.end++,
e.fixed32.preencode(i, c.key),
e.fixed32.preencode(i, c.noisePublicKey),
e.uint.preencode(i, c.capabilities),
c.receipt && e.buffer.preencode(i, c.receipt),
c.name && e.string.preencode(i, c.name))
},
encode(i, c) {
const d = i.start++
;(e.fixed32.encode(i, c.key),
e.fixed32.encode(i, c.noisePublicKey),
e.uint.encode(i, c.capabilities))
let n = 0
;(c.receipt && ((n |= 1), e.buffer.encode(i, c.receipt)),
c.isMobile && (n |= 2),
c.name && ((n |= 4), e.string.encode(i, c.name)),
(i.buffer[d] = n))
},
decode(i) {
const c = e.uint.decode(i)
return {
key: e.fixed32.decode(i),
noisePublicKey: e.fixed32.decode(i),
capabilities: e.uint.decode(i),
receipt: 1 & c ? e.buffer.decode(i) : null,
isMobile: !!(2 & c),
name: 4 & c ? e.string.decode(i) : null,
}
},
}
module.exports = { DeviceRecord: i }