import Transform from "../../domain/stream/Transform.js";
import WarpError from "../../domain/errors/WarpError.js";
/**
 * Stream transform that writes the bytes component of [path, bytes] entries
 * as Git blobs and yields [path, oid].
 *
 * Input:  `[string, Uint8Array]` — path + blob content
 * Output: `[string, string]` — path + Git blob OID
 */
export class GitBlobWriteTransform extends Transform {
    _blobPort;
    constructor(blobPort) {
        super();
        if (blobPort === null || blobPort === undefined) {
            throw new WarpError('GitBlobWriteTransform requires a blobPort', 'E_INVALID_DEPENDENCY');
        }
        this._blobPort = blobPort;
    }
    async *apply(source) {
        for await (const [path, bytes] of source) {
            const oid = await this._blobPort.writeBlob(bytes);
            yield [path, oid];
        }
    }
}
