
import { localize2, localize } from '../../../../nls.js';
import { Action2, MenuId, registerAction2, MenuRegistry } from '../../../../platform/actions/common/actions.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.service.js';
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';

const renderWhitespaceSetting = "editor.renderWhitespace";
class RenderWhitespaceNoneAction extends Action2 {
    static {
        this.ID = "editor.action.renderWhitespace.none";
    }
    constructor() {
        super({
            id: RenderWhitespaceNoneAction.ID,
            title: ( localize2(8492, "Set Render Whitespace to None")),
            shortTitle: ( localize2(8493, "None")),
            category: Categories.View,
            f1: false,
            toggled: ( ContextKeyExpr.equals(`config.${renderWhitespaceSetting}`, "none")),
            menu: {
                id: MenuId.EditorRenderWhitespaceSubmenu,
                group: "1_config",
                order: 1
            }
        });
    }
    run(accessor) {
        return accessor.get(IConfigurationService).updateValue(renderWhitespaceSetting, "none");
    }
}
class RenderWhitespaceBoundaryAction extends Action2 {
    static {
        this.ID = "editor.action.renderWhitespace.boundary";
    }
    constructor() {
        super({
            id: RenderWhitespaceBoundaryAction.ID,
            title: ( localize2(8494, "Set Render Whitespace to Boundary")),
            shortTitle: ( localize2(8495, "Boundary")),
            category: Categories.View,
            f1: false,
            toggled: ( ContextKeyExpr.equals(`config.${renderWhitespaceSetting}`, "boundary")),
            menu: {
                id: MenuId.EditorRenderWhitespaceSubmenu,
                group: "1_config",
                order: 2
            }
        });
    }
    run(accessor) {
        return accessor.get(IConfigurationService).updateValue(renderWhitespaceSetting, "boundary");
    }
}
class RenderWhitespaceSelectionAction extends Action2 {
    static {
        this.ID = "editor.action.renderWhitespace.selection";
    }
    constructor() {
        super({
            id: RenderWhitespaceSelectionAction.ID,
            title: ( localize2(8496, "Set Render Whitespace to Selection")),
            shortTitle: ( localize2(8497, "Selection")),
            category: Categories.View,
            f1: false,
            toggled: ( ContextKeyExpr.equals(`config.${renderWhitespaceSetting}`, "selection")),
            menu: {
                id: MenuId.EditorRenderWhitespaceSubmenu,
                group: "1_config",
                order: 3
            }
        });
    }
    run(accessor) {
        return accessor.get(IConfigurationService).updateValue(renderWhitespaceSetting, "selection");
    }
}
class RenderWhitespaceTrailingAction extends Action2 {
    static {
        this.ID = "editor.action.renderWhitespace.trailing";
    }
    constructor() {
        super({
            id: RenderWhitespaceTrailingAction.ID,
            title: ( localize2(8498, "Set Render Whitespace to Trailing")),
            shortTitle: ( localize2(8499, "Trailing")),
            category: Categories.View,
            f1: false,
            toggled: ( ContextKeyExpr.equals(`config.${renderWhitespaceSetting}`, "trailing")),
            menu: {
                id: MenuId.EditorRenderWhitespaceSubmenu,
                group: "1_config",
                order: 4
            }
        });
    }
    run(accessor) {
        return accessor.get(IConfigurationService).updateValue(renderWhitespaceSetting, "trailing");
    }
}
class RenderWhitespaceAllAction extends Action2 {
    static {
        this.ID = "editor.action.renderWhitespace.all";
    }
    constructor() {
        super({
            id: RenderWhitespaceAllAction.ID,
            title: ( localize2(8500, "Set Render Whitespace to All")),
            shortTitle: ( localize2(8501, "All")),
            category: Categories.View,
            f1: false,
            toggled: ( ContextKeyExpr.equals(`config.${renderWhitespaceSetting}`, "all")),
            menu: {
                id: MenuId.EditorRenderWhitespaceSubmenu,
                group: "1_config",
                order: 5
            }
        });
    }
    run(accessor) {
        return accessor.get(IConfigurationService).updateValue(renderWhitespaceSetting, "all");
    }
}
class ToggleRenderWhitespaceAction extends Action2 {
    static {
        this.ID = "editor.action.toggleRenderWhitespace";
    }
    constructor() {
        super({
            id: ToggleRenderWhitespaceAction.ID,
            title: ( localize2(8502, "Toggle Render Whitespace")),
            category: Categories.View,
            f1: true
        });
    }
    run(accessor) {
        const configurationService = accessor.get(IConfigurationService);
        const renderWhitespace = configurationService.getValue(renderWhitespaceSetting);
        let newRenderWhitespace;
        if (renderWhitespace === "none") {
            newRenderWhitespace = "all";
        } else {
            newRenderWhitespace = "none";
        }
        return configurationService.updateValue(renderWhitespaceSetting, newRenderWhitespace);
    }
}
registerAction2(RenderWhitespaceNoneAction);
registerAction2(RenderWhitespaceBoundaryAction);
registerAction2(RenderWhitespaceSelectionAction);
registerAction2(RenderWhitespaceTrailingAction);
registerAction2(RenderWhitespaceAllAction);
registerAction2(ToggleRenderWhitespaceAction);
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
    submenu: MenuId.EditorRenderWhitespaceSubmenu,
    title: ( localize(8503, "Render Whitespace")),
    group: "4_editor",
    order: 4
});
