@codingame/monaco-vscode-api 1.67.7 → 1.67.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4305 @@
1
+ import { E as Emitter, a as assertAllDefined, I as ILifecycleService, u as unsupported } from './missing-services-305b736f.js';
2
+ import { b as __decorate, d as __param, f as IFileService, w as refineServiceDecorator, n as IEditorGroupsService, s as IHostService, p as IProductService } from './services-ac6b4b50.js';
3
+ import { editorWidgetBackground, editorWidgetForeground, widgetShadow, contrastBorder, buttonForeground, buttonBackground, buttonSecondaryBackground, buttonSecondaryForeground, buttonSecondaryHoverBackground, buttonHoverBackground, buttonBorder, simpleCheckboxBorder, simpleCheckboxBackground, simpleCheckboxForeground, problemsErrorIconForeground, problemsWarningIconForeground, problemsInfoIconForeground, inputBackground, inputForeground, inputBorder, textLinkForeground, progressBarBackground, resolveColorValue, registerColor, editorBackground, transparent, treeIndentGuidesStroke, focusBorder, listActiveSelectionBackground, darken, listActiveSelectionForeground, editorInfoForeground, errorForeground, editorWarningForeground, activeContrastBorder, lighten, editorErrorForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
4
+ import { localize } from 'monaco-editor/esm/vs/nls.js';
5
+ import { Color } from 'monaco-editor/esm/vs/base/common/color.js';
6
+ import { Disposable, toDisposable, DisposableStore, dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
7
+ import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
8
+ import { NoOpNotification, Severity, INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
9
+ import { isCancellationError } from 'monaco-editor/esm/vs/base/common/errors.js';
10
+ import { toErrorMessage } from 'monaco-editor/esm/vs/base/common/errorMessage.js';
11
+ import { equals, isNonEmptyArray } from 'monaco-editor/esm/vs/base/common/arrays.js';
12
+ import { Action, ActionRunner } from 'monaco-editor/esm/vs/base/common/actions.js';
13
+ import { hash } from 'monaco-editor/esm/vs/base/common/hash.js';
14
+ import { RawContextKey, IContextKeyService, ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
15
+ import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
16
+ import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
17
+ import { isEqual, basename, dirname, extname } from 'monaco-editor/esm/vs/base/common/resources.js';
18
+ import { CommandsRegistry, ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
19
+ import { KeybindingsRegistry } from 'monaco-editor/esm/vs/platform/keybinding/common/keybindingsRegistry.js';
20
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
21
+ import { IListService, WorkbenchList } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
22
+ import { MenuRegistry, MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
23
+ import { registerIcon } from 'monaco-editor/esm/vs/platform/theme/common/iconRegistry.js';
24
+ import { CSSIcon, Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
25
+ import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
26
+ import { ThemeIcon, IThemeService, Themable, registerThemingParticipant } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
27
+ import { addDisposableListener, EventType, EventHelper, trackFocus, reset, clearNode, $, isAncestor, Dimension, scheduleAtNextAnimationFrame, hide, show, getClientArea } from 'monaco-editor/esm/vs/base/browser/dom.js';
28
+ import { mixin } from 'monaco-editor/esm/vs/base/common/objects.js';
29
+ import { Gesture, EventType as EventType$1 } from 'monaco-editor/esm/vs/base/browser/touch.js';
30
+ import { renderLabelWithIcons } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabels.js';
31
+ import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
32
+ import { DomEmitter } from 'monaco-editor/esm/vs/base/browser/event.js';
33
+ import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
34
+ import { ProgressBar } from 'monaco-editor/esm/vs/base/browser/ui/progressbar/progressbar.js';
35
+ import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
36
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
37
+ import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
38
+ import { IOpenerService } from 'monaco-editor/esm/vs/platform/opener/common/opener.js';
39
+ import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
40
+ import { DropdownMenuActionViewItem } from 'monaco-editor/esm/vs/base/browser/ui/dropdown/dropdownActionViewItem.js';
41
+ import { assertIsDefined } from 'monaco-editor/esm/vs/base/common/types.js';
42
+ import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
43
+ import { I as IntervalCounter } from './async-9ffe4d42.js';
44
+ import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
45
+ import { Widget } from 'monaco-editor/esm/vs/base/browser/ui/widget.js';
46
+ import { isMacintosh, isWindows, isLinux } from 'monaco-editor/esm/vs/base/common/platform.js';
47
+ import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
48
+ import { MarkdownRenderer } from 'monaco-editor/esm/vs/editor/contrib/markdownRenderer/browser/markdownRenderer.js';
49
+ import Severity$1 from 'monaco-editor/esm/vs/base/common/severity.js';
50
+ import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
51
+ import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
52
+ import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
53
+ import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
54
+ import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
55
+ import 'monaco-editor/esm/vs/base/common/buffer.js';
56
+ import 'monaco-editor/esm/vs/base/parts/quickinput/browser/quickInput.js';
57
+ import 'monaco-editor/esm/vs/platform/instantiation/common/extensions.js';
58
+ import 'monaco-editor/esm/vs/platform/label/common/label.js';
59
+ import 'monaco-editor/esm/vs/editor/editor.api.js';
60
+ import 'monaco-editor/esm/vs/base/common/network.js';
61
+ import 'monaco-editor/esm/vs/editor/common/languageFeatureRegistry.js';
62
+ import 'monaco-editor/esm/vs/base/common/strings.js';
63
+ import 'monaco-editor/esm/vs/platform/environment/common/environment.js';
64
+ import 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
65
+ import 'monaco-editor/esm/vs/base/common/path.js';
66
+ import 'monaco-editor/esm/vs/base/common/linkedList.js';
67
+ import 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
68
+ import 'monaco-editor/esm/vs/base/common/stopwatch.js';
69
+ import 'monaco-editor/esm/vs/base/common/cancellation.js';
70
+ import 'monaco-editor/esm/vs/editor/browser/services/bulkEditService.js';
71
+ import 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
72
+ import 'monaco-editor/esm/vs/editor/common/languages/languageConfigurationRegistry.js';
73
+ import 'monaco-editor/esm/vs/editor/common/services/editorWorker.js';
74
+ import 'monaco-editor/esm/vs/editor/common/services/languageFeatures.js';
75
+ import 'monaco-editor/esm/vs/editor/common/services/resolverService.js';
76
+ import 'monaco-editor/esm/vs/platform/markers/common/markers.js';
77
+ import 'monaco-editor/esm/vs/platform/quickinput/common/quickInput.js';
78
+ function isErrorWithActions(obj) {
79
+ const candidate = obj;
80
+ return candidate instanceof Error && Array.isArray(candidate.actions);
81
+ }
82
+ var NeverShowAgainScope;
83
+ (function(NeverShowAgainScope) {
84
+ NeverShowAgainScope[NeverShowAgainScope["WORKSPACE"] = 0] = "WORKSPACE";
85
+ NeverShowAgainScope[NeverShowAgainScope["GLOBAL"] = 1] = "GLOBAL";
86
+ })(NeverShowAgainScope || (NeverShowAgainScope = {}));
87
+ var NotificationsFilter;
88
+ (function(NotificationsFilter) {
89
+ NotificationsFilter[NotificationsFilter["OFF"] = 0] = "OFF";
90
+ NotificationsFilter[NotificationsFilter["SILENT"] = 1] = "SILENT";
91
+ NotificationsFilter[NotificationsFilter["ERROR"] = 2] = "ERROR";
92
+ })(NotificationsFilter || (NotificationsFilter = {}));
93
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
94
+ var css$3 = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n.monaco-workbench > .notifications-toasts {\n\tposition: absolute;\n\tz-index: 1000;\n\tright: 3px;\n\tbottom: 26px;\n\tdisplay: none;\n\toverflow: hidden;\n}\n\n.monaco-workbench.nostatusbar > .notifications-toasts {\n\tbottom: 3px;\n}\n\n.monaco-workbench > .notifications-toasts.visible {\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.monaco-workbench > .notifications-toasts .notification-toast-container {\n\toverflow: hidden; /* this ensures that the notification toast does not shine through */\n}\n\n.monaco-workbench > .notifications-toasts .notification-toast-container > .notification-toast {\n\tmargin: 8px; /* enables separation and drop shadows around toasts */\n\ttransform: translate3d(0px, 100%, 0px); /* move the notification 50px to the bottom (to prevent bleed through) */\n\topacity: 0; /* fade the toast in */\n\ttransition:\ttransform 300ms ease-out, opacity 300ms ease-out;\n}\n\n.monaco-workbench > .notifications-toasts .notification-toast-container > .notification-toast.notification-fade-in {\n\topacity: 1;\n\ttransform: none;\n}\n\n.monaco-workbench > .notifications-toasts .notification-toast-container > .notification-toast.notification-fade-in-done {\n\topacity: 1;\n\ttransform: none;\n\ttransition:\tnone;\n}\n";
95
+ n(css$3,{});
96
+ var css$2 = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n/** Notification: Container */\n\n.monaco-workbench .notifications-list-container .notification-list-item {\n\tdisplay: flex;\n\tflex-direction: column;\n\tflex-direction: column-reverse; /* the details row appears first in order for better keyboard access to notification buttons */\n\tpadding: 10px 5px;\n\theight: 100%;\n\tbox-sizing: border-box;\n}\n\n.monaco-workbench .notifications-list-container .notification-offset-helper {\n\topacity: 0;\n\tposition: absolute;\n\tline-height: 22px;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n}\n\n/** Notification: Main Row */\n\n.monaco-workbench .notifications-list-container .notification-list-item > .notification-list-item-main-row {\n\tdisplay: flex;\n\tflex-grow: 1;\n}\n\n/** Notification: Icon */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-icon {\n\tdisplay: flex;\n\talign-items: center;\n\tflex: 0 0 16px;\n\theight: 22px;\n\tmargin-right: 4px;\n\tmargin-left: 4px;\n\tfont-size: 18px;\n\tbackground-position: center;\n\tbackground-repeat: no-repeat;\n}\n\n/** Notification: Message */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-message {\n\tline-height: 22px;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tflex: 1; /* let the message always grow */\n\tuser-select: text;\n\t-webkit-user-select: text;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-message a:focus {\n\toutline-width: 1px;\n\toutline-style: solid;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item.expanded .notification-list-item-message {\n\twhite-space: normal;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n}\n\n/** Notification: Toolbar Container */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-toolbar-container {\n\tdisplay: none;\n\theight: 22px;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item:hover .notification-list-item-toolbar-container,\n.monaco-workbench .notifications-list-container .monaco-list-row.focused .notification-list-item .notification-list-item-toolbar-container,\n.monaco-workbench .notifications-list-container .notification-list-item.expanded .notification-list-item-toolbar-container {\n\tdisplay: block;\n}\n\n/** Notification: Details Row */\n\n.monaco-workbench .notifications-list-container .notification-list-item > .notification-list-item-details-row {\n\tdisplay: none;\n\talign-items: center;\n\tpadding-left: 5px;\n\toverflow: hidden; /* details row should never overflow */\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item.expanded > .notification-list-item-details-row {\n\tdisplay: flex;\n}\n\n/** Notification: Source */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-source {\n\tflex: 1;\n\tfont-size: 12px;\n\toverflow: hidden; /* always give away space to buttons container */\n\ttext-overflow: ellipsis;\n}\n\n/** Notification: Buttons */\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container {\n\tdisplay: flex;\n\toverflow: hidden;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container > .monaco-button-dropdown,\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container > .monaco-button {\n\tmargin: 4px 5px; /* allows button focus outline to be visible */\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container .monaco-button {\n\toutline-offset: 2px !important;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container .monaco-text-button {\n\twidth: fit-content;\n\twidth: -moz-fit-content;\n\tpadding: 5px 10px;\n\tdisplay: inline-block;\t/* to enable ellipsis in text overflow */\n\tfont-size: 12px;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-buttons-container .monaco-dropdown-button {\n\tpadding: 5px\n}\n\n/** Notification: Progress */\n\n.monaco-workbench .notifications-list-container .progress-bit {\n\theight: 2px;\n\tbottom: 0;\n}\n";
97
+ n(css$2,{});
98
+ function computeStyles(theme, styleMap) {
99
+ const styles = Object.create(null);
100
+ for (let key in styleMap) {
101
+ const value = styleMap[key];
102
+ if (value) {
103
+ styles[key] = resolveColorValue(value, theme);
104
+ }
105
+ }
106
+ return styles;
107
+ }
108
+ function attachStyler(themeService, styleMap, widgetOrCallback) {
109
+ function applyStyles() {
110
+ const styles = computeStyles(themeService.getColorTheme(), styleMap);
111
+ if (typeof widgetOrCallback === 'function') {
112
+ widgetOrCallback(styles);
113
+ }
114
+ else {
115
+ widgetOrCallback.style(styles);
116
+ }
117
+ }
118
+ applyStyles();
119
+ return themeService.onDidColorThemeChange(applyStyles);
120
+ }
121
+ function attachButtonStyler(widget, themeService, style) {
122
+ return attachStyler(themeService, {
123
+ buttonForeground: style?.buttonForeground || buttonForeground,
124
+ buttonBackground: style?.buttonBackground || buttonBackground,
125
+ buttonHoverBackground: style?.buttonHoverBackground || buttonHoverBackground,
126
+ buttonSecondaryForeground: style?.buttonSecondaryForeground || buttonSecondaryForeground,
127
+ buttonSecondaryBackground: style?.buttonSecondaryBackground || buttonSecondaryBackground,
128
+ buttonSecondaryHoverBackground: style?.buttonSecondaryHoverBackground || buttonSecondaryHoverBackground,
129
+ buttonBorder: style?.buttonBorder || buttonBorder,
130
+ }, widget);
131
+ }
132
+ function attachProgressBarStyler(widget, themeService, style) {
133
+ return attachStyler(themeService, {
134
+ progressBarBackground: style?.progressBarBackground || progressBarBackground
135
+ }, widget);
136
+ }
137
+ const defaultDialogStyles = {
138
+ dialogBackground: editorWidgetBackground,
139
+ dialogForeground: editorWidgetForeground,
140
+ dialogShadow: widgetShadow,
141
+ dialogBorder: contrastBorder,
142
+ buttonForeground: buttonForeground,
143
+ buttonBackground: buttonBackground,
144
+ buttonSecondaryBackground: buttonSecondaryBackground,
145
+ buttonSecondaryForeground: buttonSecondaryForeground,
146
+ buttonSecondaryHoverBackground: buttonSecondaryHoverBackground,
147
+ buttonHoverBackground: buttonHoverBackground,
148
+ buttonBorder: buttonBorder,
149
+ checkboxBorder: simpleCheckboxBorder,
150
+ checkboxBackground: simpleCheckboxBackground,
151
+ checkboxForeground: simpleCheckboxForeground,
152
+ errorIconForeground: problemsErrorIconForeground,
153
+ warningIconForeground: problemsWarningIconForeground,
154
+ infoIconForeground: problemsInfoIconForeground,
155
+ inputBackground: inputBackground,
156
+ inputForeground: inputForeground,
157
+ inputBorder: inputBorder,
158
+ textLinkForeground: textLinkForeground
159
+ };
160
+ function attachDialogStyler(widget, themeService, style) {
161
+ return attachStyler(themeService, { ...defaultDialogStyles, ...style }, widget);
162
+ }
163
+ const TAB_ACTIVE_BACKGROUND = registerColor('tab.activeBackground', {
164
+ dark: editorBackground,
165
+ light: editorBackground,
166
+ hc: editorBackground
167
+ }, localize(
168
+ 'tabActiveBackground',
169
+ "Active tab background color in an active group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
170
+ ));
171
+ registerColor('tab.unfocusedActiveBackground', {
172
+ dark: TAB_ACTIVE_BACKGROUND,
173
+ light: TAB_ACTIVE_BACKGROUND,
174
+ hc: TAB_ACTIVE_BACKGROUND
175
+ }, localize(
176
+ 'tabUnfocusedActiveBackground',
177
+ "Active tab background color in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
178
+ ));
179
+ const TAB_INACTIVE_BACKGROUND = registerColor('tab.inactiveBackground', {
180
+ dark: '#2D2D2D',
181
+ light: '#ECECEC',
182
+ hc: null
183
+ }, localize(
184
+ 'tabInactiveBackground',
185
+ "Inactive tab background color in an active group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
186
+ ));
187
+ registerColor('tab.unfocusedInactiveBackground', {
188
+ dark: TAB_INACTIVE_BACKGROUND,
189
+ light: TAB_INACTIVE_BACKGROUND,
190
+ hc: TAB_INACTIVE_BACKGROUND
191
+ }, localize(
192
+ 'tabUnfocusedInactiveBackground',
193
+ "Inactive tab background color in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
194
+ ));
195
+ const TAB_ACTIVE_FOREGROUND = registerColor('tab.activeForeground', {
196
+ dark: Color.white,
197
+ light: '#333333',
198
+ hc: Color.white
199
+ }, localize(
200
+ 'tabActiveForeground',
201
+ "Active tab foreground color in an active group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
202
+ ));
203
+ const TAB_INACTIVE_FOREGROUND = registerColor('tab.inactiveForeground', {
204
+ dark: transparent(TAB_ACTIVE_FOREGROUND, 0.5),
205
+ light: transparent(TAB_ACTIVE_FOREGROUND, 0.7),
206
+ hc: Color.white
207
+ }, localize(
208
+ 'tabInactiveForeground',
209
+ "Inactive tab foreground color in an active group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
210
+ ));
211
+ registerColor('tab.unfocusedActiveForeground', {
212
+ dark: transparent(TAB_ACTIVE_FOREGROUND, 0.5),
213
+ light: transparent(TAB_ACTIVE_FOREGROUND, 0.7),
214
+ hc: Color.white
215
+ }, localize(
216
+ 'tabUnfocusedActiveForeground',
217
+ "Active tab foreground color in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
218
+ ));
219
+ registerColor('tab.unfocusedInactiveForeground', {
220
+ dark: transparent(TAB_INACTIVE_FOREGROUND, 0.5),
221
+ light: transparent(TAB_INACTIVE_FOREGROUND, 0.5),
222
+ hc: Color.white
223
+ }, localize(
224
+ 'tabUnfocusedInactiveForeground',
225
+ "Inactive tab foreground color in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
226
+ ));
227
+ const TAB_HOVER_BACKGROUND = registerColor('tab.hoverBackground', {
228
+ dark: null,
229
+ light: null,
230
+ hc: null
231
+ }, localize(
232
+ 'tabHoverBackground',
233
+ "Tab background color when hovering. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
234
+ ));
235
+ registerColor('tab.unfocusedHoverBackground', {
236
+ dark: transparent(TAB_HOVER_BACKGROUND, 0.5),
237
+ light: transparent(TAB_HOVER_BACKGROUND, 0.7),
238
+ hc: null
239
+ }, localize(
240
+ 'tabUnfocusedHoverBackground',
241
+ "Tab background color in an unfocused group when hovering. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
242
+ ));
243
+ const TAB_HOVER_FOREGROUND = registerColor('tab.hoverForeground', {
244
+ dark: null,
245
+ light: null,
246
+ hc: null
247
+ }, localize(
248
+ 'tabHoverForeground',
249
+ "Tab foreground color when hovering. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
250
+ ));
251
+ registerColor('tab.unfocusedHoverForeground', {
252
+ dark: transparent(TAB_HOVER_FOREGROUND, 0.5),
253
+ light: transparent(TAB_HOVER_FOREGROUND, 0.5),
254
+ hc: null
255
+ }, localize(
256
+ 'tabUnfocusedHoverForeground',
257
+ "Tab foreground color in an unfocused group when hovering. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
258
+ ));
259
+ registerColor('tab.border', {
260
+ dark: '#252526',
261
+ light: '#F3F3F3',
262
+ hc: contrastBorder
263
+ }, localize(
264
+ 'tabBorder',
265
+ "Border to separate tabs from each other. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
266
+ ));
267
+ registerColor('tab.lastPinnedBorder', {
268
+ dark: treeIndentGuidesStroke,
269
+ light: treeIndentGuidesStroke,
270
+ hc: contrastBorder
271
+ }, localize(
272
+ 'lastPinnedTabBorder',
273
+ "Border to separate pinned tabs from other tabs. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
274
+ ));
275
+ const TAB_ACTIVE_BORDER = registerColor('tab.activeBorder', {
276
+ dark: null,
277
+ light: null,
278
+ hc: null
279
+ }, localize(
280
+ 'tabActiveBorder',
281
+ "Border on the bottom of an active tab. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
282
+ ));
283
+ registerColor('tab.unfocusedActiveBorder', {
284
+ dark: transparent(TAB_ACTIVE_BORDER, 0.5),
285
+ light: transparent(TAB_ACTIVE_BORDER, 0.7),
286
+ hc: null
287
+ }, localize(
288
+ 'tabActiveUnfocusedBorder',
289
+ "Border on the bottom of an active tab in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
290
+ ));
291
+ const TAB_ACTIVE_BORDER_TOP = registerColor('tab.activeBorderTop', {
292
+ dark: null,
293
+ light: null,
294
+ hc: null
295
+ }, localize(
296
+ 'tabActiveBorderTop',
297
+ "Border to the top of an active tab. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
298
+ ));
299
+ registerColor('tab.unfocusedActiveBorderTop', {
300
+ dark: transparent(TAB_ACTIVE_BORDER_TOP, 0.5),
301
+ light: transparent(TAB_ACTIVE_BORDER_TOP, 0.7),
302
+ hc: null
303
+ }, localize(
304
+ 'tabActiveUnfocusedBorderTop',
305
+ "Border to the top of an active tab in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
306
+ ));
307
+ const TAB_HOVER_BORDER = registerColor('tab.hoverBorder', {
308
+ dark: null,
309
+ light: null,
310
+ hc: null
311
+ }, localize(
312
+ 'tabHoverBorder',
313
+ "Border to highlight tabs when hovering. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
314
+ ));
315
+ registerColor('tab.unfocusedHoverBorder', {
316
+ dark: transparent(TAB_HOVER_BORDER, 0.5),
317
+ light: transparent(TAB_HOVER_BORDER, 0.7),
318
+ hc: null
319
+ }, localize(
320
+ 'tabUnfocusedHoverBorder',
321
+ "Border to highlight tabs in an unfocused group when hovering. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
322
+ ));
323
+ const TAB_ACTIVE_MODIFIED_BORDER = registerColor('tab.activeModifiedBorder', {
324
+ dark: '#3399CC',
325
+ light: '#33AAEE',
326
+ hc: null
327
+ }, localize(
328
+ 'tabActiveModifiedBorder',
329
+ "Border on the top of modified active tabs in an active group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
330
+ ));
331
+ const TAB_INACTIVE_MODIFIED_BORDER = registerColor('tab.inactiveModifiedBorder', {
332
+ dark: transparent(TAB_ACTIVE_MODIFIED_BORDER, 0.5),
333
+ light: transparent(TAB_ACTIVE_MODIFIED_BORDER, 0.5),
334
+ hc: Color.white
335
+ }, localize(
336
+ 'tabInactiveModifiedBorder',
337
+ "Border on the top of modified inactive tabs in an active group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
338
+ ));
339
+ registerColor('tab.unfocusedActiveModifiedBorder', {
340
+ dark: transparent(TAB_ACTIVE_MODIFIED_BORDER, 0.5),
341
+ light: transparent(TAB_ACTIVE_MODIFIED_BORDER, 0.7),
342
+ hc: Color.white
343
+ }, localize(
344
+ 'unfocusedActiveModifiedBorder',
345
+ "Border on the top of modified active tabs in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
346
+ ));
347
+ registerColor('tab.unfocusedInactiveModifiedBorder', {
348
+ dark: transparent(TAB_INACTIVE_MODIFIED_BORDER, 0.5),
349
+ light: transparent(TAB_INACTIVE_MODIFIED_BORDER, 0.5),
350
+ hc: Color.white
351
+ }, localize(
352
+ 'unfocusedINactiveModifiedBorder',
353
+ "Border on the top of modified inactive tabs in an unfocused group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."
354
+ ));
355
+ registerColor('editorPane.background', {
356
+ dark: editorBackground,
357
+ light: editorBackground,
358
+ hc: editorBackground
359
+ }, localize(
360
+ 'editorPaneBackground',
361
+ "Background color of the editor pane visible on the left and right side of the centered editor layout."
362
+ ));
363
+ registerColor('editorGroup.emptyBackground', {
364
+ dark: null,
365
+ light: null,
366
+ hc: null
367
+ }, localize(
368
+ 'editorGroupEmptyBackground',
369
+ "Background color of an empty editor group. Editor groups are the containers of editors."
370
+ ));
371
+ registerColor('editorGroup.focusedEmptyBorder', {
372
+ dark: null,
373
+ light: null,
374
+ hc: focusBorder
375
+ }, localize(
376
+ 'editorGroupFocusedEmptyBorder',
377
+ "Border color of an empty editor group that is focused. Editor groups are the containers of editors."
378
+ ));
379
+ registerColor('editorGroupHeader.tabsBackground', {
380
+ dark: '#252526',
381
+ light: '#F3F3F3',
382
+ hc: null
383
+ }, localize(
384
+ 'tabsContainerBackground',
385
+ "Background color of the editor group title header when tabs are enabled. Editor groups are the containers of editors."
386
+ ));
387
+ registerColor('editorGroupHeader.tabsBorder', {
388
+ dark: null,
389
+ light: null,
390
+ hc: null
391
+ }, localize(
392
+ 'tabsContainerBorder',
393
+ "Border color of the editor group title header when tabs are enabled. Editor groups are the containers of editors."
394
+ ));
395
+ registerColor('editorGroupHeader.noTabsBackground', {
396
+ dark: editorBackground,
397
+ light: editorBackground,
398
+ hc: editorBackground
399
+ }, localize(
400
+ 'editorGroupHeaderBackground',
401
+ "Background color of the editor group title header when tabs are disabled (`\"workbench.editor.showTabs\": false`). Editor groups are the containers of editors."
402
+ ));
403
+ registerColor('editorGroupHeader.border', {
404
+ dark: null,
405
+ light: null,
406
+ hc: contrastBorder
407
+ }, localize(
408
+ 'editorTitleContainerBorder',
409
+ "Border color of the editor group title header. Editor groups are the containers of editors."
410
+ ));
411
+ const EDITOR_GROUP_BORDER = registerColor('editorGroup.border', {
412
+ dark: '#444444',
413
+ light: '#E7E7E7',
414
+ hc: contrastBorder
415
+ }, localize(
416
+ 'editorGroupBorder',
417
+ "Color to separate multiple editor groups from each other. Editor groups are the containers of editors."
418
+ ));
419
+ const EDITOR_DRAG_AND_DROP_BACKGROUND = registerColor('editorGroup.dropBackground', {
420
+ dark: Color.fromHex('#53595D').transparent(0.5),
421
+ light: Color.fromHex('#2677CB').transparent(0.18),
422
+ hc: null
423
+ }, localize(
424
+ 'editorDragAndDropBackground',
425
+ "Background color when dragging editors around. The color should have transparency so that the editor contents can still shine through."
426
+ ));
427
+ registerColor('sideBySideEditor.horizontalBorder', {
428
+ dark: EDITOR_GROUP_BORDER,
429
+ light: EDITOR_GROUP_BORDER,
430
+ hc: EDITOR_GROUP_BORDER
431
+ }, localize(
432
+ 'sideBySideEditor.horizontalBorder',
433
+ "Color to separate two editors from each other when shown side by side in an editor group from top to bottom."
434
+ ));
435
+ registerColor('sideBySideEditor.verticalBorder', {
436
+ dark: EDITOR_GROUP_BORDER,
437
+ light: EDITOR_GROUP_BORDER,
438
+ hc: EDITOR_GROUP_BORDER
439
+ }, localize(
440
+ 'sideBySideEditor.verticalBorder',
441
+ "Color to separate two editors from each other when shown side by side in an editor group from left to right."
442
+ ));
443
+ registerColor('panel.background', {
444
+ dark: editorBackground,
445
+ light: editorBackground,
446
+ hc: editorBackground
447
+ }, localize(
448
+ 'panelBackground',
449
+ "Panel background color. Panels are shown below the editor area and contain views like output and integrated terminal."
450
+ ));
451
+ const PANEL_BORDER = registerColor('panel.border', {
452
+ dark: Color.fromHex('#808080').transparent(0.35),
453
+ light: Color.fromHex('#808080').transparent(0.35),
454
+ hc: contrastBorder
455
+ }, localize(
456
+ 'panelBorder',
457
+ "Panel border color to separate the panel from the editor. Panels are shown below the editor area and contain views like output and integrated terminal."
458
+ ));
459
+ const PANEL_ACTIVE_TITLE_FOREGROUND = registerColor('panelTitle.activeForeground', {
460
+ dark: '#E7E7E7',
461
+ light: '#424242',
462
+ hc: Color.white
463
+ }, localize(
464
+ 'panelActiveTitleForeground',
465
+ "Title color for the active panel. Panels are shown below the editor area and contain views like output and integrated terminal."
466
+ ));
467
+ registerColor('panelTitle.inactiveForeground', {
468
+ dark: transparent(PANEL_ACTIVE_TITLE_FOREGROUND, 0.6),
469
+ light: transparent(PANEL_ACTIVE_TITLE_FOREGROUND, 0.75),
470
+ hc: Color.white
471
+ }, localize(
472
+ 'panelInactiveTitleForeground',
473
+ "Title color for the inactive panel. Panels are shown below the editor area and contain views like output and integrated terminal."
474
+ ));
475
+ registerColor('panelTitle.activeBorder', {
476
+ dark: PANEL_ACTIVE_TITLE_FOREGROUND,
477
+ light: PANEL_ACTIVE_TITLE_FOREGROUND,
478
+ hc: contrastBorder
479
+ }, localize(
480
+ 'panelActiveTitleBorder',
481
+ "Border color for the active panel title. Panels are shown below the editor area and contain views like output and integrated terminal."
482
+ ));
483
+ registerColor('panelInput.border', {
484
+ dark: null,
485
+ light: Color.fromHex('#ddd'),
486
+ hc: null
487
+ }, localize('panelInputBorder', "Input box border for inputs in the panel."));
488
+ registerColor('panel.dropBorder', {
489
+ dark: PANEL_ACTIVE_TITLE_FOREGROUND,
490
+ light: PANEL_ACTIVE_TITLE_FOREGROUND,
491
+ hc: PANEL_ACTIVE_TITLE_FOREGROUND,
492
+ }, localize(
493
+ 'panelDragAndDropBorder',
494
+ "Drag and drop feedback color for the panel titles. Panels are shown below the editor area and contain views like output and integrated terminal."
495
+ ));
496
+ registerColor('panelSection.dropBackground', {
497
+ dark: EDITOR_DRAG_AND_DROP_BACKGROUND,
498
+ light: EDITOR_DRAG_AND_DROP_BACKGROUND,
499
+ hc: EDITOR_DRAG_AND_DROP_BACKGROUND,
500
+ }, localize(
501
+ 'panelSectionDragAndDropBackground',
502
+ "Drag and drop feedback color for the panel sections. The color should have transparency so that the panel sections can still shine through. Panels are shown below the editor area and contain views like output and integrated terminal. Panel sections are views nested within the panels."
503
+ ));
504
+ registerColor('panelSectionHeader.background', {
505
+ dark: Color.fromHex('#808080').transparent(0.2),
506
+ light: Color.fromHex('#808080').transparent(0.2),
507
+ hc: null
508
+ }, localize(
509
+ 'panelSectionHeaderBackground',
510
+ "Panel section header background color. Panels are shown below the editor area and contain views like output and integrated terminal. Panel sections are views nested within the panels."
511
+ ));
512
+ registerColor('panelSectionHeader.foreground', {
513
+ dark: null,
514
+ light: null,
515
+ hc: null
516
+ }, localize(
517
+ 'panelSectionHeaderForeground',
518
+ "Panel section header foreground color. Panels are shown below the editor area and contain views like output and integrated terminal. Panel sections are views nested within the panels."
519
+ ));
520
+ registerColor('panelSectionHeader.border', {
521
+ dark: contrastBorder,
522
+ light: contrastBorder,
523
+ hc: contrastBorder
524
+ }, localize(
525
+ 'panelSectionHeaderBorder',
526
+ "Panel section header border color used when multiple views are stacked vertically in the panel. Panels are shown below the editor area and contain views like output and integrated terminal. Panel sections are views nested within the panels."
527
+ ));
528
+ registerColor('panelSection.border', {
529
+ dark: PANEL_BORDER,
530
+ light: PANEL_BORDER,
531
+ hc: PANEL_BORDER
532
+ }, localize(
533
+ 'panelSectionBorder',
534
+ "Panel section border color used when multiple views are stacked horizontally in the panel. Panels are shown below the editor area and contain views like output and integrated terminal. Panel sections are views nested within the panels."
535
+ ));
536
+ registerColor('banner.background', {
537
+ dark: listActiveSelectionBackground,
538
+ light: darken(listActiveSelectionBackground, 0.3),
539
+ hc: listActiveSelectionBackground
540
+ }, localize(
541
+ 'banner.background',
542
+ "Banner background color. The banner is shown under the title bar of the window."
543
+ ));
544
+ registerColor('banner.foreground', {
545
+ dark: listActiveSelectionForeground,
546
+ light: listActiveSelectionForeground,
547
+ hc: listActiveSelectionForeground
548
+ }, localize(
549
+ 'banner.foreground',
550
+ "Banner foreground color. The banner is shown under the title bar of the window."
551
+ ));
552
+ registerColor('banner.iconForeground', {
553
+ dark: editorInfoForeground,
554
+ light: editorInfoForeground,
555
+ hc: editorInfoForeground
556
+ }, localize(
557
+ 'banner.iconForeground',
558
+ "Banner icon color. The banner is shown under the title bar of the window."
559
+ ));
560
+ const STATUS_BAR_FOREGROUND = registerColor('statusBar.foreground', {
561
+ dark: '#FFFFFF',
562
+ light: '#FFFFFF',
563
+ hc: '#FFFFFF'
564
+ }, localize(
565
+ 'statusBarForeground',
566
+ "Status bar foreground color when a workspace or folder is opened. The status bar is shown in the bottom of the window."
567
+ ));
568
+ registerColor('statusBar.noFolderForeground', {
569
+ dark: STATUS_BAR_FOREGROUND,
570
+ light: STATUS_BAR_FOREGROUND,
571
+ hc: STATUS_BAR_FOREGROUND
572
+ }, localize(
573
+ 'statusBarNoFolderForeground',
574
+ "Status bar foreground color when no folder is opened. The status bar is shown in the bottom of the window."
575
+ ));
576
+ registerColor('statusBar.background', {
577
+ dark: '#007ACC',
578
+ light: '#007ACC',
579
+ hc: null
580
+ }, localize(
581
+ 'statusBarBackground',
582
+ "Status bar background color when a workspace or folder is opened. The status bar is shown in the bottom of the window."
583
+ ));
584
+ registerColor('statusBar.noFolderBackground', {
585
+ dark: '#68217A',
586
+ light: '#68217A',
587
+ hc: null
588
+ }, localize(
589
+ 'statusBarNoFolderBackground',
590
+ "Status bar background color when no folder is opened. The status bar is shown in the bottom of the window."
591
+ ));
592
+ const STATUS_BAR_BORDER = registerColor('statusBar.border', {
593
+ dark: null,
594
+ light: null,
595
+ hc: contrastBorder
596
+ }, localize(
597
+ 'statusBarBorder',
598
+ "Status bar border color separating to the sidebar and editor. The status bar is shown in the bottom of the window."
599
+ ));
600
+ registerColor('statusBar.focusBorder', {
601
+ dark: STATUS_BAR_FOREGROUND,
602
+ light: STATUS_BAR_FOREGROUND,
603
+ hc: null,
604
+ }, localize(
605
+ 'statusBarFocusBorder',
606
+ "Status bar border color when focused on keyboard navigation. The status bar is shown in the bottom of the window."
607
+ ));
608
+ registerColor('statusBar.noFolderBorder', {
609
+ dark: STATUS_BAR_BORDER,
610
+ light: STATUS_BAR_BORDER,
611
+ hc: STATUS_BAR_BORDER
612
+ }, localize(
613
+ 'statusBarNoFolderBorder',
614
+ "Status bar border color separating to the sidebar and editor when no folder is opened. The status bar is shown in the bottom of the window."
615
+ ));
616
+ registerColor('statusBarItem.activeBackground', {
617
+ dark: Color.white.transparent(0.18),
618
+ light: Color.white.transparent(0.18),
619
+ hc: Color.white.transparent(0.18)
620
+ }, localize(
621
+ 'statusBarItemActiveBackground',
622
+ "Status bar item background color when clicking. The status bar is shown in the bottom of the window."
623
+ ));
624
+ registerColor('statusBarItem.focusBorder', {
625
+ dark: STATUS_BAR_FOREGROUND,
626
+ light: STATUS_BAR_FOREGROUND,
627
+ hc: null,
628
+ }, localize(
629
+ 'statusBarItemFocusBorder',
630
+ "Status bar item border color when focused on keyboard navigation. The status bar is shown in the bottom of the window."
631
+ ));
632
+ registerColor('statusBarItem.hoverBackground', {
633
+ dark: Color.white.transparent(0.12),
634
+ light: Color.white.transparent(0.12),
635
+ hc: Color.white.transparent(0.12)
636
+ }, localize(
637
+ 'statusBarItemHoverBackground',
638
+ "Status bar item background color when hovering. The status bar is shown in the bottom of the window."
639
+ ));
640
+ registerColor('statusBarItem.compactHoverBackground', {
641
+ dark: Color.white.transparent(0.20),
642
+ light: Color.white.transparent(0.20),
643
+ hc: Color.white.transparent(0.20)
644
+ }, localize(
645
+ 'statusBarItemCompactHoverBackground',
646
+ "Status bar item background color when hovering an item that contains two hovers. The status bar is shown in the bottom of the window."
647
+ ));
648
+ registerColor('statusBarItem.prominentForeground', {
649
+ dark: STATUS_BAR_FOREGROUND,
650
+ light: STATUS_BAR_FOREGROUND,
651
+ hc: STATUS_BAR_FOREGROUND
652
+ }, localize(
653
+ 'statusBarProminentItemForeground',
654
+ "Status bar prominent items foreground color. Prominent items stand out from other status bar entries to indicate importance. Change mode `Toggle Tab Key Moves Focus` from command palette to see an example. The status bar is shown in the bottom of the window."
655
+ ));
656
+ registerColor('statusBarItem.prominentBackground', {
657
+ dark: Color.black.transparent(0.5),
658
+ light: Color.black.transparent(0.5),
659
+ hc: Color.black.transparent(0.5),
660
+ }, localize(
661
+ 'statusBarProminentItemBackground',
662
+ "Status bar prominent items background color. Prominent items stand out from other status bar entries to indicate importance. Change mode `Toggle Tab Key Moves Focus` from command palette to see an example. The status bar is shown in the bottom of the window."
663
+ ));
664
+ registerColor('statusBarItem.prominentHoverBackground', {
665
+ dark: Color.black.transparent(0.3),
666
+ light: Color.black.transparent(0.3),
667
+ hc: Color.black.transparent(0.3),
668
+ }, localize(
669
+ 'statusBarProminentItemHoverBackground',
670
+ "Status bar prominent items background color when hovering. Prominent items stand out from other status bar entries to indicate importance. Change mode `Toggle Tab Key Moves Focus` from command palette to see an example. The status bar is shown in the bottom of the window."
671
+ ));
672
+ registerColor('statusBarItem.errorBackground', {
673
+ dark: darken(errorForeground, .4),
674
+ light: darken(errorForeground, .4),
675
+ hc: null,
676
+ }, localize(
677
+ 'statusBarErrorItemBackground',
678
+ "Status bar error items background color. Error items stand out from other status bar entries to indicate error conditions. The status bar is shown in the bottom of the window."
679
+ ));
680
+ registerColor('statusBarItem.errorForeground', {
681
+ dark: Color.white,
682
+ light: Color.white,
683
+ hc: Color.white,
684
+ }, localize(
685
+ 'statusBarErrorItemForeground',
686
+ "Status bar error items foreground color. Error items stand out from other status bar entries to indicate error conditions. The status bar is shown in the bottom of the window."
687
+ ));
688
+ registerColor('statusBarItem.warningBackground', {
689
+ dark: darken(editorWarningForeground, .4),
690
+ light: darken(editorWarningForeground, .4),
691
+ hc: null,
692
+ }, localize(
693
+ 'statusBarWarningItemBackground',
694
+ "Status bar warning items background color. Warning items stand out from other status bar entries to indicate warning conditions. The status bar is shown in the bottom of the window."
695
+ ));
696
+ registerColor('statusBarItem.warningForeground', {
697
+ dark: Color.white,
698
+ light: Color.white,
699
+ hc: Color.white,
700
+ }, localize(
701
+ 'statusBarWarningItemForeground',
702
+ "Status bar warning items foreground color. Warning items stand out from other status bar entries to indicate warning conditions. The status bar is shown in the bottom of the window."
703
+ ));
704
+ registerColor('activityBar.background', {
705
+ dark: '#333333',
706
+ light: '#2C2C2C',
707
+ hc: '#000000'
708
+ }, localize(
709
+ 'activityBarBackground',
710
+ "Activity bar background color. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
711
+ ));
712
+ const ACTIVITY_BAR_FOREGROUND = registerColor('activityBar.foreground', {
713
+ dark: Color.white,
714
+ light: Color.white,
715
+ hc: Color.white
716
+ }, localize(
717
+ 'activityBarForeground',
718
+ "Activity bar item foreground color when it is active. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
719
+ ));
720
+ registerColor('activityBar.inactiveForeground', {
721
+ dark: transparent(ACTIVITY_BAR_FOREGROUND, 0.4),
722
+ light: transparent(ACTIVITY_BAR_FOREGROUND, 0.4),
723
+ hc: Color.white
724
+ }, localize(
725
+ 'activityBarInActiveForeground',
726
+ "Activity bar item foreground color when it is inactive. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
727
+ ));
728
+ registerColor('activityBar.border', {
729
+ dark: null,
730
+ light: null,
731
+ hc: contrastBorder
732
+ }, localize(
733
+ 'activityBarBorder',
734
+ "Activity bar border color separating to the side bar. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
735
+ ));
736
+ registerColor('activityBar.activeBorder', {
737
+ dark: ACTIVITY_BAR_FOREGROUND,
738
+ light: ACTIVITY_BAR_FOREGROUND,
739
+ hc: null
740
+ }, localize(
741
+ 'activityBarActiveBorder',
742
+ "Activity bar border color for the active item. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
743
+ ));
744
+ registerColor('activityBar.activeFocusBorder', {
745
+ dark: null,
746
+ light: null,
747
+ hc: null
748
+ }, localize(
749
+ 'activityBarActiveFocusBorder',
750
+ "Activity bar focus border color for the active item. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
751
+ ));
752
+ registerColor('activityBar.activeBackground', {
753
+ dark: null,
754
+ light: null,
755
+ hc: null
756
+ }, localize(
757
+ 'activityBarActiveBackground',
758
+ "Activity bar background color for the active item. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
759
+ ));
760
+ registerColor('activityBar.dropBorder', {
761
+ dark: ACTIVITY_BAR_FOREGROUND,
762
+ light: ACTIVITY_BAR_FOREGROUND,
763
+ hc: ACTIVITY_BAR_FOREGROUND,
764
+ }, localize(
765
+ 'activityBarDragAndDropBorder',
766
+ "Drag and drop feedback color for the activity bar items. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
767
+ ));
768
+ const ACTIVITY_BAR_BADGE_BACKGROUND = registerColor('activityBarBadge.background', {
769
+ dark: '#007ACC',
770
+ light: '#007ACC',
771
+ hc: '#000000'
772
+ }, localize(
773
+ 'activityBarBadgeBackground',
774
+ "Activity notification badge background color. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
775
+ ));
776
+ const ACTIVITY_BAR_BADGE_FOREGROUND = registerColor('activityBarBadge.foreground', {
777
+ dark: Color.white,
778
+ light: Color.white,
779
+ hc: Color.white
780
+ }, localize(
781
+ 'activityBarBadgeForeground',
782
+ "Activity notification badge foreground color. The activity bar is showing on the far left or right and allows to switch between views of the side bar."
783
+ ));
784
+ registerColor('statusBarItem.remoteBackground', {
785
+ dark: ACTIVITY_BAR_BADGE_BACKGROUND,
786
+ light: ACTIVITY_BAR_BADGE_BACKGROUND,
787
+ hc: ACTIVITY_BAR_BADGE_BACKGROUND
788
+ }, localize(
789
+ 'statusBarItemHostBackground',
790
+ "Background color for the remote indicator on the status bar."
791
+ ));
792
+ registerColor('statusBarItem.remoteForeground', {
793
+ dark: ACTIVITY_BAR_BADGE_FOREGROUND,
794
+ light: ACTIVITY_BAR_BADGE_FOREGROUND,
795
+ hc: ACTIVITY_BAR_BADGE_FOREGROUND
796
+ }, localize(
797
+ 'statusBarItemHostForeground',
798
+ "Foreground color for the remote indicator on the status bar."
799
+ ));
800
+ registerColor('extensionBadge.remoteBackground', {
801
+ dark: ACTIVITY_BAR_BADGE_BACKGROUND,
802
+ light: ACTIVITY_BAR_BADGE_BACKGROUND,
803
+ hc: ACTIVITY_BAR_BADGE_BACKGROUND
804
+ }, localize(
805
+ 'extensionBadge.remoteBackground',
806
+ "Background color for the remote badge in the extensions view."
807
+ ));
808
+ registerColor('extensionBadge.remoteForeground', {
809
+ dark: ACTIVITY_BAR_BADGE_FOREGROUND,
810
+ light: ACTIVITY_BAR_BADGE_FOREGROUND,
811
+ hc: ACTIVITY_BAR_BADGE_FOREGROUND
812
+ }, localize(
813
+ 'extensionBadge.remoteForeground',
814
+ "Foreground color for the remote badge in the extensions view."
815
+ ));
816
+ registerColor('sideBar.background', {
817
+ dark: '#252526',
818
+ light: '#F3F3F3',
819
+ hc: '#000000'
820
+ }, localize(
821
+ 'sideBarBackground',
822
+ "Side bar background color. The side bar is the container for views like explorer and search."
823
+ ));
824
+ const SIDE_BAR_FOREGROUND = registerColor('sideBar.foreground', {
825
+ dark: null,
826
+ light: null,
827
+ hc: null
828
+ }, localize(
829
+ 'sideBarForeground',
830
+ "Side bar foreground color. The side bar is the container for views like explorer and search."
831
+ ));
832
+ registerColor('sideBar.border', {
833
+ dark: null,
834
+ light: null,
835
+ hc: contrastBorder
836
+ }, localize(
837
+ 'sideBarBorder',
838
+ "Side bar border color on the side separating to the editor. The side bar is the container for views like explorer and search."
839
+ ));
840
+ registerColor('sideBarTitle.foreground', {
841
+ dark: SIDE_BAR_FOREGROUND,
842
+ light: SIDE_BAR_FOREGROUND,
843
+ hc: SIDE_BAR_FOREGROUND
844
+ }, localize(
845
+ 'sideBarTitleForeground',
846
+ "Side bar title foreground color. The side bar is the container for views like explorer and search."
847
+ ));
848
+ registerColor('sideBar.dropBackground', {
849
+ dark: EDITOR_DRAG_AND_DROP_BACKGROUND,
850
+ light: EDITOR_DRAG_AND_DROP_BACKGROUND,
851
+ hc: EDITOR_DRAG_AND_DROP_BACKGROUND,
852
+ }, localize(
853
+ 'sideBarDragAndDropBackground',
854
+ "Drag and drop feedback color for the side bar sections. The color should have transparency so that the side bar sections can still shine through. The side bar is the container for views like explorer and search. Side bar sections are views nested within the side bar."
855
+ ));
856
+ registerColor('sideBarSectionHeader.background', {
857
+ dark: Color.fromHex('#808080').transparent(0.2),
858
+ light: Color.fromHex('#808080').transparent(0.2),
859
+ hc: null
860
+ }, localize(
861
+ 'sideBarSectionHeaderBackground',
862
+ "Side bar section header background color. The side bar is the container for views like explorer and search. Side bar sections are views nested within the side bar."
863
+ ));
864
+ registerColor('sideBarSectionHeader.foreground', {
865
+ dark: SIDE_BAR_FOREGROUND,
866
+ light: SIDE_BAR_FOREGROUND,
867
+ hc: SIDE_BAR_FOREGROUND
868
+ }, localize(
869
+ 'sideBarSectionHeaderForeground',
870
+ "Side bar section header foreground color. The side bar is the container for views like explorer and search. Side bar sections are views nested within the side bar."
871
+ ));
872
+ registerColor('sideBarSectionHeader.border', {
873
+ dark: contrastBorder,
874
+ light: contrastBorder,
875
+ hc: contrastBorder
876
+ }, localize(
877
+ 'sideBarSectionHeaderBorder',
878
+ "Side bar section header border color. The side bar is the container for views like explorer and search. Side bar sections are views nested within the side bar."
879
+ ));
880
+ const TITLE_BAR_ACTIVE_FOREGROUND = registerColor('titleBar.activeForeground', {
881
+ dark: '#CCCCCC',
882
+ light: '#333333',
883
+ hc: '#FFFFFF'
884
+ }, localize(
885
+ 'titleBarActiveForeground',
886
+ "Title bar foreground when the window is active."
887
+ ));
888
+ registerColor('titleBar.inactiveForeground', {
889
+ dark: transparent(TITLE_BAR_ACTIVE_FOREGROUND, 0.6),
890
+ light: transparent(TITLE_BAR_ACTIVE_FOREGROUND, 0.6),
891
+ hc: null
892
+ }, localize(
893
+ 'titleBarInactiveForeground',
894
+ "Title bar foreground when the window is inactive."
895
+ ));
896
+ const TITLE_BAR_ACTIVE_BACKGROUND = registerColor('titleBar.activeBackground', {
897
+ dark: '#3C3C3C',
898
+ light: '#DDDDDD',
899
+ hc: '#000000'
900
+ }, localize(
901
+ 'titleBarActiveBackground',
902
+ "Title bar background when the window is active."
903
+ ));
904
+ registerColor('titleBar.inactiveBackground', {
905
+ dark: transparent(TITLE_BAR_ACTIVE_BACKGROUND, 0.6),
906
+ light: transparent(TITLE_BAR_ACTIVE_BACKGROUND, 0.6),
907
+ hc: null
908
+ }, localize(
909
+ 'titleBarInactiveBackground',
910
+ "Title bar background when the window is inactive."
911
+ ));
912
+ registerColor('titleBar.border', {
913
+ dark: null,
914
+ light: null,
915
+ hc: contrastBorder
916
+ }, localize('titleBarBorder', "Title bar border color."));
917
+ registerColor('menubar.selectionForeground', {
918
+ dark: TITLE_BAR_ACTIVE_FOREGROUND,
919
+ light: TITLE_BAR_ACTIVE_FOREGROUND,
920
+ hc: TITLE_BAR_ACTIVE_FOREGROUND
921
+ }, localize(
922
+ 'menubarSelectionForeground',
923
+ "Foreground color of the selected menu item in the menubar."
924
+ ));
925
+ registerColor('menubar.selectionBackground', {
926
+ dark: transparent(Color.white, 0.1),
927
+ light: transparent(Color.black, 0.1),
928
+ hc: null
929
+ }, localize(
930
+ 'menubarSelectionBackground',
931
+ "Background color of the selected menu item in the menubar."
932
+ ));
933
+ registerColor('menubar.selectionBorder', {
934
+ dark: null,
935
+ light: null,
936
+ hc: activeContrastBorder
937
+ }, localize(
938
+ 'menubarSelectionBorder',
939
+ "Border color of the selected menu item in the menubar."
940
+ ));
941
+ registerColor('notificationCenter.border', {
942
+ dark: null,
943
+ light: null,
944
+ hc: contrastBorder
945
+ }, localize(
946
+ 'notificationCenterBorder',
947
+ "Notifications center border color. Notifications slide in from the bottom right of the window."
948
+ ));
949
+ const NOTIFICATIONS_TOAST_BORDER = registerColor('notificationToast.border', {
950
+ dark: null,
951
+ light: null,
952
+ hc: contrastBorder
953
+ }, localize(
954
+ 'notificationToastBorder',
955
+ "Notification toast border color. Notifications slide in from the bottom right of the window."
956
+ ));
957
+ const NOTIFICATIONS_FOREGROUND = registerColor('notifications.foreground', {
958
+ dark: editorWidgetForeground,
959
+ light: editorWidgetForeground,
960
+ hc: editorWidgetForeground
961
+ }, localize(
962
+ 'notificationsForeground',
963
+ "Notifications foreground color. Notifications slide in from the bottom right of the window."
964
+ ));
965
+ const NOTIFICATIONS_BACKGROUND = registerColor('notifications.background', {
966
+ dark: editorWidgetBackground,
967
+ light: editorWidgetBackground,
968
+ hc: editorWidgetBackground
969
+ }, localize(
970
+ 'notificationsBackground',
971
+ "Notifications background color. Notifications slide in from the bottom right of the window."
972
+ ));
973
+ const NOTIFICATIONS_LINKS = registerColor('notificationLink.foreground', {
974
+ dark: textLinkForeground,
975
+ light: textLinkForeground,
976
+ hc: textLinkForeground
977
+ }, localize(
978
+ 'notificationsLink',
979
+ "Notification links foreground color. Notifications slide in from the bottom right of the window."
980
+ ));
981
+ registerColor('notificationCenterHeader.foreground', {
982
+ dark: null,
983
+ light: null,
984
+ hc: null
985
+ }, localize(
986
+ 'notificationCenterHeaderForeground',
987
+ "Notifications center header foreground color. Notifications slide in from the bottom right of the window."
988
+ ));
989
+ const NOTIFICATIONS_CENTER_HEADER_BACKGROUND = registerColor('notificationCenterHeader.background', {
990
+ dark: lighten(NOTIFICATIONS_BACKGROUND, 0.3),
991
+ light: darken(NOTIFICATIONS_BACKGROUND, 0.05),
992
+ hc: NOTIFICATIONS_BACKGROUND
993
+ }, localize(
994
+ 'notificationCenterHeaderBackground',
995
+ "Notifications center header background color. Notifications slide in from the bottom right of the window."
996
+ ));
997
+ registerColor('notifications.border', {
998
+ dark: NOTIFICATIONS_CENTER_HEADER_BACKGROUND,
999
+ light: NOTIFICATIONS_CENTER_HEADER_BACKGROUND,
1000
+ hc: NOTIFICATIONS_CENTER_HEADER_BACKGROUND
1001
+ }, localize(
1002
+ 'notificationsBorder',
1003
+ "Notifications border color separating from other notifications in the notifications center. Notifications slide in from the bottom right of the window."
1004
+ ));
1005
+ const NOTIFICATIONS_ERROR_ICON_FOREGROUND = registerColor('notificationsErrorIcon.foreground', {
1006
+ dark: editorErrorForeground,
1007
+ light: editorErrorForeground,
1008
+ hc: editorErrorForeground
1009
+ }, localize(
1010
+ 'notificationsErrorIconForeground',
1011
+ "The color used for the icon of error notifications. Notifications slide in from the bottom right of the window."
1012
+ ));
1013
+ const NOTIFICATIONS_WARNING_ICON_FOREGROUND = registerColor('notificationsWarningIcon.foreground', {
1014
+ dark: editorWarningForeground,
1015
+ light: editorWarningForeground,
1016
+ hc: editorWarningForeground
1017
+ }, localize(
1018
+ 'notificationsWarningIconForeground',
1019
+ "The color used for the icon of warning notifications. Notifications slide in from the bottom right of the window."
1020
+ ));
1021
+ const NOTIFICATIONS_INFO_ICON_FOREGROUND = registerColor('notificationsInfoIcon.foreground', {
1022
+ dark: editorInfoForeground,
1023
+ light: editorInfoForeground,
1024
+ hc: editorInfoForeground
1025
+ }, localize(
1026
+ 'notificationsInfoIconForeground',
1027
+ "The color used for the icon of info notifications. Notifications slide in from the bottom right of the window."
1028
+ ));
1029
+ registerColor('window.activeBorder', {
1030
+ dark: null,
1031
+ light: null,
1032
+ hc: contrastBorder
1033
+ }, localize(
1034
+ 'windowActiveBorder',
1035
+ "The color used for the border of the window when it is active. Only supported in the desktop client when using the custom title bar."
1036
+ ));
1037
+ registerColor('window.inactiveBorder', {
1038
+ dark: null,
1039
+ light: null,
1040
+ hc: contrastBorder
1041
+ }, localize(
1042
+ 'windowInactiveBorder',
1043
+ "The color used for the border of the window when it is inactive. Only supported in the desktop client when using the custom title bar."
1044
+ ));
1045
+ const defaultOptions = {
1046
+ buttonBackground: Color.fromHex('#0E639C'),
1047
+ buttonHoverBackground: Color.fromHex('#006BB3'),
1048
+ buttonForeground: Color.white
1049
+ };
1050
+ class Button extends Disposable {
1051
+ constructor(container, options) {
1052
+ super();
1053
+ this._onDidClick = this._register( new Emitter());
1054
+ this.options = options || Object.create(null);
1055
+ mixin(this.options, defaultOptions, false);
1056
+ this.buttonForeground = this.options.buttonForeground;
1057
+ this.buttonBackground = this.options.buttonBackground;
1058
+ this.buttonHoverBackground = this.options.buttonHoverBackground;
1059
+ this.buttonSecondaryForeground = this.options.buttonSecondaryForeground;
1060
+ this.buttonSecondaryBackground = this.options.buttonSecondaryBackground;
1061
+ this.buttonSecondaryHoverBackground = this.options.buttonSecondaryHoverBackground;
1062
+ this.buttonBorder = this.options.buttonBorder;
1063
+ this._element = document.createElement('a');
1064
+ this._element.classList.add('monaco-button');
1065
+ this._element.tabIndex = 0;
1066
+ this._element.setAttribute('role', 'button');
1067
+ container.appendChild(this._element);
1068
+ this._register(Gesture.addTarget(this._element));
1069
+ [EventType.CLICK, EventType$1.Tap].forEach(eventType => {
1070
+ this._register(addDisposableListener(this._element, eventType, e => {
1071
+ if (!this.enabled) {
1072
+ EventHelper.stop(e);
1073
+ return;
1074
+ }
1075
+ this._onDidClick.fire(e);
1076
+ }));
1077
+ });
1078
+ this._register(addDisposableListener(this._element, EventType.KEY_DOWN, e => {
1079
+ const event = new StandardKeyboardEvent(e);
1080
+ let eventHandled = false;
1081
+ if (this.enabled && (event.equals(3 ) || event.equals(10 ))) {
1082
+ this._onDidClick.fire(e);
1083
+ eventHandled = true;
1084
+ }
1085
+ else if (event.equals(9 )) {
1086
+ this._element.blur();
1087
+ eventHandled = true;
1088
+ }
1089
+ if (eventHandled) {
1090
+ EventHelper.stop(event, true);
1091
+ }
1092
+ }));
1093
+ this._register(addDisposableListener(this._element, EventType.MOUSE_OVER, e => {
1094
+ if (!this._element.classList.contains('disabled')) {
1095
+ this.setHoverBackground();
1096
+ }
1097
+ }));
1098
+ this._register(addDisposableListener(this._element, EventType.MOUSE_OUT, e => {
1099
+ this.applyStyles();
1100
+ }));
1101
+ this.focusTracker = this._register(trackFocus(this._element));
1102
+ this._register(this.focusTracker.onDidFocus(() => this.setHoverBackground()));
1103
+ this._register(this.focusTracker.onDidBlur(() => this.applyStyles()));
1104
+ this.applyStyles();
1105
+ }
1106
+ get onDidClick() { return this._onDidClick.event; }
1107
+ setHoverBackground() {
1108
+ let hoverBackground;
1109
+ if (this.options.secondary) {
1110
+ hoverBackground = this.buttonSecondaryHoverBackground ? this.buttonSecondaryHoverBackground.toString() : null;
1111
+ }
1112
+ else {
1113
+ hoverBackground = this.buttonHoverBackground ? this.buttonHoverBackground.toString() : null;
1114
+ }
1115
+ if (hoverBackground) {
1116
+ this._element.style.backgroundColor = hoverBackground;
1117
+ }
1118
+ }
1119
+ style(styles) {
1120
+ this.buttonForeground = styles.buttonForeground;
1121
+ this.buttonBackground = styles.buttonBackground;
1122
+ this.buttonHoverBackground = styles.buttonHoverBackground;
1123
+ this.buttonSecondaryForeground = styles.buttonSecondaryForeground;
1124
+ this.buttonSecondaryBackground = styles.buttonSecondaryBackground;
1125
+ this.buttonSecondaryHoverBackground = styles.buttonSecondaryHoverBackground;
1126
+ this.buttonBorder = styles.buttonBorder;
1127
+ this.applyStyles();
1128
+ }
1129
+ applyStyles() {
1130
+ if (this._element) {
1131
+ let background, foreground;
1132
+ if (this.options.secondary) {
1133
+ foreground = this.buttonSecondaryForeground ? this.buttonSecondaryForeground.toString() : '';
1134
+ background = this.buttonSecondaryBackground ? this.buttonSecondaryBackground.toString() : '';
1135
+ }
1136
+ else {
1137
+ foreground = this.buttonForeground ? this.buttonForeground.toString() : '';
1138
+ background = this.buttonBackground ? this.buttonBackground.toString() : '';
1139
+ }
1140
+ const border = this.buttonBorder ? this.buttonBorder.toString() : '';
1141
+ this._element.style.color = foreground;
1142
+ this._element.style.backgroundColor = background;
1143
+ this._element.style.borderWidth = border ? '1px' : '';
1144
+ this._element.style.borderStyle = border ? 'solid' : '';
1145
+ this._element.style.borderColor = border;
1146
+ }
1147
+ }
1148
+ get element() {
1149
+ return this._element;
1150
+ }
1151
+ set label(value) {
1152
+ this._element.classList.add('monaco-text-button');
1153
+ if (this.options.supportIcons) {
1154
+ reset(this._element, ...renderLabelWithIcons(value));
1155
+ }
1156
+ else {
1157
+ this._element.textContent = value;
1158
+ }
1159
+ if (typeof this.options.title === 'string') {
1160
+ this._element.title = this.options.title;
1161
+ }
1162
+ else if (this.options.title) {
1163
+ this._element.title = value;
1164
+ }
1165
+ }
1166
+ set icon(icon) {
1167
+ this._element.classList.add(...CSSIcon.asClassNameArray(icon));
1168
+ }
1169
+ set enabled(value) {
1170
+ if (value) {
1171
+ this._element.classList.remove('disabled');
1172
+ this._element.setAttribute('aria-disabled', String(false));
1173
+ this._element.tabIndex = 0;
1174
+ }
1175
+ else {
1176
+ this._element.classList.add('disabled');
1177
+ this._element.setAttribute('aria-disabled', String(true));
1178
+ }
1179
+ }
1180
+ get enabled() {
1181
+ return !this._element.classList.contains('disabled');
1182
+ }
1183
+ focus() {
1184
+ this._element.focus();
1185
+ }
1186
+ hasFocus() {
1187
+ return this._element === document.activeElement;
1188
+ }
1189
+ }
1190
+ class ButtonWithDropdown extends Disposable {
1191
+ constructor(container, options) {
1192
+ super();
1193
+ this._onDidClick = this._register( new Emitter());
1194
+ this.onDidClick = this._onDidClick.event;
1195
+ this.element = document.createElement('div');
1196
+ this.element.classList.add('monaco-button-dropdown');
1197
+ container.appendChild(this.element);
1198
+ this.button = this._register( new Button(this.element, options));
1199
+ this._register(this.button.onDidClick(e => this._onDidClick.fire(e)));
1200
+ this.action = this._register( new Action(
1201
+ 'primaryAction',
1202
+ this.button.label,
1203
+ undefined,
1204
+ true,
1205
+ async () => this._onDidClick.fire(undefined)
1206
+ ));
1207
+ this.dropdownButton = this._register( new Button(this.element, { ...options, title: false, supportIcons: true }));
1208
+ this.dropdownButton.element.classList.add('monaco-dropdown-button');
1209
+ this.dropdownButton.icon = Codicon.dropDownButton;
1210
+ this._register(this.dropdownButton.onDidClick(e => {
1211
+ options.contextMenuProvider.showContextMenu({
1212
+ getAnchor: () => this.dropdownButton.element,
1213
+ getActions: () => [this.action, ...options.actions],
1214
+ actionRunner: options.actionRunner,
1215
+ onHide: () => this.dropdownButton.element.setAttribute('aria-expanded', 'false')
1216
+ });
1217
+ this.dropdownButton.element.setAttribute('aria-expanded', 'true');
1218
+ }));
1219
+ }
1220
+ set label(value) {
1221
+ this.button.label = value;
1222
+ this.action.label = value;
1223
+ }
1224
+ set icon(icon) {
1225
+ this.button.icon = icon;
1226
+ }
1227
+ set enabled(enabled) {
1228
+ this.button.enabled = enabled;
1229
+ this.dropdownButton.enabled = enabled;
1230
+ }
1231
+ get enabled() {
1232
+ return this.button.enabled;
1233
+ }
1234
+ style(styles) {
1235
+ this.button.style(styles);
1236
+ this.dropdownButton.style(styles);
1237
+ }
1238
+ focus() {
1239
+ this.button.focus();
1240
+ }
1241
+ hasFocus() {
1242
+ return this.button.hasFocus() || this.dropdownButton.hasFocus();
1243
+ }
1244
+ }
1245
+ class ButtonWithDescription extends Button {
1246
+ constructor(container, options) {
1247
+ super(container, options);
1248
+ this._element.classList.add('monaco-description-button');
1249
+ this._labelElement = document.createElement('div');
1250
+ this._labelElement.classList.add('monaco-button-label');
1251
+ this._labelElement.tabIndex = -1;
1252
+ this._element.appendChild(this._labelElement);
1253
+ this._descriptionElement = document.createElement('div');
1254
+ this._descriptionElement.classList.add('monaco-button-description');
1255
+ this._descriptionElement.tabIndex = -1;
1256
+ this._element.appendChild(this._descriptionElement);
1257
+ }
1258
+ set label(value) {
1259
+ this._element.classList.add('monaco-text-button');
1260
+ if (this.options.supportIcons) {
1261
+ reset(this._labelElement, ...renderLabelWithIcons(value));
1262
+ }
1263
+ else {
1264
+ this._labelElement.textContent = value;
1265
+ }
1266
+ if (typeof this.options.title === 'string') {
1267
+ this._element.title = this.options.title;
1268
+ }
1269
+ else if (this.options.title) {
1270
+ this._element.title = value;
1271
+ }
1272
+ }
1273
+ set description(value) {
1274
+ if (this.options.supportIcons) {
1275
+ reset(this._descriptionElement, ...renderLabelWithIcons(value));
1276
+ }
1277
+ else {
1278
+ this._descriptionElement.textContent = value;
1279
+ }
1280
+ }
1281
+ }
1282
+ class ButtonBar extends Disposable {
1283
+ constructor(container) {
1284
+ super();
1285
+ this.container = container;
1286
+ this._buttons = [];
1287
+ }
1288
+ get buttons() {
1289
+ return this._buttons;
1290
+ }
1291
+ addButton(options) {
1292
+ const button = this._register( new Button(this.container, options));
1293
+ this.pushButton(button);
1294
+ return button;
1295
+ }
1296
+ addButtonWithDescription(options) {
1297
+ const button = this._register( new ButtonWithDescription(this.container, options));
1298
+ this.pushButton(button);
1299
+ return button;
1300
+ }
1301
+ addButtonWithDropdown(options) {
1302
+ const button = this._register( new ButtonWithDropdown(this.container, options));
1303
+ this.pushButton(button);
1304
+ return button;
1305
+ }
1306
+ pushButton(button) {
1307
+ this._buttons.push(button);
1308
+ const index = this._buttons.length - 1;
1309
+ this._register(addDisposableListener(button.element, EventType.KEY_DOWN, e => {
1310
+ const event = new StandardKeyboardEvent(e);
1311
+ let eventHandled = true;
1312
+ let buttonIndexToFocus;
1313
+ if (event.equals(15 )) {
1314
+ buttonIndexToFocus = index > 0 ? index - 1 : this._buttons.length - 1;
1315
+ }
1316
+ else if (event.equals(17 )) {
1317
+ buttonIndexToFocus = index === this._buttons.length - 1 ? 0 : index + 1;
1318
+ }
1319
+ else {
1320
+ eventHandled = false;
1321
+ }
1322
+ if (eventHandled && typeof buttonIndexToFocus === 'number') {
1323
+ this._buttons[buttonIndexToFocus].focus();
1324
+ EventHelper.stop(e, true);
1325
+ }
1326
+ }));
1327
+ }
1328
+ }
1329
+ class LinkedText {
1330
+ constructor(nodes) {
1331
+ this.nodes = nodes;
1332
+ }
1333
+ toString() {
1334
+ return this.nodes.map(node => typeof node === 'string' ? node : node.label).join('');
1335
+ }
1336
+ }
1337
+ const LINK_REGEX = /\[([^\]]+)\]\(((?:https?:\/\/|command:|file:)[^\)\s]+)(?: ("|')([^\3]+)(\3))?\)/gi;
1338
+ function parseLinkedText(text) {
1339
+ const result = [];
1340
+ let index = 0;
1341
+ let match;
1342
+ while (match = LINK_REGEX.exec(text)) {
1343
+ if (match.index - index > 0) {
1344
+ result.push(text.substring(index, match.index));
1345
+ }
1346
+ const [, label, href, , title] = match;
1347
+ if (title) {
1348
+ result.push({ label, href, title });
1349
+ }
1350
+ else {
1351
+ result.push({ label, href });
1352
+ }
1353
+ index = match.index + match[0].length;
1354
+ }
1355
+ if (index < text.length) {
1356
+ result.push(text.substring(index));
1357
+ }
1358
+ return (
1359
+ new LinkedText(result)
1360
+ );
1361
+ }
1362
+ class NotificationHandle extends Disposable {
1363
+ constructor(item, onClose) {
1364
+ super();
1365
+ this.item = item;
1366
+ this.onClose = onClose;
1367
+ this._onDidClose = this._register( new Emitter());
1368
+ this.onDidClose = this._onDidClose.event;
1369
+ this._onDidChangeVisibility = this._register( new Emitter());
1370
+ this.onDidChangeVisibility = this._onDidChangeVisibility.event;
1371
+ this.registerListeners();
1372
+ }
1373
+ registerListeners() {
1374
+ this._register(this.item.onDidChangeVisibility(visible => this._onDidChangeVisibility.fire(visible)));
1375
+ Event.once(this.item.onDidClose)(() => {
1376
+ this._onDidClose.fire();
1377
+ this.dispose();
1378
+ });
1379
+ }
1380
+ get progress() {
1381
+ return this.item.progress;
1382
+ }
1383
+ updateSeverity(severity) {
1384
+ this.item.updateSeverity(severity);
1385
+ }
1386
+ updateMessage(message) {
1387
+ this.item.updateMessage(message);
1388
+ }
1389
+ updateActions(actions) {
1390
+ this.item.updateActions(actions);
1391
+ }
1392
+ close() {
1393
+ this.onClose(this.item);
1394
+ this.dispose();
1395
+ }
1396
+ }
1397
+ class NotificationsModel extends Disposable {
1398
+ constructor() {
1399
+ super(...arguments);
1400
+ this._onDidChangeNotification = this._register( new Emitter());
1401
+ this.onDidChangeNotification = this._onDidChangeNotification.event;
1402
+ this._onDidChangeStatusMessage = this._register( new Emitter());
1403
+ this.onDidChangeStatusMessage = this._onDidChangeStatusMessage.event;
1404
+ this._onDidChangeFilter = this._register( new Emitter());
1405
+ this.onDidChangeFilter = this._onDidChangeFilter.event;
1406
+ this._notifications = [];
1407
+ this.filter = NotificationsFilter.OFF;
1408
+ }
1409
+ get notifications() { return this._notifications; }
1410
+ get statusMessage() { return this._statusMessage; }
1411
+ setFilter(filter) {
1412
+ this.filter = filter;
1413
+ this._onDidChangeFilter.fire(filter);
1414
+ }
1415
+ addNotification(notification) {
1416
+ const item = this.createViewItem(notification);
1417
+ if (!item) {
1418
+ return NotificationsModel.NO_OP_NOTIFICATION;
1419
+ }
1420
+ const duplicate = this.findNotification(item);
1421
+ if (duplicate) {
1422
+ duplicate.close();
1423
+ }
1424
+ this._notifications.splice(0, 0, item);
1425
+ this._onDidChangeNotification.fire({ item, index: 0, kind: 0 });
1426
+ return (
1427
+ new NotificationHandle(item, item => this.onClose(item))
1428
+ );
1429
+ }
1430
+ onClose(item) {
1431
+ const liveItem = this.findNotification(item);
1432
+ if (liveItem && liveItem !== item) {
1433
+ liveItem.close();
1434
+ }
1435
+ else {
1436
+ item.close();
1437
+ }
1438
+ }
1439
+ findNotification(item) {
1440
+ return this._notifications.find(notification => notification.equals(item));
1441
+ }
1442
+ createViewItem(notification) {
1443
+ const item = NotificationViewItem.create(notification, this.filter);
1444
+ if (!item) {
1445
+ return undefined;
1446
+ }
1447
+ const fireNotificationChangeEvent = (kind, detail) => {
1448
+ const index = this._notifications.indexOf(item);
1449
+ if (index >= 0) {
1450
+ this._onDidChangeNotification.fire({ item, index, kind, detail });
1451
+ }
1452
+ };
1453
+ const itemExpansionChangeListener = item.onDidChangeExpansion(() => fireNotificationChangeEvent(2 ));
1454
+ const itemContentChangeListener = item.onDidChangeContent(e => fireNotificationChangeEvent(1 , e.kind));
1455
+ Event.once(item.onDidClose)(() => {
1456
+ itemExpansionChangeListener.dispose();
1457
+ itemContentChangeListener.dispose();
1458
+ const index = this._notifications.indexOf(item);
1459
+ if (index >= 0) {
1460
+ this._notifications.splice(index, 1);
1461
+ this._onDidChangeNotification.fire({ item, index, kind: 3 });
1462
+ }
1463
+ });
1464
+ return item;
1465
+ }
1466
+ showStatusMessage(message, options) {
1467
+ const item = StatusMessageViewItem.create(message, options);
1468
+ if (!item) {
1469
+ return Disposable.None;
1470
+ }
1471
+ this._statusMessage = item;
1472
+ this._onDidChangeStatusMessage.fire({ kind: 0 , item });
1473
+ return toDisposable(() => {
1474
+ if (this._statusMessage === item) {
1475
+ this._statusMessage = undefined;
1476
+ this._onDidChangeStatusMessage.fire({ kind: 1 , item });
1477
+ }
1478
+ });
1479
+ }
1480
+ }
1481
+ NotificationsModel.NO_OP_NOTIFICATION = new NoOpNotification();
1482
+ function isNotificationViewItem(obj) {
1483
+ return obj instanceof NotificationViewItem;
1484
+ }
1485
+ class NotificationViewItemProgress extends Disposable {
1486
+ constructor() {
1487
+ super();
1488
+ this._onDidChange = this._register( new Emitter());
1489
+ this.onDidChange = this._onDidChange.event;
1490
+ this._state = Object.create(null);
1491
+ }
1492
+ get state() {
1493
+ return this._state;
1494
+ }
1495
+ infinite() {
1496
+ if (this._state.infinite) {
1497
+ return;
1498
+ }
1499
+ this._state.infinite = true;
1500
+ this._state.total = undefined;
1501
+ this._state.worked = undefined;
1502
+ this._state.done = undefined;
1503
+ this._onDidChange.fire();
1504
+ }
1505
+ done() {
1506
+ if (this._state.done) {
1507
+ return;
1508
+ }
1509
+ this._state.done = true;
1510
+ this._state.infinite = undefined;
1511
+ this._state.total = undefined;
1512
+ this._state.worked = undefined;
1513
+ this._onDidChange.fire();
1514
+ }
1515
+ total(value) {
1516
+ if (this._state.total === value) {
1517
+ return;
1518
+ }
1519
+ this._state.total = value;
1520
+ this._state.infinite = undefined;
1521
+ this._state.done = undefined;
1522
+ this._onDidChange.fire();
1523
+ }
1524
+ worked(value) {
1525
+ if (typeof this._state.worked === 'number') {
1526
+ this._state.worked += value;
1527
+ }
1528
+ else {
1529
+ this._state.worked = value;
1530
+ }
1531
+ this._state.infinite = undefined;
1532
+ this._state.done = undefined;
1533
+ this._onDidChange.fire();
1534
+ }
1535
+ }
1536
+ class NotificationViewItem extends Disposable {
1537
+ constructor(id, _severity, _sticky, _silent, _message, _source, progress, actions) {
1538
+ super();
1539
+ this.id = id;
1540
+ this._severity = _severity;
1541
+ this._sticky = _sticky;
1542
+ this._silent = _silent;
1543
+ this._message = _message;
1544
+ this._source = _source;
1545
+ this._visible = false;
1546
+ this._onDidChangeExpansion = this._register( new Emitter());
1547
+ this.onDidChangeExpansion = this._onDidChangeExpansion.event;
1548
+ this._onDidClose = this._register( new Emitter());
1549
+ this.onDidClose = this._onDidClose.event;
1550
+ this._onDidChangeContent = this._register( new Emitter());
1551
+ this.onDidChangeContent = this._onDidChangeContent.event;
1552
+ this._onDidChangeVisibility = this._register( new Emitter());
1553
+ this.onDidChangeVisibility = this._onDidChangeVisibility.event;
1554
+ if (progress) {
1555
+ this.setProgress(progress);
1556
+ }
1557
+ this.setActions(actions);
1558
+ }
1559
+ static create(notification, filter = NotificationsFilter.OFF) {
1560
+ if (!notification || !notification.message || isCancellationError(notification.message)) {
1561
+ return undefined;
1562
+ }
1563
+ let severity;
1564
+ if (typeof notification.severity === 'number') {
1565
+ severity = notification.severity;
1566
+ }
1567
+ else {
1568
+ severity = Severity.Info;
1569
+ }
1570
+ const message = NotificationViewItem.parseNotificationMessage(notification.message);
1571
+ if (!message) {
1572
+ return undefined;
1573
+ }
1574
+ let actions;
1575
+ if (notification.actions) {
1576
+ actions = notification.actions;
1577
+ }
1578
+ else if (isErrorWithActions(notification.message)) {
1579
+ actions = { primary: notification.message.actions };
1580
+ }
1581
+ return (
1582
+ new NotificationViewItem(
1583
+ notification.id,
1584
+ severity,
1585
+ notification.sticky,
1586
+ notification.silent || filter === NotificationsFilter.SILENT || (filter === NotificationsFilter.ERROR && notification.severity !== Severity.Error),
1587
+ message,
1588
+ notification.source,
1589
+ notification.progress,
1590
+ actions
1591
+ )
1592
+ );
1593
+ }
1594
+ static parseNotificationMessage(input) {
1595
+ let message;
1596
+ if (input instanceof Error) {
1597
+ message = toErrorMessage(input, false);
1598
+ }
1599
+ else if (typeof input === 'string') {
1600
+ message = input;
1601
+ }
1602
+ if (!message) {
1603
+ return undefined;
1604
+ }
1605
+ const raw = message;
1606
+ if (message.length > NotificationViewItem.MAX_MESSAGE_LENGTH) {
1607
+ message = `${message.substr(0, NotificationViewItem.MAX_MESSAGE_LENGTH)}...`;
1608
+ }
1609
+ message = message.replace(/(\r\n|\n|\r)/gm, ' ').trim();
1610
+ const linkedText = parseLinkedText(message);
1611
+ return { raw, linkedText, original: input };
1612
+ }
1613
+ setProgress(progress) {
1614
+ if (progress.infinite) {
1615
+ this.progress.infinite();
1616
+ }
1617
+ else if (progress.total) {
1618
+ this.progress.total(progress.total);
1619
+ if (progress.worked) {
1620
+ this.progress.worked(progress.worked);
1621
+ }
1622
+ }
1623
+ }
1624
+ setActions(actions = { primary: [], secondary: [] }) {
1625
+ this._actions = {
1626
+ primary: Array.isArray(actions.primary) ? actions.primary : [],
1627
+ secondary: Array.isArray(actions.secondary) ? actions.secondary : []
1628
+ };
1629
+ this._expanded = actions.primary && actions.primary.length > 0;
1630
+ }
1631
+ get canCollapse() {
1632
+ return !this.hasActions;
1633
+ }
1634
+ get expanded() {
1635
+ return !!this._expanded;
1636
+ }
1637
+ get severity() {
1638
+ return this._severity;
1639
+ }
1640
+ get sticky() {
1641
+ if (this._sticky) {
1642
+ return true;
1643
+ }
1644
+ const hasActions = this.hasActions;
1645
+ if ((hasActions && this._severity === Severity.Error) ||
1646
+ (!hasActions && this._expanded) ||
1647
+ (this._progress && !this._progress.state.done)
1648
+ ) {
1649
+ return true;
1650
+ }
1651
+ return false;
1652
+ }
1653
+ get silent() {
1654
+ return !!this._silent;
1655
+ }
1656
+ get hasActions() {
1657
+ if (!this._actions) {
1658
+ return false;
1659
+ }
1660
+ if (!this._actions.primary) {
1661
+ return false;
1662
+ }
1663
+ return this._actions.primary.length > 0;
1664
+ }
1665
+ get hasProgress() {
1666
+ return !!this._progress;
1667
+ }
1668
+ get progress() {
1669
+ if (!this._progress) {
1670
+ this._progress = this._register( new NotificationViewItemProgress());
1671
+ this._register(this._progress.onDidChange(() => this._onDidChangeContent.fire({ kind: 3 })));
1672
+ }
1673
+ return this._progress;
1674
+ }
1675
+ get message() {
1676
+ return this._message;
1677
+ }
1678
+ get source() {
1679
+ return typeof this._source === 'string' ? this._source : (this._source ? this._source.label : undefined);
1680
+ }
1681
+ get sourceId() {
1682
+ return (this._source && typeof this._source !== 'string' && 'id' in this._source) ? this._source.id : undefined;
1683
+ }
1684
+ get actions() {
1685
+ return this._actions;
1686
+ }
1687
+ get visible() {
1688
+ return this._visible;
1689
+ }
1690
+ updateSeverity(severity) {
1691
+ if (severity === this._severity) {
1692
+ return;
1693
+ }
1694
+ this._severity = severity;
1695
+ this._onDidChangeContent.fire({ kind: 0 });
1696
+ }
1697
+ updateMessage(input) {
1698
+ const message = NotificationViewItem.parseNotificationMessage(input);
1699
+ if (!message || message.raw === this._message.raw) {
1700
+ return;
1701
+ }
1702
+ this._message = message;
1703
+ this._onDidChangeContent.fire({ kind: 1 });
1704
+ }
1705
+ updateActions(actions) {
1706
+ this.setActions(actions);
1707
+ this._onDidChangeContent.fire({ kind: 2 });
1708
+ }
1709
+ updateVisibility(visible) {
1710
+ if (this._visible !== visible) {
1711
+ this._visible = visible;
1712
+ this._onDidChangeVisibility.fire(visible);
1713
+ }
1714
+ }
1715
+ expand() {
1716
+ if (this._expanded || !this.canCollapse) {
1717
+ return;
1718
+ }
1719
+ this._expanded = true;
1720
+ this._onDidChangeExpansion.fire();
1721
+ }
1722
+ collapse(skipEvents) {
1723
+ if (!this._expanded || !this.canCollapse) {
1724
+ return;
1725
+ }
1726
+ this._expanded = false;
1727
+ if (!skipEvents) {
1728
+ this._onDidChangeExpansion.fire();
1729
+ }
1730
+ }
1731
+ toggle() {
1732
+ if (this._expanded) {
1733
+ this.collapse();
1734
+ }
1735
+ else {
1736
+ this.expand();
1737
+ }
1738
+ }
1739
+ close() {
1740
+ this._onDidClose.fire();
1741
+ this.dispose();
1742
+ }
1743
+ equals(other) {
1744
+ if (this.hasProgress || other.hasProgress) {
1745
+ return false;
1746
+ }
1747
+ if (typeof this.id === 'string' || typeof other.id === 'string') {
1748
+ return this.id === other.id;
1749
+ }
1750
+ if (typeof this._source === 'object') {
1751
+ if (this._source.label !== other.source || this._source.id !== other.sourceId) {
1752
+ return false;
1753
+ }
1754
+ }
1755
+ else if (this._source !== other.source) {
1756
+ return false;
1757
+ }
1758
+ if (this._message.raw !== other.message.raw) {
1759
+ return false;
1760
+ }
1761
+ const primaryActions = (this._actions && this._actions.primary) || [];
1762
+ const otherPrimaryActions = (other.actions && other.actions.primary) || [];
1763
+ return equals(primaryActions, otherPrimaryActions, (action, otherAction) => (action.id + action.label) === (otherAction.id + otherAction.label));
1764
+ }
1765
+ }
1766
+ NotificationViewItem.MAX_MESSAGE_LENGTH = 1000;
1767
+ class ChoiceAction extends Action {
1768
+ constructor(id, choice) {
1769
+ super(id, choice.label, undefined, true, async () => {
1770
+ choice.run();
1771
+ this._onDidRun.fire();
1772
+ });
1773
+ this._onDidRun = this._register( new Emitter());
1774
+ this.onDidRun = this._onDidRun.event;
1775
+ this._keepOpen = !!choice.keepOpen;
1776
+ this._menu = !choice.isSecondary && choice.menu ? choice.menu.map((c, index) => new ChoiceAction(`${id}.${index}`, c)) : undefined;
1777
+ }
1778
+ get menu() {
1779
+ return this._menu;
1780
+ }
1781
+ get keepOpen() {
1782
+ return this._keepOpen;
1783
+ }
1784
+ }
1785
+ class StatusMessageViewItem {
1786
+ static create(notification, options) {
1787
+ if (!notification || isCancellationError(notification)) {
1788
+ return undefined;
1789
+ }
1790
+ let message;
1791
+ if (notification instanceof Error) {
1792
+ message = toErrorMessage(notification, false);
1793
+ }
1794
+ else if (typeof notification === 'string') {
1795
+ message = notification;
1796
+ }
1797
+ if (!message) {
1798
+ return undefined;
1799
+ }
1800
+ return { message, options };
1801
+ }
1802
+ }
1803
+ var css$1 = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-toolbar-container .action-item,\n.monaco-workbench > .notifications-center > .notifications-center-header > .notifications-center-header-toolbar .action-item {\n\tmargin-right: 4px;\n}\n\n.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-toolbar-container .action-item:first-child,\n.monaco-workbench > .notifications-center > .notifications-center-header > .notifications-center-header-toolbar .action-item:first-child {\n\tmargin-left: 4px;\n}\n";
1804
+ n(css$1,{});
1805
+ function notificationToMetrics(message, source, silent) {
1806
+ return {
1807
+ id: hash(message.toString()).toString(),
1808
+ silent,
1809
+ source: source || 'core'
1810
+ };
1811
+ }
1812
+ const MultipleEditorGroupsContext = new RawContextKey('multipleEditorGroups', false, localize('multipleEditorGroups', "Whether there are multiple editor groups opened"));
1813
+ MultipleEditorGroupsContext.toNegated();
1814
+ const NotificationFocusedContext = new RawContextKey('notificationFocus', true, localize('notificationFocus', "Whether a notification has keyboard focus"));
1815
+ const NotificationsCenterVisibleContext = new RawContextKey('notificationCenterVisible', false, localize('notificationCenterVisible', "Whether the notifications center is visible"));
1816
+ const NotificationsToastsVisibleContext = new RawContextKey('notificationToastsVisible', false, localize('notificationToastsVisible', "Whether a notification toast is visible"));
1817
+ let ResourceContextKey = class ResourceContextKey {
1818
+ constructor(_contextKeyService, _fileService, _languageService, _modelService) {
1819
+ this._contextKeyService = _contextKeyService;
1820
+ this._fileService = _fileService;
1821
+ this._languageService = _languageService;
1822
+ this._modelService = _modelService;
1823
+ this._disposables = new DisposableStore();
1824
+ this._schemeKey = ResourceContextKey.Scheme.bindTo(this._contextKeyService);
1825
+ this._filenameKey = ResourceContextKey.Filename.bindTo(this._contextKeyService);
1826
+ this._dirnameKey = ResourceContextKey.Dirname.bindTo(this._contextKeyService);
1827
+ this._pathKey = ResourceContextKey.Path.bindTo(this._contextKeyService);
1828
+ this._langIdKey = ResourceContextKey.LangId.bindTo(this._contextKeyService);
1829
+ this._resourceKey = ResourceContextKey.Resource.bindTo(this._contextKeyService);
1830
+ this._extensionKey = ResourceContextKey.Extension.bindTo(this._contextKeyService);
1831
+ this._hasResource = ResourceContextKey.HasResource.bindTo(this._contextKeyService);
1832
+ this._isFileSystemResource = ResourceContextKey.IsFileSystemResource.bindTo(this._contextKeyService);
1833
+ this._disposables.add(_fileService.onDidChangeFileSystemProviderRegistrations(() => {
1834
+ const resource = this.get();
1835
+ this._isFileSystemResource.set(Boolean(resource && _fileService.hasProvider(resource)));
1836
+ }));
1837
+ this._disposables.add(_modelService.onModelAdded(model => {
1838
+ if (isEqual(model.uri, this.get())) {
1839
+ this._setLangId();
1840
+ }
1841
+ }));
1842
+ this._disposables.add(_modelService.onModelLanguageChanged(e => {
1843
+ if (isEqual(e.model.uri, this.get())) {
1844
+ this._setLangId();
1845
+ }
1846
+ }));
1847
+ }
1848
+ dispose() {
1849
+ this._disposables.dispose();
1850
+ }
1851
+ _setLangId() {
1852
+ const value = this.get();
1853
+ if (!value) {
1854
+ this._langIdKey.set(null);
1855
+ return;
1856
+ }
1857
+ const langId = this._modelService.getModel(value)?.getLanguageId() ?? this._languageService.guessLanguageIdByFilepathOrFirstLine(value);
1858
+ this._langIdKey.set(langId);
1859
+ }
1860
+ set(value) {
1861
+ if (isEqual(this.get(), value ?? undefined)) {
1862
+ return;
1863
+ }
1864
+ this._contextKeyService.bufferChangeEvents(() => {
1865
+ this._resourceKey.set(value);
1866
+ this._schemeKey.set(value ? value.scheme : null);
1867
+ this._filenameKey.set(value ? basename(value) : null);
1868
+ this._dirnameKey.set(value ? dirname(value).fsPath : null);
1869
+ this._pathKey.set(value ? value.fsPath : null);
1870
+ this._setLangId();
1871
+ this._extensionKey.set(value ? extname(value) : null);
1872
+ this._hasResource.set(Boolean(value));
1873
+ this._isFileSystemResource.set(value ? this._fileService.hasProvider(value) : false);
1874
+ });
1875
+ }
1876
+ reset() {
1877
+ this._contextKeyService.bufferChangeEvents(() => {
1878
+ this._resourceKey.reset();
1879
+ this._schemeKey.reset();
1880
+ this._filenameKey.reset();
1881
+ this._dirnameKey.reset();
1882
+ this._pathKey.reset();
1883
+ this._langIdKey.reset();
1884
+ this._extensionKey.reset();
1885
+ this._hasResource.reset();
1886
+ this._isFileSystemResource.reset();
1887
+ });
1888
+ }
1889
+ get() {
1890
+ return this._resourceKey.get() ?? undefined;
1891
+ }
1892
+ };
1893
+ ResourceContextKey.Scheme = new RawContextKey('resourceScheme', undefined, { type: 'string', description: localize('resourceScheme', "The scheme of the rsource") });
1894
+ ResourceContextKey.Filename = new RawContextKey(
1895
+ 'resourceFilename',
1896
+ undefined,
1897
+ { type: 'string', description: localize('resourceFilename', "The file name of the resource") }
1898
+ );
1899
+ ResourceContextKey.Dirname = new RawContextKey('resourceDirname', undefined, { type: 'string', description: localize('resourceDirname', "The folder name the resource is contained in") });
1900
+ ResourceContextKey.Path = new RawContextKey('resourcePath', undefined, { type: 'string', description: localize('resourcePath', "The full path of the resource") });
1901
+ ResourceContextKey.LangId = new RawContextKey('resourceLangId', undefined, { type: 'string', description: localize('resourceLangId', "The language identifier of the resource") });
1902
+ ResourceContextKey.Resource = new RawContextKey('resource', undefined, { type: 'URI', description: localize('resource', "The full value of the resource including scheme and path") });
1903
+ ResourceContextKey.Extension = new RawContextKey('resourceExtname', undefined, { type: 'string', description: localize('resourceExtname', "The extension name of the resource") });
1904
+ ResourceContextKey.HasResource = new RawContextKey('resourceSet', undefined, { type: 'boolean', description: localize('resourceSet', "Whether a resource is present or not") });
1905
+ ResourceContextKey.IsFileSystemResource = new RawContextKey(
1906
+ 'isFileSystemResource',
1907
+ undefined,
1908
+ { type: 'boolean', description: localize(
1909
+ 'isFileSystemResource',
1910
+ "Whether the resource is backed by a file system provider"
1911
+ ) }
1912
+ );
1913
+ ResourceContextKey = __decorate([
1914
+ __param(0, IContextKeyService),
1915
+ __param(1, IFileService),
1916
+ __param(2, ILanguageService),
1917
+ __param(3, IModelService)
1918
+ ], ResourceContextKey);
1919
+ const SHOW_NOTIFICATIONS_CENTER = 'notifications.showList';
1920
+ const HIDE_NOTIFICATIONS_CENTER = 'notifications.hideList';
1921
+ const HIDE_NOTIFICATION_TOAST = 'notifications.hideToasts';
1922
+ const FOCUS_NOTIFICATION_TOAST = 'notifications.focusToasts';
1923
+ const FOCUS_NEXT_NOTIFICATION_TOAST = 'notifications.focusNextToast';
1924
+ const FOCUS_PREVIOUS_NOTIFICATION_TOAST = 'notifications.focusPreviousToast';
1925
+ const FOCUS_FIRST_NOTIFICATION_TOAST = 'notifications.focusFirstToast';
1926
+ const FOCUS_LAST_NOTIFICATION_TOAST = 'notifications.focusLastToast';
1927
+ const COLLAPSE_NOTIFICATION = 'notification.collapse';
1928
+ const EXPAND_NOTIFICATION = 'notification.expand';
1929
+ const TOGGLE_NOTIFICATION = 'notification.toggle';
1930
+ const CLEAR_NOTIFICATION = 'notification.clear';
1931
+ const CLEAR_ALL_NOTIFICATIONS = 'notifications.clearAll';
1932
+ function registerNotificationCommands(center, toasts, model) {
1933
+ function getNotificationFromContext(listService, context) {
1934
+ if (isNotificationViewItem(context)) {
1935
+ return context;
1936
+ }
1937
+ const list = listService.lastFocusedList;
1938
+ if (list instanceof WorkbenchList) {
1939
+ const focusedElement = list.getFocusedElements()[0];
1940
+ if (isNotificationViewItem(focusedElement)) {
1941
+ return focusedElement;
1942
+ }
1943
+ }
1944
+ return undefined;
1945
+ }
1946
+ CommandsRegistry.registerCommand(SHOW_NOTIFICATIONS_CENTER, () => {
1947
+ toasts.hide();
1948
+ center.show();
1949
+ });
1950
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
1951
+ id: HIDE_NOTIFICATIONS_CENTER,
1952
+ weight: 200 + 50,
1953
+ when: NotificationsCenterVisibleContext,
1954
+ primary: 9 ,
1955
+ handler: accessor => {
1956
+ const telemetryService = accessor.get(ITelemetryService);
1957
+ for (const notification of model.notifications) {
1958
+ if (notification.visible) {
1959
+ telemetryService.publicLog2('notification:hide', notificationToMetrics(notification.message.original, notification.sourceId, notification.silent));
1960
+ }
1961
+ }
1962
+ center.hide();
1963
+ }
1964
+ });
1965
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
1966
+ id: CLEAR_NOTIFICATION,
1967
+ weight: 200 ,
1968
+ when: NotificationFocusedContext,
1969
+ primary: 20 ,
1970
+ mac: {
1971
+ primary: 2048 | 1
1972
+ },
1973
+ handler: (accessor, args) => {
1974
+ const notification = getNotificationFromContext(accessor.get(IListService), args);
1975
+ if (notification && !notification.hasProgress) {
1976
+ notification.close();
1977
+ }
1978
+ }
1979
+ });
1980
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
1981
+ id: EXPAND_NOTIFICATION,
1982
+ weight: 200 ,
1983
+ when: NotificationFocusedContext,
1984
+ primary: 17 ,
1985
+ handler: (accessor, args) => {
1986
+ const notification = getNotificationFromContext(accessor.get(IListService), args);
1987
+ if (notification) {
1988
+ notification.expand();
1989
+ }
1990
+ }
1991
+ });
1992
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
1993
+ id: COLLAPSE_NOTIFICATION,
1994
+ weight: 200 ,
1995
+ when: NotificationFocusedContext,
1996
+ primary: 15 ,
1997
+ handler: (accessor, args) => {
1998
+ const notification = getNotificationFromContext(accessor.get(IListService), args);
1999
+ if (notification) {
2000
+ notification.collapse();
2001
+ }
2002
+ }
2003
+ });
2004
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
2005
+ id: TOGGLE_NOTIFICATION,
2006
+ weight: 200 ,
2007
+ when: NotificationFocusedContext,
2008
+ primary: 10 ,
2009
+ secondary: [3 ],
2010
+ handler: accessor => {
2011
+ const notification = getNotificationFromContext(accessor.get(IListService));
2012
+ if (notification) {
2013
+ notification.toggle();
2014
+ }
2015
+ }
2016
+ });
2017
+ KeybindingsRegistry.registerKeybindingRule({
2018
+ id: HIDE_NOTIFICATION_TOAST,
2019
+ weight: 200 - 50,
2020
+ when: NotificationsToastsVisibleContext,
2021
+ primary: 9
2022
+ });
2023
+ KeybindingsRegistry.registerKeybindingRule({
2024
+ id: HIDE_NOTIFICATION_TOAST,
2025
+ weight: 200 + 100,
2026
+ when: ContextKeyExpr.and(NotificationsToastsVisibleContext, NotificationFocusedContext),
2027
+ primary: 9
2028
+ });
2029
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
2030
+ id: FOCUS_NEXT_NOTIFICATION_TOAST,
2031
+ weight: 200 ,
2032
+ when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext),
2033
+ primary: 18 ,
2034
+ handler: (accessor) => {
2035
+ toasts.focusNext();
2036
+ }
2037
+ });
2038
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
2039
+ id: FOCUS_PREVIOUS_NOTIFICATION_TOAST,
2040
+ weight: 200 ,
2041
+ when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext),
2042
+ primary: 16 ,
2043
+ handler: (accessor) => {
2044
+ toasts.focusPrevious();
2045
+ }
2046
+ });
2047
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
2048
+ id: FOCUS_FIRST_NOTIFICATION_TOAST,
2049
+ weight: 200 ,
2050
+ when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext),
2051
+ primary: 11 ,
2052
+ secondary: [14 ],
2053
+ handler: (accessor) => {
2054
+ toasts.focusFirst();
2055
+ }
2056
+ });
2057
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
2058
+ id: FOCUS_LAST_NOTIFICATION_TOAST,
2059
+ weight: 200 ,
2060
+ when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext),
2061
+ primary: 12 ,
2062
+ secondary: [13 ],
2063
+ handler: (accessor) => {
2064
+ toasts.focusLast();
2065
+ }
2066
+ });
2067
+ const category = { value: localize('notifications', "Notifications"), original: 'Notifications' };
2068
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: SHOW_NOTIFICATIONS_CENTER, title: { value: localize('showNotifications', "Show Notifications"), original: 'Show Notifications' }, category } });
2069
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: HIDE_NOTIFICATIONS_CENTER, title: { value: localize('hideNotifications', "Hide Notifications"), original: 'Hide Notifications' }, category }, when: NotificationsCenterVisibleContext });
2070
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: CLEAR_ALL_NOTIFICATIONS, title: { value: localize('clearAllNotifications', "Clear All Notifications"), original: 'Clear All Notifications' }, category } });
2071
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: FOCUS_NOTIFICATION_TOAST, title: { value: localize('focusNotificationToasts', "Focus Notification Toast"), original: 'Focus Notification Toast' }, category }, when: NotificationsToastsVisibleContext });
2072
+ }
2073
+ const clearIcon = registerIcon('notifications-clear', Codicon.close, localize('clearIcon', 'Icon for the clear action in notifications.'));
2074
+ const clearAllIcon = registerIcon('notifications-clear-all', Codicon.clearAll, localize('clearAllIcon', 'Icon for the clear all action in notifications.'));
2075
+ const hideIcon = registerIcon('notifications-hide', Codicon.chevronDown, localize('hideIcon', 'Icon for the hide action in notifications.'));
2076
+ const expandIcon = registerIcon('notifications-expand', Codicon.chevronUp, localize('expandIcon', 'Icon for the expand action in notifications.'));
2077
+ const collapseIcon = registerIcon('notifications-collapse', Codicon.chevronDown, localize('collapseIcon', 'Icon for the collapse action in notifications.'));
2078
+ const configureIcon = registerIcon('notifications-configure', Codicon.gear, localize('configureIcon', 'Icon for the configure action in notifications.'));
2079
+ let ClearNotificationAction = class ClearNotificationAction extends Action {
2080
+ constructor(id, label, commandService) {
2081
+ super(id, label, ThemeIcon.asClassName(clearIcon));
2082
+ this.commandService = commandService;
2083
+ }
2084
+ async run(notification) {
2085
+ this.commandService.executeCommand(CLEAR_NOTIFICATION, notification);
2086
+ }
2087
+ };
2088
+ ClearNotificationAction.ID = CLEAR_NOTIFICATION;
2089
+ ClearNotificationAction.LABEL = localize('clearNotification', "Clear Notification");
2090
+ ClearNotificationAction = __decorate([
2091
+ __param(2, ICommandService)
2092
+ ], ClearNotificationAction);
2093
+ let ClearAllNotificationsAction = class ClearAllNotificationsAction extends Action {
2094
+ constructor(id, label, commandService) {
2095
+ super(id, label, ThemeIcon.asClassName(clearAllIcon));
2096
+ this.commandService = commandService;
2097
+ }
2098
+ async run() {
2099
+ this.commandService.executeCommand(CLEAR_ALL_NOTIFICATIONS);
2100
+ }
2101
+ };
2102
+ ClearAllNotificationsAction.ID = CLEAR_ALL_NOTIFICATIONS;
2103
+ ClearAllNotificationsAction.LABEL = localize('clearNotifications', "Clear All Notifications");
2104
+ ClearAllNotificationsAction = __decorate([
2105
+ __param(2, ICommandService)
2106
+ ], ClearAllNotificationsAction);
2107
+ let HideNotificationsCenterAction = class HideNotificationsCenterAction extends Action {
2108
+ constructor(id, label, commandService) {
2109
+ super(id, label, ThemeIcon.asClassName(hideIcon));
2110
+ this.commandService = commandService;
2111
+ }
2112
+ async run() {
2113
+ this.commandService.executeCommand(HIDE_NOTIFICATIONS_CENTER);
2114
+ }
2115
+ };
2116
+ HideNotificationsCenterAction.ID = HIDE_NOTIFICATIONS_CENTER;
2117
+ HideNotificationsCenterAction.LABEL = localize('hideNotificationsCenter', "Hide Notifications");
2118
+ HideNotificationsCenterAction = __decorate([
2119
+ __param(2, ICommandService)
2120
+ ], HideNotificationsCenterAction);
2121
+ let ExpandNotificationAction = class ExpandNotificationAction extends Action {
2122
+ constructor(id, label, commandService) {
2123
+ super(id, label, ThemeIcon.asClassName(expandIcon));
2124
+ this.commandService = commandService;
2125
+ }
2126
+ async run(notification) {
2127
+ this.commandService.executeCommand(EXPAND_NOTIFICATION, notification);
2128
+ }
2129
+ };
2130
+ ExpandNotificationAction.ID = EXPAND_NOTIFICATION;
2131
+ ExpandNotificationAction.LABEL = localize('expandNotification', "Expand Notification");
2132
+ ExpandNotificationAction = __decorate([
2133
+ __param(2, ICommandService)
2134
+ ], ExpandNotificationAction);
2135
+ let CollapseNotificationAction = class CollapseNotificationAction extends Action {
2136
+ constructor(id, label, commandService) {
2137
+ super(id, label, ThemeIcon.asClassName(collapseIcon));
2138
+ this.commandService = commandService;
2139
+ }
2140
+ async run(notification) {
2141
+ this.commandService.executeCommand(COLLAPSE_NOTIFICATION, notification);
2142
+ }
2143
+ };
2144
+ CollapseNotificationAction.ID = COLLAPSE_NOTIFICATION;
2145
+ CollapseNotificationAction.LABEL = localize('collapseNotification', "Collapse Notification");
2146
+ CollapseNotificationAction = __decorate([
2147
+ __param(2, ICommandService)
2148
+ ], CollapseNotificationAction);
2149
+ class ConfigureNotificationAction extends Action {
2150
+ constructor(id, label, configurationActions) {
2151
+ super(id, label, ThemeIcon.asClassName(configureIcon));
2152
+ this.configurationActions = configurationActions;
2153
+ }
2154
+ }
2155
+ ConfigureNotificationAction.ID = 'workbench.action.configureNotification';
2156
+ ConfigureNotificationAction.LABEL = localize('configureNotification', "Configure Notification");
2157
+ let CopyNotificationMessageAction = class CopyNotificationMessageAction extends Action {
2158
+ constructor(id, label, clipboardService) {
2159
+ super(id, label);
2160
+ this.clipboardService = clipboardService;
2161
+ }
2162
+ run(notification) {
2163
+ return this.clipboardService.writeText(notification.message.raw);
2164
+ }
2165
+ };
2166
+ CopyNotificationMessageAction.ID = 'workbench.action.copyNotificationMessage';
2167
+ CopyNotificationMessageAction.LABEL = localize('copyNotification', "Copy Text");
2168
+ CopyNotificationMessageAction = __decorate([
2169
+ __param(2, IClipboardService)
2170
+ ], CopyNotificationMessageAction);
2171
+ let NotificationActionRunner = class NotificationActionRunner extends ActionRunner {
2172
+ constructor(telemetryService, notificationService) {
2173
+ super();
2174
+ this.telemetryService = telemetryService;
2175
+ this.notificationService = notificationService;
2176
+ }
2177
+ async runAction(action, context) {
2178
+ this.telemetryService.publicLog2('workbenchActionExecuted', { id: action.id, from: 'message' });
2179
+ if (isNotificationViewItem(context)) {
2180
+ this.telemetryService.publicLog2('notification:actionExecuted', {
2181
+ id: hash(context.message.original.toString()).toString(),
2182
+ actionLabel: action.label,
2183
+ source: context.sourceId || 'core',
2184
+ silent: context.silent
2185
+ });
2186
+ }
2187
+ try {
2188
+ await super.runAction(action, context);
2189
+ }
2190
+ catch (error) {
2191
+ this.notificationService.error(error);
2192
+ }
2193
+ }
2194
+ };
2195
+ NotificationActionRunner = __decorate([
2196
+ __param(0, ITelemetryService),
2197
+ __param(1, INotificationService)
2198
+ ], NotificationActionRunner);
2199
+ class NotificationsListDelegate {
2200
+ constructor(container) {
2201
+ this.offsetHelper = this.createOffsetHelper(container);
2202
+ }
2203
+ createOffsetHelper(container) {
2204
+ const offsetHelper = document.createElement('div');
2205
+ offsetHelper.classList.add('notification-offset-helper');
2206
+ container.appendChild(offsetHelper);
2207
+ return offsetHelper;
2208
+ }
2209
+ getHeight(notification) {
2210
+ if (!notification.expanded) {
2211
+ return NotificationsListDelegate.ROW_HEIGHT;
2212
+ }
2213
+ let expandedHeight = NotificationsListDelegate.ROW_HEIGHT;
2214
+ const preferredMessageHeight = this.computePreferredHeight(notification);
2215
+ const messageOverflows = NotificationsListDelegate.LINE_HEIGHT < preferredMessageHeight;
2216
+ if (messageOverflows) {
2217
+ const overflow = preferredMessageHeight - NotificationsListDelegate.LINE_HEIGHT;
2218
+ expandedHeight += overflow;
2219
+ }
2220
+ if (notification.source || isNonEmptyArray(notification.actions && notification.actions.primary)) {
2221
+ expandedHeight += NotificationsListDelegate.ROW_HEIGHT;
2222
+ }
2223
+ if (expandedHeight === NotificationsListDelegate.ROW_HEIGHT) {
2224
+ notification.collapse(true );
2225
+ }
2226
+ return expandedHeight;
2227
+ }
2228
+ computePreferredHeight(notification) {
2229
+ let actions = 1;
2230
+ if (notification.canCollapse) {
2231
+ actions++;
2232
+ }
2233
+ if (isNonEmptyArray(notification.actions && notification.actions.secondary)) {
2234
+ actions++;
2235
+ }
2236
+ this.offsetHelper.style.width = `${450 - ((10 + 26 + (actions * (24 + 8)) - 4) )}px`;
2237
+ const renderedMessage = NotificationMessageRenderer.render(notification.message);
2238
+ this.offsetHelper.appendChild(renderedMessage);
2239
+ const preferredHeight = Math.max(this.offsetHelper.offsetHeight, this.offsetHelper.scrollHeight);
2240
+ clearNode(this.offsetHelper);
2241
+ return preferredHeight;
2242
+ }
2243
+ getTemplateId(element) {
2244
+ if (element instanceof NotificationViewItem) {
2245
+ return NotificationRenderer.TEMPLATE_ID;
2246
+ }
2247
+ throw new Error('unknown element type: ' + element);
2248
+ }
2249
+ }
2250
+ NotificationsListDelegate.ROW_HEIGHT = 42;
2251
+ NotificationsListDelegate.LINE_HEIGHT = 22;
2252
+ class NotificationMessageRenderer {
2253
+ static render(message, actionHandler) {
2254
+ const messageContainer = document.createElement('span');
2255
+ for (const node of message.linkedText.nodes) {
2256
+ if (typeof node === 'string') {
2257
+ messageContainer.appendChild(document.createTextNode(node));
2258
+ }
2259
+ else {
2260
+ let title = node.title;
2261
+ if (!title && node.href.startsWith('command:')) {
2262
+ title = localize(
2263
+ 'executeCommand',
2264
+ "Click to execute command '{0}'",
2265
+ node.href.substr('command:'.length)
2266
+ );
2267
+ }
2268
+ else if (!title) {
2269
+ title = node.href;
2270
+ }
2271
+ const anchor = $('a', { href: node.href, title: title, }, node.label);
2272
+ if (actionHandler) {
2273
+ const onPointer = (e) => {
2274
+ EventHelper.stop(e, true);
2275
+ actionHandler.callback(node.href);
2276
+ };
2277
+ const onClick = actionHandler.toDispose.add( new DomEmitter(anchor, 'click')).event;
2278
+ actionHandler.toDispose.add(Gesture.addTarget(anchor));
2279
+ const onTap = actionHandler.toDispose.add( new DomEmitter(anchor, EventType$1.Tap)).event;
2280
+ Event.any(onClick, onTap)(onPointer, null, actionHandler.toDispose);
2281
+ }
2282
+ messageContainer.appendChild(anchor);
2283
+ }
2284
+ }
2285
+ return messageContainer;
2286
+ }
2287
+ }
2288
+ let NotificationRenderer = class NotificationRenderer {
2289
+ constructor(actionRunner, themeService, contextMenuService, instantiationService) {
2290
+ this.actionRunner = actionRunner;
2291
+ this.themeService = themeService;
2292
+ this.contextMenuService = contextMenuService;
2293
+ this.instantiationService = instantiationService;
2294
+ }
2295
+ get templateId() {
2296
+ return NotificationRenderer.TEMPLATE_ID;
2297
+ }
2298
+ renderTemplate(container) {
2299
+ const data = Object.create(null);
2300
+ data.toDispose = new DisposableStore();
2301
+ data.container = document.createElement('div');
2302
+ data.container.classList.add('notification-list-item');
2303
+ data.mainRow = document.createElement('div');
2304
+ data.mainRow.classList.add('notification-list-item-main-row');
2305
+ data.icon = document.createElement('div');
2306
+ data.icon.classList.add('notification-list-item-icon', 'codicon');
2307
+ data.message = document.createElement('div');
2308
+ data.message.classList.add('notification-list-item-message');
2309
+ const toolbarContainer = document.createElement('div');
2310
+ toolbarContainer.classList.add('notification-list-item-toolbar-container');
2311
+ data.toolbar = new ActionBar(toolbarContainer, {
2312
+ ariaLabel: localize('notificationActions', "Notification Actions"),
2313
+ actionViewItemProvider: action => {
2314
+ if (action && action instanceof ConfigureNotificationAction) {
2315
+ const item = new DropdownMenuActionViewItem(
2316
+ action,
2317
+ action.configurationActions,
2318
+ this.contextMenuService,
2319
+ { actionRunner: this.actionRunner, classNames: action.class }
2320
+ );
2321
+ data.toDispose.add(item);
2322
+ return item;
2323
+ }
2324
+ return undefined;
2325
+ },
2326
+ actionRunner: this.actionRunner
2327
+ });
2328
+ data.toDispose.add(data.toolbar);
2329
+ data.detailsRow = document.createElement('div');
2330
+ data.detailsRow.classList.add('notification-list-item-details-row');
2331
+ data.source = document.createElement('div');
2332
+ data.source.classList.add('notification-list-item-source');
2333
+ data.buttonsContainer = document.createElement('div');
2334
+ data.buttonsContainer.classList.add('notification-list-item-buttons-container');
2335
+ container.appendChild(data.container);
2336
+ data.container.appendChild(data.detailsRow);
2337
+ data.detailsRow.appendChild(data.source);
2338
+ data.detailsRow.appendChild(data.buttonsContainer);
2339
+ data.container.appendChild(data.mainRow);
2340
+ data.mainRow.appendChild(data.icon);
2341
+ data.mainRow.appendChild(data.message);
2342
+ data.mainRow.appendChild(toolbarContainer);
2343
+ data.progress = new ProgressBar(container);
2344
+ data.toDispose.add(attachProgressBarStyler(data.progress, this.themeService));
2345
+ data.toDispose.add(data.progress);
2346
+ data.renderer = this.instantiationService.createInstance(NotificationTemplateRenderer, data, this.actionRunner);
2347
+ data.toDispose.add(data.renderer);
2348
+ return data;
2349
+ }
2350
+ renderElement(notification, index, data) {
2351
+ data.renderer.setInput(notification);
2352
+ }
2353
+ disposeTemplate(templateData) {
2354
+ dispose(templateData.toDispose);
2355
+ }
2356
+ };
2357
+ NotificationRenderer.TEMPLATE_ID = 'notification';
2358
+ NotificationRenderer = __decorate([
2359
+ __param(1, IThemeService),
2360
+ __param(2, IContextMenuService),
2361
+ __param(3, IInstantiationService)
2362
+ ], NotificationRenderer);
2363
+ let NotificationTemplateRenderer = class NotificationTemplateRenderer extends Disposable {
2364
+ constructor(template, actionRunner, openerService, instantiationService, themeService, keybindingService, contextMenuService) {
2365
+ super();
2366
+ this.template = template;
2367
+ this.actionRunner = actionRunner;
2368
+ this.openerService = openerService;
2369
+ this.instantiationService = instantiationService;
2370
+ this.themeService = themeService;
2371
+ this.keybindingService = keybindingService;
2372
+ this.contextMenuService = contextMenuService;
2373
+ this.inputDisposables = this._register( new DisposableStore());
2374
+ if (!NotificationTemplateRenderer.closeNotificationAction) {
2375
+ NotificationTemplateRenderer.closeNotificationAction = instantiationService.createInstance(ClearNotificationAction, ClearNotificationAction.ID, ClearNotificationAction.LABEL);
2376
+ NotificationTemplateRenderer.expandNotificationAction = instantiationService.createInstance(ExpandNotificationAction, ExpandNotificationAction.ID, ExpandNotificationAction.LABEL);
2377
+ NotificationTemplateRenderer.collapseNotificationAction = instantiationService.createInstance(CollapseNotificationAction, CollapseNotificationAction.ID, CollapseNotificationAction.LABEL);
2378
+ }
2379
+ }
2380
+ setInput(notification) {
2381
+ this.inputDisposables.clear();
2382
+ this.render(notification);
2383
+ }
2384
+ render(notification) {
2385
+ this.template.container.classList.toggle('expanded', notification.expanded);
2386
+ this.inputDisposables.add(addDisposableListener(this.template.container, EventType.MOUSE_UP, e => {
2387
+ if (e.button === 1 ) {
2388
+ EventHelper.stop(e, true);
2389
+ }
2390
+ }));
2391
+ this.inputDisposables.add(addDisposableListener(this.template.container, EventType.AUXCLICK, e => {
2392
+ if (!notification.hasProgress && e.button === 1 ) {
2393
+ EventHelper.stop(e, true);
2394
+ notification.close();
2395
+ }
2396
+ }));
2397
+ this.renderSeverity(notification);
2398
+ const messageOverflows = this.renderMessage(notification);
2399
+ this.renderSecondaryActions(notification, messageOverflows);
2400
+ this.renderSource(notification);
2401
+ this.renderButtons(notification);
2402
+ this.renderProgress(notification);
2403
+ this.inputDisposables.add(notification.onDidChangeContent(event => {
2404
+ switch (event.kind) {
2405
+ case 0 :
2406
+ this.renderSeverity(notification);
2407
+ break;
2408
+ case 3 :
2409
+ this.renderProgress(notification);
2410
+ break;
2411
+ case 1 :
2412
+ this.renderMessage(notification);
2413
+ break;
2414
+ }
2415
+ }));
2416
+ }
2417
+ renderSeverity(notification) {
2418
+ NotificationTemplateRenderer.SEVERITIES.forEach(severity => {
2419
+ if (notification.severity !== severity) {
2420
+ this.template.icon.classList.remove(...this.toSeverityIcon(severity).classNamesArray);
2421
+ }
2422
+ });
2423
+ this.template.icon.classList.add(...this.toSeverityIcon(notification.severity).classNamesArray);
2424
+ }
2425
+ renderMessage(notification) {
2426
+ clearNode(this.template.message);
2427
+ this.template.message.appendChild(NotificationMessageRenderer.render(notification.message, {
2428
+ callback: link => this.openerService.open( URI.parse(link), { allowCommands: true }),
2429
+ toDispose: this.inputDisposables
2430
+ }));
2431
+ const messageOverflows = notification.canCollapse && !notification.expanded && this.template.message.scrollWidth > this.template.message.clientWidth;
2432
+ if (messageOverflows) {
2433
+ this.template.message.title = this.template.message.textContent + '';
2434
+ }
2435
+ else {
2436
+ this.template.message.removeAttribute('title');
2437
+ }
2438
+ const links = this.template.message.querySelectorAll('a');
2439
+ for (let i = 0; i < links.length; i++) {
2440
+ links.item(i).tabIndex = -1;
2441
+ }
2442
+ return messageOverflows;
2443
+ }
2444
+ renderSecondaryActions(notification, messageOverflows) {
2445
+ const actions = [];
2446
+ const secondaryActions = notification.actions ? notification.actions.secondary : undefined;
2447
+ if (isNonEmptyArray(secondaryActions)) {
2448
+ const configureNotificationAction = this.instantiationService.createInstance(ConfigureNotificationAction, ConfigureNotificationAction.ID, ConfigureNotificationAction.LABEL, secondaryActions);
2449
+ actions.push(configureNotificationAction);
2450
+ this.inputDisposables.add(configureNotificationAction);
2451
+ }
2452
+ let showExpandCollapseAction = false;
2453
+ if (notification.canCollapse) {
2454
+ if (notification.expanded) {
2455
+ showExpandCollapseAction = true;
2456
+ }
2457
+ else if (notification.source) {
2458
+ showExpandCollapseAction = true;
2459
+ }
2460
+ else if (messageOverflows) {
2461
+ showExpandCollapseAction = true;
2462
+ }
2463
+ }
2464
+ if (showExpandCollapseAction) {
2465
+ actions.push(notification.expanded ? NotificationTemplateRenderer.collapseNotificationAction : NotificationTemplateRenderer.expandNotificationAction);
2466
+ }
2467
+ if (!notification.hasProgress) {
2468
+ actions.push(NotificationTemplateRenderer.closeNotificationAction);
2469
+ }
2470
+ this.template.toolbar.clear();
2471
+ this.template.toolbar.context = notification;
2472
+ actions.forEach(action => this.template.toolbar.push(action, { icon: true, label: false, keybinding: this.getKeybindingLabel(action) }));
2473
+ }
2474
+ renderSource(notification) {
2475
+ if (notification.expanded && notification.source) {
2476
+ this.template.source.textContent = localize('notificationSource', "Source: {0}", notification.source);
2477
+ this.template.source.title = notification.source;
2478
+ }
2479
+ else {
2480
+ this.template.source.textContent = '';
2481
+ this.template.source.removeAttribute('title');
2482
+ }
2483
+ }
2484
+ renderButtons(notification) {
2485
+ clearNode(this.template.buttonsContainer);
2486
+ const primaryActions = notification.actions ? notification.actions.primary : undefined;
2487
+ if (notification.expanded && isNonEmptyArray(primaryActions)) {
2488
+ const that = this;
2489
+ const actionRunner = new (class extends ActionRunner {
2490
+ async runAction(action) {
2491
+ that.actionRunner.run(action, notification);
2492
+ if (!(action instanceof ChoiceAction) || !action.keepOpen) {
2493
+ notification.close();
2494
+ }
2495
+ }
2496
+ })();
2497
+ const buttonToolbar = this.inputDisposables.add( new ButtonBar(this.template.buttonsContainer));
2498
+ for (const action of primaryActions) {
2499
+ const buttonOptions = { title: true, };
2500
+ const dropdownActions = action instanceof ChoiceAction ? action.menu : undefined;
2501
+ const button = this.inputDisposables.add(dropdownActions
2502
+ ? buttonToolbar.addButtonWithDropdown({
2503
+ ...buttonOptions,
2504
+ contextMenuProvider: this.contextMenuService,
2505
+ actions: dropdownActions,
2506
+ actionRunner
2507
+ })
2508
+ : buttonToolbar.addButton(buttonOptions));
2509
+ button.label = action.label;
2510
+ this.inputDisposables.add(button.onDidClick(e => {
2511
+ if (e) {
2512
+ EventHelper.stop(e, true);
2513
+ }
2514
+ actionRunner.run(action);
2515
+ }));
2516
+ this.inputDisposables.add(attachButtonStyler(button, this.themeService));
2517
+ }
2518
+ }
2519
+ }
2520
+ renderProgress(notification) {
2521
+ if (!notification.hasProgress) {
2522
+ this.template.progress.stop().hide();
2523
+ return;
2524
+ }
2525
+ const state = notification.progress.state;
2526
+ if (state.infinite) {
2527
+ this.template.progress.infinite().show();
2528
+ }
2529
+ else if (typeof state.total === 'number' || typeof state.worked === 'number') {
2530
+ if (typeof state.total === 'number' && !this.template.progress.hasTotal()) {
2531
+ this.template.progress.total(state.total);
2532
+ }
2533
+ if (typeof state.worked === 'number') {
2534
+ this.template.progress.setWorked(state.worked).show();
2535
+ }
2536
+ }
2537
+ else {
2538
+ this.template.progress.done().hide();
2539
+ }
2540
+ }
2541
+ toSeverityIcon(severity) {
2542
+ switch (severity) {
2543
+ case Severity.Warning:
2544
+ return Codicon.warning;
2545
+ case Severity.Error:
2546
+ return Codicon.error;
2547
+ }
2548
+ return Codicon.info;
2549
+ }
2550
+ getKeybindingLabel(action) {
2551
+ const keybinding = this.keybindingService.lookupKeybinding(action.id);
2552
+ return keybinding ? keybinding.getLabel() : null;
2553
+ }
2554
+ };
2555
+ NotificationTemplateRenderer.SEVERITIES = [Severity.Info, Severity.Warning, Severity.Error];
2556
+ NotificationTemplateRenderer = __decorate([
2557
+ __param(2, IOpenerService),
2558
+ __param(3, IInstantiationService),
2559
+ __param(4, IThemeService),
2560
+ __param(5, IKeybindingService),
2561
+ __param(6, IContextMenuService)
2562
+ ], NotificationTemplateRenderer);
2563
+ let NotificationsList = class NotificationsList extends Themable {
2564
+ constructor(container, options, instantiationService, themeService, contextMenuService) {
2565
+ super(themeService);
2566
+ this.container = container;
2567
+ this.options = options;
2568
+ this.instantiationService = instantiationService;
2569
+ this.contextMenuService = contextMenuService;
2570
+ this.viewModel = [];
2571
+ }
2572
+ show(focus) {
2573
+ if (this.isVisible) {
2574
+ if (focus) {
2575
+ const list = assertIsDefined(this.list);
2576
+ list.domFocus();
2577
+ }
2578
+ return;
2579
+ }
2580
+ if (!this.list) {
2581
+ this.createNotificationsList();
2582
+ }
2583
+ this.isVisible = true;
2584
+ if (focus) {
2585
+ const list = assertIsDefined(this.list);
2586
+ list.domFocus();
2587
+ }
2588
+ }
2589
+ createNotificationsList() {
2590
+ this.listContainer = document.createElement('div');
2591
+ this.listContainer.classList.add('notifications-list-container');
2592
+ const actionRunner = this._register(this.instantiationService.createInstance(NotificationActionRunner));
2593
+ const renderer = this.instantiationService.createInstance(NotificationRenderer, actionRunner);
2594
+ const listDelegate = this.listDelegate = new NotificationsListDelegate(this.listContainer);
2595
+ const options = this.options;
2596
+ const list = this.list = this._register(this.instantiationService.createInstance(WorkbenchList, 'NotificationsList', this.listContainer, listDelegate, [renderer], {
2597
+ ...options,
2598
+ setRowLineHeight: false,
2599
+ horizontalScrolling: false,
2600
+ overrideStyles: {
2601
+ listBackground: NOTIFICATIONS_BACKGROUND
2602
+ },
2603
+ accessibilityProvider: {
2604
+ getAriaLabel(element) {
2605
+ if (!element.source) {
2606
+ return (
2607
+ localize('notificationAriaLabel', "{0}, notification", element.message.raw)
2608
+ );
2609
+ }
2610
+ return (
2611
+ localize(
2612
+ 'notificationWithSourceAriaLabel',
2613
+ "{0}, source: {1}, notification",
2614
+ element.message.raw,
2615
+ element.source
2616
+ )
2617
+ );
2618
+ },
2619
+ getWidgetAriaLabel() {
2620
+ return options.widgetAriaLabel ?? localize('notificationsList', "Notifications List");
2621
+ },
2622
+ getRole() {
2623
+ return 'dialog';
2624
+ }
2625
+ }
2626
+ }));
2627
+ const copyAction = this._register(this.instantiationService.createInstance(CopyNotificationMessageAction, CopyNotificationMessageAction.ID, CopyNotificationMessageAction.LABEL));
2628
+ this._register((list.onContextMenu(e => {
2629
+ if (!e.element) {
2630
+ return;
2631
+ }
2632
+ this.contextMenuService.showContextMenu({
2633
+ getAnchor: () => e.anchor,
2634
+ getActions: () => [copyAction],
2635
+ getActionsContext: () => e.element,
2636
+ actionRunner
2637
+ });
2638
+ })));
2639
+ this._register((list.onMouseDblClick(event => event.element.toggle())));
2640
+ const listFocusTracker = this._register(trackFocus(list.getHTMLElement()));
2641
+ this._register(listFocusTracker.onDidBlur(() => {
2642
+ if (document.hasFocus()) {
2643
+ list.setFocus([]);
2644
+ }
2645
+ }));
2646
+ NotificationFocusedContext.bindTo(list.contextKeyService);
2647
+ this._register(list.onDidChangeSelection(e => {
2648
+ if (e.indexes.length > 0) {
2649
+ list.setSelection([]);
2650
+ }
2651
+ }));
2652
+ this.container.appendChild(this.listContainer);
2653
+ this.updateStyles();
2654
+ }
2655
+ updateNotificationsList(start, deleteCount, items = []) {
2656
+ const [list, listContainer] = assertAllDefined(this.list, this.listContainer);
2657
+ const listHasDOMFocus = isAncestor(document.activeElement, listContainer);
2658
+ const focusedIndex = list.getFocus()[0];
2659
+ const focusedItem = this.viewModel[focusedIndex];
2660
+ let focusRelativeTop = null;
2661
+ if (typeof focusedIndex === 'number') {
2662
+ focusRelativeTop = list.getRelativeTop(focusedIndex);
2663
+ }
2664
+ this.viewModel.splice(start, deleteCount, ...items);
2665
+ list.splice(start, deleteCount, items);
2666
+ list.layout();
2667
+ if (this.viewModel.length === 0) {
2668
+ this.hide();
2669
+ }
2670
+ else if (typeof focusedIndex === 'number') {
2671
+ let indexToFocus = 0;
2672
+ if (focusedItem) {
2673
+ let indexToFocusCandidate = this.viewModel.indexOf(focusedItem);
2674
+ if (indexToFocusCandidate === -1) {
2675
+ indexToFocusCandidate = focusedIndex - 1;
2676
+ }
2677
+ if (indexToFocusCandidate < this.viewModel.length && indexToFocusCandidate >= 0) {
2678
+ indexToFocus = indexToFocusCandidate;
2679
+ }
2680
+ }
2681
+ if (typeof focusRelativeTop === 'number') {
2682
+ list.reveal(indexToFocus, focusRelativeTop);
2683
+ }
2684
+ list.setFocus([indexToFocus]);
2685
+ }
2686
+ if (this.isVisible && listHasDOMFocus) {
2687
+ list.domFocus();
2688
+ }
2689
+ }
2690
+ updateNotificationHeight(item) {
2691
+ const index = this.viewModel.indexOf(item);
2692
+ if (index === -1) {
2693
+ return;
2694
+ }
2695
+ const [list, listDelegate] = assertAllDefined(this.list, this.listDelegate);
2696
+ list.updateElementHeight(index, listDelegate.getHeight(item));
2697
+ list.layout();
2698
+ }
2699
+ hide() {
2700
+ if (!this.isVisible || !this.list) {
2701
+ return;
2702
+ }
2703
+ this.isVisible = false;
2704
+ this.list.splice(0, this.viewModel.length);
2705
+ this.viewModel = [];
2706
+ }
2707
+ focusFirst() {
2708
+ if (!this.isVisible || !this.list) {
2709
+ return;
2710
+ }
2711
+ this.list.focusFirst();
2712
+ this.list.domFocus();
2713
+ }
2714
+ hasFocus() {
2715
+ if (!this.isVisible || !this.listContainer) {
2716
+ return false;
2717
+ }
2718
+ return isAncestor(document.activeElement, this.listContainer);
2719
+ }
2720
+ updateStyles() {
2721
+ if (this.listContainer) {
2722
+ const foreground = this.getColor(NOTIFICATIONS_FOREGROUND);
2723
+ this.listContainer.style.color = foreground ? foreground : '';
2724
+ const background = this.getColor(NOTIFICATIONS_BACKGROUND);
2725
+ this.listContainer.style.background = background ? background : '';
2726
+ const outlineColor = this.getColor(contrastBorder);
2727
+ this.listContainer.style.outlineColor = outlineColor ? outlineColor : '';
2728
+ }
2729
+ }
2730
+ layout(width, maxHeight) {
2731
+ if (this.listContainer && this.list) {
2732
+ this.listContainer.style.width = `${width}px`;
2733
+ if (typeof maxHeight === 'number') {
2734
+ this.list.getHTMLElement().style.maxHeight = `${maxHeight}px`;
2735
+ }
2736
+ this.list.layout();
2737
+ }
2738
+ }
2739
+ dispose() {
2740
+ this.hide();
2741
+ super.dispose();
2742
+ }
2743
+ };
2744
+ NotificationsList = __decorate([
2745
+ __param(2, IInstantiationService),
2746
+ __param(3, IThemeService),
2747
+ __param(4, IContextMenuService)
2748
+ ], NotificationsList);
2749
+ registerThemingParticipant((theme, collector) => {
2750
+ const linkColor = theme.getColor(NOTIFICATIONS_LINKS);
2751
+ if (linkColor) {
2752
+ collector.addRule(`.monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-message a { color: ${linkColor}; }`);
2753
+ }
2754
+ const focusOutline = theme.getColor(focusBorder);
2755
+ if (focusOutline) {
2756
+ collector.addRule(`
2757
+ .monaco-workbench .notifications-list-container .notification-list-item .notification-list-item-message a:focus {
2758
+ outline-color: ${focusOutline};
2759
+ }`);
2760
+ }
2761
+ const notificationErrorIconForegroundColor = theme.getColor(NOTIFICATIONS_ERROR_ICON_FOREGROUND);
2762
+ if (notificationErrorIconForegroundColor) {
2763
+ const errorCodiconSelector = Codicon.error.cssSelector;
2764
+ collector.addRule(`
2765
+ .monaco-workbench .notifications-center ${errorCodiconSelector},
2766
+ .monaco-workbench .notifications-toasts ${errorCodiconSelector} {
2767
+ color: ${notificationErrorIconForegroundColor};
2768
+ }`);
2769
+ }
2770
+ const notificationWarningIconForegroundColor = theme.getColor(NOTIFICATIONS_WARNING_ICON_FOREGROUND);
2771
+ if (notificationWarningIconForegroundColor) {
2772
+ const warningCodiconSelector = Codicon.warning.cssSelector;
2773
+ collector.addRule(`
2774
+ .monaco-workbench .notifications-center ${warningCodiconSelector},
2775
+ .monaco-workbench .notifications-toasts ${warningCodiconSelector} {
2776
+ color: ${notificationWarningIconForegroundColor};
2777
+ }`);
2778
+ }
2779
+ const notificationInfoIconForegroundColor = theme.getColor(NOTIFICATIONS_INFO_ICON_FOREGROUND);
2780
+ if (notificationInfoIconForegroundColor) {
2781
+ const infoCodiconSelector = Codicon.info.cssSelector;
2782
+ collector.addRule(`
2783
+ .monaco-workbench .notifications-center ${infoCodiconSelector},
2784
+ .monaco-workbench .notifications-toasts ${infoCodiconSelector} {
2785
+ color: ${notificationInfoIconForegroundColor};
2786
+ }`);
2787
+ }
2788
+ });
2789
+ const IWorkbenchLayoutService = refineServiceDecorator(ILayoutService);
2790
+ var ToastVisibility;
2791
+ (function(ToastVisibility) {
2792
+ ToastVisibility[ToastVisibility["HIDDEN_OR_VISIBLE"] = 0] = "HIDDEN_OR_VISIBLE";
2793
+ ToastVisibility[ToastVisibility["HIDDEN"] = 1] = "HIDDEN";
2794
+ ToastVisibility[ToastVisibility["VISIBLE"] = 2] = "VISIBLE";
2795
+ })(ToastVisibility || (ToastVisibility = {}));
2796
+ let NotificationsToasts = class NotificationsToasts extends Themable {
2797
+ constructor(container, model, instantiationService, layoutService, themeService, editorGroupService, contextKeyService, lifecycleService, hostService) {
2798
+ super(themeService);
2799
+ this.container = container;
2800
+ this.model = model;
2801
+ this.instantiationService = instantiationService;
2802
+ this.layoutService = layoutService;
2803
+ this.editorGroupService = editorGroupService;
2804
+ this.contextKeyService = contextKeyService;
2805
+ this.lifecycleService = lifecycleService;
2806
+ this.hostService = hostService;
2807
+ this._onDidChangeVisibility = this._register( new Emitter());
2808
+ this.onDidChangeVisibility = this._onDidChangeVisibility.event;
2809
+ this._isVisible = false;
2810
+ this.mapNotificationToToast = new Map();
2811
+ this.mapNotificationToDisposable = new Map();
2812
+ this.notificationsToastsVisibleContextKey = NotificationsToastsVisibleContext.bindTo(this.contextKeyService);
2813
+ this.addedToastsIntervalCounter = new IntervalCounter(NotificationsToasts.SPAM_PROTECTION.interval);
2814
+ this.registerListeners();
2815
+ }
2816
+ get isVisible() { return !!this._isVisible; }
2817
+ registerListeners() {
2818
+ this._register(this.layoutService.onDidLayout(dimension => this.layout(Dimension.lift(dimension))));
2819
+ this.lifecycleService.when(3 ).then(() => {
2820
+ this.model.notifications.forEach(notification => this.addToast(notification));
2821
+ this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
2822
+ });
2823
+ this._register(this.model.onDidChangeFilter(filter => {
2824
+ if (filter === NotificationsFilter.SILENT || filter === NotificationsFilter.ERROR) {
2825
+ this.hide();
2826
+ }
2827
+ }));
2828
+ }
2829
+ onDidChangeNotification(e) {
2830
+ switch (e.kind) {
2831
+ case 0 :
2832
+ return this.addToast(e.item);
2833
+ case 3 :
2834
+ return this.removeToast(e.item);
2835
+ }
2836
+ }
2837
+ addToast(item) {
2838
+ if (this.isNotificationsCenterVisible) {
2839
+ return;
2840
+ }
2841
+ if (item.silent) {
2842
+ return;
2843
+ }
2844
+ if (this.addedToastsIntervalCounter.increment() > NotificationsToasts.SPAM_PROTECTION.limit) {
2845
+ return;
2846
+ }
2847
+ const itemDisposables = new DisposableStore();
2848
+ this.mapNotificationToDisposable.set(item, itemDisposables);
2849
+ itemDisposables.add(scheduleAtNextAnimationFrame(() => this.doAddToast(item, itemDisposables)));
2850
+ }
2851
+ doAddToast(item, itemDisposables) {
2852
+ let notificationsToastsContainer = this.notificationsToastsContainer;
2853
+ if (!notificationsToastsContainer) {
2854
+ notificationsToastsContainer = this.notificationsToastsContainer = document.createElement('div');
2855
+ notificationsToastsContainer.classList.add('notifications-toasts');
2856
+ this.container.appendChild(notificationsToastsContainer);
2857
+ }
2858
+ notificationsToastsContainer.classList.add('visible');
2859
+ const notificationToastContainer = document.createElement('div');
2860
+ notificationToastContainer.classList.add('notification-toast-container');
2861
+ const firstToast = notificationsToastsContainer.firstChild;
2862
+ if (firstToast) {
2863
+ notificationsToastsContainer.insertBefore(notificationToastContainer, firstToast);
2864
+ }
2865
+ else {
2866
+ notificationsToastsContainer.appendChild(notificationToastContainer);
2867
+ }
2868
+ const notificationToast = document.createElement('div');
2869
+ notificationToast.classList.add('notification-toast');
2870
+ notificationToastContainer.appendChild(notificationToast);
2871
+ const notificationList = this.instantiationService.createInstance(NotificationsList, notificationToast, {
2872
+ verticalScrollMode: 2 ,
2873
+ widgetAriaLabel: (() => {
2874
+ if (!item.source) {
2875
+ return (
2876
+ localize('notificationAriaLabel', "{0}, notification", item.message.raw)
2877
+ );
2878
+ }
2879
+ return (
2880
+ localize(
2881
+ 'notificationWithSourceAriaLabel',
2882
+ "{0}, source: {1}, notification",
2883
+ item.message.raw,
2884
+ item.source
2885
+ )
2886
+ );
2887
+ })()
2888
+ });
2889
+ itemDisposables.add(notificationList);
2890
+ const toast = { item, list: notificationList, container: notificationToastContainer, toast: notificationToast };
2891
+ this.mapNotificationToToast.set(item, toast);
2892
+ itemDisposables.add(toDisposable(() => this.updateToastVisibility(toast, false)));
2893
+ notificationList.show();
2894
+ const maxDimensions = this.computeMaxDimensions();
2895
+ this.layoutLists(maxDimensions.width);
2896
+ notificationList.updateNotificationsList(0, 0, [item]);
2897
+ this.layoutContainer(maxDimensions.height);
2898
+ itemDisposables.add(item.onDidChangeExpansion(() => {
2899
+ notificationList.updateNotificationsList(0, 1, [item]);
2900
+ }));
2901
+ itemDisposables.add(item.onDidChangeContent(e => {
2902
+ switch (e.kind) {
2903
+ case 2 :
2904
+ notificationList.updateNotificationsList(0, 1, [item]);
2905
+ break;
2906
+ case 1 :
2907
+ if (item.expanded) {
2908
+ notificationList.updateNotificationHeight(item);
2909
+ }
2910
+ break;
2911
+ }
2912
+ }));
2913
+ Event.once(item.onDidClose)(() => {
2914
+ this.removeToast(item);
2915
+ });
2916
+ this.purgeNotification(item, notificationToastContainer, notificationList, itemDisposables);
2917
+ this.updateStyles();
2918
+ this.notificationsToastsVisibleContextKey.set(true);
2919
+ notificationToast.classList.add('notification-fade-in');
2920
+ itemDisposables.add(addDisposableListener(notificationToast, 'transitionend', () => {
2921
+ notificationToast.classList.remove('notification-fade-in');
2922
+ notificationToast.classList.add('notification-fade-in-done');
2923
+ }));
2924
+ item.updateVisibility(true);
2925
+ if (!this._isVisible) {
2926
+ this._isVisible = true;
2927
+ this._onDidChangeVisibility.fire();
2928
+ }
2929
+ }
2930
+ purgeNotification(item, notificationToastContainer, notificationList, disposables) {
2931
+ let isMouseOverToast = false;
2932
+ disposables.add(addDisposableListener(notificationToastContainer, EventType.MOUSE_OVER, () => isMouseOverToast = true));
2933
+ disposables.add(addDisposableListener(notificationToastContainer, EventType.MOUSE_OUT, () => isMouseOverToast = false));
2934
+ let purgeTimeoutHandle;
2935
+ let listener;
2936
+ const hideAfterTimeout = () => {
2937
+ purgeTimeoutHandle = setTimeout(() => {
2938
+ if (!this.hostService.hasFocus) {
2939
+ if (!listener) {
2940
+ listener = this.hostService.onDidChangeFocus(focus => {
2941
+ if (focus) {
2942
+ hideAfterTimeout();
2943
+ }
2944
+ });
2945
+ disposables.add(listener);
2946
+ }
2947
+ }
2948
+ else if (item.sticky ||
2949
+ notificationList.hasFocus() ||
2950
+ isMouseOverToast
2951
+ ) {
2952
+ hideAfterTimeout();
2953
+ }
2954
+ else {
2955
+ this.removeToast(item);
2956
+ }
2957
+ }, NotificationsToasts.PURGE_TIMEOUT[item.severity]);
2958
+ };
2959
+ hideAfterTimeout();
2960
+ disposables.add(toDisposable(() => clearTimeout(purgeTimeoutHandle)));
2961
+ }
2962
+ removeToast(item) {
2963
+ let focusEditor = false;
2964
+ const notificationToast = this.mapNotificationToToast.get(item);
2965
+ if (notificationToast) {
2966
+ const toastHasDOMFocus = isAncestor(document.activeElement, notificationToast.container);
2967
+ if (toastHasDOMFocus) {
2968
+ focusEditor = !(this.focusNext() || this.focusPrevious());
2969
+ }
2970
+ this.mapNotificationToToast.delete(item);
2971
+ }
2972
+ const notificationDisposables = this.mapNotificationToDisposable.get(item);
2973
+ if (notificationDisposables) {
2974
+ dispose(notificationDisposables);
2975
+ this.mapNotificationToDisposable.delete(item);
2976
+ }
2977
+ if (this.mapNotificationToToast.size > 0) {
2978
+ this.layout(this.workbenchDimensions);
2979
+ }
2980
+ else {
2981
+ this.doHide();
2982
+ if (focusEditor) {
2983
+ this.editorGroupService.activeGroup.focus();
2984
+ }
2985
+ }
2986
+ }
2987
+ removeToasts() {
2988
+ this.mapNotificationToToast.clear();
2989
+ this.mapNotificationToDisposable.forEach(disposable => dispose(disposable));
2990
+ this.mapNotificationToDisposable.clear();
2991
+ this.doHide();
2992
+ }
2993
+ doHide() {
2994
+ if (this.notificationsToastsContainer) {
2995
+ this.notificationsToastsContainer.classList.remove('visible');
2996
+ }
2997
+ this.notificationsToastsVisibleContextKey.set(false);
2998
+ if (this._isVisible) {
2999
+ this._isVisible = false;
3000
+ this._onDidChangeVisibility.fire();
3001
+ }
3002
+ }
3003
+ hide() {
3004
+ const focusEditor = this.notificationsToastsContainer ? isAncestor(document.activeElement, this.notificationsToastsContainer) : false;
3005
+ this.removeToasts();
3006
+ if (focusEditor) {
3007
+ this.editorGroupService.activeGroup.focus();
3008
+ }
3009
+ }
3010
+ focus() {
3011
+ const toasts = this.getToasts(ToastVisibility.VISIBLE);
3012
+ if (toasts.length > 0) {
3013
+ toasts[0].list.focusFirst();
3014
+ return true;
3015
+ }
3016
+ return false;
3017
+ }
3018
+ focusNext() {
3019
+ const toasts = this.getToasts(ToastVisibility.VISIBLE);
3020
+ for (let i = 0; i < toasts.length; i++) {
3021
+ const toast = toasts[i];
3022
+ if (toast.list.hasFocus()) {
3023
+ const nextToast = toasts[i + 1];
3024
+ if (nextToast) {
3025
+ nextToast.list.focusFirst();
3026
+ return true;
3027
+ }
3028
+ break;
3029
+ }
3030
+ }
3031
+ return false;
3032
+ }
3033
+ focusPrevious() {
3034
+ const toasts = this.getToasts(ToastVisibility.VISIBLE);
3035
+ for (let i = 0; i < toasts.length; i++) {
3036
+ const toast = toasts[i];
3037
+ if (toast.list.hasFocus()) {
3038
+ const previousToast = toasts[i - 1];
3039
+ if (previousToast) {
3040
+ previousToast.list.focusFirst();
3041
+ return true;
3042
+ }
3043
+ break;
3044
+ }
3045
+ }
3046
+ return false;
3047
+ }
3048
+ focusFirst() {
3049
+ const toast = this.getToasts(ToastVisibility.VISIBLE)[0];
3050
+ if (toast) {
3051
+ toast.list.focusFirst();
3052
+ return true;
3053
+ }
3054
+ return false;
3055
+ }
3056
+ focusLast() {
3057
+ const toasts = this.getToasts(ToastVisibility.VISIBLE);
3058
+ if (toasts.length > 0) {
3059
+ toasts[toasts.length - 1].list.focusFirst();
3060
+ return true;
3061
+ }
3062
+ return false;
3063
+ }
3064
+ update(isCenterVisible) {
3065
+ if (this.isNotificationsCenterVisible !== isCenterVisible) {
3066
+ this.isNotificationsCenterVisible = isCenterVisible;
3067
+ if (this.isNotificationsCenterVisible) {
3068
+ this.removeToasts();
3069
+ }
3070
+ }
3071
+ }
3072
+ updateStyles() {
3073
+ this.mapNotificationToToast.forEach(({ toast }) => {
3074
+ const backgroundColor = this.getColor(NOTIFICATIONS_BACKGROUND);
3075
+ toast.style.background = backgroundColor ? backgroundColor : '';
3076
+ const widgetShadowColor = this.getColor(widgetShadow);
3077
+ toast.style.boxShadow = widgetShadowColor ? `0 0 8px 2px ${widgetShadowColor}` : '';
3078
+ const borderColor = this.getColor(NOTIFICATIONS_TOAST_BORDER);
3079
+ toast.style.border = borderColor ? `1px solid ${borderColor}` : '';
3080
+ });
3081
+ }
3082
+ getToasts(state) {
3083
+ const notificationToasts = [];
3084
+ this.mapNotificationToToast.forEach(toast => {
3085
+ switch (state) {
3086
+ case ToastVisibility.HIDDEN_OR_VISIBLE:
3087
+ notificationToasts.push(toast);
3088
+ break;
3089
+ case ToastVisibility.HIDDEN:
3090
+ if (!this.isToastInDOM(toast)) {
3091
+ notificationToasts.push(toast);
3092
+ }
3093
+ break;
3094
+ case ToastVisibility.VISIBLE:
3095
+ if (this.isToastInDOM(toast)) {
3096
+ notificationToasts.push(toast);
3097
+ }
3098
+ break;
3099
+ }
3100
+ });
3101
+ return notificationToasts.reverse();
3102
+ }
3103
+ layout(dimension) {
3104
+ this.workbenchDimensions = dimension;
3105
+ const maxDimensions = this.computeMaxDimensions();
3106
+ if (maxDimensions.height) {
3107
+ this.layoutContainer(maxDimensions.height);
3108
+ }
3109
+ this.layoutLists(maxDimensions.width);
3110
+ }
3111
+ computeMaxDimensions() {
3112
+ let maxWidth = NotificationsToasts.MAX_WIDTH;
3113
+ let availableWidth = maxWidth;
3114
+ let availableHeight;
3115
+ if (this.workbenchDimensions) {
3116
+ availableWidth = this.workbenchDimensions.width;
3117
+ availableWidth -= (2 * 8);
3118
+ availableHeight = this.workbenchDimensions.height;
3119
+ if (this.layoutService.isVisible("workbench.parts.statusbar" )) {
3120
+ availableHeight -= 22;
3121
+ }
3122
+ if (this.layoutService.isVisible("workbench.parts.titlebar" )) {
3123
+ availableHeight -= 22;
3124
+ }
3125
+ availableHeight -= (2 * 12);
3126
+ }
3127
+ availableHeight = typeof availableHeight === 'number'
3128
+ ? Math.round(availableHeight * 0.618)
3129
+ : 0;
3130
+ return (
3131
+ new Dimension(Math.min(maxWidth, availableWidth), availableHeight)
3132
+ );
3133
+ }
3134
+ layoutLists(width) {
3135
+ this.mapNotificationToToast.forEach(({ list }) => list.layout(width));
3136
+ }
3137
+ layoutContainer(heightToGive) {
3138
+ let visibleToasts = 0;
3139
+ for (const toast of this.getToasts(ToastVisibility.HIDDEN_OR_VISIBLE)) {
3140
+ toast.container.style.opacity = '0';
3141
+ this.updateToastVisibility(toast, true);
3142
+ heightToGive -= toast.container.offsetHeight;
3143
+ let makeVisible = false;
3144
+ if (visibleToasts === NotificationsToasts.MAX_NOTIFICATIONS) {
3145
+ makeVisible = false;
3146
+ }
3147
+ else if (heightToGive >= 0) {
3148
+ makeVisible = true;
3149
+ }
3150
+ this.updateToastVisibility(toast, makeVisible);
3151
+ toast.container.style.opacity = '';
3152
+ if (makeVisible) {
3153
+ visibleToasts++;
3154
+ }
3155
+ }
3156
+ }
3157
+ updateToastVisibility(toast, visible) {
3158
+ if (this.isToastInDOM(toast) === visible) {
3159
+ return;
3160
+ }
3161
+ const notificationsToastsContainer = assertIsDefined(this.notificationsToastsContainer);
3162
+ if (visible) {
3163
+ notificationsToastsContainer.appendChild(toast.container);
3164
+ }
3165
+ else {
3166
+ notificationsToastsContainer.removeChild(toast.container);
3167
+ }
3168
+ toast.item.updateVisibility(visible);
3169
+ }
3170
+ isToastInDOM(toast) {
3171
+ return !!toast.container.parentElement;
3172
+ }
3173
+ };
3174
+ NotificationsToasts.MAX_WIDTH = 450;
3175
+ NotificationsToasts.MAX_NOTIFICATIONS = 3;
3176
+ NotificationsToasts.PURGE_TIMEOUT = {
3177
+ [Severity.Info]: 15000,
3178
+ [Severity.Warning]: 18000,
3179
+ [Severity.Error]: 20000
3180
+ };
3181
+ NotificationsToasts.SPAM_PROTECTION = {
3182
+ interval: 800,
3183
+ limit: NotificationsToasts.MAX_NOTIFICATIONS
3184
+ };
3185
+ NotificationsToasts = __decorate([
3186
+ __param(2, IInstantiationService),
3187
+ __param(3, IWorkbenchLayoutService),
3188
+ __param(4, IThemeService),
3189
+ __param(5, IEditorGroupsService),
3190
+ __param(6, IContextKeyService),
3191
+ __param(7, ILifecycleService),
3192
+ __param(8, IHostService)
3193
+ ], NotificationsToasts);
3194
+ let NotificationService = class NotificationService extends Disposable {
3195
+ constructor(storageService) {
3196
+ super();
3197
+ this.storageService = storageService;
3198
+ this.model = this._register( new NotificationsModel());
3199
+ this._onDidAddNotification = this._register( new Emitter());
3200
+ this.onDidAddNotification = this._onDidAddNotification.event;
3201
+ this._onDidRemoveNotification = this._register( new Emitter());
3202
+ this.onDidRemoveNotification = this._onDidRemoveNotification.event;
3203
+ this.registerListeners();
3204
+ }
3205
+ registerListeners() {
3206
+ this._register(this.model.onDidChangeNotification(e => {
3207
+ switch (e.kind) {
3208
+ case 0 :
3209
+ case 3 : {
3210
+ const notification = {
3211
+ message: e.item.message.original,
3212
+ severity: e.item.severity,
3213
+ source: typeof e.item.sourceId === 'string' && typeof e.item.source === 'string' ? { id: e.item.sourceId, label: e.item.source } : e.item.source,
3214
+ silent: e.item.silent
3215
+ };
3216
+ if (e.kind === 0 ) {
3217
+ this._onDidAddNotification.fire(notification);
3218
+ }
3219
+ if (e.kind === 3 ) {
3220
+ this._onDidRemoveNotification.fire(notification);
3221
+ }
3222
+ break;
3223
+ }
3224
+ }
3225
+ }));
3226
+ }
3227
+ setFilter(filter) {
3228
+ this.model.setFilter(filter);
3229
+ }
3230
+ info(message) {
3231
+ if (Array.isArray(message)) {
3232
+ message.forEach(m => this.info(m));
3233
+ return;
3234
+ }
3235
+ this.model.addNotification({ severity: Severity.Info, message });
3236
+ }
3237
+ warn(message) {
3238
+ if (Array.isArray(message)) {
3239
+ message.forEach(m => this.warn(m));
3240
+ return;
3241
+ }
3242
+ this.model.addNotification({ severity: Severity.Warning, message });
3243
+ }
3244
+ error(message) {
3245
+ if (Array.isArray(message)) {
3246
+ message.forEach(m => this.error(m));
3247
+ return;
3248
+ }
3249
+ this.model.addNotification({ severity: Severity.Error, message });
3250
+ }
3251
+ notify(notification) {
3252
+ const toDispose = new DisposableStore();
3253
+ let handle;
3254
+ if (notification.neverShowAgain) {
3255
+ const scope = notification.neverShowAgain.scope === NeverShowAgainScope.WORKSPACE ? 1 : 0 ;
3256
+ const id = notification.neverShowAgain.id;
3257
+ if (this.storageService.getBoolean(id, scope)) {
3258
+ return (
3259
+ new NoOpNotification()
3260
+ );
3261
+ }
3262
+ const neverShowAgainAction = toDispose.add( new Action('workbench.notification.neverShowAgain', localize('neverShowAgain', "Don't Show Again"), undefined, true, async () => {
3263
+ handle.close();
3264
+ this.storageService.store(id, true, scope, 0 );
3265
+ }));
3266
+ const actions = {
3267
+ primary: notification.actions?.primary || [],
3268
+ secondary: notification.actions?.secondary || []
3269
+ };
3270
+ if (!notification.neverShowAgain.isSecondary) {
3271
+ actions.primary = [neverShowAgainAction, ...actions.primary];
3272
+ }
3273
+ else {
3274
+ actions.secondary = [...actions.secondary, neverShowAgainAction];
3275
+ }
3276
+ notification.actions = actions;
3277
+ }
3278
+ handle = this.model.addNotification(notification);
3279
+ Event.once(handle.onDidClose)(() => toDispose.dispose());
3280
+ return handle;
3281
+ }
3282
+ prompt(severity, message, choices, options) {
3283
+ const toDispose = new DisposableStore();
3284
+ if (options?.neverShowAgain) {
3285
+ const scope = options.neverShowAgain.scope === NeverShowAgainScope.WORKSPACE ? 1 : 0 ;
3286
+ const id = options.neverShowAgain.id;
3287
+ if (this.storageService.getBoolean(id, scope)) {
3288
+ return (
3289
+ new NoOpNotification()
3290
+ );
3291
+ }
3292
+ const neverShowAgainChoice = {
3293
+ label: localize('neverShowAgain', "Don't Show Again"),
3294
+ run: () => this.storageService.store(id, true, scope, 0 ),
3295
+ isSecondary: options.neverShowAgain.isSecondary
3296
+ };
3297
+ if (!options.neverShowAgain.isSecondary) {
3298
+ choices = [neverShowAgainChoice, ...choices];
3299
+ }
3300
+ else {
3301
+ choices = [...choices, neverShowAgainChoice];
3302
+ }
3303
+ }
3304
+ let choiceClicked = false;
3305
+ let handle;
3306
+ const primaryActions = [];
3307
+ const secondaryActions = [];
3308
+ choices.forEach((choice, index) => {
3309
+ const action = new ChoiceAction(`workbench.dialog.choice.${index}`, choice);
3310
+ if (!choice.isSecondary) {
3311
+ primaryActions.push(action);
3312
+ }
3313
+ else {
3314
+ secondaryActions.push(action);
3315
+ }
3316
+ toDispose.add(action.onDidRun(() => {
3317
+ choiceClicked = true;
3318
+ if (!choice.keepOpen) {
3319
+ handle.close();
3320
+ }
3321
+ }));
3322
+ toDispose.add(action);
3323
+ });
3324
+ const actions = { primary: primaryActions, secondary: secondaryActions };
3325
+ handle = this.notify({ severity, message, actions, sticky: options?.sticky, silent: options?.silent });
3326
+ Event.once(handle.onDidClose)(() => {
3327
+ toDispose.dispose();
3328
+ if (options && typeof options.onCancel === 'function' && !choiceClicked) {
3329
+ options.onCancel();
3330
+ }
3331
+ });
3332
+ return handle;
3333
+ }
3334
+ status(message, options) {
3335
+ return this.model.showStatusMessage(message, options);
3336
+ }
3337
+ };
3338
+ NotificationService = __decorate([
3339
+ __param(0, IStorageService)
3340
+ ], NotificationService);
3341
+ const defaultOpts = {
3342
+ inputActiveOptionBorder: Color.fromHex('#007ACC00'),
3343
+ inputActiveOptionForeground: Color.fromHex('#FFFFFF'),
3344
+ inputActiveOptionBackground: Color.fromHex('#0E639C50')
3345
+ };
3346
+ class Checkbox extends Widget {
3347
+ constructor(opts) {
3348
+ super();
3349
+ this._onChange = this._register( new Emitter());
3350
+ this.onChange = this._onChange.event;
3351
+ this._onKeyDown = this._register( new Emitter());
3352
+ this.onKeyDown = this._onKeyDown.event;
3353
+ this._opts = { ...defaultOpts, ...opts };
3354
+ this._checked = this._opts.isChecked;
3355
+ const classes = ['monaco-custom-checkbox'];
3356
+ if (this._opts.icon) {
3357
+ classes.push(...CSSIcon.asClassNameArray(this._opts.icon));
3358
+ }
3359
+ if (this._opts.actionClassName) {
3360
+ classes.push(...this._opts.actionClassName.split(' '));
3361
+ }
3362
+ if (this._checked) {
3363
+ classes.push('checked');
3364
+ }
3365
+ this.domNode = document.createElement('div');
3366
+ this.domNode.title = this._opts.title;
3367
+ this.domNode.classList.add(...classes);
3368
+ if (!this._opts.notFocusable) {
3369
+ this.domNode.tabIndex = 0;
3370
+ }
3371
+ this.domNode.setAttribute('role', 'checkbox');
3372
+ this.domNode.setAttribute('aria-checked', String(this._checked));
3373
+ this.domNode.setAttribute('aria-label', this._opts.title);
3374
+ this.applyStyles();
3375
+ this.onclick(this.domNode, (ev) => {
3376
+ if (this.enabled) {
3377
+ this.checked = !this._checked;
3378
+ this._onChange.fire(false);
3379
+ ev.preventDefault();
3380
+ }
3381
+ });
3382
+ this.ignoreGesture(this.domNode);
3383
+ this.onkeydown(this.domNode, (keyboardEvent) => {
3384
+ if (keyboardEvent.keyCode === 10 || keyboardEvent.keyCode === 3 ) {
3385
+ this.checked = !this._checked;
3386
+ this._onChange.fire(true);
3387
+ keyboardEvent.preventDefault();
3388
+ return;
3389
+ }
3390
+ this._onKeyDown.fire(keyboardEvent);
3391
+ });
3392
+ }
3393
+ get enabled() {
3394
+ return this.domNode.getAttribute('aria-disabled') !== 'true';
3395
+ }
3396
+ focus() {
3397
+ this.domNode.focus();
3398
+ }
3399
+ get checked() {
3400
+ return this._checked;
3401
+ }
3402
+ set checked(newIsChecked) {
3403
+ this._checked = newIsChecked;
3404
+ this.domNode.setAttribute('aria-checked', String(this._checked));
3405
+ this.domNode.classList.toggle('checked', this._checked);
3406
+ this.applyStyles();
3407
+ }
3408
+ width() {
3409
+ return 2 + 2 + 2 + 16 ;
3410
+ }
3411
+ style(styles) {
3412
+ if (styles.inputActiveOptionBorder) {
3413
+ this._opts.inputActiveOptionBorder = styles.inputActiveOptionBorder;
3414
+ }
3415
+ if (styles.inputActiveOptionForeground) {
3416
+ this._opts.inputActiveOptionForeground = styles.inputActiveOptionForeground;
3417
+ }
3418
+ if (styles.inputActiveOptionBackground) {
3419
+ this._opts.inputActiveOptionBackground = styles.inputActiveOptionBackground;
3420
+ }
3421
+ this.applyStyles();
3422
+ }
3423
+ applyStyles() {
3424
+ if (this.domNode) {
3425
+ this.domNode.style.borderColor = this._checked && this._opts.inputActiveOptionBorder ? this._opts.inputActiveOptionBorder.toString() : '';
3426
+ this.domNode.style.color = this._checked && this._opts.inputActiveOptionForeground ? this._opts.inputActiveOptionForeground.toString() : 'inherit';
3427
+ this.domNode.style.backgroundColor = this._checked && this._opts.inputActiveOptionBackground ? this._opts.inputActiveOptionBackground.toString() : '';
3428
+ }
3429
+ }
3430
+ enable() {
3431
+ this.domNode.setAttribute('aria-disabled', String(false));
3432
+ }
3433
+ disable() {
3434
+ this.domNode.setAttribute('aria-disabled', String(true));
3435
+ }
3436
+ setTitle(newTitle) {
3437
+ this.domNode.title = newTitle;
3438
+ this.domNode.setAttribute('aria-label', newTitle);
3439
+ }
3440
+ }
3441
+ class SimpleCheckbox extends Widget {
3442
+ constructor(title, isChecked) {
3443
+ super();
3444
+ this.title = title;
3445
+ this.isChecked = isChecked;
3446
+ this.checkbox = new Checkbox(
3447
+ { title: this.title, isChecked: this.isChecked, icon: Codicon.check, actionClassName: 'monaco-simple-checkbox' }
3448
+ );
3449
+ this.domNode = this.checkbox.domNode;
3450
+ this.styles = {};
3451
+ this.checkbox.onChange(() => {
3452
+ this.applyStyles();
3453
+ });
3454
+ }
3455
+ get checked() {
3456
+ return this.checkbox.checked;
3457
+ }
3458
+ set checked(newIsChecked) {
3459
+ this.checkbox.checked = newIsChecked;
3460
+ this.applyStyles();
3461
+ }
3462
+ focus() {
3463
+ this.domNode.focus();
3464
+ }
3465
+ hasFocus() {
3466
+ return this.domNode === document.activeElement;
3467
+ }
3468
+ style(styles) {
3469
+ this.styles = styles;
3470
+ this.applyStyles();
3471
+ }
3472
+ applyStyles() {
3473
+ this.domNode.style.color = this.styles.checkboxForeground ? this.styles.checkboxForeground.toString() : '';
3474
+ this.domNode.style.backgroundColor = this.styles.checkboxBackground ? this.styles.checkboxBackground.toString() : '';
3475
+ this.domNode.style.borderColor = this.styles.checkboxBorder ? this.styles.checkboxBorder.toString() : '';
3476
+ }
3477
+ }
3478
+ function mnemonicButtonLabel(label, forceDisableMnemonics) {
3479
+ if (isMacintosh || forceDisableMnemonics) {
3480
+ return label.replace(/\(&&\w\)|&&/g, '');
3481
+ }
3482
+ if (isWindows) {
3483
+ return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
3484
+ }
3485
+ return label.replace(/&&/g, '_');
3486
+ }
3487
+ var css = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n/** Dialog: Modal Block */\n.monaco-dialog-modal-block {\n\tposition: fixed;\n\theight: 100%;\n\twidth: 100%;\n\tleft:0;\n\ttop:0;\n\tz-index: 2600;\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n}\n\n.monaco-dialog-modal-block.dimmed {\n\tbackground: rgba(0, 0, 0, 0.3);\n}\n\n/** Dialog: Container */\n.monaco-dialog-box {\n\tdisplay: flex;\n\tflex-direction: column-reverse;\n\twidth: min-content;\n\tmin-width: 500px;\n\tmax-width: 90vw;\n\tmin-height: 75px;\n\tpadding: 10px;\n\ttransform: translate3d(0px, 0px, 0px);\n}\n\n/** Dialog: Title Actions Row */\n.monaco-dialog-box .dialog-toolbar-row {\n\theight: 22px;\n\tpadding-bottom: 4px;\n}\n\n.monaco-dialog-box .dialog-toolbar-row .actions-container {\n\tjustify-content: flex-end;\n}\n\n/** Dialog: Message Row */\n.monaco-dialog-box .dialog-message-row {\n\tdisplay: flex;\n\tflex-grow: 1;\n\talign-items: center;\n\tpadding: 0 10px;\n}\n\n.monaco-dialog-box .dialog-message-row > .dialog-icon.codicon {\n\tflex: 0 0 48px;\n\theight: 48px;\n\talign-self: baseline;\n\tfont-size: 48px;\n}\n\n/** Dialog: Message Container */\n.monaco-dialog-box .dialog-message-row .dialog-message-container {\n\tdisplay: flex;\n\tflex-direction: column;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tpadding-left: 24px;\n\tuser-select: text;\n\t-webkit-user-select: text;\n\t-ms-user-select: text;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n\twhite-space: normal;\n}\n\n/** Dialog: Message */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message {\n\tline-height: 22px;\n\tfont-size: 18px;\n\tflex: 1; /* let the message always grow */\n\twhite-space: normal;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n\tmin-height: 48px; /* matches icon height */\n\tmargin-bottom: 8px;\n\tdisplay: flex;\n\talign-items: center;\n}\n\n/** Dialog: Details */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-detail {\n\tline-height: 22px;\n\tflex: 1; /* let the message always grow */\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message a:focus {\n\toutline-width: 1px;\n\toutline-style: solid;\n}\n\n/** Dialog: Checkbox */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row {\n\tpadding: 15px 0px 0px;\n\tdisplay: flex;\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row .dialog-checkbox-message {\n\tcursor: pointer;\n\tuser-select: none;\n\t-webkit-user-select: none;\n\t-ms-user-select: none;\n}\n\n/** Dialog: Input */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input {\n\tpadding: 15px 0px 0px;\n\tdisplay: flex;\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input .monaco-inputbox {\n\tflex: 1;\n}\n\n/** Dialog: File Path */\n.monaco-dialog-box code {\n\tfont-family: var(--monaco-monospace-font);\n}\n\n/** Dialog: Buttons Row */\n.monaco-dialog-box > .dialog-buttons-row {\n\tdisplay: flex;\n\talign-items: center;\n\tpadding-right: 1px;\n\toverflow: hidden; /* buttons row should never overflow */\n}\n\n.monaco-dialog-box > .dialog-buttons-row {\n\tdisplay: flex;\n\twhite-space: nowrap;\n\tpadding: 20px 10px 10px;\n}\n\n/** Dialog: Buttons */\n.monaco-dialog-box > .dialog-buttons-row > .dialog-buttons {\n\tdisplay: flex;\n\twidth: 100%;\n\tjustify-content: flex-end;\n\toverflow: hidden;\n\tmargin-left: 67px; /* for long buttons, force align with text */\n}\n\n.monaco-dialog-box > .dialog-buttons-row > .dialog-buttons > .monaco-button {\n\twidth: fit-content;\n\twidth: -moz-fit-content;\n\tpadding: 5px 10px;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tmargin: 4px 5px; /* allows button focus outline to be visible */\n\toutline-offset: 2px !important;\n}\n";
3488
+ n(css,{});
3489
+ class Dialog extends Disposable {
3490
+ constructor(container, message, buttons, options) {
3491
+ super();
3492
+ this.container = container;
3493
+ this.message = message;
3494
+ this.options = options;
3495
+ this.modalElement = this.container.appendChild($(`.monaco-dialog-modal-block.dimmed`));
3496
+ this.shadowElement = this.modalElement.appendChild($('.dialog-shadow'));
3497
+ this.element = this.shadowElement.appendChild($('.monaco-dialog-box'));
3498
+ this.element.setAttribute('role', 'dialog');
3499
+ this.element.tabIndex = -1;
3500
+ hide(this.element);
3501
+ if (Array.isArray(buttons) && buttons.length > 0) {
3502
+ this.buttons = buttons;
3503
+ }
3504
+ else if (!this.options.disableDefaultAction) {
3505
+ this.buttons = [ localize('ok', "OK")];
3506
+ }
3507
+ else {
3508
+ this.buttons = [];
3509
+ }
3510
+ const buttonsRowElement = this.element.appendChild($('.dialog-buttons-row'));
3511
+ this.buttonsContainer = buttonsRowElement.appendChild($('.dialog-buttons'));
3512
+ const messageRowElement = this.element.appendChild($('.dialog-message-row'));
3513
+ this.iconElement = messageRowElement.appendChild($('#monaco-dialog-icon.dialog-icon'));
3514
+ this.iconElement.setAttribute('aria-label', this.getIconAriaLabel());
3515
+ this.messageContainer = messageRowElement.appendChild($('.dialog-message-container'));
3516
+ if (this.options.detail || this.options.renderBody) {
3517
+ const messageElement = this.messageContainer.appendChild($('.dialog-message'));
3518
+ const messageTextElement = messageElement.appendChild($('#monaco-dialog-message-text.dialog-message-text'));
3519
+ messageTextElement.innerText = this.message;
3520
+ }
3521
+ this.messageDetailElement = this.messageContainer.appendChild($('#monaco-dialog-message-detail.dialog-message-detail'));
3522
+ if (this.options.detail || !this.options.renderBody) {
3523
+ this.messageDetailElement.innerText = this.options.detail ? this.options.detail : message;
3524
+ }
3525
+ else {
3526
+ this.messageDetailElement.style.display = 'none';
3527
+ }
3528
+ if (this.options.renderBody) {
3529
+ const customBody = this.messageContainer.appendChild($('#monaco-dialog-message-body.dialog-message-body'));
3530
+ this.options.renderBody(customBody);
3531
+ for (const el of this.messageContainer.querySelectorAll('a')) {
3532
+ el.tabIndex = 0;
3533
+ }
3534
+ }
3535
+ if (this.options.inputs) {
3536
+ this.inputs = this.options.inputs.map(input => {
3537
+ const inputRowElement = this.messageContainer.appendChild($('.dialog-message-input'));
3538
+ const inputBox = this._register( new InputBox(inputRowElement, undefined, {
3539
+ placeholder: input.placeholder,
3540
+ type: input.type ?? 'text',
3541
+ }));
3542
+ if (input.value) {
3543
+ inputBox.value = input.value;
3544
+ }
3545
+ return inputBox;
3546
+ });
3547
+ }
3548
+ else {
3549
+ this.inputs = [];
3550
+ }
3551
+ if (this.options.checkboxLabel) {
3552
+ const checkboxRowElement = this.messageContainer.appendChild($('.dialog-checkbox-row'));
3553
+ const checkbox = this.checkbox = this._register( new SimpleCheckbox(this.options.checkboxLabel, !!this.options.checkboxChecked));
3554
+ checkboxRowElement.appendChild(checkbox.domNode);
3555
+ const checkboxMessageElement = checkboxRowElement.appendChild($('.dialog-checkbox-message'));
3556
+ checkboxMessageElement.innerText = this.options.checkboxLabel;
3557
+ this._register(addDisposableListener(checkboxMessageElement, EventType.CLICK, () => checkbox.checked = !checkbox.checked));
3558
+ }
3559
+ const toolbarRowElement = this.element.appendChild($('.dialog-toolbar-row'));
3560
+ this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar'));
3561
+ }
3562
+ getIconAriaLabel() {
3563
+ let typeLabel = localize('dialogInfoMessage', 'Info');
3564
+ return typeLabel;
3565
+ }
3566
+ updateMessage(message) {
3567
+ this.messageDetailElement.innerText = message;
3568
+ }
3569
+ async show() {
3570
+ this.focusToReturn = document.activeElement;
3571
+ return (
3572
+ new Promise((resolve) => {
3573
+ clearNode(this.buttonsContainer);
3574
+ const buttonBar = this.buttonBar = this._register( new ButtonBar(this.buttonsContainer));
3575
+ const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);
3576
+ buttonMap.forEach((entry, index) => {
3577
+ const primary = buttonMap[index].index === 0;
3578
+ const button = this.options.buttonDetails ? this._register(buttonBar.addButtonWithDescription({ title: true, secondary: !primary })) : this._register(buttonBar.addButton({ title: true, secondary: !primary }));
3579
+ button.label = mnemonicButtonLabel(buttonMap[index].label, true);
3580
+ if (button instanceof ButtonWithDescription) {
3581
+ button.description = this.options.buttonDetails[buttonMap[index].index];
3582
+ }
3583
+ this._register(button.onDidClick(e => {
3584
+ if (e) {
3585
+ EventHelper.stop(e);
3586
+ }
3587
+ resolve({
3588
+ button: buttonMap[index].index,
3589
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
3590
+ values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
3591
+ });
3592
+ }));
3593
+ });
3594
+ this._register(addDisposableListener(window, 'keydown', e => {
3595
+ const evt = new StandardKeyboardEvent(e);
3596
+ if (evt.equals(512 )) {
3597
+ evt.preventDefault();
3598
+ }
3599
+ if (evt.equals(3 )) {
3600
+ if (this.inputs.some(input => input.hasFocus())) {
3601
+ EventHelper.stop(e);
3602
+ resolve({
3603
+ button: buttonMap.find(button => button.index !== this.options.cancelId)?.index ?? 0,
3604
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
3605
+ values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
3606
+ });
3607
+ }
3608
+ return;
3609
+ }
3610
+ if (evt.equals(10 )) {
3611
+ return;
3612
+ }
3613
+ let eventHandled = false;
3614
+ if (evt.equals(2 ) || evt.equals(17 ) || evt.equals(1024 | 2 ) || evt.equals(15 )) {
3615
+ const focusableElements = [];
3616
+ let focusedIndex = -1;
3617
+ if (this.messageContainer) {
3618
+ const links = this.messageContainer.querySelectorAll('a');
3619
+ for (const link of links) {
3620
+ focusableElements.push(link);
3621
+ if (link === document.activeElement) {
3622
+ focusedIndex = focusableElements.length - 1;
3623
+ }
3624
+ }
3625
+ }
3626
+ for (const input of this.inputs) {
3627
+ focusableElements.push(input);
3628
+ if (input.hasFocus()) {
3629
+ focusedIndex = focusableElements.length - 1;
3630
+ }
3631
+ }
3632
+ if (this.checkbox) {
3633
+ focusableElements.push(this.checkbox);
3634
+ if (this.checkbox.hasFocus()) {
3635
+ focusedIndex = focusableElements.length - 1;
3636
+ }
3637
+ }
3638
+ if (this.buttonBar) {
3639
+ for (const button of this.buttonBar.buttons) {
3640
+ focusableElements.push(button);
3641
+ if (button.hasFocus()) {
3642
+ focusedIndex = focusableElements.length - 1;
3643
+ }
3644
+ }
3645
+ }
3646
+ if (evt.equals(2 ) || evt.equals(17 )) {
3647
+ if (focusedIndex === -1) {
3648
+ focusedIndex = 0;
3649
+ }
3650
+ const newFocusedIndex = (focusedIndex + 1) % focusableElements.length;
3651
+ focusableElements[newFocusedIndex].focus();
3652
+ }
3653
+ else {
3654
+ if (focusedIndex === -1) {
3655
+ focusedIndex = focusableElements.length;
3656
+ }
3657
+ let newFocusedIndex = focusedIndex - 1;
3658
+ if (newFocusedIndex === -1) {
3659
+ newFocusedIndex = focusableElements.length - 1;
3660
+ }
3661
+ focusableElements[newFocusedIndex].focus();
3662
+ }
3663
+ eventHandled = true;
3664
+ }
3665
+ if (eventHandled) {
3666
+ EventHelper.stop(e, true);
3667
+ }
3668
+ else if (this.options.keyEventProcessor) {
3669
+ this.options.keyEventProcessor(evt);
3670
+ }
3671
+ }, true));
3672
+ this._register(addDisposableListener(window, 'keyup', e => {
3673
+ EventHelper.stop(e, true);
3674
+ const evt = new StandardKeyboardEvent(e);
3675
+ if (!this.options.disableCloseAction && evt.equals(9 )) {
3676
+ resolve({
3677
+ button: this.options.cancelId || 0,
3678
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
3679
+ });
3680
+ }
3681
+ }, true));
3682
+ this._register(addDisposableListener(this.element, 'focusout', e => {
3683
+ if (!!e.relatedTarget && !!this.element) {
3684
+ if (!isAncestor(e.relatedTarget, this.element)) {
3685
+ this.focusToReturn = e.relatedTarget;
3686
+ if (e.target) {
3687
+ e.target.focus();
3688
+ EventHelper.stop(e, true);
3689
+ }
3690
+ }
3691
+ }
3692
+ }, false));
3693
+ const spinModifierClassName = 'codicon-modifier-spin';
3694
+ this.iconElement.classList.remove(...Codicon.dialogError.classNamesArray, ...Codicon.dialogWarning.classNamesArray, ...Codicon.dialogInfo.classNamesArray, ...Codicon.loading.classNamesArray, spinModifierClassName);
3695
+ if (this.options.icon) {
3696
+ this.iconElement.classList.add(...this.options.icon.classNamesArray);
3697
+ }
3698
+ else {
3699
+ switch (this.options.type) {
3700
+ case 'error':
3701
+ this.iconElement.classList.add(...Codicon.dialogError.classNamesArray);
3702
+ break;
3703
+ case 'warning':
3704
+ this.iconElement.classList.add(...Codicon.dialogWarning.classNamesArray);
3705
+ break;
3706
+ case 'pending':
3707
+ this.iconElement.classList.add(...Codicon.loading.classNamesArray, spinModifierClassName);
3708
+ break;
3709
+ case 'none':
3710
+ case 'info':
3711
+ case 'question':
3712
+ default:
3713
+ this.iconElement.classList.add(...Codicon.dialogInfo.classNamesArray);
3714
+ break;
3715
+ }
3716
+ }
3717
+ if (!this.options.disableCloseAction) {
3718
+ const actionBar = this._register( new ActionBar(this.toolbarContainer, {}));
3719
+ const action = this._register( new Action('dialog.close', localize('dialogClose', "Close Dialog"), Codicon.dialogClose.classNames, true, async () => {
3720
+ resolve({
3721
+ button: this.options.cancelId || 0,
3722
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
3723
+ });
3724
+ }));
3725
+ actionBar.push(action, { icon: true, label: false, });
3726
+ }
3727
+ this.applyStyles();
3728
+ this.element.setAttribute('aria-modal', 'true');
3729
+ this.element.setAttribute('aria-labelledby', 'monaco-dialog-icon monaco-dialog-message-text');
3730
+ this.element.setAttribute('aria-describedby', 'monaco-dialog-icon monaco-dialog-message-text monaco-dialog-message-detail monaco-dialog-message-body');
3731
+ show(this.element);
3732
+ if (this.inputs.length > 0) {
3733
+ this.inputs[0].focus();
3734
+ this.inputs[0].select();
3735
+ }
3736
+ else {
3737
+ buttonMap.forEach((value, index) => {
3738
+ if (value.index === 0) {
3739
+ buttonBar.buttons[index].focus();
3740
+ }
3741
+ });
3742
+ }
3743
+ })
3744
+ );
3745
+ }
3746
+ applyStyles() {
3747
+ if (this.styles) {
3748
+ const style = this.styles;
3749
+ const fgColor = style.dialogForeground;
3750
+ const bgColor = style.dialogBackground;
3751
+ const shadowColor = style.dialogShadow ? `0 0px 8px ${style.dialogShadow}` : '';
3752
+ const border = style.dialogBorder ? `1px solid ${style.dialogBorder}` : '';
3753
+ const linkFgColor = style.textLinkForeground;
3754
+ this.shadowElement.style.boxShadow = shadowColor;
3755
+ this.element.style.color = fgColor?.toString() ?? '';
3756
+ this.element.style.backgroundColor = bgColor?.toString() ?? '';
3757
+ this.element.style.border = border;
3758
+ if (this.buttonBar) {
3759
+ this.buttonBar.buttons.forEach(button => button.style(style));
3760
+ }
3761
+ if (this.checkbox) {
3762
+ this.checkbox.style(style);
3763
+ }
3764
+ if (fgColor && bgColor) {
3765
+ const messageDetailColor = fgColor.transparent(.9);
3766
+ this.messageDetailElement.style.color = messageDetailColor.makeOpaque(bgColor).toString();
3767
+ }
3768
+ if (linkFgColor) {
3769
+ for (const el of this.messageContainer.getElementsByTagName('a')) {
3770
+ el.style.color = linkFgColor.toString();
3771
+ }
3772
+ }
3773
+ let color;
3774
+ switch (this.options.type) {
3775
+ case 'error':
3776
+ color = style.errorIconForeground;
3777
+ break;
3778
+ case 'warning':
3779
+ color = style.warningIconForeground;
3780
+ break;
3781
+ default:
3782
+ color = style.infoIconForeground;
3783
+ break;
3784
+ }
3785
+ if (color) {
3786
+ this.iconElement.style.color = color.toString();
3787
+ }
3788
+ for (const input of this.inputs) {
3789
+ input.style(style);
3790
+ }
3791
+ }
3792
+ }
3793
+ style(style) {
3794
+ this.styles = style;
3795
+ this.applyStyles();
3796
+ }
3797
+ dispose() {
3798
+ super.dispose();
3799
+ if (this.modalElement) {
3800
+ this.modalElement.remove();
3801
+ this.modalElement = undefined;
3802
+ }
3803
+ if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) {
3804
+ this.focusToReturn.focus();
3805
+ this.focusToReturn = undefined;
3806
+ }
3807
+ }
3808
+ rearrangeButtons(buttons, cancelId) {
3809
+ const buttonMap = [];
3810
+ if (buttons.length === 0) {
3811
+ return buttonMap;
3812
+ }
3813
+ buttons.forEach((button, index) => {
3814
+ buttonMap.push({ label: button, index });
3815
+ });
3816
+ if (isMacintosh || isLinux) {
3817
+ if (cancelId !== undefined && cancelId < buttons.length) {
3818
+ const cancelButton = buttonMap.splice(cancelId, 1)[0];
3819
+ buttonMap.reverse();
3820
+ buttonMap.splice(buttonMap.length - 1, 0, cancelButton);
3821
+ }
3822
+ }
3823
+ return buttonMap;
3824
+ }
3825
+ }
3826
+ const minute = 60;
3827
+ const hour = minute * 60;
3828
+ const day = hour * 24;
3829
+ const week = day * 7;
3830
+ const month = day * 30;
3831
+ const year = day * 365;
3832
+ function fromNow(date, appendAgoLabel, useFullTimeWords) {
3833
+ if (typeof date !== 'number') {
3834
+ date = date.getTime();
3835
+ }
3836
+ const seconds = Math.round(( new Date().getTime() - date) / 1000);
3837
+ if (seconds < -30) {
3838
+ return (
3839
+ localize('date.fromNow.in', 'in {0}', fromNow( new Date().getTime() + seconds * 1000, false))
3840
+ );
3841
+ }
3842
+ if (seconds < 30) {
3843
+ return (
3844
+ localize('date.fromNow.now', 'now')
3845
+ );
3846
+ }
3847
+ let value;
3848
+ if (seconds < minute) {
3849
+ value = seconds;
3850
+ if (appendAgoLabel) {
3851
+ if (value === 1) {
3852
+ return useFullTimeWords
3853
+ ? localize('date.fromNow.seconds.singular.ago.fullWord', '{0} second ago', value)
3854
+ : localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value);
3855
+ }
3856
+ else {
3857
+ return useFullTimeWords
3858
+ ? localize('date.fromNow.seconds.plural.ago.fullWord', '{0} seconds ago', value)
3859
+ : localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value);
3860
+ }
3861
+ }
3862
+ else {
3863
+ if (value === 1) {
3864
+ return useFullTimeWords
3865
+ ? localize('date.fromNow.seconds.singular.fullWord', '{0} second', value)
3866
+ : localize('date.fromNow.seconds.singular', '{0} sec', value);
3867
+ }
3868
+ else {
3869
+ return useFullTimeWords
3870
+ ? localize('date.fromNow.seconds.plural.fullWord', '{0} seconds', value)
3871
+ : localize('date.fromNow.seconds.plural', '{0} secs', value);
3872
+ }
3873
+ }
3874
+ }
3875
+ if (seconds < hour) {
3876
+ value = Math.floor(seconds / minute);
3877
+ if (appendAgoLabel) {
3878
+ if (value === 1) {
3879
+ return useFullTimeWords
3880
+ ? localize('date.fromNow.minutes.singular.ago.fullWord', '{0} minute ago', value)
3881
+ : localize('date.fromNow.minutes.singular.ago', '{0} min ago', value);
3882
+ }
3883
+ else {
3884
+ return useFullTimeWords
3885
+ ? localize('date.fromNow.minutes.plural.ago.fullWord', '{0} minutes ago', value)
3886
+ : localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value);
3887
+ }
3888
+ }
3889
+ else {
3890
+ if (value === 1) {
3891
+ return useFullTimeWords
3892
+ ? localize('date.fromNow.minutes.singular.fullWord', '{0} minute', value)
3893
+ : localize('date.fromNow.minutes.singular', '{0} min', value);
3894
+ }
3895
+ else {
3896
+ return useFullTimeWords
3897
+ ? localize('date.fromNow.minutes.plural.fullWord', '{0} minutes', value)
3898
+ : localize('date.fromNow.minutes.plural', '{0} mins', value);
3899
+ }
3900
+ }
3901
+ }
3902
+ if (seconds < day) {
3903
+ value = Math.floor(seconds / hour);
3904
+ if (appendAgoLabel) {
3905
+ if (value === 1) {
3906
+ return useFullTimeWords
3907
+ ? localize('date.fromNow.hours.singular.ago.fullWord', '{0} hour ago', value)
3908
+ : localize('date.fromNow.hours.singular.ago', '{0} hr ago', value);
3909
+ }
3910
+ else {
3911
+ return useFullTimeWords
3912
+ ? localize('date.fromNow.hours.plural.ago.fullWord', '{0} hours ago', value)
3913
+ : localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value);
3914
+ }
3915
+ }
3916
+ else {
3917
+ if (value === 1) {
3918
+ return useFullTimeWords
3919
+ ? localize('date.fromNow.hours.singular.fullWord', '{0} hour', value)
3920
+ : localize('date.fromNow.hours.singular', '{0} hr', value);
3921
+ }
3922
+ else {
3923
+ return useFullTimeWords
3924
+ ? localize('date.fromNow.hours.plural.fullWord', '{0} hours', value)
3925
+ : localize('date.fromNow.hours.plural', '{0} hrs', value);
3926
+ }
3927
+ }
3928
+ }
3929
+ if (seconds < week) {
3930
+ value = Math.floor(seconds / day);
3931
+ if (appendAgoLabel) {
3932
+ return value === 1
3933
+ ? localize('date.fromNow.days.singular.ago', '{0} day ago', value)
3934
+ : localize('date.fromNow.days.plural.ago', '{0} days ago', value);
3935
+ }
3936
+ else {
3937
+ return value === 1
3938
+ ? localize('date.fromNow.days.singular', '{0} day', value)
3939
+ : localize('date.fromNow.days.plural', '{0} days', value);
3940
+ }
3941
+ }
3942
+ if (seconds < month) {
3943
+ value = Math.floor(seconds / week);
3944
+ if (appendAgoLabel) {
3945
+ if (value === 1) {
3946
+ return useFullTimeWords
3947
+ ? localize('date.fromNow.weeks.singular.ago.fullWord', '{0} week ago', value)
3948
+ : localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value);
3949
+ }
3950
+ else {
3951
+ return useFullTimeWords
3952
+ ? localize('date.fromNow.weeks.plural.ago.fullWord', '{0} weeks ago', value)
3953
+ : localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value);
3954
+ }
3955
+ }
3956
+ else {
3957
+ if (value === 1) {
3958
+ return useFullTimeWords
3959
+ ? localize('date.fromNow.weeks.singular.fullWord', '{0} week', value)
3960
+ : localize('date.fromNow.weeks.singular', '{0} wk', value);
3961
+ }
3962
+ else {
3963
+ return useFullTimeWords
3964
+ ? localize('date.fromNow.weeks.plural.fullWord', '{0} weeks', value)
3965
+ : localize('date.fromNow.weeks.plural', '{0} wks', value);
3966
+ }
3967
+ }
3968
+ }
3969
+ if (seconds < year) {
3970
+ value = Math.floor(seconds / month);
3971
+ if (appendAgoLabel) {
3972
+ if (value === 1) {
3973
+ return useFullTimeWords
3974
+ ? localize('date.fromNow.months.singular.ago.fullWord', '{0} month ago', value)
3975
+ : localize('date.fromNow.months.singular.ago', '{0} mo ago', value);
3976
+ }
3977
+ else {
3978
+ return useFullTimeWords
3979
+ ? localize('date.fromNow.months.plural.ago.fullWord', '{0} months ago', value)
3980
+ : localize('date.fromNow.months.plural.ago', '{0} mos ago', value);
3981
+ }
3982
+ }
3983
+ else {
3984
+ if (value === 1) {
3985
+ return useFullTimeWords
3986
+ ? localize('date.fromNow.months.singular.fullWord', '{0} month', value)
3987
+ : localize('date.fromNow.months.singular', '{0} mo', value);
3988
+ }
3989
+ else {
3990
+ return useFullTimeWords
3991
+ ? localize('date.fromNow.months.plural.fullWord', '{0} months', value)
3992
+ : localize('date.fromNow.months.plural', '{0} mos', value);
3993
+ }
3994
+ }
3995
+ }
3996
+ value = Math.floor(seconds / year);
3997
+ if (appendAgoLabel) {
3998
+ if (value === 1) {
3999
+ return useFullTimeWords
4000
+ ? localize('date.fromNow.years.singular.ago.fullWord', '{0} year ago', value)
4001
+ : localize('date.fromNow.years.singular.ago', '{0} yr ago', value);
4002
+ }
4003
+ else {
4004
+ return useFullTimeWords
4005
+ ? localize('date.fromNow.years.plural.ago.fullWord', '{0} years ago', value)
4006
+ : localize('date.fromNow.years.plural.ago', '{0} yrs ago', value);
4007
+ }
4008
+ }
4009
+ else {
4010
+ if (value === 1) {
4011
+ return useFullTimeWords
4012
+ ? localize('date.fromNow.years.singular.fullWord', '{0} year', value)
4013
+ : localize('date.fromNow.years.singular', '{0} yr', value);
4014
+ }
4015
+ else {
4016
+ return useFullTimeWords
4017
+ ? localize('date.fromNow.years.plural.fullWord', '{0} years', value)
4018
+ : localize('date.fromNow.years.plural', '{0} yrs', value);
4019
+ }
4020
+ }
4021
+ }
4022
+ let BrowserDialogHandler = class BrowserDialogHandler {
4023
+ constructor(logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
4024
+ this.logService = logService;
4025
+ this.layoutService = layoutService;
4026
+ this.themeService = themeService;
4027
+ this.keybindingService = keybindingService;
4028
+ this.instantiationService = instantiationService;
4029
+ this.productService = productService;
4030
+ this.clipboardService = clipboardService;
4031
+ this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
4032
+ }
4033
+ async confirm(confirmation) {
4034
+ this.logService.trace('DialogService#confirm', confirmation.message);
4035
+ const buttons = [];
4036
+ if (confirmation.primaryButton) {
4037
+ buttons.push(confirmation.primaryButton);
4038
+ }
4039
+ else {
4040
+ buttons.push( localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes"));
4041
+ }
4042
+ if (confirmation.secondaryButton) {
4043
+ buttons.push(confirmation.secondaryButton);
4044
+ }
4045
+ else if (typeof confirmation.secondaryButton === 'undefined') {
4046
+ buttons.push( localize('cancelButton', "Cancel"));
4047
+ }
4048
+ const result = await this.doShow(confirmation.type, confirmation.message, buttons, confirmation.detail, 1, confirmation.checkbox);
4049
+ return { confirmed: result.button === 0, checkboxChecked: result.checkboxChecked };
4050
+ }
4051
+ getDialogType(severity) {
4052
+ return (severity === Severity$1.Info) ? 'question' : (severity === Severity$1.Error) ? 'error' : (severity === Severity$1.Warning) ? 'warning' : 'none';
4053
+ }
4054
+ async show(severity, message, buttons, options) {
4055
+ this.logService.trace('DialogService#show', message);
4056
+ const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, undefined, typeof options?.custom === 'object' ? options.custom : undefined);
4057
+ return {
4058
+ choice: result.button,
4059
+ checkboxChecked: result.checkboxChecked
4060
+ };
4061
+ }
4062
+ async doShow(type, message, buttons, detail, cancelId, checkbox, inputs, customOptions) {
4063
+ const dialogDisposables = new DisposableStore();
4064
+ const renderBody = customOptions ? (parent) => {
4065
+ parent.classList.add(...(customOptions.classes || []));
4066
+ (customOptions.markdownDetails || []).forEach(markdownDetail => {
4067
+ const result = this.markdownRenderer.render(markdownDetail.markdown);
4068
+ parent.appendChild(result.element);
4069
+ result.element.classList.add(...(markdownDetail.classes || []));
4070
+ dialogDisposables.add(result);
4071
+ });
4072
+ } : undefined;
4073
+ const dialog = new Dialog(this.layoutService.container, message, buttons, {
4074
+ detail,
4075
+ cancelId,
4076
+ type,
4077
+ keyEventProcessor: (event) => {
4078
+ const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
4079
+ if (resolved?.commandId) {
4080
+ if (BrowserDialogHandler.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
4081
+ EventHelper.stop(event, true);
4082
+ }
4083
+ }
4084
+ },
4085
+ renderBody,
4086
+ icon: customOptions?.icon,
4087
+ disableCloseAction: customOptions?.disableCloseAction,
4088
+ buttonDetails: customOptions?.buttonDetails,
4089
+ checkboxLabel: checkbox?.label,
4090
+ checkboxChecked: checkbox?.checked,
4091
+ inputs
4092
+ });
4093
+ dialogDisposables.add(dialog);
4094
+ dialogDisposables.add(attachDialogStyler(dialog, this.themeService));
4095
+ const result = await dialog.show();
4096
+ dialogDisposables.dispose();
4097
+ return result;
4098
+ }
4099
+ async input(severity, message, buttons, inputs, options) {
4100
+ this.logService.trace('DialogService#input', message);
4101
+ const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, inputs);
4102
+ return {
4103
+ choice: result.button,
4104
+ checkboxChecked: result.checkboxChecked,
4105
+ values: result.values
4106
+ };
4107
+ }
4108
+ async about() {
4109
+ const detailString = (useAgo) => {
4110
+ return (
4111
+ localize(
4112
+ 'aboutDetail',
4113
+ "Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
4114
+ this.productService.version || 'Unknown',
4115
+ this.productService.commit || 'Unknown',
4116
+ this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow( new Date(this.productService.date), true) + ')' : ''}` : 'Unknown',
4117
+ navigator.userAgent
4118
+ )
4119
+ );
4120
+ };
4121
+ const detail = detailString(true);
4122
+ const detailToCopy = detailString(false);
4123
+ const { choice } = await this.show(Severity$1.Info, this.productService.nameLong, [ localize('copy', "Copy"), localize('ok', "OK")], { detail, cancelId: 1 });
4124
+ if (choice === 0) {
4125
+ this.clipboardService.writeText(detailToCopy);
4126
+ }
4127
+ }
4128
+ };
4129
+ BrowserDialogHandler.ALLOWABLE_COMMANDS = [
4130
+ 'copy',
4131
+ 'cut',
4132
+ 'editor.action.selectAll',
4133
+ 'editor.action.clipboardCopyAction',
4134
+ 'editor.action.clipboardCutAction',
4135
+ 'editor.action.clipboardPasteAction'
4136
+ ];
4137
+ BrowserDialogHandler = __decorate([
4138
+ __param(0, ILogService),
4139
+ __param(1, ILayoutService),
4140
+ __param(2, IThemeService),
4141
+ __param(3, IKeybindingService),
4142
+ __param(4, IInstantiationService),
4143
+ __param(5, IProductService),
4144
+ __param(6, IClipboardService)
4145
+ ], BrowserDialogHandler);
4146
+ let DialogHandlerContribution = class DialogHandlerContribution extends Disposable {
4147
+ constructor(dialogService, logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
4148
+ super();
4149
+ this.dialogService = dialogService;
4150
+ this.impl = new BrowserDialogHandler(
4151
+ logService,
4152
+ layoutService,
4153
+ themeService,
4154
+ keybindingService,
4155
+ instantiationService,
4156
+ productService,
4157
+ clipboardService
4158
+ );
4159
+ this.model = this.dialogService.model;
4160
+ this._register(this.model.onWillShowDialog(() => {
4161
+ if (!this.currentDialog) {
4162
+ this.processDialogs();
4163
+ }
4164
+ }));
4165
+ this.processDialogs();
4166
+ }
4167
+ async processDialogs() {
4168
+ while (this.model.dialogs.length) {
4169
+ this.currentDialog = this.model.dialogs[0];
4170
+ let result = undefined;
4171
+ if (this.currentDialog.args.confirmArgs) {
4172
+ const args = this.currentDialog.args.confirmArgs;
4173
+ result = await this.impl.confirm(args.confirmation);
4174
+ }
4175
+ else if (this.currentDialog.args.inputArgs) {
4176
+ const args = this.currentDialog.args.inputArgs;
4177
+ result = await this.impl.input(args.severity, args.message, args.buttons, args.inputs, args.options);
4178
+ }
4179
+ else if (this.currentDialog.args.showArgs) {
4180
+ const args = this.currentDialog.args.showArgs;
4181
+ result = await this.impl.show(args.severity, args.message, args.buttons, args.options);
4182
+ }
4183
+ else {
4184
+ await this.impl.about();
4185
+ }
4186
+ this.currentDialog.close(result);
4187
+ this.currentDialog = undefined;
4188
+ }
4189
+ }
4190
+ };
4191
+ DialogHandlerContribution = __decorate([
4192
+ __param(0, IDialogService),
4193
+ __param(1, ILogService),
4194
+ __param(2, ILayoutService),
4195
+ __param(3, IThemeService),
4196
+ __param(4, IKeybindingService),
4197
+ __param(5, IInstantiationService),
4198
+ __param(6, IProductService),
4199
+ __param(7, IClipboardService)
4200
+ ], DialogHandlerContribution);
4201
+ class DialogsModel extends Disposable {
4202
+ constructor() {
4203
+ super(...arguments);
4204
+ this.dialogs = [];
4205
+ this._onWillShowDialog = this._register( new Emitter());
4206
+ this.onWillShowDialog = this._onWillShowDialog.event;
4207
+ this._onDidShowDialog = this._register( new Emitter());
4208
+ this.onDidShowDialog = this._onDidShowDialog.event;
4209
+ }
4210
+ show(dialog) {
4211
+ const promise = new DeferredPromise();
4212
+ const item = {
4213
+ args: dialog,
4214
+ close: result => {
4215
+ this.dialogs.splice(0, 1);
4216
+ promise.complete(result);
4217
+ this._onDidShowDialog.fire();
4218
+ }
4219
+ };
4220
+ this.dialogs.push(item);
4221
+ this._onWillShowDialog.fire();
4222
+ return {
4223
+ item,
4224
+ result: promise.p
4225
+ };
4226
+ }
4227
+ }
4228
+ class DialogService extends Disposable {
4229
+ constructor() {
4230
+ super(...arguments);
4231
+ this.model = this._register( new DialogsModel());
4232
+ this.onWillShowDialog = this.model.onWillShowDialog;
4233
+ this.onDidShowDialog = this.model.onDidShowDialog;
4234
+ }
4235
+ async confirm(confirmation) {
4236
+ const handle = this.model.show({ confirmArgs: { confirmation } });
4237
+ return await handle.result;
4238
+ }
4239
+ async show(severity, message, buttons, options) {
4240
+ const handle = this.model.show({ showArgs: { severity, message, buttons, options } });
4241
+ return await handle.result;
4242
+ }
4243
+ async input(severity, message, buttons, inputs, options) {
4244
+ const handle = this.model.show({ inputArgs: { severity, message, buttons, inputs, options } });
4245
+ return await handle.result;
4246
+ }
4247
+ async about() {
4248
+ const handle = this.model.show({});
4249
+ await handle.result;
4250
+ }
4251
+ }
4252
+ class LayoutService {
4253
+ constructor(container, _codeEditorService) {
4254
+ this.container = container;
4255
+ this._codeEditorService = _codeEditorService;
4256
+ this._onDidLayout = new Emitter();
4257
+ this.onDidLayout = this._onDidLayout.event;
4258
+ window.addEventListener('resize', () => this.layout());
4259
+ this.layout();
4260
+ }
4261
+ isVisible() {
4262
+ return false;
4263
+ }
4264
+ get dimension() { return this._dimension; }
4265
+ layout() {
4266
+ this._dimension = getClientArea(window.document.body);
4267
+ this._onDidLayout.fire(this._dimension);
4268
+ }
4269
+ get hasContainer() {
4270
+ return true;
4271
+ }
4272
+ focus() {
4273
+ this._codeEditorService.getFocusedCodeEditor()?.focus();
4274
+ }
4275
+ }
4276
+ function register(container) {
4277
+ container.classList.add('monaco-workbench');
4278
+ const model = StandaloneServices.get(INotificationService).model;
4279
+ const instantiationService = StandaloneServices.get(IInstantiationService);
4280
+ const notificationsToasts = instantiationService.createInstance(NotificationsToasts, container, model);
4281
+ notificationsToasts.layout(getClientArea(container));
4282
+ const notificationsCenter = {
4283
+ isVisible: false,
4284
+ show: unsupported,
4285
+ hide: unsupported,
4286
+ clearAll: function () {
4287
+ for (const notification of [...model.notifications] ) {
4288
+ if (!notification.hasProgress) {
4289
+ notification.close();
4290
+ }
4291
+ }
4292
+ }
4293
+ };
4294
+ registerNotificationCommands(notificationsCenter, notificationsToasts, model);
4295
+ StandaloneServices.get(IInstantiationService).createInstance(DialogHandlerContribution);
4296
+ }
4297
+ function getServiceOverride(container) {
4298
+ setTimeout(() => register(container));
4299
+ return {
4300
+ [IDialogService.toString()]: new SyncDescriptor(DialogService),
4301
+ [INotificationService.toString()]: new SyncDescriptor(NotificationService),
4302
+ [ILayoutService.toString()]: new SyncDescriptor(LayoutService, [container])
4303
+ };
4304
+ }
4305
+ export { getServiceOverride as default };