const t = require("ready-resource"),
i = require("hypercore-id-encoding")
class e extends t {
constructor(t) {
;(super(),
(this.handle = t),
(this.description = t.description),
(this.type = this.description.type),
(this.scope = this.description.discoveryKey),
(this.priority = this.description.priority),
(this.keet = this.handle.manager.keet),
(this.store = this.keet.store),
(this.local = this.keet.local),
(this.swarm = this.keet.swarm),
(this.swarmWorker = this.keet.swarmWorker),
(this.files = this.keet.files),
(this._running = null))
}
_open() {
;((this._running = this._run()), this._running.catch(this.keet.onerror))
}
get id() {
return (this._id || (this._id = e.getId(this.description)), this._id)
}
async run() {
;(this.opened || (await this.ready()), await this._running, await this.close())
}
async _run() {}
async _close() {}
static getId(t) {
return `${t.timestamp}:${i.encode(t.discoveryKey)}:${t.type}`
}
}
module.exports = { Task: e }