@codingame/monaco-vscode-api 1.69.4 → 1.69.7

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.
package/dist/layout.js ADDED
@@ -0,0 +1,1318 @@
1
+ import { _ as __decorate, a as __param } from './contextkey.js';
2
+ import { j as IProductService } from './services2.js';
3
+ import { E as Emitter } from './missing-services.js';
4
+ import { Widget } from 'monaco-editor/esm/vs/base/browser/ui/widget.js';
5
+ import { CSSIcon, Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
6
+ import { Color } from 'monaco-editor/esm/vs/base/common/color.js';
7
+ import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
8
+ import { addDisposableListener, EventType, EventHelper, trackFocus, reset, getClientArea, $, hide, clearNode, isAncestor, show } from 'monaco-editor/esm/vs/base/browser/dom.js';
9
+ import { mixin } from 'monaco-editor/esm/vs/base/common/objects.js';
10
+ import { Gesture, EventType as EventType$1 } from 'monaco-editor/esm/vs/base/browser/touch.js';
11
+ import { renderLabelWithIcons } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabels.js';
12
+ import { Action } from 'monaco-editor/esm/vs/base/common/actions.js';
13
+ import { localize } from 'monaco-editor/esm/vs/nls.js';
14
+ import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
15
+ import { isMacintosh, isLinux, isWindows } from 'monaco-editor/esm/vs/base/common/platform.js';
16
+ import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
17
+ import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
18
+ import { buttonForeground, buttonSeparator, buttonBackground, buttonHoverBackground, buttonSecondaryForeground, buttonSecondaryBackground, buttonSecondaryHoverBackground, buttonBorder, progressBarBackground, resolveColorValue, editorWidgetBackground, editorWidgetForeground, widgetShadow, contrastBorder, checkboxBorder, checkboxBackground, checkboxForeground, problemsErrorIconForeground, problemsWarningIconForeground, problemsInfoIconForeground, inputBackground, inputForeground, inputBorder, textLinkForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
19
+ import { MarkdownRenderer } from 'monaco-editor/esm/vs/editor/contrib/markdownRenderer/browser/markdownRenderer.js';
20
+ import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
21
+ import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
22
+ import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
23
+ import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
24
+ import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
25
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
26
+ import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
27
+ import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
28
+ import { I as IWorkbenchLayoutService } from './layoutService.js';
29
+ import { o as onServicesInitialized } from './tools.js';
30
+ import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
31
+ import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
32
+ import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
33
+ 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}}
34
+ const defaultOpts = {
35
+ inputActiveOptionBorder: ( (Color.fromHex('#007ACC00'))),
36
+ inputActiveOptionForeground: ( (Color.fromHex('#FFFFFF'))),
37
+ inputActiveOptionBackground: ( (Color.fromHex('#0E639C50')))
38
+ };
39
+ class Toggle extends Widget {
40
+ constructor(opts) {
41
+ super();
42
+ this._onChange = this._register(( (new Emitter())));
43
+ this.onChange = this._onChange.event;
44
+ this._onKeyDown = this._register(( (new Emitter())));
45
+ this.onKeyDown = this._onKeyDown.event;
46
+ this._opts = { ...defaultOpts, ...opts };
47
+ this._checked = this._opts.isChecked;
48
+ const classes = ['monaco-custom-toggle'];
49
+ if (this._opts.icon) {
50
+ this._icon = this._opts.icon;
51
+ classes.push(...CSSIcon.asClassNameArray(this._icon));
52
+ }
53
+ if (this._opts.actionClassName) {
54
+ classes.push(...this._opts.actionClassName.split(' '));
55
+ }
56
+ if (this._checked) {
57
+ classes.push('checked');
58
+ }
59
+ this.domNode = document.createElement('div');
60
+ this.domNode.title = this._opts.title;
61
+ this.domNode.classList.add(...classes);
62
+ if (!this._opts.notFocusable) {
63
+ this.domNode.tabIndex = 0;
64
+ }
65
+ this.domNode.setAttribute('role', 'checkbox');
66
+ this.domNode.setAttribute('aria-checked', String(this._checked));
67
+ this.domNode.setAttribute('aria-label', this._opts.title);
68
+ this.applyStyles();
69
+ this.onclick(this.domNode, (ev) => {
70
+ if (this.enabled) {
71
+ this.checked = !this._checked;
72
+ this._onChange.fire(false);
73
+ ev.preventDefault();
74
+ }
75
+ });
76
+ this.ignoreGesture(this.domNode);
77
+ this.onkeydown(this.domNode, (keyboardEvent) => {
78
+ if (keyboardEvent.keyCode === 10 || keyboardEvent.keyCode === 3 ) {
79
+ this.checked = !this._checked;
80
+ this._onChange.fire(true);
81
+ keyboardEvent.preventDefault();
82
+ keyboardEvent.stopPropagation();
83
+ return;
84
+ }
85
+ this._onKeyDown.fire(keyboardEvent);
86
+ });
87
+ }
88
+ get enabled() {
89
+ return this.domNode.getAttribute('aria-disabled') !== 'true';
90
+ }
91
+ focus() {
92
+ this.domNode.focus();
93
+ }
94
+ get checked() {
95
+ return this._checked;
96
+ }
97
+ set checked(newIsChecked) {
98
+ this._checked = newIsChecked;
99
+ this.domNode.setAttribute('aria-checked', String(this._checked));
100
+ this.domNode.classList.toggle('checked', this._checked);
101
+ this.applyStyles();
102
+ }
103
+ setIcon(icon) {
104
+ if (this._icon) {
105
+ this.domNode.classList.remove(...CSSIcon.asClassNameArray(this._icon));
106
+ }
107
+ this._icon = icon;
108
+ if (this._icon) {
109
+ this.domNode.classList.add(...CSSIcon.asClassNameArray(this._icon));
110
+ }
111
+ }
112
+ width() {
113
+ return 2 + 2 + 2 + 16 ;
114
+ }
115
+ style(styles) {
116
+ if (styles.inputActiveOptionBorder) {
117
+ this._opts.inputActiveOptionBorder = styles.inputActiveOptionBorder;
118
+ }
119
+ if (styles.inputActiveOptionForeground) {
120
+ this._opts.inputActiveOptionForeground = styles.inputActiveOptionForeground;
121
+ }
122
+ if (styles.inputActiveOptionBackground) {
123
+ this._opts.inputActiveOptionBackground = styles.inputActiveOptionBackground;
124
+ }
125
+ this.applyStyles();
126
+ }
127
+ applyStyles() {
128
+ if (this.domNode) {
129
+ this.domNode.style.borderColor = this._checked && this._opts.inputActiveOptionBorder ? ( (this._opts.inputActiveOptionBorder.toString())) : '';
130
+ this.domNode.style.color = this._checked && this._opts.inputActiveOptionForeground ? ( (this._opts.inputActiveOptionForeground.toString())) : 'inherit';
131
+ this.domNode.style.backgroundColor = this._checked && this._opts.inputActiveOptionBackground ? ( (this._opts.inputActiveOptionBackground.toString())) : '';
132
+ }
133
+ }
134
+ enable() {
135
+ this.domNode.setAttribute('aria-disabled', String(false));
136
+ }
137
+ disable() {
138
+ this.domNode.setAttribute('aria-disabled', String(true));
139
+ }
140
+ setTitle(newTitle) {
141
+ this.domNode.title = newTitle;
142
+ this.domNode.setAttribute('aria-label', newTitle);
143
+ }
144
+ }
145
+ class Checkbox extends Widget {
146
+ constructor(title, isChecked) {
147
+ super();
148
+ this.title = title;
149
+ this.isChecked = isChecked;
150
+ this.checkbox = ( (new Toggle(
151
+ { title: this.title, isChecked: this.isChecked, icon: Codicon.check, actionClassName: 'monaco-checkbox' }
152
+ )));
153
+ this.domNode = this.checkbox.domNode;
154
+ this.styles = {};
155
+ this.checkbox.onChange(() => {
156
+ this.applyStyles();
157
+ });
158
+ }
159
+ get checked() {
160
+ return this.checkbox.checked;
161
+ }
162
+ set checked(newIsChecked) {
163
+ this.checkbox.checked = newIsChecked;
164
+ this.applyStyles();
165
+ }
166
+ focus() {
167
+ this.domNode.focus();
168
+ }
169
+ hasFocus() {
170
+ return this.domNode === document.activeElement;
171
+ }
172
+ style(styles) {
173
+ this.styles = styles;
174
+ this.applyStyles();
175
+ }
176
+ applyStyles() {
177
+ this.domNode.style.color = this.styles.checkboxForeground ? ( (this.styles.checkboxForeground.toString())) : '';
178
+ this.domNode.style.backgroundColor = this.styles.checkboxBackground ? ( (this.styles.checkboxBackground.toString())) : '';
179
+ this.domNode.style.borderColor = this.styles.checkboxBorder ? ( (this.styles.checkboxBorder.toString())) : '';
180
+ }
181
+ }
182
+ function computeStyles(theme, styleMap) {
183
+ const styles = Object.create(null);
184
+ for (const key in styleMap) {
185
+ const value = styleMap[key];
186
+ if (value) {
187
+ styles[key] = resolveColorValue(value, theme);
188
+ }
189
+ }
190
+ return styles;
191
+ }
192
+ function attachStyler(themeService, styleMap, widgetOrCallback) {
193
+ function applyStyles() {
194
+ const styles = computeStyles(themeService.getColorTheme(), styleMap);
195
+ if (typeof widgetOrCallback === 'function') {
196
+ widgetOrCallback(styles);
197
+ }
198
+ else {
199
+ widgetOrCallback.style(styles);
200
+ }
201
+ }
202
+ applyStyles();
203
+ return themeService.onDidColorThemeChange(applyStyles);
204
+ }
205
+ function attachButtonStyler(widget, themeService, style) {
206
+ return attachStyler(themeService, {
207
+ buttonForeground: style?.buttonForeground || buttonForeground,
208
+ buttonSeparator: style?.buttonSeparator || buttonSeparator,
209
+ buttonBackground: style?.buttonBackground || buttonBackground,
210
+ buttonHoverBackground: style?.buttonHoverBackground || buttonHoverBackground,
211
+ buttonSecondaryForeground: style?.buttonSecondaryForeground || buttonSecondaryForeground,
212
+ buttonSecondaryBackground: style?.buttonSecondaryBackground || buttonSecondaryBackground,
213
+ buttonSecondaryHoverBackground: style?.buttonSecondaryHoverBackground || buttonSecondaryHoverBackground,
214
+ buttonBorder: style?.buttonBorder || buttonBorder,
215
+ }, widget);
216
+ }
217
+ function attachProgressBarStyler(widget, themeService, style) {
218
+ return attachStyler(themeService, {
219
+ progressBarBackground: style?.progressBarBackground || progressBarBackground
220
+ }, widget);
221
+ }
222
+ const defaultDialogStyles = {
223
+ dialogBackground: editorWidgetBackground,
224
+ dialogForeground: editorWidgetForeground,
225
+ dialogShadow: widgetShadow,
226
+ dialogBorder: contrastBorder,
227
+ buttonForeground: buttonForeground,
228
+ buttonSeparator: buttonSeparator,
229
+ buttonBackground: buttonBackground,
230
+ buttonSecondaryBackground: buttonSecondaryBackground,
231
+ buttonSecondaryForeground: buttonSecondaryForeground,
232
+ buttonSecondaryHoverBackground: buttonSecondaryHoverBackground,
233
+ buttonHoverBackground: buttonHoverBackground,
234
+ buttonBorder: buttonBorder,
235
+ checkboxBorder: checkboxBorder,
236
+ checkboxBackground: checkboxBackground,
237
+ checkboxForeground: checkboxForeground,
238
+ errorIconForeground: problemsErrorIconForeground,
239
+ warningIconForeground: problemsWarningIconForeground,
240
+ infoIconForeground: problemsInfoIconForeground,
241
+ inputBackground: inputBackground,
242
+ inputForeground: inputForeground,
243
+ inputBorder: inputBorder,
244
+ textLinkForeground: textLinkForeground
245
+ };
246
+ function attachDialogStyler(widget, themeService, style) {
247
+ return attachStyler(themeService, { ...defaultDialogStyles, ...style }, widget);
248
+ }
249
+ const defaultOptions = {
250
+ buttonBackground: ( (Color.fromHex('#0E639C'))),
251
+ buttonHoverBackground: ( (Color.fromHex('#006BB3'))),
252
+ buttonSeparator: Color.white,
253
+ buttonForeground: Color.white
254
+ };
255
+ class Button extends Disposable {
256
+ constructor(container, options) {
257
+ super();
258
+ this._onDidClick = this._register(( (new Emitter())));
259
+ this.options = options || Object.create(null);
260
+ mixin(this.options, defaultOptions, false);
261
+ this.buttonForeground = this.options.buttonForeground;
262
+ this.buttonBackground = this.options.buttonBackground;
263
+ this.buttonHoverBackground = this.options.buttonHoverBackground;
264
+ this.buttonSecondaryForeground = this.options.buttonSecondaryForeground;
265
+ this.buttonSecondaryBackground = this.options.buttonSecondaryBackground;
266
+ this.buttonSecondaryHoverBackground = this.options.buttonSecondaryHoverBackground;
267
+ this.buttonBorder = this.options.buttonBorder;
268
+ this._element = document.createElement('a');
269
+ this._element.classList.add('monaco-button');
270
+ this._element.tabIndex = 0;
271
+ this._element.setAttribute('role', 'button');
272
+ container.appendChild(this._element);
273
+ this._register(Gesture.addTarget(this._element));
274
+ [EventType.CLICK, EventType$1.Tap].forEach(eventType => {
275
+ this._register(addDisposableListener(this._element, eventType, e => {
276
+ if (!this.enabled) {
277
+ EventHelper.stop(e);
278
+ return;
279
+ }
280
+ this._onDidClick.fire(e);
281
+ }));
282
+ });
283
+ this._register(addDisposableListener(this._element, EventType.KEY_DOWN, e => {
284
+ const event = ( (new StandardKeyboardEvent(e)));
285
+ let eventHandled = false;
286
+ if (this.enabled && (event.equals(3 ) || event.equals(10 ))) {
287
+ this._onDidClick.fire(e);
288
+ eventHandled = true;
289
+ }
290
+ else if (event.equals(9 )) {
291
+ this._element.blur();
292
+ eventHandled = true;
293
+ }
294
+ if (eventHandled) {
295
+ EventHelper.stop(event, true);
296
+ }
297
+ }));
298
+ this._register(addDisposableListener(this._element, EventType.MOUSE_OVER, e => {
299
+ if (!this._element.classList.contains('disabled')) {
300
+ this.setHoverBackground();
301
+ }
302
+ }));
303
+ this._register(addDisposableListener(this._element, EventType.MOUSE_OUT, e => {
304
+ this.applyStyles();
305
+ }));
306
+ this.focusTracker = this._register(trackFocus(this._element));
307
+ this._register(this.focusTracker.onDidFocus(() => { if (this.enabled) {
308
+ this.setHoverBackground();
309
+ } }));
310
+ this._register(this.focusTracker.onDidBlur(() => { if (this.enabled) {
311
+ this.applyStyles();
312
+ } }));
313
+ this.applyStyles();
314
+ }
315
+ get onDidClick() { return this._onDidClick.event; }
316
+ setHoverBackground() {
317
+ let hoverBackground;
318
+ if (this.options.secondary) {
319
+ hoverBackground = this.buttonSecondaryHoverBackground ? ( (this.buttonSecondaryHoverBackground.toString())) : null;
320
+ }
321
+ else {
322
+ hoverBackground = this.buttonHoverBackground ? ( (this.buttonHoverBackground.toString())) : null;
323
+ }
324
+ if (hoverBackground) {
325
+ this._element.style.backgroundColor = hoverBackground;
326
+ }
327
+ }
328
+ style(styles) {
329
+ this.buttonForeground = styles.buttonForeground;
330
+ this.buttonBackground = styles.buttonBackground;
331
+ this.buttonHoverBackground = styles.buttonHoverBackground;
332
+ this.buttonSecondaryForeground = styles.buttonSecondaryForeground;
333
+ this.buttonSecondaryBackground = styles.buttonSecondaryBackground;
334
+ this.buttonSecondaryHoverBackground = styles.buttonSecondaryHoverBackground;
335
+ this.buttonBorder = styles.buttonBorder;
336
+ this.applyStyles();
337
+ }
338
+ applyStyles() {
339
+ if (this._element) {
340
+ let background, foreground;
341
+ if (this.options.secondary) {
342
+ foreground = this.buttonSecondaryForeground ? ( (this.buttonSecondaryForeground.toString())) : '';
343
+ background = this.buttonSecondaryBackground ? ( (this.buttonSecondaryBackground.toString())) : '';
344
+ }
345
+ else {
346
+ foreground = this.buttonForeground ? ( (this.buttonForeground.toString())) : '';
347
+ background = this.buttonBackground ? ( (this.buttonBackground.toString())) : '';
348
+ }
349
+ const border = this.buttonBorder ? ( (this.buttonBorder.toString())) : '';
350
+ this._element.style.color = foreground;
351
+ this._element.style.backgroundColor = background;
352
+ this._element.style.borderWidth = border ? '1px' : '';
353
+ this._element.style.borderStyle = border ? 'solid' : '';
354
+ this._element.style.borderColor = border;
355
+ }
356
+ }
357
+ get element() {
358
+ return this._element;
359
+ }
360
+ set label(value) {
361
+ this._element.classList.add('monaco-text-button');
362
+ if (this.options.supportIcons) {
363
+ reset(this._element, ...renderLabelWithIcons(value));
364
+ }
365
+ else {
366
+ this._element.textContent = value;
367
+ }
368
+ if (typeof this.options.title === 'string') {
369
+ this._element.title = this.options.title;
370
+ }
371
+ else if (this.options.title) {
372
+ this._element.title = value;
373
+ }
374
+ }
375
+ set icon(icon) {
376
+ this._element.classList.add(...CSSIcon.asClassNameArray(icon));
377
+ }
378
+ set enabled(value) {
379
+ if (value) {
380
+ this._element.classList.remove('disabled');
381
+ this._element.setAttribute('aria-disabled', String(false));
382
+ this._element.tabIndex = 0;
383
+ }
384
+ else {
385
+ this._element.classList.add('disabled');
386
+ this._element.setAttribute('aria-disabled', String(true));
387
+ }
388
+ }
389
+ get enabled() {
390
+ return !this._element.classList.contains('disabled');
391
+ }
392
+ focus() {
393
+ this._element.focus();
394
+ }
395
+ hasFocus() {
396
+ return this._element === document.activeElement;
397
+ }
398
+ }
399
+ class ButtonWithDropdown extends Disposable {
400
+ constructor(container, options) {
401
+ super();
402
+ this._onDidClick = this._register(( (new Emitter())));
403
+ this.onDidClick = this._onDidClick.event;
404
+ this.element = document.createElement('div');
405
+ this.element.classList.add('monaco-button-dropdown');
406
+ container.appendChild(this.element);
407
+ this.button = this._register(( (new Button(this.element, options))));
408
+ this._register(this.button.onDidClick(e => this._onDidClick.fire(e)));
409
+ this.action = this._register(( (new Action(
410
+ 'primaryAction',
411
+ this.button.label,
412
+ undefined,
413
+ true,
414
+ async () => this._onDidClick.fire(undefined)
415
+ ))));
416
+ this.separatorContainer = document.createElement('div');
417
+ this.separatorContainer.classList.add('monaco-button-dropdown-separator');
418
+ this.separator = document.createElement('div');
419
+ this.separatorContainer.appendChild(this.separator);
420
+ this.element.appendChild(this.separatorContainer);
421
+ this.dropdownButton = this._register(( (new Button(this.element, { ...options, title: false, supportIcons: true }))));
422
+ this.dropdownButton.element.title = ( (localize("button dropdown more actions", 'More Actions...')));
423
+ this.dropdownButton.element.setAttribute('aria-haspopup', 'true');
424
+ this.dropdownButton.element.setAttribute('aria-expanded', 'false');
425
+ this.dropdownButton.element.classList.add('monaco-dropdown-button');
426
+ this.dropdownButton.icon = Codicon.dropDownButton;
427
+ this._register(this.dropdownButton.onDidClick(e => {
428
+ options.contextMenuProvider.showContextMenu({
429
+ getAnchor: () => this.dropdownButton.element,
430
+ getActions: () => options.addPrimaryActionToDropdown === false ? [...options.actions] : [this.action, ...options.actions],
431
+ actionRunner: options.actionRunner,
432
+ onHide: () => this.dropdownButton.element.setAttribute('aria-expanded', 'false')
433
+ });
434
+ this.dropdownButton.element.setAttribute('aria-expanded', 'true');
435
+ }));
436
+ }
437
+ set label(value) {
438
+ this.button.label = value;
439
+ this.action.label = value;
440
+ }
441
+ set icon(icon) {
442
+ this.button.icon = icon;
443
+ }
444
+ set enabled(enabled) {
445
+ this.button.enabled = enabled;
446
+ this.dropdownButton.enabled = enabled;
447
+ this.element.classList.toggle('disabled', !enabled);
448
+ }
449
+ get enabled() {
450
+ return this.button.enabled;
451
+ }
452
+ style(styles) {
453
+ this.button.style(styles);
454
+ this.dropdownButton.style(styles);
455
+ const border = styles.buttonBorder ? ( (styles.buttonBorder.toString())) : '';
456
+ this.separatorContainer.style.borderTopWidth = border ? '1px' : '';
457
+ this.separatorContainer.style.borderTopStyle = border ? 'solid' : '';
458
+ this.separatorContainer.style.borderTopColor = border;
459
+ this.separatorContainer.style.borderBottomWidth = border ? '1px' : '';
460
+ this.separatorContainer.style.borderBottomStyle = border ? 'solid' : '';
461
+ this.separatorContainer.style.borderBottomColor = border;
462
+ this.separatorContainer.style.backgroundColor = styles.buttonBackground?.toString() ?? '';
463
+ this.separator.style.backgroundColor = styles.buttonSeparator?.toString() ?? '';
464
+ }
465
+ focus() {
466
+ this.button.focus();
467
+ }
468
+ hasFocus() {
469
+ return this.button.hasFocus() || this.dropdownButton.hasFocus();
470
+ }
471
+ }
472
+ class ButtonWithDescription extends Button {
473
+ constructor(container, options) {
474
+ super(container, options);
475
+ this._element.classList.add('monaco-description-button');
476
+ this._labelElement = document.createElement('div');
477
+ this._labelElement.classList.add('monaco-button-label');
478
+ this._element.appendChild(this._labelElement);
479
+ this._descriptionElement = document.createElement('div');
480
+ this._descriptionElement.classList.add('monaco-button-description');
481
+ this._element.appendChild(this._descriptionElement);
482
+ }
483
+ set label(value) {
484
+ this._element.classList.add('monaco-text-button');
485
+ if (this.options.supportIcons) {
486
+ reset(this._labelElement, ...renderLabelWithIcons(value));
487
+ }
488
+ else {
489
+ this._labelElement.textContent = value;
490
+ }
491
+ if (typeof this.options.title === 'string') {
492
+ this._element.title = this.options.title;
493
+ }
494
+ else if (this.options.title) {
495
+ this._element.title = value;
496
+ }
497
+ }
498
+ set description(value) {
499
+ if (this.options.supportIcons) {
500
+ reset(this._descriptionElement, ...renderLabelWithIcons(value));
501
+ }
502
+ else {
503
+ this._descriptionElement.textContent = value;
504
+ }
505
+ }
506
+ }
507
+ class ButtonBar extends Disposable {
508
+ constructor(container) {
509
+ super();
510
+ this.container = container;
511
+ this._buttons = [];
512
+ }
513
+ get buttons() {
514
+ return this._buttons;
515
+ }
516
+ addButton(options) {
517
+ const button = this._register(( (new Button(this.container, options))));
518
+ this.pushButton(button);
519
+ return button;
520
+ }
521
+ addButtonWithDescription(options) {
522
+ const button = this._register(( (new ButtonWithDescription(this.container, options))));
523
+ this.pushButton(button);
524
+ return button;
525
+ }
526
+ addButtonWithDropdown(options) {
527
+ const button = this._register(( (new ButtonWithDropdown(this.container, options))));
528
+ this.pushButton(button);
529
+ return button;
530
+ }
531
+ pushButton(button) {
532
+ this._buttons.push(button);
533
+ const index = this._buttons.length - 1;
534
+ this._register(addDisposableListener(button.element, EventType.KEY_DOWN, e => {
535
+ const event = ( (new StandardKeyboardEvent(e)));
536
+ let eventHandled = true;
537
+ let buttonIndexToFocus;
538
+ if (event.equals(15 )) {
539
+ buttonIndexToFocus = index > 0 ? index - 1 : this._buttons.length - 1;
540
+ }
541
+ else if (event.equals(17 )) {
542
+ buttonIndexToFocus = index === this._buttons.length - 1 ? 0 : index + 1;
543
+ }
544
+ else {
545
+ eventHandled = false;
546
+ }
547
+ if (eventHandled && typeof buttonIndexToFocus === 'number') {
548
+ this._buttons[buttonIndexToFocus].focus();
549
+ EventHelper.stop(e, true);
550
+ }
551
+ }));
552
+ }
553
+ }
554
+ function mnemonicButtonLabel(label, forceDisableMnemonics) {
555
+ if (isMacintosh || forceDisableMnemonics) {
556
+ return label.replace(/\(&&\w\)|&&/g, '');
557
+ }
558
+ if (isWindows) {
559
+ return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
560
+ }
561
+ return label.replace(/&&/g, '_');
562
+ }
563
+ 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";
564
+ n(css,{});
565
+ class Dialog extends Disposable {
566
+ constructor(container, message, buttons, options) {
567
+ super();
568
+ this.container = container;
569
+ this.message = message;
570
+ this.options = options;
571
+ this.modalElement = this.container.appendChild($(`.monaco-dialog-modal-block.dimmed`));
572
+ this.shadowElement = this.modalElement.appendChild($('.dialog-shadow'));
573
+ this.element = this.shadowElement.appendChild($('.monaco-dialog-box'));
574
+ this.element.setAttribute('role', 'dialog');
575
+ this.element.tabIndex = -1;
576
+ hide(this.element);
577
+ if (Array.isArray(buttons) && buttons.length > 0) {
578
+ this.buttons = buttons;
579
+ }
580
+ else if (!this.options.disableDefaultAction) {
581
+ this.buttons = [( (localize('ok', "OK")))];
582
+ }
583
+ else {
584
+ this.buttons = [];
585
+ }
586
+ const buttonsRowElement = this.element.appendChild($('.dialog-buttons-row'));
587
+ this.buttonsContainer = buttonsRowElement.appendChild($('.dialog-buttons'));
588
+ const messageRowElement = this.element.appendChild($('.dialog-message-row'));
589
+ this.iconElement = messageRowElement.appendChild($('#monaco-dialog-icon.dialog-icon'));
590
+ this.iconElement.setAttribute('aria-label', this.getIconAriaLabel());
591
+ this.messageContainer = messageRowElement.appendChild($('.dialog-message-container'));
592
+ if (this.options.detail || this.options.renderBody) {
593
+ const messageElement = this.messageContainer.appendChild($('.dialog-message'));
594
+ const messageTextElement = messageElement.appendChild($('#monaco-dialog-message-text.dialog-message-text'));
595
+ messageTextElement.innerText = this.message;
596
+ }
597
+ this.messageDetailElement = this.messageContainer.appendChild($('#monaco-dialog-message-detail.dialog-message-detail'));
598
+ if (this.options.detail || !this.options.renderBody) {
599
+ this.messageDetailElement.innerText = this.options.detail ? this.options.detail : message;
600
+ }
601
+ else {
602
+ this.messageDetailElement.style.display = 'none';
603
+ }
604
+ if (this.options.renderBody) {
605
+ const customBody = this.messageContainer.appendChild($('#monaco-dialog-message-body.dialog-message-body'));
606
+ this.options.renderBody(customBody);
607
+ for (const el of this.messageContainer.querySelectorAll('a')) {
608
+ el.tabIndex = 0;
609
+ }
610
+ }
611
+ if (this.options.inputs) {
612
+ this.inputs = this.options.inputs.map(input => {
613
+ const inputRowElement = this.messageContainer.appendChild($('.dialog-message-input'));
614
+ const inputBox = this._register(( (new InputBox(inputRowElement, undefined, {
615
+ placeholder: input.placeholder,
616
+ type: input.type ?? 'text',
617
+ }))));
618
+ if (input.value) {
619
+ inputBox.value = input.value;
620
+ }
621
+ return inputBox;
622
+ });
623
+ }
624
+ else {
625
+ this.inputs = [];
626
+ }
627
+ if (this.options.checkboxLabel) {
628
+ const checkboxRowElement = this.messageContainer.appendChild($('.dialog-checkbox-row'));
629
+ const checkbox = this.checkbox = this._register(( (new Checkbox(this.options.checkboxLabel, !!this.options.checkboxChecked))));
630
+ checkboxRowElement.appendChild(checkbox.domNode);
631
+ const checkboxMessageElement = checkboxRowElement.appendChild($('.dialog-checkbox-message'));
632
+ checkboxMessageElement.innerText = this.options.checkboxLabel;
633
+ this._register(addDisposableListener(checkboxMessageElement, EventType.CLICK, () => checkbox.checked = !checkbox.checked));
634
+ }
635
+ const toolbarRowElement = this.element.appendChild($('.dialog-toolbar-row'));
636
+ this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar'));
637
+ }
638
+ getIconAriaLabel() {
639
+ const typeLabel = ( (localize('dialogInfoMessage', 'Info')));
640
+ return typeLabel;
641
+ }
642
+ updateMessage(message) {
643
+ this.messageDetailElement.innerText = message;
644
+ }
645
+ async show() {
646
+ this.focusToReturn = document.activeElement;
647
+ return (
648
+ (new Promise((resolve) => {
649
+ clearNode(this.buttonsContainer);
650
+ const buttonBar = this.buttonBar = this._register(( (new ButtonBar(this.buttonsContainer))));
651
+ const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);
652
+ buttonMap.forEach((entry, index) => {
653
+ const primary = buttonMap[index].index === 0;
654
+ const button = this.options.buttonDetails ? this._register(buttonBar.addButtonWithDescription({ title: true, secondary: !primary })) : this._register(buttonBar.addButton({ title: true, secondary: !primary }));
655
+ button.label = mnemonicButtonLabel(buttonMap[index].label, true);
656
+ if (button instanceof ButtonWithDescription) {
657
+ button.description = this.options.buttonDetails[buttonMap[index].index];
658
+ }
659
+ this._register(button.onDidClick(e => {
660
+ if (e) {
661
+ EventHelper.stop(e);
662
+ }
663
+ resolve({
664
+ button: buttonMap[index].index,
665
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
666
+ values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
667
+ });
668
+ }));
669
+ });
670
+ this._register(addDisposableListener(window, 'keydown', e => {
671
+ const evt = ( (new StandardKeyboardEvent(e)));
672
+ if (evt.equals(512 )) {
673
+ evt.preventDefault();
674
+ }
675
+ if (evt.equals(3 )) {
676
+ if (this.inputs.some(input => input.hasFocus())) {
677
+ EventHelper.stop(e);
678
+ resolve({
679
+ button: buttonMap.find(button => button.index !== this.options.cancelId)?.index ?? 0,
680
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
681
+ values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
682
+ });
683
+ }
684
+ return;
685
+ }
686
+ if (evt.equals(10 )) {
687
+ return;
688
+ }
689
+ let eventHandled = false;
690
+ if (evt.equals(2 ) || evt.equals(17 ) || evt.equals(1024 | 2 ) || evt.equals(15 )) {
691
+ const focusableElements = [];
692
+ let focusedIndex = -1;
693
+ if (this.messageContainer) {
694
+ const links = this.messageContainer.querySelectorAll('a');
695
+ for (const link of links) {
696
+ focusableElements.push(link);
697
+ if (link === document.activeElement) {
698
+ focusedIndex = focusableElements.length - 1;
699
+ }
700
+ }
701
+ }
702
+ for (const input of this.inputs) {
703
+ focusableElements.push(input);
704
+ if (input.hasFocus()) {
705
+ focusedIndex = focusableElements.length - 1;
706
+ }
707
+ }
708
+ if (this.checkbox) {
709
+ focusableElements.push(this.checkbox);
710
+ if (this.checkbox.hasFocus()) {
711
+ focusedIndex = focusableElements.length - 1;
712
+ }
713
+ }
714
+ if (this.buttonBar) {
715
+ for (const button of this.buttonBar.buttons) {
716
+ focusableElements.push(button);
717
+ if (button.hasFocus()) {
718
+ focusedIndex = focusableElements.length - 1;
719
+ }
720
+ }
721
+ }
722
+ if (evt.equals(2 ) || evt.equals(17 )) {
723
+ if (focusedIndex === -1) {
724
+ focusedIndex = 0;
725
+ }
726
+ const newFocusedIndex = (focusedIndex + 1) % focusableElements.length;
727
+ focusableElements[newFocusedIndex].focus();
728
+ }
729
+ else {
730
+ if (focusedIndex === -1) {
731
+ focusedIndex = focusableElements.length;
732
+ }
733
+ let newFocusedIndex = focusedIndex - 1;
734
+ if (newFocusedIndex === -1) {
735
+ newFocusedIndex = focusableElements.length - 1;
736
+ }
737
+ focusableElements[newFocusedIndex].focus();
738
+ }
739
+ eventHandled = true;
740
+ }
741
+ if (eventHandled) {
742
+ EventHelper.stop(e, true);
743
+ }
744
+ else if (this.options.keyEventProcessor) {
745
+ this.options.keyEventProcessor(evt);
746
+ }
747
+ }, true));
748
+ this._register(addDisposableListener(window, 'keyup', e => {
749
+ EventHelper.stop(e, true);
750
+ const evt = ( (new StandardKeyboardEvent(e)));
751
+ if (!this.options.disableCloseAction && evt.equals(9 )) {
752
+ resolve({
753
+ button: this.options.cancelId || 0,
754
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
755
+ });
756
+ }
757
+ }, true));
758
+ this._register(addDisposableListener(this.element, 'focusout', e => {
759
+ if (!!e.relatedTarget && !!this.element) {
760
+ if (!isAncestor(e.relatedTarget, this.element)) {
761
+ this.focusToReturn = e.relatedTarget;
762
+ if (e.target) {
763
+ e.target.focus();
764
+ EventHelper.stop(e, true);
765
+ }
766
+ }
767
+ }
768
+ }, false));
769
+ const spinModifierClassName = 'codicon-modifier-spin';
770
+ this.iconElement.classList.remove(...Codicon.dialogError.classNamesArray, ...Codicon.dialogWarning.classNamesArray, ...Codicon.dialogInfo.classNamesArray, ...Codicon.loading.classNamesArray, spinModifierClassName);
771
+ if (this.options.icon) {
772
+ this.iconElement.classList.add(...this.options.icon.classNamesArray);
773
+ }
774
+ else {
775
+ switch (this.options.type) {
776
+ case 'error':
777
+ this.iconElement.classList.add(...Codicon.dialogError.classNamesArray);
778
+ break;
779
+ case 'warning':
780
+ this.iconElement.classList.add(...Codicon.dialogWarning.classNamesArray);
781
+ break;
782
+ case 'pending':
783
+ this.iconElement.classList.add(...Codicon.loading.classNamesArray, spinModifierClassName);
784
+ break;
785
+ case 'none':
786
+ case 'info':
787
+ case 'question':
788
+ default:
789
+ this.iconElement.classList.add(...Codicon.dialogInfo.classNamesArray);
790
+ break;
791
+ }
792
+ }
793
+ if (!this.options.disableCloseAction) {
794
+ const actionBar = this._register(( (new ActionBar(this.toolbarContainer, {}))));
795
+ const action = this._register(( (new Action(
796
+ 'dialog.close',
797
+ (localize('dialogClose', "Close Dialog")),
798
+ Codicon.dialogClose.classNames,
799
+ true,
800
+ async () => {
801
+ resolve({
802
+ button: this.options.cancelId || 0,
803
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
804
+ });
805
+ }
806
+ ))));
807
+ actionBar.push(action, { icon: true, label: false, });
808
+ }
809
+ this.applyStyles();
810
+ this.element.setAttribute('aria-modal', 'true');
811
+ this.element.setAttribute('aria-labelledby', 'monaco-dialog-icon monaco-dialog-message-text');
812
+ this.element.setAttribute('aria-describedby', 'monaco-dialog-icon monaco-dialog-message-text monaco-dialog-message-detail monaco-dialog-message-body');
813
+ show(this.element);
814
+ if (this.inputs.length > 0) {
815
+ this.inputs[0].focus();
816
+ this.inputs[0].select();
817
+ }
818
+ else {
819
+ buttonMap.forEach((value, index) => {
820
+ if (value.index === 0) {
821
+ buttonBar.buttons[index].focus();
822
+ }
823
+ });
824
+ }
825
+ }))
826
+ );
827
+ }
828
+ applyStyles() {
829
+ if (this.styles) {
830
+ const style = this.styles;
831
+ const fgColor = style.dialogForeground;
832
+ const bgColor = style.dialogBackground;
833
+ const shadowColor = style.dialogShadow ? `0 0px 8px ${style.dialogShadow}` : '';
834
+ const border = style.dialogBorder ? `1px solid ${style.dialogBorder}` : '';
835
+ const linkFgColor = style.textLinkForeground;
836
+ this.shadowElement.style.boxShadow = shadowColor;
837
+ this.element.style.color = fgColor?.toString() ?? '';
838
+ this.element.style.backgroundColor = bgColor?.toString() ?? '';
839
+ this.element.style.border = border;
840
+ this.buttonBar?.buttons.forEach(button => button.style(style));
841
+ this.checkbox?.style(style);
842
+ if (fgColor && bgColor) {
843
+ const messageDetailColor = ( (fgColor.transparent(.9)));
844
+ this.messageDetailElement.style.color = ( (messageDetailColor.makeOpaque(bgColor).toString()));
845
+ }
846
+ if (linkFgColor) {
847
+ for (const el of this.messageContainer.getElementsByTagName('a')) {
848
+ el.style.color = ( (linkFgColor.toString()));
849
+ }
850
+ }
851
+ let color;
852
+ switch (this.options.type) {
853
+ case 'error':
854
+ color = style.errorIconForeground;
855
+ break;
856
+ case 'warning':
857
+ color = style.warningIconForeground;
858
+ break;
859
+ default:
860
+ color = style.infoIconForeground;
861
+ break;
862
+ }
863
+ if (color) {
864
+ this.iconElement.style.color = ( (color.toString()));
865
+ }
866
+ for (const input of this.inputs) {
867
+ input.style(style);
868
+ }
869
+ }
870
+ }
871
+ style(style) {
872
+ this.styles = style;
873
+ this.applyStyles();
874
+ }
875
+ dispose() {
876
+ super.dispose();
877
+ if (this.modalElement) {
878
+ this.modalElement.remove();
879
+ this.modalElement = undefined;
880
+ }
881
+ if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) {
882
+ this.focusToReturn.focus();
883
+ this.focusToReturn = undefined;
884
+ }
885
+ }
886
+ rearrangeButtons(buttons, cancelId) {
887
+ const buttonMap = [];
888
+ if (buttons.length === 0) {
889
+ return buttonMap;
890
+ }
891
+ buttons.forEach((button, index) => {
892
+ buttonMap.push({ label: button, index });
893
+ });
894
+ if (isMacintosh || isLinux) {
895
+ if (cancelId !== undefined && cancelId < buttons.length) {
896
+ const cancelButton = buttonMap.splice(cancelId, 1)[0];
897
+ buttonMap.reverse();
898
+ buttonMap.splice(buttonMap.length - 1, 0, cancelButton);
899
+ }
900
+ }
901
+ return buttonMap;
902
+ }
903
+ }
904
+ const minute = 60;
905
+ const hour = minute * 60;
906
+ const day = hour * 24;
907
+ const week = day * 7;
908
+ const month = day * 30;
909
+ const year = day * 365;
910
+ function fromNow(date, appendAgoLabel, useFullTimeWords) {
911
+ if (typeof date !== 'number') {
912
+ date = date.getTime();
913
+ }
914
+ const seconds = Math.round((( (new Date())).getTime() - date) / 1000);
915
+ if (seconds < -30) {
916
+ return (
917
+ (localize(
918
+ 'date.fromNow.in',
919
+ 'in {0}',
920
+ fromNow(( (new Date())).getTime() + seconds * 1000, false)
921
+ ))
922
+ );
923
+ }
924
+ if (seconds < 30) {
925
+ return (
926
+ (localize('date.fromNow.now', 'now'))
927
+ );
928
+ }
929
+ let value;
930
+ if (seconds < minute) {
931
+ value = seconds;
932
+ if (appendAgoLabel) {
933
+ if (value === 1) {
934
+ return useFullTimeWords
935
+ ? ( (localize('date.fromNow.seconds.singular.ago.fullWord', '{0} second ago', value)))
936
+ : ( (localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value)));
937
+ }
938
+ else {
939
+ return useFullTimeWords
940
+ ? ( (localize('date.fromNow.seconds.plural.ago.fullWord', '{0} seconds ago', value)))
941
+ : ( (localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value)));
942
+ }
943
+ }
944
+ else {
945
+ if (value === 1) {
946
+ return useFullTimeWords
947
+ ? ( (localize('date.fromNow.seconds.singular.fullWord', '{0} second', value)))
948
+ : ( (localize('date.fromNow.seconds.singular', '{0} sec', value)));
949
+ }
950
+ else {
951
+ return useFullTimeWords
952
+ ? ( (localize('date.fromNow.seconds.plural.fullWord', '{0} seconds', value)))
953
+ : ( (localize('date.fromNow.seconds.plural', '{0} secs', value)));
954
+ }
955
+ }
956
+ }
957
+ if (seconds < hour) {
958
+ value = Math.floor(seconds / minute);
959
+ if (appendAgoLabel) {
960
+ if (value === 1) {
961
+ return useFullTimeWords
962
+ ? ( (localize('date.fromNow.minutes.singular.ago.fullWord', '{0} minute ago', value)))
963
+ : ( (localize('date.fromNow.minutes.singular.ago', '{0} min ago', value)));
964
+ }
965
+ else {
966
+ return useFullTimeWords
967
+ ? ( (localize('date.fromNow.minutes.plural.ago.fullWord', '{0} minutes ago', value)))
968
+ : ( (localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value)));
969
+ }
970
+ }
971
+ else {
972
+ if (value === 1) {
973
+ return useFullTimeWords
974
+ ? ( (localize('date.fromNow.minutes.singular.fullWord', '{0} minute', value)))
975
+ : ( (localize('date.fromNow.minutes.singular', '{0} min', value)));
976
+ }
977
+ else {
978
+ return useFullTimeWords
979
+ ? ( (localize('date.fromNow.minutes.plural.fullWord', '{0} minutes', value)))
980
+ : ( (localize('date.fromNow.minutes.plural', '{0} mins', value)));
981
+ }
982
+ }
983
+ }
984
+ if (seconds < day) {
985
+ value = Math.floor(seconds / hour);
986
+ if (appendAgoLabel) {
987
+ if (value === 1) {
988
+ return useFullTimeWords
989
+ ? ( (localize('date.fromNow.hours.singular.ago.fullWord', '{0} hour ago', value)))
990
+ : ( (localize('date.fromNow.hours.singular.ago', '{0} hr ago', value)));
991
+ }
992
+ else {
993
+ return useFullTimeWords
994
+ ? ( (localize('date.fromNow.hours.plural.ago.fullWord', '{0} hours ago', value)))
995
+ : ( (localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value)));
996
+ }
997
+ }
998
+ else {
999
+ if (value === 1) {
1000
+ return useFullTimeWords
1001
+ ? ( (localize('date.fromNow.hours.singular.fullWord', '{0} hour', value)))
1002
+ : ( (localize('date.fromNow.hours.singular', '{0} hr', value)));
1003
+ }
1004
+ else {
1005
+ return useFullTimeWords
1006
+ ? ( (localize('date.fromNow.hours.plural.fullWord', '{0} hours', value)))
1007
+ : ( (localize('date.fromNow.hours.plural', '{0} hrs', value)));
1008
+ }
1009
+ }
1010
+ }
1011
+ if (seconds < week) {
1012
+ value = Math.floor(seconds / day);
1013
+ if (appendAgoLabel) {
1014
+ return value === 1
1015
+ ? ( (localize('date.fromNow.days.singular.ago', '{0} day ago', value)))
1016
+ : ( (localize('date.fromNow.days.plural.ago', '{0} days ago', value)));
1017
+ }
1018
+ else {
1019
+ return value === 1
1020
+ ? ( (localize('date.fromNow.days.singular', '{0} day', value)))
1021
+ : ( (localize('date.fromNow.days.plural', '{0} days', value)));
1022
+ }
1023
+ }
1024
+ if (seconds < month) {
1025
+ value = Math.floor(seconds / week);
1026
+ if (appendAgoLabel) {
1027
+ if (value === 1) {
1028
+ return useFullTimeWords
1029
+ ? ( (localize('date.fromNow.weeks.singular.ago.fullWord', '{0} week ago', value)))
1030
+ : ( (localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value)));
1031
+ }
1032
+ else {
1033
+ return useFullTimeWords
1034
+ ? ( (localize('date.fromNow.weeks.plural.ago.fullWord', '{0} weeks ago', value)))
1035
+ : ( (localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value)));
1036
+ }
1037
+ }
1038
+ else {
1039
+ if (value === 1) {
1040
+ return useFullTimeWords
1041
+ ? ( (localize('date.fromNow.weeks.singular.fullWord', '{0} week', value)))
1042
+ : ( (localize('date.fromNow.weeks.singular', '{0} wk', value)));
1043
+ }
1044
+ else {
1045
+ return useFullTimeWords
1046
+ ? ( (localize('date.fromNow.weeks.plural.fullWord', '{0} weeks', value)))
1047
+ : ( (localize('date.fromNow.weeks.plural', '{0} wks', value)));
1048
+ }
1049
+ }
1050
+ }
1051
+ if (seconds < year) {
1052
+ value = Math.floor(seconds / month);
1053
+ if (appendAgoLabel) {
1054
+ if (value === 1) {
1055
+ return useFullTimeWords
1056
+ ? ( (localize('date.fromNow.months.singular.ago.fullWord', '{0} month ago', value)))
1057
+ : ( (localize('date.fromNow.months.singular.ago', '{0} mo ago', value)));
1058
+ }
1059
+ else {
1060
+ return useFullTimeWords
1061
+ ? ( (localize('date.fromNow.months.plural.ago.fullWord', '{0} months ago', value)))
1062
+ : ( (localize('date.fromNow.months.plural.ago', '{0} mos ago', value)));
1063
+ }
1064
+ }
1065
+ else {
1066
+ if (value === 1) {
1067
+ return useFullTimeWords
1068
+ ? ( (localize('date.fromNow.months.singular.fullWord', '{0} month', value)))
1069
+ : ( (localize('date.fromNow.months.singular', '{0} mo', value)));
1070
+ }
1071
+ else {
1072
+ return useFullTimeWords
1073
+ ? ( (localize('date.fromNow.months.plural.fullWord', '{0} months', value)))
1074
+ : ( (localize('date.fromNow.months.plural', '{0} mos', value)));
1075
+ }
1076
+ }
1077
+ }
1078
+ value = Math.floor(seconds / year);
1079
+ if (appendAgoLabel) {
1080
+ if (value === 1) {
1081
+ return useFullTimeWords
1082
+ ? ( (localize('date.fromNow.years.singular.ago.fullWord', '{0} year ago', value)))
1083
+ : ( (localize('date.fromNow.years.singular.ago', '{0} yr ago', value)));
1084
+ }
1085
+ else {
1086
+ return useFullTimeWords
1087
+ ? ( (localize('date.fromNow.years.plural.ago.fullWord', '{0} years ago', value)))
1088
+ : ( (localize('date.fromNow.years.plural.ago', '{0} yrs ago', value)));
1089
+ }
1090
+ }
1091
+ else {
1092
+ if (value === 1) {
1093
+ return useFullTimeWords
1094
+ ? ( (localize('date.fromNow.years.singular.fullWord', '{0} year', value)))
1095
+ : ( (localize('date.fromNow.years.singular', '{0} yr', value)));
1096
+ }
1097
+ else {
1098
+ return useFullTimeWords
1099
+ ? ( (localize('date.fromNow.years.plural.fullWord', '{0} years', value)))
1100
+ : ( (localize('date.fromNow.years.plural', '{0} yrs', value)));
1101
+ }
1102
+ }
1103
+ }
1104
+ let BrowserDialogHandler = class BrowserDialogHandler {
1105
+ constructor(logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
1106
+ this.logService = logService;
1107
+ this.layoutService = layoutService;
1108
+ this.themeService = themeService;
1109
+ this.keybindingService = keybindingService;
1110
+ this.instantiationService = instantiationService;
1111
+ this.productService = productService;
1112
+ this.clipboardService = clipboardService;
1113
+ this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
1114
+ }
1115
+ async confirm(confirmation) {
1116
+ this.logService.trace('DialogService#confirm', confirmation.message);
1117
+ const buttons = [];
1118
+ if (confirmation.primaryButton) {
1119
+ buttons.push(confirmation.primaryButton);
1120
+ }
1121
+ else {
1122
+ buttons.push(( (localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes"))));
1123
+ }
1124
+ if (confirmation.secondaryButton) {
1125
+ buttons.push(confirmation.secondaryButton);
1126
+ }
1127
+ else if (typeof confirmation.secondaryButton === 'undefined') {
1128
+ buttons.push(( (localize('cancelButton', "Cancel"))));
1129
+ }
1130
+ const result = await this.doShow(confirmation.type, confirmation.message, buttons, confirmation.detail, 1, confirmation.checkbox);
1131
+ return { confirmed: result.button === 0, checkboxChecked: result.checkboxChecked };
1132
+ }
1133
+ getDialogType(severity) {
1134
+ return (severity === Severity.Info) ? 'question' : (severity === Severity.Error) ? 'error' : (severity === Severity.Warning) ? 'warning' : 'none';
1135
+ }
1136
+ async show(severity, message, buttons, options) {
1137
+ this.logService.trace('DialogService#show', message);
1138
+ const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, undefined, typeof options?.custom === 'object' ? options.custom : undefined);
1139
+ return {
1140
+ choice: result.button,
1141
+ checkboxChecked: result.checkboxChecked
1142
+ };
1143
+ }
1144
+ async doShow(type, message, buttons, detail, cancelId, checkbox, inputs, customOptions) {
1145
+ const dialogDisposables = ( (new DisposableStore()));
1146
+ const renderBody = customOptions ? (parent) => {
1147
+ parent.classList.add(...(customOptions.classes || []));
1148
+ customOptions.markdownDetails?.forEach(markdownDetail => {
1149
+ const result = this.markdownRenderer.render(markdownDetail.markdown);
1150
+ parent.appendChild(result.element);
1151
+ result.element.classList.add(...(markdownDetail.classes || []));
1152
+ dialogDisposables.add(result);
1153
+ });
1154
+ } : undefined;
1155
+ const dialog = ( (new Dialog(this.layoutService.container, message, buttons, {
1156
+ detail,
1157
+ cancelId,
1158
+ type,
1159
+ keyEventProcessor: (event) => {
1160
+ const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
1161
+ if (resolved?.commandId) {
1162
+ if (BrowserDialogHandler.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
1163
+ EventHelper.stop(event, true);
1164
+ }
1165
+ }
1166
+ },
1167
+ renderBody,
1168
+ icon: customOptions?.icon,
1169
+ disableCloseAction: customOptions?.disableCloseAction,
1170
+ buttonDetails: customOptions?.buttonDetails,
1171
+ checkboxLabel: checkbox?.label,
1172
+ checkboxChecked: checkbox?.checked,
1173
+ inputs
1174
+ })));
1175
+ dialogDisposables.add(dialog);
1176
+ dialogDisposables.add(attachDialogStyler(dialog, this.themeService));
1177
+ const result = await dialog.show();
1178
+ dialogDisposables.dispose();
1179
+ return result;
1180
+ }
1181
+ async input(severity, message, buttons, inputs, options) {
1182
+ this.logService.trace('DialogService#input', message);
1183
+ const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, inputs);
1184
+ return {
1185
+ choice: result.button,
1186
+ checkboxChecked: result.checkboxChecked,
1187
+ values: result.values
1188
+ };
1189
+ }
1190
+ async about() {
1191
+ const detailString = (useAgo) => {
1192
+ return (
1193
+ (localize(
1194
+ 'aboutDetail',
1195
+ "Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
1196
+ this.productService.version || 'Unknown',
1197
+ this.productService.commit || 'Unknown',
1198
+ this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(( new Date(this.productService.date)), true) + ')' : ''}` : 'Unknown',
1199
+ navigator.userAgent
1200
+ ))
1201
+ );
1202
+ };
1203
+ const detail = detailString(true);
1204
+ const detailToCopy = detailString(false);
1205
+ const { choice } = await this.show(Severity.Info, this.productService.nameLong, [( (localize('copy', "Copy"))), ( (localize('ok', "OK")))], { detail, cancelId: 1 });
1206
+ if (choice === 0) {
1207
+ this.clipboardService.writeText(detailToCopy);
1208
+ }
1209
+ }
1210
+ };
1211
+ BrowserDialogHandler.ALLOWABLE_COMMANDS = [
1212
+ 'copy',
1213
+ 'cut',
1214
+ 'editor.action.selectAll',
1215
+ 'editor.action.clipboardCopyAction',
1216
+ 'editor.action.clipboardCutAction',
1217
+ 'editor.action.clipboardPasteAction'
1218
+ ];
1219
+ BrowserDialogHandler = ( (__decorate([
1220
+ ( (__param(0, ILogService))),
1221
+ ( (__param(1, ILayoutService))),
1222
+ ( (__param(2, IThemeService))),
1223
+ ( (__param(3, IKeybindingService))),
1224
+ ( (__param(4, IInstantiationService))),
1225
+ ( (__param(5, IProductService))),
1226
+ ( (__param(6, IClipboardService)))
1227
+ ], BrowserDialogHandler)));
1228
+ let DialogHandlerContribution = class DialogHandlerContribution extends Disposable {
1229
+ constructor(dialogService, logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
1230
+ super();
1231
+ this.dialogService = dialogService;
1232
+ this.impl = ( (new BrowserDialogHandler(
1233
+ logService,
1234
+ layoutService,
1235
+ themeService,
1236
+ keybindingService,
1237
+ instantiationService,
1238
+ productService,
1239
+ clipboardService
1240
+ )));
1241
+ this.model = this.dialogService.model;
1242
+ this._register(this.model.onWillShowDialog(() => {
1243
+ if (!this.currentDialog) {
1244
+ this.processDialogs();
1245
+ }
1246
+ }));
1247
+ this.processDialogs();
1248
+ }
1249
+ async processDialogs() {
1250
+ while (this.model.dialogs.length) {
1251
+ this.currentDialog = this.model.dialogs[0];
1252
+ let result = undefined;
1253
+ if (this.currentDialog.args.confirmArgs) {
1254
+ const args = this.currentDialog.args.confirmArgs;
1255
+ result = await this.impl.confirm(args.confirmation);
1256
+ }
1257
+ else if (this.currentDialog.args.inputArgs) {
1258
+ const args = this.currentDialog.args.inputArgs;
1259
+ result = await this.impl.input(args.severity, args.message, args.buttons, args.inputs, args.options);
1260
+ }
1261
+ else if (this.currentDialog.args.showArgs) {
1262
+ const args = this.currentDialog.args.showArgs;
1263
+ result = await this.impl.show(args.severity, args.message, args.buttons, args.options);
1264
+ }
1265
+ else {
1266
+ await this.impl.about();
1267
+ }
1268
+ this.currentDialog.close(result);
1269
+ this.currentDialog = undefined;
1270
+ }
1271
+ }
1272
+ };
1273
+ DialogHandlerContribution = ( (__decorate([
1274
+ ( (__param(0, IDialogService))),
1275
+ ( (__param(1, ILogService))),
1276
+ ( (__param(2, ILayoutService))),
1277
+ ( (__param(3, IThemeService))),
1278
+ ( (__param(4, IKeybindingService))),
1279
+ ( (__param(5, IInstantiationService))),
1280
+ ( (__param(6, IProductService))),
1281
+ ( (__param(7, IClipboardService)))
1282
+ ], DialogHandlerContribution)));
1283
+ class LayoutService {
1284
+ constructor(container) {
1285
+ this.container = container;
1286
+ this.offset = { top: 0, quickPickTop: 0 };
1287
+ this._onDidLayout = new Emitter();
1288
+ this.onDidLayout = this._onDidLayout.event;
1289
+ window.addEventListener('resize', () => this.layout());
1290
+ this.layout();
1291
+ }
1292
+ isVisible() {
1293
+ return false;
1294
+ }
1295
+ get dimension() { return this._dimension; }
1296
+ layout() {
1297
+ this._dimension = getClientArea(window.document.body);
1298
+ this._onDidLayout.fire(this._dimension);
1299
+ }
1300
+ get hasContainer() {
1301
+ return true;
1302
+ }
1303
+ focus() {
1304
+ StandaloneServices.get(ICodeEditorService).getFocusedCodeEditor()?.focus();
1305
+ }
1306
+ }
1307
+ function initialize(instantiationService) {
1308
+ const container = instantiationService.invokeFunction((accessor) => accessor.get(ILayoutService)).container;
1309
+ container.classList.add('monaco-workbench');
1310
+ }
1311
+ function getServiceOverride(container = document.body) {
1312
+ onServicesInitialized(initialize);
1313
+ return {
1314
+ [( ILayoutService.toString())]: new SyncDescriptor(LayoutService, [container]),
1315
+ [( IWorkbenchLayoutService.toString())]: new SyncDescriptor(LayoutService, [container])
1316
+ };
1317
+ }
1318
+ export { ButtonBar as B, DialogHandlerContribution as D, attachButtonStyler as a, attachProgressBarStyler as b, getServiceOverride as g, n };