"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const TextDecoder_1 = require("../../../../../wrap/TextDecoder");
const _ids_1 = require("../../../../_ids");
class TextDecoder_ extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['label', 'opt'],
            fo: ['decoder'],
            i: [],
            o: [],
        }, {
            output: {
                decoder: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_TEXT_DECODER);
    }
    f({ label, opt }, done, fail) {
        const { api: { text: { TextDecoder }, }, } = this.__system;
        let decoder_;
        try {
            decoder_ = new TextDecoder(label, opt);
        }
        catch (err) {
            fail(err.message.toLowerCase());
            return;
        }
        const decoder = (0, TextDecoder_1.wrapTextDecoder)(decoder_, this.__system);
        done({
            decoder,
        });
    }
}
exports.default = TextDecoder_;
//# sourceMappingURL=index.js.map