"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require("../../../../../Class/$");
const Holder_1 = require("../../../../../Class/Holder");
const _ids_1 = require("../../../../_ids");
class ToBlob extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['canvas', 'quality', 'type'],
            fo: ['blob'],
            i: [],
            o: [],
        }, {
            input: {
                canvas: {
                    ref: true,
                },
            },
            output: {
                blob: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_TO_BLOB);
    }
    async f({ canvas, quality, type }, done) {
        let _blob;
        try {
            _blob = await canvas.toBlob(type, quality);
        }
        catch (err) {
            done(undefined, err.message);
            return;
        }
        const blob = new (class _Blob extends _1.$ {
            constructor() {
                super(...arguments);
                this.__ = ['B', 'IM', 'BO'];
            }
            async image() {
                return _blob;
            }
            async blob() {
                return _blob;
            }
            async raw() {
                return _blob;
            }
        })(this.__system);
        done({
            blob,
        });
    }
}
exports.default = ToBlob;
//# sourceMappingURL=index.js.map