"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const operators_1 = require("rxjs/operators");
const rxjs_1 = require("rxjs");
const errors_1 = require("@ledgerhq/errors");
const api_1 = __importDefault(require("../manager/api"));
function uninstallApp(transport, targetId, app) {
    return api_1.default.install(transport, "uninstall-app", {
        targetId,
        perso: app.perso,
        deleteKey: app.delete_key,
        firmware: app.delete,
        firmwareKey: app.delete_key,
        hash: app.hash,
    }, true).pipe((0, operators_1.ignoreElements)(), (0, operators_1.catchError)((e) => {
        if (!e || !e.message)
            return (0, rxjs_1.throwError)(() => e);
        const status = e.message.slice(e.message.length - 4);
        if (status === "6a83") {
            return (0, rxjs_1.throwError)(() => new errors_1.ManagerAppDepUninstallRequired("", {
                appName: app.name,
            }));
        }
        return (0, rxjs_1.throwError)(() => e);
    }));
}
exports.default = uninstallApp;
//# sourceMappingURL=uninstallApp.js.map