"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 ExportKey extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['key', 'format'],
            fo: ['key'],
        }, {
            input: {
                key: {
                    ref: true,
                },
            },
            output: {},
        }, system, _ids_1.ID_EXPORT_KEY);
    }
    async f({ key, format }, done) {
        const { api: { crypto: { exportKey }, }, } = this.__system;
        const key___ = (await key.raw());
        let key__;
        try {
            key__ = (await exportKey(format, key___));
        }
        catch (err) {
            done(undefined, err.message.toLowerCase());
            return;
        }
        const key_ = (0, ArrayBuffer_1.wrapArrayBuffer)(key__, this.__system);
        done({ key: key_ });
    }
}
exports.default = ExportKey;
//# sourceMappingURL=index.js.map