@codingame/monaco-vscode-api 1.67.8 → 1.67.11

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