"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VALID_MIME_TYPES = void 0;
const Holder_1 = require("../../../../../Class/Holder");
const _ids_1 = require("../../../../_ids");
exports.VALID_MIME_TYPES = ['text/plain', 'text/html', 'text/uri-list'];
class AttachText extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['component', 'text', 'type'],
            fo: [],
            i: [],
            o: [],
        }, {
            input: {
                component: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_ATTACH_TEXT);
    }
    async f({ component, text, type }, done, fail) {
        if (!exports.VALID_MIME_TYPES.includes(type)) {
            fail('invalid mime type');
            return;
        }
        this._unlisten = component.attachText(type, text);
    }
    d() {
        if (this._unlisten) {
            this._unlisten();
            this._unlisten = undefined;
        }
    }
}
exports.default = AttachText;
//# sourceMappingURL=index.js.map