import { CancellationToken } from '../../../base/common/cancellation.js';
import { IStringDictionary } from '../../../base/common/collections.js';
import { URI } from '../../../base/common/uri.js';
import { TargetPlatform, IExtension } from '../../extensions/common/extensions.js';

interface IProductVersion {
    readonly version: string;
    readonly date?: string;
}
interface IGalleryExtensionProperties {
    dependencies?: string[];
    extensionPack?: string[];
    engine?: string;
    enabledApiProposals?: string[];
    localizedLanguages?: string[];
    targetPlatform: TargetPlatform;
    isPreReleaseVersion: boolean;
}
interface IGalleryExtensionAsset {
    uri: string;
    fallbackUri: string;
}
interface IGalleryExtensionAssets {
    manifest: IGalleryExtensionAsset | null;
    readme: IGalleryExtensionAsset | null;
    changelog: IGalleryExtensionAsset | null;
    license: IGalleryExtensionAsset | null;
    repository: IGalleryExtensionAsset | null;
    download: IGalleryExtensionAsset;
    icon: IGalleryExtensionAsset | null;
    signature: IGalleryExtensionAsset | null;
    coreTranslations: [string, IGalleryExtensionAsset][];
}
interface IExtensionIdentifier {
    id: string;
    uuid?: string;
}
interface IGalleryExtensionIdentifier extends IExtensionIdentifier {
    uuid: string;
}
interface IGalleryExtension {
    type: 'gallery';
    name: string;
    identifier: IGalleryExtensionIdentifier;
    version: string;
    displayName: string;
    publisherId: string;
    publisher: string;
    publisherDisplayName: string;
    publisherDomain?: {
        link: string;
        verified: boolean;
    };
    publisherSponsorLink?: string;
    description: string;
    installCount: number;
    rating: number;
    ratingCount: number;
    categories: readonly string[];
    tags: readonly string[];
    releaseDate: number;
    lastUpdated: number;
    preview: boolean;
    hasPreReleaseVersion: boolean;
    hasReleaseVersion: boolean;
    isSigned: boolean;
    allTargetPlatforms: TargetPlatform[];
    assets: IGalleryExtensionAssets;
    properties: IGalleryExtensionProperties;
    telemetryData?: any;
    queryContext?: IStringDictionary<any>;
    supportLink?: string;
}
type InstallSource = 'gallery' | 'vsix' | 'resource';
interface IGalleryMetadata {
    id: string;
    publisherId: string;
    publisherDisplayName: string;
    isPreReleaseVersion: boolean;
    targetPlatform?: TargetPlatform;
}
type Metadata = Partial<IGalleryMetadata & {
    isApplicationScoped: boolean;
    isMachineScoped: boolean;
    isBuiltin: boolean;
    isSystem: boolean;
    updated: boolean;
    preRelease: boolean;
    hasPreReleaseVersion: boolean;
    installedTimestamp: number;
    pinned: boolean;
    source: InstallSource;
}>;
interface ILocalExtension extends IExtension {
    isWorkspaceScoped: boolean;
    isMachineScoped: boolean;
    isApplicationScoped: boolean;
    publisherId: string | null;
    installedTimestamp?: number;
    isPreReleaseVersion: boolean;
    hasPreReleaseVersion: boolean;
    preRelease: boolean;
    updated: boolean;
    pinned: boolean;
    source: InstallSource;
}
interface IDeprecationInfo {
    readonly disallowInstall?: boolean;
    readonly extension?: {
        readonly id: string;
        readonly displayName: string;
        readonly autoMigrate?: {
            readonly storage: boolean;
        };
        readonly preRelease?: boolean;
    };
    readonly settings?: readonly string[];
    readonly additionalInfo?: string;
}
interface ISearchPrefferedResults {
    readonly query?: string;
    readonly preferredResults?: string[];
}
interface IExtensionsControlManifest {
    readonly malicious: IExtensionIdentifier[];
    readonly deprecated: IStringDictionary<IDeprecationInfo>;
    readonly search: ISearchPrefferedResults[];
    readonly extensionsEnabledWithPreRelease?: string[];
}
declare const enum InstallOperation {
    None = 1,
    Install = 2,
    Update = 3,
    Migrate = 4
}
interface InstallExtensionEvent {
    readonly identifier: IExtensionIdentifier;
    readonly source: URI | IGalleryExtension;
    readonly profileLocation: URI;
    readonly applicationScoped?: boolean;
    readonly workspaceScoped?: boolean;
}
interface InstallExtensionResult {
    readonly identifier: IExtensionIdentifier;
    readonly operation: InstallOperation;
    readonly source?: URI | IGalleryExtension;
    readonly local?: ILocalExtension;
    readonly error?: Error;
    readonly context?: IStringDictionary<any>;
    readonly profileLocation: URI;
    readonly applicationScoped?: boolean;
    readonly workspaceScoped?: boolean;
}
interface UninstallExtensionEvent {
    readonly identifier: IExtensionIdentifier;
    readonly profileLocation: URI;
    readonly applicationScoped?: boolean;
    readonly workspaceScoped?: boolean;
}
interface DidUninstallExtensionEvent {
    readonly identifier: IExtensionIdentifier;
    readonly error?: string;
    readonly profileLocation: URI;
    readonly applicationScoped?: boolean;
    readonly workspaceScoped?: boolean;
}
interface DidUpdateExtensionMetadata {
    readonly profileLocation: URI;
    readonly local: ILocalExtension;
}
type InstallOptions = {
    isBuiltin?: boolean;
    isWorkspaceScoped?: boolean;
    isMachineScoped?: boolean;
    isApplicationScoped?: boolean;
    pinned?: boolean;
    donotIncludePackAndDependencies?: boolean;
    installGivenVersion?: boolean;
    preRelease?: boolean;
    installPreReleaseVersion?: boolean;
    donotVerifySignature?: boolean;
    operation?: InstallOperation;
    profileLocation?: URI;
    installOnlyNewlyAddedFromExtensionPack?: boolean;
    productVersion?: IProductVersion;
    /**
     * Context passed through to InstallExtensionResult
     */
    context?: IStringDictionary<any>;
};
type UninstallOptions = {
    readonly profileLocation?: URI;
    readonly donotIncludePack?: boolean;
    readonly donotCheckDependents?: boolean;
    readonly versionOnly?: boolean;
    readonly remove?: boolean;
};
interface IExtensionManagementParticipant {
    postInstall(local: ILocalExtension, source: URI | IGalleryExtension, options: InstallOptions, token: CancellationToken): Promise<void>;
    postUninstall(local: ILocalExtension, options: UninstallOptions, token: CancellationToken): Promise<void>;
}
type InstallExtensionInfo = {
    readonly extension: IGalleryExtension;
    readonly options: InstallOptions;
};

export { type DidUninstallExtensionEvent, type DidUpdateExtensionMetadata, type IDeprecationInfo, type IExtensionIdentifier, type IExtensionManagementParticipant, type IExtensionsControlManifest, type IGalleryExtension, type IGalleryExtensionAsset, type IGalleryExtensionAssets, type IGalleryExtensionIdentifier, type IGalleryExtensionProperties, type IGalleryMetadata, type ILocalExtension, type IProductVersion, type ISearchPrefferedResults, type InstallExtensionEvent, type InstallExtensionInfo, type InstallExtensionResult, InstallOperation, type InstallOptions, type InstallSource, type Metadata, type UninstallExtensionEvent, type UninstallOptions };
