"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCadesExtensionPath = getCadesExtensionPath;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const logger_1 = require("./logger");
function getCadesExtensionPath(options) {
    const extensionsDir = options?.extensionsDir ?? path_1.default.join(process.cwd(), 'extensions');
    const extensionFolderName = options?.extensionFolderName ?? 'Extension for CAdES Browser Plug-in 1.3.16';
    const manifestFileName = options?.manifestFileName ?? 'manifest.json';
    const extensionPath = path_1.default.join(extensionsDir, extensionFolderName);
    const manifestPath = path_1.default.join(extensionPath, manifestFileName);
    if (fs_1.default.existsSync(manifestPath)) {
        logger_1.logger.info(`CAdES extension path resolved: ${extensionPath}`, 'cades-extension-utils');
        return extensionPath;
    }
    const errorMessage = `CAdES extension not found at: ${extensionPath}\nPlease ensure the extension is properly installed.`;
    logger_1.logger.error(errorMessage, 'cades-extension-utils');
    throw new Error(errorMessage);
}
