
import { localize, localize2 } from '../../../../nls.js';
import { GlobalCompareResourcesAction, FocusFilesExplorer, ShowActiveFileInExplorer, CompareWithClipboardAction, CompareNewUntitledTextFilesAction, ToggleAutoSaveAction, OpenActiveFileInEmptyWorkspace, SetActiveEditorReadonlyInSession, SetActiveEditorWriteableInSession, ToggleActiveEditorReadonlyInSession, ResetActiveEditorReadonlyInSession, renameHandler, moveFileToTrashHandler, deleteFileHandler, cutFileHandler, copyFileHandler, pasteFileHandler, openFilePreserveFocusHandler, NEW_FILE_LABEL, NEW_FILE_COMMAND_ID, NEW_FOLDER_LABEL, NEW_FOLDER_COMMAND_ID, COPY_FILE_LABEL, FileCopiedContext, PASTE_FILE_LABEL, DOWNLOAD_LABEL, DOWNLOAD_COMMAND_ID, UPLOAD_LABEL, UPLOAD_COMMAND_ID, TRIGGER_RENAME_LABEL, MOVE_FILE_TO_TRASH_LABEL } from './fileActions.js';
import { acceptLocalChangesCommand, revertLocalChangesCommand, CONFLICT_RESOLUTION_CONTEXT } from './editors/textFileSaveErrorHandler.js';
import { registerAction2, MenuRegistry, MenuId } from '../../../../platform/actions/common/actions.js';
import { KeyCode, KeyMod as KeyMod$1 } from '../../../../base/common/keyCodes.js';
import { openWindowCommand, newWindowCommand } from './fileCommands.js';
import { COPY_PATH_COMMAND_ID, COPY_RELATIVE_PATH_COMMAND_ID, REVEAL_IN_EXPLORER_COMMAND_ID, SAVE_FILE_LABEL, SAVE_FILE_COMMAND_ID, SAVE_FILE_WITHOUT_FORMATTING_LABEL, SAVE_FILE_WITHOUT_FORMATTING_COMMAND_ID, SAVE_ALL_IN_GROUP_COMMAND_ID, SAVE_FILES_COMMAND_ID, REVERT_FILE_COMMAND_ID, COMPARE_WITH_SAVED_COMMAND_ID, SAVE_FILE_AS_LABEL, SAVE_FILE_AS_COMMAND_ID, NEW_UNTITLED_FILE_LABEL, NEW_UNTITLED_FILE_COMMAND_ID, OPEN_TO_SIDE_COMMAND_ID, OpenEditorsGroupContext, OpenEditorsReadonlyEditorContext, OpenEditorsDirtyEditorContext, COMPARE_RESOURCE_COMMAND_ID, ResourceSelectedForCompareContext, SELECT_FOR_COMPARE_COMMAND_ID, COMPARE_SELECTED_COMMAND_ID, OpenEditorsSelectedFileOrUntitledContext, OPEN_WITH_EXPLORER_COMMAND_ID, REMOVE_ROOT_FOLDER_LABEL, REMOVE_ROOT_FOLDER_COMMAND_ID, SAVE_ALL_COMMAND_ID } from './fileConstants.js';
import { CommandsRegistry } from '../../../../platform/commands/common/commands.js';
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
import { KeybindingsRegistry, KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
import { FilesExplorerFocusCondition, ExplorerRootContext, ExplorerResourceWritableContext, ExplorerResourceMoveableToTrash, ExplorerResourceCut, ExplorerFolderContext, ExplorerResourceAvailableEditorIdsContext, FoldersViewVisibleContext } from '../common/files.js';
import { ADD_ROOT_FOLDER_LABEL, ADD_ROOT_FOLDER_COMMAND_ID } from '../../../browser/actions/workspaceCommands.js';
import { REOPEN_WITH_COMMAND_ID, CLOSE_EDITOR_COMMAND_ID, CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID, CLOSE_SAVED_EDITORS_COMMAND_ID, CLOSE_EDITORS_IN_GROUP_COMMAND_ID } from '../../../browser/parts/editor/editorCommands.js';
import { AutoSaveAfterShortDelayContext } from '../../../services/filesConfiguration/common/filesConfigurationService.js';
import { WorkbenchListDoubleSelection } from '../../../../platform/list/browser/listService.js';
import { Schemas } from '../../../../base/common/network.js';
import { ResourceContextKey, MultipleEditorsSelectedInGroupContext, IsSessionsWindowContext, WorkspaceFolderCountContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, TwoEditorsSelectedInGroupContext, SelectedEditorsInGroupFileOrUntitledResourceContextKey, IsSandboxWorkspaceContext, HasWebFileSystemAccess, EnterMultiRootWorkspaceSupportContext, WorkbenchStateContext, ActiveEditorContext, SidebarFocusContext, ActiveEditorCanRevertContext } from '../../../common/contextkeys.js';
import { IsWebContext } from '../../../../platform/contextkey/common/contextkeys.js';
import { IExplorerService } from './files.service.js';
import { Codicon } from '../../../../base/common/codicons.js';
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';

registerAction2(GlobalCompareResourcesAction);
registerAction2(FocusFilesExplorer);
registerAction2(ShowActiveFileInExplorer);
registerAction2(CompareWithClipboardAction);
registerAction2(CompareNewUntitledTextFilesAction);
registerAction2(ToggleAutoSaveAction);
registerAction2(OpenActiveFileInEmptyWorkspace);
registerAction2(SetActiveEditorReadonlyInSession);
registerAction2(SetActiveEditorWriteableInSession);
registerAction2(ToggleActiveEditorReadonlyInSession);
registerAction2(ResetActiveEditorReadonlyInSession);
CommandsRegistry.registerCommand("_files.windowOpen", openWindowCommand);
CommandsRegistry.registerCommand("_files.newWindow", newWindowCommand);
const explorerCommandsWeightBonus = 10;
const RENAME_ID = "renameFile";
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: RENAME_ID,
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerRootContext.toNegated()), ExplorerResourceWritableContext)),
    primary: KeyCode.F2,
    mac: {
        primary: KeyCode.Enter
    },
    handler: renameHandler
});
const MOVE_FILE_TO_TRASH_ID = "moveFileToTrash";
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: MOVE_FILE_TO_TRASH_ID,
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceMoveableToTrash)),
    primary: KeyCode.Delete,
    mac: {
        primary: KeyMod$1.CtrlCmd | KeyCode.Backspace,
        secondary: [KeyCode.Delete]
    },
    handler: moveFileToTrashHandler
});
const DELETE_FILE_ID = "deleteFile";
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: DELETE_FILE_ID,
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: FilesExplorerFocusCondition,
    primary: KeyMod$1.Shift | KeyCode.Delete,
    mac: {
        primary: KeyMod$1.CtrlCmd | KeyMod$1.Alt | KeyCode.Backspace
    },
    handler: deleteFileHandler
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: DELETE_FILE_ID,
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerResourceMoveableToTrash.toNegated()))),
    primary: KeyCode.Delete,
    mac: {
        primary: KeyMod$1.CtrlCmd | KeyCode.Backspace
    },
    handler: deleteFileHandler
});
const CUT_FILE_ID = "filesExplorer.cut";
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: CUT_FILE_ID,
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerRootContext.toNegated()), ExplorerResourceWritableContext)),
    primary: KeyMod$1.CtrlCmd | KeyCode.KeyX,
    handler: cutFileHandler
});
const COPY_FILE_ID = "filesExplorer.copy";
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: COPY_FILE_ID,
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerRootContext.toNegated()))),
    primary: KeyMod$1.CtrlCmd | KeyCode.KeyC,
    handler: copyFileHandler
});
const PASTE_FILE_ID = "filesExplorer.paste";
CommandsRegistry.registerCommand(PASTE_FILE_ID, pasteFileHandler);
KeybindingsRegistry.registerKeybindingRule({
    id: `^${PASTE_FILE_ID}`,
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceWritableContext)),
    primary: KeyMod$1.CtrlCmd | KeyCode.KeyV
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: "filesExplorer.cancelCut",
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceCut)),
    primary: KeyCode.Escape,
    handler: async accessor => {
        const explorerService = accessor.get(IExplorerService);
        await explorerService.setToCopy([], true);
    }
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: "filesExplorer.openFilePreserveFocus",
    weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
    when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerFolderContext.toNegated()))),
    primary: KeyCode.Space,
    handler: openFilePreserveFocusHandler
});
const copyPathCommand = {
    id: COPY_PATH_COMMAND_ID,
    title: ( localize(10304, "Copy Path"))
};
const copyRelativePathCommand = {
    id: COPY_RELATIVE_PATH_COMMAND_ID,
    title: ( localize(10305, "Copy Relative Path"))
};
const revealInSideBarCommand = {
    id: REVEAL_IN_EXPLORER_COMMAND_ID,
    title: ( localize(10306, "Reveal in Explorer View"))
};
appendEditorTitleContextMenuItem(
    COPY_PATH_COMMAND_ID,
    copyPathCommand.title,
    ResourceContextKey.IsFileSystemResource,
    "1_cutcopypaste",
    true
);
appendEditorTitleContextMenuItem(
    COPY_RELATIVE_PATH_COMMAND_ID,
    copyRelativePathCommand.title,
    ResourceContextKey.IsFileSystemResource,
    "1_cutcopypaste",
    true
);
appendEditorTitleContextMenuItem(
    revealInSideBarCommand.id,
    revealInSideBarCommand.title,
    ResourceContextKey.IsFileSystemResource,
    "2_files",
    false,
    1
);
function appendEditorTitleContextMenuItem(id, title, when, group, supportsMultiSelect, order) {
    const precondition = supportsMultiSelect !== true ? ( MultipleEditorsSelectedInGroupContext.negate()) : undefined;
    MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, {
        command: {
            id,
            title,
            precondition
        },
        when,
        group,
        order
    });
}
appendSaveConflictEditorTitleAction("workbench.files.action.acceptLocalChanges", ( localize(10307, "Use your changes and overwrite file contents")), Codicon.check, -10, acceptLocalChangesCommand);
appendSaveConflictEditorTitleAction("workbench.files.action.revertLocalChanges", ( localize(10308, "Discard your changes and revert to file contents")), Codicon.discard, -9, revertLocalChangesCommand);
function appendSaveConflictEditorTitleAction(id, title, icon, order, command) {
    CommandsRegistry.registerCommand(id, command);
    MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
        command: {
            id,
            title,
            icon
        },
        when: ( ContextKeyExpr.equals(CONFLICT_RESOLUTION_CONTEXT, true)),
        group: "navigation",
        order
    });
}
function appendToCommandPalette(
    {
        id,
        title,
        category,
        metadata
    },
    when
) {
    MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
        command: {
            id,
            title,
            category,
            metadata
        },
        when
    });
}
appendToCommandPalette({
    id: COPY_PATH_COMMAND_ID,
    title: ( localize2(10309, "Copy Path of Active File")),
    category: Categories.File
}, ( IsSessionsWindowContext.negate()));
appendToCommandPalette({
    id: COPY_RELATIVE_PATH_COMMAND_ID,
    title: ( localize2(10310, "Copy Relative Path of Active File")),
    category: Categories.File
}, ( IsSessionsWindowContext.negate()));
appendToCommandPalette({
    id: SAVE_FILE_COMMAND_ID,
    title: SAVE_FILE_LABEL,
    category: Categories.File
});
appendToCommandPalette({
    id: SAVE_FILE_WITHOUT_FORMATTING_COMMAND_ID,
    title: SAVE_FILE_WITHOUT_FORMATTING_LABEL,
    category: Categories.File
});
appendToCommandPalette({
    id: SAVE_ALL_IN_GROUP_COMMAND_ID,
    title: ( localize2(10311, "Save All in Group")),
    category: Categories.File
}, ( IsSessionsWindowContext.negate()));
appendToCommandPalette({
    id: SAVE_FILES_COMMAND_ID,
    title: ( localize2(10312, "Save All Files")),
    category: Categories.File
}, ( IsSessionsWindowContext.negate()));
appendToCommandPalette({
    id: REVERT_FILE_COMMAND_ID,
    title: ( localize2(10313, "Revert File")),
    category: Categories.File
}, ( IsSessionsWindowContext.negate()));
appendToCommandPalette({
    id: COMPARE_WITH_SAVED_COMMAND_ID,
    title: ( localize2(10314, "Compare Active File with Saved")),
    category: Categories.File,
    metadata: {
        description: ( localize2(
            10315,
            "Opens a new diff editor to compare the active file with the version on disk."
        ))
    }
});
appendToCommandPalette({
    id: SAVE_FILE_AS_COMMAND_ID,
    title: SAVE_FILE_AS_LABEL,
    category: Categories.File
}, ( IsSessionsWindowContext.negate()));
appendToCommandPalette({
    id: NEW_FILE_COMMAND_ID,
    title: NEW_FILE_LABEL,
    category: Categories.File
}, ( ContextKeyExpr.and(( WorkspaceFolderCountContext.notEqualsTo("0")), ( IsSessionsWindowContext.negate()))));
appendToCommandPalette({
    id: NEW_FOLDER_COMMAND_ID,
    title: NEW_FOLDER_LABEL,
    category: Categories.File,
    metadata: {
        description: ( localize2(10316, "Create a new folder or directory"))
    }
}, ( ContextKeyExpr.and(( WorkspaceFolderCountContext.notEqualsTo("0")), ( IsSessionsWindowContext.negate()))));
appendToCommandPalette({
    id: NEW_UNTITLED_FILE_COMMAND_ID,
    title: NEW_UNTITLED_FILE_LABEL,
    category: Categories.File
}, ( IsSessionsWindowContext.negate()));
const isFileOrUntitledResourceContextKey = ( ContextKeyExpr.or(ResourceContextKey.IsFileSystemResource, ( ResourceContextKey.Scheme.isEqualTo(Schemas.untitled))));
const openToSideCommand = {
    id: OPEN_TO_SIDE_COMMAND_ID,
    title: ( localize(10317, "Open to the Side"))
};
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "navigation",
    order: 10,
    command: openToSideCommand,
    when: isFileOrUntitledResourceContextKey
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "1_open",
    order: 10,
    command: {
        id: REOPEN_WITH_COMMAND_ID,
        title: ( localize(10318, "Reopen Editor With..."))
    },
    when: ( ContextKeyExpr.and(
    ActiveEditorAvailableEditorIdsContext, (
    OpenEditorsGroupContext.toNegated())))
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "1_cutcopypaste",
    order: 10,
    command: copyPathCommand,
    when: ResourceContextKey.IsFileSystemResource
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "1_cutcopypaste",
    order: 20,
    command: copyRelativePathCommand,
    when: ResourceContextKey.IsFileSystemResource
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "2_save",
    order: 10,
    command: {
        id: SAVE_FILE_COMMAND_ID,
        title: SAVE_FILE_LABEL,
        precondition: OpenEditorsDirtyEditorContext
    },
    when: ( ContextKeyExpr.or((
    ResourceContextKey.Scheme.isEqualTo(Schemas.untitled)), (
    ContextKeyExpr.and((
    OpenEditorsGroupContext.toNegated()), (
    OpenEditorsReadonlyEditorContext.toNegated()), (
    AutoSaveAfterShortDelayContext.toNegated())))))
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "2_save",
    order: 20,
    command: {
        id: REVERT_FILE_COMMAND_ID,
        title: ( localize(10313, "Revert File")),
        precondition: OpenEditorsDirtyEditorContext
    },
    when: ( ContextKeyExpr.and((
    OpenEditorsGroupContext.toNegated()), (
    OpenEditorsReadonlyEditorContext.toNegated()), (
    ResourceContextKey.Scheme.notEqualsTo(Schemas.untitled)), (
    AutoSaveAfterShortDelayContext.toNegated())))
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "2_save",
    order: 30,
    command: {
        id: SAVE_ALL_IN_GROUP_COMMAND_ID,
        title: ( localize(10319, "Save All")),
        precondition: DirtyWorkingCopiesContext
    },
    when: OpenEditorsGroupContext
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "3_compare",
    order: 10,
    command: {
        id: COMPARE_WITH_SAVED_COMMAND_ID,
        title: ( localize(10320, "Compare with Saved")),
        precondition: OpenEditorsDirtyEditorContext
    },
    when: ( ContextKeyExpr.and(ResourceContextKey.IsFileSystemResource, ( AutoSaveAfterShortDelayContext.toNegated()), ( WorkbenchListDoubleSelection.toNegated())))
});
const compareResourceCommand = {
    id: COMPARE_RESOURCE_COMMAND_ID,
    title: ( localize(10321, "Compare with Selected"))
};
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "3_compare",
    order: 20,
    command: compareResourceCommand,
    when: ( ContextKeyExpr.and(
        ResourceContextKey.HasResource,
        ResourceSelectedForCompareContext,
        isFileOrUntitledResourceContextKey,
        ( WorkbenchListDoubleSelection.toNegated())
    ))
});
const selectForCompareCommand = {
    id: SELECT_FOR_COMPARE_COMMAND_ID,
    title: ( localize(10322, "Select for Compare"))
};
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "3_compare",
    order: 30,
    command: selectForCompareCommand,
    when: ( ContextKeyExpr.and(
        ResourceContextKey.HasResource,
        isFileOrUntitledResourceContextKey,
        ( WorkbenchListDoubleSelection.toNegated())
    ))
});
const compareSelectedCommand = {
    id: COMPARE_SELECTED_COMMAND_ID,
    title: ( localize(10323, "Compare Selected"))
};
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "3_compare",
    order: 30,
    command: compareSelectedCommand,
    when: ( ContextKeyExpr.and(
        ResourceContextKey.HasResource,
        WorkbenchListDoubleSelection,
        OpenEditorsSelectedFileOrUntitledContext
    ))
});
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, {
    group: "1_compare",
    order: 30,
    command: compareSelectedCommand,
    when: ( ContextKeyExpr.and(
        ResourceContextKey.HasResource,
        TwoEditorsSelectedInGroupContext,
        SelectedEditorsInGroupFileOrUntitledResourceContextKey
    ))
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "4_close",
    order: 10,
    command: {
        id: CLOSE_EDITOR_COMMAND_ID,
        title: ( localize(10324, "Close"))
    },
    when: ( OpenEditorsGroupContext.toNegated())
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "4_close",
    order: 20,
    command: {
        id: CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID,
        title: ( localize(10325, "Close Others"))
    },
    when: ( OpenEditorsGroupContext.toNegated())
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "4_close",
    order: 30,
    command: {
        id: CLOSE_SAVED_EDITORS_COMMAND_ID,
        title: ( localize(10326, "Close Saved"))
    }
});
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
    group: "4_close",
    order: 40,
    command: {
        id: CLOSE_EDITORS_IN_GROUP_COMMAND_ID,
        title: ( localize(10327, "Close All"))
    }
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "navigation",
    order: 4,
    command: {
        id: NEW_FILE_COMMAND_ID,
        title: NEW_FILE_LABEL,
        precondition: ExplorerResourceWritableContext
    },
    when: ExplorerFolderContext
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "navigation",
    order: 6,
    command: {
        id: NEW_FOLDER_COMMAND_ID,
        title: NEW_FOLDER_LABEL,
        precondition: ExplorerResourceWritableContext
    },
    when: ExplorerFolderContext
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "navigation",
    order: 10,
    command: openToSideCommand,
    when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ResourceContextKey.HasResource))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "navigation",
    order: 20,
    command: {
        id: OPEN_WITH_EXPLORER_COMMAND_ID,
        title: ( localize(10328, "Open With..."))
    },
    when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ExplorerResourceAvailableEditorIdsContext))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "3_compare",
    order: 20,
    command: compareResourceCommand,
    when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ResourceContextKey.HasResource, ResourceSelectedForCompareContext, ( WorkbenchListDoubleSelection.toNegated())))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "3_compare",
    order: 30,
    command: selectForCompareCommand,
    when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ResourceContextKey.HasResource, ( WorkbenchListDoubleSelection.toNegated())))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "3_compare",
    order: 30,
    command: compareSelectedCommand,
    when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ResourceContextKey.HasResource, WorkbenchListDoubleSelection))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "5_cutcopypaste",
    order: 8,
    command: {
        id: CUT_FILE_ID,
        title: ( localize(10329, "Cut"))
    },
    when: ( ContextKeyExpr.and(( ExplorerRootContext.toNegated()), ExplorerResourceWritableContext))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "5_cutcopypaste",
    order: 10,
    command: {
        id: COPY_FILE_ID,
        title: COPY_FILE_LABEL
    },
    when: ( ExplorerRootContext.toNegated())
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "5_cutcopypaste",
    order: 20,
    command: {
        id: PASTE_FILE_ID,
        title: PASTE_FILE_LABEL,
        precondition: ( ContextKeyExpr.and(ExplorerResourceWritableContext, FileCopiedContext))
    },
    when: ExplorerFolderContext
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, ({
    group: "5b_importexport",
    order: 10,
    command: {
        id: DOWNLOAD_COMMAND_ID,
        title: DOWNLOAD_LABEL
    },
    when: ( ContextKeyExpr.and(( IsSandboxWorkspaceContext.toNegated()), ( ContextKeyExpr.or((
    ContextKeyExpr.and(( IsWebContext.toNegated()), ( ResourceContextKey.Scheme.notEqualsTo(Schemas.file)))), (
    ContextKeyExpr.and(IsWebContext, ( ExplorerFolderContext.toNegated()), ( ExplorerRootContext.toNegated()))), (
    ContextKeyExpr.and(IsWebContext, HasWebFileSystemAccess))))))
}));
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, ({
    group: "5b_importexport",
    order: 20,
    command: {
        id: UPLOAD_COMMAND_ID,
        title: UPLOAD_LABEL
    },
    when: ( ContextKeyExpr.and(
    IsWebContext,
    ExplorerFolderContext,
    ExplorerResourceWritableContext))
}));
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "6_copypath",
    order: 10,
    command: copyPathCommand,
    when: ResourceContextKey.IsFileSystemResource
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "6_copypath",
    order: 20,
    command: copyRelativePathCommand,
    when: ResourceContextKey.IsFileSystemResource
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "2_workspace",
    order: 10,
    command: {
        id: ADD_ROOT_FOLDER_COMMAND_ID,
        title: ADD_ROOT_FOLDER_LABEL
    },
    when: ( ContextKeyExpr.and(ExplorerRootContext, ( ContextKeyExpr.or(EnterMultiRootWorkspaceSupportContext, ( WorkbenchStateContext.isEqualTo("workspace"))))))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "2_workspace",
    order: 30,
    command: {
        id: REMOVE_ROOT_FOLDER_COMMAND_ID,
        title: REMOVE_ROOT_FOLDER_LABEL
    },
    when: ( ContextKeyExpr.and(ExplorerRootContext, ExplorerFolderContext, ( ContextKeyExpr.and(( WorkspaceFolderCountContext.notEqualsTo("0")), ( ContextKeyExpr.or(EnterMultiRootWorkspaceSupportContext, ( WorkbenchStateContext.isEqualTo("workspace"))))))))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "7_modification",
    order: 10,
    command: {
        id: RENAME_ID,
        title: TRIGGER_RENAME_LABEL,
        precondition: ExplorerResourceWritableContext
    },
    when: ( ExplorerRootContext.toNegated())
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "7_modification",
    order: 20,
    command: {
        id: MOVE_FILE_TO_TRASH_ID,
        title: MOVE_FILE_TO_TRASH_LABEL
    },
    alt: {
        id: DELETE_FILE_ID,
        title: ( localize(10330, "Delete Permanently"))
    },
    when: ( ContextKeyExpr.and(( ExplorerRootContext.toNegated()), ExplorerResourceMoveableToTrash))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
    group: "7_modification",
    order: 20,
    command: {
        id: DELETE_FILE_ID,
        title: ( localize(10330, "Delete Permanently"))
    },
    when: ( ContextKeyExpr.and(( ExplorerRootContext.toNegated()), ( ExplorerResourceMoveableToTrash.toNegated())))
});
for (const menuId of [MenuId.EmptyEditorGroupContext, MenuId.EditorTabsBarContext]) {
    MenuRegistry.appendMenuItem(menuId, {
        command: {
            id: NEW_UNTITLED_FILE_COMMAND_ID,
            title: ( localize(10331, "New Text File"))
        },
        group: "1_file",
        order: 10
    });
    MenuRegistry.appendMenuItem(menuId, {
        command: {
            id: "workbench.action.quickOpen",
            title: ( localize(10332, "Open File..."))
        },
        group: "1_file",
        order: 20
    });
}
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
    group: "1_new",
    command: {
        id: NEW_UNTITLED_FILE_COMMAND_ID,
        title: ( localize(10333, "&&New Text File"))
    },
    order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
    group: "4_save",
    command: {
        id: SAVE_FILE_COMMAND_ID,
        title: ( localize(10334, "&&Save")),
        precondition: ( ContextKeyExpr.or(ActiveEditorContext, ( ContextKeyExpr.and(FoldersViewVisibleContext, SidebarFocusContext))))
    },
    order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
    group: "4_save",
    command: {
        id: SAVE_FILE_AS_COMMAND_ID,
        title: ( localize(10335, "Save &&As...")),
        precondition: ( ContextKeyExpr.or(ActiveEditorContext, ( ContextKeyExpr.and(FoldersViewVisibleContext, SidebarFocusContext))))
    },
    order: 2
});
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
    group: "4_save",
    command: {
        id: SAVE_ALL_COMMAND_ID,
        title: ( localize(10336, "Save A&&ll")),
        precondition: DirtyWorkingCopiesContext
    },
    order: 3
});
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
    group: "5_autosave",
    command: {
        id: ToggleAutoSaveAction.ID,
        title: ( localize(10337, "A&&uto Save")),
        toggled: ( ContextKeyExpr.notEquals("config.files.autoSave", "off"))
    },
    order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
    group: "6_close",
    command: {
        id: REVERT_FILE_COMMAND_ID,
        title: ( localize(10338, "Re&&vert File")),
        precondition: ( ContextKeyExpr.or((
        ContextKeyExpr.and(ActiveEditorCanRevertContext)), (
        ContextKeyExpr.and(( ResourceContextKey.Scheme.notEqualsTo(Schemas.untitled)), FoldersViewVisibleContext, SidebarFocusContext))))
    },
    order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
    group: "6_close",
    command: {
        id: CLOSE_EDITOR_COMMAND_ID,
        title: ( localize(10339, "&&Close Editor")),
        precondition: ( ContextKeyExpr.or(ActiveEditorContext, ( ContextKeyExpr.and(FoldersViewVisibleContext, SidebarFocusContext))))
    },
    order: 2
});
MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
    group: "3_global_nav",
    command: {
        id: "workbench.action.quickOpen",
        title: ( localize(10340, "Go to &&File..."))
    },
    order: 1
});
MenuRegistry.appendMenuItem(MenuId.ChatAttachmentsContext, {
    group: "navigation",
    order: 10,
    command: openToSideCommand,
    when: ( ContextKeyExpr.and(ResourceContextKey.IsFileSystemResource, ( ExplorerFolderContext.toNegated())))
});
MenuRegistry.appendMenuItem(MenuId.ChatAttachmentsContext, {
    group: "navigation",
    order: 20,
    command: revealInSideBarCommand,
    when: ResourceContextKey.IsFileSystemResource
});
MenuRegistry.appendMenuItem(MenuId.ChatAttachmentsContext, {
    group: "1_cutcopypaste",
    order: 10,
    command: copyPathCommand,
    when: ResourceContextKey.IsFileSystemResource
});
MenuRegistry.appendMenuItem(MenuId.ChatAttachmentsContext, {
    group: "1_cutcopypaste",
    order: 20,
    command: copyRelativePathCommand,
    when: ResourceContextKey.IsFileSystemResource
});
for (const menuId of [
    MenuId.ChatInlineResourceAnchorContext,
    MenuId.ChatInputResourceAttachmentContext
]) {
    MenuRegistry.appendMenuItem(menuId, {
        group: "navigation",
        order: 10,
        command: openToSideCommand,
        when: ( ContextKeyExpr.and(ResourceContextKey.HasResource, ( ExplorerFolderContext.toNegated())))
    });
    MenuRegistry.appendMenuItem(menuId, {
        group: "navigation",
        order: 20,
        command: revealInSideBarCommand,
        when: ResourceContextKey.IsFileSystemResource
    });
    MenuRegistry.appendMenuItem(menuId, {
        group: "1_cutcopypaste",
        order: 10,
        command: copyPathCommand,
        when: ResourceContextKey.IsFileSystemResource
    });
    MenuRegistry.appendMenuItem(menuId, {
        group: "1_cutcopypaste",
        order: 20,
        command: copyRelativePathCommand,
        when: ResourceContextKey.IsFileSystemResource
    });
}

export { appendEditorTitleContextMenuItem, appendToCommandPalette, revealInSideBarCommand };
