
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
import { Emitter } from '../../../../../base/common/event.js';
import { localize } from '../../../../../nls.js';
import { IWorkspaceContextService } from '../../../../../platform/workspace/common/workspace.service.js';
import '../../../../../platform/theme/common/colorUtils.js';
import '../../../../../platform/theme/common/colors/baseColors.js';
import '../../../../../platform/theme/common/colors/chartsColors.js';
import '../../../../../platform/theme/common/colors/editorColors.js';
import '../../../../../platform/theme/common/colors/inputColors.js';
import { listInvalidItemForeground, listDeemphasizedForeground } from '../../../../../platform/theme/common/colors/listColors.js';
import '../../../../../platform/theme/common/colors/menuColors.js';
import '../../../../../platform/theme/common/colors/minimapColors.js';
import '../../../../../platform/theme/common/colors/miscColors.js';
import '../../../../../platform/theme/common/colors/quickpickColors.js';
import '../../../../../platform/theme/common/colors/searchColors.js';
import { DisposableStore } from '../../../../../base/common/lifecycle.js';
import { explorerRootErrorEmitter } from './explorerViewer.js';
import { IExplorerService } from '../files.service.js';
import { toErrorMessage } from '../../../../../base/common/errorMessage.js';

function provideDecorations(fileStat) {
    if (fileStat.isRoot && fileStat.error) {
        return {
            tooltip: ( localize(
                10591,
                "Unable to resolve workspace folder ({0})",
                toErrorMessage(fileStat.error)
            )),
            letter: "!",
            color: listInvalidItemForeground
        };
    }
    if (fileStat.isSymbolicLink) {
        return {
            tooltip: ( localize(10592, "Symbolic Link")),
            letter: "⤷"
        };
    }
    if (fileStat.isUnknown) {
        return {
            tooltip: ( localize(10593, "Unknown File Type")),
            letter: "?"
        };
    }
    if (fileStat.isExcluded) {
        return {
            color: listDeemphasizedForeground
        };
    }
    return undefined;
}
let ExplorerDecorationsProvider = class ExplorerDecorationsProvider {
    constructor(explorerService, contextService) {
        this.explorerService = explorerService;
        this.label = ( localize(10594, "Explorer"));
        this._onDidChange = ( new Emitter());
        this.toDispose = ( new DisposableStore());
        this.toDispose.add(this._onDidChange);
        this.toDispose.add(contextService.onDidChangeWorkspaceFolders(e => {
            this._onDidChange.fire(( e.changed.concat(e.added).map(wf => wf.uri)));
        }));
        this.toDispose.add(explorerRootErrorEmitter.event((resource => {
            this._onDidChange.fire([resource]);
        })));
    }
    get onDidChange() {
        return this._onDidChange.event;
    }
    async provideDecorations(resource) {
        const fileStat = this.explorerService.findClosest(resource);
        if (!fileStat) {
            throw ( new Error("ExplorerItem not found"));
        }
        return provideDecorations(fileStat);
    }
    dispose() {
        this.toDispose.dispose();
    }
};
ExplorerDecorationsProvider = ( __decorate([( __param(0, IExplorerService)), ( __param(1, IWorkspaceContextService))], ExplorerDecorationsProvider));

export { ExplorerDecorationsProvider, provideDecorations };
