"use strict";const path=require("path"),yazl=require("yazl"),TarStream=require("../tar/stream");class ZipStream extends TarStream{_init(){const e=(this._zipfile=new yazl.ZipFile).outputStream;e.on("end",()=>this.push(null)),e.on("data",e=>this.push(e)),e.on("error",e=>this.emit("error",e))}_addFileEntry(e,r){this._zipfile.addFile(e,r.relativePath||path.basename(e),r),this._onEntryFinish()}_addBufferEntry(e,r){if(!r.relativePath)return this.emit("error",new Error("opts.relativePath is required if entry is a buffer"));this._zipfile.addBuffer(e,r.relativePath,r),this._onEntryFinish()}_addStreamEntry(e,r){if(!r.relativePath)return this.emit("error",new Error("opts.relativePath is required if entry is a stream"));e.on("error",e=>this.emit("error",e)),this._zipfile.addReadStream(e,r.relativePath,r),this._onEntryFinish()}_finalize(){this._zipfile.end()}}module.exports=ZipStream;