import { localize2WithPath } from '../../../nls.js';
const _moduleId = "vs/platform/extensionManagement/common/extensionManagement";
const EXTENSION_IDENTIFIER_PATTERN = '^([a-z0-9A-Z][a-z0-9-A-Z]*)\\.([a-z0-9A-Z][a-z0-9-A-Z]*)$';
const EXTENSION_IDENTIFIER_REGEX = ( (new RegExp(EXTENSION_IDENTIFIER_PATTERN)));
const WEB_EXTENSION_TAG = '__web_extension';
const EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT = 'skipWalkthrough';
const EXTENSION_INSTALL_SYNC_CONTEXT = 'extensionsSync';
const EXTENSION_INSTALL_DEP_PACK_CONTEXT = 'dependecyOrPackExtensionInstall';
function TargetPlatformToString(targetPlatform) {
    switch (targetPlatform) {
        case "win32-x64" : return 'Windows 64 bit';
        case "win32-arm64" : return 'Windows ARM';
        case "linux-x64" : return 'Linux 64 bit';
        case "linux-arm64" : return 'Linux ARM 64';
        case "linux-armhf" : return 'Linux ARM';
        case "alpine-x64" : return 'Alpine Linux 64 bit';
        case "alpine-arm64" : return 'Alpine ARM 64';
        case "darwin-x64" : return 'Mac';
        case "darwin-arm64" : return 'Mac Silicon';
        case "web" : return 'Web';
        case "universal" : return "universal" ;
        case "unknown" : return "unknown" ;
        case "undefined" : return "undefined" ;
    }
}
function toTargetPlatform(targetPlatform) {
    switch (targetPlatform) {
        case "win32-x64" : return "win32-x64" ;
        case "win32-arm64" : return "win32-arm64" ;
        case "linux-x64" : return "linux-x64" ;
        case "linux-arm64" : return "linux-arm64" ;
        case "linux-armhf" : return "linux-armhf" ;
        case "alpine-x64" : return "alpine-x64" ;
        case "alpine-arm64" : return "alpine-arm64" ;
        case "darwin-x64" : return "darwin-x64" ;
        case "darwin-arm64" : return "darwin-arm64" ;
        case "web" : return "web" ;
        case "universal" : return "universal" ;
        default: return "unknown" ;
    }
}
function getTargetPlatform(platform, arch) {
    switch (platform) {
        case 3 :
            if (arch === 'x64') {
                return "win32-x64" ;
            }
            if (arch === 'arm64') {
                return "win32-arm64" ;
            }
            return "unknown" ;
        case 2 :
            if (arch === 'x64') {
                return "linux-x64" ;
            }
            if (arch === 'arm64') {
                return "linux-arm64" ;
            }
            if (arch === 'arm') {
                return "linux-armhf" ;
            }
            return "unknown" ;
        case 'alpine':
            if (arch === 'x64') {
                return "alpine-x64" ;
            }
            if (arch === 'arm64') {
                return "alpine-arm64" ;
            }
            return "unknown" ;
        case 1 :
            if (arch === 'x64') {
                return "darwin-x64" ;
            }
            if (arch === 'arm64') {
                return "darwin-arm64" ;
            }
            return "unknown" ;
        case 0 : return "web" ;
    }
}
function isNotWebExtensionInWebTargetPlatform(allTargetPlatforms, productTargetPlatform) {
    return productTargetPlatform === "web"  && !allTargetPlatforms.includes("web" );
}
function isTargetPlatformCompatible(extensionTargetPlatform, allTargetPlatforms, productTargetPlatform) {
    if (isNotWebExtensionInWebTargetPlatform(allTargetPlatforms, productTargetPlatform)) {
        return false;
    }
    if (extensionTargetPlatform === "undefined" ) {
        return true;
    }
    if (extensionTargetPlatform === "universal" ) {
        return true;
    }
    if (extensionTargetPlatform === "unknown" ) {
        return false;
    }
    if (extensionTargetPlatform === productTargetPlatform) {
        return true;
    }
    return false;
}
function isIExtensionIdentifier(thing) {
    return thing
        && typeof thing === 'object'
        && typeof thing.id === 'string'
        && (!thing.uuid || typeof thing.uuid === 'string');
}
var ExtensionManagementErrorCode;
( ((function(ExtensionManagementErrorCode) {
    ExtensionManagementErrorCode["Unsupported"] = "Unsupported";
    ExtensionManagementErrorCode["Deprecated"] = "Deprecated";
    ExtensionManagementErrorCode["Malicious"] = "Malicious";
    ExtensionManagementErrorCode["Incompatible"] = "Incompatible";
    ExtensionManagementErrorCode["IncompatibleTargetPlatform"] = "IncompatibleTargetPlatform";
    ExtensionManagementErrorCode["ReleaseVersionNotFound"] = "ReleaseVersionNotFound";
    ExtensionManagementErrorCode["Invalid"] = "Invalid";
    ExtensionManagementErrorCode["Download"] = "Download";
    ExtensionManagementErrorCode["DownloadSignature"] = "DownloadSignature";
    ExtensionManagementErrorCode["UpdateMetadata"] = "UpdateMetadata";
    ExtensionManagementErrorCode["Extract"] = "Extract";
    ExtensionManagementErrorCode["Scanning"] = "Scanning";
    ExtensionManagementErrorCode["Delete"] = "Delete";
    ExtensionManagementErrorCode["Rename"] = "Rename";
    ExtensionManagementErrorCode["CorruptZip"] = "CorruptZip";
    ExtensionManagementErrorCode["IncompleteZip"] = "IncompleteZip";
    ExtensionManagementErrorCode["Signature"] = "Signature";
    ExtensionManagementErrorCode["NotAllowed"] = "NotAllowed";
    ExtensionManagementErrorCode["Gallery"] = "Gallery";
    ExtensionManagementErrorCode["Unknown"] = "Unknown";
    ExtensionManagementErrorCode["Internal"] = "Internal";
})(ExtensionManagementErrorCode || (ExtensionManagementErrorCode = {}))));
class ExtensionManagementError extends Error {
    constructor(message, code) {
        super(message);
        this.code = code;
        this.name = code;
    }
}
var ExtensionGalleryErrorCode;
( ((function(ExtensionGalleryErrorCode) {
    ExtensionGalleryErrorCode["Timeout"] = "Timeout";
    ExtensionGalleryErrorCode["Cancelled"] = "Cancelled";
    ExtensionGalleryErrorCode["Failed"] = "Failed";
})(ExtensionGalleryErrorCode || (ExtensionGalleryErrorCode = {}))));
class ExtensionGalleryError extends Error {
    constructor(message, code) {
        super(message);
        this.code = code;
        this.name = code;
    }
}
const DISABLED_EXTENSIONS_STORAGE_PATH = 'extensionsIdentifiers/disabled';
const ENABLED_EXTENSIONS_STORAGE_PATH = 'extensionsIdentifiers/enabled';
const ExtensionsLocalizedLabel = ( localize2WithPath(_moduleId, 0, "Extensions"));
const PreferencesLocalizedLabel = ( localize2WithPath(_moduleId, 1, 'Preferences'));
export { DISABLED_EXTENSIONS_STORAGE_PATH, ENABLED_EXTENSIONS_STORAGE_PATH, EXTENSION_IDENTIFIER_PATTERN, EXTENSION_IDENTIFIER_REGEX, EXTENSION_INSTALL_DEP_PACK_CONTEXT, EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT, EXTENSION_INSTALL_SYNC_CONTEXT, ExtensionGalleryError, ExtensionGalleryErrorCode, ExtensionManagementError, ExtensionManagementErrorCode, ExtensionsLocalizedLabel, PreferencesLocalizedLabel, TargetPlatformToString, WEB_EXTENSION_TAG, getTargetPlatform, isIExtensionIdentifier, isNotWebExtensionInWebTargetPlatform, isTargetPlatformCompatible, toTargetPlatform };
