"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FusesPlugin = void 0;
const path_1 = __importDefault(require("path"));
const plugin_base_1 = require("@electron-forge/plugin-base");
const fuses_1 = require("@electron/fuses");
const getElectronExecutablePath_1 = require("./util/getElectronExecutablePath");
class FusesPlugin extends plugin_base_1.PluginBase {
    constructor(fusesConfig) {
        super(fusesConfig);
        this.name = 'fuses';
        this.fusesConfig = {};
        this.fusesConfig = fusesConfig;
    }
    getHooks() {
        return {
            packageAfterCopy: (0, plugin_base_1.namedHookWithTaskFn)(async (listrTask, resolvedForgeConfig, resourcesPath, electronVersion, platform, arch) => {
                const { fusesConfig } = this;
                const applePlatforms = ['darwin', 'mas'];
                if (Object.keys(fusesConfig).length) {
                    const pathToElectronExecutable = (0, getElectronExecutablePath_1.getElectronExecutablePath)({
                        appName: applePlatforms.includes(platform) ? 'Electron' : 'electron',
                        basePath: path_1.default.resolve(resourcesPath, '../..'),
                        platform,
                    });
                    const osxSignConfig = resolvedForgeConfig.packagerConfig.osxSign;
                    const hasOSXSignConfig = (typeof osxSignConfig === 'object' && Boolean(Object.keys(osxSignConfig).length)) || Boolean(osxSignConfig);
                    await (0, fuses_1.flipFuses)(pathToElectronExecutable, {
                        resetAdHocDarwinSignature: !hasOSXSignConfig && applePlatforms.includes(platform) && arch === 'arm64',
                        ...this.fusesConfig,
                    });
                }
            }, 'Flipping Fuses'),
        };
    }
}
exports.default = FusesPlugin;
exports.FusesPlugin = FusesPlugin;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRnVzZXNQbHVnaW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvRnVzZXNQbHVnaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsZ0RBQXdCO0FBRXhCLDZEQUE4RTtBQU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