const e = require("sub-encoder"),
t = require("compact-encoding"),
{ PluginSchema: i } = require("@holepunchto/keet-core-schemas"),
{ PluginOperation: r } = i.Operations
module.exports = class {
static PLUGIN_NAME = "@holepunchto/kv-store"
constructor(i, r) {
;((this.view = i),
(this.prefix = r),
(this._enc = { keyEncoding: new e(r, t.raw.string), valueEncoding: t.raw.string }))
}
_put(e, t) {
return this.view.bee.put(e, t, this._enc)
}
_del(e) {
return this.view.bee.del(e, this._enc)
}
apply(e) {
if (e.type !== r.TYPE || e.value.name !== this.constructor.PLUGIN_NAME) return
const { type: t, key: i, value: n } = e.value.value
return "put" === t ? this._put(i, n) : "del" === t ? this._del(i, n) : void 0
}
}