"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const CryptoKey_1 = require("../../../../../wrap/CryptoKey");
const _ids_1 = require("../../../../_ids");
class ImportKey extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['format', 'algorithm', 'extractable', 'keyUsages'],
            fo: ['key'],
            i: [],
            o: [],
        }, {
            input: {
                algorithm: {
                    ref: true,
                },
            },
            output: {
                key: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_IMPORT_KEY);
    }
    async f({ format, data, algorithm, extractable, keyUsages }, done) {
        const { api: { crypto: { importKey }, }, } = this.__system;
        let data_ = data.raw();
        let algorithm_ = algorithm.raw();
        const key_ = await importKey(format, data_, algorithm_, extractable, keyUsages);
        const key = (0, CryptoKey_1.wrapCryptoKey)(key_, this.__system);
        done({ key });
    }
}
exports.default = ImportKey;
//# sourceMappingURL=index.js.map