
import { isWeb, isMacintosh, isNative } from '../../../../base/common/platform.js';
import { isAuxiliaryWindow } from '../../../../base/browser/window.js';
import { hasNativeTitlebar, TitleBarSetting, CustomTitleBarVisibility, hasNativeMenu, getMenuBarVisibility } from '../../../../platform/window/common/window.js';
import { isFullscreen, isWCOEnabled } from '../../../../base/browser/browser.js';

var Parts;
(function (Parts) {
    Parts["TITLEBAR_PART"] = "workbench.parts.titlebar";
    Parts["BANNER_PART"] = "workbench.parts.banner";
    Parts["ACTIVITYBAR_PART"] = "workbench.parts.activitybar";
    Parts["SIDEBAR_PART"] = "workbench.parts.sidebar";
    Parts["PANEL_PART"] = "workbench.parts.panel";
    Parts["AUXILIARYBAR_PART"] = "workbench.parts.auxiliarybar";
    Parts["SESSIONS_PART"] = "workbench.parts.sessions";
    Parts["EDITOR_PART"] = "workbench.parts.editor";
    Parts["STATUSBAR_PART"] = "workbench.parts.statusbar";
})(Parts || (Parts = {}));
var ZenModeSettings;
(function (ZenModeSettings) {
    ZenModeSettings["SHOW_TABS"] = "zenMode.showTabs";
    ZenModeSettings["HIDE_LINENUMBERS"] = "zenMode.hideLineNumbers";
    ZenModeSettings["HIDE_STATUSBAR"] = "zenMode.hideStatusBar";
    ZenModeSettings["HIDE_ACTIVITYBAR"] = "zenMode.hideActivityBar";
    ZenModeSettings["CENTER_LAYOUT"] = "zenMode.centerLayout";
    ZenModeSettings["FULLSCREEN"] = "zenMode.fullScreen";
    ZenModeSettings["RESTORE"] = "zenMode.restore";
    ZenModeSettings["SILENT_NOTIFICATIONS"] = "zenMode.silentNotifications";
})(ZenModeSettings || (ZenModeSettings = {}));
var LayoutSettings;
(function (LayoutSettings) {
    LayoutSettings["ACTIVITY_BAR_LOCATION"] = "workbench.activityBar.location";
    LayoutSettings["ACTIVITY_BAR_AUTO_HIDE"] = "workbench.activityBar.autoHide";
    LayoutSettings["ACTIVITY_BAR_COMPACT"] = "workbench.activityBar.compact";
    LayoutSettings["EDITOR_TABS_MODE"] = "workbench.editor.showTabs";
    LayoutSettings["EDITOR_ACTIONS_LOCATION"] = "workbench.editor.editorActionsLocation";
    LayoutSettings["COMMAND_CENTER"] = "window.commandCenter";
    LayoutSettings["LAYOUT_ACTIONS"] = "workbench.layoutControl.enabled";
    LayoutSettings["SHADOWS"] = "workbench.shadows";
})(LayoutSettings || (LayoutSettings = {}));
var ActivityBarPosition;
(function (ActivityBarPosition) {
    ActivityBarPosition["DEFAULT"] = "default";
    ActivityBarPosition["TOP"] = "top";
    ActivityBarPosition["BOTTOM"] = "bottom";
    ActivityBarPosition["HIDDEN"] = "hidden";
})(ActivityBarPosition || (ActivityBarPosition = {}));
var EditorTabsMode;
(function (EditorTabsMode) {
    EditorTabsMode["MULTIPLE"] = "multiple";
    EditorTabsMode["SINGLE"] = "single";
    EditorTabsMode["NONE"] = "none";
})(EditorTabsMode || (EditorTabsMode = {}));
var EditorActionsLocation;
(function (EditorActionsLocation) {
    EditorActionsLocation["DEFAULT"] = "default";
    EditorActionsLocation["TITLEBAR"] = "titleBar";
    EditorActionsLocation["HIDDEN"] = "hidden";
})(EditorActionsLocation || (EditorActionsLocation = {}));
var Position;
(function (Position) {
    Position[Position["LEFT"] = 0] = "LEFT";
    Position[Position["RIGHT"] = 1] = "RIGHT";
    Position[Position["BOTTOM"] = 2] = "BOTTOM";
    Position[Position["TOP"] = 3] = "TOP";
})(Position || (Position = {}));
function isHorizontal(position) {
    return position === Position.BOTTOM || position === Position.TOP;
}
var PartOpensMaximizedOptions;
(function (PartOpensMaximizedOptions) {
    PartOpensMaximizedOptions[PartOpensMaximizedOptions["ALWAYS"] = 0] = "ALWAYS";
    PartOpensMaximizedOptions[PartOpensMaximizedOptions["NEVER"] = 1] = "NEVER";
    PartOpensMaximizedOptions[PartOpensMaximizedOptions["REMEMBER_LAST"] = 2] = "REMEMBER_LAST";
})(PartOpensMaximizedOptions || (PartOpensMaximizedOptions = {}));
function positionToString(position) {
    switch (position) {
        case Position.LEFT: return 'left';
        case Position.RIGHT: return 'right';
        case Position.BOTTOM: return 'bottom';
        case Position.TOP: return 'top';
        default: return 'bottom';
    }
}
const positionsByString = {
    [positionToString(Position.LEFT)]: Position.LEFT,
    [positionToString(Position.RIGHT)]: Position.RIGHT,
    [positionToString(Position.BOTTOM)]: Position.BOTTOM,
    [positionToString(Position.TOP)]: Position.TOP
};
function positionFromString(str) {
    return positionsByString[str];
}
function partOpensMaximizedSettingToString(setting) {
    switch (setting) {
        case PartOpensMaximizedOptions.ALWAYS: return 'always';
        case PartOpensMaximizedOptions.NEVER: return 'never';
        case PartOpensMaximizedOptions.REMEMBER_LAST: return 'preserve';
        default: return 'preserve';
    }
}
const partOpensMaximizedByString = {
    [partOpensMaximizedSettingToString(PartOpensMaximizedOptions.ALWAYS)]: PartOpensMaximizedOptions.ALWAYS,
    [partOpensMaximizedSettingToString(PartOpensMaximizedOptions.NEVER)]: PartOpensMaximizedOptions.NEVER,
    [partOpensMaximizedSettingToString(PartOpensMaximizedOptions.REMEMBER_LAST)]: PartOpensMaximizedOptions.REMEMBER_LAST
};
function partOpensMaximizedFromString(str) {
    return partOpensMaximizedByString[str];
}
function isMultiWindowPart(part) {
    return part === Parts.EDITOR_PART ||
        part === Parts.STATUSBAR_PART ||
        part === Parts.TITLEBAR_PART;
}
function shouldShowCustomTitleBar(configurationService, window, menuBarToggled) {
    const inFullscreen = isFullscreen(window);
    const nativeTitleBarEnabled = hasNativeTitlebar(configurationService);
    if (!isWeb) {
        const showCustomTitleBar = configurationService.getValue(TitleBarSetting.CUSTOM_TITLE_BAR_VISIBILITY);
        if (showCustomTitleBar === CustomTitleBarVisibility.NEVER && nativeTitleBarEnabled || showCustomTitleBar === CustomTitleBarVisibility.WINDOWED && inFullscreen) {
            return false;
        }
    }
    if (!isTitleBarEmpty(configurationService)) {
        return true;
    }
    if (nativeTitleBarEnabled && hasNativeMenu(configurationService)) {
        return false;
    }
    if (isMacintosh && isNative) {
        return !inFullscreen;
    }
    if (isNative && !inFullscreen) {
        return true;
    }
    if (isWCOEnabled() && !inFullscreen) {
        return true;
    }
    const menuBarVisibility = !isAuxiliaryWindow(window) ? getMenuBarVisibility(configurationService) : 'hidden';
    switch (menuBarVisibility) {
        case 'classic':
            return !inFullscreen || !!menuBarToggled;
        case 'compact':
        case 'hidden':
            return false;
        case 'toggle':
            return !!menuBarToggled;
        case 'visible':
            return true;
        default:
            return isWeb ? false : !inFullscreen || !!menuBarToggled;
    }
}
function isTitleBarEmpty(configurationService) {
    if (configurationService.getValue(LayoutSettings.COMMAND_CENTER)) {
        return false;
    }
    const activityBarPosition = configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION);
    if (activityBarPosition === ActivityBarPosition.TOP || activityBarPosition === ActivityBarPosition.BOTTOM) {
        return false;
    }
    const editorActionsLocation = configurationService.getValue(LayoutSettings.EDITOR_ACTIONS_LOCATION);
    const editorTabsMode = configurationService.getValue(LayoutSettings.EDITOR_TABS_MODE);
    if (editorActionsLocation === EditorActionsLocation.TITLEBAR || editorActionsLocation === EditorActionsLocation.DEFAULT && editorTabsMode === EditorTabsMode.NONE) {
        return false;
    }
    if (configurationService.getValue(LayoutSettings.LAYOUT_ACTIONS)) {
        return false;
    }
    return true;
}

export { ActivityBarPosition, EditorActionsLocation, EditorTabsMode, LayoutSettings, PartOpensMaximizedOptions, Parts, Position, ZenModeSettings, isHorizontal, isMultiWindowPart, partOpensMaximizedFromString, positionFromString, positionToString, shouldShowCustomTitleBar };
