"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseNpmPackageSpec = void 0;
const npa = require('npm-package-arg');
const WizError_1 = require("../modules/WizError");
const I18n_1 = require("../modules/I18n");
function parseNpmPackageSpec(pkg) {
    try {
        const { scope, name, fetchSpec } = npa(pkg);
        const namespace = scope === null || scope === void 0 ? void 0 : scope.replace('@', '');
        const packageName = name.split('/').pop();
        const version = fetchSpec === '*' ? undefined : fetchSpec;
        return {
            namespace,
            version,
            package: packageName,
        };
    }
    catch (error) {
        throw new WizError_1.WizError(I18n_1.default.error('PACKAGE_NAME_NOT_EXISTS', pkg));
    }
}
exports.parseNpmPackageSpec = parseNpmPackageSpec;
//# sourceMappingURL=parseNpmPackageSpec.js.map