"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const ArrayBuffer_1 = require("../../../../../wrap/ArrayBuffer");
const _ids_1 = require("../../../../_ids");
class ToArrayBuffer extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['body', 'any'],
            fo: ['buffer'],
            i: [],
            o: ['done'],
        }, {
            input: {
                body: {
                    ref: true,
                },
            },
            output: {
                buffer: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_TO_BLOB);
    }
    async f({ body }, done, fail) {
        let arrayBuffer_;
        try {
            arrayBuffer_ = await body.arrayBuffer();
        }
        catch (err) {
            fail(err.message.toLowerCase());
            return;
        }
        const buffer = (0, ArrayBuffer_1.wrapArrayBuffer)(arrayBuffer_, this.__system);
        done({ buffer });
    }
    b() {
        this._output.done.push(true);
    }
}
exports.default = ToArrayBuffer;
//# sourceMappingURL=index.js.map